diff options
Diffstat (limited to 'tests')
55 files changed, 0 insertions, 645 deletions
diff --git a/tests/autodrag.html b/tests/autodrag.html deleted file mode 100644 index 841bb026e..000000000 --- a/tests/autodrag.html +++ /dev/null @@ -1,156 +0,0 @@ -<!DOCTYPE html> -<html lang="en"> -<head> - <title>jQuery UI - Automated Tests</title> - - <script type="text/javascript" src="../jquery-1.2.6.js"></script> - <script type="text/javascript" src="../ui/ui.core.js"></script> - <script type="text/javascript" src="../ui/ui.draggable.js"></script> - <script type="text/javascript" src="../ui/ui.selectable.js"></script> - - <script type="text/javascript" src="simulate/jquery.simulate.js"></script> - <script type="text/javascript" src="ui.testmouse.js"></script> - -<style type="text/css"> - -html, body { height: 100%; } -#main { height: 100%; } - -#foo { position: relative; margin: 10px; padding: 10px; border: 3px solid gray; width: 200px; height: 200px; background: #eef; text-align: center; } -#foo * { margin: 4px; } -.ui-draggable .msg-missing-class { display: none !important; background: red; color: white; font-weight: bold; } -.ui-draggable .msg-enabled { display: block; } -.ui-draggable .msg-disabled { display: none; } -.ui-draggable-disabled .msg-enabled { display: none !important; } -.ui-draggable-disabled .msg-disabled { display: block !important; } -.ui-selectable .msg-missing-class { display: none !important; background: red; color: white; font-weight: bold; } -.ui-selectable .msg-enabled { display: block; } -.ui-selectable .msg-disabled { display: none; } -.ui-selectable-disabled .msg-enabled { display: none !important; } -.ui-selectable-disabled .msg-disabled { display: block !important; } -//.ui-selectee { border: 1px solid white; } -.ui-selecting { background: Highlight; color: HighlightText; outline: 1px dotted white; } -.ui-selected { background: Highlight; color: HighlightText; outline: 1px dotted black; } - -</style> - -<script type="text/javascript"> -$(function() { - - var speed = "fast"; - - var queue; - var start = function() { - queue = tests.slice().reverse(); // clone - $("#status").text("Running..."); - nextTest(); - } - var stop = function() { - $("#status").text("Ready"); - teardown(); - } - - var tests = []; - var nextTest = function() { - if (queue.length) { - var nTest = queue.pop(); - teardown(function() { - setupAndRun(nTest); - }); - } else { - stop(); - } - } - - var num = 0; - - var addTest = function(fn) { - num += 1; - tests.push({ - num: num, - fn: fn - }); - } - - var setupAndRun = function(nTest) { - $('#testnum').text(nTest.num); - $('#sandbox').hide() - .append('<ul id="foo">' + - '<li class="msg-missing-class">THIS TEXT SHOULD NOT BE VISIBLE</li>' + - '<li class="msg-enabled">enabled</li>' + - '<li class="msg-disabled">disabled</li>' + - '<li>Item 2</li>' + - '<li>Item 3</li>' + - '<li>Item 4</li>' + - '<li>Item 5</li>' + - '<li>Item 6</li>' + - '<li>Item 7</li>' + - '<li>Item 8</li>' + - '</ul>') - $('#foo').testMouse({ - speed: speed, - complete: nextTest - }); - $('#sandbox').show(); - nTest.fn.apply(nTest.fn); - } - - var teardown = function(fn) { - $('#sandbox').hide(); - $('#foo').remove(); - if ($.isFunction(fn)) fn.apply(); - } - var plugin = "draggable"; - //plugin = "selectable" - var testFn = "testMouse"; - var testArgs = ["drag", 40, 50]; - //1 - addTest(function() { $("#foo")[plugin]()[testFn].apply($("#foo"), testArgs); }); - //2 - addTest(function() { $("#foo")[plugin]({ disabled: true })[testFn].apply($("#foo"), testArgs); }); - addTest(function() { $("#foo")[plugin]({ disabled: false })[testFn].apply($("#foo"), testArgs); }); - //4 - addTest(function() { $("#foo")[plugin]()[plugin]('disable')[testFn].apply($("#foo"), testArgs); }); - addTest(function() { $("#foo")[plugin]()[plugin]('enable')[testFn].apply($("#foo"), testArgs); }); - //6 - addTest(function() { $("#foo")[plugin]()[plugin]('enable')[plugin]('disable')[testFn].apply($("#foo"), testArgs); }); - addTest(function() { $("#foo")[plugin]()[plugin]('disable')[plugin]('enable')[testFn].apply($("#foo"), testArgs); }); - //8 - addTest(function() { $("#foo")[plugin]({ disabled: false })[plugin]('disable')[testFn].apply($("#foo"), testArgs); }); - addTest(function() { $("#foo")[plugin]({ disabled: true })[plugin]('enable')[testFn].apply($("#foo"), testArgs); }); - //10 - addTest(function() { $("#foo")[plugin]({ disabled: false }).data('disabled.' + plugin, true)[testFn].apply($("#foo"), testArgs); }); - addTest(function() { $("#foo")[plugin]({ disabled: true }).data('disabled.' + plugin, false)[testFn].apply($("#foo"), testArgs); }); - - $('#begin').click(function() { - start(); - }); - -}); -</script> - -</head> -<body> - -<div id="main"> - - <h1>jQuery UI - Automated Tests</h1> - - <div> - Status: <span id="status">Ready</span> - </div> - - <div> - Test: <span id="testnum"></span> - </div> - - <div style="height: 3em;"><button id="begin">Run Test</button></div> - - <div id="sandbox"> - - </div> - -</div> - -</body> -</html> diff --git a/tests/cursors/linux/auto.png b/tests/cursors/linux/auto.png Binary files differdeleted file mode 100644 index 03ac2f281..000000000 --- a/tests/cursors/linux/auto.png +++ /dev/null diff --git a/tests/cursors/linux/crosshair.png b/tests/cursors/linux/crosshair.png Binary files differdeleted file mode 100644 index 30904f933..000000000 --- a/tests/cursors/linux/crosshair.png +++ /dev/null diff --git a/tests/cursors/linux/default.png b/tests/cursors/linux/default.png Binary files differdeleted file mode 100644 index 03ac2f281..000000000 --- a/tests/cursors/linux/default.png +++ /dev/null diff --git a/tests/cursors/linux/e-resize.png b/tests/cursors/linux/e-resize.png Binary files differdeleted file mode 100644 index b4c40ff17..000000000 --- a/tests/cursors/linux/e-resize.png +++ /dev/null diff --git a/tests/cursors/linux/help.png b/tests/cursors/linux/help.png Binary files differdeleted file mode 100644 index a6b5836d6..000000000 --- a/tests/cursors/linux/help.png +++ /dev/null diff --git a/tests/cursors/linux/move.png b/tests/cursors/linux/move.png Binary files differdeleted file mode 100644 index 39ae04520..000000000 --- a/tests/cursors/linux/move.png +++ /dev/null diff --git a/tests/cursors/linux/n-resize.png b/tests/cursors/linux/n-resize.png Binary files differdeleted file mode 100644 index afef5b438..000000000 --- a/tests/cursors/linux/n-resize.png +++ /dev/null diff --git a/tests/cursors/linux/ne-resize.png b/tests/cursors/linux/ne-resize.png Binary files differdeleted file mode 100644 index 8c5e970e1..000000000 --- a/tests/cursors/linux/ne-resize.png +++ /dev/null diff --git a/tests/cursors/linux/none.cur b/tests/cursors/linux/none.cur Binary files differdeleted file mode 100644 index 4f7970a9f..000000000 --- a/tests/cursors/linux/none.cur +++ /dev/null diff --git a/tests/cursors/linux/none.png b/tests/cursors/linux/none.png Binary files differdeleted file mode 100644 index 3b34811c5..000000000 --- a/tests/cursors/linux/none.png +++ /dev/null diff --git a/tests/cursors/linux/nw-resize.png b/tests/cursors/linux/nw-resize.png Binary files differdeleted file mode 100644 index 7c17be53e..000000000 --- a/tests/cursors/linux/nw-resize.png +++ /dev/null diff --git a/tests/cursors/linux/pointer.png b/tests/cursors/linux/pointer.png Binary files differdeleted file mode 100644 index b39fcef8f..000000000 --- a/tests/cursors/linux/pointer.png +++ /dev/null diff --git a/tests/cursors/linux/s-resize.png b/tests/cursors/linux/s-resize.png Binary files differdeleted file mode 100644 index afef5b438..000000000 --- a/tests/cursors/linux/s-resize.png +++ /dev/null diff --git a/tests/cursors/linux/se-resize.png b/tests/cursors/linux/se-resize.png Binary files differdeleted file mode 100644 index 7c17be53e..000000000 --- a/tests/cursors/linux/se-resize.png +++ /dev/null diff --git a/tests/cursors/linux/sw-resize.png b/tests/cursors/linux/sw-resize.png Binary files differdeleted file mode 100644 index 8c5e970e1..000000000 --- a/tests/cursors/linux/sw-resize.png +++ /dev/null diff --git a/tests/cursors/linux/text.png b/tests/cursors/linux/text.png Binary files differdeleted file mode 100644 index 85a54fcb7..000000000 --- a/tests/cursors/linux/text.png +++ /dev/null diff --git a/tests/cursors/linux/w-resize.png b/tests/cursors/linux/w-resize.png Binary files differdeleted file mode 100644 index b4c40ff17..000000000 --- a/tests/cursors/linux/w-resize.png +++ /dev/null diff --git a/tests/cursors/mac/auto.png b/tests/cursors/mac/auto.png Binary files differdeleted file mode 100644 index 65b21e435..000000000 --- a/tests/cursors/mac/auto.png +++ /dev/null diff --git a/tests/cursors/mac/crosshair.png b/tests/cursors/mac/crosshair.png Binary files differdeleted file mode 100644 index b4f165b6a..000000000 --- a/tests/cursors/mac/crosshair.png +++ /dev/null diff --git a/tests/cursors/mac/default.png b/tests/cursors/mac/default.png Binary files differdeleted file mode 100644 index 65b21e435..000000000 --- a/tests/cursors/mac/default.png +++ /dev/null diff --git a/tests/cursors/mac/e-resize.png b/tests/cursors/mac/e-resize.png Binary files differdeleted file mode 100644 index 583ce1862..000000000 --- a/tests/cursors/mac/e-resize.png +++ /dev/null diff --git a/tests/cursors/mac/help.png b/tests/cursors/mac/help.png Binary files differdeleted file mode 100644 index 5e8ee5870..000000000 --- a/tests/cursors/mac/help.png +++ /dev/null diff --git a/tests/cursors/mac/move.png b/tests/cursors/mac/move.png Binary files differdeleted file mode 100644 index cf7608539..000000000 --- a/tests/cursors/mac/move.png +++ /dev/null diff --git a/tests/cursors/mac/n-resize.png b/tests/cursors/mac/n-resize.png Binary files differdeleted file mode 100644 index 1242980a4..000000000 --- a/tests/cursors/mac/n-resize.png +++ /dev/null diff --git a/tests/cursors/mac/ne-resize.png b/tests/cursors/mac/ne-resize.png Binary files differdeleted file mode 100644 index da3f6d05f..000000000 --- a/tests/cursors/mac/ne-resize.png +++ /dev/null diff --git a/tests/cursors/mac/none.cur b/tests/cursors/mac/none.cur Binary files differdeleted file mode 100644 index 4f7970a9f..000000000 --- a/tests/cursors/mac/none.cur +++ /dev/null diff --git a/tests/cursors/mac/none.png b/tests/cursors/mac/none.png Binary files differdeleted file mode 100644 index 3b34811c5..000000000 --- a/tests/cursors/mac/none.png +++ /dev/null diff --git a/tests/cursors/mac/nw-resize.png b/tests/cursors/mac/nw-resize.png Binary files differdeleted file mode 100644 index b6c5e3956..000000000 --- a/tests/cursors/mac/nw-resize.png +++ /dev/null diff --git a/tests/cursors/mac/pointer.png b/tests/cursors/mac/pointer.png Binary files differdeleted file mode 100644 index 45fbd2b77..000000000 --- a/tests/cursors/mac/pointer.png +++ /dev/null diff --git a/tests/cursors/mac/s-resize.png b/tests/cursors/mac/s-resize.png Binary files differdeleted file mode 100644 index 1242980a4..000000000 --- a/tests/cursors/mac/s-resize.png +++ /dev/null diff --git a/tests/cursors/mac/se-resize.png b/tests/cursors/mac/se-resize.png Binary files differdeleted file mode 100644 index b6c5e3956..000000000 --- a/tests/cursors/mac/se-resize.png +++ /dev/null diff --git a/tests/cursors/mac/sw-resize.png b/tests/cursors/mac/sw-resize.png Binary files differdeleted file mode 100644 index da3f6d05f..000000000 --- a/tests/cursors/mac/sw-resize.png +++ /dev/null diff --git a/tests/cursors/mac/text.png b/tests/cursors/mac/text.png Binary files differdeleted file mode 100644 index 2257903e9..000000000 --- a/tests/cursors/mac/text.png +++ /dev/null diff --git a/tests/cursors/mac/w-resize.png b/tests/cursors/mac/w-resize.png Binary files differdeleted file mode 100644 index 583ce1862..000000000 --- a/tests/cursors/mac/w-resize.png +++ /dev/null diff --git a/tests/cursors/win/auto.png b/tests/cursors/win/auto.png Binary files differdeleted file mode 100644 index b2c5c858c..000000000 --- a/tests/cursors/win/auto.png +++ /dev/null diff --git a/tests/cursors/win/crosshair.png b/tests/cursors/win/crosshair.png Binary files differdeleted file mode 100644 index 02c99b7fd..000000000 --- a/tests/cursors/win/crosshair.png +++ /dev/null diff --git a/tests/cursors/win/default.png b/tests/cursors/win/default.png Binary files differdeleted file mode 100644 index b2c5c858c..000000000 --- a/tests/cursors/win/default.png +++ /dev/null diff --git a/tests/cursors/win/e-resize.png b/tests/cursors/win/e-resize.png Binary files differdeleted file mode 100644 index 056eb699f..000000000 --- a/tests/cursors/win/e-resize.png +++ /dev/null diff --git a/tests/cursors/win/help.png b/tests/cursors/win/help.png Binary files differdeleted file mode 100644 index b8034bb7b..000000000 --- a/tests/cursors/win/help.png +++ /dev/null diff --git a/tests/cursors/win/move.png b/tests/cursors/win/move.png Binary files differdeleted file mode 100644 index 627e79937..000000000 --- a/tests/cursors/win/move.png +++ /dev/null diff --git a/tests/cursors/win/n-resize.png b/tests/cursors/win/n-resize.png Binary files differdeleted file mode 100644 index d06244cbb..000000000 --- a/tests/cursors/win/n-resize.png +++ /dev/null diff --git a/tests/cursors/win/ne-resize.png b/tests/cursors/win/ne-resize.png Binary files differdeleted file mode 100644 index 79f6c3ae3..000000000 --- a/tests/cursors/win/ne-resize.png +++ /dev/null diff --git a/tests/cursors/win/none.cur b/tests/cursors/win/none.cur Binary files differdeleted file mode 100644 index 4f7970a9f..000000000 --- a/tests/cursors/win/none.cur +++ /dev/null diff --git a/tests/cursors/win/none.png b/tests/cursors/win/none.png Binary files differdeleted file mode 100644 index 1764445c9..000000000 --- a/tests/cursors/win/none.png +++ /dev/null diff --git a/tests/cursors/win/nw-resize.png b/tests/cursors/win/nw-resize.png Binary files differdeleted file mode 100644 index af48a12d2..000000000 --- a/tests/cursors/win/nw-resize.png +++ /dev/null diff --git a/tests/cursors/win/pointer.png b/tests/cursors/win/pointer.png Binary files differdeleted file mode 100644 index 7d07182a9..000000000 --- a/tests/cursors/win/pointer.png +++ /dev/null diff --git a/tests/cursors/win/s-resize.png b/tests/cursors/win/s-resize.png Binary files differdeleted file mode 100644 index d06244cbb..000000000 --- a/tests/cursors/win/s-resize.png +++ /dev/null diff --git a/tests/cursors/win/se-resize.png b/tests/cursors/win/se-resize.png Binary files differdeleted file mode 100644 index af48a12d2..000000000 --- a/tests/cursors/win/se-resize.png +++ /dev/null diff --git a/tests/cursors/win/sw-resize.png b/tests/cursors/win/sw-resize.png Binary files differdeleted file mode 100644 index 79f6c3ae3..000000000 --- a/tests/cursors/win/sw-resize.png +++ /dev/null diff --git a/tests/cursors/win/text.png b/tests/cursors/win/text.png Binary files differdeleted file mode 100644 index ce8dc22ee..000000000 --- a/tests/cursors/win/text.png +++ /dev/null diff --git a/tests/cursors/win/w-resize.png b/tests/cursors/win/w-resize.png Binary files differdeleted file mode 100644 index 056eb699f..000000000 --- a/tests/cursors/win/w-resize.png +++ /dev/null diff --git a/tests/images/click.png b/tests/images/click.png Binary files differdeleted file mode 100644 index 2b32f8d84..000000000 --- a/tests/images/click.png +++ /dev/null diff --git a/tests/jquery.useraction.js b/tests/jquery.useraction.js deleted file mode 100644 index 82ec0cd22..000000000 --- a/tests/jquery.useraction.js +++ /dev/null @@ -1,347 +0,0 @@ -/* Copyright (c) 2007 Eduardo Lundgren (eduardolundgren@gmail.com) - * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) - * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses. - * - * Version: 0.1a - * Date: May, 2008 - * Requires jQuery 1.2.x+ - * Docs: http://docs.jquery.com/Plugins/userAction - * Greetings: Richard Worth - */ - -;(function($) { - -$.fn.extend({ - userAction: function(type) { - var args = arguments, opts = {}, a1 = args[1], a2 = args[2]; - - // transfer center offset - if (a1 && a1.length) { - opts.center = [a1[0], a1[1]]; - } - // set x and y - else if (typeof a1 == StringPool.NUMBER) { - opts.x = a1; opts.y = a2; - } - // extend options - else { - $.extend(opts, a1); - } - - return this.each(function() { - new $.userAction(this, type, opts); - }); - } -}); - -$.userAction = function(el, type, options) { - this.type = type; - this.options = $.extend({}, $.userAction.defaults, options || {}); - this.target = $(this.options.target || el)[0]; - - var self = this, o = this.options, c = o.center, center = { x: 0, y: 0 }; - - if (!o.x && !o.y) { - center = this.findCenter( - c && c.length ? c : [0, 0] - ) - } - - // if x and y not set, get the center of the element - o.x = o.x || center.x; o.y = o.y || center.y; - - var EVENT_DEFAULT = { - target: this.target, - view: window, - bubbles: o.bubbles || true, - cancelable: o.cancelable || false, - ctrlKey: o.ctrlKey || false, - altKey: o.altKey || false, - shiftKey: o.shiftKey || false, - metaKey: o.metaKey || false - }; - - // Simulating drag and drop event - if (/^drag$/i.test(type)) { - var self = this, t = this.target, queue = $.data(t, StringPool.DATA_QUEUE), - data = [options.dx || options.x, options.dy || options.y, this]; - - var fire = function() { - self.drag(options.dx || options.x, options.dy || options.y); - }; - - if (/^sync$/i.test(o.speed)) { - fire(); return; - } - - if (!queue) { - $.data(t, StringPool.DATA_QUEUE, [data]); fire(); return; - } - // queuing drags... - if (queue && queue.length) { - queue.push(data); - } - // if drag, stop here. - return; - } - - var isMouse = /^mouse(over|out|down|up|move)|(dbl)?click$/i.test(type), - isKeyboard = /^textevent|key(up|down|press)$/i.test(type), - - EVT = isMouse ? - $.extend({}, EVENT_DEFAULT, { - clientX: o.x, clientY: o.y, - screenX: o.screenX || 0, screenY: o.screenY || 0, - relatedTarget: $(o.relatedTarget)[0] || null, detail: 0, - button: o.button || ($.browser.msie ? 1 : 0), isTrusted: false - }) : - $.extend({}, EVENT_DEFAULT, { - keyCode: o.keyCode || 0, charCode: o.charCode || 0 - }); - - // avoid e.type == undefined before dispatchment - EVT.type = type; - - if (o.before) o.before.apply(this.target, [$.event.fix(EVT), o.x, o.y, this]); - - // check event type for mouse events - if (isMouse) { - // simulating mouse event - EVT = this.mouseEvent(EVT) - } - - // check event type for key events - if (isKeyboard) { - // simulating keuboard event - EVT = this.keyboardEvent(EVT); - } - - if (o.after) o.after.apply(this.target, [$.event.fix(EVT), o.x, o.y, this]); -}; - -$.extend($.userAction.prototype, { - - down: function(target) { - $(target).userAction(StringPool.MOUSEOVER).userAction(StringPool.MOUSEDOWN) - .userAction(StringPool.MOUSEMOVE); - }, - - up: function(target) { - $(target).userAction(StringPool.MOUSEUP).userAction(StringPool.MOUSEOUT); - }, - - move: function(target, x, y, after) { - $(target).userAction(StringPool.MOUSEMOVE, { x: x, y: y, after: after }); - }, - - drag: function(dx, dy) { - // drag helper function, thanks Richard Worth's testmouse api. - var self = this, o = this.options, center = this.findCenter(), - target = $(this.target), lastx = center.x, lasty = center.y, - fake = $(StringPool.FAKE_CURSOR_EXP), - speed = o.speed || StringPool.SLOW, - easing = o.easing || StringPool.SWING; - - var complete = function() { - // fire complete or after cb - if (o.after||o.complete) (o.after||o.complete).apply(self.target, [o, self]); - }; - - // drag synchronously - if (/^sync$/i.test(o.speed)) { - self.down(target); - - var mdx = Math.abs(dx)||0, mdy = Math.abs(dy)||0, range = Math.max(mdx, mdy), - sx = dx/mdx||1, sy = dy/mdy||1; - - for (var dt = 1; dt <= range; dt++) { - var x = center.x + sx*(dt <= mdx ? dt : 0), y = center.y + sy*(dt <= mdy ? dt : 0); - this.move(target, x, y, o.drag); - } - self.up(target); - complete(); - return; - } - - // drag asynchronously - animated - fake = fake.size() ? fake : - $(StringPool.FAKE_CURSOR_DIV) - .css({ position: StringPool.ABSOLUTE }).appendTo(document.body); - - fake - .animate({ left: center.x, top: center.y }, speed, easing, function(){ - self.down(target); - }) - .animate({ left: center.x + (dx||0), top: center.y + (dy||0) }, { - speed: speed, - easing: easing, - step: function(i, anim) { - lastx = anim.prop == StringPool.LEFT ? i : lastx; - lasty = anim.prop == StringPool.TOP ? i : lasty; - self.move(target, lastx, lasty, o.drag); - }, - complete: function() { - - self.up(target); - - // remove fake cursor - $(this).remove(); - - complete(); - - // trigger drag queue - var queue = $.data(self.target, StringPool.DATA_QUEUE); - if (queue) queue.shift(); - - if (queue && queue[0]) { - // trigger drag on correct instance - queue[0][2].drag(queue[0][0], queue[0][1]); - } - else - $.removeData(self.target, StringPool.DATA_QUEUE); - } - }); - }, - - mouseEvent: function(EVT) { - var evt, type = this.type, o = this.options; - - //check for DOM-compliant browsers - if ($.isFunction(document.createEvent)) { - evt = document.createEvent(StringPool.MOUSE_EVENTS); - - //Safari 2.x doesn't implement initMouseEvent() - if ($.isFunction(evt.initMouseEvent)) { - evt.initMouseEvent(type, - EVT.bubbles, EVT.cancelable, EVT.view, EVT.detail, - EVT.screenX, EVT.screenY, EVT.clientX, EVT.clientY, - EVT.ctrlKey, EVT.altKey, EVT.shiftKey, EVT.metaKey, - EVT.button, EVT.relatedTarget); - } else { - // Safari - evt = document.createEvent(StringPool.UI_EVENTS); - customEvent.initEvent(type, EVT.bubbles, EVT.cancelable); - $.extend(evt, EVT); - } - - // check to see if relatedTarget has been assigned - if (EVT.relatedTarget && !evt.relatedTarget){ - if (type == StringPool.MOUSEOUT) { - evt.toElement = EVT.relatedTarget; - } else if (type == StringPool.MOUSEOVER) { - evt.fromElement = EVT.relatedTarget; - } - } - // fire the event - this.target.dispatchEvent(evt); - - } else if (document.createEventObject) { - evt = document.createEventObject(); - - // assign available properties - $.extend(evt, EVT) - - // IE won't allow assignment to toElement or fromElement - evt.relatedTarget = EVT.relatedTarget; - - // fix for 2 pixels bug from mousecords - evt.pageX = o.x; evt.pageY = o.y; - - // fire the event - this.target.fireEvent(StringPool.ON + type, evt); - } - - return evt; - }, - - keyboardEvent: function(EVT) { - var evt, type = this.type, o = this.options; - - // check for DOM-compliant browsers first - if ($.isFunction(document.createEvent)) { - - try { - // try to create key event - evt = document.createEvent(StringPool.KEY_EVENTS); - - evt.initKeyEvent(type, - EVT.bubbles, EVT.cancelable, EVT.view, EVT.ctrlKey, - EVT.altKey, EVT.shiftKey, EVT.metaKey, EVT.keyCode, EVT.charCode); - - } catch (err) { - // we need another try-catch for Safari 2.x - try { - // generic event for opera and webkit nightlies, will fail in Safari 2.x - evt = document.createEvent(StringPool.EVENTS); - } catch (ierr){ - // Safari 2.x - create a UIEvent - evt = document.createEvent(StringPool.UI_EVENTS); - } finally { - evt.initEvent(type, EVT.bubbles, EVT.cancelable); - - // initializing - $.each(EVT, function(k, v) { - // using try-catch for avoiding Opera NO_MODIFICATION_ALLOWED_ERR - try { evt[k] = v; } catch(e) { } - }); - } - } - - // fire the event - this.target.dispatchEvent(evt); - - } else if (document.createEventObject) { - // create an IE event object - evt = document.createEventObject(); - - // assign available properties - $.extend(evt, EVT); - - // IE doesn't support charCode explicitly - evt.keyCode = (EVT.charCode > 0) ? EVT.charCode : EVT.keyCode; - - // fire the event - this.target.fireEvent(StringPool.ON + type, evt); - } - - return evt; - }, - - findCenter: function(offset) { - var el = $(this.target), o = el.offset(); - return { - x: o.left + (((offset||[0, 0])[0]) || 0) + el.outerWidth() / 2, - y: o.top + (((offset||[0, 0])[1]) || 0) + el.outerHeight() / 2 - }; - } -}); - -$.extend($.userAction, { - defaults: { - center: true - } -}); - -var StringPool = { - ON: 'on', - NUMBER: 'number', - MOUSEOVER: 'mouseover', - MOUSEOUT: 'mouseout', - MOUSEDOWN: 'mousedown', - MOUSEUP: 'mouseup', - MOUSEMOVE: 'mousemove', - MOUSE_EVENTS: 'MouseEvents', - UI_EVENTS: 'UIEvents', - KEY_EVENTS: 'KeyEvents', - EVENTS: 'Events', - FAKE_CURSOR_EXP: 'div.ui-fake-cursor', - FAKE_CURSOR_DIV: '<div class="ui-fake-cursor"/>', - ABSOLUTE: 'absolute', - DATA_QUEUE: 'ua-drag-queue', - TOP: 'top', - LEFT: 'left', - SLOW: 'slow', - SWING: 'swing' -}; - -})(jQuery);
\ No newline at end of file diff --git a/tests/ui.testmouse.js b/tests/ui.testmouse.js deleted file mode 100644 index 5c4d41204..000000000 --- a/tests/ui.testmouse.js +++ /dev/null @@ -1,142 +0,0 @@ -/* - * jQuery UI testMouse - * - * Copyright (c) 2008 Richard D. Worth (rdworth.org) - * Dual licensed under the MIT (MIT-LICENSE.txt) - * and GPL (GPL-LICENSE.txt) licenses. - * - * Revision: $Id: $ - */ -;(function($) { - - var mouseX = 0; - var mouseY = 0; - - $(function() { - $(document).mousemove(function(e) { - if (e.isTrusted !== false) { - mouseX = e.pageX; - mouseY = e.pageY; - } - }); - }); - - $.widget("ui.testMouse", { - trackMouse: function() {}, - init: function() { - }, - destroy: function() { - }, - center: function(offset) { - var o = this.element.offset(); - return { - x: (o.left + (offset || [0, 0])[0] || 0) + this.element.width() / 2, - y: (o.top + (offset || [0, 0])[1] || 0) + this.element.height() / 2 - }; - }, - drag: function(dx, dy) { - var self = this; - - var center = this.center(); - this.left = center.x; - this.top = center.y; - - var OS = (/(win|mac|linux)/i.exec(navigator.platform) || ['other'])[0].toLowerCase(); - - var defaultUrl = ['cursors', OS == 'other' ? 'win' : OS, 'default.png'].join('/'); - var cursorUrl = function() { - return ['cursors', OS == 'other' ? 'win' : OS, self.element.css('cursor') + '.png'].join('/'); - } - var noneUrl = ['cursors', OS == 'other' ? 'win' : OS, 'none' + ($.browser.safari ? '.png' : '.cur')].join('/'); - - var fakemouse = $('<img src="' + defaultUrl + '" />'); - var realmouse = $('<img src="' + defaultUrl + '" />'); - if ($.browser.msie && $.browser.version == 6) { - fakemouse = $('<div style="height:32;width:32;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + defaultUrl + '\', sizingMethod=\'scale\');" ></div>'); - realmouse = $('<div><div style="height:32;width:32;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + defaultUrl + '\', sizingMethod=\'scale\');" ></div></div>'); - } - var mousescreen = $('<div/>'); - - var updateCursor = function() { - if ($.browser.msie && $.browser.version == 6) { - fakemouse.css('filter', 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + cursorUrl() + '\', sizingMethod=\'scale\''); - } else { - fakemouse.attr('src', cursorUrl()); - } - } - var resetCursor = function() { - if ($.browser.msie && $.browser.version == 6) { - fakemouse.css('filter', 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + defaultUrl + '\', sizingMethod=\'scale\''); - } else { - fakemouse.attr('src', defaultUrl); - } - } - - var testStart = function() { - self.element.bind("mouseover", updateCursor).bind("mouseout", resetCursor); - fakemouse.appendTo('body').css({ position: 'absolute', left: mouseX, top: mouseY, zIndex: 5000 }); - realmouse.appendTo('body').css({ position: 'absolute', left: mouseX, top: mouseY, zIndex: 5000, opacity: 0.1 }); - mousescreen.appendTo('body').css({ width: '100%', height: '100%', position: 'absolute', top: 0, left: 0, zIndex: 5000 }) - .mousemove(function(e) { realmouse.css({ left: e.pageX, top: e.pageY }); return false; }) - .mousedown(function() { return false; }) - .mouseup(function() { return false; }); - mousescreen.css('cursor', 'url(' + noneUrl + '), crosshair'); - ($.browser.opera && mousescreen.css('cursor', 'crosshair')); - } - var testStop = function() { - self.element.unbind("mouseover", updateCursor).unbind("mouseout", resetCursor); - mousescreen.remove(); - mouseX = realmouse.css("left"); - mouseY = realmouse.css("top"); - realmouse.remove(); - fakemouse.remove(); - self.options.complete.apply(); - } - - testStart(); - - this.lastX = null; - - var before = function() { - self.element.triggerHandler('mouseover'); - self.element.simulate("mousedown", { clientX: self.left, clientY: self.top }); - self.element.simulate("mousemove", { clientX: self.left, clientY: self.top }); - } - - var during = function(xory) { - if (!self.lastX) { - self.lastX = xory; - } else { - var x = self.lastX, y = xory; - self.element.simulate("mousemove", { clientX: x, clientY: y }); - self.lastX = null; - } - } - - var after = function() { - self.element.triggerHandler('mouseout'); - self.element.simulate("mouseup", { clientX: 0, clientY: 0 }); - testStop(); - } - - fakemouse - .animate({ left: this.left, top: this.top }, this.options.speed, before) - .animate({ left: this.left + dx, top: this.top + dy }, { - speed: this.options.speed, - easing: "swing", - step: during - }) - .animate({ left: this.left + dx, top: this.top + dy }, { - speed: this.options.speed, - easing: "swing", - complete: after - }); - - } - }); - - $.ui.testMouse.defaults = { - speed: "slow" - } - -})(jQuery); |