Skip to content

@f0t0n /base.js
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
JS Namespace example
(function($, window) {
/**
* Provides a namespace for BugKick classes
*/
var _ = window[baseNameSpace] = window[baseNameSpace] || {};
_.jQuery_URL = 'https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js'
/**
*
* @param namespace {@string}
*/
_.namespace = function(namespace) {
var branch = namespace.split('.'),
path = _;
if(branch.length > 0 && branch[0] == baseNameSpace) {
branch.shift();
}
for(var i = 0, node; node = branch[i++];) {
path[node] = path[node] || {};
path = path[node];
}
return path;
};
/* Namespace definitions */
_.string = _.namespace('string');
_.url = _.namespace('url');
_.page = _.namespace('page');
/****************************/
/**
* Concatenates string expressions. This is useful
* since some browsers are very inefficient when it comes to using plus to
* concat strings. Be careful when using null and undefined here since
* these will not be included in the result. If you need to represent these
* be sure to cast the argument to a String first.
* For example:
* <pre>buildString('a', 'b', 'c', 'd') -> 'abcd'
* buildString(null, undefined) -> ''
* </pre>
* @param {...*} var_args A list of strings to concatenate. If not a string,
* it will be casted to one.
* @return {string} The concatenation of {@code var_args}.
*/
_.string.buildString = function(var_args) {
return Array.prototype.join.call(arguments, '');
};
})(jQuery, window);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.