Skip to content

Commit

Permalink
possible fix for issue #268
Browse files Browse the repository at this point in the history
  • Loading branch information
dasilva333 committed Oct 16, 2015
1 parent df495b5 commit 0b70fac
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 103 deletions.
2 changes: 1 addition & 1 deletion www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<script type="text/javascript" src="js/dependencies/jquery-ui.touchpunch.js"></script>
<script type="text/javascript" src="js/dependencies/jquery.toaster.js"></script>
<script type="text/javascript" src="js/dependencies/idle-timer.min.js"></script>
<script type="text/javascript" src="js/dependencies/hammer.js"></script>
<script type="text/javascript" src="js/dependencies/quo.standalone.js"></script>
<script type="text/javascript" src="js/dependencies/bootstrap.js"></script>
<script type="text/javascript" src="js/dependencies/bootstrap-dialog.js"></script>
<script type="text/javascript" src="js/dependencies/knockout.js"></script>
Expand Down
181 changes: 86 additions & 95 deletions www/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,24 +209,22 @@ window.ko.bindingHandlers.logger = {

window.ko.bindingHandlers.scrollToView = {
init: function(element, valueAccessor, allBindings, viewModel, bindingContext) {
Hammer(element, {
time: 2000
})
.on("tap", function() {
var index = $(element).index('.mobile-characters-image'),
distance = $(".profile:eq(" + index + ")");
if (distance.length > 0) {
distance = distance.position().top - 50;
app.scrollTo(distance);
}
})
.on("press", function() {
$.toaster({
priority: 'info',
title: 'Info',
message: app.activeText().this_icon + viewModel.uniqueName()
});
});
var elem = $$(element)
elem.on("touch", function() {
var index = $(element).index('.mobile-characters-image'),
distance = $(".profile:eq(" + index + ")");
if (distance.length > 0) {
distance = distance.position().top - 50;
app.scrollTo(distance);
}
});
elem.on("hold", function() {
$.toaster({
priority: 'info',
title: 'Info',
message: app.activeText().this_icon + viewModel.uniqueName()
});
});
}
};

Expand All @@ -239,75 +237,72 @@ window.ko.bindingHandlers.fastclick = {

ko.bindingHandlers.moveItem = {
init: function(element, valueAccessor, allBindings, viewModel, bindingContext) {
Hammer(element, {
time: 2000
})
.on("tap", function(ev) {
tgd.localLog("item.tap");
var target = tgd.getEventDelegate(ev.target, ".itemLink");
if (target) {
var item = ko.contextFor(target).$data;
tgd.moveItemPositionHandler(target, item);
}
})
.on("doubletap", function(ev) {
tgd.localLog("item.doubletap");
var target = tgd.getEventDelegate(ev.target, ".itemLink");
if (target) {
var context = ko.contextFor(target);
if (context && "$data" in context) {
var item = context.$data;
if (item.transferStatus < 2) {
if (app.dynamicMode() === false) {
app.dynamicMode(true);
app.createLoadout();
}
tgd.localLog("double tap");
if (item._id > 0) {
app.activeLoadout().addUniqueItem({
id: item._id,
bucketType: item.bucketType,
doEquip: false
});
} else {
app.activeLoadout().addGenericItem({
hash: item.id,
bucketType: item.bucketType,
primaryStat: item.primaryStat()
});
}
} else {
$.toaster({
priority: 'danger',
title: 'Warning',
message: app.activeText().unable_create_loadout_for_type
});
}
}
}
})
// press is actually hold
.on("press", function(ev) {
tgd.localLog("item.press");
var target = tgd.getEventDelegate(ev.target, ".itemLink");
if (target) {
var context = ko.contextFor(target);
if (context && "$data" in context) {
var item = context.$data;
if (item && item.doEquip && app.loadoutMode() === true) {
item.doEquip(!item.doEquip());
item.markAsEquip(item, {
target: target
});
} else if (!isMobile) {
tgd.moveItemPositionHandler(target, item);
} else {
$ZamTooltips.lastElement = target;
$ZamTooltips.show("destinydb", "items", item.id, target);
}
}
}
});
var elem = $$(element);
elem.on("touch", function(ev) {
tgd.localLog("item.tap");
var target = tgd.getEventDelegate(ev.target, ".itemLink");
if (target) {
var item = ko.contextFor(target).$data;
tgd.moveItemPositionHandler(target, item);
}
});
elem.on("doubleTap", function(ev) {
tgd.localLog("item.doubletap");
var target = tgd.getEventDelegate(ev.target, ".itemLink");
if (target) {
var context = ko.contextFor(target);
if (context && "$data" in context) {
var item = context.$data;
if (item.transferStatus < 2) {
if (app.dynamicMode() === false) {
app.dynamicMode(true);
app.createLoadout();
}
tgd.localLog("double tap");
if (item._id > 0) {
app.activeLoadout().addUniqueItem({
id: item._id,
bucketType: item.bucketType,
doEquip: false
});
} else {
app.activeLoadout().addGenericItem({
hash: item.id,
bucketType: item.bucketType,
primaryStat: item.primaryStat()
});
}
} else {
$.toaster({
priority: 'danger',
title: 'Warning',
message: app.activeText().unable_create_loadout_for_type
});
}
}
}
})
elem.on("hold", function(ev) {
tgd.localLog("item.press");
var target = tgd.getEventDelegate(ev.target, ".itemLink");
if (target) {
var context = ko.contextFor(target);
if (context && "$data" in context) {
var item = context.$data;
if (item && item.doEquip && app.loadoutMode() === true) {
item.doEquip(!item.doEquip());
item.markAsEquip(item, {
target: target
});
} else if (!isMobile) {
tgd.moveItemPositionHandler(target, item);
} else {
$ZamTooltips.lastElement = target;
$ZamTooltips.show("destinydb", "items", item.id, target);
}
}
}
});
}
};

Expand Down Expand Up @@ -1933,14 +1928,10 @@ var app = function() {
}

if (isMobile) {
Hammer(document.getElementById('charactersContainer'), {
drag_min_distance: 1,
swipe_velocity: 0.1,
drag_horizontal: true,
drag_vertical: false
}).on("swipeleft", self.shiftViewLeft)
.on("swiperight", self.shiftViewRight)
.on("tap", self.globalClickHandler);
var cContainer = $$(document.getElementById('charactersContainer'))
cContainer.on("swipeLeft", self.shiftViewLeft)
cContainer.on("swipeRight", self.shiftViewRight)
cContainer.on("touch", self.globalClickHandler);

if (window.device && device.platform === "iOS" && device.version >= 7.0) {
StatusBar.overlaysWebView(false);
Expand Down
Loading

0 comments on commit 0b70fac

Please sign in to comment.