Merge "mediawiki.Title: Add 'params' parameter to #getUrl"
[lhc/web/wiklou.git] / resources / mediawiki / mediawiki.Title.js
index 346ab33..e1031c6 100644 (file)
         *     var title = mw.Title.newFromImg( $( 'img:first' ) );
         *
         * @static
-        * @param {HTMLImageElement|jQuery} img The image to use as a base.
-        * @return {mw.Title|null} The file title - null if unsuccessful.
+        * @param {HTMLElement|jQuery} img The image to use as a base
+        * @return {mw.Title|null} The file title or null if unsuccessful
         */
        Title.newFromImg = function ( img ) {
                var matches, i, regex, src, decodedSrc,
 
                        // thumb.php-generated thumbnails
                        thumbPhpRegex = /thumb\.php/,
-
                        regexes = [
                                // Thumbnails
-                               /\/[a-f0-9]\/[a-f0-9]{2}\/([^\s\/]+)\/[0-9]+px-\1[^\s\/]*$/,
+                               /\/[a-f0-9]\/[a-f0-9]{2}\/([^\s\/]+)\/[^\s\/]+-(?:\1|thumbnail)[^\s\/]*$/,
 
                                // Thumbnails in non-hashed upload directories
-                               /\/([^\s\/]+)\/[0-9]+px-\1[^\s\/]*$/,
+                               /\/([^\s\/]+)\/[^\s\/]+-(?:\1|thumbnail)[^\s\/]*$/,
 
                                // Full size images
                                /\/[a-f0-9]\/[a-f0-9]{2}\/([^\s\/]+)$/,
 
                        recount = regexes.length;
 
-               img = img.jquery ? img.get( 0 ) : img;
-
-               src = img.src;
+               src = img.jquery ? img[0].src : img.src;
 
                matches = src.match( thumbPhpRegex );
 
                /**
                 * Get the URL to this title
                 *
-                * @see mw.util#wikiGetlink
+                * @see mw.util#getUrl
+                * @param {Object} [params] A mapping of query parameter names to values,
+                *     e.g. `{ action: 'edit' }`.
                 * @return {string}
                 */
-               getUrl: function () {
-                       return mw.util.wikiGetlink( this.toString() );
+               getUrl: function ( params ) {
+                       return mw.util.getUrl( this.toString(), params );
                },
 
                /**