mirror of
https://github.com/piskelapp/piskel.git
synced 2023-08-10 21:12:52 +03:00
Fixed jshint warnings
This commit is contained in:
parent
2edda09f08
commit
26dc185bca
@ -1,50 +1,48 @@
|
|||||||
(function () {
|
(function () {
|
||||||
var ns = $.namespace("pskl");
|
var ns = $.namespace("pskl");
|
||||||
|
|
||||||
ns.KeyManager = function () {
|
ns.KeyManager = function () {
|
||||||
$(document.body).keydown($.proxy(this.onKeyUp_, this));
|
$(document.body).keydown($.proxy(this.onKeyUp_, this));
|
||||||
};
|
};
|
||||||
|
|
||||||
// Kind of object that make you want to stop front-end _engineering_:
|
// Kind of object that make you want to stop front-end _engineering_:
|
||||||
ns.KeyManager.prototype.CharCodeToKeyCodeMap = {
|
ns.KeyManager.prototype.CharCodeToKeyCodeMap = {
|
||||||
|
|
||||||
90 : "z",
|
90 : "z",
|
||||||
89 : "y",
|
89 : "y",
|
||||||
88 : "x",
|
88 : "x",
|
||||||
67 : "c",
|
67 : "c",
|
||||||
86 : "v"
|
86 : "v"
|
||||||
};
|
};
|
||||||
|
|
||||||
ns.KeyManager.prototype.KeyboardActions = {
|
ns.KeyManager.prototype.KeyboardActions = {
|
||||||
|
|
||||||
"ctrl" : {
|
"ctrl" : {
|
||||||
"z" : Events.UNDO,
|
"z" : Events.UNDO,
|
||||||
"y" : Events.REDO,
|
"y" : Events.REDO,
|
||||||
"x" : Events.CUT,
|
"x" : Events.CUT,
|
||||||
"c" : Events.COPY,
|
"c" : Events.COPY,
|
||||||
"v" : Events.PASTE
|
"v" : Events.PASTE
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ns.KeyManager.prototype.onKeyUp_ = function(evt) {
|
||||||
|
var isMac = false;
|
||||||
ns.KeyManager.prototype.onKeyUp_ = function(evt) {
|
if (navigator.appVersion.indexOf("Mac")!=-1) {
|
||||||
var isMac = false;
|
// Welcome in mac world where vowels are consons and meta used instead of ctrl:
|
||||||
if (navigator.appVersion.indexOf("Mac")!=-1) {
|
isMac = true;
|
||||||
// Welcome in mac world where vowels are consons and meta used instead of ctrl:
|
}
|
||||||
isMac = true;
|
|
||||||
}
|
if (isMac ? evt.metaKey : evt.ctrlKey) {
|
||||||
|
// Get key pressed:
|
||||||
if (isMac ? evt.metaKey : evt.ctrlKey) {
|
var letter = this.CharCodeToKeyCodeMap[evt.which];
|
||||||
// Get key pressed:
|
if(letter) {
|
||||||
var letter = this.CharCodeToKeyCodeMap[evt.which];
|
var eventToTrigger = this.KeyboardActions.ctrl[letter];
|
||||||
if(letter) {
|
if(eventToTrigger) {
|
||||||
var eventToTrigger = this.KeyboardActions["ctrl"][letter];
|
$.publish(eventToTrigger);
|
||||||
if(eventToTrigger) {
|
}
|
||||||
$.publish(eventToTrigger);
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
})();
|
})();
|
Loading…
Reference in New Issue
Block a user