Added Tools dialogue with first tool, remove selected legends. ToDo: remove decals.

pull/129/head
iandoug 9 years ago
parent a8dab4924e
commit 0388244e65

@ -106,6 +106,8 @@ Nav Bar / Header
<ul class="nav navbar-nav navbar-right" style="">
<!-- Options button -->
<li><a href="#" ng-click="showOptions()"><i class="fa fa-cog"></i> Options</a></li>
<!-- Tools button -->
<li><a href="#" ng-click="showTools()"><i class="fa fa-wrench"></i> Tools</a></li>
<!-- Permalink button -->
<li><a ng-href="{{getPermalink()}}" target="_blank" ng-click="dirty = false"><i class="fa fa-link"></i> Permalink</a></li>
<!-- User button -->
@ -1002,6 +1004,47 @@ Options Dialog
</div>
</script>
<!--***********************************************
Tools Dialog
************************************************-->
<script type="text/ng-template" id="toolsDialog.html">
<div class="modal-header">
<button type="button" class="close" ng-click="cancel()">&times;</button>
<h4 class="modal-title">Tools</h4>
</div>
<div class="modal-body">
<h5>Remove or Move Legends:</h5>
<div class="form-group form-group-sm form-horizontal">
<label class="control-label text-nowrap" style='margin-left: 5px;'>Remove Legends:</label>
<div class="btn-group btn-group-xs" role="group">
<button type="button" class="btn btn-success hint--top hint--rounded" data-hint="Remove all the legends from all the keys. Does not remove decals." ng-click="removeLegends('all')"> All</button>
</div>
<div class="btn-group btn-group-xs" role="group">
<button type="button" class="btn btn-success hint--top hint--rounded" data-hint="Remove the legends from all the Alphabetical keys." ng-click="removeLegends('alphas')"> Alphas</button>
</div>
<div class="btn-group btn-group-xs" role="group">
<button type="button" class="btn btn-success hint--top hint--rounded" data-hint="Remove the legends from all the Number keys." ng-click="removeLegends('nums')"> Nums</button>
</div>
<div class="btn-group btn-group-xs" role="group">
<button type="button" class="btn btn-success hint--top hint--rounded" data-hint="Remove the legends from all the Punctuation keys." ng-click="removeLegends('punct')"> Punct</button>
</div>
<div class="btn-group btn-group-xs" role="group">
<button type="button" class="btn btn-success hint--top hint--rounded" data-hint="Remove the legends from all the Function keys." ng-click="removeLegends('fn')"> Fn</button>
</div>
<div class="btn-group btn-group-xs" role="group">
<button type="button" class="btn btn-success hint--top hint--rounded" data-hint="Remove the legends from all the other keys except decals." ng-click="removeLegends('others')"> Others</button>
</div>
<div class="btn-group btn-group-xs" role="group">
<button type="button" class="btn btn-success hint--top hint--rounded" data-hint="Remove the legends from all the Decals." ng-click="removeLegends('decals')"> Decals</button>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger" ng-click="cancel()">Cancel</button>
</div>
</script>
<!--***********************************************
Markdown dialog for displaying README, etc.
************************************************-->

44
kb.js

@ -337,6 +337,31 @@
document.getElementById("body_all").style.display = "";
document.getElementById("summary_print").style.display = "none";
};
$scope.removeLegends = function(param) {
switch (param) {
case 'all' : var re = /.*/; break;
case 'alphas' : var re = /^[A-Za-z]$/; break;
case 'nums' : var re = /^[0-9]*$/; break;
case 'punct' : var re = /^[\`\~\!\@\#\$\%\^\&\*\(\)\-\_\=\+\[\{\]\}\;\:\'\"\,\<\.\>\/\?\\\|]$/; break;
case 'fn' : var re = /F\d\d?/; break;
case 'others' : var re = /^[^A-Za-z0-9\`\~\!\@\#\$\%\^\&\*\(\)\-\_\=\+\[\{\]\}\;\:\'\"\,\<\.\>\/\?\\\|]$|^[A-Za-z\s][A-Za-z\s]+$/; break;
}
var prop = 'labels';
angular.forEach($scope.keys(), function(key) {
if(!key.decal) {
for (var i=0; i<=11; i++){
if (key.labels[i]){
var lab = key.labels[i];
lab = lab.replace(re, '');
update(key,prop,lab,i);
renderKey(key);
}
}
}
});
};
// Helper function to select a single key
function selectKey(key,event) {
@ -427,7 +452,7 @@
var reverseColors = {}; // array to provide fast reverse lookups of colour names for Summary.
// might be an issue if a colour features twice... only last will stick
// The set of known palettes
// The set of known palettes
$scope.palettes = {};
$http.get('colors.json').success(function(data) {
$scope.palettes = data;
@ -704,7 +729,7 @@
return (v[prop] || v._)();
}
function update(key,prop,value,index) {
function update(key,prop,value,index) {//alert("yes ian");
var u = {
_ : function() { key[prop] = value; },
width : function() { key.width = value; if(!key.stepped || key.width > key.width2) key.width2 = value; },
@ -1445,6 +1470,21 @@
}
};
$scope.showTools = function(event) {
if(activeModal) activeModal.dismiss('cancel');
activeModal = $modal.open({
templateUrl:"toolsDialog.html",
controller:"modalCtrl",
scope:$scope,
resolve: { params: function() { return { moveStep:$scope.moveStep, sizeStep:$scope.sizeStep, rotateStep:$scope.rotateStep }; } }
});
activeModal.result.then(function(params) { $.extend($scope, params); });
if(event) {
event.preventDefault();
event.stopPropagation();
}
};
// Clipboard functions
var clipboard = {};
$scope.cut = function(event) {

Loading…
Cancel
Save