From: Richard Worth Date: Mon, 26 May 2008 10:18:11 +0000 (+0000) Subject: Added platform cursors X-Git-Tag: 1.5.1~308 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=a1ca614a88c6f9719b5cced75cd84965e857e1d6;p=jquery-ui.git Added platform cursors --- diff --git a/ui/tests/autodrag.html b/ui/tests/autodrag.html index 05cbefd99..78caac169 100644 --- a/ui/tests/autodrag.html +++ b/ui/tests/autodrag.html @@ -8,9 +8,9 @@ @@ -74,25 +74,50 @@ function draggableTest(el, dx, dy) { var left = center.x; var top = center.y; - var fakemouse = $(''); - var realmouse = $(''); + 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, $(el).css('cursor') + '.png'].join('/'); + } + var noneUrl = ['cursors', OS == 'other' ? 'win' : OS, 'none.cur'].join('/'); + + var fakemouse = $(''); + var realmouse = $(''); if ($.browser.msie && $.browser.version == 6) { - fakemouse = $('
'); - realmouse = $('
'); + fakemouse = $('
'); + realmouse = $('
'); } var mousescreen = $('
'); + + 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() { + $(el).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 }) - .mousedown(function() { return false; }); + 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; }); - (!$.browser.safari && mousescreen.css({ cursor: 'url(images/blank.cur), auto' })); + mousescreen.css('cursor', 'url(' + noneUrl + '), crosshair'); + (($.browser.safari || $.browser.opera) && mousescreen.css('cursor', 'crosshair')); } var testStop = function() { + $(el).unbind("mouseover", updateCursor).unbind("mouseout", resetCursor); mousescreen.remove(); mouseX = realmouse.css("left"); mouseY = realmouse.css("top"); @@ -105,25 +130,28 @@ function draggableTest(el, dx, dy) { var lastX = null; fakemouse - .animate({ left: left, top: top }, "fast", function() { + .animate({ left: left, top: top }, "slow", function() { + $(el).triggerHandler('mouseover'); testMouseDown(el, left, top); testMouseMove(el, left, top); }) .animate({ left: left + dx, top: top + dy }, { - speed: "fast", + speed: "slow", easing: "swing", step: function (xory) { if (!lastX) { lastX = xory; } else { - testMouseMove(el, lastX, xory); + var x = lastX, y = xory; + testMouseMove(el, x, y); lastX = null; } }, complete: function() { + $(el).triggerHandler('mouseout'); testMouseUp(el, 0, 0); $(this).animate({ left: realmouse.css("left"), top: realmouse.css("top") }, { - speed: "fast", + speed: "slow", complete: function() { testStop(); } diff --git a/ui/tests/cursors/linux/auto.png b/ui/tests/cursors/linux/auto.png new file mode 100644 index 000000000..03ac2f281 Binary files /dev/null and b/ui/tests/cursors/linux/auto.png differ diff --git a/ui/tests/cursors/linux/crosshair.png b/ui/tests/cursors/linux/crosshair.png new file mode 100644 index 000000000..30904f933 Binary files /dev/null and b/ui/tests/cursors/linux/crosshair.png differ diff --git a/ui/tests/cursors/linux/default.png b/ui/tests/cursors/linux/default.png new file mode 100644 index 000000000..03ac2f281 Binary files /dev/null and b/ui/tests/cursors/linux/default.png differ diff --git a/ui/tests/cursors/linux/e-resize.png b/ui/tests/cursors/linux/e-resize.png new file mode 100644 index 000000000..b4c40ff17 Binary files /dev/null and b/ui/tests/cursors/linux/e-resize.png differ diff --git a/ui/tests/cursors/linux/help.png b/ui/tests/cursors/linux/help.png new file mode 100644 index 000000000..a6b5836d6 Binary files /dev/null and b/ui/tests/cursors/linux/help.png differ diff --git a/ui/tests/cursors/linux/move.png b/ui/tests/cursors/linux/move.png new file mode 100644 index 000000000..39ae04520 Binary files /dev/null and b/ui/tests/cursors/linux/move.png differ diff --git a/ui/tests/cursors/linux/n-resize.png b/ui/tests/cursors/linux/n-resize.png new file mode 100644 index 000000000..afef5b438 Binary files /dev/null and b/ui/tests/cursors/linux/n-resize.png differ diff --git a/ui/tests/cursors/linux/ne-resize.png b/ui/tests/cursors/linux/ne-resize.png new file mode 100644 index 000000000..8c5e970e1 Binary files /dev/null and b/ui/tests/cursors/linux/ne-resize.png differ diff --git a/ui/tests/cursors/linux/none.cur b/ui/tests/cursors/linux/none.cur new file mode 100644 index 000000000..4f7970a9f Binary files /dev/null and b/ui/tests/cursors/linux/none.cur differ diff --git a/ui/tests/cursors/linux/none.png b/ui/tests/cursors/linux/none.png new file mode 100644 index 000000000..3b34811c5 Binary files /dev/null and b/ui/tests/cursors/linux/none.png differ diff --git a/ui/tests/cursors/linux/nw-resize.png b/ui/tests/cursors/linux/nw-resize.png new file mode 100644 index 000000000..7c17be53e Binary files /dev/null and b/ui/tests/cursors/linux/nw-resize.png differ diff --git a/ui/tests/cursors/linux/pointer.png b/ui/tests/cursors/linux/pointer.png new file mode 100644 index 000000000..b39fcef8f Binary files /dev/null and b/ui/tests/cursors/linux/pointer.png differ diff --git a/ui/tests/cursors/linux/s-resize.png b/ui/tests/cursors/linux/s-resize.png new file mode 100644 index 000000000..afef5b438 Binary files /dev/null and b/ui/tests/cursors/linux/s-resize.png differ diff --git a/ui/tests/cursors/linux/se-resize.png b/ui/tests/cursors/linux/se-resize.png new file mode 100644 index 000000000..7c17be53e Binary files /dev/null and b/ui/tests/cursors/linux/se-resize.png differ diff --git a/ui/tests/cursors/linux/sw-resize.png b/ui/tests/cursors/linux/sw-resize.png new file mode 100644 index 000000000..8c5e970e1 Binary files /dev/null and b/ui/tests/cursors/linux/sw-resize.png differ diff --git a/ui/tests/cursors/linux/text.png b/ui/tests/cursors/linux/text.png new file mode 100644 index 000000000..85a54fcb7 Binary files /dev/null and b/ui/tests/cursors/linux/text.png differ diff --git a/ui/tests/cursors/linux/w-resize.png b/ui/tests/cursors/linux/w-resize.png new file mode 100644 index 000000000..b4c40ff17 Binary files /dev/null and b/ui/tests/cursors/linux/w-resize.png differ diff --git a/ui/tests/cursors/mac/auto.png b/ui/tests/cursors/mac/auto.png new file mode 100644 index 000000000..65b21e435 Binary files /dev/null and b/ui/tests/cursors/mac/auto.png differ diff --git a/ui/tests/cursors/mac/crosshair.png b/ui/tests/cursors/mac/crosshair.png new file mode 100644 index 000000000..b4f165b6a Binary files /dev/null and b/ui/tests/cursors/mac/crosshair.png differ diff --git a/ui/tests/cursors/mac/default.png b/ui/tests/cursors/mac/default.png new file mode 100644 index 000000000..65b21e435 Binary files /dev/null and b/ui/tests/cursors/mac/default.png differ diff --git a/ui/tests/cursors/mac/e-resize.png b/ui/tests/cursors/mac/e-resize.png new file mode 100644 index 000000000..583ce1862 Binary files /dev/null and b/ui/tests/cursors/mac/e-resize.png differ diff --git a/ui/tests/cursors/mac/help.png b/ui/tests/cursors/mac/help.png new file mode 100644 index 000000000..5e8ee5870 Binary files /dev/null and b/ui/tests/cursors/mac/help.png differ diff --git a/ui/tests/cursors/mac/move.png b/ui/tests/cursors/mac/move.png new file mode 100644 index 000000000..cf7608539 Binary files /dev/null and b/ui/tests/cursors/mac/move.png differ diff --git a/ui/tests/cursors/mac/n-resize.png b/ui/tests/cursors/mac/n-resize.png new file mode 100644 index 000000000..1242980a4 Binary files /dev/null and b/ui/tests/cursors/mac/n-resize.png differ diff --git a/ui/tests/cursors/mac/ne-resize.png b/ui/tests/cursors/mac/ne-resize.png new file mode 100644 index 000000000..da3f6d05f Binary files /dev/null and b/ui/tests/cursors/mac/ne-resize.png differ diff --git a/ui/tests/cursors/mac/none.cur b/ui/tests/cursors/mac/none.cur new file mode 100644 index 000000000..4f7970a9f Binary files /dev/null and b/ui/tests/cursors/mac/none.cur differ diff --git a/ui/tests/cursors/mac/none.png b/ui/tests/cursors/mac/none.png new file mode 100644 index 000000000..3b34811c5 Binary files /dev/null and b/ui/tests/cursors/mac/none.png differ diff --git a/ui/tests/cursors/mac/nw-resize.png b/ui/tests/cursors/mac/nw-resize.png new file mode 100644 index 000000000..b6c5e3956 Binary files /dev/null and b/ui/tests/cursors/mac/nw-resize.png differ diff --git a/ui/tests/cursors/mac/pointer.png b/ui/tests/cursors/mac/pointer.png new file mode 100644 index 000000000..45fbd2b77 Binary files /dev/null and b/ui/tests/cursors/mac/pointer.png differ diff --git a/ui/tests/cursors/mac/s-resize.png b/ui/tests/cursors/mac/s-resize.png new file mode 100644 index 000000000..1242980a4 Binary files /dev/null and b/ui/tests/cursors/mac/s-resize.png differ diff --git a/ui/tests/cursors/mac/se-resize.png b/ui/tests/cursors/mac/se-resize.png new file mode 100644 index 000000000..b6c5e3956 Binary files /dev/null and b/ui/tests/cursors/mac/se-resize.png differ diff --git a/ui/tests/cursors/mac/sw-resize.png b/ui/tests/cursors/mac/sw-resize.png new file mode 100644 index 000000000..da3f6d05f Binary files /dev/null and b/ui/tests/cursors/mac/sw-resize.png differ diff --git a/ui/tests/cursors/mac/text.png b/ui/tests/cursors/mac/text.png new file mode 100644 index 000000000..2257903e9 Binary files /dev/null and b/ui/tests/cursors/mac/text.png differ diff --git a/ui/tests/cursors/mac/w-resize.png b/ui/tests/cursors/mac/w-resize.png new file mode 100644 index 000000000..583ce1862 Binary files /dev/null and b/ui/tests/cursors/mac/w-resize.png differ diff --git a/ui/tests/cursors/win/auto.png b/ui/tests/cursors/win/auto.png new file mode 100644 index 000000000..b2c5c858c Binary files /dev/null and b/ui/tests/cursors/win/auto.png differ diff --git a/ui/tests/cursors/win/crosshair.png b/ui/tests/cursors/win/crosshair.png new file mode 100644 index 000000000..02c99b7fd Binary files /dev/null and b/ui/tests/cursors/win/crosshair.png differ diff --git a/ui/tests/cursors/win/default.png b/ui/tests/cursors/win/default.png new file mode 100644 index 000000000..b2c5c858c Binary files /dev/null and b/ui/tests/cursors/win/default.png differ diff --git a/ui/tests/cursors/win/e-resize.png b/ui/tests/cursors/win/e-resize.png new file mode 100644 index 000000000..056eb699f Binary files /dev/null and b/ui/tests/cursors/win/e-resize.png differ diff --git a/ui/tests/cursors/win/help.png b/ui/tests/cursors/win/help.png new file mode 100644 index 000000000..b8034bb7b Binary files /dev/null and b/ui/tests/cursors/win/help.png differ diff --git a/ui/tests/cursors/win/move.png b/ui/tests/cursors/win/move.png new file mode 100644 index 000000000..627e79937 Binary files /dev/null and b/ui/tests/cursors/win/move.png differ diff --git a/ui/tests/cursors/win/n-resize.png b/ui/tests/cursors/win/n-resize.png new file mode 100644 index 000000000..d06244cbb Binary files /dev/null and b/ui/tests/cursors/win/n-resize.png differ diff --git a/ui/tests/cursors/win/ne-resize.png b/ui/tests/cursors/win/ne-resize.png new file mode 100644 index 000000000..79f6c3ae3 Binary files /dev/null and b/ui/tests/cursors/win/ne-resize.png differ diff --git a/ui/tests/cursors/win/none.cur b/ui/tests/cursors/win/none.cur new file mode 100644 index 000000000..4f7970a9f Binary files /dev/null and b/ui/tests/cursors/win/none.cur differ diff --git a/ui/tests/cursors/win/none.png b/ui/tests/cursors/win/none.png new file mode 100644 index 000000000..3b34811c5 Binary files /dev/null and b/ui/tests/cursors/win/none.png differ diff --git a/ui/tests/cursors/win/nw-resize.png b/ui/tests/cursors/win/nw-resize.png new file mode 100644 index 000000000..af48a12d2 Binary files /dev/null and b/ui/tests/cursors/win/nw-resize.png differ diff --git a/ui/tests/cursors/win/pointer.png b/ui/tests/cursors/win/pointer.png new file mode 100644 index 000000000..7d07182a9 Binary files /dev/null and b/ui/tests/cursors/win/pointer.png differ diff --git a/ui/tests/cursors/win/s-resize.png b/ui/tests/cursors/win/s-resize.png new file mode 100644 index 000000000..d06244cbb Binary files /dev/null and b/ui/tests/cursors/win/s-resize.png differ diff --git a/ui/tests/cursors/win/se-resize.png b/ui/tests/cursors/win/se-resize.png new file mode 100644 index 000000000..af48a12d2 Binary files /dev/null and b/ui/tests/cursors/win/se-resize.png differ diff --git a/ui/tests/cursors/win/sw-resize.png b/ui/tests/cursors/win/sw-resize.png new file mode 100644 index 000000000..79f6c3ae3 Binary files /dev/null and b/ui/tests/cursors/win/sw-resize.png differ diff --git a/ui/tests/cursors/win/text.png b/ui/tests/cursors/win/text.png new file mode 100644 index 000000000..ce8dc22ee Binary files /dev/null and b/ui/tests/cursors/win/text.png differ diff --git a/ui/tests/cursors/win/w-resize.png b/ui/tests/cursors/win/w-resize.png new file mode 100644 index 000000000..056eb699f Binary files /dev/null and b/ui/tests/cursors/win/w-resize.png differ diff --git a/ui/tests/images/blank.cur b/ui/tests/images/blank.cur deleted file mode 100644 index 4f7970a9f..000000000 Binary files a/ui/tests/images/blank.cur and /dev/null differ diff --git a/ui/tests/images/se-resize.png b/ui/tests/images/se-resize.png deleted file mode 100644 index ae636e455..000000000 Binary files a/ui/tests/images/se-resize.png and /dev/null differ