Committer: dpetrov
LJSUP-12136: Implement mixins for jquery ui widgetsU trunk/htdocs/js/basic.js
Modified: trunk/htdocs/js/basic.js =================================================================== --- trunk/htdocs/js/basic.js 2012-05-11 10:58:37 UTC (rev 21916) +++ trunk/htdocs/js/basic.js 2012-05-11 11:51:34 UTC (rev 21917) @@ -109,7 +109,7 @@ }; /** - * @namespace LiveJournal utility objects + * @namespace LJ LiveJournal utility objects */ LJ = window.LJ || {}; @@ -329,6 +329,9 @@ head.appendChild(cssNode); }; +/** + * @namespace LJ.UI Namespace should contain utility functions that are connected with widgets. + */ LJ.UI = LJ.UI || {}; /** @@ -396,7 +399,35 @@ return html; }; +LJ.UI._mixins = {}; +/** + * Register a mixin to allow to use it later in the jQuery UI widgets. + * + * @param {string} name Name of the widget. + * @param {Function} module The function that will bootsrap widget. The Function will be applied + * to the widget instance and the return object will represent the public api for the mixin. + */ +LJ.UI.mixin = function(name, module) { + if (arguments.length === 1) { + if (LJ.UI._mixins.hasOwnProperty(name)) { + return LJ.UI._mixins[name]; + } else { + LJ.console.log('Warn: Mixin ', name, ' was called but is not defined yet.'); + } + } else { + LJ.UI._mixins[name] = module; + } +}; + +/** + * @namespace LJ.Support The namespace should contain variables to check whether some funcionality is availible in the current browser. + */ +LJ.Support = LJ.Support || {}; + +LJ.Support.geoLocation = 'geolocation' in navigator; + + /* object extensions */ if (!Object.extend) Object.extend = function (d, s){