diff options
Diffstat (limited to 'resources/src/mediawiki.page')
8 files changed, 189 insertions, 38 deletions
diff --git a/resources/src/mediawiki.page/mediawiki.page.gallery.css b/resources/src/mediawiki.page/mediawiki.page.gallery.css new file mode 100644 index 00000000..20deb214 --- /dev/null +++ b/resources/src/mediawiki.page/mediawiki.page.gallery.css @@ -0,0 +1,101 @@ +/* Galleries */ +/* These display attributes look nonsensical, but are needed to support IE and FF2 */ +/* Don't forget to update mediawiki.page.gallery.print.css */ +li.gallerybox { + vertical-align: top; + display: -moz-inline-box; + display: inline-block; +} + +ul.gallery, +li.gallerybox { + zoom: 1; + *display: inline; +} + +ul.gallery { + margin: 2px; + padding: 2px; + display: block; +} + +li.gallerycaption { + font-weight: bold; + text-align: center; + display: block; + word-wrap: break-word; +} + +li.gallerybox div.thumb { + text-align: center; + border: 1px solid #ccc; + background-color: #f9f9f9; + margin: 2px; +} + +li.gallerybox div.thumb img { + display: block; + margin: 0 auto; +} + +div.gallerytext { + overflow: hidden; + font-size: 94%; + padding: 2px 4px; + word-wrap: break-word; +} + +/* new gallery stuff */ +ul.mw-gallery-nolines li.gallerybox div.thumb { + background-color: transparent; + border: none; +} + +ul.mw-gallery-nolines li.gallerybox div.gallerytext { + text-align: center; +} + +/* height constrained gallery */ + +ul.mw-gallery-packed li.gallerybox div.thumb, +ul.mw-gallery-packed-overlay li.gallerybox div.thumb, +ul.mw-gallery-packed-hover li.gallerybox div.thumb { + background-color: transparent; + border: none; +} + +ul.mw-gallery-packed li.gallerybox div.thumb img, +ul.mw-gallery-packed-overlay li.gallerybox div.thumb img, +ul.mw-gallery-packed-hover li.gallerybox div.thumb img { + margin: 0 auto; +} + +ul.mw-gallery-packed-hover li.gallerybox, +ul.mw-gallery-packed-overlay li.gallerybox { + position: relative; +} + +ul.mw-gallery-packed-hover div.gallerytextwrapper { + overflow: hidden; + height: 0; +} + +ul.mw-gallery-packed-hover li.gallerybox:hover div.gallerytextwrapper, +ul.mw-gallery-packed-overlay li.gallerybox div.gallerytextwrapper, +ul.mw-gallery-packed-hover li.gallerybox.mw-gallery-focused div.gallerytextwrapper { + position: absolute; + background: white; + background: rgba(255, 255, 255, 0.8); + padding: 5px 10px; + bottom: 0; + left: 0; /* Needed for IE */ + height: auto; + font-weight: bold; + margin: 2px; /* correspond to style on div.thumb */ +} + +ul.mw-gallery-packed-hover, +ul.mw-gallery-packed-overlay, +ul.mw-gallery-packed { + text-align: center; +} diff --git a/resources/src/mediawiki.page/mediawiki.page.gallery.js b/resources/src/mediawiki.page/mediawiki.page.gallery.js index 95140704..dfccf215 100644 --- a/resources/src/mediawiki.page/mediawiki.page.gallery.js +++ b/resources/src/mediawiki.page/mediawiki.page.gallery.js @@ -12,6 +12,7 @@ /** * Perform the layout justification. + * * @ignore * @context {HTMLElement} A `ul.mw-gallery-*` element */ @@ -30,14 +31,14 @@ $this = $( this ); if ( top !== lastTop ) { - rows[rows.length] = []; + rows[ rows.length ] = []; lastTop = top; } $img = $this.find( 'div.thumb a.image img' ); - if ( $img.length && $img[0].height ) { - imgHeight = $img[0].height; - imgWidth = $img[0].width; + if ( $img.length && $img[ 0 ].height ) { + imgHeight = $img[ 0 ].height; + imgWidth = $img[ 0 ].width; } else { // If we don't have a real image, get the containing divs width/height. // Note that if we do have a real image, using this method will generally @@ -54,7 +55,7 @@ } captionWidth = $this.children().children( 'div.gallerytextwrapper' ).width(); - rows[rows.length - 1][rows[rows.length - 1].length] = { + rows[ rows.length - 1 ][ rows[ rows.length - 1 ].length ] = { $elm: $this, width: $this.outerWidth(), imgWidth: imgWidth, @@ -96,25 +97,25 @@ maxWidth = $gallery.width(); combinedAspect = 0; combinedPadding = 0; - curRow = rows[i]; + curRow = rows[ i ]; curRowHeight = 0; for ( j = 0; j < curRow.length; j++ ) { if ( curRowHeight === 0 ) { - if ( isFinite( curRow[j].height ) ) { + if ( isFinite( curRow[ j ].height ) ) { // Get the height of this row, by taking the first // non-out of bounds height - curRowHeight = curRow[j].height; + curRowHeight = curRow[ j ].height; } } - if ( curRow[j].aspect === 0 || !isFinite( curRow[j].aspect ) ) { + if ( curRow[ j ].aspect === 0 || !isFinite( curRow[ j ].aspect ) ) { // One of the dimensions are 0. Probably should // not try to resize. - combinedPadding += curRow[j].width; + combinedPadding += curRow[ j ].width; } else { - combinedAspect += curRow[j].aspect; - combinedPadding += curRow[j].width - curRow[j].imgWidth; + combinedAspect += curRow[ j ].aspect; + combinedPadding += curRow[ j ].width - curRow[ j ].imgWidth; } } @@ -162,13 +163,13 @@ } for ( j = 0; j < curRow.length; j++ ) { - newWidth = preferredHeight * curRow[j].aspect; - padding = curRow[j].width - curRow[j].imgWidth; - $outerDiv = curRow[j].$elm; + newWidth = preferredHeight * curRow[ j ].aspect; + padding = curRow[ j ].width - curRow[ j ].imgWidth; + $outerDiv = curRow[ j ].$elm; $innerDiv = $outerDiv.children( 'div' ).first(); $imageDiv = $innerDiv.children( 'div.thumb' ); $imageElm = $imageDiv.find( 'img' ).first(); - imageElm = $imageElm.length ? $imageElm[0] : null; + imageElm = $imageElm.length ? $imageElm[ 0 ] : null; $caption = $outerDiv.find( 'div.gallerytextwrapper' ); // Since we are going to re-adjust the height, the vertical @@ -187,7 +188,7 @@ $outerDiv.width( newWidth + padding ); $innerDiv.width( newWidth + padding ); $imageDiv.width( newWidth ); - $caption.width( curRow[j].captionWidth + ( newWidth - curRow[j].imgWidth ) ); + $caption.width( curRow[ j ].captionWidth + ( newWidth - curRow[ j ].imgWidth ) ); } if ( imageElm ) { @@ -220,7 +221,7 @@ $( this ).find( 'div.gallerytextwrapper' ).width( captionWidth ); $imageElm = $( this ).find( 'img' ).first(); - imageElm = $imageElm.length ? $imageElm[0] : null; + imageElm = $imageElm.length ? $imageElm[ 0 ] : null; if ( imageElm ) { imageElm.width = imgWidth; imageElm.height = imgHeight; diff --git a/resources/src/mediawiki.page/mediawiki.page.gallery.print.css b/resources/src/mediawiki.page/mediawiki.page.gallery.print.css new file mode 100644 index 00000000..0c14865e --- /dev/null +++ b/resources/src/mediawiki.page/mediawiki.page.gallery.print.css @@ -0,0 +1,35 @@ +li.gallerybox { + vertical-align: top; + display: inline-block; +} + +ul.gallery, li.gallerybox { + zoom: 1; + *display: inline; +} + +ul.gallery { + margin: 2px; + padding: 2px; + display: block; +} + +li.gallerycaption { + font-weight: bold; + text-align: center; + display: block; + word-wrap: break-word; +} + +li.gallerybox div.thumb { + text-align: center; + border: 1px solid #ccc; + margin: 2px; +} + +div.gallerytext { + overflow: hidden; + font-size: 94%; + padding: 2px 4px; + word-wrap: break-word; +} diff --git a/resources/src/mediawiki.page/mediawiki.page.image.pagination.js b/resources/src/mediawiki.page/mediawiki.page.image.pagination.js index 9ad9c30a..49a51dfc 100644 --- a/resources/src/mediawiki.page/mediawiki.page.image.pagination.js +++ b/resources/src/mediawiki.page/mediawiki.page.image.pagination.js @@ -2,6 +2,7 @@ * Implement AJAX navigation for multi-page images so the user may browse without a full page reload. */ ( function ( mw, $ ) { + /*jshint latedef:false */ var jqXhr, $multipageimage, $spinner, cache = {}, cacheOrder = []; @@ -18,11 +19,11 @@ jqXhr = undefined; // Try the cache - if ( cache[url] ) { + if ( cache[ url ] ) { // Update access freshness cacheOrder.splice( $.inArray( url, cacheOrder ), 1 ); cacheOrder.push( url ); - return $.Deferred().resolve( cache[url] ).promise(); + return $.Deferred().resolve( cache[ url ] ).promise(); } // @todo Don't fetch the entire page. Ideally we'd only fetch the content portion or the data @@ -36,12 +37,12 @@ jqXhr = undefined; // Cache the newly loaded page - cache[url] = $contents; + cache[ url ] = $contents; cacheOrder.push( url ); // Remove the oldest entry if we're over the limit if ( cacheOrder.length > 10 ) { - delete cache[ cacheOrder[0] ]; + delete cache[ cacheOrder[ 0 ] ]; cacheOrder = cacheOrder.slice( 1 ); } } ); diff --git a/resources/src/mediawiki.page/mediawiki.page.patrol.ajax.js b/resources/src/mediawiki.page/mediawiki.page.patrol.ajax.js index cc72e168..f9b0d356 100644 --- a/resources/src/mediawiki.page/mediawiki.page.patrol.ajax.js +++ b/resources/src/mediawiki.page/mediawiki.page.patrol.ajax.js @@ -17,7 +17,7 @@ var $spinner, href, rcid, apiRequest; // Start preloading the notification module (normally loaded by mw.notify()) - mw.loader.load( ['mediawiki.notification'], null, true ); + mw.loader.load( 'mediawiki.notification' ); // Hide the link and create a spinner to show it inside the brackets. $spinner = $.createSpinner( { @@ -43,7 +43,7 @@ mw.notify( mw.msg( 'markedaspatrollednotify', title.toText() ) ); } else { // This should never happen as errors should trigger fail - mw.notify( mw.msg( 'markedaspatrollederrornotify' ) ); + mw.notify( mw.msg( 'markedaspatrollederrornotify' ), { type: 'error' } ); } } ) .fail( function ( error ) { @@ -53,9 +53,9 @@ $patrolLinks.show(); if ( error === 'noautopatrol' ) { // Can't patrol own - mw.notify( mw.msg( 'markedaspatrollederror-noautopatrol' ) ); + mw.notify( mw.msg( 'markedaspatrollederror-noautopatrol' ), { type: 'warn' } ); } else { - mw.notify( mw.msg( 'markedaspatrollederrornotify' ) ); + mw.notify( mw.msg( 'markedaspatrollederrornotify' ), { type: 'error' } ); } } ); diff --git a/resources/src/mediawiki.page/mediawiki.page.ready.js b/resources/src/mediawiki.page/mediawiki.page.ready.js index 36eb9d4f..9505bdd1 100644 --- a/resources/src/mediawiki.page/mediawiki.page.ready.js +++ b/resources/src/mediawiki.page/mediawiki.page.ready.js @@ -59,6 +59,17 @@ } $nodes.updateTooltipAccessKeys(); + // Infuse OOUI widgets, if any are present + $nodes = $( '[data-ooui]' ); + if ( $nodes.length ) { + // FIXME: We should only load the widgets that are being infused + mw.loader.using( [ 'mediawiki.widgets', 'mediawiki.widgets.UserInputWidget' ] ).done( function () { + $nodes.each( function () { + OO.ui.infuse( this ); + } ); + } ); + } + } ); }( mediaWiki, jQuery ) ); diff --git a/resources/src/mediawiki.page/mediawiki.page.startup.js b/resources/src/mediawiki.page/mediawiki.page.startup.js index ddd4f0c4..708dcb5c 100644 --- a/resources/src/mediawiki.page/mediawiki.page.startup.js +++ b/resources/src/mediawiki.page/mediawiki.page.startup.js @@ -1,12 +1,11 @@ ( function ( mw, $ ) { - mw.page = {}; + // Support: MediaWiki < 1.26 + // Cached HTML will not yet have this from OutputPage::getHeadScripts. + document.documentElement.className = document.documentElement.className + .replace( /(^|\s)client-nojs(\s|$)/, '$1client-js$2' ); - // Client profile classes for <html> - // Allows for easy hiding/showing of JS or no-JS-specific UI elements - $( document.documentElement ) - .addClass( 'client-js' ) - .removeClass( 'client-nojs' ); + mw.page = {}; $( function () { mw.util.init(); diff --git a/resources/src/mediawiki.page/mediawiki.page.watch.ajax.js b/resources/src/mediawiki.page/mediawiki.page.watch.ajax.js index d252f0e4..a3197da3 100644 --- a/resources/src/mediawiki.page/mediawiki.page.watch.ajax.js +++ b/resources/src/mediawiki.page/mediawiki.page.watch.ajax.js @@ -84,12 +84,12 @@ actionPaths = mw.config.get( 'wgActionPaths' ); for ( key in actionPaths ) { if ( actionPaths.hasOwnProperty( key ) ) { - parts = actionPaths[key].split( '$1' ); + parts = actionPaths[ key ].split( '$1' ); for ( i = 0; i < parts.length; i++ ) { - parts[i] = $.escapeRE( parts[i] ); + parts[ i ] = mw.RegExp.escape( parts[ i ] ); } m = new RegExp( parts.join( '(.+)' ) ).exec( url ); - if ( m && m[1] ) { + if ( m && m[ 1 ] ) { return key; } @@ -116,7 +116,7 @@ var action, api, $link; // Start preloading the notification module (normally loaded by mw.notify()) - mw.loader.load( ['mediawiki.notification'], null, true ); + mw.loader.load( 'mediawiki.notification' ); action = mwUriGetAction( this.href ); @@ -138,7 +138,7 @@ api = new mw.Api(); - api[action]( title ) + api[ action ]( title ) .done( function ( watchResponse ) { var otherAction = action === 'watch' ? 'unwatch' : 'watch'; @@ -170,7 +170,10 @@ msg = mw.message( 'watcherrortext', link ); // Report to user about the error - mw.notify( msg, { tag: 'watch-self' } ); + mw.notify( msg, { + tag: 'watch-self', + type: 'error' + } ); } ); } ); } ); |