Merge branch 'master' into selectmenu

This commit is contained in:
Felix Nagel 2013-04-02 19:42:19 +02:00
commit 73c7342bc4
22 changed files with 328 additions and 195 deletions

View File

@ -15,7 +15,6 @@
<link rel="stylesheet" href="../demos.css">
<script>
$(function() {
$.datepicker.setDefaults( $.datepicker.regional[ "" ] );
$( "#datepicker" ).datepicker( $.datepicker.regional[ "fr" ] );
$( "#locale" ).change(function() {
$( "#datepicker" ).datepicker( "option",
@ -28,8 +27,9 @@
<p>Date: <input type="text" id="datepicker"/>&nbsp;
<select id="locale">
<option value="ar">Arabic (&#8235;(&#1604;&#1593;&#1585;&#1576;&#1610;</option>
<option value="ar">Arabic (&#8235;(&#1575;&#1604;&#1593;&#1585;&#1576;&#1610;&#1577;</option>
<option value="zh-TW">Chinese Traditional (&#32321;&#39636;&#20013;&#25991;)</option>
<option value="">English</option>
<option value="fr" selected="selected">French (Fran&ccedil;ais)</option>
<option value="he">Hebrew (&#8235;(&#1506;&#1489;&#1512;&#1497;&#1514;</option>
</select></p>

View File

@ -53,7 +53,7 @@
],
"dependencies": {},
"devDependencies": {
"grunt": "0.4.0",
"grunt": "0.4.1",
"grunt-contrib-jshint": "0.1.1",
"grunt-contrib-uglify": "0.1.1",
"grunt-contrib-concat": "0.1.3",

View File

@ -13,25 +13,25 @@
"trailing": true,
"undef": true,
"unused": true,
"predef": [
"asyncTest",
"closeEnough",
"deepEqual",
"domEqual",
"equal",
"expect",
"Globalize",
"module",
"notEqual",
"notDeepEqual",
"notStrictEqual",
"ok",
"QUnit",
"start",
"strictEqual",
"stop",
"test",
"TestHelpers",
"JSHINT"
]
"globals": {
"asyncTest": false,
"closeEnough": false,
"deepEqual": false,
"domEqual": false,
"equal": false,
"expect": false,
"Globalize": false,
"module": false,
"notEqual": false,
"notDeepEqual": false,
"notStrictEqual": false,
"ok": false,
"QUnit": true,
"start": false,
"strictEqual": false,
"stop": false,
"test": false,
"TestHelpers": true,
"JSHINT": false
}
}

View File

@ -35,7 +35,7 @@ test( "enable/disable", function() {
});
test( "refresh", function() {
expect( 17 );
expect( 19 );
var element = $( "#navigation" )
.parent()
.height( 300 )
@ -109,6 +109,15 @@ test( "refresh", function() {
element.find( "div.foo" ).eq( 0 ).remove();
element.accordion( "refresh" );
state( element, 1 );
// collapse all panels
element.accordion( "option", {
collapsible: true,
active: false
});
state( element, 0 );
element.accordion( "refresh" );
state( element, 0 );
});
test( "widget", function() {

View File

@ -188,4 +188,14 @@ test( "ARIA", function() {
"Live region for multiple values" );
});
test( ".replaceWith() (#9172)", function() {
expect( 1 );
var element = $( "#autocomplete" ).autocomplete(),
replacement = "<div>test</div>",
parent = element.parent();
element.replaceWith( replacement );
equal( parent.html().toLowerCase(), replacement );
});
}( jQuery ) );

View File

@ -15,7 +15,7 @@ test("destroy", function() {
test( "refresh: Ensure disabled state is preserved correctly.", function() {
expect( 8 );
var element = $( "<a href='#'></a>" );
element.button({ disabled: true }).button( "refresh" );
ok( element.button( "option", "disabled" ), "Anchor button should remain disabled after refresh" ); //See #8237

View File

@ -4,18 +4,7 @@
(function( $ ) {
var relativeElement, absoluteElement;
module( "draggable: core", {
setup: function() {
relativeElement = $("<div style='width: 200px; height: 100px;'>Relative</div>").appendTo("#qunit-fixture");
absoluteElement = $("<div style='background: green; width: 200px; height: 100px; position: absolute; top: 10px; left: 10px;'><span>Absolute</span></div>").appendTo("#qunit-fixture");
},
teardown: function() {
relativeElement.remove();
absoluteElement.remove();
}
});
module( "draggable: core" );
test( "element types", function() {
var typeNames = (
@ -55,18 +44,18 @@ test( "element types", function() {
test( "No options, relative", function() {
expect( 1 );
TestHelpers.draggable.shouldMove( relativeElement.draggable() );
TestHelpers.draggable.shouldMove( $( "#draggable1" ).draggable() );
});
test( "No options, absolute", function() {
expect( 1 );
TestHelpers.draggable.shouldMove( absoluteElement.draggable() );
TestHelpers.draggable.shouldMove( $( "#draggable2" ).draggable() );
});
test( "resizable handle with complex markup (#8756 / #8757)", function() {
expect( 2 );
relativeElement
$( "#draggable1" )
.append(
$("<div>")
.addClass("ui-resizable-handle ui-resizable-w")
@ -74,7 +63,7 @@ test( "resizable handle with complex markup (#8756 / #8757)", function() {
);
var handle = $(".ui-resizable-w div"),
target = relativeElement.draggable().resizable({ handles: "all" });
target = $( "#draggable1" ).draggable().resizable({ handles: "all" });
// todo: fix resizable so it doesn't require a mouseover
handle.simulate("mouseover").simulate( "drag", { dx: -50 } );
@ -85,4 +74,24 @@ test( "resizable handle with complex markup (#8756 / #8757)", function() {
equal( target.width(), 200, "compare width" );
});
test( "#8269: Removing draggable element on drop", function() {
expect( 1 );
var element = $( "#draggable1" ).wrap( "<div id='wrapper' />" ).draggable(),
dropOffset = $( "#droppable" ).offset();
$( "#droppable" ).droppable({
drop: function() {
$( "#wrapper" ).remove();
ok( true, "element removed from DOM on drop" );
}
});
element.simulate( "drag", {
handle: "corner",
x: dropOffset.left,
y: dropOffset.top
});
});
})( jQuery );

View File

@ -378,7 +378,7 @@ test( "containment, account for border", function() {
});
test( "containment, default, switching after initialization", function() {
expect( 2 );
expect( 3 );
var element = $( "#draggable1" ).draggable({ containment: false });
@ -393,9 +393,8 @@ test( "containment, default, switching after initialization", function() {
TestHelpers.draggable.testDrag( element, element, -100, -100, 0, 0 );
// TODO: Switching back to false does not update to false
// element.draggable( "option", "containment", false );
// TestHelpers.draggable.testDrag( element, element, -100, -100, -100, -100 );
element.draggable( "option", "containment", false );
TestHelpers.draggable.testDrag( element, element, -100, -100, -100, -100 );
});
test( "{ cursor: 'auto' }, default", function() {
@ -1057,11 +1056,11 @@ test( "scope", function() {
$( "#droppable" ).droppable({ scope: "tasks" });
TestHelpers.draggable.testDrag( element, element, 100, 100, 0, 0, "revert: valid reverts when dropped on a droppable" );
TestHelpers.draggable.testDrag( element, element, 100, 100, 0, 0, "revert: valid reverts when dropped on a droppable in scope" );
$( "#droppable" ).droppable( "destroy" ).droppable({ scope: "nottasks" });
TestHelpers.draggable.testDrag( element, element, 100, 100, 100, 100, "revert: valid reverts when dropped on a droppable" );
TestHelpers.draggable.testDrag( element, element, 100, 100, 100, 100, "revert: valid reverts when dropped on a droppable out of scope" );
});
test( "scroll, scrollSensitivity, and scrollSpeed", function() {
@ -1113,7 +1112,8 @@ test( "#6817: auto scroll goes double distance when dragging", function() {
scroll: true,
stop: function( e, ui ) {
equal( ui.offset.top, newY, "offset of item matches pointer position after scroll" );
equal( ui.offset.top - offsetBefore.top, distance, "offset of item only moves expected distance after scroll" );
// TODO: fix IE8 testswarm IFRAME positioning bug so closeEnough can be turned back to equal
closeEnough( ui.offset.top - offsetBefore.top, distance, 1, "offset of item only moves expected distance after scroll" );
}
}),
scrollSensitivity = element.draggable( "option", "scrollSensitivity" ),
@ -1138,7 +1138,7 @@ test( "#6817: auto scroll goes double distance when dragging", function() {
});
test( "snap, snapMode, and snapTolerance", function() {
expect( 9 );
expect( 10 );
var newX, newY,
snapTolerance = 15,
@ -1164,7 +1164,9 @@ test( "snap, snapMode, and snapTolerance", function() {
moves: 1
});
deepEqual( element.offset(), { top: newY, left: newX }, "doesn't snap outside the snapTolerance" );
// TODO: fix IE8 testswarm IFRAME positioning bug so closeEnough can be turned back to equal
closeEnough( element.offset().left, newX, 1, "doesn't snap outside the snapTolerance" );
closeEnough( element.offset().top, newY, 1, "doesn't snap outside the snapTolerance" );
newX += 3;
@ -1258,7 +1260,7 @@ test( "snap, snapMode, and snapTolerance", function() {
});
test( "#8459: element can snap to an element that was removed during drag", function() {
expect( 1 );
expect( 2 );
var newX, newY,
snapTolerance = 15,
@ -1287,7 +1289,9 @@ test( "#8459: element can snap to an element that was removed during drag", func
moves: 1
});
deepEqual( element.offset(), { top: newY, left: newX }, "doesn't snap to a removed element" );
// TODO: fix IE8 testswarm IFRAME positioning bug so closeEnough can be turned back to equal
closeEnough( element.offset().left, newX, 1, "doesn't snap to a removed element" );
closeEnough( element.offset().top, newY, 1, "doesn't snap to a removed element" );
});
test( "#8165: Snapping large rectangles to small rectangles doesn't snap properly", function() {

View File

@ -221,7 +221,9 @@ test( "of", function() {
});
test( "offsets", function() {
expect( 7 );
expect( 9 );
var offset;
$( "#elx" ).position({
my: "left top",
@ -261,7 +263,9 @@ test( "offsets", function() {
of: "#parentx",
collision: "none"
});
deepEqual( $( "#elx" ).offset(), { top: 65, left: 37 }, "decimal percentage offsets in my" );
offset = $( "#elx" ).offset();
equal( Math.round( offset.top ), 65, "decimal percentage offsets in my" );
equal( Math.round( offset.left ), 37, "decimal percentage offsets in my" );
$( "#elx" ).position({
my: "left+10.4 top-10.6",
@ -269,7 +273,9 @@ test( "offsets", function() {
of: "#parentx",
collision: "none"
});
deepEqual( $( "#elx" ).offset(), { top: 49, left: 50 }, "decimal offsets in my" );
offset = $( "#elx" ).offset();
equal( Math.round( offset.top ), 49, "decimal offsets in my" );
equal( Math.round( offset.left ), 50, "decimal offsets in my" );
$( "#elx" ).position({
my: "left+right top-left",

View File

@ -38,27 +38,30 @@ test( "stop", function() {
test( "mousedown: initial position of helper", function() {
expect( 2 );
var contentToForceScroll, helper,
element = $("#selectable1").selectable();
var helperOffset,
element = $( "#selectable1" ).selectable(),
contentToForceScroll = $( "<div>" ).css({
height: "10000px",
width: "10000px"
});
contentToForceScroll = $("<div>").css({
height: "10000px",
width: "10000px"
});
contentToForceScroll.appendTo( "body" );
$( window ).scrollTop( 100 ).scrollLeft( 100 );
contentToForceScroll.appendTo("body");
$( window ).scrollTop( 1 ).scrollLeft( 1 );
element.simulate( "mousedown", {
clientX: 10,
clientY: 10
});
helper = $(".ui-selectable-helper");
equal( helper.css("top"), "11px", "Scroll top should be accounted for." );
equal( helper.css("left"), "11px", "Scroll left should be accounted for." );
// we do a GTE comparison here because IE7 erroneously subtracts
// 2 pixels from a simulated mousedown for clientX/Y
// Support: IE7
helperOffset = $( ".ui-selectable-helper" ).offset();
ok( helperOffset.top >= 99, "Scroll top should be accounted for." );
ok( helperOffset.left >= 99, "Scroll left should be accounted for." );
// Cleanup
element.simulate("mouseup");
element.simulate( "mouseup" );
contentToForceScroll.remove();
$( window ).scrollTop( 0 ).scrollLeft( 0 );
});

View File

@ -44,6 +44,9 @@
border-width: 0;
height:19px;
}
#sortable-table {
width: 100%;
}
</style>
</head>
<body>

View File

@ -136,21 +136,51 @@ test( "#8792: issues with floated items in connected lists", function() {
element = $( "#qunit-fixture li:eq(0)" );
// move the first li to the right of the second li in the first ul
element.simulate( "drag", {
dx: 51,
dx: 55,
moves: 15
});
equal( changeCount, 1, "change fired only once (no jitters) when dragging a floated sortable in it's own container" );
// move the first li ( which is now in the second spot )
// through the first spot in the second ul to the second spot in the second ul
element.simulate( "drag", {
dx: 50,
dx: 100,
moves: 15
});
equal( changeCount, 3, "change fired once for each expected change when dragging a floated sortable to a connected container" );
});
test( "#8301: single axis with connected list", function() {
expect( 1 );
var element = $( "#sortable" ).sortable({
axis: "y",
tolerance: "pointer",
connectWith: ".connected"
});
$( "<ul class='connected'><li>Item 7</li><li>Item 8</li></ul>" )
.sortable({
axis: "y",
tolerance: "pointer",
connectWith: "#sortable",
receive: function() {
ok( true, "connected list received item" );
}
})
.insertAfter( element );
element.find( "li" ).eq( 0 ).simulate( "drag", {
handle: "corner",
dy: 120,
moves: 1
});
});
/*
test("{ connectWith: false }, default", function() {
ok(false, "missing test - untested code is broken code.");
@ -302,7 +332,7 @@ test( "{ placeholder: false } img", function() {
var element = $( "#sortable-images" ).sortable({
start: function( event, ui ) {
equal( ui.placeholder.attr( "src" ), "../images/jqueryui_32x32.png", "placeholder img has correct src" );
ok( ui.placeholder.attr( "src" ).indexOf( "images/jqueryui_32x32.png" ) > 0, "placeholder img has correct src" );
equal( ui.placeholder.height(), 32, "placeholder has correct height" );
equal( ui.placeholder.width(), 32, "placeholder has correct width" );
}
@ -329,19 +359,31 @@ test( "{ placeholder: String }", function() {
});
test( "{ placholder: String } tr", function() {
expect( 3 );
expect( 4 );
var element = $( "#sortable-table tbody" ).sortable({
placeholder: "test",
start: function( event, ui ) {
ok( ui.placeholder.hasClass( "test" ), "placeholder has class" );
equal( ui.placeholder.children().length, 1, "placeholder tr contains a td" );
equal( ui.placeholder.children().html(), $( "<span>&#160;</span>" ).html(),
"placeholder td has content for forced dimensions" );
}
});
var originalWidths,
element = $( "#sortable-table tbody" ).sortable({
placeholder: "test",
start: function( event, ui ) {
var currentWidths = otherRow.children().map(function() {
return $( this ).width();
}).get();
ok( ui.placeholder.hasClass( "test" ), "placeholder has class" );
deepEqual( currentWidths, originalWidths, "table cells maintian size" );
equal( ui.placeholder.children().length, dragRow.children().length,
"placeholder has correct number of cells" );
equal( ui.placeholder.children().html(), $( "<span>&#160;</span>" ).html(),
"placeholder td has content for forced dimensions" );
}
}),
rows = element.children( "tr" ),
dragRow = rows.eq( 0 ),
otherRow = rows.eq( 1 );
element.find( "tr" ).eq( 0 ).simulate( "drag", {
originalWidths = otherRow.children().map(function() {
return $( this ).width();
}).get();
dragRow.simulate( "drag", {
dy: 1
});
});

View File

@ -94,8 +94,11 @@ asyncTest( "blur input while spinning with UP", function() {
function step2() {
value = element.val();
ok( value > 11, "repeating while key is down" );
element[0].blur();
setTimeout( step3, 250 );
element.bind( "blur", function() {
value = element.val();
setTimeout( step3, 750 );
})[ 0 ].blur();
}
function step3() {

View File

@ -77,16 +77,22 @@ TestHelpers.testJshint = function( module ) {
dataType: "text"
})
).done(function( hintArgs, srcArgs ) {
var passed = JSHINT( srcArgs[ 0 ], hintArgs[ 0 ] ),
errors = $.map( JSHINT.errors, function( error ) {
// JSHINT may report null if there are too many errors
if ( !error ) {
return;
}
var globals, passed, errors,
jshintrc = hintArgs[ 0 ],
source = srcArgs[ 0 ];
return "[L" + error.line + ":C" + error.character + "] " +
error.reason + "\n" + error.evidence + "\n";
}).join( "\n" );
globals = jshintrc.globals || {};
delete jshintrc.globals;
passed = JSHINT( source, jshintrc, globals ),
errors = $.map( JSHINT.errors, function( error ) {
// JSHINT may report null if there are too many errors
if ( !error ) {
return;
}
return "[L" + error.line + ":C" + error.character + "] " +
error.reason + "\n" + error.evidence + "\n";
}).join( "\n" );
ok( passed, errors );
start();
})

View File

@ -12,7 +12,7 @@
"trailing": true,
"undef": true,
"unused": true,
"predef": [
"Globalize"
]
"globals": {
"Globalize": false
}
}

23
ui/i18n/jquery.ui.datepicker-it-CH.js vendored Normal file
View File

@ -0,0 +1,23 @@
/* Italian initialisation for the jQuery UI date picker plugin. */
/* Written by Antonello Pasella (antonello.pasella@gmail.com). */
jQuery(function($){
$.datepicker.regional['it-CH'] = {
closeText: 'Chiudi',
prevText: '&#x3C;Prec',
nextText: 'Succ&#x3E;',
currentText: 'Oggi',
monthNames: ['Gennaio','Febbraio','Marzo','Aprile','Maggio','Giugno',
'Luglio','Agosto','Settembre','Ottobre','Novembre','Dicembre'],
monthNamesShort: ['Gen','Feb','Mar','Apr','Mag','Giu',
'Lug','Ago','Set','Ott','Nov','Dic'],
dayNames: ['Domenica','Lunedì','Martedì','Mercoledì','Giovedì','Venerdì','Sabato'],
dayNamesShort: ['Dom','Lun','Mar','Mer','Gio','Ven','Sab'],
dayNamesMin: ['Do','Lu','Ma','Me','Gi','Ve','Sa'],
weekHeader: 'Sm',
dateFormat: 'dd.mm.yy',
firstDay: 1,
isRTL: false,
showMonthAfterYear: false,
yearSuffix: ''};
$.datepicker.setDefaults($.datepicker.regional['it-CH']);
});

View File

@ -223,7 +223,7 @@ $.widget( "ui.accordion", {
options.active = false;
this.active = $();
// active false only when collapsible is true
} if ( options.active === false ) {
} else if ( options.active === false ) {
this._activate( 0 );
// was active, but active panel is gone
} else if ( this.active.length && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {

View File

@ -195,8 +195,6 @@ $.widget( "ui.autocomplete", {
.addClass( "ui-autocomplete ui-front" )
.appendTo( this._appendTo() )
.menu({
// custom key handling for now
input: $(),
// disable ARIA support, the live region takes care of that
role: null
})
@ -298,7 +296,7 @@ $.widget( "ui.autocomplete", {
"aria-live": "polite"
})
.addClass( "ui-helper-hidden-accessible" )
.insertAfter( this.element );
.insertBefore( this.element );
// turning off autocomplete prevents the browser from remembering the
// value when navigating through history, so we re-enable autocomplete

62
ui/jquery.ui.core.js vendored
View File

@ -266,55 +266,29 @@ $.fn.extend({
}
});
$.extend( $.ui, {
// $.ui.plugin is deprecated. Use the proxy pattern instead.
plugin: {
add: function( module, option, set ) {
var i,
proto = $.ui[ module ].prototype;
for ( i in set ) {
proto.plugins[ i ] = proto.plugins[ i ] || [];
proto.plugins[ i ].push( [ option, set[ i ] ] );
}
},
call: function( instance, name, args ) {
var i,
set = instance.plugins[ name ];
if ( !set || !instance.element[ 0 ].parentNode || instance.element[ 0 ].parentNode.nodeType === 11 ) {
return;
}
for ( i = 0; i < set.length; i++ ) {
if ( instance.options[ set[ i ][ 0 ] ] ) {
set[ i ][ 1 ].apply( instance.element, args );
}
}
// $.ui.plugin is deprecated. Use $.widget() extensions instead.
$.ui.plugin = {
add: function( module, option, set ) {
var i,
proto = $.ui[ module ].prototype;
for ( i in set ) {
proto.plugins[ i ] = proto.plugins[ i ] || [];
proto.plugins[ i ].push( [ option, set[ i ] ] );
}
},
// only used by resizable
hasScroll: function( el, a ) {
//If overflow is hidden, the element might have extra content, but the user wants to hide it
if ( $( el ).css( "overflow" ) === "hidden") {
return false;
call: function( instance, name, args ) {
var i,
set = instance.plugins[ name ];
if ( !set || !instance.element[ 0 ].parentNode || instance.element[ 0 ].parentNode.nodeType === 11 ) {
return;
}
var scroll = ( a && a === "left" ) ? "scrollLeft" : "scrollTop",
has = false;
if ( el[ scroll ] > 0 ) {
return true;
for ( i = 0; i < set.length; i++ ) {
if ( instance.options[ set[ i ][ 0 ] ] ) {
set[ i ][ 1 ].apply( instance.element, args );
}
}
// TODO: determine which cases actually cause this to happen
// if the element doesn't have the scroll set, see if it's possible to
// set the scroll
el[ scroll ] = 1;
has = ( el[ scroll ] > 0 );
el[ scroll ] = 0;
return has;
}
});
};
})( jQuery );

View File

@ -156,9 +156,7 @@ $.widget("ui.draggable", $.ui.mouse, {
(o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
//Set a containment if given in the options
if(o.containment) {
this._setContainment();
}
this._setContainment();
//Trigger event + callbacks
if(this._trigger("start", event) === false) {
@ -383,40 +381,56 @@ $.widget("ui.draggable", $.ui.mouse, {
var over, c, ce,
o = this.options;
if(o.containment === "parent") {
o.containment = this.helper[0].parentNode;
}
if(o.containment === "document" || o.containment === "window") {
this.containment = [
o.containment === "document" ? 0 : $(window).scrollLeft() - this.offset.relative.left - this.offset.parent.left,
o.containment === "document" ? 0 : $(window).scrollTop() - this.offset.relative.top - this.offset.parent.top,
(o.containment === "document" ? 0 : $(window).scrollLeft()) + $(o.containment === "document" ? document : window).width() - this.helperProportions.width - this.margins.left,
(o.containment === "document" ? 0 : $(window).scrollTop()) + ($(o.containment === "document" ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
];
if ( !o.containment ) {
this.containment = null;
return;
}
if(!(/^(document|window|parent)$/).test(o.containment) && o.containment.constructor !== Array) {
c = $(o.containment);
ce = c[0];
if(!ce) {
return;
}
over = ($(ce).css("overflow") !== "hidden");
if ( o.containment === "window" ) {
this.containment = [
(parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0),
(parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0),
(over ? Math.max(ce.scrollWidth,ce.offsetWidth) : ce.offsetWidth) - (parseInt($(ce).css("borderRightWidth"),10) || 0) - (parseInt($(ce).css("paddingRight"),10) || 0) - this.helperProportions.width - this.margins.left - this.margins.right,
(over ? Math.max(ce.scrollHeight,ce.offsetHeight) : ce.offsetHeight) - (parseInt($(ce).css("borderBottomWidth"),10) || 0) - (parseInt($(ce).css("paddingBottom"),10) || 0) - this.helperProportions.height - this.margins.top - this.margins.bottom
$( 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
];
this.relative_container = c;
return;
}
} else if(o.containment.constructor === Array) {
if ( o.containment === "document") {
this.containment = [
0,
0,
$( document ).width() - this.helperProportions.width - this.margins.left,
( $( document ).height() || document.body.parentNode.scrollHeight ) - this.helperProportions.height - this.margins.top
];
return;
}
if ( o.containment.constructor === Array ) {
this.containment = o.containment;
return;
}
if ( o.containment === "parent" ) {
o.containment = this.helper[ 0 ].parentNode;
}
c = $( o.containment );
ce = c[ 0 ];
if( !ce ) {
return;
}
over = c.css( "overflow" ) !== "hidden";
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 ) ,
( over ? Math.max( ce.scrollWidth, ce.offsetWidth ) : ce.offsetWidth ) - ( parseInt( c.css( "borderRightWidth" ), 10 ) || 0 ) - ( parseInt( c.css( "paddingRight" ), 10 ) || 0 ) - this.helperProportions.width - this.margins.left - this.margins.right,
( over ? Math.max( ce.scrollHeight, ce.offsetHeight ) : ce.offsetHeight ) - ( parseInt( c.css( "borderBottomWidth" ), 10 ) || 0 ) - ( parseInt( c.css( "paddingBottom" ), 10 ) || 0 ) - this.helperProportions.height - this.margins.top - this.margins.bottom
];
this.relative_container = c;
},
_convertPositionTo: function(d, pos) {
@ -469,18 +483,21 @@ $.widget("ui.draggable", $.ui.mouse, {
* Constrain the position to a mix of grid, containment.
*/
if(this.originalPosition) { //If we are not dragging yet, we won't check for options
if(this.containment) {
if (this.relative_container){
co = this.relative_container.offset();
containment = [ this.containment[0] + co.left,
this.containment[1] + co.top,
this.containment[2] + co.left,
this.containment[3] + co.top ];
}
else {
containment = this.containment;
}
// If we are not dragging yet, we won't check for options
if ( this.originalPosition ) {
if ( this.containment ) {
if ( this.relative_container ){
co = this.relative_container.offset();
containment = [
this.containment[ 0 ] + co.left,
this.containment[ 1 ] + co.top,
this.containment[ 2 ] + co.left,
this.containment[ 3 ] + co.top
];
}
else {
containment = this.containment;
}
if(event.pageX - this.offset.click.left < containment[0]) {
pageX = containment[0] + this.offset.click.left;

View File

@ -23,6 +23,29 @@ function isNumber(value) {
return !isNaN(parseInt(value, 10));
}
function hasScroll( el, a ) {
//If overflow is hidden, the element might have extra content, but the user wants to hide it
if ( $( el ).css( "overflow" ) === "hidden") {
return false;
}
var scroll = ( a && a === "left" ) ? "scrollLeft" : "scrollTop",
has = false;
if ( el[ scroll ] > 0 ) {
return true;
}
// TODO: determine which cases actually cause this to happen
// if the element doesn't have the scroll set, see if it's possible to
// set the scroll
el[ scroll ] = 1;
has = ( el[ scroll ] > 0 );
el[ scroll ] = 0;
return has;
}
$.widget("ui.resizable", $.ui.mouse, {
version: "@VERSION",
widgetEventPrefix: "resize",
@ -381,7 +404,7 @@ $.widget("ui.resizable", $.ui.mouse, {
pr = this._proportionallyResizeElements;
ista = pr.length && (/textarea/i).test(pr[0].nodeName);
soffseth = ista && $.ui.hasScroll(pr[0], "left") /* TODO - jump height */ ? 0 : that.sizeDiff.height;
soffseth = ista && hasScroll(pr[0], "left") /* TODO - jump height */ ? 0 : that.sizeDiff.height;
soffsetw = ista ? 0 : that.sizeDiff.width;
s = { width: (that.helper.width() - soffsetw), height: (that.helper.height() - soffseth) };
@ -655,7 +678,7 @@ $.ui.plugin.add("resizable", "animate", {
o = that.options,
pr = that._proportionallyResizeElements,
ista = pr.length && (/textarea/i).test(pr[0].nodeName),
soffseth = ista && $.ui.hasScroll(pr[0], "left") /* TODO - jump height */ ? 0 : that.sizeDiff.height,
soffseth = ista && hasScroll(pr[0], "left") /* TODO - jump height */ ? 0 : that.sizeDiff.height,
soffsetw = ista ? 0 : that.sizeDiff.width,
style = { width: (that.size.width - soffsetw), height: (that.size.height - soffseth) },
left = (parseInt(that.element.css("left"), 10) + (that.position.left - that.originalPosition.left)) || null,
@ -728,8 +751,8 @@ $.ui.plugin.add("resizable", "containment", {
co = that.containerOffset;
ch = that.containerSize.height;
cw = that.containerSize.width;
width = ($.ui.hasScroll(ce, "left") ? ce.scrollWidth : cw );
height = ($.ui.hasScroll(ce) ? ce.scrollHeight : ch);
width = (hasScroll(ce, "left") ? ce.scrollWidth : cw );
height = (hasScroll(ce) ? ce.scrollHeight : ch);
that.parentData = {
element: ce, left: co.left, top: co.top, width: width, height: height

View File

@ -535,7 +535,9 @@ $.widget("ui.sortable", $.ui.mouse, {
b = t + item.height,
dyClick = this.offset.click.top,
dxClick = this.offset.click.left,
isOverElement = (y1 + dyClick) > t && (y1 + dyClick) < b && (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 ||
@ -750,15 +752,16 @@ $.widget("ui.sortable", $.ui.mouse, {
element: function() {
var nodeName = that.currentItem[0].nodeName.toLowerCase(),
element = $( that.document[0].createElement( nodeName ) )
element = $( "<" + nodeName + ">", that.document[0] )
.addClass(className || that.currentItem[0].className+" ui-sortable-placeholder")
.removeClass("ui-sortable-helper");
if ( nodeName === "tr" ) {
// Use a high colspan to force the td to expand the full
// width of the table (browsers are smart enough to
// handle this properly)
element.append( "<td colspan='99'>&#160;</td>" );
that.currentItem.children().each(function() {
$( "<td>&#160;</td>", that.document[0] )
.attr( "colspan", $( this ).attr( "colspan" ) || 1 )
.appendTo( element );
});
} else if ( nodeName === "img" ) {
element.attr( "src", that.currentItem.attr( "src" ) );
}