* Mostly whitespace in callers: $('foo').bar(baz,quux) => $( 'foo' ).bar( baz, quux )
* Also several occurrences of mixes spaces and tabs in the indention in front of a line, converted to tabs.
* And double spaces -> single spaces at random.
$el.text( $el.data( 'autoEllipsis.originalText' ) );
}
}
-
+
// container element - used for measuring against
var $container = $el;
// trimmable text element - only the text within this element will be trimmed
.empty()
.append( $trimmableText );
}
-
+
var text = $container.text();
var trimmableText = $trimmableText.text();
var w = $container.width();
return;
}
}
-
+
if ( $trimmableText.width() + pw > w ) {
switch ( options.position ) {
case 'right':
} else {
cache[text][w][options.position] = $container.html();
}
-
+
} );
};
// Based on key-event info from http://unixpapa.com/js/key.html
// jQuery should also normalize e.which to be consistent cross-browser,
// however the same check is still needed regardless of jQuery.
-
+
// Note: At the moment, for some older opera versions (~< 10.5)
// some special keys won't be recognized (aka left arrow key).
// Backspace will be, so not big issue.
-
+
if ( e.which === 0 || e.charCode === 0 || e.which === 8 ||
e.ctrlKey || e.altKey || e.metaKey )
{
if ( prevCheckbox !== null && e.shiftKey ) {
// Check or uncheck this one and all in-between checkboxes
$box.slice(
- Math.min( $box.index( prevCheckbox ), $box.index( e.target ) ),
- Math.max( $box.index( prevCheckbox ), $box.index( e.target ) ) + 1
- ).prop( {checked: e.target.checked ? true : false} );
+ Math.min( $box.index( prevCheckbox ), $box.index( e.target ) ),
+ Math.max( $box.index( prevCheckbox ), $box.index( e.target ) ) + 1
+ ).prop( 'checked', e.target.checked ? true : false );
}
// Either way, update the prevCheckbox variable to the one clicked now
prevCheckbox = e.target;
/* Public Methods */
$.client = {
-
+
/**
* Get an object containing information about the client.
*
}
// Use the cached version if possible
if ( profileCache[nav.userAgent] === undefined ) {
-
+
/* Configuration */
-
+
// Name of browsers or layout engines we don't recognize
var uk = 'unknown';
// Generic version digit
var x = 'x';
// Strings found in user agent strings that need to be conformed
- var wildUserAgents = [ 'Opera', 'Navigator', 'Minefield', 'KHTML', 'Chrome', 'PLAYSTATION 3'];
+ var wildUserAgents = ['Opera', 'Navigator', 'Minefield', 'KHTML', 'Chrome', 'PLAYSTATION 3'];
// Translations for conforming user agent strings
var userAgentTranslations = [
- // Tons of browsers lie about being something they are not
+ // Tons of browsers lie about being something they are not
[/(Firefox|MSIE|KHTML,\slike\sGecko|Konqueror)/, ''],
// Chrome lives in the shadow of Safari still
['Chrome Safari', 'Chrome'],
var platforms = ['win', 'mac', 'linux', 'sunos', 'solaris', 'iphone'];
// Translations for conforming operating system names
var platformTranslations = [['sunos', 'solaris']];
-
+
/* Methods */
-
+
// Performs multiple replacements on a string
var translate = function( source, translations ) {
for ( var i = 0; i < translations.length; i++ ) {
}
return source;
};
-
- /* Pre-processing */
-
+
+ /* Pre-processing */
+
var ua = nav.userAgent,
match,
name = uk,
}
// Everything will be in lowercase from now on
ua = ua.toLowerCase();
-
+
/* Extraction */
-
+
if ( match = new RegExp( '(' + names.join( '|' ) + ')' ).exec( ua ) ) {
name = translate( match[1], nameTranslations );
}
if ( match = new RegExp( '(' + versionPrefixes.join( '|' ) + ')' + versionSuffix ).exec( ua ) ) {
version = match[3];
}
-
+
/* Edge Cases -- did I mention about how user agent string lie? */
-
+
// Decode Safari's crazy 400+ version numbers
if ( name.match( /safari/ ) && version > 400 ) {
version = '2.0';
version = ua.match( /version\/([0-9\.]*)/i )[1] || 10;
}
var versionNumber = parseFloat( version, 10 ) || 0.0;
-
+
/* Caching */
-
+
profileCache[nav.userAgent] = {
'name': name,
'layout': layout,
}
return profileCache[nav.userAgent];
},
-
+
/**
* Checks the current browser against a support map object to determine if the browser has been black-listed or
* not. If the browser was not configured specifically it is assumed to work. It is assumed that the body
if( !this.length ) return this;
//merge options into the defaults
var $settings = $.extend( {}, $.collapsibleTabs.defaults, options );
-
+
this.each( function() {
var $this = $( this );
// add the element to our array of collapsible managers
$.collapsibleTabs.addData( $( this ) );
} );
} );
-
+
// if we haven't already bound our resize hanlder, bind it now
if( !$.collapsibleTabs.boundEvent ) {
$( window )
$.collapsibleTabs.instances.each( function() {
var $this = $( this ), data = $.collapsibleTabs.getSettings( $this );
if( data.shifting ) return;
-
+
// if the two navigations are colliding
if( $this.children( data.collapsible ).length > 0 && data.collapseCondition() ) {
-
+
$this.trigger( "beforeTabCollapse" );
// move the element to the dropdown menu
$.collapsibleTabs.moveToCollapsed( $this.children( data.collapsible + ':last' ) );
}
-
+
// if there are still moveable items in the dropdown menu,
// and there is sufficient space to place them in the tab container
if( $( data.collapsedContainer + ' ' + data.collapsible ).length > 0
fx.start = getColor( fx.elem, attr );
fx.end = $.colorUtil.getRGB( fx.end );
}
-
+
fx.elem.style[attr] = 'rgb(' + [
Math.max(Math.min( parseInt((fx.pos * (fx.end[0] - fx.start[0])) + fx.start[0]), 255), 0),
Math.max(Math.min( parseInt((fx.pos * (fx.end[1] - fx.start[1])) + fx.start[1]), 255), 0),
}
}
);
-
+
function getColor(elem, attr) {
var color;
// Keep going until we find an element that has color, or we hit the body
if ( color != '' && color != 'transparent' || $.nodeName(elem, 'body') )
- break;
+ break;
attr = 'backgroundColor';
} while ( elem = elem.parentNode );
return $.colorUtil.getRGB(color);
};
-
+
} )( jQuery );
// After this $defaultToggle is either null or a valid jQuery instance.
return;
}
-
+
var $containers = null;
if ( action == 'collapse' ) {
// Slide doens't work with tables, but fade does as of jQuery 1.1.3
// http://stackoverflow.com/questions/467336#920480
$containers = $collapsible.find( '>tbody>tr' );
- if ( $defaultToggle ) {
+ if ( $defaultToggle ) {
// Exclude tablerow containing togglelink
$containers.not( $defaultToggle.closest( 'tr' ) ).stop(true, true).fadeOut();
} else {
- if ( instantHide ) {
+ if ( instantHide ) {
$containers.hide();
} else {
$containers.stop( true, true ).fadeOut();
}
}
-
+
} else if ( $collapsible.is( 'ul' ) || $collapsible.is( 'ol' ) ) {
$containers = $collapsible.find( '> li' );
if ( $defaultToggle ) {
$containers.stop( true, true ).slideUp();
}
}
-
+
} else { // <div>, <p> etc.
var $collapsibleContent = $collapsible.find( '> .mw-collapsible-content' );
-
+
// If a collapsible-content is defined, collapse it
if ( $collapsibleContent.length ) {
if ( instantHide ) {
}
} else {
-
+
// Expand the element
if ( $collapsible.is( 'table' ) ) {
$containers = $collapsible.find( '>tbody>tr' );
} else {
$containers.stop(true, true).fadeIn();
}
-
+
} else if ( $collapsible.is( 'ul' ) || $collapsible.is( 'ol' ) ) {
$containers = $collapsible.find( '> li' );
if ( $defaultToggle ) {
} else {
$containers.stop( true, true ).slideDown();
}
-
+
} else { // <div>, <p> etc.
var $collapsibleContent = $collapsible.find( '> .mw-collapsible-content' );
-
+
// If a collapsible-content is defined, collapse it
if ( $collapsibleContent.length ) {
$collapsibleContent.slideDown();
$collapsible = $that.closest( '.mw-collapsible.mw-made-collapsible' ).toggleClass( 'mw-collapsed' );
e.preventDefault();
e.stopPropagation();
-
+
// It's expanded right now
if ( !$that.hasClass( 'mw-collapsible-toggle-collapsed' ) ) {
// Change link to "Show"
}
e.preventDefault();
e.stopPropagation();
-
+
// It's expanded right now
if ( !$that.hasClass( 'mw-collapsible-toggle-collapsed' ) ) {
// Change toggle to collapsed
var action = $collapsible.hasClass( 'mw-collapsed' ) ? 'expand' : 'collapse';
$collapsible.toggleClass( 'mw-collapsed' );
toggleElement( $collapsible, action, $that );
-
+
};
// Use custom text or default ?
} else {
$that.addClass( 'mw-made-collapsible' );
}
-
+
// Check if this element has a custom position for the toggle link
// (ie. outside the container or deeper inside the tree)
// Then: Locate the custom toggle link(s) and bind them
var thatId = $that.attr( 'id' ),
$customTogglers = $( '.' + thatId.replace( 'mw-customcollapsible', 'mw-customtoggle' ) );
mw.log( _fn + 'Found custom collapsible: #' + thatId );
-
+
// Double check that there is actually a customtoggle link
if ( $customTogglers.length ) {
$customTogglers.bind( 'click.mw-collapse', function( e ) {
} else {
mw.log( _fn + '#' + thatId + ': Missing toggler!' );
}
-
+
// Initial state
if ( $that.hasClass( 'mw-collapsed' ) ) {
$that.removeClass( 'mw-collapsed' );
}
// If this is not a custom case, do the default:
- // Wrap the contents add the toggle link
+ // Wrap the contents add the toggle link
} else {
// Elements are treated differently
// The toggle-link will be in one the the cells (td or th) of the first row
var $firstRowCells = $( 'tr:first th, tr:first td', that ),
$toggle = $firstRowCells.find( '> .mw-collapsible-toggle' );
-
+
// If theres no toggle link, add it to the last cell
if ( !$toggle.length ) {
$firstRowCells.eq(-1).prepend( $toggleLink );
toggleLinkPremade( $toggle, e );
} );
}
-
+
} else if ( $that.is( 'ul' ) || $that.is( 'ol' ) ) {
// The toggle-link will be in the first list-item
var $firstItem = $( 'li:first', $that),
$toggle = $firstItem.find( '> .mw-collapsible-toggle' );
-
+
// If theres no toggle link, add it
if ( !$toggle.length ) {
// Make sure the numeral order doesn't get messed up, force the first (soon to be second) item
// to be "1". Except if the value-attribute is already used.
// If no value was set WebKit returns "", Mozilla returns '-1', others return null or undefined.
var firstval = $firstItem.attr( 'value' );
- if ( firstval === undefined || !firstval || firstval == '-1' ) {
+ if ( firstval === undefined || !firstval || firstval == '-1' ) {
$firstItem.attr( 'value', '1' );
}
$that.prepend( $toggleLink.wrap( '<li class="mw-collapsible-toggle-li"></li>' ).parent() );
toggleLinkPremade( $toggle, e );
} );
}
-
+
} else { // <div>, <p> etc.
-
+
// The toggle-link will be the first child of the element
var $toggle = $that.find( '> .mw-collapsible-toggle' );
if ( !$that.find( '> .mw-collapsible-content' ).length ) {
$that.wrapInner( '<div class="mw-collapsible-content"></div>' );
}
-
+
// If theres no toggle link, add it
if ( !$toggle.length ) {
$that.prepend( $toggleLink );
'group': 'default',
'replace': false, // if true replaces any previous message in this group
'target': 'js-messagebox'
- }, options );
+ }, options );
var $target = $.messageBoxNew( { id: options.target } );
var groupID = options.target + '-' + options.group;
var $group = $( '#' + groupID );
// text somewhere in the middle of the placeholder string,
// we want to set the contents of the search box to the
// dropped text.
-
+
// IE wants getData( 'text' ) but Firefox wants getData( 'text/plain' )
// Firefox fails gracefully with an empty string, IE barfs with an error
try {
// Got an exception, so use the IE way
this.value = e.originalEvent.dataTransfer.getData( 'text' );
}
-
+
// On Firefox, drop fires after the dropped text has been inserted,
// but on IE it fires before. If we don't prevent the default action,
// IE will insert the dropped text twice.
( function( $ ) {
/**
* Finds the lowerst tabindex in use within a selection
- *
+ *
* @return number Lowest tabindex on the page
*/
$.fn.firstTabIndex = function() {
/**
* Finds the highest tabindex in use within a selection
- *
+ *
* @return number Highest tabindex on the page
*/
$.fn.lastTabIndex = function() {
if ( firstTime ) {
firstTime = false;
-
+
// Legacy fix of .sortbottoms
// Wrap them inside inside a tfoot (because that's what they actually want to be) &
// Move them up one level in the DOM
var sortbottoms = $table.find('tr.sortbottom').wrap('<tfoot>');
sortbottoms.parents('table').append(sortbottoms.parent());
-
+
explodeRowspans( $table );
// try to auto detect column type, and store in tables config
table.config.parsers = buildParserCache( table, $headers );
encapsulateSelection: function( options ) {
return this.each( function() {
var pre = options.pre, post = options.post;
-
+
/**
* Check if the selected text is the same as the insert text
*/
}
}
}
-
+
/**
* Do the splitlines stuff.
- *
+ *
* Wrap each line of the selected text with pre and post
*/
function doSplitLines( selText, pre, post ) {
}
return insertText;
}
-
+
var isSample = false;
if ( this.style.display == 'none' ) {
// Do nothing
var endPos = this.selectionEnd;
var scrollTop = this.scrollTop;
checkSelectedText();
-
- var insertText = pre + selText + post;
+
+ var insertText = pre + selText + post;
if ( options.splitlines ) {
insertText = doSplitLines( selText, pre, post );
}
var selText = $(this).textSelection( 'getSelection' );
var scrollTop = this.scrollTop;
var range = document.selection.createRange();
-
+
checkSelectedText();
- var insertText = pre + selText + post;
+ var insertText = pre + selText + post;
if ( options.splitlines ) {
insertText = doSplitLines( selText, pre, post );
}
post += "\n";
}
}
-
+
range.text = insertText;
if ( isSample && options.selectPeri && range.moveStart ) {
range.moveStart( 'character', - post.length - selText.length );
if ( newLines ) length = length - newLines.length;
selection.moveStart( 'character', options.start );
selection.moveEnd( 'character', -length + options.end );
-
+
// This line can cause an error under certain circumstances (textarea empty, no selection)
// Silence that error
try {
}
var context = $(this).data( 'wikiEditor-context' );
var hasIframe = typeof context !== 'undefined' && context && typeof context.$iframe !== 'undefined';
-
+
// IE selection restore voodoo
var needSave = false;
if ( hasIframe && context.savedSelection !== null ) {
$suggestionList,
url = mw.util.wikiScript( 'api' ),
maxRowWindow;
-
+
//Append the container which will hold the menu to the body
$( 'body' ).append( $container );
$legend.parent().show();
}
var ident = $legend.parent().attr( 'id' );
-
+
var $li = $( '<li/>', {
'class' : ( i === 0 ) ? 'selected' : null
});
var $a = $( '<a/>', {
text : $legend.text(),
- id : ident.replace('prefsection', 'preftab'),
+ id : ident.replace('prefsection', 'preftab'),
href : '#' + ident
}).click( function( e ) {
e.preventDefault();
var scrollTop = $(window).scrollTop();
window.location.hash = $(this).attr('href');
$(window).scrollTop(scrollTop);
-
+
$preftoc.find( 'li' ).removeClass( 'selected' );
$(this).parent().addClass( 'selected' );
$( '#preferences > fieldset' ).hide();
$tzTextbox.val( minutesToHours( minuteDiff ) );
$tzSelect.val( 'other' );
$tzTextbox.get( 0 ).disabled = false;
- } else if ( type == 'other' ) {
+ } else if ( type == 'other' ) {
// Grab data from the textbox, parse it.
minuteDiff = hoursToMinutes( $tzTextbox.val() );
} else {
var $select = null;
var rc = mw.special.recentchanges = {
-
+
/**
* Handler to disable/enable the namespace selector checkboxes when the
* special 'all' namespace is selected/unselected respectively.
*/
- updateCheckboxes: function() {
+ updateCheckboxes: function() {
// The option element for the 'all' namespace has an empty value
var isAllNS = ('' === $select.find('option:selected').val() );
init: function() {
// Populate
- $select = $( '#namespace' );
+ $select = $( '#namespace' );
// Bind to change event, and trigger once to set the initial state of the checkboxes.
$select.change( rc.updateCheckboxes ).change();
/**
- * Fixes sister projects box moving down the extract
+ * Fixes sister projects box moving down the extract
* of the first result (bug #16886).
- * It only happens when the window is small and
- * This changes slightly the layout for big screens
- * where there was space for the extracts and the
- * sister projects and thus it showed like in any
+ * It only happens when the window is small and
+ * This changes slightly the layout for big screens
+ * where there was space for the extracts and the
+ * sister projects and thus it showed like in any
* other browser.
*
* This will only affect IE 7 and lower
'</div>' );
thumb.find( '.filename' ).text( file.name ).end()
.find( '.fileinfo' ).text( prettySize( file.size ) ).end();
-
+
var ctx = thumb.find( 'canvas' )[0].getContext( '2d' ),
spinner = new Image();
- spinner.onload = function() {
- ctx.drawImage( spinner, (previewSize - spinner.width) / 2,
- (previewSize - spinner.height) / 2 );
+ spinner.onload = function() {
+ ctx.drawImage( spinner, (previewSize - spinner.width) / 2,
+ (previewSize - spinner.height) / 2 );
};
spinner.src = mw.config.get( 'wgScriptPath' ) + '/skins/common/images/spinner.gif';
$( '#mw-htmlform-source' ).parent().prepend( thumb );
fetchPreview( file, function( dataURL ) {
var img = new Image(),
rotation = 0;
-
+
if ( meta && meta.tiff && meta.tiff.Orientation ) {
rotation = (360 - function () {
// See includes/media/Bitmap.php
}
}() ) % 360;
}
-
+
img.onload = function() {
var width, height, x, y, dx, dy;
// Fit the image within the previewSizexpreviewSize box
dy = (180 - height) / 2;
switch ( rotation ) {
// If a rotation is applied, the direction of the axis
- // changes as well. You can derive the values below by
+ // changes as well. You can derive the values below by
// drawing on paper an axis system, rotate it and see
// where the positive axis direction is
case 0:
y = dy;
break;
case 90:
-
+
x = dx;
y = dy - previewSize;
break;
y = dy;
break;
}
-
+
ctx.clearRect( 0, 0, 180, 180 );
ctx.rotate( rotation / 180 * Math.PI );
ctx.drawImage( img, x, y, width, height );
-
+
// Image size
var info = mw.msg( 'widthheight', img.width, img.height ) +
', ' + prettySize( file.size );
function clearPreview() {
$( '#mw-upload-thumbnail' ).remove();
}
-
+
/**
* Check if the file does not exceed the maximum size
*/
return sizes['*'];
}
$( '.mw-upload-source-error' ).remove();
-
- var maxSize = getMaxUploadSize( 'file' );
+
+ var maxSize = getMaxUploadSize( 'file' );
if ( file.size > maxSize ) {
- var error = $( '<p class="error mw-upload-source-error" id="wpSourceTypeFile-error">' +
+ var error = $( '<p class="error mw-upload-source-error" id="wpSourceTypeFile-error">' +
mw.message( 'largefileserver', file.size, maxSize ).escaped() + '</p>' );
$( '#wpUploadFile' ).after( error );
return false;
}
return true;
}
-
-
+
+
/**
* Initialization
*/
if ( this.files && this.files.length ) {
// Note: would need to be updated to handle multiple files.
var file = this.files[0];
-
+
if ( !checkMaxUploadSize( file ) ) {
return;
}
-
+
if ( fileIsPreviewable( file ) ) {
showPreview( file );
}
/**
* Utility functions for jazzing up HTMLForm elements
*/
-( function( $ ) {
+( function( $ ) {
/**
* jQuery plugin to fade or snap to visible state.
}
return title;
};
-
+
/* Static space */
test( 'Special text', window.foo = function() {
expect(5);
- // http://en.wikipedia.org/wiki/UTF-8
+ // http://en.wikipedia.org/wiki/UTF-8
var U_0024 = '\u0024',
U_00A2 = '\u00A2',
U_20AC = '\u20AC',
byteLimitTest({
description: 'Plain text input',
$input: $( '<input>' )
- .attr( {
- 'type': 'text'
- }),
+ .attr( 'type', 'text' ),
sample: simpleSample,
hasLimit: false,
expected: simpleSample
byteLimitTest({
description: 'Limit using a custom value',
$input: $( '<input>' )
- .attr( {
- 'type': 'text'
- })
+ .attr( 'type', 'text' )
.byteLimit( 10 ),
sample: simpleSample,
hasLimit: true,
byteLimitTest({
description: 'Limit using a custom value (multibyte)',
$input: $( '<input>' )
- .attr( {
- 'type': 'text'
- })
+ .attr( 'type', 'text' )
.byteLimit( 14 ),
sample: mbSample,
hasLimit: true,
byteLimitTest({
description: 'Limit using a custom value (multibyte) overlapping a byte',
$input: $( '<input>' )
- .attr( {
- 'type': 'text'
- })
+ .attr( 'type', 'text' )
.byteLimit( 12 ),
sample: mbSample,
hasLimit: true,
byteLimitTest({
description: 'Pass the limit and a callback as input filter',
$input: $( '<input>' )
- .attr( {
- 'type': 'text'
- })
+ .attr( 'type', 'text' )
.byteLimit( 6, function( val ) {
_titleConfig();
"version": "4.0.1",
"versionBase": "4",
"versionNumber": 4
- }
+ }
},
// Firefox 5
// Safari 3
"version": "4.0.5",
"versionBase": "4",
"versionNumber": 4
- }
+ }
},
'Mozilla/5.0 (Windows; U; Windows NT 6.0; cs-CZ) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/4.0.5 Safari/531.22.7': {
title: 'Safari 4',
equal( $.trimLeft( ' foo bar ' ), 'foo bar ', 'trimLeft' );
equal( $.trimRight( ' foo bar ' ), ' foo bar', 'trimRight' );
- equal( $.ucFirst( 'foo'), 'Foo', 'ucFirst' );
+ equal( $.ucFirst( 'foo' ), 'Foo', 'ucFirst' );
equal( $.escapeRE( '<!-- ([{+mW+}]) $^|?>' ),
'<!\\-\\- \\(\\[\\{\\+mW\\+\\}\\]\\) \\$\\^\\|\\?>', 'escapeRE - Escape specials' );
module( 'jquery.tablesorter' );
// setup hack
-mw.config.set('wgMonthNames', window.wgMonthNames = ['', 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']);
-mw.config.set('wgMonthNamesShort', window.wgMonthNamesShort = ['', 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']);
-mw.config.set('wgDefaultDateFormat', window.wgDefaultDateFormat = 'dmy');
+mw.config.set( 'wgMonthNames', window.wgMonthNames = ['', 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']);
+mw.config.set( 'wgMonthNamesShort', window.wgMonthNamesShort = ['', 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']);
+mw.config.set( 'wgDefaultDateFormat', window.wgDefaultDateFormat = 'dmy' );
test( '-- Initial check', function() {
expect(1);
* @return jQuery
*/
var tableCreate = function( header, data ) {
- var $table = $('<table class="sortable"><thead></thead><tbody></tbody></table>'),
- $thead = $table.find('thead'),
- $tbody = $table.find('tbody');
- var $tr = $('<tr>');
- $.each(header, function(i, str) {
- var $th = $('<th>');
- $th.text(str).appendTo($tr);
+ var $table = $( '<table class="sortable"><thead></thead><tbody></tbody></table>' ),
+ $thead = $table.find( 'thead' ),
+ $tbody = $table.find( 'tbody' );
+ var $tr = $( '<tr>' );
+ $.each( header, function( i, str ) {
+ var $th = $( '<th>' );
+ $th.text( str ).appendTo( $tr );
});
- $tr.appendTo($thead);
+ $tr.appendTo( $thead );
for (var i = 0; i < data.length; i++) {
- $tr = $('<tr>');
- $.each(data[i], function(j, str) {
- var $td = $('<td>');
- $td.text(str).appendTo($tr);
+ $tr = $( '<tr>' );
+ $.each( data[i], function( j, str ) {
+ var $td = $( '<td>' );
+ $td.text( str ).appendTo( $tr );
});
- $tr.appendTo($tbody);
+ $tr.appendTo( $tbody );
}
return $table;
};
*/
var tableExtract = function( $table ) {
var data = [];
- $table.find('tbody').find('tr').each(function(i, tr) {
+ $table.find( 'tbody' ).find( 'tr' ).each( function( i, tr ) {
var row = [];
- $(tr).find('td,th').each(function(i, td) {
- row.push($(td).text());
+ $( tr ).find( 'td,th' ).each( function( i, td ) {
+ row.push( $( td ).text() );
});
- data.push(row);
+ data.push( row );
});
return data;
};
expect(1);
var $table = tableCreate( header, data );
- //$('body').append($table);
+ //$( 'body' ).append($table);
// Give caller a chance to set up sorting and manipulate the table.
callback( $table );
ascendingName,
function( $table ) {
$table.tablesorter();
- $table.find('.headerSort:eq(0)').click();
+ $table.find( '.headerSort:eq(0)' ).click();
}
);
tableTest(
ascendingName,
function( $table ) {
$table.tablesorter();
- $table.find('.headerSort:eq(0)').click();
+ $table.find( '.headerSort:eq(0)' ).click();
}
);
tableTest(
reversed(ascendingName),
function( $table ) {
$table.tablesorter();
- $table.find('.headerSort:eq(0)').click().click();
+ $table.find( '.headerSort:eq(0)' ).click().click();
}
);
tableTest(
ascendingRadius,
function( $table ) {
$table.tablesorter();
- $table.find('.headerSort:eq(1)').click();
+ $table.find( '.headerSort:eq(1)' ).click();
}
);
tableTest(
reversed(ascendingRadius),
function( $table ) {
$table.tablesorter();
- $table.find('.headerSort:eq(1)').click().click();
+ $table.find( '.headerSort:eq(1)' ).click().click();
}
);
],
function( $table ) {
// @fixme reset it at end or change module to allow us to override it
- mw.config.set('wgDefaultDateFormat', window.wgDefaultDateFormat = 'dmy');
+ mw.config.set( 'wgDefaultDateFormat', window.wgDefaultDateFormat = 'dmy' );
$table.tablesorter();
- $table.find('.headerSort:eq(0)').click();
+ $table.find( '.headerSort:eq(0)' ).click();
}
);
tableTest(
],
function( $table ) {
// @fixme reset it at end or change module to allow us to override it
- mw.config.set('wgDefaultDateFormat', window.wgDefaultDateFormat = 'mdy');
+ mw.config.set( 'wgDefaultDateFormat', window.wgDefaultDateFormat = 'mdy' );
$table.tablesorter();
- $table.find('.headerSort:eq(0)').click();
+ $table.find( '.headerSort:eq(0)' ).click();
}
);
ipv4Sorted,
function( $table ) {
$table.tablesorter();
- $table.find('.headerSort:eq(0)').click();
+ $table.find( '.headerSort:eq(0)' ).click();
}
);
tableTest(
reversed(ipv4Sorted),
function( $table ) {
$table.tablesorter();
- $table.find('.headerSort:eq(0)').click().click();
+ $table.find( '.headerSort:eq(0)' ).click().click();
}
);
umlautWords,
umlautWordsSorted,
function( $table ) {
- mw.config.set('tableSorterCollation', {'ä':'ae', 'ö' : 'oe', 'ß': 'ss', 'ü':'ue'});
+ mw.config.set( 'tableSorterCollation', {'ä':'ae', 'ö' : 'oe', 'ß': 'ss', 'ü':'ue'});
$table.tablesorter();
- $table.find('.headerSort:eq(0)').click();
- mw.config.set('tableSorterCollation', {});
+ $table.find( '.headerSort:eq(0)' ).click();
+ mw.config.set( 'tableSorterCollation', {} );
}
);
planetsRowspan,
function( $table ) {
//Quick&Dirty mod
- $table.find('tr:eq(3) td:eq(1), tr:eq(4) td:eq(1)').remove();
- $table.find('tr:eq(2) td:eq(1)').prop('rowspan', '3');
+ $table.find( 'tr:eq(3) td:eq(1), tr:eq(4) td:eq(1)' ).remove();
+ $table.find( 'tr:eq(2) td:eq(1)' ).prop( 'rowspan', '3' );
$table.tablesorter();
- $table.find('.headerSort:eq(0)').click();
+ $table.find( '.headerSort:eq(0)' ).click();
}
);
tableTest(
planetsRowspanII,
function( $table ) {
//Quick&Dirty mod
- $table.find('tr:eq(3) td:eq(0), tr:eq(4) td:eq(0)').remove();
- $table.find('tr:eq(2) td:eq(0)').prop('rowspan', '3');
+ $table.find( 'tr:eq(3) td:eq(0), tr:eq(4) td:eq(0)' ).remove();
+ $table.find( 'tr:eq(2) td:eq(0)' ).prop( 'rowspan', '3' );
$table.tablesorter();
- $table.find('.headerSort:eq(0)').click();
+ $table.find( '.headerSort:eq(0)' ).click();
}
);
complexMDYDates,
complexMDYSorted,
function( $table ) {
- mw.config.set('wgDefaultDateFormat', window.wgDefaultDateFormat = 'mdy');
+ mw.config.set( 'wgDefaultDateFormat', window.wgDefaultDateFormat = 'mdy' );
$table.tablesorter();
- $table.find('.headerSort:eq(0)').click();
+ $table.find( '.headerSort:eq(0)' ).click();
}
);
planets,
ascendingNameLegacy,
function( $table ) {
- $table.find('tr:last').addClass('sortbottom');
+ $table.find( 'tr:last' ).addClass( 'sortbottom' );
$table.tablesorter();
- $table.find('.headerSort:eq(0)').click();
+ $table.find( '.headerSort:eq(0)' ).click();
}
);
} );
/**
- * Test factory for $.fn.textSelection('encapsulateText')
+ * Test factory for $.fn.textSelection( 'encapsulateText' )
*
* @param options {object} associative array containing:
* description {string}
* output {string}
* start {int} starting char for selection
* end {int} ending char for selection
- * params {object} add'l parameters for $().textSelection('encapsulateText')
+ * params {object} add'l parameters for $().textSelection( 'encapsulateText' )
*/
var encapsulateTest = function( options ) {
var opt = $.extend({
}
expect(tests);
- var $fixture = $('<div id="qunit-fixture"></div>');
- var $textarea = $('<textarea>');
+ var $fixture = $( '<div id="qunit-fixture"></div>' );
+ var $textarea = $( '<textarea>' );
$fixture.append($textarea);
- $('body').append($fixture);
+ $( 'body' ).append($fixture);
//$textarea.textSelection( 'setContents', opt.before.text); // this method is actually missing atm...
$textarea.val( opt.before.text ); // won't work with the WikiEditor iframe?
test( '-- Initial check', function() {
expect( 2 );
- ok( mw.special.recentchanges.init,
- 'mw.special.recentchanges.init defined'
- );
- ok( mw.special.recentchanges.updateCheckboxes,
- 'mw.special.recentchanges.updateCheckboxes defined'
- );
+ ok( mw.special.recentchanges.init, 'mw.special.recentchanges.init defined' );
+ ok( mw.special.recentchanges.updateCheckboxes, 'mw.special.recentchanges.updateCheckboxes defined' );
// TODO: verify checkboxes == [ 'nsassociated', 'nsinvert' ]
});
$options.eq(1).removeProp( 'selected' );
$options.eq(0).prop( 'selected', true );
$( '#namespace' ).change();
-
+
// ... and checkboxes should now be disabled
strictEqual( $( '#nsinvert' ).prop( 'disabled' ), true );
strictEqual( $( '#nsassociated' ).prop( 'disabled' ), true );
// Extract path
var tests_path = rePath.exec( location.href );
- mw.loader.implement( 'is.awesome', [QUnit.fixurl( tests_path + 'data/defineTestCallback.js')], {}, {} );
+ mw.loader.implement( 'is.awesome', [QUnit.fixurl( tests_path + 'data/defineTestCallback.js' )], {}, {} );
mw.loader.using( 'is.awesome', function() {
var tbMW = mw.util.addPortletLink( 'p-tb', 'http://mediawiki.org/',
'MediaWiki.org', 't-mworg', 'Go to MediaWiki.org ', 'm', tbRL ),
$tbMW = $( tbMW );
-
+
equal( $tbMW.attr( 'id' ), 't-mworg', 'Link has correct ID set' );
equal( $tbMW.closest( '.portlet' ).attr( 'id' ), 'p-tb', 'Link was inserted within correct portlet' );
strictEqual( $tbMW.find( 'span').length, 0, 'No <span> element should be added for porlets without vectorTabs class.' );
strictEqual( $( caFoo ).find( 'span').length, 1, 'A <span> element should be added for porlets with vectorTabs class.' );
-
+
// Clean up
$( [tbRL, tbMW, tbRLDM, caFoo] )
.add( $mwPanel )