diff options
Diffstat (limited to 'tests')
27 files changed, 1486 insertions, 814 deletions
diff --git a/tests/jquery.simulate.js b/tests/jquery.simulate.js index 939320668..7be499e17 100644 --- a/tests/jquery.simulate.js +++ b/tests/jquery.simulate.js @@ -1,150 +1,150 @@ -/*
- * jquery.simulate - simulate browser mouse and keyboard events
- *
- * Copyright (c) 2009 AUTHORS.txt (http://jqueryui.com/about)
- * Dual licensed under the MIT (MIT-LICENSE.txt)
- * and GPL (GPL-LICENSE.txt) licenses.
- *
- */
-
-;(function($) {
-
-$.fn.extend({
- simulate: function(type, options) {
- return this.each(function() {
- var opt = $.extend({}, $.simulate.defaults, options || {});
- new $.simulate(this, type, opt);
- });
- }
-});
-
-$.simulate = function(el, type, options) {
- this.target = el;
- this.options = options;
-
- if (/^drag$/.test(type)) {
- this[type].apply(this, [this.target, options]);
- } else {
- this.simulateEvent(el, type, options);
- }
-}
-
-$.extend($.simulate.prototype, {
- simulateEvent: function(el, type, options) {
- var evt = this.createEvent(type, options);
- this.dispatchEvent(el, type, evt, options);
- return evt;
- },
- createEvent: function(type, options) {
- if (/^mouse(over|out|down|up|move)|(dbl)?click$/.test(type)) {
- return this.mouseEvent(type, options);
- } else if (/^key(up|down|press)$/.test(type)) {
- return this.keyboardEvent(type, options);
- }
- },
- mouseEvent: function(type, options) {
- var evt;
- var e = $.extend({
- bubbles: true, cancelable: (type != "mousemove"), view: window, detail: 0,
- screenX: 0, screenY: 0, clientX: 0, clientY: 0,
- ctrlKey: false, altKey: false, shiftKey: false, metaKey: false,
- button: 0, relatedTarget: undefined
- }, options);
-
- var relatedTarget = $(e.relatedTarget)[0];
-
- if ($.isFunction(document.createEvent)) {
- evt = document.createEvent("MouseEvents");
- evt.initMouseEvent(type, e.bubbles, e.cancelable, e.view, e.detail,
- e.screenX, e.screenY, e.clientX, e.clientY,
- e.ctrlKey, e.altKey, e.shiftKey, e.metaKey,
- e.button, e.relatedTarget || document.body.parentNode);
- } else if (document.createEventObject) {
- evt = document.createEventObject();
- $.extend(evt, e);
- evt.button = { 0:1, 1:4, 2:2 }[evt.button] || evt.button;
- }
- return evt;
- },
- keyboardEvent: function(type, options) {
- var evt;
-
- var e = $.extend({ bubbles: true, cancelable: true, view: window,
- ctrlKey: false, altKey: false, shiftKey: false, metaKey: false,
- keyCode: 0, charCode: 0
- }, options);
-
- if ($.isFunction(document.createEvent)) {
- try {
- evt = document.createEvent("KeyEvents");
- evt.initKeyEvent(type, e.bubbles, e.cancelable, e.view,
- e.ctrlKey, e.altKey, e.shiftKey, e.metaKey,
- e.keyCode, e.charCode);
- } catch(err) {
- evt = document.createEvent("Events");
- evt.initEvent(type, e.bubbles, e.cancelable);
- $.extend(evt, { view: e.view,
- ctrlKey: e.ctrlKey, altKey: e.altKey, shiftKey: e.shiftKey, metaKey: e.metaKey,
- keyCode: e.keyCode, charCode: e.charCode
- });
- }
- } else if (document.createEventObject) {
- evt = document.createEventObject();
- $.extend(evt, e);
- }
- if ($.browser.msie || $.browser.opera) {
- evt.keyCode = (e.charCode > 0) ? e.charCode : e.keyCode;
- evt.charCode = undefined;
- }
- return evt;
- },
-
- dispatchEvent: function(el, type, evt) {
- if (el.dispatchEvent) {
- el.dispatchEvent(evt);
- } else if (el.fireEvent) {
- el.fireEvent('on' + type, evt);
- }
- return evt;
- },
-
- drag: function(el) {
- var self = this, center = this.findCenter(this.target),
- options = this.options, x = Math.floor(center.x), y = Math.floor(center.y),
- dx = options.dx || 0, dy = options.dy || 0, target = this.target;
- var coord = { clientX: x, clientY: y };
- this.simulateEvent(target, "mousedown", coord);
- coord = { clientX: x + 1, clientY: y + 1 };
- this.simulateEvent(document, "mousemove", coord);
- coord = { clientX: x + dx, clientY: y + dy };
- this.simulateEvent(document, "mousemove", coord);
- this.simulateEvent(document, "mousemove", coord);
- this.simulateEvent(target, "mouseup", coord);
- },
- findCenter: function(el) {
- var el = $(this.target), o = el.offset();
- return {
- x: o.left + el.outerWidth() / 2,
- y: o.top + el.outerHeight() / 2
- };
- }
-});
-
-$.extend($.simulate, {
- defaults: {
- speed: 'sync'
- },
- VK_TAB: 9,
- VK_ENTER: 13,
- VK_ESC: 27,
- VK_PGUP: 33,
- VK_PGDN: 34,
- VK_END: 35,
- VK_HOME: 36,
- VK_LEFT: 37,
- VK_UP: 38,
- VK_RIGHT: 39,
- VK_DOWN: 40
-});
-
-})(jQuery);
+/* + * jquery.simulate - simulate browser mouse and keyboard events + * + * Copyright (c) 2009 AUTHORS.txt (http://jqueryui.com/about) + * Dual licensed under the MIT (MIT-LICENSE.txt) + * and GPL (GPL-LICENSE.txt) licenses. + * + */ + +;(function($) { + +$.fn.extend({ + simulate: function(type, options) { + return this.each(function() { + var opt = $.extend({}, $.simulate.defaults, options || {}); + new $.simulate(this, type, opt); + }); + } +}); + +$.simulate = function(el, type, options) { + this.target = el; + this.options = options; + + if (/^drag$/.test(type)) { + this[type].apply(this, [this.target, options]); + } else { + this.simulateEvent(el, type, options); + } +} + +$.extend($.simulate.prototype, { + simulateEvent: function(el, type, options) { + var evt = this.createEvent(type, options); + this.dispatchEvent(el, type, evt, options); + return evt; + }, + createEvent: function(type, options) { + if (/^mouse(over|out|down|up|move)|(dbl)?click$/.test(type)) { + return this.mouseEvent(type, options); + } else if (/^key(up|down|press)$/.test(type)) { + return this.keyboardEvent(type, options); + } + }, + mouseEvent: function(type, options) { + var evt; + var e = $.extend({ + bubbles: true, cancelable: (type != "mousemove"), view: window, detail: 0, + screenX: 0, screenY: 0, clientX: 0, clientY: 0, + ctrlKey: false, altKey: false, shiftKey: false, metaKey: false, + button: 0, relatedTarget: undefined + }, options); + + var relatedTarget = $(e.relatedTarget)[0]; + + if ($.isFunction(document.createEvent)) { + evt = document.createEvent("MouseEvents"); + evt.initMouseEvent(type, e.bubbles, e.cancelable, e.view, e.detail, + e.screenX, e.screenY, e.clientX, e.clientY, + e.ctrlKey, e.altKey, e.shiftKey, e.metaKey, + e.button, e.relatedTarget || document.body.parentNode); + } else if (document.createEventObject) { + evt = document.createEventObject(); + $.extend(evt, e); + evt.button = { 0:1, 1:4, 2:2 }[evt.button] || evt.button; + } + return evt; + }, + keyboardEvent: function(type, options) { + var evt; + + var e = $.extend({ bubbles: true, cancelable: true, view: window, + ctrlKey: false, altKey: false, shiftKey: false, metaKey: false, + keyCode: 0, charCode: 0 + }, options); + + if ($.isFunction(document.createEvent)) { + try { + evt = document.createEvent("KeyEvents"); + evt.initKeyEvent(type, e.bubbles, e.cancelable, e.view, + e.ctrlKey, e.altKey, e.shiftKey, e.metaKey, + e.keyCode, e.charCode); + } catch(err) { + evt = document.createEvent("Events"); + evt.initEvent(type, e.bubbles, e.cancelable); + $.extend(evt, { view: e.view, + ctrlKey: e.ctrlKey, altKey: e.altKey, shiftKey: e.shiftKey, metaKey: e.metaKey, + keyCode: e.keyCode, charCode: e.charCode + }); + } + } else if (document.createEventObject) { + evt = document.createEventObject(); + $.extend(evt, e); + } + if ($.browser.msie || $.browser.opera) { + evt.keyCode = (e.charCode > 0) ? e.charCode : e.keyCode; + evt.charCode = undefined; + } + return evt; + }, + + dispatchEvent: function(el, type, evt) { + if (el.dispatchEvent) { + el.dispatchEvent(evt); + } else if (el.fireEvent) { + el.fireEvent('on' + type, evt); + } + return evt; + }, + + drag: function(el) { + var self = this, center = this.findCenter(this.target), + options = this.options, x = Math.floor(center.x), y = Math.floor(center.y), + dx = options.dx || 0, dy = options.dy || 0, target = this.target; + var coord = { clientX: x, clientY: y }; + this.simulateEvent(target, "mousedown", coord); + coord = { clientX: x + 1, clientY: y + 1 }; + this.simulateEvent(document, "mousemove", coord); + coord = { clientX: x + dx, clientY: y + dy }; + this.simulateEvent(document, "mousemove", coord); + this.simulateEvent(document, "mousemove", coord); + this.simulateEvent(target, "mouseup", coord); + }, + findCenter: function(el) { + var el = $(this.target), o = el.offset(); + return { + x: o.left + el.outerWidth() / 2, + y: o.top + el.outerHeight() / 2 + }; + } +}); + +$.extend($.simulate, { + defaults: { + speed: 'sync' + }, + VK_TAB: 9, + VK_ENTER: 13, + VK_ESC: 27, + VK_PGUP: 33, + VK_PGDN: 34, + VK_END: 35, + VK_HOME: 36, + VK_LEFT: 37, + VK_UP: 38, + VK_RIGHT: 39, + VK_DOWN: 40 +}); + +})(jQuery); diff --git a/tests/static/button/default.html b/tests/static/button/default.html new file mode 100644 index 000000000..1d1ce80fc --- /dev/null +++ b/tests/static/button/default.html @@ -0,0 +1,129 @@ +<!DOCTYPE html> +<html lang="en"> +<head> + <title>Button Static Test : Default</title> + <link rel="stylesheet" href="../static.css" type="text/css" /> + <link rel="stylesheet" href="../../../themes/base/ui.base.css" type="text/css" /> + <link rel="stylesheet" href="../../../themes/base/ui.theme.css" type="text/css" title="ui-theme" /> + <script type="text/javascript" src="../../../jquery-1.3.2.js"></script> + <script type="text/javascript" src="../static.js"></script> + <style> + div { margin: 0 0 1em; } + h2 { margin: 2em 0 1em; } + </style> +</head> +<body> + + <h2>Using button elements</h2> + + <div> + <button class="ui-button ui-button-text-only ui-widget ui-state-default ui-corner-all"> + <span class="ui-button-text">Button</span> + </button> + + <button class="ui-button ui-button-icon-only ui-widget ui-state-default ui-corner-all" title="Button"> + <span class="ui-button-icon-primary ui-icon ui-icon-locked"></span> + <span class="ui-button-text">Button</span> + </button> + + <button class="ui-button ui-button-text-icon ui-widget ui-state-default ui-corner-all"> + <span class="ui-button-icon-primary ui-icon ui-icon-locked"></span> + <span class="ui-button-text">Button</span> + </button> + + <button class="ui-button ui-button-text-icons ui-widget ui-state-default ui-corner-all"> + <span class="ui-button-icon-primary ui-icon ui-icon-gear"></span> + <span class="ui-button-text">Button</span> + <span class="ui-button-icon-secondary ui-icon ui-icon-triangle-1-s"></span> + </button> + + <button class="ui-button ui-button-icons-only ui-widget ui-state-default ui-corner-all"> + <span class="ui-button-icon-primary ui-icon ui-icon-gear"></span> + <span class="ui-button-text">Button</span> + <span class="ui-button-icon-secondary ui-icon ui-icon-triangle-1-s"></span> + </button> + </div> + + <h2>Using anchor elements</h2> + + <div> + <a href="#" class="ui-button ui-button-text-only ui-widget ui-state-default ui-corner-all"> + <span class="ui-button-text">Button</span> + </a> + + <a href="#" class="ui-button ui-button-icon-only ui-widget ui-state-default ui-corner-all" title="Button"> + <span class="ui-button-icon-primary ui-icon ui-icon-locked"></span> + <span class="ui-button-text">Button</span> + </a> + + <a href="#" class="ui-button ui-button-text-icon ui-widget ui-state-default ui-corner-all"> + <span class="ui-button-icon-primary ui-icon ui-icon-locked"></span> + <span class="ui-button-text">Button</span> + </a> + + <a href="#" class="ui-button ui-button-text-icons ui-widget ui-state-default ui-corner-all"> + <span class="ui-button-icon-primary ui-icon ui-icon-gear"></span> + <span class="ui-button-text">Button</span> + <span class="ui-button-icon-secondary ui-icon ui-icon-triangle-1-s"></span> + </a> + + <a href="#" class="ui-button ui-button-icons-only ui-widget ui-state-default ui-corner-all"> + <span class="ui-button-icon-primary ui-icon ui-icon-gear"></span> + <span class="ui-button-text">Button</span> + <span class="ui-button-icon-secondary ui-icon ui-icon-triangle-1-s"></span> + </a> + </div> + + + + <h2>Using label elements (used when proxying to radio or check inputs)</h2> + + <div> + <label class="ui-button ui-button-text-only ui-widget ui-state-default ui-corner-all"> + <span class="ui-button-text">Button</span> + </label> + + <label class="ui-button ui-button-icon-only ui-widget ui-state-default ui-corner-all" title="Button"> + <span class="ui-button-icon-primary ui-icon ui-icon-locked"></span> + <span class="ui-button-text">Button</span> + </label> + + <label class="ui-button ui-button-text-icon ui-widget ui-state-default ui-corner-all"> + <span class="ui-button-icon-primary ui-icon ui-icon-locked"></span> + <span class="ui-button-text">Button</span> + </label> + + <label class="ui-button ui-button-text-icons ui-widget ui-state-default ui-corner-all"> + <span class="ui-button-icon-primary ui-icon ui-icon-gear"></span> + <span class="ui-button-text">Button</span> + <span class="ui-button-icon-secondary ui-icon ui-icon-triangle-1-s"></span> + </label> + + <label class="ui-button ui-button-icons-only ui-widget ui-state-default ui-corner-all"> + <span class="ui-button-icon-primary ui-icon ui-icon-gear"></span> + <span class="ui-button-text">Button</span> + <span class="ui-button-icon-secondary ui-icon ui-icon-triangle-1-s"></span> + </label> + </div> + + + <h2>Button Sets</h2> + + <div class="ui-button-set"> + <button class="ui-button ui-button-text-only ui-widget ui-state-default ui-corner-left"><span class="ui-button-text">Simple button</span></button> + <button class="ui-button ui-button-text-only ui-widget ui-state-default"><span class="ui-button-text">Simple button</span></button> + <button class="ui-button ui-button-text-only ui-widget ui-state-default ui-corner-right"><span class="ui-button-text">Simple button</span></button> + </div> + + + +<script type="text/javascript" src="http://jqueryui.com/themeroller/themeswitchertool/"></script> +<script> + $('<div/>').css({ + position: "absolute", + right: 10, + top: 10 + }).appendTo(document.body).themeswitcher(); +</script> +</body> +</html> diff --git a/tests/static/menu/default.html b/tests/static/menu/default.html new file mode 100644 index 000000000..2830433e3 --- /dev/null +++ b/tests/static/menu/default.html @@ -0,0 +1,38 @@ +<!doctype html> +<html> +<head> + <title>Menu Static Test : Default</title> + <link rel="stylesheet" href="../static.css" type="text/css" /> + <link rel="stylesheet" href="../../../themes/base/ui.base.css" type="text/css" /> + <link rel="stylesheet" href="../../../themes/base/ui.theme.css" type="text/css" title="ui-theme" /> + <script type="text/javascript" src="../../../jquery-1.3.2.js"></script> + <script type="text/javascript" src="../static.js"></script> + +</head> +<body> + + +<ul role="menu" aria-activedescendant="ui-active-menuitem" class="ui-menu ui-widget ui-widget-content ui-corner-bottom"> + <li class="ui-menu-item" role="menuitem"><a href="#" tabindex="-1" class="ui-corner-all">Aberdeen</a></li> + <li class="ui-menu-item" role="menuitem" id="ui-active-menuitem"><a href="#" tabindex="-1" class="ui-state-hover ui-corner-all">Ada</a></li> + <li class="ui-menu-item" role="menuitem"><a href="#" tabindex="-1" class="ui-corner-all">Adamsville</a></li> + <li class="ui-menu-item" role="menuitem"><a href="#" tabindex="-1" class="ui-corner-all">Addyston</a></li> + <li class="ui-menu-item" role="menuitem"><a href="#" tabindex="-1" class="ui-corner-all">Adelphi</a></li> + <li class="ui-menu-item" role="menuitem"><a href="#" tabindex="-1" class="ui-corner-all">Adena</a></li> + <li class="ui-menu-item" role="menuitem"><a href="#" tabindex="-1" class="ui-corner-all">Adrian</a></li> + <li class="ui-menu-item" role="menuitem"><a href="#" tabindex="-1" class="ui-corner-all">Akron</a></li> + <li class="ui-menu-item" role="menuitem"><a href="#" tabindex="-1" class="ui-corner-all">Albany</a></li> + <li class="ui-menu-item" role="menuitem"><a href="#" tabindex="-1" class="ui-corner-all">Alexandria</a></li> + <li class="ui-menu-item" role="menuitem"><a href="#" tabindex="-1" class="ui-corner-all">Alger</a></li> + <li class="ui-menu-item" role="menuitem"><a href="#" tabindex="-1" class="ui-corner-all">Alledonia</a></li> + <li class="ui-menu-item" role="menuitem"><a href="#" tabindex="-1" class="ui-corner-all">Alliance</a></li> + <li class="ui-menu-item" role="menuitem"><a href="#" tabindex="-1" class="ui-corner-all">Alpha</a></li> + <li class="ui-menu-item" role="menuitem"><a href="#" tabindex="-1" class="ui-corner-all">Alvada</a></li> + <li class="ui-menu-item" role="menuitem"><a href="#" tabindex="-1" class="ui-corner-all">Alvordton</a></li> + <li class="ui-menu-item" role="menuitem"><a href="#" tabindex="-1" class="ui-corner-all">Amanda</a></li> + <li class="ui-menu-item" role="menuitem"><a href="#" tabindex="-1" class="ui-corner-all">Amelia</a></li> + <li class="ui-menu-item" role="menuitem"><a href="#" tabindex="-1" class="ui-corner-all">Amesville</a></li> +</ul> + +</body> +</html> diff --git a/tests/unit/accordion/accordion_core.js b/tests/unit/accordion/accordion_core.js index 797ead864..47d2509e6 100644 --- a/tests/unit/accordion/accordion_core.js +++ b/tests/unit/accordion/accordion_core.js @@ -5,7 +5,7 @@ (function($) { -jQuery.ui.accordion.defaults.animated = false; +$.ui.accordion.prototype.options.animated = false; function state(accordion) { var args = $.makeArray(arguments).slice(1); diff --git a/tests/unit/accordion/accordion_options.js b/tests/unit/accordion/accordion_options.js index b77cb787e..ddb2c38cb 100644 --- a/tests/unit/accordion/accordion_options.js +++ b/tests/unit/accordion/accordion_options.js @@ -127,19 +127,20 @@ test("{ header: '> li > :first-child,> :not(li):even' }, default", function() { }); test("{ icons: false }", function() { + var list = $("#list1"); function icons(on) { - same($("#list1 span.ui-icon").length, on ? 3 : 0); - same( $("#list1").hasClass("ui-accordion-icons"), on ); + same($("span.ui-icon", list).length, on ? 3 : 0); + same( list.hasClass("ui-accordion-icons"), on ); } - $("#list1").accordion(); + list.accordion(); icons(true); - $("#list1").accordion("destroy").accordion({ + list.accordion("destroy").accordion({ icons: false }); icons(false); - $("#list1").accordion("option", "icons", $.ui.accordion.defaults.icons); + list.accordion("option", "icons", $.ui.accordion.prototype.options.icons); icons(true); - $("#list1").accordion("option", "icons", false); + list.accordion("option", "icons", false); icons(false); }); diff --git a/tests/unit/button/button.html b/tests/unit/button/button.html new file mode 100644 index 000000000..5017c9bc6 --- /dev/null +++ b/tests/unit/button/button.html @@ -0,0 +1,56 @@ +<!doctype html>
+<html lang="en">
+<head>
+ <title>jQuery UI Button Test Suite</title>
+
+ <script type="text/javascript" src="../../../jquery-1.3.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.button.js"></script>
+
+ <link type="text/css" href="../testsuite.css" rel="stylesheet" />
+ <script type="text/javascript" src="../../../external/testrunner-r6588.js"></script>
+ <script type="text/javascript" src="../../jquery.simulate.js"></script>
+ <script type="text/javascript" src="../testsuite.js"></script>
+
+ <script type="text/javascript" src="button_core.js"></script>
+ <script type="text/javascript" src="button_defaults.js"></script>
+ <script type="text/javascript" src="button_events.js"></script>
+ <script type="text/javascript" src="button_methods.js"></script>
+ <script type="text/javascript" src="button_options.js"></script>
+ <script type="text/javascript" src="button_tickets.js"></script>
+
+</head>
+<body>
+
+<div id="main">
+
+ <div><button id="button" class="foo">Label</button></div>
+
+ <div id="radio0" style="margin-top: 2em;">
+ <input type="radio" id="radio01" name="radio" checked="checked" /><label for="radio01">Choice 1</label>
+ <input type="radio" id="radio02" name="radio" /><label for="radio02">Choice 2</label>
+ <input type="radio" id="radio03" name="radio" /><label for="radio03">Choice 3</label>
+ </div>
+ <form>
+ <div id="radio1" style="margin-top: 2em;">
+ <input type="radio" id="radio11" name="radio" /><label for="radio11">Choice 1</label>
+ <input type="radio" id="radio12" name="radio" checked="checked" /><label for="radio12">Choice 2</label>
+ <input type="radio" id="radio13" name="radio" /><label for="radio13">Choice 3</label>
+ </div>
+ </form>
+ <form>
+ <div id="radio2" style="margin-top: 2em;">
+ <input type="radio" id="radio21" name="radio" /><label for="radio21">Choice 1</label>
+ <input type="radio" id="radio22" name="radio" /><label for="radio22">Choice 2</label>
+ <input type="radio" id="radio23" name="radio" checked="checked" /><label for="radio23">Choice 3</label>
+ </div>
+ </form>
+
+ <input type="checkbox" id="check" /><label for="check">Toggle</label>
+
+ <div><input id="submit" type="submit" value="Label" /></div>
+</div>
+
+</body>
+</html>
diff --git a/tests/unit/button/button_core.js b/tests/unit/button/button_core.js new file mode 100644 index 000000000..12016627f --- /dev/null +++ b/tests/unit/button/button_core.js @@ -0,0 +1,70 @@ +/*
+ * button_core.js
+ */
+
+
+(function($) {
+
+module("button: core");
+
+test("checkbox", function() {
+ var input = $("#check");
+ label = $("label[for=check]");
+ ok( input.is(":visble") );
+ ok( label.is(":not(.ui-button)") );
+ input.button();
+ ok( input.is(":hidden") );
+ ok( label.is(".ui-button") );
+});
+
+test("radios", function() {
+ var inputs = $("#radio0 input");
+ labels = $("#radio0 label");
+ ok( inputs.is(":visble") );
+ ok( labels.is(":not(.ui-button)") );
+ inputs.button();
+ ok( inputs.is(":hidden") );
+ ok( labels.is(".ui-button") );
+});
+
+function assert(noForm, form1, form2) {
+ ok( $("#radio0 .ui-button" + noForm).is(".ui-state-active") );
+ ok( $("#radio1 .ui-button" + form1).is(".ui-state-active") );
+ ok( $("#radio2 .ui-button" + form2).is(".ui-state-active") );
+}
+
+test("radio groups", function() {
+ $(":radio").button();
+ assert(":eq(0)", ":eq(1)", ":eq(2)");
+
+ // click outside of forms
+ $("#radio0 .ui-button:eq(1)").click();
+ assert(":eq(1)", ":eq(1)", ":eq(2)");
+
+ // click in first form
+ $("#radio1 .ui-button:eq(0)").click();
+ assert(":eq(1)", ":eq(0)", ":eq(2)");
+
+ // click in second form
+ $("#radio2 .ui-button:eq(0)").click();
+ assert(":eq(1)", ":eq(0)", ":eq(0)");
+});
+
+test("input type submit, don't create child elements", function() {
+ var input = $("#submit")
+ same( input.children().length, 0 );
+ input.button();
+ same( input.children().length, 0 );
+});
+
+test("buttonset", function() {
+ var set = $("#radio1").buttonset();
+ ok( set.is(".ui-button-set") );
+ same( set.children(".ui-button").length, 3 );
+ same( set.children("input:radio:hidden").length, 3 );
+ ok( set.children("label:eq(0)").is(".ui-button.ui-corner-left:not(.ui-corner-all)") );
+ ok( set.children("label:eq(1)").is(".ui-button:not(.ui-corner-all)") );
+ ok( set.children("label:eq(2)").is(".ui-button.ui-corner-right:not(.ui-corner-all)") );
+});
+
+})(jQuery);
diff --git a/tests/unit/button/button_defaults.js b/tests/unit/button/button_defaults.js new file mode 100644 index 000000000..f0152e3c2 --- /dev/null +++ b/tests/unit/button/button_defaults.js @@ -0,0 +1,15 @@ +/*
+ * button_defaults.js
+ */
+
+var button_defaults = {
+ disabled: false,
+ text: true,
+ label: null,
+ icons: {
+ primary: null,
+ secondary: null
+ }
+};
+
+commonWidgetTests('button', { defaults: button_defaults });
diff --git a/tests/unit/button/button_events.js b/tests/unit/button/button_events.js new file mode 100644 index 000000000..17f505458 --- /dev/null +++ b/tests/unit/button/button_events.js @@ -0,0 +1,17 @@ +/*
+ * button_events.js
+ */
+(function($) {
+
+module("button: events");
+
+test("click-through", function() {
+ expect(2);
+ var set = $("#radio1").buttonset();
+ set.find("input:first").click(function() {
+ ok( true );
+ });
+ ok( set.find("label:first").click().is(".ui-button") );
+});
+
+})(jQuery);
diff --git a/tests/unit/button/button_methods.js b/tests/unit/button/button_methods.js new file mode 100644 index 000000000..a162a8930 --- /dev/null +++ b/tests/unit/button/button_methods.js @@ -0,0 +1,15 @@ +/*
+ * button_methods.js
+ */
+(function($) {
+
+
+module("button: methods");
+
+test("destroy", function() {
+ var beforeHtml = $("#button").parent().html();
+ var afterHtml = $("#button").button().button("destroy").parent().html();
+ same( beforeHtml, afterHtml );
+});
+
+})(jQuery);
diff --git a/tests/unit/button/button_options.js b/tests/unit/button/button_options.js new file mode 100644 index 000000000..f44679a34 --- /dev/null +++ b/tests/unit/button/button_options.js @@ -0,0 +1,69 @@ +/*
+ * button_options.js
+ */
+(function($) {
+
+module("button: options");
+
+test("text false without icon", function() {
+ $("#button").button({
+ text: false
+ });
+ ok( $("#button").is(".ui-button-text-only:not(.ui-button-icon-only)") );
+
+ $("#button").button("destroy");
+});
+
+test("text false with icon", function() {
+ $("#button").button({
+ text: false,
+ icons: {
+ primary: "iconclass"
+ }
+ });
+ ok( $("#button").is(".ui-button-icon-only:not(.ui-button-text):has(span.ui-icon.iconclass)") );
+
+ $("#button").button("destroy");
+});
+
+test("label, default", function() {
+ $("#button").button();
+ same( $("#button").text(), "Label" );
+
+ $("#button").button("destroy");
+});
+
+test("label", function() {
+ $("#button").button({
+ label: "xxx"
+ });
+ same( $("#button").text(), "xxx" );
+
+ $("#button").button("destroy");
+});
+
+test("label default with input type submit", function() {
+ same( $("#submit").button().val(), "Label" );
+});
+
+test("label with input type submit", function() {
+ var label = $("#submit").button({
+ label: "xxx"
+ }).val();
+ same( label, "xxx" );
+});
+
+test("icons", function() {
+ $("#button").button({
+ text: false,
+ icons: {
+ primary: "iconclass",
+ secondary: "iconclass2"
+ }
+ });
+ ok( $("#button").is(":has(span.ui-icon.ui-button-icon-primary.iconclass):has(span.ui-icon.ui-button-icon-secondary.iconclass2)") );
+
+ $("#button").button("destroy");
+});
+
+})(jQuery);
diff --git a/tests/unit/button/button_tickets.js b/tests/unit/button/button_tickets.js new file mode 100644 index 000000000..d3b981e21 --- /dev/null +++ b/tests/unit/button/button_tickets.js @@ -0,0 +1,10 @@ +/*
+ * button_tickets.js
+ */
+(function($) {
+
+module("button: tickets");
+
+
+
+})(jQuery);
diff --git a/tests/unit/core/core.js b/tests/unit/core/core.js index a35935c52..23292671a 100644 --- a/tests/unit/core/core.js +++ b/tests/unit/core/core.js @@ -57,40 +57,4 @@ test('zIndex', function() { equals($('#zIndexAutoNoParent').zIndex(), 0, 'zIndex never explicitly set in hierarchy'); }); -test('widget factory, merge multiple option arguments', function() { - expect(1); - $.widget("ui.widgetTest", { - _init: function() { - same(this.options, { - disabled: false, - option1: "value1", - option2: "value2", - option3: "value3", - option4: { - option4a: "valuea", - option4b: "valueb" - } - }); - } - }); - $("#main > :first").widgetTest({ - option1: "valuex", - option2: "valuex", - option3: "value3", - option4: { - option4a: "valuex" - } - }, { - option1: "value1", - option2: "value2", - option4: { - option4b: "valueb" - } - }, { - option4: { - option4a: "valuea" - } - }); -}); - })(jQuery); diff --git a/tests/unit/datepicker/datepicker_core.js b/tests/unit/datepicker/datepicker_core.js index f34c9fa06..9867022f7 100644 --- a/tests/unit/datepicker/datepicker_core.js +++ b/tests/unit/datepicker/datepicker_core.js @@ -47,6 +47,11 @@ module("datepicker: core", { } }); +test("widget method", function() { + var actual = $("#inp").datepicker().datepicker("widget")[0]; + same($("body > #ui-datepicker-div:last-child")[0], actual); +}); + test('baseStructure', function() { var inp = init('#inp'); inp.focus(); diff --git a/tests/unit/dialog/dialog_core.js b/tests/unit/dialog/dialog_core.js index 3924c1d7f..cf76045b4 100644 --- a/tests/unit/dialog/dialog_core.js +++ b/tests/unit/dialog/dialog_core.js @@ -147,4 +147,9 @@ test("ARIA", function() { el.remove(); }); +test("widget method", function() { + var dialog = $("<div/>").appendTo("#main").dialog(); + same(dialog.parent()[0], dialog.dialog("widget")[0]); +}); + })(jQuery); diff --git a/tests/unit/position/position_core.js b/tests/unit/position/position_core.js index f05a2e804..705a7ec34 100644 --- a/tests/unit/position/position_core.js +++ b/tests/unit/position/position_core.js @@ -1,333 +1,333 @@ -/*
- * position_core.js
- */
-(function($) {
-
-test('my, at, of', function() {
- $('#elx').position({
- my: 'left top',
- at: 'left top',
- of: '#parentx',
- collision: 'none'
- });
- same($('#elx').offset(), { top: 40, left: 40 }, 'left top, left top');
-
- $('#elx').position({
- my: 'left top',
- at: 'left bottom',
- of: '#parentx',
- collision: 'none'
- });
- same($('#elx').offset(), { top: 60, left: 40 }, 'left top, left bottom');
-
- $('#elx').position({
- my: 'left',
- at: 'bottom',
- of: '#parentx',
- collision: 'none'
- });
- same($('#elx').offset(), { top: 55, left: 50 }, 'left, bottom');
-
- $('#elx').position({
- my: 'left foo',
- at: 'bar baz',
- of: '#parentx',
- collision: 'none'
- });
- same($('#elx').offset(), { top: 45, left: 50 }, 'left foo, bar baz');
-});
-
-test('multiple elements', function() {
- var elements = $('#el1, #el2');
- var result = elements.position({
- my: 'left top',
- at: 'left bottom',
- of: '#parent',
- collision: 'none'
- });
-
- same(result, elements);
- var expected = {top: 10, left: 4};
- elements.each(function() {
- same($(this).offset(), expected);
- });
-});
-
-test('positions', function() {
- var definitions = [];
- var offsets = {
- left: 0,
- center: 3,
- right: 6,
- top: 0,
- center: 3,
- bottom: 6
- };
- var start = { left: 4, top: 4 };
- $.each([0, 1], function(my) {
- $.each(["top", "center", "bottom"], function(vindex, vertical) {
- $.each(["left", "center", "right"], function(hindex, horizontal) {
- definitions.push({
- my: my ? horizontal + " " + vertical : 'left top',
- at: !my ? horizontal + " " + vertical : 'left top',
- result: {
- top: my ? start.top - offsets[vertical] : start.top + offsets[vertical],
- left: my ? start.left - offsets[horizontal] : start.left + offsets[horizontal]
- }
- });
- });
- });
- });
- var el = $("#el1");
- $.each(definitions, function(index, definition) {
- el.position({
- my: definition.my,
- at: definition.at,
- of: '#parent',
- collision: 'none'
- });
- same(el.offset(), definition.result, "Position via " + jsDump.parse({my:definition.my, at:definition.at}));
- });
-});
-
-test('of', function() {
- $('#elx').position({
- my: 'left top',
- at: 'left top',
- of: '#parentx',
- collision: 'none'
- });
- same($('#elx').offset(), { top: 40, left: 40 }, 'selector');
-
- $('#elx').position({
- my: 'left top',
- at: 'left bottom',
- of: $('#parentx'),
- collision: 'none'
- });
- same($('#elx').offset(), { top: 60, left: 40 }, 'jQuery object');
-
- $('#elx').position({
- my: 'left top',
- at: 'left top',
- of: $('#parentx')[0],
- collision: 'none'
- });
- same($('#elx').offset(), { top: 40, left: 40 }, 'DOM element');
-
- $('#elx').position({
- my: 'right bottom',
- at: 'right bottom',
- of: document,
- collision: 'none'
- });
- same($('#elx').offset(), {
- top: $(document).height() - 10,
- left: $(document).width() - 10
- }, 'document');
-
- $('#elx').position({
- my: 'right bottom',
- at: 'right bottom',
- of: window,
- collision: 'none'
- });
- same($('#elx').offset(), {
- top: $(window).height() - 10,
- left: $(window).width() - 10
- }, 'window');
-
- $(window).scrollTop(500).scrollLeft(200);
- $('#elx').position({
- my: 'right bottom',
- at: 'right bottom',
- of: window,
- collision: 'none'
- });
- same($('#elx').offset(), {
- top: $(window).height() + 500 - 10,
- left: $(window).width() + 200 - 10
- }, 'window, scrolled');
- $(window).scrollTop(0).scrollLeft(0);
-
- var event = $.extend($.Event('someEvent'), { pageX: 200, pageY: 300 });
- $('#elx').position({
- my: 'left top',
- at: 'left top',
- of: event,
- collision: 'none'
- });
- same($('#elx').offset(), {
- top: 300,
- left: 200
- }, 'event - left top, left top');
-
- event = $.extend($.Event('someEvent'), { pageX: 400, pageY: 600 });
- $('#elx').position({
- my: 'left top',
- at: 'right bottom',
- of: event,
- collision: 'none'
- });
- same($('#elx').offset(), {
- top: 600,
- left: 400
- }, 'event - left top, right bottom');
-});
-
-test('offset', function() {
- $('#elx').position({
- my: 'left top',
- at: 'left bottom',
- of: '#parentx',
- offset: '10',
- collision: 'none'
- });
- same($('#elx').offset(), { top: 70, left: 50 }, 'single value');
-
- $('#elx').position({
- my: 'left top',
- at: 'left bottom',
- of: '#parentx',
- offset: '5 -3',
- collision: 'none'
- });
- same($('#elx').offset(), { top: 57, left: 45 }, 'two values');
-
- $('#elx').position({
- my: 'left top',
- at: 'left bottom',
- of: '#parentx',
- offset: '5px -3px',
- collision: 'none'
- });
- same($('#elx').offset(), { top: 57, left: 45 }, 'with units');
-});
-
-test('by', function() {
- expect(6);
-
- var count = 0,
- elems = $('#el1, #el2'),
- expectedPosition = { top: 40, left: 40 },
- originalPosition = elems.position({
- my: 'right bottom',
- at: 'rigt bottom',
- of: '#parentx',
- collision: 'none'
- }).offset();
-
- elems.position({
- my: 'left top',
- at: 'left top',
- of: '#parentx',
- by: function(position) {
- same(this, elems[count], 'correct context for call #' + count);
- same(position, expectedPosition, 'correct position for call #' + count);
- count++;
- }
- });
-
- elems.each(function() {
- same($(this).offset(), originalPosition, 'elements not moved');
- });
-});
-
-function collisionTest(config, result, msg) {
- var elem = $("#elx").position($.extend({
- my: "left top",
- at: "right bottom",
- of: window
- }, config));
- same(elem.offset(), result, msg);
-}
-
-function collisionTest2(config, result, msg) {
- collisionTest($.extend({
- my: "right bottom",
- at: "left top"
- }, config), result, msg);
-}
-
-test("collision: fit, no offset", function() {
- collisionTest({
- collision: "fit"
- }, { top: $(window).height() - 10, left: $(window).width() - 10 }, "right bottom");
-
- collisionTest2({
- collision: "fit"
- }, { top: 0, left: 0 }, "left top");
-});
-
-test("collision: fit, with offset", function() {
- collisionTest({
- collision: "fit",
- offset: "2 3"
- }, { top: $(window).height() - 10, left: $(window).width() - 10 }, "right bottom");
-
- collisionTest2({
- collision: "fit",
- offset: "2 3"
- }, { top: 0, left: 0 }, "left top, positive offset");
-
- collisionTest2({
- collision: "fit",
- offset: "-2 -3"
- }, { top: 0, left: 0 }, "left top, negative offset");
-});
-
-test("collision: flip, no offset", function() {
- collisionTest({
- collision: "flip"
- }, { top: -10, left: -10 }, "left top");
-
- collisionTest2({
- collision: "flip"
- }, { top: $(window).height(), left: $(window).width() }, "right bottom");
-});
-
-test("collision: flip, with offset", function() {
- collisionTest({
- collision: "flip",
- offset: "2 3"
- }, { top: -13, left: -12 }, "left top, with offset added");
-
- collisionTest2({
- collision: "flip",
- offset: "2 3"
- }, { top: $(window).height() - 3, left: $(window).width() - 2 }, "bottom, positive offset");
-
- collisionTest2({
- collision: "flip",
- offset: "-2 -3"
- }, { top: $(window).height() + 3, left: $(window).width() + 2 }, "right bottom, negative offset");
-});
-
-test("collision: none, no offset", function() {
- collisionTest({
- collision: "none"
- }, { top: $(window).height(), left: $(window).width() }, "left top");
-
- collisionTest2({
- collision: "none"
- }, { top: -10, left: -10 }, "moved to the right bottom");
-});
-
-test("collision: none, with offset", function() {
- collisionTest({
- collision: "none",
- offset: "2 3"
- }, { top: $(window).height() + 3, left: $(window).width() + 2 }, "right bottom, with offset added");
-
- collisionTest2({
- collision: "none",
- offset: "2 3"
- }, { top: -7, left: -8 }, "left top, positive offset");
-
- collisionTest2({
- collision: "none",
- offset: "-2 -3"
- }, { top: -13, left: -12 }, "left top, negative offset");
-});
-
-})(jQuery);
+/* + * position_core.js + */ +(function($) { + +test('my, at, of', function() { + $('#elx').position({ + my: 'left top', + at: 'left top', + of: '#parentx', + collision: 'none' + }); + same($('#elx').offset(), { top: 40, left: 40 }, 'left top, left top'); + + $('#elx').position({ + my: 'left top', + at: 'left bottom', + of: '#parentx', + collision: 'none' + }); + same($('#elx').offset(), { top: 60, left: 40 }, 'left top, left bottom'); + + $('#elx').position({ + my: 'left', + at: 'bottom', + of: '#parentx', + collision: 'none' + }); + same($('#elx').offset(), { top: 55, left: 50 }, 'left, bottom'); + + $('#elx').position({ + my: 'left foo', + at: 'bar baz', + of: '#parentx', + collision: 'none' + }); + same($('#elx').offset(), { top: 45, left: 50 }, 'left foo, bar baz'); +}); + +test('multiple elements', function() { + var elements = $('#el1, #el2'); + var result = elements.position({ + my: 'left top', + at: 'left bottom', + of: '#parent', + collision: 'none' + }); + + same(result, elements); + var expected = {top: 10, left: 4}; + elements.each(function() { + same($(this).offset(), expected); + }); +}); + +test('positions', function() { + var definitions = []; + var offsets = { + left: 0, + center: 3, + right: 6, + top: 0, + center: 3, + bottom: 6 + }; + var start = { left: 4, top: 4 }; + $.each([0, 1], function(my) { + $.each(["top", "center", "bottom"], function(vindex, vertical) { + $.each(["left", "center", "right"], function(hindex, horizontal) { + definitions.push({ + my: my ? horizontal + " " + vertical : 'left top', + at: !my ? horizontal + " " + vertical : 'left top', + result: { + top: my ? start.top - offsets[vertical] : start.top + offsets[vertical], + left: my ? start.left - offsets[horizontal] : start.left + offsets[horizontal] + } + }); + }); + }); + }); + var el = $("#el1"); + $.each(definitions, function(index, definition) { + el.position({ + my: definition.my, + at: definition.at, + of: '#parent', + collision: 'none' + }); + same(el.offset(), definition.result, "Position via " + jsDump.parse({my:definition.my, at:definition.at})); + }); +}); + +test('of', function() { + $('#elx').position({ + my: 'left top', + at: 'left top', + of: '#parentx', + collision: 'none' + }); + same($('#elx').offset(), { top: 40, left: 40 }, 'selector'); + + $('#elx').position({ + my: 'left top', + at: 'left bottom', + of: $('#parentx'), + collision: 'none' + }); + same($('#elx').offset(), { top: 60, left: 40 }, 'jQuery object'); + + $('#elx').position({ + my: 'left top', + at: 'left top', + of: $('#parentx')[0], + collision: 'none' + }); + same($('#elx').offset(), { top: 40, left: 40 }, 'DOM element'); + + $('#elx').position({ + my: 'right bottom', + at: 'right bottom', + of: document, + collision: 'none' + }); + same($('#elx').offset(), { + top: $(document).height() - 10, + left: $(document).width() - 10 + }, 'document'); + + $('#elx').position({ + my: 'right bottom', + at: 'right bottom', + of: window, + collision: 'none' + }); + same($('#elx').offset(), { + top: $(window).height() - 10, + left: $(window).width() - 10 + }, 'window'); + + $(window).scrollTop(500).scrollLeft(200); + $('#elx').position({ + my: 'right bottom', + at: 'right bottom', + of: window, + collision: 'none' + }); + same($('#elx').offset(), { + top: $(window).height() + 500 - 10, + left: $(window).width() + 200 - 10 + }, 'window, scrolled'); + $(window).scrollTop(0).scrollLeft(0); + + var event = $.extend($.Event('someEvent'), { pageX: 200, pageY: 300 }); + $('#elx').position({ + my: 'left top', + at: 'left top', + of: event, + collision: 'none' + }); + same($('#elx').offset(), { + top: 300, + left: 200 + }, 'event - left top, left top'); + + event = $.extend($.Event('someEvent'), { pageX: 400, pageY: 600 }); + $('#elx').position({ + my: 'left top', + at: 'right bottom', + of: event, + collision: 'none' + }); + same($('#elx').offset(), { + top: 600, + left: 400 + }, 'event - left top, right bottom'); +}); + +test('offset', function() { + $('#elx').position({ + my: 'left top', + at: 'left bottom', + of: '#parentx', + offset: '10', + collision: 'none' + }); + same($('#elx').offset(), { top: 70, left: 50 }, 'single value'); + + $('#elx').position({ + my: 'left top', + at: 'left bottom', + of: '#parentx', + offset: '5 -3', + collision: 'none' + }); + same($('#elx').offset(), { top: 57, left: 45 }, 'two values'); + + $('#elx').position({ + my: 'left top', + at: 'left bottom', + of: '#parentx', + offset: '5px -3px', + collision: 'none' + }); + same($('#elx').offset(), { top: 57, left: 45 }, 'with units'); +}); + +test('using', function() { + expect(6); + + var count = 0, + elems = $('#el1, #el2'), + expectedPosition = { top: 40, left: 40 }, + originalPosition = elems.position({ + my: 'right bottom', + at: 'rigt bottom', + of: '#parentx', + collision: 'none' + }).offset(); + + elems.position({ + my: 'left top', + at: 'left top', + of: '#parentx', + using: function(position) { + same(this, elems[count], 'correct context for call #' + count); + same(position, expectedPosition, 'correct position for call #' + count); + count++; + } + }); + + elems.each(function() { + same($(this).offset(), originalPosition, 'elements not moved'); + }); +}); + +function collisionTest(config, result, msg) { + var elem = $("#elx").position($.extend({ + my: "left top", + at: "right bottom", + of: window + }, config)); + same(elem.offset(), result, msg); +} + +function collisionTest2(config, result, msg) { + collisionTest($.extend({ + my: "right bottom", + at: "left top" + }, config), result, msg); +} + +test("collision: fit, no offset", function() { + collisionTest({ + collision: "fit" + }, { top: $(window).height() - 10, left: $(window).width() - 10 }, "right bottom"); + + collisionTest2({ + collision: "fit" + }, { top: 0, left: 0 }, "left top"); +}); + +test("collision: fit, with offset", function() { + collisionTest({ + collision: "fit", + offset: "2 3" + }, { top: $(window).height() - 10, left: $(window).width() - 10 }, "right bottom"); + + collisionTest2({ + collision: "fit", + offset: "2 3" + }, { top: 0, left: 0 }, "left top, positive offset"); + + collisionTest2({ + collision: "fit", + offset: "-2 -3" + }, { top: 0, left: 0 }, "left top, negative offset"); +}); + +test("collision: flip, no offset", function() { + collisionTest({ + collision: "flip" + }, { top: -10, left: -10 }, "left top"); + + collisionTest2({ + collision: "flip" + }, { top: $(window).height(), left: $(window).width() }, "right bottom"); +}); + +test("collision: flip, with offset", function() { + collisionTest({ + collision: "flip", + offset: "2 3" + }, { top: -13, left: -12 }, "left top, with offset added"); + + collisionTest2({ + collision: "flip", + offset: "2 3" + }, { top: $(window).height() - 3, left: $(window).width() - 2 }, "bottom, positive offset"); + + collisionTest2({ + collision: "flip", + offset: "-2 -3" + }, { top: $(window).height() + 3, left: $(window).width() + 2 }, "right bottom, negative offset"); +}); + +test("collision: none, no offset", function() { + collisionTest({ + collision: "none" + }, { top: $(window).height(), left: $(window).width() }, "left top"); + + collisionTest2({ + collision: "none" + }, { top: -10, left: -10 }, "moved to the right bottom"); +}); + +test("collision: none, with offset", function() { + collisionTest({ + collision: "none", + offset: "2 3" + }, { top: $(window).height() + 3, left: $(window).width() + 2 }, "right bottom, with offset added"); + + collisionTest2({ + collision: "none", + offset: "2 3" + }, { top: -7, left: -8 }, "left top, positive offset"); + + collisionTest2({ + collision: "none", + offset: "-2 -3" + }, { top: -13, left: -12 }, "left top, negative offset"); +}); + +})(jQuery); diff --git a/tests/unit/testsuite.js b/tests/unit/testsuite.js index 345a5a106..81390d59b 100644 --- a/tests/unit/testsuite.js +++ b/tests/unit/testsuite.js @@ -3,15 +3,14 @@ var hasDuplicate = false; function testWidgetDefaults(widget, defaults) { var pluginDefaults = $.extend({}, - $.widget.defaults, - $.ui[widget].defaults + $.ui[widget].prototype.options ); - // ensure that all defualts have the correct value + // ensure that all defaults have the correct value test('defined defaults', function() { $.each(defaults, function(key, val) { if ($.isFunction(val)) { - ok(val !== undefined); + ok(val !== undefined, key); return; } same(pluginDefaults[key], val, key); @@ -24,72 +23,21 @@ function testWidgetDefaults(widget, defaults) { ok(key in defaults, key); }); }); - - // defaults after init - test('defaults on init', function() { - var el = $('<div/>')[widget](), - instance = el.data(widget); - - $.each(defaults, function(key, val) { - if ($.isFunction(val)) { - ok(val !== undefined); - return; - } - same(instance.options[key], val, key); - }); - el.remove(); - }); -} - -function testSettingOptions(widget, options) { - test('option values', function() { - var el = $('<div/>')[widget](), - instance = el.data(widget); - - $.each(options, function(i, option) { - $.each({ - 'null': null, - 'false': false, - 'true': true, - zero: 0, - number: 1, - 'empty string': '', - string: 'string', - 'empty array': [], - array: ['array'], - 'empty object': {}, - object: {obj: 'ect'}, - date: new Date(), - regexp: /regexp/, - 'function': function() {} - }, function(type, val) { - el[widget]('option', option, val); - same(instance.options[option], val, option + ': ' + type); - }); - }); - - el.remove(); - }); } function testWidgetOverrides(widget) { test('$.widget overrides', function() { - $.each(['option', '_getData', '_trigger'], function(i, method) { - ok($.widget.prototype[method] == $.ui[widget].prototype[method], + $.each(['_widgetInit', 'option', '_trigger'], function(i, method) { + ok($.Widget.prototype[method] == $.ui[widget].prototype[method], 'should not override ' + method); }); }); } + function commonWidgetTests(widget, settings) { - var options = []; - $.each(settings.defaults, function(option) { - options.push(option); - }); - module(widget + ": common widget"); testWidgetDefaults(widget, settings.defaults); - testSettingOptions(widget, options); testWidgetOverrides(widget); } diff --git a/tests/unit/widget/widget.html b/tests/unit/widget/widget.html new file mode 100644 index 000000000..f28f24ca7 --- /dev/null +++ b/tests/unit/widget/widget.html @@ -0,0 +1,24 @@ +<!doctype html> +<html lang="en"> +<head> + <title>jQuery UI Widget Test Suite</title> + + <script type="text/javascript" src="../../../jquery-1.3.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> + + <link type="text/css" href="../testsuite.css" rel="stylesheet" /> + <script type="text/javascript" src="../../../external/testrunner-r6588.js"></script> + <script type="text/javascript" src="../../jquery.simulate.js"></script> + <script type="text/javascript" src="../testsuite.js"></script> + + <script type="text/javascript" src="widget.js"></script> +</head> +<body> + +<div id="main"> + +</div> + +</body> +</html> diff --git a/tests/unit/widget/widget.js b/tests/unit/widget/widget.js new file mode 100644 index 000000000..3e7d9aaa6 --- /dev/null +++ b/tests/unit/widget/widget.js @@ -0,0 +1,168 @@ +/* + * widget unit tests + */ +(function($) { + +module('widget factory', { + teardown: function() { + delete $.ui.testWidget; + } +}); + +test('widget creation', function() { + var myPrototype = { + _init: function() {}, + creationTest: function() {} + }; + + $.widget('ui.testWidget', myPrototype); + ok($.isFunction($.ui.testWidget), 'constructor was created'); + equals('object', typeof $.ui.testWidget.prototype, 'prototype was created'); + equals($.ui.testWidget.prototype._init, myPrototype._init, 'init function is copied over'); + equals($.ui.testWidget.prototype.creationTest, myPrototype.creationTest, 'random function is copied over'); + equals($.ui.testWidget.prototype.option, $.Widget.prototype.option, 'option method copied over from base widget'); +}); + +test('jQuery usage', function() { + expect(10); + + var shouldInit = false; + + $.widget('ui.testWidget', { + getterSetterVal: 5, + _init: function() { + ok(shouldInit, 'init called on instantiation'); + }, + methodWithParams: function(param1, param2) { + ok(true, 'method called via .pluginName(methodName)'); + equals(param1, 'value1', 'parameter passed via .pluginName(methodName, param)'); + equals(param2, 'value2', 'multiple parameter passed via .pluginName(methodName, param, param)'); + + return this; + }, + getterSetterMethod: function(val) { + if (val) { + this.getterSetterVal = val; + } else { + return this.getterSetterVal; + } + } + }); + + shouldInit = true; + var elem = $('<div></div>').testWidget(); + shouldInit = false; + + var instance = elem.data('testWidget'); + equals(typeof instance, 'object', 'instance stored in .data(pluginName)'); + equals(instance.element[0], elem[0], 'element stored on widget'); + var ret = elem.testWidget('methodWithParams', 'value1', 'value2'); + equals(ret, elem, 'jQuery object returned from method call'); + + ret = elem.testWidget('getterSetterMethod'); + equals(ret, 5, 'getter/setter can act as getter'); + ret = elem.testWidget('getterSetterMethod', 30); + equals(ret, elem, 'getter/setter method can be chainable'); + equals(instance.getterSetterVal, 30, 'getter/setter can act as setter'); +}); + +test('direct usage', function() { + expect(9); + + var shouldInit = false; + + $.widget('ui.testWidget', { + getterSetterVal: 5, + _init: function() { + ok(shouldInit, 'init called on instantiation'); + }, + methodWithParams: function(param1, param2) { + ok(true, 'method called via .pluginName(methodName)'); + equals(param1, 'value1', 'parameter passed via .pluginName(methodName, param)'); + equals(param2, 'value2', 'multiple parameter passed via .pluginName(methodName, param, param)'); + + return this; + }, + getterSetterMethod: function(val) { + if (val) { + this.getterSetterVal = val; + } else { + return this.getterSetterVal; + } + } + }); + + var elem = $('<div></div>')[0]; + + shouldInit = true; + var instance = new $.ui.testWidget({}, elem); + shouldInit = false; + + equals($(elem).data('testWidget'), instance, 'instance stored in .data(pluginName)'); + equals(instance.element[0], elem, 'element stored on widget'); + + var ret = instance.methodWithParams('value1', 'value2'); + equals(ret, instance, 'plugin returned from method call'); + + ret = instance.getterSetterMethod(); + equals(ret, 5, 'getter/setter can act as getter'); + instance.getterSetterMethod(30); + equals(instance.getterSetterVal, 30, 'getter/setter can act as setter'); +}); + +test('merge multiple option arguments', function() { + expect(1); + $.widget("ui.testWidget", { + _init: function() { + same(this.options, { + disabled: false, + option1: "value1", + option2: "value2", + option3: "value3", + option4: { + option4a: "valuea", + option4b: "valueb" + } + }); + } + }); + $("<div></div>").testWidget({ + option1: "valuex", + option2: "valuex", + option3: "value3", + option4: { + option4a: "valuex" + } + }, { + option1: "value1", + option2: "value2", + option4: { + option4b: "valueb" + } + }, { + option4: { + option4a: "valuea" + } + }); +}); + +test(".widget() - base", function() { + $.widget("ui.testWidget", { + _init: function() {} + }); + var div = $("<div></div>").testWidget() + same(div[0], div.testWidget("widget")[0]); +}); + +test(".widget() - overriden", function() { + var wrapper = $("<div></div>"); + $.widget("ui.testWidget", { + _init: function() {}, + widget: function() { + return wrapper; + } + }); + same(wrapper[0], $("<div></div>").testWidget().testWidget("widget")[0]); +}); + +})(jQuery); diff --git a/tests/visual/accordion/accordion_option_fillSpace_true.html b/tests/visual/accordion/accordion_option_fillSpace_true.html index d03420523..5bcee045b 100644 --- a/tests/visual/accordion/accordion_option_fillSpace_true.html +++ b/tests/visual/accordion/accordion_option_fillSpace_true.html @@ -1,51 +1,51 @@ -<!doctype html>
-<html lang="en">
-<head>
- <title>Accordion Visual Test : Accordion option autoHeight true</title>
- <link rel="stylesheet" href="../visual.css" type="text/css" />
- <link rel="stylesheet" href="../../../themes/base/ui.all.css" type="text/css">
- <script type="text/javascript" src="../../../jquery-1.3.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.accordion.js"></script>
- <script type="text/javascript">
- $(function() {
- $("#accordion").accordion({
- fillSpace: true
- });
- })
- </script>
-</head>
-<body>
-
-<div style="height: 500px; width: 500px; border: 1px solid red;">
- <div id="accordion" style="width:490px;">
- <h3><a href="#">Accordion Header 1</a></h3>
- <div style="padding-top: 1em">
- Accordion Content 1
- </div>
- <h3><a href="#">Accordion Header 2</a></h3>
- <div style="padding-top: 3em">
- Accordion Content 2
- <p>paragraph</p>
- <p>paragraph</p>
- <p>paragraph</p>
- <p>paragraph</p>
- <p>paragraph</p>
- <p>paragraph</p>
- <p>paragraph</p>
- </div>
- <h3><a href="#">Accordion Header 3</a></h3>
- <div style="padding-top: 0">
- Accordion Content 3
- <ul>
- <li>list item</li>
- <li>list item</li>
- <li>list item</li>
- </ul>
- </div>
- </div>
-</div>
-
-</body>
-</html>
+<!doctype html> +<html lang="en"> +<head> + <title>Accordion Visual Test : Accordion option autoHeight true</title> + <link rel="stylesheet" href="../visual.css" type="text/css" /> + <link rel="stylesheet" href="../../../themes/base/ui.all.css" type="text/css"> + <script type="text/javascript" src="../../../jquery-1.3.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.accordion.js"></script> + <script type="text/javascript"> + $(function() { + $("#accordion").accordion({ + fillSpace: true + }); + }) + </script> +</head> +<body> + +<div style="height: 500px; width: 500px; border: 1px solid red;"> + <div id="accordion" style="width:490px;"> + <h3><a href="#">Accordion Header 1</a></h3> + <div style="padding-top: 1em"> + Accordion Content 1 + </div> + <h3><a href="#">Accordion Header 2</a></h3> + <div style="padding-top: 3em"> + Accordion Content 2 + <p>paragraph</p> + <p>paragraph</p> + <p>paragraph</p> + <p>paragraph</p> + <p>paragraph</p> + <p>paragraph</p> + <p>paragraph</p> + </div> + <h3><a href="#">Accordion Header 3</a></h3> + <div style="padding-top: 0"> + Accordion Content 3 + <ul> + <li>list item</li> + <li>list item</li> + <li>list item</li> + </ul> + </div> + </div> +</div> + +</body> +</html> diff --git a/tests/visual/accordion/accordion_ticket_4322.html b/tests/visual/accordion/accordion_ticket_4322.html index 9d82f61ae..1bfe2a05d 100644 --- a/tests/visual/accordion/accordion_ticket_4322.html +++ b/tests/visual/accordion/accordion_ticket_4322.html @@ -1,74 +1,74 @@ -<!doctype html>
-<html lang="en">
-<head>
- <title>Accordion Visual Test : Accordion ticket #4322</title>
- <link rel="stylesheet" href="../visual.css" type="text/css" />
- <link rel="stylesheet" href="../../../themes/base/ui.all.css" type="text/css">
- <script type="text/javascript" src="../../../jquery-1.3.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.accordion.js"></script>
- <style>
- p {margin: .5em 0;}
- </style>
- <script type="text/javascript">
- $(function() {
- $("#accordion1, #accordion2").accordion();
- })
- </script>
-</head>
-<body>
-
-<h1 class="ui-widget-header"><a href="http://dev.jqueryui.com/ticket/4322">#4322 - Accordion going smaller and smaller in IE 6</a></h1>
-
- <div id="accordion1" style="width:200px">
- <h3><a href="#">Section 1</a></h3>
- <div>
-
- <p>
- Mauris mauris ante, blandit et, ultrices a, suscipit eget, quam. Integer
- ut neque. Vivamus nisi metus, molestie vel, gravida in, condimentum sit
- amet, nunc. Nam a nibh. Donec suscipit eros. Nam mi. Proin viverra leo ut
- odio. Curabitur malesuada. Vestibulum a velit eu ante scelerisque vulputate.
- </p>
- </div>
- <h3><a href="#">Section 2</a></h3>
- <div>
- <p>
- Sed non urna. Donec et ante. Phasellus eu ligula. Vestibulum sit amet
- purus. Vivamus hendrerit, dolor at aliquet laoreet, mauris turpis porttitor
- velit, faucibus interdum tellus libero ac justo. Vivamus non quam. In
- suscipit faucibus urna.
- </p>
- </div>
- </div>
-
- content below
-
- <div id="accordion2">
- <h3><a href="#">Section 1</a></h3>
- <div>
-
- <p>
- Mauris mauris ante, blandit et, ultrices a, suscipit eget, quam. Integer
- ut neque. Vivamus nisi metus, molestie vel, gravida in, condimentum sit
- amet, nunc. Nam a nibh. Donec suscipit eros. Nam mi. Proin viverra leo ut
- odio. Curabitur malesuada. Vestibulum a velit eu ante scelerisque vulputate.
- </p>
- </div>
- <h3><a href="#">Section 2</a></h3>
- <div>
- <p>
- Sed non urna. Donec et ante. Phasellus eu ligula. Vestibulum sit amet
- purus. Vivamus hendrerit, dolor at aliquet laoreet, mauris turpis porttitor
- velit, faucibus interdum tellus libero ac justo. Vivamus non quam. In
- suscipit faucibus urna.
- </p>
- </div>
- </div>
-
- content below
-
-
-</body>
-</html>
+<!doctype html> +<html lang="en"> +<head> + <title>Accordion Visual Test : Accordion ticket #4322</title> + <link rel="stylesheet" href="../visual.css" type="text/css" /> + <link rel="stylesheet" href="../../../themes/base/ui.all.css" type="text/css"> + <script type="text/javascript" src="../../../jquery-1.3.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.accordion.js"></script> + <style> + p {margin: .5em 0;} + </style> + <script type="text/javascript"> + $(function() { + $("#accordion1, #accordion2").accordion(); + }) + </script> +</head> +<body> + +<h1 class="ui-widget-header"><a href="http://dev.jqueryui.com/ticket/4322">#4322 - Accordion going smaller and smaller in IE 6</a></h1> + + <div id="accordion1" style="width:200px"> + <h3><a href="#">Section 1</a></h3> + <div> + + <p> + Mauris mauris ante, blandit et, ultrices a, suscipit eget, quam. Integer + ut neque. Vivamus nisi metus, molestie vel, gravida in, condimentum sit + amet, nunc. Nam a nibh. Donec suscipit eros. Nam mi. Proin viverra leo ut + odio. Curabitur malesuada. Vestibulum a velit eu ante scelerisque vulputate. + </p> + </div> + <h3><a href="#">Section 2</a></h3> + <div> + <p> + Sed non urna. Donec et ante. Phasellus eu ligula. Vestibulum sit amet + purus. Vivamus hendrerit, dolor at aliquet laoreet, mauris turpis porttitor + velit, faucibus interdum tellus libero ac justo. Vivamus non quam. In + suscipit faucibus urna. + </p> + </div> + </div> + + content below + + <div id="accordion2"> + <h3><a href="#">Section 1</a></h3> + <div> + + <p> + Mauris mauris ante, blandit et, ultrices a, suscipit eget, quam. Integer + ut neque. Vivamus nisi metus, molestie vel, gravida in, condimentum sit + amet, nunc. Nam a nibh. Donec suscipit eros. Nam mi. Proin viverra leo ut + odio. Curabitur malesuada. Vestibulum a velit eu ante scelerisque vulputate. + </p> + </div> + <h3><a href="#">Section 2</a></h3> + <div> + <p> + Sed non urna. Donec et ante. Phasellus eu ligula. Vestibulum sit amet + purus. Vivamus hendrerit, dolor at aliquet laoreet, mauris turpis porttitor + velit, faucibus interdum tellus libero ac justo. Vivamus non quam. In + suscipit faucibus urna. + </p> + </div> + </div> + + content below + + +</body> +</html> diff --git a/tests/visual/accordion/accordion_ticket_4444.html b/tests/visual/accordion/accordion_ticket_4444.html index 121bf0cef..4cce368d3 100644 --- a/tests/visual/accordion/accordion_ticket_4444.html +++ b/tests/visual/accordion/accordion_ticket_4444.html @@ -1,50 +1,50 @@ -<!doctype html>
-<html lang="en">
-<head>
- <title>Accordion Visual Test : Accordion ticket #4444</title>
- <link rel="stylesheet" href="../visual.css" type="text/css" />
- <link rel="stylesheet" href="../../../themes/base/ui.all.css" type="text/css">
- <script type="text/javascript" src="../../../jquery-1.3.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.accordion.js"></script>
- <script type="text/javascript">
- $(function() {
- $("#accordion").accordion({
- autoHeight: false
- });
- })
- </script>
-</head>
-<body>
-
-<h1 class="ui-widget-header"><a href="http://dev.jqueryui.com/ticket/4444">#4444 - Accordion Content disappears with autoHeight set to false in IE 6</a></h1>
-
-<div id="accordion" >
- <h3><a href="#">Section 1</a></h3>
- <div >
- Accordion Content 1<br>
- <a href="#">Link Test #1</a>
- </div>
-
- <h3><a href="#">Section 2</a></h3>
- <div>
- <a href="#" >Accordion Content 2</a>
- </div>
- <h3><a href="#">Section 3</a></h3>
- <div>
- <p>Accordion Content 3 </p>
- <ul>
- <li>List item</li>
- <li>List item</li>
- <li>List item</li>
- <li>List item</li>
- <li>List item</li>
- <li>List item</li>
- <li>List item</li>
- </ul>
- </div>
-</div>
-
-</body>
-</html>
+<!doctype html> +<html lang="en"> +<head> + <title>Accordion Visual Test : Accordion ticket #4444</title> + <link rel="stylesheet" href="../visual.css" type="text/css" /> + <link rel="stylesheet" href="../../../themes/base/ui.all.css" type="text/css"> + <script type="text/javascript" src="../../../jquery-1.3.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.accordion.js"></script> + <script type="text/javascript"> + $(function() { + $("#accordion").accordion({ + autoHeight: false + }); + }) + </script> +</head> +<body> + +<h1 class="ui-widget-header"><a href="http://dev.jqueryui.com/ticket/4444">#4444 - Accordion Content disappears with autoHeight set to false in IE 6</a></h1> + +<div id="accordion" > + <h3><a href="#">Section 1</a></h3> + <div > + Accordion Content 1<br> + <a href="#">Link Test #1</a> + </div> + + <h3><a href="#">Section 2</a></h3> + <div> + <a href="#" >Accordion Content 2</a> + </div> + <h3><a href="#">Section 3</a></h3> + <div> + <p>Accordion Content 3 </p> + <ul> + <li>List item</li> + <li>List item</li> + <li>List item</li> + <li>List item</li> + <li>List item</li> + <li>List item</li> + <li>List item</li> + </ul> + </div> +</div> + +</body> +</html> diff --git a/tests/visual/button/default.html b/tests/visual/button/default.html new file mode 100644 index 000000000..4eb457fc4 --- /dev/null +++ b/tests/visual/button/default.html @@ -0,0 +1,137 @@ +<!DOCTYPE html> +<html lang="en"> +<head> + <title>Button Visual push: Default</title> + <link rel="stylesheet" href="../visual.css" type="text/css" /> + <link rel="stylesheet" href="../../../themes/base/ui.all.css" type="text/css"> + <style type="text/css"> + #toolbar { margin-top: 2em; padding:0.2em; } + #ops1, #ops2, #format, #mode { margin-right: 1em } + </style> + <script type="text/javascript" src="../../../jquery-1.3.2.js"></script> + <script type="text/javascript" src="../../../external/jquery.metadata.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.button.js"></script> + <script type="text/javascript"> + $(function() { + var buttons = $('#push button, #check').button(); + var buttonSets = $('#radio0, #radio1, #radio2, #ops1, #format, #ops2, #mode, #inputs, #anchors').buttonset(); + + buttons.add(buttonSets).click(function(event) { + var target = $(event.target); + if (target.closest('.ui-button').length) { + $("<div></div>") + .text("Clicked " + (target.text() || target.val())) + .appendTo("#log"); + } + }); + + $("#disable-widgets").toggle(function() { + buttons.button("disable"); + buttonSets.buttonset("disable"); + }, function() { + buttons.button("enable"); + buttonSets.buttonset("enable"); + }); + $("#toggle-widgets").toggle(function() { + buttons.button(); + buttonSets.buttonset(); + }, function() { + buttons.button("destroy"); + buttonSets.buttonset("destroy"); + }).click(); + }); + </script> +</head> +<body> + +<div id="push"> + <div> + No icon + <button>Simple button, only text</button> + <button class="ui-priority-secondary">Secondary priority button</button> + </div> + <br/> + <div> + With icon + <button class="{button:{icons:{primary:'ui-icon-locked'},text:false}}">Button with icon only</button> + <button class="{button:{icons:{primary:'ui-icon-locked'}}}">Button with icon on the left</button> + <button class="{button:{icons:{primary:'ui-icon-gear',secondary:'ui-icon-triangle-1-s'}}}">Button with two icons</button> + <button class="{button:{icons:{primary:'ui-icon-gear',secondary:'ui-icon-triangle-1-s'},text:false}}">Button with two icons</button> + </div> +</div> + +<div id="toggle" style="margin-top: 2em;"> + <input type="checkbox" id="check" /><label for="check">Toggle</label> +</div> + +<div id="radio0" style="margin-top: 2em;"> + <input type="radio" id="radio01" name="radio" checked="checked" /><label for="radio01">Choice 1</label> + <input type="radio" id="radio02" name="radio" /><label for="radio02">Choice 2</label> + <input type="radio" id="radio03" name="radio" /><label for="radio03">Choice 3</label> +</div> +<form> + <div id="radio1" style="margin-top: 2em;"> + <input type="radio" id="radio11" name="radio" /><label for="radio11">Choice 1</label> + <input type="radio" id="radio12" name="radio" checked="checked" /><label for="radio12">Choice 2</label> + <input type="radio" id="radio13" name="radio" /><label for="radio13">Choice 3</label> + </div> +</form> +<form> + <div id="radio2" style="margin-top: 2em;"> + <input type="radio" id="radio21" name="radio" /><label for="radio21">Choice 1</label> + <input type="radio" id="radio22" name="radio" /><label for="radio22">Choice 2</label> + <input type="radio" id="radio23" name="radio" checked="checked" /><label for="radio23">Choice 3</label> + </div> +</form> + +<div id="toolbar" class="ui-widget-header ui-corner-all ui-helper-clearfix"> + <span id="ops1"> + <button class="{button:{icons:{primary:'ui-icon-folder-open'},text:false}}">Open</button> + <button class="{button:{icons:{primary:'ui-icon-disk'},text:false}}">Save</button> + <button class="{button:{icons:{primary:'ui-icon-trash'},text:false}}">Delete</button> + </span> + <span id="format"> + <input type="checkbox" id="check1" /><label for="check1">B</label> + <input type="checkbox" id="check2" /><label for="check2">I</label> + <input type="checkbox" id="check3" /><label for="check3">U</label> + </span> + <span id="ops2"> + <button class="{button:{icons:{primary:'ui-icon-print'},text:false}}">Print...</button> + <button class="{button:{icons:{primary:'ui-icon-mail-closed'},text:false}}">Mail to...</button> + </span> + <span id="mode"> + <input type="radio" id="mode1" name="radio2" checked="checked" /><label for="mode1">Edit</label> + <input type="radio" id="mode2" name="radio2" /><label for="mode2">View</label> + </span> +</div> + +<div id="inputs" style="margin-top: 2em;"> + <input type="submit" value="Submit button" /> + <input type="reset" value="Reset button" class="{button:{label:'Custom reset'}}" /> +</div> + +<div id="anchors" style="margin-top: 2em;"> + <a href="#">Anchor 1</a> + <a href="#" class="{button:{icons:{primary:'ui-icon-print'},text:false}}">Anchor 2</a> + <a href="#" class="{button:{icons:{primary:'ui-icon-mail-closed'},text:false}}">Anchor 3</a> + <a href="#">Anchor 4</a> +</div> + +<div style="margin-top: 2em;"> + <button id="disable-widgets">Toggle disabled</button> + <button id="toggle-widgets">Toggle widget</button> +</div> +<div id="log"></div> + +<script type="text/javascript" src="http://jqueryui.com/themeroller/themeswitchertool/"></script> +<script type="text/javascript"> + $.fn.themeswitcher && $('<div></div>').css({ + position: "absolute", + right: 10, + top: 10 + }).appendTo(document.body).themeswitcher(); +</script> +</body> +</html> diff --git a/tests/visual/dialog/dialog_option_modal_false.html b/tests/visual/dialog/dialog_option_modal_false.html index 2a77881d9..45dad2fc3 100644 --- a/tests/visual/dialog/dialog_option_modal_false.html +++ b/tests/visual/dialog/dialog_option_modal_false.html @@ -21,7 +21,7 @@ </script> </head> <body> - +<input /> <div id="dialog" title="Dialog Title"> <p> Dialog Content </p> </div> diff --git a/tests/visual/dialog/dialog_option_modal_true.html b/tests/visual/dialog/dialog_option_modal_true.html index 4ee3ded23..b6e10e0d0 100644 --- a/tests/visual/dialog/dialog_option_modal_true.html +++ b/tests/visual/dialog/dialog_option_modal_true.html @@ -21,7 +21,7 @@ </script> </head> <body> - +<input /> <div id="dialog" title="Dialog Title"> <p> Dialog Content </p> </div> diff --git a/tests/visual/index.html b/tests/visual/index.html index 8f322f627..465dbc021 100644 --- a/tests/visual/index.html +++ b/tests/visual/index.html @@ -25,6 +25,7 @@ <h2>Widgets</h2> <ul> <li><a href="accordion/default.html">Accordion</a></li> + <li><a href="button/default.html">Button</a></li> <li><a href="datepicker/default.html">Datepicker</a></li> <li><a href="dialog/default.html">Dialog</a></li> <li><a href="progressbar/default.html">Progressbar</a></li> diff --git a/tests/visual/sortable/sortable_ticket_4551.html b/tests/visual/sortable/sortable_ticket_4551.html index 8188d33f8..73f5791d6 100644 --- a/tests/visual/sortable/sortable_ticket_4551.html +++ b/tests/visual/sortable/sortable_ticket_4551.html @@ -1,53 +1,53 @@ -<!doctype html>
-<html lang="en">
-<head>
- <title>Sortable Visual Test : Sortable ticket #4551</title>
- <link rel="stylesheet" href="../visual.css" type="text/css" />
- <link rel="stylesheet" href="../../../themes/base/ui.all.css" type="text/css">
- <script type="text/javascript" src="../../../jquery-1.3.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.mouse.js"></script>
- <script type="text/javascript" src="../../../ui/jquery.ui.sortable.js"></script>
- <script type="text/javascript">
- $(function() {
- $("#first, #second").sortable({
- connectWith: '.sortable'
- }).disableSelection();
- });
- </script>
- <style type="text/css">
- .sortable { margin: 0; padding: 0; }
- .sortable div { margin: 3px 3px 3px 0; background: #ccc; padding: 1px; border: 1px solid black; float:left; width: 100px; height: 140px; font-size: 1em; text-align: center; }
- #second div { background: #acc; }
- </style>
-</head>
-<body>
-
-<h1 class="ui-widget-header"><a href="http://dev.jqueryui.com/ticket/4551">#4551 - Sortable connectWith fails if item is floated</a></h1>
-
-<div id="first" class="sortable">
- <div>1</div>
- <div>2</div>
- <div>3</div>
- <div>4</div>
- <div>5</div>
- <div>6</div>
- <div>7</div>
- <div>8</div>
- <div>9</div>
- <div>10</div>
- <div>11</div>
- <div>12</div>
-</div>
-
-<br style="clear:both;">
-<hr />
-
-<div id="second" class="sortable">
- <div>12</div>
- <div>14</div>
-</div>
-
-</body>
-</html>
+<!doctype html> +<html lang="en"> +<head> + <title>Sortable Visual Test : Sortable ticket #4551</title> + <link rel="stylesheet" href="../visual.css" type="text/css" /> + <link rel="stylesheet" href="../../../themes/base/ui.all.css" type="text/css"> + <script type="text/javascript" src="../../../jquery-1.3.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.mouse.js"></script> + <script type="text/javascript" src="../../../ui/jquery.ui.sortable.js"></script> + <script type="text/javascript"> + $(function() { + $("#first, #second").sortable({ + connectWith: '.sortable' + }).disableSelection(); + }); + </script> + <style type="text/css"> + .sortable { margin: 0; padding: 0; } + .sortable div { margin: 3px 3px 3px 0; background: #ccc; padding: 1px; border: 1px solid black; float:left; width: 100px; height: 140px; font-size: 1em; text-align: center; } + #second div { background: #acc; } + </style> +</head> +<body> + +<h1 class="ui-widget-header"><a href="http://dev.jqueryui.com/ticket/4551">#4551 - Sortable connectWith fails if item is floated</a></h1> + +<div id="first" class="sortable"> + <div>1</div> + <div>2</div> + <div>3</div> + <div>4</div> + <div>5</div> + <div>6</div> + <div>7</div> + <div>8</div> + <div>9</div> + <div>10</div> + <div>11</div> + <div>12</div> +</div> + +<br style="clear:both;"> +<hr /> + +<div id="second" class="sortable"> + <div>12</div> + <div>14</div> +</div> + +</body> +</html> |