Committer: dpetrov
LJSUP-12126: Port choose date widget from the old update.bml pageU trunk/htdocs/js/jquery/jquery.lj.inlineCalendar.js
Modified: trunk/htdocs/js/jquery/jquery.lj.inlineCalendar.js =================================================================== --- trunk/htdocs/js/jquery/jquery.lj.inlineCalendar.js 2012-05-23 08:34:50 UTC (rev 11993) +++ trunk/htdocs/js/jquery/jquery.lj.inlineCalendar.js 2012-05-23 08:51:10 UTC (rev 11994) @@ -101,11 +101,17 @@ cellHover : 'hover' }, + //now, all lang variables are collected from Site.ml_text and should not be modified + mlPrefix: { + monthNamesShort: ['monthNames', 'date.month.{name}.short'], + monthNamesLong: ['monthNames', 'date.month.{name}.long'], + dayNamesShort: ['dayNames', 'date.day.{name}.short'] + }, + ml: { - monthNamesLong: [ "January", "February", "March", "April", "May", "June", "July", - "August", "September", "October", "November", "December"], - monthNamesShort: [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], - dayNamesShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], + monthNames: [ "january", "february", "march", "april", "may", "june", "july", + "august", "september", "october", "november", "december"], + dayNames: ['sunday', 'monday', 'tuesday', 'wednesday', 'tuesday', 'friday', 'saturday'], caption: "Calendar" } }; @@ -306,8 +312,24 @@ _preInit: function() { var def = $[ this.namespace ][ this.widgetName ].getDefaults(); this.options = jQuery.extend( true, {}, def, this.options ); + this._prepareMLVars(); }, + _prepareMLVars: function() { + var self = this, + expandVar = function(prefix, name) { + return LiveJournal.getLocalizedStr(prefix.supplant({name: name})); + }, + prefixData; + + for (var prefix in this.options.mlPrefix) { + if (this.options.mlPrefix.hasOwnProperty(prefix)) { + prefixData = this.options.mlPrefix[prefix]; + this.options.ml[prefix] = this.options.ml[prefixData[0]].map(expandVar.bind(null, prefixData[1])); + } + } + }, + // @TODO: need to change the structure of initialization code to remove this method _initialize: function() { if( !this.options.displayedMonth ) { @@ -557,7 +579,7 @@ setDefaults: function ( opts ) { if( opts ) { - jQuery.extend( defaultOptions, opts ); + jQuery.extend( true, defaultOptions, opts ); } } } );