diff options
Diffstat (limited to 'resources/jquery/jquery.mwExtension.js')
-rw-r--r-- | resources/jquery/jquery.mwExtension.js | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/resources/jquery/jquery.mwExtension.js b/resources/jquery/jquery.mwExtension.js index 023ea7f3..bbffd7b7 100644 --- a/resources/jquery/jquery.mwExtension.js +++ b/resources/jquery/jquery.mwExtension.js @@ -1,26 +1,26 @@ /* * JavaScript backwards-compatibility alternatives and other convenience functions */ -( function( $ ) { +( function ( $ ) { $.extend({ - trimLeft: function( str ) { + trimLeft: function ( str ) { return str === null ? '' : str.toString().replace( /^\s+/, '' ); }, - trimRight: function( str ) { + trimRight: function ( str ) { return str === null ? '' : str.toString().replace( /\s+$/, '' ); }, - ucFirst: function( str ) { + ucFirst: function ( str ) { return str.charAt( 0 ).toUpperCase() + str.substr( 1 ); }, - escapeRE: function( str ) { - return str.replace ( /([\\{}()|.?*+\-^$\[\]])/g, "\\$1" ); + escapeRE: function ( str ) { + return str.replace ( /([\\{}()|.?*+\-\^$\[\]])/g, "\\$1" ); }, - isDomElement: function( el ) { + isDomElement: function ( el ) { return !!el && !!el.nodeType; }, - isEmpty: function( v ) { + isEmpty: function ( v ) { if ( v === '' || v === 0 || v === '0' || v === null || v === false || v === undefined ) { @@ -39,8 +39,8 @@ } return false; }, - compareArray: function( arrThis, arrAgainst ) { - if ( arrThis.length != arrAgainst.length ) { + compareArray: function ( arrThis, arrAgainst ) { + if ( arrThis.length !== arrAgainst.length ) { return false; } for ( var i = 0; i < arrThis.length; i++ ) { @@ -54,25 +54,25 @@ } return true; }, - compareObject: function( objectA, objectB ) { + compareObject: function ( objectA, objectB ) { + var prop, type; // Do a simple check if the types match - if ( typeof objectA == typeof objectB ) { + if ( typeof objectA === typeof objectB ) { // Only loop over the contents if it really is an object - if ( typeof objectA == 'object' ) { + if ( typeof objectA === 'object' ) { // If they are aliases of the same object (ie. mw and mediaWiki) return now if ( objectA === objectB ) { return true; } else { - var prop; // Iterate over each property for ( prop in objectA ) { // Check if this property is also present in the other object if ( prop in objectB ) { // Compare the types of the properties - var type = typeof objectA[prop]; - if ( type == typeof objectB[prop] ) { + type = typeof objectA[prop]; + if ( type === typeof objectB[prop] ) { // Recursively check objects inside this one switch ( type ) { case 'object' : @@ -118,4 +118,4 @@ } }); -} )( jQuery ); +}( jQuery ) ); |