Yaron Koren has submitted this change and it was merged.
Change subject: Making SF pass JSHint test
......................................................................
Making SF pass JSHint test
Bug: 61630
Change-Id: I40e5d3b7588f176909f152a4602f9423cf63d286
---
A .jshintrc
M libs/SF_autoedit.js
M libs/SF_autogrow.js
M libs/SF_checkboxes.js
M libs/SF_collapsible.js
M libs/SF_imagePreview.js
M libs/SF_popupform.js
M libs/SF_preview.js
M libs/SF_submit.js
M libs/SF_wikieditor.js
M libs/SemanticForms.js
M libs/ext.dynatree.js
M libs/ext.sf.select2.base.js
M libs/ext.sf.select2.combobox.js
M libs/ext.sf.select2.tokens.js
M libs/jquery.browser.js
M libs/jquery.dynatree.js
M libs/jquery.fancybox.js
18 files changed, 341 insertions(+), 252 deletions(-)
Approvals:
Yaron Koren: Verified; Looks good to me, approved
diff --git a/.jshintrc b/.jshintrc
new file mode 100644
index 0000000..80b00ba
--- /dev/null
+++ b/.jshintrc
@@ -0,0 +1,41 @@
+{
+ "predef": [
+ "mediaWiki",
+ "jQuery",
+ "semanticforms",
+ "mw",
+ "$",
+ "sf",
+ "ext"
+ ],
+
+ "bitwise": true,
+ "camelcase": false,
+ "curly": true,
+ "eqeqeq": true,
+ "forin": false,
+ "immed": true,
+ "latedef": true,
+ "newcap": true,
+ "noarg": false,
+ "noempty": true,
+ "nonew": true,
+ "quotmark": false,
+ "regexp": false,
+ "undef": true,
+ "unused": false,
+ "strict": false,
+ "trailing": true,
+
+ "laxbreak": true,
+ "smarttabs": true,
+ "multistr": true,
+
+ "browser": true,
+
+ "nomen": false,
+ "onevar": false,
+
+ "scripturl": false,
+ "supernew": false
+}
diff --git a/libs/SF_autoedit.js b/libs/SF_autoedit.js
index a41e50d..904251c 100644
--- a/libs/SF_autoedit.js
+++ b/libs/SF_autoedit.js
@@ -4,7 +4,6 @@
* @author Stephan Gambke
*/
-/*global jQuery, mediaWiki */
/*global confirm */
( function ( $, mw ) {
diff --git a/libs/SF_autogrow.js b/libs/SF_autogrow.js
index c566a90..2c21a11 100644
--- a/libs/SF_autogrow.js
+++ b/libs/SF_autogrow.js
@@ -21,12 +21,6 @@
autoGrowRowsDefault[id] = textArea.rows;
}
-function autoGrowBindEvents(textArea) {
- textArea.onkeyup = function() {
- autoGrow(textArea);
- }
-}
-
function autoGrow(textArea) {
var linesCount = 0;
var lines = textArea.value.split('\n');
@@ -35,10 +29,18 @@
linesCount += Math.floor((lines[i].length /
autoGrowColsDefault[textArea.id]) + 1);
}
- if (linesCount >= autoGrowRowsDefault[textArea.id])
+ if (linesCount >= autoGrowRowsDefault[textArea.id]) {
textArea.rows = linesCount + 1;
- else
+ }
+ else {
textArea.rows = autoGrowRowsDefault[textArea.id];
+ }
+}
+
+function autoGrowBindEvents(textArea) {
+ textArea.onkeyup = function() {
+ autoGrow(textArea);
+ };
}
// jQuery method
diff --git a/libs/SF_checkboxes.js b/libs/SF_checkboxes.js
index f49f0b8..019e502 100644
--- a/libs/SF_checkboxes.js
+++ b/libs/SF_checkboxes.js
@@ -4,8 +4,6 @@
* @author Stephan Gambke
*/
-/*global jQuery, mediaWiki */
-
( function ( $, mw ) {
'use strict';
@@ -50,7 +48,7 @@
} );
return this;
- }
+ };
$().ready( function ( $ ) {
$( '.checkboxesSpan.select-all' ).appendSelectionSwitches();
diff --git a/libs/SF_collapsible.js b/libs/SF_collapsible.js
index 330f61d..c945f40 100644
--- a/libs/SF_collapsible.js
+++ b/libs/SF_collapsible.js
@@ -26,7 +26,7 @@
this.each(function(){
var fieldset = jQuery(this);
var legend = fieldset.children('legend');
- if ( setting.collapsed == true ) {
+ if ( setting.collapsed === true ) {
legend.toggle(
function(){
sfShowFieldsetContent(fieldset,
setting);
@@ -45,7 +45,7 @@
function(){
sfShowFieldsetContent(fieldset,
setting);
}
- )
+ );
}
});
};
diff --git a/libs/SF_imagePreview.js b/libs/SF_imagePreview.js
index 842e5a2..c1f3aff 100644
--- a/libs/SF_imagePreview.js
+++ b/libs/SF_imagePreview.js
@@ -23,9 +23,9 @@
if ( data.query && data.query.pages ) {
var pages = data.query.pages;
- for ( p in pages ) {
+ for ( var p = 0; p < pages.length; p++
) {
var info = pages[p].imageinfo;
- for ( i in info ) {
+ for ( var i = 0; i <
info.length; i++ ) {
callback(
info[i].thumburl );
return;
}
diff --git a/libs/SF_popupform.js b/libs/SF_popupform.js
index c7a8222..02b0e58 100644
--- a/libs/SF_popupform.js
+++ b/libs/SF_popupform.js
@@ -4,6 +4,7 @@
* @author Stephan Gambke
*
*/
+/*global escape*/
// initialise
jQuery( function() {
@@ -163,8 +164,11 @@
var closeBtn = jQuery( "<div class='popupform-close'></div> " );
// initially hide background and waitIndicator
- if (brokenChrome) background.css("background", "transparent");
- else background.css("opacity", 0.0);
+ if (brokenChrome) {
+ background.css("background", "transparent");
+ } else {
+ background.css("opacity", 0.0);
+ }
waitIndicator.hide();
container.hide();
@@ -191,22 +195,27 @@
.appendTo( "body" );
// fade background in
- if ( !brokenChrome ) background.fadeTo( 400, 0.3 );
+ if ( !brokenChrome ) {
+ background.fadeTo( 400, 0.3 );
+ }
fadeIn( waitIndicator );
// attach event handler to close button
closeBtn.click( handleCloseFrame );
}
- function handleLoadFrame(){
+ function handleLoadFrame() {
var iframecontents = iframe.contents();
var containerAlreadyVisible = container.is( ':visible' );
if ( !containerAlreadyVisible ) {
// no need to hide it again
- if ( brokenBrowser ) container[0].style.visibility =
"hidden";
- else container[0].style.opacity = 0;
+ if ( brokenBrowser ) {
+ container[0].style.visibility = "hidden";
+ } else {
+ container[0].style.opacity = 0;
+ }
}
container.show();
@@ -215,16 +224,22 @@
content = iframecontents.find("#gumax-content-body");
// normal skins use #content (e.g. Vector, Monobook)
- if ( content.length == 0 ) content =
iframecontents.find("#content");
+ if ( content.length === 0 ) {
+ content = iframecontents.find("#content");
+ }
// some skins use #mw_content (e.g. Modern)
- if ( content.length == 0 ) content =
iframecontents.find("#mw_content");
+ if ( content.length === 0 ) {
+ content = iframecontents.find("#mw_content");
+ }
var iframebody = content.closest("body");
var iframedoc = iframebody.parent();
// this is not a normal MW page (or it uses an unknown skin)
- if ( content.length == 0 ) content = iframebody;
+ if ( content.length === 0 ) {
+ content = iframebody;
+ }
// the huge left margin looks ugly in Vector, reduce it
// (How does this look for other skins?)
@@ -269,9 +284,7 @@
var elem = jQuery(this);
// TODO: Does this really help?
- if ( getStyle(this, "display") != "none"
-// && ( getStyle( this, "width") != "0px"
|| getStyle( this, "height") != "0px" )
- && ! (
+ if ( getStyle(this, "display") != "none" && ! (
( this.offsetLeft +
elem.outerWidth(true) < 0 ) || // left of document
( this.offsetTop +
elem.outerHeight(true) < 0 ) || // above document
( this.offsetLeft > 100000 ) ||
// right of document
@@ -331,7 +344,9 @@
if ( innersubmitprocessed ) {
clearInterval( interval );
innersubmitprocessed = false;
- if ( submitok )
handleSubmitData( event );
+ if ( submitok ) {
+ handleSubmitData( event
);
+ }
}
}, 10);
@@ -400,8 +415,8 @@
.not('a[href^="#"]') // local links
.not('a.sfFancyBox') // link to file upload
.click(function(event){
- if ( event.result != false ) { // if not already
caught by somebody else
- closeFrameAndFollowLink(
event.target.getAttribute('href') )
+ if ( event.result !== false ) { // if not already
caught by somebody else
+ closeFrameAndFollowLink(
event.target.getAttribute('href') );
}
return false;
});
@@ -438,7 +453,7 @@
var innerform = jQuery("<div>" + returnedData +
"</div>").find("form");
// check if we got an error page
- if ( innerform.length == 0 ) {
+ if ( innerform.length === 0 ) {
form.unbind( event );
@@ -470,12 +485,15 @@
var stop = url.indexOf("&", start);
- if ( stop >= 0 ) url = url.substr( 0, start - 1
) + url.substr(stop + 1);
- else url = url.substr( 0, start - 1 );
+ if ( stop >= 0 ) {
+ url = url.substr( 0, start - 1 ) +
url.substr(stop + 1);
+ } else {
+ url = url.substr( 0, start - 1 );
+ }
}
- var form = jQuery('<form action="' + url + '"
method="POST"><input type="hidden" name="action" value="purge"></form>')
+ form = jQuery('<form action="' + url + '"
method="POST"><input type="hidden" name="action" value="purge"></form>')
.appendTo('body');
form
@@ -496,11 +514,11 @@
var oldContW = content.width();
var oldContH = content.height();
- var availW = Math.floor( jQuery(window).width() * .8 );
- var availH = Math.floor( jQuery(window).height() * .8 );
+ var availW = Math.floor( jQuery(window).width() * 0.8 );
+ var availH = Math.floor( jQuery(window).height() * 0.8 );
- var emergencyW = Math.floor( jQuery(window).width() * .85 );
- var emergencyH = Math.floor( jQuery(window).height() * .85 );
+ var emergencyW = Math.floor( jQuery(window).width() * 0.85 );
+ var emergencyH = Math.floor( jQuery(window).height() * 0.85 );
// FIXME: these might not be the true values
var scrollW = 25;
@@ -657,10 +675,9 @@
.width( frameW )
.height ( frameH );
- with ( container[0].style ) {
- top = (Math.floor(( - frameH ) / 2)) +
"px";
- left = (Math.floor(( - frameW ) / 2)) +
"px";
- }
+ container[0].style.top = (Math.floor(( - frameH
) / 2)) + "px";
+ container[0].style.left = (Math.floor(( -
frameW ) / 2)) + "px";
+
setTimeout(function(){
@@ -708,7 +725,7 @@
if ( jQuery.browser.mozilla ) {
body
- .css('overflow', 'auto')
+ .css('overflow', 'auto');
}
return true;
@@ -756,11 +773,16 @@
if ( brokenBrowser ){
elem.show();
- if ( callback ) callback();
+ if ( callback ) {
+ callback();
+ }
} else {
// what an ugly hack
- if ( elem === waitIndicator ) elem.fadeIn( 200,
callback );
- else elem.fadeIn( callback );
+ if ( elem === waitIndicator ) {
+ elem.fadeIn( 200, callback );
+ } else {
+ elem.fadeIn( callback );
+ }
}
}
@@ -768,11 +790,16 @@
// no fading for broken browsers
if ( brokenBrowser ){
elem.hide();
- if ( callback ) callback();
+ if ( callback ) {
+ callback();
+ }
} else {
// what an ugly hack
- if ( elem === waitIndicator ) elem.fadeOut( 200,
callback );
- else elem.fadeOut( callback );
+ if ( elem === waitIndicator ) {
+ elem.fadeOut( 200, callback );
+ } else {
+ elem.fadeOut( callback );
+ }
}
}
@@ -780,10 +807,15 @@
// no fading for broken browsers
if ( brokenBrowser ){
- if (target > 0) elem[0].style.visibility = "visible";
- else elem[0].style.visibility = "hidden";
+ if (target > 0) {
+ elem[0].style.visibility = "visible";
+ } else {
+ elem[0].style.visibility = "hidden";
+ }
- if ( callback ) callback();
+ if ( callback ) {
+ callback();
+ }
} else {
elem.fadeTo(time, target, callback);
@@ -794,4 +826,4 @@
this.handlePopupFormInput = handlePopupFormInput;
this.handlePopupFormLink = handlePopupFormLink;
this.adjustFrameSize = adjustFrameSize;
-};
+}();
\ No newline at end of file
diff --git a/libs/SF_preview.js b/libs/SF_preview.js
index 424fd86..0d4f93b 100644
--- a/libs/SF_preview.js
+++ b/libs/SF_preview.js
@@ -4,7 +4,6 @@
* @author Stephan Gambke
*/
-/*global jQuery, mediaWiki */
/*global validateAll */
( function ( $, mw ) {
diff --git a/libs/SF_submit.js b/libs/SF_submit.js
index 484939b..9a3dcdb 100644
--- a/libs/SF_submit.js
+++ b/libs/SF_submit.js
@@ -4,7 +4,6 @@
* @author Stephan Gambke
*/
-/*global jQuery, mediaWiki */
/*global validateAll */
( function ( $, mw ) {
diff --git a/libs/SF_wikieditor.js b/libs/SF_wikieditor.js
index 0dae2fe..4931847 100644
--- a/libs/SF_wikieditor.js
+++ b/libs/SF_wikieditor.js
@@ -1,4 +1,5 @@
// create ext if it does not exist yet
+/*global wgWikiEditorEnabledModules*/
if ( typeof( window.ext ) === "undefined" ) {
window.ext = {};
}
@@ -16,7 +17,7 @@
input.wikiEditor( 'addModule',
jQuery.wikiEditor.modules.toolbar.config.getDefaultConfig() );
// hide sig if required
- if ( wgWikiEditorEnabledModules
&& wgWikiEditorEnabledModules['hidesig'] == true ) {
+ if ( wgWikiEditorEnabledModules
&& wgWikiEditorEnabledModules.hidesig === true ) {
input.wikiEditor(
'removeFromToolbar', {
'section':
'main',
'group':
'insert',
diff --git a/libs/SemanticForms.js b/libs/SemanticForms.js
index d035bc8..49e07ae 100644
--- a/libs/SemanticForms.js
+++ b/libs/SemanticForms.js
@@ -10,6 +10,7 @@
* @author Harold Solbrig
* @author Eugene Mednikov
*/
+ /*global sfgShowOnSelect, sfgFieldProperties, validateAll, alert, sf*/
// Activate autocomplete functionality for the specified field
(function(jQuery) {
@@ -18,17 +19,19 @@
jQuery.ui.autocomplete.prototype._renderItem = function( ul, item) {
var delim = this.element.context.delimiter;
- if ( delim == null ) {
+ var term;
+ if ( delim === null ) {
term = this.term;
} else {
term = this.term.split( delim ).pop();
}
var re = new RegExp("(?![^&;]+;)(?!<[^<>]*)(" +
term.replace(/([\^\$\(\)\[\]\{\}\*\.\+\?\|\\])/gi, "\\$1") +
")(?![^<>]*>)(?![^&;]+;)", "gi");
var loc = item.label.search(re);
+ var t;
if (loc >= 0) {
- var t = item.label.substr(0, loc) + '<strong>' +
item.label.substr(loc, term.length) + '</strong>' + item.label.substr(loc +
term.length);
+ t = item.label.substr(0, loc) + '<strong>' +
item.label.substr(loc, term.length) + '</strong>' + item.label.substr(loc +
term.length);
} else {
- var t = item.label;
+ t = item.label;
}
return jQuery( "<li></li>" )
.data( "item.autocomplete", item )
@@ -52,7 +55,7 @@
var data_source = field_values[0];
if (field_values[1] == 'list') {
delimiter = ",";
- if (field_values[2] != null) {
+ if (field_values[2] !== null && field_values[2] !== undefined) {
delimiter = field_values[2];
}
}
@@ -62,7 +65,7 @@
// This doesn't cover the case of a delimiter that's a newline
// plus something else, like ".\n" or "\n\n", but as far as we
// know no one has yet needed that.
- if ( delimiter != null ) {
+ if ( delimiter !== null && delimiter !== undefined ) {
if ( delimiter == "\\n" ) {
delimiter = "\n";
} else {
@@ -77,10 +80,11 @@
jQuery.extend( jQuery.ui.autocomplete, {
filter: function(array, term) {
var sfgAutocompleteOnAllChars = mw.config.get(
'sfgAutocompleteOnAllChars' );
- if ( sfgAutocompleteOnAllChars ) {
- var matcher = new
RegExp(jQuery.ui.autocomplete.escapeRegex(term), "i" );
+ var matcher;
+ if ( sfgAutocompleteOnAllChars ) {
+ matcher = new
RegExp(jQuery.ui.autocomplete.escapeRegex(term), "i" );
} else {
- var matcher = new RegExp("\\b" +
jQuery.ui.autocomplete.escapeRegex(term), "i" );
+ matcher = new RegExp("\\b" +
jQuery.ui.autocomplete.escapeRegex(term), "i" );
}
return jQuery.grep( array, function(value) {
return matcher.test( value.label || value.value ||
value );
@@ -88,23 +92,22 @@
}
});
- values = jQuery(this).data('autocompletevalues');
+ var values = jQuery(this).data('autocompletevalues');
if ( !values ) {
var sfgAutocompleteValues = mw.config.get( 'sfgAutocompleteValues' );
values = sfgAutocompleteValues[field_string];
}
- if (values != null) {
+ var split = function (val) {
+ return val.split(delimiter);
+ };
+ var extractLast = function (term) {
+ return split(term).pop();
+ };
+ if (values !== null && values !== undefined) {
// Local autocompletion
- if (delimiter != null) {
+ if (delimiter !== null && delimiter !== undefined) {
// Autocomplete for multiple values
-
- function split(val) {
- return val.split(delimiter);
- }
- function extractLast(term) {
- return split(term).pop();
- }
var thisInput = jQuery(this);
@@ -148,13 +151,7 @@
var data_type = jQuery(this).attr("autocompletedatatype");
myServer += "?action=sfautocomplete&format=json&" + data_type + "=" +
data_source;
- if (delimiter != null) {
- function split(val) {
- return val.split(delimiter);
- }
- function extractLast(term) {
- return split(term).pop();
- }
+ if (delimiter !== null && delimiter !== undefined) {
jQuery(this).autocomplete({
source: function(request, response) {
jQuery.getJSON(myServer, {
@@ -163,8 +160,8 @@
response(jQuery.map(data.sfautocomplete, function(item) {
return {
value: item.title
- }
- }))
+ };
+ }));
});
},
search: function() {
@@ -204,8 +201,8 @@
response(jQuery.map(data.sfautocomplete, function(item) {
return {
value:
item.title
- }
- }))
+ };
+ }));
}
});
},
@@ -249,7 +246,9 @@
// @param param The parameter object given to the validation function
jQuery.fn.SemanticForms_registerInputValidation = function(valfunction, param)
{
- if ( ! this.attr("id") ) return this;
+ if ( ! this.attr("id") ) {
+ return this;
+ }
if ( ! jQuery("#sfForm").data("SemanticForms") ) {
setupSF();
@@ -278,7 +277,9 @@
jQuery.fn.SemanticForms_registerInputInit = function( initFunction, param,
noexecute ) {
// return if element has no id
- if ( ! this.attr("id") ) return this;
+ if ( ! this.attr("id") ) {
+ return this;
+ }
// setup data structure if necessary
if ( ! jQuery("#sfForm").data("SemanticForms") ) {
@@ -288,7 +289,7 @@
// if no initialization function for this input was registered yet,
// create entry
if ( !
jQuery("#sfForm").data("SemanticForms").initFunctions[this.attr("id")] ) {
-
jQuery("#sfForm").data("SemanticForms").initFunctions[this.attr("id")] = new
Array();
+
jQuery("#sfForm").data("SemanticForms").initFunctions[this.attr("id")] = [];
}
// record initialization function
@@ -299,10 +300,10 @@
// execute initialization if input is not part of
multipleTemplateStarter
// and if not forbidden
- if ( this.closest(".multipleTemplateStarter").length == 0 &&
!noexecute) {
+ if ( this.closest(".multipleTemplateStarter").length === 0 &&
!noexecute) {
var input = this;
// ensure initFunction is only exectued after doc structure is
complete
- jQuery(function() {initFunction ( input.attr("id"), param )});
+ jQuery(function() {initFunction ( input.attr("id"), param );});
}
return this;
@@ -415,7 +416,7 @@
var showOnSelectVals = sfgShowOnSelect[this.attr("id")];
var instanceWrapperDiv = this.closest('.multipleTemplateInstance');
- if ( instanceWrapperDiv.length == 0 ) {
+ if ( instanceWrapperDiv.length === 0 ) {
instanceWrapperDiv = null;
}
@@ -451,7 +452,7 @@
var showOnSelectVals = sfgShowOnSelect[this.attr("id")];
var instanceWrapperDiv = this.closest('.multipleTemplateInstance');
- if ( instanceWrapperDiv.length == 0 ) {
+ if ( instanceWrapperDiv.length === 0 ) {
instanceWrapperDiv = null;
}
@@ -472,7 +473,7 @@
var div_id = sfgShowOnSelect[this.attr("id")];
var instanceWrapperDiv = this.closest('.multipleTemplateInstance');
- if ( instanceWrapperDiv.length == 0 ) {
+ if ( instanceWrapperDiv.length === 0 ) {
instanceWrapperDiv = null;
}
@@ -507,16 +508,17 @@
} else {
return true;
}
-}
+};
jQuery.fn.validateMandatoryField = function() {
var fieldVal = this.find(".mandatoryField").val();
- if (fieldVal == null) {
- var isEmpty = true;
+ var isEmpty;
+ if (fieldVal === null) {
+ isEmpty = true;
} else if (jQuery.isArray(fieldVal)) {
- var isEmpty = (fieldVal.length == 0);
+ isEmpty = (fieldVal.length === 0);
} else {
- var isEmpty = (fieldVal.replace(/\s+/, '') == '');
+ isEmpty = (fieldVal.replace(/\s+/, '') === '');
}
if (isEmpty) {
this.addErrorMessage( 'sf_blank_error' );
@@ -528,7 +530,7 @@
jQuery.fn.validateMandatoryComboBox = function() {
var combobox = this.find( "input.sfComboBox" );
- if (combobox.val() == '') {
+ if (combobox.val() === '') {
this.addErrorMessage( 'sf_blank_error' );
return false;
} else {
@@ -537,9 +539,9 @@
};
jQuery.fn.validateMandatoryDateField = function() {
- if (this.find(".dayInput").val() == '' ||
- this.find(".monthInput").val() == '' ||
- this.find(".yearInput").val() == '') {
+ if (this.find(".dayInput").val() === '' ||
+ this.find(".monthInput").val() === '' ||
+ this.find(".yearInput").val() === '') {
this.addErrorMessage( 'sf_blank_error' );
return false;
} else {
@@ -562,7 +564,7 @@
// Get the number of checked checkboxes within this span - must
// be at least one.
var numChecked = this.find("input:checked").size();
- if (numChecked == 0) {
+ if (numChecked === 0) {
this.addErrorMessage( 'sf_blank_error' );
return false;
} else {
@@ -578,7 +580,7 @@
var fieldVal = this.find("input").val();
// code borrowed from http://snippets.dzone.com/posts/show/452
var url_regexp =
/(ftp|http|https|rtsp|news):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;
- if (fieldVal == "" || url_regexp.test(fieldVal)) {
+ if (fieldVal === "" || url_regexp.test(fieldVal)) {
return true;
} else {
this.addErrorMessage( 'sf_bad_url_error' );
@@ -590,7 +592,7 @@
var fieldVal = this.find("input").val();
// code borrowed from
http://javascript.internet.com/forms/email-validation---basic.html
var email_regexp =
/^\s*\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,6})+\s*$/;
- if (fieldVal == '' || email_regexp.test(fieldVal)) {
+ if (fieldVal === '' || email_regexp.test(fieldVal)) {
return true;
} else {
this.addErrorMessage( 'sf_bad_email_error' );
@@ -602,7 +604,7 @@
var fieldVal = this.find("input").val();
// Handle "E notation"/scientific notation ("1.2e-3") in addition
// to regular numbers
- if (fieldVal == '' ||
+ if (fieldVal === '' ||
fieldVal.match(/^\s*[\-+]?((\d+[\.,]?\d*)|(\d*[\.,]?\d+))([eE]?[\-\+]?\d+)?\s*$/))
{
return true;
} else {
@@ -615,7 +617,7 @@
// validate only if day and year fields are both filled in
var dayVal = this.find(".dayInput").val();
var yearVal = this.find(".yearInput").val();
- if (dayVal == '' || yearVal == '') {
+ if (dayVal === '' || yearVal === '') {
return true;
} else if (dayVal.match(/^\d+$/) && dayVal <= 31) {
// no year validation, since it can also include
@@ -638,35 +640,55 @@
jQuery(".multipleTemplateStarter").find("span,
div").addClass("hiddenBySF");
jQuery(".multipleTemplateList").each( function() {
- if (! jQuery(this).validateNumInstances() ) num_errors += 1;
+ if (! jQuery(this).validateNumInstances() ) {
+ num_errors += 1;
+ }
});
jQuery("span.inputSpan.mandatoryFieldSpan").not(".hiddenBySF").each(
function() {
- if (! jQuery(this).validateMandatoryField() ) num_errors += 1;
+ if (! jQuery(this).validateMandatoryField() ) {
+ num_errors += 1;
+ }
});
jQuery("div.ui-widget.mandatory").not(".hiddenBySF").each( function() {
- if (! jQuery(this).validateMandatoryComboBox() ) num_errors +=
1;
+ if (! jQuery(this).validateMandatoryComboBox() ) {
+ num_errors += 1;
+ }
});
jQuery("span.dateInput.mandatoryFieldSpan").not(".hiddenBySF").each(
function() {
- if (! jQuery(this).validateMandatoryDateField() ) num_errors +=
1;
+ if (! jQuery(this).validateMandatoryDateField() ) {
+ num_errors += 1;
+ }
});
jQuery("span.radioButtonSpan.mandatoryFieldSpan").not(".hiddenBySF").each(
function() {
- if (! jQuery(this).validateMandatoryRadioButton() ) num_errors
+= 1;
+ if (! jQuery(this).validateMandatoryRadioButton() ) {
+ num_errors += 1;
+ }
});
jQuery("span.checkboxesSpan.mandatoryFieldSpan").not(".hiddenBySF").each(
function() {
- if (! jQuery(this).validateMandatoryCheckboxes() ) num_errors
+= 1;
+ if (! jQuery(this).validateMandatoryCheckboxes() ) {
+ num_errors += 1;
+ }
});
jQuery("span.URLInput").not(".hiddenBySF").each( function() {
- if (! jQuery(this).validateURLField() ) num_errors += 1;
+ if (! jQuery(this).validateURLField() ) {
+ num_errors += 1;
+ }
});
jQuery("span.emailInput").not(".hiddenBySF").each( function() {
- if (! jQuery(this).validateEmailField() ) num_errors += 1;
+ if (! jQuery(this).validateEmailField() ) {
+ num_errors += 1;
+ }
});
jQuery("span.numberInput").not(".hiddenBySF").each( function() {
- if (! jQuery(this).validateNumberField() ) num_errors += 1;
+ if (! jQuery(this).validateNumberField() ) {
+ num_errors += 1;
+ }
});
jQuery("span.dateInput").not(".hiddenBySF").each( function() {
- if (! jQuery(this).validateDateField() ) num_errors += 1;
+ if (! jQuery(this).validateDateField() ) {
+ num_errors += 1;
+ }
});
// call registered validation functions
@@ -679,22 +701,23 @@
// if input is not part of multipleTemplateStarter
if ( typeof sfdata.validationFunctions[i] !==
'undefined' &&
- jQuery("#" +
sfdata.validationFunctions[i].input).closest(".multipleTemplateStarter").length
== 0 &&
- jQuery("#" +
sfdata.validationFunctions[i].input).closest(".hiddenBySF").length == 0 ) {
+ jQuery("#" +
sfdata.validationFunctions[i].input).closest(".multipleTemplateStarter").length
=== 0 &&
+ jQuery("#" +
sfdata.validationFunctions[i].input).closest(".hiddenBySF").length === 0 ) {
if (! sfdata.validationFunctions[i].valfunction(
sfdata.validationFunctions[i].input,
sfdata.validationFunctions[i].parameters)
- )
+ ) {
num_errors += 1;
+ }
}
}
}
if (num_errors > 0) {
// add error header, if it's not there already
- if (jQuery("#form_error_header").size() == 0) {
- jQuery("#mw-content-text").prepend('<div
id="form_error_header" class="errorbox" style="font-size: medium"><img src="' +
mw.config.get( 'sfgScriptPath' ) + '/skins/MW-Icon-AlertMark.png" /> ' +
mw.message( 'sf_formerrors_header' ).escaped() + '</div><br clear="both" />');
+ if (jQuery("#form_error_header").size() === 0) {
+ jQuery("#contentSub").append('<div
id="form_error_header" class="errorbox" style="font-size: medium"><img src="' +
mw.config.get( 'sfgScriptPath' ) + '/skins/MW-Icon-AlertMark.png" /> ' +
mw.message( 'sf_formerrors_header' ).escaped() + '</div><br clear="both" />');
}
scroll(0, 0);
} else {
@@ -706,9 +729,9 @@
.attr('disabled', 'disabled')
.addClass('disabledBySF');
//remove error box if it exists because there are no errors in
the form now
- jQuery("#mw-content-text").find(".errorbox").remove();
+ jQuery("#contentSub").find(".errorbox").remove();
}
- return (num_errors == 0);
+ return (num_errors === 0);
};
/**
@@ -767,12 +790,13 @@
var sfdata =
jQuery("#sfForm").data('SemanticForms');
if ( sfdata ) { // found data object?
+ var i;
if ( sfdata.initFunctions[old_id] ) {
// For every initialization
method for
// input with id old_id,
register the
// method for the new input.
- for ( var i = 0; i <
sfdata.initFunctions[old_id].length; i++ ) {
+ for ( i = 0; i <
sfdata.initFunctions[old_id].length; i++ ) {
jQuery(this).SemanticForms_registerInputInit(
sfdata.initFunctions[old_id][i].initFunction,
@@ -785,7 +809,7 @@
// For every validation method for the
// input with ID old_id, register it
// for the new input.
- for ( var i = 0; i <
sfdata.validationFunctions.length; i++ ) {
+ for ( i = 0; i <
sfdata.validationFunctions.length; i++ ) {
if ( typeof
sfdata.validationFunctions[i] !== 'undefined' &&
sfdata.validationFunctions[i].input == old_id ) {
@@ -840,7 +864,7 @@
thatData[i].initFunction(
this.id,
thatData[i].parameters
- )
+ );
}
}
}
@@ -855,8 +879,8 @@
// regular inputs, and the 'origName' attribute for inputs in multiple-instance
// templates.
jQuery.fn.setDependentAutocompletion = function( dependentField, baseField,
baseValue ) {
- propName = sfgFieldProperties[dependentField];
- baseProp = sfgFieldProperties[baseField];
+ var propName = sfgFieldProperties[dependentField];
+ var baseProp = sfgFieldProperties[baseField];
var myServer = mw.config.get( 'wgScriptPath' ) + "/api.php";
myServer += "?action=sfautocomplete&format=json&property=" + propName +
"&baseprop=" + baseProp + "&basevalue=" + baseValue;
var dependentValues = [];
@@ -879,7 +903,7 @@
dataType: 'json',
async: false,
success: function(data) {
- realData = data.sfautocomplete;
+ var realData = data.sfautocomplete;
jQuery.each(realData, function(key, val) {
dependentValues.push(val.title);
});
@@ -894,13 +918,13 @@
* for its 'dependent' field (e.g., for a city).
*/
jQuery.fn.setAutocompleteForDependentField = function( partOfMultiple ) {
- curValue = jQuery(this).val();
- if ( curValue == null ) { return this; }
+ var curValue = jQuery(this).val();
+ if ( curValue === null ) { return this; }
- nameAttr = partOfMultiple ? 'origName' : 'name';
- name = jQuery(this).attr(nameAttr);
+ var nameAttr = partOfMultiple ? 'origName' : 'name';
+ var name = jQuery(this).attr(nameAttr);
var sfgDependentFields = mw.config.get( 'sfgDependentFields' );
- dependent_on_me = [];
+ var dependent_on_me = [];
for ( var i = 0; i < sfgDependentFields.length; i++ ) {
var dependentFieldPair = sfgDependentFields[i];
if ( dependentFieldPair[0] == name ) {
@@ -911,12 +935,13 @@
var self = this;
jQuery.each( dependent_on_me, function() {
- dependentField = this;
+ var dependentField = this;
+ var dependent_field_element;
if ( partOfMultiple ) {
- var dependent_field_element =
jQuery(self).closest(".multipleTemplateInstance")
+ dependent_field_element =
jQuery(self).closest(".multipleTemplateInstance")
.find('[origName="' + dependentField + '"]');
} else {
- var dependent_field_element = jQuery('[name="' +
dependentField + '"]');
+ dependent_field_element = jQuery('[name="' +
dependentField + '"]');
}
var class_name = $(dependent_field_element).attr( 'class' );
if ( class_name.indexOf( 'sfComboBox' ) != -1 ) {
diff --git a/libs/ext.dynatree.js b/libs/ext.dynatree.js
index f53acb9..116b04d 100644
--- a/libs/ext.dynatree.js
+++ b/libs/ext.dynatree.js
@@ -1,7 +1,7 @@
$(function () {
- // Attach the dynatree widget to an existing <div id="tree"> element
- // and pass the tree options as an argument to the dynatree() function:
- var nodeSelection = $("div[id*=treeinput]");
+ // Attach the dynatree widget to an existing <div id="tree"> element
+ // and pass the tree options as an argument to the dynatree() function:
+ var nodeSelection = $("div[id*=treeinput]");
nodeSelection.each (function (index) {
var node = nodeSelection.eq(index);
var selectMode = 2;
@@ -12,42 +12,41 @@
}
node.dynatree({
- checkbox: true,
- minExpandLevel: 1,
+ checkbox: true,
+ minExpandLevel: 1,
classNames: checkboxClass,
- selectMode: selectMode,
- onClick: function (node, event) {
- var targetType = node.getEventTargetType(event);
- if ( targetType == "expander" ) {
- node.toggleExpand();
- } else if ( targetType == "checkbox" ||
- targetType == "title" ) {
- node.toggleSelect();
- }
+ selectMode: selectMode,
+ onClick: function (node, event) {
+ var targetType = node.getEventTargetType(event);
+ if ( targetType == "expander" ) {
+ node.toggleExpand();
+ } else if ( targetType == "checkbox" ||
+ targetType == "title" ) {
+ node.toggleSelect();
+ }
- return false;
- },
- //Un/check real checkboxes recursively after selection
- onSelect: function (select, dtnode) {
- var inputkey = "chb-" + dtnode.data.key;
- $("[id='" + inputkey + "']").attr("checked",
select);
- },
- //Prevent reappearing of checkbox when node is collapse
- onExpand: function (select, dtnode) {
- $("#chb-" + dtnode.data.key).attr("checked",
- dtnode.isSelected()).addClass("hidden");
- }
- });
- //Update real checkboxes according to selections
- $.map(node.dynatree("getTree").getSelectedNodes(),
- function (dtnode) {
- $("#chb-" + dtnode.data.key).attr("checked",
true);
- dtnode.activate();
- });
- var activeNode = node.dynatree("getTree").getActiveNode();
- if (activeNode !== null) {
- activeNode.deactivate()
- }
- });
+ return false;
+ },
+ //Un/check real checkboxes recursively after selection
+ onSelect: function (select, dtnode) {
+ var inputkey = "chb-" + dtnode.data.key;
+ $("[id='" + inputkey + "']").attr("checked", select);
+ },
+ //Prevent reappearing of checkbox when node is collapse
+ onExpand: function (select, dtnode) {
+ $("#chb-" + dtnode.data.key).attr("checked",
+ dtnode.isSelected()).addClass("hidden");
+ }
+ });
+ //Update real checkboxes according to selections
+ $.map(node.dynatree("getTree").getSelectedNodes(),
+ function (dtnode) {
+ $("#chb-" + dtnode.data.key).attr("checked", true);
+ dtnode.activate();
+ });
+ var activeNode = node.dynatree("getTree").getActiveNode();
+ if (activeNode !== null) {
+ activeNode.deactivate();
+ }
+ });
});
-
diff --git a/libs/ext.sf.select2.base.js b/libs/ext.sf.select2.base.js
index f2143d2..0a9c590 100644
--- a/libs/ext.sf.select2.base.js
+++ b/libs/ext.sf.select2.base.js
@@ -76,15 +76,15 @@
var markup = "";
var text_highlight =
sf.select2.base.prototype.textHighlight;
- if ( text != undefined && image != undefined &&
description != undefined ) {
+ if ( text !== undefined && image !== undefined &&
description !== undefined ) {
markup += "<table class='sf-select2-result'>
<tr>";
markup += "<td class='sf-result-thumbnail'><img
src='" + image + "'/></td>";
markup += "<td class='sf-result-info'><div
class='sf-result-title'>" + text_highlight(text, term) + "</div>";
markup += "<div class='sf-result-description'>"
+ description + "</div>";
markup += "</td></tr></table>";
- } else if ( text != undefined && image != undefined ) {
+ } else if ( text !== undefined && image !== undefined )
{
markup += "<img class='sf-icon' src='"+ image
+"'/>" + text_highlight(text, term);
- } else if ( text != undefined && description !=
undefined ) {
+ } else if ( text !== undefined && description !==
undefined ) {
markup += "<table class='sf-select2-result'>
<tr>";
markup += "<td class='sf-result-info'><div
class='sf-result-title'>" + text_highlight(text, term) + "</div>";
markup += "<div class='sf-result-description'>"
+ description + "</div>";
@@ -118,7 +118,6 @@
var input_id = "#" + this.id;
var name_attr = this.nameAttr( $(input_id) );
var name = $(input_id).attr( name_attr );
- var dependent_on_me = [];
var sfgDependentFields = mw.config.get(
'sfgDependentFields' );
for ( var i = 0; i < sfgDependentFields.length; i++ ) {
@@ -174,7 +173,7 @@
*
*/
partOfMultiple: function( element ) {
- return element.attr( "origname" ) != undefined ? true :
false;
+ return element.attr( "origname" ) !== undefined ? true
: false;
},
/*
* Gives dependent field options which include
@@ -188,11 +187,12 @@
getDependentFieldOpts: function( dep_on ) {
var input_id = "#" + this.id;
var dep_field_opts = {};
+ var base_element;
if ( this.partOfMultiple($(input_id)) ) {
- var base_element = $(input_id).closest(
".multipleTemplateInstance" )
+ base_element = $(input_id).closest(
".multipleTemplateInstance" )
.find(
'[origname ="' + dep_on + '" ]' );
} else {
- var base_element = $('[name ="' + dep_on + '"
]');
+ base_element = $('[name ="' + dep_on + '" ]');
}
dep_field_opts.base_value = base_element.val();
dep_field_opts.base_prop = base_element.attr(
"autocompletesettings" );
@@ -249,7 +249,7 @@
var remove_diacritics =
sf.select2.base.prototype.removeDiacritics;
var no_diac_text = remove_diacritics(text);
var start =
no_diac_text.toUpperCase().indexOf(term.toUpperCase());
- if (start != 0 && !mw.config.get(
'sfgAutocompleteOnAllChars' )) {
+ if (start !== 0 && !mw.config.get(
'sfgAutocompleteOnAllChars' )) {
start = no_diac_text.toUpperCase().indexOf(" "
+ term.toUpperCase());
if ( start != -1 ) {
start = start + 1;
diff --git a/libs/ext.sf.select2.combobox.js b/libs/ext.sf.select2.combobox.js
index 79a4169..ca6e6ae 100644
--- a/libs/ext.sf.select2.combobox.js
+++ b/libs/ext.sf.select2.combobox.js
@@ -43,11 +43,11 @@
combobox_proto.setOptions = function() {
var input_id = this.id;
var opts = {};
- var input_id = "#" + input_id;
+ input_id = "#" + input_id;
var input_tagname = $(input_id).prop( "tagName" );
var autocomplete_opts = this.getAutocompleteOpts();
- if ( autocomplete_opts.autocompletedatatype != undefined ) {
+ if ( autocomplete_opts.autocompletedatatype !== undefined ) {
opts.ajax = this.getAjaxOpts();
opts.minimumInputLength = 1;
opts.formatInputTooShort = mw.msg(
"sf-select2-input-too-short", opts.minimumInputLength );
@@ -62,10 +62,11 @@
var no_diac_text =
sf.select2.base.prototype.removeDiacritics( text );
var position =
no_diac_text.toUpperCase().indexOf(term.toUpperCase());
var position_with_space =
no_diac_text.toUpperCase().indexOf(" " + term.toUpperCase());
- if ( (position != -1 && position == 0 ) ||
position_with_space != -1 )
+ if ( (position != -1 && position === 0 ) ||
position_with_space != -1 ) {
return true;
- else
+ } else {
return false;
+ }
};
}
opts.formatResult = this.formatResult;
@@ -75,12 +76,12 @@
if ( $(input_id).attr( "existingvaluesonly" ) !== "true" &&
input_tagname == "INPUT" ) {
opts.createSearchChoice = function( term, data ) { if (
$(data).filter(function() { return this.text.localeCompare( term )===0;
}).length===0 ) {return { id:term, text:term };} };
}
- if ( $(input_id).val() != "" && input_tagname == "INPUT" ) {
+ if ( $(input_id).val() !== "" && input_tagname == "INPUT" ) {
opts.initSelection = function ( element, callback ) {
var data = {id: element.val(), text: element.val()}; callback(data); };
}
opts.allowClear = true;
var size = $(input_id).attr("size");
- if ( size == undefined ) {
+ if ( size === undefined ) {
size = 35; //default value
}
opts.containerCss = { 'min-width': size * 6 };
@@ -100,17 +101,17 @@
var input_id = "#" + this.id;
var values = [{id: 0, text: ""}];
var dep_on = this.dependentOn();
- var i;
- if ( dep_on == null ) {
+ var i, data;
+ if ( dep_on === null ) {
if ( autocompletesettings == 'external data' ) {
var name =
$(input_id).attr(this.nameAttr($(input_id)));
var sfgEDSettings = mw.config.get(
'sfgEDSettings' );
var edgValues = mw.config.get( 'edgValues' );
- var data = {};
- if ( sfgEDSettings[name].title != undefined &&
sfgEDSettings[name].title != "" ) {
+ data = {};
+ if ( sfgEDSettings[name].title !== undefined &&
sfgEDSettings[name].title !== "" ) {
data.title =
edgValues[sfgEDSettings[name].title];
i = 0;
- if ( data.title != undefined ) {
+ if ( data.title !== undefined &&
data.title !== null ) {
data.title.forEach(function() {
values.push({
id: i + 1, text:
data.title[i]
@@ -118,20 +119,20 @@
i++;
});
}
- if ( sfgEDSettings[name].image !=
undefined && sfgEDSettings[name].image != "" ) {
+ if ( sfgEDSettings[name].image !==
undefined && sfgEDSettings[name].image !== "" ) {
data.image =
edgValues[sfgEDSettings[name].image];
i = 0;
- if ( data.image != undefined ) {
+ if ( data.image !== undefined
&& data.image !== null ) {
data.image.forEach(function() {
values[i+1].image = data.image[i];
i++;
});
}
}
- if ( sfgEDSettings[name].description !=
undefined && sfgEDSettings[name].description != "" ) {
+ if ( sfgEDSettings[name].description
!== undefined && sfgEDSettings[name].description !== "" ) {
data.description =
edgValues[sfgEDSettings[name].description];
i = 0;
- if ( data.description !=
undefined ) {
+ if ( data.description !==
undefined && data.description !== null ) {
data.description.forEach(function() {
values[i+1].description = data.description[i];
i++;
@@ -142,10 +143,10 @@
} else {
var sfgAutocompleteValues = mw.config.get(
'sfgAutocompleteValues' );
- var data =
sfgAutocompleteValues[autocompletesettings];
+ data =
sfgAutocompleteValues[autocompletesettings];
i = 0;
//Convert data into the format accepted by
Select2
- if (data != undefined) {
+ if (data !== undefined && data !== null ) {
data.forEach(function()
{
values.push({
@@ -186,7 +187,6 @@
*
*/
combobox_proto.getAjaxOpts = function() {
- var input_id = "#" + this.id;
var autocomplete_opts = this.getAutocompleteOpts();
var my_server = mw.util.wikiScript( 'api' );
my_server += "?action=sfautocomplete&format=json&" +
autocomplete_opts.autocompletedatatype + "=" +
autocomplete_opts.autocompletesettings;
@@ -219,7 +219,7 @@
combobox_proto.onChange = function() {
var self = this;
var data = $(this).select2( "data" );
- if (data != null) {
+ if (data !== null) {
$(this).val( data.text );
} else {
$(this).val( '' );
@@ -230,11 +230,12 @@
var cmbox = new sf.select2.combobox();
var dep_on_me = $.unique(cmbox.dependentOnMe( $(this) ));
dep_on_me.forEach( function( dependent_field_name ) {
+ var dependent_field;
if ( cmbox.partOfMultiple( $(self) ) ) {
- var dependent_field = $(self).closest(
".multipleTemplateInstance" )
+ dependent_field = $(self).closest(
".multipleTemplateInstance" )
.find( '[origname ="' +
dependent_field_name + '" ]' );
} else {
- var dependent_field = $('[name ="' +
dependent_field_name + '" ]');
+ dependent_field = $('[name ="' +
dependent_field_name + '" ]');
}
cmbox.dependentFieldAutocompleteHandler(
dependent_field, self );
});
diff --git a/libs/ext.sf.select2.tokens.js b/libs/ext.sf.select2.tokens.js
index 793fff8..2fa126a 100644
--- a/libs/ext.sf.select2.tokens.js
+++ b/libs/ext.sf.select2.tokens.js
@@ -59,11 +59,11 @@
var self = this;
var input_id = this.id;
var opts = {};
- var input_id = "#" + input_id;
+ input_id = "#" + input_id;
var input_tagname = $(input_id).prop( "tagName" );
var autocomplete_opts = this.getAutocompleteOpts();
- if ( autocomplete_opts.autocompletedatatype != undefined ) {
+ if ( autocomplete_opts.autocompletedatatype !== undefined ) {
opts.ajax = this.getAjaxOpts();
opts.minimumInputLength = 1;
opts.formatInputTooShort = "";
@@ -78,10 +78,11 @@
var no_diac_text =
sf.select2.base.prototype.removeDiacritics( text );
var position =
no_diac_text.toUpperCase().indexOf(term.toUpperCase());
var position_with_space =
no_diac_text.toUpperCase().indexOf(" " + term.toUpperCase());
- if ( (position != -1 && position == 0 ) ||
position_with_space != -1 )
+ if ( (position != -1 && position === 0 ) ||
position_with_space != -1 ) {
return true;
- else
+ } else {
return false;
+ }
};
}
opts.formatResult = this.formatResult;
@@ -91,13 +92,13 @@
if ( $(input_id).attr( "existingvaluesonly" ) !== "true" &&
input_tagname == "INPUT" ) {
opts.createSearchChoice = function( term, data ) { if (
$(data).filter(function() { return this.text.localeCompare( term )===0;
}).length===0 ) {return { id:term, text:term };} };
}
- if ( $(input_id).val() != "" && input_tagname == "INPUT" ) {
+ if ( $(input_id).val() !== "" && input_tagname == "INPUT" ) {
opts.initSelection = function ( element, callback ) {
var data = [];
var delim = self.getDelimiter($(input_id));
var i = 0;
$(element.val().trim().split(delim)).each(function () {
- if ( this != "" ) {
+ if ( this !== "" ) {
data.push({id: i, text: this});
i += 1;
}
@@ -107,7 +108,7 @@
};
}
var size = $(input_id).attr("size");
- if ( size == undefined ) {
+ if ( size === undefined ) {
size = 100; //default value
}
opts.containerCss = { 'min-width': size * 6 };
@@ -118,11 +119,15 @@
opts.tokenSeparators = this.getDelimiter($(input_id));
opts.openOnEnter = true;
var maxvalues = $(input_id).attr( "maxvalues" );
- if ( maxvalues != undefined ) {
+ if ( maxvalues !== undefined ) {
opts.maximumSelectionSize = maxvalues;
opts.formatSelectionTooBig = mw.msg(
"sf-select2-selection-too-big", maxvalues );
}
- opts.adaptContainerCssClass = function( clazz ) { if (clazz ==
"mandatoryField") return ""; };
+ opts.adaptContainerCssClass = function( clazz ) {
+ if (clazz == "mandatoryField") {
+ return "";
+ }
+ };
return opts;
};
@@ -136,17 +141,18 @@
tokens_proto.getData = function( autocompletesettings ) {
var input_id = "#" + this.id;
var values = [];
+ var data;
var dep_on = this.dependentOn();
- if ( dep_on == null ) {
+ if ( dep_on === null ) {
if ( autocompletesettings == 'external data' ) {
var name =
$(input_id).attr(this.nameAttr($(input_id)));
var sfgEDSettings = mw.config.get(
'sfgEDSettings' );
var edgValues = mw.config.get( 'edgValues' );
- var data = {};
- if ( sfgEDSettings[name].title != undefined &&
sfgEDSettings[name].title != "" ) {
+ data = {};
+ if ( sfgEDSettings[name].title !== undefined &&
sfgEDSettings[name].title !== "" ) {
data.title =
edgValues[sfgEDSettings[name].title];
i = 0;
- if ( data.title != undefined ) {
+ if ( data.title !== undefined &&
data.title !== null ) {
data.title.forEach(function() {
values.push({
id: i + 1, text:
data.title[i]
@@ -154,20 +160,20 @@
i++;
});
}
- if ( sfgEDSettings[name].image !=
undefined && sfgEDSettings[name].image != "" ) {
+ if ( sfgEDSettings[name].image !==
undefined && sfgEDSettings[name].image !== "" ) {
data.image =
edgValues[sfgEDSettings[name].image];
i = 0;
- if ( data.image != undefined ) {
+ if ( data.image !== undefined
&& data.image !== null ) {
data.image.forEach(function() {
values[i].image
= data.image[i];
i++;
});
}
}
- if ( sfgEDSettings[name].description !=
undefined && sfgEDSettings[name].description != "" ) {
+ if ( sfgEDSettings[name].description
!== undefined && sfgEDSettings[name].description !== "" ) {
data.description =
edgValues[sfgEDSettings[name].description];
i = 0;
- if ( data.description !=
undefined ) {
+ if ( data.description !==
undefined && data.description !== null ) {
data.description.forEach(function() {
values[i].description = data.description[i];
i++;
@@ -178,10 +184,10 @@
} else {
var sfgAutocompleteValues = mw.config.get(
'sfgAutocompleteValues' );
- var data =
sfgAutocompleteValues[autocompletesettings];
+ data =
sfgAutocompleteValues[autocompletesettings];
var i = 0;
//Convert data into the format accepted by
Select2
- if (data != undefined) {
+ if ( data !== undefined && data !== null ) {
data.forEach(function()
{
values.push({
@@ -222,7 +228,6 @@
*
*/
tokens_proto.getAjaxOpts = function() {
- var input_id = "#" + this.id;
var autocomplete_opts = this.getAutocompleteOpts();
var data_source =
autocomplete_opts.autocompletesettings.split(',')[0];
var my_server = mw.util.wikiScript( 'api' );
@@ -259,7 +264,7 @@
var tokens = new sf.select2.tokens();
var delim = tokens.getDelimiter( $(this) );
- if (data != null) {
+ if (data !== null) {
var tokens_value = "";
data.forEach( function( token ) {
tokens_value += token.text.trim() + delim + " ";
@@ -278,7 +283,7 @@
tokens_proto.getDelimiter = function ( element ) {
var field_values = element.attr('autocompletesettings').split(
',' );
var delimiter = ",";
- if (field_values[1] == 'list' && field_values[2] != null) {
+ if (field_values[1] == 'list' && field_values[2] !== undefined
) {
delimiter = field_values[2];
}
diff --git a/libs/jquery.browser.js b/libs/jquery.browser.js
index ab190f6..53df749 100644
--- a/libs/jquery.browser.js
+++ b/libs/jquery.browser.js
@@ -26,8 +26,8 @@
// Don't clobber any existing jQuery.browser in case it's different
if (!jQuery.browser) {
- matched = uaMatch(navigator.userAgent);
- browser = {};
+ var matched = uaMatch(navigator.userAgent);
+ var browser = {};
if (matched.browser) {
browser[ matched.browser ] = true;
diff --git a/libs/jquery.dynatree.js b/libs/jquery.dynatree.js
index 606f3dd..308ad00 100644
--- a/libs/jquery.dynatree.js
+++ b/libs/jquery.dynatree.js
@@ -430,15 +430,8 @@
}
// IE6 doesn't correctly evaluate multiple class names,
// so we create combined class names that can be used
in the CSS
- cnList.push(cn.combinedExpanderPrefix
- + (this.bExpanded ? "e" : "c")
- + (data.isLazy && this.childList ===
null ? "d" : "")
- + (isLastSib ? "l" : "")
- );
- cnList.push(cn.combinedIconPrefix
- + (this.bExpanded ? "e" : "c")
- + (data.isFolder ? "f" : "")
- );
+ cnList.push(cn.combinedExpanderPrefix +
(this.bExpanded ? "e" : "c") + (data.isLazy && this.childList === null ? "d" :
"") + (isLastSib ? "l" : ""));
+ cnList.push(cn.combinedIconPrefix +
(this.bExpanded ? "e" : "c") + (data.isFolder ? "f" : ""));
this.span.className = cnList.join(" ");
// TODO: we should not set this in the <span> tag also,
if we set it here:
@@ -1136,9 +1129,7 @@
}
}
// Do not apply animations in init phase, or before lazy-loading
- var allowEffects = !(this.data.isLazy && this.childList ===
null)
- && !this._isLoading
- && !forceSync;
+ var allowEffects = !(this.data.isLazy && this.childList ===
null) && !this._isLoading && !forceSync;
this.render(allowEffects);
// Auto-collapse mode: collapse all siblings
@@ -1519,8 +1510,7 @@
// We listen to this, if a callback was passed to reloadChildren
if(callback){
var self = this;
- var eventType = "nodeLoaded.dynatree." +
this.tree.$tree.attr("id")
- + "." + this.data.key;
+ var eventType = "nodeLoaded.dynatree." +
this.tree.$tree.attr("id") + "." + this.data.key;
this.tree.$tree.bind(eventType, function(e, node, isOk){
self.tree.$tree.unbind(eventType);
self.tree.logDebug("loaded %o, %o, %o", e,
node, isOk);
@@ -2851,8 +2841,7 @@
}else if(hitMode === "after" &&
otherNode && node === otherNode.getPrevSibling()){
// this.logDebug(" drop before
source node prevented");
hitMode = null;
- }else if(hitMode === "over" && otherNode
- && otherNode.parent ===
node && otherNode.isLastSibling() ){
+ }else if(hitMode === "over" &&
otherNode && otherNode.parent === node && otherNode.isLastSibling() ){
// this.logDebug(" drop last
child over own parent prevented");
hitMode = null;
}
@@ -2861,8 +2850,7 @@
ui.helper.data("hitMode", hitMode);
}
// Auto-expand node (only when 'over' the node, not
'before', or 'after')
- if(hitMode === "over"
- && dnd.autoExpandMS && node.hasChildren() !==
false && !node.bExpanded) {
+ if(hitMode === "over" && dnd.autoExpandMS &&
node.hasChildren() !== false && !node.bExpanded) {
node.scheduleAction("expand", dnd.autoExpandMS);
}
if(hitMode && dnd.onDragOver){
diff --git a/libs/jquery.fancybox.js b/libs/jquery.fancybox.js
index bcf92be..68d2865 100644
--- a/libs/jquery.fancybox.js
+++ b/libs/jquery.fancybox.js
@@ -373,7 +373,7 @@
if (wrap.is(":visible")) {
$( close.add( nav_left ).add( nav_right )
).hide();
- pos = wrap.position(),
+ pos = wrap.position();
start_pos = {
top : pos.top,
@@ -808,7 +808,7 @@
var rel = $(this).attr('rel') || '';
- if (!rel || rel == '' || rel === 'nofollow') {
+ if (!rel || rel === '' || rel === 'nofollow') {
selectedArray.push(this);
} else {
@@ -1071,7 +1071,7 @@
if (busy) {
e.preventDefault();
- } else if ($(e.target).get(0).clientHeight == 0
|| $(e.target).get(0).scrollHeight === $(e.target).get(0).clientHeight) {
+ } else if ($(e.target).get(0).clientHeight ===
0 || $(e.target).get(0).scrollHeight === $(e.target).get(0).clientHeight) {
e.preventDefault();
$.fancybox[ delta > 0 ? 'prev' :
'next']();
}
--
To view, visit https://gerrit.wikimedia.org/r/151970
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I40e5d3b7588f176909f152a4602f9423cf63d286
Gerrit-PatchSet: 8
Gerrit-Project: mediawiki/extensions/SemanticForms
Gerrit-Branch: master
Gerrit-Owner: Jatin <[email protected]>
Gerrit-Reviewer: Foxtrott <[email protected]>
Gerrit-Reviewer: Jatin <[email protected]>
Gerrit-Reviewer: Yaron Koren <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits