Merge branch 'master' of git://github.com/iandoug/keyboard-layout-editor into iandoug-master

pull/139/head
Ian Prest 9 years ago
commit 8bfbdac388

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 969 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

@ -372,3 +372,18 @@ table.summarytable th, table.summarytable td {
padding: 2px 5px;
}
table.imgtable th, table.imgtable td {
padding: 2px;
}
table.keytable {
border: 1px solid black;
border-collapse: collapse;
}
table.keytable th, table.keytable td {
padding: 2px;
}
table.keystable th, table.keystable td {
padding: 5px;
}

@ -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 -->
@ -1008,6 +1010,147 @@ 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">
<p>You should save your work before using these tools, there is no Undo.<br>
Actions will affect selected keys only. If no keys are selected, actions will affect all keys.</p>
<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')"> !@#$p[};"<.?..</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 special legends, like FontAwesome, WebFont, images, etc, and anything between them in the same slot." ng-click="removeLegends('specials')"> Specials</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 (almost) 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>
<br>
<div class="form-group form-group-sm form-horizontal">
<label class="control-label text-nowrap" style='margin-left: 5px;'>Move Legends Pairs:</label>
<div class="btn-group btn-group-xs" role="group">
<table class="imgtable">
<tr>
<td>
<a class="hint--top hint--rounded" data-hint="Move both left column legends to the middle column." ng-click="moveLegends('move',0,6,1,7)"><img src="img/left2middle.png"></a>
</td>
<td>
<a class="hint--top hint--rounded" data-hint="Move both middle column legends to the right column." ng-click="moveLegends('move',1,7,2,8)"><img src="img/middle2right.png"></a>
</td>
<td>
<a class="hint--top hint--rounded" data-hint="Move both right column legends to the left column." ng-click="moveLegends('move',2,8,0,6)"><img src="img/right2left.png"></a>
</td>
<td>
<a class="hint--top hint--rounded" data-hint="Swap left column top and bottom legends." ng-click="moveLegends('swap',0,6)"><img src="img/swaptopbottom.png"></a>
</td>
</tr>
</table>
</div>
</div>
<br>
<form>
<div class="form-group form-group-sm form-horizontal">
<label class="control-label text-nowrap" style='margin-left: 5px;'>Move Single Legends:</label>
<div class="btn-group btn-group-xs" role="group">
<table class='keystable'>
<tr><td>
<label for='fromtable'>From</label>
<table class="keytable" id='fromtable'>
<tr>
<td><input type='radio' name='fromId' value='0'></td>
<td><input type='radio' name='fromId' value='1'></td>
<td><input type='radio' name='fromId' value='2'></td>
</tr>
<tr>
<td><input type='radio' name='fromId' value='3'></td>
<td><input type='radio' name='fromId' value='4'></td>
<td><input type='radio' name='fromId' value='5'></td>
</tr>
<tr>
<td><input type='radio' name='fromId' value='6'></td>
<td><input type='radio' name='fromId' value='7'></td>
<td><input type='radio' name='fromId' value='8'></td>
</tr>
</table>
<table class="keytable">
<tr>
<td><input type='radio' name='fromId' value='9'></td>
<td><input type='radio' name='fromId' value='10'></td>
<td><input type='radio' name='fromId' value='11'></td>
</tr>
</table>
</td>
<td>
<label for='totable'>To</label>
<table class="keytable" id="totable">
<tr>
<td><input type='radio' name='toId' value='0'></td>
<td><input type='radio' name='toId' value='1'></td>
<td><input type='radio' name='toId' value='2'></td>
</tr>
<tr>
<td><input type='radio' name='toId' value='3'></td>
<td><input type='radio' name='toId' value='4'></td>
<td><input type='radio' name='toId' value='5'></td>
</tr>
<tr>
<td><input type='radio' name='toId' value='6'></td>
<td><input type='radio' name='toId' value='7'></td>
<td><input type='radio' name='toId' value='8'></td>
</tr>
</table>
<table class="keytable">
<tr>
<td><input type='radio' name='toId' value='9'></td>
<td><input type='radio' name='toId' value='10'></td>
<td><input type='radio' name='toId' value='11'></td>
</tr>
</table>
</td>
<td>
<button type="button" class="btn btn-success hint--top hint--rounded" data-hint="Move the legends in the From spot to the To spot." ng-click="moveSingleLegends()"> Go</button>
</td>
</tr>
</table>
</div>
</div>
<br>
<div class="form-group form-group-sm form-horizontal">
<label class="control-label text-nowrap" style='margin-left: 5px;'>Unhide decal keys:</label>
<div class="btn-group btn-group-xs" role="group">
<button type="button" class="btn btn-success hint--top hint--rounded" data-hint="Show the hidden decal keys." ng-click="unhideDecals()"> Unhide</button>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" ng-click="cancel()">Done</button>
</div>
</script>
<!--***********************************************
Markdown dialog for displaying README, etc.
************************************************-->

133
kb.js

@ -337,6 +337,122 @@
document.getElementById("body_all").style.display = "";
document.getElementById("summary_print").style.display = "none";
};
$scope.removeLegends = function(param) {
var prop = 'labels';
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 'specials' : var re = /<.*>/; break;
case 'others' : var re = /^[^A-Za-z0-9\`\~\!\@\#\$\%\^\&\*\(\)\-\_\=\+\[\{\]\}\;\:\'\"\,\<\.\>\/\?\\\|]$|^[A-Za-z\s][A-Za-z\s]+$|\&\#.*|\&.*?;/; break;
case 'decals' : {
angular.forEach($scope.keys(), function(key) {
if(key.decal) {
for (var i=0; i<=11; i++){
if (key.labels[i]){
var lab = "";
update(key,prop,lab,i); // should we wipe the textSize and textColor too?
renderKey(key);
}
}
}
}); break;
}
}
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); // should we wipe the textSize and textColor too?
renderKey(key);
}
}
}
});
};
$scope.unhideDecals = function() {
var prop = 'decal';
angular.forEach($scope.keys(), function(key) {
if(key.decal) {
update(key,prop,false);
renderKey(key);
}
});
};
$scope.moveLegends = function(moveOrSwap,a,b,c,d) {
var move = (moveOrSwap == 'move'? true : false);
var all = ($scope.selectedKeys.length>0 ? false : true);
angular.forEach($scope.keys(), function(key) {
var ndx =$scope.selectedKeys.indexOf(key);
if(!key.decal && (ndx>=0 || all) && move) {
if ((key.labels[a] && key.labels[b]) && !((key.labels[c] || key.labels[d])))
{
key.labels[c] = key.labels[a];
key.labels[d] = key.labels[b];
key.labels[a] = '';
key.labels[b] = '';
key.textColor[c] = key.textColor[a];
key.textColor[d] = key.textColor[b];
key.textColor[a] = '';
key.textColor[b] = '';
key.textSize[c] = key.textSize[a];
key.textSize[d] = key.textSize[b];
key.textSize[a] = '';
key.textSize[b] = '';
};
};
if(!key.decal && (ndx>=0 || all) && !move) {
if (key.labels[a] && key.labels[b])
{
var swap = key.labels[b];
key.labels[b] = key.labels[a];
key.labels[a] = swap;
var swap = key.textColor[b];
key.textColor[b] = key.textColor[a];
key.textColor[a] = swap;
var swap = key.textSize[b];
key.textSize[b] = key.textSize[a];
key.textSize[a] = swap;
};
};
renderKey(key);
});
};
$scope.moveSingleLegends = function() {
var fromId = document.querySelector('input[name = "fromId"]:checked').value;
// alert(fromId);
var toId = document.querySelector('input[name = "toId"]:checked').value;
// alert(toId);
var all = ($scope.selectedKeys.length>0 ? false : true);
if ((fromId >=0) && (toId >= 0))
{angular.forEach($scope.keys(), function(key) {
var ndx =$scope.selectedKeys.indexOf(key);
if(!key.decal && (ndx>=0 || all)) {
if (key.labels[fromId] && !(key.labels[toId]))
{
key.labels[toId] = key.labels[fromId];
key.labels[fromId] = '';
key.textColor[toId] = key.textColor[fromId];
key.textColor[fromId] = '';
key.textSize[toId] = key.textSize[fromId];
key.textSize[fromId] = '';
};
};
renderKey(key);
})
}
};
// Helper function to select a single key
function selectKey(key,event) {
@ -427,7 +543,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;
@ -1445,6 +1561,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) {

@ -1,5 +1,9 @@
{
"cherry": { "mount": "cherry", "name": "Cherry MX Mount", "brands": {
"aula": { "brand": "aula", "name": "AULA (HiDeep Inc.)", "switches": {
"Blue": { "part": "Blue", "name": "AULA Blue", "feel": "clicky", "weight": 50 }
}},
"cherry": { "brand": "cherry", "name": "Cherry Electrical Products", "switches": {
"MX1A-A1xx": { "part": "MX1A-A1xx", "name": "MX White", "feel": "clicky", "weight": 70 },
"MX1A-11xx": { "part": "MX1A-11xx", "name": "MX Black", "feel": "linear", "weight": 60 },
@ -55,6 +59,13 @@
"PG151101D64/D10": { "part": "PG151101D64/D10", "name": "Kailh Blue", "feel": "clicky", "weight": 60 },
"PG151101D49/D09": { "part": "PG151101D49/D09", "name": "Kailh Brown", "feel": "tactile", "weight": 55 },
"PG151101D05/D43": { "part": "PG151101D05/D43", "name": "Kailh Red", "feel": "linear", "weight": 50 }
}},
"nimxo": { "brand": "nimxo", "name": "NIMXO (Ni Mosuo)", "switches": {
"Gray": { "part": "Gray", "name": "NIMXO Gray", "feel": "clicky", "weight": 60 }
}},
"razor": { "brand": "razor", "name": "Razor Inc.", "switches": {
"Green": { "part": "Green", "name": "Razor Green", "feel": "clicky", "weight": 50 },
"Orange": { "part": "Orange", "name": "Razor Orange", "feel": "tactile", "weight": 45 }
}}
}},
"alps": { "mount": "alps", "name": "Alps Mount", "brands": {
@ -68,4 +79,7 @@
"PG155B01": { "part": "PG155B01", "name": "Quiet Click", "feel": "tactile", "weight": 60 }
}}
}}
}
}

Loading…
Cancel
Save