Skip to content

Commit

Permalink
Principles switched to checkboxes to allow deselecting
Browse files Browse the repository at this point in the history
Fixes #7
  • Loading branch information
LupusUmbrae committed May 30, 2016
1 parent ac879f6 commit 75ab809
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
20 changes: 19 additions & 1 deletion static/javascript/kdm.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,13 @@
eventName: setEvent
});
}
$rootScope.$apply();
$(this).dialog("close");
} else {
$rootScope.addtimeline.error = true;
$rootScope.addtimeline.errormsg = msgs.join(", ");
$rootScope.$apply();
}
$rootScope.$apply();
},
Cancel: function() {
$(this).dialog("close");
Expand Down Expand Up @@ -323,6 +324,7 @@
scope.$watch('tabs[' + tabIndex + '].population.lost', watchCheckboxArray, true);
scope.$watch('tabs[' + tabIndex + '].deathCount', watchCheckboxArray, true);
scope.$watch('tabs[' + tabIndex + '].timeline', watchCheckboxArray, true);
scope.$watch('tabs[' + tabIndex + '].principles', watchPrinciples, true);
}
}

Expand Down Expand Up @@ -356,6 +358,22 @@
}
}

function watchPrinciples(newVal, oldVal) {
if (newVal !== oldVal) {
var newCur;
var oldCur;
for (var i = 0; i < newVal.length; i++) {
newCur = newVal[i];
oldCur = oldVal[i];
if (newCur.choiceleft && oldCur.choiceright) {
newCur.choiceright = false;
} else if (newCur.choiceright && oldCur.choiceleft) {
newCur.choiceleft = false;
}
}
}
}

function deleteTab($rootScope, tabid) {
var tabs = $rootScope.tabs;
var index = -1;
Expand Down
4 changes: 2 additions & 2 deletions static/templates/settlement/principles.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<input type="text" ng-readonly="principle.disabled" class="underlined fullwidth left-align" ng-model="principle.name">
</div>
<div class="col-xs-1">
<label ng-show="principle.left" class="radio-inline"><input type="radio" name="{{principle.name}}" value="{{principle.left}}" ng-model="principle.choice" class="radio-box"><span></span></label>
<label ng-show="principle.left"><input type="checkbox" name="{{principle.name}}" value="{{principle.left}}" ng-model="principle.choiceleft" ><span></span></label>
</div>
<div class="col-xs-3">
<input type="text" ng-readonly="principle.disabled" class="underlined left-align" ng-model="principle.left">
Expand All @@ -20,7 +20,7 @@
<small>or</small>
</div>
<div class="col-xs-1">
<label ng-show="principle.right" class="radio-inline"><input type="radio" name="{{principle.name}}" value="{{principle.right}}" ng-model="principle.choice" class="radio-box"><span></span></label>
<label ng-show="principle.right"><input type="checkbox" name="{{principle.name}}" value="{{principle.right}}" ng-model="principle.choiceright"><span></span></label>
</div>
<div class="col-xs-3">
<input type="text" ng-readonly="principle.disabled" class="underlined left-align" ng-model="principle.right">
Expand Down

0 comments on commit 75ab809

Please sign in to comment.