Merge branch 'master' into tooltip

This commit is contained in:
jzaefferer 2010-03-26 12:45:32 -04:00
commit f1933142e4
14 changed files with 547 additions and 32 deletions

View File

@ -1,8 +1,8 @@
jQuery UI Authors (http://ui.jquery.com/about)
jQuery UI Authors (http://jqueryui.com/about)
This software consists of voluntary contributions made by many
individuals. For exact contribution history, see the revision history
and logs, available at http://jquery-ui.googlecode.com/svn/
and logs, available at http://github.com/jquery/jquery-ui
Brandon Aaron
Paul Bakaus (paulbakaus.com)

View File

@ -33,7 +33,7 @@
if (!request.term || matcher.test(text))
return {
id: $(this).val(),
label: text.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)(" + request.term.replace(/([\^\$\(\)\[\]\{\}\*\.\+\?\|\\])/gi, "\\$1") + ")(?![^<>]*>)(?![^&;]+;)", "gi"), "<strong>$1</strong>"),
label: text.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)(" + $.ui.autocomplete.escapeRegex(request.term) + ")(?![^<>]*>)(?![^&;]+;)", "gi"), "<strong>$1</strong>"),
value: text
};
}));

View File

@ -18,7 +18,6 @@
}
$("#birds").autocomplete({
// TODO doesn't work when loaded from /demos/#autocomplete|remote
source: "search.php",
minLength: 2,
select: function(event, ui) {

46
external/qunit.js vendored
View File

@ -18,6 +18,7 @@ var QUnit = {
stats: { all: 0, bad: 0 },
moduleStats: { all: 0, bad: 0 },
started: +new Date,
updateRate: 1000,
blocking: false,
autorun: false,
assertions: [],
@ -590,8 +591,16 @@ function synchronize( callback ) {
}
function process() {
var start = (new Date()).getTime();
while ( config.queue.length && !config.blocking ) {
config.queue.shift()();
if ( config.updateRate <= 0 || (((new Date()).getTime() - start) < config.updateRate) ) {
config.queue.shift()();
} else {
setTimeout( process, 13 );
break;
}
}
}
@ -679,6 +688,7 @@ QUnit.equiv = function () {
var innerEquiv; // the real equiv function
var callers = []; // stack to decide between skip/abort functions
var parents = []; // stack to avoiding loops from circular referencing
// Determine what is o.
@ -788,28 +798,39 @@ QUnit.equiv = function () {
},
"array": function (b, a) {
var i;
var i, j, loop;
var len;
// b could be an object literal here
if ( ! (hoozit(b) === "array")) {
return false;
}
}
len = a.length;
if (len !== b.length) { // safe and faster
return false;
}
//track reference to avoid circular references
parents.push(a);
for (i = 0; i < len; i++) {
if ( ! innerEquiv(a[i], b[i])) {
loop = false;
for(j=0;j<parents.length;j++){
if(parents[j] === a[i]){
loop = true;//dont rewalk array
}
}
if (!loop && ! innerEquiv(a[i], b[i])) {
parents.pop();
return false;
}
}
parents.pop();
return true;
},
"object": function (b, a) {
var i;
var i, j, loop;
var eq = true; // unless we can proove it
var aProperties = [], bProperties = []; // collection of strings
@ -820,18 +841,25 @@ QUnit.equiv = function () {
// stack constructor before traversing properties
callers.push(a.constructor);
//track reference to avoid circular references
parents.push(a);
for (i in a) { // be strict: don't ensures hasOwnProperty and go deep
loop = false;
for(j=0;j<parents.length;j++){
if(parents[j] === a[i])
loop = true; //don't go down the same path twice
}
aProperties.push(i); // collect a's properties
if ( ! innerEquiv(a[i], b[i])) {
if (!loop && ! innerEquiv(a[i], b[i])) {
eq = false;
break;
}
}
callers.pop(); // unstack, we are done
parents.pop();
for (i in b) {
bProperties.push(i); // collect b's properties

View File

@ -11,6 +11,7 @@
<link rel="stylesheet" href="../../../external/qunit.css" type="text/css"/>
<script type="text/javascript" src="../../../external/qunit.js"></script>
<script type="text/javascript" src="../../jquery.simulate.js"></script>
<script type="text/javascript" src="../testsuite.js"></script>
<script type="text/javascript" src="core.js"></script>
<script type="text/javascript" src="selector.js"></script>

View File

@ -45,5 +45,5 @@ function commonWidgetTests(widget, settings) {
if ( !url || url.indexOf("http") !== 0 ) {
return;
}
document.write("<scr" + "ipt src='http://testswarm.com/js/inject.js?" + (new Date).getTime() + "'></scr" + "ipt>");
document.write("<scr" + "ipt src='http://swarm.jquery.org/js/inject.js?" + (new Date).getTime() + "'></scr" + "ipt>");
})();

View File

@ -14,7 +14,7 @@
$.widget("ui.drilldown", {
_init: function() {
var self = this;
this.active = this.element;
this.active = this.element.find(">ul").attr("tabindex", 0);
// hide submenus and create indicator icons
this.element.find("ul").hide().prev("a").prepend('<span class="ui-icon ui-icon-carat-1-e"></span>').end().filter(":first").show();
@ -84,17 +84,21 @@
parent.parent().removeData("submenu");
submenu = submenu.data("submenu");
};
},
widget: function() {
return this.element.find(">ul");
}
});
var nestedmenu = $("#drilldown").drilldown({
var drilldown = $("#drilldown").drilldown({
selected: function(event, ui) {
$("#log").append("<div>Selected " + ui.item.text() + "</div>");
}
});
$().keydown(function(event) {
var menu = nestedmenu.data("drilldown").active.data("menu");
drilldown.drilldown("widget").keydown(function(event) {
var menu = drilldown.data("drilldown").active.data("menu");
if (menu.widget().is(":hidden"))
return;
event.stopPropagation();
@ -109,10 +113,10 @@
menu.previous();
break;
case $.ui.keyCode.LEFT:
nestedmenu.nestedmenu("up");
drilldown.drilldown("up");
break;
case $.ui.keyCode.RIGHT:
nestedmenu.nestedmenu("down");
drilldown.drilldown("down");
break;
case $.ui.keyCode.DOWN:
menu.next();
@ -121,11 +125,11 @@
case $.ui.keyCode.ENTER:
case $.ui.keyCode.TAB:
menu.select();
nestedmenu.nestedmenu("hide");
drilldown.drilldown("hide");
event.preventDefault();
break;
case $.ui.keyCode.ESCAPE:
nestedmenu.nestedmenu("hide");
drilldown.drilldown("hide");
break;
default:
clearTimeout(menu.filterTimer);

View File

@ -0,0 +1,235 @@
<!doctype html>
<html>
<head>
<title>Menu Visual Test: Default</title>
<link rel="stylesheet" href="../visual.css" type="text/css" />
<link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css" type="text/css" title="ui-theme" />
<script type="text/javascript" src="../../../jquery-1.4.2.js"></script>
<script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script>
<script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script>
<script type="text/javascript" src="../../../ui/jquery.ui.position.js"></script>
<script type="text/javascript" src="../../../ui/jquery.ui.button.js"></script>
<script type="text/javascript" src="../../../ui/jquery.ui.autocomplete.js"></script>
<script type="text/javascript">
$(function() {
$.widget("ui.drilldown", {
_init: function() {
var self = this;
this.active = this.element.find(">ul").attr("tabindex", 0);
// hide submenus and create indicator icons
this.element.find("ul").hide().prev("a").prepend('<span class="ui-icon ui-icon-carat-1-e"></span>').end().filter(":first").show();
this.element.find("ul").menu({
focus: function(event, ui) {
self.activeItem = ui.item;
},
selected: function(event, ui) {
if (this != self.active[0]) {
return;
}
var nested = $(">ul", ui.item);
if (nested.length) {
self._open(nested);
} else {
self.element.find("h3").text(ui.item.text());
self.options.selected.apply(this, arguments);
}
}
});
this.back = this.element.children(":last").button({
icons: {
primary: "ui-icon-carat-1-w"
}
}).click(function() {
self.up();
return false;
}).hide();
},
_open: function(submenu) {
this.active = submenu.show().css({
top: 0,
left: 0
}).position({
my: "left top",
at: "left top",
of: this.widget()
});
this.back.show();
},
up: function() {
if (this.active.parent()[0] == this.element[0]) {
return;
}
this.active.hide();
this.active = this.active.parent().parent().show();
if (!this.active.parent().parent().is(":ui-menu")) {
this.back.hide();
}
},
down: function(event) {
var nested = this.activeItem.find(">ul");
if (nested.length) {
this._open(nested);
nested.menu("activate", event, nested.children(":first"))
}
},
show: function() {
},
hide: function() {
},
widget: function() {
return this.element.find(">ul");
}
});
var drilldown = $("#drilldown").drilldown({
selected: function(event, ui) {
$("#log").append("<div>Selected " + ui.item.text() + "</div>");
}
});
drilldown.drilldown("widget").keydown(function(event) {
var menu = drilldown.data("drilldown").active.data("menu");
if (menu.widget().is(":hidden"))
return;
event.stopPropagation();
switch (event.keyCode) {
case $.ui.keyCode.PAGE_UP:
menu.previousPage();
break;
case $.ui.keyCode.PAGE_DOWN:
menu.nextPage();
break;
case $.ui.keyCode.UP:
menu.previous();
break;
case $.ui.keyCode.LEFT:
drilldown.drilldown("up");
break;
case $.ui.keyCode.RIGHT:
drilldown.drilldown("down");
break;
case $.ui.keyCode.DOWN:
menu.next();
event.preventDefault();
break;
case $.ui.keyCode.ENTER:
case $.ui.keyCode.TAB:
menu.select();
drilldown.drilldown("hide");
event.preventDefault();
break;
case $.ui.keyCode.ESCAPE:
drilldown.drilldown("hide", event);
break;
default:
clearTimeout(menu.filterTimer);
var prev = menu.previousFilter || "";
var character = String.fromCharCode(event.keyCode);
var skip = false;
if (character == prev) {
skip = true;
} else {
character = prev + character;
}
var match = menu.widget().children("li").filter(function() {
return new RegExp("^" + character, "i").test($("a", this).text());
});
var match = skip && match.index(menu.active.next()) != -1 ? match.next() : match;
if (!match.length) {
character = String.fromCharCode(event.keyCode);
match = menu.widget().children("li").filter(function() {
return new RegExp("^" + character, "i").test($(this).text());
});
}
if (match.length) {
menu.activate(event, match);
if (match.length > 1) {
menu.previousFilter = character;
menu.filterTimer = setTimeout(function() {
delete menu.previousFilter;
}, 1000);
} else {
delete menu.previousFilter;
}
} else {
delete menu.previousFilter;
}
}
});
});
</script>
<style>
body { font-size:62.5%; }
.ui-menu { width: 200px; height: 170px; }
.ui-menu .ui-menu { position: absolute; }
.ui-menu .ui-icon { float: right; }
</style>
</head>
<body>
<div id="drilldown">
<h3>Make a selection...</h3>
<ul>
<li>
<a href="#">Amsterdam</a>
<ul>
<li><a href="#">Aberdeen</a></li>
<li><a href="#">Ada</a></li>
<li>
<a href="#">Adamsville</a>
<ul>
<li><a href="#">Anaheim</a></li>
<li>
<a href="#">Cologne</a>
<ul>
<li><a href="#">Mberdeen</a></li>
<li><a href="#">Mda</a></li>
<li><a href="#">Mdamsville</a></li>
<li><a href="#">Mddyston</a></li>
<li><a href="#">Mmesville</a></li>
</ul>
</li>
<li><a href="#">Frankfurt</a></li>
</ul>
</li>
<li><a href="#">Addyston</a></li>
<li><a href="#">Amesville</a></li>
</ul>
</li>
<li><a href="#">Anaheim</a></li>
<li><a href="#">Cologne</a></li>
<li><a href="#">Frankfurt</a></li>
<li>
<a href="#">Magdeburg</a>
<ul>
<li><a href="#">Mberdeen</a></li>
<li><a href="#">Mda</a></li>
<li><a href="#">Mdamsville</a></li>
<li><a href="#">Mddyston</a></li>
<li><a href="#">Mmesville</a></li>
</ul>
</li>
<li><a href="#">Munich</a></li>
<li><a href="#">Utrecht</a></li>
<li><a href="#">Zurich</a></li>
</ul>
<a href="#">Go back</a>
</div>
<div class="ui-widget" style="margin-top:2em; font-family:Arial">
Log:
<div id="log" style="height: 400px; width: 300px; overflow: auto;" class="ui-widget-content"></div>
</div>
</body>
</html>

View File

@ -106,11 +106,16 @@
$("button").click(function(event) {
// TODO required to prevent the click handler below from handling this event
event.stopPropagation();
nestedmenu.nestedmenu("show").position({
my: "left top",
at: "right top",
of: event.pageX > 0 ? event : this
});
nestedmenu.nestedmenu("show")
.css({
top: 0,
left: 0
})
.position({
my: "left top",
at: "right top",
of: this
});
$(document).one("click", function() {
nestedmenu.nestedmenu("hide");
})

View File

@ -0,0 +1,236 @@
<!doctype html>
<html>
<head>
<title>Menu Visual Test: Default</title>
<link rel="stylesheet" href="../visual.css" type="text/css" />
<link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css" type="text/css" title="ui-theme" />
<script type="text/javascript" src="../../../jquery-1.4.2.js"></script>
<script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script>
<script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script>
<script type="text/javascript" src="../../../ui/jquery.ui.position.js"></script>
<script type="text/javascript" src="../../../ui/jquery.ui.autocomplete.js"></script>
<script type="text/javascript" src="../../../external/jquery.bgiframe-2.1.1.js"></script>
<script type="text/javascript" src="http://jqueryui.com/themeroller/themeswitchertool/"></script>
<script type="text/javascript">
$(function() {
$.fn.themeswitcher && $('<div/>').css({
position: "absolute",
right: 10,
top: 10
}).appendTo(document.body).themeswitcher();
$.widget("ui.nestedmenu", {
_init: function() {
var self = this;
this.active = this.element;
// hide submenus and create indicator icons
this.element.find("ul").hide().prev("a").prepend('<span class="ui-icon ui-icon-carat-1-e"></span>');
this.element.find("ul").andSelf().menu({
selected: this.options.selected,
focus: function(event, ui) {
self.active = ui.item.parent();
self.activeItem = ui.item;
ui.item.parent().find("ul").hide();
var nested = $(">ul", ui.item);
if (nested.length && /^mouse/.test(event.originalEvent.type)) {
self._open(nested);
}
}
})
},
_open: function(submenu) {
submenu.show().css({
top: 0,
left: 0
}).position({
my: "left top",
at: "right top",
of: this.activeItem
});
},
up: function(event) {
this.active = this.active.menu("deactivate").hide().parent().parent();
this.activeItem = this.active.data("menu").active;
},
down: function(event) {
var submenu = $(">ul", this.activeItem);
this._open(submenu, this.activeItem);
submenu.menu("activate", event, submenu.children(":first"));
},
show: function() {
this.active = this.element;
this.element.show();
},
hide: function() {
this.element.find("ul").andSelf().menu("deactivate").hide();
}
});
var nestedmenu = $("#menu").nestedmenu({
selected: function(event, ui) {
$("#log").append("<div>Selected " + ui.item.text() + "</div>");
}
}).hide();
$("button").click(function(event) {
// TODO required to prevent the click handler below from handling this event
event.stopPropagation();
nestedmenu.nestedmenu("show")
.css({
top: 0,
left: 0
})
.position({
my: "left top",
at: "right top",
of: this
});
$(document).one("click", function() {
nestedmenu.nestedmenu("hide");
})
}).keydown(function(event) {
var menu = nestedmenu.data("nestedmenu").active.data("menu");
if (menu.widget().is(":hidden"))
return;
event.stopPropagation();
switch (event.keyCode) {
case $.ui.keyCode.PAGE_UP:
menu.previousPage(event);
break;
case $.ui.keyCode.PAGE_DOWN:
menu.nextPage(event);
break;
case $.ui.keyCode.UP:
menu.previous(event);
break;
case $.ui.keyCode.LEFT:
nestedmenu.nestedmenu("up", event);
break;
case $.ui.keyCode.RIGHT:
nestedmenu.nestedmenu("down", event);
break;
case $.ui.keyCode.DOWN:
menu.next(event);
event.preventDefault();
break;
case $.ui.keyCode.ENTER:
case $.ui.keyCode.TAB:
menu.select();
nestedmenu.nestedmenu("hide");
event.preventDefault();
break;
case $.ui.keyCode.ESCAPE:
nestedmenu.nestedmenu("hide");
break;
default:
clearTimeout(menu.filterTimer);
var prev = menu.previousFilter || "";
var character = String.fromCharCode(event.keyCode);
var skip = false;
if (character == prev) {
skip = true;
} else {
character = prev + character;
}
var match = menu.widget().children("li").filter(function() {
return new RegExp("^" + character, "i").test($("a", this).text());
});
var match = skip && match.index(menu.active.next()) != -1 ? match.next() : match;
if (!match.length) {
character = String.fromCharCode(event.keyCode);
match = menu.widget().children("li").filter(function() {
return new RegExp("^" + character, "i").test($(this).text());
});
}
if (match.length) {
menu.activate(event, match);
if (match.length > 1) {
menu.previousFilter = character;
menu.filterTimer = setTimeout(function() {
delete menu.previousFilter;
}, 1000);
} else {
delete menu.previousFilter;
}
} else {
delete menu.previousFilter;
}
}
});
});
</script>
<style>
body { font-size:62.5%; }
.ui-menu { width: 200px; position: absolute; }
.ui-menu .ui-icon { float: right; }
</style>
</head>
<body>
<button>Show context menu</button>
<br/>
<select>
<option>some option with some text</option>
</select>
<ul id="menu">
<li>
<a href="#">Amsterdam</a>
<ul>
<li><a href="#">Aberdeen</a></li>
<li><a href="#">Ada</a></li>
<li>
<a href="#">Adamsville</a>
<ul>
<li><a href="#">Anaheim</a></li>
<li>
<a href="#">Cologne</a>
<ul>
<li><a href="#">Mberdeen</a></li>
<li><a href="#">Mda</a></li>
<li><a href="#">Mdamsville</a></li>
<li><a href="#">Mddyston</a></li>
<li><a href="#">Mmesville</a></li>
</ul>
</li>
<li><a href="#">Frankfurt</a></li>
</ul>
</li>
<li><a href="#">Addyston</a></li>
<li><a href="#">Amesville</a></li>
</ul>
</li>
<li><a href="#">Anaheim</a></li>
<li><a href="#">Cologne</a></li>
<li><a href="#">Frankfurt</a></li>
<li>
<a href="#">Magdeburg</a>
<ul>
<li><a href="#">Mberdeen</a></li>
<li><a href="#">Mda</a></li>
<li><a href="#">Mdamsville</a></li>
<li><a href="#">Mddyston</a></li>
<li><a href="#">Mmesville</a></li>
</ul>
</li>
<li><a href="#">Munich</a></li>
<li><a href="#">Utrecht</a></li>
<li><a href="#">Zurich</a></li>
</ul>
<div class="ui-widget" style="margin-top:2em; font-family:Arial">
Log:
<div id="log" style="height: 400px; width: 300px; overflow: auto;" class="ui-widget-content"></div>
</div>
</body>
</html>

View File

@ -20,6 +20,9 @@
.ui-menu .ui-menu-item {
margin:0;
padding: 0;
zoom: 1;
float: left;
clear: left;
width: 100%;
}
.ui-menu .ui-menu-item a {

View File

@ -70,7 +70,7 @@ $.widget( "ui.autocomplete", {
case keyCode.RIGHT:
case keyCode.SHIFT:
case keyCode.CONTROL:
case 18:
case keyCode.ALT:
// ignore metakeys (shift, ctrl, alt)
break;
default:
@ -140,7 +140,7 @@ $.widget( "ui.autocomplete", {
destroy: function() {
this.element
.removeClass( "ui-autocomplete-input ui-widget ui-widget-content" )
.removeClass( "ui-autocomplete-input" )
.removeAttr( "autocomplete" )
.removeAttr( "role" )
.removeAttr( "aria-autocomplete" )
@ -335,7 +335,7 @@ $.widget("ui.menu", {
"aria-activedescendant": "ui-active-menuitem"
})
.click(function( event ) {
if ( !$( event.target ).closest( ".ui-menu-item" ).length ) {
if ( !$( event.target ).closest( ".ui-menu-item a" ).length ) {
return;
}
// temporary

View File

@ -70,6 +70,7 @@ $.ui = {
},
keyCode: {
ALT: 18,
BACKSPACE: 8,
CAPS_LOCK: 20,
COMMA: 188,

View File

@ -622,8 +622,11 @@ $.widget("ui.dialog", {
// reset content sizing
// hide for non content measurement because height: 0 doesn't work in IE quirks mode (see #4350)
this.element.css('width', 'auto')
.hide();
this.element.css({
width: 'auto',
minHeight: 0,
height: 0
});
// reset wrapper sizing
// determine the height of all the non-content elements