CMS Tree Page View - Version 1.6.2

Version Description

(December 2020) =

Please create Issues for any jQuery deprecations (or other issues) you come across!

  • Fixes a number of jQuery deprecations
Download this release

Release Info

Developer jchristopher
Plugin Icon wp plugin CMS Tree Page View
Version 1.6.2
Comparing to
See all releases

Code changes from version 1.6.1 to 1.6.2

functions.php CHANGED
@@ -749,6 +749,7 @@ function cms_tpv_options() {
749
  continue;
750
  }
751
 
 
752
  $name = $one_post_type->name;
753
 
754
  if ($name === "post") {
@@ -801,7 +802,7 @@ function cms_tpv_options() {
801
  <input type="hidden" name="action" value="update" />
802
  <input type="hidden" name="cms_tpv_action" value="save_settings" />
803
  <?php // TODO: why is the line below needed? gives deprecated errors ?>
804
- <input type="hidden" name="page_options" value="<?php echo join($arr_page_options, ",") ?>" />
805
  <p class="submit">
806
  <input type="submit" class="button-primary" value="<?php _e('Save Changes', 'cms-tree-page-view') ?>" />
807
  </p>
749
  continue;
750
  }
751
 
752
+
753
  $name = $one_post_type->name;
754
 
755
  if ($name === "post") {
802
  <input type="hidden" name="action" value="update" />
803
  <input type="hidden" name="cms_tpv_action" value="save_settings" />
804
  <?php // TODO: why is the line below needed? gives deprecated errors ?>
805
+ <input type="hidden" name="page_options" value="<?php echo esc_attr( implode( ',', $arr_page_options ) ); ?>" />
806
  <p class="submit">
807
  <input type="submit" class="button-primary" value="<?php _e('Save Changes', 'cms-tree-page-view') ?>" />
808
  </p>
index.php CHANGED
@@ -5,7 +5,7 @@ Plugin URI: https://github.com/jchristopher/cms-tree-page-view
5
  Description: Adds a CMS-like tree view of all your pages, like the view often found in a page-focused CMS. Use the tree view to edit, view, add pages and search pages (very useful if you have many pages). And with drag and drop you can rearrange the order of your pages. Page management won't get any easier than this!
6
  Text Domain: cms-tree-page-view
7
  Domain Path: /languages/
8
- Version: 1.6.1
9
  Author: Jon Christopher
10
  Author URI: https://jonchristopher.us/
11
  License: GPL2
@@ -29,7 +29,7 @@ License: GPL2
29
 
30
  #require("functions.php");
31
 
32
- define( "CMS_TPV_VERSION", "1.6.1");
33
  define( "CMS_TPV_NAME", "CMS Tree Page View");
34
 
35
  require(dirname(__FILE__) . "/functions.php");
5
  Description: Adds a CMS-like tree view of all your pages, like the view often found in a page-focused CMS. Use the tree view to edit, view, add pages and search pages (very useful if you have many pages). And with drag and drop you can rearrange the order of your pages. Page management won't get any easier than this!
6
  Text Domain: cms-tree-page-view
7
  Domain Path: /languages/
8
+ Version: 1.6.2
9
  Author: Jon Christopher
10
  Author URI: https://jonchristopher.us/
11
  License: GPL2
29
 
30
  #require("functions.php");
31
 
32
+ define( "CMS_TPV_VERSION", "1.6.2");
33
  define( "CMS_TPV_NAME", "CMS Tree Page View");
34
 
35
  require(dirname(__FILE__) . "/functions.php");
readme.txt CHANGED
@@ -4,8 +4,8 @@ Donate link: http://eskapism.se/sida/donate/
4
  Tags: page, pages, posts, custom posts, tree, cms, dashboard, overview, drag-and-drop, rearrange, management, manage, admin
5
  Text Domain: cms-tree-page-view
6
  Requires at least: 3.8
7
- Tested up to: 5.4.2
8
- Stable tag: 1.6.1
9
 
10
  Adds a tree view of all pages & custom posts. Get a great overview + options to drag & drop to reorder & option to add multiple pages.
11
 
@@ -116,6 +116,12 @@ Now the tree with the pages will be visible both on the dashboard and in the men
116
 
117
  == Changelog ==
118
 
 
 
 
 
 
 
119
  = 1.6.1 (July 2020) =
120
 
121
  CMS Tree Page View has been adopted by [Jon Christopher](https://jonchristopher.us/blog/cms-tree-page-view-has-been-adopted-by-me/)! Please read the [announcement post](https://jonchristopher.us/blog/cms-tree-page-view-has-been-adopted-by-me/) for more information and ways to provide feedback.
4
  Tags: page, pages, posts, custom posts, tree, cms, dashboard, overview, drag-and-drop, rearrange, management, manage, admin
5
  Text Domain: cms-tree-page-view
6
  Requires at least: 3.8
7
+ Tested up to: 5.6.0
8
+ Stable tag: 1.6.2
9
 
10
  Adds a tree view of all pages & custom posts. Get a great overview + options to drag & drop to reorder & option to add multiple pages.
11
 
116
 
117
  == Changelog ==
118
 
119
+ = 1.6.2 (December 2020) =
120
+
121
+ Please [create Issues](https://github.com/jchristopher/cms-tree-page-view/issues) for any jQuery deprecations (or other issues) you come across!
122
+
123
+ - Fixes a number of jQuery deprecations
124
+
125
  = 1.6.1 (July 2020) =
126
 
127
  CMS Tree Page View has been adopted by [Jon Christopher](https://jonchristopher.us/blog/cms-tree-page-view-has-been-adopted-by-me/)! Please read the [announcement post](https://jonchristopher.us/blog/cms-tree-page-view-has-been-adopted-by-me/) for more information and ways to provide feedback.
scripts/cms_tree_page_view.js CHANGED
@@ -279,7 +279,7 @@ jQuery(function($) {
279
  // set search url to include post type
280
  treeOptionsTmp.search.ajax.url = ajaxurl + CMS_TPV_AJAXURL + CMS_TPV_VIEW + '&cms-tpv-nonce=' + window.CMS_TPV_NONCE + "&post_type=" + cms_tpv_get_post_type(this);
281
 
282
- $elm.bind("search.jstree", function (event, data) {
283
  if (data.rslt.nodes.length === 0) {
284
  // no hits. doh.
285
  $(this).closest(".cms_tpv_wrapper").find(".cms_tree_view_search_form_no_hits").fadeIn("fast");
@@ -287,7 +287,7 @@ jQuery(function($) {
287
  });
288
 
289
  // whole tre loaded
290
- $elm.bind("loaded.jstree", cms_tpv_tree_loaded);
291
 
292
  $elm.jstree(treeOptionsTmp);
293
 
@@ -612,7 +612,7 @@ jQuery(document).on("mouseenter", "div.cms_tpv_container", function(e) {
612
  */
613
  function cms_tpv_bind_clean_node() {
614
 
615
- cms_tpv_tree.bind("move_node.jstree", function (event, data) {
616
  var nodeBeingMoved = data.rslt.o; // noden vi flyttar
617
  var nodeNewParent = data.rslt.np;
618
  var nodePosition = data.rslt.p;
@@ -669,7 +669,7 @@ function cms_tpv_bind_clean_node() {
669
 
670
  });
671
 
672
- cms_tpv_tree.bind("clean_node.jstree", function(event, data) {
673
  var obj = (data.rslt.obj);
674
  if (obj && obj != -1) {
675
  obj.each(function(i, elm) {
@@ -720,11 +720,11 @@ function cms_tpv_bind_clean_node() {
720
 
721
  // Perform search when submiting form
722
  jQuery(document).on("submit", "form.cms_tree_view_search_form", function(e) {
 
723
 
724
- var $wrapper = jQuery(this).closest(".cms_tpv_wrapper");
725
  $wrapper.find(".cms_tpv_search_no_hits").hide();
726
- var s = $wrapper.find(".cms_tree_view_search").attr("value");
727
- s = jQuery.trim( s );
728
 
729
  if (s) {
730
  $wrapper.find(".cms_tree_view_search_form_no_hits").fadeOut("fast");
@@ -875,7 +875,7 @@ function cms_tvp_set_view(view, elm) {
875
  var treeOptionsTmp = jQuery.extend(true, {}, treeOptions);
876
  treeOptionsTmp.json_data.ajax.url = ajaxurl + CMS_TPV_AJAXURL + view + '&cms-tpv-nonce=' + window.CMS_TPV_NONCE + "&post_type=" + cms_tpv_get_post_type(elm) + "&lang=" + cms_tpv_get_wpml_selected_lang(elm);
877
 
878
- $wrapper.find(".cms_tpv_container").bind("loaded.jstree open_node.jstree", cms_tpv_tree_loaded);
879
  $wrapper.find(".cms_tpv_container").jstree(treeOptionsTmp);
880
 
881
  }
279
  // set search url to include post type
280
  treeOptionsTmp.search.ajax.url = ajaxurl + CMS_TPV_AJAXURL + CMS_TPV_VIEW + '&cms-tpv-nonce=' + window.CMS_TPV_NONCE + "&post_type=" + cms_tpv_get_post_type(this);
281
 
282
+ $elm.on("search.jstree", function (event, data) {
283
  if (data.rslt.nodes.length === 0) {
284
  // no hits. doh.
285
  $(this).closest(".cms_tpv_wrapper").find(".cms_tree_view_search_form_no_hits").fadeIn("fast");
287
  });
288
 
289
  // whole tre loaded
290
+ $elm.on("loaded.jstree", cms_tpv_tree_loaded);
291
 
292
  $elm.jstree(treeOptionsTmp);
293
 
612
  */
613
  function cms_tpv_bind_clean_node() {
614
 
615
+ cms_tpv_tree.on("move_node.jstree", function (event, data) {
616
  var nodeBeingMoved = data.rslt.o; // noden vi flyttar
617
  var nodeNewParent = data.rslt.np;
618
  var nodePosition = data.rslt.p;
669
 
670
  });
671
 
672
+ cms_tpv_tree.on("clean_node.jstree", function(event, data) {
673
  var obj = (data.rslt.obj);
674
  if (obj && obj != -1) {
675
  obj.each(function(i, elm) {
720
 
721
  // Perform search when submiting form
722
  jQuery(document).on("submit", "form.cms_tree_view_search_form", function(e) {
723
+ e.preventDefault();
724
 
725
+ var $wrapper = jQuery(this).parents(".cms_tpv_wrapper");
726
  $wrapper.find(".cms_tpv_search_no_hits").hide();
727
+ var s = $wrapper.find(".cms_tree_view_search").val().trim();
 
728
 
729
  if (s) {
730
  $wrapper.find(".cms_tree_view_search_form_no_hits").fadeOut("fast");
875
  var treeOptionsTmp = jQuery.extend(true, {}, treeOptions);
876
  treeOptionsTmp.json_data.ajax.url = ajaxurl + CMS_TPV_AJAXURL + view + '&cms-tpv-nonce=' + window.CMS_TPV_NONCE + "&post_type=" + cms_tpv_get_post_type(elm) + "&lang=" + cms_tpv_get_wpml_selected_lang(elm);
877
 
878
+ $wrapper.find(".cms_tpv_container").on("loaded.jstree open_node.jstree", cms_tpv_tree_loaded);
879
  $wrapper.find(".cms_tpv_container").jstree(treeOptionsTmp);
880
 
881
  }
scripts/jquery.alerts.js CHANGED
@@ -12,7 +12,7 @@
12
  // jAlert( message, [title, callback] )
13
  // jConfirm( message, [title, callback] )
14
  // jPrompt( message, [value, title, callback] )
15
- //
16
  // History:
17
  //
18
  // 1.00 - Released (29 December 2008)
@@ -20,16 +20,16 @@
20
  // 1.01 - Fixed bug where unbinding would destroy all resize events
21
  //
22
  // License:
23
- //
24
  // This plugin is dual-licensed under the GNU General Public License and the MIT License and
25
- // is copyright 2008 A Beautiful Site, LLC.
26
  //
27
  (function($) {
28
-
29
  $.alerts = {
30
-
31
  // These properties can be read/written by accessing $.alerts.propertyName from your scripts at any time
32
-
33
  verticalOffset: -75, // vertical offset of the dialog from center screen, in pixels
34
  horizontalOffset: 0, // horizontal offset of the dialog from center screen, in pixels/
35
  repositionOnResize: true, // re-centers the dialog on window resize
@@ -39,37 +39,37 @@
39
  okButton: '&nbsp;OK&nbsp;', // text for the OK button
40
  cancelButton: '&nbsp;Cancel&nbsp;', // text for the Cancel button
41
  dialogClass: null, // if specified, this class will be applied to all dialogs
42
-
43
  // Public methods
44
-
45
  alert: function(message, title, callback) {
46
  if( title == null ) title = 'Alert';
47
  $.alerts._show(title, message, null, 'alert', function(result) {
48
  if( callback ) callback(result);
49
  });
50
  },
51
-
52
  confirm: function(message, title, callback) {
53
  if( title == null ) title = 'Confirm';
54
  $.alerts._show(title, message, null, 'confirm', function(result) {
55
  if( callback ) callback(result);
56
  });
57
  },
58
-
59
  prompt: function(message, value, title, callback) {
60
  if( title == null ) title = 'Prompt';
61
  $.alerts._show(title, message, value, 'prompt', function(result) {
62
  if( callback ) callback(result);
63
  });
64
  },
65
-
66
  // Private methods
67
-
68
  _show: function(title, msg, value, type, callback) {
69
-
70
  $.alerts._hide();
71
  $.alerts._overlay('show');
72
-
73
  $("BODY").append(
74
  '<div id="popup_container">' +
75
  '<h1 id="popup_title"></h1>' +
@@ -77,32 +77,33 @@
77
  '<div id="popup_message"></div>' +
78
  '</div>' +
79
  '</div>');
80
-
81
  if( $.alerts.dialogClass ) $("#popup_container").addClass($.alerts.dialogClass);
82
-
83
  // IE6 Fix
84
- var pos = ($.browser.msie && parseInt($.browser.version) <= 6 ) ? 'absolute' : 'fixed';
85
-
 
86
  $("#popup_container").css({
87
  position: pos,
88
  zIndex: 99999,
89
  padding: 0,
90
  margin: 0
91
  });
92
-
93
  $("#popup_title").text(title);
94
  $("#popup_content").addClass(type);
95
  $("#popup_message").text(msg);
96
  $("#popup_message").html( $("#popup_message").text().replace(/\n/g, '<br />') );
97
-
98
  $("#popup_container").css({
99
  minWidth: $("#popup_container").outerWidth(),
100
  maxWidth: $("#popup_container").outerWidth()
101
  });
102
-
103
  $.alerts._reposition();
104
  $.alerts._maintainPosition(true);
105
-
106
  switch( type ) {
107
  case 'alert':
108
  $("#popup_message").after('<div id="popup_panel"><input type="button" value="' + $.alerts.okButton + '" id="popup_ok" /></div>');
@@ -150,7 +151,7 @@
150
  $("#popup_prompt").focus().select();
151
  break;
152
  }
153
-
154
  // Make draggable
155
  if( $.alerts.draggable ) {
156
  try {
@@ -159,13 +160,13 @@
159
  } catch(e) { /* requires jQuery UI draggables */ }
160
  }
161
  },
162
-
163
  _hide: function() {
164
  $("#popup_container").remove();
165
  $.alerts._overlay('hide');
166
  $.alerts._maintainPosition(false);
167
  },
168
-
169
  _overlay: function(status) {
170
  switch( status ) {
171
  case 'show':
@@ -187,23 +188,23 @@
187
  break;
188
  }
189
  },
190
-
191
  _reposition: function() {
192
  var top = (($(window).height() / 2) - ($("#popup_container").outerHeight() / 2)) + $.alerts.verticalOffset;
193
  var left = (($(window).width() / 2) - ($("#popup_container").outerWidth() / 2)) + $.alerts.horizontalOffset;
194
  if( top < 0 ) top = 0;
195
  if( left < 0 ) left = 0;
196
-
197
  // IE6 fix
198
- if( $.browser.msie && parseInt($.browser.version) <= 6 ) top = top + $(window).scrollTop();
199
-
200
  $("#popup_container").css({
201
  top: top + 'px',
202
  left: left + 'px'
203
  });
204
  $("#popup_overlay").height( $(document).height() );
205
  },
206
-
207
  _maintainPosition: function(status) {
208
  if( $.alerts.repositionOnResize ) {
209
  switch(status) {
@@ -216,20 +217,20 @@
216
  }
217
  }
218
  }
219
-
220
  }
221
-
222
  // Shortuct functions
223
  jAlert = function(message, title, callback) {
224
  $.alerts.alert(message, title, callback);
225
  }
226
-
227
  jConfirm = function(message, title, callback) {
228
  $.alerts.confirm(message, title, callback);
229
  };
230
-
231
  jPrompt = function(message, value, title, callback) {
232
  $.alerts.prompt(message, value, title, callback);
233
  };
234
-
235
  })(jQuery);
12
  // jAlert( message, [title, callback] )
13
  // jConfirm( message, [title, callback] )
14
  // jPrompt( message, [value, title, callback] )
15
+ //
16
  // History:
17
  //
18
  // 1.00 - Released (29 December 2008)
20
  // 1.01 - Fixed bug where unbinding would destroy all resize events
21
  //
22
  // License:
23
+ //
24
  // This plugin is dual-licensed under the GNU General Public License and the MIT License and
25
+ // is copyright 2008 A Beautiful Site, LLC.
26
  //
27
  (function($) {
28
+
29
  $.alerts = {
30
+
31
  // These properties can be read/written by accessing $.alerts.propertyName from your scripts at any time
32
+
33
  verticalOffset: -75, // vertical offset of the dialog from center screen, in pixels
34
  horizontalOffset: 0, // horizontal offset of the dialog from center screen, in pixels/
35
  repositionOnResize: true, // re-centers the dialog on window resize
39
  okButton: '&nbsp;OK&nbsp;', // text for the OK button
40
  cancelButton: '&nbsp;Cancel&nbsp;', // text for the Cancel button
41
  dialogClass: null, // if specified, this class will be applied to all dialogs
42
+
43
  // Public methods
44
+
45
  alert: function(message, title, callback) {
46
  if( title == null ) title = 'Alert';
47
  $.alerts._show(title, message, null, 'alert', function(result) {
48
  if( callback ) callback(result);
49
  });
50
  },
51
+
52
  confirm: function(message, title, callback) {
53
  if( title == null ) title = 'Confirm';
54
  $.alerts._show(title, message, null, 'confirm', function(result) {
55
  if( callback ) callback(result);
56
  });
57
  },
58
+
59
  prompt: function(message, value, title, callback) {
60
  if( title == null ) title = 'Prompt';
61
  $.alerts._show(title, message, value, 'prompt', function(result) {
62
  if( callback ) callback(result);
63
  });
64
  },
65
+
66
  // Private methods
67
+
68
  _show: function(title, msg, value, type, callback) {
69
+
70
  $.alerts._hide();
71
  $.alerts._overlay('show');
72
+
73
  $("BODY").append(
74
  '<div id="popup_container">' +
75
  '<h1 id="popup_title"></h1>' +
77
  '<div id="popup_message"></div>' +
78
  '</div>' +
79
  '</div>');
80
+
81
  if( $.alerts.dialogClass ) $("#popup_container").addClass($.alerts.dialogClass);
82
+
83
  // IE6 Fix
84
+ // var pos = ($.browser.msie && parseInt($.browser.version) <= 6 ) ? 'absolute' : 'fixed';
85
+ var pos = 'fixed';
86
+
87
  $("#popup_container").css({
88
  position: pos,
89
  zIndex: 99999,
90
  padding: 0,
91
  margin: 0
92
  });
93
+
94
  $("#popup_title").text(title);
95
  $("#popup_content").addClass(type);
96
  $("#popup_message").text(msg);
97
  $("#popup_message").html( $("#popup_message").text().replace(/\n/g, '<br />') );
98
+
99
  $("#popup_container").css({
100
  minWidth: $("#popup_container").outerWidth(),
101
  maxWidth: $("#popup_container").outerWidth()
102
  });
103
+
104
  $.alerts._reposition();
105
  $.alerts._maintainPosition(true);
106
+
107
  switch( type ) {
108
  case 'alert':
109
  $("#popup_message").after('<div id="popup_panel"><input type="button" value="' + $.alerts.okButton + '" id="popup_ok" /></div>');
151
  $("#popup_prompt").focus().select();
152
  break;
153
  }
154
+
155
  // Make draggable
156
  if( $.alerts.draggable ) {
157
  try {
160
  } catch(e) { /* requires jQuery UI draggables */ }
161
  }
162
  },
163
+
164
  _hide: function() {
165
  $("#popup_container").remove();
166
  $.alerts._overlay('hide');
167
  $.alerts._maintainPosition(false);
168
  },
169
+
170
  _overlay: function(status) {
171
  switch( status ) {
172
  case 'show':
188
  break;
189
  }
190
  },
191
+
192
  _reposition: function() {
193
  var top = (($(window).height() / 2) - ($("#popup_container").outerHeight() / 2)) + $.alerts.verticalOffset;
194
  var left = (($(window).width() / 2) - ($("#popup_container").outerWidth() / 2)) + $.alerts.horizontalOffset;
195
  if( top < 0 ) top = 0;
196
  if( left < 0 ) left = 0;
197
+
198
  // IE6 fix
199
+ // if( $.browser.msie && parseInt($.browser.version) <= 6 ) top = top + $(window).scrollTop();
200
+
201
  $("#popup_container").css({
202
  top: top + 'px',
203
  left: left + 'px'
204
  });
205
  $("#popup_overlay").height( $(document).height() );
206
  },
207
+
208
  _maintainPosition: function(status) {
209
  if( $.alerts.repositionOnResize ) {
210
  switch(status) {
217
  }
218
  }
219
  }
220
+
221
  }
222
+
223
  // Shortuct functions
224
  jAlert = function(message, title, callback) {
225
  $.alerts.alert(message, title, callback);
226
  }
227
+
228
  jConfirm = function(message, title, callback) {
229
  $.alerts.confirm(message, title, callback);
230
  };
231
+
232
  jPrompt = function(message, value, title, callback) {
233
  $.alerts.prompt(message, value, title, callback);
234
  };
235
+
236
  })(jQuery);
scripts/jquery.biscuit.js CHANGED
@@ -83,7 +83,7 @@ jQuery.cookie = function(name, value, options) {
83
  if (document.cookie && document.cookie != '') {
84
  var cookies = document.cookie.split(';');
85
  for (var i = 0; i < cookies.length; i++) {
86
- var cookie = jQuery.trim(cookies[i]);
87
  // Does this cookie string begin with the name we want?
88
  if (cookie.substring(0, name.length + 1) == (name + '=')) {
89
  cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
83
  if (document.cookie && document.cookie != '') {
84
  var cookies = document.cookie.split(';');
85
  for (var i = 0; i < cookies.length; i++) {
86
+ var cookie = cookies[i].trim();
87
  // Does this cookie string begin with the name we want?
88
  if (cookie.substring(0, name.length + 1) == (name + '=')) {
89
  cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
scripts/jquery.jstree.js CHANGED
@@ -17,15 +17,22 @@
17
 
18
  "use strict";
19
 
 
 
 
 
 
 
 
20
  // top wrapper to prevent multiple inclusion (is this OK?)
21
  (function () { if(jQuery && jQuery.jstree) { return; }
22
  var is_ie6 = false, is_ie7 = false, is_ff2 = false;
23
 
24
- /*
25
  * jsTree core
26
  */
27
  (function ($) {
28
- // Common functions not related to jsTree
29
  // decided to move them to a `vakata` "namespace"
30
  $.vakata = {};
31
  // CSS related functions
@@ -53,8 +60,8 @@
53
  if(sheet.insertRule) { sheet.insertRule(rule_name + ' { }', 0); } else { sheet.addRule(rule_name, null, 0); }
54
  return $.vakata.css.get_css(rule_name);
55
  },
56
- remove_css : function(rule_name, sheet) {
57
- return $.vakata.css.get_css(rule_name, true, sheet);
58
  },
59
  add_sheet : function(opts) {
60
  var tmp = false, is_new = true;
@@ -68,12 +75,12 @@
68
  }
69
 
70
  if(tmp.styleSheet) {
71
- if(is_new) {
72
- document.getElementsByTagName("head")[0].appendChild(tmp);
73
- tmp.styleSheet.cssText = opts.str;
74
  }
75
  else {
76
- tmp.styleSheet.cssText = tmp.styleSheet.cssText + " " + opts.str;
77
  }
78
  }
79
  else {
@@ -99,7 +106,7 @@
99
  }
100
  };
101
 
102
- // private variables
103
  var instances = [], // instance array (used by $.jstree.reference/create/focused)
104
  focused_instance = -1, // the index in the instance array of the currently focused instance
105
  plugins = {}, // list of included plugins
@@ -108,7 +115,7 @@
108
  // jQuery plugin wrapper (thanks to jquery UI widget function)
109
  $.fn.jstree = function (settings) {
110
  var isMethodCall = (typeof settings == 'string'), // is this a method call like $().jstree("open_node")
111
- args = Array.prototype.slice.call(arguments, 1),
112
  returnValue = this;
113
 
114
  // if a method call execute the method on all selected instances
@@ -126,8 +133,8 @@
126
  var instance_id = $.data(this, "jstree-instance-id"),
127
  a = [],
128
  b = settings ? $.extend({}, true, settings) : {},
129
- c = $(this),
130
- s = false,
131
  t = [];
132
  a = a.concat(args);
133
  if(c.data("jstree")) { a.push(c.data("jstree")); }
@@ -140,7 +147,7 @@
140
  // store the jstree instance id to the container element
141
  $.data(this, "jstree-instance-id", instance_id);
142
  // clean up all plugins
143
- b.plugins = $.isArray(b.plugins) ? b.plugins : $.jstree.defaults.plugins.slice();
144
  b.plugins.unshift("core");
145
  // only unique plugins
146
  b.plugins = b.plugins.sort().join(",,").replace(/(,|^)([^,]+)(,,\2)+(,|$)/g,"$1$2$4").replace(/,,+/g,",").replace(/,$/,"").split(",");
@@ -148,14 +155,14 @@
148
  // extend defaults with passed data
149
  s = $.extend(true, {}, $.jstree.defaults, b);
150
  s.plugins = b.plugins;
151
- $.each(plugins, function (i, val) {
152
- if($.inArray(i, s.plugins) === -1) { s[i] = null; delete s[i]; }
153
  else { t.push(i); }
154
  });
155
  s.plugins = t;
156
 
157
  // push the new object to the instances array (at the same time set the default classes to the container) and init
158
- instances[instance_id] = new $.jstree._instance(instance_id, $(this).addClass("jstree jstree-" + instance_id), s);
159
  // init all activated plugins for this instance
160
  $.each(instances[instance_id]._get_settings().plugins, function (i, val) { instances[instance_id].data[val] = {}; });
161
  $.each(instances[instance_id]._get_settings().plugins, function (i, val) { if(plugins[val]) { plugins[val].__init.apply(instances[instance_id]); } });
@@ -172,16 +179,16 @@
172
  plugins : []
173
  },
174
  _focused : function () { return instances[focused_instance] || null; },
175
- _reference : function (needle) {
176
  // get by instance id
177
  if(instances[needle]) { return instances[needle]; }
178
  // get by DOM (if still no luck - return null
179
- var o = $(needle);
180
  if(!o.length && typeof needle === "string") { o = $("#" + needle); }
181
  if(!o.length) { return null; }
182
- return instances[o.closest(".jstree").data("jstree-instance-id")] || null;
183
  },
184
- _instance : function (index, container, settings) {
185
  // for plugins to store data in
186
  this.data = { core : {} };
187
  this.get_settings = function () { return $.extend(true, {}, settings); };
@@ -189,14 +196,14 @@
189
  this.get_index = function () { return index; };
190
  this.get_container = function () { return container; };
191
  this.get_container_ul = function () { return container.children("ul:eq(0)"); };
192
- this._set_settings = function (s) {
193
  settings = $.extend(true, {}, settings, s);
194
  };
195
  },
196
  _fn : { },
197
  plugin : function (pname, pdata) {
198
  pdata = $.extend({}, {
199
- __init : $.noop,
200
  __destroy : $.noop,
201
  _fn : {},
202
  defaults : false
@@ -233,12 +240,12 @@
233
  if(typeof rslt !== "undefined") { args = rslt; }
234
 
235
  rslt = func.apply(
236
- $.extend({}, this, {
237
- __callback : function (data) {
238
  //console.log(i);
239
  this.get_container().triggerHandler( i + '.jstree', { "inst" : this, "args" : args, "rslt" : data, "rlbk" : rlbk });
240
  },
241
- __rollback : function () {
242
  rlbk = this.get_rollback();
243
  return rlbk;
244
  },
@@ -257,7 +264,7 @@
257
  },
258
  rollback : function (rb) {
259
  if(rb) {
260
- if(!$.isArray(rb)) { rb = [ rb ]; }
261
  $.each(rb, function (i, val) {
262
  instances[val.i].set_rollback(val.h, val.d);
263
  });
@@ -273,22 +280,22 @@
273
  // code is copied from jQuery ($.browser is deprecated + there is a bug in IE)
274
  var u = navigator.userAgent.toLowerCase(),
275
  v = (u.match( /.+?(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [0,'0'])[1],
276
- css_string = '' +
277
- '.jstree ul, .jstree li { display:block; margin:0 0 0 0; padding:0 0 0 0; list-style-type:none; } ' +
278
- '.jstree li { display:block; min-height:18px; line-height:18px; white-space:nowrap; margin-left:18px; min-width:18px; } ' +
279
- '.jstree-rtl li { margin-left:0; margin-right:18px; } ' +
280
- '.jstree > ul > li { margin-left:0px; } ' +
281
- '.jstree-rtl > ul > li { margin-right:0px; } ' +
282
- '.jstree ins { display:inline-block; text-decoration:none; width:18px; height:18px; margin:0 0 0 0; padding:0; } ' +
283
- '.jstree a { display:inline-block; line-height:16px; height:16px; color:black; white-space:nowrap; text-decoration:none; padding:1px 2px; margin:0; } ' +
284
- '.jstree a:focus { outline: none; } ' +
285
- '.jstree a > ins { height:16px; width:16px; } ' +
286
- '.jstree a > .jstree-icon { margin-right:3px; } ' +
287
- '.jstree-rtl a > .jstree-icon { margin-left:3px; margin-right:0; } ' +
288
- 'li.jstree-open > ul { display:block; } ' +
289
  'li.jstree-closed > ul { display:none; } ';
290
  // Correct IE 6 (does not support the > CSS selector)
291
- if(/msie/.test(u) && parseInt(v, 10) == 6) {
292
  is_ie6 = true;
293
 
294
  // fix image flicker and lack of caching
@@ -296,28 +303,28 @@
296
  document.execCommand("BackgroundImageCache", false, true);
297
  } catch (err) { }
298
 
299
- css_string += '' +
300
- '.jstree li { height:18px; margin-left:0; margin-right:0; } ' +
301
- '.jstree li li { margin-left:18px; } ' +
302
- '.jstree-rtl li li { margin-left:0px; margin-right:18px; } ' +
303
- 'li.jstree-open ul { display:block; } ' +
304
- 'li.jstree-closed ul { display:none !important; } ' +
305
- '.jstree li a { display:inline; border-width:0 !important; padding:0px 2px !important; } ' +
306
- '.jstree li a ins { height:16px; width:16px; margin-right:3px; } ' +
307
  '.jstree-rtl li a ins { margin-right:0px; margin-left:3px; } ';
308
  }
309
  // Correct IE 7 (shifts anchor nodes onhover)
310
- if(/msie/.test(u) && parseInt(v, 10) == 7) {
311
  is_ie7 = true;
312
  css_string += '.jstree li a { border-width:0 !important; padding:0px 2px !important; } ';
313
  }
314
  // correct ff2 lack of display:inline-block
315
  if(!/compatible/.test(u) && /mozilla/.test(u) && parseFloat(v, 10) < 1.9) {
316
  is_ff2 = true;
317
- css_string += '' +
318
- '.jstree ins { display:-moz-inline-box; } ' +
319
  '.jstree li { line-height:12px; } ' + // WHY??
320
- '.jstree a { display:-moz-inline-box; } ' +
321
  '.jstree .jstree-no-icons .jstree-checkbox { display:-moz-inline-stack !important; } ';
322
  /* this shouldn't be here as it is theme specific */
323
  }
@@ -332,7 +339,7 @@
332
  this.data.core.to_open = this.get_settings().core.initially_open;
333
  this.data.core.to_load = this.get_settings().core.initially_load;
334
  },
335
- defaults : {
336
  html_titles : false,
337
  animation : 500,
338
  initially_open : [],
@@ -347,9 +354,9 @@
347
  multiple_selection : "Multiple selection"
348
  }
349
  },
350
- _fn : {
351
- init : function () {
352
- this.set_focus();
353
  if(this._get_settings().core.rtl) {
354
  this.get_container().addClass("jstree-rtl").css("direction", "rtl");
355
  }
@@ -357,20 +364,20 @@
357
  this.data.core.li_height = this.get_container_ul().find("li.jstree-closed, li.jstree-leaf").eq(0).height() || 18;
358
 
359
  this.get_container()
360
- .delegate("li > ins", "click.jstree", $.proxy(function (event) {
361
  var trgt = $(event.target);
362
  if(trgt.is("ins") && event.pageY - trgt.offset().top < this.data.core.li_height) { this.toggle_node(trgt); }
363
  }, this))
364
- .bind("mousedown.jstree", $.proxy(function () {
365
  this.set_focus(); // This used to be setTimeout(set_focus,0) - why?
366
  }, this))
367
- .bind("dblclick.jstree", function (event) {
368
  var sel;
369
  if(document.selection && document.selection.empty) { document.selection.empty(); }
370
  else {
371
  if(window.getSelection) {
372
  sel = window.getSelection();
373
- try {
374
  sel.removeAllRanges();
375
  sel.collapse();
376
  } catch (err) { }
@@ -379,7 +386,7 @@
379
  });
380
  if(this._get_settings().core.notify_plugins) {
381
  this.get_container()
382
- .bind("load_node.jstree", $.proxy(function (e, data) {
383
  var o = this._get_node(data.rslt.obj),
384
  t = this;
385
  if(o === -1) { o = this.get_container_ul(); }
@@ -398,7 +405,7 @@
398
  }
399
  if(this._get_settings().core.load_open) {
400
  this.get_container()
401
- .bind("load_node.jstree", $.proxy(function (e, data) {
402
  var o = this._get_node(data.rslt.obj),
403
  t = this;
404
  if(o === -1) { o = this.get_container_ul(); }
@@ -411,7 +418,7 @@
411
  this.__callback();
412
  this.load_node(-1, function () { this.loaded(); this.reload_nodes(); });
413
  },
414
- destroy : function () {
415
  var i,
416
  n = this.get_index(),
417
  s = this._get_settings(),
@@ -422,12 +429,12 @@
422
  });
423
  this.__callback();
424
  // set focus to another instance if this one is focused
425
- if(this.is_focused()) {
426
- for(i in instances) {
427
- if(instances.hasOwnProperty(i) && i != n) {
428
- instances[i].set_focus();
429
- break;
430
- }
431
  }
432
  }
433
  // if no other instance found
@@ -435,14 +442,14 @@
435
  // remove all traces of jstree in the DOM (only the ones set using jstree*) and cleans all events
436
  this.get_container()
437
  .unbind(".jstree")
438
- .undelegate(".jstree")
439
  .removeData("jstree-instance-id")
440
  .find("[class^='jstree']")
441
  .andSelf()
442
  .attr("class", function () { return this.className.replace(/jstree[^ ]*|$/ig,''); });
443
  $(document)
444
  .unbind(".jstree-" + n)
445
- .undelegate(".jstree-" + n);
446
  // remove the actual data
447
  instances[n] = null;
448
  delete instances[n];
@@ -468,7 +475,7 @@
468
  save_opened : function () {
469
  var _this = this;
470
  this.data.core.to_open = [];
471
- this.get_container_ul().find("li.jstree-open").each(function () {
472
  if(this.id) { _this.data.core.to_open.push("#" + this.id.toString().replace(/^#/,"").replace(/\\\//g,"/").replace(/\//g,"\\\/").replace(/\\\./g,".").replace(/\./g,"\\.").replace(/\:/g,"\\:")); }
473
  });
474
  this.__callback(_this.data.core.to_open);
@@ -479,9 +486,9 @@
479
  done = true,
480
  current = [],
481
  remaining = [];
482
- if(!is_callback) {
483
- this.data.core.reopen = false;
484
- this.data.core.refreshing = true;
485
  this.data.core.to_open = $.map($.makeArray(this.data.core.to_open), function (n) { return "#" + n.toString().replace(/^#/,"").replace(/\\\//g,"/").replace(/\//g,"\\\/").replace(/\\\./g,".").replace(/\./g,"\\.").replace(/\:/g,"\\:"); });
486
  this.data.core.to_load = $.map($.makeArray(this.data.core.to_load), function (n) { return "#" + n.toString().replace(/^#/,"").replace(/\\\//g,"/").replace(/\//g,"\\\/").replace(/\\\./g,".").replace(/\./g,"\\.").replace(/\:/g,"\\:"); });
487
  if(this.data.core.to_open.length) {
@@ -496,7 +503,7 @@
496
  });
497
  if(current.length) {
498
  this.data.core.to_load = remaining;
499
- $.each(current, function (i, val) {
500
  if(!_this._is_loaded(val)) {
501
  _this.load_node(val, function () { _this.reload_nodes(true); }, function () { _this.reload_nodes(true); });
502
  done = false;
@@ -506,10 +513,10 @@
506
  }
507
  if(this.data.core.to_open.length) {
508
  $.each(this.data.core.to_open, function (i, val) {
509
- _this.open_node(val, false, true);
510
  });
511
  }
512
- if(done) {
513
  // TODO: find a more elegant approach to syncronizing returning requests
514
  if(this.data.core.reopen) { clearTimeout(this.data.core.reopen); }
515
  this.data.core.reopen = setTimeout(function () { _this.__callback({}, _this); }, 50);
@@ -521,7 +528,7 @@
521
  var _this = this;
522
  if(this.data.core.to_open.length) {
523
  $.each(this.data.core.to_open, function (i, val) {
524
- _this.open_node(val, false, true);
525
  });
526
  }
527
  this.__callback({});
@@ -537,36 +544,36 @@
537
  this.load_node(obj, function () { _this.__callback({ "obj" : obj}); _this.reload_nodes(); });
538
  },
539
  // Dummy function to fire after the first load (so that there is a jstree.loaded event)
540
- loaded : function () {
541
- this.__callback();
542
  },
543
  // deal with focus
544
- set_focus : function () {
545
  if(this.is_focused()) { return; }
546
  var f = $.jstree._focused();
547
  if(f) { f.unset_focus(); }
548
 
549
- this.get_container().addClass("jstree-focused");
550
- focused_instance = this.get_index();
551
  this.__callback();
552
  },
553
- is_focused : function () {
554
- return focused_instance == this.get_index();
555
  },
556
  unset_focus : function () {
557
  if(this.is_focused()) {
558
- this.get_container().removeClass("jstree-focused");
559
- focused_instance = -1;
560
  }
561
  this.__callback();
562
  },
563
 
564
  // traverse
565
- _get_node : function (obj) {
566
- var $obj = $(obj, this.get_container());
567
- if($obj.is(".jstree") || obj == -1) { return -1; }
568
- $obj = $obj.closest("li", this.get_container());
569
- return $obj.length ? $obj : false;
570
  },
571
  _get_next : function (obj, strict) {
572
  obj = this._get_node(obj);
@@ -676,7 +683,7 @@
676
  open_all : function (obj, do_animation, original_obj) {
677
  obj = obj ? this._get_node(obj) : -1;
678
  if(!obj || obj === -1) { obj = this.get_container_ul(); }
679
- if(original_obj) {
680
  obj = obj.find("li.jstree-closed");
681
  }
682
  else {
@@ -685,8 +692,8 @@
685
  else { obj = obj.find("li.jstree-closed"); }
686
  }
687
  var _this = this;
688
- obj.each(function () {
689
- var __this = this;
690
  if(!_this._is_loaded(this)) { _this.open_node(this, function() { _this.open_all(__this, do_animation, original_obj); }, !do_animation); }
691
  else { _this.open_node(this, false, !do_animation); }
692
  });
@@ -711,9 +718,9 @@
711
  this.__callback({ "obj" : obj });
712
  },
713
  // rollback
714
- get_rollback : function () {
715
  this.__callback();
716
- return { i : this.get_index(), h : this.get_container().children("ul").clone(true), d : this.data };
717
  },
718
  set_rollback : function (html, data) {
719
  this.get_container().empty().append(html);
@@ -743,7 +750,7 @@
743
  if(js.metadata) { d.data(js.metadata); }
744
  if(js.state) { d.addClass("jstree-" + js.state); }
745
  if(!js.data) { js.data = this._get_string("new_node"); }
746
- if(!$.isArray(js.data)) { tmp = js.data; js.data = []; js.data.push(tmp); }
747
  $.each(js.data, function (i, m) {
748
  tmp = $("<a />");
749
  if($.isFunction(m)) { m = m.call(this, js); }
@@ -755,7 +762,7 @@
755
  if(m.language) { tmp.addClass(m.language); }
756
  }
757
  tmp.prepend("<ins class='jstree-icon'>&#160;</ins>");
758
- if(m.icon) {
759
  if(m.icon.indexOf("/") === -1) { tmp.children("ins").addClass(m.icon); }
760
  else { tmp.children("ins").css("background","url('" + m.icon + "') center center no-repeat"); }
761
  }
@@ -870,11 +877,11 @@
870
  case "first":
871
  case "before":
872
  case "inside":
873
- p.cp = 0;
874
  break;
875
  case "after":
876
  case "last":
877
- p.cp = p.rt.get_container().find(" > ul > li").length;
878
  break;
879
  default:
880
  p.cp = p.p;
@@ -900,10 +907,10 @@
900
  p.cr = p.r;
901
  break;
902
  case "last":
903
- p.cp = p.r.find(" > ul > li").length;
904
  p.cr = p.r;
905
  break;
906
- default:
907
  p.cp = p.p;
908
  p.cr = p.r;
909
  break;
@@ -924,18 +931,18 @@
924
  var obj = prepared_move, ret = true, r = obj.r === -1 ? this.get_container() : obj.r;
925
  if(!obj || !obj.o || obj.or[0] === obj.o[0]) { return false; }
926
  if(obj.op && obj.np && obj.op[0] === obj.np[0] && obj.cp - 1 === obj.o.index()) { return false; }
927
- obj.o.each(function () {
928
  if(r.parentsUntil(".jstree", "li").andSelf().index(this) !== -1) { ret = false; return false; }
929
  });
930
  return ret;
931
  },
932
  move_node : function (obj, ref, position, is_copy, is_prepared, skip_check) {
933
- if(!is_prepared) {
934
  return this.prepare_move(obj, ref, position, function (p) {
935
  this.move_node(p, false, false, is_copy, true, skip_check);
936
  });
937
  }
938
- if(is_copy) {
939
  prepared_move.cy = true;
940
  }
941
  if(!skip_check && !this.check_move()) { return false; }
@@ -951,12 +958,12 @@
951
  else { o = obj.o; }
952
 
953
  if(obj.or.length) { obj.or.before(o); }
954
- else {
955
  if(!obj.np.children("ul").length) { $("<ul />").appendTo(obj.np); }
956
- obj.np.children("ul:eq(0)").append(o);
957
  }
958
 
959
- try {
960
  obj.ot.clean_node(obj.op);
961
  obj.rt.clean_node(obj.np);
962
  if(!obj.op.find("> ul > li").length) {
@@ -964,9 +971,9 @@
964
  }
965
  } catch (e) { }
966
 
967
- if(is_copy) {
968
  prepared_move.cy = true;
969
- prepared_move.oc = o;
970
  }
971
  this.__callback(prepared_move);
972
  return prepared_move;
@@ -977,7 +984,7 @@
977
  })(jQuery);
978
  //*/
979
 
980
- /*
981
  * jsTree ui plugin
982
  * This plugins handles selecting/deselecting/hovering/dehovering nodes
983
  */
@@ -989,7 +996,7 @@
989
  e2 = $('<textarea cols="10" rows="2" style="overflow: hidden;"></textarea>').css({ position: 'absolute', top: -1000, left: 0 }).appendTo('body');
990
  scrollbar_width = e1.width() - e2.width();
991
  e1.add(e2).remove();
992
- }
993
  else {
994
  e1 = $('<div />').css({ width: 100, height: 100, overflow: 'auto', position: 'absolute', top: -1000, left: 0 })
995
  .prependTo('body').append('<div />').find('div').css({ width: '100%', height: 200 });
@@ -998,65 +1005,65 @@
998
  }
999
  });
1000
  $.jstree.plugin("ui", {
1001
- __init : function () {
1002
- this.data.ui.selected = $();
1003
- this.data.ui.last_selected = false;
1004
  this.data.ui.hovered = null;
1005
  this.data.ui.to_select = this.get_settings().ui.initially_select;
1006
 
1007
  this.get_container()
1008
- .delegate("a", "click.jstree", $.proxy(function (event) {
1009
  event.preventDefault();
1010
  event.currentTarget.blur();
1011
  if(!$(event.currentTarget).hasClass("jstree-loading")) {
1012
  this.select_node(event.currentTarget, true, event);
1013
  }
1014
  }, this))
1015
- .delegate("a", "mouseenter.jstree", $.proxy(function (event) {
1016
  if(!$(event.currentTarget).hasClass("jstree-loading")) {
1017
  this.hover_node(event.target);
1018
  }
1019
  }, this))
1020
- .delegate("a", "mouseleave.jstree", $.proxy(function (event) {
1021
  if(!$(event.currentTarget).hasClass("jstree-loading")) {
1022
  this.dehover_node(event.target);
1023
  }
1024
  }, this))
1025
- .bind("reopen.jstree", $.proxy(function () {
1026
  this.reselect();
1027
  }, this))
1028
- .bind("get_rollback.jstree", $.proxy(function () {
1029
  this.dehover_node();
1030
  this.save_selected();
1031
  }, this))
1032
- .bind("set_rollback.jstree", $.proxy(function () {
1033
  this.reselect();
1034
  }, this))
1035
- .bind("close_node.jstree", $.proxy(function (event, data) {
1036
  var s = this._get_settings().ui,
1037
  obj = this._get_node(data.rslt.obj),
1038
  clk = (obj && obj.length) ? obj.children("ul").find("a.jstree-clicked") : $(),
1039
  _this = this;
1040
  if(s.selected_parent_close === false || !clk.length) { return; }
1041
- clk.each(function () {
1042
  _this.deselect_node(this);
1043
  if(s.selected_parent_close === "select_parent") { _this.select_node(obj); }
1044
  });
1045
  }, this))
1046
- .bind("delete_node.jstree", $.proxy(function (event, data) {
1047
  var s = this._get_settings().ui.select_prev_on_delete,
1048
  obj = this._get_node(data.rslt.obj),
1049
  clk = (obj && obj.length) ? obj.find("a.jstree-clicked") : [],
1050
  _this = this;
1051
  clk.each(function () { _this.deselect_node(this); });
1052
- if(s && clk.length) {
1053
- data.rslt.prev.each(function () {
1054
  if(this.parentNode) { _this.select_node(this); return false; /* if return false is removed all prev nodes will be selected */}
1055
  });
1056
  }
1057
  }, this))
1058
- .bind("move_node.jstree", $.proxy(function (event, data) {
1059
- if(data.rslt.cy) {
1060
  data.rslt.oc.find("a.jstree-clicked").removeClass("jstree-clicked");
1061
  }
1062
  }, this));
@@ -1071,13 +1078,13 @@
1071
  disable_selecting_children : false,
1072
  initially_select : []
1073
  },
1074
- _fn : {
1075
  _get_node : function (obj, allow_multiple) {
1076
  if(typeof obj === "undefined" || obj === null) { return allow_multiple ? this.data.ui.selected : this.data.ui.last_selected; }
1077
- var $obj = $(obj, this.get_container());
1078
- if($obj.is(".jstree") || obj == -1) { return -1; }
1079
- $obj = $obj.closest("li", this.get_container());
1080
- return $obj.length ? $obj : false;
1081
  },
1082
  _ui_notify : function (n, data) {
1083
  if(data.selected) {
@@ -1129,7 +1136,7 @@
1129
  proceed = true,
1130
  t = this;
1131
  if(check) {
1132
- if(s.disable_selecting_children && is_multiple &&
1133
  (
1134
  (obj.parentsUntil(".jstree","li").children("a.jstree-clicked").length) ||
1135
  (obj.children("ul").find("a.jstree-clicked:eq(0)").length)
@@ -1154,22 +1161,22 @@
1154
  proceed = false;
1155
  }
1156
  break;
1157
- case (is_selected && !is_multiple):
1158
  this.deselect_all();
1159
  is_selected = false;
1160
  proceed = true;
1161
  break;
1162
- case (!is_selected && !is_multiple):
1163
  if(s.select_limit == -1 || s.select_limit > 0) {
1164
  this.deselect_all();
1165
  proceed = true;
1166
  }
1167
  break;
1168
- case (is_selected && is_multiple):
1169
  this.deselect_node(obj);
1170
  break;
1171
- case (!is_selected && is_multiple):
1172
- if(s.select_limit == -1 || this.data.ui.selected.length + 1 <= s.select_limit) {
1173
  proceed = true;
1174
  }
1175
  break;
@@ -1192,11 +1199,11 @@
1192
  obj = this._get_node(obj);
1193
  if(!obj || obj === -1 || !obj.length || !obj.is(":visible")) { return; }
1194
  t = obj.offset().top - this.get_container().offset().top;
1195
- if(t < 0) {
1196
- c.scrollTop = c.scrollTop + t - 1;
1197
  }
1198
- if(t + this.data.core.li_height + (c.scrollWidth > c.offsetWidth ? scrollbar_width : 0) > c.offsetHeight) {
1199
- c.scrollTop = c.scrollTop + (t - c.offsetHeight + this.data.core.li_height + 1 + (c.scrollWidth > c.offsetWidth ? scrollbar_width : 0));
1200
  }
1201
  }
1202
  },
@@ -1217,8 +1224,8 @@
1217
  else { this.select_node(obj); }
1218
  },
1219
  is_selected : function (obj) { return this.data.ui.selected.index(this._get_node(obj)) >= 0; },
1220
- get_selected : function (context) {
1221
- return context ? $(context).find("a.jstree-clicked").parent() : this.data.ui.selected;
1222
  },
1223
  deselect_all : function (context) {
1224
  var ret = context ? $(context).find("a.jstree-clicked").parent() : this.get_container().find("a.jstree-clicked").parent();
@@ -1234,15 +1241,15 @@
1234
  })(jQuery);
1235
  //*/
1236
 
1237
- /*
1238
  * jsTree CRRM plugin
1239
  * Handles creating/renaming/removing/moving nodes by user interaction.
1240
  */
1241
  (function ($) {
1242
- $.jstree.plugin("crrm", {
1243
  __init : function () {
1244
  this.get_container()
1245
- .bind("move_node.jstree", $.proxy(function (e, data) {
1246
  if(this._get_settings().crrm.move.open_onmove) {
1247
  var t = this;
1248
  data.rslt.np.parentsUntil(".jstree").andSelf().filter(".jstree-closed").each(function () {
@@ -1270,7 +1277,7 @@
1270
  t = this.get_text(obj),
1271
  h1 = $("<div />", { css : { "position" : "absolute", "top" : "-200px", "left" : (rtl ? "0px" : "-1000px"), "visibility" : "hidden" } }).appendTo("body"),
1272
  h2 = obj.css("position","relative").append(
1273
- $("<input />", {
1274
  "value" : t,
1275
  "class" : "jstree-rename-input",
1276
  // "size" : t.length,
@@ -1309,7 +1316,7 @@
1309
  if(key == 13) { return false; }
1310
  }
1311
  })
1312
- ).children(".jstree-rename-input");
1313
  this.set_text(obj, "");
1314
  h1.css({
1315
  fontFamily : h2.css('fontFamily') || '',
@@ -1327,7 +1334,7 @@
1327
  obj = this._get_node(obj);
1328
  this.__rollback();
1329
  var f = this.__callback;
1330
- this._show_input(obj, function (obj, new_name, old_name) {
1331
  f.call(this, { "obj" : obj, "new_name" : new_name, "old_name" : old_name });
1332
  });
1333
  },
@@ -1341,8 +1348,8 @@
1341
  pos = $(t).index();
1342
  if(callback) { callback.call(this, t); }
1343
  if(p.length && p.hasClass("jstree-closed")) { this.open_node(p, false, true); }
1344
- if(!skip_rename) {
1345
- this._show_input(t, function (obj, new_name, old_name) {
1346
  _this.__callback({ "obj" : obj, "name" : new_name, "parent" : p, "position" : pos });
1347
  });
1348
  }
@@ -1365,7 +1372,7 @@
1365
  },
1366
  move_node : function (obj, ref, position, is_copy, is_prepared, skip_check) {
1367
  var s = this._get_settings().crrm.move;
1368
- if(!is_prepared) {
1369
  if(typeof position === "undefined") { position = s.default_position; }
1370
  if(position === "inside" && !s.default_position.match(/^(before|after)$/)) { position = s.default_position; }
1371
  return this.__call_old(true, obj, ref, position, is_copy, false, skip_check);
@@ -1391,7 +1398,7 @@
1391
  this.data.crrm.cp_nodes = obj;
1392
  this.__callback({ "obj" : obj });
1393
  },
1394
- paste : function (obj) {
1395
  obj = this._get_node(obj);
1396
  if(!obj || !obj.length) { return false; }
1397
  var nodes = this.data.crrm.ct_nodes ? this.data.crrm.ct_nodes : this.data.crrm.cp_nodes;
@@ -1407,7 +1414,7 @@
1407
  })(jQuery);
1408
  //*/
1409
 
1410
- /*
1411
  * jsTree themes plugin
1412
  * Handles loading and setting themes, as well as detecting path to themes, etc.
1413
  */
@@ -1416,15 +1423,15 @@
1416
  // this variable stores the path to the themes folder - if left as false - it will be autodetected
1417
  $.jstree._themes = false;
1418
  $.jstree.plugin("themes", {
1419
- __init : function () {
1420
  this.get_container()
1421
- .bind("init.jstree", $.proxy(function () {
1422
  var s = this._get_settings().themes;
1423
- this.data.themes.dots = s.dots;
1424
- this.data.themes.icons = s.icons;
1425
  this.set_theme(s.theme, s.url);
1426
  }, this))
1427
- .bind("loaded.jstree", $.proxy(function () {
1428
  // bound here too, as simple HTML tree's won't honor dots & icons otherwise
1429
  if(!this.data.themes.dots) { this.hide_dots(); }
1430
  else { this.show_dots(); }
@@ -1432,8 +1439,8 @@
1432
  else { this.show_icons(); }
1433
  }, this));
1434
  },
1435
- defaults : {
1436
- theme : "default",
1437
  url : false,
1438
  dots : true,
1439
  icons : true
@@ -1471,10 +1478,10 @@
1471
  // autodetect themes path
1472
  $(function () {
1473
  if($.jstree._themes === false) {
1474
- $("script").each(function () {
1475
- if(this.src.toString().match(/jquery\.jstree[^\/]*?\.js(\?.*)?$/)) {
1476
- $.jstree._themes = this.src.toString().replace(/jquery\.jstree[^\/]*?\.js(\?.*)?$/, "") + 'themes/';
1477
- return false;
1478
  }
1479
  });
1480
  }
@@ -1494,7 +1501,7 @@
1494
  var bound = [];
1495
  function exec(i, event) {
1496
  var f = $.jstree._focused(), tmp;
1497
- if(f && f.data && f.data.hotkeys && f.data.hotkeys.enabled) {
1498
  tmp = f._get_settings().hotkeys[i];
1499
  if(tmp) { return tmp.call(f, event); }
1500
  }
@@ -1505,51 +1512,51 @@
1505
  if(!this.data.ui) { throw "jsTree hotkeys: jsTree UI plugin not included."; }
1506
  $.each(this._get_settings().hotkeys, function (i, v) {
1507
  if(v !== false && $.inArray(i, bound) == -1) {
1508
- $(document).bind("keydown", i, function (event) { return exec(i, event); });
1509
  bound.push(i);
1510
  }
1511
  });
1512
  this.get_container()
1513
- .bind("lock.jstree", $.proxy(function () {
1514
  if(this.data.hotkeys.enabled) { this.data.hotkeys.enabled = false; this.data.hotkeys.revert = true; }
1515
  }, this))
1516
- .bind("unlock.jstree", $.proxy(function () {
1517
  if(this.data.hotkeys.revert) { this.data.hotkeys.enabled = true; }
1518
  }, this));
1519
  this.enable_hotkeys();
1520
  },
1521
  defaults : {
1522
- "up" : function () {
1523
  var o = this.data.ui.hovered || this.data.ui.last_selected || -1;
1524
  this.hover_node(this._get_prev(o));
1525
- return false;
1526
  },
1527
- "ctrl+up" : function () {
1528
  var o = this.data.ui.hovered || this.data.ui.last_selected || -1;
1529
  this.hover_node(this._get_prev(o));
1530
- return false;
1531
  },
1532
- "shift+up" : function () {
1533
  var o = this.data.ui.hovered || this.data.ui.last_selected || -1;
1534
  this.hover_node(this._get_prev(o));
1535
- return false;
1536
  },
1537
- "down" : function () {
1538
  var o = this.data.ui.hovered || this.data.ui.last_selected || -1;
1539
  this.hover_node(this._get_next(o));
1540
  return false;
1541
  },
1542
- "ctrl+down" : function () {
1543
  var o = this.data.ui.hovered || this.data.ui.last_selected || -1;
1544
  this.hover_node(this._get_next(o));
1545
  return false;
1546
  },
1547
- "shift+down" : function () {
1548
  var o = this.data.ui.hovered || this.data.ui.last_selected || -1;
1549
  this.hover_node(this._get_next(o));
1550
  return false;
1551
  },
1552
- "left" : function () {
1553
  var o = this.data.ui.hovered || this.data.ui.last_selected;
1554
  if(o) {
1555
  if(o.hasClass("jstree-open")) { this.close_node(o); }
@@ -1557,7 +1564,7 @@
1557
  }
1558
  return false;
1559
  },
1560
- "ctrl+left" : function () {
1561
  var o = this.data.ui.hovered || this.data.ui.last_selected;
1562
  if(o) {
1563
  if(o.hasClass("jstree-open")) { this.close_node(o); }
@@ -1565,7 +1572,7 @@
1565
  }
1566
  return false;
1567
  },
1568
- "shift+left" : function () {
1569
  var o = this.data.ui.hovered || this.data.ui.last_selected;
1570
  if(o) {
1571
  if(o.hasClass("jstree-open")) { this.close_node(o); }
@@ -1573,7 +1580,7 @@
1573
  }
1574
  return false;
1575
  },
1576
- "right" : function () {
1577
  var o = this.data.ui.hovered || this.data.ui.last_selected;
1578
  if(o && o.length) {
1579
  if(o.hasClass("jstree-closed")) { this.open_node(o); }
@@ -1581,7 +1588,7 @@
1581
  }
1582
  return false;
1583
  },
1584
- "ctrl+right" : function () {
1585
  var o = this.data.ui.hovered || this.data.ui.last_selected;
1586
  if(o && o.length) {
1587
  if(o.hasClass("jstree-closed")) { this.open_node(o); }
@@ -1589,7 +1596,7 @@
1589
  }
1590
  return false;
1591
  },
1592
- "shift+right" : function () {
1593
  var o = this.data.ui.hovered || this.data.ui.last_selected;
1594
  if(o && o.length) {
1595
  if(o.hasClass("jstree-closed")) { this.open_node(o); }
@@ -1597,19 +1604,19 @@
1597
  }
1598
  return false;
1599
  },
1600
- "space" : function () {
1601
- if(this.data.ui.hovered) { this.data.ui.hovered.children("a:eq(0)").click(); }
1602
- return false;
1603
  },
1604
- "ctrl+space" : function (event) {
1605
  event.type = "click";
1606
- if(this.data.ui.hovered) { this.data.ui.hovered.children("a:eq(0)").trigger(event); }
1607
- return false;
1608
  },
1609
- "shift+space" : function (event) {
1610
  event.type = "click";
1611
- if(this.data.ui.hovered) { this.data.ui.hovered.children("a:eq(0)").trigger(event); }
1612
- return false;
1613
  },
1614
  "f2" : function () { this.rename(this.data.ui.hovered || this.data.ui.last_selected); },
1615
  "del" : function () { this.remove(this.data.ui.hovered || this._get_node(null)); }
@@ -1626,7 +1633,7 @@
1626
  })(jQuery);
1627
  //*/
1628
 
1629
- /*
1630
  * jsTree JSON plugin
1631
  * The JSON data store. Datastores are build by overriding the `load_node` and `_is_loaded` functions.
1632
  */
@@ -1635,16 +1642,16 @@
1635
  __init : function() {
1636
  var s = this._get_settings().json_data;
1637
  if(s.progressive_unload) {
1638
- this.get_container().bind("after_close.jstree", function (e, data) {
1639
  data.rslt.obj.children("ul").remove();
1640
  });
1641
  }
1642
  },
1643
- defaults : {
1644
  // `data` can be a function:
1645
  // * accepts two arguments - node being loaded and a callback to pass the result to
1646
  // * will be executed in the current tree's scope & ajax won't be supported
1647
- data : false,
1648
  ajax : false,
1649
  correct_state : true,
1650
  progressive_render : false,
@@ -1652,9 +1659,9 @@
1652
  },
1653
  _fn : {
1654
  load_node : function (obj, s_call, e_call) { var _this = this; this.load_node_json(obj, function () { _this.__callback({ "obj" : _this._get_node(obj) }); s_call.call(this); }, e_call); },
1655
- _is_loaded : function (obj) {
1656
  var s = this._get_settings().json_data;
1657
- obj = this._get_node(obj);
1658
  return obj == -1 || !obj || (!s.ajax && !s.progressive_render && !$.isFunction(s.data)) || obj.is(".jstree-open, .jstree-leaf") || obj.children("ul").children("li").length > 0;
1659
  },
1660
  refresh : function (obj) {
@@ -1692,7 +1699,7 @@
1692
  case ($.isFunction(s.data)):
1693
  s.data.call(this, obj, $.proxy(function (d) {
1694
  d = this._parse_json(d, obj);
1695
- if(!d) {
1696
  if(obj === -1 || !obj) {
1697
  if(s.correct_state) { this.get_container().children("ul").empty(); }
1698
  }
@@ -1718,7 +1725,7 @@
1718
  this.get_container().children("ul").empty().append(d.children());
1719
  this.clean_node();
1720
  }
1721
- else {
1722
  if(s.correct_state) { this.get_container().children("ul").empty(); }
1723
  }
1724
  }
@@ -1726,7 +1733,7 @@
1726
  break;
1727
  case (!s.data && !!s.ajax) || (!!s.data && !!s.ajax && obj && obj !== -1):
1728
  error_func = function (x, t, e) {
1729
- var ef = this.get_settings().json_data.ajax.error;
1730
  if(ef) { ef.call(this, x, t, e); }
1731
  if(obj != -1 && obj.length) {
1732
  obj.children("a.jstree-loading").removeClass("jstree-loading");
@@ -1739,9 +1746,9 @@
1739
  if(e_call) { e_call.call(this); }
1740
  };
1741
  success_func = function (d, t, x) {
1742
- var sf = this.get_settings().json_data.ajax.success;
1743
  if(sf) { d = sf.call(this,d,t,x) || d; }
1744
- if(d === "" || (d && d.toString && d.toString().replace(/^[\s\n]+$/,"") === "") || (!$.isArray(d) && !$.isPlainObject(d))) {
1745
  return error_func.call(this, x, t, "");
1746
  }
1747
  d = this._parse_json(d, obj);
@@ -1753,17 +1760,17 @@
1753
  }
1754
  else {
1755
  if(obj === -1 || !obj) {
1756
- if(s.correct_state) {
1757
- this.get_container().children("ul").empty();
1758
  if(s_call) { s_call.call(this); }
1759
  }
1760
  }
1761
  else {
1762
  obj.children("a.jstree-loading").removeClass("jstree-loading");
1763
  obj.removeData("jstree-is-loading");
1764
- if(s.correct_state) {
1765
  this.correct_state(obj);
1766
- if(s_call) { s_call.call(this); }
1767
  }
1768
  }
1769
  }
@@ -1779,17 +1786,17 @@
1779
  }
1780
  },
1781
  _parse_json : function (js, obj, is_callback) {
1782
- var d = false,
1783
  p = this._get_settings(),
1784
  s = p.json_data,
1785
  t = p.core.html_titles,
1786
  tmp, i, j, ul1, ul2;
1787
 
1788
  if(!js) { return d; }
1789
- if(s.progressive_unload && obj && obj !== -1) {
1790
  obj.data("jstree-children", d);
1791
  }
1792
- if($.isArray(js)) {
1793
  d = $();
1794
  if(!js.length) { return false; }
1795
  for(i = 0, j = js.length; i < j; i++) {
@@ -1804,7 +1811,7 @@
1804
  if(js.attr) { d.attr(js.attr); }
1805
  if(js.metadata) { d.data(js.metadata); }
1806
  if(js.state) { d.addClass("jstree-" + js.state); }
1807
- if(!$.isArray(js.data)) { tmp = js.data; js.data = []; js.data.push(tmp); }
1808
  $.each(js.data, function (i, m) {
1809
  tmp = $("<a />");
1810
  if($.isFunction(m)) { m = m.call(this, js); }
@@ -1817,20 +1824,20 @@
1817
  }
1818
  tmp.prepend("<ins class='jstree-icon'>&#160;</ins>");
1819
  if(!m.icon && js.icon) { m.icon = js.icon; }
1820
- if(m.icon) {
1821
  if(m.icon.indexOf("/") === -1) { tmp.children("ins").addClass(m.icon); }
1822
  else { tmp.children("ins").css("background","url('" + m.icon + "') center center no-repeat"); }
1823
  }
1824
  d.append(tmp);
1825
  });
1826
  d.prepend("<ins class='jstree-icon'>&#160;</ins>");
1827
- if(js.children) {
1828
  if(s.progressive_render && js.state !== "open") {
1829
  d.addClass("jstree-closed").data("jstree-children", js.children);
1830
  }
1831
  else {
1832
  if(s.progressive_unload) { d.data("jstree-children", js.children); }
1833
- if($.isArray(js.children) && js.children.length) {
1834
  tmp = this._parse_json(js.children, obj, true);
1835
  if(tmp.length) {
1836
  ul2 = $("<ul />");
@@ -1849,24 +1856,24 @@
1849
  return d;
1850
  },
1851
  get_json : function (obj, li_attr, a_attr, is_callback) {
1852
- var result = [],
1853
- s = this._get_settings(),
1854
  _this = this,
1855
  tmp1, tmp2, li, a, t, lang;
1856
  obj = this._get_node(obj);
1857
  if(!obj || obj === -1) { obj = this.get_container().find("> ul > li"); }
1858
- li_attr = $.isArray(li_attr) ? li_attr : [ "id", "class" ];
1859
  if(!is_callback && this.data.types) { li_attr.push(s.types.type_attr); }
1860
- a_attr = $.isArray(a_attr) ? a_attr : [ ];
1861
 
1862
  obj.each(function () {
1863
  li = $(this);
1864
  tmp1 = { data : [] };
1865
  if(li_attr.length) { tmp1.attr = { }; }
1866
- $.each(li_attr, function (i, v) {
1867
- tmp2 = li.attr(v);
1868
  if(tmp2 && tmp2.length && tmp2.replace(/jstree[^ ]*/ig,'').length) {
1869
- tmp1.attr[v] = (" " + tmp2).replace(/ jstree[^ ]*/ig,'').replace(/\s+$/ig," ").replace(/^ /,"").replace(/ $/,"");
1870
  }
1871
  });
1872
  if(li.hasClass("jstree-open")) { tmp1.state = "open"; }
@@ -1876,13 +1883,13 @@
1876
  a.each(function () {
1877
  t = $(this);
1878
  if(
1879
- a_attr.length ||
1880
- $.inArray("languages", s.plugins) !== -1 ||
1881
- t.children("ins").get(0).style.backgroundImage.length ||
1882
  (t.children("ins").get(0).className && t.children("ins").get(0).className.replace(/jstree[^ ]*|$/ig,'').length)
1883
- ) {
1884
  lang = false;
1885
- if($.inArray("languages", s.plugins) !== -1 && $.isArray(s.languages) && s.languages.length) {
1886
  $.each(s.languages, function (l, lv) {
1887
  if(t.hasClass(lv)) {
1888
  lang = lv;
@@ -1890,11 +1897,11 @@
1890
  }
1891
  });
1892
  }
1893
- tmp2 = { attr : { }, title : _this.get_text(t, lang) };
1894
  $.each(a_attr, function (k, z) {
1895
  tmp2.attr[z] = (" " + (t.attr(z) || "")).replace(/ jstree[^ ]*/ig,'').replace(/\s+$/ig," ").replace(/^ /,"").replace(/ $/,"");
1896
  });
1897
- if($.inArray("languages", s.plugins) !== -1 && $.isArray(s.languages) && s.languages.length) {
1898
  $.each(s.languages, function (k, z) {
1899
  if(t.hasClass(z)) { tmp2.language = z; return true; }
1900
  });
@@ -1923,7 +1930,7 @@
1923
  })(jQuery);
1924
  //*/
1925
 
1926
- /*
1927
  * jsTree languages plugin
1928
  * Adds support for multiple language versions in one tree
1929
  * This basically allows for many titles coexisting in one node, but only one of them being visible at any given time
@@ -1934,11 +1941,11 @@
1934
  __init : function () { this._load_css(); },
1935
  defaults : [],
1936
  _fn : {
1937
- set_lang : function (i) {
1938
  var langs = this._get_settings().languages,
1939
  st = false,
1940
  selector = ".jstree-" + this.get_index() + ' a';
1941
- if(!$.isArray(langs) || langs.length === 0) { return false; }
1942
  if($.inArray(i,langs) == -1) {
1943
  if(!!langs[i]) { i = langs[i]; }
1944
  else { return false; }
@@ -1958,7 +1965,7 @@
1958
  _get_string : function (key, lang) {
1959
  var langs = this._get_settings().languages,
1960
  s = this._get_settings().core.strings;
1961
- if($.isArray(langs) && langs.length) {
1962
  lang = (lang && $.inArray(lang,langs) != -1) ? lang : this.data.languages.current_language;
1963
  }
1964
  if(s[lang] && s[lang][key]) { return s[lang][key]; }
@@ -1970,7 +1977,7 @@
1970
  if(!obj.size()) { return false; }
1971
  var langs = this._get_settings().languages,
1972
  s = this._get_settings().core.html_titles;
1973
- if($.isArray(langs) && langs.length) {
1974
  lang = (lang && $.inArray(lang,langs) != -1) ? lang : this.data.languages.current_language;
1975
  obj = obj.children("a." + lang);
1976
  }
@@ -1991,7 +1998,7 @@
1991
  var langs = this._get_settings().languages,
1992
  s = this._get_settings().core.html_titles,
1993
  tmp;
1994
- if($.isArray(langs) && langs.length) {
1995
  lang = (lang && $.inArray(lang,langs) != -1) ? lang : this.data.languages.current_language;
1996
  obj = obj.children("a." + lang);
1997
  }
@@ -2013,7 +2020,7 @@
2013
  str = "/* languages css */",
2014
  selector = ".jstree-" + this.get_index() + ' a',
2015
  ln;
2016
- if($.isArray(langs) && langs.length) {
2017
  this.data.languages.current_language = langs[0];
2018
  for(ln = 0; ln < langs.length; ln++) {
2019
  str += selector + "." + langs[ln] + " {";
@@ -2028,7 +2035,7 @@
2028
  var langs = this._get_settings().languages,
2029
  a = t.children("a"),
2030
  ln;
2031
- if($.isArray(langs) && langs.length) {
2032
  for(ln = 0; ln < langs.length; ln++) {
2033
  if(!a.is("." + langs[ln])) {
2034
  t.append(a.eq(0).clone().removeClass(langs.join(" ")).addClass(langs[ln]));
@@ -2072,7 +2079,7 @@
2072
  this.get_container()
2073
  .one( ( this.data.ui ? "reselect" : "reopen" ) + ".jstree", $.proxy(function () {
2074
  this.get_container()
2075
- .bind("open_node.jstree close_node.jstree select_node.jstree deselect_node.jstree", $.proxy(function (e) {
2076
  if(this._get_settings().cookies.auto_save) { this.save_cookie((e.handleObj.namespace + e.handleObj.type).replace("jstree","")); }
2077
  }, this));
2078
  }, this));
@@ -2106,20 +2113,20 @@
2106
  switch(c) {
2107
  case "open_node":
2108
  case "close_node":
2109
- if(!!s.save_opened) {
2110
- this.save_opened();
2111
- $.cookie(s.save_opened, this.data.core.to_open.join(","), s.cookie_options);
2112
  }
2113
- if(!!s.save_loaded) {
2114
- this.save_loaded();
2115
- $.cookie(s.save_loaded, this.data.core.to_load.join(","), s.cookie_options);
2116
  }
2117
  break;
2118
  case "select_node":
2119
  case "deselect_node":
2120
- if(!!s.save_selected && this.data.ui) {
2121
- this.save_selected();
2122
- $.cookie(s.save_selected, this.data.ui.to_select.join(","), s.cookie_options);
2123
  }
2124
  break;
2125
  }
@@ -2139,15 +2146,15 @@
2139
  $.jstree.plugin("sort", {
2140
  __init : function () {
2141
  this.get_container()
2142
- .bind("load_node.jstree", $.proxy(function (e, data) {
2143
  var obj = this._get_node(data.rslt.obj);
2144
  obj = obj === -1 ? this.get_container().children("ul") : obj.children("ul");
2145
  this.sort(obj);
2146
  }, this))
2147
- .bind("rename_node.jstree create_node.jstree create.jstree", $.proxy(function (e, data) {
2148
  this.sort(data.rslt.obj.parent());
2149
  }, this))
2150
- .bind("move_node.jstree", $.proxy(function (e, data) {
2151
  var m = data.rslt.np == -1 ? this.get_container() : data.rslt.np;
2152
  this.sort(m.children("ul"));
2153
  }, this));
@@ -2192,7 +2199,7 @@
2192
  helper_top : 10,
2193
  user_data : {},
2194
 
2195
- drag_start : function (e, data, html) {
2196
  if($.vakata.dnd.is_drag) { $.vakata.drag_stop({}); }
2197
  try {
2198
  e.currentTarget.unselectable = "on";
@@ -2204,14 +2211,14 @@
2204
  $.vakata.dnd.user_data = data;
2205
  $.vakata.dnd.is_down = true;
2206
  $.vakata.dnd.helper = $("<div id='vakata-dragged' />").html(html); //.fadeTo(10,0.25);
2207
- $(document).bind("mousemove", $.vakata.dnd.drag);
2208
- $(document).bind("mouseup", $.vakata.dnd.drag_stop);
2209
  return false;
2210
  },
2211
- drag : function (e) {
2212
  if(!$.vakata.dnd.is_down) { return; }
2213
  if(!$.vakata.dnd.is_drag) {
2214
- if(Math.abs(e.pageX - $.vakata.dnd.init_x) > 5 || Math.abs(e.pageY - $.vakata.dnd.init_y) > 5) {
2215
  $.vakata.dnd.helper.appendTo("body");
2216
  $.vakata.dnd.is_drag = true;
2217
  $(document).triggerHandler("drag_start.vakata", { "event" : e, "data" : $.vakata.dnd.user_data });
@@ -2222,18 +2229,18 @@
2222
  // maybe use a scrolling parent element instead of document?
2223
  if(e.type === "mousemove") { // thought of adding scroll in order to move the helper, but mouse poisition is n/a
2224
  var d = $(document), t = d.scrollTop(), l = d.scrollLeft();
2225
- if(e.pageY - t < 20) {
2226
  if(sti && dir1 === "down") { clearInterval(sti); sti = false; }
2227
  if(!sti) { dir1 = "up"; sti = setInterval(function () { $(document).scrollTop($(document).scrollTop() - $.vakata.dnd.scroll_spd); }, 150); }
2228
  }
2229
- else {
2230
  if(sti && dir1 === "up") { clearInterval(sti); sti = false; }
2231
  }
2232
  if($(window).height() - (e.pageY - t) < 20) {
2233
  if(sti && dir1 === "up") { clearInterval(sti); sti = false; }
2234
  if(!sti) { dir1 = "down"; sti = setInterval(function () { $(document).scrollTop($(document).scrollTop() + $.vakata.dnd.scroll_spd); }, 150); }
2235
  }
2236
- else {
2237
  if(sti && dir1 === "down") { clearInterval(sti); sti = false; }
2238
  }
2239
 
@@ -2241,14 +2248,14 @@
2241
  if(sli && dir2 === "right") { clearInterval(sli); sli = false; }
2242
  if(!sli) { dir2 = "left"; sli = setInterval(function () { $(document).scrollLeft($(document).scrollLeft() - $.vakata.dnd.scroll_spd); }, 150); }
2243
  }
2244
- else {
2245
  if(sli && dir2 === "left") { clearInterval(sli); sli = false; }
2246
  }
2247
  if($(window).width() - (e.pageX - l) < 20) {
2248
  if(sli && dir2 === "left") { clearInterval(sli); sli = false; }
2249
  if(!sli) { dir2 = "right"; sli = setInterval(function () { $(document).scrollLeft($(document).scrollLeft() + $.vakata.dnd.scroll_spd); }, 150); }
2250
  }
2251
- else {
2252
  if(sli && dir2 === "right") { clearInterval(sli); sli = false; }
2253
  }
2254
  }
@@ -2295,10 +2302,10 @@
2295
  mto : false
2296
  };
2297
  this.get_container()
2298
- .bind("mouseenter.jstree", $.proxy(function (e) {
2299
  if($.vakata.dnd.is_drag && $.vakata.dnd.user_data.jstree) {
2300
  if(this.data.themes) {
2301
- m.attr("class", "jstree-" + this.data.themes.theme);
2302
  if(ml) { ml.attr("class", "jstree-" + this.data.themes.theme); }
2303
  $.vakata.dnd.helper.attr("class", "jstree-dnd-helper jstree-" + this.data.themes.theme);
2304
  }
@@ -2320,7 +2327,7 @@
2320
  }
2321
  }
2322
  }, this))
2323
- .bind("mouseup.jstree", $.proxy(function (e) {
2324
  //if($.vakata.dnd.is_drag && $.vakata.dnd.user_data.jstree && $(e.currentTarget).find("> ul > li").length === 0) {
2325
  if($.vakata.dnd.is_drag && $.vakata.dnd.user_data.jstree && e.currentTarget === e.target && $.vakata.dnd.user_data.obj && $($.vakata.dnd.user_data.obj).length && $($.vakata.dnd.user_data.obj).parents(".jstree:eq(0)")[0] !== e.target) { // node should not be from the same tree
2326
  var tr = $.jstree._reference(e.currentTarget), dc;
@@ -2335,9 +2342,9 @@
2335
  }
2336
  }
2337
  }, this))
2338
- .bind("mouseleave.jstree", $.proxy(function (e) {
2339
  if(e.relatedTarget && e.relatedTarget.id && e.relatedTarget.id === "jstree-marker-line") {
2340
- return false;
2341
  }
2342
  if($.vakata.dnd.is_drag && $.vakata.dnd.user_data.jstree) {
2343
  if(this.data.dnd.i1) { clearInterval(this.data.dnd.i1); }
@@ -2349,7 +2356,7 @@
2349
  }
2350
  }
2351
  }, this))
2352
- .bind("mousemove.jstree", $.proxy(function (e) {
2353
  if($.vakata.dnd.is_drag && $.vakata.dnd.user_data.jstree) {
2354
  var cnt = this.get_container()[0];
2355
 
@@ -2381,24 +2388,24 @@
2381
 
2382
  }
2383
  }, this))
2384
- .bind("scroll.jstree", $.proxy(function (e) {
2385
  if($.vakata.dnd.is_drag && $.vakata.dnd.user_data.jstree && m && ml) {
2386
  m.hide();
2387
  ml.hide();
2388
  }
2389
  }, this))
2390
- .delegate("a", "mousedown.jstree", $.proxy(function (e) {
2391
  if(e.which === 1) {
2392
  this.start_drag(e.currentTarget, e);
2393
  return false;
2394
  }
2395
  }, this))
2396
- .delegate("a", "mouseenter.jstree", $.proxy(function (e) {
2397
  if($.vakata.dnd.is_drag && $.vakata.dnd.user_data.jstree) {
2398
  this.dnd_enter(e.currentTarget);
2399
  }
2400
  }, this))
2401
- .delegate("a", "mousemove.jstree", $.proxy(function (e) {
2402
  if($.vakata.dnd.is_drag && $.vakata.dnd.user_data.jstree) {
2403
  if(!r || !r.length || r.children("a")[0] !== e.currentTarget) {
2404
  this.dnd_enter(e.currentTarget);
@@ -2409,34 +2416,34 @@
2409
  this.dnd_show();
2410
  }
2411
  }, this))
2412
- .delegate("a", "mouseleave.jstree", $.proxy(function (e) {
2413
  if($.vakata.dnd.is_drag && $.vakata.dnd.user_data.jstree) {
2414
  if(e.relatedTarget && e.relatedTarget.id && e.relatedTarget.id === "jstree-marker-line") {
2415
- return false;
2416
  }
2417
  if(m) { m.hide(); }
2418
  if(ml) { ml.hide(); }
2419
  /*
2420
- var ec = $(e.currentTarget).closest("li"),
2421
  er = $(e.relatedTarget).closest("li");
2422
  if(er[0] !== ec.prev()[0] && er[0] !== ec.next()[0]) {
2423
  if(m) { m.hide(); }
2424
  if(ml) { ml.hide(); }
2425
  }
2426
  */
2427
- this.data.dnd.mto = setTimeout(
2428
  (function (t) { return function () { t.dnd_leave(e); }; })(this),
2429
  0);
2430
  }
2431
  }, this))
2432
- .delegate("a", "mouseup.jstree", $.proxy(function (e) {
2433
  if($.vakata.dnd.is_drag && $.vakata.dnd.user_data.jstree) {
2434
  this.dnd_finish(e);
2435
  }
2436
  }, this));
2437
 
2438
  $(document)
2439
- .bind("drag_stop.vakata", $.proxy(function () {
2440
  if(this.data.dnd.to1) { clearTimeout(this.data.dnd.to1); }
2441
  if(this.data.dnd.to2) { clearTimeout(this.data.dnd.to2); }
2442
  if(this.data.dnd.i1) { clearInterval(this.data.dnd.i1); }
@@ -2456,8 +2463,8 @@
2456
  if(m) { m.css({ "top" : "-2000px" }); }
2457
  if(ml) { ml.css({ "top" : "-2000px" }); }
2458
  }, this))
2459
- .bind("drag_start.vakata", $.proxy(function (e, data) {
2460
- if(data.data.jstree) {
2461
  var et = $(data.event.target);
2462
  if(et.closest(".jstree").hasClass("jstree-" + this.get_index())) {
2463
  this.dnd_enter(et);
@@ -2465,12 +2472,12 @@
2465
  }
2466
  }, this));
2467
  /*
2468
- .bind("keydown.jstree-" + this.get_index() + " keyup.jstree-" + this.get_index(), $.proxy(function(e) {
2469
  if($.vakata.dnd.is_drag && $.vakata.dnd.user_data.jstree && !this.data.dnd.foreign) {
2470
  var h = $.vakata.dnd.helper.children("ins");
2471
  if(e[this._get_settings().dnd.copy_modifier + "Key"] && h.hasClass("jstree-ok")) {
2472
  h.parent().html(h.parent().html().replace(/ \(Copy\)$/, "") + " (Copy)");
2473
- }
2474
  else {
2475
  h.parent().html(h.parent().html().replace(/ \(Copy\)$/, ""));
2476
  }
@@ -2482,13 +2489,13 @@
2482
  var s = this._get_settings().dnd;
2483
  if(s.drag_target) {
2484
  $(document)
2485
- .delegate(s.drag_target, "mousedown.jstree-" + this.get_index(), $.proxy(function (e) {
2486
  o = e.target;
2487
  $.vakata.dnd.drag_start(e, { jstree : true, obj : e.target }, "<ins class='jstree-icon'></ins>" + $(e.target).text() );
2488
- if(this.data.themes) {
2489
  if(m) { m.attr("class", "jstree-" + this.data.themes.theme); }
2490
  if(ml) { ml.attr("class", "jstree-" + this.data.themes.theme); }
2491
- $.vakata.dnd.helper.attr("class", "jstree-dnd-helper jstree-" + this.data.themes.theme);
2492
  }
2493
  $.vakata.dnd.helper.children("ins").attr("class","jstree-invalid");
2494
  var cnt = this.get_container();
@@ -2501,17 +2508,17 @@
2501
  }
2502
  if(s.drop_target) {
2503
  $(document)
2504
- .delegate(s.drop_target, "mouseenter.jstree-" + this.get_index(), $.proxy(function (e) {
2505
  if(this.data.dnd.active && this._get_settings().dnd.drop_check.call(this, { "o" : o, "r" : $(e.target), "e" : e })) {
2506
  $.vakata.dnd.helper.children("ins").attr("class","jstree-ok");
2507
  }
2508
  }, this))
2509
- .delegate(s.drop_target, "mouseleave.jstree-" + this.get_index(), $.proxy(function (e) {
2510
  if(this.data.dnd.active) {
2511
  $.vakata.dnd.helper.children("ins").attr("class","jstree-invalid");
2512
  }
2513
  }, this))
2514
- .delegate(s.drop_target, "mouseup.jstree-" + this.get_index(), $.proxy(function (e) {
2515
  if(this.data.dnd.active && $.vakata.dnd.helper.children("ins").hasClass("jstree-ok")) {
2516
  this._get_settings().dnd.drop_finish.call(this, { "o" : o, "r" : $(e.target), "e" : e });
2517
  }
@@ -2569,7 +2576,7 @@
2569
  o = this.data.dnd.w < this.data.core.li_height/2 ? ["inside","before","after"] : ["inside","after","before"];
2570
  }
2571
  else { o = ["after","inside","before"]; }
2572
- $.each(o, $.proxy(function (i, val) {
2573
  if(this.data.dnd[val]) {
2574
  $.vakata.dnd.helper.children("ins").attr("class","jstree-ok");
2575
  r = val;
@@ -2577,7 +2584,7 @@
2577
  }
2578
  }, this));
2579
  if(r === false) { $.vakata.dnd.helper.children("ins").attr("class","jstree-invalid"); }
2580
-
2581
  pos = rtl ? (this.data.dnd.off.right - 18) : (this.data.dnd.off.left + 10);
2582
  switch(r) {
2583
  case "before":
@@ -2620,30 +2627,30 @@
2620
  if(ml) { ml.hide(); }
2621
  },
2622
  dnd_enter : function (obj) {
2623
- if(this.data.dnd.mto) {
2624
  clearTimeout(this.data.dnd.mto);
2625
  this.data.dnd.mto = false;
2626
  }
2627
  var s = this._get_settings().dnd;
2628
  this.data.dnd.prepared = false;
2629
  r = this._get_node(obj);
2630
- if(s.check_timeout) {
2631
  // do the calculations after a minimal timeout (users tend to drag quickly to the desired location)
2632
  if(this.data.dnd.to1) { clearTimeout(this.data.dnd.to1); }
2633
- this.data.dnd.to1 = setTimeout($.proxy(this.dnd_prepare, this), s.check_timeout);
2634
  }
2635
- else {
2636
- this.dnd_prepare();
2637
  }
2638
- if(s.open_timeout) {
2639
  if(this.data.dnd.to2) { clearTimeout(this.data.dnd.to2); }
2640
- if(r && r.length && r.hasClass("jstree-closed")) {
2641
  // if the node is closed - open it, then recalculate
2642
  this.data.dnd.to2 = setTimeout($.proxy(this.dnd_open, this), s.open_timeout);
2643
  }
2644
  }
2645
  else {
2646
- if(r && r.length && r.hasClass("jstree-closed")) {
2647
  this.dnd_open();
2648
  }
2649
  }
@@ -2673,10 +2680,10 @@
2673
  cnt = this.get_container();
2674
  if(!this._get_settings().core.html_titles) { dt = dt.replace(/</ig,"&lt;").replace(/>/ig,"&gt;"); }
2675
  $.vakata.dnd.drag_start(e, { jstree : true, obj : o }, "<ins class='jstree-icon'></ins>" + dt );
2676
- if(this.data.themes) {
2677
  if(m) { m.attr("class", "jstree-" + this.data.themes.theme); }
2678
  if(ml) { ml.attr("class", "jstree-" + this.data.themes.theme); }
2679
- $.vakata.dnd.helper.attr("class", "jstree-dnd-helper jstree-" + this.data.themes.theme);
2680
  }
2681
  this.data.dnd.cof = cnt.offset();
2682
  this.data.dnd.cw = parseInt(cnt.width(),10);
@@ -2686,55 +2693,55 @@
2686
  }
2687
  });
2688
  $(function() {
2689
- var css_string = '' +
2690
- '#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; ' +
2691
  ' -moz-border-radius:4px; border-radius:4px; -webkit-border-radius:4px; ' +
2692
- '} ' +
2693
- '#vakata-dragged .jstree-ok { background:green; } ' +
2694
- '#vakata-dragged .jstree-invalid { background:red; } ' +
2695
- '#jstree-marker { padding:0; margin:0; font-size:12px; overflow:hidden; height:12px; width:8px; position:absolute; top:-30px; z-index:10001; background-repeat:no-repeat; display:none; background-color:transparent; text-shadow:1px 1px 1px white; color:black; line-height:10px; } ' +
2696
- '#jstree-marker-line { padding:0; margin:0; line-height:0%; font-size:1px; overflow:hidden; height:1px; width:100px; position:absolute; top:-30px; z-index:10000; background-repeat:no-repeat; display:none; background-color:#456c43; ' +
2697
- ' cursor:pointer; border:1px solid #eeeeee; border-left:0; -moz-box-shadow: 0px 0px 2px #666; -webkit-box-shadow: 0px 0px 2px #666; box-shadow: 0px 0px 2px #666; ' +
2698
  ' -moz-border-radius:1px; border-radius:1px; -webkit-border-radius:1px; ' +
2699
- '}' +
2700
  '';
2701
  $.vakata.css.add_sheet({ str : css_string, title : "jstree" });
2702
  m = $("<div />").attr({ id : "jstree-marker" }).hide().html("&raquo;")
2703
- .bind("mouseleave mouseenter", function (e) {
2704
  m.hide();
2705
  ml.hide();
2706
- e.preventDefault();
2707
- e.stopImmediatePropagation();
2708
- return false;
2709
  })
2710
  .appendTo("body");
2711
  ml = $("<div />").attr({ id : "jstree-marker-line" }).hide()
2712
- .bind("mouseup", function (e) {
2713
- if(r && r.length) {
2714
- r.children("a").trigger(e);
2715
- e.preventDefault();
2716
- e.stopImmediatePropagation();
2717
- return false;
2718
- }
2719
  })
2720
- .bind("mouseleave", function (e) {
2721
  var rt = $(e.relatedTarget);
2722
  if(rt.is(".jstree") || rt.closest(".jstree").length === 0) {
2723
- if(r && r.length) {
2724
- r.children("a").trigger(e);
2725
  m.hide();
2726
  ml.hide();
2727
- e.preventDefault();
2728
- e.stopImmediatePropagation();
2729
- return false;
2730
  }
2731
  }
2732
  })
2733
  .appendTo("body");
2734
- $(document).bind("drag_start.vakata", function (e, data) {
2735
  if(data.data.jstree) { m.show(); if(ml) { ml.show(); } }
2736
  });
2737
- $(document).bind("drag_stop.vakata", function (e, data) {
2738
  if(data.data.jstree) { m.hide(); if(ml) { ml.hide(); } }
2739
  });
2740
  });
@@ -2757,13 +2764,13 @@
2757
  }
2758
 
2759
  this.get_container()
2760
- .bind("open_node.jstree create_node.jstree clean_node.jstree refresh.jstree", $.proxy(function (e, data) {
2761
  this._prepare_checkboxes(data.rslt.obj);
2762
  }, this))
2763
- .bind("loaded.jstree", $.proxy(function (e) {
2764
  this._prepare_checkboxes();
2765
  }, this))
2766
- .delegate( (this.data.ui && this.data.checkbox.noui ? "a" : "ins.jstree-checkbox") , "click.jstree", $.proxy(function (e) {
2767
  e.preventDefault();
2768
  if(this._get_node(e.target).hasClass("jstree-checked")) { this.uncheck_node(e.target); }
2769
  else { this.check_node(e.target); }
@@ -2813,8 +2820,8 @@
2813
  else {
2814
  $t.children(":checkbox").addClass("jstree-real-checkbox");
2815
  }
2816
- if(c === "jstree-checked") {
2817
- $t.children(":checkbox").attr("checked","checked");
2818
  }
2819
  }
2820
  if(c === "jstree-checked" && !ts) {
@@ -2826,7 +2833,7 @@
2826
  if(obj.length === 1 && obj.is("li")) { this._repair_state(obj); }
2827
  if(obj.is("li")) { obj.each(function () { _this._repair_state(this); }); }
2828
  else { obj.find("> ul > li").each(function () { _this._repair_state(this); }); }
2829
- obj.find(".jstree-checked").parent().parent().each(function () { _this._repair_state(this); });
2830
  }
2831
  },
2832
  change_state : function (obj, state) {
@@ -2835,26 +2842,26 @@
2835
  if(!obj || obj === -1) { return false; }
2836
  state = (state === false || state === true) ? state : obj.hasClass("jstree-checked");
2837
  if(this._get_settings().checkbox.two_state) {
2838
- if(state) {
2839
- obj.removeClass("jstree-checked").addClass("jstree-unchecked");
2840
  if(rc) { obj.children(":checkbox").removeAttr("checked"); }
2841
  }
2842
- else {
2843
- obj.removeClass("jstree-unchecked").addClass("jstree-checked");
2844
  if(rc) { obj.children(":checkbox").attr("checked","checked"); }
2845
  }
2846
  }
2847
  else {
2848
- if(state) {
2849
  coll = obj.find("li").andSelf();
2850
  if(!coll.filter(".jstree-checked, .jstree-undetermined").length) { return false; }
2851
- coll.removeClass("jstree-checked jstree-undetermined").addClass("jstree-unchecked");
2852
  if(rc) { coll.children(":checkbox").removeAttr("checked"); }
2853
  }
2854
- else {
2855
  coll = obj.find("li").andSelf();
2856
  if(!coll.filter(".jstree-unchecked, .jstree-undetermined").length) { return false; }
2857
- coll.removeClass("jstree-unchecked jstree-undetermined").addClass("jstree-checked");
2858
  if(rc) { coll.children(":checkbox").attr("checked","checked"); }
2859
  if(this.data.ui) { this.data.ui.last_selected = obj; }
2860
  this.data.checkbox.last_selected = obj;
@@ -2890,20 +2897,20 @@
2890
  return true;
2891
  },
2892
  check_node : function (obj) {
2893
- if(this.change_state(obj, false)) {
2894
  obj = this._get_node(obj);
2895
  if(this._get_settings().checkbox.checked_parent_open) {
2896
  var t = this;
2897
  obj.parents(".jstree-closed").each(function () { t.open_node(this, false, true); });
2898
  }
2899
- this.__callback({ "obj" : obj });
2900
  }
2901
  },
2902
  uncheck_node : function (obj) {
2903
  if(this.change_state(obj, true)) { this.__callback({ "obj" : this._get_node(obj) }); }
2904
  },
2905
  check_all : function () {
2906
- var _this = this,
2907
  coll = this._get_settings().checkbox.two_state ? this.get_container_ul().find("li") : this.get_container_ul().children("li");
2908
  coll.each(function () {
2909
  _this.change_state(this, false);
@@ -2927,7 +2934,7 @@
2927
  obj = !obj || obj === -1 ? this.get_container() : this._get_node(obj);
2928
  return get_all || this._get_settings().checkbox.two_state ? obj.find(".jstree-checked") : obj.find("> ul > .jstree-checked, .jstree-undetermined > ul > .jstree-checked");
2929
  },
2930
- get_unchecked : function (obj, get_all) {
2931
  obj = !obj || obj === -1 ? this.get_container() : this._get_node(obj);
2932
  return get_all || this._get_settings().checkbox.two_state ? obj.find(".jstree-unchecked") : obj.find("> ul > .jstree-unchecked, .jstree-undetermined > ul > .jstree-unchecked");
2933
  },
@@ -2945,13 +2952,13 @@
2945
  if(c === 0) { if(obj.hasClass("jstree-undetermined")) { this.change_state(obj, false); } }
2946
  else if(a === 0 && b === 0) { this.change_state(obj, true); }
2947
  else if(a === c) { this.change_state(obj, false); }
2948
- else {
2949
  obj.parentsUntil(".jstree","li").andSelf().removeClass("jstree-checked jstree-unchecked").addClass("jstree-undetermined");
2950
  if(rc) { obj.parentsUntil(".jstree", "li").andSelf().children(":checkbox").removeAttr("checked"); }
2951
  }
2952
  },
2953
  reselect : function () {
2954
- if(this.data.ui && this.data.checkbox.noui) {
2955
  var _this = this,
2956
  s = this.data.ui.to_select;
2957
  s = $.map($.makeArray(s), function (n) { return "#" + n.toString().replace(/^#/,"").replace(/\\\//g,"/").replace(/\//g,"\\\/").replace(/\\\./g,".").replace(/\./g,"\\.").replace(/\:/g,"\\:"); });
@@ -2959,8 +2966,8 @@
2959
  $.each(s, function (i, val) { _this.check_node(val); });
2960
  this.__callback();
2961
  }
2962
- else {
2963
- this.__call_old();
2964
  }
2965
  },
2966
  save_loaded : function () {
@@ -2979,7 +2986,7 @@
2979
  })(jQuery);
2980
  //*/
2981
 
2982
- /*
2983
  * jsTree XML plugin
2984
  * The XML data store. Datastores are build by overriding the `load_node` and `_is_loaded` functions.
2985
  */
@@ -3006,7 +3013,7 @@
3006
  xsl = new DOMParser().parseFromString(xsl, "text/xml");
3007
  // alert(xml.transformNode());
3008
  // callback.call(null, new XMLSerializer().serializeToString(rs));
3009
-
3010
  }
3011
  if(typeof window.DOMParser !== "undefined" && typeof window.XMLHttpRequest !== "undefined" && typeof window.XSLTProcessor !== "undefined") {
3012
  processor = new XSLTProcessor();
@@ -3030,137 +3037,137 @@
3030
  return false;
3031
  };
3032
  var xsl = {
3033
- 'nest' : '<' + '?xml version="1.0" encoding="utf-8" ?>' +
3034
- '<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >' +
3035
- '<xsl:output method="html" encoding="utf-8" omit-xml-declaration="yes" standalone="no" indent="no" media-type="text/html" />' +
3036
- '<xsl:template match="/">' +
3037
- ' <xsl:call-template name="nodes">' +
3038
- ' <xsl:with-param name="node" select="/root" />' +
3039
- ' </xsl:call-template>' +
3040
- '</xsl:template>' +
3041
- '<xsl:template name="nodes">' +
3042
- ' <xsl:param name="node" />' +
3043
- ' <ul>' +
3044
- ' <xsl:for-each select="$node/item">' +
3045
- ' <xsl:variable name="children" select="count(./item) &gt; 0" />' +
3046
- ' <li>' +
3047
- ' <xsl:attribute name="class">' +
3048
- ' <xsl:if test="position() = last()">jstree-last </xsl:if>' +
3049
- ' <xsl:choose>' +
3050
- ' <xsl:when test="@state = \'open\'">jstree-open </xsl:when>' +
3051
- ' <xsl:when test="$children or @hasChildren or @state = \'closed\'">jstree-closed </xsl:when>' +
3052
- ' <xsl:otherwise>jstree-leaf </xsl:otherwise>' +
3053
- ' </xsl:choose>' +
3054
- ' <xsl:value-of select="@class" />' +
3055
- ' </xsl:attribute>' +
3056
- ' <xsl:for-each select="@*">' +
3057
- ' <xsl:if test="name() != \'class\' and name() != \'state\' and name() != \'hasChildren\'">' +
3058
- ' <xsl:attribute name="{name()}"><xsl:value-of select="." /></xsl:attribute>' +
3059
- ' </xsl:if>' +
3060
- ' </xsl:for-each>' +
3061
- ' <ins class="jstree-icon"><xsl:text>&#xa0;</xsl:text></ins>' +
3062
- ' <xsl:for-each select="content/name">' +
3063
- ' <a>' +
3064
- ' <xsl:attribute name="href">' +
3065
- ' <xsl:choose>' +
3066
- ' <xsl:when test="@href"><xsl:value-of select="@href" /></xsl:when>' +
3067
- ' <xsl:otherwise>#</xsl:otherwise>' +
3068
- ' </xsl:choose>' +
3069
- ' </xsl:attribute>' +
3070
- ' <xsl:attribute name="class"><xsl:value-of select="@lang" /> <xsl:value-of select="@class" /></xsl:attribute>' +
3071
- ' <xsl:attribute name="style"><xsl:value-of select="@style" /></xsl:attribute>' +
3072
- ' <xsl:for-each select="@*">' +
3073
- ' <xsl:if test="name() != \'style\' and name() != \'class\' and name() != \'href\'">' +
3074
- ' <xsl:attribute name="{name()}"><xsl:value-of select="." /></xsl:attribute>' +
3075
- ' </xsl:if>' +
3076
- ' </xsl:for-each>' +
3077
- ' <ins>' +
3078
- ' <xsl:attribute name="class">jstree-icon ' +
3079
- ' <xsl:if test="string-length(attribute::icon) > 0 and not(contains(@icon,\'/\'))"><xsl:value-of select="@icon" /></xsl:if>' +
3080
- ' </xsl:attribute>' +
3081
- ' <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>' +
3082
- ' <xsl:text>&#xa0;</xsl:text>' +
3083
- ' </ins>' +
3084
- ' <xsl:copy-of select="./child::node()" />' +
3085
- ' </a>' +
3086
- ' </xsl:for-each>' +
3087
- ' <xsl:if test="$children or @hasChildren"><xsl:call-template name="nodes"><xsl:with-param name="node" select="current()" /></xsl:call-template></xsl:if>' +
3088
- ' </li>' +
3089
- ' </xsl:for-each>' +
3090
- ' </ul>' +
3091
- '</xsl:template>' +
3092
  '</xsl:stylesheet>',
3093
 
3094
- 'flat' : '<' + '?xml version="1.0" encoding="utf-8" ?>' +
3095
- '<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >' +
3096
- '<xsl:output method="html" encoding="utf-8" omit-xml-declaration="yes" standalone="no" indent="no" media-type="text/xml" />' +
3097
- '<xsl:template match="/">' +
3098
- ' <ul>' +
3099
  ' <xsl:for-each select="//item[not(@parent_id) or @parent_id=0 or not(@parent_id = //item/@id)]">' + /* the last `or` may be removed */
3100
- ' <xsl:call-template name="nodes">' +
3101
- ' <xsl:with-param name="node" select="." />' +
3102
- ' <xsl:with-param name="is_last" select="number(position() = last())" />' +
3103
- ' </xsl:call-template>' +
3104
- ' </xsl:for-each>' +
3105
- ' </ul>' +
3106
- '</xsl:template>' +
3107
- '<xsl:template name="nodes">' +
3108
- ' <xsl:param name="node" />' +
3109
- ' <xsl:param name="is_last" />' +
3110
- ' <xsl:variable name="children" select="count(//item[@parent_id=$node/attribute::id]) &gt; 0" />' +
3111
- ' <li>' +
3112
- ' <xsl:attribute name="class">' +
3113
- ' <xsl:if test="$is_last = true()">jstree-last </xsl:if>' +
3114
- ' <xsl:choose>' +
3115
- ' <xsl:when test="@state = \'open\'">jstree-open </xsl:when>' +
3116
- ' <xsl:when test="$children or @hasChildren or @state = \'closed\'">jstree-closed </xsl:when>' +
3117
- ' <xsl:otherwise>jstree-leaf </xsl:otherwise>' +
3118
- ' </xsl:choose>' +
3119
- ' <xsl:value-of select="@class" />' +
3120
- ' </xsl:attribute>' +
3121
- ' <xsl:for-each select="@*">' +
3122
- ' <xsl:if test="name() != \'parent_id\' and name() != \'hasChildren\' and name() != \'class\' and name() != \'state\'">' +
3123
- ' <xsl:attribute name="{name()}"><xsl:value-of select="." /></xsl:attribute>' +
3124
- ' </xsl:if>' +
3125
- ' </xsl:for-each>' +
3126
- ' <ins class="jstree-icon"><xsl:text>&#xa0;</xsl:text></ins>' +
3127
- ' <xsl:for-each select="content/name">' +
3128
- ' <a>' +
3129
- ' <xsl:attribute name="href">' +
3130
- ' <xsl:choose>' +
3131
- ' <xsl:when test="@href"><xsl:value-of select="@href" /></xsl:when>' +
3132
- ' <xsl:otherwise>#</xsl:otherwise>' +
3133
- ' </xsl:choose>' +
3134
- ' </xsl:attribute>' +
3135
- ' <xsl:attribute name="class"><xsl:value-of select="@lang" /> <xsl:value-of select="@class" /></xsl:attribute>' +
3136
- ' <xsl:attribute name="style"><xsl:value-of select="@style" /></xsl:attribute>' +
3137
- ' <xsl:for-each select="@*">' +
3138
- ' <xsl:if test="name() != \'style\' and name() != \'class\' and name() != \'href\'">' +
3139
- ' <xsl:attribute name="{name()}"><xsl:value-of select="." /></xsl:attribute>' +
3140
- ' </xsl:if>' +
3141
- ' </xsl:for-each>' +
3142
- ' <ins>' +
3143
- ' <xsl:attribute name="class">jstree-icon ' +
3144
- ' <xsl:if test="string-length(attribute::icon) > 0 and not(contains(@icon,\'/\'))"><xsl:value-of select="@icon" /></xsl:if>' +
3145
- ' </xsl:attribute>' +
3146
- ' <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>' +
3147
- ' <xsl:text>&#xa0;</xsl:text>' +
3148
- ' </ins>' +
3149
- ' <xsl:copy-of select="./child::node()" />' +
3150
- ' </a>' +
3151
- ' </xsl:for-each>' +
3152
- ' <xsl:if test="$children">' +
3153
- ' <ul>' +
3154
- ' <xsl:for-each select="//item[@parent_id=$node/attribute::id]">' +
3155
- ' <xsl:call-template name="nodes">' +
3156
- ' <xsl:with-param name="node" select="." />' +
3157
- ' <xsl:with-param name="is_last" select="number(position() = last())" />' +
3158
- ' </xsl:call-template>' +
3159
- ' </xsl:for-each>' +
3160
- ' </ul>' +
3161
- ' </xsl:if>' +
3162
- ' </li>' +
3163
- '</xsl:template>' +
3164
  '</xsl:stylesheet>'
3165
  },
3166
  escape_xml = function(string) {
@@ -3173,7 +3180,7 @@
3173
  .replace(/'/g, '&apos;');
3174
  };
3175
  $.jstree.plugin("xml_data", {
3176
- defaults : {
3177
  data : false,
3178
  ajax : false,
3179
  xsl : "flat",
@@ -3184,7 +3191,7 @@
3184
  },
3185
  _fn : {
3186
  load_node : function (obj, s_call, e_call) { var _this = this; this.load_node_xml(obj, function () { _this.__callback({ "obj" : _this._get_node(obj) }); s_call.call(this); }, e_call); },
3187
- _is_loaded : function (obj) {
3188
  var s = this._get_settings().xml_data;
3189
  obj = this._get_node(obj);
3190
  return obj == -1 || !obj || (!s.ajax && !$.isFunction(s.data)) || obj.is(".jstree-open, .jstree-leaf") || obj.children("ul").children("li").size() > 0;
@@ -3214,18 +3221,18 @@
3214
  if(s_call) { s_call.call(this); }
3215
  }
3216
  else {
3217
- if(obj && obj !== -1) {
3218
  obj.children("a.jstree-loading").removeClass("jstree-loading");
3219
  obj.removeData("jstree-is-loading");
3220
- if(s.correct_state) {
3221
  this.correct_state(obj);
3222
- if(s_call) { s_call.call(this); }
3223
  }
3224
  }
3225
  else {
3226
- if(s.correct_state) {
3227
  this.get_container().children("ul").empty();
3228
- if(s_call) { s_call.call(this); }
3229
  }
3230
  }
3231
  }
@@ -3245,9 +3252,9 @@
3245
  if(s_call) { s_call.call(this); }
3246
  }
3247
  }
3248
- else {
3249
- if(s.correct_state) {
3250
- this.get_container().children("ul").empty();
3251
  if(s_call) { s_call.call(this); }
3252
  }
3253
  }
@@ -3256,7 +3263,7 @@
3256
  break;
3257
  case (!s.data && !!s.ajax) || (!!s.data && !!s.ajax && obj && obj !== -1):
3258
  error_func = function (x, t, e) {
3259
- var ef = this.get_settings().xml_data.ajax.error;
3260
  if(ef) { ef.call(this, x, t, e); }
3261
  if(obj !== -1 && obj.length) {
3262
  obj.children("a.jstree-loading").removeClass("jstree-loading");
@@ -3270,7 +3277,7 @@
3270
  };
3271
  success_func = function (d, t, x) {
3272
  d = x.responseText;
3273
- var sf = this.get_settings().xml_data.ajax.success;
3274
  if(sf) { d = sf.call(this,d,t,x) || d; }
3275
  if(d === "" || (d && d.toString && d.toString().replace(/^[\s\n]+$/,"") === "")) {
3276
  return error_func.call(this, x, t, "");
@@ -3286,18 +3293,18 @@
3286
  if(s_call) { s_call.call(this); }
3287
  }
3288
  else {
3289
- if(obj && obj !== -1) {
3290
  obj.children("a.jstree-loading").removeClass("jstree-loading");
3291
  obj.removeData("jstree-is-loading");
3292
- if(s.correct_state) {
3293
  this.correct_state(obj);
3294
- if(s_call) { s_call.call(this); }
3295
  }
3296
  }
3297
  else {
3298
- if(s.correct_state) {
3299
  this.get_container().children("ul").empty();
3300
- if(s_call) { s_call.call(this); }
3301
  }
3302
  }
3303
  }
@@ -3319,32 +3326,32 @@
3319
  $.vakata.xslt(xml, xsl[s.xsl], callback);
3320
  },
3321
  get_xml : function (tp, obj, li_attr, a_attr, is_callback) {
3322
- var result = "",
3323
- s = this._get_settings(),
3324
  _this = this,
3325
  tmp1, tmp2, li, a, lang;
3326
  if(!tp) { tp = "flat"; }
3327
  if(!is_callback) { is_callback = 0; }
3328
  obj = this._get_node(obj);
3329
  if(!obj || obj === -1) { obj = this.get_container().find("> ul > li"); }
3330
- li_attr = $.isArray(li_attr) ? li_attr : [ "id", "class" ];
3331
  if(!is_callback && this.data.types && $.inArray(s.types.type_attr, li_attr) === -1) { li_attr.push(s.types.type_attr); }
3332
 
3333
- a_attr = $.isArray(a_attr) ? a_attr : [ ];
3334
 
3335
- if(!is_callback) {
3336
- if(s.xml_data.get_include_preamble) {
3337
- result += '<' + '?xml version="1.0" encoding="UTF-8"?' + '>';
3338
  }
3339
- result += "<root>";
3340
  }
3341
  obj.each(function () {
3342
  result += "<item";
3343
  li = $(this);
3344
- $.each(li_attr, function (i, v) {
3345
  var t = li.attr(v);
3346
  if(!s.xml_data.get_skip_empty || typeof t !== "undefined") {
3347
- result += " " + v + "=\"" + escape_xml((" " + (t || "")).replace(/ jstree[^ ]*/ig,'').replace(/\s+$/ig," ").replace(/^ /,"").replace(/ $/,"")) + "\"";
3348
  }
3349
  });
3350
  if(li.hasClass("jstree-open")) { result += " state=\"open\""; }
@@ -3362,7 +3369,7 @@
3362
  if(tmp1.hasClass(z)) { result += " lang=\"" + escape_xml(z) + "\""; lang = z; return false; }
3363
  });
3364
  }
3365
- if(a_attr.length) {
3366
  $.each(a_attr, function (k, z) {
3367
  var t = tmp1.attr(z);
3368
  if(!s.xml_data.get_skip_empty || typeof t !== "undefined") {
@@ -3403,10 +3410,10 @@
3403
  * DOES NOT WORK WITH JSON PROGRESSIVE RENDER
3404
  */
3405
  (function ($) {
3406
- $.expr[':'].jstree_contains = function(a,i,m){
3407
  return (a.textContent || a.innerText || "").toLowerCase().indexOf(m[3].toLowerCase())>=0;
3408
  };
3409
- $.expr[':'].jstree_title_contains = function(a,i,m) {
3410
  return (a.getAttribute("title") || "").toLowerCase().indexOf(m[3].toLowerCase())>=0;
3411
  };
3412
  $.jstree.plugin("search", {
@@ -3415,12 +3422,12 @@
3415
  this.data.search.result = $();
3416
  if(this._get_settings().search.show_only_matches) {
3417
  this.get_container()
3418
- .bind("search.jstree", function (e, data) {
3419
  $(this).children("ul").find("li").hide().removeClass("jstree-last");
3420
  data.rslt.nodes.parentsUntil(".jstree").andSelf().show()
3421
  .filter("ul").each(function () { $(this).children("li:visible").eq(-1).addClass("jstree-last"); });
3422
  })
3423
- .bind("clear_search.jstree", function () {
3424
  $(this).children("ul").find("li").css("display","").end().end().jstree("clean_node", -1);
3425
  });
3426
  }
@@ -3433,7 +3440,7 @@
3433
  _fn : {
3434
  search : function (str, skip_async) {
3435
  if($.trim(str) === "") { this.clear_search(); return; }
3436
- var s = this.get_settings().search,
3437
  t = this,
3438
  error_func = function () { },
3439
  success_func = function () { };
@@ -3443,7 +3450,7 @@
3443
  this.search.supress_callback = true;
3444
  error_func = function () { };
3445
  success_func = function (d, t, x) {
3446
- var sf = this.get_settings().search.ajax.success;
3447
  if(sf) { d = sf.call(this,d,t,x) || d; }
3448
  this.data.search.to_open = d;
3449
  this._search_open();
@@ -3483,8 +3490,8 @@
3483
  });
3484
  if(current.length) {
3485
  this.data.search.to_open = remaining;
3486
- $.each(current, function (i, val) {
3487
- _this.open_node(val, function () { _this._search_open(true); });
3488
  });
3489
  done = false;
3490
  }
@@ -3496,7 +3503,7 @@
3496
  })(jQuery);
3497
  //*/
3498
 
3499
- /*
3500
  * jsTree contextmenu plugin
3501
  */
3502
  (function ($) {
@@ -3529,27 +3536,27 @@
3529
 
3530
  h = $.vakata.context.cnt.height();
3531
  w = $.vakata.context.cnt.width();
3532
- if(x + w > $(document).width()) {
3533
- x = $(document).width() - (w + 5);
3534
- $.vakata.context.cnt.find("li > ul").addClass("right");
3535
  }
3536
- if(y + h > $(document).height()) {
3537
- y = y - (h + t[0].offsetHeight);
3538
- $.vakata.context.cnt.find("li > ul").addClass("bottom");
3539
  }
3540
 
3541
  $.vakata.context.cnt
3542
  .css({ "left" : x, "top" : y })
3543
  .find("li:has(ul)")
3544
- .bind("mouseenter", function (e) {
3545
  var w = $(document).width(),
3546
  h = $(document).height(),
3547
- ul = $(this).children("ul").show();
3548
  if(w !== $(document).width()) { ul.toggleClass("right"); }
3549
  if(h !== $(document).height()) { ul.toggleClass("bottom"); }
3550
  })
3551
- .bind("mouseleave", function (e) {
3552
- $(this).children("ul").hide();
3553
  })
3554
  .end()
3555
  .css({ "visibility" : "visible" })
@@ -3608,72 +3615,72 @@
3608
  }
3609
  };
3610
  $(function () {
3611
- var css_string = '' +
3612
- '#vakata-contextmenu { display:block; visibility:hidden; left:0; top:-200px; position:absolute; margin:0; padding:0; min-width:180px; background:#ebebeb; border:1px solid silver; z-index:10000; *width:180px; } ' +
3613
- '#vakata-contextmenu ul { min-width:180px; *width:180px; } ' +
3614
- '#vakata-contextmenu ul, #vakata-contextmenu li { margin:0; padding:0; list-style-type:none; display:block; } ' +
3615
- '#vakata-contextmenu li { line-height:20px; min-height:20px; position:relative; padding:0px; } ' +
3616
- '#vakata-contextmenu li a { padding:1px 6px; line-height:17px; display:block; text-decoration:none; margin:1px 1px 0 1px; } ' +
3617
- '#vakata-contextmenu li ins { float:left; width:16px; height:16px; text-decoration:none; margin-right:2px; } ' +
3618
- '#vakata-contextmenu li a:hover, #vakata-contextmenu li.vakata-hover > a { background:gray; color:white; } ' +
3619
- '#vakata-contextmenu li ul { display:none; position:absolute; top:-2px; left:100%; background:#ebebeb; border:1px solid gray; } ' +
3620
- '#vakata-contextmenu .right { right:100%; left:auto; } ' +
3621
- '#vakata-contextmenu .bottom { bottom:-1px; top:auto; } ' +
3622
  '#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; } ';
3623
  $.vakata.css.add_sheet({ str : css_string, title : "vakata" });
3624
  $.vakata.context.cnt
3625
- .delegate("a","click", function (e) { e.preventDefault(); })
3626
- .delegate("a","mouseup", function (e) {
3627
  if(!$(this).parent().hasClass("jstree-contextmenu-disabled") && $.vakata.context.exec($(this).attr("rel"))) {
3628
  $.vakata.context.hide();
3629
  }
3630
  else { $(this).blur(); }
3631
  })
3632
- .delegate("a","mouseover", function () {
3633
  $.vakata.context.cnt.find(".vakata-hover").removeClass("vakata-hover");
3634
  })
3635
  .appendTo("body");
3636
- $(document).bind("mousedown", function (e) { if($.vakata.context.vis && !$.contains($.vakata.context.cnt[0], e.target)) { $.vakata.context.hide(); } });
3637
  // modified by pär to fix problems with wordpress hotkeys
3638
  if(false && typeof $.hotkeys !== "undefined") {
3639
  $(document)
3640
- .bind("keydown", "up", function (e) {
3641
- if($.vakata.context.vis) {
3642
  var o = $.vakata.context.cnt.find("ul:visible").last().children(".vakata-hover").removeClass("vakata-hover").prevAll("li:not(.vakata-separator)").first();
3643
  if(!o.length) { o = $.vakata.context.cnt.find("ul:visible").last().children("li:not(.vakata-separator)").last(); }
3644
  o.addClass("vakata-hover");
3645
- e.stopImmediatePropagation();
3646
  e.preventDefault();
3647
- }
3648
  })
3649
- .bind("keydown", "down", function (e) {
3650
- if($.vakata.context.vis) {
3651
  var o = $.vakata.context.cnt.find("ul:visible").last().children(".vakata-hover").removeClass("vakata-hover").nextAll("li:not(.vakata-separator)").first();
3652
  if(!o.length) { o = $.vakata.context.cnt.find("ul:visible").last().children("li:not(.vakata-separator)").first(); }
3653
  o.addClass("vakata-hover");
3654
- e.stopImmediatePropagation();
3655
  e.preventDefault();
3656
- }
3657
  })
3658
- .bind("keydown", "right", function (e) {
3659
- if($.vakata.context.vis) {
3660
  $.vakata.context.cnt.find(".vakata-hover").children("ul").show().children("li:not(.vakata-separator)").removeClass("vakata-hover").first().addClass("vakata-hover");
3661
- e.stopImmediatePropagation();
3662
  e.preventDefault();
3663
- }
3664
  })
3665
- .bind("keydown", "left", function (e) {
3666
- if($.vakata.context.vis) {
3667
  $.vakata.context.cnt.find(".vakata-hover").children("ul").hide().children(".vakata-separator").removeClass("vakata-hover");
3668
- e.stopImmediatePropagation();
3669
  e.preventDefault();
3670
- }
3671
  })
3672
- .bind("keydown", "esc", function (e) {
3673
- $.vakata.context.hide();
3674
  e.preventDefault();
3675
  })
3676
- .bind("keydown", "space", function (e) {
3677
  $.vakata.context.cnt.find(".vakata-hover").last().children("a").click();
3678
  e.preventDefault();
3679
  });
@@ -3683,26 +3690,26 @@
3683
  $.jstree.plugin("contextmenu", {
3684
  __init : function () {
3685
  this.get_container()
3686
- .delegate("a", "contextmenu.jstree", $.proxy(function (e) {
3687
  e.preventDefault();
3688
  if(!$(e.currentTarget).hasClass("jstree-loading")) {
3689
  this.show_contextmenu(e.currentTarget, e.pageX, e.pageY);
3690
  }
3691
  }, this))
3692
- .delegate("a", "click.jstree", $.proxy(function (e) {
3693
  if(this.data.contextmenu) {
3694
  $.vakata.context.hide();
3695
  }
3696
  }, this))
3697
- .bind("destroy.jstree", $.proxy(function () {
3698
  // TODO: move this to descruct method
3699
  if(this.data.contextmenu) {
3700
  $.vakata.context.hide();
3701
  }
3702
  }, this));
3703
- $(document).bind("context_hide.vakata", $.proxy(function () { this.data.contextmenu = false; }, this));
3704
  },
3705
- defaults : {
3706
  select_node : false, // requires UI plugin
3707
  show_at_node : true,
3708
  items : { // Could be a function that should return an object like this one
@@ -3731,7 +3738,7 @@
3731
  "separator_after" : false,
3732
  "label" : "Edit",
3733
  "action" : false,
3734
- "submenu" : {
3735
  "cut" : {
3736
  "separator_before" : false,
3737
  "separator_after" : false,
@@ -3783,7 +3790,7 @@
3783
  })(jQuery);
3784
  //*/
3785
 
3786
- /*
3787
  * jsTree types plugin
3788
  * Adds support types of nodes
3789
  * You can set an attribute on each li node, that represents its type.
@@ -3795,14 +3802,14 @@
3795
  var s = this._get_settings().types;
3796
  this.data.types.attach_to = [];
3797
  this.get_container()
3798
- .bind("init.jstree", $.proxy(function () {
3799
- var types = s.types,
3800
- attr = s.type_attr,
3801
- icons_css = "",
3802
  _this = this;
3803
 
3804
  $.each(types, function (i, tp) {
3805
- $.each(tp, function (k, v) {
3806
  if(!/^(max_depth|max_children|icon|valid_children)$/.test(k)) { _this.data.types.attach_to.push(k); }
3807
  });
3808
  if(!tp.icon) { return true; }
@@ -3817,9 +3824,9 @@
3817
  });
3818
  if(icons_css !== "") { $.vakata.css.add_sheet({ 'str' : icons_css, title : "jstree-types" }); }
3819
  }, this))
3820
- .bind("before.jstree", $.proxy(function (e, data) {
3821
- var s, t,
3822
- o = this._get_settings().types.use_data ? this._get_node(data.args[0]) : false,
3823
  d = o && o !== -1 && o.length ? o.data("jstree") : false;
3824
  if(d && d.types && d.types[data.func] === false) { e.stopImmediatePropagation(); return false; }
3825
  if($.inArray(data.func, this.data.types.attach_to) !== -1) {
@@ -3827,9 +3834,9 @@
3827
  s = this._get_settings().types.types;
3828
  t = this._get_type(data.args[0]);
3829
  if(
3830
- (
3831
- (s[t] && typeof s[t][data.func] !== "undefined") ||
3832
- (s["default"] && typeof s["default"][data.func] !== "undefined")
3833
  ) && this._check(data.func, data.args[0]) === false
3834
  ) {
3835
  e.stopImmediatePropagation();
@@ -3839,7 +3846,7 @@
3839
  }, this));
3840
  if(is_ie6) {
3841
  this.get_container()
3842
- .bind("load_node.jstree set_type.jstree", $.proxy(function (e, data) {
3843
  var r = data && data.rslt && data.rslt.obj && data.rslt.obj !== -1 ? this._get_node(data.rslt.obj).parent() : this.get_container_ul(),
3844
  c = false,
3845
  s = this._get_settings().types;
@@ -3862,7 +3869,7 @@
3862
  valid_children : "all",
3863
 
3864
  // whether to use $.data
3865
- use_data : false,
3866
  // where is the type stores (the rel attribute of the LI element)
3867
  type_attr : "rel",
3868
  // a list of types
@@ -3897,7 +3904,7 @@
3897
  _check : function (rule, obj, opts) {
3898
  obj = this._get_node(obj);
3899
  var v = false, t = this._get_type(obj), d = 0, _this = this, s = this._get_settings().types, data = false;
3900
- if(obj === -1) {
3901
  if(!!s[rule]) { v = s[rule]; }
3902
  else { return; }
3903
  }
@@ -3934,8 +3941,8 @@
3934
  vc = m.rt._check("valid_children", m.cr),
3935
  ch = 0, d = 1, t;
3936
 
3937
- if(vc === "none") { return false; }
3938
- if($.isArray(vc) && m.ot && m.ot._get_type) {
3939
  m.o.each(function () {
3940
  if($.inArray(m.ot._get_type(this), vc) === -1) { d = false; return false; }
3941
  });
@@ -3971,11 +3978,11 @@
3971
  ch;
3972
  if(typeof js === "string") { js = { data : js }; }
3973
  if(!js) { js = {}; }
3974
- if(vc === "none") { return false; }
3975
- if($.isArray(vc)) {
3976
- if(!js.attr || !js.attr[s.type_attr]) {
3977
  if(!js.attr) { js.attr = {}; }
3978
- js.attr[s.type_attr] = vc[0];
3979
  }
3980
  else {
3981
  if($.inArray(js.attr[s.type_attr], vc) === -1) { return false; }
@@ -3994,27 +4001,27 @@
3994
  })(jQuery);
3995
  //*/
3996
 
3997
- /*
3998
  * jsTree HTML plugin
3999
  * The HTML data store. Datastores are build by replacing the `load_node` and `_is_loaded` functions.
4000
  */
4001
  (function ($) {
4002
  $.jstree.plugin("html_data", {
4003
- __init : function () {
4004
  // this used to use html() and clean the whitespace, but this way any attached data was lost
4005
  this.data.html_data.original_container_html = this.get_container().find(" > ul > li").clone(true);
4006
  // remove white space from LI node - otherwise nodes appear a bit to the right
4007
  this.data.html_data.original_container_html.find("li").andSelf().contents().filter(function() { return this.nodeType == 3; }).remove();
4008
  },
4009
- defaults : {
4010
  data : false,
4011
  ajax : false,
4012
  correct_state : true
4013
  },
4014
  _fn : {
4015
  load_node : function (obj, s_call, e_call) { var _this = this; this.load_node_html(obj, function () { _this.__callback({ "obj" : _this._get_node(obj) }); s_call.call(this); }, e_call); },
4016
- _is_loaded : function (obj) {
4017
- obj = this._get_node(obj);
4018
  return obj == -1 || !obj || (!this._get_settings().html_data.ajax && !$.isFunction(this._get_settings().html_data.data)) || obj.is(".jstree-open, .jstree-leaf") || obj.children("ul").children("li").size() > 0;
4019
  },
4020
  load_node_html : function (obj, s_call, e_call) {
@@ -4042,15 +4049,15 @@
4042
  if(obj && obj !== -1) {
4043
  obj.children("a.jstree-loading").removeClass("jstree-loading");
4044
  obj.removeData("jstree-is-loading");
4045
- if(s.correct_state) {
4046
  this.correct_state(obj);
4047
- if(s_call) { s_call.call(this); }
4048
  }
4049
  }
4050
  else {
4051
- if(s.correct_state) {
4052
  this.get_container().children("ul").empty();
4053
- if(s_call) { s_call.call(this); }
4054
  }
4055
  }
4056
  }
@@ -4082,7 +4089,7 @@
4082
  case (!s.data && !!s.ajax) || (!!s.data && !!s.ajax && obj && obj !== -1):
4083
  obj = this._get_node(obj);
4084
  error_func = function (x, t, e) {
4085
- var ef = this.get_settings().html_data.ajax.error;
4086
  if(ef) { ef.call(this, x, t, e); }
4087
  if(obj != -1 && obj.length) {
4088
  obj.children("a.jstree-loading").removeClass("jstree-loading");
@@ -4095,7 +4102,7 @@
4095
  if(e_call) { e_call.call(this); }
4096
  };
4097
  success_func = function (d, t, x) {
4098
- var sf = this.get_settings().html_data.ajax.success;
4099
  if(sf) { d = sf.call(this,d,t,x) || d; }
4100
  if(d === "" || (d && d.toString && d.toString().replace(/^[\s\n]+$/,"") === "")) {
4101
  return error_func.call(this, x, t, "");
@@ -4112,15 +4119,15 @@
4112
  if(obj && obj !== -1) {
4113
  obj.children("a.jstree-loading").removeClass("jstree-loading");
4114
  obj.removeData("jstree-is-loading");
4115
- if(s.correct_state) {
4116
  this.correct_state(obj);
4117
- if(s_call) { s_call.call(this); }
4118
  }
4119
  }
4120
  else {
4121
- if(s.correct_state) {
4122
  this.get_container().children("ul").empty();
4123
- if(s_call) { s_call.call(this); }
4124
  }
4125
  }
4126
  }
@@ -4142,7 +4149,7 @@
4142
  })(jQuery);
4143
  //*/
4144
 
4145
- /*
4146
  * jsTree themeroller plugin
4147
  * Adds support for jQuery UI themes. Include this at the end of your plugins list, also make sure "themes" is not included.
4148
  */
@@ -4153,57 +4160,57 @@
4153
  this.get_container()
4154
  .addClass("ui-widget-content")
4155
  .addClass("jstree-themeroller")
4156
- .delegate("a","mouseenter.jstree", function (e) {
4157
  if(!$(e.currentTarget).hasClass("jstree-loading")) {
4158
  $(this).addClass(s.item_h);
4159
  }
4160
  })
4161
- .delegate("a","mouseleave.jstree", function () {
4162
  $(this).removeClass(s.item_h);
4163
  })
4164
- .bind("init.jstree", $.proxy(function (e, data) {
4165
  data.inst.get_container().find("> ul > li > .jstree-loading > ins").addClass("ui-icon-refresh");
4166
  this._themeroller(data.inst.get_container().find("> ul > li"));
4167
  }, this))
4168
- .bind("open_node.jstree create_node.jstree", $.proxy(function (e, data) {
4169
  this._themeroller(data.rslt.obj);
4170
  }, this))
4171
- .bind("loaded.jstree refresh.jstree", $.proxy(function (e) {
4172
  this._themeroller();
4173
  }, this))
4174
- .bind("close_node.jstree", $.proxy(function (e, data) {
4175
  this._themeroller(data.rslt.obj);
4176
  }, this))
4177
- .bind("delete_node.jstree", $.proxy(function (e, data) {
4178
  this._themeroller(data.rslt.parent);
4179
  }, this))
4180
- .bind("correct_state.jstree", $.proxy(function (e, data) {
4181
  data.rslt.obj
4182
  .children("ins.jstree-icon").removeClass(s.opened + " " + s.closed + " ui-icon").end()
4183
  .find("> a > ins.ui-icon")
4184
- .filter(function() {
4185
  return this.className.toString()
4186
  .replace(s.item_clsd,"").replace(s.item_open,"").replace(s.item_leaf,"")
4187
- .indexOf("ui-icon-") === -1;
4188
  }).removeClass(s.item_open + " " + s.item_clsd).addClass(s.item_leaf || "jstree-no-icon");
4189
  }, this))
4190
- .bind("select_node.jstree", $.proxy(function (e, data) {
4191
  data.rslt.obj.children("a").addClass(s.item_a);
4192
  }, this))
4193
- .bind("deselect_node.jstree deselect_all.jstree", $.proxy(function (e, data) {
4194
  this.get_container()
4195
  .find("a." + s.item_a).removeClass(s.item_a).end()
4196
  .find("a.jstree-clicked").addClass(s.item_a);
4197
  }, this))
4198
- .bind("dehover_node.jstree", $.proxy(function (e, data) {
4199
  data.rslt.obj.children("a").removeClass(s.item_h);
4200
  }, this))
4201
- .bind("hover_node.jstree", $.proxy(function (e, data) {
4202
  this.get_container()
4203
  .find("a." + s.item_h).not(data.rslt.obj).removeClass(s.item_h);
4204
  data.rslt.obj.children("a").addClass(s.item_h);
4205
  }, this))
4206
- .bind("move_node.jstree", $.proxy(function (e, data) {
4207
  this._themeroller(data.rslt.o);
4208
  this._themeroller(data.rslt.op);
4209
  }, this));
@@ -4228,10 +4235,10 @@
4228
  .children("ins.jstree-icon").removeClass(s.opened).addClass("ui-icon " + s.closed).end()
4229
  .children("a").addClass(s.item)
4230
  .children("ins.jstree-icon").addClass("ui-icon")
4231
- .filter(function() {
4232
  return this.className.toString()
4233
  .replace(s.item_clsd,"").replace(s.item_open,"").replace(s.item_leaf,"")
4234
- .indexOf("ui-icon-") === -1;
4235
  }).removeClass(s.item_leaf + " " + s.item_open).addClass(s.item_clsd || "jstree-no-icon")
4236
  .end()
4237
  .end()
@@ -4241,10 +4248,10 @@
4241
  .children("ins.jstree-icon").removeClass(s.closed).addClass("ui-icon " + s.opened).end()
4242
  .children("a").addClass(s.item)
4243
  .children("ins.jstree-icon").addClass("ui-icon")
4244
- .filter(function() {
4245
  return this.className.toString()
4246
  .replace(s.item_clsd,"").replace(s.item_open,"").replace(s.item_leaf,"")
4247
- .indexOf("ui-icon-") === -1;
4248
  }).removeClass(s.item_leaf + " " + s.item_clsd).addClass(s.item_open || "jstree-no-icon")
4249
  .end()
4250
  .end()
@@ -4254,10 +4261,10 @@
4254
  .children("ins.jstree-icon").removeClass(s.closed + " ui-icon " + s.opened).end()
4255
  .children("a").addClass(s.item)
4256
  .children("ins.jstree-icon").addClass("ui-icon")
4257
- .filter(function() {
4258
  return this.className.toString()
4259
  .replace(s.item_clsd,"").replace(s.item_open,"").replace(s.item_leaf,"")
4260
- .indexOf("ui-icon-") === -1;
4261
  }).removeClass(s.item_clsd + " " + s.item_open).addClass(s.item_leaf || "jstree-no-icon");
4262
  }
4263
  },
@@ -4273,16 +4280,16 @@
4273
  }
4274
  });
4275
  $(function() {
4276
- var css_string = '' +
4277
- '.jstree-themeroller .ui-icon { overflow:visible; } ' +
4278
- '.jstree-themeroller a { padding:0 2px; } ' +
4279
  '.jstree-themeroller .jstree-no-icon { display:none; }';
4280
  $.vakata.css.add_sheet({ str : css_string, title : "jstree" });
4281
  });
4282
  })(jQuery);
4283
  //*/
4284
 
4285
- /*
4286
  * jsTree unique plugin
4287
  * Forces different names amongst siblings (still a bit experimental)
4288
  * NOTE: does not check language versions (it will not be possible to have nodes with the same title, even in different languages)
@@ -4291,7 +4298,7 @@
4291
  $.jstree.plugin("unique", {
4292
  __init : function () {
4293
  this.get_container()
4294
- .bind("before.jstree", $.proxy(function (e, data) {
4295
  var nms = [], res = true, p, t;
4296
  if(data.func == "move_node") {
4297
  // obj, ref, position, is_copy, is_prepared, skip_check
@@ -4330,10 +4337,10 @@
4330
  }
4331
  }, this));
4332
  },
4333
- defaults : {
4334
  error_callback : $.noop
4335
  },
4336
- _fn : {
4337
  _check_unique : function (nms, p, func) {
4338
  var cnms = [];
4339
  p.children("a").each(function () { cnms.push($(this).text().replace(/^\s+/g,"")); });
@@ -4371,27 +4378,27 @@
4371
  this.data.wholerow.html = false;
4372
  this.data.wholerow.to = false;
4373
  this.get_container()
4374
- .bind("init.jstree", $.proxy(function (e, data) {
4375
  this._get_settings().core.animation = 0;
4376
  }, this))
4377
- .bind("open_node.jstree create_node.jstree clean_node.jstree loaded.jstree", $.proxy(function (e, data) {
4378
  this._prepare_wholerow_span( data && data.rslt && data.rslt.obj ? data.rslt.obj : -1 );
4379
  }, this))
4380
- .bind("search.jstree clear_search.jstree reopen.jstree after_open.jstree after_close.jstree create_node.jstree delete_node.jstree clean_node.jstree", $.proxy(function (e, data) {
4381
  if(this.data.to) { clearTimeout(this.data.to); }
4382
  this.data.to = setTimeout( (function (t, o) { return function() { t._prepare_wholerow_ul(o); }; })(this, data && data.rslt && data.rslt.obj ? data.rslt.obj : -1), 0);
4383
  }, this))
4384
- .bind("deselect_all.jstree", $.proxy(function (e, data) {
4385
  this.get_container().find(" > .jstree-wholerow .jstree-clicked").removeClass("jstree-clicked " + (this.data.themeroller ? this._get_settings().themeroller.item_a : "" ));
4386
  }, this))
4387
- .bind("select_node.jstree deselect_node.jstree ", $.proxy(function (e, data) {
4388
- data.rslt.obj.each(function () {
4389
  var ref = data.inst.get_container().find(" > .jstree-wholerow li:visible:eq(" + ( parseInt((($(this).offset().top - data.inst.get_container().offset().top + data.inst.get_container()[0].scrollTop) / data.inst.data.core.li_height),10)) + ")");
4390
  // ref.children("a")[e.type === "select_node" ? "addClass" : "removeClass"]("jstree-clicked");
4391
  ref.children("a").attr("class",data.rslt.obj.children("a").attr("class"));
4392
  });
4393
  }, this))
4394
- .bind("hover_node.jstree dehover_node.jstree", $.proxy(function (e, data) {
4395
  this.get_container().find(" > .jstree-wholerow .jstree-hovered").removeClass("jstree-hovered " + (this.data.themeroller ? this._get_settings().themeroller.item_h : "" ));
4396
  if(e.type === "hover_node") {
4397
  var ref = this.get_container().find(" > .jstree-wholerow li:visible:eq(" + ( parseInt(((data.rslt.obj.offset().top - this.get_container().offset().top + this.get_container()[0].scrollTop) / this.data.core.li_height),10)) + ")");
@@ -4399,19 +4406,19 @@
4399
  ref.children("a").attr("class",data.rslt.obj.children(".jstree-hovered").attr("class"));
4400
  }
4401
  }, this))
4402
- .delegate(".jstree-wholerow-span, ins.jstree-icon, li", "click.jstree", function (e) {
4403
  var n = $(e.currentTarget);
4404
  if(e.target.tagName === "A" || (e.target.tagName === "INS" && n.closest("li").is(".jstree-open, .jstree-closed"))) { return; }
4405
  n.closest("li").children("a:visible:eq(0)").click();
4406
  e.stopImmediatePropagation();
4407
  })
4408
- .delegate("li", "mouseover.jstree", $.proxy(function (e) {
4409
  e.stopImmediatePropagation();
4410
  if($(e.currentTarget).children(".jstree-hovered, .jstree-clicked").length) { return false; }
4411
  this.hover_node(e.currentTarget);
4412
  return false;
4413
  }, this))
4414
- .delegate("li", "mouseleave.jstree", $.proxy(function (e) {
4415
  if($(e.currentTarget).children("a").hasClass("jstree-hovered").length) { return; }
4416
  this.dehover_node(e.currentTarget);
4417
  }, this));
@@ -4455,25 +4462,25 @@
4455
  }
4456
  });
4457
  $(function() {
4458
- var css_string = '' +
4459
- '.jstree .jstree-wholerow-real { position:relative; z-index:1; } ' +
4460
- '.jstree .jstree-wholerow-real li { cursor:pointer; } ' +
4461
- '.jstree .jstree-wholerow-real a { border-left-color:transparent !important; border-right-color:transparent !important; } ' +
4462
- '.jstree .jstree-wholerow { position:relative; z-index:0; height:0; } ' +
4463
- '.jstree .jstree-wholerow ul, .jstree .jstree-wholerow li { width:100%; } ' +
4464
- '.jstree .jstree-wholerow, .jstree .jstree-wholerow ul, .jstree .jstree-wholerow li, .jstree .jstree-wholerow a { margin:0 !important; padding:0 !important; } ' +
4465
- '.jstree .jstree-wholerow, .jstree .jstree-wholerow ul, .jstree .jstree-wholerow li { background:transparent !important; }' +
4466
- '.jstree .jstree-wholerow ins, .jstree .jstree-wholerow span, .jstree .jstree-wholerow input { display:none !important; }' +
4467
- '.jstree .jstree-wholerow a, .jstree .jstree-wholerow a:hover { text-indent:-9999px; !important; width:100%; padding:0 !important; border-right-width:0px !important; border-left-width:0px !important; } ' +
4468
  '.jstree .jstree-wholerow-span { position:absolute; left:0; margin:0px; padding:0; height:18px; border-width:0; padding:0; z-index:0; }';
4469
  if(is_ff2) {
4470
- css_string += '' +
4471
- '.jstree .jstree-wholerow a { display:block; height:18px; margin:0; padding:0; border:0; } ' +
4472
  '.jstree .jstree-wholerow-real a { border-color:transparent !important; } ';
4473
  }
4474
  if(is_ie7 || is_ie6) {
4475
- css_string += '' +
4476
- '.jstree .jstree-wholerow, .jstree .jstree-wholerow li, .jstree .jstree-wholerow ul, .jstree .jstree-wholerow a { margin:0; padding:0; line-height:18px; } ' +
4477
  '.jstree .jstree-wholerow a { display:block; height:18px; line-height:18px; overflow:hidden; } ';
4478
  }
4479
  $.vakata.css.add_sheet({ str : css_string, title : "jstree" });
@@ -4519,17 +4526,17 @@
4519
  },
4520
  _fn : {
4521
  model_done : function (data, callback) {
4522
- var ret = [],
4523
  s = this._get_settings(),
4524
  _this = this;
4525
 
4526
- if(!$.isArray(data)) { data = [data]; }
4527
  $.each(data, function (i, nd) {
4528
  var r = nd.getProps() || {};
4529
  r.attr = nd.getAttr() || {};
4530
  if(nd.getChildrenCount()) { r.state = "closed"; }
4531
  r.data = nd.getName();
4532
- if(!$.isArray(r.data)) { r.data = [r.data]; }
4533
  if(_this.data.types && $.isFunction(nd.getType)) {
4534
  r.attr[s.types.type_attr] = nd.getType();
4535
  }
17
 
18
  "use strict";
19
 
20
+ // Polyfill for deprecated $.isArray
21
+ if (!Array.isArray) {
22
+ Array.isArray = function(arg) {
23
+ return Object.prototype.toString.call(arg) === '[object Array]';
24
+ };
25
+ }
26
+
27
  // top wrapper to prevent multiple inclusion (is this OK?)
28
  (function () { if(jQuery && jQuery.jstree) { return; }
29
  var is_ie6 = false, is_ie7 = false, is_ff2 = false;
30
 
31
+ /*
32
  * jsTree core
33
  */
34
  (function ($) {
35
+ // Common functions not related to jsTree
36
  // decided to move them to a `vakata` "namespace"
37
  $.vakata = {};
38
  // CSS related functions
60
  if(sheet.insertRule) { sheet.insertRule(rule_name + ' { }', 0); } else { sheet.addRule(rule_name, null, 0); }
61
  return $.vakata.css.get_css(rule_name);
62
  },
63
+ remove_css : function(rule_name, sheet) {
64
+ return $.vakata.css.get_css(rule_name, true, sheet);
65
  },
66
  add_sheet : function(opts) {
67
  var tmp = false, is_new = true;
75
  }
76
 
77
  if(tmp.styleSheet) {
78
+ if(is_new) {
79
+ document.getElementsByTagName("head")[0].appendChild(tmp);
80
+ tmp.styleSheet.cssText = opts.str;
81
  }
82
  else {
83
+ tmp.styleSheet.cssText = tmp.styleSheet.cssText + " " + opts.str;
84
  }
85
  }
86
  else {
106
  }
107
  };
108
 
109
+ // private variables
110
  var instances = [], // instance array (used by $.jstree.reference/create/focused)
111
  focused_instance = -1, // the index in the instance array of the currently focused instance
112
  plugins = {}, // list of included plugins
115
  // jQuery plugin wrapper (thanks to jquery UI widget function)
116
  $.fn.jstree = function (settings) {
117
  var isMethodCall = (typeof settings == 'string'), // is this a method call like $().jstree("open_node")
118
+ args = Array.prototype.slice.call(arguments, 1),
119
  returnValue = this;
120
 
121
  // if a method call execute the method on all selected instances
133
  var instance_id = $.data(this, "jstree-instance-id"),
134
  a = [],
135
  b = settings ? $.extend({}, true, settings) : {},
136
+ c = $(this),
137
+ s = false,
138
  t = [];
139
  a = a.concat(args);
140
  if(c.data("jstree")) { a.push(c.data("jstree")); }
147
  // store the jstree instance id to the container element
148
  $.data(this, "jstree-instance-id", instance_id);
149
  // clean up all plugins
150
+ b.plugins = Array.isArray(b.plugins) ? b.plugins : $.jstree.defaults.plugins.slice();
151
  b.plugins.unshift("core");
152
  // only unique plugins
153
  b.plugins = b.plugins.sort().join(",,").replace(/(,|^)([^,]+)(,,\2)+(,|$)/g,"$1$2$4").replace(/,,+/g,",").replace(/,$/,"").split(",");
155
  // extend defaults with passed data
156
  s = $.extend(true, {}, $.jstree.defaults, b);
157
  s.plugins = b.plugins;
158
+ $.each(plugins, function (i, val) {
159
+ if($.inArray(i, s.plugins) === -1) { s[i] = null; delete s[i]; }
160
  else { t.push(i); }
161
  });
162
  s.plugins = t;
163
 
164
  // push the new object to the instances array (at the same time set the default classes to the container) and init
165
+ instances[instance_id] = new $.jstree._instance(instance_id, $(this).addClass("jstree jstree-" + instance_id), s);
166
  // init all activated plugins for this instance
167
  $.each(instances[instance_id]._get_settings().plugins, function (i, val) { instances[instance_id].data[val] = {}; });
168
  $.each(instances[instance_id]._get_settings().plugins, function (i, val) { if(plugins[val]) { plugins[val].__init.apply(instances[instance_id]); } });
179
  plugins : []
180
  },
181
  _focused : function () { return instances[focused_instance] || null; },
182
+ _reference : function (needle) {
183
  // get by instance id
184
  if(instances[needle]) { return instances[needle]; }
185
  // get by DOM (if still no luck - return null
186
+ var o = $(needle);
187
  if(!o.length && typeof needle === "string") { o = $("#" + needle); }
188
  if(!o.length) { return null; }
189
+ return instances[o.closest(".jstree").data("jstree-instance-id")] || null;
190
  },
191
+ _instance : function (index, container, settings) {
192
  // for plugins to store data in
193
  this.data = { core : {} };
194
  this.get_settings = function () { return $.extend(true, {}, settings); };
196
  this.get_index = function () { return index; };
197
  this.get_container = function () { return container; };
198
  this.get_container_ul = function () { return container.children("ul:eq(0)"); };
199
+ this._set_settings = function (s) {
200
  settings = $.extend(true, {}, settings, s);
201
  };
202
  },
203
  _fn : { },
204
  plugin : function (pname, pdata) {
205
  pdata = $.extend({}, {
206
+ __init : $.noop,
207
  __destroy : $.noop,
208
  _fn : {},
209
  defaults : false
240
  if(typeof rslt !== "undefined") { args = rslt; }
241
 
242
  rslt = func.apply(
243
+ $.extend({}, this, {
244
+ __callback : function (data) {
245
  //console.log(i);
246
  this.get_container().triggerHandler( i + '.jstree', { "inst" : this, "args" : args, "rslt" : data, "rlbk" : rlbk });
247
  },
248
+ __rollback : function () {
249
  rlbk = this.get_rollback();
250
  return rlbk;
251
  },
264
  },
265
  rollback : function (rb) {
266
  if(rb) {
267
+ if(!Array.isArray(rb)) { rb = [ rb ]; }
268
  $.each(rb, function (i, val) {
269
  instances[val.i].set_rollback(val.h, val.d);
270
  });
280
  // code is copied from jQuery ($.browser is deprecated + there is a bug in IE)
281
  var u = navigator.userAgent.toLowerCase(),
282
  v = (u.match( /.+?(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [0,'0'])[1],
283
+ css_string = '' +
284
+ '.jstree ul, .jstree li { display:block; margin:0 0 0 0; padding:0 0 0 0; list-style-type:none; } ' +
285
+ '.jstree li { display:block; min-height:18px; line-height:18px; white-space:nowrap; margin-left:18px; min-width:18px; } ' +
286
+ '.jstree-rtl li { margin-left:0; margin-right:18px; } ' +
287
+ '.jstree > ul > li { margin-left:0px; } ' +
288
+ '.jstree-rtl > ul > li { margin-right:0px; } ' +
289
+ '.jstree ins { display:inline-block; text-decoration:none; width:18px; height:18px; margin:0 0 0 0; padding:0; } ' +
290
+ '.jstree a { display:inline-block; line-height:16px; height:16px; color:black; white-space:nowrap; text-decoration:none; padding:1px 2px; margin:0; } ' +
291
+ '.jstree a:focus { outline: none; } ' +
292
+ '.jstree a > ins { height:16px; width:16px; } ' +
293
+ '.jstree a > .jstree-icon { margin-right:3px; } ' +
294
+ '.jstree-rtl a > .jstree-icon { margin-left:3px; margin-right:0; } ' +
295
+ 'li.jstree-open > ul { display:block; } ' +
296
  'li.jstree-closed > ul { display:none; } ';
297
  // Correct IE 6 (does not support the > CSS selector)
298
+ if(/msie/.test(u) && parseInt(v, 10) == 6) {
299
  is_ie6 = true;
300
 
301
  // fix image flicker and lack of caching
303
  document.execCommand("BackgroundImageCache", false, true);
304
  } catch (err) { }
305
 
306
+ css_string += '' +
307
+ '.jstree li { height:18px; margin-left:0; margin-right:0; } ' +
308
+ '.jstree li li { margin-left:18px; } ' +
309
+ '.jstree-rtl li li { margin-left:0px; margin-right:18px; } ' +
310
+ 'li.jstree-open ul { display:block; } ' +
311
+ 'li.jstree-closed ul { display:none !important; } ' +
312
+ '.jstree li a { display:inline; border-width:0 !important; padding:0px 2px !important; } ' +
313
+ '.jstree li a ins { height:16px; width:16px; margin-right:3px; } ' +
314
  '.jstree-rtl li a ins { margin-right:0px; margin-left:3px; } ';
315
  }
316
  // Correct IE 7 (shifts anchor nodes onhover)
317
+ if(/msie/.test(u) && parseInt(v, 10) == 7) {
318
  is_ie7 = true;
319
  css_string += '.jstree li a { border-width:0 !important; padding:0px 2px !important; } ';
320
  }
321
  // correct ff2 lack of display:inline-block
322
  if(!/compatible/.test(u) && /mozilla/.test(u) && parseFloat(v, 10) < 1.9) {
323
  is_ff2 = true;
324
+ css_string += '' +
325
+ '.jstree ins { display:-moz-inline-box; } ' +
326
  '.jstree li { line-height:12px; } ' + // WHY??
327
+ '.jstree a { display:-moz-inline-box; } ' +
328
  '.jstree .jstree-no-icons .jstree-checkbox { display:-moz-inline-stack !important; } ';
329
  /* this shouldn't be here as it is theme specific */
330
  }
339
  this.data.core.to_open = this.get_settings().core.initially_open;
340
  this.data.core.to_load = this.get_settings().core.initially_load;
341
  },
342
+ defaults : {
343
  html_titles : false,
344
  animation : 500,
345
  initially_open : [],
354
  multiple_selection : "Multiple selection"
355
  }
356
  },
357
+ _fn : {
358
+ init : function () {
359
+ this.set_focus();
360
  if(this._get_settings().core.rtl) {
361
  this.get_container().addClass("jstree-rtl").css("direction", "rtl");
362
  }
364
  this.data.core.li_height = this.get_container_ul().find("li.jstree-closed, li.jstree-leaf").eq(0).height() || 18;
365
 
366
  this.get_container()
367
+ .on("li > ins", "click.jstree", $.proxy(function (event) {
368
  var trgt = $(event.target);
369
  if(trgt.is("ins") && event.pageY - trgt.offset().top < this.data.core.li_height) { this.toggle_node(trgt); }
370
  }, this))
371
+ .on("mousedown.jstree", $.proxy(function () {
372
  this.set_focus(); // This used to be setTimeout(set_focus,0) - why?
373
  }, this))
374
+ .on("dblclick.jstree", function (event) {
375
  var sel;
376
  if(document.selection && document.selection.empty) { document.selection.empty(); }
377
  else {
378
  if(window.getSelection) {
379
  sel = window.getSelection();
380
+ try {
381
  sel.removeAllRanges();
382
  sel.collapse();
383
  } catch (err) { }
386
  });
387
  if(this._get_settings().core.notify_plugins) {
388
  this.get_container()
389
+ .on("load_node.jstree", $.proxy(function (e, data) {
390
  var o = this._get_node(data.rslt.obj),
391
  t = this;
392
  if(o === -1) { o = this.get_container_ul(); }
405
  }
406
  if(this._get_settings().core.load_open) {
407
  this.get_container()
408
+ .on("load_node.jstree", $.proxy(function (e, data) {
409
  var o = this._get_node(data.rslt.obj),
410
  t = this;
411
  if(o === -1) { o = this.get_container_ul(); }
418
  this.__callback();
419
  this.load_node(-1, function () { this.loaded(); this.reload_nodes(); });
420
  },
421
+ destroy : function () {
422
  var i,
423
  n = this.get_index(),
424
  s = this._get_settings(),
429
  });
430
  this.__callback();
431
  // set focus to another instance if this one is focused
432
+ if(this.is_focused()) {
433
+ for(i in instances) {
434
+ if(instances.hasOwnProperty(i) && i != n) {
435
+ instances[i].set_focus();
436
+ break;
437
+ }
438
  }
439
  }
440
  // if no other instance found
442
  // remove all traces of jstree in the DOM (only the ones set using jstree*) and cleans all events
443
  this.get_container()
444
  .unbind(".jstree")
445
+ // .undelegate(".jstree") // TODO: Refactor deprecated method.
446
  .removeData("jstree-instance-id")
447
  .find("[class^='jstree']")
448
  .andSelf()
449
  .attr("class", function () { return this.className.replace(/jstree[^ ]*|$/ig,''); });
450
  $(document)
451
  .unbind(".jstree-" + n)
452
+ // .undelegate(".jstree-" + n); // TODO: Refactor deprecated method.
453
  // remove the actual data
454
  instances[n] = null;
455
  delete instances[n];
475
  save_opened : function () {
476
  var _this = this;
477
  this.data.core.to_open = [];
478
+ this.get_container_ul().find("li.jstree-open").each(function () {
479
  if(this.id) { _this.data.core.to_open.push("#" + this.id.toString().replace(/^#/,"").replace(/\\\//g,"/").replace(/\//g,"\\\/").replace(/\\\./g,".").replace(/\./g,"\\.").replace(/\:/g,"\\:")); }
480
  });
481
  this.__callback(_this.data.core.to_open);
486
  done = true,
487
  current = [],
488
  remaining = [];
489
+ if(!is_callback) {
490
+ this.data.core.reopen = false;
491
+ this.data.core.refreshing = true;
492
  this.data.core.to_open = $.map($.makeArray(this.data.core.to_open), function (n) { return "#" + n.toString().replace(/^#/,"").replace(/\\\//g,"/").replace(/\//g,"\\\/").replace(/\\\./g,".").replace(/\./g,"\\.").replace(/\:/g,"\\:"); });
493
  this.data.core.to_load = $.map($.makeArray(this.data.core.to_load), function (n) { return "#" + n.toString().replace(/^#/,"").replace(/\\\//g,"/").replace(/\//g,"\\\/").replace(/\\\./g,".").replace(/\./g,"\\.").replace(/\:/g,"\\:"); });
494
  if(this.data.core.to_open.length) {
503
  });
504
  if(current.length) {
505
  this.data.core.to_load = remaining;
506
+ $.each(current, function (i, val) {
507
  if(!_this._is_loaded(val)) {
508
  _this.load_node(val, function () { _this.reload_nodes(true); }, function () { _this.reload_nodes(true); });
509
  done = false;
513
  }
514
  if(this.data.core.to_open.length) {
515
  $.each(this.data.core.to_open, function (i, val) {
516
+ _this.open_node(val, false, true);
517
  });
518
  }
519
+ if(done) {
520
  // TODO: find a more elegant approach to syncronizing returning requests
521
  if(this.data.core.reopen) { clearTimeout(this.data.core.reopen); }
522
  this.data.core.reopen = setTimeout(function () { _this.__callback({}, _this); }, 50);
528
  var _this = this;
529
  if(this.data.core.to_open.length) {
530
  $.each(this.data.core.to_open, function (i, val) {
531
+ _this.open_node(val, false, true);
532
  });
533
  }
534
  this.__callback({});
544
  this.load_node(obj, function () { _this.__callback({ "obj" : obj}); _this.reload_nodes(); });
545
  },
546
  // Dummy function to fire after the first load (so that there is a jstree.loaded event)
547
+ loaded : function () {
548
+ this.__callback();
549
  },
550
  // deal with focus
551
+ set_focus : function () {
552
  if(this.is_focused()) { return; }
553
  var f = $.jstree._focused();
554
  if(f) { f.unset_focus(); }
555
 
556
+ this.get_container().addClass("jstree-focused");
557
+ focused_instance = this.get_index();
558
  this.__callback();
559
  },
560
+ is_focused : function () {
561
+ return focused_instance == this.get_index();
562
  },
563
  unset_focus : function () {
564
  if(this.is_focused()) {
565
+ this.get_container().removeClass("jstree-focused");
566
+ focused_instance = -1;
567
  }
568
  this.__callback();
569
  },
570
 
571
  // traverse
572
+ _get_node : function (obj) {
573
+ var $obj = $(obj, this.get_container());
574
+ if($obj.is(".jstree") || obj == -1) { return -1; }
575
+ $obj = $obj.closest("li", this.get_container());
576
+ return $obj.length ? $obj : false;
577
  },
578
  _get_next : function (obj, strict) {
579
  obj = this._get_node(obj);
683
  open_all : function (obj, do_animation, original_obj) {
684
  obj = obj ? this._get_node(obj) : -1;
685
  if(!obj || obj === -1) { obj = this.get_container_ul(); }
686
+ if(original_obj) {
687
  obj = obj.find("li.jstree-closed");
688
  }
689
  else {
692
  else { obj = obj.find("li.jstree-closed"); }
693
  }
694
  var _this = this;
695
+ obj.each(function () {
696
+ var __this = this;
697
  if(!_this._is_loaded(this)) { _this.open_node(this, function() { _this.open_all(__this, do_animation, original_obj); }, !do_animation); }
698
  else { _this.open_node(this, false, !do_animation); }
699
  });
718
  this.__callback({ "obj" : obj });
719
  },
720
  // rollback
721
+ get_rollback : function () {
722
  this.__callback();
723
+ return { i : this.get_index(), h : this.get_container().children("ul").clone(true), d : this.data };
724
  },
725
  set_rollback : function (html, data) {
726
  this.get_container().empty().append(html);
750
  if(js.metadata) { d.data(js.metadata); }
751
  if(js.state) { d.addClass("jstree-" + js.state); }
752
  if(!js.data) { js.data = this._get_string("new_node"); }
753
+ if(!Array.isArray(js.data)) { tmp = js.data; js.data = []; js.data.push(tmp); }
754
  $.each(js.data, function (i, m) {
755
  tmp = $("<a />");
756
  if($.isFunction(m)) { m = m.call(this, js); }
762
  if(m.language) { tmp.addClass(m.language); }
763
  }
764
  tmp.prepend("<ins class='jstree-icon'>&#160;</ins>");
765
+ if(m.icon) {
766
  if(m.icon.indexOf("/") === -1) { tmp.children("ins").addClass(m.icon); }
767
  else { tmp.children("ins").css("background","url('" + m.icon + "') center center no-repeat"); }
768
  }
877
  case "first":
878
  case "before":
879
  case "inside":
880
+ p.cp = 0;
881
  break;
882
  case "after":
883
  case "last":
884
+ p.cp = p.rt.get_container().find(" > ul > li").length;
885
  break;
886
  default:
887
  p.cp = p.p;
907
  p.cr = p.r;
908
  break;
909
  case "last":
910
+ p.cp = p.r.find(" > ul > li").length;
911
  p.cr = p.r;
912
  break;
913
+ default:
914
  p.cp = p.p;
915
  p.cr = p.r;
916
  break;
931
  var obj = prepared_move, ret = true, r = obj.r === -1 ? this.get_container() : obj.r;
932
  if(!obj || !obj.o || obj.or[0] === obj.o[0]) { return false; }
933
  if(obj.op && obj.np && obj.op[0] === obj.np[0] && obj.cp - 1 === obj.o.index()) { return false; }
934
+ obj.o.each(function () {
935
  if(r.parentsUntil(".jstree", "li").andSelf().index(this) !== -1) { ret = false; return false; }
936
  });
937
  return ret;
938
  },
939
  move_node : function (obj, ref, position, is_copy, is_prepared, skip_check) {
940
+ if(!is_prepared) {
941
  return this.prepare_move(obj, ref, position, function (p) {
942
  this.move_node(p, false, false, is_copy, true, skip_check);
943
  });
944
  }
945
+ if(is_copy) {
946
  prepared_move.cy = true;
947
  }
948
  if(!skip_check && !this.check_move()) { return false; }
958
  else { o = obj.o; }
959
 
960
  if(obj.or.length) { obj.or.before(o); }
961
+ else {
962
  if(!obj.np.children("ul").length) { $("<ul />").appendTo(obj.np); }
963
+ obj.np.children("ul:eq(0)").append(o);
964
  }
965
 
966
+ try {
967
  obj.ot.clean_node(obj.op);
968
  obj.rt.clean_node(obj.np);
969
  if(!obj.op.find("> ul > li").length) {
971
  }
972
  } catch (e) { }
973
 
974
+ if(is_copy) {
975
  prepared_move.cy = true;
976
+ prepared_move.oc = o;
977
  }
978
  this.__callback(prepared_move);
979
  return prepared_move;
984
  })(jQuery);
985
  //*/
986
 
987
+ /*
988
  * jsTree ui plugin
989
  * This plugins handles selecting/deselecting/hovering/dehovering nodes
990
  */
996
  e2 = $('<textarea cols="10" rows="2" style="overflow: hidden;"></textarea>').css({ position: 'absolute', top: -1000, left: 0 }).appendTo('body');
997
  scrollbar_width = e1.width() - e2.width();
998
  e1.add(e2).remove();
999
+ }
1000
  else {
1001
  e1 = $('<div />').css({ width: 100, height: 100, overflow: 'auto', position: 'absolute', top: -1000, left: 0 })
1002
  .prependTo('body').append('<div />').find('div').css({ width: '100%', height: 200 });
1005
  }
1006
  });
1007
  $.jstree.plugin("ui", {
1008
+ __init : function () {
1009
+ this.data.ui.selected = $();
1010
+ this.data.ui.last_selected = false;
1011
  this.data.ui.hovered = null;
1012
  this.data.ui.to_select = this.get_settings().ui.initially_select;
1013
 
1014
  this.get_container()
1015
+ .on("a", "click.jstree", $.proxy(function (event) {
1016
  event.preventDefault();
1017
  event.currentTarget.blur();
1018
  if(!$(event.currentTarget).hasClass("jstree-loading")) {
1019
  this.select_node(event.currentTarget, true, event);
1020
  }
1021
  }, this))
1022
+ .on("a", "mouseenter.jstree", $.proxy(function (event) {
1023
  if(!$(event.currentTarget).hasClass("jstree-loading")) {
1024
  this.hover_node(event.target);
1025
  }
1026
  }, this))
1027
+ .on("a", "mouseleave.jstree", $.proxy(function (event) {
1028
  if(!$(event.currentTarget).hasClass("jstree-loading")) {
1029
  this.dehover_node(event.target);
1030
  }
1031
  }, this))
1032
+ .on("reopen.jstree", $.proxy(function () {
1033
  this.reselect();
1034
  }, this))
1035
+ .on("get_rollback.jstree", $.proxy(function () {
1036
  this.dehover_node();
1037
  this.save_selected();
1038
  }, this))
1039
+ .on("set_rollback.jstree", $.proxy(function () {
1040
  this.reselect();
1041
  }, this))
1042
+ .on("close_node.jstree", $.proxy(function (event, data) {
1043
  var s = this._get_settings().ui,
1044
  obj = this._get_node(data.rslt.obj),
1045
  clk = (obj && obj.length) ? obj.children("ul").find("a.jstree-clicked") : $(),
1046
  _this = this;
1047
  if(s.selected_parent_close === false || !clk.length) { return; }
1048
+ clk.each(function () {
1049
  _this.deselect_node(this);
1050
  if(s.selected_parent_close === "select_parent") { _this.select_node(obj); }
1051
  });
1052
  }, this))
1053
+ .on("delete_node.jstree", $.proxy(function (event, data) {
1054
  var s = this._get_settings().ui.select_prev_on_delete,
1055
  obj = this._get_node(data.rslt.obj),
1056
  clk = (obj && obj.length) ? obj.find("a.jstree-clicked") : [],
1057
  _this = this;
1058
  clk.each(function () { _this.deselect_node(this); });
1059
+ if(s && clk.length) {
1060
+ data.rslt.prev.each(function () {
1061
  if(this.parentNode) { _this.select_node(this); return false; /* if return false is removed all prev nodes will be selected */}
1062
  });
1063
  }
1064
  }, this))
1065
+ .on("move_node.jstree", $.proxy(function (event, data) {
1066
+ if(data.rslt.cy) {
1067
  data.rslt.oc.find("a.jstree-clicked").removeClass("jstree-clicked");
1068
  }
1069
  }, this));
1078
  disable_selecting_children : false,
1079
  initially_select : []
1080
  },
1081
+ _fn : {
1082
  _get_node : function (obj, allow_multiple) {
1083
  if(typeof obj === "undefined" || obj === null) { return allow_multiple ? this.data.ui.selected : this.data.ui.last_selected; }
1084
+ var $obj = $(obj, this.get_container());
1085
+ if($obj.is(".jstree") || obj == -1) { return -1; }
1086
+ $obj = $obj.closest("li", this.get_container());
1087
+ return $obj.length ? $obj : false;
1088
  },
1089
  _ui_notify : function (n, data) {
1090
  if(data.selected) {
1136
  proceed = true,
1137
  t = this;
1138
  if(check) {
1139
+ if(s.disable_selecting_children && is_multiple &&
1140
  (
1141
  (obj.parentsUntil(".jstree","li").children("a.jstree-clicked").length) ||
1142
  (obj.children("ul").find("a.jstree-clicked:eq(0)").length)
1161
  proceed = false;
1162
  }
1163
  break;
1164
+ case (is_selected && !is_multiple):
1165
  this.deselect_all();
1166
  is_selected = false;
1167
  proceed = true;
1168
  break;
1169
+ case (!is_selected && !is_multiple):
1170
  if(s.select_limit == -1 || s.select_limit > 0) {
1171
  this.deselect_all();
1172
  proceed = true;
1173
  }
1174
  break;
1175
+ case (is_selected && is_multiple):
1176
  this.deselect_node(obj);
1177
  break;
1178
+ case (!is_selected && is_multiple):
1179
+ if(s.select_limit == -1 || this.data.ui.selected.length + 1 <= s.select_limit) {
1180
  proceed = true;
1181
  }
1182
  break;
1199
  obj = this._get_node(obj);
1200
  if(!obj || obj === -1 || !obj.length || !obj.is(":visible")) { return; }
1201
  t = obj.offset().top - this.get_container().offset().top;
1202
+ if(t < 0) {
1203
+ c.scrollTop = c.scrollTop + t - 1;
1204
  }
1205
+ if(t + this.data.core.li_height + (c.scrollWidth > c.offsetWidth ? scrollbar_width : 0) > c.offsetHeight) {
1206
+ c.scrollTop = c.scrollTop + (t - c.offsetHeight + this.data.core.li_height + 1 + (c.scrollWidth > c.offsetWidth ? scrollbar_width : 0));
1207
  }
1208
  }
1209
  },
1224
  else { this.select_node(obj); }
1225
  },
1226
  is_selected : function (obj) { return this.data.ui.selected.index(this._get_node(obj)) >= 0; },
1227
+ get_selected : function (context) {
1228
+ return context ? $(context).find("a.jstree-clicked").parent() : this.data.ui.selected;
1229
  },
1230
  deselect_all : function (context) {
1231
  var ret = context ? $(context).find("a.jstree-clicked").parent() : this.get_container().find("a.jstree-clicked").parent();
1241
  })(jQuery);
1242
  //*/
1243
 
1244
+ /*
1245
  * jsTree CRRM plugin
1246
  * Handles creating/renaming/removing/moving nodes by user interaction.
1247
  */
1248
  (function ($) {
1249
+ $.jstree.plugin("crrm", {
1250
  __init : function () {
1251
  this.get_container()
1252
+ .on("move_node.jstree", $.proxy(function (e, data) {
1253
  if(this._get_settings().crrm.move.open_onmove) {
1254
  var t = this;
1255
  data.rslt.np.parentsUntil(".jstree").andSelf().filter(".jstree-closed").each(function () {
1277
  t = this.get_text(obj),
1278
  h1 = $("<div />", { css : { "position" : "absolute", "top" : "-200px", "left" : (rtl ? "0px" : "-1000px"), "visibility" : "hidden" } }).appendTo("body"),
1279
  h2 = obj.css("position","relative").append(
1280
+ $("<input />", {
1281
  "value" : t,
1282
  "class" : "jstree-rename-input",
1283
  // "size" : t.length,
1316
  if(key == 13) { return false; }
1317
  }
1318
  })
1319
+ ).children(".jstree-rename-input");
1320
  this.set_text(obj, "");
1321
  h1.css({
1322
  fontFamily : h2.css('fontFamily') || '',
1334
  obj = this._get_node(obj);
1335
  this.__rollback();
1336
  var f = this.__callback;
1337
+ this._show_input(obj, function (obj, new_name, old_name) {
1338
  f.call(this, { "obj" : obj, "new_name" : new_name, "old_name" : old_name });
1339
  });
1340
  },
1348
  pos = $(t).index();
1349
  if(callback) { callback.call(this, t); }
1350
  if(p.length && p.hasClass("jstree-closed")) { this.open_node(p, false, true); }
1351
+ if(!skip_rename) {
1352
+ this._show_input(t, function (obj, new_name, old_name) {
1353
  _this.__callback({ "obj" : obj, "name" : new_name, "parent" : p, "position" : pos });
1354
  });
1355
  }
1372
  },
1373
  move_node : function (obj, ref, position, is_copy, is_prepared, skip_check) {
1374
  var s = this._get_settings().crrm.move;
1375
+ if(!is_prepared) {
1376
  if(typeof position === "undefined") { position = s.default_position; }
1377
  if(position === "inside" && !s.default_position.match(/^(before|after)$/)) { position = s.default_position; }
1378
  return this.__call_old(true, obj, ref, position, is_copy, false, skip_check);
1398
  this.data.crrm.cp_nodes = obj;
1399
  this.__callback({ "obj" : obj });
1400
  },
1401
+ paste : function (obj) {
1402
  obj = this._get_node(obj);
1403
  if(!obj || !obj.length) { return false; }
1404
  var nodes = this.data.crrm.ct_nodes ? this.data.crrm.ct_nodes : this.data.crrm.cp_nodes;
1414
  })(jQuery);
1415
  //*/
1416
 
1417
+ /*
1418
  * jsTree themes plugin
1419
  * Handles loading and setting themes, as well as detecting path to themes, etc.
1420
  */
1423
  // this variable stores the path to the themes folder - if left as false - it will be autodetected
1424
  $.jstree._themes = false;
1425
  $.jstree.plugin("themes", {
1426
+ __init : function () {
1427
  this.get_container()
1428
+ .on("init.jstree", $.proxy(function () {
1429
  var s = this._get_settings().themes;
1430
+ this.data.themes.dots = s.dots;
1431
+ this.data.themes.icons = s.icons;
1432
  this.set_theme(s.theme, s.url);
1433
  }, this))
1434
+ .on("loaded.jstree", $.proxy(function () {
1435
  // bound here too, as simple HTML tree's won't honor dots & icons otherwise
1436
  if(!this.data.themes.dots) { this.hide_dots(); }
1437
  else { this.show_dots(); }
1439
  else { this.show_icons(); }
1440
  }, this));
1441
  },
1442
+ defaults : {
1443
+ theme : "default",
1444
  url : false,
1445
  dots : true,
1446
  icons : true
1478
  // autodetect themes path
1479
  $(function () {
1480
  if($.jstree._themes === false) {
1481
+ $("script").each(function () {
1482
+ if(this.src.toString().match(/jquery\.jstree[^\/]*?\.js(\?.*)?$/)) {
1483
+ $.jstree._themes = this.src.toString().replace(/jquery\.jstree[^\/]*?\.js(\?.*)?$/, "") + 'themes/';
1484
+ return false;
1485
  }
1486
  });
1487
  }
1501
  var bound = [];
1502
  function exec(i, event) {
1503
  var f = $.jstree._focused(), tmp;
1504
+ if(f && f.data && f.data.hotkeys && f.data.hotkeys.enabled) {
1505
  tmp = f._get_settings().hotkeys[i];
1506
  if(tmp) { return tmp.call(f, event); }
1507
  }
1512
  if(!this.data.ui) { throw "jsTree hotkeys: jsTree UI plugin not included."; }
1513
  $.each(this._get_settings().hotkeys, function (i, v) {
1514
  if(v !== false && $.inArray(i, bound) == -1) {
1515
+ $(document).on("keydown", i, function (event) { return exec(i, event); });
1516
  bound.push(i);
1517
  }
1518
  });
1519
  this.get_container()
1520
+ .on("lock.jstree", $.proxy(function () {
1521
  if(this.data.hotkeys.enabled) { this.data.hotkeys.enabled = false; this.data.hotkeys.revert = true; }
1522
  }, this))
1523
+ .on("unlock.jstree", $.proxy(function () {
1524
  if(this.data.hotkeys.revert) { this.data.hotkeys.enabled = true; }
1525
  }, this));
1526
  this.enable_hotkeys();
1527
  },
1528
  defaults : {
1529
+ "up" : function () {
1530
  var o = this.data.ui.hovered || this.data.ui.last_selected || -1;
1531
  this.hover_node(this._get_prev(o));
1532
+ return false;
1533
  },
1534
+ "ctrl+up" : function () {
1535
  var o = this.data.ui.hovered || this.data.ui.last_selected || -1;
1536
  this.hover_node(this._get_prev(o));
1537
+ return false;
1538
  },
1539
+ "shift+up" : function () {
1540
  var o = this.data.ui.hovered || this.data.ui.last_selected || -1;
1541
  this.hover_node(this._get_prev(o));
1542
+ return false;
1543
  },
1544
+ "down" : function () {
1545
  var o = this.data.ui.hovered || this.data.ui.last_selected || -1;
1546
  this.hover_node(this._get_next(o));
1547
  return false;
1548
  },
1549
+ "ctrl+down" : function () {
1550
  var o = this.data.ui.hovered || this.data.ui.last_selected || -1;
1551
  this.hover_node(this._get_next(o));
1552
  return false;
1553
  },
1554
+ "shift+down" : function () {
1555
  var o = this.data.ui.hovered || this.data.ui.last_selected || -1;
1556
  this.hover_node(this._get_next(o));
1557
  return false;
1558
  },
1559
+ "left" : function () {
1560
  var o = this.data.ui.hovered || this.data.ui.last_selected;
1561
  if(o) {
1562
  if(o.hasClass("jstree-open")) { this.close_node(o); }
1564
  }
1565
  return false;
1566
  },
1567
+ "ctrl+left" : function () {
1568
  var o = this.data.ui.hovered || this.data.ui.last_selected;
1569
  if(o) {
1570
  if(o.hasClass("jstree-open")) { this.close_node(o); }
1572
  }
1573
  return false;
1574
  },
1575
+ "shift+left" : function () {
1576
  var o = this.data.ui.hovered || this.data.ui.last_selected;
1577
  if(o) {
1578
  if(o.hasClass("jstree-open")) { this.close_node(o); }
1580
  }
1581
  return false;
1582
  },
1583
+ "right" : function () {
1584
  var o = this.data.ui.hovered || this.data.ui.last_selected;
1585
  if(o && o.length) {
1586
  if(o.hasClass("jstree-closed")) { this.open_node(o); }
1588
  }
1589
  return false;
1590
  },
1591
+ "ctrl+right" : function () {
1592
  var o = this.data.ui.hovered || this.data.ui.last_selected;
1593
  if(o && o.length) {
1594
  if(o.hasClass("jstree-closed")) { this.open_node(o); }
1596
  }
1597
  return false;
1598
  },
1599
+ "shift+right" : function () {
1600
  var o = this.data.ui.hovered || this.data.ui.last_selected;
1601
  if(o && o.length) {
1602
  if(o.hasClass("jstree-closed")) { this.open_node(o); }
1604
  }
1605
  return false;
1606
  },
1607
+ "space" : function () {
1608
+ if(this.data.ui.hovered) { this.data.ui.hovered.children("a:eq(0)").click(); }
1609
+ return false;
1610
  },
1611
+ "ctrl+space" : function (event) {
1612
  event.type = "click";
1613
+ if(this.data.ui.hovered) { this.data.ui.hovered.children("a:eq(0)").trigger(event); }
1614
+ return false;
1615
  },
1616
+ "shift+space" : function (event) {
1617
  event.type = "click";
1618
+ if(this.data.ui.hovered) { this.data.ui.hovered.children("a:eq(0)").trigger(event); }
1619
+ return false;
1620
  },
1621
  "f2" : function () { this.rename(this.data.ui.hovered || this.data.ui.last_selected); },
1622
  "del" : function () { this.remove(this.data.ui.hovered || this._get_node(null)); }
1633
  })(jQuery);
1634
  //*/
1635
 
1636
+ /*
1637
  * jsTree JSON plugin
1638
  * The JSON data store. Datastores are build by overriding the `load_node` and `_is_loaded` functions.
1639
  */
1642
  __init : function() {
1643
  var s = this._get_settings().json_data;
1644
  if(s.progressive_unload) {
1645
+ this.get_container().on("after_close.jstree", function (e, data) {
1646
  data.rslt.obj.children("ul").remove();
1647
  });
1648
  }
1649
  },
1650
+ defaults : {
1651
  // `data` can be a function:
1652
  // * accepts two arguments - node being loaded and a callback to pass the result to
1653
  // * will be executed in the current tree's scope & ajax won't be supported
1654
+ data : false,
1655
  ajax : false,
1656
  correct_state : true,
1657
  progressive_render : false,
1659
  },
1660
  _fn : {
1661
  load_node : function (obj, s_call, e_call) { var _this = this; this.load_node_json(obj, function () { _this.__callback({ "obj" : _this._get_node(obj) }); s_call.call(this); }, e_call); },
1662
+ _is_loaded : function (obj) {
1663
  var s = this._get_settings().json_data;
1664
+ obj = this._get_node(obj);
1665
  return obj == -1 || !obj || (!s.ajax && !s.progressive_render && !$.isFunction(s.data)) || obj.is(".jstree-open, .jstree-leaf") || obj.children("ul").children("li").length > 0;
1666
  },
1667
  refresh : function (obj) {
1699
  case ($.isFunction(s.data)):
1700
  s.data.call(this, obj, $.proxy(function (d) {
1701
  d = this._parse_json(d, obj);
1702
+ if(!d) {
1703
  if(obj === -1 || !obj) {
1704
  if(s.correct_state) { this.get_container().children("ul").empty(); }
1705
  }
1725
  this.get_container().children("ul").empty().append(d.children());
1726
  this.clean_node();
1727
  }
1728
+ else {
1729
  if(s.correct_state) { this.get_container().children("ul").empty(); }
1730
  }
1731
  }
1733
  break;
1734
  case (!s.data && !!s.ajax) || (!!s.data && !!s.ajax && obj && obj !== -1):
1735
  error_func = function (x, t, e) {
1736
+ var ef = this.get_settings().json_data.ajax.error;
1737
  if(ef) { ef.call(this, x, t, e); }
1738
  if(obj != -1 && obj.length) {
1739
  obj.children("a.jstree-loading").removeClass("jstree-loading");
1746
  if(e_call) { e_call.call(this); }
1747
  };
1748
  success_func = function (d, t, x) {
1749
+ var sf = this.get_settings().json_data.ajax.success;
1750
  if(sf) { d = sf.call(this,d,t,x) || d; }
1751
+ if(d === "" || (d && d.toString && d.toString().replace(/^[\s\n]+$/,"") === "") || (!Array.isArray(d) && !$.isPlainObject(d))) {
1752
  return error_func.call(this, x, t, "");
1753
  }
1754
  d = this._parse_json(d, obj);
1760
  }
1761
  else {
1762
  if(obj === -1 || !obj) {
1763
+ if(s.correct_state) {
1764
+ this.get_container().children("ul").empty();
1765
  if(s_call) { s_call.call(this); }
1766
  }
1767
  }
1768
  else {
1769
  obj.children("a.jstree-loading").removeClass("jstree-loading");
1770
  obj.removeData("jstree-is-loading");
1771
+ if(s.correct_state) {
1772
  this.correct_state(obj);
1773
+ if(s_call) { s_call.call(this); }
1774
  }
1775
  }
1776
  }
1786
  }
1787
  },
1788
  _parse_json : function (js, obj, is_callback) {
1789
+ var d = false,
1790
  p = this._get_settings(),
1791
  s = p.json_data,
1792
  t = p.core.html_titles,
1793
  tmp, i, j, ul1, ul2;
1794
 
1795
  if(!js) { return d; }
1796
+ if(s.progressive_unload && obj && obj !== -1) {
1797
  obj.data("jstree-children", d);
1798
  }
1799
+ if(Array.isArray(js)) {
1800
  d = $();
1801
  if(!js.length) { return false; }
1802
  for(i = 0, j = js.length; i < j; i++) {
1811
  if(js.attr) { d.attr(js.attr); }
1812
  if(js.metadata) { d.data(js.metadata); }
1813
  if(js.state) { d.addClass("jstree-" + js.state); }
1814
+ if(!Array.isArray(js.data)) { tmp = js.data; js.data = []; js.data.push(tmp); }
1815
  $.each(js.data, function (i, m) {
1816
  tmp = $("<a />");
1817
  if($.isFunction(m)) { m = m.call(this, js); }
1824
  }
1825
  tmp.prepend("<ins class='jstree-icon'>&#160;</ins>");
1826
  if(!m.icon && js.icon) { m.icon = js.icon; }
1827
+ if(m.icon) {
1828
  if(m.icon.indexOf("/") === -1) { tmp.children("ins").addClass(m.icon); }
1829
  else { tmp.children("ins").css("background","url('" + m.icon + "') center center no-repeat"); }
1830
  }
1831
  d.append(tmp);
1832
  });
1833
  d.prepend("<ins class='jstree-icon'>&#160;</ins>");
1834
+ if(js.children) {
1835
  if(s.progressive_render && js.state !== "open") {
1836
  d.addClass("jstree-closed").data("jstree-children", js.children);
1837
  }
1838
  else {
1839
  if(s.progressive_unload) { d.data("jstree-children", js.children); }
1840
+ if(Array.isArray(js.children) && js.children.length) {
1841
  tmp = this._parse_json(js.children, obj, true);
1842
  if(tmp.length) {
1843
  ul2 = $("<ul />");
1856
  return d;
1857
  },
1858
  get_json : function (obj, li_attr, a_attr, is_callback) {
1859
+ var result = [],
1860
+ s = this._get_settings(),
1861
  _this = this,
1862
  tmp1, tmp2, li, a, t, lang;
1863
  obj = this._get_node(obj);
1864
  if(!obj || obj === -1) { obj = this.get_container().find("> ul > li"); }
1865
+ li_attr = Array.isArray(li_attr) ? li_attr : [ "id", "class" ];
1866
  if(!is_callback && this.data.types) { li_attr.push(s.types.type_attr); }
1867
+ a_attr = Array.isArray(a_attr) ? a_attr : [ ];
1868
 
1869
  obj.each(function () {
1870
  li = $(this);
1871
  tmp1 = { data : [] };
1872
  if(li_attr.length) { tmp1.attr = { }; }
1873
+ $.each(li_attr, function (i, v) {
1874
+ tmp2 = li.attr(v);
1875
  if(tmp2 && tmp2.length && tmp2.replace(/jstree[^ ]*/ig,'').length) {
1876
+ tmp1.attr[v] = (" " + tmp2).replace(/ jstree[^ ]*/ig,'').replace(/\s+$/ig," ").replace(/^ /,"").replace(/ $/,"");
1877
  }
1878
  });
1879
  if(li.hasClass("jstree-open")) { tmp1.state = "open"; }
1883
  a.each(function () {
1884
  t = $(this);
1885
  if(
1886
+ a_attr.length ||
1887
+ $.inArray("languages", s.plugins) !== -1 ||
1888
+ t.children("ins").get(0).style.backgroundImage.length ||
1889
  (t.children("ins").get(0).className && t.children("ins").get(0).className.replace(/jstree[^ ]*|$/ig,'').length)
1890
+ ) {
1891
  lang = false;
1892
+ if($.inArray("languages", s.plugins) !== -1 && Array.isArray(s.languages) && s.languages.length) {
1893
  $.each(s.languages, function (l, lv) {
1894
  if(t.hasClass(lv)) {
1895
  lang = lv;
1897
  }
1898
  });
1899
  }
1900
+ tmp2 = { attr : { }, title : _this.get_text(t, lang) };
1901
  $.each(a_attr, function (k, z) {
1902
  tmp2.attr[z] = (" " + (t.attr(z) || "")).replace(/ jstree[^ ]*/ig,'').replace(/\s+$/ig," ").replace(/^ /,"").replace(/ $/,"");
1903
  });
1904
+ if($.inArray("languages", s.plugins) !== -1 && Array.isArray(s.languages) && s.languages.length) {
1905
  $.each(s.languages, function (k, z) {
1906
  if(t.hasClass(z)) { tmp2.language = z; return true; }
1907
  });
1930
  })(jQuery);
1931
  //*/
1932
 
1933
+ /*
1934
  * jsTree languages plugin
1935
  * Adds support for multiple language versions in one tree
1936
  * This basically allows for many titles coexisting in one node, but only one of them being visible at any given time
1941
  __init : function () { this._load_css(); },
1942
  defaults : [],
1943
  _fn : {
1944
+ set_lang : function (i) {
1945
  var langs = this._get_settings().languages,
1946
  st = false,
1947
  selector = ".jstree-" + this.get_index() + ' a';
1948
+ if(!Array.isArray(langs) || langs.length === 0) { return false; }
1949
  if($.inArray(i,langs) == -1) {
1950
  if(!!langs[i]) { i = langs[i]; }
1951
  else { return false; }
1965
  _get_string : function (key, lang) {
1966
  var langs = this._get_settings().languages,
1967
  s = this._get_settings().core.strings;
1968
+ if(Array.isArray(langs) && langs.length) {
1969
  lang = (lang && $.inArray(lang,langs) != -1) ? lang : this.data.languages.current_language;
1970
  }
1971
  if(s[lang] && s[lang][key]) { return s[lang][key]; }
1977
  if(!obj.size()) { return false; }
1978
  var langs = this._get_settings().languages,
1979
  s = this._get_settings().core.html_titles;
1980
+ if(Array.isArray(langs) && langs.length) {
1981
  lang = (lang && $.inArray(lang,langs) != -1) ? lang : this.data.languages.current_language;
1982
  obj = obj.children("a." + lang);
1983
  }
1998
  var langs = this._get_settings().languages,
1999
  s = this._get_settings().core.html_titles,
2000
  tmp;
2001
+ if(Array.isArray(langs) && langs.length) {
2002
  lang = (lang && $.inArray(lang,langs) != -1) ? lang : this.data.languages.current_language;
2003
  obj = obj.children("a." + lang);
2004
  }
2020
  str = "/* languages css */",
2021
  selector = ".jstree-" + this.get_index() + ' a',
2022
  ln;
2023
+ if(Array.isArray(langs) && langs.length) {
2024
  this.data.languages.current_language = langs[0];
2025
  for(ln = 0; ln < langs.length; ln++) {
2026
  str += selector + "." + langs[ln] + " {";
2035
  var langs = this._get_settings().languages,
2036
  a = t.children("a"),
2037
  ln;
2038
+ if(Array.isArray(langs) && langs.length) {
2039
  for(ln = 0; ln < langs.length; ln++) {
2040
  if(!a.is("." + langs[ln])) {
2041
  t.append(a.eq(0).clone().removeClass(langs.join(" ")).addClass(langs[ln]));
2079
  this.get_container()
2080
  .one( ( this.data.ui ? "reselect" : "reopen" ) + ".jstree", $.proxy(function () {
2081
  this.get_container()
2082
+ .on("open_node.jstree close_node.jstree select_node.jstree deselect_node.jstree", $.proxy(function (e) {
2083
  if(this._get_settings().cookies.auto_save) { this.save_cookie((e.handleObj.namespace + e.handleObj.type).replace("jstree","")); }
2084
  }, this));
2085
  }, this));
2113
  switch(c) {
2114
  case "open_node":
2115
  case "close_node":
2116
+ if(!!s.save_opened) {
2117
+ this.save_opened();
2118
+ $.cookie(s.save_opened, this.data.core.to_open.join(","), s.cookie_options);
2119
  }
2120
+ if(!!s.save_loaded) {
2121
+ this.save_loaded();
2122
+ $.cookie(s.save_loaded, this.data.core.to_load.join(","), s.cookie_options);
2123
  }
2124
  break;
2125
  case "select_node":
2126
  case "deselect_node":
2127
+ if(!!s.save_selected && this.data.ui) {
2128
+ this.save_selected();
2129
+ $.cookie(s.save_selected, this.data.ui.to_select.join(","), s.cookie_options);
2130
  }
2131
  break;
2132
  }
2146
  $.jstree.plugin("sort", {
2147
  __init : function () {
2148
  this.get_container()
2149
+ .on("load_node.jstree", $.proxy(function (e, data) {
2150
  var obj = this._get_node(data.rslt.obj);
2151
  obj = obj === -1 ? this.get_container().children("ul") : obj.children("ul");
2152
  this.sort(obj);
2153
  }, this))
2154
+ .on("rename_node.jstree create_node.jstree create.jstree", $.proxy(function (e, data) {
2155
  this.sort(data.rslt.obj.parent());
2156
  }, this))
2157
+ .on("move_node.jstree", $.proxy(function (e, data) {
2158
  var m = data.rslt.np == -1 ? this.get_container() : data.rslt.np;
2159
  this.sort(m.children("ul"));
2160
  }, this));
2199
  helper_top : 10,
2200
  user_data : {},
2201
 
2202
+ drag_start : function (e, data, html) {
2203
  if($.vakata.dnd.is_drag) { $.vakata.drag_stop({}); }
2204
  try {
2205
  e.currentTarget.unselectable = "on";
2211
  $.vakata.dnd.user_data = data;
2212
  $.vakata.dnd.is_down = true;
2213
  $.vakata.dnd.helper = $("<div id='vakata-dragged' />").html(html); //.fadeTo(10,0.25);
2214
+ $(document).on("mousemove", $.vakata.dnd.drag);
2215
+ $(document).on("mouseup", $.vakata.dnd.drag_stop);
2216
  return false;
2217
  },
2218
+ drag : function (e) {
2219
  if(!$.vakata.dnd.is_down) { return; }
2220
  if(!$.vakata.dnd.is_drag) {
2221
+ if(Math.abs(e.pageX - $.vakata.dnd.init_x) > 5 || Math.abs(e.pageY - $.vakata.dnd.init_y) > 5) {
2222
  $.vakata.dnd.helper.appendTo("body");
2223
  $.vakata.dnd.is_drag = true;
2224
  $(document).triggerHandler("drag_start.vakata", { "event" : e, "data" : $.vakata.dnd.user_data });
2229
  // maybe use a scrolling parent element instead of document?
2230
  if(e.type === "mousemove") { // thought of adding scroll in order to move the helper, but mouse poisition is n/a
2231
  var d = $(document), t = d.scrollTop(), l = d.scrollLeft();
2232
+ if(e.pageY - t < 20) {
2233
  if(sti && dir1 === "down") { clearInterval(sti); sti = false; }
2234
  if(!sti) { dir1 = "up"; sti = setInterval(function () { $(document).scrollTop($(document).scrollTop() - $.vakata.dnd.scroll_spd); }, 150); }
2235
  }
2236
+ else {
2237
  if(sti && dir1 === "up") { clearInterval(sti); sti = false; }
2238
  }
2239
  if($(window).height() - (e.pageY - t) < 20) {
2240
  if(sti && dir1 === "up") { clearInterval(sti); sti = false; }
2241
  if(!sti) { dir1 = "down"; sti = setInterval(function () { $(document).scrollTop($(document).scrollTop() + $.vakata.dnd.scroll_spd); }, 150); }
2242
  }
2243
+ else {
2244
  if(sti && dir1 === "down") { clearInterval(sti); sti = false; }
2245
  }
2246
 
2248
  if(sli && dir2 === "right") { clearInterval(sli); sli = false; }
2249
  if(!sli) { dir2 = "left"; sli = setInterval(function () { $(document).scrollLeft($(document).scrollLeft() - $.vakata.dnd.scroll_spd); }, 150); }
2250
  }
2251
+ else {
2252
  if(sli && dir2 === "left") { clearInterval(sli); sli = false; }
2253
  }
2254
  if($(window).width() - (e.pageX - l) < 20) {
2255
  if(sli && dir2 === "left") { clearInterval(sli); sli = false; }
2256
  if(!sli) { dir2 = "right"; sli = setInterval(function () { $(document).scrollLeft($(document).scrollLeft() + $.vakata.dnd.scroll_spd); }, 150); }
2257
  }
2258
+ else {
2259
  if(sli && dir2 === "right") { clearInterval(sli); sli = false; }
2260
  }
2261
  }
2302
  mto : false
2303
  };
2304
  this.get_container()
2305
+ .on("mouseenter.jstree", $.proxy(function (e) {
2306
  if($.vakata.dnd.is_drag && $.vakata.dnd.user_data.jstree) {
2307
  if(this.data.themes) {
2308
+ m.attr("class", "jstree-" + this.data.themes.theme);
2309
  if(ml) { ml.attr("class", "jstree-" + this.data.themes.theme); }
2310
  $.vakata.dnd.helper.attr("class", "jstree-dnd-helper jstree-" + this.data.themes.theme);
2311
  }
2327
  }
2328
  }
2329
  }, this))
2330
+ .on("mouseup.jstree", $.proxy(function (e) {
2331
  //if($.vakata.dnd.is_drag && $.vakata.dnd.user_data.jstree && $(e.currentTarget).find("> ul > li").length === 0) {
2332
  if($.vakata.dnd.is_drag && $.vakata.dnd.user_data.jstree && e.currentTarget === e.target && $.vakata.dnd.user_data.obj && $($.vakata.dnd.user_data.obj).length && $($.vakata.dnd.user_data.obj).parents(".jstree:eq(0)")[0] !== e.target) { // node should not be from the same tree
2333
  var tr = $.jstree._reference(e.currentTarget), dc;
2342
  }
2343
  }
2344
  }, this))
2345
+ .on("mouseleave.jstree", $.proxy(function (e) {
2346
  if(e.relatedTarget && e.relatedTarget.id && e.relatedTarget.id === "jstree-marker-line") {
2347
+ return false;
2348
  }
2349
  if($.vakata.dnd.is_drag && $.vakata.dnd.user_data.jstree) {
2350
  if(this.data.dnd.i1) { clearInterval(this.data.dnd.i1); }
2356
  }
2357
  }
2358
  }, this))
2359
+ .on("mousemove.jstree", $.proxy(function (e) {
2360
  if($.vakata.dnd.is_drag && $.vakata.dnd.user_data.jstree) {
2361
  var cnt = this.get_container()[0];
2362
 
2388
 
2389
  }
2390
  }, this))
2391
+ .on("scroll.jstree", $.proxy(function (e) {
2392
  if($.vakata.dnd.is_drag && $.vakata.dnd.user_data.jstree && m && ml) {
2393
  m.hide();
2394
  ml.hide();
2395
  }
2396
  }, this))
2397
+ .on("a", "mousedown.jstree", $.proxy(function (e) {
2398
  if(e.which === 1) {
2399
  this.start_drag(e.currentTarget, e);
2400
  return false;
2401
  }
2402
  }, this))
2403
+ .on("a", "mouseenter.jstree", $.proxy(function (e) {
2404
  if($.vakata.dnd.is_drag && $.vakata.dnd.user_data.jstree) {
2405
  this.dnd_enter(e.currentTarget);
2406
  }
2407
  }, this))
2408
+ .on("a", "mousemove.jstree", $.proxy(function (e) {
2409
  if($.vakata.dnd.is_drag && $.vakata.dnd.user_data.jstree) {
2410
  if(!r || !r.length || r.children("a")[0] !== e.currentTarget) {
2411
  this.dnd_enter(e.currentTarget);
2416
  this.dnd_show();
2417
  }
2418
  }, this))
2419
+ .on("a", "mouseleave.jstree", $.proxy(function (e) {
2420
  if($.vakata.dnd.is_drag && $.vakata.dnd.user_data.jstree) {
2421
  if(e.relatedTarget && e.relatedTarget.id && e.relatedTarget.id === "jstree-marker-line") {
2422
+ return false;
2423
  }
2424
  if(m) { m.hide(); }
2425
  if(ml) { ml.hide(); }
2426
  /*
2427
+ var ec = $(e.currentTarget).closest("li"),
2428
  er = $(e.relatedTarget).closest("li");
2429
  if(er[0] !== ec.prev()[0] && er[0] !== ec.next()[0]) {
2430
  if(m) { m.hide(); }
2431
  if(ml) { ml.hide(); }
2432
  }
2433
  */
2434
+ this.data.dnd.mto = setTimeout(
2435
  (function (t) { return function () { t.dnd_leave(e); }; })(this),
2436
  0);
2437
  }
2438
  }, this))
2439
+ .on("a", "mouseup.jstree", $.proxy(function (e) {
2440
  if($.vakata.dnd.is_drag && $.vakata.dnd.user_data.jstree) {
2441
  this.dnd_finish(e);
2442
  }
2443
  }, this));
2444
 
2445
  $(document)
2446
+ .on("drag_stop.vakata", $.proxy(function () {
2447
  if(this.data.dnd.to1) { clearTimeout(this.data.dnd.to1); }
2448
  if(this.data.dnd.to2) { clearTimeout(this.data.dnd.to2); }
2449
  if(this.data.dnd.i1) { clearInterval(this.data.dnd.i1); }
2463
  if(m) { m.css({ "top" : "-2000px" }); }
2464
  if(ml) { ml.css({ "top" : "-2000px" }); }
2465
  }, this))
2466
+ .on("drag_start.vakata", $.proxy(function (e, data) {
2467
+ if(data.data.jstree) {
2468
  var et = $(data.event.target);
2469
  if(et.closest(".jstree").hasClass("jstree-" + this.get_index())) {
2470
  this.dnd_enter(et);
2472
  }
2473
  }, this));
2474
  /*
2475
+ .on("keydown.jstree-" + this.get_index() + " keyup.jstree-" + this.get_index(), $.proxy(function(e) {
2476
  if($.vakata.dnd.is_drag && $.vakata.dnd.user_data.jstree && !this.data.dnd.foreign) {
2477
  var h = $.vakata.dnd.helper.children("ins");
2478
  if(e[this._get_settings().dnd.copy_modifier + "Key"] && h.hasClass("jstree-ok")) {
2479
  h.parent().html(h.parent().html().replace(/ \(Copy\)$/, "") + " (Copy)");
2480
+ }
2481
  else {
2482
  h.parent().html(h.parent().html().replace(/ \(Copy\)$/, ""));
2483
  }
2489
  var s = this._get_settings().dnd;
2490
  if(s.drag_target) {
2491
  $(document)
2492
+ .on(s.drag_target, "mousedown.jstree-" + this.get_index(), $.proxy(function (e) {
2493
  o = e.target;
2494
  $.vakata.dnd.drag_start(e, { jstree : true, obj : e.target }, "<ins class='jstree-icon'></ins>" + $(e.target).text() );
2495
+ if(this.data.themes) {
2496
  if(m) { m.attr("class", "jstree-" + this.data.themes.theme); }
2497
  if(ml) { ml.attr("class", "jstree-" + this.data.themes.theme); }
2498
+ $.vakata.dnd.helper.attr("class", "jstree-dnd-helper jstree-" + this.data.themes.theme);
2499
  }
2500
  $.vakata.dnd.helper.children("ins").attr("class","jstree-invalid");
2501
  var cnt = this.get_container();
2508
  }
2509
  if(s.drop_target) {
2510
  $(document)
2511
+ .on(s.drop_target, "mouseenter.jstree-" + this.get_index(), $.proxy(function (e) {
2512
  if(this.data.dnd.active && this._get_settings().dnd.drop_check.call(this, { "o" : o, "r" : $(e.target), "e" : e })) {
2513
  $.vakata.dnd.helper.children("ins").attr("class","jstree-ok");
2514
  }
2515
  }, this))
2516
+ .on(s.drop_target, "mouseleave.jstree-" + this.get_index(), $.proxy(function (e) {
2517
  if(this.data.dnd.active) {
2518
  $.vakata.dnd.helper.children("ins").attr("class","jstree-invalid");
2519
  }
2520
  }, this))
2521
+ .on(s.drop_target, "mouseup.jstree-" + this.get_index(), $.proxy(function (e) {
2522
  if(this.data.dnd.active && $.vakata.dnd.helper.children("ins").hasClass("jstree-ok")) {
2523
  this._get_settings().dnd.drop_finish.call(this, { "o" : o, "r" : $(e.target), "e" : e });
2524
  }
2576
  o = this.data.dnd.w < this.data.core.li_height/2 ? ["inside","before","after"] : ["inside","after","before"];
2577
  }
2578
  else { o = ["after","inside","before"]; }
2579
+ $.each(o, $.proxy(function (i, val) {
2580
  if(this.data.dnd[val]) {
2581
  $.vakata.dnd.helper.children("ins").attr("class","jstree-ok");
2582
  r = val;
2584
  }
2585
  }, this));
2586
  if(r === false) { $.vakata.dnd.helper.children("ins").attr("class","jstree-invalid"); }
2587
+
2588
  pos = rtl ? (this.data.dnd.off.right - 18) : (this.data.dnd.off.left + 10);
2589
  switch(r) {
2590
  case "before":
2627
  if(ml) { ml.hide(); }
2628
  },
2629
  dnd_enter : function (obj) {
2630
+ if(this.data.dnd.mto) {
2631
  clearTimeout(this.data.dnd.mto);
2632
  this.data.dnd.mto = false;
2633
  }
2634
  var s = this._get_settings().dnd;
2635
  this.data.dnd.prepared = false;
2636
  r = this._get_node(obj);
2637
+ if(s.check_timeout) {
2638
  // do the calculations after a minimal timeout (users tend to drag quickly to the desired location)
2639
  if(this.data.dnd.to1) { clearTimeout(this.data.dnd.to1); }
2640
+ this.data.dnd.to1 = setTimeout($.proxy(this.dnd_prepare, this), s.check_timeout);
2641
  }
2642
+ else {
2643
+ this.dnd_prepare();
2644
  }
2645
+ if(s.open_timeout) {
2646
  if(this.data.dnd.to2) { clearTimeout(this.data.dnd.to2); }
2647
+ if(r && r.length && r.hasClass("jstree-closed")) {
2648
  // if the node is closed - open it, then recalculate
2649
  this.data.dnd.to2 = setTimeout($.proxy(this.dnd_open, this), s.open_timeout);
2650
  }
2651
  }
2652
  else {
2653
+ if(r && r.length && r.hasClass("jstree-closed")) {
2654
  this.dnd_open();
2655
  }
2656
  }
2680
  cnt = this.get_container();
2681
  if(!this._get_settings().core.html_titles) { dt = dt.replace(/</ig,"&lt;").replace(/>/ig,"&gt;"); }
2682
  $.vakata.dnd.drag_start(e, { jstree : true, obj : o }, "<ins class='jstree-icon'></ins>" + dt );
2683
+ if(this.data.themes) {
2684
  if(m) { m.attr("class", "jstree-" + this.data.themes.theme); }
2685
  if(ml) { ml.attr("class", "jstree-" + this.data.themes.theme); }
2686
+ $.vakata.dnd.helper.attr("class", "jstree-dnd-helper jstree-" + this.data.themes.theme);
2687
  }
2688
  this.data.dnd.cof = cnt.offset();
2689
  this.data.dnd.cw = parseInt(cnt.width(),10);
2693
  }
2694
  });
2695
  $(function() {
2696
+ var css_string = '' +
2697
+ '#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; ' +
2698
  ' -moz-border-radius:4px; border-radius:4px; -webkit-border-radius:4px; ' +
2699
+ '} ' +
2700
+ '#vakata-dragged .jstree-ok { background:green; } ' +
2701
+ '#vakata-dragged .jstree-invalid { background:red; } ' +
2702
+ '#jstree-marker { padding:0; margin:0; font-size:12px; overflow:hidden; height:12px; width:8px; position:absolute; top:-30px; z-index:10001; background-repeat:no-repeat; display:none; background-color:transparent; text-shadow:1px 1px 1px white; color:black; line-height:10px; } ' +
2703
+ '#jstree-marker-line { padding:0; margin:0; line-height:0%; font-size:1px; overflow:hidden; height:1px; width:100px; position:absolute; top:-30px; z-index:10000; background-repeat:no-repeat; display:none; background-color:#456c43; ' +
2704
+ ' cursor:pointer; border:1px solid #eeeeee; border-left:0; -moz-box-shadow: 0px 0px 2px #666; -webkit-box-shadow: 0px 0px 2px #666; box-shadow: 0px 0px 2px #666; ' +
2705
  ' -moz-border-radius:1px; border-radius:1px; -webkit-border-radius:1px; ' +
2706
+ '}' +
2707
  '';
2708
  $.vakata.css.add_sheet({ str : css_string, title : "jstree" });
2709
  m = $("<div />").attr({ id : "jstree-marker" }).hide().html("&raquo;")
2710
+ .on("mouseleave mouseenter", function (e) {
2711
  m.hide();
2712
  ml.hide();
2713
+ e.preventDefault();
2714
+ e.stopImmediatePropagation();
2715
+ return false;
2716
  })
2717
  .appendTo("body");
2718
  ml = $("<div />").attr({ id : "jstree-marker-line" }).hide()
2719
+ .on("mouseup", function (e) {
2720
+ if(r && r.length) {
2721
+ r.children("a").trigger(e);
2722
+ e.preventDefault();
2723
+ e.stopImmediatePropagation();
2724
+ return false;
2725
+ }
2726
  })
2727
+ .on("mouseleave", function (e) {
2728
  var rt = $(e.relatedTarget);
2729
  if(rt.is(".jstree") || rt.closest(".jstree").length === 0) {
2730
+ if(r && r.length) {
2731
+ r.children("a").trigger(e);
2732
  m.hide();
2733
  ml.hide();
2734
+ e.preventDefault();
2735
+ e.stopImmediatePropagation();
2736
+ return false;
2737
  }
2738
  }
2739
  })
2740
  .appendTo("body");
2741
+ $(document).on("drag_start.vakata", function (e, data) {
2742
  if(data.data.jstree) { m.show(); if(ml) { ml.show(); } }
2743
  });
2744
+ $(document).on("drag_stop.vakata", function (e, data) {
2745
  if(data.data.jstree) { m.hide(); if(ml) { ml.hide(); } }
2746
  });
2747
  });
2764
  }
2765
 
2766
  this.get_container()
2767
+ .on("open_node.jstree create_node.jstree clean_node.jstree refresh.jstree", $.proxy(function (e, data) {
2768
  this._prepare_checkboxes(data.rslt.obj);
2769
  }, this))
2770
+ .on("loaded.jstree", $.proxy(function (e) {
2771
  this._prepare_checkboxes();
2772
  }, this))
2773
+ .on( (this.data.ui && this.data.checkbox.noui ? "a" : "ins.jstree-checkbox") , "click.jstree", $.proxy(function (e) {
2774
  e.preventDefault();
2775
  if(this._get_node(e.target).hasClass("jstree-checked")) { this.uncheck_node(e.target); }
2776
  else { this.check_node(e.target); }
2820
  else {
2821
  $t.children(":checkbox").addClass("jstree-real-checkbox");
2822
  }
2823
+ if(c === "jstree-checked") {
2824
+ $t.children(":checkbox").attr("checked","checked");
2825
  }
2826
  }
2827
  if(c === "jstree-checked" && !ts) {
2833
  if(obj.length === 1 && obj.is("li")) { this._repair_state(obj); }
2834
  if(obj.is("li")) { obj.each(function () { _this._repair_state(this); }); }
2835
  else { obj.find("> ul > li").each(function () { _this._repair_state(this); }); }
2836
+ obj.find(".jstree-checked").parent().parent().each(function () { _this._repair_state(this); });
2837
  }
2838
  },
2839
  change_state : function (obj, state) {
2842
  if(!obj || obj === -1) { return false; }
2843
  state = (state === false || state === true) ? state : obj.hasClass("jstree-checked");
2844
  if(this._get_settings().checkbox.two_state) {
2845
+ if(state) {
2846
+ obj.removeClass("jstree-checked").addClass("jstree-unchecked");
2847
  if(rc) { obj.children(":checkbox").removeAttr("checked"); }
2848
  }
2849
+ else {
2850
+ obj.removeClass("jstree-unchecked").addClass("jstree-checked");
2851
  if(rc) { obj.children(":checkbox").attr("checked","checked"); }
2852
  }
2853
  }
2854
  else {
2855
+ if(state) {
2856
  coll = obj.find("li").andSelf();
2857
  if(!coll.filter(".jstree-checked, .jstree-undetermined").length) { return false; }
2858
+ coll.removeClass("jstree-checked jstree-undetermined").addClass("jstree-unchecked");
2859
  if(rc) { coll.children(":checkbox").removeAttr("checked"); }
2860
  }
2861
+ else {
2862
  coll = obj.find("li").andSelf();
2863
  if(!coll.filter(".jstree-unchecked, .jstree-undetermined").length) { return false; }
2864
+ coll.removeClass("jstree-unchecked jstree-undetermined").addClass("jstree-checked");
2865
  if(rc) { coll.children(":checkbox").attr("checked","checked"); }
2866
  if(this.data.ui) { this.data.ui.last_selected = obj; }
2867
  this.data.checkbox.last_selected = obj;
2897
  return true;
2898
  },
2899
  check_node : function (obj) {
2900
+ if(this.change_state(obj, false)) {
2901
  obj = this._get_node(obj);
2902
  if(this._get_settings().checkbox.checked_parent_open) {
2903
  var t = this;
2904
  obj.parents(".jstree-closed").each(function () { t.open_node(this, false, true); });
2905
  }
2906
+ this.__callback({ "obj" : obj });
2907
  }
2908
  },
2909
  uncheck_node : function (obj) {
2910
  if(this.change_state(obj, true)) { this.__callback({ "obj" : this._get_node(obj) }); }
2911
  },
2912
  check_all : function () {
2913
+ var _this = this,
2914
  coll = this._get_settings().checkbox.two_state ? this.get_container_ul().find("li") : this.get_container_ul().children("li");
2915
  coll.each(function () {
2916
  _this.change_state(this, false);
2934
  obj = !obj || obj === -1 ? this.get_container() : this._get_node(obj);
2935
  return get_all || this._get_settings().checkbox.two_state ? obj.find(".jstree-checked") : obj.find("> ul > .jstree-checked, .jstree-undetermined > ul > .jstree-checked");
2936
  },
2937
+ get_unchecked : function (obj, get_all) {
2938
  obj = !obj || obj === -1 ? this.get_container() : this._get_node(obj);
2939
  return get_all || this._get_settings().checkbox.two_state ? obj.find(".jstree-unchecked") : obj.find("> ul > .jstree-unchecked, .jstree-undetermined > ul > .jstree-unchecked");
2940
  },
2952
  if(c === 0) { if(obj.hasClass("jstree-undetermined")) { this.change_state(obj, false); } }
2953
  else if(a === 0 && b === 0) { this.change_state(obj, true); }
2954
  else if(a === c) { this.change_state(obj, false); }
2955
+ else {
2956
  obj.parentsUntil(".jstree","li").andSelf().removeClass("jstree-checked jstree-unchecked").addClass("jstree-undetermined");
2957
  if(rc) { obj.parentsUntil(".jstree", "li").andSelf().children(":checkbox").removeAttr("checked"); }
2958
  }
2959
  },
2960
  reselect : function () {
2961
+ if(this.data.ui && this.data.checkbox.noui) {
2962
  var _this = this,
2963
  s = this.data.ui.to_select;
2964
  s = $.map($.makeArray(s), function (n) { return "#" + n.toString().replace(/^#/,"").replace(/\\\//g,"/").replace(/\//g,"\\\/").replace(/\\\./g,".").replace(/\./g,"\\.").replace(/\:/g,"\\:"); });
2966
  $.each(s, function (i, val) { _this.check_node(val); });
2967
  this.__callback();
2968
  }
2969
+ else {
2970
+ this.__call_old();
2971
  }
2972
  },
2973
  save_loaded : function () {
2986
  })(jQuery);
2987
  //*/
2988
 
2989
+ /*
2990
  * jsTree XML plugin
2991
  * The XML data store. Datastores are build by overriding the `load_node` and `_is_loaded` functions.
2992
  */
3013
  xsl = new DOMParser().parseFromString(xsl, "text/xml");
3014
  // alert(xml.transformNode());
3015
  // callback.call(null, new XMLSerializer().serializeToString(rs));
3016
+
3017
  }
3018
  if(typeof window.DOMParser !== "undefined" && typeof window.XMLHttpRequest !== "undefined" && typeof window.XSLTProcessor !== "undefined") {
3019
  processor = new XSLTProcessor();
3037
  return false;
3038
  };
3039
  var xsl = {
3040
+ 'nest' : '<' + '?xml version="1.0" encoding="utf-8" ?>' +
3041
+ '<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >' +
3042
+ '<xsl:output method="html" encoding="utf-8" omit-xml-declaration="yes" standalone="no" indent="no" media-type="text/html" />' +
3043
+ '<xsl:template match="/">' +
3044
+ ' <xsl:call-template name="nodes">' +
3045
+ ' <xsl:with-param name="node" select="/root" />' +
3046
+ ' </xsl:call-template>' +
3047
+ '</xsl:template>' +
3048
+ '<xsl:template name="nodes">' +
3049
+ ' <xsl:param name="node" />' +
3050
+ ' <ul>' +
3051
+ ' <xsl:for-each select="$node/item">' +
3052
+ ' <xsl:variable name="children" select="count(./item) &gt; 0" />' +
3053
+ ' <li>' +
3054
+ ' <xsl:attribute name="class">' +
3055
+ ' <xsl:if test="position() = last()">jstree-last </xsl:if>' +
3056
+ ' <xsl:choose>' +
3057
+ ' <xsl:when test="@state = \'open\'">jstree-open </xsl:when>' +
3058
+ ' <xsl:when test="$children or @hasChildren or @state = \'closed\'">jstree-closed </xsl:when>' +
3059
+ ' <xsl:otherwise>jstree-leaf </xsl:otherwise>' +
3060
+ ' </xsl:choose>' +
3061
+ ' <xsl:value-of select="@class" />' +
3062
+ ' </xsl:attribute>' +
3063
+ ' <xsl:for-each select="@*">' +
3064
+ ' <xsl:if test="name() != \'class\' and name() != \'state\' and name() != \'hasChildren\'">' +
3065
+ ' <xsl:attribute name="{name()}"><xsl:value-of select="." /></xsl:attribute>' +
3066
+ ' </xsl:if>' +
3067
+ ' </xsl:for-each>' +
3068
+ ' <ins class="jstree-icon"><xsl:text>&#xa0;</xsl:text></ins>' +
3069
+ ' <xsl:for-each select="content/name">' +
3070
+ ' <a>' +
3071
+ ' <xsl:attribute name="href">' +
3072
+ ' <xsl:choose>' +
3073
+ ' <xsl:when test="@href"><xsl:value-of select="@href" /></xsl:when>' +
3074
+ ' <xsl:otherwise>#</xsl:otherwise>' +
3075
+ ' </xsl:choose>' +
3076
+ ' </xsl:attribute>' +
3077
+ ' <xsl:attribute name="class"><xsl:value-of select="@lang" /> <xsl:value-of select="@class" /></xsl:attribute>' +
3078
+ ' <xsl:attribute name="style"><xsl:value-of select="@style" /></xsl:attribute>' +
3079
+ ' <xsl:for-each select="@*">' +
3080
+ ' <xsl:if test="name() != \'style\' and name() != \'class\' and name() != \'href\'">' +
3081
+ ' <xsl:attribute name="{name()}"><xsl:value-of select="." /></xsl:attribute>' +
3082
+ ' </xsl:if>' +
3083
+ ' </xsl:for-each>' +
3084
+ ' <ins>' +
3085
+ ' <xsl:attribute name="class">jstree-icon ' +
3086
+ ' <xsl:if test="string-length(attribute::icon) > 0 and not(contains(@icon,\'/\'))"><xsl:value-of select="@icon" /></xsl:if>' +
3087
+ ' </xsl:attribute>' +
3088
+ ' <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>' +
3089
+ ' <xsl:text>&#xa0;</xsl:text>' +
3090
+ ' </ins>' +
3091
+ ' <xsl:copy-of select="./child::node()" />' +
3092
+ ' </a>' +
3093
+ ' </xsl:for-each>' +
3094
+ ' <xsl:if test="$children or @hasChildren"><xsl:call-template name="nodes"><xsl:with-param name="node" select="current()" /></xsl:call-template></xsl:if>' +
3095
+ ' </li>' +
3096
+ ' </xsl:for-each>' +
3097
+ ' </ul>' +
3098
+ '</xsl:template>' +
3099
  '</xsl:stylesheet>',
3100
 
3101
+ 'flat' : '<' + '?xml version="1.0" encoding="utf-8" ?>' +
3102
+ '<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >' +
3103
+ '<xsl:output method="html" encoding="utf-8" omit-xml-declaration="yes" standalone="no" indent="no" media-type="text/xml" />' +
3104
+ '<xsl:template match="/">' +
3105
+ ' <ul>' +
3106
  ' <xsl:for-each select="//item[not(@parent_id) or @parent_id=0 or not(@parent_id = //item/@id)]">' + /* the last `or` may be removed */
3107
+ ' <xsl:call-template name="nodes">' +
3108
+ ' <xsl:with-param name="node" select="." />' +
3109
+ ' <xsl:with-param name="is_last" select="number(position() = last())" />' +
3110
+ ' </xsl:call-template>' +
3111
+ ' </xsl:for-each>' +
3112
+ ' </ul>' +
3113
+ '</xsl:template>' +
3114
+ '<xsl:template name="nodes">' +
3115
+ ' <xsl:param name="node" />' +
3116
+ ' <xsl:param name="is_last" />' +
3117
+ ' <xsl:variable name="children" select="count(//item[@parent_id=$node/attribute::id]) &gt; 0" />' +
3118
+ ' <li>' +
3119
+ ' <xsl:attribute name="class">' +
3120
+ ' <xsl:if test="$is_last = true()">jstree-last </xsl:if>' +
3121
+ ' <xsl:choose>' +
3122
+ ' <xsl:when test="@state = \'open\'">jstree-open </xsl:when>' +
3123
+ ' <xsl:when test="$children or @hasChildren or @state = \'closed\'">jstree-closed </xsl:when>' +
3124
+ ' <xsl:otherwise>jstree-leaf </xsl:otherwise>' +
3125
+ ' </xsl:choose>' +
3126
+ ' <xsl:value-of select="@class" />' +
3127
+ ' </xsl:attribute>' +
3128
+ ' <xsl:for-each select="@*">' +
3129
+ ' <xsl:if test="name() != \'parent_id\' and name() != \'hasChildren\' and name() != \'class\' and name() != \'state\'">' +
3130
+ ' <xsl:attribute name="{name()}"><xsl:value-of select="." /></xsl:attribute>' +
3131
+ ' </xsl:if>' +
3132
+ ' </xsl:for-each>' +
3133
+ ' <ins class="jstree-icon"><xsl:text>&#xa0;</xsl:text></ins>' +
3134
+ ' <xsl:for-each select="content/name">' +
3135
+ ' <a>' +
3136
+ ' <xsl:attribute name="href">' +
3137
+ ' <xsl:choose>' +
3138
+ ' <xsl:when test="@href"><xsl:value-of select="@href" /></xsl:when>' +
3139
+ ' <xsl:otherwise>#</xsl:otherwise>' +
3140
+ ' </xsl:choose>' +
3141
+ ' </xsl:attribute>' +
3142
+ ' <xsl:attribute name="class"><xsl:value-of select="@lang" /> <xsl:value-of select="@class" /></xsl:attribute>' +
3143
+ ' <xsl:attribute name="style"><xsl:value-of select="@style" /></xsl:attribute>' +
3144
+ ' <xsl:for-each select="@*">' +
3145
+ ' <xsl:if test="name() != \'style\' and name() != \'class\' and name() != \'href\'">' +
3146
+ ' <xsl:attribute name="{name()}"><xsl:value-of select="." /></xsl:attribute>' +
3147
+ ' </xsl:if>' +
3148
+ ' </xsl:for-each>' +
3149
+ ' <ins>' +
3150
+ ' <xsl:attribute name="class">jstree-icon ' +
3151
+ ' <xsl:if test="string-length(attribute::icon) > 0 and not(contains(@icon,\'/\'))"><xsl:value-of select="@icon" /></xsl:if>' +
3152
+ ' </xsl:attribute>' +
3153
+ ' <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>' +
3154
+ ' <xsl:text>&#xa0;</xsl:text>' +
3155
+ ' </ins>' +
3156
+ ' <xsl:copy-of select="./child::node()" />' +
3157
+ ' </a>' +
3158
+ ' </xsl:for-each>' +
3159
+ ' <xsl:if test="$children">' +
3160
+ ' <ul>' +
3161
+ ' <xsl:for-each select="//item[@parent_id=$node/attribute::id]">' +
3162
+ ' <xsl:call-template name="nodes">' +
3163
+ ' <xsl:with-param name="node" select="." />' +
3164
+ ' <xsl:with-param name="is_last" select="number(position() = last())" />' +
3165
+ ' </xsl:call-template>' +
3166
+ ' </xsl:for-each>' +
3167
+ ' </ul>' +
3168
+ ' </xsl:if>' +
3169
+ ' </li>' +
3170
+ '</xsl:template>' +
3171
  '</xsl:stylesheet>'
3172
  },
3173
  escape_xml = function(string) {
3180
  .replace(/'/g, '&apos;');
3181
  };
3182
  $.jstree.plugin("xml_data", {
3183
+ defaults : {
3184
  data : false,
3185
  ajax : false,
3186
  xsl : "flat",
3191
  },
3192
  _fn : {
3193
  load_node : function (obj, s_call, e_call) { var _this = this; this.load_node_xml(obj, function () { _this.__callback({ "obj" : _this._get_node(obj) }); s_call.call(this); }, e_call); },
3194
+ _is_loaded : function (obj) {
3195
  var s = this._get_settings().xml_data;
3196
  obj = this._get_node(obj);
3197
  return obj == -1 || !obj || (!s.ajax && !$.isFunction(s.data)) || obj.is(".jstree-open, .jstree-leaf") || obj.children("ul").children("li").size() > 0;
3221
  if(s_call) { s_call.call(this); }
3222
  }
3223
  else {
3224
+ if(obj && obj !== -1) {
3225
  obj.children("a.jstree-loading").removeClass("jstree-loading");
3226
  obj.removeData("jstree-is-loading");
3227
+ if(s.correct_state) {
3228
  this.correct_state(obj);
3229
+ if(s_call) { s_call.call(this); }
3230
  }
3231
  }
3232
  else {
3233
+ if(s.correct_state) {
3234
  this.get_container().children("ul").empty();
3235
+ if(s_call) { s_call.call(this); }
3236
  }
3237
  }
3238
  }
3252
  if(s_call) { s_call.call(this); }
3253
  }
3254
  }
3255
+ else {
3256
+ if(s.correct_state) {
3257
+ this.get_container().children("ul").empty();
3258
  if(s_call) { s_call.call(this); }
3259
  }
3260
  }
3263
  break;
3264
  case (!s.data && !!s.ajax) || (!!s.data && !!s.ajax && obj && obj !== -1):
3265
  error_func = function (x, t, e) {
3266
+ var ef = this.get_settings().xml_data.ajax.error;
3267
  if(ef) { ef.call(this, x, t, e); }
3268
  if(obj !== -1 && obj.length) {
3269
  obj.children("a.jstree-loading").removeClass("jstree-loading");
3277
  };
3278
  success_func = function (d, t, x) {
3279
  d = x.responseText;
3280
+ var sf = this.get_settings().xml_data.ajax.success;
3281
  if(sf) { d = sf.call(this,d,t,x) || d; }
3282
  if(d === "" || (d && d.toString && d.toString().replace(/^[\s\n]+$/,"") === "")) {
3283
  return error_func.call(this, x, t, "");
3293
  if(s_call) { s_call.call(this); }
3294
  }
3295
  else {
3296
+ if(obj && obj !== -1) {
3297
  obj.children("a.jstree-loading").removeClass("jstree-loading");
3298
  obj.removeData("jstree-is-loading");
3299
+ if(s.correct_state) {
3300
  this.correct_state(obj);
3301
+ if(s_call) { s_call.call(this); }
3302
  }
3303
  }
3304
  else {
3305
+ if(s.correct_state) {
3306
  this.get_container().children("ul").empty();
3307
+ if(s_call) { s_call.call(this); }
3308
  }
3309
  }
3310
  }
3326
  $.vakata.xslt(xml, xsl[s.xsl], callback);
3327
  },
3328
  get_xml : function (tp, obj, li_attr, a_attr, is_callback) {
3329
+ var result = "",
3330
+ s = this._get_settings(),
3331
  _this = this,
3332
  tmp1, tmp2, li, a, lang;
3333
  if(!tp) { tp = "flat"; }
3334
  if(!is_callback) { is_callback = 0; }
3335
  obj = this._get_node(obj);
3336
  if(!obj || obj === -1) { obj = this.get_container().find("> ul > li"); }
3337
+ li_attr = Array.isArray(li_attr) ? li_attr : [ "id", "class" ];
3338
  if(!is_callback && this.data.types && $.inArray(s.types.type_attr, li_attr) === -1) { li_attr.push(s.types.type_attr); }
3339
 
3340
+ a_attr = Array.isArray(a_attr) ? a_attr : [ ];
3341
 
3342
+ if(!is_callback) {
3343
+ if(s.xml_data.get_include_preamble) {
3344
+ result += '<' + '?xml version="1.0" encoding="UTF-8"?' + '>';
3345
  }
3346
+ result += "<root>";
3347
  }
3348
  obj.each(function () {
3349
  result += "<item";
3350
  li = $(this);
3351
+ $.each(li_attr, function (i, v) {
3352
  var t = li.attr(v);
3353
  if(!s.xml_data.get_skip_empty || typeof t !== "undefined") {
3354
+ result += " " + v + "=\"" + escape_xml((" " + (t || "")).replace(/ jstree[^ ]*/ig,'').replace(/\s+$/ig," ").replace(/^ /,"").replace(/ $/,"")) + "\"";
3355
  }
3356
  });
3357
  if(li.hasClass("jstree-open")) { result += " state=\"open\""; }
3369
  if(tmp1.hasClass(z)) { result += " lang=\"" + escape_xml(z) + "\""; lang = z; return false; }
3370
  });
3371
  }
3372
+ if(a_attr.length) {
3373
  $.each(a_attr, function (k, z) {
3374
  var t = tmp1.attr(z);
3375
  if(!s.xml_data.get_skip_empty || typeof t !== "undefined") {
3410
  * DOES NOT WORK WITH JSON PROGRESSIVE RENDER
3411
  */
3412
  (function ($) {
3413
+ $.expr.pseudos.jstree_contains = function(a,i,m){
3414
  return (a.textContent || a.innerText || "").toLowerCase().indexOf(m[3].toLowerCase())>=0;
3415
  };
3416
+ $.expr.pseudos.jstree_title_contains = function(a,i,m) {
3417
  return (a.getAttribute("title") || "").toLowerCase().indexOf(m[3].toLowerCase())>=0;
3418
  };
3419
  $.jstree.plugin("search", {
3422
  this.data.search.result = $();
3423
  if(this._get_settings().search.show_only_matches) {
3424
  this.get_container()
3425
+ .on("search.jstree", function (e, data) {
3426
  $(this).children("ul").find("li").hide().removeClass("jstree-last");
3427
  data.rslt.nodes.parentsUntil(".jstree").andSelf().show()
3428
  .filter("ul").each(function () { $(this).children("li:visible").eq(-1).addClass("jstree-last"); });
3429
  })
3430
+ .on("clear_search.jstree", function () {
3431
  $(this).children("ul").find("li").css("display","").end().end().jstree("clean_node", -1);
3432
  });
3433
  }
3440
  _fn : {
3441
  search : function (str, skip_async) {
3442
  if($.trim(str) === "") { this.clear_search(); return; }
3443
+ var s = this.get_settings().search,
3444
  t = this,
3445
  error_func = function () { },
3446
  success_func = function () { };
3450
  this.search.supress_callback = true;
3451
  error_func = function () { };
3452
  success_func = function (d, t, x) {
3453
+ var sf = this.get_settings().search.ajax.success;
3454
  if(sf) { d = sf.call(this,d,t,x) || d; }
3455
  this.data.search.to_open = d;
3456
  this._search_open();
3490
  });
3491
  if(current.length) {
3492
  this.data.search.to_open = remaining;
3493
+ $.each(current, function (i, val) {
3494
+ _this.open_node(val, function () { _this._search_open(true); });
3495
  });
3496
  done = false;
3497
  }
3503
  })(jQuery);
3504
  //*/
3505
 
3506
+ /*
3507
  * jsTree contextmenu plugin
3508
  */
3509
  (function ($) {
3536
 
3537
  h = $.vakata.context.cnt.height();
3538
  w = $.vakata.context.cnt.width();
3539
+ if(x + w > $(document).width()) {
3540
+ x = $(document).width() - (w + 5);
3541
+ $.vakata.context.cnt.find("li > ul").addClass("right");
3542
  }
3543
+ if(y + h > $(document).height()) {
3544
+ y = y - (h + t[0].offsetHeight);
3545
+ $.vakata.context.cnt.find("li > ul").addClass("bottom");
3546
  }
3547
 
3548
  $.vakata.context.cnt
3549
  .css({ "left" : x, "top" : y })
3550
  .find("li:has(ul)")
3551
+ .on("mouseenter", function (e) {
3552
  var w = $(document).width(),
3553
  h = $(document).height(),
3554
+ ul = $(this).children("ul").show();
3555
  if(w !== $(document).width()) { ul.toggleClass("right"); }
3556
  if(h !== $(document).height()) { ul.toggleClass("bottom"); }
3557
  })
3558
+ .on("mouseleave", function (e) {
3559
+ $(this).children("ul").hide();
3560
  })
3561
  .end()
3562
  .css({ "visibility" : "visible" })
3615
  }
3616
  };
3617
  $(function () {
3618
+ var css_string = '' +
3619
+ '#vakata-contextmenu { display:block; visibility:hidden; left:0; top:-200px; position:absolute; margin:0; padding:0; min-width:180px; background:#ebebeb; border:1px solid silver; z-index:10000; *width:180px; } ' +
3620
+ '#vakata-contextmenu ul { min-width:180px; *width:180px; } ' +
3621
+ '#vakata-contextmenu ul, #vakata-contextmenu li { margin:0; padding:0; list-style-type:none; display:block; } ' +
3622
+ '#vakata-contextmenu li { line-height:20px; min-height:20px; position:relative; padding:0px; } ' +
3623
+ '#vakata-contextmenu li a { padding:1px 6px; line-height:17px; display:block; text-decoration:none; margin:1px 1px 0 1px; } ' +
3624
+ '#vakata-contextmenu li ins { float:left; width:16px; height:16px; text-decoration:none; margin-right:2px; } ' +
3625
+ '#vakata-contextmenu li a:hover, #vakata-contextmenu li.vakata-hover > a { background:gray; color:white; } ' +
3626
+ '#vakata-contextmenu li ul { display:none; position:absolute; top:-2px; left:100%; background:#ebebeb; border:1px solid gray; } ' +
3627
+ '#vakata-contextmenu .right { right:100%; left:auto; } ' +
3628
+ '#vakata-contextmenu .bottom { bottom:-1px; top:auto; } ' +
3629
  '#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; } ';
3630
  $.vakata.css.add_sheet({ str : css_string, title : "vakata" });
3631
  $.vakata.context.cnt
3632
+ .on("a","click", function (e) { e.preventDefault(); })
3633
+ .on("a","mouseup", function (e) {
3634
  if(!$(this).parent().hasClass("jstree-contextmenu-disabled") && $.vakata.context.exec($(this).attr("rel"))) {
3635
  $.vakata.context.hide();
3636
  }
3637
  else { $(this).blur(); }
3638
  })
3639
+ .on("a","mouseover", function () {
3640
  $.vakata.context.cnt.find(".vakata-hover").removeClass("vakata-hover");
3641
  })
3642
  .appendTo("body");
3643
+ $(document).on("mousedown", function (e) { if($.vakata.context.vis && !$.contains($.vakata.context.cnt[0], e.target)) { $.vakata.context.hide(); } });
3644
  // modified by pär to fix problems with wordpress hotkeys
3645
  if(false && typeof $.hotkeys !== "undefined") {
3646
  $(document)
3647
+ .on("keydown", "up", function (e) {
3648
+ if($.vakata.context.vis) {
3649
  var o = $.vakata.context.cnt.find("ul:visible").last().children(".vakata-hover").removeClass("vakata-hover").prevAll("li:not(.vakata-separator)").first();
3650
  if(!o.length) { o = $.vakata.context.cnt.find("ul:visible").last().children("li:not(.vakata-separator)").last(); }
3651
  o.addClass("vakata-hover");
3652
+ e.stopImmediatePropagation();
3653
  e.preventDefault();
3654
+ }
3655
  })
3656
+ .on("keydown", "down", function (e) {
3657
+ if($.vakata.context.vis) {
3658
  var o = $.vakata.context.cnt.find("ul:visible").last().children(".vakata-hover").removeClass("vakata-hover").nextAll("li:not(.vakata-separator)").first();
3659
  if(!o.length) { o = $.vakata.context.cnt.find("ul:visible").last().children("li:not(.vakata-separator)").first(); }
3660
  o.addClass("vakata-hover");
3661
+ e.stopImmediatePropagation();
3662
  e.preventDefault();
3663
+ }
3664
  })
3665
+ .on("keydown", "right", function (e) {
3666
+ if($.vakata.context.vis) {
3667
  $.vakata.context.cnt.find(".vakata-hover").children("ul").show().children("li:not(.vakata-separator)").removeClass("vakata-hover").first().addClass("vakata-hover");
3668
+ e.stopImmediatePropagation();
3669
  e.preventDefault();
3670
+ }
3671
  })
3672
+ .on("keydown", "left", function (e) {
3673
+ if($.vakata.context.vis) {
3674
  $.vakata.context.cnt.find(".vakata-hover").children("ul").hide().children(".vakata-separator").removeClass("vakata-hover");
3675
+ e.stopImmediatePropagation();
3676
  e.preventDefault();
3677
+ }
3678
  })
3679
+ .on("keydown", "esc", function (e) {
3680
+ $.vakata.context.hide();
3681
  e.preventDefault();
3682
  })
3683
+ .on("keydown", "space", function (e) {
3684
  $.vakata.context.cnt.find(".vakata-hover").last().children("a").click();
3685
  e.preventDefault();
3686
  });
3690
  $.jstree.plugin("contextmenu", {
3691
  __init : function () {
3692
  this.get_container()
3693
+ .on("a", "contextmenu.jstree", $.proxy(function (e) {
3694
  e.preventDefault();
3695
  if(!$(e.currentTarget).hasClass("jstree-loading")) {
3696
  this.show_contextmenu(e.currentTarget, e.pageX, e.pageY);
3697
  }
3698
  }, this))
3699
+ .on("a", "click.jstree", $.proxy(function (e) {
3700
  if(this.data.contextmenu) {
3701
  $.vakata.context.hide();
3702
  }
3703
  }, this))
3704
+ .on("destroy.jstree", $.proxy(function () {
3705
  // TODO: move this to descruct method
3706
  if(this.data.contextmenu) {
3707
  $.vakata.context.hide();
3708
  }
3709
  }, this));
3710
+ $(document).on("context_hide.vakata", $.proxy(function () { this.data.contextmenu = false; }, this));
3711
  },
3712
+ defaults : {
3713
  select_node : false, // requires UI plugin
3714
  show_at_node : true,
3715
  items : { // Could be a function that should return an object like this one
3738
  "separator_after" : false,
3739
  "label" : "Edit",
3740
  "action" : false,
3741
+ "submenu" : {
3742
  "cut" : {
3743
  "separator_before" : false,
3744
  "separator_after" : false,
3790
  })(jQuery);
3791
  //*/
3792
 
3793
+ /*
3794
  * jsTree types plugin
3795
  * Adds support types of nodes
3796
  * You can set an attribute on each li node, that represents its type.
3802
  var s = this._get_settings().types;
3803
  this.data.types.attach_to = [];
3804
  this.get_container()
3805
+ .on("init.jstree", $.proxy(function () {
3806
+ var types = s.types,
3807
+ attr = s.type_attr,
3808
+ icons_css = "",
3809
  _this = this;
3810
 
3811
  $.each(types, function (i, tp) {
3812
+ $.each(tp, function (k, v) {
3813
  if(!/^(max_depth|max_children|icon|valid_children)$/.test(k)) { _this.data.types.attach_to.push(k); }
3814
  });
3815
  if(!tp.icon) { return true; }
3824
  });
3825
  if(icons_css !== "") { $.vakata.css.add_sheet({ 'str' : icons_css, title : "jstree-types" }); }
3826
  }, this))
3827
+ .on("before.jstree", $.proxy(function (e, data) {
3828
+ var s, t,
3829
+ o = this._get_settings().types.use_data ? this._get_node(data.args[0]) : false,
3830
  d = o && o !== -1 && o.length ? o.data("jstree") : false;
3831
  if(d && d.types && d.types[data.func] === false) { e.stopImmediatePropagation(); return false; }
3832
  if($.inArray(data.func, this.data.types.attach_to) !== -1) {
3834
  s = this._get_settings().types.types;
3835
  t = this._get_type(data.args[0]);
3836
  if(
3837
+ (
3838
+ (s[t] && typeof s[t][data.func] !== "undefined") ||
3839
+ (s["default"] && typeof s["default"][data.func] !== "undefined")
3840
  ) && this._check(data.func, data.args[0]) === false
3841
  ) {
3842
  e.stopImmediatePropagation();
3846
  }, this));
3847
  if(is_ie6) {
3848
  this.get_container()
3849
+ .on("load_node.jstree set_type.jstree", $.proxy(function (e, data) {
3850
  var r = data && data.rslt && data.rslt.obj && data.rslt.obj !== -1 ? this._get_node(data.rslt.obj).parent() : this.get_container_ul(),
3851
  c = false,
3852
  s = this._get_settings().types;
3869
  valid_children : "all",
3870
 
3871
  // whether to use $.data
3872
+ use_data : false,
3873
  // where is the type stores (the rel attribute of the LI element)
3874
  type_attr : "rel",
3875
  // a list of types
3904
  _check : function (rule, obj, opts) {
3905
  obj = this._get_node(obj);
3906
  var v = false, t = this._get_type(obj), d = 0, _this = this, s = this._get_settings().types, data = false;
3907
+ if(obj === -1) {
3908
  if(!!s[rule]) { v = s[rule]; }
3909
  else { return; }
3910
  }
3941
  vc = m.rt._check("valid_children", m.cr),
3942
  ch = 0, d = 1, t;
3943
 
3944
+ if(vc === "none") { return false; }
3945
+ if(Array.isArray(vc) && m.ot && m.ot._get_type) {
3946
  m.o.each(function () {
3947
  if($.inArray(m.ot._get_type(this), vc) === -1) { d = false; return false; }
3948
  });
3978
  ch;
3979
  if(typeof js === "string") { js = { data : js }; }
3980
  if(!js) { js = {}; }
3981
+ if(vc === "none") { return false; }
3982
+ if(Array.isArray(vc)) {
3983
+ if(!js.attr || !js.attr[s.type_attr]) {
3984
  if(!js.attr) { js.attr = {}; }
3985
+ js.attr[s.type_attr] = vc[0];
3986
  }
3987
  else {
3988
  if($.inArray(js.attr[s.type_attr], vc) === -1) { return false; }
4001
  })(jQuery);
4002
  //*/
4003
 
4004
+ /*
4005
  * jsTree HTML plugin
4006
  * The HTML data store. Datastores are build by replacing the `load_node` and `_is_loaded` functions.
4007
  */
4008
  (function ($) {
4009
  $.jstree.plugin("html_data", {
4010
+ __init : function () {
4011
  // this used to use html() and clean the whitespace, but this way any attached data was lost
4012
  this.data.html_data.original_container_html = this.get_container().find(" > ul > li").clone(true);
4013
  // remove white space from LI node - otherwise nodes appear a bit to the right
4014
  this.data.html_data.original_container_html.find("li").andSelf().contents().filter(function() { return this.nodeType == 3; }).remove();
4015
  },
4016
+ defaults : {
4017
  data : false,
4018
  ajax : false,
4019
  correct_state : true
4020
  },
4021
  _fn : {
4022
  load_node : function (obj, s_call, e_call) { var _this = this; this.load_node_html(obj, function () { _this.__callback({ "obj" : _this._get_node(obj) }); s_call.call(this); }, e_call); },
4023
+ _is_loaded : function (obj) {
4024
+ obj = this._get_node(obj);
4025
  return obj == -1 || !obj || (!this._get_settings().html_data.ajax && !$.isFunction(this._get_settings().html_data.data)) || obj.is(".jstree-open, .jstree-leaf") || obj.children("ul").children("li").size() > 0;
4026
  },
4027
  load_node_html : function (obj, s_call, e_call) {
4049
  if(obj && obj !== -1) {
4050
  obj.children("a.jstree-loading").removeClass("jstree-loading");
4051
  obj.removeData("jstree-is-loading");
4052
+ if(s.correct_state) {
4053
  this.correct_state(obj);
4054
+ if(s_call) { s_call.call(this); }
4055
  }
4056
  }
4057
  else {
4058
+ if(s.correct_state) {
4059
  this.get_container().children("ul").empty();
4060
+ if(s_call) { s_call.call(this); }
4061
  }
4062
  }
4063
  }
4089
  case (!s.data && !!s.ajax) || (!!s.data && !!s.ajax && obj && obj !== -1):
4090
  obj = this._get_node(obj);
4091
  error_func = function (x, t, e) {
4092
+ var ef = this.get_settings().html_data.ajax.error;
4093
  if(ef) { ef.call(this, x, t, e); }
4094
  if(obj != -1 && obj.length) {
4095
  obj.children("a.jstree-loading").removeClass("jstree-loading");
4102
  if(e_call) { e_call.call(this); }
4103
  };
4104
  success_func = function (d, t, x) {
4105
+ var sf = this.get_settings().html_data.ajax.success;
4106
  if(sf) { d = sf.call(this,d,t,x) || d; }
4107
  if(d === "" || (d && d.toString && d.toString().replace(/^[\s\n]+$/,"") === "")) {
4108
  return error_func.call(this, x, t, "");
4119
  if(obj && obj !== -1) {
4120
  obj.children("a.jstree-loading").removeClass("jstree-loading");
4121
  obj.removeData("jstree-is-loading");
4122
+ if(s.correct_state) {
4123
  this.correct_state(obj);
4124
+ if(s_call) { s_call.call(this); }
4125
  }
4126
  }
4127
  else {
4128
+ if(s.correct_state) {
4129
  this.get_container().children("ul").empty();
4130
+ if(s_call) { s_call.call(this); }
4131
  }
4132
  }
4133
  }
4149
  })(jQuery);
4150
  //*/
4151
 
4152
+ /*
4153
  * jsTree themeroller plugin
4154
  * Adds support for jQuery UI themes. Include this at the end of your plugins list, also make sure "themes" is not included.
4155
  */
4160
  this.get_container()
4161
  .addClass("ui-widget-content")
4162
  .addClass("jstree-themeroller")
4163
+ .on("a","mouseenter.jstree", function (e) {
4164
  if(!$(e.currentTarget).hasClass("jstree-loading")) {
4165
  $(this).addClass(s.item_h);
4166
  }
4167
  })
4168
+ .on("a","mouseleave.jstree", function () {
4169
  $(this).removeClass(s.item_h);
4170
  })
4171
+ .on("init.jstree", $.proxy(function (e, data) {
4172
  data.inst.get_container().find("> ul > li > .jstree-loading > ins").addClass("ui-icon-refresh");
4173
  this._themeroller(data.inst.get_container().find("> ul > li"));
4174
  }, this))
4175
+ .on("open_node.jstree create_node.jstree", $.proxy(function (e, data) {
4176
  this._themeroller(data.rslt.obj);
4177
  }, this))
4178
+ .on("loaded.jstree refresh.jstree", $.proxy(function (e) {
4179
  this._themeroller();
4180
  }, this))
4181
+ .on("close_node.jstree", $.proxy(function (e, data) {
4182
  this._themeroller(data.rslt.obj);
4183
  }, this))
4184
+ .on("delete_node.jstree", $.proxy(function (e, data) {
4185
  this._themeroller(data.rslt.parent);
4186
  }, this))
4187
+ .on("correct_state.jstree", $.proxy(function (e, data) {
4188
  data.rslt.obj
4189
  .children("ins.jstree-icon").removeClass(s.opened + " " + s.closed + " ui-icon").end()
4190
  .find("> a > ins.ui-icon")
4191
+ .filter(function() {
4192
  return this.className.toString()
4193
  .replace(s.item_clsd,"").replace(s.item_open,"").replace(s.item_leaf,"")
4194
+ .indexOf("ui-icon-") === -1;
4195
  }).removeClass(s.item_open + " " + s.item_clsd).addClass(s.item_leaf || "jstree-no-icon");
4196
  }, this))
4197
+ .on("select_node.jstree", $.proxy(function (e, data) {
4198
  data.rslt.obj.children("a").addClass(s.item_a);
4199
  }, this))
4200
+ .on("deselect_node.jstree deselect_all.jstree", $.proxy(function (e, data) {
4201
  this.get_container()
4202
  .find("a." + s.item_a).removeClass(s.item_a).end()
4203
  .find("a.jstree-clicked").addClass(s.item_a);
4204
  }, this))
4205
+ .on("dehover_node.jstree", $.proxy(function (e, data) {
4206
  data.rslt.obj.children("a").removeClass(s.item_h);
4207
  }, this))
4208
+ .on("hover_node.jstree", $.proxy(function (e, data) {
4209
  this.get_container()
4210
  .find("a." + s.item_h).not(data.rslt.obj).removeClass(s.item_h);
4211
  data.rslt.obj.children("a").addClass(s.item_h);
4212
  }, this))
4213
+ .on("move_node.jstree", $.proxy(function (e, data) {
4214
  this._themeroller(data.rslt.o);
4215
  this._themeroller(data.rslt.op);
4216
  }, this));
4235
  .children("ins.jstree-icon").removeClass(s.opened).addClass("ui-icon " + s.closed).end()
4236
  .children("a").addClass(s.item)
4237
  .children("ins.jstree-icon").addClass("ui-icon")
4238
+ .filter(function() {
4239
  return this.className.toString()
4240
  .replace(s.item_clsd,"").replace(s.item_open,"").replace(s.item_leaf,"")
4241
+ .indexOf("ui-icon-") === -1;
4242
  }).removeClass(s.item_leaf + " " + s.item_open).addClass(s.item_clsd || "jstree-no-icon")
4243
  .end()
4244
  .end()
4248
  .children("ins.jstree-icon").removeClass(s.closed).addClass("ui-icon " + s.opened).end()
4249
  .children("a").addClass(s.item)
4250
  .children("ins.jstree-icon").addClass("ui-icon")
4251
+ .filter(function() {
4252
  return this.className.toString()
4253
  .replace(s.item_clsd,"").replace(s.item_open,"").replace(s.item_leaf,"")
4254
+ .indexOf("ui-icon-") === -1;
4255
  }).removeClass(s.item_leaf + " " + s.item_clsd).addClass(s.item_open || "jstree-no-icon")
4256
  .end()
4257
  .end()
4261
  .children("ins.jstree-icon").removeClass(s.closed + " ui-icon " + s.opened).end()
4262
  .children("a").addClass(s.item)
4263
  .children("ins.jstree-icon").addClass("ui-icon")
4264
+ .filter(function() {
4265
  return this.className.toString()
4266
  .replace(s.item_clsd,"").replace(s.item_open,"").replace(s.item_leaf,"")
4267
+ .indexOf("ui-icon-") === -1;
4268
  }).removeClass(s.item_clsd + " " + s.item_open).addClass(s.item_leaf || "jstree-no-icon");
4269
  }
4270
  },
4280
  }
4281
  });
4282
  $(function() {
4283
+ var css_string = '' +
4284
+ '.jstree-themeroller .ui-icon { overflow:visible; } ' +
4285
+ '.jstree-themeroller a { padding:0 2px; } ' +
4286
  '.jstree-themeroller .jstree-no-icon { display:none; }';
4287
  $.vakata.css.add_sheet({ str : css_string, title : "jstree" });
4288
  });
4289
  })(jQuery);
4290
  //*/
4291
 
4292
+ /*
4293
  * jsTree unique plugin
4294
  * Forces different names amongst siblings (still a bit experimental)
4295
  * NOTE: does not check language versions (it will not be possible to have nodes with the same title, even in different languages)
4298
  $.jstree.plugin("unique", {
4299
  __init : function () {
4300
  this.get_container()
4301
+ .on("before.jstree", $.proxy(function (e, data) {
4302
  var nms = [], res = true, p, t;
4303
  if(data.func == "move_node") {
4304
  // obj, ref, position, is_copy, is_prepared, skip_check
4337
  }
4338
  }, this));
4339
  },
4340
+ defaults : {
4341
  error_callback : $.noop
4342
  },
4343
+ _fn : {
4344
  _check_unique : function (nms, p, func) {
4345
  var cnms = [];
4346
  p.children("a").each(function () { cnms.push($(this).text().replace(/^\s+/g,"")); });
4378
  this.data.wholerow.html = false;
4379
  this.data.wholerow.to = false;
4380
  this.get_container()
4381
+ .on("init.jstree", $.proxy(function (e, data) {
4382
  this._get_settings().core.animation = 0;
4383
  }, this))
4384
+ .on("open_node.jstree create_node.jstree clean_node.jstree loaded.jstree", $.proxy(function (e, data) {
4385
  this._prepare_wholerow_span( data && data.rslt && data.rslt.obj ? data.rslt.obj : -1 );
4386
  }, this))
4387
+ .on("search.jstree clear_search.jstree reopen.jstree after_open.jstree after_close.jstree create_node.jstree delete_node.jstree clean_node.jstree", $.proxy(function (e, data) {
4388
  if(this.data.to) { clearTimeout(this.data.to); }
4389
  this.data.to = setTimeout( (function (t, o) { return function() { t._prepare_wholerow_ul(o); }; })(this, data && data.rslt && data.rslt.obj ? data.rslt.obj : -1), 0);
4390
  }, this))
4391
+ .on("deselect_all.jstree", $.proxy(function (e, data) {
4392
  this.get_container().find(" > .jstree-wholerow .jstree-clicked").removeClass("jstree-clicked " + (this.data.themeroller ? this._get_settings().themeroller.item_a : "" ));
4393
  }, this))
4394
+ .on("select_node.jstree deselect_node.jstree ", $.proxy(function (e, data) {
4395
+ data.rslt.obj.each(function () {
4396
  var ref = data.inst.get_container().find(" > .jstree-wholerow li:visible:eq(" + ( parseInt((($(this).offset().top - data.inst.get_container().offset().top + data.inst.get_container()[0].scrollTop) / data.inst.data.core.li_height),10)) + ")");
4397
  // ref.children("a")[e.type === "select_node" ? "addClass" : "removeClass"]("jstree-clicked");
4398
  ref.children("a").attr("class",data.rslt.obj.children("a").attr("class"));
4399
  });
4400
  }, this))
4401
+ .on("hover_node.jstree dehover_node.jstree", $.proxy(function (e, data) {
4402
  this.get_container().find(" > .jstree-wholerow .jstree-hovered").removeClass("jstree-hovered " + (this.data.themeroller ? this._get_settings().themeroller.item_h : "" ));
4403
  if(e.type === "hover_node") {
4404
  var ref = this.get_container().find(" > .jstree-wholerow li:visible:eq(" + ( parseInt(((data.rslt.obj.offset().top - this.get_container().offset().top + this.get_container()[0].scrollTop) / this.data.core.li_height),10)) + ")");
4406
  ref.children("a").attr("class",data.rslt.obj.children(".jstree-hovered").attr("class"));
4407
  }
4408
  }, this))
4409
+ .on(".jstree-wholerow-span, ins.jstree-icon, li", "click.jstree", function (e) {
4410
  var n = $(e.currentTarget);
4411
  if(e.target.tagName === "A" || (e.target.tagName === "INS" && n.closest("li").is(".jstree-open, .jstree-closed"))) { return; }
4412
  n.closest("li").children("a:visible:eq(0)").click();
4413
  e.stopImmediatePropagation();
4414
  })
4415
+ .on("li", "mouseover.jstree", $.proxy(function (e) {
4416
  e.stopImmediatePropagation();
4417
  if($(e.currentTarget).children(".jstree-hovered, .jstree-clicked").length) { return false; }
4418
  this.hover_node(e.currentTarget);
4419
  return false;
4420
  }, this))
4421
+ .on("li", "mouseleave.jstree", $.proxy(function (e) {
4422
  if($(e.currentTarget).children("a").hasClass("jstree-hovered").length) { return; }
4423
  this.dehover_node(e.currentTarget);
4424
  }, this));
4462
  }
4463
  });
4464
  $(function() {
4465
+ var css_string = '' +
4466
+ '.jstree .jstree-wholerow-real { position:relative; z-index:1; } ' +
4467
+ '.jstree .jstree-wholerow-real li { cursor:pointer; } ' +
4468
+ '.jstree .jstree-wholerow-real a { border-left-color:transparent !important; border-right-color:transparent !important; } ' +
4469
+ '.jstree .jstree-wholerow { position:relative; z-index:0; height:0; } ' +
4470
+ '.jstree .jstree-wholerow ul, .jstree .jstree-wholerow li { width:100%; } ' +
4471
+ '.jstree .jstree-wholerow, .jstree .jstree-wholerow ul, .jstree .jstree-wholerow li, .jstree .jstree-wholerow a { margin:0 !important; padding:0 !important; } ' +
4472
+ '.jstree .jstree-wholerow, .jstree .jstree-wholerow ul, .jstree .jstree-wholerow li { background:transparent !important; }' +
4473
+ '.jstree .jstree-wholerow ins, .jstree .jstree-wholerow span, .jstree .jstree-wholerow input { display:none !important; }' +
4474
+ '.jstree .jstree-wholerow a, .jstree .jstree-wholerow a:hover { text-indent:-9999px; !important; width:100%; padding:0 !important; border-right-width:0px !important; border-left-width:0px !important; } ' +
4475
  '.jstree .jstree-wholerow-span { position:absolute; left:0; margin:0px; padding:0; height:18px; border-width:0; padding:0; z-index:0; }';
4476
  if(is_ff2) {
4477
+ css_string += '' +
4478
+ '.jstree .jstree-wholerow a { display:block; height:18px; margin:0; padding:0; border:0; } ' +
4479
  '.jstree .jstree-wholerow-real a { border-color:transparent !important; } ';
4480
  }
4481
  if(is_ie7 || is_ie6) {
4482
+ css_string += '' +
4483
+ '.jstree .jstree-wholerow, .jstree .jstree-wholerow li, .jstree .jstree-wholerow ul, .jstree .jstree-wholerow a { margin:0; padding:0; line-height:18px; } ' +
4484
  '.jstree .jstree-wholerow a { display:block; height:18px; line-height:18px; overflow:hidden; } ';
4485
  }
4486
  $.vakata.css.add_sheet({ str : css_string, title : "jstree" });
4526
  },
4527
  _fn : {
4528
  model_done : function (data, callback) {
4529
+ var ret = [],
4530
  s = this._get_settings(),
4531
  _this = this;
4532
 
4533
+ if(!Array.isArray(data)) { data = [data]; }
4534
  $.each(data, function (i, nd) {
4535
  var r = nd.getProps() || {};
4536
  r.attr = nd.getAttr() || {};
4537
  if(nd.getChildrenCount()) { r.state = "closed"; }
4538
  r.data = nd.getName();
4539
+ if(!Array.isArray(r.data)) { r.data = [r.data]; }
4540
  if(_this.data.types && $.isFunction(nd.getType)) {
4541
  r.attr[s.types.type_attr] = nd.getType();
4542
  }