Added platform cursors

This commit is contained in:
Richard Worth 2008-05-26 10:18:11 +00:00
parent 18296272ad
commit a1ca614a88
53 changed files with 41 additions and 13 deletions

View File

@ -8,9 +8,9 @@
<style type="text/css">
html, body { height: 100%; }
html, body { height: 95%; }
#main { height: 100%; }
#drag { width: 200px; height: 200px; background: #eef; }
#drag { cursor: move; width: 200px; height: 200px; background: #eef; }
</style>
@ -74,25 +74,50 @@ function draggableTest(el, dx, dy) {
var left = center.x;
var top = center.y;
var fakemouse = $('<img src="images/cursor.png" id="fakemouse"/>');
var realmouse = $('<img src="images/cursor.png" id="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 = $('<img src="' + defaultUrl + '" id="fakemouse" />');
var realmouse = $('<img src="' + defaultUrl + '" id="realmouse" />');
if ($.browser.msie && $.browser.version == 6) {
fakemouse = $('<div id="fakemouse" style="height:23;width:16;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'images/cursor.png\', sizingMethod=\'scale\');" ></div>');
realmouse = $('<div><div id="realmouse" style="height:23;width:16;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'images/cursor.png\', sizingMethod=\'scale\');" ></div></div>');
fakemouse = $('<div id="fakemouse" style="height:32;width:32;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + defaultUrl + '\', sizingMethod=\'scale\');" ></div>');
realmouse = $('<div><div id="realmouse" style="height:32;width:32;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + defaultUrl + '\', sizingMethod=\'scale\');" ></div></div>');
}
var mousescreen = $('<div id="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();
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 851 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 413 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 851 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 861 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 710 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 871 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 836 B

View File

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 872 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 824 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 541 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 871 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 824 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 836 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 486 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 861 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 401 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 341 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 401 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 390 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 689 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 651 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 434 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 440 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 872 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 452 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 675 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 434 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 452 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 440 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 436 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 390 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 724 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 304 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 724 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 714 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 722 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 985 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 872 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 993 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 722 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 993 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 985 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 258 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 714 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB