Skip to content

Instantly share code, notes, and snippets.

@razum2um
Created April 4, 2013 16:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save razum2um/5312004 to your computer and use it in GitHub Desktop.
Save razum2um/5312004 to your computer and use it in GitHub Desktop.
(function (global) {
"use strict";
var $ = global.jQuery,
module = YOUR_NAMESPACE.namespace('other.module');
(function () {
function hidden_function() {
do_something();
return;
}
function public_function() {
hidden_function();
return;
}
module.public_function = public_function;
}());
}(this));
(function (global) {
"use strict";
// Глобальное пространство имен приложения
var YOUR_NAMESPACE = global.YOUR_NAMESPACE || {};
// Инициализация пространства имен
YOUR_NAMESPACE.namespace = function (ns_string) {
var parts = ns_string.split('.'),
parent = YOUR_NAMESPACE,
i;
if (parts[0] === ' YOUR_NAMESPACE') {
parts = parts.slice(1);
}
for (i = 0; i < parts.length; i += 1) {
if (parent[parts[i]] === undefined) {
parent[parts[i]] = {};
}
parent = parent[parts[i]];
}
return parent;
};
global.YOUR_NAMESPACE = YOUR_NAMESPACE;
}(this));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment