compass-jquery-plugin 0.3.0.beta.14 → 0.3.0.beta.16

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. data/.loadpath +5 -5
  2. data/.project +18 -18
  3. data/README.textile +19 -1
  4. data/VERSION.yml +1 -1
  5. data/compass-jquery-plugin.gemspec +42 -7
  6. data/gem_tasks/jrails.rake +1 -1
  7. data/gem_tasks/jstree.rake +96 -0
  8. data/gem_tasks/rubygems.rake +1 -1
  9. data/lib/jquery/flash_messages.rb +45 -45
  10. data/lib/jquery/jstree/jstree.rb +116 -0
  11. data/lib/jquery/jstree.rb +7 -0
  12. data/templates/dynatree/jquery.ui/dynatree.aero/ltWait.gif +0 -0
  13. data/templates/dynatree/manifest.rb +146 -147
  14. data/templates/jqgrid/i18n/jqgrid/locale-gl.js +126 -0
  15. data/templates/jqgrid/i18n/jqgrid/locale-gl.min.js +7 -0
  16. data/templates/jqgrid/jquery.jqGrid.js +11565 -11572
  17. data/templates/jqgrid/jquery.jqGrid.min.js +472 -473
  18. data/templates/jqgrid/manifest.rb +70 -72
  19. data/templates/jqical/jquery.jqical.js +7907 -7321
  20. data/templates/jqical/jquery.jqical.min.js +209 -185
  21. data/templates/jqical/jquery.ui/jqical.scss +940 -941
  22. data/templates/jrails/config/initializers/jrails.rb +1 -0
  23. data/templates/jrails/jquery.hotkeys.js +99 -0
  24. data/templates/jrails/jquery.hotkeys.min.js +3 -0
  25. data/templates/jrails/manifest.rb +2 -0
  26. data/templates/jstree/config/initializers/jstree.rb +8 -0
  27. data/templates/jstree/jquery.jstree.js +3664 -0
  28. data/templates/jstree/jquery.jstree.min.js +174 -0
  29. data/templates/jstree/jquery.ui/jstree.aero/clicked.png +0 -0
  30. data/templates/jstree/jquery.ui/jstree.aero/d.gif +0 -0
  31. data/templates/jstree/jquery.ui/jstree.aero/d.png +0 -0
  32. data/templates/jstree/jquery.ui/jstree.aero/hovered.png +0 -0
  33. data/templates/jstree/jquery.ui/jstree.aero/throbber.gif +0 -0
  34. data/templates/jstree/jquery.ui/jstree.aero.scss +209 -0
  35. data/templates/jstree/jquery.ui/jstree.aqua/clicked.png +0 -0
  36. data/templates/jstree/jquery.ui/jstree.aqua/d.gif +0 -0
  37. data/templates/jstree/jquery.ui/jstree.aqua/d.png +0 -0
  38. data/templates/jstree/jquery.ui/jstree.aqua/hovered.png +0 -0
  39. data/templates/jstree/jquery.ui/jstree.aqua/throbber.gif +0 -0
  40. data/templates/jstree/jquery.ui/jstree.aqua.scss +214 -0
  41. data/templates/jstree/jquery.ui/jstree.chrystal/d.gif +0 -0
  42. data/templates/jstree/jquery.ui/jstree.chrystal/d.png +0 -0
  43. data/templates/jstree/jquery.ui/jstree.chrystal/throbber.gif +0 -0
  44. data/templates/jstree/jquery.ui/jstree.chrystal.scss +205 -0
  45. data/templates/jstree/jquery.ui/jstree.classic/d.png +0 -0
  46. data/templates/jstree/jquery.ui/jstree.classic/dot_for_ie.gif +0 -0
  47. data/templates/jstree/jquery.ui/jstree.classic/throbber.gif +0 -0
  48. data/templates/jstree/jquery.ui/jstree.classic.scss +148 -0
  49. data/templates/jstree/jquery.ui/jstree.default/d.gif +0 -0
  50. data/templates/jstree/jquery.ui/jstree.default/d.png +0 -0
  51. data/templates/jstree/jquery.ui/jstree.default/throbber.gif +0 -0
  52. data/templates/jstree/jquery.ui/jstree.default-rtl/d.gif +0 -0
  53. data/templates/jstree/jquery.ui/jstree.default-rtl/d.png +0 -0
  54. data/templates/jstree/jquery.ui/jstree.default-rtl/dots.gif +0 -0
  55. data/templates/jstree/jquery.ui/jstree.default-rtl/throbber.gif +0 -0
  56. data/templates/jstree/jquery.ui/jstree.default-rtl.scss +228 -0
  57. data/templates/jstree/jquery.ui/jstree.default.scss +189 -0
  58. data/templates/jstree/manifest.rb +35 -0
  59. metadata +44 -9
  60. data/templates/dynatree/jquery.ui/dynatree.aero/ltWait.ani +0 -0
  61. data/templates/jqgrid/i18n/jqgrid/locale-dk.js +0 -128
  62. data/templates/jqgrid/i18n/jqgrid/locale-dk.min.js +0 -6
  63. data/templates/jqgrid/i18n/jqgrid/locale-sp.js +0 -128
  64. data/templates/jqgrid/i18n/jqgrid/locale-sp.min.js +0 -7
@@ -0,0 +1,3664 @@
1
+ /*
2
+ * jsTree 1.0-rc1
3
+ * http://jstree.com/
4
+ *
5
+ * Copyright (c) 2010 Ivan Bozhanov (vakata.com)
6
+ *
7
+ * Dual licensed under the MIT and GPL licenses (same as jQuery):
8
+ * http://www.opensource.org/licenses/mit-license.php
9
+ * http://www.gnu.org/licenses/gpl.html
10
+ *
11
+ * $Date: 2010-07-01 10:51:11 +0300 (четв, 01 юли 2010) $
12
+ * $Revision: 191 $
13
+ */
14
+
15
+ /*jslint browser: true, onevar: true, undef: true, bitwise: true, strict: true */
16
+ /*global window : false, clearInterval: false, clearTimeout: false, document: false, setInterval: false, setTimeout: false, jQuery: false, navigator: false, XSLTProcessor: false, DOMParser: false, XMLSerializer: false*/
17
+
18
+ "use strict";
19
+ // Common functions not related to jsTree
20
+ // decided to move them to a `vakata` "namespace"
21
+ (function ($) {
22
+ $.vakata = {};
23
+ // CSS related functions
24
+ $.vakata.css = {
25
+ get_css : function(rule_name, delete_flag, sheet) {
26
+ rule_name = rule_name.toLowerCase();
27
+ var css_rules = sheet.cssRules || sheet.rules,
28
+ j = 0;
29
+ do {
30
+ if(css_rules.length && j > css_rules.length + 5) { return false; }
31
+ if(css_rules[j].selectorText && css_rules[j].selectorText.toLowerCase() == rule_name) {
32
+ if(delete_flag === true) {
33
+ if(sheet.removeRule) { sheet.removeRule(j); }
34
+ if(sheet.deleteRule) { sheet.deleteRule(j); }
35
+ return true;
36
+ }
37
+ else { return css_rules[j]; }
38
+ }
39
+ }
40
+ while (css_rules[++j]);
41
+ return false;
42
+ },
43
+ add_css : function(rule_name, sheet) {
44
+ if($.jstree.css.get_css(rule_name, false, sheet)) { return false; }
45
+ if(sheet.insertRule) { sheet.insertRule(rule_name + ' { }', 0); } else { sheet.addRule(rule_name, null, 0); }
46
+ return $.vakata.css.get_css(rule_name);
47
+ },
48
+ remove_css : function(rule_name, sheet) {
49
+ return $.vakata.css.get_css(rule_name, true, sheet);
50
+ },
51
+ add_sheet : function(opts) {
52
+ var tmp;
53
+ if(opts.str) {
54
+ tmp = document.createElement("style");
55
+ tmp.setAttribute('type',"text/css");
56
+ if(tmp.styleSheet) {
57
+ document.getElementsByTagName("head")[0].appendChild(tmp);
58
+ tmp.styleSheet.cssText = opts.str;
59
+ }
60
+ else {
61
+ tmp.appendChild(document.createTextNode(opts.str));
62
+ document.getElementsByTagName("head")[0].appendChild(tmp);
63
+ }
64
+ return tmp.sheet || tmp.styleSheet;
65
+ }
66
+ if(opts.url) {
67
+ if(document.createStyleSheet) {
68
+ try { tmp = document.createStyleSheet(opts.url); } catch (e) { }
69
+ }
70
+ else {
71
+ tmp = document.createElement('link');
72
+ tmp.rel = 'stylesheet';
73
+ tmp.type = 'text/css';
74
+ tmp.media = "all";
75
+ tmp.href = opts.url;
76
+ document.getElementsByTagName("head")[0].appendChild(tmp);
77
+ return tmp.styleSheet;
78
+ }
79
+ }
80
+ }
81
+ };
82
+ })(jQuery);
83
+ //*/
84
+
85
+
86
+ /*
87
+ * jsTree core 1.0
88
+ */
89
+ (function ($) {
90
+ // private variables
91
+ var instances = [], // instance array (used by $.jstree.reference/create/focused)
92
+ focused_instance = -1, // the index in the instance array of the currently focused instance
93
+ plugins = {}, // list of included plugins
94
+ prepared_move = {}, // for the move plugin
95
+ is_ie6 = false;
96
+
97
+ // jQuery plugin wrapper (thanks to jquery UI widget function)
98
+ $.fn.jstree = function (settings) {
99
+ var isMethodCall = (typeof settings == 'string'), // is this a method call like $().jstree("open_node")
100
+ args = Array.prototype.slice.call(arguments, 1),
101
+ returnValue = this;
102
+
103
+ // extend settings and allow for multiple hashes and metadata
104
+ if(!isMethodCall && $.meta) { args.push($.metadata.get(this).jstree); }
105
+ settings = !isMethodCall && args.length ? $.extend.apply(null, [true, settings].concat(args)) : settings;
106
+ // block calls to "private" methods
107
+ if(isMethodCall && settings.substring(0, 1) == '_') { return returnValue; }
108
+
109
+ // if a method call execute the method on all selected instances
110
+ if(isMethodCall) {
111
+ this.each(function() {
112
+ var instance = instances[$.data(this, "jstree-instance-id")],
113
+ methodValue = (instance && $.isFunction(instance[settings])) ? instance[settings].apply(instance, args) : instance;
114
+ if(typeof methodValue !== "undefined" && (settings.indexOf("is_" === 0) || (methodValue !== true && methodValue !== false))) { returnValue = methodValue; return false; }
115
+ });
116
+ }
117
+ else {
118
+ this.each(function() {
119
+ var instance_id = $.data(this, "jstree-instance-id"),
120
+ s = false;
121
+ // if an instance already exists, destroy it first
122
+ if(typeof instance_id !== "undefined" && instances[instance_id]) { instances[instance_id].destroy(); }
123
+ // push a new empty object to the instances array
124
+ instance_id = parseInt(instances.push({}),10) - 1;
125
+ // store the jstree instance id to the container element
126
+ $.data(this, "jstree-instance-id", instance_id);
127
+ // clean up all plugins
128
+ if(!settings) { settings = {}; }
129
+ settings.plugins = $.isArray(settings.plugins) ? settings.plugins : $.jstree.defaults.plugins;
130
+ if($.inArray("core", settings.plugins) === -1) { settings.plugins.unshift("core"); }
131
+
132
+ // only unique plugins (NOT WORKING)
133
+ // settings.plugins = settings.plugins.sort().join(",,").replace(/(,|^)([^,]+)(,,\2)+(,|$)/g,"$1$2$4").replace(/,,+/g,",").replace(/,$/,"").split(",");
134
+
135
+ // extend defaults with passed data
136
+ s = $.extend(true, {}, $.jstree.defaults, settings);
137
+ s.plugins = settings.plugins;
138
+ $.each(plugins, function (i, val) { if($.inArray(i, s.plugins) === -1) { s[i] = null; delete s[i]; } });
139
+ // push the new object to the instances array (at the same time set the default classes to the container) and init
140
+ instances[instance_id] = new $.jstree._instance(instance_id, $(this).addClass("jstree jstree-" + instance_id), s);
141
+ // init all activated plugins for this instance
142
+ $.each(instances[instance_id]._get_settings().plugins, function (i, val) { instances[instance_id].data[val] = {}; });
143
+ $.each(instances[instance_id]._get_settings().plugins, function (i, val) { if(plugins[val]) { plugins[val].__init.apply(instances[instance_id]); } });
144
+ // initialize the instance
145
+ instances[instance_id].init();
146
+ });
147
+ }
148
+ // return the jquery selection (or if it was a method call that returned a value - the returned value)
149
+ return returnValue;
150
+ };
151
+ // object to store exposed functions and objects
152
+ $.jstree = {
153
+ defaults : {
154
+ plugins : []
155
+ },
156
+ _focused : function () { return instances[focused_instance] || null; },
157
+ _reference : function (needle) {
158
+ // get by instance id
159
+ if(instances[needle]) { return instances[needle]; }
160
+ // get by DOM (if still no luck - return null
161
+ var o = $(needle);
162
+ if(!o.length && typeof needle === "string") { o = $("#" + needle); }
163
+ if(!o.length) { return null; }
164
+ return instances[o.closest(".jstree").data("jstree-instance-id")] || null;
165
+ },
166
+ _instance : function (index, container, settings) {
167
+ // for plugins to store data in
168
+ this.data = { core : {} };
169
+ this.get_settings = function () { return $.extend(true, {}, settings); };
170
+ this._get_settings = function () { return settings; };
171
+ this.get_index = function () { return index; };
172
+ this.get_container = function () { return container; };
173
+ this._set_settings = function (s) {
174
+ settings = $.extend(true, {}, settings, s);
175
+ };
176
+ },
177
+ _fn : { },
178
+ plugin : function (pname, pdata) {
179
+ pdata = $.extend({}, {
180
+ __init : $.noop,
181
+ __destroy : $.noop,
182
+ _fn : {},
183
+ defaults : false
184
+ }, pdata);
185
+ plugins[pname] = pdata;
186
+
187
+ $.jstree.defaults[pname] = pdata.defaults;
188
+ $.each(pdata._fn, function (i, val) {
189
+ val.plugin = pname;
190
+ val.old = $.jstree._fn[i];
191
+ $.jstree._fn[i] = function () {
192
+ var rslt,
193
+ func = val,
194
+ args = Array.prototype.slice.call(arguments),
195
+ evnt = new $.Event("before.jstree"),
196
+ rlbk = false;
197
+
198
+ // Check if function belongs to the included plugins of this instance
199
+ do {
200
+ if(func && func.plugin && $.inArray(func.plugin, this._get_settings().plugins) !== -1) { break; }
201
+ func = func.old;
202
+ } while(func);
203
+ if(!func) { return; }
204
+
205
+ // a chance to stop execution (or change arguments):
206
+ // * just bind to jstree.before
207
+ // * check the additional data object (func property)
208
+ // * call event.stopImmediatePropagation()
209
+ // * return false (or an array of arguments)
210
+ rslt = this.get_container().triggerHandler(evnt, { "func" : i, "inst" : this, "args" : args });
211
+ if(rslt === false) { return; }
212
+ if(typeof rslt !== "undefined") { args = rslt; }
213
+
214
+ // context and function to trigger events, then finally call the function
215
+ if(i.indexOf("_") === 0) {
216
+ rslt = func.apply(this, args);
217
+ }
218
+ else {
219
+ rslt = func.apply(
220
+ $.extend({}, this, {
221
+ __callback : function (data) {
222
+ this.get_container().triggerHandler( i + '.jstree', { "inst" : this, "args" : args, "rslt" : data, "rlbk" : rlbk });
223
+ },
224
+ __rollback : function () {
225
+ rlbk = this.get_rollback();
226
+ return rlbk;
227
+ },
228
+ __call_old : function (replace_arguments) {
229
+ return func.old.apply(this, (replace_arguments ? Array.prototype.slice.call(arguments, 1) : args ) );
230
+ }
231
+ }), args);
232
+ }
233
+
234
+ // return the result
235
+ return rslt;
236
+ };
237
+ $.jstree._fn[i].old = val.old;
238
+ $.jstree._fn[i].plugin = pname;
239
+ });
240
+ },
241
+ rollback : function (rb) {
242
+ if(rb) {
243
+ if(!$.isArray(rb)) { rb = [ rb ]; }
244
+ $.each(rb, function (i, val) {
245
+ instances[val.i].set_rollback(val.h, val.d);
246
+ });
247
+ }
248
+ }
249
+ };
250
+ // set the prototype for all instances
251
+ $.jstree._fn = $.jstree._instance.prototype = {};
252
+
253
+ // css functions - used internally
254
+
255
+ // load the css when DOM is ready
256
+ $(function() {
257
+ // code is copied form jQuery ($.browser is deprecated + there is a bug in IE)
258
+ var u = navigator.userAgent.toLowerCase(),
259
+ v = (u.match( /.+?(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [0,'0'])[1],
260
+ css_string = '' +
261
+ '.jstree ul, .jstree li { display:block; margin:0 0 0 0; padding:0 0 0 0; list-style-type:none; } ' +
262
+ '.jstree li { display:block; min-height:18px; line-height:18px; white-space:nowrap; margin-left:18px; } ' +
263
+ '.jstree-rtl li { margin-left:0; margin-right:18px; } ' +
264
+ '.jstree > ul > li { margin-left:0px; } ' +
265
+ '.jstree-rtl > ul > li { margin-right:0px; } ' +
266
+ '.jstree ins { display:inline-block; text-decoration:none; width:18px; height:18px; margin:0 0 0 0; padding:0; } ' +
267
+ '.jstree a { display:inline-block; line-height:16px; height:16px; color:black; white-space:nowrap; text-decoration:none; padding:1px 2px; margin:0; } ' +
268
+ '.jstree a:focus { outline: none; } ' +
269
+ '.jstree a > ins { height:16px; width:16px; } ' +
270
+ '.jstree a > .jstree-icon { margin-right:3px; } ' +
271
+ '.jstree-rtl a > .jstree-icon { margin-left:3px; margin-right:0; } ' +
272
+ 'li.jstree-open > ul { display:block; } ' +
273
+ 'li.jstree-closed > ul { display:none; } ';
274
+ // Correct IE 6 (does not support the > CSS selector)
275
+ if(/msie/.test(u) && parseInt(v, 10) == 6) {
276
+ is_ie6 = true;
277
+ css_string += '' +
278
+ '.jstree li { height:18px; margin-left:0; margin-right:0; } ' +
279
+ '.jstree li li { margin-left:18px; } ' +
280
+ '.jstree-rtl li li { margin-left:0px; margin-right:18px; } ' +
281
+ 'li.jstree-open ul { display:block; } ' +
282
+ 'li.jstree-closed ul { display:none !important; } ' +
283
+ '.jstree li a { display:inline; border-width:0 !important; padding:0px 2px !important; } ' +
284
+ '.jstree li a ins { height:16px; width:16px; margin-right:3px; } ' +
285
+ '.jstree-rtl li a ins { margin-right:0px; margin-left:3px; } ';
286
+ }
287
+ // Correct IE 7 (shifts anchor nodes onhover)
288
+ if(/msie/.test(u) && parseInt(v, 10) == 7) {
289
+ css_string += '.jstree li a { border-width:0 !important; padding:0px 2px !important; } ';
290
+ }
291
+ $.vakata.css.add_sheet({ str : css_string });
292
+ });
293
+
294
+ // core functions (open, close, create, update, delete)
295
+ $.jstree.plugin("core", {
296
+ __init : function () {
297
+ this.data.core.to_open = $.map($.makeArray(this.get_settings().core.initially_open), function (n) { return "#" + n.toString().replace(/^#/,"").replace('\\/','/').replace('/','\\/'); });
298
+ },
299
+ defaults : {
300
+ html_titles : false,
301
+ animation : 500,
302
+ initially_open : [],
303
+ rtl : false,
304
+ strings : {
305
+ loading : "Loading ...",
306
+ new_node : "New node"
307
+ }
308
+ },
309
+ _fn : {
310
+ init : function () {
311
+ this.set_focus();
312
+ if(this._get_settings().core.rtl) {
313
+ this.get_container().addClass("jstree-rtl").css("direction", "rtl");
314
+ }
315
+ this.get_container().html("<ul><li class='jstree-last jstree-leaf'><ins>&#160;</ins><a class='jstree-loading' href='#'><ins class='jstree-icon'>&#160;</ins>" + this._get_settings().core.strings.loading + "</a></li></ul>");
316
+ this.data.core.li_height = this.get_container().find("ul li.jstree-closed, ul li.jstree-leaf").eq(0).height() || 18;
317
+
318
+ this.get_container()
319
+ .delegate("li > ins", "click.jstree", $.proxy(function (event) {
320
+ var trgt = $(event.target);
321
+ if(trgt.is("ins") && event.pageY - trgt.offset().top < this.data.core.li_height) { this.toggle_node(trgt); }
322
+ }, this))
323
+ .bind("mousedown.jstree", $.proxy(function () {
324
+ this.set_focus(); // This used to be setTimeout(set_focus,0) - why?
325
+ }, this))
326
+ .bind("dblclick.jstree", function (event) {
327
+ var sel;
328
+ if(document.selection && document.selection.empty) { document.selection.empty(); }
329
+ else {
330
+ if(window.getSelection) {
331
+ sel = window.getSelection();
332
+ try {
333
+ sel.removeAllRanges();
334
+ sel.collapse();
335
+ } catch (err) { }
336
+ }
337
+ }
338
+ });
339
+ this.__callback();
340
+ this.load_node(-1, function () { this.loaded(); this.reopen(); });
341
+ },
342
+ destroy : function () {
343
+ var i,
344
+ n = this.get_index(),
345
+ s = this._get_settings(),
346
+ _this = this;
347
+
348
+ $.each(s.plugins, function (i, val) {
349
+ try { plugins[val].__destroy.apply(_this); } catch(err) { }
350
+ });
351
+ this.__callback();
352
+ // set focus to another instance if this one is focused
353
+ if(this.is_focused()) {
354
+ for(i in instances) {
355
+ if(instances.hasOwnProperty(i) && i != n) {
356
+ instances[i].set_focus();
357
+ break;
358
+ }
359
+ }
360
+ }
361
+ // if no other instance found
362
+ if(n === focused_instance) { focused_instance = -1; }
363
+ // remove all traces of jstree in the DOM (only the ones set using jstree*) and cleans all events
364
+ this.get_container()
365
+ .unbind(".jstree")
366
+ .undelegate(".jstree")
367
+ .removeData("jstree-instance-id")
368
+ .find("[class^='jstree']")
369
+ .andSelf()
370
+ .attr("class", function () { return this.className.replace(/jstree[^ ]*|$/ig,''); });
371
+ // remove the actual data
372
+ instances[n] = null;
373
+ delete instances[n];
374
+ },
375
+ save_opened : function () {
376
+ var _this = this;
377
+ this.data.core.to_open = [];
378
+ this.get_container().find(".jstree-open").each(function () {
379
+ _this.data.core.to_open.push("#" + this.id.toString().replace(/^#/,"").replace('\\/','/').replace('/','\\/'));
380
+ });
381
+ this.__callback(_this.data.core.to_open);
382
+ },
383
+ reopen : function (is_callback) {
384
+ var _this = this,
385
+ done = true,
386
+ current = [],
387
+ remaining = [];
388
+ if(!is_callback) { this.data.core.reopen = false; this.data.core.refreshing = true; }
389
+ if(this.data.core.to_open.length) {
390
+ $.each(this.data.core.to_open, function (i, val) {
391
+ if(val == "#") { return true; }
392
+ if($(val).length && $(val).is(".jstree-closed")) { current.push(val); }
393
+ else { remaining.push(val); }
394
+ });
395
+ if(current.length) {
396
+ this.data.core.to_open = remaining;
397
+ $.each(current, function (i, val) {
398
+ _this.open_node(val, function () { _this.reopen(true); }, true);
399
+ });
400
+ done = false;
401
+ }
402
+ }
403
+ if(done) {
404
+ // TODO: find a more elegant approach to syncronizing returning requests
405
+ if(this.data.core.reopen) { clearTimeout(this.data.core.reopen); }
406
+ this.data.core.reopen = setTimeout(function () { _this.__callback({}, _this); }, 50);
407
+ this.data.core.refreshing = false;
408
+ }
409
+ },
410
+ refresh : function (obj) {
411
+ var _this = this;
412
+ this.save_opened();
413
+ if(!obj) { obj = -1; }
414
+ obj = this._get_node(obj);
415
+ if(!obj) { obj = -1; }
416
+ if(obj !== -1) { obj.children("UL").remove(); }
417
+ this.load_node(obj, function () { _this.__callback({ "obj" : obj}); _this.reopen(); });
418
+ },
419
+ // Dummy function to fire after the first load (so that there is a jstree.loaded event)
420
+ loaded : function () {
421
+ this.__callback();
422
+ },
423
+ // deal with focus
424
+ set_focus : function () {
425
+ var f = $.jstree._focused();
426
+ if(f && f !== this) {
427
+ f.get_container().removeClass("jstree-focused");
428
+ }
429
+ if(f !== this) {
430
+ this.get_container().addClass("jstree-focused");
431
+ focused_instance = this.get_index();
432
+ }
433
+ this.__callback();
434
+ },
435
+ is_focused : function () {
436
+ return focused_instance == this.get_index();
437
+ },
438
+
439
+ // traverse
440
+ _get_node : function (obj) {
441
+ var $obj = $(obj, this.get_container());
442
+ if($obj.is(".jstree") || obj == -1) { return -1; }
443
+ $obj = $obj.closest("li", this.get_container());
444
+ return $obj.length ? $obj : false;
445
+ },
446
+ _get_next : function (obj, strict) {
447
+ obj = this._get_node(obj);
448
+ if(obj === -1) { return this.get_container().find("> ul > li:first-child"); }
449
+ if(!obj.length) { return false; }
450
+ if(strict) { return (obj.nextAll("li").size() > 0) ? obj.nextAll("li:eq(0)") : false; }
451
+
452
+ if(obj.hasClass("jstree-open")) { return obj.find("li:eq(0)"); }
453
+ else if(obj.nextAll("li").size() > 0) { return obj.nextAll("li:eq(0)"); }
454
+ else { return obj.parentsUntil(".jstree","li").next("li").eq(0); }
455
+ },
456
+ _get_prev : function (obj, strict) {
457
+ obj = this._get_node(obj);
458
+ if(obj === -1) { return this.get_container().find("> ul > li:last-child"); }
459
+ if(!obj.length) { return false; }
460
+ if(strict) { return (obj.prevAll("li").length > 0) ? obj.prevAll("li:eq(0)") : false; }
461
+
462
+ if(obj.prev("li").length) {
463
+ obj = obj.prev("li").eq(0);
464
+ while(obj.hasClass("jstree-open")) { obj = obj.children("ul:eq(0)").children("li:last"); }
465
+ return obj;
466
+ }
467
+ else { var o = obj.parentsUntil(".jstree","li:eq(0)"); return o.length ? o : false; }
468
+ },
469
+ _get_parent : function (obj) {
470
+ obj = this._get_node(obj);
471
+ if(obj == -1 || !obj.length) { return false; }
472
+ var o = obj.parentsUntil(".jstree", "li:eq(0)");
473
+ return o.length ? o : -1;
474
+ },
475
+ _get_children : function (obj) {
476
+ obj = this._get_node(obj);
477
+ if(obj === -1) { return this.get_container().children("ul:eq(0)").children("li"); }
478
+ if(!obj.length) { return false; }
479
+ return obj.children("ul:eq(0)").children("li");
480
+ },
481
+ get_path : function (obj, id_mode) {
482
+ var p = [],
483
+ _this = this;
484
+ obj = this._get_node(obj);
485
+ if(obj === -1 || !obj || !obj.length) { return false; }
486
+ obj.parentsUntil(".jstree", "li").each(function () {
487
+ p.push( id_mode ? this.id : _this.get_text(this) );
488
+ });
489
+ p.reverse();
490
+ p.push( id_mode ? obj.attr("id") : this.get_text(obj) );
491
+ return p;
492
+ },
493
+
494
+ is_open : function (obj) { obj = this._get_node(obj); return obj && obj !== -1 && obj.hasClass("jstree-open"); },
495
+ is_closed : function (obj) { obj = this._get_node(obj); return obj && obj !== -1 && obj.hasClass("jstree-closed"); },
496
+ is_leaf : function (obj) { obj = this._get_node(obj); return obj && obj !== -1 && obj.hasClass("jstree-leaf"); },
497
+ // open/close
498
+ open_node : function (obj, callback, skip_animation) {
499
+ obj = this._get_node(obj);
500
+ if(!obj.length) { return false; }
501
+ if(!obj.hasClass("jstree-closed")) { if(callback) { callback.call(); } return false; }
502
+ var s = skip_animation || is_ie6 ? 0 : this._get_settings().core.animation,
503
+ t = this;
504
+ if(!this._is_loaded(obj)) {
505
+ obj.children("a").addClass("jstree-loading");
506
+ this.load_node(obj, function () { t.open_node(obj, callback, skip_animation); }, callback);
507
+ }
508
+ else {
509
+ if(s) { obj.children("ul").css("display","none"); }
510
+ obj.removeClass("jstree-closed").addClass("jstree-open").children("a").removeClass("jstree-loading");
511
+ if(s) { obj.children("ul").stop(true).slideDown(s, function () { this.style.display = ""; }); }
512
+ this.__callback({ "obj" : obj });
513
+ if(callback) { callback.call(); }
514
+ }
515
+ },
516
+ close_node : function (obj, skip_animation) {
517
+ obj = this._get_node(obj);
518
+ var s = skip_animation || is_ie6 ? 0 : this._get_settings().core.animation;
519
+ if(!obj.length || !obj.hasClass("jstree-open")) { return false; }
520
+ if(s) { obj.children("ul").attr("style","display:block !important"); }
521
+ obj.removeClass("jstree-open").addClass("jstree-closed");
522
+ if(s) { obj.children("ul").stop(true).slideUp(s, function () { this.style.display = ""; }); }
523
+ this.__callback({ "obj" : obj });
524
+ },
525
+ toggle_node : function (obj) {
526
+ obj = this._get_node(obj);
527
+ if(obj.hasClass("jstree-closed")) { return this.open_node(obj); }
528
+ if(obj.hasClass("jstree-open")) { return this.close_node(obj); }
529
+ },
530
+ open_all : function (obj, original_obj) {
531
+ obj = obj ? this._get_node(obj) : this.get_container();
532
+ if(!obj || obj === -1) { obj = this.get_container(); }
533
+ if(original_obj) {
534
+ obj = obj.find("li.jstree-closed");
535
+ }
536
+ else {
537
+ original_obj = obj;
538
+ if(obj.is(".jstree-closed")) { obj = obj.find("li.jstree-closed").andSelf(); }
539
+ else { obj = obj.find("li.jstree-closed"); }
540
+ }
541
+ var _this = this;
542
+ obj.each(function () {
543
+ var __this = this;
544
+ if(!_this._is_loaded(this)) { _this.open_node(this, function() { _this.open_all(__this, original_obj); }, true); }
545
+ else { _this.open_node(this, false, true); }
546
+ });
547
+ // so that callback is fired AFTER all nodes are open
548
+ if(original_obj.find('li.jstree-closed').length === 0) { this.__callback({ "obj" : original_obj }); }
549
+ },
550
+ close_all : function (obj) {
551
+ var _this = this;
552
+ obj = obj ? this._get_node(obj) : this.get_container();
553
+ if(!obj || obj === -1) { obj = this.get_container(); }
554
+ obj.find("li.jstree-open").andSelf().each(function () { _this.close_node(this); });
555
+ this.__callback({ "obj" : obj });
556
+ },
557
+ clean_node : function (obj) {
558
+ obj = obj && obj != -1 ? $(obj) : this.get_container();
559
+ obj = obj.is("li") ? obj.find("li").andSelf() : obj.find("li");
560
+ obj.removeClass("jstree-last")
561
+ .filter("li:last-child").addClass("jstree-last").end()
562
+ .filter(":has(li)")
563
+ .not(".jstree-open").removeClass("jstree-leaf").addClass("jstree-closed");
564
+ obj.not(".jstree-open, .jstree-closed").addClass("jstree-leaf").children("ul").remove();
565
+ this.__callback({ "obj" : obj });
566
+ },
567
+ // rollback
568
+ get_rollback : function () {
569
+ this.__callback();
570
+ return { i : this.get_index(), h : this.get_container().children("ul").clone(true), d : this.data };
571
+ },
572
+ set_rollback : function (html, data) {
573
+ this.get_container().empty().append(html);
574
+ this.data = data;
575
+ this.__callback();
576
+ },
577
+ // Dummy functions to be overwritten by any datastore plugin included
578
+ load_node : function (obj, s_call, e_call) { this.__callback({ "obj" : obj }); },
579
+ _is_loaded : function (obj) { return true; },
580
+
581
+ // Basic operations: create
582
+ create_node : function (obj, position, js, callback, is_loaded) {
583
+ obj = this._get_node(obj);
584
+ position = typeof position === "undefined" ? "last" : position;
585
+ var d = $("<li>"),
586
+ s = this._get_settings().core,
587
+ tmp;
588
+
589
+ if(obj !== -1 && !obj.length) { return false; }
590
+ if(!is_loaded && !this._is_loaded(obj)) { this.load_node(obj, function () { this.create_node(obj, position, js, callback, true); }); return false; }
591
+
592
+ this.__rollback();
593
+
594
+ if(typeof js === "string") { js = { "data" : js }; }
595
+ if(!js) { js = {}; }
596
+ if(js.attr) { d.attr(js.attr); }
597
+ if(js.state) { d.addClass("jstree-" + js.state); }
598
+ if(!js.data) { js.data = s.strings.new_node; }
599
+ if(!$.isArray(js.data)) { tmp = js.data; js.data = []; js.data.push(tmp); }
600
+ $.each(js.data, function (i, m) {
601
+ tmp = $("<a>");
602
+ if($.isFunction(m)) { m = m.call(this, js); }
603
+ if(typeof m == "string") { tmp.attr('href','#')[ s.html_titles ? "html" : "text" ](m); }
604
+ else {
605
+ if(!m.attr) { m.attr = {}; }
606
+ if(!m.attr.href) { m.attr.href = '#'; }
607
+ tmp.attr(m.attr)[ s.html_titles ? "html" : "text" ](m.title);
608
+ if(m.language) { tmp.addClass(m.language); }
609
+ }
610
+ tmp.prepend("<ins class='jstree-icon'>&#160;</ins>");
611
+ if(m.icon) {
612
+ if(m.icon.indexOf("/") === -1) { tmp.children("ins").addClass(m.icon); }
613
+ else { tmp.children("ins").css("background","url('" + m.icon + "') center center no-repeat"); }
614
+ }
615
+ d.append(tmp);
616
+ });
617
+ d.prepend("<ins class='jstree-icon'>&#160;</ins>");
618
+ if(obj === -1) {
619
+ obj = this.get_container();
620
+ if(position === "before") { position = "first"; }
621
+ if(position === "after") { position = "last"; }
622
+ }
623
+ switch(position) {
624
+ case "before": obj.before(d); tmp = this._get_parent(obj); break;
625
+ case "after" : obj.after(d); tmp = this._get_parent(obj); break;
626
+ case "inside":
627
+ case "first" :
628
+ if(!obj.children("ul").length) { obj.append("<ul>"); }
629
+ obj.children("ul").prepend(d);
630
+ tmp = obj;
631
+ break;
632
+ case "last":
633
+ if(!obj.children("ul").length) { obj.append("<ul>"); }
634
+ obj.children("ul").append(d);
635
+ tmp = obj;
636
+ break;
637
+ default:
638
+ if(!obj.children("ul").length) { obj.append("<ul>"); }
639
+ if(!position) { position = 0; }
640
+ tmp = obj.children("ul").children("li").eq(position);
641
+ if(tmp.length) { tmp.before(d); }
642
+ else { obj.children("ul").append(d); }
643
+ tmp = obj;
644
+ break;
645
+ }
646
+ if(tmp === -1 || tmp.get(0) === this.get_container().get(0)) { tmp = -1; }
647
+ this.clean_node(tmp);
648
+ this.__callback({ "obj" : d, "parent" : tmp });
649
+ if(callback) { callback.call(this, d); }
650
+ return d;
651
+ },
652
+ // Basic operations: rename (deal with text)
653
+ get_text : function (obj) {
654
+ obj = this._get_node(obj);
655
+ if(!obj.length) { return false; }
656
+ var s = this._get_settings().core.html_titles;
657
+ obj = obj.children("a:eq(0)");
658
+ if(s) {
659
+ obj = obj.clone();
660
+ obj.children("INS").remove();
661
+ return obj.html();
662
+ }
663
+ else {
664
+ obj = obj.contents().filter(function() { return this.nodeType == 3; })[0];
665
+ return obj.nodeValue;
666
+ }
667
+ },
668
+ set_text : function (obj, val) {
669
+ obj = this._get_node(obj);
670
+ if(!obj.length) { return false; }
671
+ obj = obj.children("a:eq(0)");
672
+ if(this._get_settings().core.html_titles) {
673
+ var tmp = obj.children("INS").clone();
674
+ obj.html(val).prepend(tmp);
675
+ this.__callback({ "obj" : obj, "name" : val });
676
+ return true;
677
+ }
678
+ else {
679
+ obj = obj.contents().filter(function() { return this.nodeType == 3; })[0];
680
+ this.__callback({ "obj" : obj, "name" : val });
681
+ return (obj.nodeValue = val);
682
+ }
683
+ },
684
+ rename_node : function (obj, val) {
685
+ obj = this._get_node(obj);
686
+ this.__rollback();
687
+ if(obj && obj.length && this.set_text.apply(this, Array.prototype.slice.call(arguments))) { this.__callback({ "obj" : obj, "name" : val }); }
688
+ },
689
+ // Basic operations: deleting nodes
690
+ delete_node : function (obj) {
691
+ obj = this._get_node(obj);
692
+ if(!obj.length) { return false; }
693
+ this.__rollback();
694
+ var p = this._get_parent(obj), prev = this._get_prev(obj);
695
+ obj = obj.remove();
696
+ if(p !== -1 && p.find("> ul > li").length === 0) {
697
+ p.removeClass("jstree-open jstree-closed").addClass("jstree-leaf");
698
+ }
699
+ this.clean_node(p);
700
+ this.__callback({ "obj" : obj, "prev" : prev });
701
+ return obj;
702
+ },
703
+ prepare_move : function (o, r, pos, cb, is_cb) {
704
+ var p = {};
705
+
706
+ p.ot = $.jstree._reference(p.o) || this;
707
+ p.o = p.ot._get_node(o);
708
+ p.r = r === - 1 ? -1 : this._get_node(r);
709
+ p.p = (typeof p === "undefined") ? "last" : pos; // TODO: move to a setting
710
+ if(!is_cb && prepared_move.o && prepared_move.o[0] === p.o[0] && prepared_move.r[0] === p.r[0] && prepared_move.p === p.p) {
711
+ this.__callback(prepared_move);
712
+ if(cb) { cb.call(this, prepared_move); }
713
+ return;
714
+ }
715
+ p.ot = $.jstree._reference(p.o) || this;
716
+ p.rt = r === -1 ? p.ot : $.jstree._reference(p.r) || this;
717
+ if(p.r === -1) {
718
+ p.cr = -1;
719
+ switch(p.p) {
720
+ case "first":
721
+ case "before":
722
+ case "inside":
723
+ p.cp = 0;
724
+ break;
725
+ case "after":
726
+ case "last":
727
+ p.cp = p.rt.get_container().find(" > ul > li").length;
728
+ break;
729
+ default:
730
+ p.cp = p.p;
731
+ break;
732
+ }
733
+ }
734
+ else {
735
+ if(!/^(before|after)$/.test(p.p) && !this._is_loaded(p.r)) {
736
+ return this.load_node(p.r, function () { this.prepare_move(o, r, pos, cb, true); });
737
+ }
738
+ switch(p.p) {
739
+ case "before":
740
+ p.cp = p.r.index();
741
+ p.cr = p.rt._get_parent(p.r);
742
+ break;
743
+ case "after":
744
+ p.cp = p.r.index() + 1;
745
+ p.cr = p.rt._get_parent(p.r);
746
+ break;
747
+ case "inside":
748
+ case "first":
749
+ p.cp = 0;
750
+ p.cr = p.r;
751
+ break;
752
+ case "last":
753
+ p.cp = p.r.find(" > ul > li").length;
754
+ p.cr = p.r;
755
+ break;
756
+ default:
757
+ p.cp = p.p;
758
+ p.cr = p.r;
759
+ break;
760
+ }
761
+ }
762
+ p.np = p.cr == -1 ? p.rt.get_container() : p.cr;
763
+ p.op = p.ot._get_parent(p.o);
764
+ p.or = p.np.find(" > ul > li:nth-child(" + (p.cp + 1) + ")");
765
+
766
+ prepared_move = p;
767
+ this.__callback(prepared_move);
768
+ if(cb) { cb.call(this, prepared_move); }
769
+ },
770
+ check_move : function () {
771
+ var obj = prepared_move, ret = true;
772
+ if(obj.or[0] === obj.o[0]) { return false; }
773
+ obj.o.each(function () {
774
+ if(obj.r.parentsUntil(".jstree").andSelf().filter("li").index(this) !== -1) { ret = false; return false; }
775
+ });
776
+ return ret;
777
+ },
778
+ move_node : function (obj, ref, position, is_copy, is_prepared, skip_check) {
779
+ if(!is_prepared) {
780
+ return this.prepare_move(obj, ref, position, function (p) {
781
+ this.move_node(p, false, false, is_copy, true, skip_check);
782
+ });
783
+ }
784
+ if(!skip_check && !this.check_move()) { return false; }
785
+
786
+ this.__rollback();
787
+ var o = false;
788
+ if(is_copy) {
789
+ o = obj.o.clone();
790
+ o.find("*[id]").andSelf().each(function () {
791
+ if(this.id) { this.id = "copy_" + this.id; }
792
+ });
793
+ }
794
+ else { o = obj.o; }
795
+
796
+ if(obj.or.length) { obj.or.before(o); }
797
+ else {
798
+ if(!obj.np.children("ul").length) { $("<ul>").appendTo(obj.np); }
799
+ obj.np.children("ul:eq(0)").append(o);
800
+ }
801
+
802
+ try {
803
+ obj.ot.clean_node(obj.op);
804
+ obj.rt.clean_node(obj.np);
805
+ if(!obj.op.find("> ul > li").length) {
806
+ obj.op.removeClass("jstree-open jstree-closed").addClass("jstree-leaf").children("ul").remove();
807
+ }
808
+ } catch (e) { }
809
+
810
+ if(is_copy) {
811
+ prepared_move.cy = true;
812
+ prepared_move.oc = o;
813
+ }
814
+ this.__callback(prepared_move);
815
+ return prepared_move;
816
+ },
817
+ _get_move : function () { return prepared_move; }
818
+ }
819
+ });
820
+ })(jQuery);
821
+ //*/
822
+
823
+
824
+ /*
825
+ * jsTree ui plugin 1.0
826
+ * This plugins handles selecting/deselecting/hovering/dehovering nodes
827
+ */
828
+ (function ($) {
829
+ $.jstree.plugin("ui", {
830
+ __init : function () {
831
+ this.data.ui.selected = $();
832
+ this.data.ui.last_selected = false;
833
+ this.data.ui.hovered = null;
834
+ this.data.ui.to_select = this.get_settings().ui.initially_select;
835
+
836
+ this.get_container()
837
+ .delegate("a", "click.jstree", $.proxy(function (event) {
838
+ event.preventDefault();
839
+ this.select_node(event.currentTarget, true, event);
840
+ }, this))
841
+ .delegate("a", "mouseenter.jstree", $.proxy(function (event) {
842
+ this.hover_node(event.target);
843
+ }, this))
844
+ .delegate("a", "mouseleave.jstree", $.proxy(function (event) {
845
+ this.dehover_node(event.target);
846
+ }, this))
847
+ .bind("reopen.jstree", $.proxy(function () {
848
+ this.reselect();
849
+ }, this))
850
+ .bind("get_rollback.jstree", $.proxy(function () {
851
+ this.dehover_node();
852
+ this.save_selected();
853
+ }, this))
854
+ .bind("set_rollback.jstree", $.proxy(function () {
855
+ this.reselect();
856
+ }, this))
857
+ .bind("close_node.jstree", $.proxy(function (event, data) {
858
+ var s = this._get_settings().ui,
859
+ obj = this._get_node(data.rslt.obj),
860
+ clk = (obj && obj.length) ? obj.children("ul").find(".jstree-clicked") : $(),
861
+ _this = this;
862
+ if(s.selected_parent_close === false || !clk.length) { return; }
863
+ clk.each(function () {
864
+ _this.deselect_node(this);
865
+ if(s.selected_parent_close === "select_parent") { _this.select_node(obj); }
866
+ });
867
+ }, this))
868
+ .bind("delete_node.jstree", $.proxy(function (event, data) {
869
+ var s = this._get_settings().ui.select_prev_on_delete,
870
+ obj = this._get_node(data.rslt.obj),
871
+ clk = (obj && obj.length) ? obj.find(".jstree-clicked") : [],
872
+ _this = this;
873
+ clk.each(function () { _this.deselect_node(this); });
874
+ if(s && clk.length) { this.select_node(data.rslt.prev); }
875
+ }, this))
876
+ .bind("move_node.jstree", $.proxy(function (event, data) {
877
+ if(data.rslt.cy) {
878
+ data.rslt.oc.find(".jstree-clicked").removeClass("jstree-clicked");
879
+ }
880
+ }, this));
881
+ },
882
+ defaults : {
883
+ select_limit : -1, // 0, 1, 2 ... or -1 for unlimited
884
+ select_multiple_modifier : "ctrl", // on, or ctrl, shift, alt
885
+ selected_parent_close : "select_parent", // false, "deselect", "select_parent"
886
+ select_prev_on_delete : true,
887
+ disable_selecting_children : false,
888
+ initially_select : []
889
+ },
890
+ _fn : {
891
+ _get_node : function (obj, allow_multiple) {
892
+ if(typeof obj === "undefined" || obj === null) { return allow_multiple ? this.data.ui.selected : this.data.ui.last_selected; }
893
+ var $obj = $(obj, this.get_container());
894
+ if($obj.is(".jstree") || obj == -1) { return -1; }
895
+ $obj = $obj.closest("li", this.get_container());
896
+ return $obj.length ? $obj : false;
897
+ },
898
+ save_selected : function () {
899
+ var _this = this;
900
+ this.data.ui.to_select = [];
901
+ this.data.ui.selected.each(function () { _this.data.ui.to_select.push("#" + this.id.toString().replace(/^#/,"").replace('\\/','/').replace('/','\\/')); });
902
+ this.__callback(this.data.ui.to_select);
903
+ },
904
+ reselect : function () {
905
+ var _this = this,
906
+ s = this.data.ui.to_select;
907
+ s = $.map($.makeArray(s), function (n) { return "#" + n.toString().replace(/^#/,"").replace('\\/','/').replace('/','\\/'); });
908
+ this.deselect_all();
909
+ $.each(s, function (i, val) { if(val && val !== "#") { _this.select_node(val); } });
910
+ this.__callback();
911
+ },
912
+ refresh : function (obj) {
913
+ this.save_selected();
914
+ return this.__call_old();
915
+ },
916
+ hover_node : function (obj) {
917
+ obj = this._get_node(obj);
918
+ if(!obj.length) { return false; }
919
+ //if(this.data.ui.hovered && obj.get(0) === this.data.ui.hovered.get(0)) { return; }
920
+ if(!obj.hasClass("jstree-hovered")) { this.dehover_node(); }
921
+ this.data.ui.hovered = obj.children("a").addClass("jstree-hovered").parent();
922
+ this.__callback({ "obj" : obj });
923
+ },
924
+ dehover_node : function () {
925
+ var obj = this.data.ui.hovered, p;
926
+ if(!obj || !obj.length) { return false; }
927
+ p = obj.children("a").removeClass("jstree-hovered").parent();
928
+ if(this.data.ui.hovered[0] === p[0]) { this.data.ui.hovered = null; }
929
+ this.__callback({ "obj" : obj });
930
+ },
931
+ select_node : function (obj, check, e) {
932
+ obj = this._get_node(obj);
933
+ if(obj == -1 || !obj || !obj.length) { return false; }
934
+ var s = this._get_settings().ui,
935
+ is_multiple = (s.select_multiple_modifier == "on" || (s.select_multiple_modifier !== false && e && e[s.select_multiple_modifier + "Key"])),
936
+ is_selected = this.is_selected(obj),
937
+ proceed = true;
938
+ if(check) {
939
+ if(s.disable_selecting_children && is_multiple && obj.parents("li", this.get_container()).children(".jstree-clicked").length) {
940
+ return false;
941
+ }
942
+ proceed = false;
943
+ switch(!0) {
944
+ case (is_selected && !is_multiple):
945
+ this.deselect_all();
946
+ is_selected = false;
947
+ proceed = true;
948
+ break;
949
+ case (!is_selected && !is_multiple):
950
+ if(s.select_limit == -1 || s.select_limit > 0) {
951
+ this.deselect_all();
952
+ proceed = true;
953
+ }
954
+ break;
955
+ case (is_selected && is_multiple):
956
+ this.deselect_node(obj);
957
+ break;
958
+ case (!is_selected && is_multiple):
959
+ if(s.select_limit == -1 || this.data.ui.selected.length + 1 <= s.select_limit) {
960
+ proceed = true;
961
+ }
962
+ break;
963
+ }
964
+ }
965
+ if(proceed && !is_selected) {
966
+ obj.children("a").addClass("jstree-clicked");
967
+ this.data.ui.selected = this.data.ui.selected.add(obj);
968
+ this.data.ui.last_selected = obj;
969
+ this.__callback({ "obj" : obj });
970
+ }
971
+ },
972
+ deselect_node : function (obj) {
973
+ obj = this._get_node(obj);
974
+ if(!obj.length) { return false; }
975
+ if(this.is_selected(obj)) {
976
+ obj.children("a").removeClass("jstree-clicked");
977
+ this.data.ui.selected = this.data.ui.selected.not(obj);
978
+ if(this.data.ui.last_selected.get(0) === obj.get(0)) { this.data.ui.last_selected = this.data.ui.selected.eq(0); }
979
+ this.__callback({ "obj" : obj });
980
+ }
981
+ },
982
+ toggle_select : function (obj) {
983
+ obj = this._get_node(obj);
984
+ if(!obj.length) { return false; }
985
+ if(this.is_selected(obj)) { this.deselect_node(obj); }
986
+ else { this.select_node(obj); }
987
+ },
988
+ is_selected : function (obj) { return this.data.ui.selected.index(this._get_node(obj)) >= 0; },
989
+ get_selected : function (context) {
990
+ return context ? $(context).find(".jstree-clicked").parent() : this.data.ui.selected;
991
+ },
992
+ deselect_all : function (context) {
993
+ if(context) { $(context).find(".jstree-clicked").removeClass("jstree-clicked"); }
994
+ else { this.get_container().find(".jstree-clicked").removeClass("jstree-clicked"); }
995
+ this.data.ui.selected = $([]);
996
+ this.data.ui.last_selected = false;
997
+ this.__callback();
998
+ }
999
+ }
1000
+ });
1001
+ // include the selection plugin by default
1002
+ $.jstree.defaults.plugins.push("ui");
1003
+ })(jQuery);
1004
+ //*/
1005
+
1006
+
1007
+ /*
1008
+ * jsTree CRRM plugin 1.0
1009
+ * Handles creating/renaming/removing/moving nodes by user interaction.
1010
+ */
1011
+ (function ($) {
1012
+ $.jstree.plugin("crrm", {
1013
+ __init : function () {
1014
+ this.get_container()
1015
+ .bind("move_node.jstree", $.proxy(function (e, data) {
1016
+ if(this._get_settings().crrm.move.open_onmove) {
1017
+ var t = this;
1018
+ data.rslt.np.parentsUntil(".jstree").andSelf().filter(".jstree-closed").each(function () {
1019
+ t.open_node(this, false, true);
1020
+ });
1021
+ }
1022
+ }, this));
1023
+ },
1024
+ defaults : {
1025
+ input_width_limit : 200,
1026
+ move : {
1027
+ always_copy : false, // false, true or "multitree"
1028
+ open_onmove : true,
1029
+ default_position : "last",
1030
+ check_move : function (m) { return true; }
1031
+ }
1032
+ },
1033
+ _fn : {
1034
+ _show_input : function (obj, callback) {
1035
+ obj = this._get_node(obj);
1036
+ var rtl = this._get_settings().core.rtl,
1037
+ w = this._get_settings().crrm.input_width_limit,
1038
+ w1 = obj.children("ins").width(),
1039
+ w2 = obj.find("> a:visible > ins").width() * obj.find("> a:visible > ins").length,
1040
+ t = this.get_text(obj),
1041
+ h1 = $("<div>", { css : { "position" : "absolute", "top" : "-200px", "left" : (rtl ? "0px" : "-1000px"), "visibility" : "hidden" } }).appendTo("body"),
1042
+ h2 = obj.css("position","relative").append(
1043
+ $("<input>", {
1044
+ "value" : t,
1045
+ // "size" : t.length,
1046
+ "css" : {
1047
+ "padding" : "0",
1048
+ "border" : "1px solid silver",
1049
+ "position" : "absolute",
1050
+ "left" : (rtl ? "auto" : (w1 + w2 + 4) + "px"),
1051
+ "right" : (rtl ? (w1 + w2 + 4) + "px" : "auto"),
1052
+ "top" : "0px",
1053
+ "height" : (this.data.core.li_height - 2) + "px",
1054
+ "lineHeight" : (this.data.core.li_height - 2) + "px",
1055
+ "width" : "150px" // will be set a bit further down
1056
+ },
1057
+ "blur" : $.proxy(function () {
1058
+ var i = obj.children("input"),
1059
+ v = i.val();
1060
+ if(v === "") { v = t; }
1061
+ i.remove(); // rollback purposes
1062
+ this.set_text(obj,t); // rollback purposes
1063
+ this.rename_node(obj, v);
1064
+ callback.call(this, obj, v, t);
1065
+ obj.css("position","");
1066
+ }, this),
1067
+ "keyup" : function (event) {
1068
+ var key = event.keyCode || event.which;
1069
+ if(key == 27) { this.value = t; this.blur(); return; }
1070
+ else if(key == 13) { this.blur(); return; }
1071
+ else {
1072
+ h2.width(Math.min(h1.text("pW" + this.value).width(),w));
1073
+ }
1074
+ }
1075
+ })
1076
+ ).children("input");
1077
+ this.set_text(obj, "");
1078
+ h1.css({
1079
+ fontFamily : h2.css('fontFamily') || '',
1080
+ fontSize : h2.css('fontSize') || '',
1081
+ fontWeight : h2.css('fontWeight') || '',
1082
+ fontStyle : h2.css('fontStyle') || '',
1083
+ fontStretch : h2.css('fontStretch') || '',
1084
+ fontVariant : h2.css('fontVariant') || '',
1085
+ letterSpacing : h2.css('letterSpacing') || '',
1086
+ wordSpacing : h2.css('wordSpacing') || ''
1087
+ });
1088
+ h2.width(Math.min(h1.text("pW" + h2[0].value).width(),w))[0].select();
1089
+ },
1090
+ rename : function (obj) {
1091
+ obj = this._get_node(obj);
1092
+ this.__rollback();
1093
+ var f = this.__callback;
1094
+ this._show_input(obj, function (obj, new_name, old_name) {
1095
+ f.call(this, { "obj" : obj, "new_name" : new_name, "old_name" : old_name });
1096
+ });
1097
+ },
1098
+ create : function (obj, position, js, callback, skip_rename) {
1099
+ var t, _this = this;
1100
+ obj = this._get_node(obj);
1101
+ if(!obj) { obj = -1; }
1102
+ this.__rollback();
1103
+ t = this.create_node(obj, position, js, function (t) {
1104
+ var p = this._get_parent(t),
1105
+ pos = $(t).index();
1106
+ if(callback) { callback.call(this, t); }
1107
+ if(p.length && p.hasClass("jstree-closed")) { this.open_node(p, false, true); }
1108
+ if(!skip_rename) {
1109
+ this._show_input(t, function (obj, new_name, old_name) {
1110
+ _this.__callback({ "obj" : obj, "name" : new_name, "parent" : p, "position" : pos });
1111
+ });
1112
+ }
1113
+ else { _this.__callback({ "obj" : t, "name" : this.get_text(t), "parent" : p, "position" : pos }); }
1114
+ });
1115
+ return t;
1116
+ },
1117
+ remove : function (obj) {
1118
+ obj = this._get_node(obj, true);
1119
+ this.__rollback();
1120
+ this.delete_node(obj);
1121
+ this.__callback({ "obj" : obj });
1122
+ },
1123
+ check_move : function () {
1124
+ if(!this.__call_old()) { return false; }
1125
+ var s = this._get_settings().crrm.move;
1126
+ if(!s.check_move.call(this, this._get_move())) { return false; }
1127
+ return true;
1128
+ },
1129
+ move_node : function (obj, ref, position, is_copy, is_prepared, skip_check) {
1130
+ var s = this._get_settings().crrm.move;
1131
+ if(!is_prepared) {
1132
+ if(!position) { position = s.default_position; }
1133
+ if(position === "inside" && !s.default_position.match(/^(before|after)$/)) { position = s.default_position; }
1134
+ return this.__call_old(true, obj, ref, position, is_copy, false, skip_check);
1135
+ }
1136
+ // if the move is already prepared
1137
+ if(s.always_copy === true || (s.always_copy === "multitree" && obj.rt.get_index() !== obj.ot.get_index() )) {
1138
+ is_copy = true;
1139
+ }
1140
+ this.__call_old(true, obj, ref, position, is_copy, true, skip_check);
1141
+ },
1142
+
1143
+ cut : function (obj) {
1144
+ obj = this._get_node(obj);
1145
+ this.data.crrm.cp_nodes = false;
1146
+ this.data.crrm.ct_nodes = false;
1147
+ if(!obj || !obj.length) { return false; }
1148
+ this.data.crrm.ct_nodes = obj;
1149
+ },
1150
+ copy : function (obj) {
1151
+ obj = this._get_node(obj);
1152
+ this.data.crrm.cp_nodes = false;
1153
+ this.data.crrm.ct_nodes = false;
1154
+ if(!obj || !obj.length) { return false; }
1155
+ this.data.crrm.cp_nodes = obj;
1156
+ },
1157
+ paste : function (obj) {
1158
+ obj = this._get_node(obj);
1159
+ if(!obj || !obj.length) { return false; }
1160
+ if(!this.data.crrm.ct_nodes && !this.data.crrm.cp_nodes) { return false; }
1161
+ if(this.data.crrm.ct_nodes) { this.move_node(this.data.crrm.ct_nodes, obj); }
1162
+ if(this.data.crrm.cp_nodes) { this.move_node(this.data.crrm.cp_nodes, obj, false, true); }
1163
+ this.data.crrm.cp_nodes = false;
1164
+ this.data.crrm.ct_nodes = false;
1165
+ }
1166
+ }
1167
+ });
1168
+ // include the crr plugin by default
1169
+ $.jstree.defaults.plugins.push("crrm");
1170
+ })(jQuery);
1171
+ //*/
1172
+
1173
+
1174
+ /*
1175
+ * jsTree themes plugin 1.0
1176
+ * Handles loading and setting themes, as well as detecting path to themes, etc.
1177
+ */
1178
+ (function ($) {
1179
+ var themes_loaded = [];
1180
+ // this variable stores the path to the themes folder - if left as false - it will be autodetected
1181
+ $.jstree._themes = false;
1182
+ $.jstree.plugin("themes", {
1183
+ __init : function () {
1184
+ this.get_container()
1185
+ .bind("init.jstree", $.proxy(function () {
1186
+ var s = this._get_settings().themes;
1187
+ this.data.themes.dots = s.dots;
1188
+ this.data.themes.icons = s.icons;
1189
+ //alert(s.dots);
1190
+ this.set_theme(s.theme, s.url);
1191
+ }, this))
1192
+ .bind("loaded.jstree", $.proxy(function () {
1193
+ // bound here too, as simple HTML tree's won't honor dots & icons otherwise
1194
+ if(!this.data.themes.dots) { this.hide_dots(); }
1195
+ else { this.show_dots(); }
1196
+ if(!this.data.themes.icons) { this.hide_icons(); }
1197
+ else { this.show_icons(); }
1198
+ }, this));
1199
+ },
1200
+ defaults : {
1201
+ theme : "default",
1202
+ url : false,
1203
+ dots : true,
1204
+ icons : true
1205
+ },
1206
+ _fn : {
1207
+ set_theme : function (theme_name, theme_url) {
1208
+ if(!theme_name) { return false; }
1209
+ //if(!theme_url) { theme_url = $.jstree._themes + theme_name + '/style.css'; }
1210
+ if(!theme_url) { theme_url = $.jstree._themes + 'jstree.' + theme_name + '.css'; } if($.inArray(theme_url, themes_loaded) == -1) {
1211
+ $.vakata.css.add_sheet({ "url" : theme_url, "rel" : "jstree" });
1212
+ themes_loaded.push(theme_url);
1213
+ }
1214
+ if(this.data.themes.theme != theme_name) {
1215
+ this.get_container().removeClass('jstree-' + this.data.themes.theme);
1216
+ this.data.themes.theme = theme_name;
1217
+ }
1218
+ this.get_container().addClass('jstree-' + theme_name);
1219
+ if(!this.data.themes.dots) { this.hide_dots(); }
1220
+ else { this.show_dots(); }
1221
+ if(!this.data.themes.icons) { this.hide_icons(); }
1222
+ else { this.show_icons(); }
1223
+ this.__callback();
1224
+ },
1225
+ get_theme : function () { return this.data.themes.theme; },
1226
+
1227
+ show_dots : function () { this.data.themes.dots = true; this.get_container().children("ul").removeClass("jstree-no-dots"); },
1228
+ hide_dots : function () { this.data.themes.dots = false; this.get_container().children("ul").addClass("jstree-no-dots"); },
1229
+ toggle_dots : function () { if(this.data.themes.dots) { this.hide_dots(); } else { this.show_dots(); } },
1230
+
1231
+ show_icons : function () { this.data.themes.icons = true; this.get_container().children("ul").removeClass("jstree-no-icons"); },
1232
+ hide_icons : function () { this.data.themes.icons = false; this.get_container().children("ul").addClass("jstree-no-icons"); },
1233
+ toggle_icons: function () { if(this.data.themes.icons) { this.hide_icons(); } else { this.show_icons(); } }
1234
+ }
1235
+ });
1236
+ // autodetect themes path
1237
+ $(function () {
1238
+ //if($.jstree._themes === false) {
1239
+ // $("script").each(function () {
1240
+ // if(this.src.toString().match(/jquery\.jstree[^\/]*?\.js(\?.*)?$/)) {
1241
+ // $.jstree._themes = this.src.toString().replace(/jquery\.jstree[^\/]*?\.js(\?.*)?$/, "") + 'themes/';
1242
+ // return false;
1243
+ // }
1244
+ // });
1245
+ //}
1246
+ //if($.jstree._themes === false) { $.jstree._themes = "themes/"; }
1247
+ if($.jstree._themes === false) { $.jstree._themes = "/stylesheets/compiled/jquery.ui/"; }
1248
+ });
1249
+ // include the themes plugin by default
1250
+ $.jstree.defaults.plugins.push("themes");
1251
+ })(jQuery);
1252
+ //*/
1253
+
1254
+
1255
+ /*
1256
+ * jsTree hotkeys plugin 1.0
1257
+ * Enables keyboard navigation for all tree instances
1258
+ * Depends on the jstree ui & jquery hotkeys plugins
1259
+ */
1260
+ (function ($) {
1261
+ var bound = [];
1262
+ function exec(i, event) {
1263
+ var f = $.jstree._focused(), tmp;
1264
+ if(f && f.data && f.data.hotkeys && f.data.hotkeys.enabled) {
1265
+ tmp = f._get_settings().hotkeys[i];
1266
+ if(tmp) { return tmp.call(f, event); }
1267
+ }
1268
+ }
1269
+ $.jstree.plugin("hotkeys", {
1270
+ __init : function () {
1271
+ if(typeof $.hotkeys === "undefined") { throw "jsTree hotkeys: jQuery hotkeys plugin not included."; }
1272
+ if(!this.data.ui) { throw "jsTree hotkeys: jsTree UI plugin not included."; }
1273
+ $.each(this._get_settings().hotkeys, function (i, val) {
1274
+ if($.inArray(i, bound) == -1) {
1275
+ $(document).bind("keydown", i, function (event) { return exec(i, event); });
1276
+ bound.push(i);
1277
+ }
1278
+ });
1279
+ this.enable_hotkeys();
1280
+ },
1281
+ defaults : {
1282
+ "up" : function () {
1283
+ var o = this.data.ui.hovered || this.data.ui.last_selected || -1;
1284
+ this.hover_node(this._get_prev(o));
1285
+ return false;
1286
+ },
1287
+ "down" : function () {
1288
+ var o = this.data.ui.hovered || this.data.ui.last_selected || -1;
1289
+ this.hover_node(this._get_next(o));
1290
+ return false;
1291
+ },
1292
+ "left" : function () {
1293
+ var o = this.data.ui.hovered || this.data.ui.last_selected;
1294
+ if(o) {
1295
+ if(o.hasClass("jstree-open")) { this.close_node(o); }
1296
+ else { this.hover_node(this._get_prev(o)); }
1297
+ }
1298
+ return false;
1299
+ },
1300
+ "right" : function () {
1301
+ var o = this.data.ui.hovered || this.data.ui.last_selected;
1302
+ if(o && o.length) {
1303
+ if(o.hasClass("jstree-closed")) { this.open_node(o); }
1304
+ else { this.hover_node(this._get_next(o)); }
1305
+ }
1306
+ return false;
1307
+ },
1308
+ "space" : function () {
1309
+ if(this.data.ui.hovered) { this.data.ui.hovered.children("a:eq(0)").click(); }
1310
+ return false;
1311
+ },
1312
+ "ctrl+space" : function (event) {
1313
+ event.type = "click";
1314
+ if(this.data.ui.hovered) { this.data.ui.hovered.children("a:eq(0)").trigger(event); }
1315
+ return false;
1316
+ },
1317
+ "f2" : function () { this.rename(this.data.ui.hovered || this.data.ui.last_selected); },
1318
+ "del" : function () { this.remove(this.data.ui.hovered || this._get_node(null)); }
1319
+ },
1320
+ _fn : {
1321
+ enable_hotkeys : function () {
1322
+ this.data.hotkeys.enabled = true;
1323
+ },
1324
+ disable_hotkeys : function () {
1325
+ this.data.hotkeys.enabled = false;
1326
+ }
1327
+ }
1328
+ });
1329
+ })(jQuery);
1330
+ //*/
1331
+
1332
+
1333
+ /*
1334
+ * jsTree JSON 1.0
1335
+ * The JSON data store. Datastores are build by overriding the `load_node` and `_is_loaded` functions.
1336
+ */
1337
+ (function ($) {
1338
+ $.jstree.plugin("json_data", {
1339
+ defaults : {
1340
+ data : false,
1341
+ ajax : false,
1342
+ correct_state : true,
1343
+ progressive_render : false
1344
+ },
1345
+ _fn : {
1346
+ load_node : function (obj, s_call, e_call) { var _this = this; this.load_node_json(obj, function () { _this.__callback({ "obj" : obj }); s_call.call(this); }, e_call); },
1347
+ _is_loaded : function (obj) {
1348
+ var s = this._get_settings().json_data, d;
1349
+ obj = this._get_node(obj);
1350
+ if(obj && obj !== -1 && s.progressive_render && !obj.is(".jstree-open, .jstree-leaf") && obj.children("ul").children("li").length === 0 && obj.data("jstree-children")) {
1351
+ d = this._parse_json(obj.data("jstree-children"));
1352
+ if(d) {
1353
+ obj.append(d);
1354
+ $.removeData(obj, "jstree-children");
1355
+ }
1356
+ this.clean_node(obj);
1357
+ return true;
1358
+ }
1359
+ return obj == -1 || !obj || !s.ajax || obj.is(".jstree-open, .jstree-leaf") || obj.children("ul").children("li").size() > 0;
1360
+ },
1361
+ load_node_json : function (obj, s_call, e_call) {
1362
+ var s = this.get_settings().json_data, d,
1363
+ error_func = function () {},
1364
+ success_func = function () {};
1365
+ obj = this._get_node(obj);
1366
+ if(obj && obj !== -1) {
1367
+ if(obj.data("jstree-is-loading")) { return; }
1368
+ else { obj.data("jstree-is-loading",true); }
1369
+ }
1370
+ switch(!0) {
1371
+ case (!s.data && !s.ajax): throw "Neither data nor ajax settings supplied.";
1372
+ case (!!s.data && !s.ajax) || (!!s.data && !!s.ajax && (!obj || obj === -1)):
1373
+ if(!obj || obj == -1) {
1374
+ d = this._parse_json(s.data);
1375
+ if(d) {
1376
+ this.get_container().children("ul").empty().append(d.children());
1377
+ this.clean_node();
1378
+ }
1379
+ else {
1380
+ if(s.correct_state) { this.get_container().children("ul").empty(); }
1381
+ }
1382
+ }
1383
+ if(s_call) { s_call.call(this); }
1384
+ break;
1385
+ case (!s.data && !!s.ajax) || (!!s.data && !!s.ajax && obj && obj !== -1):
1386
+ error_func = function (x, t, e) {
1387
+ var ef = this.get_settings().json_data.ajax.error;
1388
+ if(ef) { ef.call(this, x, t, e); }
1389
+ if(obj != -1 && obj.length) {
1390
+ obj.children(".jstree-loading").removeClass("jstree-loading");
1391
+ obj.data("jstree-is-loading",false);
1392
+ if(t === "success" && s.correct_state) { obj.removeClass("jstree-open jstree-closed").addClass("jstree-leaf"); }
1393
+ }
1394
+ else {
1395
+ if(t === "success" && s.correct_state) { this.get_container().children("ul").empty(); }
1396
+ }
1397
+ if(e_call) { e_call.call(this); }
1398
+ };
1399
+ success_func = function (d, t, x) {
1400
+ var sf = this.get_settings().json_data.ajax.success;
1401
+ if(sf) { d = sf.call(this,d,t,x) || d; }
1402
+ if(d === "" || (!$.isArray(d) && !$.isPlainObject(d))) {
1403
+ return error_func.call(this, x, t, "");
1404
+ }
1405
+ d = this._parse_json(d);
1406
+ if(d) {
1407
+ if(obj === -1 || !obj) { this.get_container().children("ul").empty().append(d.children()); }
1408
+ else { obj.append(d).children(".jstree-loading").removeClass("jstree-loading"); obj.data("jstree-is-loading",false); }
1409
+ this.clean_node(obj);
1410
+ if(s_call) { s_call.call(this); }
1411
+ }
1412
+ else {
1413
+ if(obj === -1 || !obj) {
1414
+ if(s.correct_state) {
1415
+ this.get_container().children("ul").empty();
1416
+ if(s_call) { s_call.call(this); }
1417
+ }
1418
+ }
1419
+ else {
1420
+ obj.children(".jstree-loading").removeClass("jstree-loading");
1421
+ obj.data("jstree-is-loading",false);
1422
+ if(s.correct_state) {
1423
+ obj.removeClass("jstree-open jstree-closed").addClass("jstree-leaf");
1424
+ if(s_call) { s_call.call(this); }
1425
+ }
1426
+ }
1427
+ }
1428
+ };
1429
+ s.ajax.context = this;
1430
+ s.ajax.error = error_func;
1431
+ s.ajax.success = success_func;
1432
+ if(!s.ajax.dataType) { s.ajax.dataType = "json"; }
1433
+ if($.isFunction(s.ajax.url)) { s.ajax.url = s.ajax.url.call(this, obj); }
1434
+ if($.isFunction(s.ajax.data)) { s.ajax.data = s.ajax.data.call(this, obj); }
1435
+ $.ajax(s.ajax);
1436
+ break;
1437
+ }
1438
+ },
1439
+ _parse_json : function (js, is_callback) {
1440
+ var d = false,
1441
+ p = this._get_settings(),
1442
+ s = p.json_data,
1443
+ t = p.core.html_titles,
1444
+ tmp, i, j, ul1, ul2;
1445
+
1446
+ if(!js) { return d; }
1447
+ if($.isFunction(js)) {
1448
+ js = js.call(this);
1449
+ }
1450
+ if($.isArray(js)) {
1451
+ d = $();
1452
+ if(!js.length) { return false; }
1453
+ for(i = 0, j = js.length; i < j; i++) {
1454
+ tmp = this._parse_json(js[i], true);
1455
+ if(tmp.length) { d = d.add(tmp); }
1456
+ }
1457
+ }
1458
+ else {
1459
+ if(typeof js == "string") { js = { data : js }; }
1460
+ if(!js.data && js.data !== "") { return d; }
1461
+ d = $("<li>");
1462
+ if(js.attr) { d.attr(js.attr); }
1463
+ if(js.metadata) { d.data("jstree", js.metadata); }
1464
+ if(js.state) { d.addClass("jstree-" + js.state); }
1465
+ if(!$.isArray(js.data)) { tmp = js.data; js.data = []; js.data.push(tmp); }
1466
+ $.each(js.data, function (i, m) {
1467
+ tmp = $("<a>");
1468
+ if($.isFunction(m)) { m = m.call(this, js); }
1469
+ if(typeof m == "string") { tmp.attr('href','#')[ t ? "html" : "text" ](m); }
1470
+ else {
1471
+ if(!m.attr) { m.attr = {}; }
1472
+ if(!m.attr.href) { m.attr.href = '#'; }
1473
+ tmp.attr(m.attr)[ t ? "html" : "text" ](m.title);
1474
+ if(m.language) { tmp.addClass(m.language); }
1475
+ }
1476
+ tmp.prepend("<ins class='jstree-icon'>&#160;</ins>");
1477
+ if(!m.icon && js.icon) { m.icon = js.icon; }
1478
+ if(m.icon) {
1479
+ if(m.icon.indexOf("/") === -1) { tmp.children("ins").addClass(m.icon); }
1480
+ else { tmp.children("ins").css("background","url('" + m.icon + "') center center no-repeat"); }
1481
+ }
1482
+ d.append(tmp);
1483
+ });
1484
+ d.prepend("<ins class='jstree-icon'>&#160;</ins>");
1485
+ if(js.children) {
1486
+ if(s.progressive_render && js.state !== "open") {
1487
+ d.addClass("jstree-closed").data("jstree-children", js.children);
1488
+ }
1489
+ else {
1490
+ if($.isFunction(js.children)) {
1491
+ js.children = js.children.call(this, js);
1492
+ }
1493
+ if($.isArray(js.children) && js.children.length) {
1494
+ tmp = this._parse_json(js.children, true);
1495
+ if(tmp.length) {
1496
+ ul2 = $("<ul>");
1497
+ ul2.append(tmp);
1498
+ d.append(ul2);
1499
+ }
1500
+ }
1501
+ }
1502
+ }
1503
+ }
1504
+ if(!is_callback) {
1505
+ ul1 = $("<ul>");
1506
+ ul1.append(d);
1507
+ d = ul1;
1508
+ }
1509
+ return d;
1510
+ },
1511
+ get_json : function (obj, li_attr, a_attr, is_callback) {
1512
+ var result = [],
1513
+ s = this._get_settings(),
1514
+ _this = this,
1515
+ tmp1, tmp2, li, a, t, lang;
1516
+ obj = this._get_node(obj);
1517
+ if(!obj || obj === -1) { obj = this.get_container().find("> ul > li"); }
1518
+ li_attr = $.isArray(li_attr) ? li_attr : [ "id", "class" ];
1519
+ if(!is_callback && this.data.types) { li_attr.push(s.types.type_attr); }
1520
+ a_attr = $.isArray(a_attr) ? a_attr : [ ];
1521
+
1522
+ obj.each(function () {
1523
+ li = $(this);
1524
+ tmp1 = { data : [] };
1525
+ if(li_attr.length) { tmp1.attr = { }; }
1526
+ $.each(li_attr, function (i, v) {
1527
+ tmp2 = li.attr(v);
1528
+ if(tmp2 && tmp2.length && tmp2.replace(/jstree[^ ]*|$/ig,'').length) {
1529
+ tmp1.attr[v] = tmp2.replace(/jstree[^ ]*|$/ig,'');
1530
+ }
1531
+ });
1532
+ if(li.hasClass("jstree-open")) { tmp1.state = "open"; }
1533
+ if(li.hasClass("jstree-closed")) { tmp1.state = "closed"; }
1534
+ a = li.children("a");
1535
+ a.each(function () {
1536
+ t = $(this);
1537
+ if(
1538
+ a_attr.length ||
1539
+ $.inArray("languages", s.plugins) !== -1 ||
1540
+ t.children("ins").get(0).style.backgroundImage.length ||
1541
+ (t.children("ins").get(0).className && t.children("ins").get(0).className.replace(/jstree[^ ]*|$/ig,'').length)
1542
+ ) {
1543
+ lang = false;
1544
+ if($.inArray("languages", s.plugins) !== -1 && $.isArray(s.languages) && s.languages.length) {
1545
+ $.each(s.languages, function (l, lv) {
1546
+ if(t.hasClass(lv)) {
1547
+ lang = lv;
1548
+ return false;
1549
+ }
1550
+ });
1551
+ }
1552
+ tmp2 = { attr : { }, title : _this.get_text(t, lang) };
1553
+ $.each(a_attr, function (k, z) {
1554
+ tmp1.attr[z] = (t.attr(z) || "").replace(/jstree[^ ]*|$/ig,'');
1555
+ });
1556
+ $.each(s.languages, function (k, z) {
1557
+ if(t.hasClass(z)) { tmp2.language = z; return true; }
1558
+ });
1559
+ if(t.children("ins").get(0).className.replace(/jstree[^ ]*|$/ig,'').replace(/^\s+$/ig,"").length) {
1560
+ tmp2.icon = t.children("ins").get(0).className.replace(/jstree[^ ]*|$/ig,'').replace(/^\s+$/ig,"");
1561
+ }
1562
+ if(t.children("ins").get(0).style.backgroundImage.length) {
1563
+ tmp2.icon = t.children("ins").get(0).style.backgroundImage.replace("url(","").replace(")","");
1564
+ }
1565
+ }
1566
+ else {
1567
+ tmp2 = _this.get_text(t);
1568
+ }
1569
+ if(a.length > 1) { tmp1.data.push(tmp2); }
1570
+ else { tmp1.data = tmp2; }
1571
+ });
1572
+ li = li.find("> ul > li");
1573
+ if(li.length) { tmp1.children = _this.get_json(li, li_attr, a_attr, true); }
1574
+ result.push(tmp1);
1575
+ });
1576
+ return result;
1577
+ }
1578
+ }
1579
+ });
1580
+ })(jQuery);
1581
+ //*/
1582
+
1583
+
1584
+ /*
1585
+ * jsTree languages plugin 1.0
1586
+ * Adds support for multiple language versions in one tree
1587
+ * This basically allows for many titles coexisting in one node, but only one of them being visible at any given time
1588
+ * This is useful for maintaining the same structure in many languages (hence the name of the plugin)
1589
+ */
1590
+ (function ($) {
1591
+ $.jstree.plugin("languages", {
1592
+ __init : function () { this._load_css(); },
1593
+ defaults : [],
1594
+ _fn : {
1595
+ set_lang : function (i) {
1596
+ var langs = this._get_settings().languages,
1597
+ st = false,
1598
+ selector = ".jstree-" + this.get_index() + ' a';
1599
+ if(!$.isArray(langs) || langs.length === 0) { return false; }
1600
+ if($.inArray(i,langs) == -1) {
1601
+ if(!!langs[i]) { i = langs[i]; }
1602
+ else { return false; }
1603
+ }
1604
+ if(i == this.data.languages.current_language) { return true; }
1605
+ st = $.vakata.css.get_css(selector + "." + this.data.languages.current_language, false, this.data.languages.language_css);
1606
+ if(st !== false) { st.style.display = "none"; }
1607
+ st = $.vakata.css.get_css(selector + "." + i, false, this.data.languages.language_css);
1608
+ if(st !== false) { st.style.display = ""; }
1609
+ this.data.languages.current_language = i;
1610
+ this.__callback(i);
1611
+ return true;
1612
+ },
1613
+ get_lang : function () {
1614
+ return this.data.languages.current_language;
1615
+ },
1616
+ get_text : function (obj, lang) {
1617
+ obj = this._get_node(obj) || this.data.ui.last_selected;
1618
+ if(!obj.size()) { return false; }
1619
+ var langs = this._get_settings().languages,
1620
+ s = this._get_settings().core.html_titles;
1621
+ if($.isArray(langs) && langs.length) {
1622
+ lang = (lang && $.inArray(lang,langs) != -1) ? lang : this.data.languages.current_language;
1623
+ obj = obj.children("a." + lang);
1624
+ }
1625
+ else { obj = obj.children("a:eq(0)"); }
1626
+ if(s) {
1627
+ obj = obj.clone();
1628
+ obj.children("INS").remove();
1629
+ return obj.html();
1630
+ }
1631
+ else {
1632
+ obj = obj.contents().filter(function() { return this.nodeType == 3; })[0];
1633
+ return obj.nodeValue;
1634
+ }
1635
+ },
1636
+ set_text : function (obj, val, lang) {
1637
+ obj = this._get_node(obj) || this.data.ui.last_selected;
1638
+ if(!obj.size()) { return false; }
1639
+ var langs = this._get_settings().languages,
1640
+ s = this._get_settings().core.html_titles,
1641
+ tmp;
1642
+ if($.isArray(langs) && langs.length) {
1643
+ lang = (lang && $.inArray(lang,langs) != -1) ? lang : this.data.languages.current_language;
1644
+ obj = obj.children("a." + lang);
1645
+ }
1646
+ else { obj = obj.children("a:eq(0)"); }
1647
+ if(s) {
1648
+ tmp = obj.children("INS").clone();
1649
+ obj.html(val).prepend(tmp);
1650
+ this.__callback({ "obj" : obj, "name" : val, "lang" : lang });
1651
+ return true;
1652
+ }
1653
+ else {
1654
+ obj = obj.contents().filter(function() { return this.nodeType == 3; })[0];
1655
+ this.__callback({ "obj" : obj, "name" : val, "lang" : lang });
1656
+ return (obj.nodeValue = val);
1657
+ }
1658
+ },
1659
+ _load_css : function () {
1660
+ var langs = this._get_settings().languages,
1661
+ str = "/* languages css */",
1662
+ selector = ".jstree-" + this.get_index() + ' a',
1663
+ ln;
1664
+ if($.isArray(langs) && langs.length) {
1665
+ this.data.languages.current_language = langs[0];
1666
+ for(ln = 0; ln < langs.length; ln++) {
1667
+ str += selector + "." + langs[ln] + " {";
1668
+ if(langs[ln] != this.data.languages.current_language) { str += " display:none; "; }
1669
+ str += " } ";
1670
+ }
1671
+ this.data.languages.language_css = $.vakata.css.add_sheet({ 'str' : str });
1672
+ }
1673
+ },
1674
+ create_node : function (obj, position, js, callback) {
1675
+ var t = this.__call_old(true, obj, position, js, function (t) {
1676
+ var langs = this._get_settings().languages,
1677
+ a = t.children("a"),
1678
+ ln;
1679
+ if($.isArray(langs) && langs.length) {
1680
+ for(ln = 0; ln < langs.length; ln++) {
1681
+ if(!a.is("." + langs[ln])) {
1682
+ t.append(a.eq(0).clone().removeClass(langs.join(" ")).addClass(langs[ln]));
1683
+ }
1684
+ }
1685
+ a.not("." + langs.join(", .")).remove();
1686
+ }
1687
+ if(callback) { callback.call(this, t); }
1688
+ });
1689
+ return t;
1690
+ }
1691
+ }
1692
+ });
1693
+ })(jQuery);
1694
+ //*/
1695
+
1696
+
1697
+ /*
1698
+ * jsTree cookies plugin 1.0
1699
+ * Stores the currently opened/selected nodes in a cookie and then restores them
1700
+ * Depends on the jquery.cookie plugin
1701
+ */
1702
+ (function ($) {
1703
+ $.jstree.plugin("cookies", {
1704
+ __init : function () {
1705
+ if(typeof $.cookie === "undefined") { throw "jsTree cookie: jQuery cookie plugin not included."; }
1706
+
1707
+ var s = this._get_settings().cookies,
1708
+ tmp;
1709
+ if(!!s.save_opened) {
1710
+ tmp = $.cookie(s.save_opened);
1711
+ if(tmp && tmp.length) { this.data.core.to_open = tmp.split(","); }
1712
+ }
1713
+ if(!!s.save_selected) {
1714
+ tmp = $.cookie(s.save_selected);
1715
+ if(tmp && tmp.length && this.data.ui) { this.data.ui.to_select = tmp.split(","); }
1716
+ }
1717
+ this.get_container()
1718
+ .one( ( this.data.ui ? "reselect" : "reopen" ) + ".jstree", $.proxy(function () {
1719
+ this.get_container()
1720
+ .bind("open_node.jstree close_node.jstree select_node.jstree deselect_node.jstree", $.proxy(function (e) {
1721
+ if(this._get_settings().cookies.auto_save) { this.save_cookie((e.handleObj.namespace + e.handleObj.type).replace("jstree","")); }
1722
+ }, this));
1723
+ }, this));
1724
+ },
1725
+ defaults : {
1726
+ save_opened : "jstree_open",
1727
+ save_selected : "jstree_select",
1728
+ auto_save : true,
1729
+ cookie_options : {}
1730
+ },
1731
+ _fn : {
1732
+ save_cookie : function (c) {
1733
+ if(this.data.core.refreshing) { return; }
1734
+ var s = this._get_settings().cookies;
1735
+ if(!c) { // if called manually and not by event
1736
+ if(s.save_opened) {
1737
+ this.save_opened();
1738
+ $.cookie(s.save_opened, this.data.core.to_open.join(","), s.cookie_options);
1739
+ }
1740
+ if(s.save_selected && this.data.ui) {
1741
+ this.save_selected();
1742
+ $.cookie(s.save_selected, this.data.ui.to_select.join(","), s.cookie_options);
1743
+ }
1744
+ return;
1745
+ }
1746
+ switch(c) {
1747
+ case "open_node":
1748
+ case "close_node":
1749
+ if(!!s.save_opened) {
1750
+ this.save_opened();
1751
+ $.cookie(s.save_opened, this.data.core.to_open.join(","), s.cookie_options);
1752
+ }
1753
+ break;
1754
+ case "select_node":
1755
+ case "deselect_node":
1756
+ if(!!s.save_selected && this.data.ui) {
1757
+ this.save_selected();
1758
+ $.cookie(s.save_selected, this.data.ui.to_select.join(","), s.cookie_options);
1759
+ }
1760
+ break;
1761
+ }
1762
+ }
1763
+ }
1764
+ });
1765
+ // include cookies by default
1766
+ $.jstree.defaults.plugins.push("cookies");
1767
+ })(jQuery);
1768
+ //*/
1769
+
1770
+
1771
+ /*
1772
+ * jsTree sort plugin 1.0
1773
+ * Sorts items alphabetically (or using any other function)
1774
+ */
1775
+ (function ($) {
1776
+ $.jstree.plugin("sort", {
1777
+ __init : function () {
1778
+ this.get_container()
1779
+ .bind("load_node.jstree", $.proxy(function (e, data) {
1780
+ var obj = this._get_node(data.rslt.obj);
1781
+ obj = obj === -1 ? this.get_container().children("ul") : obj.children("ul");
1782
+ this.sort(obj);
1783
+ }, this))
1784
+ .bind("rename_node.jstree", $.proxy(function (e, data) {
1785
+ this.sort(data.rslt.obj.parent());
1786
+ }, this))
1787
+ .bind("move_node.jstree", $.proxy(function (e, data) {
1788
+ var m = data.rslt.np == -1 ? this.get_container() : data.rslt.np;
1789
+ this.sort(m.children("ul"));
1790
+ }, this));
1791
+ },
1792
+ defaults : function (a, b) { return this.get_text(a) > this.get_text(b) ? 1 : -1; },
1793
+ _fn : {
1794
+ sort : function (obj) {
1795
+ var s = this._get_settings().sort,
1796
+ t = this;
1797
+ obj.append($.makeArray(obj.children("li")).sort($.proxy(s, t)));
1798
+ obj.find("> li > ul").each(function() { t.sort($(this)); });
1799
+ this.clean_node(obj);
1800
+ }
1801
+ }
1802
+ });
1803
+ })(jQuery);
1804
+ //*/
1805
+
1806
+
1807
+ /*
1808
+ * jsTree DND plugin 1.0
1809
+ * Drag and drop plugin for moving/copying nodes
1810
+ */
1811
+ (function ($) {
1812
+ var o = false,
1813
+ r = false,
1814
+ m = false,
1815
+ sli = false,
1816
+ sti = false,
1817
+ dir1 = false,
1818
+ dir2 = false;
1819
+ $.vakata.dnd = {
1820
+ is_down : false,
1821
+ is_drag : false,
1822
+ helper : false,
1823
+ scroll_spd : 10,
1824
+ init_x : 0,
1825
+ init_y : 0,
1826
+ threshold : 5,
1827
+ user_data : {},
1828
+
1829
+ drag_start : function (e, data, html) {
1830
+ if($.vakata.dnd.is_drag) { $.vakata.drag_stop({}); }
1831
+ try {
1832
+ e.currentTarget.unselectable = "on";
1833
+ e.currentTarget.onselectstart = function() { return false; };
1834
+ if(e.currentTarget.style) { e.currentTarget.style.MozUserSelect = "none"; }
1835
+ } catch(err) { }
1836
+ $.vakata.dnd.init_x = e.pageX;
1837
+ $.vakata.dnd.init_y = e.pageY;
1838
+ $.vakata.dnd.user_data = data;
1839
+ $.vakata.dnd.is_down = true;
1840
+ $.vakata.dnd.helper = $("<div id='vakata-dragged'>").html(html).css("opacity", "0.75");
1841
+ $(document).bind("mousemove", $.vakata.dnd.drag);
1842
+ $(document).bind("mouseup", $.vakata.dnd.drag_stop);
1843
+ return false;
1844
+ },
1845
+ drag : function (e) {
1846
+ if(!$.vakata.dnd.is_down) { return; }
1847
+ if(!$.vakata.dnd.is_drag) {
1848
+ if(Math.abs(e.pageX - $.vakata.dnd.init_x) > 5 || Math.abs(e.pageY - $.vakata.dnd.init_y) > 5) {
1849
+ $.vakata.dnd.helper.appendTo("body");
1850
+ $.vakata.dnd.is_drag = true;
1851
+ $(document).triggerHandler("drag_start.vakata", { "event" : e, "data" : $.vakata.dnd.user_data });
1852
+ }
1853
+ else { return; }
1854
+ }
1855
+
1856
+ // maybe use a scrolling parent element instead of document?
1857
+ if(e.type === "mousemove") { // thought of adding scroll in order to move the helper, but mouse poisition is n/a
1858
+ var d = $(document), t = d.scrollTop(), l = d.scrollLeft();
1859
+ if(e.pageY - t < 20) {
1860
+ if(sti && dir1 === "down") { clearInterval(sti); sti = false; }
1861
+ if(!sti) { dir1 = "up"; sti = setInterval(function () { $(document).scrollTop($(document).scrollTop() - $.vakata.dnd.scroll_spd); }, 150); }
1862
+ }
1863
+ else {
1864
+ if(sti && dir1 === "up") { clearInterval(sti); sti = false; }
1865
+ }
1866
+ if($(window).height() - (e.pageY - t) < 20) {
1867
+ if(sti && dir1 === "up") { clearInterval(sti); sti = false; }
1868
+ if(!sti) { dir1 = "down"; sti = setInterval(function () { $(document).scrollTop($(document).scrollTop() + $.vakata.dnd.scroll_spd); }, 150); }
1869
+ }
1870
+ else {
1871
+ if(sti && dir1 === "down") { clearInterval(sti); sti = false; }
1872
+ }
1873
+
1874
+ if(e.pageX - l < 20) {
1875
+ if(sli && dir2 === "right") { clearInterval(sli); sli = false; }
1876
+ if(!sli) { dir2 = "left"; sli = setInterval(function () { $(document).scrollLeft($(document).scrollLeft() - $.vakata.dnd.scroll_spd); }, 150); }
1877
+ }
1878
+ else {
1879
+ if(sli && dir2 === "left") { clearInterval(sli); sli = false; }
1880
+ }
1881
+ if($(window).width() - (e.pageX - l) < 20) {
1882
+ if(sli && dir2 === "left") { clearInterval(sli); sli = false; }
1883
+ if(!sli) { dir2 = "right"; sli = setInterval(function () { $(document).scrollLeft($(document).scrollLeft() + $.vakata.dnd.scroll_spd); }, 150); }
1884
+ }
1885
+ else {
1886
+ if(sli && dir2 === "right") { clearInterval(sli); sli = false; }
1887
+ }
1888
+ }
1889
+
1890
+ $.vakata.dnd.helper.css({ left : (e.pageX + 5) + "px", top : (e.pageY + 10) + "px" });
1891
+ $(document).triggerHandler("drag.vakata", { "event" : e, "data" : $.vakata.dnd.user_data });
1892
+ },
1893
+ drag_stop : function (e) {
1894
+ $(document).unbind("mousemove", $.vakata.dnd.drag);
1895
+ $(document).unbind("mouseup", $.vakata.dnd.drag_stop);
1896
+ $(document).triggerHandler("drag_stop.vakata", { "event" : e, "data" : $.vakata.dnd.user_data });
1897
+ $.vakata.dnd.helper.remove();
1898
+ $.vakata.dnd.init_x = 0;
1899
+ $.vakata.dnd.init_y = 0;
1900
+ $.vakata.dnd.user_data = {};
1901
+ $.vakata.dnd.is_down = false;
1902
+ $.vakata.dnd.is_drag = false;
1903
+ }
1904
+ };
1905
+ $(function() {
1906
+ var css_string = '#vakata-dragged { display:block; margin:0 0 0 0; padding:4px 4px 4px 24px; position:absolute; top:-2000px; line-height:16px; z-index:10000; } ';
1907
+ $.vakata.css.add_sheet({ str : css_string });
1908
+ });
1909
+
1910
+ $.jstree.plugin("dnd", {
1911
+ __init : function () {
1912
+ this.data.dnd = {
1913
+ active : false,
1914
+ after : false,
1915
+ inside : false,
1916
+ before : false,
1917
+ off : false,
1918
+ prepared : false,
1919
+ w : 0,
1920
+ to1 : false,
1921
+ to2 : false,
1922
+ cof : false,
1923
+ cw : false,
1924
+ ch : false,
1925
+ i1 : false,
1926
+ i2 : false
1927
+ };
1928
+ this.get_container()
1929
+ .bind("mouseenter.jstree", $.proxy(function () {
1930
+ if($.vakata.dnd.is_drag && $.vakata.dnd.user_data.jstree && this.data.themes) {
1931
+ m.attr("class", "jstree-" + this.data.themes.theme);
1932
+ $.vakata.dnd.helper.attr("class", "jstree-dnd-helper jstree-" + this.data.themes.theme);
1933
+ }
1934
+ }, this))
1935
+ .bind("mouseleave.jstree", $.proxy(function () {
1936
+ if($.vakata.dnd.is_drag && $.vakata.dnd.user_data.jstree) {
1937
+ if(this.data.dnd.i1) { clearInterval(this.data.dnd.i1); }
1938
+ if(this.data.dnd.i2) { clearInterval(this.data.dnd.i2); }
1939
+ }
1940
+ }, this))
1941
+ .bind("mousemove.jstree", $.proxy(function (e) {
1942
+ if($.vakata.dnd.is_drag && $.vakata.dnd.user_data.jstree) {
1943
+ var cnt = this.get_container()[0];
1944
+
1945
+ // Horizontal scroll
1946
+ if(e.pageX + 24 > this.data.dnd.cof.left + this.data.dnd.cw) {
1947
+ if(this.data.dnd.i1) { clearInterval(this.data.dnd.i1); }
1948
+ this.data.dnd.i1 = setInterval($.proxy(function () { this.scrollLeft += $.vakata.dnd.scroll_spd; }, cnt), 100);
1949
+ }
1950
+ else if(e.pageX - 24 < this.data.dnd.cof.left) {
1951
+ if(this.data.dnd.i1) { clearInterval(this.data.dnd.i1); }
1952
+ this.data.dnd.i1 = setInterval($.proxy(function () { this.scrollLeft -= $.vakata.dnd.scroll_spd; }, cnt), 100);
1953
+ }
1954
+ else {
1955
+ if(this.data.dnd.i1) { clearInterval(this.data.dnd.i1); }
1956
+ }
1957
+
1958
+ // Vertical scroll
1959
+ if(e.pageY + 24 > this.data.dnd.cof.top + this.data.dnd.ch) {
1960
+ if(this.data.dnd.i2) { clearInterval(this.data.dnd.i2); }
1961
+ this.data.dnd.i2 = setInterval($.proxy(function () { this.scrollTop += $.vakata.dnd.scroll_spd; }, cnt), 100);
1962
+ }
1963
+ else if(e.pageY - 24 < this.data.dnd.cof.top) {
1964
+ if(this.data.dnd.i2) { clearInterval(this.data.dnd.i2); }
1965
+ this.data.dnd.i2 = setInterval($.proxy(function () { this.scrollTop -= $.vakata.dnd.scroll_spd; }, cnt), 100);
1966
+ }
1967
+ else {
1968
+ if(this.data.dnd.i2) { clearInterval(this.data.dnd.i2); }
1969
+ }
1970
+
1971
+ }
1972
+ }, this))
1973
+ .delegate("a", "mousedown.jstree", $.proxy(function (e) {
1974
+ if(e.which === 1) {
1975
+ this.start_drag(e.currentTarget, e);
1976
+ return false;
1977
+ }
1978
+ }, this))
1979
+ .delegate("a", "mouseenter.jstree", $.proxy(function (e) {
1980
+ if($.vakata.dnd.is_drag && $.vakata.dnd.user_data.jstree) {
1981
+ this.dnd_enter(e.currentTarget);
1982
+ }
1983
+ }, this))
1984
+ .delegate("a", "mousemove.jstree", $.proxy(function (e) {
1985
+ if($.vakata.dnd.is_drag && $.vakata.dnd.user_data.jstree) {
1986
+ if(typeof this.data.dnd.off.top === "undefined") { this.data.dnd.off = $(e.target).offset(); }
1987
+ this.data.dnd.w = (e.pageY - (this.data.dnd.off.top || 0)) % this.data.core.li_height;
1988
+ if(this.data.dnd.w < 0) { this.data.dnd.w += this.data.core.li_height; }
1989
+ this.dnd_show();
1990
+ }
1991
+ }, this))
1992
+ .delegate("a", "mouseleave.jstree", $.proxy(function (e) {
1993
+ if($.vakata.dnd.is_drag && $.vakata.dnd.user_data.jstree) {
1994
+ this.data.dnd.after = false;
1995
+ this.data.dnd.before = false;
1996
+ this.data.dnd.inside = false;
1997
+ $.vakata.dnd.helper.children("ins").attr("class","jstree-invalid");
1998
+ m.hide();
1999
+ if(r && r[0] === e.target.parentNode) {
2000
+ if(this.data.dnd.to1) {
2001
+ clearTimeout(this.data.dnd.to1);
2002
+ this.data.dnd.to1 = false;
2003
+ }
2004
+ if(this.data.dnd.to2) {
2005
+ clearTimeout(this.data.dnd.to2);
2006
+ this.data.dnd.to2 = false;
2007
+ }
2008
+ }
2009
+ }
2010
+ }, this))
2011
+ .delegate("a", "mouseup.jstree", $.proxy(function (e) {
2012
+ if($.vakata.dnd.is_drag && $.vakata.dnd.user_data.jstree) {
2013
+ this.dnd_finish(e);
2014
+ }
2015
+ }, this));
2016
+
2017
+ $(document)
2018
+ .bind("drag_stop.vakata", $.proxy(function () {
2019
+ this.data.dnd.after = false;
2020
+ this.data.dnd.before = false;
2021
+ this.data.dnd.inside = false;
2022
+ this.data.dnd.off = false;
2023
+ this.data.dnd.prepared = false;
2024
+ this.data.dnd.w = false;
2025
+ this.data.dnd.to1 = false;
2026
+ this.data.dnd.to2 = false;
2027
+ this.data.dnd.active = false;
2028
+ this.data.dnd.foreign = false;
2029
+ if(m) { m.css({ "top" : "-2000px" }); }
2030
+ }, this))
2031
+ .bind("drag_start.vakata", $.proxy(function (e, data) {
2032
+ if(data.data.jstree) {
2033
+ var et = $(data.event.target);
2034
+ if(et.closest(".jstree").hasClass("jstree-" + this.get_index())) {
2035
+ this.dnd_enter(et);
2036
+ }
2037
+ }
2038
+ }, this));
2039
+
2040
+ var s = this._get_settings().dnd;
2041
+ if(s.drag_target) {
2042
+ $(document)
2043
+ .delegate(s.drag_target, "mousedown.jstree", $.proxy(function (e) {
2044
+ o = e.target;
2045
+ $.vakata.dnd.drag_start(e, { jstree : true, obj : e.target }, "<ins class='jstree-icon'></ins>" + $(e.target).text() );
2046
+ if(this.data.themes) {
2047
+ m.attr("class", "jstree-" + this.data.themes.theme);
2048
+ $.vakata.dnd.helper.attr("class", "jstree-dnd-helper jstree-" + this.data.themes.theme);
2049
+ }
2050
+ $.vakata.dnd.helper.children("ins").attr("class","jstree-invalid");
2051
+ var cnt = this.get_container();
2052
+ this.data.dnd.cof = cnt.offset();
2053
+ this.data.dnd.cw = parseInt(cnt.width(),10);
2054
+ this.data.dnd.ch = parseInt(cnt.height(),10);
2055
+ this.data.dnd.foreign = true;
2056
+ return false;
2057
+ }, this));
2058
+ }
2059
+ if(s.drop_target) {
2060
+ $(document)
2061
+ .delegate(s.drop_target, "mouseenter.jstree", $.proxy(function (e) {
2062
+ if(this.data.dnd.active && this._get_settings().dnd.drop_check.call(this, { "o" : o, "r" : $(e.target) })) {
2063
+ $.vakata.dnd.helper.children("ins").attr("class","jstree-ok");
2064
+ }
2065
+ }, this))
2066
+ .delegate(s.drop_target, "mouseleave.jstree", $.proxy(function (e) {
2067
+ if(this.data.dnd.active) {
2068
+ $.vakata.dnd.helper.children("ins").attr("class","jstree-invalid");
2069
+ }
2070
+ }, this))
2071
+ .delegate(s.drop_target, "mouseup.jstree", $.proxy(function (e) {
2072
+ if(this.data.dnd.active && $.vakata.dnd.helper.children("ins").hasClass("jstree-ok")) {
2073
+ this._get_settings().dnd.drop_finish.call(this, { "o" : o, "r" : $(e.target) });
2074
+ }
2075
+ }, this));
2076
+ }
2077
+ },
2078
+ defaults : {
2079
+ copy_modifier : "ctrl",
2080
+ check_timeout : 200,
2081
+ open_timeout : 500,
2082
+ drop_target : ".jstree-drop",
2083
+ drop_check : function (data) { return true; },
2084
+ drop_finish : $.noop,
2085
+ drag_target : ".jstree-draggable",
2086
+ drag_finish : $.noop,
2087
+ drag_check : function (data) { return { after : false, before : false, inside : true }; }
2088
+ },
2089
+ _fn : {
2090
+ dnd_prepare : function () {
2091
+ if(!r || !r.length) { return; }
2092
+ this.data.dnd.off = r.offset();
2093
+ if(this._get_settings().core.rtl) {
2094
+ this.data.dnd.off.right = this.data.dnd.off.left + r.width();
2095
+ }
2096
+ if(this.data.dnd.foreign) {
2097
+ var a = this._get_settings().dnd.drag_check.call(this, { "o" : o, "r" : r });
2098
+ this.data.dnd.after = a.after;
2099
+ this.data.dnd.before = a.before;
2100
+ this.data.dnd.inside = a.inside;
2101
+ this.data.dnd.prepared = true;
2102
+ return this.dnd_show();
2103
+ }
2104
+ this.prepare_move(o, r, "before");
2105
+ this.data.dnd.before = this.check_move();
2106
+ this.prepare_move(o, r, "after");
2107
+ this.data.dnd.after = this.check_move();
2108
+ if(this._is_loaded(r)) {
2109
+ this.prepare_move(o, r, "inside");
2110
+ this.data.dnd.inside = this.check_move();
2111
+ }
2112
+ else {
2113
+ this.data.dnd.inside = false;
2114
+ }
2115
+ this.data.dnd.prepared = true;
2116
+ return this.dnd_show();
2117
+ },
2118
+ dnd_show : function () {
2119
+ if(!this.data.dnd.prepared) { return; }
2120
+ var o = ["before","inside","after"],
2121
+ r = false,
2122
+ rtl = this._get_settings().core.rtl,
2123
+ pos;
2124
+ if(this.data.dnd.w < this.data.core.li_height/3) { o = ["before","inside","after"]; }
2125
+ else if(this.data.dnd.w <= this.data.core.li_height*2/3) {
2126
+ o = this.data.dnd.w < this.data.core.li_height/2 ? ["inside","before","after"] : ["inside","after","before"];
2127
+ }
2128
+ else { o = ["after","inside","before"]; }
2129
+ $.each(o, $.proxy(function (i, val) {
2130
+ if(this.data.dnd[val]) {
2131
+ $.vakata.dnd.helper.children("ins").attr("class","jstree-ok");
2132
+ r = val;
2133
+ return false;
2134
+ }
2135
+ }, this));
2136
+ if(r === false) { $.vakata.dnd.helper.children("ins").attr("class","jstree-invalid"); }
2137
+
2138
+ pos = rtl ? (this.data.dnd.off.right - 18) : (this.data.dnd.off.left + 10);
2139
+ switch(r) {
2140
+ case "before":
2141
+ m.css({ "left" : pos + "px", "top" : (this.data.dnd.off.top - 6) + "px" }).show();
2142
+ break;
2143
+ case "after":
2144
+ m.css({ "left" : pos + "px", "top" : (this.data.dnd.off.top + this.data.core.li_height - 7) + "px" }).show();
2145
+ break;
2146
+ case "inside":
2147
+ m.css({ "left" : pos + ( rtl ? -4 : 4) + "px", "top" : (this.data.dnd.off.top + this.data.core.li_height/2 - 5) + "px" }).show();
2148
+ break;
2149
+ default:
2150
+ m.hide();
2151
+ break;
2152
+ }
2153
+ return r;
2154
+ },
2155
+ dnd_open : function () {
2156
+ this.data.dnd.to2 = false;
2157
+ this.open_node(r, $.proxy(this.dnd_prepare,this), true);
2158
+ },
2159
+ dnd_finish : function (e) {
2160
+ if(this.data.dnd.foreign) {
2161
+ if(this.data.dnd.after || this.data.dnd.before || this.data.dnd.inside) {
2162
+ this._get_settings().dnd.drag_finish.call(this, { "o" : o, "r" : r });
2163
+ }
2164
+ }
2165
+ else {
2166
+ this.dnd_prepare();
2167
+ this.move_node(o, r, this.dnd_show(), e[this._get_settings().dnd.copy_modifier + "Key"]);
2168
+ }
2169
+ o = false;
2170
+ r = false;
2171
+ m.hide();
2172
+ },
2173
+ dnd_enter : function (obj) {
2174
+ var s = this._get_settings().dnd;
2175
+ this.data.dnd.prepared = false;
2176
+ r = this._get_node(obj);
2177
+ if(s.check_timeout) {
2178
+ // do the calculations after a minimal timeout (users tend to drag quickly to the desired location)
2179
+ if(this.data.dnd.to1) { clearTimeout(this.data.dnd.to1); }
2180
+ this.data.dnd.to1 = setTimeout($.proxy(this.dnd_prepare, this), s.check_timeout);
2181
+ }
2182
+ else {
2183
+ this.dnd_prepare();
2184
+ }
2185
+ if(s.open_timeout) {
2186
+ if(this.data.dnd.to2) { clearTimeout(this.data.dnd.to2); }
2187
+ if(r && r.length && r.hasClass("jstree-closed")) {
2188
+ // if the node is closed - open it, then recalculate
2189
+ this.data.dnd.to2 = setTimeout($.proxy(this.dnd_open, this), s.open_timeout);
2190
+ }
2191
+ }
2192
+ else {
2193
+ if(r && r.length && r.hasClass("jstree-closed")) {
2194
+ this.dnd_open();
2195
+ }
2196
+ }
2197
+ },
2198
+ start_drag : function (obj, e) {
2199
+ o = this._get_node(obj);
2200
+ if(this.data.ui && this.is_selected(o)) { o = this._get_node(null, true); }
2201
+ $.vakata.dnd.drag_start(e, { jstree : true, obj : o }, "<ins class='jstree-icon'></ins>" + (o.length > 1 ? "Multiple selection" : this.get_text(o)) );
2202
+ if(this.data.themes) {
2203
+ m.attr("class", "jstree-" + this.data.themes.theme);
2204
+ $.vakata.dnd.helper.attr("class", "jstree-dnd-helper jstree-" + this.data.themes.theme);
2205
+ }
2206
+ var cnt = this.get_container();
2207
+ this.data.dnd.cof = cnt.children("ul").offset();
2208
+ this.data.dnd.cw = parseInt(cnt.width(),10);
2209
+ this.data.dnd.ch = parseInt(cnt.height(),10);
2210
+ this.data.dnd.active = true;
2211
+ }
2212
+ }
2213
+ });
2214
+ $(function() {
2215
+ var css_string = '' +
2216
+ '#vakata-dragged ins { display:block; text-decoration:none; width:16px; height:16px; margin:0 0 0 0; padding:0; position:absolute; top:4px; left:4px; } ' +
2217
+ '#vakata-dragged .jstree-ok { background:green; } ' +
2218
+ '#vakata-dragged .jstree-invalid { background:red; } ' +
2219
+ '#jstree-marker { padding:0; margin:0; line-height:12px; font-size:1px; overflow:hidden; height:12px; width:8px; position:absolute; top:-30px; z-index:10000; background-repeat:no-repeat; display:none; background-color:silver; } ';
2220
+ $.vakata.css.add_sheet({ str : css_string });
2221
+ m = $("<div>").attr({ id : "jstree-marker" }).hide().appendTo("body");
2222
+ $(document).bind("drag_start.vakata", function (e, data) {
2223
+ if(data.data.jstree) {
2224
+ m.show();
2225
+ }
2226
+ });
2227
+ $(document).bind("drag_stop.vakata", function (e, data) {
2228
+ if(data.data.jstree) { m.hide(); }
2229
+ });
2230
+ });
2231
+ })(jQuery);
2232
+ //*/
2233
+
2234
+
2235
+ /*
2236
+ * jsTree checkbox plugin 1.0
2237
+ * Inserts checkboxes in front of every node
2238
+ * Depends on the ui plugin
2239
+ * DOES NOT WORK NICELY WITH MULTITREE DRAG'N'DROP
2240
+ */
2241
+ (function ($) {
2242
+ $.jstree.plugin("checkbox", {
2243
+ __init : function () {
2244
+ this.select_node = this.deselect_node = this.deselect_all = $.noop;
2245
+ this.get_selected = this.get_checked;
2246
+
2247
+ this.get_container()
2248
+ .bind("open_node.jstree create_node.jstree clean_node.jstree", $.proxy(function (e, data) {
2249
+ this._prepare_checkboxes(data.rslt.obj);
2250
+ }, this))
2251
+ .bind("loaded.jstree", $.proxy(function (e) {
2252
+ this._prepare_checkboxes();
2253
+ }, this))
2254
+ .delegate("a", "click.jstree", $.proxy(function (e) {
2255
+ if(this._get_node(e.target).hasClass("jstree-checked")) { this.uncheck_node(e.target); }
2256
+ else { this.check_node(e.target); }
2257
+ if(this.data.ui) { this.save_selected(); }
2258
+ if(this.data.cookies) { this.save_cookie("select_node"); }
2259
+ e.preventDefault();
2260
+ }, this));
2261
+ },
2262
+ __destroy : function () {
2263
+ this.get_container().find(".jstree-checkbox").remove();
2264
+ },
2265
+ _fn : {
2266
+ _prepare_checkboxes : function (obj) {
2267
+ obj = !obj || obj == -1 ? this.get_container() : this._get_node(obj);
2268
+ var c, _this = this, t;
2269
+ obj.each(function () {
2270
+ t = $(this);
2271
+ c = t.is("li") && t.hasClass("jstree-checked") ? "jstree-checked" : "jstree-unchecked";
2272
+ t.find("a").not(":has(.jstree-checkbox)").prepend("<ins class='jstree-checkbox'>&#160;</ins>").parent().not(".jstree-checked, .jstree-unchecked").addClass(c);
2273
+ });
2274
+ if(obj.is("li")) { this._repair_state(obj); }
2275
+ else { obj.find("> ul > li").each(function () { _this._repair_state(this); }); }
2276
+ },
2277
+ change_state : function (obj, state) {
2278
+ obj = this._get_node(obj);
2279
+ state = (state === false || state === true) ? state : obj.hasClass("jstree-checked");
2280
+ if(state) { obj.find("li").andSelf().removeClass("jstree-checked jstree-undetermined").addClass("jstree-unchecked"); }
2281
+ else {
2282
+ obj.find("li").andSelf().removeClass("jstree-unchecked jstree-undetermined").addClass("jstree-checked");
2283
+ if(this.data.ui) { this.data.ui.last_selected = obj; }
2284
+ this.data.checkbox.last_selected = obj;
2285
+ }
2286
+ obj.parentsUntil(".jstree", "li").each(function () {
2287
+ var $this = $(this);
2288
+ if(state) {
2289
+ if($this.children("ul").children(".jstree-checked, .jstree-undetermined").length) {
2290
+ $this.parentsUntil(".jstree", "li").andSelf().removeClass("jstree-checked jstree-unchecked").addClass("jstree-undetermined");
2291
+ return false;
2292
+ }
2293
+ else {
2294
+ $this.removeClass("jstree-checked jstree-undetermined").addClass("jstree-unchecked");
2295
+ }
2296
+ }
2297
+ else {
2298
+ if($this.children("ul").children(".jstree-unchecked, .jstree-undetermined").length) {
2299
+ $this.parentsUntil(".jstree", "li").andSelf().removeClass("jstree-checked jstree-unchecked").addClass("jstree-undetermined");
2300
+ return false;
2301
+ }
2302
+ else {
2303
+ $this.removeClass("jstree-unchecked jstree-undetermined").addClass("jstree-checked");
2304
+ }
2305
+ }
2306
+ });
2307
+ if(this.data.ui) { this.data.ui.selected = this.get_checked(); }
2308
+ this.__callback(obj);
2309
+ },
2310
+ check_node : function (obj) {
2311
+ this.change_state(obj, false);
2312
+ },
2313
+ uncheck_node : function (obj) {
2314
+ this.change_state(obj, true);
2315
+ },
2316
+ check_all : function () {
2317
+ var _this = this;
2318
+ this.get_container().children("ul").children("li").each(function () {
2319
+ _this.check_node(this, false);
2320
+ });
2321
+ },
2322
+ uncheck_all : function () {
2323
+ var _this = this;
2324
+ this.get_container().children("ul").children("li").each(function () {
2325
+ _this.change_state(this, true);
2326
+ });
2327
+ },
2328
+
2329
+ is_checked : function(obj) {
2330
+ obj = this._get_node(obj);
2331
+ return obj.length ? obj.is(".jstree-checked") : false;
2332
+ },
2333
+ get_checked : function (obj) {
2334
+ obj = !obj || obj === -1 ? this.get_container() : this._get_node(obj);
2335
+ return obj.find("> ul > .jstree-checked, .jstree-undetermined > ul > .jstree-checked");
2336
+ },
2337
+ get_unchecked : function (obj) {
2338
+ obj = !obj || obj === -1 ? this.get_container() : this._get_node(obj);
2339
+ return obj.find("> ul > .jstree-unchecked, .jstree-undetermined > ul > .jstree-unchecked");
2340
+ },
2341
+
2342
+ show_checkboxes : function () { this.get_container().children("ul").removeClass("jstree-no-checkboxes"); },
2343
+ hide_checkboxes : function () { this.get_container().children("ul").addClass("jstree-no-checkboxes"); },
2344
+
2345
+ _repair_state : function (obj) {
2346
+ obj = this._get_node(obj);
2347
+ if(!obj.length) { return; }
2348
+ var a = obj.find("> ul > .jstree-checked").length,
2349
+ b = obj.find("> ul > .jstree-undetermined").length,
2350
+ c = obj.find("> ul > li").length;
2351
+
2352
+ if(c === 0) { if(obj.hasClass("jstree-undetermined")) { this.check_node(obj); } }
2353
+ else if(a === 0 && b === 0) { this.uncheck_node(obj); }
2354
+ else if(a === c) { this.check_node(obj); }
2355
+ else {
2356
+ obj.parentsUntil(".jstree","li").removeClass("jstree-checked jstree-unchecked").addClass("jstree-undetermined");
2357
+ }
2358
+ },
2359
+ reselect : function () {
2360
+ if(this.data.ui) {
2361
+ var _this = this,
2362
+ s = this.data.ui.to_select;
2363
+ s = $.map($.makeArray(s), function (n) { return "#" + n.toString().replace(/^#/,"").replace('\\/','/').replace('/','\\/'); });
2364
+ this.deselect_all();
2365
+ $.each(s, function (i, val) { _this.check_node(val); });
2366
+ this.__callback();
2367
+ }
2368
+ }
2369
+ }
2370
+ });
2371
+ })(jQuery);
2372
+ //*/
2373
+
2374
+
2375
+ /*
2376
+ * jsTree XML 1.0
2377
+ * The XML data store. Datastores are build by overriding the `load_node` and `_is_loaded` functions.
2378
+ */
2379
+ (function ($) {
2380
+ $.vakata.xslt = function (xml, xsl, callback) {
2381
+ var rs = "", xm, xs, processor, support;
2382
+ if(document.recalc) {
2383
+ xm = document.createElement('xml');
2384
+ xs = document.createElement('xml');
2385
+ xm.innerHTML = xml;
2386
+ xs.innerHTML = xsl;
2387
+ $("body").append(xm).append(xs);
2388
+ setTimeout( (function (xm, xs, callback) {
2389
+ return function () {
2390
+ callback.call(null, xm.transformNode(xs.XMLDocument));
2391
+ setTimeout( (function (xm, xs) { return function () { jQuery("body").remove(xm).remove(xs); }; })(xm, xs), 200);
2392
+ };
2393
+ }) (xm, xs, callback), 100);
2394
+ return true;
2395
+ }
2396
+ if(typeof window.DOMParser !== "undefined" && typeof window.XMLHttpRequest !== "undefined" && typeof window.XSLTProcessor !== "undefined") {
2397
+ processor = new XSLTProcessor();
2398
+ support = $.isFunction(processor.transformDocument) ? (typeof window.XMLSerializer !== "undefined") : true;
2399
+ if(!support) { return false; }
2400
+ xml = new DOMParser().parseFromString(xml, "text/xml");
2401
+ xsl = new DOMParser().parseFromString(xsl, "text/xml");
2402
+ if($.isFunction(processor.transformDocument)) {
2403
+ rs = document.implementation.createDocument("", "", null);
2404
+ processor.transformDocument(xml, xsl, rs, null);
2405
+ callback.call(null, XMLSerializer().serializeToString(rs));
2406
+ return true;
2407
+ }
2408
+ else {
2409
+ processor.importStylesheet(xsl);
2410
+ rs = processor.transformToFragment(xml, document);
2411
+ callback.call(null, $("<div>").append(rs).html());
2412
+ return true;
2413
+ }
2414
+ }
2415
+ return false;
2416
+ };
2417
+ var xsl = {
2418
+ 'nest' : '<?xml version="1.0" encoding="utf-8" ?>' +
2419
+ '<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >' +
2420
+ '<xsl:output method="html" encoding="utf-8" omit-xml-declaration="yes" standalone="no" indent="no" media-type="text/html" />' +
2421
+ '<xsl:template match="/">' +
2422
+ ' <xsl:call-template name="nodes">' +
2423
+ ' <xsl:with-param name="node" select="/root" />' +
2424
+ ' </xsl:call-template>' +
2425
+ '</xsl:template>' +
2426
+ '<xsl:template name="nodes">' +
2427
+ ' <xsl:param name="node" />' +
2428
+ ' <ul>' +
2429
+ ' <xsl:for-each select="$node/item">' +
2430
+ ' <xsl:variable name="children" select="count(./item) &gt; 0" />' +
2431
+ ' <li>' +
2432
+ ' <xsl:attribute name="class">' +
2433
+ ' <xsl:if test="position() = last()">jstree-last </xsl:if>' +
2434
+ ' <xsl:choose>' +
2435
+ ' <xsl:when test="@state = \'open\'">jstree-open </xsl:when>' +
2436
+ ' <xsl:when test="$children or @hasChildren or @state = \'closed\'">jstree-closed </xsl:when>' +
2437
+ ' <xsl:otherwise>jstree-leaf </xsl:otherwise>' +
2438
+ ' </xsl:choose>' +
2439
+ ' <xsl:value-of select="@class" />' +
2440
+ ' </xsl:attribute>' +
2441
+ ' <xsl:for-each select="@*">' +
2442
+ ' <xsl:if test="name() != \'class\' and name() != \'state\' and name() != \'hasChildren\'">' +
2443
+ ' <xsl:attribute name="{name()}"><xsl:value-of select="." /></xsl:attribute>' +
2444
+ ' </xsl:if>' +
2445
+ ' </xsl:for-each>' +
2446
+ ' <ins class="jstree-icon"><xsl:text>&#xa0;</xsl:text></ins>' +
2447
+ ' <xsl:for-each select="content/name">' +
2448
+ ' <a>' +
2449
+ ' <xsl:attribute name="href">' +
2450
+ ' <xsl:choose>' +
2451
+ ' <xsl:when test="@href"><xsl:value-of select="@href" /></xsl:when>' +
2452
+ ' <xsl:otherwise>#</xsl:otherwise>' +
2453
+ ' </xsl:choose>' +
2454
+ ' </xsl:attribute>' +
2455
+ ' <xsl:attribute name="class"><xsl:value-of select="@lang" /> <xsl:value-of select="@class" /></xsl:attribute>' +
2456
+ ' <xsl:attribute name="style"><xsl:value-of select="@style" /></xsl:attribute>' +
2457
+ ' <xsl:for-each select="@*">' +
2458
+ ' <xsl:if test="name() != \'style\' and name() != \'class\' and name() != \'href\'">' +
2459
+ ' <xsl:attribute name="{name()}"><xsl:value-of select="." /></xsl:attribute>' +
2460
+ ' </xsl:if>' +
2461
+ ' </xsl:for-each>' +
2462
+ ' <ins>' +
2463
+ ' <xsl:attribute name="class">jstree-icon ' +
2464
+ ' <xsl:if test="string-length(attribute::icon) > 0 and not(contains(@icon,\'/\'))"><xsl:value-of select="@icon" /></xsl:if>' +
2465
+ ' </xsl:attribute>' +
2466
+ ' <xsl:if test="string-length(attribute::icon) > 0 and contains(@icon,\'/\')"><xsl:attribute name="style">background:url(<xsl:value-of select="@icon" />) center center no-repeat;</xsl:attribute></xsl:if>' +
2467
+ ' <xsl:text>&#xa0;</xsl:text>' +
2468
+ ' </ins>' +
2469
+ ' <xsl:value-of select="current()" />' +
2470
+ ' </a>' +
2471
+ ' </xsl:for-each>' +
2472
+ ' <xsl:if test="$children or @hasChildren"><xsl:call-template name="nodes"><xsl:with-param name="node" select="current()" /></xsl:call-template></xsl:if>' +
2473
+ ' </li>' +
2474
+ ' </xsl:for-each>' +
2475
+ ' </ul>' +
2476
+ '</xsl:template>' +
2477
+ '</xsl:stylesheet>',
2478
+
2479
+ 'flat' : '<?xml version="1.0" encoding="utf-8" ?>' +
2480
+ '<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >' +
2481
+ '<xsl:output method="html" encoding="utf-8" omit-xml-declaration="yes" standalone="no" indent="no" media-type="text/xml" />' +
2482
+ '<xsl:template match="/">' +
2483
+ ' <ul>' +
2484
+ ' <xsl:for-each select="//item[not(@parent_id) or @parent_id=0 or not(@parent_id = //item/@id)]">' + /* the last `or` may be removed */
2485
+ ' <xsl:call-template name="nodes">' +
2486
+ ' <xsl:with-param name="node" select="." />' +
2487
+ ' <xsl:with-param name="is_last" select="number(position() = last())" />' +
2488
+ ' </xsl:call-template>' +
2489
+ ' </xsl:for-each>' +
2490
+ ' </ul>' +
2491
+ '</xsl:template>' +
2492
+ '<xsl:template name="nodes">' +
2493
+ ' <xsl:param name="node" />' +
2494
+ ' <xsl:param name="is_last" />' +
2495
+ ' <xsl:variable name="children" select="count(//item[@parent_id=$node/attribute::id]) &gt; 0" />' +
2496
+ ' <li>' +
2497
+ ' <xsl:attribute name="class">' +
2498
+ ' <xsl:if test="$is_last = true()">jstree-last </xsl:if>' +
2499
+ ' <xsl:choose>' +
2500
+ ' <xsl:when test="@state = \'open\'">jstree-open </xsl:when>' +
2501
+ ' <xsl:when test="$children or @hasChildren or @state = \'closed\'">jstree-closed </xsl:when>' +
2502
+ ' <xsl:otherwise>jstree-leaf </xsl:otherwise>' +
2503
+ ' </xsl:choose>' +
2504
+ ' <xsl:value-of select="@class" />' +
2505
+ ' </xsl:attribute>' +
2506
+ ' <xsl:for-each select="@*">' +
2507
+ ' <xsl:if test="name() != \'parent_id\' and name() != \'hasChildren\' and name() != \'class\' and name() != \'state\'">' +
2508
+ ' <xsl:attribute name="{name()}"><xsl:value-of select="." /></xsl:attribute>' +
2509
+ ' </xsl:if>' +
2510
+ ' </xsl:for-each>' +
2511
+ ' <ins class="jstree-icon"><xsl:text>&#xa0;</xsl:text></ins>' +
2512
+ ' <xsl:for-each select="content/name">' +
2513
+ ' <a>' +
2514
+ ' <xsl:attribute name="href">' +
2515
+ ' <xsl:choose>' +
2516
+ ' <xsl:when test="@href"><xsl:value-of select="@href" /></xsl:when>' +
2517
+ ' <xsl:otherwise>#</xsl:otherwise>' +
2518
+ ' </xsl:choose>' +
2519
+ ' </xsl:attribute>' +
2520
+ ' <xsl:attribute name="class"><xsl:value-of select="@lang" /> <xsl:value-of select="@class" /></xsl:attribute>' +
2521
+ ' <xsl:attribute name="style"><xsl:value-of select="@style" /></xsl:attribute>' +
2522
+ ' <xsl:for-each select="@*">' +
2523
+ ' <xsl:if test="name() != \'style\' and name() != \'class\' and name() != \'href\'">' +
2524
+ ' <xsl:attribute name="{name()}"><xsl:value-of select="." /></xsl:attribute>' +
2525
+ ' </xsl:if>' +
2526
+ ' </xsl:for-each>' +
2527
+ ' <ins>' +
2528
+ ' <xsl:attribute name="class">jstree-icon ' +
2529
+ ' <xsl:if test="string-length(attribute::icon) > 0 and not(contains(@icon,\'/\'))"><xsl:value-of select="@icon" /></xsl:if>' +
2530
+ ' </xsl:attribute>' +
2531
+ ' <xsl:if test="string-length(attribute::icon) > 0 and contains(@icon,\'/\')"><xsl:attribute name="style">background:url(<xsl:value-of select="@icon" />) center center no-repeat;</xsl:attribute></xsl:if>' +
2532
+ ' <xsl:text>&#xa0;</xsl:text>' +
2533
+ ' </ins>' +
2534
+ ' <xsl:value-of select="current()" />' +
2535
+ ' </a>' +
2536
+ ' </xsl:for-each>' +
2537
+ ' <xsl:if test="$children">' +
2538
+ ' <ul>' +
2539
+ ' <xsl:for-each select="//item[@parent_id=$node/attribute::id]">' +
2540
+ ' <xsl:call-template name="nodes">' +
2541
+ ' <xsl:with-param name="node" select="." />' +
2542
+ ' <xsl:with-param name="is_last" select="number(position() = last())" />' +
2543
+ ' </xsl:call-template>' +
2544
+ ' </xsl:for-each>' +
2545
+ ' </ul>' +
2546
+ ' </xsl:if>' +
2547
+ ' </li>' +
2548
+ '</xsl:template>' +
2549
+ '</xsl:stylesheet>'
2550
+ };
2551
+ $.jstree.plugin("xml_data", {
2552
+ defaults : {
2553
+ data : false,
2554
+ ajax : false,
2555
+ xsl : "flat",
2556
+ clean_node : false,
2557
+ correct_state : true
2558
+ },
2559
+ _fn : {
2560
+ load_node : function (obj, s_call, e_call) { var _this = this; this.load_node_xml(obj, function () { _this.__callback({ "obj" : obj }); s_call.call(this); }, e_call); },
2561
+ _is_loaded : function (obj) {
2562
+ var s = this._get_settings().xml_data;
2563
+ obj = this._get_node(obj);
2564
+ return obj == -1 || !obj || !s.ajax || obj.is(".jstree-open, .jstree-leaf") || obj.children("ul").children("li").size() > 0;
2565
+ },
2566
+ load_node_xml : function (obj, s_call, e_call) {
2567
+ var s = this.get_settings().xml_data,
2568
+ error_func = function () {},
2569
+ success_func = function () {};
2570
+
2571
+ obj = this._get_node(obj);
2572
+ if(obj && obj !== -1) {
2573
+ if(obj.data("jstree-is-loading")) { return; }
2574
+ else { obj.data("jstree-is-loading",true); }
2575
+ }
2576
+ switch(!0) {
2577
+ case (!s.data && !s.ajax): throw "Neither data nor ajax settings supplied.";
2578
+ case (!!s.data && !s.ajax) || (!!s.data && !!s.ajax && (!obj || obj === -1)):
2579
+ if(!obj || obj == -1) {
2580
+ this.parse_xml(s.data, $.proxy(function (d) {
2581
+ if(d) {
2582
+ d = d.replace(/ ?xmlns="[^"]*"/ig, "");
2583
+ if(d.length > 10) {
2584
+ d = $(d);
2585
+ this.get_container().children("ul").empty().append(d.children());
2586
+ if(s.clean_node) { this.clean_node(obj); }
2587
+ if(s_call) { s_call.call(this); }
2588
+ }
2589
+ }
2590
+ else {
2591
+ if(s.correct_state) {
2592
+ this.get_container().children("ul").empty();
2593
+ if(s_call) { s_call.call(this); }
2594
+ }
2595
+ }
2596
+ }, this));
2597
+ }
2598
+ break;
2599
+ case (!s.data && !!s.ajax) || (!!s.data && !!s.ajax && obj && obj !== -1):
2600
+ error_func = function (x, t, e) {
2601
+ var ef = this.get_settings().xml_data.ajax.error;
2602
+ if(ef) { ef.call(this, x, t, e); }
2603
+ if(obj !== -1 && obj.length) {
2604
+ obj.children(".jstree-loading").removeClass("jstree-loading");
2605
+ obj.data("jstree-is-loading",false);
2606
+ if(t === "success" && s.correct_state) { obj.removeClass("jstree-open jstree-closed").addClass("jstree-leaf"); }
2607
+ }
2608
+ else {
2609
+ if(t === "success" && s.correct_state) { this.get_container().children("ul").empty(); }
2610
+ }
2611
+ if(e_call) { e_call.call(this); }
2612
+ };
2613
+ success_func = function (d, t, x) {
2614
+ d = x.responseText;
2615
+ var sf = this.get_settings().xml_data.ajax.success;
2616
+ if(sf) { d = sf.call(this,d,t,x) || d; }
2617
+ if(d == "") {
2618
+ return error_func.call(this, x, t, "");
2619
+ }
2620
+ this.parse_xml(d, $.proxy(function (d) {
2621
+ if(d) {
2622
+ d = d.replace(/ ?xmlns="[^"]*"/ig, "");
2623
+ if(d.length > 10) {
2624
+ d = $(d);
2625
+ if(obj === -1 || !obj) { this.get_container().children("ul").empty().append(d.children()); }
2626
+ else { obj.children(".jstree-loading").removeClass("jstree-loading"); obj.append(d); obj.data("jstree-is-loading",false); }
2627
+ if(s.clean_node) { this.clean_node(obj); }
2628
+ if(s_call) { s_call.call(this); }
2629
+ }
2630
+ else {
2631
+ if(obj && obj !== -1) {
2632
+ obj.children(".jstree-loading").removeClass("jstree-loading");
2633
+ obj.data("jstree-is-loading",false);
2634
+ if(s.correct_state) {
2635
+ obj.removeClass("jstree-open jstree-closed").addClass("jstree-leaf");
2636
+ if(s_call) { s_call.call(this); }
2637
+ }
2638
+ }
2639
+ else {
2640
+ if(s.correct_state) {
2641
+ this.get_container().children("ul").empty();
2642
+ if(s_call) { s_call.call(this); }
2643
+ }
2644
+ }
2645
+ }
2646
+ }
2647
+ }, this));
2648
+ };
2649
+ s.ajax.context = this;
2650
+ s.ajax.error = error_func;
2651
+ s.ajax.success = success_func;
2652
+ if(!s.ajax.dataType) { s.ajax.dataType = "xml"; }
2653
+ if($.isFunction(s.ajax.url)) { s.ajax.url = s.ajax.url.call(this, obj); }
2654
+ if($.isFunction(s.ajax.data)) { s.ajax.data = s.ajax.data.call(this, obj); }
2655
+ $.ajax(s.ajax);
2656
+ break;
2657
+ }
2658
+ },
2659
+ parse_xml : function (xml, callback) {
2660
+ var s = this._get_settings().xml_data;
2661
+ $.vakata.xslt(xml, xsl[s.xsl], callback);
2662
+ },
2663
+ get_xml : function (tp, obj, li_attr, a_attr, is_callback) {
2664
+ var result = "",
2665
+ s = this._get_settings(),
2666
+ _this = this,
2667
+ tmp1, tmp2, li, a, lang;
2668
+ if(!tp) { tp = "flat"; }
2669
+ if(!is_callback) { is_callback = 0; }
2670
+ obj = this._get_node(obj);
2671
+ if(!obj || obj === -1) { obj = this.get_container().find("> ul > li"); }
2672
+ li_attr = $.isArray(li_attr) ? li_attr : [ "id", "class" ];
2673
+ if(!is_callback && this.data.types && $.inArray(s.types.type_attr, li_attr) === -1) { li_attr.push(s.types.type_attr); }
2674
+
2675
+ a_attr = $.isArray(a_attr) ? a_attr : [ ];
2676
+
2677
+ if(!is_callback) { result += "<root>"; }
2678
+ obj.each(function () {
2679
+ result += "<item";
2680
+ li = $(this);
2681
+ $.each(li_attr, function (i, v) { result += " " + v + "=\"" + (li.attr(v) || "").replace(/jstree[^ ]*|$/ig,'').replace(/^\s+$/ig,"") + "\""; });
2682
+ if(li.hasClass("jstree-open")) { result += " state=\"open\""; }
2683
+ if(li.hasClass("jstree-closed")) { result += " state=\"closed\""; }
2684
+ if(tp === "flat") { result += " parent_id=\"" + is_callback + "\""; }
2685
+ result += ">";
2686
+ result += "<content>";
2687
+ a = li.children("a");
2688
+ a.each(function () {
2689
+ tmp1 = $(this);
2690
+ lang = false;
2691
+ result += "<name";
2692
+ if($.inArray("languages", s.plugins) !== -1) {
2693
+ $.each(s.languages, function (k, z) {
2694
+ if(tmp1.hasClass(z)) { result += " lang=\"" + z + "\""; lang = z; return false; }
2695
+ });
2696
+ }
2697
+ if(a_attr.length) {
2698
+ $.each(a_attr, function (k, z) {
2699
+ result += " " + z + "=\"" + (tmp1.attr(z) || "").replace(/jstree[^ ]*|$/ig,'') + "\"";
2700
+ });
2701
+ }
2702
+ if(tmp1.children("ins").get(0).className.replace(/jstree[^ ]*|$/ig,'').replace(/^\s+$/ig,"").length) {
2703
+ result += ' icon="' + tmp1.children("ins").get(0).className.replace(/jstree[^ ]*|$/ig,'').replace(/^\s+$/ig,"") + '"';
2704
+ }
2705
+ if(tmp1.children("ins").get(0).style.backgroundImage.length) {
2706
+ result += ' icon="' + tmp1.children("ins").get(0).style.backgroundImage.replace("url(","").replace(")","") + '"';
2707
+ }
2708
+ result += ">";
2709
+ result += "<![CDATA[" + _this.get_text(tmp1, lang) + "]]>";
2710
+ result += "</name>";
2711
+ });
2712
+ result += "</content>";
2713
+ tmp2 = li[0].id;
2714
+ li = li.find("> ul > li");
2715
+ if(li.length) { tmp2 = _this.get_xml(tp, li, li_attr, a_attr, tmp2); }
2716
+ else { tmp2 = ""; }
2717
+ if(tp == "nest") { result += tmp2; }
2718
+ result += "</item>";
2719
+ if(tp == "flat") { result += tmp2; }
2720
+ });
2721
+ if(!is_callback) { result += "</root>"; }
2722
+ return result;
2723
+ }
2724
+ }
2725
+ });
2726
+ })(jQuery);
2727
+ //*/
2728
+
2729
+
2730
+ /*
2731
+ * jsTree search plugin 1.0
2732
+ * Enables both sync and async search on the tree
2733
+ * DOES NOT WORK WITH JSON PROGRESSIVE RENDER
2734
+ */
2735
+ (function ($) {
2736
+ $.expr[':'].jstree_contains = function(a,i,m){
2737
+ return (a.textContent || a.innerText || "").toLowerCase().indexOf(m[3].toLowerCase())>=0;
2738
+ };
2739
+ $.jstree.plugin("search", {
2740
+ __init : function () {
2741
+ this.data.search.str = "";
2742
+ this.data.search.result = $();
2743
+ },
2744
+ defaults : {
2745
+ ajax : false, // OR ajax object
2746
+ case_insensitive : false
2747
+ },
2748
+ _fn : {
2749
+ search : function (str, skip_async) {
2750
+ if(str === "") { return; }
2751
+ var s = this.get_settings().search,
2752
+ t = this,
2753
+ error_func = function () { },
2754
+ success_func = function () { };
2755
+ this.data.search.str = str;
2756
+
2757
+ if(!skip_async && s.ajax !== false && this.get_container().find(".jstree-closed:eq(0)").length > 0) {
2758
+ this.search.supress_callback = true;
2759
+ error_func = function () { };
2760
+ success_func = function (d, t, x) {
2761
+ var sf = this.get_settings().search.ajax.success;
2762
+ if(sf) { d = sf.call(this,d,t,x) || d; }
2763
+ this.data.search.to_open = d;
2764
+ this._search_open();
2765
+ };
2766
+ s.ajax.context = this;
2767
+ s.ajax.error = error_func;
2768
+ s.ajax.success = success_func;
2769
+ if($.isFunction(s.ajax.url)) { s.ajax.url = s.ajax.url.call(this, str); }
2770
+ if($.isFunction(s.ajax.data)) { s.ajax.data = s.ajax.data.call(this, str); }
2771
+ if(!s.ajax.data) { s.ajax.data = { "search_string" : str }; }
2772
+ if(!s.ajax.dataType || /^json/.exec(s.ajax.dataType)) { s.ajax.dataType = "json"; }
2773
+ $.ajax(s.ajax);
2774
+ return;
2775
+ }
2776
+ if(this.data.search.result.length) { this.clear_search(); }
2777
+ this.data.search.result = this.get_container().find("a" + (this.data.languages ? "." + this.get_lang() : "" ) + ":" + (s.case_insensitive ? "jstree_contains" : "contains") + "(" + this.data.search.str + ")");
2778
+ this.data.search.result.addClass("jstree-search").parents(".jstree-closed").each(function () {
2779
+ t.open_node(this, false, true);
2780
+ });
2781
+ this.__callback({ nodes : this.data.search.result, str : str });
2782
+ },
2783
+ clear_search : function (str) {
2784
+ this.data.search.result.removeClass("jstree-search");
2785
+ this.__callback(this.data.search.result);
2786
+ this.data.search.result = $();
2787
+ },
2788
+ _search_open : function (is_callback) {
2789
+ var _this = this,
2790
+ done = true,
2791
+ current = [],
2792
+ remaining = [];
2793
+ if(this.data.search.to_open.length) {
2794
+ $.each(this.data.search.to_open, function (i, val) {
2795
+ if(val == "#") { return true; }
2796
+ if($(val).length && $(val).is(".jstree-closed")) { current.push(val); }
2797
+ else { remaining.push(val); }
2798
+ });
2799
+ if(current.length) {
2800
+ this.data.search.to_open = remaining;
2801
+ $.each(current, function (i, val) {
2802
+ _this.open_node(val, function () { _this._search_open(true); });
2803
+ });
2804
+ done = false;
2805
+ }
2806
+ }
2807
+ if(done) { this.search(this.data.search.str, true); }
2808
+ }
2809
+ }
2810
+ });
2811
+ })(jQuery);
2812
+ //*/
2813
+
2814
+
2815
+ /*
2816
+ * jsTree contextmenu plugin 1.0
2817
+ */
2818
+ (function ($) {
2819
+ $.vakata.context = {
2820
+ cnt : $("<div id='vakata-contextmenu'>"),
2821
+ vis : false,
2822
+ tgt : false,
2823
+ par : false,
2824
+ func : false,
2825
+ data : false,
2826
+ show : function (s, t, x, y, d, p) {
2827
+ var html = $.vakata.context.parse(s), h, w;
2828
+ if(!html) { return; }
2829
+ $.vakata.context.vis = true;
2830
+ $.vakata.context.tgt = t;
2831
+ $.vakata.context.par = p || t || null;
2832
+ $.vakata.context.data = d || null;
2833
+ $.vakata.context.cnt
2834
+ .html(html)
2835
+ .css({ "visibility" : "hidden", "display" : "block", "left" : 0, "top" : 0 });
2836
+ h = $.vakata.context.cnt.height();
2837
+ w = $.vakata.context.cnt.width();
2838
+ if(x + w > $(document).width()) {
2839
+ x = $(document).width() - (w + 5);
2840
+ $.vakata.context.cnt.find("li > ul").addClass("right");
2841
+ }
2842
+ if(y + h > $(document).height()) {
2843
+ y = y - (h + t[0].offsetHeight);
2844
+ $.vakata.context.cnt.find("li > ul").addClass("bottom");
2845
+ }
2846
+
2847
+ $.vakata.context.cnt
2848
+ .css({ "left" : x, "top" : y })
2849
+ .find("li:has(ul)")
2850
+ .bind("mouseenter", function (e) {
2851
+ var w = $(document).width(),
2852
+ h = $(document).height(),
2853
+ ul = $(this).children("ul").show();
2854
+ if(w !== $(document).width()) { ul.toggleClass("right"); }
2855
+ if(h !== $(document).height()) { ul.toggleClass("bottom"); }
2856
+ })
2857
+ .bind("mouseleave", function (e) {
2858
+ $(this).children("ul").hide();
2859
+ })
2860
+ .end()
2861
+ .css({ "visibility" : "visible" })
2862
+ .show();
2863
+ $(document).triggerHandler("context_show.vakata");
2864
+ },
2865
+ hide : function () {
2866
+ $.vakata.context.vis = false;
2867
+ $.vakata.context.cnt.attr("class","").hide();
2868
+ $(document).triggerHandler("context_hide.vakata");
2869
+ },
2870
+ parse : function (s, is_callback) {
2871
+ if(!s) { return false; }
2872
+ var str = "",
2873
+ tmp = false,
2874
+ was_sep = true;
2875
+ if(!is_callback) { $.vakata.context.func = {}; }
2876
+ str += "<ul>";
2877
+ $.each(s, function (i, val) {
2878
+ if(!val) { return true; }
2879
+ $.vakata.context.func[i] = val.action;
2880
+ if(!was_sep && val.separator_before) {
2881
+ str += "<li class='vakata-separator vakata-separator-before'></li>";
2882
+ }
2883
+ was_sep = false;
2884
+ str += "<li class='" + (val._class || "") + (val._disabled ? " jstree-contextmenu-disabled " : "") + "'><ins ";
2885
+ if(val.icon && val.icon.indexOf("/") === -1) { str += " class='" + val.icon + "' "; }
2886
+ if(val.icon && val.icon.indexOf("/") !== -1) { str += " style='background:url(" + val.icon + ") center center no-repeat;' "; }
2887
+ str += ">&#160;</ins><a href='#' rel='" + i + "'>";
2888
+ if(val.submenu) {
2889
+ str += "<span style='float:right;'>&raquo;</span>";
2890
+ }
2891
+ str += val.label + "</a>";
2892
+ if(val.submenu) {
2893
+ tmp = $.vakata.context.parse(val.submenu, true);
2894
+ if(tmp) { str += tmp; }
2895
+ }
2896
+ str += "</li>";
2897
+ if(val.separator_after) {
2898
+ str += "<li class='vakata-separator vakata-separator-after'></li>";
2899
+ was_sep = true;
2900
+ }
2901
+ });
2902
+ str = str.replace(/<li class\='vakata-separator vakata-separator-after'\><\/li\>$/,"");
2903
+ str += "</ul>";
2904
+ return str.length > 10 ? str : false;
2905
+ },
2906
+ exec : function (i) {
2907
+ if($.isFunction($.vakata.context.func[i])) {
2908
+ $.vakata.context.func[i].call($.vakata.context.data, $.vakata.context.par);
2909
+ return true;
2910
+ }
2911
+ else { return false; }
2912
+ }
2913
+ };
2914
+ $(function () {
2915
+ var css_string = '' +
2916
+ '#vakata-contextmenu { display:none; position:absolute; margin:0; padding:0; min-width:180px; background:#ebebeb; border:1px solid silver; z-index:10000; *width:180px; } ' +
2917
+ '#vakata-contextmenu ul { min-width:180px; *width:180px; } ' +
2918
+ '#vakata-contextmenu ul, #vakata-contextmenu li { margin:0; padding:0; list-style-type:none; display:block; } ' +
2919
+ '#vakata-contextmenu li { line-height:20px; min-height:20px; position:relative; padding:0px; } ' +
2920
+ '#vakata-contextmenu li a { padding:1px 6px; line-height:17px; display:block; text-decoration:none; margin:1px 1px 0 1px; } ' +
2921
+ '#vakata-contextmenu li ins { float:left; width:16px; height:16px; text-decoration:none; margin-right:2px; } ' +
2922
+ '#vakata-contextmenu li a:hover, #vakata-contextmenu li.vakata-hover > a { background:gray; color:white; } ' +
2923
+ '#vakata-contextmenu li ul { display:none; position:absolute; top:-2px; left:100%; background:#ebebeb; border:1px solid gray; } ' +
2924
+ '#vakata-contextmenu .right { right:100%; left:auto; } ' +
2925
+ '#vakata-contextmenu .bottom { bottom:-1px; top:auto; } ' +
2926
+ '#vakata-contextmenu li.vakata-separator { min-height:0; height:1px; line-height:1px; font-size:1px; overflow:hidden; margin:0 2px; background:silver; /* border-top:1px solid #fefefe; */ padding:0; } ';
2927
+ $.vakata.css.add_sheet({ str : css_string });
2928
+ $.vakata.context.cnt
2929
+ .delegate("a","click", function (e) { e.preventDefault(); })
2930
+ .delegate("a","mouseup", function (e) {
2931
+ if(!$(this).parent().hasClass("jstree-contextmenu-disabled") && $.vakata.context.exec($(this).attr("rel"))) {
2932
+ $.vakata.context.hide();
2933
+ }
2934
+ else { $(this).blur(); }
2935
+ })
2936
+ .delegate("a","mouseover", function () {
2937
+ $.vakata.context.cnt.find(".vakata-hover").removeClass("vakata-hover");
2938
+ })
2939
+ .appendTo("body");
2940
+ $(document).bind("mousedown", function (e) { if($.vakata.context.vis && !$.contains($.vakata.context.cnt[0], e.target)) { $.vakata.context.hide(); } });
2941
+ if(typeof $.hotkeys !== "undefined") {
2942
+ $(document)
2943
+ .bind("keydown", "up", function (e) {
2944
+ if($.vakata.context.vis) {
2945
+ var o = $.vakata.context.cnt.find("ul:visible").last().children(".vakata-hover").removeClass("vakata-hover").prevAll("li:not(.vakata-separator)").first();
2946
+ if(!o.length) { o = $.vakata.context.cnt.find("ul:visible").last().children("li:not(.vakata-separator)").last(); }
2947
+ o.addClass("vakata-hover");
2948
+ e.stopImmediatePropagation();
2949
+ e.preventDefault();
2950
+ }
2951
+ })
2952
+ .bind("keydown", "down", function (e) {
2953
+ if($.vakata.context.vis) {
2954
+ var o = $.vakata.context.cnt.find("ul:visible").last().children(".vakata-hover").removeClass("vakata-hover").nextAll("li:not(.vakata-separator)").first();
2955
+ if(!o.length) { o = $.vakata.context.cnt.find("ul:visible").last().children("li:not(.vakata-separator)").first(); }
2956
+ o.addClass("vakata-hover");
2957
+ e.stopImmediatePropagation();
2958
+ e.preventDefault();
2959
+ }
2960
+ })
2961
+ .bind("keydown", "right", function (e) {
2962
+ if($.vakata.context.vis) {
2963
+ $.vakata.context.cnt.find(".vakata-hover").children("ul").show().children("li:not(.vakata-separator)").removeClass("vakata-hover").first().addClass("vakata-hover");
2964
+ e.stopImmediatePropagation();
2965
+ e.preventDefault();
2966
+ }
2967
+ })
2968
+ .bind("keydown", "left", function (e) {
2969
+ if($.vakata.context.vis) {
2970
+ $.vakata.context.cnt.find(".vakata-hover").children("ul").hide().children(".vakata-separator").removeClass("vakata-hover");
2971
+ e.stopImmediatePropagation();
2972
+ e.preventDefault();
2973
+ }
2974
+ })
2975
+ .bind("keydown", "esc", function (e) {
2976
+ $.vakata.context.hide();
2977
+ e.preventDefault();
2978
+ })
2979
+ .bind("keydown", "space", function (e) {
2980
+ $.vakata.context.cnt.find(".vakata-hover").last().children("a").click();
2981
+ e.preventDefault();
2982
+ });
2983
+ }
2984
+ });
2985
+
2986
+ $.jstree.plugin("contextmenu", {
2987
+ __init : function () {
2988
+ this.get_container()
2989
+ .delegate("a", "contextmenu.jstree", $.proxy(function (e) {
2990
+ e.preventDefault();
2991
+ this.show_contextmenu(e.currentTarget, e.pageX, e.pageY);
2992
+ }, this))
2993
+ .bind("destroy.jstree", $.proxy(function () {
2994
+ if(this.data.contextmenu) {
2995
+ $.vakata.context.hide();
2996
+ }
2997
+ }, this));
2998
+ $(document).bind("context_hide.vakata", $.proxy(function () { this.data.contextmenu = false; }, this));
2999
+ },
3000
+ defaults : {
3001
+ select_node : false, // requires UI plugin
3002
+ show_at_node : true,
3003
+ items : { // Could be a function that should return an object like this one
3004
+ "create" : {
3005
+ "separator_before" : false,
3006
+ "separator_after" : true,
3007
+ "label" : "Create",
3008
+ "action" : function (obj) { this.create(obj); }
3009
+ },
3010
+ "rename" : {
3011
+ "separator_before" : false,
3012
+ "separator_after" : false,
3013
+ "label" : "Rename",
3014
+ "action" : function (obj) { this.rename(obj); }
3015
+ },
3016
+ "remove" : {
3017
+ "separator_before" : false,
3018
+ "icon" : false,
3019
+ "separator_after" : false,
3020
+ "label" : "Delete",
3021
+ "action" : function (obj) { this.remove(obj); }
3022
+ },
3023
+ "ccp" : {
3024
+ "separator_before" : true,
3025
+ "icon" : false,
3026
+ "separator_after" : false,
3027
+ "label" : "Edit",
3028
+ "action" : false,
3029
+ "submenu" : {
3030
+ "cut" : {
3031
+ "separator_before" : false,
3032
+ "separator_after" : false,
3033
+ "label" : "Cut",
3034
+ "action" : function (obj) { this.cut(obj); }
3035
+ },
3036
+ "copy" : {
3037
+ "separator_before" : false,
3038
+ "icon" : false,
3039
+ "separator_after" : false,
3040
+ "label" : "Copy",
3041
+ "action" : function (obj) { this.copy(obj); }
3042
+ },
3043
+ "paste" : {
3044
+ "separator_before" : false,
3045
+ "icon" : false,
3046
+ "separator_after" : false,
3047
+ "label" : "Paste",
3048
+ "action" : function (obj) { this.paste(obj); }
3049
+ }
3050
+ }
3051
+ }
3052
+ }
3053
+ },
3054
+ _fn : {
3055
+ show_contextmenu : function (obj, x, y) {
3056
+ obj = this._get_node(obj);
3057
+ var s = this.get_settings().contextmenu,
3058
+ a = obj.children("a:visible:eq(0)"),
3059
+ o = false;
3060
+ if(s.select_node && this.data.ui && !this.is_selected(obj)) {
3061
+ this.deselect_all();
3062
+ this.select_node(obj, true);
3063
+ }
3064
+ if(s.show_at_node || typeof x === "undefined" || typeof y === "undefined") {
3065
+ o = a.offset();
3066
+ x = o.left;
3067
+ y = o.top + this.data.core.li_height;
3068
+ }
3069
+ if($.isFunction(s.items)) { s.items = s.items.call(this, obj); }
3070
+ this.data.contextmenu = true;
3071
+ $.vakata.context.show(s.items, a, x, y, this, obj);
3072
+ if(this.data.themes) { $.vakata.context.cnt.attr("class", "jstree-" + this.data.themes.theme + "-context"); }
3073
+ }
3074
+ }
3075
+ });
3076
+ })(jQuery);
3077
+ //*/
3078
+
3079
+
3080
+ /*
3081
+ * jsTree types plugin 1.0
3082
+ * Adds support types of nodes
3083
+ * You can set an attribute on each li node, that represents its type.
3084
+ * According to the type setting the node may get custom icon/validation rules
3085
+ */
3086
+ (function ($) {
3087
+ $.jstree.plugin("types", {
3088
+ __init : function () {
3089
+ var s = this._get_settings().types;
3090
+ this.data.types.attach_to = [];
3091
+ this.get_container()
3092
+ .bind("init.jstree", $.proxy(function () {
3093
+ var types = s.types,
3094
+ attr = s.type_attr,
3095
+ icons_css = "",
3096
+ _this = this;
3097
+
3098
+ $.each(types, function (i, tp) {
3099
+ $.each(tp, function (k, v) {
3100
+ if(!/^(max_depth|max_children|icon|valid_children)$/.test(k)) { _this.data.types.attach_to.push(k); }
3101
+ });
3102
+ if(!tp.icon) { return true; }
3103
+ if( tp.icon.image || tp.icon.position) {
3104
+ if(i == "default") { icons_css += '.jstree-' + _this.get_index() + ' a > .jstree-icon { '; }
3105
+ else { icons_css += '.jstree-' + _this.get_index() + ' li[' + attr + '=' + i + '] > a > .jstree-icon { '; }
3106
+ if(tp.icon.image) { icons_css += ' background-image:url(' + tp.icon.image + '); '; }
3107
+ if(tp.icon.position){ icons_css += ' background-position:' + tp.icon.position + '; '; }
3108
+ else { icons_css += ' background-position:0 0; '; }
3109
+ icons_css += '} ';
3110
+ }
3111
+ });
3112
+ if(icons_css != "") { $.vakata.css.add_sheet({ 'str' : icons_css }); }
3113
+ }, this))
3114
+ .bind("before.jstree", $.proxy(function (e, data) {
3115
+ if($.inArray(data.func, this.data.types.attach_to) !== -1) {
3116
+ var s = this._get_settings().types.types,
3117
+ t = this._get_type(data.args[0]);
3118
+ if(
3119
+ (
3120
+ (s[t] && typeof s[t][data.func] !== "undefined") ||
3121
+ (s["default"] && typeof s["default"][data.func] !== "undefined")
3122
+ ) && !this._check(data.func, data.args[0])
3123
+ ) {
3124
+ e.stopImmediatePropagation();
3125
+ return false;
3126
+ }
3127
+ }
3128
+ }, this));
3129
+ },
3130
+ defaults : {
3131
+ // defines maximum number of root nodes (-1 means unlimited, -2 means disable max_children checking)
3132
+ max_children : -1,
3133
+ // defines the maximum depth of the tree (-1 means unlimited, -2 means disable max_depth checking)
3134
+ max_depth : -1,
3135
+ // defines valid node types for the root nodes
3136
+ valid_children : "all",
3137
+
3138
+ // where is the type stores (the rel attribute of the LI element)
3139
+ type_attr : "rel",
3140
+ // a list of types
3141
+ types : {
3142
+ // the default type
3143
+ "default" : {
3144
+ "max_children" : -1,
3145
+ "max_depth" : -1,
3146
+ "valid_children": "all"
3147
+
3148
+ // Bound functions - you can bind any other function here (using boolean or function)
3149
+ //"select_node" : true,
3150
+ //"open_node" : true,
3151
+ //"close_node" : true,
3152
+ //"create_node" : true,
3153
+ //"delete_node" : true
3154
+ }
3155
+ }
3156
+ },
3157
+ _fn : {
3158
+ _get_type : function (obj) {
3159
+ obj = this._get_node(obj);
3160
+ return (!obj || !obj.length) ? false : obj.attr(this._get_settings().types.type_attr) || "default";
3161
+ },
3162
+ set_type : function (str, obj) {
3163
+ obj = this._get_node(obj);
3164
+ return (!obj.length || !str) ? false : obj.attr(this._get_settings().types.type_attr, str);
3165
+ },
3166
+ _check : function (rule, obj, opts) {
3167
+ var v = false, t = this._get_type(obj), d = 0, _this = this, s = this._get_settings().types;
3168
+ if(obj === -1) {
3169
+ if(!!s[rule]) { v = s[rule]; }
3170
+ else { return; }
3171
+ }
3172
+ else {
3173
+ if(t === false) { return; }
3174
+ if(!!s.types[t] && !!s.types[t][rule]) { v = s.types[t][rule]; }
3175
+ else if(!!s.types["default"] && !!s.types["default"][rule]) { v = s.types["default"][rule]; }
3176
+ }
3177
+ if($.isFunction(v)) { v = v.call(this, obj); }
3178
+ if(rule === "max_depth" && obj !== -1 && opts !== false && s.max_depth !== -2 && v !== 0) {
3179
+ // also include the node itself - otherwise if root node it is not checked
3180
+ this._get_node(obj).children("a:eq(0)").parentsUntil(".jstree","li").each(function (i) {
3181
+ // check if current depth already exceeds global tree depth
3182
+ if(s.max_depth !== -1 && s.max_depth - (i + 1) <= 0) { v = 0; return false; }
3183
+ d = (i === 0) ? v : _this._check(rule, this, false);
3184
+ // check if current node max depth is already matched or exceeded
3185
+ if(d !== -1 && d - (i + 1) <= 0) { v = 0; return false; }
3186
+ // otherwise - set the max depth to the current value minus current depth
3187
+ if(d >= 0 && (d - (i + 1) < v || v < 0) ) { v = d - (i + 1); }
3188
+ // if the global tree depth exists and it minus the nodes calculated so far is less than `v` or `v` is unlimited
3189
+ if(s.max_depth >= 0 && (s.max_depth - (i + 1) < v || v < 0) ) { v = s.max_depth - (i + 1); }
3190
+ });
3191
+ }
3192
+ return v;
3193
+ },
3194
+ check_move : function () {
3195
+ if(!this.__call_old()) { return false; }
3196
+ var m = this._get_move(),
3197
+ s = m.rt._get_settings().types,
3198
+ mc = m.rt._check("max_children", m.cr),
3199
+ md = m.rt._check("max_depth", m.cr),
3200
+ vc = m.rt._check("valid_children", m.cr),
3201
+ ch = 0, d = 1, t;
3202
+
3203
+ if(vc === "none") { return false; }
3204
+ if($.isArray(vc) && m.ot && m.ot._get_type) {
3205
+ m.o.each(function () {
3206
+ if($.inArray(m.ot._get_type(this), vc) === -1) { d = false; return false; }
3207
+ });
3208
+ if(d === false) { return false; }
3209
+ }
3210
+ if(s.max_children !== -2 && mc !== -1) {
3211
+ ch = m.cr === -1 ? this.get_container().children("> ul > li").not(m.o).length : m.cr.children("> ul > li").not(m.o).length;
3212
+ if(ch + m.o.length > mc) { return false; }
3213
+ }
3214
+ if(s.max_depth !== -2 && md !== -1) {
3215
+ d = 0;
3216
+ if(md === 0) { return false; }
3217
+ if(typeof m.o.d === "undefined") {
3218
+ // TODO: deal with progressive rendering and async when checking max_depth (how to know the depth of the moved node)
3219
+ t = m.o;
3220
+ while(t.length > 0) {
3221
+ t = t.find("> ul > li");
3222
+ d ++;
3223
+ }
3224
+ m.o.d = d;
3225
+ }
3226
+ if(md - m.o.d < 0) { return false; }
3227
+ }
3228
+ return true;
3229
+ },
3230
+ create_node : function (obj, position, js, callback, is_loaded, skip_check) {
3231
+ if(!skip_check && (is_loaded || this._is_loaded(obj))) {
3232
+ var p = (position && position.match(/^before|after$/i) && obj !== -1) ? this._get_parent(obj) : this._get_node(obj),
3233
+ s = this._get_settings().types,
3234
+ mc = this._check("max_children", p),
3235
+ md = this._check("max_depth", p),
3236
+ vc = this._check("valid_children", p),
3237
+ ch;
3238
+ if(!js) { js = {}; }
3239
+ if(vc === "none") { return false; }
3240
+ if($.isArray(vc)) {
3241
+ if(!js.attr || !js.attr[s.type_attr]) {
3242
+ if(!js.attr) { js.attr = {}; }
3243
+ js.attr[s.type_attr] = vc[0];
3244
+ }
3245
+ else {
3246
+ if($.inArray(js.attr[s.type_attr], vc) === -1) { return false; }
3247
+ }
3248
+ }
3249
+ if(s.max_children !== -2 && mc !== -1) {
3250
+ ch = p === -1 ? this.get_container().children("> ul > li").length : p.children("> ul > li").length;
3251
+ if(ch + 1 > mc) { return false; }
3252
+ }
3253
+ if(s.max_depth !== -2 && md !== -1 && (md - 1) < 0) { return false; }
3254
+ }
3255
+ return this.__call_old(true, obj, position, js, callback, is_loaded, skip_check);
3256
+ }
3257
+ }
3258
+ });
3259
+ })(jQuery);
3260
+ //*/
3261
+
3262
+
3263
+ /*
3264
+ * jsTree HTML data 1.0
3265
+ * The HTML data store. Datastores are build by replacing the `load_node` and `_is_loaded` functions.
3266
+ */
3267
+ (function ($) {
3268
+ $.jstree.plugin("html_data", {
3269
+ __init : function () {
3270
+ // this used to use html() and clean the whitespace, but this way any attached data was lost
3271
+ this.data.html_data.original_container_html = this.get_container().find(" > ul > li").clone(true);
3272
+ // remove white space from LI node - otherwise nodes appear a bit to the right
3273
+ this.data.html_data.original_container_html.find("li").andSelf().contents().filter(function() { return this.nodeType == 3; }).remove();
3274
+ },
3275
+ defaults : {
3276
+ data : false,
3277
+ ajax : false,
3278
+ correct_state : true
3279
+ },
3280
+ _fn : {
3281
+ load_node : function (obj, s_call, e_call) { var _this = this; this.load_node_html(obj, function () { _this.__callback({ "obj" : obj }); s_call.call(this); }, e_call); },
3282
+ _is_loaded : function (obj) {
3283
+ obj = this._get_node(obj);
3284
+ return obj == -1 || !obj || !this._get_settings().html_data.ajax || obj.is(".jstree-open, .jstree-leaf") || obj.children("ul").children("li").size() > 0;
3285
+ },
3286
+ load_node_html : function (obj, s_call, e_call) {
3287
+ var d,
3288
+ s = this.get_settings().html_data,
3289
+ error_func = function () {},
3290
+ success_func = function () {};
3291
+ obj = this._get_node(obj);
3292
+ if(obj && obj !== -1) {
3293
+ if(obj.data("jstree-is-loading")) { return; }
3294
+ else { obj.data("jstree-is-loading",true); }
3295
+ }
3296
+ switch(!0) {
3297
+ case (!s.data && !s.ajax):
3298
+ if(!obj || obj == -1) {
3299
+ this.get_container()
3300
+ .children("ul").empty()
3301
+ .append(this.data.html_data.original_container_html)
3302
+ .find("li, a").filter(function () { return this.firstChild.tagName !== "INS"; }).prepend("<ins class='jstree-icon'>&#160;</ins>").end()
3303
+ .filter("a").children("ins:first-child").not(".jstree-icon").addClass("jstree-icon");
3304
+ this.clean_node();
3305
+ }
3306
+ if(s_call) { s_call.call(this); }
3307
+ break;
3308
+ case (!!s.data && !s.ajax) || (!!s.data && !!s.ajax && (!obj || obj === -1)):
3309
+ if(!obj || obj == -1) {
3310
+ d = $(s.data);
3311
+ if(!d.is("ul")) { d = $("<ul>").append(d); }
3312
+ this.get_container()
3313
+ .children("ul").empty().append(d.children())
3314
+ .find("li, a").filter(function () { return this.firstChild.tagName !== "INS"; }).prepend("<ins class='jstree-icon'>&#160;</ins>").end()
3315
+ .filter("a").children("ins:first-child").not(".jstree-icon").addClass("jstree-icon");
3316
+ this.clean_node();
3317
+ }
3318
+ if(s_call) { s_call.call(this); }
3319
+ break;
3320
+ case (!s.data && !!s.ajax) || (!!s.data && !!s.ajax && obj && obj !== -1):
3321
+ obj = this._get_node(obj);
3322
+ error_func = function (x, t, e) {
3323
+ var ef = this.get_settings().html_data.ajax.error;
3324
+ if(ef) { ef.call(this, x, t, e); }
3325
+ if(obj != -1 && obj.length) {
3326
+ obj.children(".jstree-loading").removeClass("jstree-loading");
3327
+ obj.data("jstree-is-loading",false);
3328
+ if(t === "success" && s.correct_state) { obj.removeClass("jstree-open jstree-closed").addClass("jstree-leaf"); }
3329
+ }
3330
+ else {
3331
+ if(t === "success" && s.correct_state) { this.get_container().children("ul").empty(); }
3332
+ }
3333
+ if(e_call) { e_call.call(this); }
3334
+ };
3335
+ success_func = function (d, t, x) {
3336
+ var sf = this.get_settings().html_data.ajax.success;
3337
+ if(sf) { d = sf.call(this,d,t,x) || d; }
3338
+ if(d == "") {
3339
+ return error_func.call(this, x, t, "");
3340
+ }
3341
+ if(d) {
3342
+ d = $(d);
3343
+ if(!d.is("ul")) { d = $("<ul>").append(d); }
3344
+ if(obj == -1 || !obj) { this.get_container().children("ul").empty().append(d.children()).find("li, a").filter(function () { return this.firstChild.tagName !== "INS"; }).prepend("<ins class='jstree-icon'>&#160;</ins>").end().filter("a").children("ins:first-child").not(".jstree-icon").addClass("jstree-icon"); }
3345
+ else { obj.children(".jstree-loading").removeClass("jstree-loading"); obj.append(d).find("li, a").filter(function () { return this.firstChild.tagName !== "INS"; }).prepend("<ins class='jstree-icon'>&#160;</ins>").end().filter("a").children("ins:first-child").not(".jstree-icon").addClass("jstree-icon"); obj.data("jstree-is-loading",false); }
3346
+ this.clean_node(obj);
3347
+ if(s_call) { s_call.call(this); }
3348
+ }
3349
+ else {
3350
+ if(obj && obj !== -1) {
3351
+ obj.children(".jstree-loading").removeClass("jstree-loading");
3352
+ obj.data("jstree-is-loading",false);
3353
+ if(s.correct_state) {
3354
+ obj.removeClass("jstree-open jstree-closed").addClass("jstree-leaf");
3355
+ if(s_call) { s_call.call(this); }
3356
+ }
3357
+ }
3358
+ else {
3359
+ if(s.correct_state) {
3360
+ this.get_container().children("ul").empty();
3361
+ if(s_call) { s_call.call(this); }
3362
+ }
3363
+ }
3364
+ }
3365
+ };
3366
+ s.ajax.context = this;
3367
+ s.ajax.error = error_func;
3368
+ s.ajax.success = success_func;
3369
+ if(!s.ajax.dataType) { s.ajax.dataType = "html"; }
3370
+ if($.isFunction(s.ajax.url)) { s.ajax.url = s.ajax.url.call(this, obj); }
3371
+ if($.isFunction(s.ajax.data)) { s.ajax.data = s.ajax.data.call(this, obj); }
3372
+ $.ajax(s.ajax);
3373
+ break;
3374
+ }
3375
+ }
3376
+ }
3377
+ });
3378
+ // include the HTML data plugin by default
3379
+ $.jstree.defaults.plugins.push("html_data");
3380
+ })(jQuery);
3381
+ //*/
3382
+
3383
+
3384
+ /*
3385
+ * jsTree themeroller plugin 1.0
3386
+ * Adds support for jQuery UI themes. Include this at the end of your plugins list, also make sure "themes" is not included.
3387
+ */
3388
+ (function ($) {
3389
+ $.jstree.plugin("themeroller", {
3390
+ __init : function () {
3391
+ var s = this._get_settings().themeroller;
3392
+ this.get_container()
3393
+ .addClass("ui-widget-content")
3394
+ .delegate("a","mouseenter.jstree", function () {
3395
+ $(this).addClass(s.item_h);
3396
+ })
3397
+ .delegate("a","mouseleave.jstree", function () {
3398
+ $(this).removeClass(s.item_h);
3399
+ })
3400
+ .bind("open_node.jstree create_node.jstree", $.proxy(function (e, data) {
3401
+ this._themeroller(data.rslt.obj);
3402
+ }, this))
3403
+ .bind("loaded.jstree refresh.jstree", $.proxy(function (e) {
3404
+ this._themeroller();
3405
+ }, this))
3406
+ .bind("close_node.jstree", $.proxy(function (e, data) {
3407
+ data.rslt.obj.children("ins").removeClass(s.opened).addClass(s.closed);
3408
+ }, this))
3409
+ .bind("select_node.jstree", $.proxy(function (e, data) {
3410
+ data.rslt.obj.children("a").addClass(s.item_a);
3411
+ }, this))
3412
+ .bind("deselect_node.jstree deselect_all.jstree", $.proxy(function (e, data) {
3413
+ this.get_container()
3414
+ .find("." + s.item_a).removeClass(s.item_a).end()
3415
+ .find(".jstree-clicked").addClass(s.item_a);
3416
+ }, this))
3417
+ .bind("move_node.jstree", $.proxy(function (e, data) {
3418
+ this._themeroller(data.rslt.o);
3419
+ }, this));
3420
+ },
3421
+ __destroy : function () {
3422
+ var s = this._get_settings().themeroller,
3423
+ c = [ "ui-icon" ];
3424
+ $.each(s, function (i, v) {
3425
+ v = v.split(" ");
3426
+ if(v.length) { c = c.concat(v); }
3427
+ });
3428
+ this.get_container()
3429
+ .removeClass("ui-widget-content")
3430
+ .find("." + c.join(", .")).removeClass(c.join(" "));
3431
+ },
3432
+ _fn : {
3433
+ _themeroller : function (obj) {
3434
+ var s = this._get_settings().themeroller;
3435
+ obj = !obj || obj == -1 ? this.get_container() : this._get_node(obj).parent();
3436
+ obj
3437
+ .find("li.jstree-closed > ins.jstree-icon").removeClass(s.opened).addClass("ui-icon " + s.closed).end()
3438
+ .find("li.jstree-open > ins.jstree-icon").removeClass(s.closed).addClass("ui-icon " + s.opened).end()
3439
+ .find("a").addClass(s.item)
3440
+ .children("ins.jstree-icon").addClass("ui-icon " + s.item_icon);
3441
+ }
3442
+ },
3443
+ defaults : {
3444
+ "opened" : "ui-icon-triangle-1-se",
3445
+ "closed" : "ui-icon-triangle-1-e",
3446
+ "item" : "ui-state-default",
3447
+ "item_h" : "ui-state-hover",
3448
+ "item_a" : "ui-state-active",
3449
+ "item_icon" : "ui-icon-folder-collapsed"
3450
+ }
3451
+ });
3452
+ $(function() {
3453
+ var css_string = '.jstree .ui-icon { overflow:visible; } .jstree a { padding:0 2px; }';
3454
+ $.vakata.css.add_sheet({ str : css_string });
3455
+ });
3456
+ })(jQuery);
3457
+ //*/
3458
+
3459
+
3460
+ /*
3461
+ * jsTree unique plugin 1.0
3462
+ * Forces different names amongst siblings (still a bit experimental)
3463
+ * NOTE: does not check language versions (it will not be possible to have nodes with the same title, even in different languages)
3464
+ */
3465
+ (function ($) {
3466
+ $.jstree.plugin("unique", {
3467
+ __init : function () {
3468
+ this.get_container()
3469
+ .bind("before.jstree", $.proxy(function (e, data) {
3470
+ var nms = [], res = true, p, t;
3471
+ if(data.func == "move_node") {
3472
+ // obj, ref, position, is_copy, is_prepared, skip_check
3473
+ if(data.args[4] === true) {
3474
+ if(data.args[0].o && data.args[0].o.length) {
3475
+ data.args[0].o.children("a").each(function () { nms.push($(this).text().replace(/^\s+/g,"")); });
3476
+ res = this._check_unique(nms, data.args[0].np.find("> ul > li").not(data.args[0].o));
3477
+ }
3478
+ }
3479
+ }
3480
+ if(data.func == "create_node") {
3481
+ // obj, position, js, callback, is_loaded
3482
+ if(data.args[4] || this._is_loaded(data.args[0])) {
3483
+ p = this._get_node(data.args[0]);
3484
+ if(data.args[1] && (data.args[1] === "before" || data.args[1] === "after")) {
3485
+ p = this._get_parent(data.args[0]);
3486
+ if(!p || p === -1) { p = this.get_container(); }
3487
+ }
3488
+ if(typeof data.args[2] === "string") { nms.push(data.args[2]); }
3489
+ else if(!data.args[2] || !data.args[2].data) { nms.push(this._get_settings().core.strings.new_node); }
3490
+ else { nms.push(data.args[2].data); }
3491
+ res = this._check_unique(nms, p.find("> ul > li"));
3492
+ }
3493
+ }
3494
+ if(data.func == "rename_node") {
3495
+ // obj, val
3496
+ nms.push(data.args[1]);
3497
+ t = this._get_node(data.args[0]);
3498
+ p = this._get_parent(t);
3499
+ if(!p || p === -1) { p = this.get_container(); }
3500
+ res = this._check_unique(nms, p.find("> ul > li").not(t));
3501
+ }
3502
+ if(!res) {
3503
+ e.stopPropagation();
3504
+ return false;
3505
+ }
3506
+ }, this));
3507
+ },
3508
+ _fn : {
3509
+ _check_unique : function (nms, p) {
3510
+ var cnms = [];
3511
+ p.children("a").each(function () { cnms.push($(this).text().replace(/^\s+/g,"")); });
3512
+ if(!cnms.length || !nms.length) { return true; }
3513
+ cnms = cnms.sort().join(",,").replace(/(,|^)([^,]+)(,,\2)+(,|$)/g,"$1$2$4").replace(/,,+/g,",").replace(/,$/,"").split(",");
3514
+ if((cnms.length + nms.length) != cnms.concat(nms).sort().join(",,").replace(/(,|^)([^,]+)(,,\2)+(,|$)/g,"$1$2$4").replace(/,,+/g,",").replace(/,$/,"").split(",").length) {
3515
+ return false;
3516
+ }
3517
+ return true;
3518
+ },
3519
+ check_move : function () {
3520
+ if(!this.__call_old()) { return false; }
3521
+ var p = this._get_move(), nms = [];
3522
+ if(p.o && p.o.length) {
3523
+ p.o.children("a").each(function () { nms.push($(this).text().replace(/^\s+/g,"")); });
3524
+ return this._check_unique(nms, p.np.find("> ul > li").not(p.o));
3525
+ }
3526
+ return true;
3527
+ }
3528
+ }
3529
+ });
3530
+ })(jQuery);
3531
+ //*/
3532
+
3533
+
3534
+ /*
3535
+ * jsTree radio plugin 1.0
3536
+ * Inserts radios in front of every node
3537
+ * Depends on the ui plugin
3538
+ * DOES NOT WORK NICELY WITH MULTITREE DRAG'N'DROP
3539
+ */
3540
+ (function ($) {
3541
+ $.jstree.plugin("radio", {
3542
+ __init : function () {
3543
+ this.select_node = this.deselect_node = this.deselect_all = $.noop;
3544
+ this.get_selected = this.get_checked;
3545
+
3546
+ this.get_container()
3547
+ .bind("open_node.jstree create_node.jstree clean_node.jstree", $.proxy(function (e, data) {
3548
+ this._prepare_radios(data.rslt.obj);
3549
+ }, this))
3550
+ .bind("loaded.jstree", $.proxy(function (e) {
3551
+ this._prepare_radios();
3552
+ }, this))
3553
+ .delegate("a", "click.jstree", $.proxy(function (e) {
3554
+ if(this._get_node(e.target).hasClass("jstree-checked")) { this.uncheck_node(e.target); }
3555
+ else { this.check_node(e.target); }
3556
+ if(this.data.ui) { this.save_selected(); }
3557
+ if(this.data.cookies) { this.save_cookie("select_node"); }
3558
+ e.preventDefault();
3559
+ }, this));
3560
+ },
3561
+ __destroy : function () {
3562
+ this.get_container().find(".jstree-radio").remove();
3563
+ },
3564
+ _fn : {
3565
+ _prepare_radios : function (obj) {
3566
+ obj = !obj || obj == -1 ? this.get_container() : this._get_node(obj);
3567
+ var c, _this = this, t;
3568
+ obj.each(function () {
3569
+ t = $(this);
3570
+ c = t.is("li") && t.hasClass("jstree-checked") ? "jstree-checked" : "jstree-unchecked";
3571
+ t.find("a").not(":has(.jstree-radio)").prepend("<ins class='jstree-radio'>&#160;</ins>").parent().not(".jstree-checked, .jstree-unchecked").addClass(c);
3572
+ });
3573
+ if(obj.is("li")) { this._repair_state(obj); }
3574
+ else { obj.find("> ul > li").each(function () { _this._repair_state(this); }); }
3575
+ },
3576
+ change_state : function (obj, state) {
3577
+ obj = this._get_node(obj);
3578
+ if (obj.is(".jstree-leaf")) {
3579
+ state = (state === false || state === true) ? state : obj.hasClass("jstree-checked");
3580
+
3581
+ if(state) { obj.find("li").andSelf().removeClass("jstree-checked jstree-undetermined").addClass("jstree-unchecked"); }
3582
+ else {
3583
+ obj.parent().children(".jstree-checked").removeClass("jstree-checked").addClass("jstree-unchecked");
3584
+ obj.find("li").andSelf().removeClass("jstree-unchecked jstree-undetermined").addClass("jstree-checked");
3585
+ if(this.data.ui) { this.data.ui.last_selected = obj; }
3586
+ this.data.radio.last_selected = obj;
3587
+ }
3588
+ obj.parentsUntil(".jstree", "li").each(function () {
3589
+ var $this = $(this);
3590
+ if (state) {
3591
+ if ($this.children("ul").children(".jstree-checked, .jstree-undetermined").length) {
3592
+ $this.parentsUntil(".jstree", "li").andSelf().removeClass("jstree-checked jstree-unchecked").addClass("jstree-undetermined");
3593
+ return false;
3594
+ }
3595
+ else {
3596
+ $this.removeClass("jstree-checked jstree-undetermined").addClass("jstree-unchecked");
3597
+ }
3598
+ }
3599
+ else {
3600
+ $this.parentsUntil(".jstree", "li").andSelf().removeClass("jstree-checked jstree-unchecked").addClass("jstree-undetermined");
3601
+ return false;
3602
+ }
3603
+ });
3604
+ if(this.data.ui) { this.data.ui.selected = this.get_checked(); }
3605
+ this.__callback(obj);
3606
+ }
3607
+ },
3608
+ check_node : function (obj) {
3609
+ this.change_state(obj, false);
3610
+ },
3611
+ uncheck_node : function (obj) {
3612
+ this.change_state(obj, true);
3613
+ },
3614
+ uncheck_all : function () {
3615
+ var _this = this;
3616
+ this.get_container().children("ul").children("li").each(function () {
3617
+ _this.change_state(this, true);
3618
+ });
3619
+ },
3620
+
3621
+ is_checked : function(obj) {
3622
+ obj = this._get_node(obj);
3623
+ return obj.length ? obj.is(".jstree-checked") : false;
3624
+ },
3625
+ get_checked : function (obj) {
3626
+ obj = !obj || obj === -1 ? this.get_container() : this._get_node(obj);
3627
+ return obj.find("> ul > .jstree-checked, .jstree-undetermined > ul > .jstree-checked");
3628
+ },
3629
+ get_unchecked : function (obj) {
3630
+ obj = !obj || obj === -1 ? this.get_container() : this._get_node(obj);
3631
+ return obj.find("> ul > .jstree-unchecked, .jstree-undetermined > ul > .jstree-unchecked");
3632
+ },
3633
+
3634
+ show_radios : function () { this.get_container().children("ul").removeClass("jstree-no-radios"); },
3635
+ hide_radios : function () { this.get_container().children("ul").addClass("jstree-no-radios"); },
3636
+
3637
+ _repair_state : function (obj) {
3638
+ obj = this._get_node(obj);
3639
+ if(!obj.length) { return; }
3640
+ var a = obj.find("> ul > .jstree-checked").length,
3641
+ b = obj.find("> ul > .jstree-undetermined").length,
3642
+ c = obj.find("> ul > li").length;
3643
+
3644
+ if(c === 0) { if(obj.hasClass("jstree-undetermined")) { this.check_node(obj); } }
3645
+ else if(a === 0 && b === 0) { this.uncheck_node(obj); }
3646
+ else if(a === c) { this.check_node(obj); }
3647
+ else {
3648
+ obj.parentsUntil(".jstree","li").removeClass("jstree-checked jstree-unchecked").addClass("jstree-undetermined");
3649
+ }
3650
+ },
3651
+ reselect : function () {
3652
+ if(this.data.ui) {
3653
+ var _this = this,
3654
+ s = this.data.ui.to_select;
3655
+ s = $.map($.makeArray(s), function (n) { return "#" + n.toString().replace(/^#/,"").replace('\\/','/').replace('/','\\/'); });
3656
+ this.deselect_all();
3657
+ $.each(s, function (i, val) { _this.check_node(val); });
3658
+ this.__callback();
3659
+ }
3660
+ }
3661
+ }
3662
+ });
3663
+ })(jQuery);
3664
+ //*/