2012-08-31 12:45:07 +04:00
|
|
|
jQuery.namespace = function() {
|
2013-08-10 14:11:16 +04:00
|
|
|
var a=arguments, o=null, i, j, d;
|
|
|
|
for (i=0; i<a.length; i=i+1) {
|
|
|
|
d=a[i].split(".");
|
|
|
|
o=window;
|
|
|
|
for (j=0; j<d.length; j=j+1) {
|
|
|
|
o[d[j]]=o[d[j]] || {};
|
|
|
|
o=o[d[j]];
|
2012-08-31 12:45:07 +04:00
|
|
|
}
|
2013-08-10 14:11:16 +04:00
|
|
|
}
|
|
|
|
return o;
|
2012-08-31 12:45:07 +04:00
|
|
|
};
|
|
|
|
|
2013-08-04 23:20:25 +04:00
|
|
|
/**
|
|
|
|
* Need a polyfill for PhantomJS
|
|
|
|
*/
|
|
|
|
if (typeof Function.prototype.bind !== "function") {
|
2013-08-10 16:47:26 +04:00
|
|
|
Function.prototype.bind = function(scope) {
|
|
|
|
"use strict";
|
|
|
|
var _function = this;
|
|
|
|
return function() {
|
|
|
|
return _function.apply(scope, arguments);
|
2013-08-04 23:20:25 +04:00
|
|
|
};
|
2013-08-10 16:47:26 +04:00
|
|
|
};
|
2013-08-04 23:20:25 +04:00
|
|
|
}
|
|
|
|
|
2013-09-28 23:10:12 +04:00
|
|
|
/**
|
2012-08-31 12:45:07 +04:00
|
|
|
* @provide pskl.utils
|
|
|
|
*
|
|
|
|
* @require Constants
|
|
|
|
*/
|
2012-09-11 02:52:09 +04:00
|
|
|
(function() { // namespace: pskl.utils
|
2012-08-31 12:45:07 +04:00
|
|
|
|
2013-08-10 14:11:16 +04:00
|
|
|
var ns = $.namespace("pskl.utils");
|
2012-08-31 12:45:07 +04:00
|
|
|
|
2013-08-10 14:11:16 +04:00
|
|
|
ns.rgbToHex = function(r, g, b) {
|
2013-09-29 01:52:51 +04:00
|
|
|
if (r > 255 || g > 255 || b > 255) {
|
2013-08-10 14:11:16 +04:00
|
|
|
throw "Invalid color component";
|
2013-09-29 01:52:51 +04:00
|
|
|
}
|
|
|
|
|
2013-08-10 14:11:16 +04:00
|
|
|
return ((r << 16) | (g << 8) | b).toString(16);
|
|
|
|
};
|
2012-08-31 12:45:07 +04:00
|
|
|
|
2013-08-10 14:11:16 +04:00
|
|
|
ns.inherit = function(extendedObject, inheritFrom) {
|
|
|
|
extendedObject.prototype = Object.create(inheritFrom.prototype);
|
|
|
|
extendedObject.prototype.constructor = extendedObject;
|
|
|
|
extendedObject.prototype.superclass = inheritFrom.prototype;
|
|
|
|
};
|
2012-08-31 12:45:07 +04:00
|
|
|
|
2012-09-11 02:52:09 +04:00
|
|
|
})();
|
2012-08-31 12:45:07 +04:00
|
|
|
|