2 if(typeof window.hotkeys ==
"undefined")
throw "jsTree hotkeys: jQuery hotkeys plugin not included.";
4 $.extend($.tree.plugins, {
11 "up" : function () { $.tree.plugins.hotkeys.get_prev.apply(
this);
return false; },
12 "down" :
function () { $.tree.plugins.hotkeys.get_next.apply(
this);
return false; },
13 "left" :
function () { $.tree.plugins.hotkeys.get_left.apply(
this);
return false; },
14 "right" :
function () { $.tree.plugins.hotkeys.get_right.apply(
this);
return false; },
15 "f2" :
function () {
if(this.selected) this.rename();
return false; },
16 "del" :
function () {
if(this.selected) this.
remove();
return false; },
17 "ctrl+c":
function () {
if(this.selected) this.copy();
return false; },
18 "ctrl+x":
function () {
if(this.selected) this.cut();
return false; },
19 "ctrl+v":
function () {
if(this.selected) this.paste();
return false; }
22 exec :
function(key) {
23 if($.tree.plugins.hotkeys.disabled)
return false;
25 var t = $.tree.focused();
26 if(typeof t.settings.plugins.hotkeys ==
"undefined")
return;
27 var opts = $.extend(
true, {}, $.tree.plugins.hotkeys.defaults, t.settings.plugins.hotkeys);
28 if(typeof opts.functions[key] ==
"function")
return opts.functions[key].apply(t);
30 get_next :
function() {
31 var opts = $.extend(
true, {}, $.tree.plugins.hotkeys.defaults, this.settings.plugins.hotkeys);
32 var obj = this.hovered || this.selected;
33 return opts.hover_mode ? this.hover_branch(this.next(obj)) : this.select_branch(this.next(obj));
35 get_prev :
function() {
36 var opts = $.extend(
true, {}, $.tree.plugins.hotkeys.defaults, this.settings.plugins.hotkeys);
37 var obj = this.hovered || this.selected;
38 return opts.hover_mode ? this.hover_branch(this.prev(obj)) : this.select_branch(this.prev(obj));
40 get_left :
function() {
41 var opts = $.extend(
true, {}, $.tree.plugins.hotkeys.defaults, this.settings.plugins.hotkeys);
42 var obj = this.hovered || this.selected;
44 if(obj.hasClass(
"open")) this.close_branch(obj);
46 return opts.hover_mode ? this.hover_branch(this.parent(obj)) : this.select_branch(this.parent(obj));
50 get_right :
function() {
51 var opts = $.extend(
true, {}, $.tree.plugins.hotkeys.defaults, this.settings.plugins.hotkeys);
52 var obj = this.hovered || this.selected;
54 if(obj.hasClass(
"closed")) this.open_branch(obj);
56 return opts.hover_mode ? this.hover_branch(obj.find(
"li:eq(0)")) : this.select_branch(obj.find(
"li:eq(0)"));
62 oninit :
function (t) {
63 var opts = $.extend(
true, {}, $.tree.plugins.hotkeys.defaults, this.settings.plugins.hotkeys);
64 for(var i in opts.functions) {
65 if(opts.functions.hasOwnProperty(i) && $.inArray(i, $.tree.plugins.hotkeys.bound) == -1) {
67 $(document).bind(
"keydown", { combi : k, disableInInput:
true },
function (event) {
68 return $.tree.plugins.hotkeys.exec(k);
71 $.tree.plugins.hotkeys.bound.push(i);