From 57f801f1de95ce3731c443d35886fbcda989f3a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Tue, 12 Apr 2016 15:10:22 -0400 Subject: [PATCH 001/136] Menu: Don't reset active element until after triggering `blur` event This ensures that `ui.item` actually exists in the `blur` event. Fixes #14945 Closes gh-1696 --- tests/unit/menu/events.js | 16 ++++++++++------ ui/widgets/menu.js | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/tests/unit/menu/events.js b/tests/unit/menu/events.js index 1500c3478..4d2af394f 100644 --- a/tests/unit/menu/events.js +++ b/tests/unit/menu/events.js @@ -48,20 +48,22 @@ test( "handle click on custom item menu", function() { } ); asyncTest( "handle blur", function() { - expect( 1 ); + expect( 2 ); var blurHandled = false, + index = 1, element = $( "#menu1" ).menu( { - blur: function( event ) { + blur: function( event, ui ) { // Ignore duplicate blur event fired by IE if ( !blurHandled ) { blurHandled = true; equal( event.type, "menublur", "blur event.type is 'menublur'" ); + strictEqual( ui.item[ 0 ], element.children()[ index ], "ui.item" ); } } } ); - click( element, "1" ); + click( element, index ); setTimeout( function() { element.trigger( "blur" ); setTimeout( function() { @@ -71,20 +73,22 @@ asyncTest( "handle blur", function() { } ); asyncTest( "handle blur via click outside", function() { - expect( 1 ); + expect( 2 ); var blurHandled = false, + index = 1, element = $( "#menu1" ).menu( { - blur: function( event ) { + blur: function( event, ui ) { // Ignore duplicate blur event fired by IE if ( !blurHandled ) { blurHandled = true; equal( event.type, "menublur", "blur event.type is 'menublur'" ); + strictEqual( ui.item[ 0 ], element.children()[ index ], "ui.item" ); } } } ); - click( element, "1" ); + click( element, index ); setTimeout( function() { $( "", { id: "remove" } ).appendTo( "body" ).trigger( "click" ); setTimeout( function() { diff --git a/ui/widgets/menu.js b/ui/widgets/menu.js index f63105fa7..22db41988 100644 --- a/ui/widgets/menu.js +++ b/ui/widgets/menu.js @@ -434,9 +434,9 @@ return $.widget( "ui.menu", { this._removeClass( this.active.children( ".ui-menu-item-wrapper" ), null, "ui-state-active" ); - this.active = null; this._trigger( "blur", event, { item: this.active } ); + this.active = null; }, _startOpening: function( submenu ) { From 3bfee654bfacaa4c3192c1b42675ae575933f662 Mon Sep 17 00:00:00 2001 From: Amine HADDAD Date: Thu, 18 Feb 2016 13:28:43 +0100 Subject: [PATCH 002/136] Datepicker: Fix day names for ar-DZ locale Fixes #14948 Closes gh-1697 --- ui/i18n/datepicker-ar-DZ.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ui/i18n/datepicker-ar-DZ.js b/ui/i18n/datepicker-ar-DZ.js index 6035ce292..a2b1750b6 100644 --- a/ui/i18n/datepicker-ar-DZ.js +++ b/ui/i18n/datepicker-ar-DZ.js @@ -1,5 +1,7 @@ -/* Algerian Arabic Translation for jQuery UI date picker plugin. (can be used for Tunisia)*/ +/* Algerian Arabic Translation for jQuery UI date picker plugin. +/* Used in most of Maghreb countries, primarily in Algeria, Tunisia, Morocco. /* Mohamed Cherif BOUCHELAGHEM -- cherifbouchelaghem@yahoo.fr */ +/* Mohamed Amine HADDAD -- zatamine@gmail.com */ ( function( factory ) { if ( typeof define === "function" && define.amd ) { @@ -23,7 +25,7 @@ datepicker.regional[ "ar-DZ" ] = { monthNamesShort: [ "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12" ], dayNames: [ "الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت" ], dayNamesShort: [ "الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت" ], - dayNamesMin: [ "الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت" ], + dayNamesMin: [ "ح", "ن", "ث", "ر", "خ", "ج", "س" ], weekHeader: "أسبوع", dateFormat: "dd/mm/yy", firstDay: 6, From f42a759b32668d22cdcf5dc9ad49df0e096f8151 Mon Sep 17 00:00:00 2001 From: Alexander Schmitz Date: Wed, 30 Mar 2016 18:59:18 -0400 Subject: [PATCH 003/136] Tabs: Fix line length violations Ref gh-1690 --- ui/widgets/tabs.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ui/widgets/tabs.js b/ui/widgets/tabs.js index a35386541..a0a967c56 100644 --- a/ui/widgets/tabs.js +++ b/ui/widgets/tabs.js @@ -733,7 +733,8 @@ $.widget( "ui.tabs", { // meta-function to give users option to provide a href string instead of a numerical index. if ( typeof index === "string" ) { - index = this.anchors.index( this.anchors.filter( "[href$='" + $.ui.escapeSelector( index ) + "']" ) ); + index = this.anchors.index( this.anchors.filter( "[href$='" + + $.ui.escapeSelector( index ) + "']" ) ); } return index; From a4c9809340818bf3dc92881cc51ae8ecb3e081d5 Mon Sep 17 00:00:00 2001 From: Alexander Schmitz Date: Wed, 30 Mar 2016 19:00:14 -0400 Subject: [PATCH 004/136] Spinner: Fix line length violations Ref gh-1690 --- ui/widgets/spinner.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ui/widgets/spinner.js b/ui/widgets/spinner.js index e875f10ad..447944344 100644 --- a/ui/widgets/spinner.js +++ b/ui/widgets/spinner.js @@ -199,7 +199,8 @@ $.widget( "ui.spinner", { return; } - this._repeat( null, $( event.currentTarget ).hasClass( "ui-spinner-up" ) ? 1 : -1, event ); + this._repeat( null, $( event.currentTarget ) + .hasClass( "ui-spinner-up" ) ? 1 : -1, event ); }, "mouseup .ui-spinner-button": "_stop", "mouseenter .ui-spinner-button": function( event ) { @@ -212,7 +213,8 @@ $.widget( "ui.spinner", { if ( this._start( event ) === false ) { return false; } - this._repeat( null, $( event.currentTarget ).hasClass( "ui-spinner-up" ) ? 1 : -1, event ); + this._repeat( null, $( event.currentTarget ) + .hasClass( "ui-spinner-up" ) ? 1 : -1, event ); }, // TODO: do we really want to consider this a stop? From e1f23184a662cdafa5a8152bcbc775da5e4ef726 Mon Sep 17 00:00:00 2001 From: Alexander Schmitz Date: Wed, 30 Mar 2016 22:11:22 -0400 Subject: [PATCH 005/136] Sortable: Fix line length issues Ref gh-1690 --- ui/widgets/sortable.js | 465 ++++++++++++++++++++++++++++++----------- 1 file changed, 345 insertions(+), 120 deletions(-) diff --git a/ui/widgets/sortable.js b/ui/widgets/sortable.js index ec26250b5..2a9ce22ca 100644 --- a/ui/widgets/sortable.js +++ b/ui/widgets/sortable.js @@ -82,7 +82,8 @@ return $.widget( "ui.sortable", $.ui.mouse, { }, _isFloating: function( item ) { - return ( /left|right/ ).test( item.css( "float" ) ) || ( /inline|table-cell/ ).test( item.css( "display" ) ); + return ( /left|right/ ).test( item.css( "float" ) ) || + ( /inline|table-cell/ ).test( item.css( "display" ) ); }, _create: function() { @@ -190,7 +191,8 @@ return $.widget( "ui.sortable", $.ui.mouse, { this.currentContainer = this; - //We only need to call refreshPositions, because the refreshItems call has been moved to mouseCapture + //We only need to call refreshPositions, because the refreshItems call has been moved to + // mouseCapture this.refreshPositions(); //Create and append the visible helper @@ -223,7 +225,10 @@ return $.widget( "ui.sortable", $.ui.mouse, { top: event.pageY - this.offset.top }, parent: this._getParentOffset(), - relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper + + // This is a relative to absolute position minus the actual position calculation - + // only used for relative positioned helper + relative: this._getRelativeOffset() } ); // Only after we got the offset, we can change the helper's position to absolute @@ -240,9 +245,13 @@ return $.widget( "ui.sortable", $.ui.mouse, { ( o.cursorAt && this._adjustOffsetFromHelper( o.cursorAt ) ); //Cache the former DOM position - this.domPosition = { prev: this.currentItem.prev()[ 0 ], parent: this.currentItem.parent()[ 0 ] }; + this.domPosition = { + prev: this.currentItem.prev()[ 0 ], + parent: this.currentItem.parent()[ 0 ] + }; - //If the helper is not the original, hide the original so it's not playing any role during the drag, won't cause anything bad this way + // If the helper is not the original, hide the original so it's not playing any role during + // the drag, won't cause anything bad this way if ( this.helper[ 0 ] !== this.currentItem[ 0 ] ) { this.currentItem.hide(); } @@ -262,7 +271,8 @@ return $.widget( "ui.sortable", $.ui.mouse, { this.storedCursor = body.css( "cursor" ); body.css( "cursor", o.cursor ); - this.storedStylesheet = $( "" ).appendTo( body ); + this.storedStylesheet = + $( "" ).appendTo( body ); } if ( o.opacity ) { // opacity option @@ -280,7 +290,8 @@ return $.widget( "ui.sortable", $.ui.mouse, { } //Prepare scrolling - if ( this.scrollParent[ 0 ] !== this.document[ 0 ] && this.scrollParent[ 0 ].tagName !== "HTML" ) { + if ( this.scrollParent[ 0 ] !== this.document[ 0 ] && + this.scrollParent[ 0 ].tagName !== "HTML" ) { this.overflowOffset = this.scrollParent.offset(); } @@ -311,7 +322,10 @@ return $.widget( "ui.sortable", $.ui.mouse, { this.dragging = true; this._addClass( this.helper, "ui-sortable-helper" ); - this._mouseDrag( event ); //Execute the drag once - this causes the helper not to be visible before getting its correct position + + // Execute the drag once - this causes the helper not to be visiblebefore getting its + // correct position + this._mouseDrag( event ); return true; }, @@ -331,32 +345,45 @@ return $.widget( "ui.sortable", $.ui.mouse, { //Do scrolling if ( this.options.scroll ) { - if ( this.scrollParent[ 0 ] !== this.document[ 0 ] && this.scrollParent[ 0 ].tagName !== "HTML" ) { + if ( this.scrollParent[ 0 ] !== this.document[ 0 ] && + this.scrollParent[ 0 ].tagName !== "HTML" ) { - if ( ( this.overflowOffset.top + this.scrollParent[ 0 ].offsetHeight ) - event.pageY < o.scrollSensitivity ) { - this.scrollParent[ 0 ].scrollTop = scrolled = this.scrollParent[ 0 ].scrollTop + o.scrollSpeed; + if ( ( this.overflowOffset.top + this.scrollParent[ 0 ].offsetHeight ) - + event.pageY < o.scrollSensitivity ) { + this.scrollParent[ 0 ].scrollTop = + scrolled = this.scrollParent[ 0 ].scrollTop + o.scrollSpeed; } else if ( event.pageY - this.overflowOffset.top < o.scrollSensitivity ) { - this.scrollParent[ 0 ].scrollTop = scrolled = this.scrollParent[ 0 ].scrollTop - o.scrollSpeed; + this.scrollParent[ 0 ].scrollTop = + scrolled = this.scrollParent[ 0 ].scrollTop - o.scrollSpeed; } - if ( ( this.overflowOffset.left + this.scrollParent[ 0 ].offsetWidth ) - event.pageX < o.scrollSensitivity ) { - this.scrollParent[ 0 ].scrollLeft = scrolled = this.scrollParent[ 0 ].scrollLeft + o.scrollSpeed; + if ( ( this.overflowOffset.left + this.scrollParent[ 0 ].offsetWidth ) - + event.pageX < o.scrollSensitivity ) { + this.scrollParent[ 0 ].scrollLeft = scrolled = + this.scrollParent[ 0 ].scrollLeft + o.scrollSpeed; } else if ( event.pageX - this.overflowOffset.left < o.scrollSensitivity ) { - this.scrollParent[ 0 ].scrollLeft = scrolled = this.scrollParent[ 0 ].scrollLeft - o.scrollSpeed; + this.scrollParent[ 0 ].scrollLeft = scrolled = + this.scrollParent[ 0 ].scrollLeft - o.scrollSpeed; } } else { if ( event.pageY - this.document.scrollTop() < o.scrollSensitivity ) { scrolled = this.document.scrollTop( this.document.scrollTop() - o.scrollSpeed ); - } else if ( this.window.height() - ( event.pageY - this.document.scrollTop() ) < o.scrollSensitivity ) { + } else if ( this.window.height() - ( event.pageY - this.document.scrollTop() ) < + o.scrollSensitivity ) { scrolled = this.document.scrollTop( this.document.scrollTop() + o.scrollSpeed ); } if ( event.pageX - this.document.scrollLeft() < o.scrollSensitivity ) { - scrolled = this.document.scrollLeft( this.document.scrollLeft() - o.scrollSpeed ); - } else if ( this.window.width() - ( event.pageX - this.document.scrollLeft() ) < o.scrollSensitivity ) { - scrolled = this.document.scrollLeft( this.document.scrollLeft() + o.scrollSpeed ); + scrolled = this.document.scrollLeft( + this.document.scrollLeft() - o.scrollSpeed + ); + } else if ( this.window.width() - ( event.pageX - this.document.scrollLeft() ) < + o.scrollSensitivity ) { + scrolled = this.document.scrollLeft( + this.document.scrollLeft() + o.scrollSpeed + ); } } @@ -405,7 +432,10 @@ return $.widget( "ui.sortable", $.ui.mouse, { if ( itemElement !== this.currentItem[ 0 ] && this.placeholder[ intersection === 1 ? "next" : "prev" ]()[ 0 ] !== itemElement && !$.contains( this.placeholder[ 0 ], itemElement ) && - ( this.options.type === "semi-dynamic" ? !$.contains( this.element[ 0 ], itemElement ) : true ) + ( this.options.type === "semi-dynamic" ? + !$.contains( this.element[ 0 ], itemElement ) : + true + ) ) { this.direction = intersection === 1 ? "down" : "up"; @@ -455,15 +485,27 @@ return $.widget( "ui.sortable", $.ui.mouse, { animation = {}; if ( !axis || axis === "x" ) { - animation.left = cur.left - this.offset.parent.left - this.margins.left + ( this.offsetParent[ 0 ] === this.document[ 0 ].body ? 0 : this.offsetParent[ 0 ].scrollLeft ); + animation.left = cur.left - this.offset.parent.left - this.margins.left + + ( this.offsetParent[ 0 ] === this.document[ 0 ].body ? + 0 : + this.offsetParent[ 0 ].scrollLeft + ); } if ( !axis || axis === "y" ) { - animation.top = cur.top - this.offset.parent.top - this.margins.top + ( this.offsetParent[ 0 ] === this.document[ 0 ].body ? 0 : this.offsetParent[ 0 ].scrollTop ); + animation.top = cur.top - this.offset.parent.top - this.margins.top + + ( this.offsetParent[ 0 ] === this.document[ 0 ].body ? + 0 : + this.offsetParent[ 0 ].scrollTop + ); } this.reverting = true; - $( this.helper ).animate( animation, parseInt( this.options.revert, 10 ) || 500, function() { - that._clear( event ); - } ); + $( this.helper ).animate( + animation, + parseInt( this.options.revert, 10 ) || 500, + function() { + that._clear( event ); + } + ); } else { this._clear( event, noPropagation ); } @@ -498,11 +540,13 @@ return $.widget( "ui.sortable", $.ui.mouse, { if ( this.placeholder ) { - //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node! + //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, + // it unbinds ALL events from the original node! if ( this.placeholder[ 0 ].parentNode ) { this.placeholder[ 0 ].parentNode.removeChild( this.placeholder[ 0 ] ); } - if ( this.options.helper !== "original" && this.helper && this.helper[ 0 ].parentNode ) { + if ( this.options.helper !== "original" && this.helper && + this.helper[ 0 ].parentNode ) { this.helper.remove(); } @@ -531,9 +575,12 @@ return $.widget( "ui.sortable", $.ui.mouse, { o = o || {}; $( items ).each( function() { - var res = ( $( o.item || this ).attr( o.attribute || "id" ) || "" ).match( o.expression || ( /(.+)[\-=_](.+)/ ) ); + var res = ( $( o.item || this ).attr( o.attribute || "id" ) || "" ) + .match( o.expression || ( /(.+)[\-=_](.+)/ ) ); if ( res ) { - str.push( ( o.key || res[ 1 ] + "[]" ) + "=" + ( o.key && o.expression ? res[ 1 ] : res[ 2 ] ) ); + str.push( + ( o.key || res[ 1 ] + "[]" ) + + "=" + ( o.key && o.expression ? res[ 1 ] : res[ 2 ] ) ); } } ); @@ -552,7 +599,9 @@ return $.widget( "ui.sortable", $.ui.mouse, { o = o || {}; - items.each( function() { ret.push( $( o.item || this ).attr( o.attribute || "id" ) || "" ); } ); + items.each( function() { + ret.push( $( o.item || this ).attr( o.attribute || "id" ) || "" ); + } ); return ret; }, @@ -570,13 +619,17 @@ return $.widget( "ui.sortable", $.ui.mouse, { b = t + item.height, dyClick = this.offset.click.top, dxClick = this.offset.click.left, - isOverElementHeight = ( this.options.axis === "x" ) || ( ( y1 + dyClick ) > t && ( y1 + dyClick ) < b ), - isOverElementWidth = ( this.options.axis === "y" ) || ( ( x1 + dxClick ) > l && ( x1 + dxClick ) < r ), + isOverElementHeight = ( this.options.axis === "x" ) || ( ( y1 + dyClick ) > t && + ( y1 + dyClick ) < b ), + isOverElementWidth = ( this.options.axis === "y" ) || ( ( x1 + dxClick ) > l && + ( x1 + dxClick ) < r ), isOverElement = isOverElementHeight && isOverElementWidth; if ( this.options.tolerance === "pointer" || this.options.forcePointerForContainers || - ( this.options.tolerance !== "pointer" && this.helperProportions[ this.floating ? "width" : "height" ] > item[ this.floating ? "width" : "height" ] ) + ( this.options.tolerance !== "pointer" && + this.helperProportions[ this.floating ? "width" : "height" ] > + item[ this.floating ? "width" : "height" ] ) ) { return isOverElement; } else { @@ -590,10 +643,13 @@ return $.widget( "ui.sortable", $.ui.mouse, { }, _intersectsWithPointer: function( item ) { - var verticalDirection, horizontalDirection, - isOverElementHeight = ( this.options.axis === "x" ) || this._isOverAxis( this.positionAbs.top + this.offset.click.top, item.top, item.height ), - isOverElementWidth = ( this.options.axis === "y" ) || this._isOverAxis( this.positionAbs.left + this.offset.click.left, item.left, item.width ), + isOverElementHeight = ( this.options.axis === "x" ) || + this._isOverAxis( + this.positionAbs.top + this.offset.click.top, item.top, item.height ), + isOverElementWidth = ( this.options.axis === "y" ) || + this._isOverAxis( + this.positionAbs.left + this.offset.click.left, item.left, item.width ), isOverElement = isOverElementHeight && isOverElementWidth; if ( !isOverElement ) { @@ -611,15 +667,19 @@ return $.widget( "ui.sortable", $.ui.mouse, { _intersectsWithSides: function( item ) { - var isOverBottomHalf = this._isOverAxis( this.positionAbs.top + this.offset.click.top, item.top + ( item.height / 2 ), item.height ), - isOverRightHalf = this._isOverAxis( this.positionAbs.left + this.offset.click.left, item.left + ( item.width / 2 ), item.width ), + var isOverBottomHalf = this._isOverAxis( this.positionAbs.top + + this.offset.click.top, item.top + ( item.height / 2 ), item.height ), + isOverRightHalf = this._isOverAxis( this.positionAbs.left + + this.offset.click.left, item.left + ( item.width / 2 ), item.width ), verticalDirection = this._getDragVerticalDirection(), horizontalDirection = this._getDragHorizontalDirection(); if ( this.floating && horizontalDirection ) { - return ( ( horizontalDirection === "right" && isOverRightHalf ) || ( horizontalDirection === "left" && !isOverRightHalf ) ); + return ( ( horizontalDirection === "right" && isOverRightHalf ) || + ( horizontalDirection === "left" && !isOverRightHalf ) ); } else { - return verticalDirection && ( ( verticalDirection === "down" && isOverBottomHalf ) || ( verticalDirection === "up" && !isOverBottomHalf ) ); + return verticalDirection && ( ( verticalDirection === "down" && isOverBottomHalf ) || + ( verticalDirection === "up" && !isOverBottomHalf ) ); } }, @@ -643,7 +703,9 @@ return $.widget( "ui.sortable", $.ui.mouse, { _connectWith: function() { var options = this.options; - return options.connectWith.constructor === String ? [ options.connectWith ] : options.connectWith; + return options.connectWith.constructor === String ? + [ options.connectWith ] : + options.connectWith; }, _getItemsAsjQuery: function( connected ) { @@ -659,13 +721,22 @@ return $.widget( "ui.sortable", $.ui.mouse, { for ( j = cur.length - 1; j >= 0; j-- ) { inst = $.data( cur[ j ], this.widgetFullName ); if ( inst && inst !== this && !inst.options.disabled ) { - queries.push( [ $.isFunction( inst.options.items ) ? inst.options.items.call( inst.element ) : $( inst.options.items, inst.element ).not( ".ui-sortable-helper" ).not( ".ui-sortable-placeholder" ), inst ] ); + queries.push( [ $.isFunction( inst.options.items ) ? + inst.options.items.call( inst.element ) : + $( inst.options.items, inst.element ) + .not( ".ui-sortable-helper" ) + .not( ".ui-sortable-placeholder" ), inst ] ); } } } } - queries.push( [ $.isFunction( this.options.items ) ? this.options.items.call( this.element, null, { options: this.options, item: this.currentItem } ) : $( this.options.items, this.element ).not( ".ui-sortable-helper" ).not( ".ui-sortable-placeholder" ), this ] ); + queries.push( [ $.isFunction( this.options.items ) ? + this.options.items + .call( this.element, null, { options: this.options, item: this.currentItem } ) : + $( this.options.items, this.element ) + .not( ".ui-sortable-helper" ) + .not( ".ui-sortable-placeholder" ), this ] ); function addItems() { items.push( this ); @@ -700,16 +771,22 @@ return $.widget( "ui.sortable", $.ui.mouse, { var i, j, cur, inst, targetData, _queries, item, queriesLength, items = this.items, - queries = [ [ $.isFunction( this.options.items ) ? this.options.items.call( this.element[ 0 ], event, { item: this.currentItem } ) : $( this.options.items, this.element ), this ] ], + queries = [ [ $.isFunction( this.options.items ) ? + this.options.items.call( this.element[ 0 ], event, { item: this.currentItem } ) : + $( this.options.items, this.element ), this ] ], connectWith = this._connectWith(); - if ( connectWith && this.ready ) { //Shouldn't be run the first time through due to massive slow-down + //Shouldn't be run the first time through due to massive slow-down + if ( connectWith && this.ready ) { for ( i = connectWith.length - 1; i >= 0; i-- ) { cur = $( connectWith[ i ], this.document[ 0 ] ); for ( j = cur.length - 1; j >= 0; j-- ) { inst = $.data( cur[ j ], this.widgetFullName ); if ( inst && inst !== this && !inst.options.disabled ) { - queries.push( [ $.isFunction( inst.options.items ) ? inst.options.items.call( inst.element[ 0 ], event, { item: this.currentItem } ) : $( inst.options.items, inst.element ), inst ] ); + queries.push( [ $.isFunction( inst.options.items ) ? + inst.options.items + .call( inst.element[ 0 ], event, { item: this.currentItem } ) : + $( inst.options.items, inst.element ), inst ] ); this.containers.push( inst ); } } @@ -723,7 +800,8 @@ return $.widget( "ui.sortable", $.ui.mouse, { for ( j = 0, queriesLength = _queries.length; j < queriesLength; j++ ) { item = $( _queries[ j ] ); - item.data( this.widgetName + "-item", targetData ); // Data for target checking (mouse manager) + // Data for target checking (mouse manager) + item.data( this.widgetName + "-item", targetData ); items.push( { item: item, @@ -743,7 +821,8 @@ return $.widget( "ui.sortable", $.ui.mouse, { this.options.axis === "x" || this._isFloating( this.items[ 0 ].item ) : false; - //This has to be redone because due to the item being moved out/into the offsetParent, the offsetParent's position will change + //This has to be redone because due to the item being moved out/into the offsetParent, + // the offsetParent's position will change if ( this.offsetParent && this.helper ) { this.offset.parent = this._getParentOffset(); } @@ -754,11 +833,14 @@ return $.widget( "ui.sortable", $.ui.mouse, { item = this.items[ i ]; //We ignore calculating positions of all connected containers when we're not over them - if ( item.instance !== this.currentContainer && this.currentContainer && item.item[ 0 ] !== this.currentItem[ 0 ] ) { + if ( item.instance !== this.currentContainer && this.currentContainer && + item.item[ 0 ] !== this.currentItem[ 0 ] ) { continue; } - t = this.options.toleranceElement ? $( this.options.toleranceElement, item.item ) : item.item; + t = this.options.toleranceElement ? + $( this.options.toleranceElement, item.item ) : + item.item; if ( !fast ) { item.width = t.outerWidth(); @@ -777,8 +859,10 @@ return $.widget( "ui.sortable", $.ui.mouse, { p = this.containers[ i ].element.offset(); this.containers[ i ].containerCache.left = p.left; this.containers[ i ].containerCache.top = p.top; - this.containers[ i ].containerCache.width = this.containers[ i ].element.outerWidth(); - this.containers[ i ].containerCache.height = this.containers[ i ].element.outerHeight(); + this.containers[ i ].containerCache.width = + this.containers[ i ].element.outerWidth(); + this.containers[ i ].containerCache.height = + this.containers[ i ].element.outerHeight(); } } @@ -821,15 +905,28 @@ return $.widget( "ui.sortable", $.ui.mouse, { }, update: function( container, p ) { - // 1. If a className is set as 'placeholder option, we don't force sizes - the class is responsible for that - // 2. The option 'forcePlaceholderSize can be enabled to force it even if a class name is specified + // 1. If a className is set as 'placeholder option, we don't force sizes - + // the class is responsible for that + // 2. The option 'forcePlaceholderSize can be enabled to force it even if a + // class name is specified if ( className && !o.forcePlaceholderSize ) { return; } - //If the element doesn't have a actual height by itself (without styles coming from a stylesheet), it receives the inline height from the dragged item - if ( !p.height() ) { p.height( that.currentItem.innerHeight() - parseInt( that.currentItem.css( "paddingTop" ) || 0, 10 ) - parseInt( that.currentItem.css( "paddingBottom" ) || 0, 10 ) ); } - if ( !p.width() ) { p.width( that.currentItem.innerWidth() - parseInt( that.currentItem.css( "paddingLeft" ) || 0, 10 ) - parseInt( that.currentItem.css( "paddingRight" ) || 0, 10 ) ); } + //If the element doesn't have a actual height by itself (without styles coming + // from a stylesheet), it receives the inline height from the dragged item + if ( !p.height() ) { + p.height( + that.currentItem.innerHeight() - + parseInt( that.currentItem.css( "paddingTop" ) || 0, 10 ) - + parseInt( that.currentItem.css( "paddingBottom" ) || 0, 10 ) ); + } + if ( !p.width() ) { + p.width( + that.currentItem.innerWidth() - + parseInt( that.currentItem.css( "paddingLeft" ) || 0, 10 ) - + parseInt( that.currentItem.css( "paddingRight" ) || 0, 10 ) ); + } } }; } @@ -856,7 +953,8 @@ return $.widget( "ui.sortable", $.ui.mouse, { }, _contactContainers: function( event ) { - var i, j, dist, itemWithLeastDistance, posProperty, sizeProperty, cur, nearBottom, floating, axis, + var i, j, dist, itemWithLeastDistance, posProperty, sizeProperty, cur, nearBottom, + floating, axis, innermostContainer = null, innermostIndex = null; @@ -871,7 +969,10 @@ return $.widget( "ui.sortable", $.ui.mouse, { if ( this._intersectsWith( this.containers[ i ].containerCache ) ) { // If we've already found a container and it's more "inner" than this, then continue - if ( innermostContainer && $.contains( this.containers[ i ].element[ 0 ], innermostContainer.element[ 0 ] ) ) { + if ( innermostContainer && + $.contains( + this.containers[ i ].element[ 0 ], + innermostContainer.element[ 0 ] ) ) { continue; } @@ -902,7 +1003,8 @@ return $.widget( "ui.sortable", $.ui.mouse, { } } else { - //When entering a new container, we will find the item with the least distance and append our item near it + // When entering a new container, we will find the item with the least distance and + // append our item near it dist = 10000; itemWithLeastDistance = null; floating = innermostContainer.floating || this._isFloating( this.currentItem ); @@ -911,7 +1013,9 @@ return $.widget( "ui.sortable", $.ui.mouse, { axis = floating ? "pageX" : "pageY"; for ( j = this.items.length - 1; j >= 0; j-- ) { - if ( !$.contains( this.containers[ innermostIndex ].element[ 0 ], this.items[ j ].item[ 0 ] ) ) { + if ( !$.contains( + this.containers[ innermostIndex ].element[ 0 ], this.items[ j ].item[ 0 ] ) + ) { continue; } if ( this.items[ j ].item[ 0 ] === this.currentItem[ 0 ] ) { @@ -944,7 +1048,9 @@ return $.widget( "ui.sortable", $.ui.mouse, { return; } - itemWithLeastDistance ? this._rearrange( event, itemWithLeastDistance, null, true ) : this._rearrange( event, null, this.containers[ innermostIndex ].element, true ); + itemWithLeastDistance ? + this._rearrange( event, itemWithLeastDistance, null, true ) : + this._rearrange( event, null, this.containers[ innermostIndex ].element, true ); this._trigger( "change", event, this._uiHash() ); this.containers[ innermostIndex ]._trigger( "change", event, this._uiHash( this ) ); this.currentContainer = this.containers[ innermostIndex ]; @@ -961,15 +1067,25 @@ return $.widget( "ui.sortable", $.ui.mouse, { _createHelper: function( event ) { var o = this.options, - helper = $.isFunction( o.helper ) ? $( o.helper.apply( this.element[ 0 ], [ event, this.currentItem ] ) ) : ( o.helper === "clone" ? this.currentItem.clone() : this.currentItem ); + helper = $.isFunction( o.helper ) ? + $( o.helper.apply( this.element[ 0 ], [ event, this.currentItem ] ) ) : + ( o.helper === "clone" ? this.currentItem.clone() : this.currentItem ); //Add the helper to the DOM if that didn't happen already if ( !helper.parents( "body" ).length ) { - $( o.appendTo !== "parent" ? o.appendTo : this.currentItem[ 0 ].parentNode )[ 0 ].appendChild( helper[ 0 ] ); + $( o.appendTo !== "parent" ? + o.appendTo : + this.currentItem[ 0 ].parentNode )[ 0 ].appendChild( helper[ 0 ] ); } if ( helper[ 0 ] === this.currentItem[ 0 ] ) { - this._storedCSS = { width: this.currentItem[ 0 ].style.width, height: this.currentItem[ 0 ].style.height, position: this.currentItem.css( "position" ), top: this.currentItem.css( "top" ), left: this.currentItem.css( "left" ) }; + this._storedCSS = { + width: this.currentItem[ 0 ].style.width, + height: this.currentItem[ 0 ].style.height, + position: this.currentItem.css( "position" ), + top: this.currentItem.css( "top" ), + left: this.currentItem.css( "left" ) + }; } if ( !helper[ 0 ].style.width || o.forceHelperSize ) { @@ -1010,18 +1126,24 @@ return $.widget( "ui.sortable", $.ui.mouse, { this.offsetParent = this.helper.offsetParent(); var po = this.offsetParent.offset(); - // This is a special case where we need to modify a offset calculated on start, since the following happened: - // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent - // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that - // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag - if ( this.cssPosition === "absolute" && this.scrollParent[ 0 ] !== this.document[ 0 ] && $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) { + // This is a special case where we need to modify a offset calculated on start, since the + // following happened: + // 1. The position of the helper is absolute, so it's position is calculated based on the + // next positioned parent + // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't + // the document, which means that the scroll is included in the initial calculation of the + // offset of the parent, and never recalculated upon drag + if ( this.cssPosition === "absolute" && this.scrollParent[ 0 ] !== this.document[ 0 ] && + $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) { po.left += this.scrollParent.scrollLeft(); po.top += this.scrollParent.scrollTop(); } - // This needs to be actually done for all browsers, since pageX/pageY includes this information - // with an ugly IE fix - if ( this.offsetParent[ 0 ] === this.document[ 0 ].body || ( this.offsetParent[ 0 ].tagName && this.offsetParent[ 0 ].tagName.toLowerCase() === "html" && $.ui.ie ) ) { + // This needs to be actually done for all browsers, since pageX/pageY includes this + // information with an ugly IE fix + if ( this.offsetParent[ 0 ] === this.document[ 0 ].body || + ( this.offsetParent[ 0 ].tagName && + this.offsetParent[ 0 ].tagName.toLowerCase() === "html" && $.ui.ie ) ) { po = { top: 0, left: 0 }; } @@ -1037,8 +1159,10 @@ return $.widget( "ui.sortable", $.ui.mouse, { if ( this.cssPosition === "relative" ) { var p = this.currentItem.position(); return { - top: p.top - ( parseInt( this.helper.css( "top" ), 10 ) || 0 ) + this.scrollParent.scrollTop(), - left: p.left - ( parseInt( this.helper.css( "left" ), 10 ) || 0 ) + this.scrollParent.scrollLeft() + top: p.top - ( parseInt( this.helper.css( "top" ), 10 ) || 0 ) + + this.scrollParent.scrollTop(), + left: p.left - ( parseInt( this.helper.css( "left" ), 10 ) || 0 ) + + this.scrollParent.scrollLeft() }; } else { return { top: 0, left: 0 }; @@ -1071,8 +1195,13 @@ return $.widget( "ui.sortable", $.ui.mouse, { this.containment = [ 0 - this.offset.relative.left - this.offset.parent.left, 0 - this.offset.relative.top - this.offset.parent.top, - o.containment === "document" ? this.document.width() : this.window.width() - this.helperProportions.width - this.margins.left, - ( o.containment === "document" ? ( this.document.height() || document.body.parentNode.scrollHeight ) : this.window.height() || this.document[ 0 ].body.parentNode.scrollHeight ) - this.helperProportions.height - this.margins.top + o.containment === "document" ? + this.document.width() : + this.window.width() - this.helperProportions.width - this.margins.left, + ( o.containment === "document" ? + ( this.document.height() || document.body.parentNode.scrollHeight ) : + this.window.height() || this.document[ 0 ].body.parentNode.scrollHeight + ) - this.helperProportions.height - this.margins.top ]; } @@ -1082,10 +1211,18 @@ return $.widget( "ui.sortable", $.ui.mouse, { over = ( $( ce ).css( "overflow" ) !== "hidden" ); this.containment = [ - co.left + ( parseInt( $( ce ).css( "borderLeftWidth" ), 10 ) || 0 ) + ( parseInt( $( ce ).css( "paddingLeft" ), 10 ) || 0 ) - this.margins.left, - co.top + ( parseInt( $( ce ).css( "borderTopWidth" ), 10 ) || 0 ) + ( parseInt( $( ce ).css( "paddingTop" ), 10 ) || 0 ) - this.margins.top, - co.left + ( over ? Math.max( ce.scrollWidth, ce.offsetWidth ) : ce.offsetWidth ) - ( parseInt( $( ce ).css( "borderLeftWidth" ), 10 ) || 0 ) - ( parseInt( $( ce ).css( "paddingRight" ), 10 ) || 0 ) - this.helperProportions.width - this.margins.left, - co.top + ( over ? Math.max( ce.scrollHeight, ce.offsetHeight ) : ce.offsetHeight ) - ( parseInt( $( ce ).css( "borderTopWidth" ), 10 ) || 0 ) - ( parseInt( $( ce ).css( "paddingBottom" ), 10 ) || 0 ) - this.helperProportions.height - this.margins.top + co.left + ( parseInt( $( ce ).css( "borderLeftWidth" ), 10 ) || 0 ) + + ( parseInt( $( ce ).css( "paddingLeft" ), 10 ) || 0 ) - this.margins.left, + co.top + ( parseInt( $( ce ).css( "borderTopWidth" ), 10 ) || 0 ) + + ( parseInt( $( ce ).css( "paddingTop" ), 10 ) || 0 ) - this.margins.top, + co.left + ( over ? Math.max( ce.scrollWidth, ce.offsetWidth ) : ce.offsetWidth ) - + ( parseInt( $( ce ).css( "borderLeftWidth" ), 10 ) || 0 ) - + ( parseInt( $( ce ).css( "paddingRight" ), 10 ) || 0 ) - + this.helperProportions.width - this.margins.left, + co.top + ( over ? Math.max( ce.scrollHeight, ce.offsetHeight ) : ce.offsetHeight ) - + ( parseInt( $( ce ).css( "borderTopWidth" ), 10 ) || 0 ) - + ( parseInt( $( ce ).css( "paddingBottom" ), 10 ) || 0 ) - + this.helperProportions.height - this.margins.top ]; } @@ -1097,21 +1234,41 @@ return $.widget( "ui.sortable", $.ui.mouse, { pos = this.position; } var mod = d === "absolute" ? 1 : -1, - scroll = this.cssPosition === "absolute" && !( this.scrollParent[ 0 ] !== this.document[ 0 ] && $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ? this.offsetParent : this.scrollParent, + scroll = this.cssPosition === "absolute" && + !( this.scrollParent[ 0 ] !== this.document[ 0 ] && + $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ? + this.offsetParent : + this.scrollParent, scrollIsRootNode = ( /(html|body)/i ).test( scroll[ 0 ].tagName ); return { top: ( - pos.top + // The absolute mouse position - this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent - this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border) - ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod ) + + // The absolute mouse position + pos.top + + + // Only for relative positioned nodes: Relative offset from element to offset parent + this.offset.relative.top * mod + + + // The offsetParent's offset without borders (offset + border) + this.offset.parent.top * mod - + ( ( this.cssPosition === "fixed" ? + -this.scrollParent.scrollTop() : + ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod ) ), left: ( - pos.left + // The absolute mouse position - this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent - this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border) - ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod ) + + // The absolute mouse position + pos.left + + + // Only for relative positioned nodes: Relative offset from element to offset parent + this.offset.relative.left * mod + + + // The offsetParent's offset without borders (offset + border) + this.offset.parent.left * mod - + ( ( this.cssPosition === "fixed" ? + -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : + scroll.scrollLeft() ) * mod ) ) }; @@ -1123,13 +1280,19 @@ return $.widget( "ui.sortable", $.ui.mouse, { o = this.options, pageX = event.pageX, pageY = event.pageY, - scroll = this.cssPosition === "absolute" && !( this.scrollParent[ 0 ] !== this.document[ 0 ] && $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ? this.offsetParent : this.scrollParent, scrollIsRootNode = ( /(html|body)/i ).test( scroll[ 0 ].tagName ); + scroll = this.cssPosition === "absolute" && + !( this.scrollParent[ 0 ] !== this.document[ 0 ] && + $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ? + this.offsetParent : + this.scrollParent, + scrollIsRootNode = ( /(html|body)/i ).test( scroll[ 0 ].tagName ); // This is another very weird special case that only happens for relative elements: // 1. If the css position is relative // 2. and the scroll parent is the document or similar to the offset parent // we have to refresh the relative offset during the scroll so there are no jumps - if ( this.cssPosition === "relative" && !( this.scrollParent[ 0 ] !== this.document[ 0 ] && this.scrollParent[ 0 ] !== this.offsetParent[ 0 ] ) ) { + if ( this.cssPosition === "relative" && !( this.scrollParent[ 0 ] !== this.document[ 0 ] && + this.scrollParent[ 0 ] !== this.offsetParent[ 0 ] ) ) { this.offset.relative = this._getRelativeOffset(); } @@ -1156,29 +1319,63 @@ return $.widget( "ui.sortable", $.ui.mouse, { } if ( o.grid ) { - top = this.originalPageY + Math.round( ( pageY - this.originalPageY ) / o.grid[ 1 ] ) * o.grid[ 1 ]; - pageY = this.containment ? ( ( top - this.offset.click.top >= this.containment[ 1 ] && top - this.offset.click.top <= this.containment[ 3 ] ) ? top : ( ( top - this.offset.click.top >= this.containment[ 1 ] ) ? top - o.grid[ 1 ] : top + o.grid[ 1 ] ) ) : top; + top = this.originalPageY + Math.round( ( pageY - this.originalPageY ) / + o.grid[ 1 ] ) * o.grid[ 1 ]; + pageY = this.containment ? + ( ( top - this.offset.click.top >= this.containment[ 1 ] && + top - this.offset.click.top <= this.containment[ 3 ] ) ? + top : + ( ( top - this.offset.click.top >= this.containment[ 1 ] ) ? + top - o.grid[ 1 ] : top + o.grid[ 1 ] ) ) : + top; - left = this.originalPageX + Math.round( ( pageX - this.originalPageX ) / o.grid[ 0 ] ) * o.grid[ 0 ]; - pageX = this.containment ? ( ( left - this.offset.click.left >= this.containment[ 0 ] && left - this.offset.click.left <= this.containment[ 2 ] ) ? left : ( ( left - this.offset.click.left >= this.containment[ 0 ] ) ? left - o.grid[ 0 ] : left + o.grid[ 0 ] ) ) : left; + left = this.originalPageX + Math.round( ( pageX - this.originalPageX ) / + o.grid[ 0 ] ) * o.grid[ 0 ]; + pageX = this.containment ? + ( ( left - this.offset.click.left >= this.containment[ 0 ] && + left - this.offset.click.left <= this.containment[ 2 ] ) ? + left : + ( ( left - this.offset.click.left >= this.containment[ 0 ] ) ? + left - o.grid[ 0 ] : left + o.grid[ 0 ] ) ) : + left; } } return { top: ( - pageY - // The absolute mouse position - this.offset.click.top - // Click offset (relative to the element) - this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent - this.offset.parent.top + // The offsetParent's offset without borders (offset + border) - ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) ) + + // The absolute mouse position + pageY - + + // Click offset (relative to the element) + this.offset.click.top - + + // Only for relative positioned nodes: Relative offset from element to offset parent + this.offset.relative.top - + + // The offsetParent's offset without borders (offset + border) + this.offset.parent.top + + ( ( this.cssPosition === "fixed" ? + -this.scrollParent.scrollTop() : + ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) ) ), left: ( - pageX - // The absolute mouse position - this.offset.click.left - // Click offset (relative to the element) - this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent - this.offset.parent.left + // The offsetParent's offset without borders (offset + border) - ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) ) + + // The absolute mouse position + pageX - + + // Click offset (relative to the element) + this.offset.click.left - + + // Only for relative positioned nodes: Relative offset from element to offset parent + this.offset.relative.left - + + // The offsetParent's offset without borders (offset + border) + this.offset.parent.left + + ( ( this.cssPosition === "fixed" ? + -this.scrollParent.scrollLeft() : + scrollIsRootNode ? 0 : scroll.scrollLeft() ) ) ) }; @@ -1186,19 +1383,24 @@ return $.widget( "ui.sortable", $.ui.mouse, { _rearrange: function( event, i, a, hardRefresh ) { - a ? a[ 0 ].appendChild( this.placeholder[ 0 ] ) : i.item[ 0 ].parentNode.insertBefore( this.placeholder[ 0 ], ( this.direction === "down" ? i.item[ 0 ] : i.item[ 0 ].nextSibling ) ); + a ? a[ 0 ].appendChild( this.placeholder[ 0 ] ) : + i.item[ 0 ].parentNode.insertBefore( this.placeholder[ 0 ], + ( this.direction === "down" ? i.item[ 0 ] : i.item[ 0 ].nextSibling ) ); //Various things done here to improve the performance: // 1. we create a setTimeout, that calls refreshPositions // 2. on the instance, we have a counter variable, that get's higher after every append - // 3. on the local scope, we copy the counter variable, and check in the timeout, if it's still the same + // 3. on the local scope, we copy the counter variable, and check in the timeout, + // if it's still the same // 4. this lets only the last addition to the timeout stack through this.counter = this.counter ? ++this.counter : 1; var counter = this.counter; this._delay( function() { if ( counter === this.counter ) { - this.refreshPositions( !hardRefresh ); //Precompute after each DOM insertion, NOT on mousemove + + //Precompute after each DOM insertion, NOT on mousemove + this.refreshPositions( !hardRefresh ); } } ); @@ -1208,13 +1410,14 @@ return $.widget( "ui.sortable", $.ui.mouse, { this.reverting = false; - // We delay all events that have to be triggered to after the point where the placeholder has been removed and - // everything else normalized again + // We delay all events that have to be triggered to after the point where the placeholder + // has been removed and everything else normalized again var i, delayedTriggers = []; // We first have to update the dom position of the actual currentItem - // Note: don't do it if the current item is already removed (by a user), or it gets reappended (see #4088) + // Note: don't do it if the current item is already removed (by a user), or it gets + // reappended (see #4088) if ( !this._noFinalSort && this.currentItem.parent().length ) { this.placeholder.before( this.currentItem ); } @@ -1233,19 +1436,38 @@ return $.widget( "ui.sortable", $.ui.mouse, { } if ( this.fromOutside && !noPropagation ) { - delayedTriggers.push( function( event ) { this._trigger( "receive", event, this._uiHash( this.fromOutside ) ); } ); + delayedTriggers.push( function( event ) { + this._trigger( "receive", event, this._uiHash( this.fromOutside ) ); + } ); } - if ( ( this.fromOutside || this.domPosition.prev !== this.currentItem.prev().not( ".ui-sortable-helper" )[ 0 ] || this.domPosition.parent !== this.currentItem.parent()[ 0 ] ) && !noPropagation ) { - delayedTriggers.push( function( event ) { this._trigger( "update", event, this._uiHash() ); } ); //Trigger update callback if the DOM position has changed + if ( ( this.fromOutside || + this.domPosition.prev !== + this.currentItem.prev().not( ".ui-sortable-helper" )[ 0 ] || + this.domPosition.parent !== this.currentItem.parent()[ 0 ] ) && !noPropagation ) { + + // Trigger update callback if the DOM position has changed + delayedTriggers.push( function( event ) { + this._trigger( "update", event, this._uiHash() ); + } ); } // Check if the items Container has Changed and trigger appropriate // events. if ( this !== this.currentContainer ) { if ( !noPropagation ) { - delayedTriggers.push( function( event ) { this._trigger( "remove", event, this._uiHash() ); } ); - delayedTriggers.push( ( function( c ) { return function( event ) { c._trigger( "receive", event, this._uiHash( this ) ); }; } ).call( this, this.currentContainer ) ); - delayedTriggers.push( ( function( c ) { return function( event ) { c._trigger( "update", event, this._uiHash( this ) ); }; } ).call( this, this.currentContainer ) ); + delayedTriggers.push( function( event ) { + this._trigger( "remove", event, this._uiHash() ); + } ); + delayedTriggers.push( ( function( c ) { + return function( event ) { + c._trigger( "receive", event, this._uiHash( this ) ); + }; + } ).call( this, this.currentContainer ) ); + delayedTriggers.push( ( function( c ) { + return function( event ) { + c._trigger( "update", event, this._uiHash( this ) ); + }; + } ).call( this, this.currentContainer ) ); } } @@ -1283,7 +1505,8 @@ return $.widget( "ui.sortable", $.ui.mouse, { this._trigger( "beforeStop", event, this._uiHash() ); } - //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node! + //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, + // it unbinds ALL events from the original node! this.placeholder[ 0 ].parentNode.removeChild( this.placeholder[ 0 ] ); if ( !this.cancelHelperRemoval ) { @@ -1295,8 +1518,10 @@ return $.widget( "ui.sortable", $.ui.mouse, { if ( !noPropagation ) { for ( i = 0; i < delayedTriggers.length; i++ ) { + + // Trigger all delayed events delayedTriggers[ i ].call( this, event ); - } //Trigger all delayed events + } this._trigger( "stop", event, this._uiHash() ); } From b6b4dd1279382d9a166408368249df7e85246576 Mon Sep 17 00:00:00 2001 From: Alexander Schmitz Date: Wed, 30 Mar 2016 22:18:36 -0400 Subject: [PATCH 006/136] Slider: Fix line length issues Ref gh-1690 --- ui/widgets/slider.js | 47 +++++++++++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 11 deletions(-) diff --git a/ui/widgets/slider.js b/ui/widgets/slider.js index 8af032dcf..4c1bdc05e 100644 --- a/ui/widgets/slider.js +++ b/ui/widgets/slider.js @@ -274,10 +274,12 @@ return $.widget( "ui.slider", $.ui.mouse, { if ( this.orientation === "horizontal" ) { pixelTotal = this.elementSize.width; - pixelMouse = position.x - this.elementOffset.left - ( this._clickOffset ? this._clickOffset.left : 0 ); + pixelMouse = position.x - this.elementOffset.left - + ( this._clickOffset ? this._clickOffset.left : 0 ); } else { pixelTotal = this.elementSize.height; - pixelMouse = position.y - this.elementOffset.top - ( this._clickOffset ? this._clickOffset.top : 0 ); + pixelMouse = position.y - this.elementOffset.top - + ( this._clickOffset ? this._clickOffset.top : 0 ); } percentMouse = ( pixelMouse / pixelTotal ); @@ -595,23 +597,38 @@ return $.widget( "ui.slider", $.ui.mouse, { if ( this._hasMultipleValues() ) { this.handles.each( function( i ) { - valPercent = ( that.values( i ) - that._valueMin() ) / ( that._valueMax() - that._valueMin() ) * 100; + valPercent = ( that.values( i ) - that._valueMin() ) / ( that._valueMax() - + that._valueMin() ) * 100; _set[ that.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%"; $( this ).stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate ); if ( that.options.range === true ) { if ( that.orientation === "horizontal" ) { if ( i === 0 ) { - that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { left: valPercent + "%" }, o.animate ); + that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { + left: valPercent + "%" + }, o.animate ); } if ( i === 1 ) { - that.range[ animate ? "animate" : "css" ]( { width: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } ); + that.range[ animate ? "animate" : "css" ]( { + width: ( valPercent - lastValPercent ) + "%" + }, { + queue: false, + duration: o.animate + } ); } } else { if ( i === 0 ) { - that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { bottom: ( valPercent ) + "%" }, o.animate ); + that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { + bottom: ( valPercent ) + "%" + }, o.animate ); } if ( i === 1 ) { - that.range[ animate ? "animate" : "css" ]( { height: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } ); + that.range[ animate ? "animate" : "css" ]( { + height: ( valPercent - lastValPercent ) + "%" + }, { + queue: false, + duration: o.animate + } ); } } } @@ -628,16 +645,24 @@ return $.widget( "ui.slider", $.ui.mouse, { this.handle.stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate ); if ( oRange === "min" && this.orientation === "horizontal" ) { - this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { width: valPercent + "%" }, o.animate ); + this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { + width: valPercent + "%" + }, o.animate ); } if ( oRange === "max" && this.orientation === "horizontal" ) { - this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { width: ( 100 - valPercent ) + "%" }, o.animate ); + this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { + width: ( 100 - valPercent ) + "%" + }, o.animate ); } if ( oRange === "min" && this.orientation === "vertical" ) { - this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { height: valPercent + "%" }, o.animate ); + this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { + height: valPercent + "%" + }, o.animate ); } if ( oRange === "max" && this.orientation === "vertical" ) { - this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { height: ( 100 - valPercent ) + "%" }, o.animate ); + this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { + height: ( 100 - valPercent ) + "%" + }, o.animate ); } } }, From b74a8b68bd1e2922244a37ab6a39fb579ce429bb Mon Sep 17 00:00:00 2001 From: Alexander Schmitz Date: Wed, 30 Mar 2016 22:31:17 -0400 Subject: [PATCH 007/136] Selectable: Fix line length issues Ref gh-1690 --- ui/widgets/selectable.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ui/widgets/selectable.js b/ui/widgets/selectable.js index f3f144a81..de7c59faf 100644 --- a/ui/widgets/selectable.js +++ b/ui/widgets/selectable.js @@ -137,7 +137,8 @@ return $.widget( "ui.selectable", $.ui.mouse, { var doSelect, selectee = $.data( this, "selectable-item" ); if ( selectee ) { - doSelect = ( !event.metaKey && !event.ctrlKey ) || !selectee.$element.hasClass( "ui-selected" ); + doSelect = ( !event.metaKey && !event.ctrlKey ) || + !selectee.$element.hasClass( "ui-selected" ); that._removeClass( selectee.$element, doSelect ? "ui-unselecting" : "ui-selected" ) ._addClass( selectee.$element, doSelect ? "ui-selecting" : "ui-unselecting" ); selectee.unselecting = !doSelect; @@ -190,9 +191,11 @@ return $.widget( "ui.selectable", $.ui.mouse, { } if ( options.tolerance === "touch" ) { - hit = ( !( selectee.left > x2 || selectee.right < x1 || selectee.top > y2 || selectee.bottom < y1 ) ); + hit = ( !( selectee.left > x2 || selectee.right < x1 || selectee.top > y2 || + selectee.bottom < y1 ) ); } else if ( options.tolerance === "fit" ) { - hit = ( selectee.left > x1 && selectee.right < x2 && selectee.top > y1 && selectee.bottom < y2 ); + hit = ( selectee.left > x1 && selectee.right < x2 && selectee.top > y1 && + selectee.bottom < y2 ); } if ( hit ) { From c5eca7443c6d6d425b08c4c6d93e77ccc2702fdc Mon Sep 17 00:00:00 2001 From: Alexander Schmitz Date: Wed, 30 Mar 2016 22:33:08 -0400 Subject: [PATCH 008/136] Resizable: Fix line length issues Ref gh-1690 --- ui/widgets/resizable.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/ui/widgets/resizable.js b/ui/widgets/resizable.js index a811c6334..74863a055 100644 --- a/ui/widgets/resizable.js +++ b/ui/widgets/resizable.js @@ -286,11 +286,15 @@ $.widget( "ui.resizable", $.ui.mouse, { this._on( this.handles[ i ], { "mousedown": that._mouseDown } ); } - if ( this.elementIsWrapper && this.originalElement[ 0 ].nodeName.match( /^(textarea|input|select|button)$/i ) ) { - + if ( this.elementIsWrapper && + this.originalElement[ 0 ] + .nodeName + .match( /^(textarea|input|select|button)$/i ) ) { axis = $( this.handles[ i ], this.element ); - padWrapper = /sw|ne|nw|se|n|s/.test( i ) ? axis.outerHeight() : axis.outerWidth(); + padWrapper = /sw|ne|nw|se|n|s/.test( i ) ? + axis.outerHeight() : + axis.outerWidth(); padPos = [ "padding", /ne|nw|n/.test( i ) ? "Top" : @@ -797,7 +801,10 @@ $.ui.plugin.add( "resizable", "animate", { ista = pr.length && ( /textarea/i ).test( pr[ 0 ].nodeName ), soffseth = ista && that._hasScroll( pr[ 0 ], "left" ) ? 0 : that.sizeDiff.height, soffsetw = ista ? 0 : that.sizeDiff.width, - style = { width: ( that.size.width - soffsetw ), height: ( that.size.height - soffseth ) }, + style = { + width: ( that.size.width - soffsetw ), + height: ( that.size.height - soffseth ) + }, left = ( parseFloat( that.element.css( "left" ) ) + ( that.position.left - that.originalPosition.left ) ) || null, top = ( parseFloat( that.element.css( "top" ) ) + @@ -839,7 +846,9 @@ $.ui.plugin.add( "resizable", "containment", { o = that.options, el = that.element, oc = o.containment, - ce = ( oc instanceof $ ) ? oc.get( 0 ) : ( /parent/.test( oc ) ) ? el.parent().get( 0 ) : oc; + ce = ( oc instanceof $ ) ? + oc.get( 0 ) : + ( /parent/.test( oc ) ) ? el.parent().get( 0 ) : oc; if ( !ce ) { return; From a69b1a9eb860f62060d668eeebf04195618f99f2 Mon Sep 17 00:00:00 2001 From: Alexander Schmitz Date: Wed, 30 Mar 2016 22:52:49 -0400 Subject: [PATCH 009/136] Progressbar: Fix line length issues Ref gh-1690 --- ui/widgets/progressbar.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ui/widgets/progressbar.js b/ui/widgets/progressbar.js index 6afba892e..ba4542583 100644 --- a/ui/widgets/progressbar.js +++ b/ui/widgets/progressbar.js @@ -128,7 +128,9 @@ return $.widget( "ui.progressbar", { }, _percentage: function() { - return this.indeterminate ? 100 : 100 * ( this.options.value - this.min ) / ( this.options.max - this.min ); + return this.indeterminate ? + 100 : + 100 * ( this.options.value - this.min ) / ( this.options.max - this.min ); }, _refreshValue: function() { From 55b53b54625d690bb1371cd7171b318e9e651dcb Mon Sep 17 00:00:00 2001 From: Alexander Schmitz Date: Wed, 30 Mar 2016 22:54:03 -0400 Subject: [PATCH 010/136] Mouse: Fix line length issues Ref gh-1690 --- ui/widgets/mouse.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ui/widgets/mouse.js b/ui/widgets/mouse.js index c14aebe53..0ae8979a1 100644 --- a/ui/widgets/mouse.js +++ b/ui/widgets/mouse.js @@ -89,7 +89,8 @@ return $.widget( "ui.mouse", { // event.target.nodeName works around a bug in IE 8 with // disabled inputs (#7620) - elIsCancel = ( typeof this.options.cancel === "string" && event.target.nodeName ? $( event.target ).closest( this.options.cancel ).length : false ); + elIsCancel = ( typeof this.options.cancel === "string" && event.target.nodeName ? + $( event.target ).closest( this.options.cancel ).length : false ); if ( !btnIsLeft || elIsCancel || !this._mouseCapture( event ) ) { return true; } @@ -141,7 +142,8 @@ return $.widget( "ui.mouse", { if ( this._mouseMoved ) { // IE mouseup check - mouseup happened when mouse was out of window - if ( $.ui.ie && ( !document.documentMode || document.documentMode < 9 ) && !event.button ) { + if ( $.ui.ie && ( !document.documentMode || document.documentMode < 9 ) && + !event.button ) { return this._mouseUp( event ); // Iframe mouseup check - mouseup occurred in another document From 88f74e16567cd7b3dd70ad92e29968ea3413458e Mon Sep 17 00:00:00 2001 From: Alexander Schmitz Date: Wed, 30 Mar 2016 23:02:12 -0400 Subject: [PATCH 011/136] Menu: Fix line length issues Ref gh-1690 --- ui/widgets/menu.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/ui/widgets/menu.js b/ui/widgets/menu.js index 22db41988..329bfc610 100644 --- a/ui/widgets/menu.js +++ b/ui/widgets/menu.js @@ -81,6 +81,7 @@ return $.widget( "ui.menu", { }, "click .ui-menu-item": function( event ) { var target = $( event.target ); + var active = $( $.ui.safeActiveElement( this.document[ 0 ] ) ); if ( !this.mouseHandled && target.not( ".ui-state-disabled" ).length ) { this.select( event ); @@ -89,10 +90,13 @@ return $.widget( "ui.menu", { this.mouseHandled = true; } + + // Open submenu on click if ( target.has( ".ui-menu" ).length ) { this.expand( event ); - } else if ( !this.element.is( ":focus" ) && $( $.ui.safeActiveElement( this.document[ 0 ] ) ).closest( ".ui-menu" ).length ) { + } else if ( !this.element.is( ":focus" ) && + active.closest( ".ui-menu" ).length ) { // Redirect focus to the menu this.element.trigger( "focus", [ true ] ); @@ -142,7 +146,11 @@ return $.widget( "ui.menu", { }, blur: function( event ) { this._delay( function() { - if ( !$.contains( this.element[ 0 ], $.ui.safeActiveElement( this.document[ 0 ] ) ) ) { + var notContained = !$.contains( + this.element[ 0 ], + $.ui.safeActiveElement( this.document[ 0 ] ) + ); + if ( notContained ) { this.collapseAll( event ); } } ); @@ -479,7 +487,8 @@ return $.widget( "ui.menu", { var currentMenu = all ? this.element : $( event && event.target ).closest( this.element.find( ".ui-menu" ) ); - // If we found no valid submenu ancestor, use the main menu to close all sub menus anyway + // If we found no valid submenu ancestor, use the main menu to close all + // sub menus anyway if ( !currentMenu.length ) { currentMenu = this.element; } From 8a6d4c1a150376a1fbc5dc3ca23a66fe30fcc921 Mon Sep 17 00:00:00 2001 From: Alexander Schmitz Date: Wed, 30 Mar 2016 23:15:29 -0400 Subject: [PATCH 012/136] Droppable: Fix line length issues Ref gh-1690 --- ui/widgets/droppable.js | 85 ++++++++++++++++++++++++++++------------- 1 file changed, 58 insertions(+), 27 deletions(-) diff --git a/ui/widgets/droppable.js b/ui/widgets/droppable.js index 136a32b80..f683c7893 100644 --- a/ui/widgets/droppable.js +++ b/ui/widgets/droppable.js @@ -145,11 +145,13 @@ $.widget( "ui.droppable", { var draggable = $.ui.ddmanager.current; // Bail if draggable and droppable are same element - if ( !draggable || ( draggable.currentItem || draggable.element )[ 0 ] === this.element[ 0 ] ) { + if ( !draggable || ( draggable.currentItem || + draggable.element )[ 0 ] === this.element[ 0 ] ) { return; } - if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) { + if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem || + draggable.element ) ) ) { this._addHoverClass(); this._trigger( "over", event, this.ui( draggable ) ); } @@ -161,11 +163,13 @@ $.widget( "ui.droppable", { var draggable = $.ui.ddmanager.current; // Bail if draggable and droppable are same element - if ( !draggable || ( draggable.currentItem || draggable.element )[ 0 ] === this.element[ 0 ] ) { + if ( !draggable || ( draggable.currentItem || + draggable.element )[ 0 ] === this.element[ 0 ] ) { return; } - if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) { + if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem || + draggable.element ) ) ) { this._removeHoverClass(); this._trigger( "out", event, this.ui( draggable ) ); } @@ -178,25 +182,38 @@ $.widget( "ui.droppable", { childrenIntersection = false; // Bail if draggable and droppable are same element - if ( !draggable || ( draggable.currentItem || draggable.element )[ 0 ] === this.element[ 0 ] ) { + if ( !draggable || ( draggable.currentItem || + draggable.element )[ 0 ] === this.element[ 0 ] ) { return false; } - this.element.find( ":data(ui-droppable)" ).not( ".ui-draggable-dragging" ).each( function() { - var inst = $( this ).droppable( "instance" ); - if ( - inst.options.greedy && - !inst.options.disabled && - inst.options.scope === draggable.options.scope && - inst.accept.call( inst.element[ 0 ], ( draggable.currentItem || draggable.element ) ) && - intersect( draggable, $.extend( inst, { offset: inst.element.offset() } ), inst.options.tolerance, event ) - ) { childrenIntersection = true; return false; } - } ); + this.element + .find( ":data(ui-droppable)" ) + .not( ".ui-draggable-dragging" ) + .each( function() { + var inst = $( this ).droppable( "instance" ); + if ( + inst.options.greedy && + !inst.options.disabled && + inst.options.scope === draggable.options.scope && + inst.accept.call( + inst.element[ 0 ], ( draggable.currentItem || draggable.element ) + ) && + intersect( + draggable, + $.extend( inst, { offset: inst.element.offset() } ), + inst.options.tolerance, event + ) + ) { + childrenIntersection = true; + return false; } + } ); if ( childrenIntersection ) { return false; } - if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) { + if ( this.accept.call( this.element[ 0 ], + ( draggable.currentItem || draggable.element ) ) ) { this._removeActiveClass(); this._removeHoverClass(); @@ -247,8 +264,10 @@ var intersect = ( function() { return false; } - var x1 = ( draggable.positionAbs || draggable.position.absolute ).left + draggable.margins.left, - y1 = ( draggable.positionAbs || draggable.position.absolute ).top + draggable.margins.top, + var x1 = ( draggable.positionAbs || + draggable.position.absolute ).left + draggable.margins.left, + y1 = ( draggable.positionAbs || + draggable.position.absolute ).top + draggable.margins.top, x2 = x1 + draggable.helperProportions.width, y2 = y1 + draggable.helperProportions.height, l = droppable.offset.left, @@ -265,7 +284,8 @@ var intersect = ( function() { t < y1 + ( draggable.helperProportions.height / 2 ) && // Bottom Half y2 - ( draggable.helperProportions.height / 2 ) < b ); // Top Half case "pointer": - return isOverAxis( event.pageY, t, droppable.proportions().height ) && isOverAxis( event.pageX, l, droppable.proportions().width ); + return isOverAxis( event.pageY, t, droppable.proportions().height ) && + isOverAxis( event.pageX, l, droppable.proportions().width ); case "touch": return ( ( y1 >= t && y1 <= b ) || // Top edge touching @@ -298,7 +318,8 @@ $.ui.ddmanager = { droppablesLoop: for ( i = 0; i < m.length; i++ ) { // No disabled and non-accepted - if ( m[ i ].options.disabled || ( t && !m[ i ].accept.call( m[ i ].element[ 0 ], ( t.currentItem || t.element ) ) ) ) { + if ( m[ i ].options.disabled || ( t && !m[ i ].accept.call( m[ i ].element[ 0 ], + ( t.currentItem || t.element ) ) ) ) { continue; } @@ -321,7 +342,10 @@ $.ui.ddmanager = { } m[ i ].offset = m[ i ].element.offset(); - m[ i ].proportions( { width: m[ i ].element[ 0 ].offsetWidth, height: m[ i ].element[ 0 ].offsetHeight } ); + m[ i ].proportions( { + width: m[ i ].element[ 0 ].offsetWidth, + height: m[ i ].element[ 0 ].offsetHeight + } ); } @@ -336,11 +360,13 @@ $.ui.ddmanager = { if ( !this.options ) { return; } - if ( !this.options.disabled && this.visible && intersect( draggable, this, this.options.tolerance, event ) ) { + if ( !this.options.disabled && this.visible && + intersect( draggable, this, this.options.tolerance, event ) ) { dropped = this._drop.call( this, event ) || dropped; } - if ( !this.options.disabled && this.visible && this.accept.call( this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) { + if ( !this.options.disabled && this.visible && this.accept.call( this.element[ 0 ], + ( draggable.currentItem || draggable.element ) ) ) { this.isout = true; this.isover = false; this._deactivate.call( this, event ); @@ -352,7 +378,8 @@ $.ui.ddmanager = { }, dragStart: function( draggable, event ) { - // Listen for scrolling so that if the dragging causes scrolling the position of the droppables can be recalculated (see #5003) + // Listen for scrolling so that if the dragging causes scrolling the position of the + // droppables can be recalculated (see #5003) draggable.element.parentsUntil( "body" ).on( "scroll.droppable", function() { if ( !draggable.options.refreshPositions ) { $.ui.ddmanager.prepareOffsets( draggable, event ); @@ -361,7 +388,8 @@ $.ui.ddmanager = { }, drag: function( draggable, event ) { - // If you have a highly dynamic page, you might try this option. It renders positions every time you move the mouse. + // If you have a highly dynamic page, you might try this option. It renders positions + // every time you move the mouse. if ( draggable.options.refreshPositions ) { $.ui.ddmanager.prepareOffsets( draggable, event ); } @@ -375,7 +403,9 @@ $.ui.ddmanager = { var parentInstance, scope, parent, intersects = intersect( draggable, this, this.options.tolerance, event ), - c = !intersects && this.isover ? "isout" : ( intersects && !this.isover ? "isover" : null ); + c = !intersects && this.isover ? + "isout" : + ( intersects && !this.isover ? "isover" : null ); if ( !c ) { return; } @@ -417,7 +447,8 @@ $.ui.ddmanager = { dragStop: function( draggable, event ) { draggable.element.parentsUntil( "body" ).off( "scroll.droppable" ); - // Call prepareOffsets one final time since IE does not fire return scroll events when overflow was caused by drag (see #5003) + // Call prepareOffsets one final time since IE does not fire return scroll events when + // overflow was caused by drag (see #5003) if ( !draggable.options.refreshPositions ) { $.ui.ddmanager.prepareOffsets( draggable, event ); } From 545bcfec8ec82340b6325a63d3b5b9e9b9c1b6ef Mon Sep 17 00:00:00 2001 From: Alexander Schmitz Date: Wed, 30 Mar 2016 23:40:17 -0400 Subject: [PATCH 013/136] Draggable: Fix line length issues Ref gh-1690 --- ui/widgets/draggable.js | 279 +++++++++++++++++++++++++++++----------- 1 file changed, 202 insertions(+), 77 deletions(-) diff --git a/ui/widgets/draggable.js b/ui/widgets/draggable.js index 32bf861ed..6b862d0d0 100644 --- a/ui/widgets/draggable.js +++ b/ui/widgets/draggable.js @@ -106,7 +106,8 @@ $.widget( "ui.draggable", $.ui.mouse, { this._blurActiveElement( event ); // Among others, prevent a drag on a resizable-handle - if ( this.helper || o.disabled || $( event.target ).closest( ".ui-resizable-handle" ).length > 0 ) { + if ( this.helper || o.disabled || + $( event.target ).closest( ".ui-resizable-handle" ).length > 0 ) { return false; } @@ -220,9 +221,12 @@ $.widget( "ui.draggable", $.ui.mouse, { $.ui.ddmanager.prepareOffsets( this, event ); } - this._mouseDrag( event, true ); //Execute the drag once - this causes the helper not to be visible before getting its correct position + // Execute the drag once - this causes the helper not to be visible before getting its + // correct position + this._mouseDrag( event, true ); - //If the ddmanager is used for droppables, inform the manager that dragging has started (see #5003) + // If the ddmanager is used for droppables, inform the manager that dragging has started + // (see #5003) if ( $.ui.ddmanager ) { $.ui.ddmanager.dragStart( this, event ); } @@ -291,12 +295,20 @@ $.widget( "ui.draggable", $.ui.mouse, { this.dropped = false; } - if ( ( this.options.revert === "invalid" && !dropped ) || ( this.options.revert === "valid" && dropped ) || this.options.revert === true || ( $.isFunction( this.options.revert ) && this.options.revert.call( this.element, dropped ) ) ) { - $( this.helper ).animate( this.originalPosition, parseInt( this.options.revertDuration, 10 ), function() { - if ( that._trigger( "stop", event ) !== false ) { - that._clear(); + if ( ( this.options.revert === "invalid" && !dropped ) || + ( this.options.revert === "valid" && dropped ) || + this.options.revert === true || ( $.isFunction( this.options.revert ) && + this.options.revert.call( this.element, dropped ) ) + ) { + $( this.helper ).animate( + this.originalPosition, + parseInt( this.options.revertDuration, 10 ), + function() { + if ( that._trigger( "stop", event ) !== false ) { + that._clear(); + } } - } ); + ); } else { if ( this._trigger( "stop", event ) !== false ) { this._clear(); @@ -309,7 +321,8 @@ $.widget( "ui.draggable", $.ui.mouse, { _mouseUp: function( event ) { this._unblockFrames(); - //If the ddmanager is used for droppables, inform the manager that dragging has stopped (see #5003) + // If the ddmanager is used for droppables, inform the manager that dragging has stopped + // (see #5003) if ( $.ui.ddmanager ) { $.ui.ddmanager.dragStop( this, event ); } @@ -317,7 +330,8 @@ $.widget( "ui.draggable", $.ui.mouse, { // Only need to focus if the event occurred on the draggable itself, see #10527 if ( this.handleElement.is( event.target ) ) { - // The interaction is over; whether or not the click resulted in a drag, focus the element + // The interaction is over; whether or not the click resulted in a drag, + // focus the element this.element.trigger( "focus" ); } @@ -363,7 +377,9 @@ $.widget( "ui.draggable", $.ui.mouse, { this.element ); if ( !helper.parents( "body" ).length ) { - helper.appendTo( ( o.appendTo === "parent" ? this.element[ 0 ].parentNode : o.appendTo ) ); + helper.appendTo( ( o.appendTo === "parent" ? + this.element[ 0 ].parentNode : + o.appendTo ) ); } // Http://bugs.jqueryui.com/ticket/9446 @@ -373,7 +389,8 @@ $.widget( "ui.draggable", $.ui.mouse, { this._setPositionRelative(); } - if ( helper[ 0 ] !== this.element[ 0 ] && !( /(fixed|absolute)/ ).test( helper.css( "position" ) ) ) { + if ( helper[ 0 ] !== this.element[ 0 ] && + !( /(fixed|absolute)/ ).test( helper.css( "position" ) ) ) { helper.css( "position", "absolute" ); } @@ -418,11 +435,15 @@ $.widget( "ui.draggable", $.ui.mouse, { var po = this.offsetParent.offset(), document = this.document[ 0 ]; - // This is a special case where we need to modify a offset calculated on start, since the following happened: - // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent - // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that - // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag - if ( this.cssPosition === "absolute" && this.scrollParent[ 0 ] !== document && $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) { + // This is a special case where we need to modify a offset calculated on start, since the + // following happened: + // 1. The position of the helper is absolute, so it's position is calculated based on the + // next positioned parent + // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't + // the document, which means that the scroll is included in the initial calculation of the + // offset of the parent, and never recalculated upon drag + if ( this.cssPosition === "absolute" && this.scrollParent[ 0 ] !== document && + $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) { po.left += this.scrollParent.scrollLeft(); po.top += this.scrollParent.scrollTop(); } @@ -447,8 +468,10 @@ $.widget( "ui.draggable", $.ui.mouse, { scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] ); return { - top: p.top - ( parseInt( this.helper.css( "top" ), 10 ) || 0 ) + ( !scrollIsRootNode ? this.scrollParent.scrollTop() : 0 ), - left: p.left - ( parseInt( this.helper.css( "left" ), 10 ) || 0 ) + ( !scrollIsRootNode ? this.scrollParent.scrollLeft() : 0 ) + top: p.top - ( parseInt( this.helper.css( "top" ), 10 ) || 0 ) + + ( !scrollIsRootNode ? this.scrollParent.scrollTop() : 0 ), + left: p.left - ( parseInt( this.helper.css( "left" ), 10 ) || 0 ) + + ( !scrollIsRootNode ? this.scrollParent.scrollLeft() : 0 ) }; }, @@ -486,8 +509,11 @@ $.widget( "ui.draggable", $.ui.mouse, { this.containment = [ $( window ).scrollLeft() - this.offset.relative.left - this.offset.parent.left, $( window ).scrollTop() - this.offset.relative.top - this.offset.parent.top, - $( window ).scrollLeft() + $( window ).width() - this.helperProportions.width - this.margins.left, - $( window ).scrollTop() + ( $( window ).height() || document.body.parentNode.scrollHeight ) - this.helperProportions.height - this.margins.top + $( window ).scrollLeft() + $( window ).width() - + this.helperProportions.width - this.margins.left, + $( window ).scrollTop() + + ( $( window ).height() || document.body.parentNode.scrollHeight ) - + this.helperProportions.height - this.margins.top ]; return; } @@ -497,7 +523,8 @@ $.widget( "ui.draggable", $.ui.mouse, { 0, 0, $( document ).width() - this.helperProportions.width - this.margins.left, - ( $( document ).height() || document.body.parentNode.scrollHeight ) - this.helperProportions.height - this.margins.top + ( $( document ).height() || document.body.parentNode.scrollHeight ) - + this.helperProportions.height - this.margins.top ]; return; } @@ -521,8 +548,10 @@ $.widget( "ui.draggable", $.ui.mouse, { isUserScrollable = /(scroll|auto)/.test( c.css( "overflow" ) ); this.containment = [ - ( parseInt( c.css( "borderLeftWidth" ), 10 ) || 0 ) + ( parseInt( c.css( "paddingLeft" ), 10 ) || 0 ), - ( parseInt( c.css( "borderTopWidth" ), 10 ) || 0 ) + ( parseInt( c.css( "paddingTop" ), 10 ) || 0 ), + ( parseInt( c.css( "borderLeftWidth" ), 10 ) || 0 ) + + ( parseInt( c.css( "paddingLeft" ), 10 ) || 0 ), + ( parseInt( c.css( "borderTopWidth" ), 10 ) || 0 ) + + ( parseInt( c.css( "paddingTop" ), 10 ) || 0 ), ( isUserScrollable ? Math.max( ce.scrollWidth, ce.offsetWidth ) : ce.offsetWidth ) - ( parseInt( c.css( "borderRightWidth" ), 10 ) || 0 ) - ( parseInt( c.css( "paddingRight" ), 10 ) || 0 ) - @@ -550,16 +579,32 @@ $.widget( "ui.draggable", $.ui.mouse, { return { top: ( - pos.top + // The absolute mouse position - this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent - this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border) - ( ( this.cssPosition === "fixed" ? -this.offset.scroll.top : ( scrollIsRootNode ? 0 : this.offset.scroll.top ) ) * mod ) + + // The absolute mouse position + pos.top + + + // Only for relative positioned nodes: Relative offset from element to offset parent + this.offset.relative.top * mod + + + // The offsetParent's offset without borders (offset + border) + this.offset.parent.top * mod - + ( ( this.cssPosition === "fixed" ? + -this.offset.scroll.top : + ( scrollIsRootNode ? 0 : this.offset.scroll.top ) ) * mod ) ), left: ( - pos.left + // The absolute mouse position - this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent - this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border) - ( ( this.cssPosition === "fixed" ? -this.offset.scroll.left : ( scrollIsRootNode ? 0 : this.offset.scroll.left ) ) * mod ) + + // The absolute mouse position + pos.left + + + // Only for relative positioned nodes: Relative offset from element to offset parent + this.offset.relative.left * mod + + + // The offsetParent's offset without borders (offset + border) + this.offset.parent.left * mod - + ( ( this.cssPosition === "fixed" ? + -this.offset.scroll.left : + ( scrollIsRootNode ? 0 : this.offset.scroll.left ) ) * mod ) ) }; @@ -617,12 +662,24 @@ $.widget( "ui.draggable", $.ui.mouse, { if ( o.grid ) { - //Check for grid elements set to 0 to prevent divide by 0 error causing invalid argument errors in IE (see ticket #6950) - top = o.grid[ 1 ] ? this.originalPageY + Math.round( ( pageY - this.originalPageY ) / o.grid[ 1 ] ) * o.grid[ 1 ] : this.originalPageY; - pageY = containment ? ( ( top - this.offset.click.top >= containment[ 1 ] || top - this.offset.click.top > containment[ 3 ] ) ? top : ( ( top - this.offset.click.top >= containment[ 1 ] ) ? top - o.grid[ 1 ] : top + o.grid[ 1 ] ) ) : top; + //Check for grid elements set to 0 to prevent divide by 0 error causing invalid + // argument errors in IE (see ticket #6950) + top = o.grid[ 1 ] ? this.originalPageY + Math.round( ( pageY - + this.originalPageY ) / o.grid[ 1 ] ) * o.grid[ 1 ] : this.originalPageY; + pageY = containment ? ( ( top - this.offset.click.top >= containment[ 1 ] || + top - this.offset.click.top > containment[ 3 ] ) ? + top : + ( ( top - this.offset.click.top >= containment[ 1 ] ) ? + top - o.grid[ 1 ] : top + o.grid[ 1 ] ) ) : top; - left = o.grid[ 0 ] ? this.originalPageX + Math.round( ( pageX - this.originalPageX ) / o.grid[ 0 ] ) * o.grid[ 0 ] : this.originalPageX; - pageX = containment ? ( ( left - this.offset.click.left >= containment[ 0 ] || left - this.offset.click.left > containment[ 2 ] ) ? left : ( ( left - this.offset.click.left >= containment[ 0 ] ) ? left - o.grid[ 0 ] : left + o.grid[ 0 ] ) ) : left; + left = o.grid[ 0 ] ? this.originalPageX + + Math.round( ( pageX - this.originalPageX ) / o.grid[ 0 ] ) * o.grid[ 0 ] : + this.originalPageX; + pageX = containment ? ( ( left - this.offset.click.left >= containment[ 0 ] || + left - this.offset.click.left > containment[ 2 ] ) ? + left : + ( ( left - this.offset.click.left >= containment[ 0 ] ) ? + left - o.grid[ 0 ] : left + o.grid[ 0 ] ) ) : left; } if ( o.axis === "y" ) { @@ -636,18 +693,38 @@ $.widget( "ui.draggable", $.ui.mouse, { return { top: ( - pageY - // The absolute mouse position - this.offset.click.top - // Click offset (relative to the element) - this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent - this.offset.parent.top + // The offsetParent's offset without borders (offset + border) - ( this.cssPosition === "fixed" ? -this.offset.scroll.top : ( scrollIsRootNode ? 0 : this.offset.scroll.top ) ) + + // The absolute mouse position + pageY - + + // Click offset (relative to the element) + this.offset.click.top - + + // Only for relative positioned nodes: Relative offset from element to offset parent + this.offset.relative.top - + + // The offsetParent's offset without borders (offset + border) + this.offset.parent.top + + ( this.cssPosition === "fixed" ? + -this.offset.scroll.top : + ( scrollIsRootNode ? 0 : this.offset.scroll.top ) ) ), left: ( - pageX - // The absolute mouse position - this.offset.click.left - // Click offset (relative to the element) - this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent - this.offset.parent.left + // The offsetParent's offset without borders (offset + border) - ( this.cssPosition === "fixed" ? -this.offset.scroll.left : ( scrollIsRootNode ? 0 : this.offset.scroll.left ) ) + + // The absolute mouse position + pageX - + + // Click offset (relative to the element) + this.offset.click.left - + + // Only for relative positioned nodes: Relative offset from element to offset parent + this.offset.relative.left - + + // The offsetParent's offset without borders (offset + border) + this.offset.parent.left + + ( this.cssPosition === "fixed" ? + -this.offset.scroll.left : + ( scrollIsRootNode ? 0 : this.offset.scroll.left ) ) ) }; @@ -936,7 +1013,8 @@ $.ui.plugin.add( "draggable", "scroll", { i.scrollParentNotHidden = i.helper.scrollParent( false ); } - if ( i.scrollParentNotHidden[ 0 ] !== i.document[ 0 ] && i.scrollParentNotHidden[ 0 ].tagName !== "HTML" ) { + if ( i.scrollParentNotHidden[ 0 ] !== i.document[ 0 ] && + i.scrollParentNotHidden[ 0 ].tagName !== "HTML" ) { i.overflowOffset = i.scrollParentNotHidden.offset(); } }, @@ -949,7 +1027,8 @@ $.ui.plugin.add( "draggable", "scroll", { if ( scrollParent !== document && scrollParent.tagName !== "HTML" ) { if ( !o.axis || o.axis !== "x" ) { - if ( ( i.overflowOffset.top + scrollParent.offsetHeight ) - event.pageY < o.scrollSensitivity ) { + if ( ( i.overflowOffset.top + scrollParent.offsetHeight ) - event.pageY < + o.scrollSensitivity ) { scrollParent.scrollTop = scrolled = scrollParent.scrollTop + o.scrollSpeed; } else if ( event.pageY - i.overflowOffset.top < o.scrollSensitivity ) { scrollParent.scrollTop = scrolled = scrollParent.scrollTop - o.scrollSpeed; @@ -957,7 +1036,8 @@ $.ui.plugin.add( "draggable", "scroll", { } if ( !o.axis || o.axis !== "y" ) { - if ( ( i.overflowOffset.left + scrollParent.offsetWidth ) - event.pageX < o.scrollSensitivity ) { + if ( ( i.overflowOffset.left + scrollParent.offsetWidth ) - event.pageX < + o.scrollSensitivity ) { scrollParent.scrollLeft = scrolled = scrollParent.scrollLeft + o.scrollSpeed; } else if ( event.pageX - i.overflowOffset.left < o.scrollSensitivity ) { scrollParent.scrollLeft = scrolled = scrollParent.scrollLeft - o.scrollSpeed; @@ -969,16 +1049,22 @@ $.ui.plugin.add( "draggable", "scroll", { if ( !o.axis || o.axis !== "x" ) { if ( event.pageY - $( document ).scrollTop() < o.scrollSensitivity ) { scrolled = $( document ).scrollTop( $( document ).scrollTop() - o.scrollSpeed ); - } else if ( $( window ).height() - ( event.pageY - $( document ).scrollTop() ) < o.scrollSensitivity ) { + } else if ( $( window ).height() - ( event.pageY - $( document ).scrollTop() ) < + o.scrollSensitivity ) { scrolled = $( document ).scrollTop( $( document ).scrollTop() + o.scrollSpeed ); } } if ( !o.axis || o.axis !== "y" ) { if ( event.pageX - $( document ).scrollLeft() < o.scrollSensitivity ) { - scrolled = $( document ).scrollLeft( $( document ).scrollLeft() - o.scrollSpeed ); - } else if ( $( window ).width() - ( event.pageX - $( document ).scrollLeft() ) < o.scrollSensitivity ) { - scrolled = $( document ).scrollLeft( $( document ).scrollLeft() + o.scrollSpeed ); + scrolled = $( document ).scrollLeft( + $( document ).scrollLeft() - o.scrollSpeed + ); + } else if ( $( window ).width() - ( event.pageX - $( document ).scrollLeft() ) < + o.scrollSensitivity ) { + scrolled = $( document ).scrollLeft( + $( document ).scrollLeft() + o.scrollSpeed + ); } } @@ -998,17 +1084,18 @@ $.ui.plugin.add( "draggable", "snap", { i.snapElements = []; - $( o.snap.constructor !== String ? ( o.snap.items || ":data(ui-draggable)" ) : o.snap ).each( function() { - var $t = $( this ), - $o = $t.offset(); - if ( this !== i.element[ 0 ] ) { - i.snapElements.push( { - item: this, - width: $t.outerWidth(), height: $t.outerHeight(), - top: $o.top, left: $o.left - } ); - } - } ); + $( o.snap.constructor !== String ? ( o.snap.items || ":data(ui-draggable)" ) : o.snap ) + .each( function() { + var $t = $( this ), + $o = $t.offset(); + if ( this !== i.element[ 0 ] ) { + i.snapElements.push( { + item: this, + width: $t.outerWidth(), height: $t.outerHeight(), + top: $o.top, left: $o.left + } ); + } + } ); }, drag: function( event, ui, inst ) { @@ -1026,9 +1113,16 @@ $.ui.plugin.add( "draggable", "snap", { t = inst.snapElements[ i ].top - inst.margins.top; b = t + inst.snapElements[ i ].height; - if ( x2 < l - d || x1 > r + d || y2 < t - d || y1 > b + d || !$.contains( inst.snapElements[ i ].item.ownerDocument, inst.snapElements[ i ].item ) ) { + if ( x2 < l - d || x1 > r + d || y2 < t - d || y1 > b + d || + !$.contains( inst.snapElements[ i ].item.ownerDocument, + inst.snapElements[ i ].item ) ) { if ( inst.snapElements[ i ].snapping ) { - ( inst.options.snap.release && inst.options.snap.release.call( inst.element, event, $.extend( inst._uiHash(), { snapItem: inst.snapElements[ i ].item } ) ) ); + ( inst.options.snap.release && + inst.options.snap.release.call( + inst.element, + event, + $.extend( inst._uiHash(), { snapItem: inst.snapElements[ i ].item } ) + ) ); } inst.snapElements[ i ].snapping = false; continue; @@ -1040,16 +1134,28 @@ $.ui.plugin.add( "draggable", "snap", { ls = Math.abs( l - x2 ) <= d; rs = Math.abs( r - x1 ) <= d; if ( ts ) { - ui.position.top = inst._convertPositionTo( "relative", { top: t - inst.helperProportions.height, left: 0 } ).top; + ui.position.top = inst._convertPositionTo( "relative", { + top: t - inst.helperProportions.height, + left: 0 + } ).top; } if ( bs ) { - ui.position.top = inst._convertPositionTo( "relative", { top: b, left: 0 } ).top; + ui.position.top = inst._convertPositionTo( "relative", { + top: b, + left: 0 + } ).top; } if ( ls ) { - ui.position.left = inst._convertPositionTo( "relative", { top: 0, left: l - inst.helperProportions.width } ).left; + ui.position.left = inst._convertPositionTo( "relative", { + top: 0, + left: l - inst.helperProportions.width + } ).left; } if ( rs ) { - ui.position.left = inst._convertPositionTo( "relative", { top: 0, left: r } ).left; + ui.position.left = inst._convertPositionTo( "relative", { + top: 0, + left: r + } ).left; } } @@ -1061,21 +1167,39 @@ $.ui.plugin.add( "draggable", "snap", { ls = Math.abs( l - x1 ) <= d; rs = Math.abs( r - x2 ) <= d; if ( ts ) { - ui.position.top = inst._convertPositionTo( "relative", { top: t, left: 0 } ).top; + ui.position.top = inst._convertPositionTo( "relative", { + top: t, + left: 0 + } ).top; } if ( bs ) { - ui.position.top = inst._convertPositionTo( "relative", { top: b - inst.helperProportions.height, left: 0 } ).top; + ui.position.top = inst._convertPositionTo( "relative", { + top: b - inst.helperProportions.height, + left: 0 + } ).top; } if ( ls ) { - ui.position.left = inst._convertPositionTo( "relative", { top: 0, left: l } ).left; + ui.position.left = inst._convertPositionTo( "relative", { + top: 0, + left: l + } ).left; } if ( rs ) { - ui.position.left = inst._convertPositionTo( "relative", { top: 0, left: r - inst.helperProportions.width } ).left; + ui.position.left = inst._convertPositionTo( "relative", { + top: 0, + left: r - inst.helperProportions.width + } ).left; } } if ( !inst.snapElements[ i ].snapping && ( ts || bs || ls || rs || first ) ) { - ( inst.options.snap.snap && inst.options.snap.snap.call( inst.element, event, $.extend( inst._uiHash(), { snapItem: inst.snapElements[ i ].item } ) ) ); + ( inst.options.snap.snap && + inst.options.snap.snap.call( + inst.element, + event, + $.extend( inst._uiHash(), { + snapItem: inst.snapElements[ i ].item + } ) ) ); } inst.snapElements[ i ].snapping = ( ts || bs || ls || rs || first ); @@ -1089,7 +1213,8 @@ $.ui.plugin.add( "draggable", "stack", { var min, o = instance.options, group = $.makeArray( $( o.stack ) ).sort( function( a, b ) { - return ( parseInt( $( a ).css( "zIndex" ), 10 ) || 0 ) - ( parseInt( $( b ).css( "zIndex" ), 10 ) || 0 ); + return ( parseInt( $( a ).css( "zIndex" ), 10 ) || 0 ) - + ( parseInt( $( b ).css( "zIndex" ), 10 ) || 0 ); } ); if ( !group.length ) { return; } From c57f4e5ced7fb2d0ff8a71ded8c267e61829af01 Mon Sep 17 00:00:00 2001 From: Alexander Schmitz Date: Wed, 30 Mar 2016 23:41:14 -0400 Subject: [PATCH 014/136] Dialog: Fix line length issues Ref gh-1690 --- ui/widgets/dialog.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ui/widgets/dialog.js b/ui/widgets/dialog.js index c3ca95ed3..1bbb3fcd2 100644 --- a/ui/widgets/dialog.js +++ b/ui/widgets/dialog.js @@ -372,12 +372,14 @@ $.widget( "ui.dialog", { first = tabbables.filter( ":first" ), last = tabbables.filter( ":last" ); - if ( ( event.target === last[ 0 ] || event.target === this.uiDialog[ 0 ] ) && !event.shiftKey ) { + if ( ( event.target === last[ 0 ] || event.target === this.uiDialog[ 0 ] ) && + !event.shiftKey ) { this._delay( function() { first.trigger( "focus" ); } ); event.preventDefault(); - } else if ( ( event.target === first[ 0 ] || event.target === this.uiDialog[ 0 ] ) && event.shiftKey ) { + } else if ( ( event.target === first[ 0 ] || + event.target === this.uiDialog[ 0 ] ) && event.shiftKey ) { this._delay( function() { last.trigger( "focus" ); } ); From fcf97a033f43f0ba5262d7aeca330fac3e3c1398 Mon Sep 17 00:00:00 2001 From: Alexander Schmitz Date: Wed, 30 Mar 2016 23:42:01 -0400 Subject: [PATCH 015/136] Controlgroup: Fix line length issues Ref gh-1690 --- ui/widgets/controlgroup.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ui/widgets/controlgroup.js b/ui/widgets/controlgroup.js index ceb78c7c3..1f0da070e 100644 --- a/ui/widgets/controlgroup.js +++ b/ui/widgets/controlgroup.js @@ -86,7 +86,8 @@ return $.widget( "ui.controlgroup", { if ( widget === "controlgroupLabel" ) { labels = that.element.find( selector ); labels.each( function() { - $( this ).contents().wrapAll( "" ); + $( this ).contents() + .wrapAll( "" ); } ); that._addClass( labels, null, "ui-widget ui-widget-content ui-state-default" ); childWidgets = childWidgets.concat( labels.get() ); From adbd694a3e3d14678775695b17bd1fb7c95efacc Mon Sep 17 00:00:00 2001 From: Alexander Schmitz Date: Wed, 30 Mar 2016 23:42:53 -0400 Subject: [PATCH 016/136] Checkboxradio: Fix line length issues Ref gh-1690 --- ui/widgets/checkboxradio.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/widgets/checkboxradio.js b/ui/widgets/checkboxradio.js index 300cae8ce..0052b1950 100644 --- a/ui/widgets/checkboxradio.js +++ b/ui/widgets/checkboxradio.js @@ -71,8 +71,8 @@ $.widget( "ui.checkboxradio", [ $.ui.formResetMixin, { // input itself. this.label.contents().not( this.element ).each( function() { - // The label contents could be text, html, or a mix. We concat each element to get a string - // representation of the label, without the input as part of it. + // The label contents could be text, html, or a mix. We concat each element to get a + // string representation of the label, without the input as part of it. that.originalLabel += this.nodeType === 3 ? $( this ).text() : this.outerHTML; } ); From ca3d4511c4ffc49bf7fcd2beca46d135d73660c7 Mon Sep 17 00:00:00 2001 From: Alexander Schmitz Date: Wed, 30 Mar 2016 23:43:59 -0400 Subject: [PATCH 017/136] Accordion: Fix line length issues Ref gh-1690 --- ui/widgets/accordion.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ui/widgets/accordion.js b/ui/widgets/accordion.js index 359b4c46f..a234c272f 100644 --- a/ui/widgets/accordion.js +++ b/ui/widgets/accordion.js @@ -239,7 +239,8 @@ return $.widget( "ui.accordion", { this._processPanels(); // Was collapsed or no panel - if ( ( options.active === false && options.collapsible === true ) || !this.headers.length ) { + if ( ( options.active === false && options.collapsible === true ) || + !this.headers.length ) { options.active = false; this.active = $(); From c4e5d73b36ab64a205877abf415f41eb7e9a2d74 Mon Sep 17 00:00:00 2001 From: Alexander Schmitz Date: Thu, 31 Mar 2016 00:05:45 -0400 Subject: [PATCH 018/136] Widget: Fix line length issues Ref gh-1690 --- ui/widget.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ui/widget.js b/ui/widget.js index e38c0c871..c82b95326 100644 --- a/ui/widget.js +++ b/ui/widget.js @@ -225,12 +225,14 @@ $.widget.bridge = function( name, object ) { } if ( !instance ) { - return $.error( "cannot call methods on " + name + " prior to initialization; " + + return $.error( "cannot call methods on " + name + + " prior to initialization; " + "attempted to call method '" + options + "'" ); } if ( !$.isFunction( instance[ options ] ) || options.charAt( 0 ) === "_" ) { - return $.error( "no such method '" + options + "' for " + name + " widget instance" ); + return $.error( "no such method '" + options + "' for " + name + + " widget instance" ); } methodValue = instance[ options ].apply( instance, args ); From 9dd2576494166e0324ef3c9714a43ecfd8db90d1 Mon Sep 17 00:00:00 2001 From: Alexander Schmitz Date: Thu, 31 Mar 2016 00:06:36 -0400 Subject: [PATCH 019/136] Scroll Parent: Fix line length issues Ref gh-1690 --- ui/scroll-parent.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ui/scroll-parent.js b/ui/scroll-parent.js index 478b86ae3..e64691988 100644 --- a/ui/scroll-parent.js +++ b/ui/scroll-parent.js @@ -33,10 +33,13 @@ return $.fn.scrollParent = function( includeHidden ) { if ( excludeStaticParent && parent.css( "position" ) === "static" ) { return false; } - return overflowRegex.test( parent.css( "overflow" ) + parent.css( "overflow-y" ) + parent.css( "overflow-x" ) ); + return overflowRegex.test( parent.css( "overflow" ) + parent.css( "overflow-y" ) + + parent.css( "overflow-x" ) ); } ).eq( 0 ); - return position === "fixed" || !scrollParent.length ? $( this[ 0 ].ownerDocument || document ) : scrollParent; + return position === "fixed" || !scrollParent.length ? + $( this[ 0 ].ownerDocument || document ) : + scrollParent; }; } ) ); From de4cbdab98d2d1e23b8cfce3aeeea143883cbc49 Mon Sep 17 00:00:00 2001 From: Alexander Schmitz Date: Thu, 31 Mar 2016 00:09:19 -0400 Subject: [PATCH 020/136] Position: Fix line length issues Ref gh-1690 --- ui/position.js | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/ui/position.js b/ui/position.js index f8fa1b5db..394105667 100644 --- a/ui/position.js +++ b/ui/position.js @@ -105,7 +105,9 @@ $.position = { return cachedScrollbarWidth; } var w1, w2, - div = $( "
" ), + div = $( "
" + + "
" ), innerDiv = div.children()[ 0 ]; $( "body" ).append( div ); @@ -242,8 +244,10 @@ $.fn.position = function( options ) { elemHeight = elem.outerHeight(), marginLeft = parseCss( this, "marginLeft" ), marginTop = parseCss( this, "marginTop" ), - collisionWidth = elemWidth + marginLeft + parseCss( this, "marginRight" ) + scrollInfo.width, - collisionHeight = elemHeight + marginTop + parseCss( this, "marginBottom" ) + scrollInfo.height, + collisionWidth = elemWidth + marginLeft + parseCss( this, "marginRight" ) + + scrollInfo.width, + collisionHeight = elemHeight + marginTop + parseCss( this, "marginBottom" ) + + scrollInfo.height, position = $.extend( {}, basePosition ), myOffset = getOffsets( offsets.my, elem.outerWidth(), elem.outerHeight() ); @@ -353,7 +357,8 @@ $.ui.position = { // Element is initially over the left side of within if ( overLeft > 0 && overRight <= 0 ) { - newOverRight = position.left + overLeft + data.collisionWidth - outerWidth - withinOffset; + newOverRight = position.left + overLeft + data.collisionWidth - outerWidth - + withinOffset; position.left += overLeft - newOverRight; // Element is initially over right side of within @@ -396,7 +401,8 @@ $.ui.position = { // Element is initially over the top of within if ( overTop > 0 && overBottom <= 0 ) { - newOverBottom = position.top + overTop + data.collisionHeight - outerHeight - withinOffset; + newOverBottom = position.top + overTop + data.collisionHeight - outerHeight - + withinOffset; position.top += overTop - newOverBottom; // Element is initially over bottom of within @@ -450,12 +456,14 @@ $.ui.position = { newOverLeft; if ( overLeft < 0 ) { - newOverRight = position.left + myOffset + atOffset + offset + data.collisionWidth - outerWidth - withinOffset; + newOverRight = position.left + myOffset + atOffset + offset + data.collisionWidth - + outerWidth - withinOffset; if ( newOverRight < 0 || newOverRight < abs( overLeft ) ) { position.left += myOffset + atOffset + offset; } } else if ( overRight > 0 ) { - newOverLeft = position.left - data.collisionPosition.marginLeft + myOffset + atOffset + offset - offsetLeft; + newOverLeft = position.left - data.collisionPosition.marginLeft + myOffset + + atOffset + offset - offsetLeft; if ( newOverLeft > 0 || abs( newOverLeft ) < overRight ) { position.left += myOffset + atOffset + offset; } @@ -484,12 +492,14 @@ $.ui.position = { newOverTop, newOverBottom; if ( overTop < 0 ) { - newOverBottom = position.top + myOffset + atOffset + offset + data.collisionHeight - outerHeight - withinOffset; + newOverBottom = position.top + myOffset + atOffset + offset + data.collisionHeight - + outerHeight - withinOffset; if ( newOverBottom < 0 || newOverBottom < abs( overTop ) ) { position.top += myOffset + atOffset + offset; } } else if ( overBottom > 0 ) { - newOverTop = position.top - data.collisionPosition.marginTop + myOffset + atOffset + offset - offsetTop; + newOverTop = position.top - data.collisionPosition.marginTop + myOffset + atOffset + + offset - offsetTop; if ( newOverTop > 0 || abs( newOverTop ) < overBottom ) { position.top += myOffset + atOffset + offset; } From 3858df5d5b3da2cec040d65d88a19198a3fa4e43 Mon Sep 17 00:00:00 2001 From: Alexander Schmitz Date: Thu, 31 Mar 2016 00:22:10 -0400 Subject: [PATCH 021/136] i18n: Fix line length issues Ref gh-1690 --- ui/i18n/datepicker-ar.js | 3 ++- ui/i18n/datepicker-cy-GB.js | 10 +++++++++- ui/i18n/datepicker-et.js | 10 +++++++++- ui/i18n/datepicker-fo.js | 10 +++++++++- ui/i18n/datepicker-is.js | 10 +++++++++- ui/i18n/datepicker-ka.js | 15 ++++++++++++++- ui/i18n/datepicker-lb.js | 10 +++++++++- ui/i18n/datepicker-lt.js | 10 +++++++++- ui/i18n/datepicker-lv.js | 10 +++++++++- ui/i18n/datepicker-nb.js | 15 ++++++++++++++- ui/i18n/datepicker-nn.js | 15 ++++++++++++++- ui/i18n/datepicker-no.js | 15 ++++++++++++++- ui/i18n/datepicker-pt-BR.js | 10 +++++++++- ui/i18n/datepicker-pt.js | 10 +++++++++- ui/i18n/datepicker-rm.js | 30 ++++++++++++++++++++++++++++-- ui/i18n/datepicker-ta.js | 20 ++++++++++++++++++-- 16 files changed, 185 insertions(+), 18 deletions(-) diff --git a/ui/i18n/datepicker-ar.js b/ui/i18n/datepicker-ar.js index 025d98484..95784e88c 100644 --- a/ui/i18n/datepicker-ar.js +++ b/ui/i18n/datepicker-ar.js @@ -1,5 +1,6 @@ /* Arabic Translation for jQuery UI date picker plugin. */ -/* Used in most of Arab countries, primarily in Bahrain, Kuwait, Oman, Qatar, Saudi Arabia and the United Arab Emirates, Egypt, Sudan and Yemen. */ +/* Used in most of Arab countries, primarily in Bahrain, */ +/* Kuwait, Oman, Qatar, Saudi Arabia and the United Arab Emirates, Egypt, Sudan and Yemen. */ /* Written by Mohammed Alshehri -- m@dralshehri.com */ ( function( factory ) { diff --git a/ui/i18n/datepicker-cy-GB.js b/ui/i18n/datepicker-cy-GB.js index 26643b50c..14fce914c 100644 --- a/ui/i18n/datepicker-cy-GB.js +++ b/ui/i18n/datepicker-cy-GB.js @@ -21,7 +21,15 @@ datepicker.regional[ "cy-GB" ] = { "Gorffennaf","Awst","Medi","Hydref","Tachwedd","Rhagfyr" ], monthNamesShort: [ "Ion", "Chw", "Maw", "Ebr", "Mai", "Meh", "Gor", "Aws", "Med", "Hyd", "Tac", "Rha" ], - dayNames: [ "Dydd Sul", "Dydd Llun", "Dydd Mawrth", "Dydd Mercher", "Dydd Iau", "Dydd Gwener", "Dydd Sadwrn" ], + dayNames: [ + "Dydd Sul", + "Dydd Llun", + "Dydd Mawrth", + "Dydd Mercher", + "Dydd Iau", + "Dydd Gwener", + "Dydd Sadwrn" + ], dayNamesShort: [ "Sul", "Llu", "Maw", "Mer", "Iau", "Gwe", "Sad" ], dayNamesMin: [ "Su","Ll","Ma","Me","Ia","Gw","Sa" ], weekHeader: "Wy", diff --git a/ui/i18n/datepicker-et.js b/ui/i18n/datepicker-et.js index 691675a98..b2e226ae5 100644 --- a/ui/i18n/datepicker-et.js +++ b/ui/i18n/datepicker-et.js @@ -21,7 +21,15 @@ datepicker.regional.et = { "Juuli","August","September","Oktoober","November","Detsember" ], monthNamesShort: [ "Jaan", "Veebr", "Märts", "Apr", "Mai", "Juuni", "Juuli", "Aug", "Sept", "Okt", "Nov", "Dets" ], - dayNames: [ "Pühapäev", "Esmaspäev", "Teisipäev", "Kolmapäev", "Neljapäev", "Reede", "Laupäev" ], + dayNames: [ + "Pühapäev", + "Esmaspäev", + "Teisipäev", + "Kolmapäev", + "Neljapäev", + "Reede", + "Laupäev" + ], dayNamesShort: [ "Pühap", "Esmasp", "Teisip", "Kolmap", "Neljap", "Reede", "Laup" ], dayNamesMin: [ "P","E","T","K","N","R","L" ], weekHeader: "näd", diff --git a/ui/i18n/datepicker-fo.js b/ui/i18n/datepicker-fo.js index df1e08951..6c24b8bff 100644 --- a/ui/i18n/datepicker-fo.js +++ b/ui/i18n/datepicker-fo.js @@ -21,7 +21,15 @@ datepicker.regional.fo = { "Juli","August","September","Oktober","November","Desember" ], monthNamesShort: [ "Jan","Feb","Mar","Apr","Mei","Jun", "Jul","Aug","Sep","Okt","Nov","Des" ], - dayNames: [ "Sunnudagur","Mánadagur","Týsdagur","Mikudagur","Hósdagur","Fríggjadagur","Leyardagur" ], + dayNames: [ + "Sunnudagur", + "Mánadagur", + "Týsdagur", + "Mikudagur", + "Hósdagur", + "Fríggjadagur", + "Leyardagur" + ], dayNamesShort: [ "Sun","Mán","Týs","Mik","Hós","Frí","Ley" ], dayNamesMin: [ "Su","Má","Tý","Mi","Hó","Fr","Le" ], weekHeader: "Vk", diff --git a/ui/i18n/datepicker-is.js b/ui/i18n/datepicker-is.js index f977de326..b15f37ab0 100644 --- a/ui/i18n/datepicker-is.js +++ b/ui/i18n/datepicker-is.js @@ -21,7 +21,15 @@ datepicker.regional.is = { "Júlí","Ágúst","September","Október","Nóvember","Desember" ], monthNamesShort: [ "Jan","Feb","Mar","Apr","Maí","Jún", "Júl","Ágú","Sep","Okt","Nóv","Des" ], - dayNames: [ "Sunnudagur","Mánudagur","Þriðjudagur","Miðvikudagur","Fimmtudagur","Föstudagur","Laugardagur" ], + dayNames: [ + "Sunnudagur", + "Mánudagur", + "Þriðjudagur", + "Miðvikudagur", + "Fimmtudagur", + "Föstudagur", + "Laugardagur" + ], dayNamesShort: [ "Sun","Mán","Þri","Mið","Fim","Fös","Lau" ], dayNamesMin: [ "Su","Má","Þr","Mi","Fi","Fö","La" ], weekHeader: "Vika", diff --git a/ui/i18n/datepicker-ka.js b/ui/i18n/datepicker-ka.js index 6a4aa392f..1f596cb31 100644 --- a/ui/i18n/datepicker-ka.js +++ b/ui/i18n/datepicker-ka.js @@ -17,7 +17,20 @@ datepicker.regional.ka = { prevText: "< წინა", nextText: "შემდეგი >", currentText: "დღეს", - monthNames: [ "იანვარი","თებერვალი","მარტი","აპრილი","მაისი","ივნისი", "ივლისი","აგვისტო","სექტემბერი","ოქტომბერი","ნოემბერი","დეკემბერი" ], + monthNames: [ + "იანვარი", + "თებერვალი", + "მარტი", + "აპრილი", + "მაისი", + "ივნისი", + "ივლისი", + "აგვისტო", + "სექტემბერი", + "ოქტომბერი", + "ნოემბერი", + "დეკემბერი" + ], monthNamesShort: [ "იან","თებ","მარ","აპრ","მაი","ივნ", "ივლ","აგვ","სექ","ოქტ","ნოე","დეკ" ], dayNames: [ "კვირა","ორშაბათი","სამშაბათი","ოთხშაბათი","ხუთშაბათი","პარასკევი","შაბათი" ], dayNamesShort: [ "კვ","ორშ","სამ","ოთხ","ხუთ","პარ","შაბ" ], diff --git a/ui/i18n/datepicker-lb.js b/ui/i18n/datepicker-lb.js index a8fa03b8f..02a9c5108 100644 --- a/ui/i18n/datepicker-lb.js +++ b/ui/i18n/datepicker-lb.js @@ -21,7 +21,15 @@ datepicker.regional.lb = { "Juli","August","September","Oktober","November","Dezember" ], monthNamesShort: [ "Jan", "Feb", "Mäe", "Abr", "Mee", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dez" ], - dayNames: [ "Sonndeg", "Méindeg", "Dënschdeg", "Mëttwoch", "Donneschdeg", "Freideg", "Samschdeg" ], + dayNames: [ + "Sonndeg", + "Méindeg", + "Dënschdeg", + "Mëttwoch", + "Donneschdeg", + "Freideg", + "Samschdeg" + ], dayNamesShort: [ "Son", "Méi", "Dën", "Mët", "Don", "Fre", "Sam" ], dayNamesMin: [ "So","Mé","Dë","Më","Do","Fr","Sa" ], weekHeader: "W", diff --git a/ui/i18n/datepicker-lt.js b/ui/i18n/datepicker-lt.js index 35554764f..a57fd9df0 100644 --- a/ui/i18n/datepicker-lt.js +++ b/ui/i18n/datepicker-lt.js @@ -21,7 +21,15 @@ datepicker.regional.lt = { "Liepa","Rugpjūtis","Rugsėjis","Spalis","Lapkritis","Gruodis" ], monthNamesShort: [ "Sau","Vas","Kov","Bal","Geg","Bir", "Lie","Rugp","Rugs","Spa","Lap","Gru" ], - dayNames: [ "sekmadienis","pirmadienis","antradienis","trečiadienis","ketvirtadienis","penktadienis","šeštadienis" ], + dayNames: [ + "sekmadienis", + "pirmadienis", + "antradienis", + "trečiadienis", + "ketvirtadienis", + "penktadienis", + "šeštadienis" + ], dayNamesShort: [ "sek","pir","ant","tre","ket","pen","šeš" ], dayNamesMin: [ "Se","Pr","An","Tr","Ke","Pe","Še" ], weekHeader: "SAV", diff --git a/ui/i18n/datepicker-lv.js b/ui/i18n/datepicker-lv.js index ec49c43a6..04556fbcf 100644 --- a/ui/i18n/datepicker-lv.js +++ b/ui/i18n/datepicker-lv.js @@ -21,7 +21,15 @@ datepicker.regional.lv = { "Jūlijs","Augusts","Septembris","Oktobris","Novembris","Decembris" ], monthNamesShort: [ "Jan","Feb","Mar","Apr","Mai","Jūn", "Jūl","Aug","Sep","Okt","Nov","Dec" ], - dayNames: [ "svētdiena","pirmdiena","otrdiena","trešdiena","ceturtdiena","piektdiena","sestdiena" ], + dayNames: [ + "svētdiena", + "pirmdiena", + "otrdiena", + "trešdiena", + "ceturtdiena", + "piektdiena", + "sestdiena" + ], dayNamesShort: [ "svt","prm","otr","tre","ctr","pkt","sst" ], dayNamesMin: [ "Sv","Pr","Ot","Tr","Ct","Pk","Ss" ], weekHeader: "Ned.", diff --git a/ui/i18n/datepicker-nb.js b/ui/i18n/datepicker-nb.js index 128f6836d..eb1112bc5 100644 --- a/ui/i18n/datepicker-nb.js +++ b/ui/i18n/datepicker-nb.js @@ -17,7 +17,20 @@ datepicker.regional.nb = { prevText: "«Forrige", nextText: "Neste»", currentText: "I dag", - monthNames: [ "januar","februar","mars","april","mai","juni","juli","august","september","oktober","november","desember" ], + monthNames: [ + "januar", + "februar", + "mars", + "april", + "mai", + "juni", + "juli", + "august", + "september", + "oktober", + "november", + "desember" + ], monthNamesShort: [ "jan","feb","mar","apr","mai","jun","jul","aug","sep","okt","nov","des" ], dayNamesShort: [ "søn","man","tir","ons","tor","fre","lør" ], dayNames: [ "søndag","mandag","tirsdag","onsdag","torsdag","fredag","lørdag" ], diff --git a/ui/i18n/datepicker-nn.js b/ui/i18n/datepicker-nn.js index dfaec387b..bacd481a0 100644 --- a/ui/i18n/datepicker-nn.js +++ b/ui/i18n/datepicker-nn.js @@ -17,7 +17,20 @@ datepicker.regional.nn = { prevText: "«Førre", nextText: "Neste»", currentText: "I dag", - monthNames: [ "januar","februar","mars","april","mai","juni","juli","august","september","oktober","november","desember" ], + monthNames: [ + "januar", + "februar", + "mars", + "april", + "mai", + "juni", + "juli", + "august", + "september", + "oktober", + "november", + "desember" + ], monthNamesShort: [ "jan","feb","mar","apr","mai","jun","jul","aug","sep","okt","nov","des" ], dayNamesShort: [ "sun","mån","tys","ons","tor","fre","lau" ], dayNames: [ "sundag","måndag","tysdag","onsdag","torsdag","fredag","laurdag" ], diff --git a/ui/i18n/datepicker-no.js b/ui/i18n/datepicker-no.js index 559aa111b..8a755aae9 100644 --- a/ui/i18n/datepicker-no.js +++ b/ui/i18n/datepicker-no.js @@ -18,7 +18,20 @@ datepicker.regional.no = { prevText: "«Forrige", nextText: "Neste»", currentText: "I dag", - monthNames: [ "januar","februar","mars","april","mai","juni","juli","august","september","oktober","november","desember" ], + monthNames: [ + "januar", + "februar", + "mars", + "april", + "mai", + "juni", + "juli", + "august", + "september", + "oktober", + "november", + "desember" + ], monthNamesShort: [ "jan","feb","mar","apr","mai","jun","jul","aug","sep","okt","nov","des" ], dayNamesShort: [ "søn","man","tir","ons","tor","fre","lør" ], dayNames: [ "søndag","mandag","tirsdag","onsdag","torsdag","fredag","lørdag" ], diff --git a/ui/i18n/datepicker-pt-BR.js b/ui/i18n/datepicker-pt-BR.js index c4c0d541c..aeae7ca4e 100644 --- a/ui/i18n/datepicker-pt-BR.js +++ b/ui/i18n/datepicker-pt-BR.js @@ -21,7 +21,15 @@ datepicker.regional[ "pt-BR" ] = { "Julho","Agosto","Setembro","Outubro","Novembro","Dezembro" ], monthNamesShort: [ "Jan","Fev","Mar","Abr","Mai","Jun", "Jul","Ago","Set","Out","Nov","Dez" ], - dayNames: [ "Domingo","Segunda-feira","Terça-feira","Quarta-feira","Quinta-feira","Sexta-feira","Sábado" ], + dayNames: [ + "Domingo", + "Segunda-feira", + "Terça-feira", + "Quarta-feira", + "Quinta-feira", + "Sexta-feira", + "Sábado" + ], dayNamesShort: [ "Dom","Seg","Ter","Qua","Qui","Sex","Sáb" ], dayNamesMin: [ "Dom","Seg","Ter","Qua","Qui","Sex","Sáb" ], weekHeader: "Sm", diff --git a/ui/i18n/datepicker-pt.js b/ui/i18n/datepicker-pt.js index baed7f3de..b1afd7b3d 100644 --- a/ui/i18n/datepicker-pt.js +++ b/ui/i18n/datepicker-pt.js @@ -20,7 +20,15 @@ datepicker.regional.pt = { "Julho","Agosto","Setembro","Outubro","Novembro","Dezembro" ], monthNamesShort: [ "Jan","Fev","Mar","Abr","Mai","Jun", "Jul","Ago","Set","Out","Nov","Dez" ], - dayNames: [ "Domingo","Segunda-feira","Terça-feira","Quarta-feira","Quinta-feira","Sexta-feira","Sábado" ], + dayNames: [ + "Domingo", + "Segunda-feira", + "Terça-feira", + "Quarta-feira", + "Quinta-feira", + "Sexta-feira", + "Sábado" + ], dayNamesShort: [ "Dom","Seg","Ter","Qua","Qui","Sex","Sáb" ], dayNamesMin: [ "Dom","Seg","Ter","Qua","Qui","Sex","Sáb" ], weekHeader: "Sem", diff --git a/ui/i18n/datepicker-rm.js b/ui/i18n/datepicker-rm.js index 856c8c254..89a5c77a1 100644 --- a/ui/i18n/datepicker-rm.js +++ b/ui/i18n/datepicker-rm.js @@ -17,8 +17,34 @@ datepicker.regional.rm = { prevText: "<Suandant", nextText: "Precedent>", currentText: "Actual", - monthNames: [ "Schaner","Favrer","Mars","Avrigl","Matg","Zercladur", "Fanadur","Avust","Settember","October","November","December" ], - monthNamesShort: [ "Scha","Fev","Mar","Avr","Matg","Zer", "Fan","Avu","Sett","Oct","Nov","Dec" ], + monthNames: [ + "Schaner", + "Favrer", + "Mars", + "Avrigl", + "Matg", + "Zercladur", + "Fanadur", + "Avust", + "Settember", + "October", + "November", + "December" + ], + monthNamesShort: [ + "Scha", + "Fev", + "Mar", + "Avr", + "Matg", + "Zer", + "Fan", + "Avu", + "Sett", + "Oct", + "Nov", + "Dec" + ], dayNames: [ "Dumengia","Glindesdi","Mardi","Mesemna","Gievgia","Venderdi","Sonda" ], dayNamesShort: [ "Dum","Gli","Mar","Mes","Gie","Ven","Som" ], dayNamesMin: [ "Du","Gl","Ma","Me","Gi","Ve","So" ], diff --git a/ui/i18n/datepicker-ta.js b/ui/i18n/datepicker-ta.js index e3f09b00c..722614dd0 100644 --- a/ui/i18n/datepicker-ta.js +++ b/ui/i18n/datepicker-ta.js @@ -21,8 +21,24 @@ datepicker.regional.ta = { "ஆடி","ஆவணி","புரட்டாசி","ஐப்பசி","கார்த்திகை","மார்கழி" ], monthNamesShort: [ "தை","மாசி","பங்","சித்","வைகா","ஆனி", "ஆடி","ஆவ","புர","ஐப்","கார்","மார்" ], - dayNames: [ "ஞாயிற்றுக்கிழமை","திங்கட்கிழமை","செவ்வாய்க்கிழமை","புதன்கிழமை","வியாழக்கிழமை","வெள்ளிக்கிழமை","சனிக்கிழமை" ], - dayNamesShort: [ "ஞாயிறு","திங்கள்","செவ்வாய்","புதன்","வியாழன்","வெள்ளி","சனி" ], + dayNames: [ + "ஞாயிற்றுக்கிழமை", + "திங்கட்கிழமை", + "செவ்வாய்க்கிழமை", + "புதன்கிழமை", + "வியாழக்கிழமை", + "வெள்ளிக்கிழமை", + "சனிக்கிழமை" + ], + dayNamesShort: [ + "ஞாயிறு", + "திங்கள்", + "செவ்வாய்", + "புதன்", + "வியாழன்", + "வெள்ளி", + "சனி" + ], dayNamesMin: [ "ஞா","தி","செ","பு","வி","வெ","ச" ], weekHeader: "Не", dateFormat: "dd/mm/yy", From ba7829f34ef3b0f207cc62f10b8c5c8b4c19c62a Mon Sep 17 00:00:00 2001 From: Alexander Schmitz Date: Thu, 31 Mar 2016 00:30:21 -0400 Subject: [PATCH 022/136] Effects: Fix line length issues Ref gh-1690 --- ui/effects/effect-drop.js | 3 ++- ui/effects/effect-scale.js | 2 +- ui/effects/effect-shake.js | 4 +++- ui/effects/effect-slide.js | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/ui/effects/effect-drop.js b/ui/effects/effect-drop.js index 059fd54ca..c7e3d7a6e 100644 --- a/ui/effects/effect-drop.js +++ b/ui/effects/effect-drop.js @@ -45,7 +45,8 @@ return $.effects.define( "drop", "hide", function( options, done ) { $.effects.createPlaceholder( element ); - distance = options.distance || element[ ref === "top" ? "outerHeight" : "outerWidth" ]( true ) / 2; + distance = options.distance || + element[ ref === "top" ? "outerHeight" : "outerWidth" ]( true ) / 2; animation[ ref ] = motion + distance; diff --git a/ui/effects/effect-scale.js b/ui/effects/effect-scale.js index 9e254b27e..9379f88c7 100644 --- a/ui/effects/effect-scale.js +++ b/ui/effects/effect-scale.js @@ -9,7 +9,7 @@ //>>label: Scale Effect //>>group: Effects -//>>description: Grows or shrinks an element and its content. Restores an element to its original size. +//>>description: Grows or shrinks an element and its content. //>>docs: http://api.jqueryui.com/scale-effect/ //>>demos: http://jqueryui.com/effect/ diff --git a/ui/effects/effect-shake.js b/ui/effects/effect-shake.js index ada249aec..596aa12ae 100644 --- a/ui/effects/effect-shake.js +++ b/ui/effects/effect-shake.js @@ -58,7 +58,9 @@ return $.effects.define( "shake", function( options, done ) { // Shakes for ( ; i < times; i++ ) { - element.animate( animation1, speed, options.easing ).animate( animation2, speed, options.easing ); + element + .animate( animation1, speed, options.easing ) + .animate( animation2, speed, options.easing ); } element diff --git a/ui/effects/effect-slide.js b/ui/effects/effect-slide.js index 12e8c9ca8..3ba7a2edc 100644 --- a/ui/effects/effect-slide.js +++ b/ui/effects/effect-slide.js @@ -42,7 +42,8 @@ return $.effects.define( "slide", "show", function( options, done ) { direction = options.direction || "left", ref = ( direction === "up" || direction === "down" ) ? "top" : "left", positiveMotion = ( direction === "up" || direction === "left" ), - distance = options.distance || element[ ref === "top" ? "outerHeight" : "outerWidth" ]( true ), + distance = options.distance || + element[ ref === "top" ? "outerHeight" : "outerWidth" ]( true ), animation = {}; $.effects.createPlaceholder( element ); From 32720810d82914441c088068e5b52297e0c95192 Mon Sep 17 00:00:00 2001 From: Alexander Schmitz Date: Thu, 31 Mar 2016 00:30:43 -0400 Subject: [PATCH 023/136] Build: Fix line length issues Ref gh-1690 --- build/release.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/build/release.js b/build/release.js index b868cbebd..aaaf1c053 100644 --- a/build/release.js +++ b/build/release.js @@ -52,7 +52,8 @@ function buildCDNPackage( callback ) { var Package = require( "download.jqueryui.com/lib/package-1-12-themes" ); var Packager = require( "node-packager" ); var jqueryUi = new JqueryUi( path.resolve( "." ) ); - var target = fs.createWriteStream( "../" + jqueryUi.pkg.name + "-" + jqueryUi.pkg.version + "-cdn.zip" ); + var target = fs.createWriteStream( "../" + jqueryUi.pkg.name + "-" + jqueryUi.pkg.version + + "-cdn.zip" ); var packager = new Packager( jqueryUi.files().cache, Package, { components: jqueryUi.components().map( function( component ) { return component.name; @@ -82,7 +83,8 @@ Release.define( { "August", "September", "October", "November", "December" ], now = new Date(); return "\n\nReleased on " + monthNames[ now.getMonth() ] + " " + now.getDate() + ", " + now.getFullYear() + "\n\n"; + "}\n\nReleased on " + monthNames[ now.getMonth() ] + " " + now.getDate() + + ", " + now.getFullYear() + "\n\n"; }, generateArtifacts: function( fn ) { var files = replaceAtVersion(); From 5f41f9c6a8b143392452c5860c1dbc38cc3e31a4 Mon Sep 17 00:00:00 2001 From: Alexander Schmitz Date: Thu, 31 Mar 2016 00:31:10 -0400 Subject: [PATCH 024/136] Plugin: Fix line length issues Ref gh-1690 --- ui/plugin.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ui/plugin.js b/ui/plugin.js index 0f1d9b040..b282de7c6 100644 --- a/ui/plugin.js +++ b/ui/plugin.js @@ -28,7 +28,8 @@ return $.ui.plugin = { return; } - if ( !allowDisconnected && ( !instance.element[ 0 ].parentNode || instance.element[ 0 ].parentNode.nodeType === 11 ) ) { + if ( !allowDisconnected && ( !instance.element[ 0 ].parentNode || + instance.element[ 0 ].parentNode.nodeType === 11 ) ) { return; } From f53d6ae970fc06a42f08639ba1b8b77f2a5ea91f Mon Sep 17 00:00:00 2001 From: Alexander Schmitz Date: Thu, 31 Mar 2016 00:31:28 -0400 Subject: [PATCH 025/136] Effect: Fix line length issues Ref gh-1690 --- ui/effect.js | 47 ++++++++++++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 17 deletions(-) diff --git a/ui/effect.js b/ui/effect.js index 1a660fa49..5fb4ee579 100644 --- a/ui/effect.js +++ b/ui/effect.js @@ -49,7 +49,8 @@ $.effects = { */ ( function( jQuery, undefined ) { - var stepHooks = "backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor", + var stepHooks = "backgroundColor borderBottomColor borderLeftColor borderRightColor " + + "borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor", // Plusequals test for += 100 -= 100 rplusequals = /^([\-+])=\s*(\d+\.?\d*)/, @@ -316,7 +317,8 @@ color.fn = jQuery.extend( color.prototype, { } ); // Everything defined but alpha? - if ( inst[ cache ] && jQuery.inArray( null, inst[ cache ].slice( 0, 3 ) ) < 0 ) { + if ( inst[ cache ] && + jQuery.inArray( null, inst[ cache ].slice( 0, 3 ) ) < 0 ) { // Use the default of 1 inst[ cache ][ 3 ] = 1; @@ -624,7 +626,8 @@ color.hook = function( hook ) { var parsed, curElem, backgroundColor = ""; - if ( value !== "transparent" && ( jQuery.type( value ) !== "string" || ( parsed = stringParse( value ) ) ) ) { + if ( value !== "transparent" && ( jQuery.type( value ) !== "string" || + ( parsed = stringParse( value ) ) ) ) { value = color( parsed || value ); if ( !support.rgba && value._rgba[ 3 ] !== 1 ) { curElem = hook === "backgroundColor" ? elem.parentNode : elem; @@ -650,7 +653,8 @@ color.hook = function( hook ) { elem.style[ hook ] = value; } catch ( e ) { - // Wrapped to prevent IE from throwing errors on "invalid" values like 'auto' or 'inherit' + // Wrapped to prevent IE from throwing errors on "invalid" values like + // 'auto' or 'inherit' } } }; @@ -728,14 +732,17 @@ var classAnimationActions = [ "add", "remove", "toggle" ], padding: 1 }; -$.each( [ "borderLeftStyle", "borderRightStyle", "borderBottomStyle", "borderTopStyle" ], function( _, prop ) { - $.fx.step[ prop ] = function( fx ) { - if ( fx.end !== "none" && !fx.setAttr || fx.pos === 1 && !fx.setAttr ) { - jQuery.style( fx.elem, prop, fx.end ); - fx.setAttr = true; - } - }; -} ); +$.each( + [ "borderLeftStyle", "borderRightStyle", "borderBottomStyle", "borderTopStyle" ], + function( _, prop ) { + $.fx.step[ prop ] = function( fx ) { + if ( fx.end !== "none" && !fx.setAttr || fx.pos === 1 && !fx.setAttr ) { + jQuery.style( fx.elem, prop, fx.end ); + fx.setAttr = true; + } + }; + } +); function getElementStyles( elem ) { var key, len, @@ -1009,7 +1016,9 @@ if ( $.uiBackCompat !== false ) { $( active ).trigger( "focus" ); } - wrapper = element.parent(); //Hotfix for jQuery 1.4 since some change in wrap() seems to actually lose the reference to the wrapped element + // Hotfix for jQuery 1.4 since some change in wrap() seems to actually + // lose the reference to the wrapped element + wrapper = element.parent(); // Transfer positioning properties to the wrapper if ( element.css( "position" ) === "static" ) { @@ -1198,7 +1207,9 @@ $.extend( $.effects, { // Convert inline to inline block to account for inline elements // that turn to inline block based on content (like img) - display: /^(inline|ruby)/.test( element.css( "display" ) ) ? "inline-block" : "block", + display: /^(inline|ruby)/.test( element.css( "display" ) ) ? + "inline-block" : + "block", visibility: "hidden", // Margins need to be set to account for margin collapse @@ -1490,9 +1501,11 @@ $.fn.extend( { }, cssClip: function( clipObj ) { - return clipObj ? - this.css( "clip", "rect(" + clipObj.top + "px " + clipObj.right + "px " + clipObj.bottom + "px " + clipObj.left + "px)" ) : - parseClip( this.css( "clip" ), this ); + if ( clipObj ) { + return this.css( "clip", "rect(" + clipObj.top + "px " + clipObj.right + "px " + + clipObj.bottom + "px " + clipObj.left + "px)" ); + } + return parseClip( this.css( "clip" ), this ); }, transfer: function( options, done ) { From 307f94621a710581cef1e2557911d328291a2342 Mon Sep 17 00:00:00 2001 From: Alexander Schmitz Date: Thu, 31 Mar 2016 09:11:31 -0400 Subject: [PATCH 026/136] Selectmenu: Disable maxLineLength for description meta Ref gh-1690 --- ui/widgets/selectmenu.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ui/widgets/selectmenu.js b/ui/widgets/selectmenu.js index 87f88623f..900a245f7 100644 --- a/ui/widgets/selectmenu.js +++ b/ui/widgets/selectmenu.js @@ -9,7 +9,9 @@ //>>label: Selectmenu //>>group: Widgets +// jscs:disable maximumLineLength //>>description: Duplicates and extends the functionality of a native HTML select element, allowing it to be customizable in behavior and appearance far beyond the limitations of a native select. +// jscs:enable maximumLineLength //>>docs: http://api.jqueryui.com/selectmenu/ //>>demos: http://jqueryui.com/selectmenu/ //>>css.structure: ../../themes/base/core.css From 986aa54911764d01027f9baafce845d802167fcb Mon Sep 17 00:00:00 2001 From: Alexander Schmitz Date: Thu, 31 Mar 2016 09:12:21 -0400 Subject: [PATCH 027/136] Progressbar: Disable maxLineLength for description meta Ref gh-1690 --- ui/widgets/progressbar.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ui/widgets/progressbar.js b/ui/widgets/progressbar.js index ba4542583..dd7ee3143 100644 --- a/ui/widgets/progressbar.js +++ b/ui/widgets/progressbar.js @@ -9,7 +9,9 @@ //>>label: Progressbar //>>group: Widgets +// jscs:disable maximumLineLength //>>description: Displays a status indicator for loading state, standard percentage, and other progress indicators. +// jscs:enable maximumLineLength //>>docs: http://api.jqueryui.com/progressbar/ //>>demos: http://jqueryui.com/progressbar/ //>>css.structure: ../../themes/base/core.css From 9aa5dea9684c0a6a65ff1328fec32f5df8860186 Mon Sep 17 00:00:00 2001 From: Alexander Schmitz Date: Thu, 31 Mar 2016 09:12:37 -0400 Subject: [PATCH 028/136] Datepicker: Disable maxLineLength for jscs There are too many errors and re-write is essentially done Ref gh-1690 --- ui/widgets/datepicker.js | 1 + 1 file changed, 1 insertion(+) diff --git a/ui/widgets/datepicker.js b/ui/widgets/datepicker.js index 215ba12ac..1271de200 100644 --- a/ui/widgets/datepicker.js +++ b/ui/widgets/datepicker.js @@ -1,3 +1,4 @@ +// jscs:disable maximumLineLength /* jscs:disable requireCamelCaseOrUpperCaseIdentifiers */ /*! * jQuery UI Datepicker @VERSION From 8d1de7bff8f08db6df8b268b46ef6420de155657 Mon Sep 17 00:00:00 2001 From: Alexander Schmitz Date: Thu, 31 Mar 2016 09:13:28 -0400 Subject: [PATCH 029/136] Accordion: Disable maxLineLength for description meta Ref gh-1690 --- ui/widgets/accordion.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ui/widgets/accordion.js b/ui/widgets/accordion.js index a234c272f..530d73543 100644 --- a/ui/widgets/accordion.js +++ b/ui/widgets/accordion.js @@ -9,7 +9,9 @@ //>>label: Accordion //>>group: Widgets +// jscs:disable maximumLineLength //>>description: Displays collapsible content panels for presenting information in a limited amount of space. +// jscs:enable maximumLineLength //>>docs: http://api.jqueryui.com/accordion/ //>>demos: http://jqueryui.com/accordion/ //>>css.structure: ../../themes/base/core.css From 2eb7c96a40991da8f4bb01028f38ed1dbc2ab029 Mon Sep 17 00:00:00 2001 From: Alexander Schmitz Date: Thu, 31 Mar 2016 09:15:46 -0400 Subject: [PATCH 030/136] Effects: Disable maxLineLength for description meta explode Ref gh-1690 --- ui/effects/effect-explode.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ui/effects/effect-explode.js b/ui/effects/effect-explode.js index 92b83f545..d5aca490f 100644 --- a/ui/effects/effect-explode.js +++ b/ui/effects/effect-explode.js @@ -9,7 +9,9 @@ //>>label: Explode Effect //>>group: Effects +// jscs:disable maximumLineLength //>>description: Explodes an element in all directions into n pieces. Implodes an element to its original wholeness. +// jscs:enable maximumLineLength //>>docs: http://api.jqueryui.com/explode-effect/ //>>demos: http://jqueryui.com/effect/ From ae1be9ed8de447ecf73b0e00b968f00babba8e60 Mon Sep 17 00:00:00 2001 From: Alexander Schmitz Date: Thu, 31 Mar 2016 09:16:13 -0400 Subject: [PATCH 031/136] Effect: Disable maxLineLength for description meta Ref gh-1690 --- ui/effect.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ui/effect.js b/ui/effect.js index 5fb4ee579..5b59817d5 100644 --- a/ui/effect.js +++ b/ui/effect.js @@ -9,7 +9,9 @@ //>>label: Effects Core //>>group: Effects +// jscs:disable maximumLineLength //>>description: Extends the internal jQuery effects. Includes morphing and easing. Required by all other effects. +// jscs:enable maximumLineLength //>>docs: http://api.jqueryui.com/category/effects-core/ //>>demos: http://jqueryui.com/effect/ From 63448148a217da7e64c04b21a04982f0d64aabaa Mon Sep 17 00:00:00 2001 From: Alexander Schmitz Date: Thu, 31 Mar 2016 09:16:31 -0400 Subject: [PATCH 032/136] Build: Remove maxLineLength execption in .jscsrc Also seperates tests into a seperate task because they still have many errors Closes gh-1690 --- .jscsrc | 5 +---- Gruntfile.js | 13 +++++++++++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/.jscsrc b/.jscsrc index 5d6dfd77e..81de6df1c 100644 --- a/.jscsrc +++ b/.jscsrc @@ -8,8 +8,5 @@ "es3": true, // We want to output all errors - "maxErrors": 1000000, - - // Ref https://github.com/jquery/contribute.jquery.org/issues/80#issuecomment-45253460 - "maximumLineLength": null + "maxErrors": 1000000 } diff --git a/Gruntfile.js b/Gruntfile.js index fcd8609c6..f31cca5d4 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -173,12 +173,21 @@ grunt.initConfig({ }, jscs: { - all: { + ui: { options: { config: true }, files: { - src: [ "demos/**/*.js", "build/**/*.js", "tests/**/*.js", "ui/**/*.js" ] + src: [ "demos/**/*.js", "build/**/*.js", "ui/**/*.js" ] + } + }, + tests: { + options: { + config: true, + maximumLineLength: null + }, + files: { + src: [ "tests/**/*.js" ] } } }, From 435ed7e8d2e0221635494eedfbe22616f2a4814f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Wed, 13 Apr 2016 11:36:41 -0400 Subject: [PATCH 033/136] Menu: Remove extraneous blank lines --- ui/widgets/menu.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/ui/widgets/menu.js b/ui/widgets/menu.js index 329bfc610..73800506f 100644 --- a/ui/widgets/menu.js +++ b/ui/widgets/menu.js @@ -90,8 +90,6 @@ return $.widget( "ui.menu", { this.mouseHandled = true; } - - // Open submenu on click if ( target.has( ".ui-menu" ).length ) { this.expand( event ); From d83db4f5284df9fd80c3a98b1a3c5b6ca31b0c9a Mon Sep 17 00:00:00 2001 From: Amanpreet Singh Date: Sun, 3 Apr 2016 20:07:27 +0530 Subject: [PATCH 034/136] Accordion: Shift to use no globals --- tests/unit/accordion/core.js | 144 +++++++------- tests/unit/accordion/events.js | 157 +++++++-------- tests/unit/accordion/helper.js | 13 +- tests/unit/accordion/methods.js | 65 ++++--- tests/unit/accordion/options.js | 331 ++++++++++++++++---------------- 5 files changed, 361 insertions(+), 349 deletions(-) diff --git a/tests/unit/accordion/core.js b/tests/unit/accordion/core.js index 75f4b4ee3..119280bc9 100644 --- a/tests/unit/accordion/core.js +++ b/tests/unit/accordion/core.js @@ -1,129 +1,131 @@ define( [ + "qunit", "jquery", "./helper", "ui/widgets/accordion" -], function( $, testHelper ) { +], function( QUnit, $, testHelper ) { var setupTeardown = testHelper.setupTeardown, state = testHelper.state; -module( "accordion: core", setupTeardown() ); +QUnit.module( "accordion: core", setupTeardown() ); $.each( { div: "#list1", ul: "#navigation", dl: "#accordion-dl" }, function( type, selector ) { - test( "markup structure: " + type, function( assert ) { - expect( 10 ); + QUnit.test( "markup structure: " + type, function( assert ) { + assert.expect( 10 ); var element = $( selector ).accordion(), headers = element.find( ".ui-accordion-header" ), content = headers.next(); assert.hasClasses( element, "ui-accordion ui-widget" ); - equal( headers.length, 3, ".ui-accordion-header elements exist, correct number" ); + assert.equal( headers.length, 3, ".ui-accordion-header elements exist, correct number" ); assert.hasClasses( headers[ 0 ], "ui-accordion-header ui-accordion-header-active ui-accordion-icons" ); assert.hasClasses( headers[ 1 ], "ui-accordion-header ui-accordion-header-collapsed ui-accordion-icons" ); assert.hasClasses( headers[ 2 ], "ui-accordion-header ui-accordion-header-collapsed ui-accordion-icons" ); - equal( content.length, 3, ".ui-accordion-content elements exist, correct number" ); + assert.equal( content.length, 3, ".ui-accordion-content elements exist, correct number" ); assert.hasClasses( content[ 0 ], "ui-accordion-content ui-widget-content ui-accordion-content-active" ); assert.hasClasses( content[ 1 ], "ui-accordion-content ui-widget-content" ); assert.hasClasses( content[ 2 ], "ui-accordion-content ui-widget-content" ); - deepEqual( element.find( ".ui-accordion-header" ).next().get(), + assert.deepEqual( element.find( ".ui-accordion-header" ).next().get(), element.find( ".ui-accordion-content" ).get(), "content panels come immediately after headers" ); } ); } ); -test( "handle click on header-descendant", function() { - expect( 1 ); +QUnit.test( "handle click on header-descendant", function( assert ) { + assert.expect( 1 ); var element = $( "#navigation" ).accordion(); $( "#navigation h2:eq(1) a" ).trigger( "click" ); - state( element, 0, 1, 0 ); + state( assert, element, 0, 1, 0 ); } ); -test( "accessibility", function() { - expect( 61 ); +QUnit.test( "accessibility", function( assert ) { + assert.expect( 61 ); var element = $( "#list1" ).accordion( { active: 1, collapsible: true } ), headers = element.find( ".ui-accordion-header" ); - equal( element.attr( "role" ), "tablist", "element role" ); + assert.equal( element.attr( "role" ), "tablist", "element role" ); headers.each( function( i ) { var header = headers.eq( i ), panel = header.next(); - equal( header.attr( "role" ), "tab", "header " + i + " role" ); - equal( header.attr( "aria-controls" ), panel.attr( "id" ), "header " + i + " aria-controls" ); - equal( panel.attr( "role" ), "tabpanel", "panel " + i + " role" ); - equal( panel.attr( "aria-labelledby" ), header.attr( "id" ), "panel " + i + " aria-labelledby" ); + assert.equal( header.attr( "role" ), "tab", "header " + i + " role" ); + assert.equal( header.attr( "aria-controls" ), panel.attr( "id" ), "header " + i + " aria-controls" ); + assert.equal( panel.attr( "role" ), "tabpanel", "panel " + i + " role" ); + assert.equal( panel.attr( "aria-labelledby" ), header.attr( "id" ), "panel " + i + " aria-labelledby" ); } ); - equal( headers.eq( 1 ).attr( "tabindex" ), 0, "active header has tabindex=0" ); - equal( headers.eq( 1 ).attr( "aria-selected" ), "true", "active tab (1) has aria-selected=true" ); - equal( headers.eq( 1 ).attr( "aria-expanded" ), "true", "active tab (1) has aria-expanded=true" ); - equal( headers.eq( 1 ).next().attr( "aria-hidden" ), "false", "active tabpanel (1) has aria-hidden=false" ); - equal( headers.eq( 0 ).attr( "tabindex" ), -1, "inactive header (0) has tabindex=-1" ); - equal( headers.eq( 0 ).attr( "aria-selected" ), "false", "inactive tab (0) has aria-selected=false" ); - equal( headers.eq( 0 ).attr( "aria-expanded" ), "false", "inactive tab (0) has aria-expanded=false" ); - equal( headers.eq( 0 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel (0) has aria-hidden=true" ); - equal( headers.eq( 2 ).attr( "tabindex" ), -1, "inactive header (2) has tabindex=-1" ); - equal( headers.eq( 2 ).attr( "aria-selected" ), "false", "inactive tab (2) has aria-selected=false" ); - equal( headers.eq( 2 ).attr( "aria-expanded" ), "false", "inactive tab (2) has aria-expanded=false" ); - equal( headers.eq( 2 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel (2) has aria-hidden=true" ); + assert.equal( headers.eq( 1 ).attr( "tabindex" ), 0, "active header has tabindex=0" ); + assert.equal( headers.eq( 1 ).attr( "aria-selected" ), "true", "active tab (1) has aria-selected=true" ); + assert.equal( headers.eq( 1 ).attr( "aria-expanded" ), "true", "active tab (1) has aria-expanded=true" ); + assert.equal( headers.eq( 1 ).next().attr( "aria-hidden" ), "false", "active tabpanel (1) has aria-hidden=false" ); + assert.equal( headers.eq( 0 ).attr( "tabindex" ), -1, "inactive header (0) has tabindex=-1" ); + assert.equal( headers.eq( 0 ).attr( "aria-selected" ), "false", "inactive tab (0) has aria-selected=false" ); + assert.equal( headers.eq( 0 ).attr( "aria-expanded" ), "false", "inactive tab (0) has aria-expanded=false" ); + assert.equal( headers.eq( 0 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel (0) has aria-hidden=true" ); + assert.equal( headers.eq( 2 ).attr( "tabindex" ), -1, "inactive header (2) has tabindex=-1" ); + assert.equal( headers.eq( 2 ).attr( "aria-selected" ), "false", "inactive tab (2) has aria-selected=false" ); + assert.equal( headers.eq( 2 ).attr( "aria-expanded" ), "false", "inactive tab (2) has aria-expanded=false" ); + assert.equal( headers.eq( 2 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel (2) has aria-hidden=true" ); element.accordion( "option", "active", 0 ); - equal( headers.eq( 0 ).attr( "tabindex" ), 0, "active header (0) has tabindex=0" ); - equal( headers.eq( 0 ).attr( "aria-selected" ), "true", "active tab (0) has aria-selected=true" ); - equal( headers.eq( 0 ).attr( "aria-expanded" ), "true", "active tab (0) has aria-expanded=true" ); - equal( headers.eq( 0 ).next().attr( "aria-hidden" ), "false", "active tabpanel (0) has aria-hidden=false" ); - equal( headers.eq( 1 ).attr( "tabindex" ), -1, "inactive header (1) has tabindex=-1" ); - equal( headers.eq( 1 ).attr( "aria-selected" ), "false", "inactive tab (1) has aria-selected=false" ); - equal( headers.eq( 1 ).attr( "aria-expanded" ), "false", "inactive tab (1) has aria-expanded=false" ); - equal( headers.eq( 1 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel (1) has aria-hidden=true" ); - equal( headers.eq( 2 ).attr( "tabindex" ), -1, "inactive header (2) has tabindex=-1" ); - equal( headers.eq( 2 ).attr( "aria-selected" ), "false", "inactive tab (2) has aria-selected=false" ); - equal( headers.eq( 2 ).attr( "aria-expanded" ), "false", "inactive tab (2) has aria-expanded=false" ); - equal( headers.eq( 2 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel (2) has aria-hidden=true" ); + assert.equal( headers.eq( 0 ).attr( "tabindex" ), 0, "active header (0) has tabindex=0" ); + assert.equal( headers.eq( 0 ).attr( "aria-selected" ), "true", "active tab (0) has aria-selected=true" ); + assert.equal( headers.eq( 0 ).attr( "aria-expanded" ), "true", "active tab (0) has aria-expanded=true" ); + assert.equal( headers.eq( 0 ).next().attr( "aria-hidden" ), "false", "active tabpanel (0) has aria-hidden=false" ); + assert.equal( headers.eq( 1 ).attr( "tabindex" ), -1, "inactive header (1) has tabindex=-1" ); + assert.equal( headers.eq( 1 ).attr( "aria-selected" ), "false", "inactive tab (1) has aria-selected=false" ); + assert.equal( headers.eq( 1 ).attr( "aria-expanded" ), "false", "inactive tab (1) has aria-expanded=false" ); + assert.equal( headers.eq( 1 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel (1) has aria-hidden=true" ); + assert.equal( headers.eq( 2 ).attr( "tabindex" ), -1, "inactive header (2) has tabindex=-1" ); + assert.equal( headers.eq( 2 ).attr( "aria-selected" ), "false", "inactive tab (2) has aria-selected=false" ); + assert.equal( headers.eq( 2 ).attr( "aria-expanded" ), "false", "inactive tab (2) has aria-expanded=false" ); + assert.equal( headers.eq( 2 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel (2) has aria-hidden=true" ); element.accordion( "option", "active", false ); - equal( headers.eq( 0 ).attr( "tabindex" ), 0, "previously active header (0) has tabindex=0" ); - equal( headers.eq( 0 ).attr( "aria-selected" ), "false", "inactive tab (0) has aria-selected=false" ); - equal( headers.eq( 0 ).attr( "aria-expanded" ), "false", "inactive tab (0) has aria-expanded=false" ); - equal( headers.eq( 0 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel (0) has aria-hidden=true" ); - equal( headers.eq( 1 ).attr( "tabindex" ), -1, "inactive header (1) has tabindex=-1" ); - equal( headers.eq( 1 ).attr( "aria-selected" ), "false", "inactive tab (1) has aria-selected=false" ); - equal( headers.eq( 1 ).attr( "aria-expanded" ), "false", "inactive tab (1) has aria-expanded=false" ); - equal( headers.eq( 1 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel (1) has aria-hidden=true" ); - equal( headers.eq( 2 ).attr( "tabindex" ), -1, "inactive header (2) has tabindex=-1" ); - equal( headers.eq( 2 ).attr( "aria-selected" ), "false", "inactive tab (2) has aria-selected=false" ); - equal( headers.eq( 2 ).attr( "aria-expanded" ), "false", "inactive tab (2) has aria-expanded=false" ); - equal( headers.eq( 2 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel (2) has aria-hidden=true" ); + assert.equal( headers.eq( 0 ).attr( "tabindex" ), 0, "previously active header (0) has tabindex=0" ); + assert.equal( headers.eq( 0 ).attr( "aria-selected" ), "false", "inactive tab (0) has aria-selected=false" ); + assert.equal( headers.eq( 0 ).attr( "aria-expanded" ), "false", "inactive tab (0) has aria-expanded=false" ); + assert.equal( headers.eq( 0 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel (0) has aria-hidden=true" ); + assert.equal( headers.eq( 1 ).attr( "tabindex" ), -1, "inactive header (1) has tabindex=-1" ); + assert.equal( headers.eq( 1 ).attr( "aria-selected" ), "false", "inactive tab (1) has aria-selected=false" ); + assert.equal( headers.eq( 1 ).attr( "aria-expanded" ), "false", "inactive tab (1) has aria-expanded=false" ); + assert.equal( headers.eq( 1 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel (1) has aria-hidden=true" ); + assert.equal( headers.eq( 2 ).attr( "tabindex" ), -1, "inactive header (2) has tabindex=-1" ); + assert.equal( headers.eq( 2 ).attr( "aria-selected" ), "false", "inactive tab (2) has aria-selected=false" ); + assert.equal( headers.eq( 2 ).attr( "aria-expanded" ), "false", "inactive tab (2) has aria-expanded=false" ); + assert.equal( headers.eq( 2 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel (2) has aria-hidden=true" ); element.accordion( "option", "active", 1 ); - equal( headers.eq( 1 ).attr( "tabindex" ), 0, "active header has tabindex=0" ); - equal( headers.eq( 1 ).attr( "aria-selected" ), "true", "active tab (1) has aria-selected=true" ); - equal( headers.eq( 1 ).attr( "aria-expanded" ), "true", "active tab (1) has aria-expanded=true" ); - equal( headers.eq( 1 ).next().attr( "aria-hidden" ), "false", "active tabpanel (1) has aria-hidden=false" ); - equal( headers.eq( 0 ).attr( "tabindex" ), -1, "inactive header (0) has tabindex=-1" ); - equal( headers.eq( 0 ).attr( "aria-selected" ), "false", "inactive tab (0) has aria-selected=false" ); - equal( headers.eq( 0 ).attr( "aria-expanded" ), "false", "inactive tab (0) has aria-expanded=false" ); - equal( headers.eq( 0 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel (0) has aria-hidden=true" ); - equal( headers.eq( 2 ).attr( "tabindex" ), -1, "inactive header (2) has tabindex=-1" ); - equal( headers.eq( 2 ).attr( "aria-selected" ), "false", "inactive tab (2) has aria-selected=false" ); - equal( headers.eq( 2 ).attr( "aria-expanded" ), "false", "inactive tab (2) has aria-expanded=false" ); - equal( headers.eq( 2 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel (2) has aria-hidden=true" ); + assert.equal( headers.eq( 1 ).attr( "tabindex" ), 0, "active header has tabindex=0" ); + assert.equal( headers.eq( 1 ).attr( "aria-selected" ), "true", "active tab (1) has aria-selected=true" ); + assert.equal( headers.eq( 1 ).attr( "aria-expanded" ), "true", "active tab (1) has aria-expanded=true" ); + assert.equal( headers.eq( 1 ).next().attr( "aria-hidden" ), "false", "active tabpanel (1) has aria-hidden=false" ); + assert.equal( headers.eq( 0 ).attr( "tabindex" ), -1, "inactive header (0) has tabindex=-1" ); + assert.equal( headers.eq( 0 ).attr( "aria-selected" ), "false", "inactive tab (0) has aria-selected=false" ); + assert.equal( headers.eq( 0 ).attr( "aria-expanded" ), "false", "inactive tab (0) has aria-expanded=false" ); + assert.equal( headers.eq( 0 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel (0) has aria-hidden=true" ); + assert.equal( headers.eq( 2 ).attr( "tabindex" ), -1, "inactive header (2) has tabindex=-1" ); + assert.equal( headers.eq( 2 ).attr( "aria-selected" ), "false", "inactive tab (2) has aria-selected=false" ); + assert.equal( headers.eq( 2 ).attr( "aria-expanded" ), "false", "inactive tab (2) has aria-expanded=false" ); + assert.equal( headers.eq( 2 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel (2) has aria-hidden=true" ); } ); -asyncTest( "keyboard support", function( assert ) { - expect( 13 ); +QUnit.test( "keyboard support", function( assert ) { + var ready = assert.async(); + assert.expect( 13 ); var element = $( "#list1" ).accordion(), headers = element.find( ".ui-accordion-header" ), anchor = headers.eq( 1 ).next().find( "a" ).eq( 0 ), keyCode = $.ui.keyCode; - equal( headers.filter( ".ui-state-focus" ).length, 0, "no headers focused on init" ); + assert.equal( headers.filter( ".ui-state-focus" ).length, 0, "no headers focused on init" ); headers.eq( 0 ).simulate( "focus" ); setTimeout( step1 ); @@ -180,13 +182,13 @@ asyncTest( "keyboard support", function( assert ) { } function step9() { - equal( element.accordion( "option", "active" ), 2, "ENTER activates panel" ); + assert.equal( element.accordion( "option", "active" ), 2, "ENTER activates panel" ); headers.eq( 1 ).simulate( "keydown", { keyCode: keyCode.SPACE } ); setTimeout( step10 ); } function step10() { - equal( element.accordion( "option", "active" ), 1, "SPACE activates panel" ); + assert.equal( element.accordion( "option", "active" ), 1, "SPACE activates panel" ); anchor.simulate( "focus" ); setTimeout( step11 ); } @@ -200,7 +202,7 @@ asyncTest( "keyboard support", function( assert ) { function step12() { assert.hasClasses( headers.eq( 1 ), "ui-state-focus", "CTRL+UP moves focus to header" ); - start(); + ready(); } } ); diff --git a/tests/unit/accordion/events.js b/tests/unit/accordion/events.js index 1634b402d..b9af7ce06 100644 --- a/tests/unit/accordion/events.js +++ b/tests/unit/accordion/events.js @@ -1,16 +1,17 @@ define( [ + "qunit", "jquery", "./helper", "ui/widgets/accordion" -], function( $, testHelper ) { +], function( QUnit, $, testHelper ) { var setupTeardown = testHelper.setupTeardown, state = testHelper.state; -module( "accordion: events", setupTeardown() ); +QUnit.module( "accordion: events", setupTeardown() ); -test( "create", function() { - expect( 10 ); +QUnit.test( "create", function( assert ) { + assert.expect( 10 ); var element = $( "#list1" ), headers = element.children( "h3" ), @@ -18,10 +19,10 @@ test( "create", function() { element.accordion( { create: function( event, ui ) { - equal( ui.header.length, 1, "header length" ); - strictEqual( ui.header[ 0 ], headers[ 0 ], "header" ); - equal( ui.panel.length, 1, "panel length" ); - strictEqual( ui.panel[ 0 ], contents[ 0 ], "panel" ); + assert.equal( ui.header.length, 1, "header length" ); + assert.strictEqual( ui.header[ 0 ], headers[ 0 ], "header" ); + assert.equal( ui.panel.length, 1, "panel length" ); + assert.strictEqual( ui.panel[ 0 ], contents[ 0 ], "panel" ); } } ); element.accordion( "destroy" ); @@ -29,10 +30,10 @@ test( "create", function() { element.accordion( { active: 2, create: function( event, ui ) { - equal( ui.header.length, 1, "header length" ); - strictEqual( ui.header[ 0 ], headers[ 2 ], "header" ); - equal( ui.panel.length, 1, "panel length" ); - strictEqual( ui.panel[ 0 ], contents[ 2 ], "panel" ); + assert.equal( ui.header.length, 1, "header length" ); + assert.strictEqual( ui.header[ 0 ], headers[ 2 ], "header" ); + assert.equal( ui.panel.length, 1, "panel length" ); + assert.strictEqual( ui.panel[ 0 ], contents[ 2 ], "panel" ); } } ); element.accordion( "destroy" ); @@ -41,15 +42,15 @@ test( "create", function() { active: false, collapsible: true, create: function( event, ui ) { - equal( ui.header.length, 0, "header length" ); - equal( ui.panel.length, 0, "panel length" ); + assert.equal( ui.header.length, 0, "header length" ); + assert.equal( ui.panel.length, 0, "panel length" ); } } ); element.accordion( "destroy" ); } ); -test( "beforeActivate", function() { - expect( 38 ); +QUnit.test( "beforeActivate", function( assert ) { + assert.expect( 38 ); var element = $( "#list1" ).accordion( { active: false, collapsible: true @@ -58,63 +59,63 @@ test( "beforeActivate", function() { content = element.find( ".ui-accordion-content" ); element.one( "accordionbeforeactivate", function( event, ui ) { - ok( !( "originalEvent" in event ) ); - equal( ui.oldHeader.length, 0 ); - equal( ui.oldPanel.length, 0 ); - equal( ui.newHeader.length, 1 ); - strictEqual( ui.newHeader[ 0 ], headers[ 0 ] ); - equal( ui.newPanel.length, 1 ); - strictEqual( ui.newPanel[ 0 ], content[ 0 ] ); - state( element, 0, 0, 0 ); + assert.ok( !( "originalEvent" in event ) ); + assert.equal( ui.oldHeader.length, 0 ); + assert.equal( ui.oldPanel.length, 0 ); + assert.equal( ui.newHeader.length, 1 ); + assert.strictEqual( ui.newHeader[ 0 ], headers[ 0 ] ); + assert.equal( ui.newPanel.length, 1 ); + assert.strictEqual( ui.newPanel[ 0 ], content[ 0 ] ); + state( assert, element, 0, 0, 0 ); } ); element.accordion( "option", "active", 0 ); - state( element, 1, 0, 0 ); + state( assert, element, 1, 0, 0 ); element.one( "accordionbeforeactivate", function( event, ui ) { - equal( event.originalEvent.type, "click" ); - equal( ui.oldHeader.length, 1 ); - strictEqual( ui.oldHeader[ 0 ], headers[ 0 ] ); - equal( ui.oldPanel.length, 1 ); - strictEqual( ui.oldPanel[ 0 ], content[ 0 ] ); - equal( ui.newHeader.length, 1 ); - strictEqual( ui.newHeader[ 0 ], headers[ 1 ] ); - equal( ui.newPanel.length, 1 ); - strictEqual( ui.newPanel[ 0 ], content[ 1 ] ); - state( element, 1, 0, 0 ); + assert.equal( event.originalEvent.type, "click" ); + assert.equal( ui.oldHeader.length, 1 ); + assert.strictEqual( ui.oldHeader[ 0 ], headers[ 0 ] ); + assert.equal( ui.oldPanel.length, 1 ); + assert.strictEqual( ui.oldPanel[ 0 ], content[ 0 ] ); + assert.equal( ui.newHeader.length, 1 ); + assert.strictEqual( ui.newHeader[ 0 ], headers[ 1 ] ); + assert.equal( ui.newPanel.length, 1 ); + assert.strictEqual( ui.newPanel[ 0 ], content[ 1 ] ); + state( assert, element, 1, 0, 0 ); } ); headers.eq( 1 ).trigger( "click" ); - state( element, 0, 1, 0 ); + state( assert, element, 0, 1, 0 ); element.one( "accordionbeforeactivate", function( event, ui ) { - ok( !( "originalEvent" in event ) ); - equal( ui.oldHeader.length, 1 ); - strictEqual( ui.oldHeader[ 0 ], headers[ 1 ] ); - equal( ui.oldPanel.length, 1 ); - strictEqual( ui.oldPanel[ 0 ], content[ 1 ] ); - equal( ui.newHeader.length, 0 ); - equal( ui.newPanel.length, 0 ); - state( element, 0, 1, 0 ); + assert.ok( !( "originalEvent" in event ) ); + assert.equal( ui.oldHeader.length, 1 ); + assert.strictEqual( ui.oldHeader[ 0 ], headers[ 1 ] ); + assert.equal( ui.oldPanel.length, 1 ); + assert.strictEqual( ui.oldPanel[ 0 ], content[ 1 ] ); + assert.equal( ui.newHeader.length, 0 ); + assert.equal( ui.newPanel.length, 0 ); + state( assert, element, 0, 1, 0 ); } ); element.accordion( "option", "active", false ); - state( element, 0, 0, 0 ); + state( assert, element, 0, 0, 0 ); element.one( "accordionbeforeactivate", function( event, ui ) { - ok( !( "originalEvent" in event ) ); - equal( ui.oldHeader.length, 0 ); - equal( ui.oldPanel.length, 0 ); - equal( ui.newHeader.length, 1 ); - strictEqual( ui.newHeader[ 0 ], headers[ 2 ] ); - equal( ui.newPanel.length, 1 ); - strictEqual( ui.newPanel[ 0 ], content[ 2 ] ); + assert.ok( !( "originalEvent" in event ) ); + assert.equal( ui.oldHeader.length, 0 ); + assert.equal( ui.oldPanel.length, 0 ); + assert.equal( ui.newHeader.length, 1 ); + assert.strictEqual( ui.newHeader[ 0 ], headers[ 2 ] ); + assert.equal( ui.newPanel.length, 1 ); + assert.strictEqual( ui.newPanel[ 0 ], content[ 2 ] ); event.preventDefault(); - state( element, 0, 0, 0 ); + state( assert, element, 0, 0, 0 ); } ); element.accordion( "option", "active", 2 ); - state( element, 0, 0, 0 ); + state( assert, element, 0, 0, 0 ); } ); -test( "activate", function() { - expect( 21 ); +QUnit.test( "activate", function( assert ) { + assert.expect( 21 ); var element = $( "#list1" ).accordion( { active: false, collapsible: true @@ -123,44 +124,44 @@ test( "activate", function() { content = element.find( ".ui-accordion-content" ); element.one( "accordionactivate", function( event, ui ) { - equal( ui.oldHeader.length, 0 ); - equal( ui.oldPanel.length, 0 ); - equal( ui.newHeader.length, 1 ); - strictEqual( ui.newHeader[ 0 ], headers[ 0 ] ); - equal( ui.newPanel.length, 1 ); - strictEqual( ui.newPanel[ 0 ], content[ 0 ] ); + assert.equal( ui.oldHeader.length, 0 ); + assert.equal( ui.oldPanel.length, 0 ); + assert.equal( ui.newHeader.length, 1 ); + assert.strictEqual( ui.newHeader[ 0 ], headers[ 0 ] ); + assert.equal( ui.newPanel.length, 1 ); + assert.strictEqual( ui.newPanel[ 0 ], content[ 0 ] ); } ); element.accordion( "option", "active", 0 ); element.one( "accordionactivate", function( event, ui ) { - equal( ui.oldHeader.length, 1 ); - strictEqual( ui.oldHeader[ 0 ], headers[ 0 ] ); - equal( ui.oldPanel.length, 1 ); - strictEqual( ui.oldPanel[ 0 ], content[ 0 ] ); - equal( ui.newHeader.length, 1 ); - strictEqual( ui.newHeader[ 0 ], headers[ 1 ] ); - equal( ui.newPanel.length, 1 ); - strictEqual( ui.newPanel[ 0 ], content[ 1 ] ); + assert.equal( ui.oldHeader.length, 1 ); + assert.strictEqual( ui.oldHeader[ 0 ], headers[ 0 ] ); + assert.equal( ui.oldPanel.length, 1 ); + assert.strictEqual( ui.oldPanel[ 0 ], content[ 0 ] ); + assert.equal( ui.newHeader.length, 1 ); + assert.strictEqual( ui.newHeader[ 0 ], headers[ 1 ] ); + assert.equal( ui.newPanel.length, 1 ); + assert.strictEqual( ui.newPanel[ 0 ], content[ 1 ] ); } ); headers.eq( 1 ).trigger( "click" ); element.one( "accordionactivate", function( event, ui ) { - equal( ui.oldHeader.length, 1 ); - strictEqual( ui.oldHeader[ 0 ], headers[ 1 ] ); - equal( ui.oldPanel.length, 1 ); - strictEqual( ui.oldPanel[ 0 ], content[ 1 ] ); - equal( ui.newHeader.length, 0 ); - equal( ui.newPanel.length, 0 ); + assert.equal( ui.oldHeader.length, 1 ); + assert.strictEqual( ui.oldHeader[ 0 ], headers[ 1 ] ); + assert.equal( ui.oldPanel.length, 1 ); + assert.strictEqual( ui.oldPanel[ 0 ], content[ 1 ] ); + assert.equal( ui.newHeader.length, 0 ); + assert.equal( ui.newPanel.length, 0 ); } ); element.accordion( "option", "active", false ); // Prevent activation element.one( "accordionbeforeactivate", function( event ) { - ok( true ); + assert.ok( true ); event.preventDefault(); } ); element.one( "accordionactivate", function() { - ok( false ); + assert.ok( false ); } ); element.accordion( "option", "active", 1 ); } ); diff --git a/tests/unit/accordion/helper.js b/tests/unit/accordion/helper.js index b47510733..80bfc1854 100644 --- a/tests/unit/accordion/helper.js +++ b/tests/unit/accordion/helper.js @@ -1,13 +1,14 @@ define( [ + "qunit", "jquery", "lib/helper", "ui/widgets/accordion" -], function( $, helper ) { +], function( QUnit, $, helper ) { return $.extend( helper, { - equalHeight: function( accordion, height ) { + equalHeight: function( assert, accordion, height ) { accordion.find( ".ui-accordion-content" ).each( function() { - equal( $( this ).outerHeight(), height ); + assert.equal( $( this ).outerHeight(), height ); } ); }, @@ -23,12 +24,12 @@ return $.extend( helper, { }; }, - state: function( accordion ) { - var expected = $.makeArray( arguments ).slice( 1 ), + state: function( assert, accordion ) { + var expected = $.makeArray( arguments ).slice( 2 ), actual = accordion.find( ".ui-accordion-content" ).map( function() { return $( this ).css( "display" ) === "none" ? 0 : 1; } ).get(); - QUnit.push( QUnit.equiv( actual, expected ), actual, expected ); + assert.deepEqual( actual, expected ); } } ); diff --git a/tests/unit/accordion/methods.js b/tests/unit/accordion/methods.js index 3b1696e45..1b11e91ee 100644 --- a/tests/unit/accordion/methods.js +++ b/tests/unit/accordion/methods.js @@ -1,47 +1,48 @@ define( [ + "qunit", "jquery", "./helper", "ui/widgets/accordion" -], function( $, testHelper ) { +], function( QUnit, $, testHelper ) { var equalHeight = testHelper.equalHeight, setupTeardown = testHelper.setupTeardown, state = testHelper.state; -module( "accordion: methods", setupTeardown() ); +QUnit.module( "accordion: methods", setupTeardown() ); -test( "destroy", function( assert ) { - expect( 1 ); +QUnit.test( "destroy", function( assert ) { + assert.expect( 1 ); assert.domEqual( "#list1", function() { $( "#list1" ).accordion().accordion( "destroy" ); } ); } ); -test( "enable/disable", function( assert ) { - expect( 7 ); +QUnit.test( "enable/disable", function( assert ) { + assert.expect( 7 ); var element = $( "#list1" ).accordion(); - state( element, 1, 0, 0 ); + state( assert, element, 1, 0, 0 ); element.accordion( "disable" ); assert.hasClasses( element, "ui-state-disabled" ); - equal( element.attr( "aria-disabled" ), "true", "element gets aria-disabled" ); + assert.equal( element.attr( "aria-disabled" ), "true", "element gets aria-disabled" ); assert.hasClasses( element, "ui-accordion-disabled" ); // Event does nothing element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "click" ); - state( element, 1, 0, 0 ); + state( assert, element, 1, 0, 0 ); // Option still works element.accordion( "option", "active", 1 ); - state( element, 0, 1, 0 ); + state( assert, element, 0, 1, 0 ); element.accordion( "enable" ); element.accordion( "option", "active", 2 ); - state( element, 0, 0, 1 ); + state( assert, element, 0, 0, 1 ); } ); -test( "refresh", function() { - expect( 19 ); +QUnit.test( "refresh", function( assert ) { + assert.expect( 19 ); var element = $( "#navigation" ) .parent() .height( 300 ) @@ -49,37 +50,37 @@ test( "refresh", function() { .accordion( { heightStyle: "fill" } ); - equalHeight( element, 255 ); + equalHeight( assert, element, 255 ); element.parent().height( 500 ); element.accordion( "refresh" ); - equalHeight( element, 455 ); + equalHeight( assert, element, 455 ); element = $( "#list1" ); element.accordion(); - state( element, 1, 0, 0 ); + state( assert, element, 1, 0, 0 ); // Disable panel via markup element.find( "h3.bar" ).eq( 1 ).addClass( "ui-state-disabled" ); element.accordion( "refresh" ); - state( element, 1, 0, 0 ); + state( assert, element, 1, 0, 0 ); // Don't add multiple icons element.accordion( "refresh" ); - equal( element.find( ".ui-accordion-header-icon" ).length, 3 ); + assert.equal( element.find( ".ui-accordion-header-icon" ).length, 3 ); // Add a panel element .append( "

new 1

" ) .append( "
new 1
" ); element.accordion( "refresh" ); - state( element, 1, 0, 0, 0 ); + state( assert, element, 1, 0, 0, 0 ); // Remove all tabs element.find( "h3.bar, div.foo" ).remove(); element.accordion( "refresh" ); - state( element ); - equal( element.accordion( "option", "active" ), false, "no active accordion panel" ); + state( assert, element ); + assert.equal( element.accordion( "option", "active" ), false, "no active accordion panel" ); // Add panels element @@ -92,46 +93,46 @@ test( "refresh", function() { .append( "

new 5

" ) .append( "
new 5
" ); element.accordion( "refresh" ); - state( element, 1, 0, 0, 0 ); + state( assert, element, 1, 0, 0, 0 ); // Activate third tab element.accordion( "option", "active", 2 ); - state( element, 0, 0, 1, 0 ); + state( assert, element, 0, 0, 1, 0 ); // Remove fourth panel, third panel should stay active element.find( "h3.bar" ).eq( 3 ).remove(); element.find( "div.foo" ).eq( 3 ).remove(); element.accordion( "refresh" ); - state( element, 0, 0, 1 ); + state( assert, element, 0, 0, 1 ); // Remove third (active) panel, second panel should become active element.find( "h3.bar" ).eq( 2 ).remove(); element.find( "div.foo" ).eq( 2 ).remove(); element.accordion( "refresh" ); - state( element, 0, 1 ); + state( assert, element, 0, 1 ); // Remove first panel, previously active panel (now first) should stay active element.find( "h3.bar" ).eq( 0 ).remove(); element.find( "div.foo" ).eq( 0 ).remove(); element.accordion( "refresh" ); - state( element, 1 ); + state( assert, element, 1 ); // Collapse all panels element.accordion( "option", { collapsible: true, active: false } ); - state( element, 0 ); + state( assert, element, 0 ); element.accordion( "refresh" ); - state( element, 0 ); + state( assert, element, 0 ); } ); -test( "widget", function() { - expect( 2 ); +QUnit.test( "widget", function( assert ) { + assert.expect( 2 ); var element = $( "#list1" ).accordion(), widgetElement = element.accordion( "widget" ); - equal( widgetElement.length, 1, "one element" ); - strictEqual( widgetElement[ 0 ], element[ 0 ], "same element" ); + assert.equal( widgetElement.length, 1, "one element" ); + assert.strictEqual( widgetElement[ 0 ], element[ 0 ], "same element" ); } ); } ); diff --git a/tests/unit/accordion/options.js b/tests/unit/accordion/options.js index 228a8be40..2dec303a9 100644 --- a/tests/unit/accordion/options.js +++ b/tests/unit/accordion/options.js @@ -1,56 +1,57 @@ define( [ + "qunit", "jquery", "./helper", "ui/widgets/accordion" -], function( $, testHelper ) { +], function( QUnit, $, testHelper ) { var equalHeight = testHelper.equalHeight, setupTeardown = testHelper.setupTeardown, state = testHelper.state; -module( "accordion: options", setupTeardown() ); +QUnit.module( "accordion: options", setupTeardown() ); -test( "{ active: default }", function() { - expect( 2 ); +QUnit.test( "{ active: default }", function( assert ) { + assert.expect( 2 ); var element = $( "#list1" ).accordion(); - equal( element.accordion( "option", "active" ), 0 ); - state( element, 1, 0, 0 ); + assert.equal( element.accordion( "option", "active" ), 0 ); + state( assert, element, 1, 0, 0 ); } ); -test( "{ active: null }", function() { - expect( 2 ); +QUnit.test( "{ active: null }", function( assert ) { + assert.expect( 2 ); var element = $( "#list1" ).accordion( { active: null } ); - equal( element.accordion( "option", "active" ), 0 ); - state( element, 1, 0, 0 ); + assert.equal( element.accordion( "option", "active" ), 0 ); + state( assert, element, 1, 0, 0 ); } ); -test( "{ active: false }", function() { - expect( 7 ); +QUnit.test( "{ active: false }", function( assert ) { + assert.expect( 7 ); var element = $( "#list1" ).accordion( { active: false, collapsible: true } ); - state( element, 0, 0, 0 ); - equal( element.find( ".ui-accordion-header.ui-state-active" ).length, 0, "no headers selected" ); - equal( element.accordion( "option", "active" ), false ); + state( assert, element, 0, 0, 0 ); + assert.equal( element.find( ".ui-accordion-header.ui-state-active" ).length, 0, "no headers selected" ); + assert.equal( element.accordion( "option", "active" ), false ); element.accordion( "option", "collapsible", false ); - state( element, 1, 0, 0 ); - equal( element.accordion( "option", "active" ), 0 ); + state( assert, element, 1, 0, 0 ); + assert.equal( element.accordion( "option", "active" ), 0 ); element.accordion( "destroy" ); element.accordion( { active: false } ); - state( element, 1, 0, 0 ); - strictEqual( element.accordion( "option", "active" ), 0 ); + state( assert, element, 1, 0, 0 ); + assert.strictEqual( element.accordion( "option", "active" ), 0 ); } ); // http://bugs.jqueryui.com/ticket/11938 -test( "{ active: false, collapsible: true }", function() { - expect( 1 ); +QUnit.test( "{ active: false, collapsible: true }", function( assert ) { + assert.expect( 1 ); var element = $( "#collapsible" ).accordion(), height = element.outerHeight(); @@ -61,71 +62,72 @@ test( "{ active: false, collapsible: true }", function() { collapsible: true } ) .accordion( "option", "active", 0 ); - equal( element.outerHeight(), height ); + assert.equal( element.outerHeight(), height ); } ); -test( "{ active: Number }", function() { - expect( 8 ); +QUnit.test( "{ active: Number }", function( assert ) { + assert.expect( 8 ); var element = $( "#list1" ).accordion( { active: 2 } ); - equal( element.accordion( "option", "active" ), 2 ); - state( element, 0, 0, 1 ); + assert.equal( element.accordion( "option", "active" ), 2 ); + state( assert, element, 0, 0, 1 ); element.accordion( "option", "active", 0 ); - equal( element.accordion( "option", "active" ), 0 ); - state( element, 1, 0, 0 ); + assert.equal( element.accordion( "option", "active" ), 0 ); + state( assert, element, 1, 0, 0 ); element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "click" ); - equal( element.accordion( "option", "active" ), 1 ); - state( element, 0, 1, 0 ); + assert.equal( element.accordion( "option", "active" ), 1 ); + state( assert, element, 0, 1, 0 ); element.accordion( "option", "active", 10 ); - equal( element.accordion( "option", "active" ), 1 ); - state( element, 0, 1, 0 ); + assert.equal( element.accordion( "option", "active" ), 1 ); + state( assert, element, 0, 1, 0 ); } ); -test( "{ active: -Number }", function() { - expect( 8 ); +QUnit.test( "{ active: -Number }", function( assert ) { + assert.expect( 8 ); var element = $( "#list1" ).accordion( { active: -1 } ); - equal( element.accordion( "option", "active" ), 2 ); - state( element, 0, 0, 1 ); + assert.equal( element.accordion( "option", "active" ), 2 ); + state( assert, element, 0, 0, 1 ); element.accordion( "option", "active", -2 ); - equal( element.accordion( "option", "active" ), 1 ); - state( element, 0, 1, 0 ); + assert.equal( element.accordion( "option", "active" ), 1 ); + state( assert, element, 0, 1, 0 ); element.accordion( "option", "active", -10 ); - equal( element.accordion( "option", "active" ), 1 ); - state( element, 0, 1, 0 ); + assert.equal( element.accordion( "option", "active" ), 1 ); + state( assert, element, 0, 1, 0 ); element.accordion( "option", "active", -3 ); - equal( element.accordion( "option", "active" ), 0 ); - state( element, 1, 0, 0 ); + assert.equal( element.accordion( "option", "active" ), 0 ); + state( assert, element, 1, 0, 0 ); } ); -test( "{ animate: false }", function() { - expect( 3 ); +QUnit.test( "{ animate: false }", function( assert ) { + assert.expect( 3 ); var element = $( "#list1" ).accordion( { animate: false } ), panels = element.find( ".ui-accordion-content" ), animate = $.fn.animate; $.fn.animate = function() { - ok( false, ".animate() called" ); + assert.ok( false, ".animate() called" ); }; - ok( panels.eq( 0 ).is( ":visible" ), "first panel visible" ); + assert.ok( panels.eq( 0 ).is( ":visible" ), "first panel visible" ); element.accordion( "option", "active", 1 ); - ok( panels.eq( 0 ).is( ":hidden" ), "first panel hidden" ); - ok( panels.eq( 1 ).is( ":visible" ), "second panel visible" ); + assert.ok( panels.eq( 0 ).is( ":hidden" ), "first panel hidden" ); + assert.ok( panels.eq( 1 ).is( ":visible" ), "second panel visible" ); $.fn.animate = animate; } ); -asyncTest( "{ animate: Number }", function() { - expect( 7 ); +QUnit.test( "{ animate: Number }", function( assert ) { + var ready = assert.async(); + assert.expect( 7 ); var element = $( "#list1" ).accordion( { animate: 100 } ), @@ -134,23 +136,24 @@ asyncTest( "{ animate: Number }", function() { // Called twice (both panels) $.fn.animate = function( props, options ) { - equal( options.duration, 100, "correct duration" ); - equal( options.easing, undefined, "default easing" ); + assert.equal( options.duration, 100, "correct duration" ); + assert.equal( options.easing, undefined, "default easing" ); animate.apply( this, arguments ); }; - ok( panels.eq( 0 ).is( ":visible" ), "first panel visible" ); + assert.ok( panels.eq( 0 ).is( ":visible" ), "first panel visible" ); element.accordion( "option", "active", 1 ); panels.promise().done( function() { - ok( panels.eq( 0 ).is( ":hidden" ), "first panel hidden" ); - ok( panels.eq( 1 ).is( ":visible" ), "second panel visible" ); + assert.ok( panels.eq( 0 ).is( ":hidden" ), "first panel hidden" ); + assert.ok( panels.eq( 1 ).is( ":visible" ), "second panel visible" ); $.fn.animate = animate; - start(); + ready(); } ); } ); -asyncTest( "{ animate: String }", function() { - expect( 7 ); +QUnit.test( "{ animate: String }", function( assert ) { + var ready = assert.async(); + assert.expect( 7 ); var element = $( "#list1" ).accordion( { animate: "linear" } ), @@ -159,23 +162,24 @@ asyncTest( "{ animate: String }", function() { // Called twice (both panels) $.fn.animate = function( props, options ) { - equal( options.duration, undefined, "default duration" ); - equal( options.easing, "linear", "correct easing" ); + assert.equal( options.duration, undefined, "default duration" ); + assert.equal( options.easing, "linear", "correct easing" ); animate.apply( this, arguments ); }; - ok( panels.eq( 0 ).is( ":visible" ), "first panel visible" ); + assert.ok( panels.eq( 0 ).is( ":visible" ), "first panel visible" ); element.accordion( "option", "active", 1 ); panels.promise().done( function() { - ok( panels.eq( 0 ).is( ":hidden" ), "first panel hidden" ); - ok( panels.eq( 1 ).is( ":visible" ), "second panel visible" ); + assert.ok( panels.eq( 0 ).is( ":hidden" ), "first panel hidden" ); + assert.ok( panels.eq( 1 ).is( ":visible" ), "second panel visible" ); $.fn.animate = animate; - start(); + ready(); } ); } ); -asyncTest( "{ animate: {} }", function() { - expect( 7 ); +QUnit.test( "{ animate: {} }", function( assert ) { + var ready = assert.async(); + assert.expect( 7 ); var element = $( "#list1" ).accordion( { animate: {} } ), @@ -184,23 +188,24 @@ asyncTest( "{ animate: {} }", function() { // Called twice (both panels) $.fn.animate = function( props, options ) { - equal( options.duration, undefined, "default duration" ); - equal( options.easing, undefined, "default easing" ); + assert.equal( options.duration, undefined, "default duration" ); + assert.equal( options.easing, undefined, "default easing" ); animate.apply( this, arguments ); }; - ok( panels.eq( 0 ).is( ":visible" ), "first panel visible" ); + assert.ok( panels.eq( 0 ).is( ":visible" ), "first panel visible" ); element.accordion( "option", "active", 1 ); panels.promise().done( function() { - ok( panels.eq( 0 ).is( ":hidden" ), "first panel hidden" ); - ok( panels.eq( 1 ).is( ":visible" ), "second panel visible" ); + assert.ok( panels.eq( 0 ).is( ":hidden" ), "first panel hidden" ); + assert.ok( panels.eq( 1 ).is( ":visible" ), "second panel visible" ); $.fn.animate = animate; - start(); + ready(); } ); } ); -asyncTest( "{ animate: { duration, easing } }", function() { - expect( 7 ); +QUnit.test( "{ animate: { duration, easing } }", function( assert ) { + var ready = assert.async(); + assert.expect( 7 ); var element = $( "#list1" ).accordion( { animate: { duration: 100, easing: "linear" } } ), @@ -209,23 +214,24 @@ asyncTest( "{ animate: { duration, easing } }", function() { // Called twice (both panels) $.fn.animate = function( props, options ) { - equal( options.duration, 100, "correct duration" ); - equal( options.easing, "linear", "correct easing" ); + assert.equal( options.duration, 100, "correct duration" ); + assert.equal( options.easing, "linear", "correct easing" ); animate.apply( this, arguments ); }; - ok( panels.eq( 0 ).is( ":visible" ), "first panel visible" ); + assert.ok( panels.eq( 0 ).is( ":visible" ), "first panel visible" ); element.accordion( "option", "active", 1 ); panels.promise().done( function() { - ok( panels.eq( 0 ).is( ":hidden" ), "first panel hidden" ); - ok( panels.eq( 1 ).is( ":visible" ), "second panel visible" ); + assert.ok( panels.eq( 0 ).is( ":hidden" ), "first panel hidden" ); + assert.ok( panels.eq( 1 ).is( ":visible" ), "second panel visible" ); $.fn.animate = animate; - start(); + ready(); } ); } ); -asyncTest( "{ animate: { duration, easing } }, animate down", function() { - expect( 7 ); +QUnit.test( "{ animate: { duration, easing } }, animate down", function( assert ) { + var ready = assert.async(); + assert.expect( 7 ); var element = $( "#list1" ).accordion( { active: 1, animate: { duration: 100, easing: "linear" } @@ -235,23 +241,24 @@ asyncTest( "{ animate: { duration, easing } }, animate down", function() { // Called twice (both panels) $.fn.animate = function( props, options ) { - equal( options.duration, 100, "correct duration" ); - equal( options.easing, "linear", "correct easing" ); + assert.equal( options.duration, 100, "correct duration" ); + assert.equal( options.easing, "linear", "correct easing" ); animate.apply( this, arguments ); }; - ok( panels.eq( 1 ).is( ":visible" ), "first panel visible" ); + assert.ok( panels.eq( 1 ).is( ":visible" ), "first panel visible" ); element.accordion( "option", "active", 0 ); panels.promise().done( function() { - ok( panels.eq( 1 ).is( ":hidden" ), "first panel hidden" ); - ok( panels.eq( 0 ).is( ":visible" ), "second panel visible" ); + assert.ok( panels.eq( 1 ).is( ":hidden" ), "first panel hidden" ); + assert.ok( panels.eq( 0 ).is( ":visible" ), "second panel visible" ); $.fn.animate = animate; - start(); + ready(); } ); } ); -asyncTest( "{ animate: { duration, easing, down } }, animate down", function() { - expect( 7 ); +QUnit.test( "{ animate: { duration, easing, down } }, animate down", function( assert ) { + var ready = assert.async(); + assert.expect( 7 ); var element = $( "#list1" ).accordion( { active: 1, animate: { @@ -267,156 +274,156 @@ asyncTest( "{ animate: { duration, easing, down } }, animate down", function() { // Called twice (both panels) $.fn.animate = function( props, options ) { - equal( options.duration, 100, "correct duration" ); - equal( options.easing, "swing", "correct easing" ); + assert.equal( options.duration, 100, "correct duration" ); + assert.equal( options.easing, "swing", "correct easing" ); animate.apply( this, arguments ); }; - ok( panels.eq( 1 ).is( ":visible" ), "first panel visible" ); + assert.ok( panels.eq( 1 ).is( ":visible" ), "first panel visible" ); element.accordion( "option", "active", 0 ); panels.promise().done( function() { - ok( panels.eq( 1 ).is( ":hidden" ), "first panel hidden" ); - ok( panels.eq( 0 ).is( ":visible" ), "second panel visible" ); + assert.ok( panels.eq( 1 ).is( ":hidden" ), "first panel hidden" ); + assert.ok( panels.eq( 0 ).is( ":visible" ), "second panel visible" ); $.fn.animate = animate; - start(); + ready(); } ); } ); -test( "{ collapsible: false }", function() { - expect( 4 ); +QUnit.test( "{ collapsible: false }", function( assert ) { + assert.expect( 4 ); var element = $( "#list1" ).accordion( { active: 1 } ); element.accordion( "option", "active", false ); - equal( element.accordion( "option", "active" ), 1 ); - state( element, 0, 1, 0 ); + assert.equal( element.accordion( "option", "active" ), 1 ); + state( assert, element, 0, 1, 0 ); element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "click" ); - equal( element.accordion( "option", "active" ), 1 ); - state( element, 0, 1, 0 ); + assert.equal( element.accordion( "option", "active" ), 1 ); + state( assert, element, 0, 1, 0 ); } ); -test( "{ collapsible: true }", function() { - expect( 6 ); +QUnit.test( "{ collapsible: true }", function( assert ) { + assert.expect( 6 ); var element = $( "#list1" ).accordion( { active: 1, collapsible: true } ); element.accordion( "option", "active", false ); - equal( element.accordion( "option", "active" ), false ); - state( element, 0, 0, 0 ); + assert.equal( element.accordion( "option", "active" ), false ); + state( assert, element, 0, 0, 0 ); element.accordion( "option", "active", 1 ); - equal( element.accordion( "option", "active" ), 1 ); - state( element, 0, 1, 0 ); + assert.equal( element.accordion( "option", "active" ), 1 ); + state( assert, element, 0, 1, 0 ); element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "click" ); - equal( element.accordion( "option", "active" ), false ); - state( element, 0, 0, 0 ); + assert.equal( element.accordion( "option", "active" ), false ); + state( assert, element, 0, 0, 0 ); } ); -test( "{ event: null }", function() { - expect( 5 ); +QUnit.test( "{ event: null }", function( assert ) { + assert.expect( 5 ); var element = $( "#list1" ).accordion( { event: null } ); - state( element, 1, 0, 0 ); + state( assert, element, 1, 0, 0 ); element.accordion( "option", "active", 1 ); - equal( element.accordion( "option", "active" ), 1 ); - state( element, 0, 1, 0 ); + assert.equal( element.accordion( "option", "active" ), 1 ); + state( assert, element, 0, 1, 0 ); // Ensure default click handler isn't bound element.find( ".ui-accordion-header" ).eq( 2 ).trigger( "click" ); - equal( element.accordion( "option", "active" ), 1 ); - state( element, 0, 1, 0 ); + assert.equal( element.accordion( "option", "active" ), 1 ); + state( assert, element, 0, 1, 0 ); } ); -test( "{ event: custom }", function() { - expect( 11 ); +QUnit.test( "{ event: custom }", function( assert ) { + assert.expect( 11 ); var element = $( "#list1" ).accordion( { event: "custom1 custom2" } ); - state( element, 1, 0, 0 ); + state( assert, element, 1, 0, 0 ); element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "custom1" ); - equal( element.accordion( "option", "active" ), 1 ); - state( element, 0, 1, 0 ); + assert.equal( element.accordion( "option", "active" ), 1 ); + state( assert, element, 0, 1, 0 ); // Ensure default click handler isn't bound element.find( ".ui-accordion-header" ).eq( 2 ).trigger( "click" ); - equal( element.accordion( "option", "active" ), 1 ); - state( element, 0, 1, 0 ); + assert.equal( element.accordion( "option", "active" ), 1 ); + state( assert, element, 0, 1, 0 ); element.find( ".ui-accordion-header" ).eq( 2 ).trigger( "custom2" ); - equal( element.accordion( "option", "active" ), 2 ); - state( element, 0, 0, 1 ); + assert.equal( element.accordion( "option", "active" ), 2 ); + state( assert, element, 0, 0, 1 ); element.accordion( "option", "event", "custom3" ); // Ensure old event handlers are unbound element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "custom1" ); element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "custom2" ); - equal( element.accordion( "option", "active" ), 2 ); - state( element, 0, 0, 1 ); + assert.equal( element.accordion( "option", "active" ), 2 ); + state( assert, element, 0, 0, 1 ); element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "custom3" ); - equal( element.accordion( "option", "active" ), 1 ); - state( element, 0, 1, 0 ); + assert.equal( element.accordion( "option", "active" ), 1 ); + state( assert, element, 0, 1, 0 ); } ); -test( "{ header: default }", function() { - expect( 2 ); +QUnit.test( "{ header: default }", function( assert ) { + assert.expect( 2 ); // Default: > li > :first-child,> :not(li):even // > :not(li):even - state( $( "#list1" ).accordion(), 1, 0, 0 ); + state( assert, $( "#list1" ).accordion(), 1, 0, 0 ); // > li > :first-child - state( $( "#navigation" ).accordion(), 1, 0, 0 ); + state( assert, $( "#navigation" ).accordion(), 1, 0, 0 ); } ); -test( "{ header: custom }", function( assert ) { - expect( 6 ); +QUnit.test( "{ header: custom }", function( assert ) { + assert.expect( 6 ); var element = $( "#navigationWrapper" ).accordion( { header: "h2" } ); element.find( "h2" ).each( function() { assert.hasClasses( this, "ui-accordion-header" ); } ); - equal( element.find( ".ui-accordion-header" ).length, 3 ); - state( element, 1, 0, 0 ); + assert.equal( element.find( ".ui-accordion-header" ).length, 3 ); + state( assert, element, 1, 0, 0 ); element.accordion( "option", "active", 2 ); - state( element, 0, 0, 1 ); + state( assert, element, 0, 0, 1 ); } ); -test( "{ heightStyle: 'auto' }", function() { - expect( 3 ); +QUnit.test( "{ heightStyle: 'auto' }", function( assert ) { + assert.expect( 3 ); var element = $( "#navigation" ).accordion( { heightStyle: "auto" } ); - equalHeight( element, 105 ); + equalHeight( assert, element, 105 ); } ); -test( "{ heightStyle: 'content' }", function() { - expect( 3 ); +QUnit.test( "{ heightStyle: 'content' }", function( assert ) { + assert.expect( 3 ); var element = $( "#navigation" ).accordion( { heightStyle: "content" } ), sizes = element.find( ".ui-accordion-content" ).map( function() { return $( this ).height(); } ).get(); - equal( sizes[ 0 ], 75 ); - equal( sizes[ 1 ], 105 ); - equal( sizes[ 2 ], 45 ); + assert.equal( sizes[ 0 ], 75 ); + assert.equal( sizes[ 1 ], 105 ); + assert.equal( sizes[ 2 ], 45 ); } ); -test( "{ heightStyle: 'fill' }", function() { - expect( 3 ); +QUnit.test( "{ heightStyle: 'fill' }", function( assert ) { + assert.expect( 3 ); $( "#navigationWrapper" ).height( 500 ); var element = $( "#navigation" ).accordion( { heightStyle: "fill" } ); - equalHeight( element, 455 ); + equalHeight( assert, element, 455 ); } ); -test( "{ heightStyle: 'fill' } with sibling", function() { - expect( 3 ); +QUnit.test( "{ heightStyle: 'fill' } with sibling", function( assert ) { + assert.expect( 3 ); $( "#navigationWrapper" ).height( 500 ); $( "

Lorem Ipsum

" ) .css( { @@ -426,11 +433,11 @@ test( "{ heightStyle: 'fill' } with sibling", function() { } ) .prependTo( "#navigationWrapper" ); var element = $( "#navigation" ).accordion( { heightStyle: "fill" } ); - equalHeight( element, 355 ); + equalHeight( assert, element, 355 ); } ); -test( "{ heightStyle: 'fill' } with multiple siblings", function() { - expect( 3 ); +QUnit.test( "{ heightStyle: 'fill' } with multiple siblings", function( assert ) { + assert.expect( 3 ); $( "#navigationWrapper" ).height( 500 ); $( "

Lorem Ipsum

" ) .css( { @@ -455,15 +462,15 @@ test( "{ heightStyle: 'fill' } with multiple siblings", function() { } ) .prependTo( "#navigationWrapper" ); var element = $( "#navigation" ).accordion( { heightStyle: "fill" } ); - equalHeight( element, 305 ); + equalHeight( assert, element, 305 ); } ); -test( "{ icons: false }", function() { - expect( 8 ); +QUnit.test( "{ icons: false }", function( assert ) { + assert.expect( 8 ); var element = $( "#list1" ); function icons( on ) { - deepEqual( element.find( "span.ui-icon" ).length, on ? 3 : 0 ); - deepEqual( element.find( ".ui-accordion-header.ui-accordion-icons" ).length, on ? 3 : 0 ); + assert.deepEqual( element.find( "span.ui-icon" ).length, on ? 3 : 0 ); + assert.deepEqual( element.find( ".ui-accordion-header.ui-accordion-icons" ).length, on ? 3 : 0 ); } element.accordion(); icons( true ); @@ -477,8 +484,8 @@ test( "{ icons: false }", function() { icons( false ); } ); -test( "{ icons: hash }", function( assert ) { - expect( 3 ); +QUnit.test( "{ icons: hash }", function( assert ) { + assert.expect( 3 ); var element = $( "#list1" ).accordion( { icons: { activeHeader: "a1", header: "h1" } } ); From f375fd1300b4e08c0e71a073131260dfb8e5762f Mon Sep 17 00:00:00 2001 From: Amanpreet Singh Date: Sun, 3 Apr 2016 20:13:27 +0530 Subject: [PATCH 035/136] Button: Shift to no globals --- tests/unit/button/core.js | 16 ++-- tests/unit/button/deprecated.js | 101 ++++++++++++------------ tests/unit/button/events.js | 14 ++-- tests/unit/button/methods.js | 19 ++--- tests/unit/button/options.js | 135 ++++++++++++++++---------------- 5 files changed, 146 insertions(+), 139 deletions(-) diff --git a/tests/unit/button/core.js b/tests/unit/button/core.js index de26b0312..13bc94e33 100644 --- a/tests/unit/button/core.js +++ b/tests/unit/button/core.js @@ -1,23 +1,25 @@ define( [ + "qunit", "jquery", "ui/safe-active-element", "ui/widgets/button" -], function( $ ) { +], function( QUnit, $ ) { -module( "Button: core" ); +QUnit.module( "Button: core" ); -asyncTest( "Disabled button loses focus", function() { - expect( 2 ); +QUnit.test( "Disabled button loses focus", function( assert ) { + var ready = assert.async(); + assert.expect( 2 ); var element = $( "#button" ).button(); element.focus(); setTimeout( function() { - equal( element[ 0 ], $.ui.safeActiveElement( document ), "Button is focused" ); + assert.equal( element[ 0 ], $.ui.safeActiveElement( document ), "Button is focused" ); element.button( "disable" ); - notEqual( element[ 0 ], $.ui.safeActiveElement( document ), "Button has had focus removed" ); - start(); + assert.notEqual( element[ 0 ], $.ui.safeActiveElement( document ), "Button has had focus removed" ); + ready(); } ); } ); diff --git a/tests/unit/button/deprecated.js b/tests/unit/button/deprecated.js index fac02e2a6..81a0281b7 100644 --- a/tests/unit/button/deprecated.js +++ b/tests/unit/button/deprecated.js @@ -1,134 +1,135 @@ define( [ + "qunit", "jquery", "ui/widgets/button" -], function( $ ) { +], function( QUnit, $ ) { -module( "Button (deprecated): core" ); +QUnit.module( "Button (deprecated): core" ); -test( "Calling button on a checkbox input calls checkboxradio widget", function() { +QUnit.test( "Calling button on a checkbox input calls checkboxradio widget", function( assert ) { var checkbox = $( "#checkbox01" ); - expect( 2 ); + assert.expect( 2 ); checkbox.button(); - ok( !!checkbox.checkboxradio( "instance" ), + assert.ok( !!checkbox.checkboxradio( "instance" ), "Calling button on a checkbox creates checkboxradio instance" ); - ok( !checkbox.checkboxradio( "option", "icon" ), + assert.ok( !checkbox.checkboxradio( "option", "icon" ), "Calling button on a checkbox sets the checkboxradio icon option to false" ); } ); -test( "Calling buttonset calls controlgroup", function() { +QUnit.test( "Calling buttonset calls controlgroup", function( assert ) { var controlgroup = $( ".buttonset" ); - expect( 1 ); + assert.expect( 1 ); controlgroup.buttonset(); - ok( controlgroup.is( ":ui-controlgroup" ), "Calling buttonset creates controlgroup instance" ); + assert.ok( controlgroup.is( ":ui-controlgroup" ), "Calling buttonset creates controlgroup instance" ); } ); -module( "Button (deprecated): methods" ); +QUnit.module( "Button (deprecated): methods" ); -test( "destroy", function( assert ) { - expect( 1 ); +QUnit.test( "destroy", function( assert ) { + assert.expect( 1 ); assert.domEqual( "#checkbox02", function() { $( "#checkbox02" ).button().button( "destroy" ); } ); } ); -test( "refresh: Ensure disabled state is preserved correctly.", function() { - expect( 5 ); +QUnit.test( "refresh: Ensure disabled state is preserved correctly.", function( assert ) { + assert.expect( 5 ); var element = null; element = $( "#checkbox02" ); element.button( { disabled: true } ).button( "refresh" ); - ok( element.button( "option", "disabled" ), "Checkboxes should remain disabled after refresh" ); - ok( element.prop( "disabled" ), "Input remains disabled after refresh" ); + assert.ok( element.button( "option", "disabled" ), "Checkboxes should remain disabled after refresh" ); + assert.ok( element.prop( "disabled" ), "Input remains disabled after refresh" ); element = $( "#radio02" ); element.button( { disabled: true } ).button( "refresh" ); - ok( element.button( "option", "disabled" ), "Radio buttons should remain disabled after refresh" ); + assert.ok( element.button( "option", "disabled" ), "Radio buttons should remain disabled after refresh" ); element = $( "#checkbox02" ); element.button( { disabled: true } ).prop( "disabled", false ).button( "refresh" ); - ok( !element.button( "option", "disabled" ), "Changing a checkbox's disabled property should update the state after refresh." ); + assert.ok( !element.button( "option", "disabled" ), "Changing a checkbox's disabled property should update the state after refresh." ); element = $( "#radio02" ); element.button( { disabled: true } ).prop( "disabled", false ).button( "refresh" ); - ok( !element.button( "option", "disabled" ), "Changing a radio button's disabled property should update the state after refresh." ); + assert.ok( !element.button( "option", "disabled" ), "Changing a radio button's disabled property should update the state after refresh." ); } ); -module( "button (deprecated): options" ); +QUnit.module( "button (deprecated): options" ); -test( "Setting items option on buttonset sets the button properties on the items option", function() { - expect( 2 ); +QUnit.test( "Setting items option on buttonset sets the button properties on the items option", function( assert ) { + assert.expect( 2 ); var controlgroup = $( ".buttonset" ); controlgroup.buttonset( { items: "bar" } ); - equal( controlgroup.controlgroup( "option", "items.button" ), "bar", + assert.equal( controlgroup.controlgroup( "option", "items.button" ), "bar", "items.button set when setting items option on init on buttonset" ); controlgroup.buttonset( "option", "items", "foo" ); - equal( controlgroup.controlgroup( "option", "items.button" ), "foo", + assert.equal( controlgroup.controlgroup( "option", "items.button" ), "foo", "items.button set when setting items option on buttonset" ); } ); -test( "disabled, null", function() { - expect( 2 ); +QUnit.test( "disabled, null", function( assert ) { + assert.expect( 2 ); $( "#radio02" ).prop( "disabled", true ).button( { disabled: null } ); - deepEqual( $( "#radio02" ).button( "option", "disabled" ), true, + assert.deepEqual( $( "#radio02" ).button( "option", "disabled" ), true, "disabled option set to true" ); - deepEqual( true, $( "#radio02" ).prop( "disabled" ), "element is not disabled" ); + assert.deepEqual( true, $( "#radio02" ).prop( "disabled" ), "element is not disabled" ); } ); -test( "text / showLabel options proxied", function() { - expect( 8 ); +QUnit.test( "text / showLabel options proxied", function( assert ) { + assert.expect( 8 ); var button = $( "#button" ); button.button( { text: false, icon: "ui-icon-gear" } ); - equal( button.button( "option", "showLabel" ), false, + assert.equal( button.button( "option", "showLabel" ), false, "Setting the text option to false sets the showLabel option to false on init" ); button.button( "option", "showLabel", true ); - equal( button.button( "option", "text" ), true, + assert.equal( button.button( "option", "text" ), true, "Setting showLabel true with option method sets text option to true" ); button.button( "option", "text", false ); - equal( button.button( "option", "showLabel" ), false, + assert.equal( button.button( "option", "showLabel" ), false, "Setting text false with option method sets showLabel option to false" ); button.button( "option", "text", true ); - equal( button.button( "option", "showLabel" ), true, + assert.equal( button.button( "option", "showLabel" ), true, "Setting text true with option method sets showLabel option to true" ); button.button( "option", "showLabel", false ); - equal( button.button( "option", "text" ), false, + assert.equal( button.button( "option", "text" ), false, "Setting showLabel false with option method sets text option to false" ); button.button( "destroy" ); button.button( { text: true, icon: "ui-icon-gear" } ); - equal( button.button( "option", "showLabel" ), true, + assert.equal( button.button( "option", "showLabel" ), true, "Setting the text option to true sets the showLabel option to true on init" ); button.button( "destroy" ); button.button( { showLabel: true, icon: "ui-icon-gear" } ); - equal( button.button( "option", "text" ), true, + assert.equal( button.button( "option", "text" ), true, "Setting the showLabel option to true sets the text option to true on init" ); button.button( "destroy" ); button.button( { showLabel: false, icon: "ui-icon-gear" } ); - equal( button.button( "option", "text" ), false, + assert.equal( button.button( "option", "text" ), false, "Setting the showLabel option to false sets the text option to false on init" ); } ); -test( "icon / icons options properly proxied", function() { - expect( 10 ); +QUnit.test( "icon / icons options properly proxied", function( assert ) { + assert.expect( 10 ); var button = $( "#button" ); @@ -136,14 +137,14 @@ test( "icon / icons options properly proxied", function() { icon: "foo" } ); - equal( button.button( "option", "icons.primary" ), "foo", + assert.equal( button.button( "option", "icons.primary" ), "foo", "Icon option properly proxied on init" ); button.button( { icon: "bar" } ); - equal( button.button( "option", "icons.primary" ), "bar", + assert.equal( button.button( "option", "icons.primary" ), "bar", "Icon option properly proxied with option method" ); button.button( { @@ -152,9 +153,9 @@ test( "icon / icons options properly proxied", function() { } } ); - equal( button.button( "option", "icon" ), "foo", + assert.equal( button.button( "option", "icon" ), "foo", "Icons primary option properly proxied with option method" ); - equal( button.button( "option", "iconPosition" ), "beginning", + assert.equal( button.button( "option", "iconPosition" ), "beginning", "Icons primary option sets iconPosition option to beginning" ); button.button( { @@ -163,9 +164,9 @@ test( "icon / icons options properly proxied", function() { } } ); - equal( button.button( "option", "icon" ), "bar", + assert.equal( button.button( "option", "icon" ), "bar", "Icons secondary option properly proxied with option method" ); - equal( button.button( "option", "iconPosition" ), "end", + assert.equal( button.button( "option", "iconPosition" ), "end", "Icons secondary option sets iconPosition option to end" ); button.button( "destroy" ); @@ -176,9 +177,9 @@ test( "icon / icons options properly proxied", function() { } } ); - equal( button.button( "option", "icon" ), "foo", + assert.equal( button.button( "option", "icon" ), "foo", "Icons primary option properly proxied on init" ); - equal( button.button( "option", "iconPosition" ), "beginning", + assert.equal( button.button( "option", "iconPosition" ), "beginning", "Icons primary option sets iconPosition option to beginning on init" ); button.button( { @@ -187,9 +188,9 @@ test( "icon / icons options properly proxied", function() { } } ); - equal( button.button( "option", "icon" ), "bar", + assert.equal( button.button( "option", "icon" ), "bar", "Icons secondary option properly proxied on init" ); - equal( button.button( "option", "iconPosition" ), "end", + assert.equal( button.button( "option", "iconPosition" ), "end", "Icons secondary option sets iconPosition option to end on init" ); } ); diff --git a/tests/unit/button/events.js b/tests/unit/button/events.js index f780fb494..e8b5e01d6 100644 --- a/tests/unit/button/events.js +++ b/tests/unit/button/events.js @@ -1,18 +1,20 @@ define( [ + "qunit", "jquery", "ui/widgets/button" -], function( $ ) { +], function( QUnit, $ ) { -module( "Button: events" ); +QUnit.module( "Button: events" ); -asyncTest( "Anchor recieves click event when spacebar is pressed", function() { - expect( 1 ); +QUnit.test( "Anchor recieves click event when spacebar is pressed", function( assert ) { + var ready = assert.async(); + assert.expect( 1 ); var element = $( "#anchor-button" ).button(); element.on( "click", function( event ) { event.preventDefault(); - ok( true, "click occcured as a result of spacebar" ); - start(); + assert.ok( true, "click occcured as a result of spacebar" ); + ready(); } ); element.trigger( $.Event( "keyup", { keyCode: $.ui.keyCode.SPACE } ) ); diff --git a/tests/unit/button/methods.js b/tests/unit/button/methods.js index 09a91bbc0..823acee34 100644 --- a/tests/unit/button/methods.js +++ b/tests/unit/button/methods.js @@ -1,32 +1,33 @@ define( [ + "qunit", "jquery", "ui/widgets/button" -], function( $ ) { +], function( QUnit, $ ) { -module( "Button: methods" ); +QUnit.module( "Button: methods" ); -test( "destroy", function( assert ) { - expect( 1 ); +QUnit.test( "destroy", function( assert ) { + assert.expect( 1 ); assert.domEqual( "#button", function() { $( "#button" ).button().button( "destroy" ); } ); } ); -test( "refresh: Ensure disabled state is preserved correctly.", function() { - expect( 3 ); +QUnit.test( "refresh: Ensure disabled state is preserved correctly.", function( assert ) { + assert.expect( 3 ); var element = $( "
" ); element.button( { disabled: true } ).button( "refresh" ); - ok( element.button( "option", "disabled" ), + assert.ok( element.button( "option", "disabled" ), "Anchor button should remain disabled after refresh" ); element = $( "" ); element.button( { disabled: true } ).button( "refresh" ); - ok( element.button( "option", "disabled" ), "" ); element.button( { disabled: true } ).prop( "disabled", false ).button( "refresh" ); - ok( !element.button( "option", "disabled" ), + assert.ok( !element.button( "option", "disabled" ), "Changing a