Merge branch 'master' into selectmenu

This commit is contained in:
Felix Nagel 2013-11-13 19:45:56 +01:00
commit ab2219b6ac
34 changed files with 548 additions and 754 deletions

View File

@ -173,34 +173,19 @@ grunt.initConfig({
files: expandFiles( "tests/unit/**/*.html" ).filter(function( file ) { files: expandFiles( "tests/unit/**/*.html" ).filter(function( file ) {
// disabling everything that doesn't (quite) work with PhantomJS for now // disabling everything that doesn't (quite) work with PhantomJS for now
// TODO except for all|index|test, try to include more as we go // TODO except for all|index|test, try to include more as we go
return !( /(all|index|test|dialog|tooltip)\.html$/ ).test( file ); return !( /(all|index|test|dialog|tooltip|draggable)\.html$/ ).test( file );
}) })
}, },
jshint: { jshint: {
ui: {
options: { options: {
jshintrc: "ui/.jshintrc" jshintrc: true
}, },
files: { all: [
src: "ui/*.js" "ui/*.js",
} "Gruntfile.js",
}, "build/**/*.js",
grunt: { "tests/unit/**/*.js"
options: { ]
jshintrc: ".jshintrc"
},
files: {
src: [ "Gruntfile.js", "build/**/*.js" ]
}
},
tests: {
options: {
jshintrc: "tests/.jshintrc"
},
files: {
src: "tests/unit/**/*.js"
}
}
}, },
csslint: { csslint: {
base_theme: { base_theme: {

View File

@ -1,16 +1,16 @@
[jQuery UI](http://jqueryui.com/) - Interactions and Widgets for the web # [jQuery UI](http://jqueryui.com/) - Interactions and Widgets for the web
================================
jQuery UI is a curated set of user interface interactions, effects, widgets, and themes built on top of jQuery. Whether you're building highly interactive web applications, or you just need to add a date picker to a form control, jQuery UI is the perfect choice. jQuery UI is a curated set of user interface interactions, effects, widgets, and themes built on top of jQuery. Whether you're building highly interactive web applications, or you just need to add a date picker to a form control, jQuery UI is the perfect choice.
If you want to use jQuery UI, go to [jqueryui.com](http://jqueryui.com) to get started, [jqueryui.com/demos/](http://jqueryui.com/demos/) for demos, [api.jqueryui.com](http://api.jqueryui.com/) for API documentation, or the [Using jQuery UI Forum](http://forum.jquery.com/using-jquery-ui) for discussions and questions. If you want to use jQuery UI, go to [jqueryui.com](http://jqueryui.com) to get started, [jqueryui.com/demos/](http://jqueryui.com/demos/) for demos, [api.jqueryui.com](http://api.jqueryui.com/) for API documentation, or the [Using jQuery UI Forum](http://forum.jquery.com/using-jquery-ui) for discussions and questions.
If you want to report a bug/issue, please visit [bugs.jqueryui.com](http://bugs.jqueryui.com).
If you are interested in helping develop jQuery UI, you are in the right place. If you are interested in helping develop jQuery UI, you are in the right place.
To discuss development with team members and the community, visit the [Developing jQuery UI Forum](http://forum.jquery.com/developing-jquery-ui) or [#jqueryui-dev on irc.freenode.net](http://irc.jquery.org/). To discuss development with team members and the community, visit the [Developing jQuery UI Forum](http://forum.jquery.com/developing-jquery-ui) or [#jqueryui-dev on irc.freenode.net](http://irc.jquery.org/).
For contributors ## For contributors
---
If you want to help and provide a patch for a bugfix or new feature, please take If you want to help and provide a patch for a bugfix or new feature, please take
a few minutes and look at [our Getting Involved guide](http://wiki.jqueryui.com/w/page/35263114/Getting-Involved). a few minutes and look at [our Getting Involved guide](http://wiki.jqueryui.com/w/page/35263114/Getting-Involved).
@ -22,8 +22,7 @@ pull request for that branch. Don't mix unrelated changes. You can use the commi
message as the description for the pull request. message as the description for the pull request.
Running the Unit Tests ## Running the Unit Tests
---
Run the unit tests with a local server that supports PHP. No database is required. Pre-configured php local servers are available for Windows and Mac. Here are some options: Run the unit tests with a local server that supports PHP. No database is required. Pre-configured php local servers are available for Windows and Mac. Here are some options:
@ -33,8 +32,7 @@ Run the unit tests with a local server that supports PHP. No database is require
- [Mongoose (most platforms)](http://code.google.com/p/mongoose/) - [Mongoose (most platforms)](http://code.google.com/p/mongoose/)
Building jQuery UI ## Building jQuery UI
---
jQuery UI uses the [Grunt](http://github.com/gruntjs/grunt) build system. jQuery UI uses the [Grunt](http://github.com/gruntjs/grunt) build system.
@ -61,8 +59,7 @@ grunt --help
``` ```
For committers ## For committers
---
When looking at pull requests, first check for [proper commit messages](http://wiki.jqueryui.com/w/page/12137724/Bug-Fixing-Guide). When looking at pull requests, first check for [proper commit messages](http://wiki.jqueryui.com/w/page/12137724/Bug-Fixing-Guide).

View File

@ -21,7 +21,7 @@
}, },
"button": { "button": {
"dependencies": [], "dependencies": [],
"description": "Enhances a form with themable buttons.", "description": "Enhances a form with themeable buttons.",
"keywords": [ "keywords": [
"form", "form",
"radio", "radio",

View File

@ -21,6 +21,10 @@
</style> </style>
<script> <script>
$.widget( "custom.catcomplete", $.ui.autocomplete, { $.widget( "custom.catcomplete", $.ui.autocomplete, {
_create: function() {
this._super();
this.menu.option( "items", "> :not(.ui-autocomplete-category)" );
},
_renderMenu: function( ul, items ) { _renderMenu: function( ul, items ) {
var that = this, var that = this,
currentCategory = ""; currentCategory = "";

View File

@ -30,7 +30,7 @@
<ul> <ul>
<li class="ui-state-disabled">Ada</li> <li class="ui-state-disabled">Ada</li>
<li>Saarland</li> <li>Saarland</li>
<li>Salzburg</li> <li>Salzburg an der schönen Donau</li>
</ul> </ul>
</li> </li>
<li>Saarland</li> <li>Saarland</li>

View File

@ -22,19 +22,20 @@
<body> <body>
<ul id="menu"> <ul id="menu">
<li><a href="#"><span class="ui-icon ui-icon-disk"></span>Save</a></li> <li><span class="ui-icon ui-icon-disk"></span>Save</li>
<li><a href="#"><span class="ui-icon ui-icon-zoomin"></span>Zoom In</a></li> <li><span class="ui-icon ui-icon-zoomin"></span>Zoom In</li>
<li><a href="#"><span class="ui-icon ui-icon-zoomout"></span>Zoom Out</a></li> <li><span class="ui-icon ui-icon-zoomout"></span>Zoom Out</li>
<li class="ui-state-disabled"><a href="#"><span class="ui-icon ui-icon-print"></span>Print...</a></li> <li class="ui-state-disabled"><span class="ui-icon ui-icon-print"></span>Print...</li>
<li> <li>
<a href="#">Playback</a> Playback
<ul> <ul>
<li><a href="#"><span class="ui-icon ui-icon-seek-start"></span>Prev</a></li> <li><span class="ui-icon ui-icon-seek-start"></span>Prev</li>
<li><a href="#"><span class="ui-icon ui-icon-stop"></span>Stop</a></li> <li><span class="ui-icon ui-icon-stop"></span>Stop</li>
<li><a href="#"><span class="ui-icon ui-icon-play"></span>Play</a></li> <li><span class="ui-icon ui-icon-play"></span>Play</li>
<li><a href="#"><span class="ui-icon ui-icon-seek-end"></span>Next</a></li> <li><span class="ui-icon ui-icon-seek-end"></span>Next</li>
</ul> </ul>
</li> </li>
<li>Learn more about this menu</li>
</ul> </ul>
<div class="demo-description"> <div class="demo-description">

View File

@ -39,7 +39,7 @@
</div> </div>
<div class="demo-description"> <div class="demo-description">
<p>Delay the start of resizng for a number of milliseconds with the <code>delay</code> option; prevent resizing until the cursor is held down and dragged a specifed number of pixels with the <code>distance</code> option.</p> <p>Delay the start of resizing for a number of milliseconds with the <code>delay</code> option; prevent resizing until the cursor is held down and dragged a specifed number of pixels with the <code>distance</code> option.</p>
</div> </div>
</body> </body>
</html> </html>

View File

@ -57,7 +57,7 @@
"dependencies": {}, "dependencies": {},
"devDependencies": { "devDependencies": {
"grunt": "0.4.1", "grunt": "0.4.1",
"grunt-contrib-jshint": "0.6.3", "grunt-contrib-jshint": "0.7.1",
"grunt-contrib-uglify": "0.1.1", "grunt-contrib-uglify": "0.1.1",
"grunt-contrib-concat": "0.1.3", "grunt-contrib-concat": "0.1.3",
"grunt-contrib-qunit": "0.2.0", "grunt-contrib-qunit": "0.2.0",

View File

@ -46,29 +46,29 @@ test( "accessibility", function () {
equal( headers.eq( 1 ).attr( "tabindex" ), 0, "active header has tabindex=0" ); equal( headers.eq( 1 ).attr( "tabindex" ), 0, "active header has tabindex=0" );
equal( headers.eq( 1 ).attr( "aria-selected" ), "true", "active tab has aria-selected=true" ); equal( headers.eq( 1 ).attr( "aria-selected" ), "true", "active tab has aria-selected=true" );
equal( headers.eq( 1 ).next().attr( "aria-expanded" ), "true", "active tabpanel has aria-expanded=true" ); equal( headers.eq( 1 ).attr( "aria-expanded" ), "true", "active tab has aria-expanded=true" );
equal( headers.eq( 1 ).next().attr( "aria-hidden" ), "false", "active tabpanel has aria-hidden=false" ); equal( headers.eq( 1 ).next().attr( "aria-hidden" ), "false", "active tabpanel has aria-hidden=false" );
equal( headers.eq( 0 ).attr( "tabindex" ), -1, "inactive header has tabindex=-1" ); equal( headers.eq( 0 ).attr( "tabindex" ), -1, "inactive header has tabindex=-1" );
equal( headers.eq( 0 ).attr( "aria-selected" ), "false", "inactive tab has aria-selected=false" ); equal( headers.eq( 0 ).attr( "aria-selected" ), "false", "inactive tab has aria-selected=false" );
equal( headers.eq( 0 ).next().attr( "aria-expanded" ), "false", "inactive tabpanel has aria-expanded=false" ); equal( headers.eq( 0 ).attr( "aria-expanded" ), "false", "inactive tab has aria-expanded=false" );
equal( headers.eq( 0 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel has aria-hidden=true" ); equal( headers.eq( 0 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel has aria-hidden=true" );
equal( headers.eq( 2 ).attr( "tabindex" ), -1, "inactive header has tabindex=-1" ); equal( headers.eq( 2 ).attr( "tabindex" ), -1, "inactive header has tabindex=-1" );
equal( headers.eq( 2 ).attr( "aria-selected" ), "false", "inactive tab has aria-selected=false" ); equal( headers.eq( 2 ).attr( "aria-selected" ), "false", "inactive tab has aria-selected=false" );
equal( headers.eq( 2 ).next().attr( "aria-expanded" ), "false", "inactive tabpanel has aria-expanded=false" ); equal( headers.eq( 2 ).attr( "aria-expanded" ), "false", "inactive tab has aria-expanded=false" );
equal( headers.eq( 2 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel has aria-hidden=true" ); equal( headers.eq( 2 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel has aria-hidden=true" );
element.accordion( "option", "active", 0 ); element.accordion( "option", "active", 0 );
equal( headers.eq( 0 ).attr( "tabindex" ), 0, "active header has tabindex=0" ); equal( headers.eq( 0 ).attr( "tabindex" ), 0, "active header has tabindex=0" );
equal( headers.eq( 0 ).attr( "aria-selected" ), "true", "active tab has aria-selected=true" ); equal( headers.eq( 0 ).attr( "aria-selected" ), "true", "active tab has aria-selected=true" );
equal( headers.eq( 0 ).next().attr( "aria-expanded" ), "true", "active tabpanel has aria-expanded=true" ); equal( headers.eq( 0 ).attr( "aria-expanded" ), "true", "active tab has aria-expanded=true" );
equal( headers.eq( 0 ).next().attr( "aria-hidden" ), "false", "active tabpanel has aria-hidden=false" ); equal( headers.eq( 0 ).next().attr( "aria-hidden" ), "false", "active tabpanel has aria-hidden=false" );
equal( headers.eq( 1 ).attr( "tabindex" ), -1, "inactive header has tabindex=-1" ); equal( headers.eq( 1 ).attr( "tabindex" ), -1, "inactive header has tabindex=-1" );
equal( headers.eq( 1 ).attr( "aria-selected" ), "false", "inactive tab has aria-selected=false" ); equal( headers.eq( 1 ).attr( "aria-selected" ), "false", "inactive tab has aria-selected=false" );
equal( headers.eq( 1 ).next().attr( "aria-expanded" ), "false", "inactive tabpanel has aria-expanded=false" ); equal( headers.eq( 1 ).attr( "aria-expanded" ), "false", "inactive tab has aria-expanded=false" );
equal( headers.eq( 1 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel has aria-hidden=true" ); equal( headers.eq( 1 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel has aria-hidden=true" );
equal( headers.eq( 2 ).attr( "tabindex" ), -1, "inactive header has tabindex=-1" ); equal( headers.eq( 2 ).attr( "tabindex" ), -1, "inactive header has tabindex=-1" );
equal( headers.eq( 2 ).attr( "aria-selected" ), "false", "inactive tab has aria-selected=false" ); equal( headers.eq( 2 ).attr( "aria-selected" ), "false", "inactive tab has aria-selected=false" );
equal( headers.eq( 2 ).next().attr( "aria-expanded" ), "false", "inactive tabpanel has aria-expanded=false" ); equal( headers.eq( 2 ).attr( "aria-expanded" ), "false", "inactive tab has aria-expanded=false" );
equal( headers.eq( 2 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel has aria-hidden=true" ); equal( headers.eq( 2 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel has aria-hidden=true" );
}); });

View File

@ -8,8 +8,38 @@
<link rel="stylesheet" href="../../../external/qunit.css"> <link rel="stylesheet" href="../../../external/qunit.css">
<style> <style>
#main {
width: 1000px;
height: 1000px;
overflow: scroll;
overflow-x: scroll;
overflow-y: scroll;
position: relative;
left: 0;
top: 0;
}
#main-forceScrollable {
width: 1100px;
height: 1100px;
}
#scrollParent {
width: 1200px;
height: 1200px;
position: relative;
left: 0;
top: 0;
overflow: hidden;
overflow-x: hidden;
overflow-y: hidden;
}
#scrollParent-forceScrollable {
width: 1300px;
height: 1300px;
}
/* See #9077 */ /* See #9077 */
#draggable3, #draggable4 { z-index: 100; } #draggable3, #draggable4 {
z-index: 100;
}
</style> </style>
<script src="../../../external/qunit.js"></script> <script src="../../../external/qunit.js"></script>
@ -46,10 +76,14 @@
<h2 id="qunit-userAgent"></h2> <h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol> <ol id="qunit-tests"></ol>
<div id="qunit-fixture"> <div id="qunit-fixture">
<div id="scrollParent">
<div id="main"> <div id="main">
<div id="draggable1" style="background: green; width: 200px; height: 100px;">Relative</div> <div id="draggable1" style="background: green; width: 200px; height: 100px;">Relative</div>
<div id="draggable2" style="background: green; width: 200px; height: 100px; position: absolute; top: 10px; left: 10px;"><span><em>Absolute</em></span></div> <div id="draggable2" style="background: green; width: 200px; height: 100px; position: absolute; top: 10px; left: 10px;"><span><em>Absolute</em></span></div>
<div id="droppable" style="background: green; width: 200px; height: 100px; position: absolute; top: 110px; left: 110px;"><span>Absolute</span></div> <div id="droppable" style="background: green; width: 200px; height: 100px; position: absolute; top: 110px; left: 110px;"><span>Absolute</span></div>
<div id="main-forceScrollable"></div>
</div>
<div id="scrollParent-forceScrollable"></div>
</div> </div>
<div style="width: 1px; height: 1000px;"></div> <div style="width: 1px; height: 1000px;"></div>
<div style="position: absolute; width: 1px; height: 2000px;"></div> <div style="position: absolute; width: 1px; height: 2000px;"></div>

View File

@ -158,7 +158,7 @@ test( "axis, default, switching after initialization", function() {
test( "{ cancel: 'input,textarea,button,select,option' }, default", function() { test( "{ cancel: 'input,textarea,button,select,option' }, default", function() {
expect( 2 ); expect( 2 );
$( "<div id='draggable-option-cancel-default'><input type='text'></div>" ).appendTo( "#main" ); $( "<div id='draggable-option-cancel-default'><input type='text'></div>" ).appendTo( "#qunit-fixture" );
var element = $( "#draggable-option-cancel-default" ).draggable({ cancel: "input,textarea,button,select,option" }); var element = $( "#draggable-option-cancel-default" ).draggable({ cancel: "input,textarea,button,select,option" });
TestHelpers.draggable.shouldMove( element, "cancel: default, element dragged" ); TestHelpers.draggable.shouldMove( element, "cancel: default, element dragged" );
@ -230,7 +230,7 @@ test( "{ cancel: Selectors }, matching parent selector", function() {
test( "cancelement, default, switching after initialization", function() { test( "cancelement, default, switching after initialization", function() {
expect( 2 ); expect( 2 );
$( "<div id='draggable-option-cancel-default'><input type='text'></div>" ).appendTo( "#main" ); $( "<div id='draggable-option-cancel-default'><input type='text'></div>" ).appendTo( "#qunit-fixture" );
var input = $( "#draggable-option-cancel-default input" ), var input = $( "#draggable-option-cancel-default input" ),
element = $( "#draggable-option-cancel-default" ).draggable(); element = $( "#draggable-option-cancel-default" ).draggable();
@ -346,7 +346,7 @@ test( "{ containment: 'parent' }, absolute", function() {
test( "containment, account for border", function() { test( "containment, account for border", function() {
expect( 2 ); expect( 2 );
var el = $("#draggable1").appendTo("#main"), var el = $( "#draggable1" ).appendTo( "#scrollParent" ),
parent = el.parent().css({ parent = el.parent().css({
height: "100px", height: "100px",
width: "100px", width: "100px",
@ -368,9 +368,9 @@ test( "containment, account for border", function() {
dy: 100 dy: 100
}); });
equal( el.offset().top, parentBottom - parentBorderBottom - el.height(), closeEnough( el.offset().top, parentBottom - parentBorderBottom - el.height(), 1,
"The draggable should be on top of its parent's bottom border" ); "The draggable should be on top of its parent's bottom border" );
equal( el.offset().left, parentRight - parentBorderRight - el.width(), closeEnough( el.offset().left, parentRight - parentBorderRight - el.width(), 1,
"The draggable should be to the right of its parent's right border" ); "The draggable should be to the right of its parent's right border" );
}); });
@ -381,13 +381,7 @@ test( "containment, default, switching after initialization", function() {
TestHelpers.draggable.testDrag( element, element, -100, -100, -100, -100, "containment: default" ); TestHelpers.draggable.testDrag( element, element, -100, -100, -100, -100, "containment: default" );
element.draggable( "option", "containment", "parent" ) element.draggable( "option", "containment", "parent" ).css({ top: 0, left: 0 });
.css({
top: 0,
left: 0
})
.appendTo( $( "#main" ) );
TestHelpers.draggable.testDrag( element, element, -100, -100, 0, 0, "containment: parent as option" ); TestHelpers.draggable.testDrag( element, element, -100, -100, 0, 0, "containment: parent as option" );
element.draggable( "option", "containment", false ); element.draggable( "option", "containment", false );
@ -666,332 +660,66 @@ test( "helper, default, switching after initialization", function() {
TestHelpers.draggable.shouldMove( element, "helper: default" ); TestHelpers.draggable.shouldMove( element, "helper: default" );
element.draggable( "option", "helper", "clone" ); element.draggable( "option", "helper", "clone" );
TestHelpers.draggable.shouldMovePositionButNotOffset( element, "helper: clone" ); TestHelpers.draggable.shouldMove( element, "helper: clone" );
element.draggable( "option", "helper", "original" ); element.draggable( "option", "helper", "original" );
TestHelpers.draggable.shouldMove( element, "helper: original" ); TestHelpers.draggable.shouldMove( element, "helper: original" );
}); });
test( "{ helper: 'clone' }, relative", function() { /* jshint loopfunc: true */
expect( 2 ); (function(){
var k, l, m,
scrollElements = {
"no elements": [],
"parent": [ "#main" ],
"root": [ document ],
"parent and root": [ "#main", document ],
"grandparent": [ "#scrollParent" ]
},
positions = [ "absolute", "fixed", "relative", "static" ],
helpers = [ "original", "clone" ],
scrollPositions = [ "relative", "static", "absolute", "fixed" ];
var element = $( "#draggable1" ).draggable({ helper: "clone" }); for ( m = 0 ; m < helpers.length; m++ ) {
TestHelpers.draggable.shouldMovePositionButNotOffset( element, "helper: clone relative" ); for ( l = 0; l < positions.length; l++ ) {
}); for ( k in scrollElements ) {
(function( position, helper, scrollElements, scrollElementsTitle ){
test( "{ helper: 'clone' }, absolute", function() { test( "{ helper: '" + helper + "' }, " + position + ", with scroll offset on " + scrollElementsTitle, function() {
expect( 2 ); expect( 8 );
var i, j,
var element = $( "#draggable2" ).draggable({ helper: "clone" }); element = $( "#draggable1" ).css({ position: position, top: 0, left: 0 }).draggable({
TestHelpers.draggable.shouldMovePositionButNotOffset( element, "helper: clone absolute" ); helper: helper,
}); scroll: false
test( "{ helper: 'original' }, relative, with scroll offset on parent", function() {
expect( 6 );
var element = $( "#draggable1" ).draggable({ helper: "original" });
TestHelpers.draggable.setScroll( "#main" );
TestHelpers.draggable.testScroll( element, "relative" );
TestHelpers.draggable.setScroll( "#main" );
TestHelpers.draggable.testScroll( element, "static" );
TestHelpers.draggable.setScroll( "#main" );
TestHelpers.draggable.testScroll( element, "absolute" );
TestHelpers.draggable.restoreScroll( "#main" );
});
test( "{ helper: 'original' }, relative, with scroll offset on root", function() {
expect( 6 );
var element = $( "#draggable1" ).draggable({ helper: "original" });
TestHelpers.draggable.setScroll( document );
TestHelpers.draggable.testScroll( element, "relative" );
TestHelpers.draggable.setScroll( document );
TestHelpers.draggable.testScroll( element, "static" );
TestHelpers.draggable.setScroll( document );
TestHelpers.draggable.testScroll( element, "absolute" );
TestHelpers.draggable.restoreScroll( document );
});
test( "{ helper: 'original' }, relative, with scroll offset on root and parent", function() {
expect( 6 );
var element = $( "#draggable1" ).draggable({ helper: "original" });
TestHelpers.draggable.setScroll( "#main" );
TestHelpers.draggable.setScroll( document );
TestHelpers.draggable.testScroll( element, "relative" );
TestHelpers.draggable.setScroll( "#main" );
TestHelpers.draggable.setScroll( document );
TestHelpers.draggable.testScroll( element, "static" );
TestHelpers.draggable.setScroll( "#main" );
TestHelpers.draggable.setScroll( document );
TestHelpers.draggable.testScroll( element, "absolute" );
TestHelpers.draggable.restoreScroll( "#main" );
TestHelpers.draggable.restoreScroll( document );
});
test( "{ helper: 'original' }, absolute, with scroll offset on parent", function() {
expect( 6 );
var element = $( "#draggable1" ).css({ position: "absolute", top: 0, left: 0 }).draggable({ helper: "original" });
TestHelpers.draggable.setScroll( "#main" );
TestHelpers.draggable.testScroll( element, "relative" );
TestHelpers.draggable.setScroll( "#main" );
TestHelpers.draggable.testScroll( element, "static" );
TestHelpers.draggable.setScroll( "#main" );
TestHelpers.draggable.testScroll( element, "absolute" );
TestHelpers.draggable.restoreScroll( "#main" );
});
test( "{ helper: 'original' }, absolute, with scroll offset on root", function() {
expect( 6 );
var element = $( "#draggable1" ).css({ position: "absolute", top: 0, left: 0 }).draggable({ helper: "original" });
TestHelpers.draggable.setScroll( document );
TestHelpers.draggable.testScroll( element, "relative" );
TestHelpers.draggable.setScroll( document );
TestHelpers.draggable.testScroll( element, "static" );
TestHelpers.draggable.setScroll( document );
TestHelpers.draggable.testScroll( element, "absolute" );
TestHelpers.draggable.restoreScroll( document );
});
test( "{ helper: 'original' }, absolute, with scroll offset on root and parent", function() {
expect( 6 );
var element = $( "#draggable1" ).css({ position: "absolute", top: 0, left: 0 }).draggable({ helper: "original" });
TestHelpers.draggable.setScroll( "#main" );
TestHelpers.draggable.setScroll( document );
TestHelpers.draggable.testScroll( element, "relative" );
TestHelpers.draggable.setScroll( "#main" );
TestHelpers.draggable.setScroll( document );
TestHelpers.draggable.testScroll( element, "static" );
TestHelpers.draggable.setScroll( "#main" );
TestHelpers.draggable.setScroll( document );
TestHelpers.draggable.testScroll( element, "absolute" );
TestHelpers.draggable.restoreScroll( "#main" );
TestHelpers.draggable.restoreScroll( document );
});
test( "{ helper: 'original' }, fixed, with scroll offset on parent", function() {
expect( 4 );
var element = $( "#draggable1" ).css({ position: "fixed", top: 0, left: 0 }).draggable({ helper: "original" });
TestHelpers.draggable.setScroll( "#main" );
TestHelpers.draggable.testScroll( element, "relative" );
TestHelpers.draggable.setScroll( "#main" );
TestHelpers.draggable.testScroll( element, "static" );
TestHelpers.draggable.setScroll( "#main" );
// TODO: investigate these failure in PhantomJS
//TestHelpers.draggable.testScroll( element, "absolute" );
TestHelpers.draggable.restoreScroll( "#main" );
});
test( "{ helper: 'original' }, fixed, with scroll offset on root", function() {
expect( 4 );
var element = $( "#draggable1" ).css({ position: "fixed", top: 0, left: 0 }).draggable({ helper: "original" });
TestHelpers.draggable.setScroll( document );
TestHelpers.draggable.testScroll( element, "relative" );
TestHelpers.draggable.setScroll( document );
TestHelpers.draggable.testScroll( element, "static" );
TestHelpers.draggable.setScroll( document );
// TODO: investigate these failure in PhantomJS
//TestHelpers.draggable.testScroll( element, "absolute" );
TestHelpers.draggable.restoreScroll( document );
});
test( "{ helper: 'original' }, fixed, with scroll offset on root and parent", function() {
expect( 4 );
var element = $( "#draggable1" ).css({ position: "fixed", top: 0, left: 0 }).draggable({ helper: "original" });
TestHelpers.draggable.setScroll( "#main" );
TestHelpers.draggable.setScroll( document );
TestHelpers.draggable.testScroll( element, "relative" );
TestHelpers.draggable.setScroll( "#main" );
TestHelpers.draggable.setScroll( document );
TestHelpers.draggable.testScroll( element, "static" );
TestHelpers.draggable.setScroll( "#main" );
TestHelpers.draggable.setScroll( document );
// TODO: investigate these failure in PhantomJS
//TestHelpers.draggable.testScroll( element, "absolute" );
TestHelpers.draggable.restoreScroll( "#main" );
TestHelpers.draggable.restoreScroll( document );
});
test( "{ helper: 'clone' }, absolute", function() {
expect( 1 );
var helperOffset = null,
origOffset = $( "#draggable1" ).offset(),
element = $( "#draggable1" ).draggable({ helper: "clone", drag: function( event, ui) {
helperOffset = ui.helper.offset();
} });
element.simulate( "drag", {
dx: 1,
dy: 1
}); });
deepEqual({ top: helperOffset.top - 1, left: helperOffset.left - 1 }, origOffset, "dragged[1, 1]" );
});
test( "{ helper: 'clone' }, absolute with scroll offset on parent", function() { if ( scrollElements.length === 1 && scrollElements[ 1 ] === "#scrollParent" ) {
expect( 3 ); TestHelpers.draggable.setScrollable( "#main", false );
TestHelpers.draggable.setScrollable( "#scrollParent", true );
}
TestHelpers.draggable.setScroll( "#main" ); for ( j = 0; j < scrollPositions.length; j++ ) {
var helperOffset = null, for ( i = 0; i < scrollElements.length; i++ ) {
origOffset = null, TestHelpers.draggable.setScroll( scrollElements[ i ] );
element = $( "#draggable1" ).draggable({ }
helper: "clone",
drag: function( event, ui) { TestHelpers.draggable.testScroll( element, scrollPositions[ j ] );
helperOffset = ui.helper.offset();
for ( i = 0; i < scrollElements.length; i++ ) {
TestHelpers.draggable.restoreScroll( scrollElements[ i ] );
}
}
if ( scrollElements.length === 1 && scrollElements[ 1 ] === "#scrollParent" ) {
TestHelpers.draggable.setScrollable( "#main", true );
TestHelpers.draggable.setScrollable( "#scrollParent", false );
} }
}); });
})( positions[ l ], helpers[ m ], scrollElements[ k ], k );
$( "#main" ).css( "position", "relative" );
origOffset = $( "#draggable1" ).offset();
element.simulate( "drag", {
dx: 1,
dy: 1
});
deepEqual({ top: helperOffset.top - 1, left: helperOffset.left - 1 }, origOffset, "dragged[1, 1]" );
$( "#main" ).css( "position", "static" );
origOffset = $( "#draggable1" ).offset();
element.simulate( "drag", {
dx: 1,
dy: 1
});
deepEqual({ top: helperOffset.top - 1, left: helperOffset.left - 1 }, origOffset, "dragged[1, 1]" );
$( "#main" ).css( "position", "absolute" );
origOffset = $( "#draggable1" ).offset();
element.simulate( "drag", {
dx: 1,
dy: 1
});
deepEqual({ top: helperOffset.top - 1, left: helperOffset.left - 1 }, origOffset, "dragged[1, 1]" );
TestHelpers.draggable.restoreScroll( "#main" );
});
test( "{ helper: 'clone' }, absolute with scroll offset on root", function() {
expect( 3 );
TestHelpers.draggable.setScroll( document );
var helperOffset = null,
origOffset = null,
element = $( "#draggable1" ).draggable({
helper: "clone",
drag: function( event, ui) {
helperOffset = ui.helper.offset();
} }
});
$( "#main" ).css( "position", "relative" );
origOffset = $( "#draggable1" ).offset();
element.simulate( "drag", {
dx: 1,
dy: 1
});
deepEqual({ top: helperOffset.top - 1, left: helperOffset.left - 1 }, origOffset, "dragged[1, 1]" );
$( "#main" ).css( "position", "static" );
origOffset = $( "#draggable1" ).offset();
element.simulate( "drag", {
dx: 1,
dy: 1
});
deepEqual({ top: helperOffset.top - 1, left: helperOffset.left - 1 }, origOffset, "dragged[1, 1]" );
$( "#main" ).css( "position", "absolute" );
origOffset = $( "#draggable1" ).offset();
element.simulate( "drag", {
dx: 1,
dy: 1
});
deepEqual({ top: helperOffset.top - 1, left: helperOffset.left - 1 }, origOffset, "dragged[1, 1]" );
TestHelpers.draggable.restoreScroll( document );
});
test( "{ helper: 'clone' }, absolute with scroll offset on root and parent", function() {
expect( 3 );
TestHelpers.draggable.setScroll( document );
TestHelpers.draggable.setScroll( "#main" );
var helperOffset = null,
origOffset = null,
element = $( "#draggable1" ).draggable({
helper: "clone",
drag: function( event, ui) {
helperOffset = ui.helper.offset();
} }
}); }
})();
$( "#main" ).css( "position", "relative" ); /* jshint loopfunc: false */
origOffset = $( "#draggable1" ).offset();
element.simulate( "drag", {
dx: 1,
dy: 1
});
deepEqual({ top: helperOffset.top - 1, left: helperOffset.left - 1 }, origOffset, "dragged[1, 1]" );
$( "#main" ).css( "position", "static" );
origOffset = $( "#draggable1" ).offset();
element.simulate( "drag", {
dx: 1,
dy: 1
});
deepEqual({ top: helperOffset.top - 1, left: helperOffset.left - 1 }, origOffset, "dragged[1, 1]" );
$( "#main" ).css( "position", "absolute" );
origOffset = $( "#draggable1" ).offset();
element.simulate( "drag", {
dx: 1,
dy: 1
});
deepEqual({ top: helperOffset.top - 1, left: helperOffset.left - 1 }, origOffset, "dragged[1, 1]" );
TestHelpers.draggable.restoreScroll( document );
TestHelpers.draggable.restoreScroll( "#main" );
});
test( "{ opacity: 0.5 }", function() { test( "{ opacity: 0.5 }", function() {
expect( 1 ); expect( 1 );
@ -1098,8 +826,10 @@ test( "scope", function() {
test( "scroll, scrollSensitivity, and scrollSpeed", function() { test( "scroll, scrollSensitivity, and scrollSpeed", function() {
expect( 2 ); expect( 2 );
TestHelpers.draggable.setScrollable( "#main", false );
var viewportHeight = $( window ).height(), var viewportHeight = $( window ).height(),
element = $( "#draggable1" ).draggable({ scroll: true }), element = $( "#draggable1" ).draggable({ scroll: true }).appendTo( "#qunit-fixture" ),
scrollSensitivity = element.draggable( "option", "scrollSensitivity" ), scrollSensitivity = element.draggable( "option", "scrollSensitivity" ),
scrollSpeed = element.draggable( "option", "scrollSpeed" ); scrollSpeed = element.draggable( "option", "scrollSpeed" );

View File

@ -20,8 +20,8 @@ TestHelpers.draggable = {
var offsetBefore = el.offset(), var offsetBefore = el.offset(),
offsetExpected = { left: offsetBefore.left + expectedDX, top: offsetBefore.top + expectedDY }; offsetExpected = { left: offsetBefore.left + expectedDX, top: offsetBefore.top + expectedDY };
$( el ).one( "dragstop", function() { $( el ).one( "dragstop", function( event, ui ) {
deepEqual( el.offset(), offsetExpected, "offset dragged[" + dx + ", " + dy + "] " + msg ); deepEqual( ui.helper.offset(), offsetExpected, "offset dragged[" + dx + ", " + dy + "] " + msg );
} ); } );
}, },
testDrag: function( el, handle, dx, dy, expectedDX, expectedDY, msg ) { testDrag: function( el, handle, dx, dy, expectedDX, expectedDY, msg ) {
@ -30,10 +30,7 @@ TestHelpers.draggable = {
$( handle ).simulate( "drag", { $( handle ).simulate( "drag", {
dx: dx, 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
}); });
}, },
shouldMovePositionButNotOffset: function( el, msg, handle ) { shouldMovePositionButNotOffset: function( el, msg, handle ) {
@ -43,10 +40,7 @@ TestHelpers.draggable = {
$( handle ).simulate( "drag", { $( handle ).simulate( "drag", {
dx: 100, dx: 100,
dy: 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
}); });
}, },
shouldMove: function( el, msg, handle ) { shouldMove: function( el, msg, handle ) {
@ -68,9 +62,13 @@ TestHelpers.draggable = {
}); });
$( el ).unbind( "dragstop" ); $( el ).unbind( "dragstop" );
}, },
setScrollable: function ( what, isScrollable ) {
var overflow = isScrollable ? "scroll" : "hidden";
$( what ).css({ overflow: overflow, overflowX: overflow, overflowY: overflow });
},
testScroll: function( el, position ) { testScroll: function( el, position ) {
var oldPosition = $( "#main" ).css( "position" ); var oldPosition = $( "#main" ).css( "position" );
$( "#main" ).css( "position", position); $( "#main" ).css({ position: position, top: "0px", left: "0px" });
TestHelpers.draggable.shouldMove( el, position + " parent" ); TestHelpers.draggable.shouldMove( el, position + " parent" );
$( "#main" ).css( "position", oldPosition ); $( "#main" ).css( "position", oldPosition );
}, },

View File

@ -35,6 +35,48 @@ test("{ addClasses: false }", function() {
ok(!el.is(".ui-droppable"), "'ui-droppable' class not added"); ok(!el.is(".ui-droppable"), "'ui-droppable' class not added");
el.droppable("destroy"); el.droppable("destroy");
}); });
test( "scope", function() {
expect( 4 );
var droppableOffset, draggableOffset, oldDraggableOffset, dx, dy,
draggable1 = $("<div></div>").appendTo( "#qunit-fixture" ).draggable({ revert: "invalid" }),
draggable2 = $("<div></div>").appendTo( "#qunit-fixture" ).droppable(),
droppable = $("<div></div>").appendTo( "#qunit-fixture" ).droppable(),
newScope = "test";
draggable1.draggable( "option", "scope", newScope );
droppable.droppable( "option", "scope", newScope );
// Test that droppable accepts draggable with new scope.
droppableOffset = droppable.offset();
draggableOffset = draggable1.offset();
dx = droppableOffset.left - draggableOffset.left;
dy = droppableOffset.top - draggableOffset.top;
draggable1.simulate( "drag", {
dx: dx,
dy: dy
});
draggableOffset = draggable1.offset();
equal( draggableOffset.left, droppableOffset.left );
equal( draggableOffset.top, droppableOffset.top );
// Test that droppable doesn't accept draggable with old scope.
draggableOffset = draggable2.offset();
dx = droppableOffset.left - draggableOffset.left;
dy = droppableOffset.top - draggableOffset.top;
oldDraggableOffset = draggableOffset;
draggable2.simulate( "drag", {
dx: dx,
dy: dy
});
draggableOffset = draggable2.offset();
equal( draggableOffset.left, oldDraggableOffset.left );
equal( draggableOffset.top, oldDraggableOffset.top );
});
/* /*
test("greedy", function() { test("greedy", function() {
ok(false, 'missing test - untested code is broken code'); ok(false, 'missing test - untested code is broken code');
@ -44,10 +86,6 @@ test("hoverClass", function() {
ok(false, 'missing test - untested code is broken code'); ok(false, 'missing test - untested code is broken code');
}); });
test("scope", function() {
ok(false, 'missing test - untested code is broken code');
});
test("tolerance, fit", function() { test("tolerance, fit", function() {
ok(false, 'missing test - untested code is broken code'); ok(false, 'missing test - untested code is broken code');
}); });

View File

@ -38,7 +38,7 @@
margin: 1px; margin: 1px;
border-width: 0; border-width: 0;
} }
#sortable li{ #sortable li, #sortable2 li{
padding: 0; padding: 0;
margin: 0; margin: 0;
border-width: 0; border-width: 0;
@ -58,7 +58,15 @@
<ol id="qunit-tests"></ol> <ol id="qunit-tests"></ol>
<div id="qunit-fixture"> <div id="qunit-fixture">
<ul id="sortable"> <ul id="sortable" class="connectWith">
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
<li>Item 4</li>
<li>Item 5</li>
</ul>
<ul id="sortable2" class="connectWith">
<li>Item 1</li> <li>Item 1</li>
<li>Item 2</li> <li>Item 2</li>
<li>Item 3</li> <li>Item 3</li>

View File

@ -1,3 +1,19 @@
/* /*
* sortable_core.js * sortable_core.js
*/ */
(function( $ ) {
module( "sortable: core" );
test( "#9314: Sortable: Items cannot be dragged directly into bottom position", function() {
expect( 1 );
var el = $( ".connectWith" ).sortable({
connectWith: ".connectWith"
});
TestHelpers.sortable.sort( $( "li", el[ 1 ] )[ 0 ], 0, -12, 5, "Dragging the sortable into connected sortable" );
});
})( jQuery );

View File

@ -67,7 +67,7 @@ test( "aria-controls", function() {
tabs = element.find( ".ui-tabs-nav li" ); tabs = element.find( ".ui-tabs-nav li" );
equal( tabs.eq( 0 ).attr( "aria-controls" ), "colon:test" ); equal( tabs.eq( 0 ).attr( "aria-controls" ), "colon:test" );
equal( tabs.eq( 1 ).attr( "aria-controls" ), "inline-style" ); equal( tabs.eq( 1 ).attr( "aria-controls" ), "inline-style" );
ok( /^ui-tabs-\d+$/.test( tabs.eq( 2 ).attr( "aria-controls" ) ), "generated id" ); ok( /^ui-id-\d+$/.test( tabs.eq( 2 ).attr( "aria-controls" ) ), "generated id" );
equal( tabs.eq( 3 ).attr( "aria-controls" ), "custom-id" ); equal( tabs.eq( 3 ).attr( "aria-controls" ), "custom-id" );
}); });

View File

@ -10,27 +10,25 @@
*/ */
.ui-menu { .ui-menu {
list-style: none; list-style: none;
padding: 2px; padding: 0;
margin: 0; margin: 0;
display: block; display: block;
outline: none; outline: none;
} }
.ui-menu .ui-menu { .ui-menu .ui-menu {
margin-top: -3px;
position: absolute; position: absolute;
} }
.ui-menu .ui-menu-item { .ui-menu .ui-menu-item {
margin: 0; margin: 0;
display: block; display: block;
padding: 2px .4em; padding: 3px .4em;
line-height: 1.5; cursor: pointer;
min-height: 0; /* support: IE7 */ min-height: 0; /* support: IE7 */
font-weight: normal;
/* support: IE10, see #8844 */ /* support: IE10, see #8844 */
list-style-image: url(data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7); list-style-image: url(data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7);
} }
.ui-menu .ui-menu-divider { .ui-menu .ui-menu-divider {
margin: 5px -2px 5px -2px; margin: 5px 0;
height: 0; height: 0;
font-size: 0; font-size: 0;
line-height: 0; line-height: 0;
@ -38,19 +36,9 @@
} }
.ui-menu .ui-state-focus, .ui-menu .ui-state-focus,
.ui-menu .ui-state-active { .ui-menu .ui-state-active {
font-weight: normal;
margin: -1px; margin: -1px;
} }
.ui-menu .ui-state-disabled {
font-weight: normal;
margin: .4em 0 .2em;
line-height: 1.5;
}
.ui-menu .ui-state-disabled a {
cursor: default;
}
/* icon support */ /* icon support */
.ui-menu-icons { .ui-menu-icons {
position: relative; position: relative;
@ -69,6 +57,7 @@
/* right-aligned */ /* right-aligned */
.ui-menu .ui-menu-icon { .ui-menu .ui-menu-icon {
position: static; position: relative;
top: -.2em;
float: right; float: right;
} }

View File

@ -3,8 +3,8 @@
jQuery(function($){ jQuery(function($){
$.datepicker.regional['lv'] = { $.datepicker.regional['lv'] = {
closeText: 'Aizvērt', closeText: 'Aizvērt',
prevText: 'Iepr', prevText: 'Iepr.',
nextText: 'Nāka', nextText: 'Nāk.',
currentText: 'Šodien', currentText: 'Šodien',
monthNames: ['Janvāris','Februāris','Marts','Aprīlis','Maijs','Jūnijs', monthNames: ['Janvāris','Februāris','Marts','Aprīlis','Maijs','Jūnijs',
'Jūlijs','Augusts','Septembris','Oktobris','Novembris','Decembris'], 'Jūlijs','Augusts','Septembris','Oktobris','Novembris','Decembris'],
@ -13,8 +13,8 @@ jQuery(function($){
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'], dayNamesShort: ['svt','prm','otr','tre','ctr','pkt','sst'],
dayNamesMin: ['Sv','Pr','Ot','Tr','Ct','Pk','Ss'], dayNamesMin: ['Sv','Pr','Ot','Tr','Ct','Pk','Ss'],
weekHeader: 'Nav', weekHeader: 'Ned.',
dateFormat: 'dd-mm-yy', dateFormat: 'dd.mm.yy',
firstDay: 1, firstDay: 1,
isRTL: false, isRTL: false,
showMonthAfterYear: false, showMonthAfterYear: false,

View File

@ -14,15 +14,6 @@
*/ */
(function( $, undefined ) { (function( $, undefined ) {
var uid = 0,
hideProps = {},
showProps = {};
hideProps.height = hideProps.paddingTop = hideProps.paddingBottom =
hideProps.borderTopWidth = hideProps.borderBottomWidth = "hide";
showProps.height = showProps.paddingTop = showProps.paddingBottom =
showProps.borderTopWidth = showProps.borderBottomWidth = "show";
$.widget( "ui.accordion", { $.widget( "ui.accordion", {
version: "@VERSION", version: "@VERSION",
options: { options: {
@ -42,6 +33,22 @@ $.widget( "ui.accordion", {
beforeActivate: null beforeActivate: null
}, },
hideProps: {
borderTopWidth: "hide",
borderBottomWidth: "hide",
paddingTop: "hide",
paddingBottom: "hide",
height: "hide"
},
showProps: {
borderTopWidth: "show",
borderBottomWidth: "show",
paddingTop: "show",
paddingBottom: "show",
height: "show"
},
_create: function() { _create: function() {
var options = this.options; var options = this.options;
this.prevShow = this.prevHide = $(); this.prevShow = this.prevHide = $();
@ -99,31 +106,27 @@ $.widget( "ui.accordion", {
// clean up headers // clean up headers
this.headers this.headers
.removeClass( "ui-accordion-header ui-accordion-header-active ui-state-default ui-corner-all ui-state-active ui-state-disabled ui-corner-top" ) .removeClass( "ui-accordion-header ui-accordion-header-active ui-state-default " +
"ui-corner-all ui-state-active ui-state-disabled ui-corner-top" )
.removeAttr( "role" ) .removeAttr( "role" )
.removeAttr( "aria-expanded" )
.removeAttr( "aria-selected" ) .removeAttr( "aria-selected" )
.removeAttr( "aria-controls" ) .removeAttr( "aria-controls" )
.removeAttr( "tabIndex" ) .removeAttr( "tabIndex" )
.each(function() { .removeUniqueId();
if ( /^ui-accordion/.test( this.id ) ) {
this.removeAttribute( "id" );
}
});
this._destroyIcons(); this._destroyIcons();
// clean up content panels // clean up content panels
contents = this.headers.next() contents = this.headers.next()
.removeClass( "ui-helper-reset ui-widget-content ui-corner-bottom " +
"ui-accordion-content ui-accordion-content-active ui-state-disabled" )
.css( "display", "" ) .css( "display", "" )
.removeAttr( "role" ) .removeAttr( "role" )
.removeAttr( "aria-expanded" )
.removeAttr( "aria-hidden" ) .removeAttr( "aria-hidden" )
.removeAttr( "aria-labelledby" ) .removeAttr( "aria-labelledby" )
.removeClass( "ui-helper-reset ui-widget-content ui-corner-bottom ui-accordion-content ui-accordion-content-active ui-state-disabled" ) .removeUniqueId();
.each(function() {
if ( /^ui-accordion/.test( this.id ) ) {
this.removeAttribute( "id" );
}
});
if ( this.options.heightStyle !== "content" ) { if ( this.options.heightStyle !== "content" ) {
contents.css( "height", "" ); contents.css( "height", "" );
} }
@ -259,9 +262,7 @@ $.widget( "ui.accordion", {
var maxHeight, var maxHeight,
options = this.options, options = this.options,
heightStyle = options.heightStyle, heightStyle = options.heightStyle,
parent = this.element.parent(), parent = this.element.parent();
accordionId = this.accordionId = "ui-accordion-" +
(this.element.attr( "id" ) || ++uid);
this.active = this._findActive( options.active ) this.active = this._findActive( options.active )
.addClass( "ui-accordion-header-active ui-state-active ui-corner-top" ) .addClass( "ui-accordion-header-active ui-state-active ui-corner-top" )
@ -272,19 +273,11 @@ $.widget( "ui.accordion", {
this.headers this.headers
.attr( "role", "tab" ) .attr( "role", "tab" )
.each(function( i ) { .each(function() {
var header = $( this ), var header = $( this ),
headerId = header.attr( "id" ), headerId = header.uniqueId().attr( "id" ),
panel = header.next(), panel = header.next(),
panelId = panel.attr( "id" ); panelId = panel.uniqueId().attr( "id" );
if ( !headerId ) {
headerId = accordionId + "-header-" + i;
header.attr( "id", headerId );
}
if ( !panelId ) {
panelId = accordionId + "-panel-" + i;
panel.attr( "id", panelId );
}
header.attr( "aria-controls", panelId ); header.attr( "aria-controls", panelId );
panel.attr( "aria-labelledby", headerId ); panel.attr( "aria-labelledby", headerId );
}) })
@ -295,11 +288,11 @@ $.widget( "ui.accordion", {
.not( this.active ) .not( this.active )
.attr({ .attr({
"aria-selected": "false", "aria-selected": "false",
"aria-expanded": "false",
tabIndex: -1 tabIndex: -1
}) })
.next() .next()
.attr({ .attr({
"aria-expanded": "false",
"aria-hidden": "true" "aria-hidden": "true"
}) })
.hide(); .hide();
@ -310,11 +303,11 @@ $.widget( "ui.accordion", {
} else { } else {
this.active.attr({ this.active.attr({
"aria-selected": "true", "aria-selected": "true",
"aria-expanded": "true",
tabIndex: 0 tabIndex: 0
}) })
.next() .next()
.attr({ .attr({
"aria-expanded": "true",
"aria-hidden": "false" "aria-hidden": "false"
}); });
} }
@ -469,7 +462,6 @@ $.widget( "ui.accordion", {
} }
toHide.attr({ toHide.attr({
"aria-expanded": "false",
"aria-hidden": "true" "aria-hidden": "true"
}); });
toHide.prev().attr( "aria-selected", "false" ); toHide.prev().attr( "aria-selected", "false" );
@ -477,7 +469,10 @@ $.widget( "ui.accordion", {
// if we're opening from collapsed state, remove the previous header from the tab order // if we're opening from collapsed state, remove the previous header from the tab order
// if we're collapsing, then keep the collapsing header in the tab order // if we're collapsing, then keep the collapsing header in the tab order
if ( toShow.length && toHide.length ) { if ( toShow.length && toHide.length ) {
toHide.prev().attr( "tabIndex", -1 ); toHide.prev().attr({
"tabIndex": -1,
"aria-expanded": "false"
});
} else if ( toShow.length ) { } else if ( toShow.length ) {
this.headers.filter(function() { this.headers.filter(function() {
return $( this ).attr( "tabIndex" ) === 0; return $( this ).attr( "tabIndex" ) === 0;
@ -486,14 +481,12 @@ $.widget( "ui.accordion", {
} }
toShow toShow
.attr({ .attr( "aria-hidden", "false" )
"aria-expanded": "true",
"aria-hidden": "false"
})
.prev() .prev()
.attr({ .attr({
"aria-selected": "true", "aria-selected": "true",
tabIndex: 0 tabIndex: 0,
"aria-expanded": "true"
}); });
}, },
@ -520,14 +513,14 @@ $.widget( "ui.accordion", {
duration = duration || options.duration || animate.duration; duration = duration || options.duration || animate.duration;
if ( !toHide.length ) { if ( !toHide.length ) {
return toShow.animate( showProps, duration, easing, complete ); return toShow.animate( this.showProps, duration, easing, complete );
} }
if ( !toShow.length ) { if ( !toShow.length ) {
return toHide.animate( hideProps, duration, easing, complete ); return toHide.animate( this.hideProps, duration, easing, complete );
} }
total = toShow.show().outerHeight(); total = toShow.show().outerHeight();
toHide.animate( hideProps, { toHide.animate( this.hideProps, {
duration: duration, duration: duration,
easing: easing, easing: easing,
step: function( now, fx ) { step: function( now, fx ) {
@ -536,7 +529,7 @@ $.widget( "ui.accordion", {
}); });
toShow toShow
.hide() .hide()
.animate( showProps, { .animate( this.showProps, {
duration: duration, duration: duration,
easing: easing, easing: easing,
complete: complete, complete: complete,
@ -565,7 +558,6 @@ $.widget( "ui.accordion", {
if ( toHide.length ) { if ( toHide.length ) {
toHide.parent()[0].className = toHide.parent()[0].className; toHide.parent()[0].className = toHide.parent()[0].className;
} }
this._trigger( "activate", null, data ); this._trigger( "activate", null, data );
} }
}); });

View File

@ -14,7 +14,7 @@
*/ */
(function( $, undefined ) { (function( $, undefined ) {
var lastActive, startXPos, startYPos, clickDragged, var lastActive,
baseClasses = "ui-button ui-widget ui-state-default ui-corner-all", baseClasses = "ui-button ui-widget ui-state-default ui-corner-all",
typeClasses = "ui-button-icons-only ui-button-icon-only ui-button-text-icons ui-button-text-icon-primary ui-button-text-icon-secondary ui-button-text-only", typeClasses = "ui-button-icons-only ui-button-icon-only ui-button-text-icons ui-button-text-icon-primary ui-button-text-icon-secondary ui-button-text-only",
formResetHandler = function() { formResetHandler = function() {
@ -115,42 +115,19 @@ $.widget( "ui.button", {
if ( toggleButton ) { if ( toggleButton ) {
this.element.bind( "change" + this.eventNamespace, function() { this.element.bind( "change" + this.eventNamespace, function() {
if ( clickDragged ) {
return;
}
that.refresh(); that.refresh();
}); });
// if mouse moves between mousedown and mouseup (drag) set clickDragged flag
// prevents issue where button state changes but checkbox/radio checked state
// does not in Firefox (see ticket #6970)
this.buttonElement
.bind( "mousedown" + this.eventNamespace, function( event ) {
if ( options.disabled ) {
return;
}
clickDragged = false;
startXPos = event.pageX;
startYPos = event.pageY;
})
.bind( "mouseup" + this.eventNamespace, function( event ) {
if ( options.disabled ) {
return;
}
if ( startXPos !== event.pageX || startYPos !== event.pageY ) {
clickDragged = true;
}
});
} }
if ( this.type === "checkbox" ) { if ( this.type === "checkbox" ) {
this.buttonElement.bind( "click" + this.eventNamespace, function() { this.buttonElement.bind( "click" + this.eventNamespace, function() {
if ( options.disabled || clickDragged ) { if ( options.disabled ) {
return false; return false;
} }
}); });
} else if ( this.type === "radio" ) { } else if ( this.type === "radio" ) {
this.buttonElement.bind( "click" + this.eventNamespace, function() { this.buttonElement.bind( "click" + this.eventNamespace, function() {
if ( options.disabled || clickDragged ) { if ( options.disabled ) {
return false; return false;
} }
$( this ).addClass( "ui-state-active" ); $( this ).addClass( "ui-state-active" );

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

@ -10,9 +10,6 @@
*/ */
(function( $, undefined ) { (function( $, undefined ) {
var uuid = 0,
runiqueId = /^ui-id-\d+$/;
// $.ui might exist from components with no dependencies, e.g., $.ui.position // $.ui might exist from components with no dependencies, e.g., $.ui.position
$.ui = $.ui || {}; $.ui = $.ui || {};
@ -72,17 +69,21 @@ $.fn.extend({
return ( /fixed/ ).test( this.css( "position") ) || !scrollParent.length ? $( this[ 0 ].ownerDocument || document ) : scrollParent; return ( /fixed/ ).test( this.css( "position") ) || !scrollParent.length ? $( this[ 0 ].ownerDocument || document ) : scrollParent;
}, },
uniqueId: function() { uniqueId: (function() {
var uuid = 0;
return function() {
return this.each(function() { return this.each(function() {
if ( !this.id ) { if ( !this.id ) {
this.id = "ui-id-" + (++uuid); this.id = "ui-id-" + ( ++uuid );
} }
}); });
}, };
})(),
removeUniqueId: function() { removeUniqueId: function() {
return this.each(function() { return this.each(function() {
if ( runiqueId.test( this.id ) ) { if ( /^ui-id-\d+$/.test( this.id ) ) {
$( this ).removeAttr( "id" ); $( this ).removeAttr( "id" );
} }
}); });

View File

@ -15,10 +15,9 @@
$.extend($.ui, { datepicker: { version: "@VERSION" } }); $.extend($.ui, { datepicker: { version: "@VERSION" } });
var PROP_NAME = "datepicker", var datepicker_instActive;
instActive;
function getZindex( elem ) { function datepicker_getZindex( elem ) {
var position, value; var position, value;
while ( elem.length && elem[ 0 ] !== document ) { while ( elem.length && elem[ 0 ] !== document ) {
// Ignore z-index if position is set to a value where z-index is ignored by the browser // Ignore z-index if position is set to a value where z-index is ignored by the browser
@ -130,7 +129,7 @@ function Datepicker() {
disabled: false // The initial disabled state disabled: false // The initial disabled state
}; };
$.extend(this._defaults, this.regional[""]); $.extend(this._defaults, this.regional[""]);
this.dpDiv = bindHover($("<div id='" + this._mainDivId + "' class='ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>")); this.dpDiv = datepicker_bindHover($("<div id='" + this._mainDivId + "' class='ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>"));
} }
$.extend(Datepicker.prototype, { $.extend(Datepicker.prototype, {
@ -150,7 +149,7 @@ $.extend(Datepicker.prototype, {
* @return the manager object * @return the manager object
*/ */
setDefaults: function(settings) { setDefaults: function(settings) {
extendRemove(this._defaults, settings || {}); datepicker_extendRemove(this._defaults, settings || {});
return this; return this;
}, },
@ -183,7 +182,7 @@ $.extend(Datepicker.prototype, {
drawMonth: 0, drawYear: 0, // month being drawn drawMonth: 0, drawYear: 0, // month being drawn
inline: inline, // is datepicker inline or not inline: inline, // is datepicker inline or not
dpDiv: (!inline ? this.dpDiv : // presentation div dpDiv: (!inline ? this.dpDiv : // presentation div
bindHover($("<div class='" + this._inlineClass + " ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>")))}; datepicker_bindHover($("<div class='" + this._inlineClass + " ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>")))};
}, },
/* Attach the date picker to an input field. */ /* Attach the date picker to an input field. */
@ -198,7 +197,7 @@ $.extend(Datepicker.prototype, {
input.addClass(this.markerClassName).keydown(this._doKeyDown). input.addClass(this.markerClassName).keydown(this._doKeyDown).
keypress(this._doKeyPress).keyup(this._doKeyUp); keypress(this._doKeyPress).keyup(this._doKeyUp);
this._autoSize(inst); this._autoSize(inst);
$.data(target, PROP_NAME, inst); $.data(target, "datepicker", inst);
//If disabled option is true, disable the datepicker once it has been attached to the input (see ticket #5665) //If disabled option is true, disable the datepicker once it has been attached to the input (see ticket #5665)
if( inst.settings.disabled ) { if( inst.settings.disabled ) {
this._disableDatepicker( target ); this._disableDatepicker( target );
@ -288,7 +287,7 @@ $.extend(Datepicker.prototype, {
return; return;
} }
divSpan.addClass(this.markerClassName).append(inst.dpDiv); divSpan.addClass(this.markerClassName).append(inst.dpDiv);
$.data(target, PROP_NAME, inst); $.data(target, "datepicker", inst);
this._setDate(inst, this._getDefaultDate(inst), true); this._setDate(inst, this._getDefaultDate(inst), true);
this._updateDatepicker(inst); this._updateDatepicker(inst);
this._updateAlternate(inst); this._updateAlternate(inst);
@ -324,9 +323,9 @@ $.extend(Datepicker.prototype, {
$("body").append(this._dialogInput); $("body").append(this._dialogInput);
inst = this._dialogInst = this._newInst(this._dialogInput, false); inst = this._dialogInst = this._newInst(this._dialogInput, false);
inst.settings = {}; inst.settings = {};
$.data(this._dialogInput[0], PROP_NAME, inst); $.data(this._dialogInput[0], "datepicker", inst);
} }
extendRemove(inst.settings, settings || {}); datepicker_extendRemove(inst.settings, settings || {});
date = (date && date.constructor === Date ? this._formatDate(inst, date) : date); date = (date && date.constructor === Date ? this._formatDate(inst, date) : date);
this._dialogInput.val(date); this._dialogInput.val(date);
@ -349,7 +348,7 @@ $.extend(Datepicker.prototype, {
if ($.blockUI) { if ($.blockUI) {
$.blockUI(this.dpDiv); $.blockUI(this.dpDiv);
} }
$.data(this._dialogInput[0], PROP_NAME, inst); $.data(this._dialogInput[0], "datepicker", inst);
return this; return this;
}, },
@ -359,14 +358,14 @@ $.extend(Datepicker.prototype, {
_destroyDatepicker: function(target) { _destroyDatepicker: function(target) {
var nodeName, var nodeName,
$target = $(target), $target = $(target),
inst = $.data(target, PROP_NAME); inst = $.data(target, "datepicker");
if (!$target.hasClass(this.markerClassName)) { if (!$target.hasClass(this.markerClassName)) {
return; return;
} }
nodeName = target.nodeName.toLowerCase(); nodeName = target.nodeName.toLowerCase();
$.removeData(target, PROP_NAME); $.removeData(target, "datepicker");
if (nodeName === "input") { if (nodeName === "input") {
inst.append.remove(); inst.append.remove();
inst.trigger.remove(); inst.trigger.remove();
@ -386,7 +385,7 @@ $.extend(Datepicker.prototype, {
_enableDatepicker: function(target) { _enableDatepicker: function(target) {
var nodeName, inline, var nodeName, inline,
$target = $(target), $target = $(target),
inst = $.data(target, PROP_NAME); inst = $.data(target, "datepicker");
if (!$target.hasClass(this.markerClassName)) { if (!$target.hasClass(this.markerClassName)) {
return; return;
@ -414,7 +413,7 @@ $.extend(Datepicker.prototype, {
_disableDatepicker: function(target) { _disableDatepicker: function(target) {
var nodeName, inline, var nodeName, inline,
$target = $(target), $target = $(target),
inst = $.data(target, PROP_NAME); inst = $.data(target, "datepicker");
if (!$target.hasClass(this.markerClassName)) { if (!$target.hasClass(this.markerClassName)) {
return; return;
@ -460,7 +459,7 @@ $.extend(Datepicker.prototype, {
*/ */
_getInst: function(target) { _getInst: function(target) {
try { try {
return $.data(target, PROP_NAME); return $.data(target, "datepicker");
} }
catch (err) { catch (err) {
throw "Missing instance data for this datepicker"; throw "Missing instance data for this datepicker";
@ -500,7 +499,7 @@ $.extend(Datepicker.prototype, {
date = this._getDateDatepicker(target, true); date = this._getDateDatepicker(target, true);
minDate = this._getMinMaxDate(inst, "min"); minDate = this._getMinMaxDate(inst, "min");
maxDate = this._getMinMaxDate(inst, "max"); maxDate = this._getMinMaxDate(inst, "max");
extendRemove(inst.settings, settings); datepicker_extendRemove(inst.settings, settings);
// reformat the old minDate/maxDate values if dateFormat changes and a new minDate/maxDate isn't provided // reformat the old minDate/maxDate values if dateFormat changes and a new minDate/maxDate isn't provided
if (minDate !== null && settings.dateFormat !== undefined && settings.minDate === undefined) { if (minDate !== null && settings.dateFormat !== undefined && settings.minDate === undefined) {
inst.settings.minDate = this._formatDate(inst, minDate); inst.settings.minDate = this._formatDate(inst, minDate);
@ -728,7 +727,7 @@ $.extend(Datepicker.prototype, {
if(beforeShowSettings === false){ if(beforeShowSettings === false){
return; return;
} }
extendRemove(inst.settings, beforeShowSettings); datepicker_extendRemove(inst.settings, beforeShowSettings);
inst.lastVal = null; inst.lastVal = null;
$.datepicker._lastInput = input; $.datepicker._lastInput = input;
@ -765,7 +764,7 @@ $.extend(Datepicker.prototype, {
if (!inst.inline) { if (!inst.inline) {
showAnim = $.datepicker._get(inst, "showAnim"); showAnim = $.datepicker._get(inst, "showAnim");
duration = $.datepicker._get(inst, "duration"); duration = $.datepicker._get(inst, "duration");
inst.dpDiv.css( "z-index", getZindex( $( input ) ) + 1 ); inst.dpDiv.css( "z-index", datepicker_getZindex( $( input ) ) + 1 );
$.datepicker._datepickerShowing = true; $.datepicker._datepickerShowing = true;
if ( $.effects && $.effects.effect[ showAnim ] ) { if ( $.effects && $.effects.effect[ showAnim ] ) {
@ -785,7 +784,7 @@ $.extend(Datepicker.prototype, {
/* Generate the date picker content. */ /* Generate the date picker content. */
_updateDatepicker: function(inst) { _updateDatepicker: function(inst) {
this.maxRows = 4; //Reset the max number of rows being displayed (see #7043) this.maxRows = 4; //Reset the max number of rows being displayed (see #7043)
instActive = inst; // for delegate hover events datepicker_instActive = inst; // for delegate hover events
inst.dpDiv.empty().append(this._generateHTML(inst)); inst.dpDiv.empty().append(this._generateHTML(inst));
this._attachHandlers(inst); this._attachHandlers(inst);
inst.dpDiv.find("." + this._dayOverClass + " a").mouseover(); inst.dpDiv.find("." + this._dayOverClass + " a").mouseover();
@ -871,7 +870,7 @@ $.extend(Datepicker.prototype, {
var showAnim, duration, postProcess, onClose, var showAnim, duration, postProcess, onClose,
inst = this._curInst; inst = this._curInst;
if (!inst || (input && inst !== $.data(input, PROP_NAME))) { if (!inst || (input && inst !== $.data(input, "datepicker"))) {
return; return;
} }
@ -1975,9 +1974,9 @@ $.extend(Datepicker.prototype, {
/* /*
* Bind hover events for datepicker elements. * Bind hover events for datepicker elements.
* Done via delegate so the binding only occurs once in the lifetime of the parent div. * Done via delegate so the binding only occurs once in the lifetime of the parent div.
* Global instActive, set by _updateDatepicker allows the handlers to find their way back to the active picker. * Global datepicker_instActive, set by _updateDatepicker allows the handlers to find their way back to the active picker.
*/ */
function bindHover(dpDiv) { function datepicker_bindHover(dpDiv) {
var selector = "button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a"; var selector = "button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a";
return dpDiv.delegate(selector, "mouseout", function() { return dpDiv.delegate(selector, "mouseout", function() {
$(this).removeClass("ui-state-hover"); $(this).removeClass("ui-state-hover");
@ -1989,7 +1988,7 @@ function bindHover(dpDiv) {
} }
}) })
.delegate(selector, "mouseover", function(){ .delegate(selector, "mouseover", function(){
if (!$.datepicker._isDisabledDatepicker( instActive.inline ? dpDiv.parent()[0] : instActive.input[0])) { if (!$.datepicker._isDisabledDatepicker( datepicker_instActive.inline ? dpDiv.parent()[0] : datepicker_instActive.input[0])) {
$(this).parents(".ui-datepicker-calendar").find("a").removeClass("ui-state-hover"); $(this).parents(".ui-datepicker-calendar").find("a").removeClass("ui-state-hover");
$(this).addClass("ui-state-hover"); $(this).addClass("ui-state-hover");
if (this.className.indexOf("ui-datepicker-prev") !== -1) { if (this.className.indexOf("ui-datepicker-prev") !== -1) {
@ -2003,7 +2002,7 @@ function bindHover(dpDiv) {
} }
/* jQuery extend now ignores nulls! */ /* jQuery extend now ignores nulls! */
function extendRemove(target, props) { function datepicker_extendRemove(target, props) {
$.extend(target, props); $.extend(target, props);
for (var name in props) { for (var name in props) {
if (props[name] == null) { if (props[name] == null) {

View File

@ -19,22 +19,6 @@
*/ */
(function( $, undefined ) { (function( $, undefined ) {
var sizeRelatedOptions = {
buttons: true,
height: true,
maxHeight: true,
maxWidth: true,
minHeight: true,
minWidth: true,
width: true
},
resizableRelatedOptions = {
maxHeight: true,
maxWidth: true,
minHeight: true,
minWidth: true
};
$.widget( "ui.dialog", { $.widget( "ui.dialog", {
version: "@VERSION", version: "@VERSION",
options: { options: {
@ -83,6 +67,23 @@ $.widget( "ui.dialog", {
resizeStop: null resizeStop: null
}, },
sizeRelatedOptions: {
buttons: true,
height: true,
maxHeight: true,
maxWidth: true,
minHeight: true,
minWidth: true,
width: true
},
resizableRelatedOptions: {
maxHeight: true,
maxWidth: true,
minHeight: true,
minWidth: true
},
_create: function() { _create: function() {
this.originalCss = { this.originalCss = {
display: this.element[0].style.display, display: this.element[0].style.display,
@ -579,10 +580,10 @@ $.widget( "ui.dialog", {
$.each( options, function( key, value ) { $.each( options, function( key, value ) {
that._setOption( key, value ); that._setOption( key, value );
if ( key in sizeRelatedOptions ) { if ( key in that.sizeRelatedOptions ) {
resize = true; resize = true;
} }
if ( key in resizableRelatedOptions ) { if ( key in that.resizableRelatedOptions ) {
resizableOptions[ key ] = value; resizableOptions[ key ] = value;
} }
}); });

View File

@ -16,10 +16,6 @@
*/ */
(function( $, undefined ) { (function( $, undefined ) {
function isOverAxis( x, reference, size ) {
return ( x >= reference ) && ( x < ( reference + size ) );
}
$.widget( "ui.droppable", { $.widget( "ui.droppable", {
version: "@VERSION", version: "@VERSION",
widgetEventPrefix: "drop", widgetEventPrefix: "drop",
@ -67,23 +63,31 @@ $.widget( "ui.droppable", {
} }
}; };
// Add the reference and positions to the manager this._addToManager( o.scope );
$.ui.ddmanager.droppables[ o.scope ] = $.ui.ddmanager.droppables[ o.scope ] || [];
$.ui.ddmanager.droppables[ o.scope ].push( this );
o.addClasses && this.element.addClass( "ui-droppable" ); o.addClasses && this.element.addClass( "ui-droppable" );
}, },
_destroy: function() { _addToManager: function( scope ) {
var i = 0, // Add the reference and positions to the manager
drop = $.ui.ddmanager.droppables[ this.options.scope ]; $.ui.ddmanager.droppables[ scope ] = $.ui.ddmanager.droppables[ scope ] || [];
$.ui.ddmanager.droppables[ scope ].push( this );
},
_splice: function( drop ) {
var i = 0;
for ( ; i < drop.length; i++ ) { for ( ; i < drop.length; i++ ) {
if ( drop[ i ] === this ) { if ( drop[ i ] === this ) {
drop.splice( i, 1 ); drop.splice( i, 1 );
} }
} }
},
_destroy: function() {
var drop = $.ui.ddmanager.droppables[ this.options.scope ];
this._splice( drop );
this.element.removeClass( "ui-droppable ui-droppable-disabled" ); this.element.removeClass( "ui-droppable ui-droppable-disabled" );
}, },
@ -94,7 +98,13 @@ $.widget( "ui.droppable", {
this.accept = $.isFunction( value ) ? value : function( d ) { this.accept = $.isFunction( value ) ? value : function( d ) {
return d.is( value ); return d.is( value );
}; };
} else if ( key === "scope" ) {
var drop = $.ui.ddmanager.droppables[ this.options.scope ];
this._splice( drop );
this._addToManager( value );
} }
this._super( key, value ); this._super( key, value );
}, },
@ -204,7 +214,12 @@ $.widget( "ui.droppable", {
}); });
$.ui.intersect = function( draggable, droppable, toleranceMode ) { $.ui.intersect = (function() {
function isOverAxis( x, reference, size ) {
return ( x >= reference ) && ( x < ( reference + size ) );
}
return function( draggable, droppable, toleranceMode ) {
if ( !droppable.offset ) { if ( !droppable.offset ) {
return false; return false;
@ -245,8 +260,8 @@ $.ui.intersect = function( draggable, droppable, toleranceMode ) {
default: default:
return false; return false;
} }
};
}; })();
/* /*
This manager tracks offsets of draggables and droppables This manager tracks offsets of draggables and droppables

View File

@ -13,12 +13,11 @@
*/ */
(function( $, undefined ) { (function( $, undefined ) {
var rvertical = /up|down|vertical/,
rpositivemotion = /up|left|vertical|horizontal/;
$.effects.effect.blind = function( o, done ) { $.effects.effect.blind = function( o, done ) {
// Create element // Create element
var el = $( this ), var el = $( this ),
rvertical = /up|down|vertical/,
rpositivemotion = /up|left|vertical|horizontal/,
props = [ "position", "top", "bottom", "left", "right", "height", "width" ], props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
mode = $.effects.setMode( el, o.mode || "hide" ), mode = $.effects.setMode( el, o.mode || "hide" ),
direction = o.direction || "up", direction = o.direction || "up",
@ -76,7 +75,6 @@ $.effects.effect.blind = function( o, done ) {
done(); done();
} }
}); });
}; };
})(jQuery); })(jQuery);

11
ui/jquery.ui.menu.js vendored
View File

@ -26,7 +26,7 @@ $.widget( "ui.menu", {
items: "> *", items: "> *",
menus: "ul", menus: "ul",
position: { position: {
my: "left top", my: "left-1 top",
at: "right top" at: "right top"
}, },
role: "menu", role: "menu",
@ -44,7 +44,7 @@ $.widget( "ui.menu", {
this.mouseHandled = false; this.mouseHandled = false;
this.element this.element
.uniqueId() .uniqueId()
.addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" ) .addClass( "ui-menu ui-widget ui-widget-content" )
.toggleClass( "ui-menu-icons", !!this.element.find( ".ui-icon" ).length ) .toggleClass( "ui-menu-icons", !!this.element.find( ".ui-icon" ).length )
.attr({ .attr({
role: this.options.role, role: this.options.role,
@ -147,7 +147,7 @@ $.widget( "ui.menu", {
this.element this.element
.removeAttr( "aria-activedescendant" ) .removeAttr( "aria-activedescendant" )
.find( ".ui-menu" ).addBack() .find( ".ui-menu" ).addBack()
.removeClass( "ui-menu ui-widget ui-widget-content ui-corner-all ui-menu-icons" ) .removeClass( "ui-menu ui-widget ui-widget-content ui-menu-icons" )
.removeAttr( "role" ) .removeAttr( "role" )
.removeAttr( "tabIndex" ) .removeAttr( "tabIndex" )
.removeAttr( "aria-labelledby" ) .removeAttr( "aria-labelledby" )
@ -163,7 +163,7 @@ $.widget( "ui.menu", {
.removeAttr( "role" ) .removeAttr( "role" )
.removeAttr( "aria-disabled" ) .removeAttr( "aria-disabled" )
.removeUniqueId() .removeUniqueId()
.removeClass( "ui-corner-all ui-state-hover" ) .removeClass( "ui-state-hover" )
.removeAttr( "tabIndex" ) .removeAttr( "tabIndex" )
.removeAttr( "role" ) .removeAttr( "role" )
.removeAttr( "aria-haspopup" ) .removeAttr( "aria-haspopup" )
@ -292,7 +292,7 @@ $.widget( "ui.menu", {
// Initialize nested menus // Initialize nested menus
submenus.filter( ":not(.ui-menu)" ) submenus.filter( ":not(.ui-menu)" )
.addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" ) .addClass( "ui-menu ui-widget ui-widget-content" )
.hide() .hide()
.attr({ .attr({
role: this.options.role, role: this.options.role,
@ -328,7 +328,6 @@ $.widget( "ui.menu", {
items.not( ".ui-menu-item, .ui-menu-divider" ) items.not( ".ui-menu-item, .ui-menu-divider" )
.addClass( "ui-menu-item" ) .addClass( "ui-menu-item" )
.uniqueId() .uniqueId()
.addClass( "ui-corner-all" )
.attr({ .attr({
tabIndex: -1, tabIndex: -1,
role: this._itemRole() role: this._itemRole()

View File

@ -9,6 +9,7 @@
* http://api.jqueryui.com/position/ * http://api.jqueryui.com/position/
*/ */
(function( $, undefined ) { (function( $, undefined ) {
(function() {
$.ui = $.ui || {}; $.ui = $.ui || {};
@ -494,4 +495,5 @@ $.ui.position = {
testElementParent.removeChild( testElement ); testElementParent.removeChild( testElement );
})(); })();
})();
}( jQuery ) ); }( jQuery ) );

View File

@ -15,37 +15,6 @@
*/ */
(function( $, undefined ) { (function( $, undefined ) {
function num(v) {
return parseInt(v, 10) || 0;
}
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, { $.widget("ui.resizable", $.ui.mouse, {
version: "@VERSION", version: "@VERSION",
widgetEventPrefix: "resize", widgetEventPrefix: "resize",
@ -73,6 +42,38 @@ $.widget("ui.resizable", $.ui.mouse, {
start: null, start: null,
stop: null stop: null
}, },
_num: function( value ) {
return parseInt( value, 10 ) || 0;
},
_isNumber: function( value ) {
return !isNaN( parseInt( value , 10 ) );
},
_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;
}
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;
},
_create: function() { _create: function() {
var n, i, handle, axis, hname, var n, i, handle, axis, hname,
@ -305,8 +306,8 @@ $.widget("ui.resizable", $.ui.mouse, {
this._renderProxy(); this._renderProxy();
curleft = num(this.helper.css("left")); curleft = this._num(this.helper.css("left"));
curtop = num(this.helper.css("top")); curtop = this._num(this.helper.css("top"));
if (o.containment) { if (o.containment) {
curleft += $(o.containment).scrollLeft() || 0; curleft += $(o.containment).scrollLeft() || 0;
@ -404,7 +405,7 @@ $.widget("ui.resizable", $.ui.mouse, {
pr = this._proportionallyResizeElements; pr = this._proportionallyResizeElements;
ista = pr.length && (/textarea/i).test(pr[0].nodeName); ista = pr.length && (/textarea/i).test(pr[0].nodeName);
soffseth = ista && hasScroll(pr[0], "left") /* TODO - jump height */ ? 0 : that.sizeDiff.height; soffseth = ista && this._hasScroll(pr[0], "left") /* TODO - jump height */ ? 0 : that.sizeDiff.height;
soffsetw = ista ? 0 : that.sizeDiff.width; soffsetw = ista ? 0 : that.sizeDiff.width;
s = { width: (that.helper.width() - soffsetw), height: (that.helper.height() - soffseth) }; s = { width: (that.helper.width() - soffsetw), height: (that.helper.height() - soffseth) };
@ -442,10 +443,10 @@ $.widget("ui.resizable", $.ui.mouse, {
o = this.options; o = this.options;
b = { b = {
minWidth: isNumber(o.minWidth) ? o.minWidth : 0, minWidth: this._isNumber(o.minWidth) ? o.minWidth : 0,
maxWidth: isNumber(o.maxWidth) ? o.maxWidth : Infinity, maxWidth: this._isNumber(o.maxWidth) ? o.maxWidth : Infinity,
minHeight: isNumber(o.minHeight) ? o.minHeight : 0, minHeight: this._isNumber(o.minHeight) ? o.minHeight : 0,
maxHeight: isNumber(o.maxHeight) ? o.maxHeight : Infinity maxHeight: this._isNumber(o.maxHeight) ? o.maxHeight : Infinity
}; };
if(this._aspectRatio || forceAspectRatio) { if(this._aspectRatio || forceAspectRatio) {
@ -474,16 +475,16 @@ $.widget("ui.resizable", $.ui.mouse, {
_updateCache: function(data) { _updateCache: function(data) {
this.offset = this.helper.offset(); this.offset = this.helper.offset();
if (isNumber(data.left)) { if (this._isNumber(data.left)) {
this.position.left = data.left; this.position.left = data.left;
} }
if (isNumber(data.top)) { if (this._isNumber(data.top)) {
this.position.top = data.top; this.position.top = data.top;
} }
if (isNumber(data.height)) { if (this._isNumber(data.height)) {
this.size.height = data.height; this.size.height = data.height;
} }
if (isNumber(data.width)) { if (this._isNumber(data.width)) {
this.size.width = data.width; this.size.width = data.width;
} }
}, },
@ -494,9 +495,9 @@ $.widget("ui.resizable", $.ui.mouse, {
csize = this.size, csize = this.size,
a = this.axis; a = this.axis;
if (isNumber(data.height)) { if (this._isNumber(data.height)) {
data.width = (data.height * this.aspectRatio); data.width = (data.height * this.aspectRatio);
} else if (isNumber(data.width)) { } else if (this._isNumber(data.width)) {
data.height = (data.width / this.aspectRatio); data.height = (data.width / this.aspectRatio);
} }
@ -516,8 +517,8 @@ $.widget("ui.resizable", $.ui.mouse, {
var o = this._vBoundaries, var o = this._vBoundaries,
a = this.axis, a = this.axis,
ismaxw = isNumber(data.width) && o.maxWidth && (o.maxWidth < data.width), ismaxh = isNumber(data.height) && o.maxHeight && (o.maxHeight < data.height), ismaxw = this._isNumber(data.width) && o.maxWidth && (o.maxWidth < data.width), ismaxh = this._isNumber(data.height) && o.maxHeight && (o.maxHeight < data.height),
isminw = isNumber(data.width) && o.minWidth && (o.minWidth > data.width), isminh = isNumber(data.height) && o.minHeight && (o.minHeight > data.height), isminw = this._isNumber(data.width) && o.minWidth && (o.minWidth > data.width), isminh = this._isNumber(data.height) && o.minHeight && (o.minHeight > data.height),
dw = this.originalPosition.left + this.originalSize.width, dw = this.originalPosition.left + this.originalSize.width,
dh = this.position.top + this.size.height, dh = this.position.top + this.size.height,
cw = /sw|nw|w/.test(a), ch = /nw|ne|n/.test(a); cw = /sw|nw|w/.test(a), ch = /nw|ne|n/.test(a);
@ -678,7 +679,7 @@ $.ui.plugin.add("resizable", "animate", {
o = that.options, o = that.options,
pr = that._proportionallyResizeElements, pr = that._proportionallyResizeElements,
ista = pr.length && (/textarea/i).test(pr[0].nodeName), ista = pr.length && (/textarea/i).test(pr[0].nodeName),
soffseth = ista && hasScroll(pr[0], "left") /* TODO - jump height */ ? 0 : that.sizeDiff.height, soffseth = ista && that._hasScroll(pr[0], "left") /* TODO - jump height */ ? 0 : that.sizeDiff.height,
soffsetw = ista ? 0 : that.sizeDiff.width, 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 = (parseInt(that.element.css("left"), 10) + (that.position.left - that.originalPosition.left)) || null, left = (parseInt(that.element.css("left"), 10) + (that.position.left - that.originalPosition.left)) || null,
@ -742,7 +743,7 @@ $.ui.plugin.add("resizable", "containment", {
else { else {
element = $(ce); element = $(ce);
p = []; p = [];
$([ "Top", "Right", "Left", "Bottom" ]).each(function(i, name) { p[i] = num(element.css("padding" + name)); }); $([ "Top", "Right", "Left", "Bottom" ]).each(function(i, name) { p[i] = that._num(element.css("padding" + name)); });
that.containerOffset = element.offset(); that.containerOffset = element.offset();
that.containerPosition = element.position(); that.containerPosition = element.position();
@ -751,8 +752,8 @@ $.ui.plugin.add("resizable", "containment", {
co = that.containerOffset; co = that.containerOffset;
ch = that.containerSize.height; ch = that.containerSize.height;
cw = that.containerSize.width; cw = that.containerSize.width;
width = (hasScroll(ce, "left") ? ce.scrollWidth : cw ); width = (that._hasScroll(ce, "left") ? ce.scrollWidth : cw );
height = (hasScroll(ce) ? ce.scrollHeight : ch); height = (that._hasScroll(ce) ? ce.scrollHeight : ch);
that.parentData = { that.parentData = {
element: ce, left: co.left, top: co.top, width: width, height: height element: ce, left: co.left, top: co.top, width: width, height: height

View File

@ -15,10 +15,6 @@
*/ */
(function( $, undefined ) { (function( $, undefined ) {
// number of pages in a slider
// (how many times can you page up/down to go through the whole range)
var numPages = 5;
$.widget( "ui.slider", $.ui.mouse, { $.widget( "ui.slider", $.ui.mouse, {
version: "@VERSION", version: "@VERSION",
widgetEventPrefix: "slide", widgetEventPrefix: "slide",
@ -41,6 +37,10 @@ $.widget( "ui.slider", $.ui.mouse, {
stop: null stop: null
}, },
// number of pages in a slider
// (how many times can you page up/down to go through the whole range)
numPages: 5,
_create: function() { _create: function() {
this._keySliding = false; this._keySliding = false;
this._mouseSliding = false; this._mouseSliding = false;
@ -637,10 +637,13 @@ $.widget( "ui.slider", $.ui.mouse, {
newVal = this._valueMax(); newVal = this._valueMax();
break; break;
case $.ui.keyCode.PAGE_UP: case $.ui.keyCode.PAGE_UP:
newVal = this._trimAlignValue( curVal + ( (this._valueMax() - this._valueMin()) / numPages ) ); newVal = this._trimAlignValue(
curVal + ( ( this._valueMax() - this._valueMin() ) / this.numPages )
);
break; break;
case $.ui.keyCode.PAGE_DOWN: case $.ui.keyCode.PAGE_DOWN:
newVal = this._trimAlignValue( curVal - ( (this._valueMax() - this._valueMin()) / numPages ) ); newVal = this._trimAlignValue(
curVal - ( (this._valueMax() - this._valueMin()) / this.numPages ) );
break; break;
case $.ui.keyCode.UP: case $.ui.keyCode.UP:
case $.ui.keyCode.RIGHT: case $.ui.keyCode.RIGHT:
@ -674,7 +677,6 @@ $.widget( "ui.slider", $.ui.mouse, {
} }
} }
} }
}); });
}(jQuery)); }(jQuery));

View File

@ -15,14 +15,6 @@
*/ */
(function( $, undefined ) { (function( $, undefined ) {
function isOverAxis( x, reference, size ) {
return ( x >= reference ) && ( x < ( reference + size ) );
}
function isFloating(item) {
return (/left|right/).test(item.css("float")) || (/inline|table-cell/).test(item.css("display"));
}
$.widget("ui.sortable", $.ui.mouse, { $.widget("ui.sortable", $.ui.mouse, {
version: "@VERSION", version: "@VERSION",
widgetEventPrefix: "sort", widgetEventPrefix: "sort",
@ -65,6 +57,15 @@ $.widget("ui.sortable", $.ui.mouse, {
stop: null, stop: null,
update: null update: null
}, },
_isOverAxis: function( x, reference, size ) {
return ( x >= reference ) && ( x < ( reference + size ) );
},
_isFloating: function( item ) {
return (/left|right/).test(item.css("float")) || (/inline|table-cell/).test(item.css("display"));
},
_create: function() { _create: function() {
var o = this.options; var o = this.options;
@ -75,7 +76,7 @@ $.widget("ui.sortable", $.ui.mouse, {
this.refresh(); this.refresh();
//Let's determine if the items are being displayed horizontally //Let's determine if the items are being displayed horizontally
this.floating = this.items.length ? o.axis === "x" || isFloating(this.items[0].item) : false; this.floating = this.items.length ? o.axis === "x" || this._isFloating(this.items[0].item) : false;
//Let's determine the parent's offset //Let's determine the parent's offset
this.offset = this.element.offset(); this.offset = this.element.offset();
@ -554,8 +555,8 @@ $.widget("ui.sortable", $.ui.mouse, {
_intersectsWithPointer: function(item) { _intersectsWithPointer: function(item) {
var isOverElementHeight = (this.options.axis === "x") || isOverAxis(this.positionAbs.top + this.offset.click.top, item.top, item.height), var isOverElementHeight = (this.options.axis === "x") || this._isOverAxis(this.positionAbs.top + this.offset.click.top, item.top, item.height),
isOverElementWidth = (this.options.axis === "y") || isOverAxis(this.positionAbs.left + this.offset.click.left, item.left, item.width), isOverElementWidth = (this.options.axis === "y") || this._isOverAxis(this.positionAbs.left + this.offset.click.left, item.left, item.width),
isOverElement = isOverElementHeight && isOverElementWidth, isOverElement = isOverElementHeight && isOverElementWidth,
verticalDirection = this._getDragVerticalDirection(), verticalDirection = this._getDragVerticalDirection(),
horizontalDirection = this._getDragHorizontalDirection(); horizontalDirection = this._getDragHorizontalDirection();
@ -572,8 +573,8 @@ $.widget("ui.sortable", $.ui.mouse, {
_intersectsWithSides: function(item) { _intersectsWithSides: function(item) {
var isOverBottomHalf = isOverAxis(this.positionAbs.top + this.offset.click.top, item.top + (item.height/2), item.height), var isOverBottomHalf = this._isOverAxis(this.positionAbs.top + this.offset.click.top, item.top + (item.height/2), item.height),
isOverRightHalf = isOverAxis(this.positionAbs.left + this.offset.click.left, item.left + (item.width/2), item.width), isOverRightHalf = this._isOverAxis(this.positionAbs.left + this.offset.click.left, item.left + (item.width/2), item.width),
verticalDirection = this._getDragVerticalDirection(), verticalDirection = this._getDragVerticalDirection(),
horizontalDirection = this._getDragHorizontalDirection(); horizontalDirection = this._getDragHorizontalDirection();
@ -798,7 +799,7 @@ $.widget("ui.sortable", $.ui.mouse, {
}, },
_contactContainers: function(event) { _contactContainers: function(event) {
var i, j, dist, itemWithLeastDistance, posProperty, sizeProperty, base, cur, nearBottom, floating, var i, j, dist, itemWithLeastDistance, posProperty, sizeProperty, cur, nearBottom, floating, axis,
innermostContainer = null, innermostContainer = null,
innermostIndex = null; innermostIndex = null;
@ -846,10 +847,11 @@ $.widget("ui.sortable", $.ui.mouse, {
//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; dist = 10000;
itemWithLeastDistance = null; itemWithLeastDistance = null;
floating = innermostContainer.floating || isFloating(this.currentItem); floating = innermostContainer.floating || this._isFloating(this.currentItem);
posProperty = floating ? "left" : "top"; posProperty = floating ? "left" : "top";
sizeProperty = floating ? "width" : "height"; sizeProperty = floating ? "width" : "height";
base = this.positionAbs[posProperty] + this.offset.click[posProperty]; axis = floating ? "clientX" : "clientY";
for (j = this.items.length - 1; j >= 0; j--) { 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; continue;
@ -857,18 +859,16 @@ $.widget("ui.sortable", $.ui.mouse, {
if(this.items[j].item[0] === this.currentItem[0]) { if(this.items[j].item[0] === this.currentItem[0]) {
continue; continue;
} }
if (floating && !isOverAxis(this.positionAbs.top + this.offset.click.top, this.items[j].top, this.items[j].height)) {
continue;
}
cur = this.items[j].item.offset()[posProperty]; cur = this.items[j].item.offset()[posProperty];
nearBottom = false; nearBottom = false;
if(Math.abs(cur - base) > Math.abs(cur + this.items[j][sizeProperty] - base)){ if ( event[ axis ] - cur > this.items[ j ][ sizeProperty ] / 2 ) {
nearBottom = true; nearBottom = true;
cur += this.items[j][sizeProperty];
} }
if(Math.abs(cur - base) < dist) { if ( Math.abs( event[ axis ] - cur ) < dist ) {
dist = Math.abs(cur - base); itemWithLeastDistance = this.items[j]; dist = Math.abs( event[ axis ] - cur );
itemWithLeastDistance = this.items[ j ];
this.direction = nearBottom ? "up": "down"; this.direction = nearBottom ? "up": "down";
} }
} }

View File

@ -15,7 +15,7 @@
*/ */
(function( $ ) { (function( $ ) {
function modifier( fn ) { function spinner_modifier( fn ) {
return function() { return function() {
var previous = this.element.val(); var previous = this.element.val();
fn.apply( this, arguments ); fn.apply( this, arguments );
@ -391,7 +391,7 @@ $.widget( "ui.spinner", {
} }
}, },
_setOptions: modifier(function( options ) { _setOptions: spinner_modifier(function( options ) {
this._super( options ); this._super( options );
this._value( this.element.val() ); this._value( this.element.val() );
}), }),
@ -462,7 +462,7 @@ $.widget( "ui.spinner", {
this.uiSpinner.replaceWith( this.element ); this.uiSpinner.replaceWith( this.element );
}, },
stepUp: modifier(function( steps ) { stepUp: spinner_modifier(function( steps ) {
this._stepUp( steps ); this._stepUp( steps );
}), }),
_stepUp: function( steps ) { _stepUp: function( steps ) {
@ -472,7 +472,7 @@ $.widget( "ui.spinner", {
} }
}, },
stepDown: modifier(function( steps ) { stepDown: spinner_modifier(function( steps ) {
this._stepDown( steps ); this._stepDown( steps );
}), }),
_stepDown: function( steps ) { _stepDown: function( steps ) {
@ -482,11 +482,11 @@ $.widget( "ui.spinner", {
} }
}, },
pageUp: modifier(function( pages ) { pageUp: spinner_modifier(function( pages ) {
this._stepUp( (pages || 1) * this.options.page ); this._stepUp( (pages || 1) * this.options.page );
}), }),
pageDown: modifier(function( pages ) { pageDown: spinner_modifier(function( pages ) {
this._stepDown( (pages || 1) * this.options.page ); this._stepDown( (pages || 1) * this.options.page );
}), }),
@ -494,7 +494,7 @@ $.widget( "ui.spinner", {
if ( !arguments.length ) { if ( !arguments.length ) {
return this._parse( this.element.val() ); return this._parse( this.element.val() );
} }
modifier( this._value ).call( this, newVal ); spinner_modifier( this._value ).call( this, newVal );
}, },
widget: function() { widget: function() {

57
ui/jquery.ui.tabs.js vendored
View File

@ -14,23 +14,6 @@
*/ */
(function( $, undefined ) { (function( $, undefined ) {
var tabId = 0,
rhash = /#.*$/;
function getNextTabId() {
return ++tabId;
}
function isLocal( anchor ) {
// support: IE7
// IE7 doesn't normalize the href property when set via script (#9317)
anchor = anchor.cloneNode( false );
return anchor.hash.length > 1 &&
decodeURIComponent( anchor.href.replace( rhash, "" ) ) ===
decodeURIComponent( location.href.replace( rhash, "" ) );
}
$.widget( "ui.tabs", { $.widget( "ui.tabs", {
version: "@VERSION", version: "@VERSION",
delay: 300, delay: 300,
@ -49,6 +32,31 @@ $.widget( "ui.tabs", {
load: null load: null
}, },
_isLocal: (function() {
var rhash = /#.*$/;
return function( anchor ) {
var anchorUrl, locationUrl;
// support: IE7
// IE7 doesn't normalize the href property when set via script (#9317)
anchor = anchor.cloneNode( false );
anchorUrl = anchor.href.replace( rhash, "" );
locationUrl = location.href.replace( rhash, "" );
// decoding may throw an error if the URL isn't UTF-8 (#9518)
try {
anchorUrl = decodeURIComponent( anchorUrl );
} catch ( error ) {}
try {
locationUrl = decodeURIComponent( locationUrl );
} catch ( error ) {}
return anchor.hash.length > 1 && anchorUrl === locationUrl;
};
})(),
_create: function() { _create: function() {
var that = this, var that = this,
options = this.options; options = this.options;
@ -296,10 +304,6 @@ $.widget( "ui.tabs", {
} }
}, },
_tabId: function( tab ) {
return tab.attr( "aria-controls" ) || "ui-tabs-" + getNextTabId();
},
_sanitizeSelector: function( hash ) { _sanitizeSelector: function( hash ) {
return hash ? hash.replace( /[!"$%&'()*+,.\/:;<=>?@\[\]\^`{|}~]/g, "\\$&" ) : ""; return hash ? hash.replace( /[!"$%&'()*+,.\/:;<=>?@\[\]\^`{|}~]/g, "\\$&" ) : "";
}, },
@ -406,12 +410,15 @@ $.widget( "ui.tabs", {
originalAriaControls = tab.attr( "aria-controls" ); originalAriaControls = tab.attr( "aria-controls" );
// inline tab // inline tab
if ( isLocal( anchor ) ) { if ( that._isLocal( anchor ) ) {
selector = anchor.hash; selector = anchor.hash;
panelId = selector.substring( 1 );
panel = that.element.find( that._sanitizeSelector( selector ) ); panel = that.element.find( that._sanitizeSelector( selector ) );
// remote tab // remote tab
} else { } else {
panelId = that._tabId( tab ); // If the tab doesn't already have aria-controls,
// generate an id by using a throw-away element
panelId = tab.attr( "aria-controls" ) || $( {} ).uniqueId()[ 0 ].id;
selector = "#" + panelId; selector = "#" + panelId;
panel = that.element.find( selector ); panel = that.element.find( selector );
if ( !panel.length ) { if ( !panel.length ) {
@ -428,7 +435,7 @@ $.widget( "ui.tabs", {
tab.data( "ui-tabs-aria-controls", originalAriaControls ); tab.data( "ui-tabs-aria-controls", originalAriaControls );
} }
tab.attr({ tab.attr({
"aria-controls": selector.substring( 1 ), "aria-controls": panelId,
"aria-labelledby": anchorId "aria-labelledby": anchorId
}); });
panel.attr( "aria-labelledby", anchorId ); panel.attr( "aria-labelledby", anchorId );
@ -790,7 +797,7 @@ $.widget( "ui.tabs", {
}; };
// not remote // not remote
if ( isLocal( anchor[ 0 ] ) ) { if ( this._isLocal( anchor[ 0 ] ) ) {
return; return;
} }

View File

@ -15,33 +15,6 @@
*/ */
(function( $ ) { (function( $ ) {
var increments = 0;
function addDescribedBy( elem, id ) {
var describedby = (elem.attr( "aria-describedby" ) || "").split( /\s+/ );
describedby.push( id );
elem
.data( "ui-tooltip-id", id )
.attr( "aria-describedby", $.trim( describedby.join( " " ) ) );
}
function removeDescribedBy( elem ) {
var id = elem.data( "ui-tooltip-id" ),
describedby = (elem.attr( "aria-describedby" ) || "").split( /\s+/ ),
index = $.inArray( id, describedby );
if ( index !== -1 ) {
describedby.splice( index, 1 );
}
elem.removeData( "ui-tooltip-id" );
describedby = $.trim( describedby.join( " " ) );
if ( describedby ) {
elem.attr( "aria-describedby", describedby );
} else {
elem.removeAttr( "aria-describedby" );
}
}
$.widget( "ui.tooltip", { $.widget( "ui.tooltip", {
version: "@VERSION", version: "@VERSION",
options: { options: {
@ -69,6 +42,32 @@ $.widget( "ui.tooltip", {
open: null open: null
}, },
_addDescribedBy: function( elem, id ) {
var describedby = (elem.attr( "aria-describedby" ) || "").split( /\s+/ );
describedby.push( id );
elem
.data( "ui-tooltip-id", id )
.attr( "aria-describedby", $.trim( describedby.join( " " ) ) );
},
_removeDescribedBy: function( elem ) {
var id = elem.data( "ui-tooltip-id" ),
describedby = (elem.attr( "aria-describedby" ) || "").split( /\s+/ ),
index = $.inArray( id, describedby );
if ( index !== -1 ) {
describedby.splice( index, 1 );
}
elem.removeData( "ui-tooltip-id" );
describedby = $.trim( describedby.join( " " ) );
if ( describedby ) {
elem.attr( "aria-describedby", describedby );
} else {
elem.removeAttr( "aria-describedby" );
}
},
_create: function() { _create: function() {
this._on({ this._on({
mouseover: "open", mouseover: "open",
@ -243,7 +242,7 @@ $.widget( "ui.tooltip", {
} }
tooltip = this._tooltip( target ); tooltip = this._tooltip( target );
addDescribedBy( target, tooltip.attr( "id" ) ); this._addDescribedBy( target, tooltip.attr( "id" ) );
tooltip.find( ".ui-tooltip-content" ).html( content ); tooltip.find( ".ui-tooltip-content" ).html( content );
function position( event ) { function position( event ) {
@ -322,7 +321,7 @@ $.widget( "ui.tooltip", {
target.attr( "title", target.data( "ui-tooltip-title" ) ); target.attr( "title", target.data( "ui-tooltip-title" ) );
} }
removeDescribedBy( target ); this._removeDescribedBy( target );
tooltip.stop( true ); tooltip.stop( true );
this._hide( tooltip, this.options.hide, function() { this._hide( tooltip, this.options.hide, function() {
@ -350,17 +349,16 @@ $.widget( "ui.tooltip", {
}, },
_tooltip: function( element ) { _tooltip: function( element ) {
var id = "ui-tooltip-" + increments++, var tooltip = $( "<div>" )
tooltip = $( "<div>" ) .attr( "role", "tooltip" )
.attr({
id: id,
role: "tooltip"
})
.addClass( "ui-tooltip ui-widget ui-corner-all ui-widget-content " + .addClass( "ui-tooltip ui-widget ui-corner-all ui-widget-content " +
( this.options.tooltipClass || "" ) ); ( this.options.tooltipClass || "" ) ),
id = tooltip.uniqueId().attr( "id" );
$( "<div>" ) $( "<div>" )
.addClass( "ui-tooltip-content" ) .addClass( "ui-tooltip-content" )
.appendTo( tooltip ); .appendTo( tooltip );
tooltip.appendTo( this.document[0].body ); tooltip.appendTo( this.document[0].body );
this.tooltips[ id ] = element; this.tooltips[ id ] = element;
return tooltip; return tooltip;

View File

@ -10,18 +10,20 @@
*/ */
(function( $, undefined ) { (function( $, undefined ) {
var uuid = 0, var widget_uuid = 0,
slice = Array.prototype.slice, widget_slice = Array.prototype.slice;
_cleanData = $.cleanData;
$.cleanData = function( elems ) { $.cleanData = (function( orig ) {
return function( elems ) {
for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) { for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
try { try {
$( elem ).triggerHandler( "remove" ); $( elem ).triggerHandler( "remove" );
// http://bugs.jquery.com/ticket/8235 // http://bugs.jquery.com/ticket/8235
} catch( e ) {} } catch( e ) {}
} }
_cleanData( elems ); orig( elems );
}; };
})( $.cleanData );
$.widget = function( name, base, prototype ) { $.widget = function( name, base, prototype ) {
var fullName, existingConstructor, constructor, basePrototype, var fullName, existingConstructor, constructor, basePrototype,
@ -139,7 +141,7 @@ $.widget = function( name, base, prototype ) {
}; };
$.widget.extend = function( target ) { $.widget.extend = function( target ) {
var input = slice.call( arguments, 1 ), var input = widget_slice.call( arguments, 1 ),
inputIndex = 0, inputIndex = 0,
inputLength = input.length, inputLength = input.length,
key, key,
@ -168,7 +170,7 @@ $.widget.bridge = function( name, object ) {
var fullName = object.prototype.widgetFullName || name; var fullName = object.prototype.widgetFullName || name;
$.fn[ name ] = function( options ) { $.fn[ name ] = function( options ) {
var isMethodCall = typeof options === "string", var isMethodCall = typeof options === "string",
args = slice.call( arguments, 1 ), args = widget_slice.call( arguments, 1 ),
returnValue = this; returnValue = this;
// allow multiple hashes to be passed on init // allow multiple hashes to be passed on init
@ -233,7 +235,7 @@ $.Widget.prototype = {
_createWidget: function( options, element ) { _createWidget: function( options, element ) {
element = $( element || this.defaultElement || this )[ 0 ]; element = $( element || this.defaultElement || this )[ 0 ];
this.element = $( element ); this.element = $( element );
this.uuid = uuid++; this.uuid = widget_uuid++;
this.eventNamespace = "." + this.widgetName + this.uuid; this.eventNamespace = "." + this.widgetName + this.uuid;
this.options = $.widget.extend( {}, this.options = $.widget.extend( {},
this.options, this.options,