" );
return $.contains( element[ 0 ].ownerDocument, element[ 0 ] );
})(),
+ testDragPosition: function( el, dx, dy, expectedDX, expectedDY, msg ) {
+ msg = msg ? msg + "." : "";
+
+ $( el ).one( "dragstop", function( event, ui ) {
+ var positionExpected = { left: ui.originalPosition.left + expectedDX, top: ui.originalPosition.top + expectedDY };
+ deepEqual( ui.position, positionExpected, "position dragged[" + dx + ", " + dy + "] " + msg );
+ } );
+ },
+ testDragOffset: function( el, dx, dy, expectedDX, expectedDY, msg ) {
+ msg = msg ? msg + "." : "";
+
+ var offsetBefore = el.offset(),
+ offsetExpected = { left: offsetBefore.left + expectedDX, top: offsetBefore.top + expectedDY };
+
+ $( el ).one( "dragstop", function() {
+ deepEqual( el.offset(), offsetExpected, "offset dragged[" + dx + ", " + dy + "] " + msg );
+ } );
+ },
testDrag: function( el, handle, dx, dy, expectedDX, expectedDY, msg ) {
- var offsetAfter, actual, expected,
- offsetBefore = el.offset();
+ TestHelpers.draggable.testDragPosition( el, dx, dy, expectedDX, expectedDY, msg );
+ TestHelpers.draggable.testDragOffset( el, dx, dy, expectedDX, expectedDY, msg );
$( handle ).simulate( "drag", {
dx: dx,
- dy: dy
+ dy: dy,
+ // moves is 1 here because simulate currently fire events synchronously
+ // so we can't faithfully test things that rely on a scroll event (which is async)
+ moves: 1
});
- offsetAfter = el.offset();
-
- actual = { left: offsetAfter.left, top: offsetAfter.top };
- expected = { left: offsetBefore.left + expectedDX, top: offsetBefore.top + expectedDY };
-
- msg = msg ? msg + "." : "";
- deepEqual( actual, expected, "dragged[" + dx + ", " + dy + "] " + msg );
},
- shouldMove: function( el, why ) {
- TestHelpers.draggable.testDrag( el, el, 50, 50, 50, 50, why );
+ shouldMovePositionButNotOffset: function( el, msg, handle ) {
+ handle = handle || el;
+ TestHelpers.draggable.testDragPosition( el, 100, 100, 100, 100, msg );
+ TestHelpers.draggable.testDragOffset( el, 100, 100, 0, 0, msg );
+
+ $( handle ).simulate( "drag", {
+ dx: 100,
+ dy: 100,
+ // moves is 1 here because simulate currently fire events synchronously
+ // so we can't faithfully test things that rely on a scroll event (which is async)
+ moves: 1
+ });
},
- shouldNotMove: function( el, why ) {
- TestHelpers.draggable.testDrag( el, el, 50, 50, 0, 0, why );
+ shouldMove: function( el, msg, handle ) {
+ handle = handle || el;
+ TestHelpers.draggable.testDrag( el, handle, 100, 100, 100, 100, msg );
+ },
+ shouldNotMove: function( el, msg, handle ) {
+ handle = handle || el;
+ TestHelpers.draggable.testDrag( el, handle, 100, 100, 0, 0, msg );
+ },
+ shouldNotDrag: function( el, msg, handle ) {
+ handle = handle || el;
+ $( el ).bind( "dragstop", function() {
+ ok( false, "should not drag " + msg );
+ } );
+ $( handle ).simulate( "drag", {
+ dx: 100,
+ dy: 100
+ });
+ $( el ).unbind( "dragstop" );
},
testScroll: function( el, position ) {
var oldPosition = $( "#main" ).css( "position" );
@@ -35,20 +75,10 @@ TestHelpers.draggable = {
$( "#main" ).css( "position", oldPosition );
},
restoreScroll: function( what ) {
- if( what ) {
- $( document ).scrollTop( 0 ).scrollLeft( 0 );
- } else {
- $( "#main" ).scrollTop( 0 ).scrollLeft( 0 );
- }
+ $( what ).scrollTop( 0 ).scrollLeft( 0 );
},
setScroll: function( what ) {
- if( what ) {
- // TODO: currently, the draggable interaction doesn't properly account for scrolled pages,
- // uncomment the line below to make the tests fail that should when the page is scrolled
- // $( document ).scrollTop( 100 ).scrollLeft( 100 );
- } else {
- $( "#main" ).scrollTop( 100 ).scrollLeft( 100 );
- }
+ $( what ).scrollTop( 100 ).scrollLeft( 100 );
},
border: function( el, side ) {
return parseInt( el.css( "border-" + side + "-width" ), 10 ) || 0;
diff --git a/tests/unit/menu/menu_core.js b/tests/unit/menu/menu_core.js
index 923d2961e..df039c9e4 100644
--- a/tests/unit/menu/menu_core.js
+++ b/tests/unit/menu/menu_core.js
@@ -45,4 +45,17 @@ asyncTest( "#9044: Autofocus issue with dialog opened from menu widget", functio
});
});
+asyncTest( "#9532: Need a way in Menu to keep ui-state-active class on selected item for Selectmenu", function() {
+ expect( 1 );
+ var element = $( "#menu1" ).menu(),
+ firstChild = element.children().eq( 0 );
+
+ element.menu( "focus", null, firstChild );
+ firstChild.addClass( "ui-state-active" );
+ setTimeout( function() {
+ ok( firstChild.is( ".ui-state-active" ), "ui-state-active improperly removed" );
+ start();
+ }, 500 );
+});
+
})( jQuery );
diff --git a/tests/unit/resizable/resizable_core.js b/tests/unit/resizable/resizable_core.js
index 4cffea185..b02e8b4f1 100644
--- a/tests/unit/resizable/resizable_core.js
+++ b/tests/unit/resizable/resizable_core.js
@@ -191,4 +191,19 @@ test("resizable accounts for scroll position correctly (#3815)", function() {
equal( el.css("top"), top, "css('top') stays the same when resized" );
});
+test( "resizable stores correct size when using helper and grid (#9547)", function() {
+ expect( 2 );
+
+ var handle = ".ui-resizable-se",
+ target = $( "#resizable1" ).resizable({
+ handles: "all",
+ helper: "ui-resizable-helper",
+ grid: [ 10, 10 ]
+ });
+
+ TestHelpers.resizable.drag( handle, 1, 1 );
+ equal( target.width(), 100, "compare width" );
+ equal( target.height(), 100, "compare height" );
+});
+
})(jQuery);
diff --git a/tests/unit/selectable/selectable_events.js b/tests/unit/selectable/selectable_events.js
index ae35fa3ce..2cb99f49c 100644
--- a/tests/unit/selectable/selectable_events.js
+++ b/tests/unit/selectable/selectable_events.js
@@ -40,12 +40,8 @@ test( "mousedown: initial position of helper", function() {
var helperOffset,
element = $( "#selectable1" ).selectable(),
- contentToForceScroll = $( "
" ).css({
- height: "10000px",
- width: "10000px"
- });
+ contentToForceScroll = TestHelpers.forceScrollableWindow( "body" );
- contentToForceScroll.appendTo( "body" );
$( window ).scrollTop( 100 ).scrollLeft( 100 );
element.simulate( "mousedown", {
diff --git a/tests/unit/testsuite.js b/tests/unit/testsuite.js
index 83d69d2d9..13daa7e66 100644
--- a/tests/unit/testsuite.js
+++ b/tests/unit/testsuite.js
@@ -191,6 +191,13 @@ TestHelpers.onFocus= function( element, onFocus ) {
element.bind( "focus", fn )[ 0 ].focus();
};
+TestHelpers.forceScrollableWindow = function( appendTo ) {
+ return $( "
" ).css({
+ height: "10000px",
+ width: "10000px"
+ }).appendTo( appendTo || "#qunit-fixture" );
+};
+
/*
* Taken from https://github.com/jquery/qunit/tree/master/addons/close-enough
*/
diff --git a/tests/unit/widget/widget_core.js b/tests/unit/widget/widget_core.js
index ec4c85874..3cda48df9 100644
--- a/tests/unit/widget/widget_core.js
+++ b/tests/unit/widget/widget_core.js
@@ -535,7 +535,7 @@ test( ".option() - delegate to ._setOptions()", function() {
});
test( ".option() - delegate to ._setOption()", function() {
- expect( 2 );
+ expect( 3 );
var div,
calls = [];
$.widget( "ui.testWidget", {
@@ -554,6 +554,11 @@ test( ".option() - delegate to ._setOption()", function() {
deepEqual( calls, [{ key: "foo", val: "bar" }],
"_setOption called for single option" );
+ calls = [];
+ div.testWidget( "option", "foo", undefined );
+ deepEqual( calls, [{ key: "foo", val: undefined }],
+ "_setOption called for single option where value is undefined" );
+
calls = [];
div.testWidget( "option", {
bar: "qux",
@@ -566,9 +571,9 @@ test( ".option() - delegate to ._setOption()", function() {
});
test( ".option() - deep option setter", function() {
- expect( 6 );
+ expect( 9 );
$.widget( "ui.testWidget", {} );
- var div = $( "
" ).testWidget();
+ var result, div = $( "
" ).testWidget();
function deepOption( from, to, msg ) {
div.testWidget( "instance" ).options.foo = from;
$.ui.testWidget.prototype._setOption = function( key, value ) {
@@ -580,6 +585,12 @@ test( ".option() - deep option setter", function() {
deepOption( { bar: "baz" }, { bar: "qux" }, "one deep" );
div.testWidget( "option", "foo.bar", "qux" );
+ deepOption( { bar: "baz" }, { bar: undefined }, "one deep - value = undefined" );
+
+ result = div.testWidget( "option", "foo.bar", undefined );
+
+ deepEqual ( result, div, "option should return widget on successful set operation" );
+
deepOption( null, { bar: "baz" }, "null" );
div.testWidget( "option", "foo.bar", "baz" );
diff --git a/ui/i18n/jquery.ui.datepicker-fi.js b/ui/i18n/jquery.ui.datepicker-fi.js
index bd6d99498..e5c554aba 100644
--- a/ui/i18n/jquery.ui.datepicker-fi.js
+++ b/ui/i18n/jquery.ui.datepicker-fi.js
@@ -14,7 +14,7 @@ jQuery(function($){
dayNames: ['Sunnuntai','Maanantai','Tiistai','Keskiviikko','Torstai','Perjantai','Lauantai'],
dayNamesMin: ['Su','Ma','Ti','Ke','To','Pe','La'],
weekHeader: 'Vk',
- dateFormat: 'dd.mm.yy',
+ dateFormat: 'd.m.yy',
firstDay: 1,
isRTL: false,
showMonthAfterYear: false,
diff --git a/ui/jquery.ui.autocomplete.js b/ui/jquery.ui.autocomplete.js
index d1a3c252d..2b803b62f 100644
--- a/ui/jquery.ui.autocomplete.js
+++ b/ui/jquery.ui.autocomplete.js
@@ -294,7 +294,7 @@ $.widget( "ui.autocomplete", {
"aria-live": "polite"
})
.addClass( "ui-helper-hidden-accessible" )
- .insertBefore( this.element );
+ .appendTo( this.document[ 0 ].body );
// turning off autocomplete prevents the browser from remembering the
// value when navigating through history, so we re-enable autocomplete
diff --git a/ui/jquery.ui.draggable.js b/ui/jquery.ui.draggable.js
index 3b18f28f0..e528d194e 100644
--- a/ui/jquery.ui.draggable.js
+++ b/ui/jquery.ui.draggable.js
@@ -166,7 +166,7 @@ $.widget("ui.draggable", $.ui.mouse, {
});
//Generate the original position
- this.originalPosition = this.position = this._generatePosition(event);
+ this.originalPosition = this.position = this._generatePosition( event, false );
this.originalPageX = event.pageX;
this.originalPageY = event.pageY;
@@ -208,7 +208,7 @@ $.widget("ui.draggable", $.ui.mouse, {
}
//Compute the helpers position
- this.position = this._generatePosition(event);
+ this.position = this._generatePosition( event, true );
this.positionAbs = this._convertPositionTo("absolute");
//Call plugins and callbacks and use the resulting position if something is returned
@@ -221,12 +221,9 @@ $.widget("ui.draggable", $.ui.mouse, {
this.position = ui.position;
}
- if(!this.options.axis || this.options.axis !== "y") {
- this.helper[0].style.left = this.position.left+"px";
- }
- if(!this.options.axis || this.options.axis !== "x") {
- this.helper[0].style.top = this.position.top+"px";
- }
+ this.helper[ 0 ].style.left = this.position.left + "px";
+ this.helper[ 0 ].style.top = this.position.top + "px";
+
if($.ui.ddmanager) {
$.ui.ddmanager.drag(this, event);
}
@@ -491,7 +488,7 @@ $.widget("ui.draggable", $.ui.mouse, {
},
- _generatePosition: function(event) {
+ _generatePosition: function( event, constrainPosition ) {
var containment, co, top, left,
o = this.options,
@@ -516,7 +513,7 @@ $.widget("ui.draggable", $.ui.mouse, {
*/
// If we are not dragging yet, we won't check for options
- if ( this.originalPosition ) {
+ if ( constrainPosition ) {
if ( this.containment ) {
if ( this.relative_container ){
co = this.relative_container.offset();
@@ -554,6 +551,13 @@ $.widget("ui.draggable", $.ui.mouse, {
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" ) {
+ pageX = this.originalPageX;
+ }
+
+ if ( o.axis === "x" ) {
+ pageY = this.originalPageY;
+ }
}
return {
diff --git a/ui/jquery.ui.menu.js b/ui/jquery.ui.menu.js
index 059f80b30..b0ff38894 100644
--- a/ui/jquery.ui.menu.js
+++ b/ui/jquery.ui.menu.js
@@ -371,7 +371,7 @@ $.widget( "ui.menu", {
this._scrollIntoView( item );
this.active = item.first();
- focused = this.active.addClass( "ui-state-focus" );
+ focused = this.active.addClass( "ui-state-focus" ).removeClass( "ui-state-active" );
// Only update aria-activedescendant if there's a role
// otherwise we assume focus is managed elsewhere
if ( this.options.role ) {
@@ -498,7 +498,7 @@ $.widget( "ui.menu", {
.attr( "aria-hidden", "true" )
.attr( "aria-expanded", "false" )
.end()
- .find( ".ui-state-active" )
+ .find( ".ui-state-active" ).not( ".ui-state-focus" )
.removeClass( "ui-state-active" );
},
diff --git a/ui/jquery.ui.resizable.js b/ui/jquery.ui.resizable.js
index aab93b57f..f683e6b65 100644
--- a/ui/jquery.ui.resizable.js
+++ b/ui/jquery.ui.resizable.js
@@ -316,7 +316,7 @@ $.widget("ui.resizable", $.ui.mouse, {
//Store needed variables
this.offset = this.helper.offset();
this.position = { left: curleft, top: curtop };
- this.size = this._helper ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() };
+ this.size = this._helper ? { width: this.helper.width(), height: this.helper.height() } : { width: el.width(), height: el.height() };
this.originalSize = this._helper ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() };
this.originalPosition = { left: curleft, top: curtop };
this.sizeDiff = { width: el.outerWidth() - el.width(), height: el.outerHeight() - el.height() };
diff --git a/ui/jquery.ui.slider.js b/ui/jquery.ui.slider.js
index e4f1cf7c9..df71f363f 100644
--- a/ui/jquery.ui.slider.js
+++ b/ui/jquery.ui.slider.js
@@ -322,7 +322,7 @@ $.widget( "ui.slider", $.ui.mouse, {
} );
otherVal = this.values( index ? 0 : 1 );
if ( allowed !== false ) {
- this.values( index, newVal, true );
+ this.values( index, newVal );
}
}
} else {
diff --git a/ui/jquery.ui.sortable.js b/ui/jquery.ui.sortable.js
index 9c7bf446c..c76a02397 100644
--- a/ui/jquery.ui.sortable.js
+++ b/ui/jquery.ui.sortable.js
@@ -354,12 +354,12 @@ $.widget("ui.sortable", $.ui.mouse, {
}
// Only put the placeholder inside the current Container, skip all
- // items form other containers. This works because when moving
+ // items from other containers. This works because when moving
// an item from one container to another the
// currentContainer is switched before the placeholder is moved.
//
- // Without this moving items in "sub-sortables" can cause the placeholder to jitter
- // beetween the outer and inner container.
+ // Without this, moving items in "sub-sortables" can cause
+ // the placeholder to jitter beetween the outer and inner container.
if (item.instance !== this.currentContainer) {
continue;
}
diff --git a/ui/jquery.ui.widget.js b/ui/jquery.ui.widget.js
index a46dcaf99..cc01f784f 100644
--- a/ui/jquery.ui.widget.js
+++ b/ui/jquery.ui.widget.js
@@ -321,12 +321,12 @@ $.Widget.prototype = {
curOption = curOption[ parts[ i ] ];
}
key = parts.pop();
- if ( value === undefined ) {
+ if ( arguments.length === 1 ) {
return curOption[ key ] === undefined ? null : curOption[ key ];
}
curOption[ key ] = value;
} else {
- if ( value === undefined ) {
+ if ( arguments.length === 1 ) {
return this.options[ key ] === undefined ? null : this.options[ key ];
}
options[ key ] = value;