]> source.dussan.org Git - jquery-ui.git/commitdiff
autodrag - Added beginning of selectables tests
authorRichard Worth <rdworth@gmail.com>
Tue, 27 May 2008 02:35:36 +0000 (02:35 +0000)
committerRichard Worth <rdworth@gmail.com>
Tue, 27 May 2008 02:35:36 +0000 (02:35 +0000)
ui/tests/autodrag.html
ui/tests/ui.testmouse.js

index bb005b51807876bf81b3b7a03f1e512f848de3b7..8f436576fcb598a41eaab0e6054b50e54b789a9b 100644 (file)
@@ -1,10 +1,11 @@
 <!DOCTYPE html>\r
 <html lang="en">\r
 <head>\r
-       <title>Draggable - Automated Test Page</title>\r
+       <title>jQuery UI - Automated Tests</title>\r
        <script type="text/javascript" src="../../jquery/jquery-1.2.6.js"></script>\r
        <script type="text/javascript" src="../../ui/source/ui.core.js"></script>\r
        <script type="text/javascript" src="../../ui/source/ui.draggable.js"></script>\r
+       <script type="text/javascript" src="../../ui/source/ui.selectable.js"></script>\r
 \r
        <script type="text/javascript" src="ui.testmouse.js"></script>\r
 \r
 html, body { height: 100%; }\r
 #main { height: 100%; }\r
 \r
-#foo { position: relative; margin: 10px; padding: 10px; border: 3px solid gray; cursor: move; width: 200px; height: 100px; background: #eef; text-align: center; }\r
+#foo { position: relative; margin: 10px; padding: 10px; border: 3px solid gray; width: 200px; height: 200px; background: #eef; text-align: center; }\r
+#foo * { margin: 4px; }\r
 .ui-draggable .msg-missing-class { display: none !important; background: red; color: white; font-weight: bold; }\r
 .ui-draggable .msg-enabled { display: block; }\r
 .ui-draggable .msg-disabled { display: none; }\r
 .ui-draggable-disabled .msg-enabled { display: none !important; }\r
 .ui-draggable-disabled .msg-disabled { display: block !important; }\r
+.ui-selectable .msg-missing-class { display: none !important; background: red; color: white; font-weight: bold; }\r
+.ui-selectable .msg-enabled { display: block; }\r
+.ui-selectable .msg-disabled { display: none; }\r
+.ui-selectable-disabled .msg-enabled { display: none !important; }\r
+.ui-selectable-disabled .msg-disabled { display: block !important; }\r
+//.ui-selectee { border: 1px solid white; }\r
+.ui-selecting { background: Highlight; color: HighlightText; outline: 1px dotted white; }\r
+.ui-selected { background: Highlight; color: HighlightText; outline: 1px dotted black; }\r
 \r
 </style>\r
 \r
-<script type="text/javascript">\r
-\r
-\r
-</script>\r
-\r
 <script type="text/javascript">\r
 $(function() {\r
 \r
-       var speed = "slow"\r
+       var speed = "fast";\r
 \r
        var queue;\r
        var start = function() {\r
@@ -67,11 +72,19 @@ $(function() {
        \r
        var setupAndRun = function(nTest) {\r
                $('#testnum').text(nTest.num);\r
-               $('#sandbox').hide().append('<div id="foo">' + \r
-                       '<div class="msg-missing-class">THIS TEXT SHOULD NOT BE VISIBLE</div>' +\r
-                       '<div class="msg-enabled">enabled</div>' +\r
-                       '<div class="msg-disabled">disabled</div>' +\r
-                       '</div>');\r
+               $('#sandbox').hide()\r
+                       .append('<ul id="foo">' + \r
+                               '<li class="msg-missing-class">THIS TEXT SHOULD NOT BE VISIBLE</li>' +\r
+                               '<li class="msg-enabled">enabled</li>' +\r
+                               '<li class="msg-disabled">disabled</li>' +\r
+                               '<li>Item 2</li>' +\r
+                               '<li>Item 3</li>' +\r
+                               '<li>Item 4</li>' +\r
+                               '<li>Item 5</li>' +\r
+                               '<li>Item 6</li>' +\r
+                               '<li>Item 7</li>' +\r
+                               '<li>Item 8</li>' +\r
+                       '</ul>')\r
                $('#foo').testMouse({\r
                        speed: speed,\r
                        complete: nextTest\r
@@ -85,20 +98,27 @@ $(function() {
                $('#foo').remove();\r
                if ($.isFunction(fn)) fn.apply();\r
        }\r
+       var plugin = "draggable";\r
+       plugin = "selectable"\r
+       var testFn = "testMouse";\r
+       var testArgs = ["drag", 40, 50];\r
        //1\r
-       addTest(function() { $("#foo").draggable().testMouse("drag", 100, 100); });\r
+       addTest(function() { $("#foo")[plugin]()[testFn].apply($("#foo"), testArgs); });\r
        //2\r
-       addTest(function() { $("#foo").draggable({ disabled: true }).testMouse("drag", 100, 100); });\r
-       addTest(function() { $("#foo").draggable({ disabled: false }).testMouse("drag", 100, 100); });\r
+       addTest(function() { $("#foo")[plugin]({ disabled: true })[testFn].apply($("#foo"), testArgs); });\r
+       addTest(function() { $("#foo")[plugin]({ disabled: false })[testFn].apply($("#foo"), testArgs); });\r
        //4\r
-       addTest(function() { $("#foo").draggable().draggable('disable').testMouse("drag", 100, 100); });\r
-       addTest(function() { $("#foo").draggable().draggable('enable').testMouse("drag", 100, 100); });\r
+       addTest(function() { $("#foo")[plugin]()[plugin]('disable')[testFn].apply($("#foo"), testArgs); });\r
+       addTest(function() { $("#foo")[plugin]()[plugin]('enable')[testFn].apply($("#foo"), testArgs); });\r
        //6\r
-       addTest(function() { $("#foo").draggable().draggable('enable').draggable('disable').testMouse("drag", 100, 100); });\r
-       addTest(function() { $("#foo").draggable().draggable('disable').draggable('enable').testMouse("drag", 100, 100); });\r
+       addTest(function() { $("#foo")[plugin]()[plugin]('enable')[plugin]('disable')[testFn].apply($("#foo"), testArgs); });\r
+       addTest(function() { $("#foo")[plugin]()[plugin]('disable')[plugin]('enable')[testFn].apply($("#foo"), testArgs); });\r
        //8\r
-       addTest(function() { $("#foo").draggable({ disabled: false }).draggable('disable').testMouse("drag", 100, 100); });\r
-       addTest(function() { $("#foo").draggable({ disabled: true }).draggable('enable').testMouse("drag", 100, 100); });\r
+       addTest(function() { $("#foo")[plugin]({ disabled: false })[plugin]('disable')[testFn].apply($("#foo"), testArgs); });\r
+       addTest(function() { $("#foo")[plugin]({ disabled: true })[plugin]('enable')[testFn].apply($("#foo"), testArgs); });\r
+       //10\r
+       addTest(function() { $("#foo")[plugin]({ disabled: false }).data('disabled.' + plugin, true)[testFn].apply($("#foo"), testArgs); });\r
+       addTest(function() { $("#foo")[plugin]({ disabled: true }).data('disabled.' + plugin, false)[testFn].apply($("#foo"), testArgs); });\r
 \r
        $('#begin').click(function() {\r
                start();\r
@@ -112,7 +132,7 @@ $(function() {
 \r
 <div id="main">\r
 \r
-       <h1>jQuery UI Draggable - Automated Test</h1>\r
+       <h1>jQuery UI - Automated Tests</h1>\r
 \r
        <div>\r
                Status: <span id="status">Ready</span>\r
index d629e4bffe5b67734bd2260598087bfc17891c8c..5b73ab0130f64595fb0596c045129853bc4a5cb6 100644 (file)
        \r
        var mouseX = 0;\r
        var mouseY = 0;\r
-\r
+       \r
+       $(function() {\r
+               $(document).mousemove(function(e) {\r
+                       if (e.isTrusted !== false) {\r
+                               mouseX = e.pageX;\r
+                               mouseY = e.pageY;\r
+                       }\r
+               });\r
+       });\r
+       \r
        $.widget("ui.testMouse", {\r
                trackMouse: function() {},\r
                init: function() {\r
-                       var self = this;\r
-                       this.trackMouse = function(e) {\r
-                               if (e.isTrusted !== false) {\r
-                                       mouseX = e.pageX;\r
-                                       mouseY = e.pageY;\r
-                               }\r
-                       }\r
-                       $(document).bind("mousemove", this.trackMouse);\r
                },\r
                destroy: function() {\r
-                       $(document).unbind("mousemove", this.trackMouse);\r
                },\r
                center: function(offset) {\r
                        var o = this.element.offset();\r