aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjzaefferer <joern.zaefferer@gmail.com>2010-03-27 11:06:31 +0100
committerjzaefferer <joern.zaefferer@gmail.com>2010-03-27 11:06:31 +0100
commita009595bd3d7c6992d438900672fdf98f5e728c3 (patch)
tree6e9a6f074b639db9a92cd08f0be5f971356be453
parentf1933142e485ceaaef9ef52e56abb9f43eaaad2d (diff)
parentc49be0be1a57cac325f021ffddc2f0fbccde1553 (diff)
downloadjquery-ui-a009595bd3d7c6992d438900672fdf98f5e728c3.tar.gz
jquery-ui-a009595bd3d7c6992d438900672fdf98f5e728c3.zip
Merge branch 'master' into tooltip
-rw-r--r--external/qunit.js6
-rw-r--r--tests/unit/accordion/accordion.html67
-rw-r--r--tests/unit/accordion/accordion_methods.js18
-rw-r--r--tests/unit/accordion/accordion_options.js6
-rw-r--r--tests/unit/autocomplete/autocomplete_methods.js3
-rw-r--r--tests/unit/button/button_methods.js2
-rw-r--r--tests/unit/position/position.html4
-rw-r--r--tests/unit/position/position_core.js18
-rw-r--r--tests/unit/slider/slider_events.js58
-rw-r--r--tests/unit/slider/slider_options.js16
-rw-r--r--tests/visual/menu/drilldown.html119
-rw-r--r--tests/visual/menu/drilldown2.html235
-rw-r--r--tests/visual/menu/nested.html75
-rw-r--r--tests/visual/menu/nested2.html236
-rw-r--r--themes/base/jquery.ui.accordion.css2
-rw-r--r--ui/jquery.ui.accordion.js5
-rw-r--r--ui/jquery.ui.position.js4
-rw-r--r--ui/jquery.ui.slider.js22
18 files changed, 226 insertions, 670 deletions
diff --git a/external/qunit.js b/external/qunit.js
index 41e6c82f5..0dd315530 100644
--- a/external/qunit.js
+++ b/external/qunit.js
@@ -579,7 +579,7 @@ function validTest( name ) {
function push(result, actual, expected, message) {
message = message || (result ? "okay" : "failed");
- QUnit.ok( result, result ? message + ": " + expected : message + ", expected: " + QUnit.jsDump.parse(expected) + " result: " + QUnit.jsDump.parse(actual) );
+ QUnit.ok( result, result ? message + ": " + QUnit.jsDump.parse(expected) : message + ", expected: " + QUnit.jsDump.parse(expected) + " result: " + QUnit.jsDump.parse(actual) );
}
function synchronize( callback ) {
@@ -1060,9 +1060,9 @@ QUnit.jsDump = (function() {
name:'name',
'class':'className'
},
- HTML:true,//if true, entities are escaped ( <, >, \t, space and \n )
+ HTML:false,//if true, entities are escaped ( <, >, \t, space and \n )
indentChar:' ',//indentation unit
- multiline:true //if true, items in a collection, are separated by a \n, else just a space.
+ multiline:false //if true, items in a collection, are separated by a \n, else just a space.
};
return jsDump;
diff --git a/tests/unit/accordion/accordion.html b/tests/unit/accordion/accordion.html
index a7142250e..df0979803 100644
--- a/tests/unit/accordion/accordion.html
+++ b/tests/unit/accordion/accordion.html
@@ -25,8 +25,7 @@
<style>
#main { font-size: 10pt; font-family: 'trebuchet ms', verdana, arial; }
- #main h2 { margin: 0; }
- #main ul, #main li { padding: 0; }
+ #navigation * { margin: 0; padding: 0; font-size: 12px; }
</style>
</head>
<body>
@@ -39,37 +38,39 @@
<div id="main" style="position: absolute; top: -10000px; left: -10000px;">
- <div id="list1">
- <a>There is one obvious advantage:</a>
- <div>
- <p>
- You've seen it coming!
- <br/>
- Buy now and get nothing for free!
- <br/>
- Well, at least no free beer. Perhaps a bear, if you can afford it.
- </p>
- </div>
- <a>Now that you've got...</a>
- <div>
- <p>
- your bear, you have to admit it!
- <br/>
- No, we aren't selling bears.
- </p>
- <p>
- We could talk about renting one.
- </p>
- </div>
- <a>Rent one bear, ...</a>
- <div>
- <p>
- get two for three beer.
- </p>
- <p>
- And now, for something completely different.
- </p>
- </div>
+ <div>
+ <div id="list1" class="foo">
+ <a class="bar">There is one obvious advantage:</a>
+ <div style="" class="foo">
+ <p>
+ You've seen it coming!
+ <br/>
+ Buy now and get nothing for free!
+ <br/>
+ Well, at least no free beer. Perhaps a bear, if you can afford it.
+ </p>
+ </div>
+ <a class="bar">Now that you've got...</a>
+ <div style="" class="foo">
+ <p>
+ your bear, you have to admit it!
+ <br/>
+ No, we aren't selling bears.
+ </p>
+ <p>
+ We could talk about renting one.
+ </p>
+ </div>
+ <a class="bar">Rent one bear, ...</a>
+ <div style="" class="foo">
+ <p>
+ get two for three beer.
+ </p>
+ <p>
+ And now, for something completely different.
+ </p>
+ </div>
+ </div>
</div>
<div id="navigationWrapper">
diff --git a/tests/unit/accordion/accordion_methods.js b/tests/unit/accordion/accordion_methods.js
index 6761d24a6..d15a0b710 100644
--- a/tests/unit/accordion/accordion_methods.js
+++ b/tests/unit/accordion/accordion_methods.js
@@ -40,21 +40,9 @@ test("init", function() {
});
test("destroy", function() {
- $("<div></div>").appendTo('body').accordion().accordion("destroy").remove();
- ok(true, '.accordion("destroy") called on element');
-
- $([]).accordion().accordion("destroy").remove();
- ok(true, '.accordion("destroy") called on empty collection');
-
- $('<div></div>').accordion().accordion("destroy").remove();
- ok(true, '.accordion("destroy") called on disconnected DOMElement');
-
- $('<div></div>').accordion().accordion("destroy").accordion("foo").remove();
- ok(true, 'arbitrary method called after destroy');
-
- var expected = $('<div></div>').accordion(),
- actual = expected.accordion('destroy');
- equals(actual, expected, 'destroy is chainable');
+ var beforeHtml = $("#list1").parent().html();
+ var afterHtml = $("#list1").accordion().accordion("destroy").parent().html();
+ equal( afterHtml, beforeHtml );
});
test("enable", function() {
diff --git a/tests/unit/accordion/accordion_options.js b/tests/unit/accordion/accordion_options.js
index 0782b4bb7..cc7fc0369 100644
--- a/tests/unit/accordion/accordion_options.js
+++ b/tests/unit/accordion/accordion_options.js
@@ -116,9 +116,9 @@ test("{ fillSpace: false }, default", function() {
test("{ fillSpace: true }", function() {
$("#navigationWrapper").height(500);
$('#navigation').accordion({ fillSpace: true });
- equals( $('#navigation > li:eq(0) > ul').height(), 362 );
- equals( $('#navigation > li:eq(1) > ul').height(), 362 );
- equals( $('#navigation > li:eq(2) > ul').height(), 362 );
+ equals( $('#navigation > li:eq(0) > ul').height(), 446 );
+ equals( $('#navigation > li:eq(1) > ul').height(), 446 );
+ equals( $('#navigation > li:eq(2) > ul').height(), 446 );
});
test("{ header: '> li > :first-child,> :not(li):even' }, default", function() {
diff --git a/tests/unit/autocomplete/autocomplete_methods.js b/tests/unit/autocomplete/autocomplete_methods.js
index 5c20a6c95..76a600fe6 100644
--- a/tests/unit/autocomplete/autocomplete_methods.js
+++ b/tests/unit/autocomplete/autocomplete_methods.js
@@ -13,8 +13,7 @@ module("autocomplete: methods", {
test("destroy", function() {
var beforeHtml = $("#autocomplete").parent().html();
var afterHtml = $("#autocomplete").autocomplete().autocomplete("destroy").parent().html();
- // TODO can't use same, as that would insert the markup unescaped into the test results, screwing up other tests
- ok( beforeHtml == afterHtml );
+ equal( afterHtml, beforeHtml, "before/after html should be the same" );
})
var data = ["c++", "java", "php", "coldfusion", "javascript", "asp", "ruby", "python", "c", "scala", "groovy", "haskell", "perl"];
diff --git a/tests/unit/button/button_methods.js b/tests/unit/button/button_methods.js
index 1fcd836b8..43c02d8cc 100644
--- a/tests/unit/button/button_methods.js
+++ b/tests/unit/button/button_methods.js
@@ -9,7 +9,7 @@ module("button: methods");
test("destroy", function() {
var beforeHtml = $("#button").parent().html();
var afterHtml = $("#button").button().button("destroy").parent().html();
- same( beforeHtml, afterHtml );
+ equal( afterHtml, beforeHtml );
});
})(jQuery);
diff --git a/tests/unit/position/position.html b/tests/unit/position/position.html
index 5a54e44c9..ca5f2585d 100644
--- a/tests/unit/position/position.html
+++ b/tests/unit/position/position.html
@@ -43,5 +43,9 @@
<div style="position: absolute; height: 5000px; width: 5000px;"></div>
+<div id="bug-5280" style="height: 30px; width: 201px;">
+ <div style="width: 50px; height: 10px;"></div>
+</div>
+
</body>
</html>
diff --git a/tests/unit/position/position_core.js b/tests/unit/position/position_core.js
index 4d2716ced..57e02da0a 100644
--- a/tests/unit/position/position_core.js
+++ b/tests/unit/position/position_core.js
@@ -330,4 +330,22 @@ test("collision: none, with offset", function() {
}, { top: -13, left: -12 }, "left top, negative offset");
});
+//test('bug #5280: consistent results (avoid fractional values)', function() {
+// var wrapper = $('#bug-5280'),
+// elem = wrapper.children(),
+// offset1 = elem.position({
+// my: 'center',
+// at: 'center',
+// of: wrapper,
+// collision: 'none'
+// }).offset(),
+// offset2 = elem.position({
+// my: 'center',
+// at: 'center',
+// of: wrapper,
+// collision: 'none'
+// }).offset();
+// same(offset1, offset2);
+//});
+
})(jQuery);
diff --git a/tests/unit/slider/slider_events.js b/tests/unit/slider/slider_events.js
index fb9af8155..d7c146d84 100644
--- a/tests/unit/slider/slider_events.js
+++ b/tests/unit/slider/slider_events.js
@@ -3,45 +3,54 @@
*/
(function($) {
-var el;
-
module( "slider: events" );
-test( "start", function() {
- ok( false, "missing test - untested code is broken code." );
-});
-
-test( "slide", function() {
- ok( false, "missing test - untested code is broken code." );
-});
-
//Specs from http://wiki.jqueryui.com/Slider#specs
//"change callback: triggers when the slider has stopped moving and has a new
// value (even if same as previous value), via mouse(mouseup) or keyboard(keyup)
// or value method/option"
-test( "change", function() {
- expect(8);
+test( "mouse based interaction", function() {
+ expect(4);
- var handle;
- // Test mouseup at end of handle slide (mouse)
- el = $( "<div></div>" )
+ var el = $( "<div></div>" )
.appendTo( "body" )
.slider({
+ start: function(event, ui) {
+ equals( event.originalEvent.type, "mousedown", "start triggered by mousedown" );
+ },
+ slide: function(event, ui) {
+ equals( event.originalEvent.type, "mousemove", "slider triggered by mousemove" );
+ },
+ stop: function(event, ui) {
+ equals( event.originalEvent.type, "mouseup", "stop triggered by mouseup" );
+ },
change: function(event, ui) {
- ok( true, "change triggered by mouseup at end of handle slide (mouse)" );
+ equals( event.originalEvent.type, "mouseup", "change triggered by mouseup" );
}
});
el.find( ".ui-slider-handle" ).eq( 0 )
.simulate( "drag", { dx: 10, dy: 10 } );
- reset();
+});
+test( "keyboard based interaction", function() {
+ expect(3);
+
// Test keyup at end of handle slide (keyboard)
- el = $( "<div></div>" )
+ var el = $( "<div></div>" )
.appendTo( "body" )
.slider({
+ start: function(event, ui) {
+ equals( event.originalEvent.type, "keydown", "start triggered by keydown" );
+ },
+ slide: function(event, ui) {
+ ok( false, "Slider never triggered by keys" );
+ },
+ stop: function(event, ui) {
+ equals( event.originalEvent.type, "keyup", "stop triggered by keyup" );
+ },
change: function(event, ui) {
- ok( true, "change triggered by keyup at end of handle slide (keyboard)" );
+ equals( event.originalEvent.type, "keyup", "change triggered by keyup" );
}
});
@@ -50,9 +59,12 @@ test( "change", function() {
.simulate( "keypress", { keyCode: $.ui.keyCode.LEFT } )
.simulate( "keyup", { keyCode: $.ui.keyCode.LEFT } );
- reset();
+});
+test( "programmatic event triggers", function() {
+ expect(6);
+
// Test value method
- el = $( "<div></div>" )
+ var el = $( "<div></div>" )
.slider({
change: function(event, ui) {
ok( true, "change triggered by value method" );
@@ -94,8 +106,4 @@ test( "change", function() {
});
-test( "stop", function() {
- ok( false, "missing test - untested code is broken code." );
-});
-
}( jQuery ) );
diff --git a/tests/unit/slider/slider_options.js b/tests/unit/slider/slider_options.js
index 88eb26a8f..cc36923b3 100644
--- a/tests/unit/slider/slider_options.js
+++ b/tests/unit/slider/slider_options.js
@@ -11,10 +11,6 @@ function handle() {
module("slider: options");
-test("animate", function() {
- ok(false, "missing test - untested code is broken code.");
-});
-
test("max", function() {
el = $('<div></div>');
@@ -93,7 +89,17 @@ test("range", function() {
});
test("step", function() {
- ok(false, "missing test - untested code is broken code.");
+ var el = $('<div></div>').slider({
+ step: 10
+ });
+ equals( el.slider("value"), 0 )
+ el.slider("value", 1);
+ equals( el.slider("value"), 10 );
+ el.slider("value", 10);
+ equals( el.slider("value"), 10 );
+ el.slider("value", 11);
+ equals( el.slider("value"), 20 );
+ el.slider('destroy');
});
test("value", function() {
diff --git a/tests/visual/menu/drilldown.html b/tests/visual/menu/drilldown.html
index a97d8322c..1539045f0 100644
--- a/tests/visual/menu/drilldown.html
+++ b/tests/visual/menu/drilldown.html
@@ -8,6 +8,7 @@
<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() {
@@ -20,70 +21,92 @@
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) {
- var nested = $(">ul", ui.item);
- if (!nested.length) {
- self.element.find("h3").text(ui.item.text());
- self.options.selected.apply(this, arguments);
+ if (this != self.active[0]) {
return;
}
- self.active = ui.item.parent();
- // put a previous submenu back into its place and hide it
- self.hideDown();
+ var nested = $(">ul", ui.item);
if (nested.length) {
- // append to body in order to display the submenu above the parent menu, instead of inside of it
- nested.appendTo(document.body).menu("deactivate").show().position({
- my: "left top",
- at: "left top",
- of: self.element.children("ul:first")
- // store the current submenu
- }).data("menuparent", ui.item);
-
- self.active.data("submenu", nested);
+ 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,
+ opacity: 0
+ }).position({
+ my: "left top",
+ at: "right top",
+ of: this.widget()
+ }).position({
+ my: "left top",
+ at: "left top",
+ of: this.widget(),
+ using: function(to) {
+ $(this).animate({
+ left: to.left,
+ top: to.top,
+ opacity: 1
+ });
+ }
+ });
+ this.back.show();
},
up: function() {
- if (!this.active.data("menuparent"))
+ if (this.active.parent()[0] == this.element[0]) {
return;
- this.hideDown();
- this.active.menu("deactivate");
- this.active = this.active.data("menuparent").parent();
+ }
+ this.active.position({
+ my: "left top",
+ at: "right top",
+ of: this.widget(),
+ using: function(to) {
+ $(this).animate({
+ left: to.left,
+ top: to.top,
+ opacity: 0
+ });
+ }
+ });
+ this.active = this.active.parent().parent().show();
+ this.activeItem = this.active.data("menu").active;
+ if (!this.active.parent().parent().is(":ui-menu")) {
+ this.back.hide();
+ }
},
- down: function() {
- var submenu = this.active.data("submenu");
- if (!submenu)
- return;
- submenu.data("menu").activate(submenu.children(":first"))
- this.active = submenu;
+ down: function(event) {
+ var nested = this.activeItem.find(">ul");
+ if (nested.length) {
+ this._open(nested);
+ nested.menu("activate", event, nested.children(":first"))
+ }
},
show: function() {
- this.element.menu("deactivate").show();
- this.active = this.element;
},
hide: function() {
- this.hideDown();
- var child = this.active.hide(), parent;
- while(child.data("menuparent")) {
- parent = child.data("menuparent");
- child.appendTo(parent).removeData("menuparent");
- child = parent.parent().removeData("submenu").hide();
- }
- },
-
- hideDown: function() {
- var submenu = this.active.data("submenu");
- while(submenu) {
- var parent = submenu.data("menuparent");
- submenu.appendTo(parent).hide().removeData("menuparent");
- parent.parent().removeData("submenu");
- submenu = submenu.data("submenu");
- };
},
widget: function() {
@@ -129,7 +152,7 @@
event.preventDefault();
break;
case $.ui.keyCode.ESCAPE:
- drilldown.drilldown("hide");
+ drilldown.drilldown("hide", event);
break;
default:
clearTimeout(menu.filterTimer);
@@ -153,7 +176,7 @@
});
}
if (match.length) {
- menu.activate(match);
+ menu.activate(event, match);
if (match.length > 1) {
menu.previousFilter = character;
menu.filterTimer = setTimeout(function() {
@@ -172,6 +195,7 @@
<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>
@@ -223,6 +247,7 @@
<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">
diff --git a/tests/visual/menu/drilldown2.html b/tests/visual/menu/drilldown2.html
deleted file mode 100644
index 0c18c3679..000000000
--- a/tests/visual/menu/drilldown2.html
+++ /dev/null
@@ -1,235 +0,0 @@
-<!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>
diff --git a/tests/visual/menu/nested.html b/tests/visual/menu/nested.html
index 96a0379d3..063b946c7 100644
--- a/tests/visual/menu/nested.html
+++ b/tests/visual/menu/nested.html
@@ -9,8 +9,16 @@
<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;
@@ -24,77 +32,46 @@
focus: function(event, ui) {
self.active = ui.item.parent();
self.activeItem = ui.item;
- // put a previous submenu back into its place and hide it
- self.hideDown();
+ ui.item.parent().find("ul").hide();
var nested = $(">ul", ui.item);
- // only for mouse-events (should actually check event.originalEvent.type, but for keys, originalEvent is undefined...)
if (nested.length && /^mouse/.test(event.originalEvent.type)) {
- self._openSubmenu(nested, ui.item);
+ self._open(nested);
}
}
})
},
- _openSubmenu: function(nested, item) {
- // append to body in order to display the submenu above the parent menu, instead of inside of it
- nested.appendTo(document.body).menu("deactivate").show().position({
+ _open: function(submenu) {
+ submenu.show().css({
+ top: 0,
+ left: 0
+ }).position({
my: "left top",
at: "right top",
- of: item
- // store the current submenu
- }).data("menuparent", item);
-
- this.active.data("submenu", nested);
+ of: this.activeItem
+ });
},
up: function(event) {
- if (!this.active.data("menuparent"))
- return;
- this.active.menu("deactivate");
- this.active = this.active.data("menuparent").parent();
+ this.active = this.active.menu("deactivate").hide().parent().parent();
this.activeItem = this.active.data("menu").active;
- this.hideDown();
},
down: function(event) {
- var submenu = this.active.data("submenu");
- if (!submenu && this.activeItem) {
- // try to open submenu or return(?); only mouseover opens submenu directly, key doesn't
- var item = this.activeItem,
- nested = item.children("ul");
- if (!nested.length)
- return;
- this._openSubmenu(nested, item);
- submenu = this.active.data("submenu");
- }
- submenu.data("menu").activate(event, submenu.children(":first"))
- this.active = submenu;
+ var submenu = $(">ul", this.activeItem);
+ this._open(submenu, this.activeItem);
+ submenu.menu("activate", event, submenu.children(":first"));
},
show: function() {
- this.element.menu("deactivate").show();
this.active = this.element;
+ this.element.show();
},
hide: function() {
- this.hideDown();
- var child = this.active.hide(), parent;
- while(child.data("menuparent")) {
- parent = child.data("menuparent");
- child.appendTo(parent).removeData("menuparent");
- child = parent.parent().removeData("submenu").hide();
- }
- },
-
- hideDown: function() {
- var submenu = this.active.data("submenu");
- while(submenu) {
- var parent = submenu.data("menuparent");
- submenu.appendTo(parent).hide().removeData("menuparent");
- parent.parent().removeData("submenu");
- submenu = submenu.data("submenu");
- };
+ this.element.find("ul").andSelf().menu("deactivate").hide();
}
+
});
var nestedmenu = $("#menu").nestedmenu({
@@ -200,6 +177,10 @@
<body>
<button>Show context menu</button>
+<br/>
+<select>
+ <option>some option with some text</option>
+</select>
<ul id="menu">
<li>
diff --git a/tests/visual/menu/nested2.html b/tests/visual/menu/nested2.html
deleted file mode 100644
index 063b946c7..000000000
--- a/tests/visual/menu/nested2.html
+++ /dev/null
@@ -1,236 +0,0 @@
-<!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>
diff --git a/themes/base/jquery.ui.accordion.css b/themes/base/jquery.ui.accordion.css
index acd7f5e1e..8d8a1a6e1 100644
--- a/themes/base/jquery.ui.accordion.css
+++ b/themes/base/jquery.ui.accordion.css
@@ -4,6 +4,8 @@
.ui-accordion .ui-accordion-li-fix { display: inline; }
.ui-accordion .ui-accordion-header-active { border-bottom: 0 !important; }
.ui-accordion .ui-accordion-header a { display: block; font-size: 1em; padding: .5em .5em .5em .7em; }
+/* IE7-/Win - Fix extra vertical space in lists */
+.ui-accordion a { zoom: 1; }
.ui-accordion-icons .ui-accordion-header a { padding-left: 2.2em; }
.ui-accordion .ui-accordion-header .ui-icon { position: absolute; left: .5em; top: 50%; margin-top: -8px; }
.ui-accordion .ui-accordion-content { padding: 1em 2.2em; border-top: 0; margin-top: -2px; position: relative; top: 1px; margin-bottom: 2px; overflow: auto; display: none; zoom: 1; }
diff --git a/ui/jquery.ui.accordion.js b/ui/jquery.ui.accordion.js
index d1a7abd6d..bce78231b 100644
--- a/ui/jquery.ui.accordion.js
+++ b/ui/jquery.ui.accordion.js
@@ -74,11 +74,6 @@ $.widget("ui.accordion", {
//Append icon elements
this._createIcons();
- // IE7-/Win - Extra vertical space in lists fixed
- if ($.browser.msie) {
- this.element.find('a').css('zoom', '1');
- }
-
this.resize();
//ARIA
diff --git a/ui/jquery.ui.position.js b/ui/jquery.ui.position.js
index f01640e18..11f8baa06 100644
--- a/ui/jquery.ui.position.js
+++ b/ui/jquery.ui.position.js
@@ -113,6 +113,10 @@ $.fn.position = function( options ) {
position.top -= elemHeight / 2;
}
+ // prevent fractions (see #5280)
+ position.left = parseInt( position.left );
+ position.top = parseInt( position.top );
+
$.each( [ "left", "top" ], function( i, dir ) {
if ( $.ui.position[ collision[i] ] ) {
$.ui.position[ collision[i] ][ dir ]( position, {
diff --git a/ui/jquery.ui.slider.js b/ui/jquery.ui.slider.js
index c392facd7..185fe809c 100644
--- a/ui/jquery.ui.slider.js
+++ b/ui/jquery.ui.slider.js
@@ -152,7 +152,7 @@ $.widget("ui.slider", $.ui.mouse, {
break;
}
- var curVal, newVal, step = self._step();
+ var curVal, newVal, step = self.options.step;
if (self.options.values && self.options.values.length) {
curVal = newVal = self.values(index);
} else {
@@ -526,11 +526,6 @@ $.widget("ui.slider", $.ui.mouse, {
},
- _step: function() {
- var step = this.options.step;
- return step;
- },
-
_value: function() {
//internal value getter
// _value() returns value trimmed by min and max
@@ -564,20 +559,21 @@ $.widget("ui.slider", $.ui.mouse, {
},
_trimValue: function(val) {
- if (val < this._valueMin()) val = this._valueMin();
- if (val > this._valueMax()) val = this._valueMax();
-
+ if (val < this._valueMin()) {
+ return this._valueMin();
+ }
+ if (val > this._valueMax()) {
+ return this._valueMax();
+ }
return val;
},
_valueMin: function() {
- var valueMin = this.options.min;
- return valueMin;
+ return this.options.min;
},
_valueMax: function() {
- var valueMax = this.options.max;
- return valueMax;
+ return this.options.max;
},
_refreshValue: function() {