Consistent use the same IIFE style in javascript
[lhc/web/wiklou.git] / resources / src / mediawiki / mediawiki.util.js
index a5bc7d9..f09d03c 100644 (file)
@@ -57,7 +57,7 @@
 
                                // Make sure we don't unset util.$content if it was preset and we don't find anything
                                return util.$content;
-                       } )();
+                       }() );
                },
 
                /* Main body */
                        return null;
                },
 
-               /**
-                * @property {string}
-                * Access key prefix.
-                */
-               tooltipAccessKeyPrefix: ( function () {
-                       var profile = $.client.profile();
-
-                       // Opera on any platform
-                       if ( profile.name === 'opera' ) {
-                               return 'shift-esc-';
-                       }
-
-                       // Chrome on any platform
-                       if ( profile.name === 'chrome' ) {
-                               if ( profile.platform === 'mac' ) {
-                                       // Chrome on Mac
-                                       return 'ctrl-option-';
-                               }
-                               // Chrome on Windows or Linux
-                               // (both alt- and alt-shift work, but alt with E, D, F etc does not
-                               // work since they are browser shortcuts)
-                               return 'alt-shift-';
-                       }
-
-                       // Non-Windows Safari with webkit_version > 526
-                       if ( profile.platform !== 'win'
-                               && profile.name === 'safari'
-                               && profile.layoutVersion > 526
-                       ) {
-                               return 'ctrl-alt-';
-                       }
-
-                       // Firefox 14+ on Mac
-                       if ( profile.platform === 'mac'
-                               && profile.name === 'firefox'
-                               && profile.versionNumber >= 14
-                       ) {
-                               return 'ctrl-option-';
-                       }
-
-                       // Safari/Konqueror on any platform, or any browser on Mac
-                       // (but not Safari on Windows)
-                       if ( !( profile.platform === 'win' && profile.name === 'safari' )
-                               && ( profile.name === 'safari'
-                               || profile.platform === 'mac'
-                               || profile.name === 'konqueror' )
-                       ) {
-                               return 'ctrl-';
-                       }
-
-                       // Firefox/Iceweasel 2.x and later
-                       if ( ( profile.name === 'firefox' || profile.name === 'iceweasel' )
-                               && profile.versionBase > '1' ) {
-                               return 'alt-shift-';
-                       }
-
-                       return 'alt-';
-               } )(),
-
-               /**
-                * @property {RegExp}
-                * Regex to match accesskey tooltips.
-                *
-                * Should match:
-                *
-                * - "ctrl-option-"
-                * - "alt-shift-"
-                * - "ctrl-alt-"
-                * - "ctrl-"
-                *
-                * The accesskey is matched in group $6.
-                */
-               tooltipAccessKeyRegexp: /\[(ctrl-)?(option-)?(alt-)?(shift-)?(esc-)?(.)\]$/,
-
                /**
                 * Add the appropriate prefix to the accesskey shown in the tooltip.
                 *
                                $nodes = $( $nodes );
                        }
 
-                       $nodes.attr( 'title', function ( i, val ) {
-                               if ( val && util.tooltipAccessKeyRegexp.test( val ) ) {
-                                       return val.replace( util.tooltipAccessKeyRegexp,
-                                               '[' + util.tooltipAccessKeyPrefix + '$6]' );
-                               }
-                               return val;
-                       } );
+                       $nodes.updateTooltipAccessKeys();
                },
 
                /*
                                $item.attr( 'id', id );
                        }
 
-                       if ( tooltip ) {
-                               // Trim any existing accesskey hint and the trailing space
-                               tooltip = $.trim( tooltip.replace( util.tooltipAccessKeyRegexp, '' ) );
-                               if ( accesskey ) {
-                                       tooltip += ' [' + accesskey + ']';
-                               }
-                               $link.attr( 'title', tooltip );
-                               if ( accesskey ) {
-                                       util.updateTooltipAccessKeys( $link );
-                               }
-                       }
-
                        if ( accesskey ) {
                                $link.attr( 'accesskey', accesskey );
                        }
 
+                       if ( tooltip ) {
+                               $link.attr( 'title', tooltip ).updateTooltipAccessKeys();
+                       }
+
                        if ( nextnode ) {
                                if ( nextnode.nodeType || typeof nextnode === 'string' ) {
                                        // nextnode is a DOM element (was the only option before MW 1.17, in wikibits.js)
 
                },
 
-               /**
-                * Add a little box at the top of the screen to inform the user of
-                * something, replacing any previous message.
-                * Calling with no arguments, with an empty string or null will hide the message
-                *
-                * @param {Mixed} message The DOM-element, jQuery object or HTML-string to be put inside the message box.
-                * to allow CSS/JS to hide different boxes. null = no class used.
-                * @deprecated since 1.20 Use mw#notify
-                */
-               jsMessage: function ( message ) {
-                       if ( !arguments.length || message === '' || message === null ) {
-                               return true;
-                       }
-                       if ( typeof message !== 'object' ) {
-                               message = $.parseHTML( message );
-                       }
-                       mw.notify( message, { autoHide: true, tag: 'legacy' } );
-                       return true;
-               },
-
                /**
                 * Validate a string as representing a valid e-mail address
                 * according to HTML5 specification. Please note the specification
         */
        mw.log.deprecate( util, 'wikiGetlink', util.getUrl, 'Use mw.util.getUrl instead.' );
 
+       /**
+        * @property {string} tooltipAccessKeyPrefix
+        * Access key prefix. Might be wrong for browsers implementing the accessKeyLabel property.
+        * @deprecated since 1.24 Use the module jquery.accessKeyLabel instead.
+        */
+       mw.log.deprecate( util, 'tooltipAccessKeyPrefix', $.fn.updateTooltipAccessKeys.getAccessKeyPrefix(), 'Use jquery.accessKeyLabel instead.' );
+
+       /**
+        * @property {RegExp} tooltipAccessKeyRegexp
+        * Regex to match accesskey tooltips.
+        *
+        * Should match:
+        *
+        * - "ctrl-option-"
+        * - "alt-shift-"
+        * - "ctrl-alt-"
+        * - "ctrl-"
+        *
+        * The accesskey is matched in group $6.
+        *
+        * Will probably not work for browsers implementing the accessKeyLabel property.
+        *
+        * @deprecated since 1.24 Use the module jquery.accessKeyLabel instead.
+        */
+       mw.log.deprecate( util, 'tooltipAccessKeyRegexp', /\[(ctrl-)?(option-)?(alt-)?(shift-)?(esc-)?(.)\]$/, 'Use jquery.accessKeyLabel instead.' );
+
+       /**
+        * @method jsMessage
+        * Add a little box at the top of the screen to inform the user of
+        * something, replacing any previous message.
+        * Calling with no arguments, with an empty string or null will hide the message
+        *
+        * @param {Mixed} message The DOM-element, jQuery object or HTML-string to be put inside the message box.
+        * to allow CSS/JS to hide different boxes. null = no class used.
+        * @deprecated since 1.20 Use mw#notify
+        */
+       mw.log.deprecate( util, 'jsMessage', function ( message ) {
+               if ( !arguments.length || message === '' || message === null ) {
+                       return true;
+               }
+               if ( typeof message !== 'object' ) {
+                       message = $.parseHTML( message );
+               }
+               mw.notify( message, { autoHide: true, tag: 'legacy' } );
+               return true;
+       }, 'Use mw.notify instead.' );
+
        mw.util = util;
 
 }( mediaWiki, jQuery ) );