var _rootContext; edContext = function(oInit) { if (typeof oInit !== "undefined") { this.initialize(oInit); } return _rootContext; }; window.edContext = edContext; edContext.DATEFORMAT_DEFAULT = "dd/mm/yy"; edContext.DATEFORMAT_FR = "dd/mm/yy"; edContext.DATEFORMAT_EN = "mm/dd/yy"; edContext.TIMEFORMAT_DEFAULT = "hh:mm:ss"; edContext.TIMEFORMAT_FR = "HH:mm:ss"; edContext.TIMEFORMAT_EN = "hh:mm:ss TT"; edContext.prototype.initialize = function(oInit) { $(document).trigger("edContext_preInitialize"); var _oInit = oInit; if (typeof oInit !== "object") { _oInit = JSON.parse(oInit); } _rootContext = this; for (var attrname in _oInit) { _rootContext[attrname] = _oInit[attrname]; } this.setLocaleInformation(); $(document).trigger("edContext_postInitialize"); return _rootContext; }; edContext.prototype.loadLocaleDependencies = function() { var languageFileToInclude = "fr"; if (_rootContext.locale == "en") { languageFileToInclude = "en"; } var filesToInclude = new Array(); filesToInclude.push(edApplication().path + "js/edeal/libraries/jquery/ui/jquery.ui.datepicker-"+ languageFileToInclude + ".js"); filesToInclude.push(edApplication().path + "js/edeal/libraries/jquery/ui/jquery.ui.timepicker-"+ languageFileToInclude + ".js"); include(filesToInclude, function(){ $.datepicker.setDefaults( $.datepicker.regional[ languageFileToInclude ] ); $.datepicker.setDefaults({ dateFormat: _rootContext.dateFormat, showOn: "focus", showAnim: "slideDown", showOtherMonths: true, selectOtherMonths: true, changeMonth: true, changeYear: true, yearRange: "1900:2200", buttonImageOnly: true, /*buttonImage: edApplication().path + "skins/default/images/date/calendar.gif",*/ buttonText: "", showButtonPanel: true, //numberOfMonths: [2, 3], numberOfMonths: 1, showCurrentAtPos: 0 }); $.timepicker.setDefaults($.timepicker.regional[ languageFileToInclude ]); $.timepicker.setDefaults({ timeFormat: _rootContext.timeFormat }); }); }; edContext.prototype.setLocaleInformation = function() { if (!_rootContext.locale) { _rootContext.locale = "fr"; } _rootContext.dateFormat = edContext.DATEFORMAT_DEFAULT; _rootContext.timeFormat = edContext.TIMEFORMAT_DEFAULT; if (_rootContext.locale == "fr") { _rootContext.dateFormat = edContext.DATEFORMAT_FR; _rootContext.timeFormat = edContext.TIMEFORMAT_FR; } if (_rootContext.locale == "en") { _rootContext.dateFormat = edContext.DATEFORMAT_EN; _rootContext.timeFormat = edContext.TIMEFORMAT_EN; } }; edContext.prototype.check = function() { if (typeof _rootContext === "undefined") { console.error("edContext has not been initialized. Do it by calling edContext(initObject)"); return false; } return true; }; edContext.prototype.get = function(sPropertyName) { if (!this.check()) return undefined; return _rootContext[sPropertyName]; };