CMS Tree Page View - Version 0.7.14

Version Description

  • Added links to PayPal and Flattr, so users who like the plugin can donate.
Download this release

Release Info

Developer eskapism
Plugin Icon wp plugin CMS Tree Page View
Version 0.7.14
Comparing to
See all releases

Code changes from version 0.7.12 to 0.7.14

Files changed (5) hide show
  1. functions.php +43 -4
  2. index.php +3 -3
  3. readme.txt +17 -11
  4. scripts/jquery.jstree.js +337 -111
  5. styles/styles.css +18 -2
functions.php CHANGED
@@ -118,7 +118,7 @@ function cms_tpv_wp_dashboard_setup() {
118
  * Output on dashboard
119
  */
120
  function cms_tpv_dashboard($post_type = "") {
121
- cms_tpv_show_annoying_box();
122
  cms_tpv_print_common_tree_stuff($post_type);
123
  }
124
 
@@ -170,10 +170,10 @@ foreach ($posts as $one_post) {
170
  // */
171
 
172
  ?>
173
-
174
  <div class="wrap">
 
175
  <h2><?php echo CMS_TPV_NAME ?> <?php _e("settings", 'cms-tree-page-view') ?></h2>
176
-
177
  <form method="post" action="options.php">
178
  <?php wp_nonce_field('update-options'); ?>
179
 
@@ -425,10 +425,49 @@ function cms_tpv_pages_page() {
425
  <div class="wrap">
426
  <h2><?php echo ($post_type_object->labels->name); ?> Tree View</h2>
427
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
428
  <?php
429
- cms_tpv_show_annoying_box();
430
  cms_tpv_print_common_tree_stuff($post_type);
431
  ?>
 
432
  </div>
433
  <?php
434
  }
118
  * Output on dashboard
119
  */
120
  function cms_tpv_dashboard($post_type = "") {
121
+ // cms_tpv_show_annoying_box();
122
  cms_tpv_print_common_tree_stuff($post_type);
123
  }
124
 
170
  // */
171
 
172
  ?>
 
173
  <div class="wrap">
174
+
175
  <h2><?php echo CMS_TPV_NAME ?> <?php _e("settings", 'cms-tree-page-view') ?></h2>
176
+
177
  <form method="post" action="options.php">
178
  <?php wp_nonce_field('update-options'); ?>
179
 
425
  <div class="wrap">
426
  <h2><?php echo ($post_type_object->labels->name); ?> Tree View</h2>
427
 
428
+ <div class="bonny-plugins-inner-sidebar">
429
+ <h3>Support the author</h3>
430
+ <p>
431
+ If you like this plugin you are welcome to support the author by donating:
432
+ </p>
433
+ <form action="https://www.paypal.com/cgi-bin/webscr" method="post" style="text-align: center">
434
+ <input type="hidden" name="cmd" value="_s-xclick">
435
+ <input type="hidden" name="encrypted" value="-----BEGIN PKCS7-----MIIHXwYJKoZIhvcNAQcEoIIHUDCCB0wCAQExggEwMIIBLAIBADCBlDCBjjELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtQYXlQYWwgSW5jLjETMBEGA1UECxQKbGl2ZV9jZXJ0czERMA8GA1UEAxQIbGl2ZV9hcGkxHDAaBgkqhkiG9w0BCQEWDXJlQHBheXBhbC5jb20CAQAwDQYJKoZIhvcNAQEBBQAEgYArzkksMbzVWCE3kMsAGZ6xe4p6CQcaIaH3w9JF5RS6Z8PIelZw26PHvfrQUVAUCL3IecfDVU0hjDCDfvmQe16lNZSVvy57uwk20ryOTf5IJ7Ujulw1G0T0Fpc7M9Mb0FRWblgnbETeEREzRZiGZBPfI+cn9rghM1Sb3xcYGWFfujELMAkGBSsOAwIaBQAwgdwGCSqGSIb3DQEHATAUBggqhkiG9w0DBwQIZb6E5mM+R7iAgbgoPH19h/wvJIJR8lPTFEg2qb4bpstEjDo5rgjbdWEBbVp1dtFXdDCf4Nbivm5yvk2Ugf5sDsX1OiOcotl/1E8tW5VesSIkYtVmTgBbr9wkWuZPT8RKrvRVSVgWHxwXV4/eYFwxDsheL04BZYUV6lPSSEBPnEtO4Rn2AfBKo/gYqfb8zdu23FpWKrUMlRQ2ETDFINliKnDNx59aFEbTP85eOQpqetm/fDQKtGebOSpFTJ3TxlM3U54coIIDhzCCA4MwggLsoAMCAQICAQAwDQYJKoZIhvcNAQEFBQAwgY4xCzAJBgNVBAYTAlVTMQswCQYDVQQIEwJDQTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEUMBIGA1UEChMLUGF5UGFsIEluYy4xEzARBgNVBAsUCmxpdmVfY2VydHMxETAPBgNVBAMUCGxpdmVfYXBpMRwwGgYJKoZIhvcNAQkBFg1yZUBwYXlwYWwuY29tMB4XDTA0MDIxMzEwMTMxNVoXDTM1MDIxMzEwMTMxNVowgY4xCzAJBgNVBAYTAlVTMQswCQYDVQQIEwJDQTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEUMBIGA1UEChMLUGF5UGFsIEluYy4xEzARBgNVBAsUCmxpdmVfY2VydHMxETAPBgNVBAMUCGxpdmVfYXBpMRwwGgYJKoZIhvcNAQkBFg1yZUBwYXlwYWwuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDBR07d/ETMS1ycjtkpkvjXZe9k+6CieLuLsPumsJ7QC1odNz3sJiCbs2wC0nLE0uLGaEtXynIgRqIddYCHx88pb5HTXv4SZeuv0Rqq4+axW9PLAAATU8w04qqjaSXgbGLP3NmohqM6bV9kZZwZLR/klDaQGo1u9uDb9lr4Yn+rBQIDAQABo4HuMIHrMB0GA1UdDgQWBBSWn3y7xm8XvVk/UtcKG+wQ1mSUazCBuwYDVR0jBIGzMIGwgBSWn3y7xm8XvVk/UtcKG+wQ1mSUa6GBlKSBkTCBjjELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtQYXlQYWwgSW5jLjETMBEGA1UECxQKbGl2ZV9jZXJ0czERMA8GA1UEAxQIbGl2ZV9hcGkxHDAaBgkqhkiG9w0BCQEWDXJlQHBheXBhbC5jb22CAQAwDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQUFAAOBgQCBXzpWmoBa5e9fo6ujionW1hUhPkOBakTr3YCDjbYfvJEiv/2P+IobhOGJr85+XHhN0v4gUkEDI8r2/rNk1m0GA8HKddvTjyGw/XqXa+LSTlDYkqI8OwR8GEYj4efEtcRpRYBxV8KxAW93YDWzFGvruKnnLbDAF6VR5w/cCMn5hzGCAZowggGWAgEBMIGUMIGOMQswCQYDVQQGEwJVUzELMAkGA1UECBMCQ0ExFjAUBgNVBAcTDU1vdW50YWluIFZpZXcxFDASBgNVBAoTC1BheVBhbCBJbmMuMRMwEQYDVQQLFApsaXZlX2NlcnRzMREwDwYDVQQDFAhsaXZlX2FwaTEcMBoGCSqGSIb3DQEJARYNcmVAcGF5cGFsLmNvbQIBADAJBgUrDgMCGgUAoF0wGAYJKoZIhvcNAQkDMQsGCSqGSIb3DQEHATAcBgkqhkiG9w0BCQUxDxcNMTEwMTE2MjIyNzQyWjAjBgkqhkiG9w0BCQQxFgQUiaTKjuxCgwQjZm+TAmb0/tQbdWIwDQYJKoZIhvcNAQEBBQAEgYAn4V+IMVl19uvdDieOk8Wahvy1QYm+UfdMQn8ZuHOAswJ9vYreuqcradc4EL0kWH/o2/wzPWxoT3S2fqgdrVeKm8hnsXOWcpuFYMMu9fdLCe0wak8jpzTb02gm+LfYnK/dxe5FkgmzR2HN0tAdl+xlSUUApUZ1yZsXgWe9kFKZdg==-----END PKCS7-----">
436
+ <input type="image" src="https://www.paypal.com/en_US/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
437
+ <img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
438
+ </form>
439
+
440
+ <p style="text-align: center">
441
+ <a href="http://flattr.com/thing/117882/CMS-Tree-Page-View-Plugin-for-WordPress" target="_blank">
442
+ <img src="http://api.flattr.com/button/flattr-badge-large.png" alt="Flattr this" title="Flattr this" border="0" /></a>
443
+ </p>
444
+
445
+ <p>
446
+ You can also show your appreciation
447
+ by giving the plugin a <a href="http://wordpress.org/extend/plugins/cms-tree-page-view/">good rating over at the plugin directory</a>
448
+ or blog or tweet something nice about this plugin.
449
+ </p>
450
+
451
+ <h3>Support</h3>
452
+ <p>If you have any problems with this plugins please check out the <a href="http://wordpress.org/tags/cms-tree-page-view?forum_id=10">support forum</a>.</p>
453
+
454
+ <h3>More CMS related plugins</h3>
455
+ <p>These are some more plugins that enhance the CMS functionality of WordPress. Please check them out!</p>
456
+ <ul>
457
+ <li><a href="http://wordpress.org/extend/plugins/admin-menu-tree-page-view/">Admin Menu Tree Page View</a></li>
458
+ <li><a href="http://wordpress.org/extend/plugins/simple-history/">Simple History</a></li>
459
+ <li><a href="http://wordpress.org/extend/plugins/simple-fields/">Simple Fields</a></li>
460
+ <li><a href="http://wordpress.org/extend/plugins/simple-front-end-edit-buttons/">Simple Front End Edit Buttons</a></li>
461
+ </ul>
462
+
463
+
464
+ </div>
465
+
466
  <?php
467
+ // cms_tpv_show_annoying_box();
468
  cms_tpv_print_common_tree_stuff($post_type);
469
  ?>
470
+
471
  </div>
472
  <?php
473
  }
index.php CHANGED
@@ -2,8 +2,8 @@
2
  /*
3
  Plugin Name: CMS Tree Page View
4
  Plugin URI: http://eskapism.se/code-playground/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. By using the tree you can edit, view, add pages and even search pages (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
- Version: 0.7.12
7
  Author: Pär Thernström
8
  Author URI: http://eskapism.se/
9
  License: GPL2
@@ -27,7 +27,7 @@ License: GPL2
27
 
28
  require("functions.php");
29
 
30
- define( "CMS_TPV_VERSION", "0.7.11");
31
  define( "CMS_TPV_URL", WP_PLUGIN_URL . '/cms-tree-page-view/');
32
  define( "CMS_TPV_NAME", "CMS Tree Page View");
33
 
2
  /*
3
  Plugin Name: CMS Tree Page View
4
  Plugin URI: http://eskapism.se/code-playground/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 you 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
+ Version: 0.7.14
7
  Author: Pär Thernström
8
  Author URI: http://eskapism.se/
9
  License: GPL2
27
 
28
  require("functions.php");
29
 
30
+ define( "CMS_TPV_VERSION", "0.7.14");
31
  define( "CMS_TPV_URL", WP_PLUGIN_URL . '/cms-tree-page-view/');
32
  define( "CMS_TPV_NAME", "CMS Tree Page View");
33
 
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: eskapism, MarsApril
3
  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
  Requires at least: 3.0
6
- Tested up to: 3.0.3
7
- Stable tag: 0.7.12
8
 
9
  Adds a tree of all your pages or custom posts. Use drag & drop to reorder your pages, and edit, view, add, and search your pages.
10
 
@@ -20,15 +20,15 @@ Page management in WordPress won't get any easier than this!
20
 
21
  #### Features and highlights:
22
 
23
- * View your pages and posts in a tree-view, like you view files in Windows Explorer or the Finder in OS X
24
- * Drag and drop to rearrange/order your pages
25
- * Add pages after or inside a page
26
- * Edit pages
27
- * View pages
28
- * Search pages
29
- * Available for both regular pages and custom posts
30
- * View your site hierarchy directly from the WordPress dashboard
31
- * Support for translation plugin [WPML](http://wordpress.org/extend/plugins/sitepress-multilingual-cms/), so you can manage all the languages of your site
32
 
33
  #### Screencast
34
  Watch this screencast to see how easy you could be managing your pages:
@@ -78,6 +78,12 @@ Now the tree with the pages will be visible both on the dashboard and in the men
78
 
79
  == Changelog ==
80
 
 
 
 
 
 
 
81
  = 0.7.12 =
82
  - Readme-fix...
83
 
3
  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
  Requires at least: 3.0
6
+ Tested up to: 3.1
7
+ Stable tag: 0.7.14
8
 
9
  Adds a tree of all your pages or custom posts. Use drag & drop to reorder your pages, and edit, view, add, and search your pages.
10
 
20
 
21
  #### Features and highlights:
22
 
23
+ * View your pages & posts in a tree-view, like you view files in Windows Explorer or the Finder in OS X
24
+ * Drag and drop to rearrange/order your pages
25
+ * Add pages after or inside a page
26
+ * Edit pages
27
+ * View pages
28
+ * Search pages
29
+ * Available for both regular pages and custom posts
30
+ * View your site hierarchy directly from the WordPress dashboard
31
+ * Support for translation plugin [WPML](http://wordpress.org/extend/plugins/sitepress-multilingual-cms/), so you can manage all the languages of your site
32
 
33
  #### Screencast
34
  Watch this screencast to see how easy you could be managing your pages:
78
 
79
  == Changelog ==
80
 
81
+ = 0.7.14 =
82
+ - Added links to PayPal and Flattr, so users who like the plugin can donate.
83
+
84
+ = 0.7.13 =
85
+ - Upgraded jstree to rc2. This fixes the problems with drag & drop and mouse over that occured in WordPress 3.1 beta.
86
+
87
  = 0.7.12 =
88
  - Readme-fix...
89
 
scripts/jquery.jstree.js CHANGED
@@ -8,10 +8,11 @@
8
  * http://www.opensource.org/licenses/mit-license.php
9
  * http://www.gnu.org/licenses/gpl.html
10
  *
11
- * $Date$
12
- * $Revision$
13
  */
14
 
 
15
  /*global window : false, clearInterval: false, clearTimeout: false, document: false, setInterval: false, setTimeout: false, jQuery: false, navigator: false, XSLTProcessor: false, DOMParser: false, XMLSerializer: false*/
16
 
17
  "use strict";
@@ -88,7 +89,8 @@
88
  var instances = [], // instance array (used by $.jstree.reference/create/focused)
89
  focused_instance = -1, // the index in the instance array of the currently focused instance
90
  plugins = {}, // list of included plugins
91
- prepared_move = {}; // for the move plugin
 
92
 
93
  // jQuery plugin wrapper (thanks to jquery UI widget function)
94
  $.fn.jstree = function (settings) {
@@ -115,7 +117,7 @@
115
  var instance_id = $.data(this, "jstree-instance-id"),
116
  s = false;
117
  // if an instance already exists, destroy it first
118
- if(instance_id && instances[instance_id]) { instances[instance_id].destroy(); }
119
  // push a new empty object to the instances array
120
  instance_id = parseInt(instances.push({}),10) - 1;
121
  // store the jstree instance id to the container element
@@ -256,23 +258,29 @@
256
  css_string = '' +
257
  '.jstree ul, .jstree li { display:block; margin:0 0 0 0; padding:0 0 0 0; list-style-type:none; } ' +
258
  '.jstree li { display:block; min-height:18px; line-height:18px; white-space:nowrap; margin-left:18px; } ' +
 
259
  '.jstree > ul > li { margin-left:0px; } ' +
 
260
  '.jstree ins { display:inline-block; text-decoration:none; width:18px; height:18px; margin:0 0 0 0; padding:0; } ' +
261
  '.jstree a { display:inline-block; line-height:16px; height:16px; color:black; white-space:nowrap; text-decoration:none; padding:1px 2px; margin:0; } ' +
262
  '.jstree a:focus { outline: none; } ' +
263
  '.jstree a > ins { height:16px; width:16px; } ' +
264
  '.jstree a > .jstree-icon { margin-right:3px; } ' +
 
265
  'li.jstree-open > ul { display:block; } ' +
266
  'li.jstree-closed > ul { display:none; } ';
267
  // Correct IE 6 (does not support the > CSS selector)
268
  if(/msie/.test(u) && parseInt(v, 10) == 6) {
 
269
  css_string += '' +
270
- '.jstree li { height:18px; margin-left:0; } ' +
271
  '.jstree li li { margin-left:18px; } ' +
 
272
  'li.jstree-open ul { display:block; } ' +
273
  'li.jstree-closed ul { display:none !important; } ' +
274
- '.jstree li a { display:inline; } ' +
275
- '.jstree li a ins { height:16px; width:16px; margin-right:3px; } ';
 
276
  }
277
  // Correct IE 7 (shifts anchor nodes onhover)
278
  if(/msie/.test(u) && parseInt(v, 10) == 7) {
@@ -289,12 +297,20 @@
289
  defaults : {
290
  html_titles : false,
291
  animation : 500,
292
- initially_open : []
 
 
 
 
 
293
  },
294
  _fn : {
295
  init : function () {
296
  this.set_focus();
297
- this.get_container().html("<ul><li class='jstree-last jstree-leaf'><ins>&#160;</ins><a class='jstree-loading' href='#'><ins class='jstree-icon'>&#160;</ins>Loading ...</a></li></ul>");
 
 
 
298
  this.data.core.li_height = this.get_container().find("ul li.jstree-closed, ul li.jstree-leaf").eq(0).height() || 18;
299
 
300
  this.get_container()
@@ -328,7 +344,7 @@
328
  _this = this;
329
 
330
  $.each(s.plugins, function (i, val) {
331
- plugins[val].__destroy.apply(_this);
332
  });
333
  this.__callback();
334
  // set focus to another instance if this one is focused
@@ -433,7 +449,7 @@
433
 
434
  if(obj.hasClass("jstree-open")) { return obj.find("li:eq(0)"); }
435
  else if(obj.nextAll("li").size() > 0) { return obj.nextAll("li:eq(0)"); }
436
- else { return obj.parentsUntil(this.get_container(),"li").next("li").eq(0); }
437
  },
438
  _get_prev : function (obj, strict) {
439
  obj = this._get_node(obj);
@@ -446,12 +462,12 @@
446
  while(obj.hasClass("jstree-open")) { obj = obj.children("ul:eq(0)").children("li:last"); }
447
  return obj;
448
  }
449
- else { var o = obj.parentsUntil(this.get_container(),"li:eq(0)"); return o.length ? o : false; }
450
  },
451
  _get_parent : function (obj) {
452
  obj = this._get_node(obj);
453
  if(obj == -1 || !obj.length) { return false; }
454
- var o = obj.parentsUntil(this.get_container(), "li:eq(0)");
455
  return o.length ? o : -1;
456
  },
457
  _get_children : function (obj) {
@@ -465,7 +481,7 @@
465
  _this = this;
466
  obj = this._get_node(obj);
467
  if(obj === -1 || !obj || !obj.length) { return false; }
468
- obj.parentsUntil(this.get_container(), "li").each(function () {
469
  p.push( id_mode ? this.id : _this.get_text(this) );
470
  });
471
  p.reverse();
@@ -473,11 +489,15 @@
473
  return p;
474
  },
475
 
 
 
 
476
  // open/close
477
  open_node : function (obj, callback, skip_animation) {
478
  obj = this._get_node(obj);
479
  if(!obj.length) { return false; }
480
- var s = skip_animation ? 0 : this._get_settings().core.animation,
 
481
  t = this;
482
  if(!this._is_loaded(obj)) {
483
  obj.children("a").addClass("jstree-loading");
@@ -486,18 +506,18 @@
486
  else {
487
  if(s) { obj.children("ul").css("display","none"); }
488
  obj.removeClass("jstree-closed").addClass("jstree-open").children("a").removeClass("jstree-loading");
489
- if(s) { obj.children("ul").slideDown(s, function () { this.style.display = ""; }); }
490
  this.__callback({ "obj" : obj });
491
  if(callback) { callback.call(); }
492
  }
493
  },
494
  close_node : function (obj, skip_animation) {
495
  obj = this._get_node(obj);
496
- var s = skip_animation ? 0 : this._get_settings().core.animation;
497
- if(!obj.length) { return false; }
498
  if(s) { obj.children("ul").attr("style","display:block !important"); }
499
  obj.removeClass("jstree-open").addClass("jstree-closed");
500
- if(s) { obj.children("ul").slideUp(s, function () { this.style.display = ""; }); }
501
  this.__callback({ "obj" : obj });
502
  },
503
  toggle_node : function (obj) {
@@ -537,9 +557,9 @@
537
  obj = obj.is("li") ? obj.find("li").andSelf() : obj.find("li");
538
  obj.removeClass("jstree-last")
539
  .filter("li:last-child").addClass("jstree-last").end()
540
- .filter(":has(ul)")
541
  .not(".jstree-open").removeClass("jstree-leaf").addClass("jstree-closed");
542
- obj.not(".jstree-open, .jstree-closed").addClass("jstree-leaf");
543
  this.__callback({ "obj" : obj });
544
  },
545
  // rollback
@@ -561,7 +581,7 @@
561
  obj = this._get_node(obj);
562
  position = typeof position === "undefined" ? "last" : position;
563
  var d = $("<li>"),
564
- s = this._get_settings().core.html_titles,
565
  tmp;
566
 
567
  if(obj !== -1 && !obj.length) { return false; }
@@ -573,16 +593,16 @@
573
  if(!js) { js = {}; }
574
  if(js.attr) { d.attr(js.attr); }
575
  if(js.state) { d.addClass("jstree-" + js.state); }
576
- if(!js.data) { js.data = "New node"; }
577
  if(!$.isArray(js.data)) { tmp = js.data; js.data = []; js.data.push(tmp); }
578
  $.each(js.data, function (i, m) {
579
  tmp = $("<a>");
580
  if($.isFunction(m)) { m = m.call(this, js); }
581
- if(typeof m == "string") { tmp.attr('href','#')[ s ? "html" : "text" ](m); }
582
  else {
583
  if(!m.attr) { m.attr = {}; }
584
  if(!m.attr.href) { m.attr.href = '#'; }
585
- tmp.attr(m.attr)[ s ? "html" : "text" ](m.title);
586
  if(m.language) { tmp.addClass(m.language); }
587
  }
588
  tmp.prepend("<ins class='jstree-icon'>&#160;</ins>");
@@ -672,7 +692,7 @@
672
  var p = this._get_parent(obj), prev = this._get_prev(obj);
673
  obj = obj.remove();
674
  if(p !== -1 && p.find("> ul > li").length === 0) {
675
- p.removeClass("jstree-open, jstree-closed").addClass("jstree-leaf");
676
  }
677
  this.clean_node(p);
678
  this.__callback({ "obj" : obj, "prev" : prev });
@@ -711,7 +731,7 @@
711
  }
712
  else {
713
  if(!/^(before|after)$/.test(p.p) && !this._is_loaded(p.r)) {
714
- return this.load_node(p.r, function () { this.prepare_move(o, r, p, cb, true); });
715
  }
716
  switch(p.p) {
717
  case "before":
@@ -746,9 +766,12 @@
746
  if(cb) { cb.call(this, prepared_move); }
747
  },
748
  check_move : function () {
749
- var obj = prepared_move;
750
- if(obj.or[0] === obj.o[0] || obj.r.parentsUntil(".jstree").andSelf().filter("li").index(obj.o) !== -1) { return false; }
751
- return true;
 
 
 
752
  },
753
  move_node : function (obj, ref, position, is_copy, is_prepared, skip_check) {
754
  if(!is_prepared) {
@@ -845,7 +868,7 @@
845
  clk = (obj && obj.length) ? obj.find(".jstree-clicked") : [],
846
  _this = this;
847
  clk.each(function () { _this.deselect_node(this); });
848
- if(s) { this.select_node(data.rslt.prev); }
849
  }, this))
850
  .bind("move_node.jstree", $.proxy(function (event, data) {
851
  if(data.rslt.cy) {
@@ -1006,11 +1029,12 @@
1006
  _fn : {
1007
  _show_input : function (obj, callback) {
1008
  obj = this._get_node(obj);
1009
- var w = this._get_settings().crrm.input_width_limit,
 
1010
  w1 = obj.children("ins").width(),
1011
  w2 = obj.find("> a:visible > ins").width() * obj.find("> a:visible > ins").length,
1012
  t = this.get_text(obj),
1013
- h1 = $("<div>", { css : { "position" : "absolute", "top" : "-200px", "left" : "-1000px", "visibility" : "hidden" } }).appendTo("body"),
1014
  h2 = obj.css("position","relative").append(
1015
  $("<input>", {
1016
  "value" : t,
@@ -1019,7 +1043,8 @@
1019
  "padding" : "0",
1020
  "border" : "1px solid silver",
1021
  "position" : "absolute",
1022
- "left" : (w1 + w2 + 4) + "px",
 
1023
  "top" : "0px",
1024
  "height" : (this.data.core.li_height - 2) + "px",
1025
  "lineHeight" : (this.data.core.li_height - 2) + "px",
@@ -1101,6 +1126,7 @@
1101
  var s = this._get_settings().crrm.move;
1102
  if(!is_prepared) {
1103
  if(!position) { position = s.default_position; }
 
1104
  return this.__call_old(true, obj, ref, position, is_copy, false, skip_check);
1105
  }
1106
  // if the move is already prepared
@@ -1130,6 +1156,8 @@
1130
  if(!this.data.crrm.ct_nodes && !this.data.crrm.cp_nodes) { return false; }
1131
  if(this.data.crrm.ct_nodes) { this.move_node(this.data.crrm.ct_nodes, obj); }
1132
  if(this.data.crrm.cp_nodes) { this.move_node(this.data.crrm.cp_nodes, obj, false, true); }
 
 
1133
  }
1134
  }
1135
  });
@@ -1224,9 +1252,9 @@
1224
  (function ($) {
1225
  var bound = [];
1226
  function exec(i, event) {
1227
- var f = $.jstree._focused();
1228
  if(f && f.data && f.data.hotkeys && f.data.hotkeys.enabled) {
1229
- var tmp = f._get_settings().hotkeys[i];
1230
  if(tmp) { return tmp.call(f, event); }
1231
  }
1232
  }
@@ -1325,6 +1353,11 @@
1325
  var s = this.get_settings().json_data, d,
1326
  error_func = function () {},
1327
  success_func = function () {};
 
 
 
 
 
1328
  switch(!0) {
1329
  case (!s.data && !s.ajax): throw "Neither data nor ajax settings supplied.";
1330
  case (!!s.data && !s.ajax) || (!!s.data && !!s.ajax && (!obj || obj === -1)):
@@ -1341,12 +1374,12 @@
1341
  if(s_call) { s_call.call(this); }
1342
  break;
1343
  case (!s.data && !!s.ajax) || (!!s.data && !!s.ajax && obj && obj !== -1):
1344
- obj = this._get_node(obj);
1345
  error_func = function (x, t, e) {
1346
  var ef = this.get_settings().json_data.ajax.error;
1347
  if(ef) { ef.call(this, x, t, e); }
1348
  if(obj != -1 && obj.length) {
1349
  obj.children(".jstree-loading").removeClass("jstree-loading");
 
1350
  if(t === "success" && s.correct_state) { obj.removeClass("jstree-open jstree-closed").addClass("jstree-leaf"); }
1351
  }
1352
  else {
@@ -1363,7 +1396,7 @@
1363
  d = this._parse_json(d);
1364
  if(d) {
1365
  if(obj === -1 || !obj) { this.get_container().children("ul").empty().append(d.children()); }
1366
- else { obj.append(d).children(".jstree-loading").removeClass("jstree-loading"); }
1367
  this.clean_node(obj);
1368
  if(s_call) { s_call.call(this); }
1369
  }
@@ -1376,6 +1409,7 @@
1376
  }
1377
  else {
1378
  obj.children(".jstree-loading").removeClass("jstree-loading");
 
1379
  if(s.correct_state) {
1380
  obj.removeClass("jstree-open jstree-closed").addClass("jstree-leaf");
1381
  if(s_call) { s_call.call(this); }
@@ -1387,6 +1421,7 @@
1387
  s.ajax.error = error_func;
1388
  s.ajax.success = success_func;
1389
  if(!s.ajax.dataType) { s.ajax.dataType = "json"; }
 
1390
  if($.isFunction(s.ajax.data)) { s.ajax.data = s.ajax.data.call(this, obj); }
1391
  $.ajax(s.ajax);
1392
  break;
@@ -1507,7 +1542,7 @@
1507
  }
1508
  tmp2 = { attr : { }, title : _this.get_text(t, lang) };
1509
  $.each(a_attr, function (k, z) {
1510
- tmp1.attr[z] = li.attr(z).replace(/jstree[^ ]*|$/ig,'');
1511
  });
1512
  $.each(s.languages, function (k, z) {
1513
  if(t.hasClass(z)) { tmp2.language = z; return true; }
@@ -1666,7 +1701,7 @@
1666
  }
1667
  if(!!s.save_selected) {
1668
  tmp = $.cookie(s.save_selected);
1669
- if(tmp && tmp.length) { this.data.ui.to_select = tmp.split(","); }
1670
  }
1671
  this.get_container()
1672
  .one( ( this.data.ui ? "reselect" : "reopen" ) + ".jstree", $.proxy(function () {
@@ -1763,11 +1798,16 @@
1763
  (function ($) {
1764
  var o = false,
1765
  r = false,
1766
- m = false;
 
 
 
 
1767
  $.vakata.dnd = {
1768
  is_down : false,
1769
  is_drag : false,
1770
  helper : false,
 
1771
  init_x : 0,
1772
  init_y : 0,
1773
  threshold : 5,
@@ -1799,6 +1839,41 @@
1799
  }
1800
  else { return; }
1801
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1802
  $.vakata.dnd.helper.css({ left : (e.pageX + 5) + "px", top : (e.pageY + 10) + "px" });
1803
  $(document).triggerHandler("drag.vakata", { "event" : e, "data" : $.vakata.dnd.user_data });
1804
  },
@@ -1815,7 +1890,7 @@
1815
  }
1816
  };
1817
  $(function() {
1818
- var css_string = '#vakata-dragged { display:block; margin:0 0 0 0; padding:4px 4px 4px 24px; position:absolute; left:-2000px; top:-2000px; line-height:16px; z-index:10000; } ';
1819
  $.vakata.css.add_sheet({ str : css_string });
1820
  });
1821
 
@@ -1855,26 +1930,26 @@
1855
  var cnt = this.get_container()[0];
1856
 
1857
  // Horizontal scroll
1858
- if(e.pageX + 20 > this.data.dnd.cof.left + this.data.dnd.cw) {
1859
  if(this.data.dnd.i1) { clearInterval(this.data.dnd.i1); }
1860
- this.data.dnd.i1 = setInterval($.proxy(function () { this.scrollLeft += 5; }, cnt), 100);
1861
  }
1862
- else if(e.pageX - 20 < this.data.dnd.cof.left) {
1863
  if(this.data.dnd.i1) { clearInterval(this.data.dnd.i1); }
1864
- this.data.dnd.i1 = setInterval($.proxy(function () { this.scrollLeft -= 5; }, cnt), 100);
1865
  }
1866
  else {
1867
  if(this.data.dnd.i1) { clearInterval(this.data.dnd.i1); }
1868
  }
1869
 
1870
  // Vertical scroll
1871
- if(e.pageY + 20 > this.data.dnd.cof.top + this.data.dnd.ch) {
1872
  if(this.data.dnd.i2) { clearInterval(this.data.dnd.i2); }
1873
- this.data.dnd.i2 = setInterval($.proxy(function () { this.scrollTop += 5; }, cnt), 100);
1874
  }
1875
- else if(e.pageY - 20 < this.data.dnd.cof.top) {
1876
  if(this.data.dnd.i2) { clearInterval(this.data.dnd.i2); }
1877
- this.data.dnd.i2 = setInterval($.proxy(function () { this.scrollTop -= 5; }, cnt), 100);
1878
  }
1879
  else {
1880
  if(this.data.dnd.i2) { clearInterval(this.data.dnd.i2); }
@@ -1938,7 +2013,7 @@
1938
  this.data.dnd.to2 = false;
1939
  this.data.dnd.active = false;
1940
  this.data.dnd.foreign = false;
1941
- if(m) { m.css({ "left" : "-2000px", "top" : "-2000px" }); }
1942
  }, this))
1943
  .bind("drag_start.vakata", $.proxy(function (e, data) {
1944
  if(data.data.jstree) {
@@ -1961,7 +2036,7 @@
1961
  }
1962
  $.vakata.dnd.helper.children("ins").attr("class","jstree-invalid");
1963
  var cnt = this.get_container();
1964
- this.data.dnd.cof = cnt.children("ul").offset();
1965
  this.data.dnd.cw = parseInt(cnt.width(),10);
1966
  this.data.dnd.ch = parseInt(cnt.height(),10);
1967
  this.data.dnd.foreign = true;
@@ -2000,7 +2075,11 @@
2000
  },
2001
  _fn : {
2002
  dnd_prepare : function () {
 
2003
  this.data.dnd.off = r.offset();
 
 
 
2004
  if(this.data.dnd.foreign) {
2005
  var a = this._get_settings().dnd.drag_check.call(this, { "o" : o, "r" : r });
2006
  this.data.dnd.after = a.after;
@@ -2026,7 +2105,9 @@
2026
  dnd_show : function () {
2027
  if(!this.data.dnd.prepared) { return; }
2028
  var o = ["before","inside","after"],
2029
- r = false;
 
 
2030
  if(this.data.dnd.w < this.data.core.li_height/3) { o = ["before","inside","after"]; }
2031
  else if(this.data.dnd.w <= this.data.core.li_height*2/3) {
2032
  o = this.data.dnd.w < this.data.core.li_height/2 ? ["inside","before","after"] : ["inside","after","before"];
@@ -2040,15 +2121,17 @@
2040
  }
2041
  }, this));
2042
  if(r === false) { $.vakata.dnd.helper.children("ins").attr("class","jstree-invalid"); }
 
 
2043
  switch(r) {
2044
  case "before":
2045
- m.css({ "left" : (this.data.dnd.off.left + 10) + "px", "top" : (this.data.dnd.off.top - 6) + "px" }).show();
2046
  break;
2047
  case "after":
2048
- m.css({ "left" : (this.data.dnd.off.left + 10) + "px", "top" : (this.data.dnd.off.top + this.data.core.li_height - 7) + "px" }).show();
2049
  break;
2050
  case "inside":
2051
- m.css({ "left" : (this.data.dnd.off.left + 14) + "px", "top" : (this.data.dnd.off.top + this.data.core.li_height/2 - 5) + "px" }).show();
2052
  break;
2053
  default:
2054
  m.hide();
@@ -2088,13 +2171,13 @@
2088
  }
2089
  if(s.open_timeout) {
2090
  if(this.data.dnd.to2) { clearTimeout(this.data.dnd.to2); }
2091
- if(r.hasClass("jstree-closed")) {
2092
  // if the node is closed - open it, then recalculate
2093
  this.data.dnd.to2 = setTimeout($.proxy(this.dnd_open, this), s.open_timeout);
2094
  }
2095
  }
2096
  else {
2097
- if(r.hasClass("jstree-closed")) {
2098
  this.dnd_open();
2099
  }
2100
  }
@@ -2120,7 +2203,7 @@
2120
  '#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; } ' +
2121
  '#vakata-dragged .jstree-ok { background:green; } ' +
2122
  '#vakata-dragged .jstree-invalid { background:red; } ' +
2123
- '#jstree-marker { padding:0; margin:0; line-height:12px; font-size:1px; overflow:hidden; height:12px; width:8px; position:absolute; left:-45px; top:-30px; z-index:10000; background-repeat:no-repeat; display:none; background-color:silver; } ';
2124
  $.vakata.css.add_sheet({ str : css_string });
2125
  m = $("<div>").attr({ id : "jstree-marker" }).hide().appendTo("body");
2126
  $(document).bind("drag_start.vakata", function (e, data) {
@@ -2144,45 +2227,53 @@
2144
  (function ($) {
2145
  $.jstree.plugin("checkbox", {
2146
  __init : function () {
2147
- if(!this.data.ui) { throw("jsTree checkboxes: jsTree UI plugin not included"); }
2148
  this.select_node = this.deselect_node = this.deselect_all = $.noop;
2149
  this.get_selected = this.get_checked;
2150
 
2151
  this.get_container()
2152
- .bind("open_node.jstree create_node.jstree", $.proxy(function (e, data) {
2153
  this._prepare_checkboxes(data.rslt.obj);
2154
  }, this))
2155
  .bind("loaded.jstree", $.proxy(function (e) {
2156
  this._prepare_checkboxes();
2157
  }, this))
2158
- .bind("clean_node.jstree", $.proxy(function (e, data) {
2159
- this._repair_state(data.args[0]);
2160
- }, this))
2161
  .delegate("a", "click.jstree", $.proxy(function (e) {
2162
- this.change_state(e.target);
2163
- this.save_selected();
 
2164
  if(this.data.cookies) { this.save_cookie("select_node"); }
2165
  e.preventDefault();
2166
  }, this));
2167
  },
 
 
 
2168
  _fn : {
2169
  _prepare_checkboxes : function (obj) {
2170
  obj = !obj || obj == -1 ? this.get_container() : this._get_node(obj);
2171
- var c = obj.is("li") && obj.hasClass("jstree-checked") ? "jstree-checked" : "jstree-unchecked";
2172
- obj.find("a").not(":has(.checkbox)").prepend("<ins class='checkbox'>&#160;</ins>").parent().addClass(c);
 
 
 
 
 
 
2173
  },
2174
  change_state : function (obj, state) {
2175
  obj = this._get_node(obj);
2176
  state = (state === false || state === true) ? state : obj.hasClass("jstree-checked");
2177
  if(state) { obj.find("li").andSelf().removeClass("jstree-checked jstree-undetermined").addClass("jstree-unchecked"); }
2178
- else { obj.find("li").andSelf().removeClass("jstree-unchecked jstree-undetermined").addClass("jstree-checked"); this.data.ui.last_selected = obj; }
2179
-
2180
- var _this = this;
2181
- obj.parentsUntil(this.get_container(), "li").each(function () {
 
 
2182
  var $this = $(this);
2183
  if(state) {
2184
  if($this.children("ul").children(".jstree-checked, .jstree-undetermined").length) {
2185
- $this.parentsUntil(_this.get_container(), "li").andSelf().removeClass("jstree-checked jstree-unchecked").addClass("jstree-undetermined");
2186
  return false;
2187
  }
2188
  else {
@@ -2191,7 +2282,7 @@
2191
  }
2192
  else {
2193
  if($this.children("ul").children(".jstree-unchecked, .jstree-undetermined").length) {
2194
- $this.parentsUntil(_this.get_container(), "li").andSelf().removeClass("jstree-checked jstree-unchecked").addClass("jstree-undetermined");
2195
  return false;
2196
  }
2197
  else {
@@ -2199,7 +2290,7 @@
2199
  }
2200
  }
2201
  });
2202
- this.data.ui.selected = this.get_checked();
2203
  this.__callback(obj);
2204
  },
2205
  check_node : function (obj) {
@@ -2248,16 +2339,18 @@
2248
  else if(a === 0 && b === 0) { this.uncheck_node(obj); }
2249
  else if(a === c) { this.check_node(obj); }
2250
  else {
2251
- obj.parentsUntil(this.get_container(),"li").andSelf().removeClass("jstree-checked jstree-unchecked").addClass("jstree-undetermined");
2252
  }
2253
  },
2254
  reselect : function () {
2255
- var _this = this,
2256
- s = this.data.ui.to_select;
2257
- s = $.map($.makeArray(s), function (n) { return "#" + n.toString().replace(/^#/,"").replace('\\/','/').replace('/','\\/'); });
2258
- this.deselect_all();
2259
- $.each(s, function (i, val) { _this.check_node(val); });
2260
- this.__callback();
 
 
2261
  }
2262
  }
2263
  });
@@ -2280,7 +2373,7 @@
2280
  setTimeout( (function (xm, xs, callback) {
2281
  return function () {
2282
  callback.call(null, xm.transformNode(xs.XMLDocument));
2283
- jQuery("body").remove(xm).remove(xs);
2284
  };
2285
  }) (xm, xs, callback), 100);
2286
  return true;
@@ -2452,12 +2545,19 @@
2452
  load_node : function (obj, s_call, e_call) { var _this = this; this.load_node_xml(obj, function () { _this.__callback({ "obj" : obj }); s_call.call(this); }, e_call); },
2453
  _is_loaded : function (obj) {
2454
  var s = this._get_settings().xml_data;
 
2455
  return obj == -1 || !obj || !s.ajax || obj.is(".jstree-open, .jstree-leaf") || obj.children("ul").children("li").size() > 0;
2456
  },
2457
  load_node_xml : function (obj, s_call, e_call) {
2458
  var s = this.get_settings().xml_data,
2459
  error_func = function () {},
2460
  success_func = function () {};
 
 
 
 
 
 
2461
  switch(!0) {
2462
  case (!s.data && !s.ajax): throw "Neither data nor ajax settings supplied.";
2463
  case (!!s.data && !s.ajax) || (!!s.data && !!s.ajax && (!obj || obj === -1)):
@@ -2469,22 +2569,25 @@
2469
  d = $(d);
2470
  this.get_container().children("ul").empty().append(d.children());
2471
  if(s.clean_node) { this.clean_node(obj); }
 
2472
  }
2473
  }
2474
  else {
2475
- if(s.correct_state) { this.get_container().children("ul").empty(); }
 
 
 
2476
  }
2477
  }, this));
2478
  }
2479
- if(s_call) { s_call.call(this); }
2480
  break;
2481
  case (!s.data && !!s.ajax) || (!!s.data && !!s.ajax && obj && obj !== -1):
2482
- obj = this._get_node(obj);
2483
  error_func = function (x, t, e) {
2484
  var ef = this.get_settings().xml_data.ajax.error;
2485
  if(ef) { ef.call(this, x, t, e); }
2486
  if(obj !== -1 && obj.length) {
2487
  obj.children(".jstree-loading").removeClass("jstree-loading");
 
2488
  if(t === "success" && s.correct_state) { obj.removeClass("jstree-open jstree-closed").addClass("jstree-leaf"); }
2489
  }
2490
  else {
@@ -2505,13 +2608,14 @@
2505
  if(d.length > 10) {
2506
  d = $(d);
2507
  if(obj === -1 || !obj) { this.get_container().children("ul").empty().append(d.children()); }
2508
- else { obj.children(".jstree-loading").removeClass("jstree-loading"); obj.append(d); }
2509
  if(s.clean_node) { this.clean_node(obj); }
2510
  if(s_call) { s_call.call(this); }
2511
  }
2512
  else {
2513
  if(obj && obj !== -1) {
2514
- obj.children(".jstree-loading").removeClass("jstree-loading");
 
2515
  if(s.correct_state) {
2516
  obj.removeClass("jstree-open jstree-closed").addClass("jstree-leaf");
2517
  if(s_call) { s_call.call(this); }
@@ -2531,7 +2635,8 @@
2531
  s.ajax.error = error_func;
2532
  s.ajax.success = success_func;
2533
  if(!s.ajax.dataType) { s.ajax.dataType = "xml"; }
2534
- if($.isFunction(s.ajax.data)) { s.ajax.data = s.ajax.data.call(null, obj); }
 
2535
  $.ajax(s.ajax);
2536
  break;
2537
  }
@@ -2550,7 +2655,7 @@
2550
  obj = this._get_node(obj);
2551
  if(!obj || obj === -1) { obj = this.get_container().find("> ul > li"); }
2552
  li_attr = $.isArray(li_attr) ? li_attr : [ "id", "class" ];
2553
- if(!is_callback && this.data.types) { li_attr.push(s.types.type_attr); }
2554
 
2555
  a_attr = $.isArray(a_attr) ? a_attr : [ ];
2556
 
@@ -2576,7 +2681,7 @@
2576
  }
2577
  if(a_attr.length) {
2578
  $.each(a_attr, function (k, z) {
2579
- result += " " + z + "=\"" + li.attr(z).replace(/jstree[^ ]*|$/ig,'') + "\"";
2580
  });
2581
  }
2582
  if(tmp1.children("ins").get(0).className.replace(/jstree[^ ]*|$/ig,'').replace(/^\s+$/ig,"").length) {
@@ -2593,6 +2698,7 @@
2593
  tmp2 = li[0].id;
2594
  li = li.find("> ul > li");
2595
  if(li.length) { tmp2 = _this.get_xml(tp, li, li_attr, a_attr, tmp2); }
 
2596
  if(tp == "nest") { result += tmp2; }
2597
  result += "</item>";
2598
  if(tp == "flat") { result += tmp2; }
@@ -2625,6 +2731,7 @@
2625
  },
2626
  _fn : {
2627
  search : function (str, skip_async) {
 
2628
  var s = this.get_settings().search,
2629
  t = this,
2630
  error_func = function () { },
@@ -2643,6 +2750,7 @@
2643
  s.ajax.context = this;
2644
  s.ajax.error = error_func;
2645
  s.ajax.success = success_func;
 
2646
  if($.isFunction(s.ajax.data)) { s.ajax.data = s.ajax.data.call(this, str); }
2647
  if(!s.ajax.data) { s.ajax.data = { "search_string" : str }; }
2648
  if(!s.ajax.dataType || /^json/.exec(s.ajax.dataType)) { s.ajax.dataType = "json"; }
@@ -2695,13 +2803,15 @@
2695
  cnt : $("<div id='vakata-contextmenu'>"),
2696
  vis : false,
2697
  tgt : false,
 
2698
  func : false,
2699
  data : false,
2700
- show : function (s, t, x, y, d) {
2701
  var html = $.vakata.context.parse(s), h, w;
2702
  if(!html) { return; }
2703
  $.vakata.context.vis = true;
2704
  $.vakata.context.tgt = t;
 
2705
  $.vakata.context.data = d || null;
2706
  $.vakata.context.cnt
2707
  .html(html)
@@ -2741,17 +2851,20 @@
2741
  $(document).triggerHandler("context_hide.vakata");
2742
  },
2743
  parse : function (s, is_callback) {
 
2744
  var str = "",
2745
- tmp = false;
 
2746
  if(!is_callback) { $.vakata.context.func = {}; }
2747
  str += "<ul>";
2748
  $.each(s, function (i, val) {
2749
  if(!val) { return true; }
2750
  $.vakata.context.func[i] = val.action;
2751
- if(val.separator_before) {
2752
  str += "<li class='vakata-separator vakata-separator-before'></li>";
2753
  }
2754
- str += "<li><ins ";
 
2755
  if(val.icon && val.icon.indexOf("/") === -1) { str += " class='" + val.icon + "' "; }
2756
  if(val.icon && val.icon.indexOf("/") !== -1) { str += " style='background:url(" + val.icon + ") center center no-repeat;' "; }
2757
  str += ">&#160;</ins><a href='#' rel='" + i + "'>";
@@ -2766,14 +2879,16 @@
2766
  str += "</li>";
2767
  if(val.separator_after) {
2768
  str += "<li class='vakata-separator vakata-separator-after'></li>";
 
2769
  }
2770
  });
 
2771
  str += "</ul>";
2772
  return str.length > 10 ? str : false;
2773
  },
2774
  exec : function (i) {
2775
  if($.isFunction($.vakata.context.func[i])) {
2776
- $.vakata.context.func[i].call($.vakata.context.data, $.vakata.context.tgt);
2777
  return true;
2778
  }
2779
  else { return false; }
@@ -2796,9 +2911,10 @@
2796
  $.vakata.context.cnt
2797
  .delegate("a","click", function (e) { e.preventDefault(); })
2798
  .delegate("a","mouseup", function (e) {
2799
- if($.vakata.context.exec($(this).attr("rel"))) {
2800
  $.vakata.context.hide();
2801
  }
 
2802
  })
2803
  .delegate("a","mouseover", function () {
2804
  $.vakata.context.cnt.find(".vakata-hover").removeClass("vakata-hover");
@@ -2935,7 +3051,7 @@
2935
  }
2936
  if($.isFunction(s.items)) { s.items = s.items.call(this, obj); }
2937
  this.data.contextmenu = true;
2938
- $.vakata.context.show(s.items, a, x, y, this);
2939
  if(this.data.themes) { $.vakata.context.cnt.attr("class", "jstree-" + this.data.themes.theme + "-context"); }
2940
  }
2941
  }
@@ -2981,7 +3097,12 @@
2981
  if($.inArray(data.func, this.data.types.attach_to) !== -1) {
2982
  var s = this._get_settings().types.types,
2983
  t = this._get_type(data.args[0]);
2984
- if(s[t] && typeof s[t][data.func] !== "undefined" && !this._check(data.func, data.args[0])) {
 
 
 
 
 
2985
  e.stopImmediatePropagation();
2986
  return false;
2987
  }
@@ -3037,10 +3158,17 @@
3037
  }
3038
  if($.isFunction(v)) { v = v.call(this, obj); }
3039
  if(rule === "max_depth" && obj !== -1 && opts !== false && s.max_depth !== -2 && v !== 0) {
3040
- this._get_node(obj).parentsUntil(this.get_container(),"li").each(function (i) {
3041
- d = _this._check(rule, this, false);
 
 
 
 
3042
  if(d !== -1 && d - (i + 1) <= 0) { v = 0; return false; }
 
3043
  if(d >= 0 && (d - (i + 1) < v || v < 0) ) { v = d - (i + 1); }
 
 
3044
  });
3045
  }
3046
  return v;
@@ -3083,7 +3211,7 @@
3083
  },
3084
  create_node : function (obj, position, js, callback, is_loaded, skip_check) {
3085
  if(!skip_check && (is_loaded || this._is_loaded(obj))) {
3086
- var p = (position && position.match(/^before|after$/i)) ? this._get_parent(obj) : this._get_node(obj),
3087
  s = this._get_settings().types,
3088
  mc = this._check("max_children", p),
3089
  md = this._check("max_depth", p),
@@ -3104,7 +3232,7 @@
3104
  ch = p === -1 ? this.get_container().children("> ul > li").length : p.children("> ul > li").length;
3105
  if(ch + 1 > mc) { return false; }
3106
  }
3107
- if(s.max_depth !== -2 && md !== -1 && (md - 1) <= 0) { return false; }
3108
  }
3109
  return this.__call_old(true, obj, position, js, callback, is_loaded, skip_check);
3110
  }
@@ -3120,7 +3248,10 @@
3120
  (function ($) {
3121
  $.jstree.plugin("html_data", {
3122
  __init : function () {
3123
- this.data.html_data.original_container_html = this.get_container().html().replace(/<\/([^>]+)>\s+</ig,"</$1><").replace(/>\s+<([a-z]{1})/ig,"><$1");
 
 
 
3124
  },
3125
  defaults : {
3126
  data : false,
@@ -3138,12 +3269,19 @@
3138
  s = this.get_settings().html_data,
3139
  error_func = function () {},
3140
  success_func = function () {};
 
 
 
 
 
3141
  switch(!0) {
3142
  case (!s.data && !s.ajax):
3143
  if(!obj || obj == -1) {
3144
  this.get_container()
3145
- .html(this.data.html_data.original_container_html)
3146
- .find("li, a").filter(function () { return this.firstChild.tagName !== "INS"; }).prepend("<ins class='jstree-icon'>&#160;</ins>");
 
 
3147
  this.clean_node();
3148
  }
3149
  if(s_call) { s_call.call(this); }
@@ -3154,7 +3292,8 @@
3154
  if(!d.is("ul")) { d = $("<ul>").append(d); }
3155
  this.get_container()
3156
  .children("ul").empty().append(d.children())
3157
- .find("li, a").filter(function () { return this.firstChild.tagName !== "INS"; }).prepend("<ins class='jstree-icon'>&#160;</ins>");
 
3158
  this.clean_node();
3159
  }
3160
  if(s_call) { s_call.call(this); }
@@ -3166,6 +3305,7 @@
3166
  if(ef) { ef.call(this, x, t, e); }
3167
  if(obj != -1 && obj.length) {
3168
  obj.children(".jstree-loading").removeClass("jstree-loading");
 
3169
  if(t === "success" && s.correct_state) { obj.removeClass("jstree-open jstree-closed").addClass("jstree-leaf"); }
3170
  }
3171
  else {
@@ -3182,14 +3322,15 @@
3182
  if(d) {
3183
  d = $(d);
3184
  if(!d.is("ul")) { d = $("<ul>").append(d); }
3185
- if(obj == -1 || !obj) { this.get_container().children("ul").empty().append(d.children()).find("li, a").filter(function () { return this.firstChild.tagName !== "INS"; }).prepend("<ins class='jstree-icon'>&#160;</ins>"); }
3186
- else { obj.children(".jstree-loading").removeClass("jstree-loading"); obj.append(d).find("li, a").filter(function () { return this.firstChild.tagName !== "INS"; }).prepend("<ins class='jstree-icon'>&#160;</ins>"); }
3187
  this.clean_node(obj);
3188
  if(s_call) { s_call.call(this); }
3189
  }
3190
  else {
3191
  if(obj && obj !== -1) {
3192
  obj.children(".jstree-loading").removeClass("jstree-loading");
 
3193
  if(s.correct_state) {
3194
  obj.removeClass("jstree-open jstree-closed").addClass("jstree-leaf");
3195
  if(s_call) { s_call.call(this); }
@@ -3207,6 +3348,7 @@
3207
  s.ajax.error = error_func;
3208
  s.ajax.success = success_func;
3209
  if(!s.ajax.dataType) { s.ajax.dataType = "html"; }
 
3210
  if($.isFunction(s.ajax.data)) { s.ajax.data = s.ajax.data.call(this, obj); }
3211
  $.ajax(s.ajax);
3212
  break;
@@ -3229,10 +3371,10 @@
3229
  var s = this._get_settings().themeroller;
3230
  this.get_container()
3231
  .addClass("ui-widget-content")
3232
- .delegate("a","mouseenter", function () {
3233
  $(this).addClass(s.item_h);
3234
  })
3235
- .delegate("a","mouseleave", function () {
3236
  $(this).removeClass(s.item_h);
3237
  })
3238
  .bind("open_node.jstree create_node.jstree", $.proxy(function (e, data) {
@@ -3256,6 +3398,17 @@
3256
  this._themeroller(data.rslt.o);
3257
  }, this));
3258
  },
 
 
 
 
 
 
 
 
 
 
 
3259
  _fn : {
3260
  _themeroller : function (obj) {
3261
  var s = this._get_settings().themeroller;
@@ -3281,4 +3434,77 @@
3281
  $.vakata.css.add_sheet({ str : css_string });
3282
  });
3283
  })(jQuery);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3284
  //*/
8
  * http://www.opensource.org/licenses/mit-license.php
9
  * http://www.gnu.org/licenses/gpl.html
10
  *
11
+ * $Date: 2010-07-01 10:51:11 +0300 (четв, 01 юли 2010) $
12
+ * $Revision: 191 $
13
  */
14
 
15
+ /*jslint browser: true, onevar: true, undef: true, bitwise: true, strict: true */
16
  /*global window : false, clearInterval: false, clearTimeout: false, document: false, setInterval: false, setTimeout: false, jQuery: false, navigator: false, XSLTProcessor: false, DOMParser: false, XMLSerializer: false*/
17
 
18
  "use strict";
89
  var instances = [], // instance array (used by $.jstree.reference/create/focused)
90
  focused_instance = -1, // the index in the instance array of the currently focused instance
91
  plugins = {}, // list of included plugins
92
+ prepared_move = {}, // for the move plugin
93
+ is_ie6 = false;
94
 
95
  // jQuery plugin wrapper (thanks to jquery UI widget function)
96
  $.fn.jstree = function (settings) {
117
  var instance_id = $.data(this, "jstree-instance-id"),
118
  s = false;
119
  // if an instance already exists, destroy it first
120
+ if(typeof instance_id !== "undefined" && instances[instance_id]) { instances[instance_id].destroy(); }
121
  // push a new empty object to the instances array
122
  instance_id = parseInt(instances.push({}),10) - 1;
123
  // store the jstree instance id to the container element
258
  css_string = '' +
259
  '.jstree ul, .jstree li { display:block; margin:0 0 0 0; padding:0 0 0 0; list-style-type:none; } ' +
260
  '.jstree li { display:block; min-height:18px; line-height:18px; white-space:nowrap; margin-left:18px; } ' +
261
+ '.jstree-rtl li { margin-left:0; margin-right:18px; } ' +
262
  '.jstree > ul > li { margin-left:0px; } ' +
263
+ '.jstree-rtl > ul > li { margin-right:0px; } ' +
264
  '.jstree ins { display:inline-block; text-decoration:none; width:18px; height:18px; margin:0 0 0 0; padding:0; } ' +
265
  '.jstree a { display:inline-block; line-height:16px; height:16px; color:black; white-space:nowrap; text-decoration:none; padding:1px 2px; margin:0; } ' +
266
  '.jstree a:focus { outline: none; } ' +
267
  '.jstree a > ins { height:16px; width:16px; } ' +
268
  '.jstree a > .jstree-icon { margin-right:3px; } ' +
269
+ '.jstree-rtl a > .jstree-icon { margin-left:3px; margin-right:0; } ' +
270
  'li.jstree-open > ul { display:block; } ' +
271
  'li.jstree-closed > ul { display:none; } ';
272
  // Correct IE 6 (does not support the > CSS selector)
273
  if(/msie/.test(u) && parseInt(v, 10) == 6) {
274
+ is_ie6 = true;
275
  css_string += '' +
276
+ '.jstree li { height:18px; margin-left:0; margin-right:0; } ' +
277
  '.jstree li li { margin-left:18px; } ' +
278
+ '.jstree-rtl li li { margin-left:0px; margin-right:18px; } ' +
279
  'li.jstree-open ul { display:block; } ' +
280
  'li.jstree-closed ul { display:none !important; } ' +
281
+ '.jstree li a { display:inline; border-width:0 !important; padding:0px 2px !important; } ' +
282
+ '.jstree li a ins { height:16px; width:16px; margin-right:3px; } ' +
283
+ '.jstree-rtl li a ins { margin-right:0px; margin-left:3px; } ';
284
  }
285
  // Correct IE 7 (shifts anchor nodes onhover)
286
  if(/msie/.test(u) && parseInt(v, 10) == 7) {
297
  defaults : {
298
  html_titles : false,
299
  animation : 500,
300
+ initially_open : [],
301
+ rtl : false,
302
+ strings : {
303
+ loading : "Loading ...",
304
+ new_node : "New node"
305
+ }
306
  },
307
  _fn : {
308
  init : function () {
309
  this.set_focus();
310
+ if(this._get_settings().core.rtl) {
311
+ this.get_container().addClass("jstree-rtl").css("direction", "rtl");
312
+ }
313
+ this.get_container().html("<ul><li class='jstree-last jstree-leaf'><ins>&#160;</ins><a class='jstree-loading' href='#'><ins class='jstree-icon'>&#160;</ins>" + this._get_settings().core.strings.loading + "</a></li></ul>");
314
  this.data.core.li_height = this.get_container().find("ul li.jstree-closed, ul li.jstree-leaf").eq(0).height() || 18;
315
 
316
  this.get_container()
344
  _this = this;
345
 
346
  $.each(s.plugins, function (i, val) {
347
+ try { plugins[val].__destroy.apply(_this); } catch(err) { }
348
  });
349
  this.__callback();
350
  // set focus to another instance if this one is focused
449
 
450
  if(obj.hasClass("jstree-open")) { return obj.find("li:eq(0)"); }
451
  else if(obj.nextAll("li").size() > 0) { return obj.nextAll("li:eq(0)"); }
452
+ else { return obj.parentsUntil(".jstree","li").next("li").eq(0); }
453
  },
454
  _get_prev : function (obj, strict) {
455
  obj = this._get_node(obj);
462
  while(obj.hasClass("jstree-open")) { obj = obj.children("ul:eq(0)").children("li:last"); }
463
  return obj;
464
  }
465
+ else { var o = obj.parentsUntil(".jstree","li:eq(0)"); return o.length ? o : false; }
466
  },
467
  _get_parent : function (obj) {
468
  obj = this._get_node(obj);
469
  if(obj == -1 || !obj.length) { return false; }
470
+ var o = obj.parentsUntil(".jstree", "li:eq(0)");
471
  return o.length ? o : -1;
472
  },
473
  _get_children : function (obj) {
481
  _this = this;
482
  obj = this._get_node(obj);
483
  if(obj === -1 || !obj || !obj.length) { return false; }
484
+ obj.parentsUntil(".jstree", "li").each(function () {
485
  p.push( id_mode ? this.id : _this.get_text(this) );
486
  });
487
  p.reverse();
489
  return p;
490
  },
491
 
492
+ is_open : function (obj) { obj = this._get_node(obj); return obj && obj !== -1 && obj.hasClass("jstree-open"); },
493
+ is_closed : function (obj) { obj = this._get_node(obj); return obj && obj !== -1 && obj.hasClass("jstree-closed"); },
494
+ is_leaf : function (obj) { obj = this._get_node(obj); return obj && obj !== -1 && obj.hasClass("jstree-leaf"); },
495
  // open/close
496
  open_node : function (obj, callback, skip_animation) {
497
  obj = this._get_node(obj);
498
  if(!obj.length) { return false; }
499
+ if(!obj.hasClass("jstree-closed")) { if(callback) { callback.call(); } return false; }
500
+ var s = skip_animation || is_ie6 ? 0 : this._get_settings().core.animation,
501
  t = this;
502
  if(!this._is_loaded(obj)) {
503
  obj.children("a").addClass("jstree-loading");
506
  else {
507
  if(s) { obj.children("ul").css("display","none"); }
508
  obj.removeClass("jstree-closed").addClass("jstree-open").children("a").removeClass("jstree-loading");
509
+ if(s) { obj.children("ul").stop(true).slideDown(s, function () { this.style.display = ""; }); }
510
  this.__callback({ "obj" : obj });
511
  if(callback) { callback.call(); }
512
  }
513
  },
514
  close_node : function (obj, skip_animation) {
515
  obj = this._get_node(obj);
516
+ var s = skip_animation || is_ie6 ? 0 : this._get_settings().core.animation;
517
+ if(!obj.length || !obj.hasClass("jstree-open")) { return false; }
518
  if(s) { obj.children("ul").attr("style","display:block !important"); }
519
  obj.removeClass("jstree-open").addClass("jstree-closed");
520
+ if(s) { obj.children("ul").stop(true).slideUp(s, function () { this.style.display = ""; }); }
521
  this.__callback({ "obj" : obj });
522
  },
523
  toggle_node : function (obj) {
557
  obj = obj.is("li") ? obj.find("li").andSelf() : obj.find("li");
558
  obj.removeClass("jstree-last")
559
  .filter("li:last-child").addClass("jstree-last").end()
560
+ .filter(":has(li)")
561
  .not(".jstree-open").removeClass("jstree-leaf").addClass("jstree-closed");
562
+ obj.not(".jstree-open, .jstree-closed").addClass("jstree-leaf").children("ul").remove();
563
  this.__callback({ "obj" : obj });
564
  },
565
  // rollback
581
  obj = this._get_node(obj);
582
  position = typeof position === "undefined" ? "last" : position;
583
  var d = $("<li>"),
584
+ s = this._get_settings().core,
585
  tmp;
586
 
587
  if(obj !== -1 && !obj.length) { return false; }
593
  if(!js) { js = {}; }
594
  if(js.attr) { d.attr(js.attr); }
595
  if(js.state) { d.addClass("jstree-" + js.state); }
596
+ if(!js.data) { js.data = s.strings.new_node; }
597
  if(!$.isArray(js.data)) { tmp = js.data; js.data = []; js.data.push(tmp); }
598
  $.each(js.data, function (i, m) {
599
  tmp = $("<a>");
600
  if($.isFunction(m)) { m = m.call(this, js); }
601
+ if(typeof m == "string") { tmp.attr('href','#')[ s.html_titles ? "html" : "text" ](m); }
602
  else {
603
  if(!m.attr) { m.attr = {}; }
604
  if(!m.attr.href) { m.attr.href = '#'; }
605
+ tmp.attr(m.attr)[ s.html_titles ? "html" : "text" ](m.title);
606
  if(m.language) { tmp.addClass(m.language); }
607
  }
608
  tmp.prepend("<ins class='jstree-icon'>&#160;</ins>");
692
  var p = this._get_parent(obj), prev = this._get_prev(obj);
693
  obj = obj.remove();
694
  if(p !== -1 && p.find("> ul > li").length === 0) {
695
+ p.removeClass("jstree-open jstree-closed").addClass("jstree-leaf");
696
  }
697
  this.clean_node(p);
698
  this.__callback({ "obj" : obj, "prev" : prev });
731
  }
732
  else {
733
  if(!/^(before|after)$/.test(p.p) && !this._is_loaded(p.r)) {
734
+ return this.load_node(p.r, function () { this.prepare_move(o, r, pos, cb, true); });
735
  }
736
  switch(p.p) {
737
  case "before":
766
  if(cb) { cb.call(this, prepared_move); }
767
  },
768
  check_move : function () {
769
+ var obj = prepared_move, ret = true;
770
+ if(obj.or[0] === obj.o[0]) { return false; }
771
+ obj.o.each(function () {
772
+ if(obj.r.parentsUntil(".jstree").andSelf().filter("li").index(this) !== -1) { ret = false; return false; }
773
+ });
774
+ return ret;
775
  },
776
  move_node : function (obj, ref, position, is_copy, is_prepared, skip_check) {
777
  if(!is_prepared) {
868
  clk = (obj && obj.length) ? obj.find(".jstree-clicked") : [],
869
  _this = this;
870
  clk.each(function () { _this.deselect_node(this); });
871
+ if(s && clk.length) { this.select_node(data.rslt.prev); }
872
  }, this))
873
  .bind("move_node.jstree", $.proxy(function (event, data) {
874
  if(data.rslt.cy) {
1029
  _fn : {
1030
  _show_input : function (obj, callback) {
1031
  obj = this._get_node(obj);
1032
+ var rtl = this._get_settings().core.rtl,
1033
+ w = this._get_settings().crrm.input_width_limit,
1034
  w1 = obj.children("ins").width(),
1035
  w2 = obj.find("> a:visible > ins").width() * obj.find("> a:visible > ins").length,
1036
  t = this.get_text(obj),
1037
+ h1 = $("<div>", { css : { "position" : "absolute", "top" : "-200px", "left" : (rtl ? "0px" : "-1000px"), "visibility" : "hidden" } }).appendTo("body"),
1038
  h2 = obj.css("position","relative").append(
1039
  $("<input>", {
1040
  "value" : t,
1043
  "padding" : "0",
1044
  "border" : "1px solid silver",
1045
  "position" : "absolute",
1046
+ "left" : (rtl ? "auto" : (w1 + w2 + 4) + "px"),
1047
+ "right" : (rtl ? (w1 + w2 + 4) + "px" : "auto"),
1048
  "top" : "0px",
1049
  "height" : (this.data.core.li_height - 2) + "px",
1050
  "lineHeight" : (this.data.core.li_height - 2) + "px",
1126
  var s = this._get_settings().crrm.move;
1127
  if(!is_prepared) {
1128
  if(!position) { position = s.default_position; }
1129
+ if(position === "inside" && !s.default_position.match(/^(before|after)$/)) { position = s.default_position; }
1130
  return this.__call_old(true, obj, ref, position, is_copy, false, skip_check);
1131
  }
1132
  // if the move is already prepared
1156
  if(!this.data.crrm.ct_nodes && !this.data.crrm.cp_nodes) { return false; }
1157
  if(this.data.crrm.ct_nodes) { this.move_node(this.data.crrm.ct_nodes, obj); }
1158
  if(this.data.crrm.cp_nodes) { this.move_node(this.data.crrm.cp_nodes, obj, false, true); }
1159
+ this.data.crrm.cp_nodes = false;
1160
+ this.data.crrm.ct_nodes = false;
1161
  }
1162
  }
1163
  });
1252
  (function ($) {
1253
  var bound = [];
1254
  function exec(i, event) {
1255
+ var f = $.jstree._focused(), tmp;
1256
  if(f && f.data && f.data.hotkeys && f.data.hotkeys.enabled) {
1257
+ tmp = f._get_settings().hotkeys[i];
1258
  if(tmp) { return tmp.call(f, event); }
1259
  }
1260
  }
1353
  var s = this.get_settings().json_data, d,
1354
  error_func = function () {},
1355
  success_func = function () {};
1356
+ obj = this._get_node(obj);
1357
+ if(obj && obj !== -1) {
1358
+ if(obj.data("jstree-is-loading")) { return; }
1359
+ else { obj.data("jstree-is-loading",true); }
1360
+ }
1361
  switch(!0) {
1362
  case (!s.data && !s.ajax): throw "Neither data nor ajax settings supplied.";
1363
  case (!!s.data && !s.ajax) || (!!s.data && !!s.ajax && (!obj || obj === -1)):
1374
  if(s_call) { s_call.call(this); }
1375
  break;
1376
  case (!s.data && !!s.ajax) || (!!s.data && !!s.ajax && obj && obj !== -1):
 
1377
  error_func = function (x, t, e) {
1378
  var ef = this.get_settings().json_data.ajax.error;
1379
  if(ef) { ef.call(this, x, t, e); }
1380
  if(obj != -1 && obj.length) {
1381
  obj.children(".jstree-loading").removeClass("jstree-loading");
1382
+ obj.data("jstree-is-loading",false);
1383
  if(t === "success" && s.correct_state) { obj.removeClass("jstree-open jstree-closed").addClass("jstree-leaf"); }
1384
  }
1385
  else {
1396
  d = this._parse_json(d);
1397
  if(d) {
1398
  if(obj === -1 || !obj) { this.get_container().children("ul").empty().append(d.children()); }
1399
+ else { obj.append(d).children(".jstree-loading").removeClass("jstree-loading"); obj.data("jstree-is-loading",false); }
1400
  this.clean_node(obj);
1401
  if(s_call) { s_call.call(this); }
1402
  }
1409
  }
1410
  else {
1411
  obj.children(".jstree-loading").removeClass("jstree-loading");
1412
+ obj.data("jstree-is-loading",false);
1413
  if(s.correct_state) {
1414
  obj.removeClass("jstree-open jstree-closed").addClass("jstree-leaf");
1415
  if(s_call) { s_call.call(this); }
1421
  s.ajax.error = error_func;
1422
  s.ajax.success = success_func;
1423
  if(!s.ajax.dataType) { s.ajax.dataType = "json"; }
1424
+ if($.isFunction(s.ajax.url)) { s.ajax.url = s.ajax.url.call(this, obj); }
1425
  if($.isFunction(s.ajax.data)) { s.ajax.data = s.ajax.data.call(this, obj); }
1426
  $.ajax(s.ajax);
1427
  break;
1542
  }
1543
  tmp2 = { attr : { }, title : _this.get_text(t, lang) };
1544
  $.each(a_attr, function (k, z) {
1545
+ tmp1.attr[z] = (t.attr(z) || "").replace(/jstree[^ ]*|$/ig,'');
1546
  });
1547
  $.each(s.languages, function (k, z) {
1548
  if(t.hasClass(z)) { tmp2.language = z; return true; }
1701
  }
1702
  if(!!s.save_selected) {
1703
  tmp = $.cookie(s.save_selected);
1704
+ if(tmp && tmp.length && this.data.ui) { this.data.ui.to_select = tmp.split(","); }
1705
  }
1706
  this.get_container()
1707
  .one( ( this.data.ui ? "reselect" : "reopen" ) + ".jstree", $.proxy(function () {
1798
  (function ($) {
1799
  var o = false,
1800
  r = false,
1801
+ m = false,
1802
+ sli = false,
1803
+ sti = false,
1804
+ dir1 = false,
1805
+ dir2 = false;
1806
  $.vakata.dnd = {
1807
  is_down : false,
1808
  is_drag : false,
1809
  helper : false,
1810
+ scroll_spd : 10,
1811
  init_x : 0,
1812
  init_y : 0,
1813
  threshold : 5,
1839
  }
1840
  else { return; }
1841
  }
1842
+
1843
+ // maybe use a scrolling parent element instead of document?
1844
+ if(e.type === "mousemove") { // thought of adding scroll in order to move the helper, but mouse poisition is n/a
1845
+ var d = $(document), t = d.scrollTop(), l = d.scrollLeft();
1846
+ if(e.pageY - t < 20) {
1847
+ if(sti && dir1 === "down") { clearInterval(sti); sti = false; }
1848
+ if(!sti) { dir1 = "up"; sti = setInterval(function () { $(document).scrollTop($(document).scrollTop() - $.vakata.dnd.scroll_spd); }, 150); }
1849
+ }
1850
+ else {
1851
+ if(sti && dir1 === "up") { clearInterval(sti); sti = false; }
1852
+ }
1853
+ if($(window).height() - (e.pageY - t) < 20) {
1854
+ if(sti && dir1 === "up") { clearInterval(sti); sti = false; }
1855
+ if(!sti) { dir1 = "down"; sti = setInterval(function () { $(document).scrollTop($(document).scrollTop() + $.vakata.dnd.scroll_spd); }, 150); }
1856
+ }
1857
+ else {
1858
+ if(sti && dir1 === "down") { clearInterval(sti); sti = false; }
1859
+ }
1860
+
1861
+ if(e.pageX - l < 20) {
1862
+ if(sli && dir2 === "right") { clearInterval(sli); sli = false; }
1863
+ if(!sli) { dir2 = "left"; sli = setInterval(function () { $(document).scrollLeft($(document).scrollLeft() - $.vakata.dnd.scroll_spd); }, 150); }
1864
+ }
1865
+ else {
1866
+ if(sli && dir2 === "left") { clearInterval(sli); sli = false; }
1867
+ }
1868
+ if($(window).width() - (e.pageX - l) < 20) {
1869
+ if(sli && dir2 === "left") { clearInterval(sli); sli = false; }
1870
+ if(!sli) { dir2 = "right"; sli = setInterval(function () { $(document).scrollLeft($(document).scrollLeft() + $.vakata.dnd.scroll_spd); }, 150); }
1871
+ }
1872
+ else {
1873
+ if(sli && dir2 === "right") { clearInterval(sli); sli = false; }
1874
+ }
1875
+ }
1876
+
1877
  $.vakata.dnd.helper.css({ left : (e.pageX + 5) + "px", top : (e.pageY + 10) + "px" });
1878
  $(document).triggerHandler("drag.vakata", { "event" : e, "data" : $.vakata.dnd.user_data });
1879
  },
1890
  }
1891
  };
1892
  $(function() {
1893
+ var css_string = '#vakata-dragged { display:block; margin:0 0 0 0; padding:4px 4px 4px 24px; position:absolute; top:-2000px; line-height:16px; z-index:10000; } ';
1894
  $.vakata.css.add_sheet({ str : css_string });
1895
  });
1896
 
1930
  var cnt = this.get_container()[0];
1931
 
1932
  // Horizontal scroll
1933
+ if(e.pageX + 24 > this.data.dnd.cof.left + this.data.dnd.cw) {
1934
  if(this.data.dnd.i1) { clearInterval(this.data.dnd.i1); }
1935
+ this.data.dnd.i1 = setInterval($.proxy(function () { this.scrollLeft += $.vakata.dnd.scroll_spd; }, cnt), 100);
1936
  }
1937
+ else if(e.pageX - 24 < this.data.dnd.cof.left) {
1938
  if(this.data.dnd.i1) { clearInterval(this.data.dnd.i1); }
1939
+ this.data.dnd.i1 = setInterval($.proxy(function () { this.scrollLeft -= $.vakata.dnd.scroll_spd; }, cnt), 100);
1940
  }
1941
  else {
1942
  if(this.data.dnd.i1) { clearInterval(this.data.dnd.i1); }
1943
  }
1944
 
1945
  // Vertical scroll
1946
+ if(e.pageY + 24 > this.data.dnd.cof.top + this.data.dnd.ch) {
1947
  if(this.data.dnd.i2) { clearInterval(this.data.dnd.i2); }
1948
+ this.data.dnd.i2 = setInterval($.proxy(function () { this.scrollTop += $.vakata.dnd.scroll_spd; }, cnt), 100);
1949
  }
1950
+ else if(e.pageY - 24 < this.data.dnd.cof.top) {
1951
  if(this.data.dnd.i2) { clearInterval(this.data.dnd.i2); }
1952
+ this.data.dnd.i2 = setInterval($.proxy(function () { this.scrollTop -= $.vakata.dnd.scroll_spd; }, cnt), 100);
1953
  }
1954
  else {
1955
  if(this.data.dnd.i2) { clearInterval(this.data.dnd.i2); }
2013
  this.data.dnd.to2 = false;
2014
  this.data.dnd.active = false;
2015
  this.data.dnd.foreign = false;
2016
+ if(m) { m.css({ "top" : "-2000px" }); }
2017
  }, this))
2018
  .bind("drag_start.vakata", $.proxy(function (e, data) {
2019
  if(data.data.jstree) {
2036
  }
2037
  $.vakata.dnd.helper.children("ins").attr("class","jstree-invalid");
2038
  var cnt = this.get_container();
2039
+ this.data.dnd.cof = cnt.offset();
2040
  this.data.dnd.cw = parseInt(cnt.width(),10);
2041
  this.data.dnd.ch = parseInt(cnt.height(),10);
2042
  this.data.dnd.foreign = true;
2075
  },
2076
  _fn : {
2077
  dnd_prepare : function () {
2078
+ if(!r || !r.length) { return; }
2079
  this.data.dnd.off = r.offset();
2080
+ if(this._get_settings().core.rtl) {
2081
+ this.data.dnd.off.right = this.data.dnd.off.left + r.width();
2082
+ }
2083
  if(this.data.dnd.foreign) {
2084
  var a = this._get_settings().dnd.drag_check.call(this, { "o" : o, "r" : r });
2085
  this.data.dnd.after = a.after;
2105
  dnd_show : function () {
2106
  if(!this.data.dnd.prepared) { return; }
2107
  var o = ["before","inside","after"],
2108
+ r = false,
2109
+ rtl = this._get_settings().core.rtl,
2110
+ pos;
2111
  if(this.data.dnd.w < this.data.core.li_height/3) { o = ["before","inside","after"]; }
2112
  else if(this.data.dnd.w <= this.data.core.li_height*2/3) {
2113
  o = this.data.dnd.w < this.data.core.li_height/2 ? ["inside","before","after"] : ["inside","after","before"];
2121
  }
2122
  }, this));
2123
  if(r === false) { $.vakata.dnd.helper.children("ins").attr("class","jstree-invalid"); }
2124
+
2125
+ pos = rtl ? (this.data.dnd.off.right - 18) : (this.data.dnd.off.left + 10);
2126
  switch(r) {
2127
  case "before":
2128
+ m.css({ "left" : pos + "px", "top" : (this.data.dnd.off.top - 6) + "px" }).show();
2129
  break;
2130
  case "after":
2131
+ m.css({ "left" : pos + "px", "top" : (this.data.dnd.off.top + this.data.core.li_height - 7) + "px" }).show();
2132
  break;
2133
  case "inside":
2134
+ m.css({ "left" : pos + ( rtl ? -4 : 4) + "px", "top" : (this.data.dnd.off.top + this.data.core.li_height/2 - 5) + "px" }).show();
2135
  break;
2136
  default:
2137
  m.hide();
2171
  }
2172
  if(s.open_timeout) {
2173
  if(this.data.dnd.to2) { clearTimeout(this.data.dnd.to2); }
2174
+ if(r && r.length && r.hasClass("jstree-closed")) {
2175
  // if the node is closed - open it, then recalculate
2176
  this.data.dnd.to2 = setTimeout($.proxy(this.dnd_open, this), s.open_timeout);
2177
  }
2178
  }
2179
  else {
2180
+ if(r && r.length && r.hasClass("jstree-closed")) {
2181
  this.dnd_open();
2182
  }
2183
  }
2203
  '#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; } ' +
2204
  '#vakata-dragged .jstree-ok { background:green; } ' +
2205
  '#vakata-dragged .jstree-invalid { background:red; } ' +
2206
+ '#jstree-marker { padding:0; margin:0; line-height:12px; font-size:1px; overflow:hidden; height:12px; width:8px; position:absolute; top:-30px; z-index:10000; background-repeat:no-repeat; display:none; background-color:silver; } ';
2207
  $.vakata.css.add_sheet({ str : css_string });
2208
  m = $("<div>").attr({ id : "jstree-marker" }).hide().appendTo("body");
2209
  $(document).bind("drag_start.vakata", function (e, data) {
2227
  (function ($) {
2228
  $.jstree.plugin("checkbox", {
2229
  __init : function () {
 
2230
  this.select_node = this.deselect_node = this.deselect_all = $.noop;
2231
  this.get_selected = this.get_checked;
2232
 
2233
  this.get_container()
2234
+ .bind("open_node.jstree create_node.jstree clean_node.jstree", $.proxy(function (e, data) {
2235
  this._prepare_checkboxes(data.rslt.obj);
2236
  }, this))
2237
  .bind("loaded.jstree", $.proxy(function (e) {
2238
  this._prepare_checkboxes();
2239
  }, this))
 
 
 
2240
  .delegate("a", "click.jstree", $.proxy(function (e) {
2241
+ if(this._get_node(e.target).hasClass("jstree-checked")) { this.uncheck_node(e.target); }
2242
+ else { this.check_node(e.target); }
2243
+ if(this.data.ui) { this.save_selected(); }
2244
  if(this.data.cookies) { this.save_cookie("select_node"); }
2245
  e.preventDefault();
2246
  }, this));
2247
  },
2248
+ __destroy : function () {
2249
+ this.get_container().find(".jstree-checkbox").remove();
2250
+ },
2251
  _fn : {
2252
  _prepare_checkboxes : function (obj) {
2253
  obj = !obj || obj == -1 ? this.get_container() : this._get_node(obj);
2254
+ var c, _this = this, t;
2255
+ obj.each(function () {
2256
+ t = $(this);
2257
+ c = t.is("li") && t.hasClass("jstree-checked") ? "jstree-checked" : "jstree-unchecked";
2258
+ t.find("a").not(":has(.jstree-checkbox)").prepend("<ins class='jstree-checkbox'>&#160;</ins>").parent().not(".jstree-checked, .jstree-unchecked").addClass(c);
2259
+ });
2260
+ if(obj.is("li")) { this._repair_state(obj); }
2261
+ else { obj.find("> ul > li").each(function () { _this._repair_state(this); }); }
2262
  },
2263
  change_state : function (obj, state) {
2264
  obj = this._get_node(obj);
2265
  state = (state === false || state === true) ? state : obj.hasClass("jstree-checked");
2266
  if(state) { obj.find("li").andSelf().removeClass("jstree-checked jstree-undetermined").addClass("jstree-unchecked"); }
2267
+ else {
2268
+ obj.find("li").andSelf().removeClass("jstree-unchecked jstree-undetermined").addClass("jstree-checked");
2269
+ if(this.data.ui) { this.data.ui.last_selected = obj; }
2270
+ this.data.checkbox.last_selected = obj;
2271
+ }
2272
+ obj.parentsUntil(".jstree", "li").each(function () {
2273
  var $this = $(this);
2274
  if(state) {
2275
  if($this.children("ul").children(".jstree-checked, .jstree-undetermined").length) {
2276
+ $this.parentsUntil(".jstree", "li").andSelf().removeClass("jstree-checked jstree-unchecked").addClass("jstree-undetermined");
2277
  return false;
2278
  }
2279
  else {
2282
  }
2283
  else {
2284
  if($this.children("ul").children(".jstree-unchecked, .jstree-undetermined").length) {
2285
+ $this.parentsUntil(".jstree", "li").andSelf().removeClass("jstree-checked jstree-unchecked").addClass("jstree-undetermined");
2286
  return false;
2287
  }
2288
  else {
2290
  }
2291
  }
2292
  });
2293
+ if(this.data.ui) { this.data.ui.selected = this.get_checked(); }
2294
  this.__callback(obj);
2295
  },
2296
  check_node : function (obj) {
2339
  else if(a === 0 && b === 0) { this.uncheck_node(obj); }
2340
  else if(a === c) { this.check_node(obj); }
2341
  else {
2342
+ obj.parentsUntil(".jstree","li").removeClass("jstree-checked jstree-unchecked").addClass("jstree-undetermined");
2343
  }
2344
  },
2345
  reselect : function () {
2346
+ if(this.data.ui) {
2347
+ var _this = this,
2348
+ s = this.data.ui.to_select;
2349
+ s = $.map($.makeArray(s), function (n) { return "#" + n.toString().replace(/^#/,"").replace('\\/','/').replace('/','\\/'); });
2350
+ this.deselect_all();
2351
+ $.each(s, function (i, val) { _this.check_node(val); });
2352
+ this.__callback();
2353
+ }
2354
  }
2355
  }
2356
  });
2373
  setTimeout( (function (xm, xs, callback) {
2374
  return function () {
2375
  callback.call(null, xm.transformNode(xs.XMLDocument));
2376
+ setTimeout( (function (xm, xs) { return function () { jQuery("body").remove(xm).remove(xs); }; })(xm, xs), 200);
2377
  };
2378
  }) (xm, xs, callback), 100);
2379
  return true;
2545
  load_node : function (obj, s_call, e_call) { var _this = this; this.load_node_xml(obj, function () { _this.__callback({ "obj" : obj }); s_call.call(this); }, e_call); },
2546
  _is_loaded : function (obj) {
2547
  var s = this._get_settings().xml_data;
2548
+ obj = this._get_node(obj);
2549
  return obj == -1 || !obj || !s.ajax || obj.is(".jstree-open, .jstree-leaf") || obj.children("ul").children("li").size() > 0;
2550
  },
2551
  load_node_xml : function (obj, s_call, e_call) {
2552
  var s = this.get_settings().xml_data,
2553
  error_func = function () {},
2554
  success_func = function () {};
2555
+
2556
+ obj = this._get_node(obj);
2557
+ if(obj && obj !== -1) {
2558
+ if(obj.data("jstree-is-loading")) { return; }
2559
+ else { obj.data("jstree-is-loading",true); }
2560
+ }
2561
  switch(!0) {
2562
  case (!s.data && !s.ajax): throw "Neither data nor ajax settings supplied.";
2563
  case (!!s.data && !s.ajax) || (!!s.data && !!s.ajax && (!obj || obj === -1)):
2569
  d = $(d);
2570
  this.get_container().children("ul").empty().append(d.children());
2571
  if(s.clean_node) { this.clean_node(obj); }
2572
+ if(s_call) { s_call.call(this); }
2573
  }
2574
  }
2575
  else {
2576
+ if(s.correct_state) {
2577
+ this.get_container().children("ul").empty();
2578
+ if(s_call) { s_call.call(this); }
2579
+ }
2580
  }
2581
  }, this));
2582
  }
 
2583
  break;
2584
  case (!s.data && !!s.ajax) || (!!s.data && !!s.ajax && obj && obj !== -1):
 
2585
  error_func = function (x, t, e) {
2586
  var ef = this.get_settings().xml_data.ajax.error;
2587
  if(ef) { ef.call(this, x, t, e); }
2588
  if(obj !== -1 && obj.length) {
2589
  obj.children(".jstree-loading").removeClass("jstree-loading");
2590
+ obj.data("jstree-is-loading",false);
2591
  if(t === "success" && s.correct_state) { obj.removeClass("jstree-open jstree-closed").addClass("jstree-leaf"); }
2592
  }
2593
  else {
2608
  if(d.length > 10) {
2609
  d = $(d);
2610
  if(obj === -1 || !obj) { this.get_container().children("ul").empty().append(d.children()); }
2611
+ else { obj.children(".jstree-loading").removeClass("jstree-loading"); obj.append(d); obj.data("jstree-is-loading",false); }
2612
  if(s.clean_node) { this.clean_node(obj); }
2613
  if(s_call) { s_call.call(this); }
2614
  }
2615
  else {
2616
  if(obj && obj !== -1) {
2617
+ obj.children(".jstree-loading").removeClass("jstree-loading");
2618
+ obj.data("jstree-is-loading",false);
2619
  if(s.correct_state) {
2620
  obj.removeClass("jstree-open jstree-closed").addClass("jstree-leaf");
2621
  if(s_call) { s_call.call(this); }
2635
  s.ajax.error = error_func;
2636
  s.ajax.success = success_func;
2637
  if(!s.ajax.dataType) { s.ajax.dataType = "xml"; }
2638
+ if($.isFunction(s.ajax.url)) { s.ajax.url = s.ajax.url.call(this, obj); }
2639
+ if($.isFunction(s.ajax.data)) { s.ajax.data = s.ajax.data.call(this, obj); }
2640
  $.ajax(s.ajax);
2641
  break;
2642
  }
2655
  obj = this._get_node(obj);
2656
  if(!obj || obj === -1) { obj = this.get_container().find("> ul > li"); }
2657
  li_attr = $.isArray(li_attr) ? li_attr : [ "id", "class" ];
2658
+ if(!is_callback && this.data.types && $.inArray(s.types.type_attr, li_attr) === -1) { li_attr.push(s.types.type_attr); }
2659
 
2660
  a_attr = $.isArray(a_attr) ? a_attr : [ ];
2661
 
2681
  }
2682
  if(a_attr.length) {
2683
  $.each(a_attr, function (k, z) {
2684
+ result += " " + z + "=\"" + (tmp1.attr(z) || "").replace(/jstree[^ ]*|$/ig,'') + "\"";
2685
  });
2686
  }
2687
  if(tmp1.children("ins").get(0).className.replace(/jstree[^ ]*|$/ig,'').replace(/^\s+$/ig,"").length) {
2698
  tmp2 = li[0].id;
2699
  li = li.find("> ul > li");
2700
  if(li.length) { tmp2 = _this.get_xml(tp, li, li_attr, a_attr, tmp2); }
2701
+ else { tmp2 = ""; }
2702
  if(tp == "nest") { result += tmp2; }
2703
  result += "</item>";
2704
  if(tp == "flat") { result += tmp2; }
2731
  },
2732
  _fn : {
2733
  search : function (str, skip_async) {
2734
+ if(str === "") { return; }
2735
  var s = this.get_settings().search,
2736
  t = this,
2737
  error_func = function () { },
2750
  s.ajax.context = this;
2751
  s.ajax.error = error_func;
2752
  s.ajax.success = success_func;
2753
+ if($.isFunction(s.ajax.url)) { s.ajax.url = s.ajax.url.call(this, str); }
2754
  if($.isFunction(s.ajax.data)) { s.ajax.data = s.ajax.data.call(this, str); }
2755
  if(!s.ajax.data) { s.ajax.data = { "search_string" : str }; }
2756
  if(!s.ajax.dataType || /^json/.exec(s.ajax.dataType)) { s.ajax.dataType = "json"; }
2803
  cnt : $("<div id='vakata-contextmenu'>"),
2804
  vis : false,
2805
  tgt : false,
2806
+ par : false,
2807
  func : false,
2808
  data : false,
2809
+ show : function (s, t, x, y, d, p) {
2810
  var html = $.vakata.context.parse(s), h, w;
2811
  if(!html) { return; }
2812
  $.vakata.context.vis = true;
2813
  $.vakata.context.tgt = t;
2814
+ $.vakata.context.par = p || t || null;
2815
  $.vakata.context.data = d || null;
2816
  $.vakata.context.cnt
2817
  .html(html)
2851
  $(document).triggerHandler("context_hide.vakata");
2852
  },
2853
  parse : function (s, is_callback) {
2854
+ if(!s) { return false; }
2855
  var str = "",
2856
+ tmp = false,
2857
+ was_sep = true;
2858
  if(!is_callback) { $.vakata.context.func = {}; }
2859
  str += "<ul>";
2860
  $.each(s, function (i, val) {
2861
  if(!val) { return true; }
2862
  $.vakata.context.func[i] = val.action;
2863
+ if(!was_sep && val.separator_before) {
2864
  str += "<li class='vakata-separator vakata-separator-before'></li>";
2865
  }
2866
+ was_sep = false;
2867
+ str += "<li class='" + (val._class || "") + (val._disabled ? " jstree-contextmenu-disabled " : "") + "'><ins ";
2868
  if(val.icon && val.icon.indexOf("/") === -1) { str += " class='" + val.icon + "' "; }
2869
  if(val.icon && val.icon.indexOf("/") !== -1) { str += " style='background:url(" + val.icon + ") center center no-repeat;' "; }
2870
  str += ">&#160;</ins><a href='#' rel='" + i + "'>";
2879
  str += "</li>";
2880
  if(val.separator_after) {
2881
  str += "<li class='vakata-separator vakata-separator-after'></li>";
2882
+ was_sep = true;
2883
  }
2884
  });
2885
+ str = str.replace(/<li class\='vakata-separator vakata-separator-after'\><\/li\>$/,"");
2886
  str += "</ul>";
2887
  return str.length > 10 ? str : false;
2888
  },
2889
  exec : function (i) {
2890
  if($.isFunction($.vakata.context.func[i])) {
2891
+ $.vakata.context.func[i].call($.vakata.context.data, $.vakata.context.par);
2892
  return true;
2893
  }
2894
  else { return false; }
2911
  $.vakata.context.cnt
2912
  .delegate("a","click", function (e) { e.preventDefault(); })
2913
  .delegate("a","mouseup", function (e) {
2914
+ if(!$(this).parent().hasClass("jstree-contextmenu-disabled") && $.vakata.context.exec($(this).attr("rel"))) {
2915
  $.vakata.context.hide();
2916
  }
2917
+ else { $(this).blur(); }
2918
  })
2919
  .delegate("a","mouseover", function () {
2920
  $.vakata.context.cnt.find(".vakata-hover").removeClass("vakata-hover");
3051
  }
3052
  if($.isFunction(s.items)) { s.items = s.items.call(this, obj); }
3053
  this.data.contextmenu = true;
3054
+ $.vakata.context.show(s.items, a, x, y, this, obj);
3055
  if(this.data.themes) { $.vakata.context.cnt.attr("class", "jstree-" + this.data.themes.theme + "-context"); }
3056
  }
3057
  }
3097
  if($.inArray(data.func, this.data.types.attach_to) !== -1) {
3098
  var s = this._get_settings().types.types,
3099
  t = this._get_type(data.args[0]);
3100
+ if(
3101
+ (
3102
+ (s[t] && typeof s[t][data.func] !== "undefined") ||
3103
+ (s["default"] && typeof s["default"][data.func] !== "undefined")
3104
+ ) && !this._check(data.func, data.args[0])
3105
+ ) {
3106
  e.stopImmediatePropagation();
3107
  return false;
3108
  }
3158
  }
3159
  if($.isFunction(v)) { v = v.call(this, obj); }
3160
  if(rule === "max_depth" && obj !== -1 && opts !== false && s.max_depth !== -2 && v !== 0) {
3161
+ // also include the node itself - otherwise if root node it is not checked
3162
+ this._get_node(obj).children("a:eq(0)").parentsUntil(".jstree","li").each(function (i) {
3163
+ // check if current depth already exceeds global tree depth
3164
+ if(s.max_depth !== -1 && s.max_depth - (i + 1) <= 0) { v = 0; return false; }
3165
+ d = (i === 0) ? v : _this._check(rule, this, false);
3166
+ // check if current node max depth is already matched or exceeded
3167
  if(d !== -1 && d - (i + 1) <= 0) { v = 0; return false; }
3168
+ // otherwise - set the max depth to the current value minus current depth
3169
  if(d >= 0 && (d - (i + 1) < v || v < 0) ) { v = d - (i + 1); }
3170
+ // if the global tree depth exists and it minus the nodes calculated so far is less than `v` or `v` is unlimited
3171
+ if(s.max_depth >= 0 && (s.max_depth - (i + 1) < v || v < 0) ) { v = s.max_depth - (i + 1); }
3172
  });
3173
  }
3174
  return v;
3211
  },
3212
  create_node : function (obj, position, js, callback, is_loaded, skip_check) {
3213
  if(!skip_check && (is_loaded || this._is_loaded(obj))) {
3214
+ var p = (position && position.match(/^before|after$/i) && obj !== -1) ? this._get_parent(obj) : this._get_node(obj),
3215
  s = this._get_settings().types,
3216
  mc = this._check("max_children", p),
3217
  md = this._check("max_depth", p),
3232
  ch = p === -1 ? this.get_container().children("> ul > li").length : p.children("> ul > li").length;
3233
  if(ch + 1 > mc) { return false; }
3234
  }
3235
+ if(s.max_depth !== -2 && md !== -1 && (md - 1) < 0) { return false; }
3236
  }
3237
  return this.__call_old(true, obj, position, js, callback, is_loaded, skip_check);
3238
  }
3248
  (function ($) {
3249
  $.jstree.plugin("html_data", {
3250
  __init : function () {
3251
+ // this used to use html() and clean the whitespace, but this way any attached data was lost
3252
+ this.data.html_data.original_container_html = this.get_container().find(" > ul > li").clone(true);
3253
+ // remove white space from LI node - otherwise nodes appear a bit to the right
3254
+ this.data.html_data.original_container_html.find("li").andSelf().contents().filter(function() { return this.nodeType == 3; }).remove();
3255
  },
3256
  defaults : {
3257
  data : false,
3269
  s = this.get_settings().html_data,
3270
  error_func = function () {},
3271
  success_func = function () {};
3272
+ obj = this._get_node(obj);
3273
+ if(obj && obj !== -1) {
3274
+ if(obj.data("jstree-is-loading")) { return; }
3275
+ else { obj.data("jstree-is-loading",true); }
3276
+ }
3277
  switch(!0) {
3278
  case (!s.data && !s.ajax):
3279
  if(!obj || obj == -1) {
3280
  this.get_container()
3281
+ .children("ul").empty()
3282
+ .append(this.data.html_data.original_container_html)
3283
+ .find("li, a").filter(function () { return this.firstChild.tagName !== "INS"; }).prepend("<ins class='jstree-icon'>&#160;</ins>").end()
3284
+ .filter("a").children("ins:first-child").not(".jstree-icon").addClass("jstree-icon");
3285
  this.clean_node();
3286
  }
3287
  if(s_call) { s_call.call(this); }
3292
  if(!d.is("ul")) { d = $("<ul>").append(d); }
3293
  this.get_container()
3294
  .children("ul").empty().append(d.children())
3295
+ .find("li, a").filter(function () { return this.firstChild.tagName !== "INS"; }).prepend("<ins class='jstree-icon'>&#160;</ins>").end()
3296
+ .filter("a").children("ins:first-child").not(".jstree-icon").addClass("jstree-icon");
3297
  this.clean_node();
3298
  }
3299
  if(s_call) { s_call.call(this); }
3305
  if(ef) { ef.call(this, x, t, e); }
3306
  if(obj != -1 && obj.length) {
3307
  obj.children(".jstree-loading").removeClass("jstree-loading");
3308
+ obj.data("jstree-is-loading",false);
3309
  if(t === "success" && s.correct_state) { obj.removeClass("jstree-open jstree-closed").addClass("jstree-leaf"); }
3310
  }
3311
  else {
3322
  if(d) {
3323
  d = $(d);
3324
  if(!d.is("ul")) { d = $("<ul>").append(d); }
3325
+ if(obj == -1 || !obj) { this.get_container().children("ul").empty().append(d.children()).find("li, a").filter(function () { return this.firstChild.tagName !== "INS"; }).prepend("<ins class='jstree-icon'>&#160;</ins>").end().filter("a").children("ins:first-child").not(".jstree-icon").addClass("jstree-icon"); }
3326
+ else { obj.children(".jstree-loading").removeClass("jstree-loading"); obj.append(d).find("li, a").filter(function () { return this.firstChild.tagName !== "INS"; }).prepend("<ins class='jstree-icon'>&#160;</ins>").end().filter("a").children("ins:first-child").not(".jstree-icon").addClass("jstree-icon"); obj.data("jstree-is-loading",false); }
3327
  this.clean_node(obj);
3328
  if(s_call) { s_call.call(this); }
3329
  }
3330
  else {
3331
  if(obj && obj !== -1) {
3332
  obj.children(".jstree-loading").removeClass("jstree-loading");
3333
+ obj.data("jstree-is-loading",false);
3334
  if(s.correct_state) {
3335
  obj.removeClass("jstree-open jstree-closed").addClass("jstree-leaf");
3336
  if(s_call) { s_call.call(this); }
3348
  s.ajax.error = error_func;
3349
  s.ajax.success = success_func;
3350
  if(!s.ajax.dataType) { s.ajax.dataType = "html"; }
3351
+ if($.isFunction(s.ajax.url)) { s.ajax.url = s.ajax.url.call(this, obj); }
3352
  if($.isFunction(s.ajax.data)) { s.ajax.data = s.ajax.data.call(this, obj); }
3353
  $.ajax(s.ajax);
3354
  break;
3371
  var s = this._get_settings().themeroller;
3372
  this.get_container()
3373
  .addClass("ui-widget-content")
3374
+ .delegate("a","mouseenter.jstree", function () {
3375
  $(this).addClass(s.item_h);
3376
  })
3377
+ .delegate("a","mouseleave.jstree", function () {
3378
  $(this).removeClass(s.item_h);
3379
  })
3380
  .bind("open_node.jstree create_node.jstree", $.proxy(function (e, data) {
3398
  this._themeroller(data.rslt.o);
3399
  }, this));
3400
  },
3401
+ __destroy : function () {
3402
+ var s = this._get_settings().themeroller,
3403
+ c = [ "ui-icon" ];
3404
+ $.each(s, function (i, v) {
3405
+ v = v.split(" ");
3406
+ if(v.length) { c = c.concat(v); }
3407
+ });
3408
+ this.get_container()
3409
+ .removeClass("ui-widget-content")
3410
+ .find("." + c.join(", .")).removeClass(c.join(" "));
3411
+ },
3412
  _fn : {
3413
  _themeroller : function (obj) {
3414
  var s = this._get_settings().themeroller;
3434
  $.vakata.css.add_sheet({ str : css_string });
3435
  });
3436
  })(jQuery);
3437
+ //*/
3438
+
3439
+ /*
3440
+ * jsTree unique plugin 1.0
3441
+ * Forces different names amongst siblings (still a bit experimental)
3442
+ * NOTE: does not check language versions (it will not be possible to have nodes with the same title, even in different languages)
3443
+ */
3444
+ (function ($) {
3445
+ $.jstree.plugin("unique", {
3446
+ __init : function () {
3447
+ this.get_container()
3448
+ .bind("before.jstree", $.proxy(function (e, data) {
3449
+ var nms = [], res = true, p, t;
3450
+ if(data.func == "move_node") {
3451
+ // obj, ref, position, is_copy, is_prepared, skip_check
3452
+ if(data.args[4] === true) {
3453
+ if(data.args[0].o && data.args[0].o.length) {
3454
+ data.args[0].o.children("a").each(function () { nms.push($(this).text().replace(/^\s+/g,"")); });
3455
+ res = this._check_unique(nms, data.args[0].np.find("> ul > li").not(data.args[0].o));
3456
+ }
3457
+ }
3458
+ }
3459
+ if(data.func == "create_node") {
3460
+ // obj, position, js, callback, is_loaded
3461
+ if(data.args[4] || this._is_loaded(data.args[0])) {
3462
+ p = this._get_node(data.args[0]);
3463
+ if(data.args[1] && (data.args[1] === "before" || data.args[1] === "after")) {
3464
+ p = this._get_parent(data.args[0]);
3465
+ if(!p || p === -1) { p = this.get_container(); }
3466
+ }
3467
+ if(typeof data.args[2] === "string") { nms.push(data.args[2]); }
3468
+ else if(!data.args[2] || !data.args[2].data) { nms.push(this._get_settings().core.strings.new_node); }
3469
+ else { nms.push(data.args[2].data); }
3470
+ res = this._check_unique(nms, p.find("> ul > li"));
3471
+ }
3472
+ }
3473
+ if(data.func == "rename_node") {
3474
+ // obj, val
3475
+ nms.push(data.args[1]);
3476
+ t = this._get_node(data.args[0]);
3477
+ p = this._get_parent(t);
3478
+ if(!p || p === -1) { p = this.get_container(); }
3479
+ res = this._check_unique(nms, p.find("> ul > li").not(t));
3480
+ }
3481
+ if(!res) {
3482
+ e.stopPropagation();
3483
+ return false;
3484
+ }
3485
+ }, this));
3486
+ },
3487
+ _fn : {
3488
+ _check_unique : function (nms, p) {
3489
+ var cnms = [];
3490
+ p.children("a").each(function () { cnms.push($(this).text().replace(/^\s+/g,"")); });
3491
+ if(!cnms.length || !nms.length) { return true; }
3492
+ cnms = cnms.sort().join(",,").replace(/(,|^)([^,]+)(,,\2)+(,|$)/g,"$1$2$4").replace(/,,+/g,",").replace(/,$/,"").split(",");
3493
+ if((cnms.length + nms.length) != cnms.concat(nms).sort().join(",,").replace(/(,|^)([^,]+)(,,\2)+(,|$)/g,"$1$2$4").replace(/,,+/g,",").replace(/,$/,"").split(",").length) {
3494
+ return false;
3495
+ }
3496
+ return true;
3497
+ },
3498
+ check_move : function () {
3499
+ if(!this.__call_old()) { return false; }
3500
+ var p = this._get_move(), nms = [];
3501
+ if(p.o && p.o.length) {
3502
+ p.o.children("a").each(function () { nms.push($(this).text().replace(/^\s+/g,"")); });
3503
+ return this._check_unique(nms, p.np.find("> ul > li").not(p.o));
3504
+ }
3505
+ return true;
3506
+ }
3507
+ }
3508
+ });
3509
+ })(jQuery);
3510
  //*/
styles/styles.css CHANGED
@@ -10,11 +10,19 @@
10
  z-index: 10;
11
  }
12
  .cms_tpv_container {
13
- clear: both;
14
  overflow: visible;
15
  margin-top: 1.5em;
16
  }
17
 
 
 
 
 
 
 
 
 
18
  .pages_page_cms-tpv-pages-page .updated {
19
  clear: both;
20
  }
@@ -298,4 +306,12 @@ p.cms_tpv_annoying_little_box_close {
298
  li.cms_tpv_user_can_edit_page_no a {
299
  opacity: .6; /* Standard: FF gt 1.5, Opera, Safari */
300
  -ms-filter: "alpha(opacity=60)"; /* IE 8 */
301
- }
 
 
 
 
 
 
 
 
10
  z-index: 10;
11
  }
12
  .cms_tpv_container {
13
+ /* clear: both; */
14
  overflow: visible;
15
  margin-top: 1.5em;
16
  }
17
 
18
+ #wpbody-content .cms_tpv_container {
19
+ margin-right: 250px;
20
+ }
21
+
22
+ #dashboard-widgets-wrap .cms_tpv_container {
23
+ margin-right: 0;
24
+ }
25
+
26
  .pages_page_cms-tpv-pages-page .updated {
27
  clear: both;
28
  }
306
  li.cms_tpv_user_can_edit_page_no a {
307
  opacity: .6; /* Standard: FF gt 1.5, Opera, Safari */
308
  -ms-filter: "alpha(opacity=60)"; /* IE 8 */
309
+ }
310
+
311
+ .bonny-plugins-inner-sidebar {
312
+ float: right;
313
+ width: 210px;
314
+ padding-right: 10px;
315
+ padding-left: 10px;
316
+ border-left: 1px solid #E3E3E3;
317
+ }