Yaron Koren has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/386713 )
Change subject: Cosmetic fixes for PF_jsGrid.js ...................................................................... Cosmetic fixes for PF_jsGrid.js Change-Id: I06a2fe96f9d1153dd7f468d777e51f72a1e2be6c --- M libs/PF_jsGrid.js 1 file changed, 116 insertions(+), 116 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/PageForms refs/changes/13/386713/2 diff --git a/libs/PF_jsGrid.js b/libs/PF_jsGrid.js index 0d4b43c..8a8d8c9 100644 --- a/libs/PF_jsGrid.js +++ b/libs/PF_jsGrid.js @@ -6,132 +6,132 @@ */ /* global jsGrid, mw */ (function(jsGrid, $, undefined) { - /** - * The following code handles the 'date' input type within the grid. - * insertTemplate preprocesses the value and returns it to the grid cell to display; - * editTemplate/insertTemplate generate the edition/insertion forms; - * editValue/insertValue is in charge of putting the final values into the grid. - */ + /** + * The following code handles the 'date' input type within the grid. + * insertTemplate preprocesses the value and returns it to the grid cell to display; + * editTemplate/insertTemplate generate the edition/insertion forms; + * editValue/insertValue is in charge of putting the final values into the grid. + */ - // Global variables to store edit and insert values to be used - // by the editValue and insertValue functions to put them into - // the date field. - var Global_Edit_day_of_month; - var Global_Edit_month; - var Global_Edit_year; - var Global_Insert_day_of_month; - var Global_Insert_month; - var Global_Insert_year; + // Global variables to store edit and insert values to be used + // by the editValue and insertValue functions to put them into + // the date field. + var Global_Edit_day_of_month; + var Global_Edit_month; + var Global_Edit_year; + var Global_Insert_day_of_month; + var Global_Insert_month; + var Global_Insert_year; - // Create month selector dropdown. - function buildSelect( currentMonth ) { - var monthNames = mw.config.get('wgMonthNamesShort'); - var str = '<select class="pf_jsGrid_month" style=" width: 100% !important; font-size:14px;">'; - for (var val=1; val<=12; val++) { - var val2; - if (val < 10) { //Adds a leading 0 to single digit months, ex 01 instead of 1. - val2 = "0" + val; - } else { - val2 = val; - } - var option = '<option '; - if (val === currentMonth) { - option += 'selected="selected" '; - } - option += 'value="' + val2 + '">' + monthNames[val] + '</option>'; - str += option; + // Create month selector dropdown. + function buildSelect( currentMonth ) { + var monthNames = mw.config.get('wgMonthNamesShort'); + var str = '<select class="pf_jsGrid_month" style=" width: 100% !important; font-size:14px;">'; + for (var val=1; val<=12; val++) { + var val2; + if (val < 10) { //Adds a leading 0 to single digit months, ex 01 instead of 1. + val2 = "0" + val; + } else { + val2 = val; } - str += '</select>'; - return str; + var option = '<option '; + if (val === currentMonth) { + option += 'selected="selected" '; + } + option += 'value="' + val2 + '">' + monthNames[val] + '</option>'; + str += option; } + str += '</select>'; + return str; + } - var PFDateField = function(config) { - jsGrid.Field.call(this, config); - }; + var PFDateField = function(config) { + jsGrid.Field.call(this, config); + }; - PFDateField.prototype = new jsGrid.Field({ - sorter: function(date1, date2) { - return new Date(date1) - new Date(date2); - }, + PFDateField.prototype = new jsGrid.Field({ + sorter: function(date1, date2) { + return new Date(date1) - new Date(date2); + }, - itemTemplate: function(value) { - return value; - }, + itemTemplate: function(value) { + return value; + }, - insertTemplate: function(value) { - var html_date = '<div style="float:left; width:19%;"><label style="display:block; text-align:center; font- size:14px;">DD:</label><input class="pf_jsGrid_day" style=" font-size:14px; " type="text" value="" placeholder="DD"></input></div>'; - var html_year = '<div style="float:left; width:29%;"><label style="display:block; text-align:center; width:29%; font-size:14px;">YYYY:</label><input class="pf_jsGrid_year" style=" font-size:14px; " type="text" value="" placeholder="YYYY"></input></div>'; - var html_month = '<div style="float:left; width:48%; margin-left:2%; margin-right:2%;"><label style="display:block; text-align:center; font-size:14px;">MM:</label>' + buildSelect(1) + '</div>'; - var fullDateInputHTML = '<div class="pf_jsGrid_ymd_form">'; - if ( mw.config.get('wgAmericanDates') ) { //check for date-style format. - fullDateInputHTML += html_month + html_date + html_year; - } else { - fullDateInputHTML += html_date + html_month + html_year; - } - fullDateInputHTML += '</div>'; - - $('.pfJSGrid').on('click propertychange change keyup input paste', function() { - Global_Insert_day_of_month = $('.pf_jsGrid_day').val(); - Global_Insert_year = $('.pf_jsGrid_year').val(); - Global_Insert_month = $('.pf_jsGrid_month').val(); - }); - - return fullDateInputHTML; - }, - - editTemplate: function(value) { - var display_day_of_month = ''; - var display_year = ''; - var display_month = 0; - if ( value !== null ) { - var dateObject = new Date(value); - display_day_of_month = dateObject.getDate(); - display_year = dateObject.getFullYear(); - display_month = dateObject.getMonth(); - } - var fullDateInputHTML = '<div class="pf_jsGrid_ymd_form">'; - var html_date = '<div style="float:left; width:19%;"><label style="display:block; text-align:center; font-size:14px;">DD:</label><input class="pf_jsGrid_day" style=" font-size:14px; " type="text" value=' + display_day_of_month + '></input></div>'; - var html_year = '<div style="float:left; width:29%;"><label style="display:block; text-align:center; width:29%; font-size:14px;">YYYY:</label><input class="pf_jsGrid_year" style=" font-size:14px; " type="text" value=' + display_year + '></input></div>'; - var html_month = '<div style="float:left; width:48%; margin-left:2%; margin-right:2%;"><label style="display:block; text-align:center; font-size:14px;">MM:</label>' + buildSelect(display_month + 1) + '</div>'; - if ( mw.config.get('wgAmericanDates') ) { //check for date-style format. - fullDateInputHTML += html_month + html_date + html_year; - } else { - fullDateInputHTML += html_date + html_month + html_year; - } - fullDateInputHTML += '</div>'; - - /* - * Always use eq(1) on the edit functions since jsGrid - * has a hidden insert row, so you have to ignore that - * row else you will capture - */ - $('.pfJSGrid').on('click propertychange change keyup input paste', function() { - Global_Edit_day_of_month = $('.pf_jsGrid_day').eq(1).val(); - Global_Edit_year = $('.pf_jsGrid_year').eq(1).val(); - Global_Edit_month = $('.pf_jsGrid_month').eq(1).val(); - }); - - return fullDateInputHTML; - }, - - insertValue: function() { - if ( Global_Insert_year === undefined || Global_Insert_year === "" ) { - return null; - } - var ret = Global_Insert_year + "-" + Global_Insert_month + "-" + Global_Insert_day_of_month; - return ret; - }, - - editValue: function(value) { - if ( Global_Edit_year === undefined || Global_Edit_year === "" ) { - return null; - } - var ret = Global_Edit_year + "-" + Global_Edit_month + "-" + Global_Edit_day_of_month; - return ret; + insertTemplate: function(value) { + var html_date = '<div style="float:left; width:19%;"><label style="display:block; text-align:center; font- size:14px;">DD:</label><input class="pf_jsGrid_day" style=" font-size:14px; " type="text" value="" placeholder="DD"></input></div>'; + var html_year = '<div style="float:left; width:29%;"><label style="display:block; text-align:center; width:29%; font-size:14px;">YYYY:</label><input class="pf_jsGrid_year" style=" font-size:14px; " type="text" value="" placeholder="YYYY"></input></div>'; + var html_month = '<div style="float:left; width:48%; margin-left:2%; margin-right:2%;"><label style="display:block; text-align:center; font-size:14px;">MM:</label>' + buildSelect(1) + '</div>'; + var fullDateInputHTML = '<div class="pf_jsGrid_ymd_form">'; + if ( mw.config.get('wgAmericanDates') ) { //check for date-style format. + fullDateInputHTML += html_month + html_date + html_year; + } else { + fullDateInputHTML += html_date + html_month + html_year; } - }); + fullDateInputHTML += '</div>'; - jsGrid.fields.date = PFDateField; + $('.pfJSGrid').on('click propertychange change keyup input paste', function() { + Global_Insert_day_of_month = $('.pf_jsGrid_day').val(); + Global_Insert_year = $('.pf_jsGrid_year').val(); + Global_Insert_month = $('.pf_jsGrid_month').val(); + }); + + return fullDateInputHTML; + }, + + editTemplate: function(value) { + var display_day_of_month = ''; + var display_year = ''; + var display_month = 0; + if ( value !== null ) { + var dateObject = new Date(value); + display_day_of_month = dateObject.getDate(); + display_year = dateObject.getFullYear(); + display_month = dateObject.getMonth(); + } + var fullDateInputHTML = '<div class="pf_jsGrid_ymd_form">'; + var html_date = '<div style="float:left; width:19%;"><label style="display:block; text-align:center; font-size:14px;">DD:</label><input class="pf_jsGrid_day" style=" font-size:14px; " type="text" value=' + display_day_of_month + '></input></div>'; + var html_year = '<div style="float:left; width:29%;"><label style="display:block; text-align:center; width:29%; font-size:14px;">YYYY:</label><input class="pf_jsGrid_year" style=" font-size:14px; " type="text" value=' + display_year + '></input></div>'; + var html_month = '<div style="float:left; width:48%; margin-left:2%; margin-right:2%;"><label style="display:block; text-align:center; font-size:14px;">MM:</label>' + buildSelect(display_month + 1) + '</div>'; + if ( mw.config.get('wgAmericanDates') ) { //check for date-style format. + fullDateInputHTML += html_month + html_date + html_year; + } else { + fullDateInputHTML += html_date + html_month + html_year; + } + fullDateInputHTML += '</div>'; + + /* + * Always use eq(1) on the edit functions since jsGrid + * has a hidden insert row, so you have to ignore that + * row else you will capture + */ + $('.pfJSGrid').on('click propertychange change keyup input paste', function() { + Global_Edit_day_of_month = $('.pf_jsGrid_day').eq(1).val(); + Global_Edit_year = $('.pf_jsGrid_year').eq(1).val(); + Global_Edit_month = $('.pf_jsGrid_month').eq(1).val(); + }); + + return fullDateInputHTML; + }, + + insertValue: function() { + if ( Global_Insert_year === undefined || Global_Insert_year === "" ) { + return null; + } + var ret = Global_Insert_year + "-" + Global_Insert_month + "-" + Global_Insert_day_of_month; + return ret; + }, + + editValue: function(value) { + if ( Global_Edit_year === undefined || Global_Edit_year === "" ) { + return null; + } + var ret = Global_Edit_year + "-" + Global_Edit_month + "-" + Global_Edit_day_of_month; + return ret; + } + }); + + jsGrid.fields.date = PFDateField; }(jsGrid, jQuery)); ( function ( $, mw ) { -- To view, visit https://gerrit.wikimedia.org/r/386713 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I06a2fe96f9d1153dd7f468d777e51f72a1e2be6c Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/extensions/PageForms Gerrit-Branch: master Gerrit-Owner: Yaron Koren <yaro...@gmail.com> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits