Changed map dragging functionality to use jQuery UI. This is an attempt to fix dragging on WINE.

This commit is contained in:
Mark Aherne
2014-07-23 16:46:37 +01:00
parent c3f62d4f52
commit 5fd0d2d16e
10 changed files with 2538 additions and 49 deletions

View File

@@ -231,11 +231,12 @@
position: absolute;
width: 16px;
height: 16px;
margin: -8px 0 0 -8px;
background-image: url(uiIcons16Green.png);
background-position: -144px -96px;
background-repeat: no-repeat;
zoom: 0.125;
margin-left: -1px;
/*margin-bottom: -1px;*/
}
.mapIcon16.dead {
background-image: url(uiIcons16Red.png);

View File

@@ -79,8 +79,10 @@ body {
#uiMapImage {
position: absolute;
bottom: 2px;
left: -6px;
bottom: 1px;
left: 1px;
width: 256px;
height: 256px;
}
#uiMapContent {

File diff suppressed because one or more lines are too long

2523
nano/js/libraries/jquery-ui.js vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -63,7 +63,9 @@ NanoStateClass.prototype.onUpdate = function (data) {
if (!this.mapInitialised)
{
// Add drag functionality to the map ui
$('#uiMap').drags({handle : '#uiMapImage'});
$('#uiMap').draggable({
handle : '#uiMapImage'
});
$('#uiMapTooltip')
.off('click')

View File

@@ -159,45 +159,3 @@ if (!String.prototype.ckey) {
return this.replace(/\W/g, '').toLowerCase();
};
}
(function($) {
$.fn.drags = function(opt) {
opt = $.extend({handle:"",cursor:"move"}, opt);
if(opt.handle === "") {
var $el = this;
} else {
var $el = this.find(opt.handle);
}
return $el.css('cursor', opt.cursor).on("mousedown", function(e) {
if(opt.handle === "") {
var $drag = $(this).addClass('draggable');
} else {
var $drag = $(this).addClass('active-handle').parent().addClass('draggable');
}
var z_idx = $drag.css('z-index'),
drg_h = $drag.outerHeight(),
drg_w = $drag.outerWidth(),
pos_y = $drag.offset().top + drg_h - e.pageY,
pos_x = $drag.offset().left + drg_w - e.pageX;
$drag.css('z-index', 1000).parents().on("mousemove", function(e) {
$('.draggable').offset({
top:e.pageY + pos_y - drg_h,
left:e.pageX + pos_x - drg_w
}).on("mouseup", function() {
$(this).removeClass('draggable').css('z-index', z_idx);
});
});
e.preventDefault(); // disable selection
}).on("mouseup", function() {
if(opt.handle === "") {
$(this).removeClass('draggable');
} else {
$(this).removeClass('active-handle').parent().removeClass('draggable');
}
});
}
})(jQuery);

View File

@@ -11,3 +11,6 @@ Used In File(s): \code\game\machinery\computer\crew.dm
</div>
{{/if}}
{{/for}}
<div class="mapIcon mapIcon16 rank-captain alive" style="left: 10px; bottom: 10px;" unselectable="on"></div>
<div style="position: absolute; width: 1px; height: 1px; background: #00ff00; left: 10px; bottom: 10px;" unselectable="on"></div>