jstree-rails 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. data/.gitignore +17 -0
  2. data/Gemfile +4 -0
  3. data/INSTALLER.sh +57 -0
  4. data/LICENSE +22 -0
  5. data/README.md +29 -0
  6. data/Rakefile +2 -0
  7. data/jstree-rails.gemspec +17 -0
  8. data/lib/jstree-rails/rails.rb +6 -0
  9. data/lib/jstree-rails/version.rb +5 -0
  10. data/lib/jstree-rails.rb +8 -0
  11. data/vendor/assets/images/jstree/themes/default/d.gif +0 -0
  12. data/vendor/assets/images/jstree/themes/default/d.png +0 -0
  13. data/vendor/assets/images/jstree/themes/default/throbber.gif +0 -0
  14. data/vendor/assets/images/jstree/themes/default-rtl/d.gif +0 -0
  15. data/vendor/assets/images/jstree/themes/default-rtl/d.png +0 -0
  16. data/vendor/assets/images/jstree/themes/default-rtl/dots.gif +0 -0
  17. data/vendor/assets/images/jstree/themes/default-rtl/throbber.gif +0 -0
  18. data/vendor/assets/javascripts/jstree/index.js +15 -0
  19. data/vendor/assets/javascripts/jstree/jstree.checkbox.js +187 -0
  20. data/vendor/assets/javascripts/jstree/jstree.contextmenu.js +145 -0
  21. data/vendor/assets/javascripts/jstree/jstree.dnd.js +162 -0
  22. data/vendor/assets/javascripts/jstree/jstree.hotkeys.js +138 -0
  23. data/vendor/assets/javascripts/jstree/jstree.html.js +69 -0
  24. data/vendor/assets/javascripts/jstree/jstree.js +1982 -0
  25. data/vendor/assets/javascripts/jstree/jstree.json.js +99 -0
  26. data/vendor/assets/javascripts/jstree/jstree.rules.js +145 -0
  27. data/vendor/assets/javascripts/jstree/jstree.sort.js +38 -0
  28. data/vendor/assets/javascripts/jstree/jstree.state.js +39 -0
  29. data/vendor/assets/javascripts/jstree/jstree.themes.js +215 -0
  30. data/vendor/assets/javascripts/jstree/jstree.ui.js +201 -0
  31. data/vendor/assets/javascripts/jstree/jstree.unique.js +33 -0
  32. data/vendor/assets/javascripts/jstree/jstree.xml.js +185 -0
  33. data/vendor/assets/javascripts/jstree/vakata.js +2079 -0
  34. data/vendor/assets/stylesheets/jstree/themes/default/style.css +79 -0
  35. data/vendor/assets/stylesheets/jstree/themes/default-rtl/style.css +84 -0
  36. metadata +80 -0
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in jstree-rails.gemspec
4
+ gemspec
data/INSTALLER.sh ADDED
@@ -0,0 +1,57 @@
1
+ #!/bin/bash
2
+
3
+ # Copy the images, assets, and javascripts into the rails-jquery gem.
4
+
5
+ # This is the path to the original JsTree GitHub checkout:
6
+ # git://github.com/vakata/jstree.git
7
+ SRC_DIR=/opt/gems/jstree
8
+
9
+ # Everything that we copy from the original jstree distribution goes here.
10
+ ASSET_DIR=./vendor/assets
11
+
12
+ rm -rf $ASSET_DIR
13
+ mkdir -p $ASSET_DIR/stylesheets/jstree/themes/default
14
+ mkdir -p $ASSET_DIR/stylesheets/jstree/themes/default-rtl
15
+ mkdir -p $ASSET_DIR/images/jstree/themes/default
16
+ mkdir -p $ASSET_DIR/images/jstree/themes/default-rtl
17
+ mkdir -p $ASSET_DIR/javascripts/jstree
18
+
19
+ cp $SRC_DIR/src/*.js $ASSET_DIR/javascripts/jstree
20
+
21
+ # Caution, the order of these matters.
22
+ cat > $ASSET_DIR/javascripts/jstree/index.js <<__EOF__
23
+ //= require jstree/vakata.js
24
+ //= require jstree/jstree.js
25
+ //= require jstree/jstree.checkbox.js
26
+ //= require jstree/jstree.contextmenu.js
27
+ //= require jstree/jstree.dnd.js
28
+ //= require jstree/jstree.hotkeys.js
29
+ //= require jstree/jstree.html.js
30
+ //= require jstree/jstree.json.js
31
+ //= require jstree/jstree.rules.js
32
+ //= require jstree/jstree.sort.js
33
+ //= require jstree/jstree.state.js
34
+ //= require jstree/jstree.themes.js
35
+ //= require jstree/jstree.ui.js
36
+ //= require jstree/jstree.unique.js
37
+ //= require jstree/jstree.xml.js
38
+ __EOF__
39
+
40
+ # You will need this somewhere in your javascript to
41
+ # select a theme.
42
+ # $.jstree.THEMES_DIR = '/assets/jstree/themes/';
43
+
44
+ # Copy theme images.
45
+ cp $SRC_DIR/src/themes/default/{*.gif,*.png} \
46
+ $ASSET_DIR/images/jstree/themes/default
47
+
48
+ cp $SRC_DIR/src/themes/default-rtl/{*.gif,*.png} \
49
+ $ASSET_DIR/images/jstree/themes/default-rtl
50
+
51
+ # Copy theme stylesheets.
52
+ cp $SRC_DIR/src/themes/default/*.css \
53
+ $ASSET_DIR/stylesheets/jstree/themes/default
54
+
55
+ cp $SRC_DIR/src/themes/default-rtl/*.css \
56
+ $ASSET_DIR/stylesheets/jstree/themes/default-rtl
57
+
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Michael Schmitz
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Jstree::Rails
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'jstree-rails'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install jstree-rails
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,17 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/jstree-rails/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Michael Schmitz"]
6
+ gem.email = ["lydianblues@gmail.com"]
7
+ gem.description = %q{JSTree for Rails}
8
+ gem.summary = %q{Packagate JSTree for the Rails asset pipeline}
9
+ gem.homepage = ""
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "jstree-rails"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Jstree::Rails::VERSION
17
+ end
@@ -0,0 +1,6 @@
1
+ module JsTreeRails
2
+ module Rails
3
+ class Engine < ::Rails::Engine
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ module Jstree
2
+ module Rails
3
+ VERSION = "0.0.2"
4
+ end
5
+ end
@@ -0,0 +1,8 @@
1
+ require "jstree-rails/version"
2
+ require "jstree-rails/rails"
3
+
4
+ module FileUpload
5
+ module Rails
6
+ # Your code goes here...
7
+ end
8
+ end
@@ -0,0 +1,15 @@
1
+ //= require jstree/vakata.js
2
+ //= require jstree/jstree.js
3
+ //= require jstree/jstree.checkbox.js
4
+ //= require jstree/jstree.contextmenu.js
5
+ //= require jstree/jstree.dnd.js
6
+ //= require jstree/jstree.hotkeys.js
7
+ //= require jstree/jstree.html.js
8
+ //= require jstree/jstree.json.js
9
+ //= require jstree/jstree.rules.js
10
+ //= require jstree/jstree.sort.js
11
+ //= require jstree/jstree.state.js
12
+ //= require jstree/jstree.themes.js
13
+ //= require jstree/jstree.ui.js
14
+ //= require jstree/jstree.unique.js
15
+ //= require jstree/jstree.xml.js
@@ -0,0 +1,187 @@
1
+ /* File: jstree.checkbox.js
2
+ Adds checkboxes to the tree.
3
+ */
4
+ (function ($) {
5
+ $.jstree.plugin("checkbox", {
6
+ __construct : function () {
7
+ this.get_container()
8
+ .bind("__construct.jstree", $.proxy(function () {
9
+ // TODO: on move/copy - clean new location and parents
10
+ }, this))
11
+ .bind("move_node.jstree, copy_node.jstree", function (e, data) {
12
+ if(data.rslt.old_instance && data.rslt.old_parent && $.isFunction(data.rslt.old_instance.checkbox_repair)) {
13
+ data.rslt.old_instance.checkbox_repair(data.rslt.old_parent);
14
+ }
15
+ if(data.rslt.new_instance && $.isFunction(data.rslt.new_instance.checkbox_repair)) {
16
+ data.rslt.new_instance.checkbox_repair(data.rslt.parent);
17
+ }
18
+ })
19
+ .bind("delete_node.jstree", function (e, data) {
20
+ this.checkbox_repair(data.rslt.parent);
21
+ })
22
+ .delegate("a", "click.jstree", $.proxy(function (e) {
23
+ e.preventDefault();
24
+ e.currentTarget.blur();
25
+ var obj = this.get_node(e.currentTarget);
26
+ this.toggle_check(obj);
27
+ }, this));
28
+ },
29
+ defaults : {
30
+ three_state : true
31
+ },
32
+ _fn : {
33
+ /*
34
+ Group: CHECKBOX functions
35
+ */
36
+ check_node : function (obj) {
37
+ obj = this.get_node(obj);
38
+ obj.find(' > a > .jstree-checkbox').removeClass('jstree-unchecked jstree-undetermined').addClass('jstree-checked').children(':checkbox').prop('checked', true).prop('undermined', false);
39
+ this.checkbox_repair(obj);
40
+ },
41
+ uncheck_node : function (obj) {
42
+ obj = this.get_node(obj);
43
+ obj.find(' > a > .jstree-checkbox').removeClass('jstree-checked jstree-undetermined').addClass('jstree-unchecked').children(':checkbox').prop('checked', false).prop('undermined', false);
44
+ this.checkbox_repair(obj);
45
+ },
46
+ toggle_check : function (obj) {
47
+ obj = obj.find(' > a > .jstree-checkbox').removeClass('jstree-undetermined').toggleClass('jstree-checked');
48
+ if(!obj.hasClass('jstree-checked')) {
49
+ obj.addClass('jstree-unchecked').children(':checkbox').prop('checked', false).prop('undermined', false);
50
+ }
51
+ else {
52
+ obj.children(':checkbox').prop('checked', true).prop('undermined', false);
53
+ }
54
+ this.checkbox_repair(this.get_node(obj));
55
+ },
56
+ uncheck_all : function (context) {
57
+ var ret = context ? $(context).find(".jstree-checked").closest('li') : this.get_container().find(".jstree-checked").closest('li');
58
+ ret.children(".jstree-checkbox").removeClass("jstree-checked jstree-undetermined").addClass('jstree-unchecked').children(':checkbox').prop('checked', false).prop('undermined', false);
59
+ this.__callback({ "obj" : ret });
60
+ },
61
+
62
+ checkbox_repair : function (obj) {
63
+ if(!this.get_settings(true).checkbox.three_state) { return false; }
64
+
65
+ if(!obj || obj === -1) {
66
+ obj = this.get_container_ul().children('li');
67
+ }
68
+ if(obj.length > 1) {
69
+ obj.each($.proxy(function (i, d) {
70
+ this.checkbox_repair($(d));
71
+ }, this));
72
+ }
73
+
74
+ var c = obj.find(' > a > .jstree-checkbox'),
75
+ fix_up = true,
76
+ p, st, sc, su, si;
77
+
78
+ if(!c.hasClass('jstree-checked') && !c.hasClass('jstree-unchecked')) {
79
+ p = this.get_parent(obj);
80
+ if(p && p !== -1 && p.length && p.find('> a > .jstree-checked').length) { c.addClass('jstree-checked'); }
81
+ else { c.addClass('jstree-unchecked'); }
82
+ fix_up = false;
83
+ }
84
+
85
+ if(c.hasClass('jstree-checked')) {
86
+ obj.find('.jstree-checkbox').removeClass('jstree-undetermined jstree-unchecked').addClass('jstree-checked').children(':checkbox').prop('checked', true).prop('undermined', false);
87
+ }
88
+ if(c.hasClass('jstree-unchecked')) {
89
+ obj.find('.jstree-checkbox').removeClass('jstree-undetermined jstree-checked').addClass('jstree-unchecked').children(':checkbox').prop('checked', false).prop('undermined', false);
90
+ }
91
+
92
+ while(fix_up) {
93
+ obj = this.get_parent(obj);
94
+ if(!obj || obj === -1 || !obj.length) { return; }
95
+
96
+ st = obj.find(' > ul > li');
97
+ sc = st.find(' > a > .jstree-checked').length;
98
+ su = st.find(' > a > .jstree-unchecked').length;
99
+ si = st.find(' > a > .jstree-undetermined').length;
100
+ st = st.length;
101
+
102
+ if(sc + su + si < st) { return; }
103
+
104
+ if(su === st) {
105
+ c = obj.find(' > a > .jstree-checkbox');
106
+ if(c.hasClass('jstree-unchecked')) { return; }
107
+ c.removeClass('jstree-undetermined jstree-checked').addClass('jstree-unchecked').children(':checkbox').prop('checked', false).prop('undermined', false);
108
+ continue;
109
+ }
110
+ if(sc === st) {
111
+ c = obj.find(' > a > .jstree-checkbox');
112
+ if(c.hasClass('jstree-checked')) { return; }
113
+ c.removeClass('jstree-undetermined jstree-unchecked').addClass('jstree-checked').children(':checkbox').prop('checked', true).prop('undermined', false);
114
+ continue;
115
+ }
116
+ obj.parentsUntil(".jstree", "li").andSelf().find(' > a > .jstree-checkbox').removeClass('jstree-checked jstree-unchecked').addClass('jstree-undetermined').children(':checkbox').prop('checked', false).prop('undetermined', true);
117
+ return;
118
+ }
119
+ },
120
+
121
+ clean_node : function(obj) {
122
+ obj = this.__call_old();
123
+ var t = this;
124
+ obj = obj.each(function () {
125
+ var o = $(this),
126
+ d = o.data("jstree");
127
+ o.find(" > a > .jstree-checkbox").remove();
128
+ o.children("a").prepend("<ins class='jstree-icon jstree-checkbox " + (d && d.checkbox && d.checkbox.checked === true ? 'jstree-checked' : '') + ( (d && d.checkbox && d.checkbox.checked === false) || !t.get_settings(true).checkbox.three_state ? 'jstree-unchecked' : '') + " '><input class='jstree-check' type='checkbox' " + (d && d.checkbox && d.checkbox.checked ? ' checked="checked" ' : '') + " name='" + (d && d.checkbox && typeof d.checkbox.name !== 'undefined' ? d.checkbox.name : 'jstree[]') + "' value='" + (d && d.checkbox && typeof d.checkbox.value !== 'undefined' ? d.checkbox.value : o.attr('id')) + "' /></ins>");
129
+ });
130
+ t.checkbox_repair(obj);
131
+ return obj;
132
+ },
133
+ get_state : function () {
134
+ var state = this.__call_old();
135
+ state.checked = [];
136
+ this.get_container().find('.jstree-checked').closest('li').each(function () { if(this.id) { state.checked.push(this.id); } });
137
+ return state;
138
+ },
139
+ set_state : function (state, callback) {
140
+ if(this.__call_old()) {
141
+ if(state.checkbox) {
142
+ var _this = this;
143
+ this.uncheck_all();
144
+ $.each(state.checkbox, function (i, v) {
145
+ _this.check_node(document.getElementById(v));
146
+ });
147
+ this.checkbox_repair();
148
+ delete state.checkbox;
149
+ this.set_state(state, callback);
150
+ return false;
151
+ }
152
+ return true;
153
+ }
154
+ return false;
155
+ },
156
+ get_json : function (obj, is_callback) {
157
+ var r = this.__call_old(), i;
158
+ if(is_callback) {
159
+ i = obj.find('> a > ins > :checkbox');
160
+ r.data.jstree.checkbox = {};
161
+ r.data.jstree.checkbox.checked = i.parent().hasClass('jstree-checked');
162
+ if(i.attr('name') !== 'jstree[]') { r.data.checkbox.name = i.attr('name'); }
163
+ if(i.val() !== obj.attr('id')) { r.data.checkbox.value = i.val(); }
164
+ }
165
+ return r;
166
+ }
167
+ }
168
+ });
169
+ $(function () {
170
+ // add checkbox specific CSS
171
+ var css_string = '' +
172
+ '.jstree a > .jstree-checkbox { height:16px; width:16px; margin-right:1px; } ' +
173
+ '.jstree-rtl a > .jstree-checkbox { margin-right:0; margin-left:1px; } ' +
174
+ '.jstree .jstree-check { margin:0; padding:0; border:0; display:inline; vertical-align:text-bottom; } ';
175
+ // Correct IE 6 (does not support the > CSS selector)
176
+ if($.jstree.IS_IE6) {
177
+ css_string += '' +
178
+ '.jstree li a .jstree-checkbox { height:16px; width:16px; background:transparent; margin-right:1px; } ' +
179
+ '.jstree-rtl li a .jstree-checkbox { margin-right:0; margin-left:1px; } ';
180
+ }
181
+ // the default stylesheet
182
+ $.vakata.css.add_sheet({ str : css_string, title : "jstree" });
183
+ });
184
+ // include the checkbox plugin by default
185
+ $.jstree.defaults.plugins.push("checkbox");
186
+ })(jQuery);
187
+ //*/
@@ -0,0 +1,145 @@
1
+ /* File: jstree.contextmenu.js
2
+ Enables a rightclick contextmenu.
3
+ */
4
+ /* Group: jstree sort plugin */
5
+ (function ($) {
6
+ $.jstree.plugin("contextmenu", {
7
+ __construct : function () {
8
+ this.get_container()
9
+ .delegate("a", "contextmenu.jstree", $.proxy(function (e) {
10
+ e.preventDefault();
11
+ if(!this.is_loading(e.currentTarget)) {
12
+ this.show_contextmenu(e.currentTarget, e.pageX, e.pageY);
13
+ }
14
+ }, this))
15
+ .delegate("a", "click.jstree", $.proxy(function (e) {
16
+ if(this.data.contextmenu.visible) {
17
+ this._hide_contextmenu();
18
+ }
19
+ }, this));
20
+ $(document).bind("context_hide.vakata", $.proxy(function () { this.data.contextmenu = false; }, this));
21
+ },
22
+ __destruct : function () {
23
+ if(this.data.contextmenu) {
24
+ this._hide_contextmenu();
25
+ }
26
+ },
27
+ defaults : {
28
+ select_node : true,
29
+ show_at_node : true,
30
+ items : function (o) { // Could be an object directly
31
+ // TODO: in "_disabled" call this._check()
32
+ return {
33
+ "create" : {
34
+ "separator_before" : false,
35
+ "separator_after" : true,
36
+ "label" : "Create",
37
+ "action" : function (data) {
38
+ var inst = $.jstree._reference(data.reference),
39
+ obj = inst.get_node(data.reference);
40
+ inst.create_node(obj, {}, "last", function (new_node) {
41
+ setTimeout(function () { inst.edit(new_node); },0);
42
+ });
43
+ }
44
+ },
45
+ "rename" : {
46
+ "separator_before" : false,
47
+ "separator_after" : false,
48
+ "label" : "Rename",
49
+ "action" : function (data) {
50
+ var inst = $.jstree._reference(data.reference),
51
+ obj = inst.get_node(data.reference);
52
+ inst.edit(obj);
53
+ }
54
+ },
55
+ "remove" : {
56
+ "separator_before" : false,
57
+ "icon" : false,
58
+ "separator_after" : false,
59
+ "label" : "Delete",
60
+ "action" : function (data) {
61
+ var inst = $.jstree._reference(data.reference),
62
+ obj = inst.get_node(data.reference);
63
+ inst.delete_node(obj);
64
+ }
65
+ },
66
+ "ccp" : {
67
+ "separator_before" : true,
68
+ "icon" : false,
69
+ "separator_after" : false,
70
+ "label" : "Edit",
71
+ "action" : false,
72
+ "submenu" : {
73
+ "cut" : {
74
+ "separator_before" : false,
75
+ "separator_after" : false,
76
+ "label" : "Cut",
77
+ "action" : function (data) {
78
+ var inst = $.jstree._reference(data.reference),
79
+ obj = inst.get_node(data.reference);
80
+ inst.cut(obj);
81
+ }
82
+ },
83
+ "copy" : {
84
+ "separator_before" : false,
85
+ "icon" : false,
86
+ "separator_after" : false,
87
+ "label" : "Copy",
88
+ "action" : function (data) {
89
+ var inst = $.jstree._reference(data.reference),
90
+ obj = inst.get_node(data.reference);
91
+ inst.copy(obj);
92
+ }
93
+ },
94
+ "paste" : {
95
+ "separator_before" : false,
96
+ "icon" : false,
97
+ "_disabled" : !(this.can_paste()),
98
+ "separator_after" : false,
99
+ "label" : "Paste",
100
+ "action" : function (data) {
101
+ var inst = $.jstree._reference(data.reference),
102
+ obj = inst.get_node(data.reference);
103
+ inst.paste(obj);
104
+ }
105
+ }
106
+ }
107
+ }
108
+ };
109
+ }
110
+ },
111
+ _fn : {
112
+ show_contextmenu : function (obj, x, y) {
113
+ obj = this.get_node(obj);
114
+ var s = this.get_settings().contextmenu,
115
+ a = obj.children("a:visible:eq(0)"),
116
+ o = false,
117
+ i = false;
118
+ if(s.show_at_node || typeof x === "undefined" || typeof y === "undefined") {
119
+ o = a.offset();
120
+ x = o.left;
121
+ y = o.top + this.data.core.li_height;
122
+ }
123
+ if(s.select_node && this.data.ui && !this.is_selected(obj)) {
124
+ this.deselect_all();
125
+ this.select_node(obj);
126
+ }
127
+
128
+ i = obj.data("jstree") && obj.data("jstree").contextmenu ? obj.data("jstree").contextmenu : s.items;
129
+ if($.isFunction(i)) { i = i.call(this, obj); }
130
+
131
+ $(document).one("context_show.vakata", $.proxy(function (e, data) {
132
+ var cls = 'jstree-contextmenu';
133
+ if(this.data.themes.theme) {
134
+ cls += ' jstree-' + this.data.themes.theme + '-contextmenu';
135
+ }
136
+ $(data.element).addClass(cls);
137
+ }, this));
138
+ this.data.contextmenu.visible = true;
139
+ $.vakata.context.show(a, { 'x' : x, 'y' : y }, i);
140
+ this.__callback({ "obj" : obj, "x" : x, "y" : y });
141
+ }
142
+ }
143
+ });
144
+ $.jstree.defaults.plugins.push("contextmenu");
145
+ })(jQuery);