Right-click to clear slots feature

This commit is contained in:
Colin McLeod
2015-06-14 17:26:04 -07:00
parent 1a14674352
commit 8b0f58cb69
3 changed files with 18 additions and 5 deletions

View File

@@ -83,9 +83,10 @@ angular.module('app').controller('OutfitController', ['$window', '$rootScope', '
* @param {[type]} slot The slot object belonging to the ship instance * @param {[type]} slot The slot object belonging to the ship instance
* @param {[type]} e The event object * @param {[type]} e The event object
*/ */
$scope.select = function(type, slot, e) { $scope.select = function(type, slot, e, id) {
console.log('SELECT:', arguments);
e.stopPropagation(); e.stopPropagation();
var id = angular.element(e.target).attr('cpid'); // Get component ID id = id || angular.element(e.target).attr('cpid'); // Get component ID
if (id) { if (id) {
if (id == 'empty') { if (id == 'empty') {

View File

@@ -0,0 +1,12 @@
angular.module('app').directive('contextMenu', ['$parse', function($parse) {
return function(scope, element, attrs) {
var fn = $parse(attrs.contextMenu);
console.log(attrs.contextMenu, fn);
element.bind('contextmenu', function(e) {
scope.$apply(function() {
e.preventDefault();
fn(scope, { $event:e });
});
});
};
}]);

View File

@@ -165,7 +165,7 @@
<div id="internal" class="group"> <div id="internal" class="group">
<h1>Internal Compartments</h1> <h1>Internal Compartments</h1>
<div class="slot" ng-repeat="i in ship.internal" ng-click="selectSlot($event, i)" ng-class="{selected: selectedSlot==i}"> <div class="slot" ng-repeat="i in ship.internal" ng-click="selectSlot($event, i)" context-menu="select('i', i, $event, 'empty')" ng-class="{selected: selectedSlot==i}">
<div slot-internal class="details" slot="i" lbl="GMAP[i.c.grp]" fuel="ship.fuelCapacity"></div> <div slot-internal class="details" slot="i" lbl="GMAP[i.c.grp]" fuel="ship.fuelCapacity"></div>
<div class="select" ng-if="selectedSlot==i" ng-click="select('i',i,$event)"> <div class="select" ng-if="selectedSlot==i" ng-click="select('i',i,$event)">
<div component-select s="i" groups="availCS.getInts(i.maxClass)"></div> <div component-select s="i" groups="availCS.getInts(i.maxClass)"></div>
@@ -175,7 +175,7 @@
<div id="hardpoints" class="group"> <div id="hardpoints" class="group">
<h1>HardPoints</h1> <h1>HardPoints</h1>
<div class="slot" ng-repeat="h in ship.hardpoints | filter:{maxClass: '!0'}" ng-click="selectSlot($event, h)" ng-class="{selected: selectedSlot==h}"> <div class="slot" ng-repeat="h in ship.hardpoints | filter:{maxClass: '!0'}" ng-click="selectSlot($event, h)" context-menu="select('h', h, $event, 'empty')" ng-class="{selected: selectedSlot==h}">
<div slot-hardpoint class="details" hp="h" size="HPC[h.maxClass]" lbl="GMAP[h.c.grp]"></div> <div slot-hardpoint class="details" hp="h" size="HPC[h.maxClass]" lbl="GMAP[h.c.grp]"></div>
<div class="select" ng-class="{hardpoint: h.maxClass > 0}" ng-if="selectedSlot==h" ng-click="select('h',h,$event)"> <div class="select" ng-class="{hardpoint: h.maxClass > 0}" ng-if="selectedSlot==h" ng-click="select('h',h,$event)">
<div component-select s="h" groups="availCS.getHps(h.maxClass)"></div> <div component-select s="h" groups="availCS.getHps(h.maxClass)"></div>
@@ -185,7 +185,7 @@
<div id="utility" class="group"> <div id="utility" class="group">
<h1>Utility Mounts</h1> <h1>Utility Mounts</h1>
<div class="slot" ng-repeat="h in ship.hardpoints | filter:{maxClass: '0'}" ng-click="selectSlot($event, h)" ng-class="{selected: selectedSlot==h}"> <div class="slot" ng-repeat="h in ship.hardpoints | filter:{maxClass: '0'}" ng-click="selectSlot($event, h)" context-menu="select('h', h, $event, 'empty')" ng-class="{selected: selectedSlot==h}">
<div slot-hardpoint class="details" hp="h" size="HPC[h.maxClass]" lbl="GMAP[h.c.grp]"></div> <div slot-hardpoint class="details" hp="h" size="HPC[h.maxClass]" lbl="GMAP[h.c.grp]"></div>
<div class="select" ng-class="{hardpoint: h.maxClass > 0}" ng-if="selectedSlot==h" ng-click="select('h',h,$event)"> <div class="select" ng-class="{hardpoint: h.maxClass > 0}" ng-if="selectedSlot==h" ng-click="select('h',h,$event)">
<div component-select s="h" groups="availCS.getHps(h.maxClass)"></div> <div component-select s="h" groups="availCS.getHps(h.maxClass)"></div>