Version Description
- you chould get an error if used togther with the "Simple Fields" WordPress plugin (yes, I used the same function name in both plugin! Fool me twice, shame on me.)
Download this release
Release Info
Developer | eskapism |
Plugin | CMS Tree Page View |
Version | 0.5.2 |
Comparing to | |
See all releases |
Code changes from version 0.4.9 to 0.5.2
- functions.php +63 -23
- index.php +3 -3
- readme.txt +19 -3
- scripts/cms_tree_page_view.js +309 -0
- scripts/cms_tree_page_view.php +0 -307
- scripts/jquery.jstree.js +3284 -0
- scripts/jquery.tree.js +0 -2064
- scripts/plugins/_jquery.tree.rtl.js +0 -32
- scripts/plugins/jquery.tree.cookie.js +0 -70
- scripts/themes/default/style.css +0 -30
- scripts/themes/default/throbber.gif +0 -0
- scripts/themes/wordpress/d.png +0 -0
- scripts/themes/{default → wordpress}/dot_for_ie.gif +0 -0
- scripts/themes/{default/icons.png → wordpress/iconsxx.png} +0 -0
- scripts/themes/wordpress/style.css +72 -0
- scripts/themes/wordpress/throbber.gif +0 -0
- styles/styles.css +30 -22
functions.php
CHANGED
@@ -9,9 +9,11 @@ function cms_tpv_admin_head() {
|
|
9 |
}
|
10 |
?>
|
11 |
<script type="text/javascript">
|
|
|
12 |
var CMS_TPV_URL = "<?php echo CMS_TPV_URL ?>";
|
13 |
var CMS_TPV_AJAXURL = "?action=cms_tpv_get_childs&view=";
|
14 |
var CMS_TPV_VIEW = "<?php echo $cms_tpv_view ?>";
|
|
|
15 |
</script>
|
16 |
|
17 |
<!--[if IE 6]>
|
@@ -29,9 +31,24 @@ function cms_tpv_admin_head() {
|
|
29 |
function cms_tpv_admin_init() {
|
30 |
wp_enqueue_style( "cms_tpv_styles", CMS_TPV_URL . "styles/styles.css", false, CMS_TPV_VERSION );
|
31 |
wp_enqueue_script( "jquery-cookie", CMS_TPV_URL . "scripts/jquery.cookie.js", array("jquery"));
|
32 |
-
wp_enqueue_script( "jquery-jstree", CMS_TPV_URL . "scripts/jquery.
|
33 |
-
|
34 |
-
wp_enqueue_script( "cms_tree_page_view", CMS_TPV_URL . "scripts/cms_tree_page_view.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
load_plugin_textdomain('cms-tree-page-view', WP_CONTENT_DIR . "/plugins/languages", "/cms-tree-page-view/languages");
|
36 |
|
37 |
}
|
@@ -43,8 +60,6 @@ function cms_tpv_wp_dashboard_setup() {
|
|
43 |
}
|
44 |
|
45 |
function cms_tpv_show_on_dashboard() {
|
46 |
-
// @todo: fix this
|
47 |
-
return false;
|
48 |
if ( get_option('cms_tpv_show_on_dashboard', 1) == 1 && current_user_can("edit_pages") ) {
|
49 |
return true;
|
50 |
} else {
|
@@ -93,12 +108,10 @@ function cms_tpv_options() {
|
|
93 |
<?php _e("Show tree", 'cms-tree-page-view') ?>
|
94 |
</th>
|
95 |
<td>
|
96 |
-
<!--
|
97 |
-
@todo: fix this
|
98 |
<input type="checkbox" name="cms_tpv_show_on_dashboard" id="cms_tpv_show_on_dashboard" value="1" <?php echo get_option('cms_tpv_show_on_dashboard', 1) ? " checked='checked'" : "" ?> />
|
99 |
<label for="cms_tpv_show_on_dashboard"><?php _e("on the dashboard", 'cms-tree-page-view') ?></label>
|
100 |
<br />
|
101 |
-
|
102 |
<input type="checkbox" name="cms_tpv_show_under_pages" id="cms_tpv_show_under_pages" value="1" <?php echo get_option('cms_tpv_show_under_pages', 1) ? " checked='checked'" : "" ?> />
|
103 |
<label for="cms_tpv_show_under_pages"><?php _e("under the pages menu", 'cms-tree-page-view') ?></label>
|
104 |
</td>
|
@@ -129,15 +142,16 @@ function cms_tpv_print_common_tree_stuff() {
|
|
129 |
?>
|
130 |
|
131 |
<ul class="cms-tpv-subsubsub">
|
132 |
-
<li><a id="cms_tvp_view_all" class="<?php echo ($cms_tpv_view=="all") ? "current" : "" ?>" href="
|
133 |
-
<li><a id="cms_tvp_view_public" class="<?php echo ($cms_tpv_view=="public") ? "current" : "" ?>" href="
|
134 |
|
135 |
<li><a href="#" id="cms_tpv_open_all"><?php _e("Expand", 'cms-tree-page-view') ?></a> |</li>
|
136 |
<li><a href="#" id="cms_tpv_close_all"><?php _e("Collapse", 'cms-tree-page-view') ?></a></li>
|
137 |
|
138 |
<li>
|
139 |
-
<form id="cms_tree_view_search_form">
|
140 |
<input type="text" name="search" id="cms_tree_view_search" />
|
|
|
141 |
<input type="submit" id="cms_tree_view_search_submit" value="<?php _e("Search", 'cms-tree-page-view') ?>" />
|
142 |
<span id="cms_tree_view_search_form_working"><?php _e("Searching...", 'cms-tree-page-view') ?></span>
|
143 |
</form>
|
@@ -227,7 +241,7 @@ function cms_tpv_print_childs($pageID, $view = "all", $arrOpenChilds = null) {
|
|
227 |
?>[<?php
|
228 |
for ($i=0, $pagesCount = sizeof($arrPages); $i<$pagesCount; $i++) {
|
229 |
$onePage = $arrPages[$i];
|
230 |
-
$editLink = get_edit_post_link($onePage->ID, '
|
231 |
$content = wp_specialchars($onePage->post_content);
|
232 |
$content = str_replace(array("\n","\r"), "", $content);
|
233 |
$hasChildren = false;
|
@@ -253,21 +267,33 @@ function cms_tpv_print_childs($pageID, $view = "all", $arrOpenChilds = null) {
|
|
253 |
$title = __("<Untitled page>", 'cms-tree-page-view');
|
254 |
}
|
255 |
$title = wp_specialchars($title);
|
|
|
|
|
256 |
?>
|
257 |
{
|
258 |
"data": {
|
259 |
"title": "<?php echo $title ?>",
|
260 |
-
"
|
261 |
-
"href": "<?php echo $editLink ?>"
|
262 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
263 |
},
|
264 |
<?php echo $strState ?>
|
265 |
-
"
|
266 |
"id": "cms-tpv-<?php echo $onePage->ID ?>",
|
|
|
|
|
|
|
267 |
"rel": "<?php echo $rel ?>",
|
268 |
"childCount": <?php echo sizeof($arrChildPages) ?>,
|
269 |
-
"
|
270 |
-
"
|
271 |
}
|
272 |
<?php
|
273 |
// if id is in $arrOpenChilds then also output children on this one
|
@@ -292,9 +318,11 @@ function cms_tpv_print_childs($pageID, $view = "all", $arrOpenChilds = null) {
|
|
292 |
// Act on AJAX-call
|
293 |
function cms_tpv_get_childs() {
|
294 |
|
|
|
|
|
295 |
$action = $_GET["action"];
|
296 |
$view = $_GET["view"]; // all | public
|
297 |
-
$search = trim($_GET["
|
298 |
if ($action) {
|
299 |
|
300 |
if ($search) {
|
@@ -333,16 +361,24 @@ function cms_tpv_get_childs() {
|
|
333 |
|
334 |
$arrNodesToOpen = array_merge($arrNodesToOpen, $arrNodesToOpen2);
|
335 |
$sReturn = "";
|
|
|
|
|
|
|
|
|
|
|
336 |
foreach ($arrNodesToOpen as $oneNodeID) {
|
337 |
-
$sReturn .= "cms-tpv-{$oneNodeID},";
|
|
|
|
|
|
|
|
|
338 |
}
|
339 |
-
$sReturn = preg_replace("/,$/", "", $sReturn);
|
340 |
|
341 |
if ($sReturn) {
|
342 |
echo $sReturn;
|
343 |
} else {
|
344 |
// if no hits
|
345 |
-
echo
|
346 |
}
|
347 |
|
348 |
exit;
|
@@ -354,9 +390,10 @@ function cms_tpv_get_childs() {
|
|
354 |
$jstree_open = array();
|
355 |
if ( isset( $_COOKIE["jstree_open"] ) ) {
|
356 |
$jstree_open = $_COOKIE["jstree_open"]; // like this: [jstree_open] => cms-tpv-1282,cms-tpv-1284,cms-tpv-3
|
|
|
357 |
$jstree_open = explode( ",", $jstree_open );
|
358 |
for( $i=0; $i<sizeof( $jstree_open ); $i++ ) {
|
359 |
-
$jstree_open[$i] = (int) str_replace("cms-tpv-", "", $jstree_open[$i]);
|
360 |
}
|
361 |
}
|
362 |
|
@@ -468,6 +505,7 @@ function cms_tpv_move_page() {
|
|
468 |
|
469 |
// post_node is moved inside ref_post_node
|
470 |
// add ref_post_node as parent to post_node and set post_nodes menu_order to 0
|
|
|
471 |
$post_to_save = array(
|
472 |
"ID" => $post_node->ID,
|
473 |
"menu_order" => 0,
|
@@ -512,10 +550,12 @@ function cms_tpv_move_page() {
|
|
512 |
exit;
|
513 |
}
|
514 |
|
|
|
515 |
function bonny_d($var) {
|
516 |
echo "<pre>";
|
517 |
print_r($var);
|
518 |
echo "</pre>";
|
519 |
}
|
|
|
520 |
|
521 |
?>
|
9 |
}
|
10 |
?>
|
11 |
<script type="text/javascript">
|
12 |
+
/* <![CDATA[ */
|
13 |
var CMS_TPV_URL = "<?php echo CMS_TPV_URL ?>";
|
14 |
var CMS_TPV_AJAXURL = "?action=cms_tpv_get_childs&view=";
|
15 |
var CMS_TPV_VIEW = "<?php echo $cms_tpv_view ?>";
|
16 |
+
/* ]]> */
|
17 |
</script>
|
18 |
|
19 |
<!--[if IE 6]>
|
31 |
function cms_tpv_admin_init() {
|
32 |
wp_enqueue_style( "cms_tpv_styles", CMS_TPV_URL . "styles/styles.css", false, CMS_TPV_VERSION );
|
33 |
wp_enqueue_script( "jquery-cookie", CMS_TPV_URL . "scripts/jquery.cookie.js", array("jquery"));
|
34 |
+
wp_enqueue_script( "jquery-jstree", CMS_TPV_URL . "scripts/jquery.jstree.js", false, CMS_TPV_VERSION);
|
35 |
+
|
36 |
+
wp_enqueue_script( "cms_tree_page_view", CMS_TPV_URL . "scripts/cms_tree_page_view.js", false, CMS_TPV_VERSION);
|
37 |
+
$oLocale = array(
|
38 |
+
"Enter_title_of_new_page" => __("Enter title of new page", 'cms-tree-page-view'),
|
39 |
+
"child_pages" => __("child pages", 'cms-tree-page-view'),
|
40 |
+
"Edit_page" => __("Edit page", 'cms-tree-page-view'),
|
41 |
+
"View_page" => __("View page", 'cms-tree-page-view'),
|
42 |
+
"Edit" => __("Edit", 'cms-tree-page-view'),
|
43 |
+
"View" => __("View", 'cms-tree-page-view'),
|
44 |
+
"Add_page" => __("Add page", 'cms-tree-page-view'),
|
45 |
+
"Add_new_page_after" => __("Add new page after", 'cms-tree-page-view'),
|
46 |
+
"after" => __("after", 'cms-tree-page-view'),
|
47 |
+
"inside" => __("inside", 'cms-tree-page-view'),
|
48 |
+
"Add_new_page_inside" => __("Add new page inside", 'cms-tree-page-view')
|
49 |
+
);
|
50 |
+
wp_localize_script( "cms_tree_page_view", 'cmstpv_l10n', $oLocale);
|
51 |
+
|
52 |
load_plugin_textdomain('cms-tree-page-view', WP_CONTENT_DIR . "/plugins/languages", "/cms-tree-page-view/languages");
|
53 |
|
54 |
}
|
60 |
}
|
61 |
|
62 |
function cms_tpv_show_on_dashboard() {
|
|
|
|
|
63 |
if ( get_option('cms_tpv_show_on_dashboard', 1) == 1 && current_user_can("edit_pages") ) {
|
64 |
return true;
|
65 |
} else {
|
108 |
<?php _e("Show tree", 'cms-tree-page-view') ?>
|
109 |
</th>
|
110 |
<td>
|
|
|
|
|
111 |
<input type="checkbox" name="cms_tpv_show_on_dashboard" id="cms_tpv_show_on_dashboard" value="1" <?php echo get_option('cms_tpv_show_on_dashboard', 1) ? " checked='checked'" : "" ?> />
|
112 |
<label for="cms_tpv_show_on_dashboard"><?php _e("on the dashboard", 'cms-tree-page-view') ?></label>
|
113 |
<br />
|
114 |
+
|
115 |
<input type="checkbox" name="cms_tpv_show_under_pages" id="cms_tpv_show_under_pages" value="1" <?php echo get_option('cms_tpv_show_under_pages', 1) ? " checked='checked'" : "" ?> />
|
116 |
<label for="cms_tpv_show_under_pages"><?php _e("under the pages menu", 'cms-tree-page-view') ?></label>
|
117 |
</td>
|
142 |
?>
|
143 |
|
144 |
<ul class="cms-tpv-subsubsub">
|
145 |
+
<li><a id="cms_tvp_view_all" class="<?php echo ($cms_tpv_view=="all") ? "current" : "" ?>" href="#"><?php _e("All", 'cms-tree-page-view') ?></a> |</li>
|
146 |
+
<li><a id="cms_tvp_view_public" class="<?php echo ($cms_tpv_view=="public") ? "current" : "" ?>" href="#"><?php _e("Public", 'cms-tree-page-view') ?></a></li>
|
147 |
|
148 |
<li><a href="#" id="cms_tpv_open_all"><?php _e("Expand", 'cms-tree-page-view') ?></a> |</li>
|
149 |
<li><a href="#" id="cms_tpv_close_all"><?php _e("Collapse", 'cms-tree-page-view') ?></a></li>
|
150 |
|
151 |
<li>
|
152 |
+
<form id="cms_tree_view_search_form" method="get" action="">
|
153 |
<input type="text" name="search" id="cms_tree_view_search" />
|
154 |
+
<a title="<?php _e("Clear search", 'cms-tree-page-view') ?>" id="cms_tree_view_search_form_reset" href="#">x</a>
|
155 |
<input type="submit" id="cms_tree_view_search_submit" value="<?php _e("Search", 'cms-tree-page-view') ?>" />
|
156 |
<span id="cms_tree_view_search_form_working"><?php _e("Searching...", 'cms-tree-page-view') ?></span>
|
157 |
</form>
|
241 |
?>[<?php
|
242 |
for ($i=0, $pagesCount = sizeof($arrPages); $i<$pagesCount; $i++) {
|
243 |
$onePage = $arrPages[$i];
|
244 |
+
$editLink = get_edit_post_link($onePage->ID, 'notDisplay');
|
245 |
$content = wp_specialchars($onePage->post_content);
|
246 |
$content = str_replace(array("\n","\r"), "", $content);
|
247 |
$hasChildren = false;
|
267 |
$title = __("<Untitled page>", 'cms-tree-page-view');
|
268 |
}
|
269 |
$title = wp_specialchars($title);
|
270 |
+
#$title = html_entity_decode($title, ENT_COMPAT, "UTF-8");
|
271 |
+
#$title = html_entity_decode($title, ENT_COMPAT);
|
272 |
?>
|
273 |
{
|
274 |
"data": {
|
275 |
"title": "<?php echo $title ?>",
|
276 |
+
"attr": {
|
277 |
+
"href": "<?php echo $editLink ?>",
|
278 |
+
"xid": "cms-tpv-<?php echo $onePage->ID ?>"
|
279 |
+
},
|
280 |
+
"xicon": "<?php echo CMS_TPV_URL . "images/page_white_text.png" ?>"
|
281 |
+
},
|
282 |
+
"attr": {
|
283 |
+
"xhref": "<?php echo $editLink ?>",
|
284 |
+
"id": "cms-tpv-<?php echo $onePage->ID ?>",
|
285 |
+
"xtitle": "<?php _e("Click to edit. Drag to move.", 'cms-tree-page-view') ?>"
|
286 |
},
|
287 |
<?php echo $strState ?>
|
288 |
+
"metadata": {
|
289 |
"id": "cms-tpv-<?php echo $onePage->ID ?>",
|
290 |
+
"post_id": "<?php echo $onePage->ID ?>",
|
291 |
+
"post_type": "<?php echo $onePage->post_type ?>",
|
292 |
+
"post_status": "<?php echo $onePage->post_status ?>",
|
293 |
"rel": "<?php echo $rel ?>",
|
294 |
"childCount": <?php echo sizeof($arrChildPages) ?>,
|
295 |
+
"permalink": "<?php echo get_permalink($onePage->ID) ?>",
|
296 |
+
"editlink": "<?php echo $editLink ?>"
|
297 |
}
|
298 |
<?php
|
299 |
// if id is in $arrOpenChilds then also output children on this one
|
318 |
// Act on AJAX-call
|
319 |
function cms_tpv_get_childs() {
|
320 |
|
321 |
+
header("Content-type: application/json");
|
322 |
+
|
323 |
$action = $_GET["action"];
|
324 |
$view = $_GET["view"]; // all | public
|
325 |
+
$search = trim($_GET["search_string"]); // exits if we're doing a search
|
326 |
if ($action) {
|
327 |
|
328 |
if ($search) {
|
361 |
|
362 |
$arrNodesToOpen = array_merge($arrNodesToOpen, $arrNodesToOpen2);
|
363 |
$sReturn = "";
|
364 |
+
#foreach ($arrNodesToOpen as $oneNodeID) {
|
365 |
+
# $sReturn .= "cms-tpv-{$oneNodeID},";
|
366 |
+
#}
|
367 |
+
#$sReturn = preg_replace("/,$/", "", $sReturn);
|
368 |
+
|
369 |
foreach ($arrNodesToOpen as $oneNodeID) {
|
370 |
+
$sReturn .= "\"#cms-tpv-{$oneNodeID}\",";
|
371 |
+
}
|
372 |
+
$sReturn = preg_replace('/,$/', "", $sReturn);
|
373 |
+
if ($sReturn) {
|
374 |
+
$sReturn = "[" . $sReturn . "]";
|
375 |
}
|
|
|
376 |
|
377 |
if ($sReturn) {
|
378 |
echo $sReturn;
|
379 |
} else {
|
380 |
// if no hits
|
381 |
+
echo "[]";
|
382 |
}
|
383 |
|
384 |
exit;
|
390 |
$jstree_open = array();
|
391 |
if ( isset( $_COOKIE["jstree_open"] ) ) {
|
392 |
$jstree_open = $_COOKIE["jstree_open"]; // like this: [jstree_open] => cms-tpv-1282,cms-tpv-1284,cms-tpv-3
|
393 |
+
#var_dump($jstree_open); string(22) "#cms-tpv-14,#cms-tpv-2"
|
394 |
$jstree_open = explode( ",", $jstree_open );
|
395 |
for( $i=0; $i<sizeof( $jstree_open ); $i++ ) {
|
396 |
+
$jstree_open[$i] = (int) str_replace("#cms-tpv-", "", $jstree_open[$i]);
|
397 |
}
|
398 |
}
|
399 |
|
505 |
|
506 |
// post_node is moved inside ref_post_node
|
507 |
// add ref_post_node as parent to post_node and set post_nodes menu_order to 0
|
508 |
+
// @todo: shouldn't menu order of existing items be changed?
|
509 |
$post_to_save = array(
|
510 |
"ID" => $post_node->ID,
|
511 |
"menu_order" => 0,
|
550 |
exit;
|
551 |
}
|
552 |
|
553 |
+
if (!function_exists("bonny_d")) {
|
554 |
function bonny_d($var) {
|
555 |
echo "<pre>";
|
556 |
print_r($var);
|
557 |
echo "</pre>";
|
558 |
}
|
559 |
+
}
|
560 |
|
561 |
?>
|
index.php
CHANGED
@@ -3,7 +3,7 @@
|
|
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 |
Author: Pär Thernström
|
8 |
Author URI: http://eskapism.se/
|
9 |
License: GPL2
|
@@ -30,7 +30,7 @@ require("functions.php");
|
|
30 |
|
31 |
define( "CMS_TPV_URL", WP_PLUGIN_URL . '/cms-tree-page-view/');
|
32 |
define( "CMS_TPV_NAME", "CMS Tree Page View");
|
33 |
-
define( "CMS_TPV_VERSION", "0.
|
34 |
define( "CMS_TPV_PAGE_FILE", "edit-pages.php?page=cms-tpv-pages-page"); // this feels nasty
|
35 |
|
36 |
// on admin init: add styles and scripts
|
@@ -46,4 +46,4 @@ add_action('wp_ajax_cms_tpv_get_childs', 'cms_tpv_get_childs');
|
|
46 |
add_action('wp_ajax_cms_tpv_move_page', 'cms_tpv_move_page');
|
47 |
add_action('wp_ajax_cms_tpv_add_page', 'cms_tpv_add_page');
|
48 |
|
49 |
-
?>
|
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.5.2
|
7 |
Author: Pär Thernström
|
8 |
Author URI: http://eskapism.se/
|
9 |
License: GPL2
|
30 |
|
31 |
define( "CMS_TPV_URL", WP_PLUGIN_URL . '/cms-tree-page-view/');
|
32 |
define( "CMS_TPV_NAME", "CMS Tree Page View");
|
33 |
+
define( "CMS_TPV_VERSION", "0.5.2");
|
34 |
define( "CMS_TPV_PAGE_FILE", "edit-pages.php?page=cms-tpv-pages-page"); // this feels nasty
|
35 |
|
36 |
// on admin init: add styles and scripts
|
46 |
add_action('wp_ajax_cms_tpv_move_page', 'cms_tpv_move_page');
|
47 |
add_action('wp_ajax_cms_tpv_add_page', 'cms_tpv_add_page');
|
48 |
|
49 |
+
?>
|
readme.txt
CHANGED
@@ -1,8 +1,9 @@
|
|
1 |
=== Plugin Name ===
|
2 |
Contributors: eskapism
|
3 |
-
|
4 |
-
|
5 |
-
|
|
|
6 |
Stable tag: trunk
|
7 |
|
8 |
Adds a CMS-like tree overview of all your pages. Edit, view, add pages, search pages, and drag and drop to rearrange the order of your pages.
|
@@ -44,6 +45,21 @@ Now the tree with the pages will be visible both on the dashboard and in the men
|
|
44 |
|
45 |
== Changelog ==
|
46 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
= 0.4.9 =
|
48 |
- added French translation by Bertrand Andres
|
49 |
|
1 |
=== Plugin Name ===
|
2 |
Contributors: eskapism
|
3 |
+
Donate link: http://eskapism.se/sida/donate/
|
4 |
+
Tags: page, pages, tree, cms, dashboard, overview, drag-and-drop, rearrange, management, manage, admin
|
5 |
+
Requires at least: 3.0RC1
|
6 |
+
Tested up to: 3.0RC1
|
7 |
Stable tag: trunk
|
8 |
|
9 |
Adds a CMS-like tree overview of all your pages. Edit, view, add pages, search pages, and drag and drop to rearrange the order of your pages.
|
45 |
|
46 |
== Changelog ==
|
47 |
|
48 |
+
= 0.5.2 =
|
49 |
+
- you chould get an error if used togther with the "Simple Fields" WordPress plugin (yes, I used the same function name in both plugin! Fool me twice, shame on me.)
|
50 |
+
|
51 |
+
= 0.5.1 =
|
52 |
+
- forgot to add styles to svn
|
53 |
+
|
54 |
+
= 0.5 =
|
55 |
+
- Uses wp_localize_script to translate script. Previous method could lead to 404-error, although the file did exist.
|
56 |
+
- More valid output
|
57 |
+
- jsTree upgraded to 1.0rc
|
58 |
+
- Code rewritten for upgraded jsTree
|
59 |
+
- Added a "clear search"-button to the search box
|
60 |
+
- Dashboard widget added again! Hooray!
|
61 |
+
- Requires WordPress 3 because of jquery 1.4.2. If you are using WP 2.x you can try version 0.4.9 instead: http://downloads.wordpress.org/plugin/cms-tree-page-view.0.4.9.zip
|
62 |
+
|
63 |
= 0.4.9 =
|
64 |
- added French translation by Bertrand Andres
|
65 |
|
scripts/cms_tree_page_view.js
ADDED
@@ -0,0 +1,309 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
var cms_tpv_tree, treeOptions;
|
3 |
+
jQuery(function($) {
|
4 |
+
|
5 |
+
cms_tpv_tree = $("#cms_tpv_container");
|
6 |
+
|
7 |
+
/**
|
8 |
+
* show div with options
|
9 |
+
*/
|
10 |
+
$("#cms_tpv_container li").live("mouseenter", function() {
|
11 |
+
$(this).find(".cms_tpv_tree_actions:first").show();
|
12 |
+
});
|
13 |
+
$("#cms_tpv_container li").live("mouseleave", function() {
|
14 |
+
$(this).find(".cms_tpv_tree_actions:first").hide();
|
15 |
+
});
|
16 |
+
|
17 |
+
treeOptions = {
|
18 |
+
xplugins: ["cookie","ui","crrm","themes","json_data","search","types","dnd"],
|
19 |
+
plugins: ["themes","json_data","cookies","search","dnd"],
|
20 |
+
core: {
|
21 |
+
"html_titles": true
|
22 |
+
},
|
23 |
+
"json_data": {
|
24 |
+
"ajax": {
|
25 |
+
"url": ajaxurl + CMS_TPV_AJAXURL + CMS_TPV_VIEW,
|
26 |
+
// this function is executed in the instance's scope (this refers to the tree instance)
|
27 |
+
// the parameter is the node being loaded (may be -1, 0, or undefined when loading the root nodes)
|
28 |
+
"data" : function (n) {
|
29 |
+
// the result is fed to the AJAX request `data` option
|
30 |
+
if (n.data) {
|
31 |
+
var post_id = n.data("jstree").post_id;
|
32 |
+
return {
|
33 |
+
"id": post_id
|
34 |
+
}
|
35 |
+
}
|
36 |
+
}
|
37 |
+
|
38 |
+
}
|
39 |
+
},
|
40 |
+
"themes": {
|
41 |
+
"theme": "wordpress"
|
42 |
+
},
|
43 |
+
"search": {
|
44 |
+
"ajax" : {
|
45 |
+
"url": ajaxurl + CMS_TPV_AJAXURL + CMS_TPV_VIEW
|
46 |
+
},
|
47 |
+
"case_insensitive": true
|
48 |
+
},
|
49 |
+
"dnd": {
|
50 |
+
}
|
51 |
+
}
|
52 |
+
|
53 |
+
if ($("#cms_tpv_container").length == 1) {
|
54 |
+
cms_tpv_bind_clean_node();
|
55 |
+
cms_tpv_tree.jstree(treeOptions);
|
56 |
+
}
|
57 |
+
|
58 |
+
}); // end ondomready
|
59 |
+
|
60 |
+
|
61 |
+
// view page on click
|
62 |
+
jQuery(".cms_tpv_action_view").live("click", function() {
|
63 |
+
var $li = jQuery(this).closest("li");
|
64 |
+
var permalink = $li.data("jstree").permalink;
|
65 |
+
if (permalink) {
|
66 |
+
document.location = permalink;
|
67 |
+
}
|
68 |
+
return false;
|
69 |
+
});
|
70 |
+
|
71 |
+
// edit page on click
|
72 |
+
jQuery(".cms_tpv_action_edit").live("click", function() {
|
73 |
+
var $li = jQuery(this).closest("li");
|
74 |
+
var editlink = $li.data("jstree").editlink;
|
75 |
+
if (editlink) {
|
76 |
+
document.location = editlink;
|
77 |
+
}
|
78 |
+
return false;
|
79 |
+
});
|
80 |
+
|
81 |
+
// add page after
|
82 |
+
jQuery(".cms_tpv_action_add_page_after").live("click", function() {
|
83 |
+
var new_page_title = prompt(cmstpv_l10n.Enter_title_of_new_page, "");
|
84 |
+
if (new_page_title) {
|
85 |
+
var pageID = jQuery(this).closest("li").attr("id");
|
86 |
+
jQuery.post(ajaxurl, {
|
87 |
+
action: "cms_tpv_add_page",
|
88 |
+
pageID: pageID,
|
89 |
+
type: "after",
|
90 |
+
page_title: new_page_title
|
91 |
+
}, function(data, textStatus) {
|
92 |
+
document.location = data;
|
93 |
+
});
|
94 |
+
}
|
95 |
+
return false;
|
96 |
+
});
|
97 |
+
|
98 |
+
// add page inside
|
99 |
+
jQuery(".cms_tpv_action_add_page_inside").live("click", function() {
|
100 |
+
var new_page_title = prompt(cmstpv_l10n.Enter_title_of_new_page, "");
|
101 |
+
if (new_page_title) {
|
102 |
+
var pageID = jQuery(this).closest("li").attr("id");
|
103 |
+
jQuery.post(ajaxurl, {
|
104 |
+
action: "cms_tpv_add_page",
|
105 |
+
pageID: pageID,
|
106 |
+
type: "inside",
|
107 |
+
page_title: new_page_title
|
108 |
+
}, function(data, textStatus) {
|
109 |
+
document.location = data;
|
110 |
+
});
|
111 |
+
}
|
112 |
+
return false;
|
113 |
+
});
|
114 |
+
|
115 |
+
|
116 |
+
|
117 |
+
|
118 |
+
|
119 |
+
// check if tree is beging dragged
|
120 |
+
function cms_tpv_is_dragging() {
|
121 |
+
var eDrag = jQuery("#vakata-dragged");
|
122 |
+
return eDrag.is(":visible");
|
123 |
+
}
|
124 |
+
|
125 |
+
// mouse over, show actions
|
126 |
+
jQuery(".jstree li a").live("mouseover", function() {
|
127 |
+
$t = jQuery(this);
|
128 |
+
$actions = $t.find(".cms_tpv_action_view, .cms_tpv_action_edit, .cms_tpv_action_add_page, .cms_tpv_action_add_page_after, .cms_tpv_action_add_page_inside");
|
129 |
+
// $actions.show();
|
130 |
+
if (cms_tpv_is_dragging() == false) {
|
131 |
+
$actions.show();
|
132 |
+
}
|
133 |
+
});
|
134 |
+
// ..and hide them again
|
135 |
+
jQuery(".jstree li a").live("mouseout", function() {
|
136 |
+
$t = jQuery(this);
|
137 |
+
$actions = $t.find(".cms_tpv_action_view, .cms_tpv_action_edit, .cms_tpv_action_add_page, .cms_tpv_action_add_page_after, .cms_tpv_action_add_page_inside");
|
138 |
+
$actions.hide();
|
139 |
+
});
|
140 |
+
|
141 |
+
|
142 |
+
// hide action links on drag
|
143 |
+
jQuery.jstree.drag_start = function() {
|
144 |
+
jQuery(".cms_tpv_action_view, .cms_tpv_action_edit, .cms_tpv_action_add_page, .cms_tpv_action_add_page_after, .cms_tpv_action_add_page_inside").hide();
|
145 |
+
}
|
146 |
+
|
147 |
+
/**
|
148 |
+
* add childcount and other things to each li
|
149 |
+
*/
|
150 |
+
function cms_tpv_bind_clean_node() {
|
151 |
+
|
152 |
+
cms_tpv_tree.bind("move_node.jstree", function (event, data) {
|
153 |
+
var nodeBeingMoved = data.rslt.o; // noden vi flyttar
|
154 |
+
var nodeNewParent = data.rslt.np;
|
155 |
+
var nodePosition = data.rslt.p;
|
156 |
+
var nodeR = data.rslt.r;
|
157 |
+
var nodeRef = data.rslt.or; // noden som positionen gäller versus
|
158 |
+
|
159 |
+
/*
|
160 |
+
|
161 |
+
// om ovanför
|
162 |
+
o ovanför or
|
163 |
+
|
164 |
+
// om efter
|
165 |
+
o efter r
|
166 |
+
|
167 |
+
// om inside
|
168 |
+
o ovanför or
|
169 |
+
|
170 |
+
|
171 |
+
drop_target : ".jstree-drop",
|
172 |
+
drop_check : function (data) { return true; },
|
173 |
+
drop_finish : $.noop,
|
174 |
+
drag_target : ".jstree-draggable",
|
175 |
+
drag_finish : $.noop,
|
176 |
+
drag_check : function (data) { return { after : false, before : false, inside : true }; }
|
177 |
+
|
178 |
+
Gets executed after a valid drop, you get one parameter, which is as follows:
|
179 |
+
data.o - the object being dragged
|
180 |
+
data.r - the drop target
|
181 |
+
*/
|
182 |
+
|
183 |
+
if (nodePosition == "before") {
|
184 |
+
var node_id = jQuery( nodeBeingMoved ).attr( "id" );
|
185 |
+
ref_node_id = jQuery( nodeRef ).attr( "id" );
|
186 |
+
} else if (nodePosition == "after") {
|
187 |
+
var node_id = jQuery( nodeBeingMoved ).attr( "id" );
|
188 |
+
ref_node_id = jQuery( nodeR ).attr( "id" );
|
189 |
+
} else if (nodePosition == "inside") {
|
190 |
+
var node_id = jQuery( nodeBeingMoved ).attr( "id" );
|
191 |
+
ref_node_id = jQuery( nodeR ).attr( "id" );
|
192 |
+
}
|
193 |
+
|
194 |
+
// Update parent or menu order
|
195 |
+
jQuery.post(ajaxurl, {
|
196 |
+
action: "cms_tpv_move_page",
|
197 |
+
"node_id": node_id,
|
198 |
+
"ref_node_id": ref_node_id,
|
199 |
+
type: nodePosition
|
200 |
+
}, function(data, textStatus) {
|
201 |
+
});
|
202 |
+
|
203 |
+
});
|
204 |
+
|
205 |
+
cms_tpv_tree.bind("clean_node.jstree", function(event, data) {
|
206 |
+
obj = (data.rslt.obj);
|
207 |
+
if (obj && obj != -1) {
|
208 |
+
obj.each(function(i, elm) {
|
209 |
+
var li = jQuery(elm);
|
210 |
+
var aFirst = li.find("a:first");
|
211 |
+
|
212 |
+
// check that we haven't added our stuff already
|
213 |
+
if (li.data("done_cms_tpv_clean_node")) {
|
214 |
+
return;
|
215 |
+
} else {
|
216 |
+
li.data("done_cms_tpv_clean_node", true);
|
217 |
+
}
|
218 |
+
|
219 |
+
// add number of children
|
220 |
+
var childCount = li.data("jstree").childCount;
|
221 |
+
if (childCount > 0) {
|
222 |
+
aFirst.append("<span title='" + childCount + " " + cmstpv_l10n.child_pages + "' class='child_count'>("+childCount+")</span>");
|
223 |
+
}
|
224 |
+
|
225 |
+
// add page type
|
226 |
+
var post_status = li.data("jstree").post_status;
|
227 |
+
if (post_status != "publish") {
|
228 |
+
aFirst.find("ins").after("<span class='post_type post_type_"+post_status+"'>"+post_status+"</span>");
|
229 |
+
}
|
230 |
+
|
231 |
+
// add div for mega super über cool mouseover/dropdown actions
|
232 |
+
/*
|
233 |
+
var divHTML = "<div class='cms_tpv_tree_actions'>";
|
234 |
+
divHTML += "<p>ola!</p>";
|
235 |
+
divHTML += "<p>lorem ipsum dolor sit amet</p>";
|
236 |
+
divHTML += "</div>";
|
237 |
+
li.prepend(divHTML);
|
238 |
+
*/
|
239 |
+
|
240 |
+
// add actions that are revealed on mouse over
|
241 |
+
var html = "";
|
242 |
+
html += " <span title='"+cmstpv_l10n.Edit_page+"' class='cms_tpv_action_edit'>"+cmstpv_l10n.Edit+"</span>";
|
243 |
+
html += " <span title='"+cmstpv_l10n.View_page+"' class='cms_tpv_action_view'>"+cmstpv_l10n.View+"</span>";
|
244 |
+
|
245 |
+
html += " <span class='cms_tpv_action_add_page'>"+cmstpv_l10n.Add_page+":</span>";
|
246 |
+
html += " <span title='"+cmstpv_l10n.Add_new_page_after+"' class='cms_tpv_action_add_page_after'>"+cmstpv_l10n.after+"</span> ";
|
247 |
+
html += " <span title='"+cmstpv_l10n.Add_new_page_inside+"' class='cms_tpv_action_add_page_inside'>"+cmstpv_l10n.inside+"</span>";
|
248 |
+
aFirst.append(html);
|
249 |
+
|
250 |
+
});
|
251 |
+
}
|
252 |
+
});
|
253 |
+
}
|
254 |
+
|
255 |
+
// search: perform
|
256 |
+
jQuery("#cms_tree_view_search_form").live("submit", function() {
|
257 |
+
jQuery("#cms_tpv_search_no_hits").hide();
|
258 |
+
var s = jQuery("#cms_tree_view_search").attr("value");
|
259 |
+
s = jQuery.trim( s );
|
260 |
+
// search, oh the mighty search!
|
261 |
+
if (s) {
|
262 |
+
jQuery("#cms_tree_view_search_form_working").fadeIn("fast");
|
263 |
+
jQuery("#cms_tree_view_search_form_reset")
|
264 |
+
cms_tpv_tree.jstree("search", s);
|
265 |
+
jQuery("#cms_tree_view_search_form_reset").fadeIn("fast");
|
266 |
+
} else {
|
267 |
+
cms_tpv_tree.jstree("clear_search");
|
268 |
+
jQuery("#cms_tree_view_search_form_reset").fadeOut("fast");
|
269 |
+
}
|
270 |
+
jQuery("#cms_tree_view_search_form_working").fadeOut("fast");
|
271 |
+
return false;
|
272 |
+
});
|
273 |
+
|
274 |
+
// search: reset
|
275 |
+
jQuery("#cms_tree_view_search_form_reset").live("click", function() {
|
276 |
+
jQuery("#cms_tree_view_search").val("")
|
277 |
+
cms_tpv_tree.jstree("clear_search");
|
278 |
+
jQuery("#cms_tree_view_search_form_reset").fadeOut("fast");
|
279 |
+
return false;
|
280 |
+
});
|
281 |
+
|
282 |
+
// open/close links
|
283 |
+
jQuery("#cms_tpv_open_all").live("click", function() {
|
284 |
+
cms_tpv_tree.jstree("open_all");
|
285 |
+
return false;
|
286 |
+
});
|
287 |
+
jQuery("#cms_tpv_close_all").live("click", function() {
|
288 |
+
cms_tpv_tree.jstree("close_all");
|
289 |
+
return false;
|
290 |
+
});
|
291 |
+
|
292 |
+
// view all or public
|
293 |
+
jQuery("#cms_tvp_view_all").live("click", function() {
|
294 |
+
cms_tvp_set_view("all");
|
295 |
+
jQuery(this).addClass("current");
|
296 |
+
return false;
|
297 |
+
});
|
298 |
+
jQuery("#cms_tvp_view_public").live("click", function() {
|
299 |
+
cms_tvp_set_view("public");
|
300 |
+
jQuery(this).addClass("current");
|
301 |
+
return false;
|
302 |
+
});
|
303 |
+
function cms_tvp_set_view(view) {
|
304 |
+
jQuery("#cms_tvp_view_all,#cms_tvp_view_public").removeClass("current");
|
305 |
+
jQuery("#cms_tpv_container").jstree("destroy").html("");
|
306 |
+
cms_tpv_bind_clean_node();
|
307 |
+
treeOptions.json_data.ajax.url = ajaxurl + CMS_TPV_AJAXURL + view;
|
308 |
+
cms_tpv_tree.jstree(treeOptions);
|
309 |
+
}
|
scripts/cms_tree_page_view.php
DELETED
@@ -1,307 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
$wp_abspath = $_GET["wp-abspath"];
|
4 |
-
define('WP_USE_THEMES', false);
|
5 |
-
require($wp_abspath.'/wp-blog-header.php');
|
6 |
-
load_plugin_textdomain('cms-tree-page-view', WP_CONTENT_DIR . "/plugins/languages", "/cms-tree-page-view/languages");
|
7 |
-
|
8 |
-
?>
|
9 |
-
|
10 |
-
// Case Insensitive :contains()
|
11 |
-
// Source: http://ericphan.info/blog/2009/3/4/jquery-13-case-insensitive-contains.html
|
12 |
-
jQuery.extend(jQuery.expr[":"], {
|
13 |
-
"containsNC": function(elem, i, match, array) {
|
14 |
-
return (elem.textContent || elem.innerText || "").toLowerCase().indexOf((match[3] || "").toLowerCase()) >= 0;
|
15 |
-
}
|
16 |
-
});
|
17 |
-
|
18 |
-
// check if tree is beging dragged
|
19 |
-
function cms_tpv_is_dragging() {
|
20 |
-
return (jQuery("#jstree-dragged").length == 1) ? true : false;
|
21 |
-
}
|
22 |
-
|
23 |
-
// mouse over, show actions
|
24 |
-
jQuery(".tree li a").live("mouseover", function() {
|
25 |
-
$t = jQuery(this);
|
26 |
-
$actions = $t.find(".cms_tpv_action_view, .cms_tpv_action_edit, .cms_tpv_action_add_page, .cms_tpv_action_add_page_after, .cms_tpv_action_add_page_inside");
|
27 |
-
if (cms_tpv_is_dragging() == false) {
|
28 |
-
$actions.show();
|
29 |
-
// remove possible timeoutID
|
30 |
-
/*
|
31 |
-
var timeoutID = $t.data("timeoutID");
|
32 |
-
if (timeoutID) {
|
33 |
-
clearTimeout(timeoutID);
|
34 |
-
$t.data("timeoutID", null);
|
35 |
-
}
|
36 |
-
*/
|
37 |
-
}
|
38 |
-
});
|
39 |
-
// ..and hide them again
|
40 |
-
// @todo: hide after a short delay. fitts law stuff
|
41 |
-
jQuery(".tree li a").live("mouseout", function() {
|
42 |
-
$t = jQuery(this);
|
43 |
-
$actions = $t.find(".cms_tpv_action_view, .cms_tpv_action_edit, .cms_tpv_action_add_page, .cms_tpv_action_add_page_after, .cms_tpv_action_add_page_inside");
|
44 |
-
$actions.hide();
|
45 |
-
/*
|
46 |
-
var func = test($actions);
|
47 |
-
var timeoutID = setTimeout(func, 500);
|
48 |
-
$t.data("timeoutID", timeoutID);
|
49 |
-
*/
|
50 |
-
});
|
51 |
-
|
52 |
-
|
53 |
-
jQuery(".tree li .cms_tpv_action_view").live("mouseover", function() {
|
54 |
-
return true;
|
55 |
-
});
|
56 |
-
jQuery(".tree li .cms_tpv_action_view").live("click", function() {
|
57 |
-
return true;
|
58 |
-
});
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
// go to page on click
|
63 |
-
jQuery(".tree li a .cms_tpv_action_view").live("click", function() {
|
64 |
-
var $li = jQuery(this).closest("li");
|
65 |
-
var permalink = $li.attr("permalink");
|
66 |
-
if (permalink) {
|
67 |
-
document.location = permalink;
|
68 |
-
}
|
69 |
-
return false;
|
70 |
-
});
|
71 |
-
// edit page on click
|
72 |
-
jQuery(".tree li a .cms_tpv_action_edit").live("click", function() {
|
73 |
-
var $a = jQuery(this).closest("a");
|
74 |
-
var editlink = $a.attr("href");
|
75 |
-
if (editlink) {
|
76 |
-
document.location = editlink;
|
77 |
-
}
|
78 |
-
return false;
|
79 |
-
});
|
80 |
-
|
81 |
-
// add page after
|
82 |
-
jQuery(".tree li a .cms_tpv_action_add_page_after").live("click", function() {
|
83 |
-
var new_page_title = prompt("<?php _e("Enter title of new page", 'cms-tree-page-view') ?>", "");
|
84 |
-
if (new_page_title) {
|
85 |
-
var pageID = jQuery(this).closest("li").attr("id");
|
86 |
-
jQuery.post(ajaxurl, {
|
87 |
-
action: "cms_tpv_add_page",
|
88 |
-
pageID: pageID,
|
89 |
-
type: "after",
|
90 |
-
page_title: new_page_title
|
91 |
-
}, function(data, textStatus) {
|
92 |
-
document.location = data;
|
93 |
-
});
|
94 |
-
}
|
95 |
-
return false;
|
96 |
-
});
|
97 |
-
|
98 |
-
// add page inside
|
99 |
-
jQuery(".tree li a .cms_tpv_action_add_page_inside").live("click", function() {
|
100 |
-
var new_page_title = prompt("<?php _e("Enter title of new page", 'cms-tree-page-view') ?>", "");
|
101 |
-
if (new_page_title) {
|
102 |
-
var pageID = jQuery(this).closest("li").attr("id");
|
103 |
-
jQuery.post(ajaxurl, {
|
104 |
-
action: "cms_tpv_add_page",
|
105 |
-
pageID: pageID,
|
106 |
-
type: "inside",
|
107 |
-
page_title: new_page_title
|
108 |
-
}, function(data, textStatus) {
|
109 |
-
document.location = data;
|
110 |
-
});
|
111 |
-
}
|
112 |
-
return false;
|
113 |
-
});
|
114 |
-
|
115 |
-
|
116 |
-
// hide action links on drag
|
117 |
-
jQuery.tree.drag_start = function() {
|
118 |
-
jQuery(".cms_tpv_action_view, .cms_tpv_action_edit, .cms_tpv_action_add_page, .cms_tpv_action_add_page_after, .cms_tpv_action_add_page_inside").hide();
|
119 |
-
}
|
120 |
-
|
121 |
-
var cms_tpv_tree;
|
122 |
-
jQuery(function($) {
|
123 |
-
|
124 |
-
var treeOptions = {
|
125 |
-
data: {
|
126 |
-
async: true,
|
127 |
-
type: "json",
|
128 |
-
opts: {
|
129 |
-
url: ajaxurl + CMS_TPV_AJAXURL + CMS_TPV_VIEW
|
130 |
-
}
|
131 |
-
},
|
132 |
-
ui: {
|
133 |
-
theme_path: CMS_TPV_URL + "scripts/themes/default/style.css", // this setting seems a bit bananas. be sure to check that it works when jstree 1.0 is released
|
134 |
-
theme_name: "default",
|
135 |
-
animation: 200
|
136 |
-
},
|
137 |
-
plugins: {
|
138 |
-
cookie: {
|
139 |
-
prefix: "jstree_",
|
140 |
-
types : {
|
141 |
-
selected: false
|
142 |
-
}
|
143 |
-
}
|
144 |
-
},
|
145 |
-
types: {
|
146 |
-
"default": {
|
147 |
-
icon: {
|
148 |
-
image: CMS_TPV_URL + "images/page_white_text.png"
|
149 |
-
}
|
150 |
-
},
|
151 |
-
"draft": {
|
152 |
-
},
|
153 |
-
"pending": {
|
154 |
-
},
|
155 |
-
"password": {
|
156 |
-
},
|
157 |
-
"future": {
|
158 |
-
}
|
159 |
-
},
|
160 |
-
callback: {
|
161 |
-
// data = array of objects
|
162 |
-
ondata: function(DATA, TREE_OBJ) {
|
163 |
-
|
164 |
-
jQuery.each(DATA, function(index, value) {
|
165 |
-
|
166 |
-
// add number of children and page type and span-actions
|
167 |
-
cms_tree_page_view_add_spans_to_tree_ondata(DATA[index]);
|
168 |
-
|
169 |
-
});
|
170 |
-
return DATA;
|
171 |
-
},
|
172 |
-
|
173 |
-
// select = go and edit
|
174 |
-
// hm..or not...let me think about this... use actions-popup for now
|
175 |
-
// @todo: check if jquery live's click and dblclick can make 1 click = edit, 2 clicks = open
|
176 |
-
// @todo: currently this swallows to many clicks (on links outside the tree for example).
|
177 |
-
// newer version of jquery + next version of jstree is supposed to fix this
|
178 |
-
onselect: function(NODE, TREE_OBJ) {
|
179 |
-
$selected = $(cms_tpv_tree.selected);
|
180 |
-
|
181 |
-
// jquery < 1.4 has problems
|
182 |
-
//if (parseFloat(jQuery.fn.jquery)>=1.4) {
|
183 |
-
// @todo: 1.4 gives us problems too... fix later when jstree v1 is released
|
184 |
-
// live on the action-links does not work here...
|
185 |
-
//return true;
|
186 |
-
//} else {
|
187 |
-
var editLink = $selected.find("a").attr("href");
|
188 |
-
document.location = editLink;
|
189 |
-
//}
|
190 |
-
},
|
191 |
-
|
192 |
-
onmove: function(NODE, REF_NODE, TYPE, TREE_OBJ, RB) {
|
193 |
-
// get ids of our friends
|
194 |
-
var node_id = $( NODE ).attr( "id" );
|
195 |
-
ref_node_id = $( REF_NODE ).attr( "id" );
|
196 |
-
|
197 |
-
// Update parent or menu order
|
198 |
-
$.post(ajaxurl, {
|
199 |
-
action: "cms_tpv_move_page",
|
200 |
-
"node_id": node_id,
|
201 |
-
"ref_node_id": ref_node_id,
|
202 |
-
type: TYPE
|
203 |
-
}, function(data, textStatus) {
|
204 |
-
});
|
205 |
-
|
206 |
-
},
|
207 |
-
|
208 |
-
onsearch: function(NODES, TREE_OBJ) {
|
209 |
-
// if empy nodes = no hits
|
210 |
-
if (NODES.length == 0) {
|
211 |
-
$("#cms_tpv_search_no_hits").show();
|
212 |
-
}
|
213 |
-
NODES.addClass("search");
|
214 |
-
$("#cms_tree_view_search_form_working").fadeOut("fast");
|
215 |
-
}
|
216 |
-
|
217 |
-
}
|
218 |
-
}
|
219 |
-
|
220 |
-
if ($("#cms_tpv_container").length == 1) {
|
221 |
-
$("#cms_tpv_container").tree(treeOptions);
|
222 |
-
cms_tpv_tree = jQuery.tree.reference("#cms_tpv_container");
|
223 |
-
}
|
224 |
-
|
225 |
-
jQuery("#cms_tree_view_search_form").submit(function() {
|
226 |
-
$("#cms_tpv_search_no_hits").hide();
|
227 |
-
var s = jQuery("#cms_tree_view_search").attr("value");
|
228 |
-
s = jQuery.trim( s );
|
229 |
-
// search, oh the mighty search!
|
230 |
-
if (s) {
|
231 |
-
$("#cms_tree_view_search_form_working").fadeIn("fast");
|
232 |
-
}
|
233 |
-
cms_tpv_tree.search(s, "containsNC");
|
234 |
-
return false;
|
235 |
-
});
|
236 |
-
|
237 |
-
|
238 |
-
// open/close links
|
239 |
-
jQuery("#cms_tpv_open_all").click(function() {
|
240 |
-
cms_tpv_tree.open_all();
|
241 |
-
return false;
|
242 |
-
});
|
243 |
-
jQuery("#cms_tpv_close_all").click(function() {
|
244 |
-
cms_tpv_tree.close_all();
|
245 |
-
return false;
|
246 |
-
});
|
247 |
-
|
248 |
-
// view all or public
|
249 |
-
jQuery("#cms_tvp_view_all").click(function() {
|
250 |
-
cms_tvp_set_view("all");
|
251 |
-
jQuery(this).addClass("current");
|
252 |
-
return false;
|
253 |
-
});
|
254 |
-
jQuery("#cms_tvp_view_public").click(function() {
|
255 |
-
cms_tvp_set_view("public");
|
256 |
-
jQuery(this).addClass("current");
|
257 |
-
return false;
|
258 |
-
});
|
259 |
-
|
260 |
-
function cms_tvp_set_view(view) {
|
261 |
-
jQuery("#cms_tpv_working").fadeIn("slow");
|
262 |
-
jQuery("#cms_tvp_view_all,#cms_tvp_view_public").removeClass("current");
|
263 |
-
cms_tpv_tree.settings.data.opts.url = ajaxurl + CMS_TPV_AJAXURL + view;
|
264 |
-
cms_tpv_tree.refresh();
|
265 |
-
jQuery("#cms_tpv_working").fadeOut("slow");
|
266 |
-
}
|
267 |
-
|
268 |
-
|
269 |
-
}); // end ondomready
|
270 |
-
|
271 |
-
|
272 |
-
/**
|
273 |
-
* Add type, children count and span-actions
|
274 |
-
* data is one DATA[index]
|
275 |
-
*/
|
276 |
-
function cms_tree_page_view_add_spans_to_tree_ondata(data) {
|
277 |
-
|
278 |
-
var childCount = data.attributes.childCount;
|
279 |
-
if (childCount > 0) {
|
280 |
-
data.data.title += "<span title='" + childCount + " <?php _e("child pages", 'cms-tree-page-view') ?>" + "' class='child_count'>("+childCount+")</span>";
|
281 |
-
}
|
282 |
-
|
283 |
-
// add page type
|
284 |
-
var rel = data.attributes.rel;
|
285 |
-
if (rel != "publish") {
|
286 |
-
data.data.title = "<span class='post_type post_type_"+rel+"'>"+rel+"</span>" + data.data.title;
|
287 |
-
}
|
288 |
-
|
289 |
-
// add actions that are revealed on mouse over
|
290 |
-
data.data.title += " <span title='<?php _e("Edit page", 'cms-tree-page-view') ?>' class='cms_tpv_action_edit'><?php _e("Edit", 'cms-tree-page-view') ?></span>";
|
291 |
-
data.data.title += " <span title='<?php _e("View page", 'cms-tree-page-view') ?>' class='cms_tpv_action_view'><?php _e("View", 'cms-tree-page-view') ?></span>";
|
292 |
-
|
293 |
-
data.data.title += " <span class='cms_tpv_action_add_page'><?php _e("Add page", 'cms-tree-page-view') ?>:</span>";
|
294 |
-
data.data.title += " <span title='<?php _e("Add new page after", 'cms-tree-page-view') ?>' class='cms_tpv_action_add_page_after'><?php _e("after", 'cms-tree-page-view') ?></span> ";
|
295 |
-
data.data.title += " <span title='<?php _e("Add new page inside", 'cms-tree-page-view') ?>' class='cms_tpv_action_add_page_inside'><?php _e("inside", 'cms-tree-page-view') ?></span>";
|
296 |
-
|
297 |
-
// check if children exists. id they do: update their data too
|
298 |
-
// DATA[index][children] is an array that may exists. in that case we must do this on all kids to...
|
299 |
-
if (data.children) {
|
300 |
-
jQuery.each(data.children, function(index, value) {
|
301 |
-
cms_tree_page_view_add_spans_to_tree_ondata(data.children[index]);
|
302 |
-
});
|
303 |
-
|
304 |
-
}
|
305 |
-
|
306 |
-
return data;
|
307 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*
|
2 |
+
* jsTree 1.0-rc1
|
3 |
+
* http://jstree.com/
|
4 |
+
*
|
5 |
+
* Copyright (c) 2010 Ivan Bozhanov (vakata.com)
|
6 |
+
*
|
7 |
+
* Dual licensed under the MIT and GPL licenses (same as jQuery):
|
8 |
+
* http://www.opensource.org/licenses/mit-license.php
|
9 |
+
* http://www.gnu.org/licenses/gpl.html
|
10 |
+
*
|
11 |
+
* $Date$
|
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";
|
18 |
+
// Common functions not related to jsTree
|
19 |
+
// decided to move them to a `vakata` "namespace"
|
20 |
+
(function ($) {
|
21 |
+
$.vakata = {};
|
22 |
+
// CSS related functions
|
23 |
+
$.vakata.css = {
|
24 |
+
get_css : function(rule_name, delete_flag, sheet) {
|
25 |
+
rule_name = rule_name.toLowerCase();
|
26 |
+
var css_rules = sheet.cssRules || sheet.rules,
|
27 |
+
j = 0;
|
28 |
+
do {
|
29 |
+
if(css_rules.length && j > css_rules.length + 5) { return false; }
|
30 |
+
if(css_rules[j].selectorText && css_rules[j].selectorText.toLowerCase() == rule_name) {
|
31 |
+
if(delete_flag === true) {
|
32 |
+
if(sheet.removeRule) { sheet.removeRule(j); }
|
33 |
+
if(sheet.deleteRule) { sheet.deleteRule(j); }
|
34 |
+
return true;
|
35 |
+
}
|
36 |
+
else { return css_rules[j]; }
|
37 |
+
}
|
38 |
+
}
|
39 |
+
while (css_rules[++j]);
|
40 |
+
return false;
|
41 |
+
},
|
42 |
+
add_css : function(rule_name, sheet) {
|
43 |
+
if($.jstree.css.get_css(rule_name, false, sheet)) { return false; }
|
44 |
+
if(sheet.insertRule) { sheet.insertRule(rule_name + ' { }', 0); } else { sheet.addRule(rule_name, null, 0); }
|
45 |
+
return $.vakata.css.get_css(rule_name);
|
46 |
+
},
|
47 |
+
remove_css : function(rule_name, sheet) {
|
48 |
+
return $.vakata.css.get_css(rule_name, true, sheet);
|
49 |
+
},
|
50 |
+
add_sheet : function(opts) {
|
51 |
+
var tmp;
|
52 |
+
if(opts.str) {
|
53 |
+
tmp = document.createElement("style");
|
54 |
+
tmp.setAttribute('type',"text/css");
|
55 |
+
if(tmp.styleSheet) {
|
56 |
+
document.getElementsByTagName("head")[0].appendChild(tmp);
|
57 |
+
tmp.styleSheet.cssText = opts.str;
|
58 |
+
}
|
59 |
+
else {
|
60 |
+
tmp.appendChild(document.createTextNode(opts.str));
|
61 |
+
document.getElementsByTagName("head")[0].appendChild(tmp);
|
62 |
+
}
|
63 |
+
return tmp.sheet || tmp.styleSheet;
|
64 |
+
}
|
65 |
+
if(opts.url) {
|
66 |
+
if(document.createStyleSheet) {
|
67 |
+
try { tmp = document.createStyleSheet(opts.url); } catch (e) { }
|
68 |
+
}
|
69 |
+
else {
|
70 |
+
tmp = document.createElement('link');
|
71 |
+
tmp.rel = 'stylesheet';
|
72 |
+
tmp.type = 'text/css';
|
73 |
+
tmp.media = "all";
|
74 |
+
tmp.href = opts.url;
|
75 |
+
document.getElementsByTagName("head")[0].appendChild(tmp);
|
76 |
+
return tmp.styleSheet;
|
77 |
+
}
|
78 |
+
}
|
79 |
+
}
|
80 |
+
};
|
81 |
+
})(jQuery);
|
82 |
+
|
83 |
+
/*
|
84 |
+
* jsTree core 1.0
|
85 |
+
*/
|
86 |
+
(function ($) {
|
87 |
+
// private variables
|
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) {
|
95 |
+
var isMethodCall = (typeof settings == 'string'), // is this a method call like $().jstree("open_node")
|
96 |
+
args = Array.prototype.slice.call(arguments, 1),
|
97 |
+
returnValue = this;
|
98 |
+
|
99 |
+
// extend settings and allow for multiple hashes and metadata
|
100 |
+
if(!isMethodCall && $.meta) { args.push($.metadata.get(this).jstree); }
|
101 |
+
settings = !isMethodCall && args.length ? $.extend.apply(null, [true, settings].concat(args)) : settings;
|
102 |
+
// block calls to "private" methods
|
103 |
+
if(isMethodCall && settings.substring(0, 1) == '_') { return returnValue; }
|
104 |
+
|
105 |
+
// if a method call execute the method on all selected instances
|
106 |
+
if(isMethodCall) {
|
107 |
+
this.each(function() {
|
108 |
+
var instance = instances[$.data(this, "jstree-instance-id")],
|
109 |
+
methodValue = (instance && $.isFunction(instance[settings])) ? instance[settings].apply(instance, args) : instance;
|
110 |
+
if(typeof methodValue !== "undefined" && (settings.indexOf("is_" === 0) || (methodValue !== true && methodValue !== false))) { returnValue = methodValue; return false; }
|
111 |
+
});
|
112 |
+
}
|
113 |
+
else {
|
114 |
+
this.each(function() {
|
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
|
122 |
+
$.data(this, "jstree-instance-id", instance_id);
|
123 |
+
// clean up all plugins
|
124 |
+
if(!settings) { settings = {}; }
|
125 |
+
settings.plugins = $.isArray(settings.plugins) ? settings.plugins : $.jstree.defaults.plugins;
|
126 |
+
if($.inArray("core", settings.plugins) === -1) { settings.plugins.unshift("core"); }
|
127 |
+
|
128 |
+
// only unique plugins (NOT WORKING)
|
129 |
+
// settings.plugins = settings.plugins.sort().join(",,").replace(/(,|^)([^,]+)(,,\2)+(,|$)/g,"$1$2$4").replace(/,,+/g,",").replace(/,$/,"").split(",");
|
130 |
+
|
131 |
+
// extend defaults with passed data
|
132 |
+
s = $.extend(true, {}, $.jstree.defaults, settings);
|
133 |
+
s.plugins = settings.plugins;
|
134 |
+
$.each(plugins, function (i, val) { if($.inArray(i, s.plugins) === -1) { s[i] = null; delete s[i]; } });
|
135 |
+
// push the new object to the instances array (at the same time set the default classes to the container) and init
|
136 |
+
instances[instance_id] = new $.jstree._instance(instance_id, $(this).addClass("jstree jstree-" + instance_id), s);
|
137 |
+
// init all activated plugins for this instance
|
138 |
+
$.each(instances[instance_id]._get_settings().plugins, function (i, val) { instances[instance_id].data[val] = {}; });
|
139 |
+
$.each(instances[instance_id]._get_settings().plugins, function (i, val) { if(plugins[val]) { plugins[val].__init.apply(instances[instance_id]); } });
|
140 |
+
// initialize the instance
|
141 |
+
instances[instance_id].init();
|
142 |
+
});
|
143 |
+
}
|
144 |
+
// return the jquery selection (or if it was a method call that returned a value - the returned value)
|
145 |
+
return returnValue;
|
146 |
+
};
|
147 |
+
// object to store exposed functions and objects
|
148 |
+
$.jstree = {
|
149 |
+
defaults : {
|
150 |
+
plugins : []
|
151 |
+
},
|
152 |
+
_focused : function () { return instances[focused_instance] || null; },
|
153 |
+
_reference : function (needle) {
|
154 |
+
// get by instance id
|
155 |
+
if(instances[needle]) { return instances[needle]; }
|
156 |
+
// get by DOM (if still no luck - return null
|
157 |
+
var o = $(needle);
|
158 |
+
if(!o.length && typeof needle === "string") { o = $("#" + needle); }
|
159 |
+
if(!o.length) { return null; }
|
160 |
+
return instances[o.closest(".jstree").data("jstree-instance-id")] || null;
|
161 |
+
},
|
162 |
+
_instance : function (index, container, settings) {
|
163 |
+
// for plugins to store data in
|
164 |
+
this.data = { core : {} };
|
165 |
+
this.get_settings = function () { return $.extend(true, {}, settings); };
|
166 |
+
this._get_settings = function () { return settings; };
|
167 |
+
this.get_index = function () { return index; };
|
168 |
+
this.get_container = function () { return container; };
|
169 |
+
this._set_settings = function (s) {
|
170 |
+
settings = $.extend(true, {}, settings, s);
|
171 |
+
};
|
172 |
+
},
|
173 |
+
_fn : { },
|
174 |
+
plugin : function (pname, pdata) {
|
175 |
+
pdata = $.extend({}, {
|
176 |
+
__init : $.noop,
|
177 |
+
__destroy : $.noop,
|
178 |
+
_fn : {},
|
179 |
+
defaults : false
|
180 |
+
}, pdata);
|
181 |
+
plugins[pname] = pdata;
|
182 |
+
|
183 |
+
$.jstree.defaults[pname] = pdata.defaults;
|
184 |
+
$.each(pdata._fn, function (i, val) {
|
185 |
+
val.plugin = pname;
|
186 |
+
val.old = $.jstree._fn[i];
|
187 |
+
$.jstree._fn[i] = function () {
|
188 |
+
var rslt,
|
189 |
+
func = val,
|
190 |
+
args = Array.prototype.slice.call(arguments),
|
191 |
+
evnt = new $.Event("before.jstree"),
|
192 |
+
rlbk = false;
|
193 |
+
|
194 |
+
// Check if function belongs to the included plugins of this instance
|
195 |
+
do {
|
196 |
+
if(func && func.plugin && $.inArray(func.plugin, this._get_settings().plugins) !== -1) { break; }
|
197 |
+
func = func.old;
|
198 |
+
} while(func);
|
199 |
+
if(!func) { return; }
|
200 |
+
|
201 |
+
// a chance to stop execution (or change arguments):
|
202 |
+
// * just bind to jstree.before
|
203 |
+
// * check the additional data object (func property)
|
204 |
+
// * call event.stopImmediatePropagation()
|
205 |
+
// * return false (or an array of arguments)
|
206 |
+
rslt = this.get_container().triggerHandler(evnt, { "func" : i, "inst" : this, "args" : args });
|
207 |
+
if(rslt === false) { return; }
|
208 |
+
if(typeof rslt !== "undefined") { args = rslt; }
|
209 |
+
|
210 |
+
// context and function to trigger events, then finally call the function
|
211 |
+
if(i.indexOf("_") === 0) {
|
212 |
+
rslt = func.apply(this, args);
|
213 |
+
}
|
214 |
+
else {
|
215 |
+
rslt = func.apply(
|
216 |
+
$.extend({}, this, {
|
217 |
+
__callback : function (data) {
|
218 |
+
this.get_container().triggerHandler( i + '.jstree', { "inst" : this, "args" : args, "rslt" : data, "rlbk" : rlbk });
|
219 |
+
},
|
220 |
+
__rollback : function () {
|
221 |
+
rlbk = this.get_rollback();
|
222 |
+
return rlbk;
|
223 |
+
},
|
224 |
+
__call_old : function (replace_arguments) {
|
225 |
+
return func.old.apply(this, (replace_arguments ? Array.prototype.slice.call(arguments, 1) : args ) );
|
226 |
+
}
|
227 |
+
}), args);
|
228 |
+
}
|
229 |
+
|
230 |
+
// return the result
|
231 |
+
return rslt;
|
232 |
+
};
|
233 |
+
$.jstree._fn[i].old = val.old;
|
234 |
+
$.jstree._fn[i].plugin = pname;
|
235 |
+
});
|
236 |
+
},
|
237 |
+
rollback : function (rb) {
|
238 |
+
if(rb) {
|
239 |
+
if(!$.isArray(rb)) { rb = [ rb ]; }
|
240 |
+
$.each(rb, function (i, val) {
|
241 |
+
instances[val.i].set_rollback(val.h, val.d);
|
242 |
+
});
|
243 |
+
}
|
244 |
+
}
|
245 |
+
};
|
246 |
+
// set the prototype for all instances
|
247 |
+
$.jstree._fn = $.jstree._instance.prototype = {};
|
248 |
+
|
249 |
+
// css functions - used internally
|
250 |
+
|
251 |
+
// load the css when DOM is ready
|
252 |
+
$(function() {
|
253 |
+
// code is copied form jQuery ($.browser is deprecated + there is a bug in IE)
|
254 |
+
var u = navigator.userAgent.toLowerCase(),
|
255 |
+
v = (u.match( /.+?(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [0,'0'])[1],
|
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) {
|
279 |
+
css_string += '.jstree li a { border-width:0 !important; padding:0px 2px !important; } ';
|
280 |
+
}
|
281 |
+
$.vakata.css.add_sheet({ str : css_string });
|
282 |
+
});
|
283 |
+
|
284 |
+
// core functions (open, close, create, update, delete)
|
285 |
+
$.jstree.plugin("core", {
|
286 |
+
__init : function () {
|
287 |
+
this.data.core.to_open = $.map($.makeArray(this.get_settings().core.initially_open), function (n) { return "#" + n.toString().replace(/^#/,"").replace('\\/','/').replace('/','\\/'); });
|
288 |
+
},
|
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> </ins><a class='jstree-loading' href='#'><ins class='jstree-icon'> </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()
|
301 |
+
.delegate("li > ins", "click.jstree", $.proxy(function (event) {
|
302 |
+
var trgt = $(event.target);
|
303 |
+
if(trgt.is("ins") && event.pageY - trgt.offset().top < this.data.core.li_height) { this.toggle_node(trgt); }
|
304 |
+
}, this))
|
305 |
+
.bind("mousedown.jstree", $.proxy(function () {
|
306 |
+
this.set_focus(); // This used to be setTimeout(set_focus,0) - why?
|
307 |
+
}, this))
|
308 |
+
.bind("dblclick.jstree", function (event) {
|
309 |
+
var sel;
|
310 |
+
if(document.selection && document.selection.empty) { document.selection.empty(); }
|
311 |
+
else {
|
312 |
+
if(window.getSelection) {
|
313 |
+
sel = window.getSelection();
|
314 |
+
try {
|
315 |
+
sel.removeAllRanges();
|
316 |
+
sel.collapse();
|
317 |
+
} catch (err) { }
|
318 |
+
}
|
319 |
+
}
|
320 |
+
});
|
321 |
+
this.__callback();
|
322 |
+
this.load_node(-1, function () { this.loaded(); this.reopen(); });
|
323 |
+
},
|
324 |
+
destroy : function () {
|
325 |
+
var i,
|
326 |
+
n = this.get_index(),
|
327 |
+
s = this._get_settings(),
|
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
|
335 |
+
if(this.is_focused()) {
|
336 |
+
for(i in instances) {
|
337 |
+
if(instances.hasOwnProperty(i) && i != n) {
|
338 |
+
instances[i].set_focus();
|
339 |
+
break;
|
340 |
+
}
|
341 |
+
}
|
342 |
+
}
|
343 |
+
// if no other instance found
|
344 |
+
if(n === focused_instance) { focused_instance = -1; }
|
345 |
+
// remove all traces of jstree in the DOM (only the ones set using jstree*) and cleans all events
|
346 |
+
this.get_container()
|
347 |
+
.unbind(".jstree")
|
348 |
+
.undelegate(".jstree")
|
349 |
+
.removeData("jstree-instance-id")
|
350 |
+
.find("[class^='jstree']")
|
351 |
+
.andSelf()
|
352 |
+
.attr("class", function () { return this.className.replace(/jstree[^ ]*|$/ig,''); });
|
353 |
+
// remove the actual data
|
354 |
+
instances[n] = null;
|
355 |
+
delete instances[n];
|
356 |
+
},
|
357 |
+
save_opened : function () {
|
358 |
+
var _this = this;
|
359 |
+
this.data.core.to_open = [];
|
360 |
+
this.get_container().find(".jstree-open").each(function () {
|
361 |
+
_this.data.core.to_open.push("#" + this.id.toString().replace(/^#/,"").replace('\\/','/').replace('/','\\/'));
|
362 |
+
});
|
363 |
+
this.__callback(_this.data.core.to_open);
|
364 |
+
},
|
365 |
+
reopen : function (is_callback) {
|
366 |
+
var _this = this,
|
367 |
+
done = true,
|
368 |
+
current = [],
|
369 |
+
remaining = [];
|
370 |
+
if(!is_callback) { this.data.core.reopen = false; this.data.core.refreshing = true; }
|
371 |
+
if(this.data.core.to_open.length) {
|
372 |
+
$.each(this.data.core.to_open, function (i, val) {
|
373 |
+
if(val == "#") { return true; }
|
374 |
+
if($(val).length && $(val).is(".jstree-closed")) { current.push(val); }
|
375 |
+
else { remaining.push(val); }
|
376 |
+
});
|
377 |
+
if(current.length) {
|
378 |
+
this.data.core.to_open = remaining;
|
379 |
+
$.each(current, function (i, val) {
|
380 |
+
_this.open_node(val, function () { _this.reopen(true); }, true);
|
381 |
+
});
|
382 |
+
done = false;
|
383 |
+
}
|
384 |
+
}
|
385 |
+
if(done) {
|
386 |
+
// TODO: find a more elegant approach to syncronizing returning requests
|
387 |
+
if(this.data.core.reopen) { clearTimeout(this.data.core.reopen); }
|
388 |
+
this.data.core.reopen = setTimeout(function () { _this.__callback({}, _this); }, 50);
|
389 |
+
this.data.core.refreshing = false;
|
390 |
+
}
|
391 |
+
},
|
392 |
+
refresh : function (obj) {
|
393 |
+
var _this = this;
|
394 |
+
this.save_opened();
|
395 |
+
if(!obj) { obj = -1; }
|
396 |
+
obj = this._get_node(obj);
|
397 |
+
if(!obj) { obj = -1; }
|
398 |
+
if(obj !== -1) { obj.children("UL").remove(); }
|
399 |
+
this.load_node(obj, function () { _this.__callback({ "obj" : obj}); _this.reopen(); });
|
400 |
+
},
|
401 |
+
// Dummy function to fire after the first load (so that there is a jstree.loaded event)
|
402 |
+
loaded : function () {
|
403 |
+
this.__callback();
|
404 |
+
},
|
405 |
+
// deal with focus
|
406 |
+
set_focus : function () {
|
407 |
+
var f = $.jstree._focused();
|
408 |
+
if(f && f !== this) {
|
409 |
+
f.get_container().removeClass("jstree-focused");
|
410 |
+
}
|
411 |
+
if(f !== this) {
|
412 |
+
this.get_container().addClass("jstree-focused");
|
413 |
+
focused_instance = this.get_index();
|
414 |
+
}
|
415 |
+
this.__callback();
|
416 |
+
},
|
417 |
+
is_focused : function () {
|
418 |
+
return focused_instance == this.get_index();
|
419 |
+
},
|
420 |
+
|
421 |
+
// traverse
|
422 |
+
_get_node : function (obj) {
|
423 |
+
var $obj = $(obj, this.get_container());
|
424 |
+
if($obj.is(".jstree") || obj == -1) { return -1; }
|
425 |
+
$obj = $obj.closest("li", this.get_container());
|
426 |
+
return $obj.length ? $obj : false;
|
427 |
+
},
|
428 |
+
_get_next : function (obj, strict) {
|
429 |
+
obj = this._get_node(obj);
|
430 |
+
if(obj === -1) { return this.get_container().find("> ul > li:first-child"); }
|
431 |
+
if(!obj.length) { return false; }
|
432 |
+
if(strict) { return (obj.nextAll("li").size() > 0) ? obj.nextAll("li:eq(0)") : false; }
|
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);
|
440 |
+
if(obj === -1) { return this.get_container().find("> ul > li:last-child"); }
|
441 |
+
if(!obj.length) { return false; }
|
442 |
+
if(strict) { return (obj.prevAll("li").length > 0) ? obj.prevAll("li:eq(0)") : false; }
|
443 |
+
|
444 |
+
if(obj.prev("li").length) {
|
445 |
+
obj = obj.prev("li").eq(0);
|
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) {
|
458 |
+
obj = this._get_node(obj);
|
459 |
+
if(obj === -1) { return this.get_container().children("ul:eq(0)").children("li"); }
|
460 |
+
if(!obj.length) { return false; }
|
461 |
+
return obj.children("ul:eq(0)").children("li");
|
462 |
+
},
|
463 |
+
get_path : function (obj, id_mode) {
|
464 |
+
var p = [],
|
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();
|
472 |
+
p.push( id_mode ? obj.attr("id") : this.get_text(obj) );
|
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");
|
484 |
+
this.load_node(obj, function () { t.open_node(obj, callback, skip_animation); }, callback);
|
485 |
+
}
|
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) {
|
504 |
+
obj = this._get_node(obj);
|
505 |
+
if(obj.hasClass("jstree-closed")) { return this.open_node(obj); }
|
506 |
+
if(obj.hasClass("jstree-open")) { return this.close_node(obj); }
|
507 |
+
},
|
508 |
+
open_all : function (obj, original_obj) {
|
509 |
+
obj = obj ? this._get_node(obj) : this.get_container();
|
510 |
+
if(!obj || obj === -1) { obj = this.get_container(); }
|
511 |
+
if(original_obj) {
|
512 |
+
obj = obj.find("li.jstree-closed");
|
513 |
+
}
|
514 |
+
else {
|
515 |
+
original_obj = obj;
|
516 |
+
if(obj.is(".jstree-closed")) { obj = obj.find("li.jstree-closed").andSelf(); }
|
517 |
+
else { obj = obj.find("li.jstree-closed"); }
|
518 |
+
}
|
519 |
+
var _this = this;
|
520 |
+
obj.each(function () {
|
521 |
+
var __this = this;
|
522 |
+
if(!_this._is_loaded(this)) { _this.open_node(this, function() { _this.open_all(__this, original_obj); }, true); }
|
523 |
+
else { _this.open_node(this, false, true); }
|
524 |
+
});
|
525 |
+
// so that callback is fired AFTER all nodes are open
|
526 |
+
if(original_obj.find('li.jstree-closed').length === 0) { this.__callback({ "obj" : original_obj }); }
|
527 |
+
},
|
528 |
+
close_all : function (obj) {
|
529 |
+
var _this = this;
|
530 |
+
obj = obj ? this._get_node(obj) : this.get_container();
|
531 |
+
if(!obj || obj === -1) { obj = this.get_container(); }
|
532 |
+
obj.find("li.jstree-open").andSelf().each(function () { _this.close_node(this); });
|
533 |
+
this.__callback({ "obj" : obj });
|
534 |
+
},
|
535 |
+
clean_node : function (obj) {
|
536 |
+
obj = obj && obj != -1 ? $(obj) : this.get_container();
|
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
|
546 |
+
get_rollback : function () {
|
547 |
+
this.__callback();
|
548 |
+
return { i : this.get_index(), h : this.get_container().children("ul").clone(true), d : this.data };
|
549 |
+
},
|
550 |
+
set_rollback : function (html, data) {
|
551 |
+
this.get_container().empty().append(html);
|
552 |
+
this.data = data;
|
553 |
+
this.__callback();
|
554 |
+
},
|
555 |
+
// Dummy functions to be overwritten by any datastore plugin included
|
556 |
+
load_node : function (obj, s_call, e_call) { this.__callback({ "obj" : obj }); },
|
557 |
+
_is_loaded : function (obj) { return true; },
|
558 |
+
|
559 |
+
// Basic operations: create
|
560 |
+
create_node : function (obj, position, js, callback, is_loaded) {
|
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; }
|
568 |
+
if(!is_loaded && !this._is_loaded(obj)) { this.load_node(obj, function () { this.create_node(obj, position, js, callback, true); }); return false; }
|
569 |
+
|
570 |
+
this.__rollback();
|
571 |
+
|
572 |
+
if(typeof js === "string") { js = { "data" : js }; }
|
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'> </ins>");
|
589 |
+
if(m.icon) {
|
590 |
+
if(m.icon.indexOf("/") === -1) { tmp.children("ins").addClass(m.icon); }
|
591 |
+
else { tmp.children("ins").css("background","url('" + m.icon + "') center center no-repeat"); }
|
592 |
+
}
|
593 |
+
d.append(tmp);
|
594 |
+
});
|
595 |
+
d.prepend("<ins class='jstree-icon'> </ins>");
|
596 |
+
if(obj === -1) {
|
597 |
+
obj = this.get_container();
|
598 |
+
if(position === "before") { position = "first"; }
|
599 |
+
if(position === "after") { position = "last"; }
|
600 |
+
}
|
601 |
+
switch(position) {
|
602 |
+
case "before": obj.before(d); tmp = this._get_parent(obj); break;
|
603 |
+
case "after" : obj.after(d); tmp = this._get_parent(obj); break;
|
604 |
+
case "inside":
|
605 |
+
case "first" :
|
606 |
+
if(!obj.children("ul").length) { obj.append("<ul>"); }
|
607 |
+
obj.children("ul").prepend(d);
|
608 |
+
tmp = obj;
|
609 |
+
break;
|
610 |
+
case "last":
|
611 |
+
if(!obj.children("ul").length) { obj.append("<ul>"); }
|
612 |
+
obj.children("ul").append(d);
|
613 |
+
tmp = obj;
|
614 |
+
break;
|
615 |
+
default:
|
616 |
+
if(!obj.children("ul").length) { obj.append("<ul>"); }
|
617 |
+
if(!position) { position = 0; }
|
618 |
+
tmp = obj.children("ul").children("li").eq(position);
|
619 |
+
if(tmp.length) { tmp.before(d); }
|
620 |
+
else { obj.children("ul").append(d); }
|
621 |
+
tmp = obj;
|
622 |
+
break;
|
623 |
+
}
|
624 |
+
if(tmp === -1 || tmp.get(0) === this.get_container().get(0)) { tmp = -1; }
|
625 |
+
this.clean_node(tmp);
|
626 |
+
this.__callback({ "obj" : d, "parent" : tmp });
|
627 |
+
if(callback) { callback.call(this, d); }
|
628 |
+
return d;
|
629 |
+
},
|
630 |
+
// Basic operations: rename (deal with text)
|
631 |
+
get_text : function (obj) {
|
632 |
+
obj = this._get_node(obj);
|
633 |
+
if(!obj.length) { return false; }
|
634 |
+
var s = this._get_settings().core.html_titles;
|
635 |
+
obj = obj.children("a:eq(0)");
|
636 |
+
if(s) {
|
637 |
+
obj = obj.clone();
|
638 |
+
obj.children("INS").remove();
|
639 |
+
return obj.html();
|
640 |
+
}
|
641 |
+
else {
|
642 |
+
obj = obj.contents().filter(function() { return this.nodeType == 3; })[0];
|
643 |
+
return obj.nodeValue;
|
644 |
+
}
|
645 |
+
},
|
646 |
+
set_text : function (obj, val) {
|
647 |
+
obj = this._get_node(obj);
|
648 |
+
if(!obj.length) { return false; }
|
649 |
+
obj = obj.children("a:eq(0)");
|
650 |
+
if(this._get_settings().core.html_titles) {
|
651 |
+
var tmp = obj.children("INS").clone();
|
652 |
+
obj.html(val).prepend(tmp);
|
653 |
+
this.__callback({ "obj" : obj, "name" : val });
|
654 |
+
return true;
|
655 |
+
}
|
656 |
+
else {
|
657 |
+
obj = obj.contents().filter(function() { return this.nodeType == 3; })[0];
|
658 |
+
this.__callback({ "obj" : obj, "name" : val });
|
659 |
+
return (obj.nodeValue = val);
|
660 |
+
}
|
661 |
+
},
|
662 |
+
rename_node : function (obj, val) {
|
663 |
+
obj = this._get_node(obj);
|
664 |
+
this.__rollback();
|
665 |
+
if(obj && obj.length && this.set_text.apply(this, Array.prototype.slice.call(arguments))) { this.__callback({ "obj" : obj, "name" : val }); }
|
666 |
+
},
|
667 |
+
// Basic operations: deleting nodes
|
668 |
+
delete_node : function (obj) {
|
669 |
+
obj = this._get_node(obj);
|
670 |
+
if(!obj.length) { return false; }
|
671 |
+
this.__rollback();
|
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 });
|
679 |
+
return obj;
|
680 |
+
},
|
681 |
+
prepare_move : function (o, r, pos, cb, is_cb) {
|
682 |
+
var p = {};
|
683 |
+
|
684 |
+
p.ot = $.jstree._reference(p.o) || this;
|
685 |
+
p.o = p.ot._get_node(o);
|
686 |
+
p.r = r === - 1 ? -1 : this._get_node(r);
|
687 |
+
p.p = (typeof p === "undefined") ? "last" : pos; // TODO: move to a setting
|
688 |
+
if(!is_cb && prepared_move.o && prepared_move.o[0] === p.o[0] && prepared_move.r[0] === p.r[0] && prepared_move.p === p.p) {
|
689 |
+
this.__callback(prepared_move);
|
690 |
+
if(cb) { cb.call(this, prepared_move); }
|
691 |
+
return;
|
692 |
+
}
|
693 |
+
p.ot = $.jstree._reference(p.o) || this;
|
694 |
+
p.rt = r === -1 ? p.ot : $.jstree._reference(p.r) || this;
|
695 |
+
if(p.r === -1) {
|
696 |
+
p.cr = -1;
|
697 |
+
switch(p.p) {
|
698 |
+
case "first":
|
699 |
+
case "before":
|
700 |
+
case "inside":
|
701 |
+
p.cp = 0;
|
702 |
+
break;
|
703 |
+
case "after":
|
704 |
+
case "last":
|
705 |
+
p.cp = p.rt.get_container().find(" > ul > li").length;
|
706 |
+
break;
|
707 |
+
default:
|
708 |
+
p.cp = p.p;
|
709 |
+
break;
|
710 |
+
}
|
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":
|
718 |
+
p.cp = p.r.index();
|
719 |
+
p.cr = p.rt._get_parent(p.r);
|
720 |
+
break;
|
721 |
+
case "after":
|
722 |
+
p.cp = p.r.index() + 1;
|
723 |
+
p.cr = p.rt._get_parent(p.r);
|
724 |
+
break;
|
725 |
+
case "inside":
|
726 |
+
case "first":
|
727 |
+
p.cp = 0;
|
728 |
+
p.cr = p.r;
|
729 |
+
break;
|
730 |
+
case "last":
|
731 |
+
p.cp = p.r.find(" > ul > li").length;
|
732 |
+
p.cr = p.r;
|
733 |
+
break;
|
734 |
+
default:
|
735 |
+
p.cp = p.p;
|
736 |
+
p.cr = p.r;
|
737 |
+
break;
|
738 |
+
}
|
739 |
+
}
|
740 |
+
p.np = p.cr == -1 ? p.rt.get_container() : p.cr;
|
741 |
+
p.op = p.ot._get_parent(p.o);
|
742 |
+
p.or = p.np.find(" > ul > li:nth-child(" + (p.cp + 1) + ")");
|
743 |
+
|
744 |
+
prepared_move = p;
|
745 |
+
this.__callback(prepared_move);
|
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) {
|
755 |
+
return this.prepare_move(obj, ref, position, function (p) {
|
756 |
+
this.move_node(p, false, false, is_copy, true, skip_check);
|
757 |
+
});
|
758 |
+
}
|
759 |
+
if(!skip_check && !this.check_move()) { return false; }
|
760 |
+
|
761 |
+
this.__rollback();
|
762 |
+
var o = false;
|
763 |
+
if(is_copy) {
|
764 |
+
o = obj.o.clone();
|
765 |
+
o.find("*[id]").andSelf().each(function () {
|
766 |
+
if(this.id) { this.id = "copy_" + this.id; }
|
767 |
+
});
|
768 |
+
}
|
769 |
+
else { o = obj.o; }
|
770 |
+
|
771 |
+
if(obj.or.length) { obj.or.before(o); }
|
772 |
+
else {
|
773 |
+
if(!obj.np.children("ul").length) { $("<ul>").appendTo(obj.np); }
|
774 |
+
obj.np.children("ul:eq(0)").append(o);
|
775 |
+
}
|
776 |
+
|
777 |
+
try {
|
778 |
+
obj.ot.clean_node(obj.op);
|
779 |
+
obj.rt.clean_node(obj.np);
|
780 |
+
if(!obj.op.find("> ul > li").length) {
|
781 |
+
obj.op.removeClass("jstree-open jstree-closed").addClass("jstree-leaf").children("ul").remove();
|
782 |
+
}
|
783 |
+
} catch (e) { }
|
784 |
+
|
785 |
+
if(is_copy) {
|
786 |
+
prepared_move.cy = true;
|
787 |
+
prepared_move.oc = o;
|
788 |
+
}
|
789 |
+
this.__callback(prepared_move);
|
790 |
+
return prepared_move;
|
791 |
+
},
|
792 |
+
_get_move : function () { return prepared_move; }
|
793 |
+
}
|
794 |
+
});
|
795 |
+
})(jQuery);
|
796 |
+
//*/
|
797 |
+
|
798 |
+
/*
|
799 |
+
* jsTree ui plugin 1.0
|
800 |
+
* This plugins handles selecting/deselecting/hovering/dehovering nodes
|
801 |
+
*/
|
802 |
+
(function ($) {
|
803 |
+
$.jstree.plugin("ui", {
|
804 |
+
__init : function () {
|
805 |
+
this.data.ui.selected = $();
|
806 |
+
this.data.ui.last_selected = false;
|
807 |
+
this.data.ui.hovered = null;
|
808 |
+
this.data.ui.to_select = this.get_settings().ui.initially_select;
|
809 |
+
|
810 |
+
this.get_container()
|
811 |
+
.delegate("a", "click.jstree", $.proxy(function (event) {
|
812 |
+
event.preventDefault();
|
813 |
+
this.select_node(event.currentTarget, true, event);
|
814 |
+
}, this))
|
815 |
+
.delegate("a", "mouseenter.jstree", $.proxy(function (event) {
|
816 |
+
this.hover_node(event.target);
|
817 |
+
}, this))
|
818 |
+
.delegate("a", "mouseleave.jstree", $.proxy(function (event) {
|
819 |
+
this.dehover_node(event.target);
|
820 |
+
}, this))
|
821 |
+
.bind("reopen.jstree", $.proxy(function () {
|
822 |
+
this.reselect();
|
823 |
+
}, this))
|
824 |
+
.bind("get_rollback.jstree", $.proxy(function () {
|
825 |
+
this.dehover_node();
|
826 |
+
this.save_selected();
|
827 |
+
}, this))
|
828 |
+
.bind("set_rollback.jstree", $.proxy(function () {
|
829 |
+
this.reselect();
|
830 |
+
}, this))
|
831 |
+
.bind("close_node.jstree", $.proxy(function (event, data) {
|
832 |
+
var s = this._get_settings().ui,
|
833 |
+
obj = this._get_node(data.rslt.obj),
|
834 |
+
clk = (obj && obj.length) ? obj.children("ul").find(".jstree-clicked") : $(),
|
835 |
+
_this = this;
|
836 |
+
if(s.selected_parent_close === false || !clk.length) { return; }
|
837 |
+
clk.each(function () {
|
838 |
+
_this.deselect_node(this);
|
839 |
+
if(s.selected_parent_close === "select_parent") { _this.select_node(obj); }
|
840 |
+
});
|
841 |
+
}, this))
|
842 |
+
.bind("delete_node.jstree", $.proxy(function (event, data) {
|
843 |
+
var s = this._get_settings().ui.select_prev_on_delete,
|
844 |
+
obj = this._get_node(data.rslt.obj),
|
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) {
|
852 |
+
data.rslt.oc.find(".jstree-clicked").removeClass("jstree-clicked");
|
853 |
+
}
|
854 |
+
}, this));
|
855 |
+
},
|
856 |
+
defaults : {
|
857 |
+
select_limit : -1, // 0, 1, 2 ... or -1 for unlimited
|
858 |
+
select_multiple_modifier : "ctrl", // on, or ctrl, shift, alt
|
859 |
+
selected_parent_close : "select_parent", // false, "deselect", "select_parent"
|
860 |
+
select_prev_on_delete : true,
|
861 |
+
disable_selecting_children : false,
|
862 |
+
initially_select : []
|
863 |
+
},
|
864 |
+
_fn : {
|
865 |
+
_get_node : function (obj, allow_multiple) {
|
866 |
+
if(typeof obj === "undefined" || obj === null) { return allow_multiple ? this.data.ui.selected : this.data.ui.last_selected; }
|
867 |
+
var $obj = $(obj, this.get_container());
|
868 |
+
if($obj.is(".jstree") || obj == -1) { return -1; }
|
869 |
+
$obj = $obj.closest("li", this.get_container());
|
870 |
+
return $obj.length ? $obj : false;
|
871 |
+
},
|
872 |
+
save_selected : function () {
|
873 |
+
var _this = this;
|
874 |
+
this.data.ui.to_select = [];
|
875 |
+
this.data.ui.selected.each(function () { _this.data.ui.to_select.push("#" + this.id.toString().replace(/^#/,"").replace('\\/','/').replace('/','\\/')); });
|
876 |
+
this.__callback(this.data.ui.to_select);
|
877 |
+
},
|
878 |
+
reselect : function () {
|
879 |
+
var _this = this,
|
880 |
+
s = this.data.ui.to_select;
|
881 |
+
s = $.map($.makeArray(s), function (n) { return "#" + n.toString().replace(/^#/,"").replace('\\/','/').replace('/','\\/'); });
|
882 |
+
this.deselect_all();
|
883 |
+
$.each(s, function (i, val) { if(val && val !== "#") { _this.select_node(val); } });
|
884 |
+
this.__callback();
|
885 |
+
},
|
886 |
+
refresh : function (obj) {
|
887 |
+
this.save_selected();
|
888 |
+
return this.__call_old();
|
889 |
+
},
|
890 |
+
hover_node : function (obj) {
|
891 |
+
obj = this._get_node(obj);
|
892 |
+
if(!obj.length) { return false; }
|
893 |
+
//if(this.data.ui.hovered && obj.get(0) === this.data.ui.hovered.get(0)) { return; }
|
894 |
+
if(!obj.hasClass("jstree-hovered")) { this.dehover_node(); }
|
895 |
+
this.data.ui.hovered = obj.children("a").addClass("jstree-hovered").parent();
|
896 |
+
this.__callback({ "obj" : obj });
|
897 |
+
},
|
898 |
+
dehover_node : function () {
|
899 |
+
var obj = this.data.ui.hovered, p;
|
900 |
+
if(!obj || !obj.length) { return false; }
|
901 |
+
p = obj.children("a").removeClass("jstree-hovered").parent();
|
902 |
+
if(this.data.ui.hovered[0] === p[0]) { this.data.ui.hovered = null; }
|
903 |
+
this.__callback({ "obj" : obj });
|
904 |
+
},
|
905 |
+
select_node : function (obj, check, e) {
|
906 |
+
obj = this._get_node(obj);
|
907 |
+
if(obj == -1 || !obj || !obj.length) { return false; }
|
908 |
+
var s = this._get_settings().ui,
|
909 |
+
is_multiple = (s.select_multiple_modifier == "on" || (s.select_multiple_modifier !== false && e && e[s.select_multiple_modifier + "Key"])),
|
910 |
+
is_selected = this.is_selected(obj),
|
911 |
+
proceed = true;
|
912 |
+
if(check) {
|
913 |
+
if(s.disable_selecting_children && is_multiple && obj.parents("li", this.get_container()).children(".jstree-clicked").length) {
|
914 |
+
return false;
|
915 |
+
}
|
916 |
+
proceed = false;
|
917 |
+
switch(!0) {
|
918 |
+
case (is_selected && !is_multiple):
|
919 |
+
this.deselect_all();
|
920 |
+
is_selected = false;
|
921 |
+
proceed = true;
|
922 |
+
break;
|
923 |
+
case (!is_selected && !is_multiple):
|
924 |
+
if(s.select_limit == -1 || s.select_limit > 0) {
|
925 |
+
this.deselect_all();
|
926 |
+
proceed = true;
|
927 |
+
}
|
928 |
+
break;
|
929 |
+
case (is_selected && is_multiple):
|
930 |
+
this.deselect_node(obj);
|
931 |
+
break;
|
932 |
+
case (!is_selected && is_multiple):
|
933 |
+
if(s.select_limit == -1 || this.data.ui.selected.length + 1 <= s.select_limit) {
|
934 |
+
proceed = true;
|
935 |
+
}
|
936 |
+
break;
|
937 |
+
}
|
938 |
+
}
|
939 |
+
if(proceed && !is_selected) {
|
940 |
+
obj.children("a").addClass("jstree-clicked");
|
941 |
+
this.data.ui.selected = this.data.ui.selected.add(obj);
|
942 |
+
this.data.ui.last_selected = obj;
|
943 |
+
this.__callback({ "obj" : obj });
|
944 |
+
}
|
945 |
+
},
|
946 |
+
deselect_node : function (obj) {
|
947 |
+
obj = this._get_node(obj);
|
948 |
+
if(!obj.length) { return false; }
|
949 |
+
if(this.is_selected(obj)) {
|
950 |
+
obj.children("a").removeClass("jstree-clicked");
|
951 |
+
this.data.ui.selected = this.data.ui.selected.not(obj);
|
952 |
+
if(this.data.ui.last_selected.get(0) === obj.get(0)) { this.data.ui.last_selected = this.data.ui.selected.eq(0); }
|
953 |
+
this.__callback({ "obj" : obj });
|
954 |
+
}
|
955 |
+
},
|
956 |
+
toggle_select : function (obj) {
|
957 |
+
obj = this._get_node(obj);
|
958 |
+
if(!obj.length) { return false; }
|
959 |
+
if(this.is_selected(obj)) { this.deselect_node(obj); }
|
960 |
+
else { this.select_node(obj); }
|
961 |
+
},
|
962 |
+
is_selected : function (obj) { return this.data.ui.selected.index(this._get_node(obj)) >= 0; },
|
963 |
+
get_selected : function (context) {
|
964 |
+
return context ? $(context).find(".jstree-clicked").parent() : this.data.ui.selected;
|
965 |
+
},
|
966 |
+
deselect_all : function (context) {
|
967 |
+
if(context) { $(context).find(".jstree-clicked").removeClass("jstree-clicked"); }
|
968 |
+
else { this.get_container().find(".jstree-clicked").removeClass("jstree-clicked"); }
|
969 |
+
this.data.ui.selected = $([]);
|
970 |
+
this.data.ui.last_selected = false;
|
971 |
+
this.__callback();
|
972 |
+
}
|
973 |
+
}
|
974 |
+
});
|
975 |
+
// include the selection plugin by default
|
976 |
+
$.jstree.defaults.plugins.push("ui");
|
977 |
+
})(jQuery);
|
978 |
+
//*/
|
979 |
+
|
980 |
+
/*
|
981 |
+
* jsTree CRRM plugin 1.0
|
982 |
+
* Handles creating/renaming/removing/moving nodes by user interaction.
|
983 |
+
*/
|
984 |
+
(function ($) {
|
985 |
+
$.jstree.plugin("crrm", {
|
986 |
+
__init : function () {
|
987 |
+
this.get_container()
|
988 |
+
.bind("move_node.jstree", $.proxy(function (e, data) {
|
989 |
+
if(this._get_settings().crrm.move.open_onmove) {
|
990 |
+
var t = this;
|
991 |
+
data.rslt.np.parentsUntil(".jstree").andSelf().filter(".jstree-closed").each(function () {
|
992 |
+
t.open_node(this, false, true);
|
993 |
+
});
|
994 |
+
}
|
995 |
+
}, this));
|
996 |
+
},
|
997 |
+
defaults : {
|
998 |
+
input_width_limit : 200,
|
999 |
+
move : {
|
1000 |
+
always_copy : false, // false, true or "multitree"
|
1001 |
+
open_onmove : true,
|
1002 |
+
default_position : "last",
|
1003 |
+
check_move : function (m) { return true; }
|
1004 |
+
}
|
1005 |
+
},
|
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,
|
1017 |
+
// "size" : t.length,
|
1018 |
+
"css" : {
|
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",
|
1026 |
+
"width" : "150px" // will be set a bit further down
|
1027 |
+
},
|
1028 |
+
"blur" : $.proxy(function () {
|
1029 |
+
var i = obj.children("input"),
|
1030 |
+
v = i.val();
|
1031 |
+
if(v === "") { v = t; }
|
1032 |
+
i.remove(); // rollback purposes
|
1033 |
+
this.set_text(obj,t); // rollback purposes
|
1034 |
+
this.rename_node(obj, v);
|
1035 |
+
callback.call(this, obj, v, t);
|
1036 |
+
obj.css("position","");
|
1037 |
+
}, this),
|
1038 |
+
"keyup" : function (event) {
|
1039 |
+
var key = event.keyCode || event.which;
|
1040 |
+
if(key == 27) { this.value = t; this.blur(); return; }
|
1041 |
+
else if(key == 13) { this.blur(); return; }
|
1042 |
+
else {
|
1043 |
+
h2.width(Math.min(h1.text("pW" + this.value).width(),w));
|
1044 |
+
}
|
1045 |
+
}
|
1046 |
+
})
|
1047 |
+
).children("input");
|
1048 |
+
this.set_text(obj, "");
|
1049 |
+
h1.css({
|
1050 |
+
fontFamily : h2.css('fontFamily') || '',
|
1051 |
+
fontSize : h2.css('fontSize') || '',
|
1052 |
+
fontWeight : h2.css('fontWeight') || '',
|
1053 |
+
fontStyle : h2.css('fontStyle') || '',
|
1054 |
+
fontStretch : h2.css('fontStretch') || '',
|
1055 |
+
fontVariant : h2.css('fontVariant') || '',
|
1056 |
+
letterSpacing : h2.css('letterSpacing') || '',
|
1057 |
+
wordSpacing : h2.css('wordSpacing') || ''
|
1058 |
+
});
|
1059 |
+
h2.width(Math.min(h1.text("pW" + h2[0].value).width(),w))[0].select();
|
1060 |
+
},
|
1061 |
+
rename : function (obj) {
|
1062 |
+
obj = this._get_node(obj);
|
1063 |
+
this.__rollback();
|
1064 |
+
var f = this.__callback;
|
1065 |
+
this._show_input(obj, function (obj, new_name, old_name) {
|
1066 |
+
f.call(this, { "obj" : obj, "new_name" : new_name, "old_name" : old_name });
|
1067 |
+
});
|
1068 |
+
},
|
1069 |
+
create : function (obj, position, js, callback, skip_rename) {
|
1070 |
+
var t, _this = this;
|
1071 |
+
obj = this._get_node(obj);
|
1072 |
+
if(!obj) { obj = -1; }
|
1073 |
+
this.__rollback();
|
1074 |
+
t = this.create_node(obj, position, js, function (t) {
|
1075 |
+
var p = this._get_parent(t),
|
1076 |
+
pos = $(t).index();
|
1077 |
+
if(callback) { callback.call(this, t); }
|
1078 |
+
if(p.length && p.hasClass("jstree-closed")) { this.open_node(p, false, true); }
|
1079 |
+
if(!skip_rename) {
|
1080 |
+
this._show_input(t, function (obj, new_name, old_name) {
|
1081 |
+
_this.__callback({ "obj" : obj, "name" : new_name, "parent" : p, "position" : pos });
|
1082 |
+
});
|
1083 |
+
}
|
1084 |
+
else { _this.__callback({ "obj" : t, "name" : this.get_text(t), "parent" : p, "position" : pos }); }
|
1085 |
+
});
|
1086 |
+
return t;
|
1087 |
+
},
|
1088 |
+
remove : function (obj) {
|
1089 |
+
obj = this._get_node(obj, true);
|
1090 |
+
this.__rollback();
|
1091 |
+
this.delete_node(obj);
|
1092 |
+
this.__callback({ "obj" : obj });
|
1093 |
+
},
|
1094 |
+
check_move : function () {
|
1095 |
+
if(!this.__call_old()) { return false; }
|
1096 |
+
var s = this._get_settings().crrm.move;
|
1097 |
+
if(!s.check_move.call(this, this._get_move())) { return false; }
|
1098 |
+
return true;
|
1099 |
+
},
|
1100 |
+
move_node : function (obj, ref, position, is_copy, is_prepared, skip_check) {
|
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
|
1107 |
+
if(s.always_copy === true || (s.always_copy === "multitree" && obj.rt.get_index() !== obj.ot.get_index() )) {
|
1108 |
+
is_copy = true;
|
1109 |
+
}
|
1110 |
+
this.__call_old(true, obj, ref, position, is_copy, true, skip_check);
|
1111 |
+
},
|
1112 |
+
|
1113 |
+
cut : function (obj) {
|
1114 |
+
obj = this._get_node(obj);
|
1115 |
+
this.data.crrm.cp_nodes = false;
|
1116 |
+
this.data.crrm.ct_nodes = false;
|
1117 |
+
if(!obj || !obj.length) { return false; }
|
1118 |
+
this.data.crrm.ct_nodes = obj;
|
1119 |
+
},
|
1120 |
+
copy : function (obj) {
|
1121 |
+
obj = this._get_node(obj);
|
1122 |
+
this.data.crrm.cp_nodes = false;
|
1123 |
+
this.data.crrm.ct_nodes = false;
|
1124 |
+
if(!obj || !obj.length) { return false; }
|
1125 |
+
this.data.crrm.cp_nodes = obj;
|
1126 |
+
},
|
1127 |
+
paste : function (obj) {
|
1128 |
+
obj = this._get_node(obj);
|
1129 |
+
if(!obj || !obj.length) { return false; }
|
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 |
+
});
|
1136 |
+
// include the crr plugin by default
|
1137 |
+
$.jstree.defaults.plugins.push("crrm");
|
1138 |
+
})(jQuery);
|
1139 |
+
|
1140 |
+
/*
|
1141 |
+
* jsTree themes plugin 1.0
|
1142 |
+
* Handles loading and setting themes, as well as detecting path to themes, etc.
|
1143 |
+
*/
|
1144 |
+
(function ($) {
|
1145 |
+
var themes_loaded = [];
|
1146 |
+
// this variable stores the path to the themes folder - if left as false - it will be autodetected
|
1147 |
+
$.jstree._themes = false;
|
1148 |
+
$.jstree.plugin("themes", {
|
1149 |
+
__init : function () {
|
1150 |
+
this.get_container()
|
1151 |
+
.bind("init.jstree", $.proxy(function () {
|
1152 |
+
var s = this._get_settings().themes;
|
1153 |
+
this.data.themes.dots = s.dots;
|
1154 |
+
this.data.themes.icons = s.icons;
|
1155 |
+
//alert(s.dots);
|
1156 |
+
this.set_theme(s.theme, s.url);
|
1157 |
+
}, this))
|
1158 |
+
.bind("loaded.jstree", $.proxy(function () {
|
1159 |
+
// bound here too, as simple HTML tree's won't honor dots & icons otherwise
|
1160 |
+
if(!this.data.themes.dots) { this.hide_dots(); }
|
1161 |
+
else { this.show_dots(); }
|
1162 |
+
if(!this.data.themes.icons) { this.hide_icons(); }
|
1163 |
+
else { this.show_icons(); }
|
1164 |
+
}, this));
|
1165 |
+
},
|
1166 |
+
defaults : {
|
1167 |
+
theme : "default",
|
1168 |
+
url : false,
|
1169 |
+
dots : true,
|
1170 |
+
icons : true
|
1171 |
+
},
|
1172 |
+
_fn : {
|
1173 |
+
set_theme : function (theme_name, theme_url) {
|
1174 |
+
if(!theme_name) { return false; }
|
1175 |
+
if(!theme_url) { theme_url = $.jstree._themes + theme_name + '/style.css'; }
|
1176 |
+
if($.inArray(theme_url, themes_loaded) == -1) {
|
1177 |
+
$.vakata.css.add_sheet({ "url" : theme_url, "rel" : "jstree" });
|
1178 |
+
themes_loaded.push(theme_url);
|
1179 |
+
}
|
1180 |
+
if(this.data.themes.theme != theme_name) {
|
1181 |
+
this.get_container().removeClass('jstree-' + this.data.themes.theme);
|
1182 |
+
this.data.themes.theme = theme_name;
|
1183 |
+
}
|
1184 |
+
this.get_container().addClass('jstree-' + theme_name);
|
1185 |
+
if(!this.data.themes.dots) { this.hide_dots(); }
|
1186 |
+
else { this.show_dots(); }
|
1187 |
+
if(!this.data.themes.icons) { this.hide_icons(); }
|
1188 |
+
else { this.show_icons(); }
|
1189 |
+
this.__callback();
|
1190 |
+
},
|
1191 |
+
get_theme : function () { return this.data.themes.theme; },
|
1192 |
+
|
1193 |
+
show_dots : function () { this.data.themes.dots = true; this.get_container().children("ul").removeClass("jstree-no-dots"); },
|
1194 |
+
hide_dots : function () { this.data.themes.dots = false; this.get_container().children("ul").addClass("jstree-no-dots"); },
|
1195 |
+
toggle_dots : function () { if(this.data.themes.dots) { this.hide_dots(); } else { this.show_dots(); } },
|
1196 |
+
|
1197 |
+
show_icons : function () { this.data.themes.icons = true; this.get_container().children("ul").removeClass("jstree-no-icons"); },
|
1198 |
+
hide_icons : function () { this.data.themes.icons = false; this.get_container().children("ul").addClass("jstree-no-icons"); },
|
1199 |
+
toggle_icons: function () { if(this.data.themes.icons) { this.hide_icons(); } else { this.show_icons(); } }
|
1200 |
+
}
|
1201 |
+
});
|
1202 |
+
// autodetect themes path
|
1203 |
+
$(function () {
|
1204 |
+
if($.jstree._themes === false) {
|
1205 |
+
$("script").each(function () {
|
1206 |
+
if(this.src.toString().match(/jquery\.jstree[^\/]*?\.js(\?.*)?$/)) {
|
1207 |
+
$.jstree._themes = this.src.toString().replace(/jquery\.jstree[^\/]*?\.js(\?.*)?$/, "") + 'themes/';
|
1208 |
+
return false;
|
1209 |
+
}
|
1210 |
+
});
|
1211 |
+
}
|
1212 |
+
if($.jstree._themes === false) { $.jstree._themes = "themes/"; }
|
1213 |
+
});
|
1214 |
+
// include the themes plugin by default
|
1215 |
+
$.jstree.defaults.plugins.push("themes");
|
1216 |
+
})(jQuery);
|
1217 |
+
//*/
|
1218 |
+
|
1219 |
+
/*
|
1220 |
+
* jsTree hotkeys plugin 1.0
|
1221 |
+
* Enables keyboard navigation for all tree instances
|
1222 |
+
* Depends on the jstree ui & jquery hotkeys plugins
|
1223 |
+
*/
|
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 |
+
}
|
1233 |
+
$.jstree.plugin("hotkeys", {
|
1234 |
+
__init : function () {
|
1235 |
+
if(typeof $.hotkeys === "undefined") { throw "jsTree hotkeys: jQuery hotkeys plugin not included."; }
|
1236 |
+
if(!this.data.ui) { throw "jsTree hotkeys: jsTree UI plugin not included."; }
|
1237 |
+
$.each(this._get_settings().hotkeys, function (i, val) {
|
1238 |
+
if($.inArray(i, bound) == -1) {
|
1239 |
+
$(document).bind("keydown", i, function (event) { return exec(i, event); });
|
1240 |
+
bound.push(i);
|
1241 |
+
}
|
1242 |
+
});
|
1243 |
+
this.enable_hotkeys();
|
1244 |
+
},
|
1245 |
+
defaults : {
|
1246 |
+
"up" : function () {
|
1247 |
+
var o = this.data.ui.hovered || this.data.ui.last_selected || -1;
|
1248 |
+
this.hover_node(this._get_prev(o));
|
1249 |
+
return false;
|
1250 |
+
},
|
1251 |
+
"down" : function () {
|
1252 |
+
var o = this.data.ui.hovered || this.data.ui.last_selected || -1;
|
1253 |
+
this.hover_node(this._get_next(o));
|
1254 |
+
return false;
|
1255 |
+
},
|
1256 |
+
"left" : function () {
|
1257 |
+
var o = this.data.ui.hovered || this.data.ui.last_selected;
|
1258 |
+
if(o) {
|
1259 |
+
if(o.hasClass("jstree-open")) { this.close_node(o); }
|
1260 |
+
else { this.hover_node(this._get_prev(o)); }
|
1261 |
+
}
|
1262 |
+
return false;
|
1263 |
+
},
|
1264 |
+
"right" : function () {
|
1265 |
+
var o = this.data.ui.hovered || this.data.ui.last_selected;
|
1266 |
+
if(o && o.length) {
|
1267 |
+
if(o.hasClass("jstree-closed")) { this.open_node(o); }
|
1268 |
+
else { this.hover_node(this._get_next(o)); }
|
1269 |
+
}
|
1270 |
+
return false;
|
1271 |
+
},
|
1272 |
+
"space" : function () {
|
1273 |
+
if(this.data.ui.hovered) { this.data.ui.hovered.children("a:eq(0)").click(); }
|
1274 |
+
return false;
|
1275 |
+
},
|
1276 |
+
"ctrl+space" : function (event) {
|
1277 |
+
event.type = "click";
|
1278 |
+
if(this.data.ui.hovered) { this.data.ui.hovered.children("a:eq(0)").trigger(event); }
|
1279 |
+
return false;
|
1280 |
+
},
|
1281 |
+
"f2" : function () { this.rename(this.data.ui.hovered || this.data.ui.last_selected); },
|
1282 |
+
"del" : function () { this.remove(this.data.ui.hovered || this._get_node(null)); }
|
1283 |
+
},
|
1284 |
+
_fn : {
|
1285 |
+
enable_hotkeys : function () {
|
1286 |
+
this.data.hotkeys.enabled = true;
|
1287 |
+
},
|
1288 |
+
disable_hotkeys : function () {
|
1289 |
+
this.data.hotkeys.enabled = false;
|
1290 |
+
}
|
1291 |
+
}
|
1292 |
+
});
|
1293 |
+
})(jQuery);
|
1294 |
+
//*/
|
1295 |
+
|
1296 |
+
/*
|
1297 |
+
* jsTree JSON 1.0
|
1298 |
+
* The JSON data store. Datastores are build by overriding the `load_node` and `_is_loaded` functions.
|
1299 |
+
*/
|
1300 |
+
(function ($) {
|
1301 |
+
$.jstree.plugin("json_data", {
|
1302 |
+
defaults : {
|
1303 |
+
data : false,
|
1304 |
+
ajax : false,
|
1305 |
+
correct_state : true,
|
1306 |
+
progressive_render : false
|
1307 |
+
},
|
1308 |
+
_fn : {
|
1309 |
+
load_node : function (obj, s_call, e_call) { var _this = this; this.load_node_json(obj, function () { _this.__callback({ "obj" : obj }); s_call.call(this); }, e_call); },
|
1310 |
+
_is_loaded : function (obj) {
|
1311 |
+
var s = this._get_settings().json_data, d;
|
1312 |
+
obj = this._get_node(obj);
|
1313 |
+
if(obj && obj !== -1 && s.progressive_render && !obj.is(".jstree-open, .jstree-leaf") && obj.children("ul").children("li").length === 0 && obj.data("jstree-children")) {
|
1314 |
+
d = this._parse_json(obj.data("jstree-children"));
|
1315 |
+
if(d) {
|
1316 |
+
obj.append(d);
|
1317 |
+
$.removeData(obj, "jstree-children");
|
1318 |
+
}
|
1319 |
+
this.clean_node(obj);
|
1320 |
+
return true;
|
1321 |
+
}
|
1322 |
+
return obj == -1 || !obj || !s.ajax || obj.is(".jstree-open, .jstree-leaf") || obj.children("ul").children("li").size() > 0;
|
1323 |
+
},
|
1324 |
+
load_node_json : function (obj, s_call, e_call) {
|
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)):
|
1331 |
+
if(!obj || obj == -1) {
|
1332 |
+
d = this._parse_json(s.data);
|
1333 |
+
if(d) {
|
1334 |
+
this.get_container().children("ul").empty().append(d.children());
|
1335 |
+
this.clean_node();
|
1336 |
+
}
|
1337 |
+
else {
|
1338 |
+
if(s.correct_state) { this.get_container().children("ul").empty(); }
|
1339 |
+
}
|
1340 |
+
}
|
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 {
|
1353 |
+
if(t === "success" && s.correct_state) { this.get_container().children("ul").empty(); }
|
1354 |
+
}
|
1355 |
+
if(e_call) { e_call.call(this); }
|
1356 |
+
};
|
1357 |
+
success_func = function (d, t, x) {
|
1358 |
+
var sf = this.get_settings().json_data.ajax.success;
|
1359 |
+
if(sf) { d = sf.call(this,d,t,x) || d; }
|
1360 |
+
if(d === "" || (!$.isArray(d) && !$.isPlainObject(d))) {
|
1361 |
+
return error_func.call(this, x, t, "");
|
1362 |
+
}
|
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 |
+
}
|
1370 |
+
else {
|
1371 |
+
if(obj === -1 || !obj) {
|
1372 |
+
if(s.correct_state) {
|
1373 |
+
this.get_container().children("ul").empty();
|
1374 |
+
if(s_call) { s_call.call(this); }
|
1375 |
+
}
|
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); }
|
1382 |
+
}
|
1383 |
+
}
|
1384 |
+
}
|
1385 |
+
};
|
1386 |
+
s.ajax.context = this;
|
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;
|
1393 |
+
}
|
1394 |
+
},
|
1395 |
+
_parse_json : function (js, is_callback) {
|
1396 |
+
var d = false,
|
1397 |
+
p = this._get_settings(),
|
1398 |
+
s = p.json_data,
|
1399 |
+
t = p.core.html_titles,
|
1400 |
+
tmp, i, j, ul1, ul2;
|
1401 |
+
|
1402 |
+
if(!js) { return d; }
|
1403 |
+
if($.isFunction(js)) {
|
1404 |
+
js = js.call(this);
|
1405 |
+
}
|
1406 |
+
if($.isArray(js)) {
|
1407 |
+
d = $();
|
1408 |
+
if(!js.length) { return false; }
|
1409 |
+
for(i = 0, j = js.length; i < j; i++) {
|
1410 |
+
tmp = this._parse_json(js[i], true);
|
1411 |
+
if(tmp.length) { d = d.add(tmp); }
|
1412 |
+
}
|
1413 |
+
}
|
1414 |
+
else {
|
1415 |
+
if(typeof js == "string") { js = { data : js }; }
|
1416 |
+
if(!js.data && js.data !== "") { return d; }
|
1417 |
+
d = $("<li>");
|
1418 |
+
if(js.attr) { d.attr(js.attr); }
|
1419 |
+
if(js.metadata) { d.data("jstree", js.metadata); }
|
1420 |
+
if(js.state) { d.addClass("jstree-" + js.state); }
|
1421 |
+
if(!$.isArray(js.data)) { tmp = js.data; js.data = []; js.data.push(tmp); }
|
1422 |
+
$.each(js.data, function (i, m) {
|
1423 |
+
tmp = $("<a>");
|
1424 |
+
if($.isFunction(m)) { m = m.call(this, js); }
|
1425 |
+
if(typeof m == "string") { tmp.attr('href','#')[ t ? "html" : "text" ](m); }
|
1426 |
+
else {
|
1427 |
+
if(!m.attr) { m.attr = {}; }
|
1428 |
+
if(!m.attr.href) { m.attr.href = '#'; }
|
1429 |
+
tmp.attr(m.attr)[ t ? "html" : "text" ](m.title);
|
1430 |
+
if(m.language) { tmp.addClass(m.language); }
|
1431 |
+
}
|
1432 |
+
tmp.prepend("<ins class='jstree-icon'> </ins>");
|
1433 |
+
if(!m.icon && js.icon) { m.icon = js.icon; }
|
1434 |
+
if(m.icon) {
|
1435 |
+
if(m.icon.indexOf("/") === -1) { tmp.children("ins").addClass(m.icon); }
|
1436 |
+
else { tmp.children("ins").css("background","url('" + m.icon + "') center center no-repeat"); }
|
1437 |
+
}
|
1438 |
+
d.append(tmp);
|
1439 |
+
});
|
1440 |
+
d.prepend("<ins class='jstree-icon'> </ins>");
|
1441 |
+
if(js.children) {
|
1442 |
+
if(s.progressive_render && js.state !== "open") {
|
1443 |
+
d.addClass("jstree-closed").data("jstree-children", js.children);
|
1444 |
+
}
|
1445 |
+
else {
|
1446 |
+
if($.isFunction(js.children)) {
|
1447 |
+
js.children = js.children.call(this, js);
|
1448 |
+
}
|
1449 |
+
if($.isArray(js.children) && js.children.length) {
|
1450 |
+
tmp = this._parse_json(js.children, true);
|
1451 |
+
if(tmp.length) {
|
1452 |
+
ul2 = $("<ul>");
|
1453 |
+
ul2.append(tmp);
|
1454 |
+
d.append(ul2);
|
1455 |
+
}
|
1456 |
+
}
|
1457 |
+
}
|
1458 |
+
}
|
1459 |
+
}
|
1460 |
+
if(!is_callback) {
|
1461 |
+
ul1 = $("<ul>");
|
1462 |
+
ul1.append(d);
|
1463 |
+
d = ul1;
|
1464 |
+
}
|
1465 |
+
return d;
|
1466 |
+
},
|
1467 |
+
get_json : function (obj, li_attr, a_attr, is_callback) {
|
1468 |
+
var result = [],
|
1469 |
+
s = this._get_settings(),
|
1470 |
+
_this = this,
|
1471 |
+
tmp1, tmp2, li, a, t, lang;
|
1472 |
+
obj = this._get_node(obj);
|
1473 |
+
if(!obj || obj === -1) { obj = this.get_container().find("> ul > li"); }
|
1474 |
+
li_attr = $.isArray(li_attr) ? li_attr : [ "id", "class" ];
|
1475 |
+
if(!is_callback && this.data.types) { li_attr.push(s.types.type_attr); }
|
1476 |
+
a_attr = $.isArray(a_attr) ? a_attr : [ ];
|
1477 |
+
|
1478 |
+
obj.each(function () {
|
1479 |
+
li = $(this);
|
1480 |
+
tmp1 = { data : [] };
|
1481 |
+
if(li_attr.length) { tmp1.attr = { }; }
|
1482 |
+
$.each(li_attr, function (i, v) {
|
1483 |
+
tmp2 = li.attr(v);
|
1484 |
+
if(tmp2 && tmp2.length && tmp2.replace(/jstree[^ ]*|$/ig,'').length) {
|
1485 |
+
tmp1.attr[v] = tmp2.replace(/jstree[^ ]*|$/ig,'');
|
1486 |
+
}
|
1487 |
+
});
|
1488 |
+
if(li.hasClass("jstree-open")) { tmp1.state = "open"; }
|
1489 |
+
if(li.hasClass("jstree-closed")) { tmp1.state = "closed"; }
|
1490 |
+
a = li.children("a");
|
1491 |
+
a.each(function () {
|
1492 |
+
t = $(this);
|
1493 |
+
if(
|
1494 |
+
a_attr.length ||
|
1495 |
+
$.inArray("languages", s.plugins) !== -1 ||
|
1496 |
+
t.children("ins").get(0).style.backgroundImage.length ||
|
1497 |
+
(t.children("ins").get(0).className && t.children("ins").get(0).className.replace(/jstree[^ ]*|$/ig,'').length)
|
1498 |
+
) {
|
1499 |
+
lang = false;
|
1500 |
+
if($.inArray("languages", s.plugins) !== -1 && $.isArray(s.languages) && s.languages.length) {
|
1501 |
+
$.each(s.languages, function (l, lv) {
|
1502 |
+
if(t.hasClass(lv)) {
|
1503 |
+
lang = lv;
|
1504 |
+
return false;
|
1505 |
+
}
|
1506 |
+
});
|
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; }
|
1514 |
+
});
|
1515 |
+
if(t.children("ins").get(0).className.replace(/jstree[^ ]*|$/ig,'').replace(/^\s+$/ig,"").length) {
|
1516 |
+
tmp2.icon = t.children("ins").get(0).className.replace(/jstree[^ ]*|$/ig,'').replace(/^\s+$/ig,"");
|
1517 |
+
}
|
1518 |
+
if(t.children("ins").get(0).style.backgroundImage.length) {
|
1519 |
+
tmp2.icon = t.children("ins").get(0).style.backgroundImage.replace("url(","").replace(")","");
|
1520 |
+
}
|
1521 |
+
}
|
1522 |
+
else {
|
1523 |
+
tmp2 = _this.get_text(t);
|
1524 |
+
}
|
1525 |
+
if(a.length > 1) { tmp1.data.push(tmp2); }
|
1526 |
+
else { tmp1.data = tmp2; }
|
1527 |
+
});
|
1528 |
+
li = li.find("> ul > li");
|
1529 |
+
if(li.length) { tmp1.children = _this.get_json(li, li_attr, a_attr, true); }
|
1530 |
+
result.push(tmp1);
|
1531 |
+
});
|
1532 |
+
return result;
|
1533 |
+
}
|
1534 |
+
}
|
1535 |
+
});
|
1536 |
+
})(jQuery);
|
1537 |
+
//*/
|
1538 |
+
|
1539 |
+
/*
|
1540 |
+
* jsTree languages plugin 1.0
|
1541 |
+
* Adds support for multiple language versions in one tree
|
1542 |
+
* This basically allows for many titles coexisting in one node, but only one of them being visible at any given time
|
1543 |
+
* This is useful for maintaining the same structure in many languages (hence the name of the plugin)
|
1544 |
+
*/
|
1545 |
+
(function ($) {
|
1546 |
+
$.jstree.plugin("languages", {
|
1547 |
+
__init : function () { this._load_css(); },
|
1548 |
+
defaults : [],
|
1549 |
+
_fn : {
|
1550 |
+
set_lang : function (i) {
|
1551 |
+
var langs = this._get_settings().languages,
|
1552 |
+
st = false,
|
1553 |
+
selector = ".jstree-" + this.get_index() + ' a';
|
1554 |
+
if(!$.isArray(langs) || langs.length === 0) { return false; }
|
1555 |
+
if($.inArray(i,langs) == -1) {
|
1556 |
+
if(!!langs[i]) { i = langs[i]; }
|
1557 |
+
else { return false; }
|
1558 |
+
}
|
1559 |
+
if(i == this.data.languages.current_language) { return true; }
|
1560 |
+
st = $.vakata.css.get_css(selector + "." + this.data.languages.current_language, false, this.data.languages.language_css);
|
1561 |
+
if(st !== false) { st.style.display = "none"; }
|
1562 |
+
st = $.vakata.css.get_css(selector + "." + i, false, this.data.languages.language_css);
|
1563 |
+
if(st !== false) { st.style.display = ""; }
|
1564 |
+
this.data.languages.current_language = i;
|
1565 |
+
this.__callback(i);
|
1566 |
+
return true;
|
1567 |
+
},
|
1568 |
+
get_lang : function () {
|
1569 |
+
return this.data.languages.current_language;
|
1570 |
+
},
|
1571 |
+
get_text : function (obj, lang) {
|
1572 |
+
obj = this._get_node(obj) || this.data.ui.last_selected;
|
1573 |
+
if(!obj.size()) { return false; }
|
1574 |
+
var langs = this._get_settings().languages,
|
1575 |
+
s = this._get_settings().core.html_titles;
|
1576 |
+
if($.isArray(langs) && langs.length) {
|
1577 |
+
lang = (lang && $.inArray(lang,langs) != -1) ? lang : this.data.languages.current_language;
|
1578 |
+
obj = obj.children("a." + lang);
|
1579 |
+
}
|
1580 |
+
else { obj = obj.children("a:eq(0)"); }
|
1581 |
+
if(s) {
|
1582 |
+
obj = obj.clone();
|
1583 |
+
obj.children("INS").remove();
|
1584 |
+
return obj.html();
|
1585 |
+
}
|
1586 |
+
else {
|
1587 |
+
obj = obj.contents().filter(function() { return this.nodeType == 3; })[0];
|
1588 |
+
return obj.nodeValue;
|
1589 |
+
}
|
1590 |
+
},
|
1591 |
+
set_text : function (obj, val, lang) {
|
1592 |
+
obj = this._get_node(obj) || this.data.ui.last_selected;
|
1593 |
+
if(!obj.size()) { return false; }
|
1594 |
+
var langs = this._get_settings().languages,
|
1595 |
+
s = this._get_settings().core.html_titles,
|
1596 |
+
tmp;
|
1597 |
+
if($.isArray(langs) && langs.length) {
|
1598 |
+
lang = (lang && $.inArray(lang,langs) != -1) ? lang : this.data.languages.current_language;
|
1599 |
+
obj = obj.children("a." + lang);
|
1600 |
+
}
|
1601 |
+
else { obj = obj.children("a:eq(0)"); }
|
1602 |
+
if(s) {
|
1603 |
+
tmp = obj.children("INS").clone();
|
1604 |
+
obj.html(val).prepend(tmp);
|
1605 |
+
this.__callback({ "obj" : obj, "name" : val, "lang" : lang });
|
1606 |
+
return true;
|
1607 |
+
}
|
1608 |
+
else {
|
1609 |
+
obj = obj.contents().filter(function() { return this.nodeType == 3; })[0];
|
1610 |
+
this.__callback({ "obj" : obj, "name" : val, "lang" : lang });
|
1611 |
+
return (obj.nodeValue = val);
|
1612 |
+
}
|
1613 |
+
},
|
1614 |
+
_load_css : function () {
|
1615 |
+
var langs = this._get_settings().languages,
|
1616 |
+
str = "/* languages css */",
|
1617 |
+
selector = ".jstree-" + this.get_index() + ' a',
|
1618 |
+
ln;
|
1619 |
+
if($.isArray(langs) && langs.length) {
|
1620 |
+
this.data.languages.current_language = langs[0];
|
1621 |
+
for(ln = 0; ln < langs.length; ln++) {
|
1622 |
+
str += selector + "." + langs[ln] + " {";
|
1623 |
+
if(langs[ln] != this.data.languages.current_language) { str += " display:none; "; }
|
1624 |
+
str += " } ";
|
1625 |
+
}
|
1626 |
+
this.data.languages.language_css = $.vakata.css.add_sheet({ 'str' : str });
|
1627 |
+
}
|
1628 |
+
},
|
1629 |
+
create_node : function (obj, position, js, callback) {
|
1630 |
+
var t = this.__call_old(true, obj, position, js, function (t) {
|
1631 |
+
var langs = this._get_settings().languages,
|
1632 |
+
a = t.children("a"),
|
1633 |
+
ln;
|
1634 |
+
if($.isArray(langs) && langs.length) {
|
1635 |
+
for(ln = 0; ln < langs.length; ln++) {
|
1636 |
+
if(!a.is("." + langs[ln])) {
|
1637 |
+
t.append(a.eq(0).clone().removeClass(langs.join(" ")).addClass(langs[ln]));
|
1638 |
+
}
|
1639 |
+
}
|
1640 |
+
a.not("." + langs.join(", .")).remove();
|
1641 |
+
}
|
1642 |
+
if(callback) { callback.call(this, t); }
|
1643 |
+
});
|
1644 |
+
return t;
|
1645 |
+
}
|
1646 |
+
}
|
1647 |
+
});
|
1648 |
+
})(jQuery);
|
1649 |
+
//*/
|
1650 |
+
|
1651 |
+
/*
|
1652 |
+
* jsTree cookies plugin 1.0
|
1653 |
+
* Stores the currently opened/selected nodes in a cookie and then restores them
|
1654 |
+
* Depends on the jquery.cookie plugin
|
1655 |
+
*/
|
1656 |
+
(function ($) {
|
1657 |
+
$.jstree.plugin("cookies", {
|
1658 |
+
__init : function () {
|
1659 |
+
if(typeof $.cookie === "undefined") { throw "jsTree cookie: jQuery cookie plugin not included."; }
|
1660 |
+
|
1661 |
+
var s = this._get_settings().cookies,
|
1662 |
+
tmp;
|
1663 |
+
if(!!s.save_opened) {
|
1664 |
+
tmp = $.cookie(s.save_opened);
|
1665 |
+
if(tmp && tmp.length) { this.data.core.to_open = tmp.split(","); }
|
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 () {
|
1673 |
+
this.get_container()
|
1674 |
+
.bind("open_node.jstree close_node.jstree select_node.jstree deselect_node.jstree", $.proxy(function (e) {
|
1675 |
+
if(this._get_settings().cookies.auto_save) { this.save_cookie((e.handleObj.namespace + e.handleObj.type).replace("jstree","")); }
|
1676 |
+
}, this));
|
1677 |
+
}, this));
|
1678 |
+
},
|
1679 |
+
defaults : {
|
1680 |
+
save_opened : "jstree_open",
|
1681 |
+
save_selected : "jstree_select",
|
1682 |
+
auto_save : true,
|
1683 |
+
cookie_options : {}
|
1684 |
+
},
|
1685 |
+
_fn : {
|
1686 |
+
save_cookie : function (c) {
|
1687 |
+
if(this.data.core.refreshing) { return; }
|
1688 |
+
var s = this._get_settings().cookies;
|
1689 |
+
if(!c) { // if called manually and not by event
|
1690 |
+
if(s.save_opened) {
|
1691 |
+
this.save_opened();
|
1692 |
+
$.cookie(s.save_opened, this.data.core.to_open.join(","), s.cookie_options);
|
1693 |
+
}
|
1694 |
+
if(s.save_selected && this.data.ui) {
|
1695 |
+
this.save_selected();
|
1696 |
+
$.cookie(s.save_selected, this.data.ui.to_select.join(","), s.cookie_options);
|
1697 |
+
}
|
1698 |
+
return;
|
1699 |
+
}
|
1700 |
+
switch(c) {
|
1701 |
+
case "open_node":
|
1702 |
+
case "close_node":
|
1703 |
+
if(!!s.save_opened) {
|
1704 |
+
this.save_opened();
|
1705 |
+
$.cookie(s.save_opened, this.data.core.to_open.join(","), s.cookie_options);
|
1706 |
+
}
|
1707 |
+
break;
|
1708 |
+
case "select_node":
|
1709 |
+
case "deselect_node":
|
1710 |
+
if(!!s.save_selected && this.data.ui) {
|
1711 |
+
this.save_selected();
|
1712 |
+
$.cookie(s.save_selected, this.data.ui.to_select.join(","), s.cookie_options);
|
1713 |
+
}
|
1714 |
+
break;
|
1715 |
+
}
|
1716 |
+
}
|
1717 |
+
}
|
1718 |
+
});
|
1719 |
+
// include cookies by default
|
1720 |
+
$.jstree.defaults.plugins.push("cookies");
|
1721 |
+
})(jQuery);
|
1722 |
+
//*/
|
1723 |
+
|
1724 |
+
/*
|
1725 |
+
* jsTree sort plugin 1.0
|
1726 |
+
* Sorts items alphabetically (or using any other function)
|
1727 |
+
*/
|
1728 |
+
(function ($) {
|
1729 |
+
$.jstree.plugin("sort", {
|
1730 |
+
__init : function () {
|
1731 |
+
this.get_container()
|
1732 |
+
.bind("load_node.jstree", $.proxy(function (e, data) {
|
1733 |
+
var obj = this._get_node(data.rslt.obj);
|
1734 |
+
obj = obj === -1 ? this.get_container().children("ul") : obj.children("ul");
|
1735 |
+
this.sort(obj);
|
1736 |
+
}, this))
|
1737 |
+
.bind("rename_node.jstree", $.proxy(function (e, data) {
|
1738 |
+
this.sort(data.rslt.obj.parent());
|
1739 |
+
}, this))
|
1740 |
+
.bind("move_node.jstree", $.proxy(function (e, data) {
|
1741 |
+
var m = data.rslt.np == -1 ? this.get_container() : data.rslt.np;
|
1742 |
+
this.sort(m.children("ul"));
|
1743 |
+
}, this));
|
1744 |
+
},
|
1745 |
+
defaults : function (a, b) { return this.get_text(a) > this.get_text(b) ? 1 : -1; },
|
1746 |
+
_fn : {
|
1747 |
+
sort : function (obj) {
|
1748 |
+
var s = this._get_settings().sort,
|
1749 |
+
t = this;
|
1750 |
+
obj.append($.makeArray(obj.children("li")).sort($.proxy(s, t)));
|
1751 |
+
obj.find("> li > ul").each(function() { t.sort($(this)); });
|
1752 |
+
this.clean_node(obj);
|
1753 |
+
}
|
1754 |
+
}
|
1755 |
+
});
|
1756 |
+
})(jQuery);
|
1757 |
+
//*/
|
1758 |
+
|
1759 |
+
/*
|
1760 |
+
* jsTree DND plugin 1.0
|
1761 |
+
* Drag and drop plugin for moving/copying nodes
|
1762 |
+
*/
|
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,
|
1774 |
+
user_data : {},
|
1775 |
+
|
1776 |
+
drag_start : function (e, data, html) {
|
1777 |
+
if($.vakata.dnd.is_drag) { $.vakata.drag_stop({}); }
|
1778 |
+
try {
|
1779 |
+
e.currentTarget.unselectable = "on";
|
1780 |
+
e.currentTarget.onselectstart = function() { return false; };
|
1781 |
+
if(e.currentTarget.style) { e.currentTarget.style.MozUserSelect = "none"; }
|
1782 |
+
} catch(err) { }
|
1783 |
+
$.vakata.dnd.init_x = e.pageX;
|
1784 |
+
$.vakata.dnd.init_y = e.pageY;
|
1785 |
+
$.vakata.dnd.user_data = data;
|
1786 |
+
$.vakata.dnd.is_down = true;
|
1787 |
+
$.vakata.dnd.helper = $("<div id='vakata-dragged'>").html(html).css("opacity", "0.75");
|
1788 |
+
$(document).bind("mousemove", $.vakata.dnd.drag);
|
1789 |
+
$(document).bind("mouseup", $.vakata.dnd.drag_stop);
|
1790 |
+
return false;
|
1791 |
+
},
|
1792 |
+
drag : function (e) {
|
1793 |
+
if(!$.vakata.dnd.is_down) { return; }
|
1794 |
+
if(!$.vakata.dnd.is_drag) {
|
1795 |
+
if(Math.abs(e.pageX - $.vakata.dnd.init_x) > 5 || Math.abs(e.pageY - $.vakata.dnd.init_y) > 5) {
|
1796 |
+
$.vakata.dnd.helper.appendTo("body");
|
1797 |
+
$.vakata.dnd.is_drag = true;
|
1798 |
+
$(document).triggerHandler("drag_start.vakata", { "event" : e, "data" : $.vakata.dnd.user_data });
|
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 |
+
},
|
1805 |
+
drag_stop : function (e) {
|
1806 |
+
$(document).unbind("mousemove", $.vakata.dnd.drag);
|
1807 |
+
$(document).unbind("mouseup", $.vakata.dnd.drag_stop);
|
1808 |
+
$(document).triggerHandler("drag_stop.vakata", { "event" : e, "data" : $.vakata.dnd.user_data });
|
1809 |
+
$.vakata.dnd.helper.remove();
|
1810 |
+
$.vakata.dnd.init_x = 0;
|
1811 |
+
$.vakata.dnd.init_y = 0;
|
1812 |
+
$.vakata.dnd.user_data = {};
|
1813 |
+
$.vakata.dnd.is_down = false;
|
1814 |
+
$.vakata.dnd.is_drag = false;
|
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 |
+
|
1822 |
+
$.jstree.plugin("dnd", {
|
1823 |
+
__init : function () {
|
1824 |
+
this.data.dnd = {
|
1825 |
+
active : false,
|
1826 |
+
after : false,
|
1827 |
+
inside : false,
|
1828 |
+
before : false,
|
1829 |
+
off : false,
|
1830 |
+
prepared : false,
|
1831 |
+
w : 0,
|
1832 |
+
to1 : false,
|
1833 |
+
to2 : false,
|
1834 |
+
cof : false,
|
1835 |
+
cw : false,
|
1836 |
+
ch : false,
|
1837 |
+
i1 : false,
|
1838 |
+
i2 : false
|
1839 |
+
};
|
1840 |
+
this.get_container()
|
1841 |
+
.bind("mouseenter.jstree", $.proxy(function () {
|
1842 |
+
if($.vakata.dnd.is_drag && $.vakata.dnd.user_data.jstree && this.data.themes) {
|
1843 |
+
m.attr("class", "jstree-" + this.data.themes.theme);
|
1844 |
+
$.vakata.dnd.helper.attr("class", "jstree-dnd-helper jstree-" + this.data.themes.theme);
|
1845 |
+
}
|
1846 |
+
}, this))
|
1847 |
+
.bind("mouseleave.jstree", $.proxy(function () {
|
1848 |
+
if($.vakata.dnd.is_drag && $.vakata.dnd.user_data.jstree) {
|
1849 |
+
if(this.data.dnd.i1) { clearInterval(this.data.dnd.i1); }
|
1850 |
+
if(this.data.dnd.i2) { clearInterval(this.data.dnd.i2); }
|
1851 |
+
}
|
1852 |
+
}, this))
|
1853 |
+
.bind("mousemove.jstree", $.proxy(function (e) {
|
1854 |
+
if($.vakata.dnd.is_drag && $.vakata.dnd.user_data.jstree) {
|
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); }
|
1881 |
+
}
|
1882 |
+
|
1883 |
+
}
|
1884 |
+
}, this))
|
1885 |
+
.delegate("a", "mousedown.jstree", $.proxy(function (e) {
|
1886 |
+
if(e.which === 1) {
|
1887 |
+
this.start_drag(e.currentTarget, e);
|
1888 |
+
return false;
|
1889 |
+
}
|
1890 |
+
}, this))
|
1891 |
+
.delegate("a", "mouseenter.jstree", $.proxy(function (e) {
|
1892 |
+
if($.vakata.dnd.is_drag && $.vakata.dnd.user_data.jstree) {
|
1893 |
+
this.dnd_enter(e.currentTarget);
|
1894 |
+
}
|
1895 |
+
}, this))
|
1896 |
+
.delegate("a", "mousemove.jstree", $.proxy(function (e) {
|
1897 |
+
if($.vakata.dnd.is_drag && $.vakata.dnd.user_data.jstree) {
|
1898 |
+
if(typeof this.data.dnd.off.top === "undefined") { this.data.dnd.off = $(e.target).offset(); }
|
1899 |
+
this.data.dnd.w = (e.pageY - (this.data.dnd.off.top || 0)) % this.data.core.li_height;
|
1900 |
+
if(this.data.dnd.w < 0) { this.data.dnd.w += this.data.core.li_height; }
|
1901 |
+
this.dnd_show();
|
1902 |
+
}
|
1903 |
+
}, this))
|
1904 |
+
.delegate("a", "mouseleave.jstree", $.proxy(function (e) {
|
1905 |
+
if($.vakata.dnd.is_drag && $.vakata.dnd.user_data.jstree) {
|
1906 |
+
this.data.dnd.after = false;
|
1907 |
+
this.data.dnd.before = false;
|
1908 |
+
this.data.dnd.inside = false;
|
1909 |
+
$.vakata.dnd.helper.children("ins").attr("class","jstree-invalid");
|
1910 |
+
m.hide();
|
1911 |
+
if(r && r[0] === e.target.parentNode) {
|
1912 |
+
if(this.data.dnd.to1) {
|
1913 |
+
clearTimeout(this.data.dnd.to1);
|
1914 |
+
this.data.dnd.to1 = false;
|
1915 |
+
}
|
1916 |
+
if(this.data.dnd.to2) {
|
1917 |
+
clearTimeout(this.data.dnd.to2);
|
1918 |
+
this.data.dnd.to2 = false;
|
1919 |
+
}
|
1920 |
+
}
|
1921 |
+
}
|
1922 |
+
}, this))
|
1923 |
+
.delegate("a", "mouseup.jstree", $.proxy(function (e) {
|
1924 |
+
if($.vakata.dnd.is_drag && $.vakata.dnd.user_data.jstree) {
|
1925 |
+
this.dnd_finish(e);
|
1926 |
+
}
|
1927 |
+
}, this));
|
1928 |
+
|
1929 |
+
$(document)
|
1930 |
+
.bind("drag_stop.vakata", $.proxy(function () {
|
1931 |
+
this.data.dnd.after = false;
|
1932 |
+
this.data.dnd.before = false;
|
1933 |
+
this.data.dnd.inside = false;
|
1934 |
+
this.data.dnd.off = false;
|
1935 |
+
this.data.dnd.prepared = false;
|
1936 |
+
this.data.dnd.w = false;
|
1937 |
+
this.data.dnd.to1 = false;
|
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) {
|
1945 |
+
var et = $(data.event.target);
|
1946 |
+
if(et.closest(".jstree").hasClass("jstree-" + this.get_index())) {
|
1947 |
+
this.dnd_enter(et);
|
1948 |
+
}
|
1949 |
+
}
|
1950 |
+
}, this));
|
1951 |
+
|
1952 |
+
var s = this._get_settings().dnd;
|
1953 |
+
if(s.drag_target) {
|
1954 |
+
$(document)
|
1955 |
+
.delegate(s.drag_target, "mousedown.jstree", $.proxy(function (e) {
|
1956 |
+
o = e.target;
|
1957 |
+
$.vakata.dnd.drag_start(e, { jstree : true, obj : e.target }, "<ins class='jstree-icon'></ins>" + $(e.target).text() );
|
1958 |
+
if(this.data.themes) {
|
1959 |
+
m.attr("class", "jstree-" + this.data.themes.theme);
|
1960 |
+
$.vakata.dnd.helper.attr("class", "jstree-dnd-helper jstree-" + this.data.themes.theme);
|
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;
|
1968 |
+
return false;
|
1969 |
+
}, this));
|
1970 |
+
}
|
1971 |
+
if(s.drop_target) {
|
1972 |
+
$(document)
|
1973 |
+
.delegate(s.drop_target, "mouseenter.jstree", $.proxy(function (e) {
|
1974 |
+
if(this.data.dnd.active && this._get_settings().dnd.drop_check.call(this, { "o" : o, "r" : $(e.target) })) {
|
1975 |
+
$.vakata.dnd.helper.children("ins").attr("class","jstree-ok");
|
1976 |
+
}
|
1977 |
+
}, this))
|
1978 |
+
.delegate(s.drop_target, "mouseleave.jstree", $.proxy(function (e) {
|
1979 |
+
if(this.data.dnd.active) {
|
1980 |
+
$.vakata.dnd.helper.children("ins").attr("class","jstree-invalid");
|
1981 |
+
}
|
1982 |
+
}, this))
|
1983 |
+
.delegate(s.drop_target, "mouseup.jstree", $.proxy(function (e) {
|
1984 |
+
if(this.data.dnd.active && $.vakata.dnd.helper.children("ins").hasClass("jstree-ok")) {
|
1985 |
+
this._get_settings().dnd.drop_finish.call(this, { "o" : o, "r" : $(e.target) });
|
1986 |
+
}
|
1987 |
+
}, this));
|
1988 |
+
}
|
1989 |
+
},
|
1990 |
+
defaults : {
|
1991 |
+
copy_modifier : "ctrl",
|
1992 |
+
check_timeout : 200,
|
1993 |
+
open_timeout : 500,
|
1994 |
+
drop_target : ".jstree-drop",
|
1995 |
+
drop_check : function (data) { return true; },
|
1996 |
+
drop_finish : $.noop,
|
1997 |
+
drag_target : ".jstree-draggable",
|
1998 |
+
drag_finish : $.noop,
|
1999 |
+
drag_check : function (data) { return { after : false, before : false, inside : true }; }
|
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;
|
2007 |
+
this.data.dnd.before = a.before;
|
2008 |
+
this.data.dnd.inside = a.inside;
|
2009 |
+
this.data.dnd.prepared = true;
|
2010 |
+
return this.dnd_show();
|
2011 |
+
}
|
2012 |
+
this.prepare_move(o, r, "before");
|
2013 |
+
this.data.dnd.before = this.check_move();
|
2014 |
+
this.prepare_move(o, r, "after");
|
2015 |
+
this.data.dnd.after = this.check_move();
|
2016 |
+
if(this._is_loaded(r)) {
|
2017 |
+
this.prepare_move(o, r, "inside");
|
2018 |
+
this.data.dnd.inside = this.check_move();
|
2019 |
+
}
|
2020 |
+
else {
|
2021 |
+
this.data.dnd.inside = false;
|
2022 |
+
}
|
2023 |
+
this.data.dnd.prepared = true;
|
2024 |
+
return this.dnd_show();
|
2025 |
+
},
|
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"];
|
2033 |
+
}
|
2034 |
+
else { o = ["after","inside","before"]; }
|
2035 |
+
$.each(o, $.proxy(function (i, val) {
|
2036 |
+
if(this.data.dnd[val]) {
|
2037 |
+
$.vakata.dnd.helper.children("ins").attr("class","jstree-ok");
|
2038 |
+
r = val;
|
2039 |
+
return false;
|
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();
|
2055 |
+
break;
|
2056 |
+
}
|
2057 |
+
return r;
|
2058 |
+
},
|
2059 |
+
dnd_open : function () {
|
2060 |
+
this.data.dnd.to2 = false;
|
2061 |
+
this.open_node(r, $.proxy(this.dnd_prepare,this), true);
|
2062 |
+
},
|
2063 |
+
dnd_finish : function (e) {
|
2064 |
+
if(this.data.dnd.foreign) {
|
2065 |
+
if(this.data.dnd.after || this.data.dnd.before || this.data.dnd.inside) {
|
2066 |
+
this._get_settings().dnd.drag_finish.call(this, { "o" : o, "r" : r });
|
2067 |
+
}
|
2068 |
+
}
|
2069 |
+
else {
|
2070 |
+
this.dnd_prepare();
|
2071 |
+
this.move_node(o, r, this.dnd_show(), e[this._get_settings().dnd.copy_modifier + "Key"]);
|
2072 |
+
}
|
2073 |
+
o = false;
|
2074 |
+
r = false;
|
2075 |
+
m.hide();
|
2076 |
+
},
|
2077 |
+
dnd_enter : function (obj) {
|
2078 |
+
var s = this._get_settings().dnd;
|
2079 |
+
this.data.dnd.prepared = false;
|
2080 |
+
r = this._get_node(obj);
|
2081 |
+
if(s.check_timeout) {
|
2082 |
+
// do the calculations after a minimal timeout (users tend to drag quickly to the desired location)
|
2083 |
+
if(this.data.dnd.to1) { clearTimeout(this.data.dnd.to1); }
|
2084 |
+
this.data.dnd.to1 = setTimeout($.proxy(this.dnd_prepare, this), s.check_timeout);
|
2085 |
+
}
|
2086 |
+
else {
|
2087 |
+
this.dnd_prepare();
|
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 |
+
}
|
2101 |
+
},
|
2102 |
+
start_drag : function (obj, e) {
|
2103 |
+
o = this._get_node(obj);
|
2104 |
+
if(this.data.ui && this.is_selected(o)) { o = this._get_node(null, true); }
|
2105 |
+
$.vakata.dnd.drag_start(e, { jstree : true, obj : o }, "<ins class='jstree-icon'></ins>" + (o.length > 1 ? "Multiple selection" : this.get_text(o)) );
|
2106 |
+
if(this.data.themes) {
|
2107 |
+
m.attr("class", "jstree-" + this.data.themes.theme);
|
2108 |
+
$.vakata.dnd.helper.attr("class", "jstree-dnd-helper jstree-" + this.data.themes.theme);
|
2109 |
+
}
|
2110 |
+
var cnt = this.get_container();
|
2111 |
+
this.data.dnd.cof = cnt.children("ul").offset();
|
2112 |
+
this.data.dnd.cw = parseInt(cnt.width(),10);
|
2113 |
+
this.data.dnd.ch = parseInt(cnt.height(),10);
|
2114 |
+
this.data.dnd.active = true;
|
2115 |
+
}
|
2116 |
+
}
|
2117 |
+
});
|
2118 |
+
$(function() {
|
2119 |
+
var css_string = '' +
|
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) {
|
2127 |
+
if(data.data.jstree) {
|
2128 |
+
m.show();
|
2129 |
+
}
|
2130 |
+
});
|
2131 |
+
$(document).bind("drag_stop.vakata", function (e, data) {
|
2132 |
+
if(data.data.jstree) { m.hide(); }
|
2133 |
+
});
|
2134 |
+
});
|
2135 |
+
})(jQuery);
|
2136 |
+
//*/
|
2137 |
+
|
2138 |
+
/*
|
2139 |
+
* jsTree checkbox plugin 1.0
|
2140 |
+
* Inserts checkboxes in front of every node
|
2141 |
+
* Depends on the ui plugin
|
2142 |
+
* DOES NOT WORK NICELY WITH MULTITREE DRAG'N'DROP
|
2143 |
+
*/
|
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'> </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 {
|
2189 |
+
$this.removeClass("jstree-checked jstree-undetermined").addClass("jstree-unchecked");
|
2190 |
+
}
|
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 {
|
2198 |
+
$this.removeClass("jstree-unchecked jstree-undetermined").addClass("jstree-checked");
|
2199 |
+
}
|
2200 |
+
}
|
2201 |
+
});
|
2202 |
+
this.data.ui.selected = this.get_checked();
|
2203 |
+
this.__callback(obj);
|
2204 |
+
},
|
2205 |
+
check_node : function (obj) {
|
2206 |
+
this.change_state(obj, false);
|
2207 |
+
},
|
2208 |
+
uncheck_node : function (obj) {
|
2209 |
+
this.change_state(obj, true);
|
2210 |
+
},
|
2211 |
+
check_all : function () {
|
2212 |
+
var _this = this;
|
2213 |
+
this.get_container().children("ul").children("li").each(function () {
|
2214 |
+
_this.check_node(this, false);
|
2215 |
+
});
|
2216 |
+
},
|
2217 |
+
uncheck_all : function () {
|
2218 |
+
var _this = this;
|
2219 |
+
this.get_container().children("ul").children("li").each(function () {
|
2220 |
+
_this.change_state(this, true);
|
2221 |
+
});
|
2222 |
+
},
|
2223 |
+
|
2224 |
+
is_checked : function(obj) {
|
2225 |
+
obj = this._get_node(obj);
|
2226 |
+
return obj.length ? obj.is(".jstree-checked") : false;
|
2227 |
+
},
|
2228 |
+
get_checked : function (obj) {
|
2229 |
+
obj = !obj || obj === -1 ? this.get_container() : this._get_node(obj);
|
2230 |
+
return obj.find("> ul > .jstree-checked, .jstree-undetermined > ul > .jstree-checked");
|
2231 |
+
},
|
2232 |
+
get_unchecked : function (obj) {
|
2233 |
+
obj = !obj || obj === -1 ? this.get_container() : this._get_node(obj);
|
2234 |
+
return obj.find("> ul > .jstree-unchecked, .jstree-undetermined > ul > .jstree-unchecked");
|
2235 |
+
},
|
2236 |
+
|
2237 |
+
show_checkboxes : function () { this.get_container().children("ul").removeClass("jstree-no-checkboxes"); },
|
2238 |
+
hide_checkboxes : function () { this.get_container().children("ul").addClass("jstree-no-checkboxes"); },
|
2239 |
+
|
2240 |
+
_repair_state : function (obj) {
|
2241 |
+
obj = this._get_node(obj);
|
2242 |
+
if(!obj.length) { return; }
|
2243 |
+
var a = obj.find("> ul > .jstree-checked").length,
|
2244 |
+
b = obj.find("> ul > .jstree-undetermined").length,
|
2245 |
+
c = obj.find("> ul > li").length;
|
2246 |
+
|
2247 |
+
if(c === 0) { if(obj.hasClass("jstree-undetermined")) { this.check_node(obj); } }
|
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 |
+
});
|
2264 |
+
})(jQuery);
|
2265 |
+
//*/
|
2266 |
+
|
2267 |
+
/*
|
2268 |
+
* jsTree XML 1.0
|
2269 |
+
* The XML data store. Datastores are build by overriding the `load_node` and `_is_loaded` functions.
|
2270 |
+
*/
|
2271 |
+
(function ($) {
|
2272 |
+
$.vakata.xslt = function (xml, xsl, callback) {
|
2273 |
+
var rs = "", xm, xs, processor, support;
|
2274 |
+
if(document.recalc) {
|
2275 |
+
xm = document.createElement('xml');
|
2276 |
+
xs = document.createElement('xml');
|
2277 |
+
xm.innerHTML = xml;
|
2278 |
+
xs.innerHTML = xsl;
|
2279 |
+
$("body").append(xm).append(xs);
|
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;
|
2287 |
+
}
|
2288 |
+
if(typeof window.DOMParser !== "undefined" && typeof window.XMLHttpRequest !== "undefined" && typeof window.XSLTProcessor !== "undefined") {
|
2289 |
+
processor = new XSLTProcessor();
|
2290 |
+
support = $.isFunction(processor.transformDocument) ? (typeof window.XMLSerializer !== "undefined") : true;
|
2291 |
+
if(!support) { return false; }
|
2292 |
+
xml = new DOMParser().parseFromString(xml, "text/xml");
|
2293 |
+
xsl = new DOMParser().parseFromString(xsl, "text/xml");
|
2294 |
+
if($.isFunction(processor.transformDocument)) {
|
2295 |
+
rs = document.implementation.createDocument("", "", null);
|
2296 |
+
processor.transformDocument(xml, xsl, rs, null);
|
2297 |
+
callback.call(null, XMLSerializer().serializeToString(rs));
|
2298 |
+
return true;
|
2299 |
+
}
|
2300 |
+
else {
|
2301 |
+
processor.importStylesheet(xsl);
|
2302 |
+
rs = processor.transformToFragment(xml, document);
|
2303 |
+
callback.call(null, $("<div>").append(rs).html());
|
2304 |
+
return true;
|
2305 |
+
}
|
2306 |
+
}
|
2307 |
+
return false;
|
2308 |
+
};
|
2309 |
+
var xsl = {
|
2310 |
+
'nest' : '<?xml version="1.0" encoding="utf-8" ?>' +
|
2311 |
+
'<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >' +
|
2312 |
+
'<xsl:output method="html" encoding="utf-8" omit-xml-declaration="yes" standalone="no" indent="no" media-type="text/html" />' +
|
2313 |
+
'<xsl:template match="/">' +
|
2314 |
+
' <xsl:call-template name="nodes">' +
|
2315 |
+
' <xsl:with-param name="node" select="/root" />' +
|
2316 |
+
' </xsl:call-template>' +
|
2317 |
+
'</xsl:template>' +
|
2318 |
+
'<xsl:template name="nodes">' +
|
2319 |
+
' <xsl:param name="node" />' +
|
2320 |
+
' <ul>' +
|
2321 |
+
' <xsl:for-each select="$node/item">' +
|
2322 |
+
' <xsl:variable name="children" select="count(./item) > 0" />' +
|
2323 |
+
' <li>' +
|
2324 |
+
' <xsl:attribute name="class">' +
|
2325 |
+
' <xsl:if test="position() = last()">jstree-last </xsl:if>' +
|
2326 |
+
' <xsl:choose>' +
|
2327 |
+
' <xsl:when test="@state = \'open\'">jstree-open </xsl:when>' +
|
2328 |
+
' <xsl:when test="$children or @hasChildren or @state = \'closed\'">jstree-closed </xsl:when>' +
|
2329 |
+
' <xsl:otherwise>jstree-leaf </xsl:otherwise>' +
|
2330 |
+
' </xsl:choose>' +
|
2331 |
+
' <xsl:value-of select="@class" />' +
|
2332 |
+
' </xsl:attribute>' +
|
2333 |
+
' <xsl:for-each select="@*">' +
|
2334 |
+
' <xsl:if test="name() != \'class\' and name() != \'state\' and name() != \'hasChildren\'">' +
|
2335 |
+
' <xsl:attribute name="{name()}"><xsl:value-of select="." /></xsl:attribute>' +
|
2336 |
+
' </xsl:if>' +
|
2337 |
+
' </xsl:for-each>' +
|
2338 |
+
' <ins class="jstree-icon"><xsl:text> </xsl:text></ins>' +
|
2339 |
+
' <xsl:for-each select="content/name">' +
|
2340 |
+
' <a>' +
|
2341 |
+
' <xsl:attribute name="href">' +
|
2342 |
+
' <xsl:choose>' +
|
2343 |
+
' <xsl:when test="@href"><xsl:value-of select="@href" /></xsl:when>' +
|
2344 |
+
' <xsl:otherwise>#</xsl:otherwise>' +
|
2345 |
+
' </xsl:choose>' +
|
2346 |
+
' </xsl:attribute>' +
|
2347 |
+
' <xsl:attribute name="class"><xsl:value-of select="@lang" /> <xsl:value-of select="@class" /></xsl:attribute>' +
|
2348 |
+
' <xsl:attribute name="style"><xsl:value-of select="@style" /></xsl:attribute>' +
|
2349 |
+
' <xsl:for-each select="@*">' +
|
2350 |
+
' <xsl:if test="name() != \'style\' and name() != \'class\' and name() != \'href\'">' +
|
2351 |
+
' <xsl:attribute name="{name()}"><xsl:value-of select="." /></xsl:attribute>' +
|
2352 |
+
' </xsl:if>' +
|
2353 |
+
' </xsl:for-each>' +
|
2354 |
+
' <ins>' +
|
2355 |
+
' <xsl:attribute name="class">jstree-icon ' +
|
2356 |
+
' <xsl:if test="string-length(attribute::icon) > 0 and not(contains(@icon,\'/\'))"><xsl:value-of select="@icon" /></xsl:if>' +
|
2357 |
+
' </xsl:attribute>' +
|
2358 |
+
' <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>' +
|
2359 |
+
' <xsl:text> </xsl:text>' +
|
2360 |
+
' </ins>' +
|
2361 |
+
' <xsl:value-of select="current()" />' +
|
2362 |
+
' </a>' +
|
2363 |
+
' </xsl:for-each>' +
|
2364 |
+
' <xsl:if test="$children or @hasChildren"><xsl:call-template name="nodes"><xsl:with-param name="node" select="current()" /></xsl:call-template></xsl:if>' +
|
2365 |
+
' </li>' +
|
2366 |
+
' </xsl:for-each>' +
|
2367 |
+
' </ul>' +
|
2368 |
+
'</xsl:template>' +
|
2369 |
+
'</xsl:stylesheet>',
|
2370 |
+
|
2371 |
+
'flat' : '<?xml version="1.0" encoding="utf-8" ?>' +
|
2372 |
+
'<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >' +
|
2373 |
+
'<xsl:output method="html" encoding="utf-8" omit-xml-declaration="yes" standalone="no" indent="no" media-type="text/xml" />' +
|
2374 |
+
'<xsl:template match="/">' +
|
2375 |
+
' <ul>' +
|
2376 |
+
' <xsl:for-each select="//item[not(@parent_id) or @parent_id=0 or not(@parent_id = //item/@id)]">' + /* the last `or` may be removed */
|
2377 |
+
' <xsl:call-template name="nodes">' +
|
2378 |
+
' <xsl:with-param name="node" select="." />' +
|
2379 |
+
' <xsl:with-param name="is_last" select="number(position() = last())" />' +
|
2380 |
+
' </xsl:call-template>' +
|
2381 |
+
' </xsl:for-each>' +
|
2382 |
+
' </ul>' +
|
2383 |
+
'</xsl:template>' +
|
2384 |
+
'<xsl:template name="nodes">' +
|
2385 |
+
' <xsl:param name="node" />' +
|
2386 |
+
' <xsl:param name="is_last" />' +
|
2387 |
+
' <xsl:variable name="children" select="count(//item[@parent_id=$node/attribute::id]) > 0" />' +
|
2388 |
+
' <li>' +
|
2389 |
+
' <xsl:attribute name="class">' +
|
2390 |
+
' <xsl:if test="$is_last = true()">jstree-last </xsl:if>' +
|
2391 |
+
' <xsl:choose>' +
|
2392 |
+
' <xsl:when test="@state = \'open\'">jstree-open </xsl:when>' +
|
2393 |
+
' <xsl:when test="$children or @hasChildren or @state = \'closed\'">jstree-closed </xsl:when>' +
|
2394 |
+
' <xsl:otherwise>jstree-leaf </xsl:otherwise>' +
|
2395 |
+
' </xsl:choose>' +
|
2396 |
+
' <xsl:value-of select="@class" />' +
|
2397 |
+
' </xsl:attribute>' +
|
2398 |
+
' <xsl:for-each select="@*">' +
|
2399 |
+
' <xsl:if test="name() != \'parent_id\' and name() != \'hasChildren\' and name() != \'class\' and name() != \'state\'">' +
|
2400 |
+
' <xsl:attribute name="{name()}"><xsl:value-of select="." /></xsl:attribute>' +
|
2401 |
+
' </xsl:if>' +
|
2402 |
+
' </xsl:for-each>' +
|
2403 |
+
' <ins class="jstree-icon"><xsl:text> </xsl:text></ins>' +
|
2404 |
+
' <xsl:for-each select="content/name">' +
|
2405 |
+
' <a>' +
|
2406 |
+
' <xsl:attribute name="href">' +
|
2407 |
+
' <xsl:choose>' +
|
2408 |
+
' <xsl:when test="@href"><xsl:value-of select="@href" /></xsl:when>' +
|
2409 |
+
' <xsl:otherwise>#</xsl:otherwise>' +
|
2410 |
+
' </xsl:choose>' +
|
2411 |
+
' </xsl:attribute>' +
|
2412 |
+
' <xsl:attribute name="class"><xsl:value-of select="@lang" /> <xsl:value-of select="@class" /></xsl:attribute>' +
|
2413 |
+
' <xsl:attribute name="style"><xsl:value-of select="@style" /></xsl:attribute>' +
|
2414 |
+
' <xsl:for-each select="@*">' +
|
2415 |
+
' <xsl:if test="name() != \'style\' and name() != \'class\' and name() != \'href\'">' +
|
2416 |
+
' <xsl:attribute name="{name()}"><xsl:value-of select="." /></xsl:attribute>' +
|
2417 |
+
' </xsl:if>' +
|
2418 |
+
' </xsl:for-each>' +
|
2419 |
+
' <ins>' +
|
2420 |
+
' <xsl:attribute name="class">jstree-icon ' +
|
2421 |
+
' <xsl:if test="string-length(attribute::icon) > 0 and not(contains(@icon,\'/\'))"><xsl:value-of select="@icon" /></xsl:if>' +
|
2422 |
+
' </xsl:attribute>' +
|
2423 |
+
' <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>' +
|
2424 |
+
' <xsl:text> </xsl:text>' +
|
2425 |
+
' </ins>' +
|
2426 |
+
' <xsl:value-of select="current()" />' +
|
2427 |
+
' </a>' +
|
2428 |
+
' </xsl:for-each>' +
|
2429 |
+
' <xsl:if test="$children">' +
|
2430 |
+
' <ul>' +
|
2431 |
+
' <xsl:for-each select="//item[@parent_id=$node/attribute::id]">' +
|
2432 |
+
' <xsl:call-template name="nodes">' +
|
2433 |
+
' <xsl:with-param name="node" select="." />' +
|
2434 |
+
' <xsl:with-param name="is_last" select="number(position() = last())" />' +
|
2435 |
+
' </xsl:call-template>' +
|
2436 |
+
' </xsl:for-each>' +
|
2437 |
+
' </ul>' +
|
2438 |
+
' </xsl:if>' +
|
2439 |
+
' </li>' +
|
2440 |
+
'</xsl:template>' +
|
2441 |
+
'</xsl:stylesheet>'
|
2442 |
+
};
|
2443 |
+
$.jstree.plugin("xml_data", {
|
2444 |
+
defaults : {
|
2445 |
+
data : false,
|
2446 |
+
ajax : false,
|
2447 |
+
xsl : "flat",
|
2448 |
+
clean_node : false,
|
2449 |
+
correct_state : true
|
2450 |
+
},
|
2451 |
+
_fn : {
|
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)):
|
2464 |
+
if(!obj || obj == -1) {
|
2465 |
+
this.parse_xml(s.data, $.proxy(function (d) {
|
2466 |
+
if(d) {
|
2467 |
+
d = d.replace(/ ?xmlns="[^"]*"/ig, "");
|
2468 |
+
if(d.length > 10) {
|
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 {
|
2491 |
+
if(t === "success" && s.correct_state) { this.get_container().children("ul").empty(); }
|
2492 |
+
}
|
2493 |
+
if(e_call) { e_call.call(this); }
|
2494 |
+
};
|
2495 |
+
success_func = function (d, t, x) {
|
2496 |
+
d = x.responseText;
|
2497 |
+
var sf = this.get_settings().xml_data.ajax.success;
|
2498 |
+
if(sf) { d = sf.call(this,d,t,x) || d; }
|
2499 |
+
if(d == "") {
|
2500 |
+
return error_func.call(this, x, t, "");
|
2501 |
+
}
|
2502 |
+
this.parse_xml(d, $.proxy(function (d) {
|
2503 |
+
if(d) {
|
2504 |
+
d = d.replace(/ ?xmlns="[^"]*"/ig, "");
|
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); }
|
2518 |
+
}
|
2519 |
+
}
|
2520 |
+
else {
|
2521 |
+
if(s.correct_state) {
|
2522 |
+
this.get_container().children("ul").empty();
|
2523 |
+
if(s_call) { s_call.call(this); }
|
2524 |
+
}
|
2525 |
+
}
|
2526 |
+
}
|
2527 |
+
}
|
2528 |
+
}, this));
|
2529 |
+
};
|
2530 |
+
s.ajax.context = this;
|
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 |
+
}
|
2538 |
+
},
|
2539 |
+
parse_xml : function (xml, callback) {
|
2540 |
+
var s = this._get_settings().xml_data;
|
2541 |
+
$.vakata.xslt(xml, xsl[s.xsl], callback);
|
2542 |
+
},
|
2543 |
+
get_xml : function (tp, obj, li_attr, a_attr, is_callback) {
|
2544 |
+
var result = "",
|
2545 |
+
s = this._get_settings(),
|
2546 |
+
_this = this,
|
2547 |
+
tmp1, tmp2, li, a, lang;
|
2548 |
+
if(!tp) { tp = "flat"; }
|
2549 |
+
if(!is_callback) { is_callback = 0; }
|
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 |
+
|
2557 |
+
if(!is_callback) { result += "<root>"; }
|
2558 |
+
obj.each(function () {
|
2559 |
+
result += "<item";
|
2560 |
+
li = $(this);
|
2561 |
+
$.each(li_attr, function (i, v) { result += " " + v + "=\"" + (li.attr(v) || "").replace(/jstree[^ ]*|$/ig,'').replace(/^\s+$/ig,"") + "\""; });
|
2562 |
+
if(li.hasClass("jstree-open")) { result += " state=\"open\""; }
|
2563 |
+
if(li.hasClass("jstree-closed")) { result += " state=\"closed\""; }
|
2564 |
+
if(tp === "flat") { result += " parent_id=\"" + is_callback + "\""; }
|
2565 |
+
result += ">";
|
2566 |
+
result += "<content>";
|
2567 |
+
a = li.children("a");
|
2568 |
+
a.each(function () {
|
2569 |
+
tmp1 = $(this);
|
2570 |
+
lang = false;
|
2571 |
+
result += "<name";
|
2572 |
+
if($.inArray("languages", s.plugins) !== -1) {
|
2573 |
+
$.each(s.languages, function (k, z) {
|
2574 |
+
if(tmp1.hasClass(z)) { result += " lang=\"" + z + "\""; lang = z; return false; }
|
2575 |
+
});
|
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) {
|
2583 |
+
result += ' icon="' + tmp1.children("ins").get(0).className.replace(/jstree[^ ]*|$/ig,'').replace(/^\s+$/ig,"") + '"';
|
2584 |
+
}
|
2585 |
+
if(tmp1.children("ins").get(0).style.backgroundImage.length) {
|
2586 |
+
result += ' icon="' + tmp1.children("ins").get(0).style.backgroundImage.replace("url(","").replace(")","") + '"';
|
2587 |
+
}
|
2588 |
+
result += ">";
|
2589 |
+
result += "<![CDATA[" + _this.get_text(tmp1, lang) + "]]>";
|
2590 |
+
result += "</name>";
|
2591 |
+
});
|
2592 |
+
result += "</content>";
|
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; }
|
2599 |
+
});
|
2600 |
+
if(!is_callback) { result += "</root>"; }
|
2601 |
+
return result;
|
2602 |
+
}
|
2603 |
+
}
|
2604 |
+
});
|
2605 |
+
})(jQuery);
|
2606 |
+
//*/
|
2607 |
+
|
2608 |
+
/*
|
2609 |
+
* jsTree search plugin 1.0
|
2610 |
+
* Enables both sync and async search on the tree
|
2611 |
+
* DOES NOT WORK WITH JSON PROGRESSIVE RENDER
|
2612 |
+
*/
|
2613 |
+
(function ($) {
|
2614 |
+
$.expr[':'].jstree_contains = function(a,i,m){
|
2615 |
+
return (a.textContent || a.innerText || "").toLowerCase().indexOf(m[3].toLowerCase())>=0;
|
2616 |
+
};
|
2617 |
+
$.jstree.plugin("search", {
|
2618 |
+
__init : function () {
|
2619 |
+
this.data.search.str = "";
|
2620 |
+
this.data.search.result = $();
|
2621 |
+
},
|
2622 |
+
defaults : {
|
2623 |
+
ajax : false, // OR ajax object
|
2624 |
+
case_insensitive : false
|
2625 |
+
},
|
2626 |
+
_fn : {
|
2627 |
+
search : function (str, skip_async) {
|
2628 |
+
var s = this.get_settings().search,
|
2629 |
+
t = this,
|
2630 |
+
error_func = function () { },
|
2631 |
+
success_func = function () { };
|
2632 |
+
this.data.search.str = str;
|
2633 |
+
|
2634 |
+
if(!skip_async && s.ajax !== false && this.get_container().find(".jstree-closed:eq(0)").length > 0) {
|
2635 |
+
this.search.supress_callback = true;
|
2636 |
+
error_func = function () { };
|
2637 |
+
success_func = function (d, t, x) {
|
2638 |
+
var sf = this.get_settings().search.ajax.success;
|
2639 |
+
if(sf) { d = sf.call(this,d,t,x) || d; }
|
2640 |
+
this.data.search.to_open = d;
|
2641 |
+
this._search_open();
|
2642 |
+
};
|
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"; }
|
2649 |
+
$.ajax(s.ajax);
|
2650 |
+
return;
|
2651 |
+
}
|
2652 |
+
if(this.data.search.result.length) { this.clear_search(); }
|
2653 |
+
this.data.search.result = this.get_container().find("a" + (this.data.languages ? "." + this.get_lang() : "" ) + ":" + (s.case_insensitive ? "jstree_contains" : "contains") + "(" + this.data.search.str + ")");
|
2654 |
+
this.data.search.result.addClass("jstree-search").parents(".jstree-closed").each(function () {
|
2655 |
+
t.open_node(this, false, true);
|
2656 |
+
});
|
2657 |
+
this.__callback({ nodes : this.data.search.result, str : str });
|
2658 |
+
},
|
2659 |
+
clear_search : function (str) {
|
2660 |
+
this.data.search.result.removeClass("jstree-search");
|
2661 |
+
this.__callback(this.data.search.result);
|
2662 |
+
this.data.search.result = $();
|
2663 |
+
},
|
2664 |
+
_search_open : function (is_callback) {
|
2665 |
+
var _this = this,
|
2666 |
+
done = true,
|
2667 |
+
current = [],
|
2668 |
+
remaining = [];
|
2669 |
+
if(this.data.search.to_open.length) {
|
2670 |
+
$.each(this.data.search.to_open, function (i, val) {
|
2671 |
+
if(val == "#") { return true; }
|
2672 |
+
if($(val).length && $(val).is(".jstree-closed")) { current.push(val); }
|
2673 |
+
else { remaining.push(val); }
|
2674 |
+
});
|
2675 |
+
if(current.length) {
|
2676 |
+
this.data.search.to_open = remaining;
|
2677 |
+
$.each(current, function (i, val) {
|
2678 |
+
_this.open_node(val, function () { _this._search_open(true); });
|
2679 |
+
});
|
2680 |
+
done = false;
|
2681 |
+
}
|
2682 |
+
}
|
2683 |
+
if(done) { this.search(this.data.search.str, true); }
|
2684 |
+
}
|
2685 |
+
}
|
2686 |
+
});
|
2687 |
+
})(jQuery);
|
2688 |
+
//*/
|
2689 |
+
|
2690 |
+
/*
|
2691 |
+
* jsTree contextmenu plugin 1.0
|
2692 |
+
*/
|
2693 |
+
(function ($) {
|
2694 |
+
$.vakata.context = {
|
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)
|
2708 |
+
.css({ "visibility" : "hidden", "display" : "block", "left" : 0, "top" : 0 });
|
2709 |
+
h = $.vakata.context.cnt.height();
|
2710 |
+
w = $.vakata.context.cnt.width();
|
2711 |
+
if(x + w > $(document).width()) {
|
2712 |
+
x = $(document).width() - (w + 5);
|
2713 |
+
$.vakata.context.cnt.find("li > ul").addClass("right");
|
2714 |
+
}
|
2715 |
+
if(y + h > $(document).height()) {
|
2716 |
+
y = y - (h + t[0].offsetHeight);
|
2717 |
+
$.vakata.context.cnt.find("li > ul").addClass("bottom");
|
2718 |
+
}
|
2719 |
+
|
2720 |
+
$.vakata.context.cnt
|
2721 |
+
.css({ "left" : x, "top" : y })
|
2722 |
+
.find("li:has(ul)")
|
2723 |
+
.bind("mouseenter", function (e) {
|
2724 |
+
var w = $(document).width(),
|
2725 |
+
h = $(document).height(),
|
2726 |
+
ul = $(this).children("ul").show();
|
2727 |
+
if(w !== $(document).width()) { ul.toggleClass("right"); }
|
2728 |
+
if(h !== $(document).height()) { ul.toggleClass("bottom"); }
|
2729 |
+
})
|
2730 |
+
.bind("mouseleave", function (e) {
|
2731 |
+
$(this).children("ul").hide();
|
2732 |
+
})
|
2733 |
+
.end()
|
2734 |
+
.css({ "visibility" : "visible" })
|
2735 |
+
.show();
|
2736 |
+
$(document).triggerHandler("context_show.vakata");
|
2737 |
+
},
|
2738 |
+
hide : function () {
|
2739 |
+
$.vakata.context.vis = false;
|
2740 |
+
$.vakata.context.cnt.attr("class","").hide();
|
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 += "> </ins><a href='#' rel='" + i + "'>";
|
2758 |
+
if(val.submenu) {
|
2759 |
+
str += "<span style='float:right;'>»</span>";
|
2760 |
+
}
|
2761 |
+
str += val.label + "</a>";
|
2762 |
+
if(val.submenu) {
|
2763 |
+
tmp = $.vakata.context.parse(val.submenu, true);
|
2764 |
+
if(tmp) { str += tmp; }
|
2765 |
+
}
|
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; }
|
2780 |
+
}
|
2781 |
+
};
|
2782 |
+
$(function () {
|
2783 |
+
var css_string = '' +
|
2784 |
+
'#vakata-contextmenu { display:none; position:absolute; margin:0; padding:0; min-width:180px; background:#ebebeb; border:1px solid silver; z-index:10000; *width:180px; } ' +
|
2785 |
+
'#vakata-contextmenu ul { min-width:180px; *width:180px; } ' +
|
2786 |
+
'#vakata-contextmenu ul, #vakata-contextmenu li { margin:0; padding:0; list-style-type:none; display:block; } ' +
|
2787 |
+
'#vakata-contextmenu li { line-height:20px; min-height:20px; position:relative; padding:0px; } ' +
|
2788 |
+
'#vakata-contextmenu li a { padding:1px 6px; line-height:17px; display:block; text-decoration:none; margin:1px 1px 0 1px; } ' +
|
2789 |
+
'#vakata-contextmenu li ins { float:left; width:16px; height:16px; text-decoration:none; margin-right:2px; } ' +
|
2790 |
+
'#vakata-contextmenu li a:hover, #vakata-contextmenu li.vakata-hover > a { background:gray; color:white; } ' +
|
2791 |
+
'#vakata-contextmenu li ul { display:none; position:absolute; top:-2px; left:100%; background:#ebebeb; border:1px solid gray; } ' +
|
2792 |
+
'#vakata-contextmenu .right { right:100%; left:auto; } ' +
|
2793 |
+
'#vakata-contextmenu .bottom { bottom:-1px; top:auto; } ' +
|
2794 |
+
'#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; } ';
|
2795 |
+
$.vakata.css.add_sheet({ str : css_string });
|
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");
|
2805 |
+
})
|
2806 |
+
.appendTo("body");
|
2807 |
+
$(document).bind("mousedown", function (e) { if($.vakata.context.vis && !$.contains($.vakata.context.cnt[0], e.target)) { $.vakata.context.hide(); } });
|
2808 |
+
if(typeof $.hotkeys !== "undefined") {
|
2809 |
+
$(document)
|
2810 |
+
.bind("keydown", "up", function (e) {
|
2811 |
+
if($.vakata.context.vis) {
|
2812 |
+
var o = $.vakata.context.cnt.find("ul:visible").last().children(".vakata-hover").removeClass("vakata-hover").prevAll("li:not(.vakata-separator)").first();
|
2813 |
+
if(!o.length) { o = $.vakata.context.cnt.find("ul:visible").last().children("li:not(.vakata-separator)").last(); }
|
2814 |
+
o.addClass("vakata-hover");
|
2815 |
+
e.stopImmediatePropagation();
|
2816 |
+
e.preventDefault();
|
2817 |
+
}
|
2818 |
+
})
|
2819 |
+
.bind("keydown", "down", function (e) {
|
2820 |
+
if($.vakata.context.vis) {
|
2821 |
+
var o = $.vakata.context.cnt.find("ul:visible").last().children(".vakata-hover").removeClass("vakata-hover").nextAll("li:not(.vakata-separator)").first();
|
2822 |
+
if(!o.length) { o = $.vakata.context.cnt.find("ul:visible").last().children("li:not(.vakata-separator)").first(); }
|
2823 |
+
o.addClass("vakata-hover");
|
2824 |
+
e.stopImmediatePropagation();
|
2825 |
+
e.preventDefault();
|
2826 |
+
}
|
2827 |
+
})
|
2828 |
+
.bind("keydown", "right", function (e) {
|
2829 |
+
if($.vakata.context.vis) {
|
2830 |
+
$.vakata.context.cnt.find(".vakata-hover").children("ul").show().children("li:not(.vakata-separator)").removeClass("vakata-hover").first().addClass("vakata-hover");
|
2831 |
+
e.stopImmediatePropagation();
|
2832 |
+
e.preventDefault();
|
2833 |
+
}
|
2834 |
+
})
|
2835 |
+
.bind("keydown", "left", function (e) {
|
2836 |
+
if($.vakata.context.vis) {
|
2837 |
+
$.vakata.context.cnt.find(".vakata-hover").children("ul").hide().children(".vakata-separator").removeClass("vakata-hover");
|
2838 |
+
e.stopImmediatePropagation();
|
2839 |
+
e.preventDefault();
|
2840 |
+
}
|
2841 |
+
})
|
2842 |
+
.bind("keydown", "esc", function (e) {
|
2843 |
+
$.vakata.context.hide();
|
2844 |
+
e.preventDefault();
|
2845 |
+
})
|
2846 |
+
.bind("keydown", "space", function (e) {
|
2847 |
+
$.vakata.context.cnt.find(".vakata-hover").last().children("a").click();
|
2848 |
+
e.preventDefault();
|
2849 |
+
});
|
2850 |
+
}
|
2851 |
+
});
|
2852 |
+
|
2853 |
+
$.jstree.plugin("contextmenu", {
|
2854 |
+
__init : function () {
|
2855 |
+
this.get_container()
|
2856 |
+
.delegate("a", "contextmenu.jstree", $.proxy(function (e) {
|
2857 |
+
e.preventDefault();
|
2858 |
+
this.show_contextmenu(e.currentTarget, e.pageX, e.pageY);
|
2859 |
+
}, this))
|
2860 |
+
.bind("destroy.jstree", $.proxy(function () {
|
2861 |
+
if(this.data.contextmenu) {
|
2862 |
+
$.vakata.context.hide();
|
2863 |
+
}
|
2864 |
+
}, this));
|
2865 |
+
$(document).bind("context_hide.vakata", $.proxy(function () { this.data.contextmenu = false; }, this));
|
2866 |
+
},
|
2867 |
+
defaults : {
|
2868 |
+
select_node : false, // requires UI plugin
|
2869 |
+
show_at_node : true,
|
2870 |
+
items : { // Could be a function that should return an object like this one
|
2871 |
+
"create" : {
|
2872 |
+
"separator_before" : false,
|
2873 |
+
"separator_after" : true,
|
2874 |
+
"label" : "Create",
|
2875 |
+
"action" : function (obj) { this.create(obj); }
|
2876 |
+
},
|
2877 |
+
"rename" : {
|
2878 |
+
"separator_before" : false,
|
2879 |
+
"separator_after" : false,
|
2880 |
+
"label" : "Rename",
|
2881 |
+
"action" : function (obj) { this.rename(obj); }
|
2882 |
+
},
|
2883 |
+
"remove" : {
|
2884 |
+
"separator_before" : false,
|
2885 |
+
"icon" : false,
|
2886 |
+
"separator_after" : false,
|
2887 |
+
"label" : "Delete",
|
2888 |
+
"action" : function (obj) { this.remove(obj); }
|
2889 |
+
},
|
2890 |
+
"ccp" : {
|
2891 |
+
"separator_before" : true,
|
2892 |
+
"icon" : false,
|
2893 |
+
"separator_after" : false,
|
2894 |
+
"label" : "Edit",
|
2895 |
+
"action" : false,
|
2896 |
+
"submenu" : {
|
2897 |
+
"cut" : {
|
2898 |
+
"separator_before" : false,
|
2899 |
+
"separator_after" : false,
|
2900 |
+
"label" : "Cut",
|
2901 |
+
"action" : function (obj) { this.cut(obj); }
|
2902 |
+
},
|
2903 |
+
"copy" : {
|
2904 |
+
"separator_before" : false,
|
2905 |
+
"icon" : false,
|
2906 |
+
"separator_after" : false,
|
2907 |
+
"label" : "Copy",
|
2908 |
+
"action" : function (obj) { this.copy(obj); }
|
2909 |
+
},
|
2910 |
+
"paste" : {
|
2911 |
+
"separator_before" : false,
|
2912 |
+
"icon" : false,
|
2913 |
+
"separator_after" : false,
|
2914 |
+
"label" : "Paste",
|
2915 |
+
"action" : function (obj) { this.paste(obj); }
|
2916 |
+
}
|
2917 |
+
}
|
2918 |
+
}
|
2919 |
+
}
|
2920 |
+
},
|
2921 |
+
_fn : {
|
2922 |
+
show_contextmenu : function (obj, x, y) {
|
2923 |
+
obj = this._get_node(obj);
|
2924 |
+
var s = this.get_settings().contextmenu,
|
2925 |
+
a = obj.children("a:visible:eq(0)"),
|
2926 |
+
o = false;
|
2927 |
+
if(s.select_node && this.data.ui && !this.is_selected(obj)) {
|
2928 |
+
this.deselect_all();
|
2929 |
+
this.select_node(obj, true);
|
2930 |
+
}
|
2931 |
+
if(s.show_at_node || typeof x === "undefined" || typeof y === "undefined") {
|
2932 |
+
o = a.offset();
|
2933 |
+
x = o.left;
|
2934 |
+
y = o.top + this.data.core.li_height;
|
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 |
+
}
|
2942 |
+
});
|
2943 |
+
})(jQuery);
|
2944 |
+
//*/
|
2945 |
+
|
2946 |
+
/*
|
2947 |
+
* jsTree types plugin 1.0
|
2948 |
+
* Adds support types of nodes
|
2949 |
+
* You can set an attribute on each li node, that represents its type.
|
2950 |
+
* According to the type setting the node may get custom icon/validation rules
|
2951 |
+
*/
|
2952 |
+
(function ($) {
|
2953 |
+
$.jstree.plugin("types", {
|
2954 |
+
__init : function () {
|
2955 |
+
var s = this._get_settings().types;
|
2956 |
+
this.data.types.attach_to = [];
|
2957 |
+
this.get_container()
|
2958 |
+
.bind("init.jstree", $.proxy(function () {
|
2959 |
+
var types = s.types,
|
2960 |
+
attr = s.type_attr,
|
2961 |
+
icons_css = "",
|
2962 |
+
_this = this;
|
2963 |
+
|
2964 |
+
$.each(types, function (i, tp) {
|
2965 |
+
$.each(tp, function (k, v) {
|
2966 |
+
if(!/^(max_depth|max_children|icon|valid_children)$/.test(k)) { _this.data.types.attach_to.push(k); }
|
2967 |
+
});
|
2968 |
+
if(!tp.icon) { return true; }
|
2969 |
+
if( tp.icon.image || tp.icon.position) {
|
2970 |
+
if(i == "default") { icons_css += '.jstree-' + _this.get_index() + ' a > .jstree-icon { '; }
|
2971 |
+
else { icons_css += '.jstree-' + _this.get_index() + ' li[' + attr + '=' + i + '] > a > .jstree-icon { '; }
|
2972 |
+
if(tp.icon.image) { icons_css += ' background-image:url(' + tp.icon.image + '); '; }
|
2973 |
+
if(tp.icon.position){ icons_css += ' background-position:' + tp.icon.position + '; '; }
|
2974 |
+
else { icons_css += ' background-position:0 0; '; }
|
2975 |
+
icons_css += '} ';
|
2976 |
+
}
|
2977 |
+
});
|
2978 |
+
if(icons_css != "") { $.vakata.css.add_sheet({ 'str' : icons_css }); }
|
2979 |
+
}, this))
|
2980 |
+
.bind("before.jstree", $.proxy(function (e, data) {
|
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 |
+
}
|
2988 |
+
}
|
2989 |
+
}, this));
|
2990 |
+
},
|
2991 |
+
defaults : {
|
2992 |
+
// defines maximum number of root nodes (-1 means unlimited, -2 means disable max_children checking)
|
2993 |
+
max_children : -1,
|
2994 |
+
// defines the maximum depth of the tree (-1 means unlimited, -2 means disable max_depth checking)
|
2995 |
+
max_depth : -1,
|
2996 |
+
// defines valid node types for the root nodes
|
2997 |
+
valid_children : "all",
|
2998 |
+
|
2999 |
+
// where is the type stores (the rel attribute of the LI element)
|
3000 |
+
type_attr : "rel",
|
3001 |
+
// a list of types
|
3002 |
+
types : {
|
3003 |
+
// the default type
|
3004 |
+
"default" : {
|
3005 |
+
"max_children" : -1,
|
3006 |
+
"max_depth" : -1,
|
3007 |
+
"valid_children": "all"
|
3008 |
+
|
3009 |
+
// Bound functions - you can bind any other function here (using boolean or function)
|
3010 |
+
//"select_node" : true,
|
3011 |
+
//"open_node" : true,
|
3012 |
+
//"close_node" : true,
|
3013 |
+
//"create_node" : true,
|
3014 |
+
//"delete_node" : true
|
3015 |
+
}
|
3016 |
+
}
|
3017 |
+
},
|
3018 |
+
_fn : {
|
3019 |
+
_get_type : function (obj) {
|
3020 |
+
obj = this._get_node(obj);
|
3021 |
+
return (!obj || !obj.length) ? false : obj.attr(this._get_settings().types.type_attr) || "default";
|
3022 |
+
},
|
3023 |
+
set_type : function (str, obj) {
|
3024 |
+
obj = this._get_node(obj);
|
3025 |
+
return (!obj.length || !str) ? false : obj.attr(this._get_settings().types.type_attr, str);
|
3026 |
+
},
|
3027 |
+
_check : function (rule, obj, opts) {
|
3028 |
+
var v = false, t = this._get_type(obj), d = 0, _this = this, s = this._get_settings().types;
|
3029 |
+
if(obj === -1) {
|
3030 |
+
if(!!s[rule]) { v = s[rule]; }
|
3031 |
+
else { return; }
|
3032 |
+
}
|
3033 |
+
else {
|
3034 |
+
if(t === false) { return; }
|
3035 |
+
if(!!s.types[t] && !!s.types[t][rule]) { v = s.types[t][rule]; }
|
3036 |
+
else if(!!s.types["default"] && !!s.types["default"][rule]) { v = s.types["default"][rule]; }
|
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;
|
3047 |
+
},
|
3048 |
+
check_move : function () {
|
3049 |
+
if(!this.__call_old()) { return false; }
|
3050 |
+
var m = this._get_move(),
|
3051 |
+
s = m.rt._get_settings().types,
|
3052 |
+
mc = m.rt._check("max_children", m.cr),
|
3053 |
+
md = m.rt._check("max_depth", m.cr),
|
3054 |
+
vc = m.rt._check("valid_children", m.cr),
|
3055 |
+
ch = 0, d = 1, t;
|
3056 |
+
|
3057 |
+
if(vc === "none") { return false; }
|
3058 |
+
if($.isArray(vc) && m.ot && m.ot._get_type) {
|
3059 |
+
m.o.each(function () {
|
3060 |
+
if($.inArray(m.ot._get_type(this), vc) === -1) { d = false; return false; }
|
3061 |
+
});
|
3062 |
+
if(d === false) { return false; }
|
3063 |
+
}
|
3064 |
+
if(s.max_children !== -2 && mc !== -1) {
|
3065 |
+
ch = m.cr === -1 ? this.get_container().children("> ul > li").not(m.o).length : m.cr.children("> ul > li").not(m.o).length;
|
3066 |
+
if(ch + m.o.length > mc) { return false; }
|
3067 |
+
}
|
3068 |
+
if(s.max_depth !== -2 && md !== -1) {
|
3069 |
+
d = 0;
|
3070 |
+
if(md === 0) { return false; }
|
3071 |
+
if(typeof m.o.d === "undefined") {
|
3072 |
+
// TODO: deal with progressive rendering and async when checking max_depth (how to know the depth of the moved node)
|
3073 |
+
t = m.o;
|
3074 |
+
while(t.length > 0) {
|
3075 |
+
t = t.find("> ul > li");
|
3076 |
+
d ++;
|
3077 |
+
}
|
3078 |
+
m.o.d = d;
|
3079 |
+
}
|
3080 |
+
if(md - m.o.d < 0) { return false; }
|
3081 |
+
}
|
3082 |
+
return true;
|
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),
|
3090 |
+
vc = this._check("valid_children", p),
|
3091 |
+
ch;
|
3092 |
+
if(!js) { js = {}; }
|
3093 |
+
if(vc === "none") { return false; }
|
3094 |
+
if($.isArray(vc)) {
|
3095 |
+
if(!js.attr || !js.attr[s.type_attr]) {
|
3096 |
+
if(!js.attr) { js.attr = {}; }
|
3097 |
+
js.attr[s.type_attr] = vc[0];
|
3098 |
+
}
|
3099 |
+
else {
|
3100 |
+
if($.inArray(js.attr[s.type_attr], vc) === -1) { return false; }
|
3101 |
+
}
|
3102 |
+
}
|
3103 |
+
if(s.max_children !== -2 && mc !== -1) {
|
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 |
+
}
|
3111 |
+
}
|
3112 |
+
});
|
3113 |
+
})(jQuery);
|
3114 |
+
//*/
|
3115 |
+
|
3116 |
+
/*
|
3117 |
+
* jsTree HTML data 1.0
|
3118 |
+
* The HTML data store. Datastores are build by replacing the `load_node` and `_is_loaded` functions.
|
3119 |
+
*/
|
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,
|
3127 |
+
ajax : false,
|
3128 |
+
correct_state : true
|
3129 |
+
},
|
3130 |
+
_fn : {
|
3131 |
+
load_node : function (obj, s_call, e_call) { var _this = this; this.load_node_html(obj, function () { _this.__callback({ "obj" : obj }); s_call.call(this); }, e_call); },
|
3132 |
+
_is_loaded : function (obj) {
|
3133 |
+
obj = this._get_node(obj);
|
3134 |
+
return obj == -1 || !obj || !this._get_settings().html_data.ajax || obj.is(".jstree-open, .jstree-leaf") || obj.children("ul").children("li").size() > 0;
|
3135 |
+
},
|
3136 |
+
load_node_html : function (obj, s_call, e_call) {
|
3137 |
+
var d,
|
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'> </ins>");
|
3147 |
+
this.clean_node();
|
3148 |
+
}
|
3149 |
+
if(s_call) { s_call.call(this); }
|
3150 |
+
break;
|
3151 |
+
case (!!s.data && !s.ajax) || (!!s.data && !!s.ajax && (!obj || obj === -1)):
|
3152 |
+
if(!obj || obj == -1) {
|
3153 |
+
d = $(s.data);
|
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'> </ins>");
|
3158 |
+
this.clean_node();
|
3159 |
+
}
|
3160 |
+
if(s_call) { s_call.call(this); }
|
3161 |
+
break;
|
3162 |
+
case (!s.data && !!s.ajax) || (!!s.data && !!s.ajax && obj && obj !== -1):
|
3163 |
+
obj = this._get_node(obj);
|
3164 |
+
error_func = function (x, t, e) {
|
3165 |
+
var ef = this.get_settings().html_data.ajax.error;
|
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 {
|
3172 |
+
if(t === "success" && s.correct_state) { this.get_container().children("ul").empty(); }
|
3173 |
+
}
|
3174 |
+
if(e_call) { e_call.call(this); }
|
3175 |
+
};
|
3176 |
+
success_func = function (d, t, x) {
|
3177 |
+
var sf = this.get_settings().html_data.ajax.success;
|
3178 |
+
if(sf) { d = sf.call(this,d,t,x) || d; }
|
3179 |
+
if(d == "") {
|
3180 |
+
return error_func.call(this, x, t, "");
|
3181 |
+
}
|
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'> </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'> </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); }
|
3196 |
+
}
|
3197 |
+
}
|
3198 |
+
else {
|
3199 |
+
if(s.correct_state) {
|
3200 |
+
this.get_container().children("ul").empty();
|
3201 |
+
if(s_call) { s_call.call(this); }
|
3202 |
+
}
|
3203 |
+
}
|
3204 |
+
}
|
3205 |
+
};
|
3206 |
+
s.ajax.context = this;
|
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;
|
3213 |
+
}
|
3214 |
+
}
|
3215 |
+
}
|
3216 |
+
});
|
3217 |
+
// include the HTML data plugin by default
|
3218 |
+
$.jstree.defaults.plugins.push("html_data");
|
3219 |
+
})(jQuery);
|
3220 |
+
//*/
|
3221 |
+
|
3222 |
+
/*
|
3223 |
+
* jsTree themeroller plugin 1.0
|
3224 |
+
* Adds support for jQuery UI themes. Include this at the end of your plugins list, also make sure "themes" is not included.
|
3225 |
+
*/
|
3226 |
+
(function ($) {
|
3227 |
+
$.jstree.plugin("themeroller", {
|
3228 |
+
__init : function () {
|
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) {
|
3239 |
+
this._themeroller(data.rslt.obj);
|
3240 |
+
}, this))
|
3241 |
+
.bind("loaded.jstree refresh.jstree", $.proxy(function (e) {
|
3242 |
+
this._themeroller();
|
3243 |
+
}, this))
|
3244 |
+
.bind("close_node.jstree", $.proxy(function (e, data) {
|
3245 |
+
data.rslt.obj.children("ins").removeClass(s.opened).addClass(s.closed);
|
3246 |
+
}, this))
|
3247 |
+
.bind("select_node.jstree", $.proxy(function (e, data) {
|
3248 |
+
data.rslt.obj.children("a").addClass(s.item_a);
|
3249 |
+
}, this))
|
3250 |
+
.bind("deselect_node.jstree deselect_all.jstree", $.proxy(function (e, data) {
|
3251 |
+
this.get_container()
|
3252 |
+
.find("." + s.item_a).removeClass(s.item_a).end()
|
3253 |
+
.find(".jstree-clicked").addClass(s.item_a);
|
3254 |
+
}, this))
|
3255 |
+
.bind("move_node.jstree", $.proxy(function (e, data) {
|
3256 |
+
this._themeroller(data.rslt.o);
|
3257 |
+
}, this));
|
3258 |
+
},
|
3259 |
+
_fn : {
|
3260 |
+
_themeroller : function (obj) {
|
3261 |
+
var s = this._get_settings().themeroller;
|
3262 |
+
obj = !obj || obj == -1 ? this.get_container() : this._get_node(obj).parent();
|
3263 |
+
obj
|
3264 |
+
.find("li.jstree-closed > ins.jstree-icon").removeClass(s.opened).addClass("ui-icon " + s.closed).end()
|
3265 |
+
.find("li.jstree-open > ins.jstree-icon").removeClass(s.closed).addClass("ui-icon " + s.opened).end()
|
3266 |
+
.find("a").addClass(s.item)
|
3267 |
+
.children("ins.jstree-icon").addClass("ui-icon " + s.item_icon);
|
3268 |
+
}
|
3269 |
+
},
|
3270 |
+
defaults : {
|
3271 |
+
"opened" : "ui-icon-triangle-1-se",
|
3272 |
+
"closed" : "ui-icon-triangle-1-e",
|
3273 |
+
"item" : "ui-state-default",
|
3274 |
+
"item_h" : "ui-state-hover",
|
3275 |
+
"item_a" : "ui-state-active",
|
3276 |
+
"item_icon" : "ui-icon-folder-collapsed"
|
3277 |
+
}
|
3278 |
+
});
|
3279 |
+
$(function() {
|
3280 |
+
var css_string = '.jstree .ui-icon { overflow:visible; } .jstree a { padding:0 2px; }';
|
3281 |
+
$.vakata.css.add_sheet({ str : css_string });
|
3282 |
+
});
|
3283 |
+
})(jQuery);
|
3284 |
+
//*/
|
scripts/jquery.tree.js
DELETED
@@ -1,2064 +0,0 @@
|
|
1 |
-
/*
|
2 |
-
* jsTree 0.9.9a
|
3 |
-
* http://jstree.com/
|
4 |
-
*
|
5 |
-
* Copyright (c) 2009 Ivan Bozhanov (vakata.com)
|
6 |
-
*
|
7 |
-
* Dual licensed under the MIT and GPL licenses:
|
8 |
-
* http://www.opensource.org/licenses/mit-license.php
|
9 |
-
* http://www.gnu.org/licenses/gpl.html
|
10 |
-
*
|
11 |
-
* Date: 2009-10-06
|
12 |
-
*
|
13 |
-
*/
|
14 |
-
|
15 |
-
(function($) {
|
16 |
-
// jQuery plugin
|
17 |
-
$.tree = {
|
18 |
-
datastores : { },
|
19 |
-
plugins : { },
|
20 |
-
defaults : {
|
21 |
-
data : {
|
22 |
-
async : false, // Are async requests used to load open_branch contents
|
23 |
-
type : "html", // One of included datastores
|
24 |
-
opts : { method: "GET", url: false } // Options passed to datastore
|
25 |
-
},
|
26 |
-
selected : false, // FALSE or STRING or ARRAY
|
27 |
-
opened : [], // ARRAY OF INITIALLY OPENED NODES
|
28 |
-
languages : [], // ARRAY of string values (which will be used as CSS classes - so they must be valid)
|
29 |
-
ui : {
|
30 |
-
dots : true, // BOOL - dots or no dots
|
31 |
-
animation : 0, // INT - duration of open/close animations in miliseconds
|
32 |
-
scroll_spd : 4,
|
33 |
-
theme_path : false, // Path to the theme CSS file - if set to false and theme_name is not false - will lookup jstree-path-here/themes/theme-name-here/style.css
|
34 |
-
theme_name : "default",// if set to false no theme will be loaded
|
35 |
-
selected_parent_close : "select_parent", // false, "deselect", "select_parent"
|
36 |
-
selected_delete : "select_previous" // false, "select_previous"
|
37 |
-
},
|
38 |
-
types : {
|
39 |
-
"default" : {
|
40 |
-
clickable : true, // can be function
|
41 |
-
renameable : true, // can be function
|
42 |
-
deletable : true, // can be function
|
43 |
-
creatable : true, // can be function
|
44 |
-
draggable : true, // can be function
|
45 |
-
max_children : -1, // -1 - not set, 0 - no children, 1 - one child, etc // can be function
|
46 |
-
max_depth : -1, // -1 - not set, 0 - no children, 1 - one level of children, etc // can be function
|
47 |
-
valid_children : "all", // all, none, array of values // can be function
|
48 |
-
icon : {
|
49 |
-
image : false,
|
50 |
-
position : false
|
51 |
-
}
|
52 |
-
}
|
53 |
-
},
|
54 |
-
rules : {
|
55 |
-
multiple : false, // FALSE | CTRL | ON - multiple selection off/ with or without holding Ctrl
|
56 |
-
multitree : "none", // all, none, array of tree IDs to accept from
|
57 |
-
type_attr : "rel", // STRING attribute name (where is the type stored as string)
|
58 |
-
createat : "bottom", // STRING (top or bottom) new nodes get inserted at top or bottom
|
59 |
-
drag_copy : "ctrl", // FALSE | CTRL | ON - drag to copy off/ with or without holding Ctrl
|
60 |
-
drag_button : "left", // left, right or both
|
61 |
-
use_max_children : true,
|
62 |
-
use_max_depth : true,
|
63 |
-
|
64 |
-
max_children: -1,
|
65 |
-
max_depth : -1,
|
66 |
-
valid_children : "all"
|
67 |
-
},
|
68 |
-
lang : {
|
69 |
-
new_node : "New folder",
|
70 |
-
loading : "Loading ..."
|
71 |
-
},
|
72 |
-
callback : {
|
73 |
-
beforechange: function(NODE,TREE_OBJ) { return true },
|
74 |
-
beforeopen : function(NODE,TREE_OBJ) { return true },
|
75 |
-
beforeclose : function(NODE,TREE_OBJ) { return true },
|
76 |
-
beforemove : function(NODE,REF_NODE,TYPE,TREE_OBJ) { return true },
|
77 |
-
beforecreate: function(NODE,REF_NODE,TYPE,TREE_OBJ) { return true },
|
78 |
-
beforerename: function(NODE,LANG,TREE_OBJ) { return true },
|
79 |
-
beforedelete: function(NODE,TREE_OBJ) { return true },
|
80 |
-
beforedata : function(NODE,TREE_OBJ) { return { id : $(NODE).attr("id") || 0 } }, // PARAMETERS PASSED TO SERVER
|
81 |
-
ondata : function(DATA,TREE_OBJ) { return DATA; }, // modify data before parsing it
|
82 |
-
onparse : function(STR,TREE_OBJ) { return STR; }, // modify string before visualizing it
|
83 |
-
onhover : function(NODE,TREE_OBJ) { }, // node hovered
|
84 |
-
onselect : function(NODE,TREE_OBJ) { }, // node selected
|
85 |
-
ondeselect : function(NODE,TREE_OBJ) { }, // node deselected
|
86 |
-
onchange : function(NODE,TREE_OBJ) { }, // focus changed
|
87 |
-
onrename : function(NODE,TREE_OBJ,RB) { }, // node renamed
|
88 |
-
onmove : function(NODE,REF_NODE,TYPE,TREE_OBJ,RB) { }, // move completed
|
89 |
-
oncopy : function(NODE,REF_NODE,TYPE,TREE_OBJ,RB) { }, // copy completed
|
90 |
-
oncreate : function(NODE,REF_NODE,TYPE,TREE_OBJ,RB) { }, // node created
|
91 |
-
ondelete : function(NODE,TREE_OBJ,RB) { }, // node deleted
|
92 |
-
onopen : function(NODE,TREE_OBJ) { }, // node opened
|
93 |
-
onopen_all : function(TREE_OBJ) { }, // all nodes opened
|
94 |
-
onclose_all : function(TREE_OBJ) { }, // all nodes closed
|
95 |
-
onclose : function(NODE,TREE_OBJ) { }, // node closed
|
96 |
-
error : function(TEXT,TREE_OBJ) { }, // error occured
|
97 |
-
ondblclk : function(NODE,TREE_OBJ) { TREE_OBJ.toggle_branch.call(TREE_OBJ, NODE); TREE_OBJ.select_branch.call(TREE_OBJ, NODE); },
|
98 |
-
onrgtclk : function(NODE,TREE_OBJ,EV) { }, // right click - to prevent use: EV.preventDefault(); EV.stopPropagation(); return false
|
99 |
-
onload : function(TREE_OBJ) { },
|
100 |
-
oninit : function(TREE_OBJ) { },
|
101 |
-
onfocus : function(TREE_OBJ) { },
|
102 |
-
ondestroy : function(TREE_OBJ) { },
|
103 |
-
onsearch : function(NODES, TREE_OBJ) { NODES.addClass("search"); },
|
104 |
-
ondrop : function(NODE,REF_NODE,TYPE,TREE_OBJ) { },
|
105 |
-
check : function(RULE,NODE,VALUE,TREE_OBJ) { return VALUE; },
|
106 |
-
check_move : function(NODE,REF_NODE,TYPE,TREE_OBJ) { return true; }
|
107 |
-
},
|
108 |
-
plugins : { }
|
109 |
-
},
|
110 |
-
|
111 |
-
create : function () { return new tree_component(); },
|
112 |
-
focused : function () { return tree_component.inst[tree_component.focused]; },
|
113 |
-
reference : function (obj) {
|
114 |
-
var o = $(obj);
|
115 |
-
if(!o.size()) o = $("#" + obj);
|
116 |
-
if(!o.size()) return null;
|
117 |
-
o = (o.is(".tree")) ? o.attr("id") : o.parents(".tree:eq(0)").attr("id");
|
118 |
-
return tree_component.inst[o] || null;
|
119 |
-
},
|
120 |
-
rollback : function (data) {
|
121 |
-
for(var i in data) {
|
122 |
-
if(!data.hasOwnProperty(i)) continue;
|
123 |
-
var tmp = tree_component.inst[i];
|
124 |
-
var lock = !tmp.locked;
|
125 |
-
|
126 |
-
// if not locked - lock the tree
|
127 |
-
if(lock) tmp.lock(true);
|
128 |
-
// Cancel ongoing rename
|
129 |
-
tmp.inp = false;
|
130 |
-
tmp.container.html(data[i].html).find(".dragged").removeClass("dragged").end().find(".hover").removeClass("hover");
|
131 |
-
|
132 |
-
if(data[i].selected) {
|
133 |
-
tmp.selected = $("#" + data[i].selected);
|
134 |
-
tmp.selected_arr = [];
|
135 |
-
tmp.container
|
136 |
-
.find("a.clicked").each( function () {
|
137 |
-
tmp.selected_arr.push(tmp.get_node(this));
|
138 |
-
});
|
139 |
-
}
|
140 |
-
// if this function set the lock - unlock
|
141 |
-
if(lock) tmp.lock(false);
|
142 |
-
|
143 |
-
delete lock;
|
144 |
-
delete tmp;
|
145 |
-
}
|
146 |
-
},
|
147 |
-
drop_mode : function (opts) {
|
148 |
-
opts = $.extend(opts, { show : false, type : "default", str : "Foreign node" });
|
149 |
-
tree_component.drag_drop.foreign = true;
|
150 |
-
tree_component.drag_drop.isdown = true;
|
151 |
-
tree_component.drag_drop.moving = true;
|
152 |
-
tree_component.drag_drop.appended = false;
|
153 |
-
tree_component.drag_drop.f_type = opts.type;
|
154 |
-
tree_component.drag_drop.f_data = opts;
|
155 |
-
|
156 |
-
|
157 |
-
if(!opts.show) {
|
158 |
-
tree_component.drag_drop.drag_help = false;
|
159 |
-
tree_component.drag_drop.drag_node = false;
|
160 |
-
}
|
161 |
-
else {
|
162 |
-
tree_component.drag_drop.drag_help = $("<div id='jstree-dragged' class='tree tree-default'><ul><li class='last dragged foreign'><a href='#'><ins> </ins>" + opts.str + "</a></li></ul></div>");
|
163 |
-
tree_component.drag_drop.drag_node = tree_component.drag_drop.drag_help.find("li:eq(0)");
|
164 |
-
}
|
165 |
-
if($.tree.drag_start !== false) $.tree.drag_start.call(null, false);
|
166 |
-
},
|
167 |
-
drag_start : false,
|
168 |
-
drag : false,
|
169 |
-
drag_end : false
|
170 |
-
};
|
171 |
-
$.fn.tree = function (opts) {
|
172 |
-
return this.each(function() {
|
173 |
-
var conf = $.extend({},opts);
|
174 |
-
if(tree_component.inst && tree_component.inst[$(this).attr('id')]) tree_component.inst[$(this).attr('id')].destroy();
|
175 |
-
if(conf !== false) new tree_component().init(this, conf);
|
176 |
-
});
|
177 |
-
};
|
178 |
-
|
179 |
-
// core
|
180 |
-
function tree_component () {
|
181 |
-
return {
|
182 |
-
cntr : ++tree_component.cntr,
|
183 |
-
settings : $.extend({},$.tree.defaults),
|
184 |
-
|
185 |
-
init : function(elem, conf) {
|
186 |
-
var _this = this;
|
187 |
-
this.container = $(elem);
|
188 |
-
if(this.container.size == 0) return false;
|
189 |
-
tree_component.inst[this.cntr] = this;
|
190 |
-
if(!this.container.attr("id")) this.container.attr("id","jstree_" + this.cntr);
|
191 |
-
tree_component.inst[this.container.attr("id")] = tree_component.inst[this.cntr];
|
192 |
-
tree_component.focused = this.cntr;
|
193 |
-
this.settings = $.extend(true, {}, this.settings, conf);
|
194 |
-
|
195 |
-
// DEAL WITH LANGUAGE VERSIONS
|
196 |
-
if(this.settings.languages && this.settings.languages.length) {
|
197 |
-
this.current_lang = this.settings.languages[0];
|
198 |
-
var st = false;
|
199 |
-
var id = "#" + this.container.attr("id");
|
200 |
-
for(var ln = 0; ln < this.settings.languages.length; ln++) {
|
201 |
-
st = tree_component.add_css(id + " ." + this.settings.languages[ln]);
|
202 |
-
if(st !== false) st.style.display = (this.settings.languages[ln] == this.current_lang) ? "" : "none";
|
203 |
-
}
|
204 |
-
}
|
205 |
-
else this.current_lang = false;
|
206 |
-
// THEMES
|
207 |
-
this.container.addClass("tree");
|
208 |
-
if(this.settings.ui.theme_name !== false) {
|
209 |
-
if(this.settings.ui.theme_path === false) {
|
210 |
-
$("script").each(function () {
|
211 |
-
if(this.src.toString().match(/jquery\.tree.*?js$/)) { _this.settings.ui.theme_path = this.src.toString().replace(/jquery\.tree.*?js$/, "") + "themes/" + _this.settings.ui.theme_name + "/style.css"; return false; }
|
212 |
-
});
|
213 |
-
}
|
214 |
-
if(this.settings.ui.theme_path != "" && $.inArray(this.settings.ui.theme_path, tree_component.themes) == -1) {
|
215 |
-
tree_component.add_sheet({ url : this.settings.ui.theme_path });
|
216 |
-
tree_component.themes.push(this.settings.ui.theme_path);
|
217 |
-
}
|
218 |
-
this.container.addClass("tree-" + this.settings.ui.theme_name);
|
219 |
-
}
|
220 |
-
// TYPE ICONS
|
221 |
-
var type_icons = "";
|
222 |
-
for(var t in this.settings.types) {
|
223 |
-
if(!this.settings.types.hasOwnProperty(t)) continue;
|
224 |
-
if(!this.settings.types[t].icon) continue;
|
225 |
-
if( this.settings.types[t].icon.image || this.settings.types[t].icon.position) {
|
226 |
-
if(t == "default") type_icons += "#" + this.container.attr("id") + " li > a ins { ";
|
227 |
-
else type_icons += "#" + this.container.attr("id") + " li[rel=" + t + "] > a ins { ";
|
228 |
-
if(this.settings.types[t].icon.image) type_icons += " background-image:url(" + this.settings.types[t].icon.image + "); ";
|
229 |
-
if(this.settings.types[t].icon.position) type_icons += " background-position:" + this.settings.types[t].icon.position + "; ";
|
230 |
-
type_icons += "} ";
|
231 |
-
}
|
232 |
-
}
|
233 |
-
if(type_icons != "") tree_component.add_sheet({ str : type_icons });
|
234 |
-
|
235 |
-
if(this.settings.rules.multiple) this.selected_arr = [];
|
236 |
-
this.offset = false;
|
237 |
-
this.hovered = false;
|
238 |
-
this.locked = false;
|
239 |
-
|
240 |
-
if(tree_component.drag_drop.marker === false) tree_component.drag_drop.marker = $("<div>").attr({ id : "jstree-marker" }).hide().appendTo("body");
|
241 |
-
this.callback("oninit", [this]);
|
242 |
-
this.refresh();
|
243 |
-
this.attach_events();
|
244 |
-
this.focus();
|
245 |
-
},
|
246 |
-
refresh : function (obj) {
|
247 |
-
if(this.locked) return this.error("LOCKED");
|
248 |
-
var _this = this;
|
249 |
-
if(obj && !this.settings.data.async) obj = false;
|
250 |
-
this.is_partial_refresh = obj ? true : false;
|
251 |
-
|
252 |
-
// SAVE OPENED
|
253 |
-
this.opened = Array();
|
254 |
-
if(this.settings.opened != false) {
|
255 |
-
$.each(this.settings.opened, function (i, item) {
|
256 |
-
if(this.replace(/^#/,"").length > 0) { _this.opened.push("#" + this.replace(/^#/,"")); }
|
257 |
-
});
|
258 |
-
this.settings.opened = false;
|
259 |
-
}
|
260 |
-
else {
|
261 |
-
this.container.find("li.open").each(function (i) { if(this.id) { _this.opened.push("#" + this.id); } });
|
262 |
-
}
|
263 |
-
|
264 |
-
// SAVE SELECTED
|
265 |
-
if(this.selected) {
|
266 |
-
this.settings.selected = Array();
|
267 |
-
if(obj) {
|
268 |
-
$(obj).find("li:has(a.clicked)").each(function () {
|
269 |
-
if(this.id) _this.settings.selected.push("#" + this.id);
|
270 |
-
});
|
271 |
-
}
|
272 |
-
else {
|
273 |
-
if(this.selected_arr) {
|
274 |
-
$.each(this.selected_arr, function () {
|
275 |
-
if(this.attr("id")) _this.settings.selected.push("#" + this.attr("id"));
|
276 |
-
});
|
277 |
-
}
|
278 |
-
else {
|
279 |
-
if(this.selected.attr("id")) this.settings.selected.push("#" + this.selected.attr("id"));
|
280 |
-
}
|
281 |
-
}
|
282 |
-
}
|
283 |
-
else if(this.settings.selected !== false) {
|
284 |
-
var tmp = Array();
|
285 |
-
if((typeof this.settings.selected).toLowerCase() == "object") {
|
286 |
-
$.each(this.settings.selected, function () {
|
287 |
-
if(this.replace(/^#/,"").length > 0) tmp.push("#" + this.replace(/^#/,""));
|
288 |
-
});
|
289 |
-
}
|
290 |
-
else {
|
291 |
-
if(this.settings.selected.replace(/^#/,"").length > 0) tmp.push("#" + this.settings.selected.replace(/^#/,""));
|
292 |
-
}
|
293 |
-
this.settings.selected = tmp;
|
294 |
-
}
|
295 |
-
|
296 |
-
if(obj && this.settings.data.async) {
|
297 |
-
this.opened = Array();
|
298 |
-
obj = this.get_node(obj);
|
299 |
-
obj.find("li.open").each(function (i) { _this.opened.push("#" + this.id); });
|
300 |
-
if(obj.hasClass("open")) obj.removeClass("open").addClass("closed");
|
301 |
-
if(obj.hasClass("leaf")) obj.removeClass("leaf");
|
302 |
-
obj.children("ul:eq(0)").html("");
|
303 |
-
return this.open_branch(obj, true, function () { _this.reselect.apply(_this); });
|
304 |
-
}
|
305 |
-
|
306 |
-
var _this = this;
|
307 |
-
var _datastore = new $.tree.datastores[this.settings.data.type]();
|
308 |
-
if(this.container.children("ul").size() == 0) {
|
309 |
-
this.container.html("<ul class='ltr' style='direction:ltr;'><li class='last'><a class='loading' href='#'><ins> </ins>" + (this.settings.lang.loading || "Loading ...") + "</a></li></ul>");
|
310 |
-
}
|
311 |
-
_datastore.load(this.callback("beforedata",[false,this]),this,this.settings.data.opts,function(data) {
|
312 |
-
data = _this.callback("ondata",[data, _this]);
|
313 |
-
_datastore.parse(data,_this,_this.settings.data.opts,function(str) {
|
314 |
-
str = _this.callback("onparse", [str, _this]);
|
315 |
-
_this.container.empty().append($("<ul class='ltr'>").html(str));
|
316 |
-
_this.container.find("li:last-child").addClass("last").end().find("li:has(ul)").not(".open").addClass("closed");
|
317 |
-
_this.container.find("li").not(".open").not(".closed").addClass("leaf");
|
318 |
-
_this.reselect();
|
319 |
-
});
|
320 |
-
});
|
321 |
-
},
|
322 |
-
reselect : function (is_callback) {
|
323 |
-
var _this = this;
|
324 |
-
|
325 |
-
if(!is_callback) this.cl_count = 0;
|
326 |
-
else this.cl_count --;
|
327 |
-
// REOPEN BRANCHES
|
328 |
-
if(this.opened && this.opened.length) {
|
329 |
-
var opn = false;
|
330 |
-
for(var j = 0; this.opened && j < this.opened.length; j++) {
|
331 |
-
if(this.settings.data.async) {
|
332 |
-
var tmp = this.get_node(this.opened[j]);
|
333 |
-
if(tmp.size() && tmp.hasClass("closed") > 0) {
|
334 |
-
opn = true;
|
335 |
-
var tmp = this.opened[j].toString().replace('/','\\/');
|
336 |
-
delete this.opened[j];
|
337 |
-
this.open_branch(tmp, true, function () { _this.reselect.apply(_this, [true]); } );
|
338 |
-
this.cl_count ++;
|
339 |
-
}
|
340 |
-
}
|
341 |
-
else this.open_branch(this.opened[j], true);
|
342 |
-
}
|
343 |
-
if(this.settings.data.async && opn) return;
|
344 |
-
if(this.cl_count > 0) return;
|
345 |
-
delete this.opened;
|
346 |
-
}
|
347 |
-
if(this.cl_count > 0) return;
|
348 |
-
|
349 |
-
// DOTS and RIGHT TO LEFT
|
350 |
-
this.container.css("direction","ltr").children("ul:eq(0)").addClass("ltr");
|
351 |
-
if(this.settings.ui.dots == false) this.container.children("ul:eq(0)").addClass("no_dots");
|
352 |
-
|
353 |
-
// REPOSITION SCROLL
|
354 |
-
if(this.scrtop) {
|
355 |
-
this.container.scrollTop(_this.scrtop);
|
356 |
-
delete this.scrtop;
|
357 |
-
}
|
358 |
-
// RESELECT PREVIOUSLY SELECTED
|
359 |
-
if(this.settings.selected !== false) {
|
360 |
-
$.each(this.settings.selected, function (i) {
|
361 |
-
if(_this.is_partial_refresh) _this.select_branch($(_this.settings.selected[i].toString().replace('/','\\/'), _this.container), (_this.settings.rules.multiple !== false) );
|
362 |
-
else _this.select_branch($(_this.settings.selected[i].toString().replace('/','\\/'), _this.container), (_this.settings.rules.multiple !== false && i > 0) );
|
363 |
-
});
|
364 |
-
this.settings.selected = false;
|
365 |
-
}
|
366 |
-
this.callback("onload", [_this]);
|
367 |
-
},
|
368 |
-
|
369 |
-
get : function (obj, format, opts) {
|
370 |
-
if(!format) format = this.settings.data.type;
|
371 |
-
if(!opts) opts = this.settings.data.opts;
|
372 |
-
return new $.tree.datastores[format]().get(obj, this, opts);
|
373 |
-
},
|
374 |
-
|
375 |
-
attach_events : function () {
|
376 |
-
var _this = this;
|
377 |
-
|
378 |
-
this.container
|
379 |
-
.bind("mousedown.jstree", function (event) {
|
380 |
-
if(tree_component.drag_drop.isdown) {
|
381 |
-
tree_component.drag_drop.move_type = false;
|
382 |
-
event.preventDefault();
|
383 |
-
event.stopPropagation();
|
384 |
-
event.stopImmediatePropagation();
|
385 |
-
return false;
|
386 |
-
}
|
387 |
-
})
|
388 |
-
.bind("mouseup.jstree", function (event) {
|
389 |
-
setTimeout( function() { _this.focus.apply(_this); }, 5);
|
390 |
-
})
|
391 |
-
.bind("click.jstree", function (event) {
|
392 |
-
//event.stopPropagation();
|
393 |
-
return true;
|
394 |
-
});
|
395 |
-
$("li", this.container.get(0))
|
396 |
-
.live("click", function(event) { // WHEN CLICK IS ON THE ARROW
|
397 |
-
if(event.target.tagName != "LI") return true;
|
398 |
-
_this.off_height();
|
399 |
-
if(event.pageY - $(event.target).offset().top > _this.li_height) return true;
|
400 |
-
_this.toggle_branch.apply(_this, [event.target]);
|
401 |
-
event.stopPropagation();
|
402 |
-
return false;
|
403 |
-
});
|
404 |
-
$("a", this.container.get(0))
|
405 |
-
.live("click", function (event) { // WHEN CLICK IS ON THE TEXT OR ICON
|
406 |
-
if(event.which && event.which == 3) return true;
|
407 |
-
if(_this.locked) {
|
408 |
-
event.preventDefault();
|
409 |
-
event.target.blur();
|
410 |
-
return _this.error("LOCKED");
|
411 |
-
}
|
412 |
-
_this.select_branch.apply(_this, [event.target, event.ctrlKey || _this.settings.rules.multiple == "on"]);
|
413 |
-
if(_this.inp) { _this.inp.blur(); }
|
414 |
-
event.preventDefault();
|
415 |
-
event.target.blur();
|
416 |
-
return false;
|
417 |
-
})
|
418 |
-
.live("dblclick", function (event) { // WHEN DOUBLECLICK ON TEXT OR ICON
|
419 |
-
if(_this.locked) {
|
420 |
-
event.preventDefault();
|
421 |
-
event.stopPropagation();
|
422 |
-
event.target.blur();
|
423 |
-
return _this.error("LOCKED");
|
424 |
-
}
|
425 |
-
_this.callback("ondblclk", [_this.get_node(event.target).get(0), _this]);
|
426 |
-
event.preventDefault();
|
427 |
-
event.stopPropagation();
|
428 |
-
event.target.blur();
|
429 |
-
})
|
430 |
-
.live("contextmenu", function (event) {
|
431 |
-
if(_this.locked) {
|
432 |
-
event.target.blur();
|
433 |
-
return _this.error("LOCKED");
|
434 |
-
}
|
435 |
-
return _this.callback("onrgtclk", [_this.get_node(event.target).get(0), _this, event]);
|
436 |
-
})
|
437 |
-
.live("mouseover", function (event) {
|
438 |
-
if(_this.locked) {
|
439 |
-
event.preventDefault();
|
440 |
-
event.stopPropagation();
|
441 |
-
return _this.error("LOCKED");
|
442 |
-
}
|
443 |
-
if(_this.hovered !== false && (event.target.tagName == "A" || event.target.tagName == "INS")) {
|
444 |
-
_this.hovered.children("a").removeClass("hover");
|
445 |
-
_this.hovered = false;
|
446 |
-
}
|
447 |
-
_this.callback("onhover",[_this.get_node(event.target).get(0), _this]);
|
448 |
-
})
|
449 |
-
.live("mousedown", function (event) {
|
450 |
-
if(_this.settings.rules.drag_button == "left" && event.which && event.which != 1) return true;
|
451 |
-
if(_this.settings.rules.drag_button == "right" && event.which && event.which != 3) return true;
|
452 |
-
_this.focus.apply(_this);
|
453 |
-
if(_this.locked) return _this.error("LOCKED");
|
454 |
-
// SELECT LIST ITEM NODE
|
455 |
-
var obj = _this.get_node(event.target);
|
456 |
-
// IF ITEM IS DRAGGABLE
|
457 |
-
if(_this.settings.rules.multiple != false && _this.selected_arr.length > 1 && obj.children("a:eq(0)").hasClass("clicked")) {
|
458 |
-
var counter = 0;
|
459 |
-
for(var i in _this.selected_arr) {
|
460 |
-
if(!_this.selected_arr.hasOwnProperty(i)) continue;
|
461 |
-
if(_this.check("draggable", _this.selected_arr[i])) {
|
462 |
-
_this.selected_arr[i].addClass("dragged");
|
463 |
-
tree_component.drag_drop.origin_tree = _this;
|
464 |
-
counter ++;
|
465 |
-
}
|
466 |
-
}
|
467 |
-
if(counter > 0) {
|
468 |
-
if(_this.check("draggable", obj)) tree_component.drag_drop.drag_node = obj;
|
469 |
-
else tree_component.drag_drop.drag_node = _this.container.find("li.dragged:eq(0)");
|
470 |
-
tree_component.drag_drop.isdown = true;
|
471 |
-
tree_component.drag_drop.drag_help = $("<div id='jstree-dragged' class='tree " + ( _this.settings.ui.theme_name != "" ? " tree-" + _this.settings.ui.theme_name : "" ) + "' />").append("<ul class='" + _this.container.children("ul:eq(0)").get(0).className + "' />");
|
472 |
-
var tmp = tree_component.drag_drop.drag_node.clone();
|
473 |
-
if(_this.settings.languages.length > 0) tmp.find("a").not("." + _this.current_lang).hide();
|
474 |
-
tree_component.drag_drop.drag_help.children("ul:eq(0)").append(tmp);
|
475 |
-
tree_component.drag_drop.drag_help.find("li:eq(0)").removeClass("last").addClass("last").children("a").html("<ins> </ins>Multiple selection").end().children("ul").remove();
|
476 |
-
|
477 |
-
tree_component.drag_drop.dragged = _this.container.find("li.dragged");
|
478 |
-
}
|
479 |
-
}
|
480 |
-
else {
|
481 |
-
if(_this.check("draggable", obj)) {
|
482 |
-
tree_component.drag_drop.drag_node = obj;
|
483 |
-
tree_component.drag_drop.drag_help = $("<div id='jstree-dragged' class='tree " + ( _this.settings.ui.theme_name != "" ? " tree-" + _this.settings.ui.theme_name : "" ) + "' />").append("<ul class='" + _this.container.children("ul:eq(0)").get(0).className + "' />");
|
484 |
-
var tmp = obj.clone();
|
485 |
-
if(_this.settings.languages.length > 0) tmp.find("a").not("." + _this.current_lang).hide();
|
486 |
-
tree_component.drag_drop.drag_help.children("ul:eq(0)").append(tmp);
|
487 |
-
tree_component.drag_drop.drag_help.find("li:eq(0)").removeClass("last").addClass("last");
|
488 |
-
tree_component.drag_drop.isdown = true;
|
489 |
-
tree_component.drag_drop.foreign = false;
|
490 |
-
tree_component.drag_drop.origin_tree = _this;
|
491 |
-
obj.addClass("dragged");
|
492 |
-
|
493 |
-
tree_component.drag_drop.dragged = _this.container.find("li.dragged");
|
494 |
-
}
|
495 |
-
}
|
496 |
-
tree_component.drag_drop.init_x = event.pageX;
|
497 |
-
tree_component.drag_drop.init_y = event.pageY;
|
498 |
-
obj.blur();
|
499 |
-
event.preventDefault();
|
500 |
-
event.stopPropagation();
|
501 |
-
return false;
|
502 |
-
});
|
503 |
-
},
|
504 |
-
focus : function () {
|
505 |
-
if(this.locked) return false;
|
506 |
-
if(tree_component.focused != this.cntr) {
|
507 |
-
tree_component.focused = this.cntr;
|
508 |
-
this.callback("onfocus",[this]);
|
509 |
-
}
|
510 |
-
},
|
511 |
-
|
512 |
-
off_height : function () {
|
513 |
-
if(this.offset === false) {
|
514 |
-
this.container.css({ position : "relative" });
|
515 |
-
this.offset = this.container.offset();
|
516 |
-
var tmp = 0;
|
517 |
-
tmp = parseInt($.curCSS(this.container.get(0), "paddingTop", true),10);
|
518 |
-
if(tmp) this.offset.top += tmp;
|
519 |
-
tmp = parseInt($.curCSS(this.container.get(0), "borderTopWidth", true),10);
|
520 |
-
if(tmp) this.offset.top += tmp;
|
521 |
-
this.container.css({ position : "" });
|
522 |
-
}
|
523 |
-
if(!this.li_height) {
|
524 |
-
var tmp = this.container.find("ul li.closed, ul li.leaf").eq(0);
|
525 |
-
this.li_height = tmp.height();
|
526 |
-
if(tmp.children("ul:eq(0)").size()) this.li_height -= tmp.children("ul:eq(0)").height();
|
527 |
-
if(!this.li_height) this.li_height = 18;
|
528 |
-
}
|
529 |
-
},
|
530 |
-
scroll_check : function (x,y) {
|
531 |
-
var _this = this;
|
532 |
-
var cnt = _this.container;
|
533 |
-
var off = _this.container.offset();
|
534 |
-
|
535 |
-
var st = cnt.scrollTop();
|
536 |
-
var sl = cnt.scrollLeft();
|
537 |
-
// DETECT HORIZONTAL SCROLL
|
538 |
-
var h_cor = (cnt.get(0).scrollWidth > cnt.width()) ? 40 : 20;
|
539 |
-
|
540 |
-
if(y - off.top < 20) cnt.scrollTop(Math.max( (st - _this.settings.ui.scroll_spd) ,0)); // NEAR TOP
|
541 |
-
if(cnt.height() - (y - off.top) < h_cor) cnt.scrollTop(st + _this.settings.ui.scroll_spd); // NEAR BOTTOM
|
542 |
-
if(x - off.left < 20) cnt.scrollLeft(Math.max( (sl - _this.settings.ui.scroll_spd),0)); // NEAR LEFT
|
543 |
-
if(cnt.width() - (x - off.left) < 40) cnt.scrollLeft(sl + _this.settings.ui.scroll_spd); // NEAR RIGHT
|
544 |
-
|
545 |
-
if(cnt.scrollLeft() != sl || cnt.scrollTop() != st) {
|
546 |
-
tree_component.drag_drop.move_type = false;
|
547 |
-
tree_component.drag_drop.ref_node = false;
|
548 |
-
tree_component.drag_drop.marker.hide();
|
549 |
-
}
|
550 |
-
tree_component.drag_drop.scroll_time = setTimeout( function() { _this.scroll_check(x,y); }, 50);
|
551 |
-
},
|
552 |
-
scroll_into_view : function (obj) {
|
553 |
-
obj = obj ? this.get_node(obj) : this.selected;
|
554 |
-
if(!obj) return false;
|
555 |
-
var off_t = obj.offset().top;
|
556 |
-
var beg_t = this.container.offset().top;
|
557 |
-
var end_t = beg_t + this.container.height();
|
558 |
-
var h_cor = (this.container.get(0).scrollWidth > this.container.width()) ? 40 : 20;
|
559 |
-
if(off_t + 5 < beg_t) this.container.scrollTop(this.container.scrollTop() - (beg_t - off_t + 5) );
|
560 |
-
if(off_t + h_cor > end_t) this.container.scrollTop(this.container.scrollTop() + (off_t + h_cor - end_t) );
|
561 |
-
},
|
562 |
-
|
563 |
-
get_node : function (obj) {
|
564 |
-
return $(obj).closest("li");
|
565 |
-
},
|
566 |
-
get_type : function (obj) {
|
567 |
-
obj = !obj ? this.selected : this.get_node(obj);
|
568 |
-
if(!obj) return;
|
569 |
-
var tmp = obj.attr(this.settings.rules.type_attr);
|
570 |
-
return tmp || "default";
|
571 |
-
},
|
572 |
-
set_type : function (str, obj) {
|
573 |
-
obj = !obj ? this.selected : this.get_node(obj);
|
574 |
-
if(!obj || !str) return;
|
575 |
-
obj.attr(this.settings.rules.type_attr, str);
|
576 |
-
},
|
577 |
-
get_text : function (obj, lang) {
|
578 |
-
obj = this.get_node(obj);
|
579 |
-
if(!obj || obj.size() == 0) return "";
|
580 |
-
if(this.settings.languages && this.settings.languages.length) {
|
581 |
-
lang = lang ? lang : this.current_lang;
|
582 |
-
obj = obj.children("a." + lang);
|
583 |
-
}
|
584 |
-
else obj = obj.children("a:visible");
|
585 |
-
var val = "";
|
586 |
-
obj.contents().each(function () {
|
587 |
-
if(this.nodeType == 3) { val = this.data; return false; }
|
588 |
-
});
|
589 |
-
return val;
|
590 |
-
},
|
591 |
-
|
592 |
-
check : function (rule, obj) {
|
593 |
-
if(this.locked) return false;
|
594 |
-
var v = false;
|
595 |
-
// if root node
|
596 |
-
if(obj === -1) { if(typeof this.settings.rules[rule] != "undefined") v = this.settings.rules[rule]; }
|
597 |
-
else {
|
598 |
-
obj = !obj ? this.selected : this.get_node(obj);
|
599 |
-
if(!obj) return;
|
600 |
-
var t = this.get_type(obj);
|
601 |
-
if(typeof this.settings.types[t] != "undefined" && typeof this.settings.types[t][rule] != "undefined") v = this.settings.types[t][rule];
|
602 |
-
else if(typeof this.settings.types["default"] != "undefined" && typeof this.settings.types["default"][rule] != "undefined") v = this.settings.types["default"][rule];
|
603 |
-
}
|
604 |
-
if(typeof v == "function") v = v.call(null, obj, this);
|
605 |
-
v = this.callback("check", [rule, obj, v, this]);
|
606 |
-
return v;
|
607 |
-
},
|
608 |
-
check_move : function (nod, ref_node, how) {
|
609 |
-
if(this.locked) return false;
|
610 |
-
if($(ref_node).closest("li.dragged").size()) return false;
|
611 |
-
|
612 |
-
var tree1 = nod.parents(".tree:eq(0)").get(0);
|
613 |
-
var tree2 = ref_node.parents(".tree:eq(0)").get(0);
|
614 |
-
// if different trees
|
615 |
-
if(tree1 && tree1 != tree2) {
|
616 |
-
var m = $.tree.reference(tree2.id).settings.rules.multitree;
|
617 |
-
if(m == "none" || ($.isArray(m) && $.inArray(tree1.id, m) == -1)) return false;
|
618 |
-
}
|
619 |
-
|
620 |
-
var p = (how != "inside") ? this.parent(ref_node) : this.get_node(ref_node);
|
621 |
-
nod = this.get_node(nod);
|
622 |
-
if(p == false) return false;
|
623 |
-
var r = {
|
624 |
-
max_depth : this.settings.rules.use_max_depth ? this.check("max_depth", p) : -1,
|
625 |
-
max_children : this.settings.rules.use_max_children ? this.check("max_children", p) : -1,
|
626 |
-
valid_children : this.check("valid_children", p)
|
627 |
-
};
|
628 |
-
var nod_type = (typeof nod == "string") ? nod : this.get_type(nod);
|
629 |
-
if(typeof r.valid_children != "undefined" && (r.valid_children == "none" || (typeof r.valid_children == "object" && $.inArray(nod_type, $.makeArray(r.valid_children)) == -1))) return false;
|
630 |
-
|
631 |
-
if(this.settings.rules.use_max_children) {
|
632 |
-
if(typeof r.max_children != "undefined" && r.max_children != -1) {
|
633 |
-
if(r.max_children == 0) return false;
|
634 |
-
var c_count = 1;
|
635 |
-
if(tree_component.drag_drop.moving == true && tree_component.drag_drop.foreign == false) {
|
636 |
-
c_count = tree_component.drag_drop.dragged.size();
|
637 |
-
c_count = c_count - p.find('> ul > li.dragged').size();
|
638 |
-
}
|
639 |
-
if(r.max_children < p.find('> ul > li').size() + c_count) return false;
|
640 |
-
}
|
641 |
-
}
|
642 |
-
|
643 |
-
if(this.settings.rules.use_max_depth) {
|
644 |
-
if(typeof r.max_depth != "undefined" && r.max_depth === 0) return this.error("MOVE: MAX-DEPTH REACHED");
|
645 |
-
// check for max_depth up the chain
|
646 |
-
var mx = (r.max_depth > 0) ? r.max_depth : false;
|
647 |
-
var i = 0;
|
648 |
-
var t = p;
|
649 |
-
while(t !== -1) {
|
650 |
-
t = this.parent(t);
|
651 |
-
i ++;
|
652 |
-
var m = this.check("max_depth",t);
|
653 |
-
if(m >= 0) {
|
654 |
-
mx = (mx === false) ? (m - i) : Math.min(mx, m - i);
|
655 |
-
}
|
656 |
-
if(mx !== false && mx <= 0) return this.error("MOVE: MAX-DEPTH REACHED");
|
657 |
-
}
|
658 |
-
if(mx !== false && mx <= 0) return this.error("MOVE: MAX-DEPTH REACHED");
|
659 |
-
if(mx !== false) {
|
660 |
-
var incr = 1;
|
661 |
-
if(typeof nod != "string") {
|
662 |
-
var t = nod;
|
663 |
-
// possible async problem - when nodes are not all loaded down the chain
|
664 |
-
while(t.size() > 0) {
|
665 |
-
if(mx - incr < 0) return this.error("MOVE: MAX-DEPTH REACHED");
|
666 |
-
t = t.children("ul").children("li");
|
667 |
-
incr ++;
|
668 |
-
}
|
669 |
-
}
|
670 |
-
}
|
671 |
-
}
|
672 |
-
if(this.callback("check_move", [nod, ref_node, how, this]) == false) return false;
|
673 |
-
return true;
|
674 |
-
},
|
675 |
-
|
676 |
-
hover_branch : function (obj) {
|
677 |
-
if(this.locked) return this.error("LOCKED");
|
678 |
-
var _this = this;
|
679 |
-
var obj = _this.get_node(obj);
|
680 |
-
if(!obj.size()) return this.error("HOVER: NOT A VALID NODE");
|
681 |
-
if(!_this.check("clickable", obj)) return this.error("SELECT: NODE NOT SELECTABLE");
|
682 |
-
if(this.hovered) this.hovered.children("A").removeClass("hover");
|
683 |
-
this.hovered = obj;
|
684 |
-
this.hovered.children("a").addClass("hover");
|
685 |
-
this.scroll_into_view(this.hovered);
|
686 |
-
},
|
687 |
-
select_branch : function (obj, multiple) {
|
688 |
-
if(this.locked) return this.error("LOCKED");
|
689 |
-
if(!obj && this.hovered !== false) obj = this.hovered;
|
690 |
-
var _this = this;
|
691 |
-
obj = _this.get_node(obj);
|
692 |
-
if(!obj.size()) return this.error("SELECT: NOT A VALID NODE");
|
693 |
-
obj.children("a").removeClass("hover");
|
694 |
-
// CHECK AGAINST RULES FOR SELECTABLE NODES
|
695 |
-
if(!_this.check("clickable", obj)) return this.error("SELECT: NODE NOT SELECTABLE");
|
696 |
-
if(_this.callback("beforechange",[obj.get(0),_this]) === false) return this.error("SELECT: STOPPED BY USER");
|
697 |
-
// IF multiple AND obj IS ALREADY SELECTED - DESELECT IT
|
698 |
-
if(this.settings.rules.multiple != false && multiple && obj.children("a.clicked").size() > 0) {
|
699 |
-
return this.deselect_branch(obj);
|
700 |
-
}
|
701 |
-
if(this.settings.rules.multiple != false && multiple) {
|
702 |
-
this.selected_arr.push(obj);
|
703 |
-
}
|
704 |
-
if(this.settings.rules.multiple != false && !multiple) {
|
705 |
-
for(var i in this.selected_arr) {
|
706 |
-
if(!this.selected_arr.hasOwnProperty(i)) continue;
|
707 |
-
this.selected_arr[i].children("A").removeClass("clicked");
|
708 |
-
this.callback("ondeselect", [this.selected_arr[i].get(0), _this]);
|
709 |
-
}
|
710 |
-
this.selected_arr = [];
|
711 |
-
this.selected_arr.push(obj);
|
712 |
-
if(this.selected && this.selected.children("A").hasClass("clicked")) {
|
713 |
-
this.selected.children("A").removeClass("clicked");
|
714 |
-
this.callback("ondeselect", [this.selected.get(0), _this]);
|
715 |
-
}
|
716 |
-
}
|
717 |
-
if(!this.settings.rules.multiple) {
|
718 |
-
if(this.selected) {
|
719 |
-
this.selected.children("A").removeClass("clicked");
|
720 |
-
this.callback("ondeselect", [this.selected.get(0), _this]);
|
721 |
-
}
|
722 |
-
}
|
723 |
-
// SAVE NEWLY SELECTED
|
724 |
-
this.selected = obj;
|
725 |
-
if(this.hovered !== false) {
|
726 |
-
this.hovered.children("A").removeClass("hover");
|
727 |
-
this.hovered = obj;
|
728 |
-
}
|
729 |
-
|
730 |
-
// FOCUS NEW NODE AND OPEN ALL PARENT NODES IF CLOSED
|
731 |
-
this.selected.children("a").addClass("clicked").end().parents("li.closed").each( function () { _this.open_branch(this, true); });
|
732 |
-
|
733 |
-
// SCROLL SELECTED NODE INTO VIEW
|
734 |
-
this.scroll_into_view(this.selected);
|
735 |
-
|
736 |
-
this.callback("onselect", [this.selected.get(0), _this]);
|
737 |
-
this.callback("onchange", [this.selected.get(0), _this]);
|
738 |
-
},
|
739 |
-
deselect_branch : function (obj) {
|
740 |
-
if(this.locked) return this.error("LOCKED");
|
741 |
-
var _this = this;
|
742 |
-
var obj = this.get_node(obj);
|
743 |
-
if(obj.children("a.clicked").size() == 0) return this.error("DESELECT: NODE NOT SELECTED");
|
744 |
-
|
745 |
-
obj.children("a").removeClass("clicked");
|
746 |
-
this.callback("ondeselect", [obj.get(0), _this]);
|
747 |
-
if(this.settings.rules.multiple != false && this.selected_arr.length > 1) {
|
748 |
-
this.selected_arr = [];
|
749 |
-
this.container.find("a.clicked").filter(":first-child").parent().each(function () {
|
750 |
-
_this.selected_arr.push($(this));
|
751 |
-
});
|
752 |
-
if(obj.get(0) == this.selected.get(0)) {
|
753 |
-
this.selected = this.selected_arr[0];
|
754 |
-
}
|
755 |
-
}
|
756 |
-
else {
|
757 |
-
if(this.settings.rules.multiple != false) this.selected_arr = [];
|
758 |
-
this.selected = false;
|
759 |
-
}
|
760 |
-
this.callback("onchange", [obj.get(0), _this]);
|
761 |
-
},
|
762 |
-
toggle_branch : function (obj) {
|
763 |
-
if(this.locked) return this.error("LOCKED");
|
764 |
-
var obj = this.get_node(obj);
|
765 |
-
if(obj.hasClass("closed")) return this.open_branch(obj);
|
766 |
-
if(obj.hasClass("open")) return this.close_branch(obj);
|
767 |
-
},
|
768 |
-
open_branch : function (obj, disable_animation, callback) {
|
769 |
-
var _this = this;
|
770 |
-
|
771 |
-
if(this.locked) return this.error("LOCKED");
|
772 |
-
var obj = this.get_node(obj);
|
773 |
-
if(!obj.size()) return this.error("OPEN: NO SUCH NODE");
|
774 |
-
if(obj.hasClass("leaf")) return this.error("OPEN: OPENING LEAF NODE");
|
775 |
-
if(this.settings.data.async && obj.find("li").size() == 0) {
|
776 |
-
|
777 |
-
if(this.callback("beforeopen",[obj.get(0),this]) === false) return this.error("OPEN: STOPPED BY USER");
|
778 |
-
|
779 |
-
obj.children("ul:eq(0)").remove().end().append("<ul><li class='last'><a class='loading' href='#'><ins> </ins>" + (_this.settings.lang.loading || "Loading ...") + "</a></li></ul>");
|
780 |
-
obj.removeClass("closed").addClass("open");
|
781 |
-
|
782 |
-
var _datastore = new $.tree.datastores[this.settings.data.type]();
|
783 |
-
_datastore.load(this.callback("beforedata",[obj,this]),this,this.settings.data.opts,function(data){
|
784 |
-
data = _this.callback("ondata", [data, _this]);
|
785 |
-
if(!data || data.length == 0) {
|
786 |
-
obj.removeClass("closed").removeClass("open").addClass("leaf").children("ul").remove();
|
787 |
-
if(callback) callback.call();
|
788 |
-
return;
|
789 |
-
}
|
790 |
-
_datastore.parse(data,_this,_this.settings.data.opts,function(str){
|
791 |
-
str = _this.callback("onparse", [str, _this]);
|
792 |
-
// if(obj.children('ul:eq(0)').children('li').size() > 1) obj.children("ul").find('.loaading').parent().replaceWith(str); else
|
793 |
-
obj.children("ul:eq(0)").replaceWith($("<ul>").html(str));
|
794 |
-
obj.find("li:last-child").addClass("last").end().find("li:has(ul)").not(".open").addClass("closed");
|
795 |
-
obj.find("li").not(".open").not(".closed").addClass("leaf");
|
796 |
-
_this.open_branch.apply(_this, [obj]);
|
797 |
-
if(callback) callback.call();
|
798 |
-
});
|
799 |
-
});
|
800 |
-
return true;
|
801 |
-
}
|
802 |
-
else {
|
803 |
-
if(!this.settings.data.async) {
|
804 |
-
if(this.callback("beforeopen",[obj.get(0),this]) === false) return this.error("OPEN: STOPPED BY USER");
|
805 |
-
}
|
806 |
-
if(parseInt(this.settings.ui.animation) > 0 && !disable_animation ) {
|
807 |
-
obj.children("ul:eq(0)").css("display","none");
|
808 |
-
obj.removeClass("closed").addClass("open");
|
809 |
-
obj.children("ul:eq(0)").slideDown(parseInt(this.settings.ui.animation), function() {
|
810 |
-
$(this).css("display","");
|
811 |
-
if(callback) callback.call();
|
812 |
-
});
|
813 |
-
} else {
|
814 |
-
obj.removeClass("closed").addClass("open");
|
815 |
-
if(callback) callback.call();
|
816 |
-
}
|
817 |
-
this.callback("onopen", [obj.get(0), this]);
|
818 |
-
return true;
|
819 |
-
}
|
820 |
-
},
|
821 |
-
close_branch : function (obj, disable_animation) {
|
822 |
-
if(this.locked) return this.error("LOCKED");
|
823 |
-
var _this = this;
|
824 |
-
var obj = this.get_node(obj);
|
825 |
-
if(!obj.size()) return this.error("CLOSE: NO SUCH NODE");
|
826 |
-
if(_this.callback("beforeclose",[obj.get(0),_this]) === false) return this.error("CLOSE: STOPPED BY USER");
|
827 |
-
if(parseInt(this.settings.ui.animation) > 0 && !disable_animation && obj.children("ul:eq(0)").size() == 1) {
|
828 |
-
obj.children("ul:eq(0)").slideUp(parseInt(this.settings.ui.animation), function() {
|
829 |
-
if(obj.hasClass("open")) obj.removeClass("open").addClass("closed");
|
830 |
-
$(this).css("display","");
|
831 |
-
});
|
832 |
-
}
|
833 |
-
else {
|
834 |
-
if(obj.hasClass("open")) obj.removeClass("open").addClass("closed");
|
835 |
-
}
|
836 |
-
if(this.selected && this.settings.ui.selected_parent_close !== false && obj.children("ul:eq(0)").find("a.clicked").size() > 0) {
|
837 |
-
obj.find("li:has(a.clicked)").each(function() {
|
838 |
-
_this.deselect_branch(this);
|
839 |
-
});
|
840 |
-
if(this.settings.ui.selected_parent_close == "select_parent" && obj.children("a.clicked").size() == 0) this.select_branch(obj, (this.settings.rules.multiple != false && this.selected_arr.length > 0) );
|
841 |
-
}
|
842 |
-
this.callback("onclose", [obj.get(0), this]);
|
843 |
-
},
|
844 |
-
open_all : function (obj, callback) {
|
845 |
-
if(this.locked) return this.error("LOCKED");
|
846 |
-
var _this = this;
|
847 |
-
obj = obj ? this.get_node(obj) : this.container;
|
848 |
-
|
849 |
-
var s = obj.find("li.closed").size();
|
850 |
-
if(!callback) this.cl_count = 0;
|
851 |
-
else this.cl_count --;
|
852 |
-
if(s > 0) {
|
853 |
-
this.cl_count += s;
|
854 |
-
// maybe add .andSelf()
|
855 |
-
obj.find("li.closed").each( function () { var __this = this; _this.open_branch.apply(_this, [this, true, function() { _this.open_all.apply(_this, [__this, true]); } ]); });
|
856 |
-
}
|
857 |
-
else if(this.cl_count == 0) this.callback("onopen_all",[this]);
|
858 |
-
},
|
859 |
-
close_all : function (obj) {
|
860 |
-
if(this.locked) return this.error("LOCKED");
|
861 |
-
var _this = this;
|
862 |
-
obj = obj ? this.get_node(obj) : this.container;
|
863 |
-
// maybe add .andSelf()
|
864 |
-
obj.find("li.open").each( function () { _this.close_branch(this, true); });
|
865 |
-
this.callback("onclose_all",[this]);
|
866 |
-
},
|
867 |
-
|
868 |
-
set_lang : function (i) {
|
869 |
-
if(!$.isArray(this.settings.languages) || this.settings.languages.length == 0) return false;
|
870 |
-
if(this.locked) return this.error("LOCKED");
|
871 |
-
if(!$.inArray(i,this.settings.languages) && typeof this.settings.languages[i] != "undefined") i = this.settings.languages[i];
|
872 |
-
if(typeof i == "undefined") return false;
|
873 |
-
if(i == this.current_lang) return true;
|
874 |
-
var st = false;
|
875 |
-
var id = "#" + this.container.attr("id");
|
876 |
-
st = tree_component.get_css(id + " ." + this.current_lang);
|
877 |
-
if(st !== false) st.style.display = "none";
|
878 |
-
st = tree_component.get_css(id + " ." + i);
|
879 |
-
if(st !== false) st.style.display = "";
|
880 |
-
this.current_lang = i;
|
881 |
-
return true;
|
882 |
-
},
|
883 |
-
get_lang : function () {
|
884 |
-
if(!$.isArray(this.settings.languages) || this.settings.languages.length == 0) return false;
|
885 |
-
return this.current_lang;
|
886 |
-
},
|
887 |
-
|
888 |
-
create : function (obj, ref_node, position) {
|
889 |
-
if(this.locked) return this.error("LOCKED");
|
890 |
-
|
891 |
-
var root = false;
|
892 |
-
if(ref_node == -1) { root = true; ref_node = this.container; }
|
893 |
-
else ref_node = ref_node ? this.get_node(ref_node) : this.selected;
|
894 |
-
|
895 |
-
if(!root && (!ref_node || !ref_node.size())) return this.error("CREATE: NO NODE SELECTED");
|
896 |
-
|
897 |
-
var pos = position;
|
898 |
-
|
899 |
-
var tmp = ref_node; // for type calculation
|
900 |
-
if(position == "before") {
|
901 |
-
position = ref_node.parent().children().index(ref_node);
|
902 |
-
ref_node = ref_node.parents("li:eq(0)");
|
903 |
-
}
|
904 |
-
if(position == "after") {
|
905 |
-
position = ref_node.parent().children().index(ref_node) + 1;
|
906 |
-
ref_node = ref_node.parents("li:eq(0)");
|
907 |
-
}
|
908 |
-
if(!root && ref_node.size() == 0) { root = true; ref_node = this.container; }
|
909 |
-
|
910 |
-
if(!root) {
|
911 |
-
if(!this.check("creatable", ref_node)) return this.error("CREATE: CANNOT CREATE IN NODE");
|
912 |
-
if(ref_node.hasClass("closed")) {
|
913 |
-
if(this.settings.data.async && ref_node.children("ul").size() == 0) {
|
914 |
-
var _this = this;
|
915 |
-
return this.open_branch(ref_node, true, function () { _this.create.apply(_this, [obj, ref_node, position]); } );
|
916 |
-
}
|
917 |
-
else this.open_branch(ref_node, true);
|
918 |
-
}
|
919 |
-
}
|
920 |
-
|
921 |
-
// creating new object to pass to parseJSON
|
922 |
-
var torename = false;
|
923 |
-
if(!obj) obj = {};
|
924 |
-
else obj = $.extend(true, {}, obj);
|
925 |
-
if(!obj.attributes) obj.attributes = {};
|
926 |
-
if(!obj.attributes[this.settings.rules.type_attr]) obj.attributes[this.settings.rules.type_attr] = this.get_type(tmp) || "default";
|
927 |
-
if(this.settings.languages.length) {
|
928 |
-
if(!obj.data) { obj.data = {}; torename = true; }
|
929 |
-
for(var i = 0; i < this.settings.languages.length; i++) {
|
930 |
-
if(!obj.data[this.settings.languages[i]]) obj.data[this.settings.languages[i]] = ((typeof this.settings.lang.new_node).toLowerCase() != "string" && this.settings.lang.new_node[i]) ? this.settings.lang.new_node[i] : this.settings.lang.new_node;
|
931 |
-
}
|
932 |
-
}
|
933 |
-
else {
|
934 |
-
if(!obj.data) { obj.data = this.settings.lang.new_node; torename = true; }
|
935 |
-
}
|
936 |
-
|
937 |
-
obj = this.callback("ondata",[obj, this]);
|
938 |
-
var obj_s = $.tree.datastores.json().parse(obj,this);
|
939 |
-
obj_s = this.callback("onparse", [obj_s, this]);
|
940 |
-
var $li = $(obj_s);
|
941 |
-
|
942 |
-
if($li.children("ul").size()) {
|
943 |
-
if(!$li.is(".open")) $li.addClass("closed");
|
944 |
-
}
|
945 |
-
else $li.addClass("leaf");
|
946 |
-
$li.find("li:last-child").addClass("last").end().find("li:has(ul)").not(".open").addClass("closed");
|
947 |
-
$li.find("li").not(".open").not(".closed").addClass("leaf");
|
948 |
-
|
949 |
-
var r = {
|
950 |
-
max_depth : this.settings.rules.use_max_depth ? this.check("max_depth", (root ? -1 : ref_node) ) : -1,
|
951 |
-
max_children : this.settings.rules.use_max_children ? this.check("max_children", (root ? -1 : ref_node) ) : -1,
|
952 |
-
valid_children : this.check("valid_children", (root ? -1 : ref_node) )
|
953 |
-
};
|
954 |
-
var nod_type = this.get_type($li);
|
955 |
-
if(typeof r.valid_children != "undefined" && (r.valid_children == "none" || ($.isArray(r.valid_children) && $.inArray(nod_type, r.valid_children) == -1))) return this.error("CREATE: NODE NOT A VALID CHILD");
|
956 |
-
|
957 |
-
if(this.settings.rules.use_max_children) {
|
958 |
-
if(typeof r.max_children != "undefined" && r.max_children != -1 && r.max_children >= this.children(ref_node).size()) return this.error("CREATE: MAX_CHILDREN REACHED");
|
959 |
-
}
|
960 |
-
|
961 |
-
if(this.settings.rules.use_max_depth) {
|
962 |
-
if(typeof r.max_depth != "undefined" && r.max_depth === 0) return this.error("CREATE: MAX-DEPTH REACHED");
|
963 |
-
// check for max_depth up the chain
|
964 |
-
var mx = (r.max_depth > 0) ? r.max_depth : false;
|
965 |
-
var i = 0;
|
966 |
-
var t = ref_node;
|
967 |
-
|
968 |
-
while(t !== -1 && !root) {
|
969 |
-
t = this.parent(t);
|
970 |
-
i ++;
|
971 |
-
var m = this.check("max_depth",t);
|
972 |
-
if(m >= 0) {
|
973 |
-
mx = (mx === false) ? (m - i) : Math.min(mx, m - i);
|
974 |
-
}
|
975 |
-
if(mx !== false && mx <= 0) return this.error("CREATE: MAX-DEPTH REACHED");
|
976 |
-
}
|
977 |
-
if(mx !== false && mx <= 0) return this.error("CREATE: MAX-DEPTH REACHED");
|
978 |
-
if(mx !== false) {
|
979 |
-
var incr = 1;
|
980 |
-
var t = $li;
|
981 |
-
while(t.size() > 0) {
|
982 |
-
if(mx - incr < 0) return this.error("CREATE: MAX-DEPTH REACHED");
|
983 |
-
t = t.children("ul").children("li");
|
984 |
-
incr ++;
|
985 |
-
}
|
986 |
-
}
|
987 |
-
}
|
988 |
-
|
989 |
-
if((typeof position).toLowerCase() == "undefined" || position == "inside")
|
990 |
-
position = (this.settings.rules.createat == "top") ? 0 : ref_node.children("ul:eq(0)").children("li").size();
|
991 |
-
if(ref_node.children("ul").size() == 0 || (root == true && ref_node.children("ul").children("li").size() == 0) ) {
|
992 |
-
if(!root) var a = this.moved($li,ref_node.children("a:eq(0)"),"inside", true);
|
993 |
-
else var a = this.moved($li,this.container.children("ul:eq(0)"),"inside", true);
|
994 |
-
}
|
995 |
-
else if(pos == "before" && ref_node.children("ul:eq(0)").children("li:nth-child(" + (position + 1) + ")").size())
|
996 |
-
var a = this.moved($li,ref_node.children("ul:eq(0)").children("li:nth-child(" + (position + 1) + ")").children("a:eq(0)"),"before", true);
|
997 |
-
else if(pos == "after" && ref_node.children("ul:eq(0)").children("li:nth-child(" + (position) + ")").size())
|
998 |
-
var a = this.moved($li,ref_node.children("ul:eq(0)").children("li:nth-child(" + (position) + ")").children("a:eq(0)"),"after", true);
|
999 |
-
else if(ref_node.children("ul:eq(0)").children("li:nth-child(" + (position + 1) + ")").size())
|
1000 |
-
var a = this.moved($li,ref_node.children("ul:eq(0)").children("li:nth-child(" + (position + 1) + ")").children("a:eq(0)"),"before", true);
|
1001 |
-
else
|
1002 |
-
var a = this.moved($li,ref_node.children("ul:eq(0)").children("li:last").children("a:eq(0)"),"after",true);
|
1003 |
-
|
1004 |
-
if(a === false) return this.error("CREATE: ABORTED");
|
1005 |
-
|
1006 |
-
if(torename) {
|
1007 |
-
this.select_branch($li.children("a:eq(0)"));
|
1008 |
-
this.rename();
|
1009 |
-
}
|
1010 |
-
return $li;
|
1011 |
-
},
|
1012 |
-
rename : function (obj, new_name) {
|
1013 |
-
if(this.locked) return this.error("LOCKED");
|
1014 |
-
obj = obj ? this.get_node(obj) : this.selected;
|
1015 |
-
var _this = this;
|
1016 |
-
if(!obj || !obj.size()) return this.error("RENAME: NO NODE SELECTED");
|
1017 |
-
if(!this.check("renameable", obj)) return this.error("RENAME: NODE NOT RENAMABLE");
|
1018 |
-
if(!this.callback("beforerename",[obj.get(0), _this.current_lang, _this])) return this.error("RENAME: STOPPED BY USER");
|
1019 |
-
|
1020 |
-
obj.parents("li.closed").each(function () { _this.open_branch(this) });
|
1021 |
-
if(this.current_lang) obj = obj.find("a." + this.current_lang);
|
1022 |
-
else obj = obj.find("a:first");
|
1023 |
-
|
1024 |
-
// Rollback
|
1025 |
-
var rb = {};
|
1026 |
-
rb[this.container.attr("id")] = this.get_rollback();
|
1027 |
-
|
1028 |
-
var icn = obj.children("ins").clone();
|
1029 |
-
if((typeof new_name).toLowerCase() == "string") {
|
1030 |
-
obj.text(new_name).prepend(icn);
|
1031 |
-
_this.callback("onrename", [_this.get_node(obj).get(0), _this, rb]);
|
1032 |
-
}
|
1033 |
-
else {
|
1034 |
-
var last_value = "";
|
1035 |
-
obj.contents().each(function () {
|
1036 |
-
if(this.nodeType == 3) { last_value = this.data; return false; }
|
1037 |
-
});
|
1038 |
-
_this.inp = $("<input type='text' autocomplete='off' />");
|
1039 |
-
_this.inp
|
1040 |
-
.val(last_value.replace(/&/g,"&").replace(/>/g,">").replace(/</g,"<"))
|
1041 |
-
.bind("mousedown", function (event) { event.stopPropagation(); })
|
1042 |
-
.bind("mouseup", function (event) { event.stopPropagation(); })
|
1043 |
-
.bind("click", function (event) { event.stopPropagation(); })
|
1044 |
-
.bind("keyup", function (event) {
|
1045 |
-
var key = event.keyCode || event.which;
|
1046 |
-
if(key == 27) { this.value = last_value; this.blur(); return }
|
1047 |
-
if(key == 13) { this.blur(); return; }
|
1048 |
-
});
|
1049 |
-
_this.inp.blur(function(event) {
|
1050 |
-
if(this.value == "") this.value = last_value;
|
1051 |
-
obj.text(this.value).prepend(icn);
|
1052 |
-
obj.get(0).style.display = "";
|
1053 |
-
obj.prevAll("span").remove();
|
1054 |
-
_this.inp = false;
|
1055 |
-
_this.callback("onrename", [_this.get_node(obj).get(0), _this, rb]);
|
1056 |
-
});
|
1057 |
-
|
1058 |
-
var spn = $("<span />").addClass(obj.attr("class")).append(icn).append(_this.inp);
|
1059 |
-
obj.get(0).style.display = "none";
|
1060 |
-
obj.parent().prepend(spn);
|
1061 |
-
_this.inp.get(0).focus();
|
1062 |
-
_this.inp.get(0).select();
|
1063 |
-
}
|
1064 |
-
},
|
1065 |
-
remove : function(obj) {
|
1066 |
-
if(this.locked) return this.error("LOCKED");
|
1067 |
-
var _this = this;
|
1068 |
-
|
1069 |
-
// Rollback
|
1070 |
-
var rb = {};
|
1071 |
-
rb[this.container.attr("id")] = this.get_rollback();
|
1072 |
-
|
1073 |
-
if(obj && (!this.selected || this.get_node(obj).get(0) != this.selected.get(0) )) {
|
1074 |
-
obj = this.get_node(obj);
|
1075 |
-
if(obj.size()) {
|
1076 |
-
if(!this.check("deletable", obj)) return this.error("DELETE: NODE NOT DELETABLE");
|
1077 |
-
if(!this.callback("beforedelete",[obj.get(0), _this])) return this.error("DELETE: STOPPED BY USER");
|
1078 |
-
$parent = obj.parent();
|
1079 |
-
if(obj.find("a.clicked").size()) {
|
1080 |
-
var reset_selected = false;
|
1081 |
-
_this.selected_arr = [];
|
1082 |
-
this.container.find("a.clicked").filter(":first-child").parent().each(function () {
|
1083 |
-
if(!reset_selected && this == _this.selected.get(0)) reset_selected = true;
|
1084 |
-
if($(this).parents().index(obj) != -1) return true;
|
1085 |
-
_this.selected_arr.push($(this));
|
1086 |
-
});
|
1087 |
-
if(reset_selected) this.selected = this.selected_arr[0] || false;
|
1088 |
-
}
|
1089 |
-
obj = obj.remove();
|
1090 |
-
$parent.children("li:last").addClass("last");
|
1091 |
-
if($parent.children("li").size() == 0) {
|
1092 |
-
$li = $parent.parents("li:eq(0)");
|
1093 |
-
$li.removeClass("open").removeClass("closed").addClass("leaf").children("ul").remove();
|
1094 |
-
}
|
1095 |
-
this.callback("ondelete", [obj.get(0), this, rb]);
|
1096 |
-
}
|
1097 |
-
}
|
1098 |
-
else if(this.selected) {
|
1099 |
-
if(!this.check("deletable", this.selected)) return this.error("DELETE: NODE NOT DELETABLE");
|
1100 |
-
if(!this.callback("beforedelete",[this.selected.get(0), _this])) return this.error("DELETE: STOPPED BY USER");
|
1101 |
-
$parent = this.selected.parent();
|
1102 |
-
var obj = this.selected;
|
1103 |
-
if(this.settings.rules.multiple == false || this.selected_arr.length == 1) {
|
1104 |
-
var stop = true;
|
1105 |
-
var tmp = this.settings.ui.selected_delete == "select_previous" ? this.prev(this.selected) : false;
|
1106 |
-
}
|
1107 |
-
obj = obj.remove();
|
1108 |
-
$parent.children("li:last").addClass("last");
|
1109 |
-
if($parent.children("li").size() == 0) {
|
1110 |
-
$li = $parent.parents("li:eq(0)");
|
1111 |
-
$li.removeClass("open").removeClass("closed").addClass("leaf").children("ul").remove();
|
1112 |
-
}
|
1113 |
-
if(!stop && this.settings.rules.multiple != false) {
|
1114 |
-
var _this = this;
|
1115 |
-
this.selected_arr = [];
|
1116 |
-
this.container.find("a.clicked").filter(":first-child").parent().each(function () {
|
1117 |
-
_this.selected_arr.push($(this));
|
1118 |
-
});
|
1119 |
-
if(this.selected_arr.length > 0) {
|
1120 |
-
this.selected = this.selected_arr[0];
|
1121 |
-
this.remove();
|
1122 |
-
}
|
1123 |
-
}
|
1124 |
-
if(stop && tmp) this.select_branch(tmp);
|
1125 |
-
this.callback("ondelete", [obj.get(0), this, rb]);
|
1126 |
-
}
|
1127 |
-
else return this.error("DELETE: NO NODE SELECTED");
|
1128 |
-
},
|
1129 |
-
|
1130 |
-
next : function (obj, strict) {
|
1131 |
-
obj = this.get_node(obj);
|
1132 |
-
if(!obj.size()) return false;
|
1133 |
-
if(strict) return (obj.nextAll("li").size() > 0) ? obj.nextAll("li:eq(0)") : false;
|
1134 |
-
|
1135 |
-
if(obj.hasClass("open")) return obj.find("li:eq(0)");
|
1136 |
-
else if(obj.nextAll("li").size() > 0) return obj.nextAll("li:eq(0)");
|
1137 |
-
else return obj.parents("li").next("li").eq(0);
|
1138 |
-
},
|
1139 |
-
prev : function(obj, strict) {
|
1140 |
-
obj = this.get_node(obj);
|
1141 |
-
if(!obj.size()) return false;
|
1142 |
-
if(strict) return (obj.prevAll("li").size() > 0) ? obj.prevAll("li:eq(0)") : false;
|
1143 |
-
|
1144 |
-
if(obj.prev("li").size()) {
|
1145 |
-
var obj = obj.prev("li").eq(0);
|
1146 |
-
while(obj.hasClass("open")) obj = obj.children("ul:eq(0)").children("li:last");
|
1147 |
-
return obj;
|
1148 |
-
}
|
1149 |
-
else return obj.parents("li:eq(0)").size() ? obj.parents("li:eq(0)") : false;
|
1150 |
-
},
|
1151 |
-
parent : function(obj) {
|
1152 |
-
obj = this.get_node(obj);
|
1153 |
-
if(!obj.size()) return false;
|
1154 |
-
return obj.parents("li:eq(0)").size() ? obj.parents("li:eq(0)") : -1;
|
1155 |
-
},
|
1156 |
-
children : function(obj) {
|
1157 |
-
if(obj === -1) return this.container.children("ul:eq(0)").children("li");
|
1158 |
-
|
1159 |
-
obj = this.get_node(obj);
|
1160 |
-
if(!obj.size()) return false;
|
1161 |
-
return obj.children("ul:eq(0)").children("li");
|
1162 |
-
},
|
1163 |
-
|
1164 |
-
toggle_dots : function () {
|
1165 |
-
if(this.settings.ui.dots) {
|
1166 |
-
this.settings.ui.dots = false;
|
1167 |
-
this.container.children("ul:eq(0)").addClass("no_dots");
|
1168 |
-
}
|
1169 |
-
else {
|
1170 |
-
this.settings.ui.dots = true;
|
1171 |
-
this.container.children("ul:eq(0)").removeClass("no_dots");
|
1172 |
-
}
|
1173 |
-
},
|
1174 |
-
|
1175 |
-
callback : function (cb, args) {
|
1176 |
-
var p = false;
|
1177 |
-
var r = null;
|
1178 |
-
for(var i in this.settings.plugins) {
|
1179 |
-
if(typeof $.tree.plugins[i] != "object") continue;
|
1180 |
-
p = $.tree.plugins[i];
|
1181 |
-
if(p.callbacks && typeof p.callbacks[cb] == "function") r = p.callbacks[cb].apply(this, args);
|
1182 |
-
if(typeof r !== "undefined" && r !== null) {
|
1183 |
-
if(cb == "ondata" || cb == "onparse") args[0] = r; // keep the chain if data or parse
|
1184 |
-
else return r;
|
1185 |
-
}
|
1186 |
-
}
|
1187 |
-
p = this.settings.callback[cb];
|
1188 |
-
if(typeof p == "function") return p.apply(null, args);
|
1189 |
-
},
|
1190 |
-
get_rollback : function () {
|
1191 |
-
var rb = {};
|
1192 |
-
rb.html = this.container.html();
|
1193 |
-
rb.selected = this.selected ? this.selected.attr("id") : false;
|
1194 |
-
return rb;
|
1195 |
-
},
|
1196 |
-
moved : function (what, where, how, is_new, is_copy, rb) {
|
1197 |
-
var what = $(what);
|
1198 |
-
var $parent = $(what).parents("ul:eq(0)");
|
1199 |
-
var $where = $(where);
|
1200 |
-
if($where.is("ins")) $where = $where.parent();
|
1201 |
-
|
1202 |
-
// Rollback
|
1203 |
-
if(!rb) {
|
1204 |
-
var rb = {};
|
1205 |
-
rb[this.container.attr("id")] = this.get_rollback();
|
1206 |
-
if(!is_new) {
|
1207 |
-
var tmp = what.size() > 1 ? what.eq(0).parents(".tree:eq(0)") : what.parents(".tree:eq(0)");
|
1208 |
-
if(tmp.get(0) != this.container.get(0)) {
|
1209 |
-
tmp = tree_component.inst[tmp.attr("id")];
|
1210 |
-
rb[tmp.container.attr("id")] = tmp.get_rollback();
|
1211 |
-
}
|
1212 |
-
delete tmp;
|
1213 |
-
}
|
1214 |
-
}
|
1215 |
-
|
1216 |
-
if(how == "inside" && this.settings.data.async) {
|
1217 |
-
var _this = this;
|
1218 |
-
if(this.get_node($where).hasClass("closed")) {
|
1219 |
-
return this.open_branch(this.get_node($where), true, function () { _this.moved.apply(_this, [what, where, how, is_new, is_copy, rb]); });
|
1220 |
-
}
|
1221 |
-
if(this.get_node($where).find("> ul > li > a.loading").size() == 1) {
|
1222 |
-
setTimeout(function () { _this.moved.apply(_this, [what, where, how, is_new, is_copy]); }, 200);
|
1223 |
-
return;
|
1224 |
-
}
|
1225 |
-
}
|
1226 |
-
|
1227 |
-
|
1228 |
-
// IF MULTIPLE
|
1229 |
-
if(what.size() > 1) {
|
1230 |
-
var _this = this;
|
1231 |
-
var tmp = this.moved(what.eq(0), where, how, false, is_copy, rb);
|
1232 |
-
what.each(function (i) {
|
1233 |
-
if(i == 0) return;
|
1234 |
-
if(tmp) { // if tmp is false - the previous move was a no-go
|
1235 |
-
tmp = _this.moved(this, tmp.children("a:eq(0)"), "after", false, is_copy, rb);
|
1236 |
-
}
|
1237 |
-
});
|
1238 |
-
return what;
|
1239 |
-
}
|
1240 |
-
|
1241 |
-
if(is_copy) {
|
1242 |
-
_what = what.clone();
|
1243 |
-
_what.each(function (i) {
|
1244 |
-
this.id = this.id + "_copy";
|
1245 |
-
$(this).find("li").each(function () {
|
1246 |
-
this.id = this.id + "_copy";
|
1247 |
-
});
|
1248 |
-
$(this).removeClass("dragged").find("a.clicked").removeClass("clicked").end().find("li.dragged").removeClass("dragged");
|
1249 |
-
});
|
1250 |
-
}
|
1251 |
-
else _what = what;
|
1252 |
-
if(is_new) {
|
1253 |
-
if(!this.callback("beforecreate", [this.get_node(what).get(0), this.get_node(where).get(0),how,this])) return false;
|
1254 |
-
}
|
1255 |
-
else {
|
1256 |
-
if(!this.callback("beforemove", [this.get_node(what).get(0), this.get_node(where).get(0),how,this])) return false;
|
1257 |
-
}
|
1258 |
-
|
1259 |
-
if(!is_new) {
|
1260 |
-
var tmp = what.parents(".tree:eq(0)");
|
1261 |
-
// if different trees
|
1262 |
-
if(tmp.get(0) != this.container.get(0)) {
|
1263 |
-
tmp = tree_component.inst[tmp.attr("id")];
|
1264 |
-
|
1265 |
-
// if there are languages - otherwise - no cleanup needed
|
1266 |
-
if(tmp.settings.languages.length) {
|
1267 |
-
var res = [];
|
1268 |
-
// if new tree has no languages - use current visible
|
1269 |
-
if(this.settings.languages.length == 0) res.push("." + tmp.current_lang);
|
1270 |
-
else {
|
1271 |
-
for(var i in this.settings.languages) {
|
1272 |
-
if(!this.settings.languages.hasOwnProperty(i)) continue;
|
1273 |
-
for(var j in tmp.settings.languages) {
|
1274 |
-
if(!tmp.settings.languages.hasOwnProperty(j)) continue;
|
1275 |
-
if(this.settings.languages[i] == tmp.settings.languages[j]) res.push("." + this.settings.languages[i]);
|
1276 |
-
}
|
1277 |
-
}
|
1278 |
-
}
|
1279 |
-
if(res.length == 0) return this.error("MOVE: NO COMMON LANGUAGES");
|
1280 |
-
_what.find("a").not(res.join(",")).remove();
|
1281 |
-
}
|
1282 |
-
_what.find("a.clicked").removeClass("clicked");
|
1283 |
-
}
|
1284 |
-
}
|
1285 |
-
what = _what;
|
1286 |
-
|
1287 |
-
// ADD NODE TO NEW PLACE
|
1288 |
-
switch(how) {
|
1289 |
-
case "before":
|
1290 |
-
$where.parents("ul:eq(0)").children("li.last").removeClass("last");
|
1291 |
-
$where.parent().before(what.removeClass("last"));
|
1292 |
-
$where.parents("ul:eq(0)").children("li:last").addClass("last");
|
1293 |
-
break;
|
1294 |
-
case "after":
|
1295 |
-
$where.parents("ul:eq(0)").children("li.last").removeClass("last");
|
1296 |
-
$where.parent().after(what.removeClass("last"));
|
1297 |
-
$where.parents("ul:eq(0)").children("li:last").addClass("last");
|
1298 |
-
break;
|
1299 |
-
case "inside":
|
1300 |
-
if($where.parent().children("ul:first").size()) {
|
1301 |
-
if(this.settings.rules.createat == "top") {
|
1302 |
-
$where.parent().children("ul:first").prepend(what.removeClass("last")).children("li:last").addClass("last");
|
1303 |
-
|
1304 |
-
// restored this section
|
1305 |
-
var tmp_node = $where.parent().children("ul:first").children("li:first");
|
1306 |
-
if(tmp_node.size()) {
|
1307 |
-
how = "before";
|
1308 |
-
where = tmp_node;
|
1309 |
-
}
|
1310 |
-
}
|
1311 |
-
else {
|
1312 |
-
// restored this section
|
1313 |
-
var tmp_node = $where.parent().children("ul:first").children(".last");
|
1314 |
-
if(tmp_node.size()) {
|
1315 |
-
how = "after";
|
1316 |
-
where = tmp_node;
|
1317 |
-
}
|
1318 |
-
|
1319 |
-
$where.parent().children("ul:first").children(".last").removeClass("last").end().append(what.removeClass("last")).children("li:last").addClass("last");
|
1320 |
-
}
|
1321 |
-
}
|
1322 |
-
else {
|
1323 |
-
what.addClass("last");
|
1324 |
-
$where.parent().removeClass("leaf").append("<ul/>");
|
1325 |
-
if(!$where.parent().hasClass("open")) $where.parent().addClass("closed");
|
1326 |
-
$where.parent().children("ul:first").prepend(what);
|
1327 |
-
}
|
1328 |
-
if($where.parent().hasClass("closed")) { this.open_branch($where); }
|
1329 |
-
break;
|
1330 |
-
default:
|
1331 |
-
break;
|
1332 |
-
}
|
1333 |
-
// CLEANUP OLD PARENT
|
1334 |
-
if($parent.find("li").size() == 0) {
|
1335 |
-
var $li = $parent.parent();
|
1336 |
-
$li.removeClass("open").removeClass("closed").addClass("leaf");
|
1337 |
-
if(!$li.is(".tree")) $li.children("ul").remove();
|
1338 |
-
$li.parents("ul:eq(0)").children("li.last").removeClass("last").end().children("li:last").addClass("last");
|
1339 |
-
}
|
1340 |
-
else {
|
1341 |
-
$parent.children("li.last").removeClass("last");
|
1342 |
-
$parent.children("li:last").addClass("last");
|
1343 |
-
}
|
1344 |
-
|
1345 |
-
// NO LONGER CORRECT WITH position PARAM - if(is_new && how != "inside") where = this.get_node(where).parents("li:eq(0)");
|
1346 |
-
if(is_copy) this.callback("oncopy", [this.get_node(what).get(0), this.get_node(where).get(0), how, this, rb]);
|
1347 |
-
else if(is_new) this.callback("oncreate", [this.get_node(what).get(0), ($where.is("ul") ? -1 : this.get_node(where).get(0) ), how, this, rb]);
|
1348 |
-
else this.callback("onmove", [this.get_node(what).get(0), this.get_node(where).get(0), how, this, rb]);
|
1349 |
-
return what;
|
1350 |
-
},
|
1351 |
-
error : function (code) {
|
1352 |
-
this.callback("error",[code,this]);
|
1353 |
-
return false;
|
1354 |
-
},
|
1355 |
-
lock : function (state) {
|
1356 |
-
this.locked = state;
|
1357 |
-
if(this.locked) this.container.children("ul:eq(0)").addClass("locked");
|
1358 |
-
else this.container.children("ul:eq(0)").removeClass("locked");
|
1359 |
-
},
|
1360 |
-
cut : function (obj) {
|
1361 |
-
if(this.locked) return this.error("LOCKED");
|
1362 |
-
obj = obj ? this.get_node(obj) : this.container.find("a.clicked").filter(":first-child").parent();
|
1363 |
-
if(!obj || !obj.size()) return this.error("CUT: NO NODE SELECTED");
|
1364 |
-
tree_component.cut_copy.copy_nodes = false;
|
1365 |
-
tree_component.cut_copy.cut_nodes = obj;
|
1366 |
-
},
|
1367 |
-
copy : function (obj) {
|
1368 |
-
if(this.locked) return this.error("LOCKED");
|
1369 |
-
obj = obj ? this.get_node(obj) : this.container.find("a.clicked").filter(":first-child").parent();
|
1370 |
-
if(!obj || !obj.size()) return this.error("COPY: NO NODE SELECTED");
|
1371 |
-
tree_component.cut_copy.copy_nodes = obj;
|
1372 |
-
tree_component.cut_copy.cut_nodes = false;
|
1373 |
-
},
|
1374 |
-
paste : function (obj, position) {
|
1375 |
-
if(this.locked) return this.error("LOCKED");
|
1376 |
-
|
1377 |
-
var root = false;
|
1378 |
-
if(obj == -1) { root = true; obj = this.container; }
|
1379 |
-
else obj = obj ? this.get_node(obj) : this.selected;
|
1380 |
-
|
1381 |
-
if(!root && (!obj || !obj.size())) return this.error("PASTE: NO NODE SELECTED");
|
1382 |
-
if(!tree_component.cut_copy.copy_nodes && !tree_component.cut_copy.cut_nodes) return this.error("PASTE: NOTHING TO DO");
|
1383 |
-
|
1384 |
-
var _this = this;
|
1385 |
-
|
1386 |
-
var pos = position;
|
1387 |
-
|
1388 |
-
if(position == "before") {
|
1389 |
-
position = obj.parent().children().index(obj);
|
1390 |
-
obj = obj.parents("li:eq(0)");
|
1391 |
-
}
|
1392 |
-
else if(position == "after") {
|
1393 |
-
position = obj.parent().children().index(obj) + 1;
|
1394 |
-
obj = obj.parents("li:eq(0)");
|
1395 |
-
}
|
1396 |
-
else if((typeof position).toLowerCase() == "undefined" || position == "inside") {
|
1397 |
-
position = (this.settings.rules.createat == "top") ? 0 : obj.children("ul:eq(0)").children("li").size();
|
1398 |
-
}
|
1399 |
-
if(!root && obj.size() == 0) { root = true; obj = this.container; }
|
1400 |
-
|
1401 |
-
if(tree_component.cut_copy.copy_nodes && tree_component.cut_copy.copy_nodes.size()) {
|
1402 |
-
var ok = true;
|
1403 |
-
if(!root && !this.check_move(tree_component.cut_copy.copy_nodes, obj.children("a:eq(0)"), "inside")) return false;
|
1404 |
-
|
1405 |
-
if(obj.children("ul").size() == 0 || (root == true && obj.children("ul").children("li").size() == 0) ) {
|
1406 |
-
if(!root) var a = this.moved(tree_component.cut_copy.copy_nodes,obj.children("a:eq(0)"),"inside", false, true);
|
1407 |
-
else var a = this.moved(tree_component.cut_copy.copy_nodes,this.container.children("ul:eq(0)"),"inside", false, true);
|
1408 |
-
}
|
1409 |
-
else if(pos == "before" && obj.children("ul:eq(0)").children("li:nth-child(" + (position + 1) + ")").size())
|
1410 |
-
var a = this.moved(tree_component.cut_copy.copy_nodes,obj.children("ul:eq(0)").children("li:nth-child(" + (position + 1) + ")").children("a:eq(0)"),"before", false, true);
|
1411 |
-
else if(pos == "after" && obj.children("ul:eq(0)").children("li:nth-child(" + (position) + ")").size())
|
1412 |
-
var a = this.moved(tree_component.cut_copy.copy_nodes,obj.children("ul:eq(0)").children("li:nth-child(" + (position) + ")").children("a:eq(0)"),"after", false, true);
|
1413 |
-
else if(obj.children("ul:eq(0)").children("li:nth-child(" + (position + 1) + ")").size())
|
1414 |
-
var a = this.moved(tree_component.cut_copy.copy_nodes,obj.children("ul:eq(0)").children("li:nth-child(" + (position + 1) + ")").children("a:eq(0)"),"before", false, true);
|
1415 |
-
else
|
1416 |
-
var a = this.moved(tree_component.cut_copy.copy_nodes,obj.children("ul:eq(0)").children("li:last").children("a:eq(0)"),"after", false, true);
|
1417 |
-
tree_component.cut_copy.copy_nodes = false;
|
1418 |
-
}
|
1419 |
-
if(tree_component.cut_copy.cut_nodes && tree_component.cut_copy.cut_nodes.size()) {
|
1420 |
-
var ok = true;
|
1421 |
-
obj.parents().andSelf().each(function () {
|
1422 |
-
if(tree_component.cut_copy.cut_nodes.index(this) != -1) {
|
1423 |
-
ok = false;
|
1424 |
-
return false;
|
1425 |
-
}
|
1426 |
-
});
|
1427 |
-
if(!ok) return this.error("Invalid paste");
|
1428 |
-
if(!root && !this.check_move(tree_component.cut_copy.cut_nodes, obj.children("a:eq(0)"), "inside")) return false;
|
1429 |
-
|
1430 |
-
if(obj.children("ul").size() == 0 || (root == true && obj.children("ul").children("li").size() == 0) ) {
|
1431 |
-
if(!root) var a = this.moved(tree_component.cut_copy.cut_nodes,obj.children("a:eq(0)"),"inside");
|
1432 |
-
else var a = this.moved(tree_component.cut_copy.cut_nodes,this.container.children("ul:eq(0)"),"inside");
|
1433 |
-
}
|
1434 |
-
else if(pos == "before" && obj.children("ul:eq(0)").children("li:nth-child(" + (position + 1) + ")").size())
|
1435 |
-
var a = this.moved(tree_component.cut_copy.cut_nodes,obj.children("ul:eq(0)").children("li:nth-child(" + (position + 1) + ")").children("a:eq(0)"),"before");
|
1436 |
-
else if(pos == "after" && obj.children("ul:eq(0)").children("li:nth-child(" + (position) + ")").size())
|
1437 |
-
var a = this.moved(tree_component.cut_copy.cut_nodes,obj.children("ul:eq(0)").children("li:nth-child(" + (position) + ")").children("a:eq(0)"),"after");
|
1438 |
-
else if(obj.children("ul:eq(0)").children("li:nth-child(" + (position + 1) + ")").size())
|
1439 |
-
var a = this.moved(tree_component.cut_copy.cut_nodes,obj.children("ul:eq(0)").children("li:nth-child(" + (position + 1) + ")").children("a:eq(0)"),"before");
|
1440 |
-
else
|
1441 |
-
var a = this.moved(tree_component.cut_copy.cut_nodes,obj.children("ul:eq(0)").children("li:last").children("a:eq(0)"),"after");
|
1442 |
-
tree_component.cut_copy.cut_nodes = false;
|
1443 |
-
}
|
1444 |
-
},
|
1445 |
-
search : function(str, func) {
|
1446 |
-
var _this = this;
|
1447 |
-
if(!str || (this.srch && str != this.srch) ) {
|
1448 |
-
this.srch = "";
|
1449 |
-
this.srch_opn = false;
|
1450 |
-
this.container.find("a.search").removeClass("search");
|
1451 |
-
}
|
1452 |
-
this.srch = str;
|
1453 |
-
if(!str) return;
|
1454 |
-
|
1455 |
-
if(!func) func = "contains";
|
1456 |
-
if(this.settings.data.async) {
|
1457 |
-
if(!this.srch_opn) {
|
1458 |
-
var dd = $.extend( { "search" : str } , this.callback("beforedata", [false, this] ) );
|
1459 |
-
$.ajax({
|
1460 |
-
type : this.settings.data.opts.method,
|
1461 |
-
url : this.settings.data.opts.url,
|
1462 |
-
data : dd,
|
1463 |
-
dataType : "text",
|
1464 |
-
success : function (data) {
|
1465 |
-
_this.srch_opn = $.unique(data.split(","));
|
1466 |
-
_this.search.apply(_this,[str, func]);
|
1467 |
-
}
|
1468 |
-
});
|
1469 |
-
}
|
1470 |
-
else if(this.srch_opn.length) {
|
1471 |
-
if(this.srch_opn && this.srch_opn.length) {
|
1472 |
-
var opn = false;
|
1473 |
-
for(var j = 0; j < this.srch_opn.length; j++) {
|
1474 |
-
if(this.get_node("#" + this.srch_opn[j]).size() > 0) {
|
1475 |
-
opn = true;
|
1476 |
-
var tmp = "#" + this.srch_opn[j];
|
1477 |
-
delete this.srch_opn[j];
|
1478 |
-
this.open_branch(tmp, true, function () { _this.search.apply(_this,[str, func]); } );
|
1479 |
-
}
|
1480 |
-
}
|
1481 |
-
if(!opn) {
|
1482 |
-
this.srch_opn = [];
|
1483 |
-
_this.search.apply(_this,[str, func]);
|
1484 |
-
}
|
1485 |
-
}
|
1486 |
-
}
|
1487 |
-
else {
|
1488 |
-
this.srch_opn = false;
|
1489 |
-
var selector = "a";
|
1490 |
-
// IF LANGUAGE VERSIONS
|
1491 |
-
if(this.settings.languages.length) selector += "." + this.current_lang;
|
1492 |
-
this.callback("onsearch", [this.container.find(selector + ":" + func + "('" + str + "')"), this]);
|
1493 |
-
}
|
1494 |
-
}
|
1495 |
-
else {
|
1496 |
-
var selector = "a";
|
1497 |
-
// IF LANGUAGE VERSIONS
|
1498 |
-
if(this.settings.languages.length) selector += "." + this.current_lang;
|
1499 |
-
var nn = this.container.find(selector + ":" + func + "('" + str + "')");
|
1500 |
-
nn.parents("li.closed").each( function () { _this.open_branch(this, true); });
|
1501 |
-
this.callback("onsearch", [nn, this]);
|
1502 |
-
}
|
1503 |
-
},
|
1504 |
-
add_sheet : tree_component.add_sheet,
|
1505 |
-
|
1506 |
-
destroy : function() {
|
1507 |
-
this.callback("ondestroy", [this]);
|
1508 |
-
|
1509 |
-
this.container.unbind(".jstree");
|
1510 |
-
$("#" + this.container.attr("id")).die("click.jstree").die("dblclick.jstree").die("mouseover.jstree").die("mouseout.jstree").die("mousedown.jstree");
|
1511 |
-
this.container.removeClass("tree ui-widget ui-widget-content tree-default tree-" + this.settings.ui.theme_name).children("ul").removeClass("no_dots ltr locked").find("li").removeClass("leaf").removeClass("open").removeClass("closed").removeClass("last").children("a").removeClass("clicked hover search");
|
1512 |
-
|
1513 |
-
if(this.cntr == tree_component.focused) {
|
1514 |
-
for(var i in tree_component.inst) {
|
1515 |
-
if(i != this.cntr && i != this.container.attr("id")) {
|
1516 |
-
tree_component.inst[i].focus();
|
1517 |
-
break;
|
1518 |
-
}
|
1519 |
-
}
|
1520 |
-
}
|
1521 |
-
|
1522 |
-
tree_component.inst[this.cntr] = false;
|
1523 |
-
tree_component.inst[this.container.attr("id")] = false;
|
1524 |
-
delete tree_component.inst[this.cntr];
|
1525 |
-
delete tree_component.inst[this.container.attr("id")];
|
1526 |
-
tree_component.cntr --;
|
1527 |
-
}
|
1528 |
-
}
|
1529 |
-
};
|
1530 |
-
|
1531 |
-
// instance manager
|
1532 |
-
tree_component.cntr = 0;
|
1533 |
-
tree_component.inst = {};
|
1534 |
-
|
1535 |
-
// themes
|
1536 |
-
tree_component.themes = [];
|
1537 |
-
|
1538 |
-
// drag'n'drop stuff
|
1539 |
-
tree_component.drag_drop = {
|
1540 |
-
isdown : false, // Is there a drag
|
1541 |
-
drag_node : false, // The actual node
|
1542 |
-
drag_help : false, // The helper
|
1543 |
-
dragged : false,
|
1544 |
-
|
1545 |
-
init_x : false,
|
1546 |
-
init_y : false,
|
1547 |
-
moving : false,
|
1548 |
-
|
1549 |
-
origin_tree : false,
|
1550 |
-
marker : false,
|
1551 |
-
|
1552 |
-
move_type : false, // before, after or inside
|
1553 |
-
ref_node : false, // reference node
|
1554 |
-
appended : false, // is helper appended
|
1555 |
-
|
1556 |
-
foreign : false, // Is the dragged node a foreign one
|
1557 |
-
droppable : [], // Array of classes that can be dropped onto the tree
|
1558 |
-
|
1559 |
-
open_time : false, // Timeout for opening nodes
|
1560 |
-
scroll_time : false // Timeout for scrolling
|
1561 |
-
};
|
1562 |
-
tree_component.mouseup = function(event) {
|
1563 |
-
var tmp = tree_component.drag_drop;
|
1564 |
-
if(tmp.open_time) clearTimeout(tmp.open_time);
|
1565 |
-
if(tmp.scroll_time) clearTimeout(tmp.scroll_time);
|
1566 |
-
|
1567 |
-
if(tmp.moving && $.tree.drag_end !== false) $.tree.drag_end.call(null, event, tmp);
|
1568 |
-
|
1569 |
-
if(tmp.foreign === false && tmp.drag_node && tmp.drag_node.size()) {
|
1570 |
-
tmp.drag_help.remove();
|
1571 |
-
if(tmp.move_type) {
|
1572 |
-
var tree1 = tree_component.inst[tmp.ref_node.parents(".tree:eq(0)").attr("id")];
|
1573 |
-
if(tree1) tree1.moved(tmp.dragged, tmp.ref_node, tmp.move_type, false, (tmp.origin_tree.settings.rules.drag_copy == "on" || (tmp.origin_tree.settings.rules.drag_copy == "ctrl" && event.ctrlKey) ) );
|
1574 |
-
}
|
1575 |
-
tmp.move_type = false;
|
1576 |
-
tmp.ref_node = false;
|
1577 |
-
}
|
1578 |
-
if(tmp.foreign !== false) {
|
1579 |
-
if(tmp.drag_help) tmp.drag_help.remove();
|
1580 |
-
if(tmp.move_type) {
|
1581 |
-
var tree1 = tree_component.inst[tmp.ref_node.parents(".tree:eq(0)").attr("id")];
|
1582 |
-
if(tree1) tree1.callback("ondrop",[tmp.f_data, tree1.get_node(tmp.ref_node).get(0), tmp.move_type, tree1]);
|
1583 |
-
}
|
1584 |
-
tmp.foreign = false;
|
1585 |
-
tmp.move_type = false;
|
1586 |
-
tmp.ref_node = false;
|
1587 |
-
}
|
1588 |
-
// RESET EVERYTHING
|
1589 |
-
if(tree_component.drag_drop.marker) tree_component.drag_drop.marker.hide();
|
1590 |
-
if(tmp.dragged && tmp.dragged.size()) tmp.dragged.removeClass("dragged");
|
1591 |
-
tmp.dragged = false;
|
1592 |
-
tmp.drag_help = false;
|
1593 |
-
tmp.drag_node = false;
|
1594 |
-
tmp.f_type = false;
|
1595 |
-
tmp.f_data = false;
|
1596 |
-
tmp.init_x = false;
|
1597 |
-
tmp.init_y = false;
|
1598 |
-
tmp.moving = false;
|
1599 |
-
tmp.appended = false;
|
1600 |
-
tmp.origin_tree = false;
|
1601 |
-
if(tmp.isdown) {
|
1602 |
-
tmp.isdown = false;
|
1603 |
-
event.preventDefault();
|
1604 |
-
event.stopPropagation();
|
1605 |
-
return false;
|
1606 |
-
}
|
1607 |
-
};
|
1608 |
-
tree_component.mousemove = function(event) {
|
1609 |
-
var tmp = tree_component.drag_drop;
|
1610 |
-
var is_start = false;
|
1611 |
-
|
1612 |
-
if(tmp.isdown) {
|
1613 |
-
if(!tmp.moving && Math.abs(tmp.init_x - event.pageX) < 5 && Math.abs(tmp.init_y - event.pageY) < 5) {
|
1614 |
-
event.preventDefault();
|
1615 |
-
event.stopPropagation();
|
1616 |
-
return false;
|
1617 |
-
}
|
1618 |
-
else {
|
1619 |
-
if(!tmp.moving) {
|
1620 |
-
tree_component.drag_drop.moving = true;
|
1621 |
-
is_start = true;
|
1622 |
-
}
|
1623 |
-
}
|
1624 |
-
|
1625 |
-
if(tmp.open_time) clearTimeout(tmp.open_time);
|
1626 |
-
|
1627 |
-
if(tmp.drag_help !== false) {
|
1628 |
-
if(!tmp.appended) {
|
1629 |
-
if(tmp.foreign !== false) tmp.origin_tree = $.tree.focused();
|
1630 |
-
$("body").append(tmp.drag_help);
|
1631 |
-
tmp.w = tmp.drag_help.width();
|
1632 |
-
tmp.appended = true;
|
1633 |
-
}
|
1634 |
-
tmp.drag_help.css({ "left" : (event.pageX + 5 ), "top" : (event.pageY + 15) });
|
1635 |
-
}
|
1636 |
-
|
1637 |
-
if(is_start && $.tree.drag_start !== false) $.tree.drag_start.call(null, event, tmp);
|
1638 |
-
if($.tree.drag !== false) $.tree.drag.call(null, event, tmp);
|
1639 |
-
|
1640 |
-
if(event.target.tagName == "DIV" && event.target.id == "jstree-marker") return false;
|
1641 |
-
|
1642 |
-
var et = $(event.target);
|
1643 |
-
if(et.is("ins")) et = et.parent();
|
1644 |
-
var cnt = et.is(".tree") ? et : et.parents(".tree:eq(0)");
|
1645 |
-
|
1646 |
-
// if not moving over a tree
|
1647 |
-
if(cnt.size() == 0 || !tree_component.inst[cnt.attr("id")]) {
|
1648 |
-
if(tmp.scroll_time) clearTimeout(tmp.scroll_time);
|
1649 |
-
if(tmp.drag_help !== false) tmp.drag_help.find("li:eq(0) ins").addClass("forbidden");
|
1650 |
-
tmp.move_type = false;
|
1651 |
-
tmp.ref_node = false;
|
1652 |
-
tree_component.drag_drop.marker.hide();
|
1653 |
-
return false;
|
1654 |
-
}
|
1655 |
-
|
1656 |
-
var tree2 = tree_component.inst[cnt.attr("id")];
|
1657 |
-
tree2.off_height();
|
1658 |
-
|
1659 |
-
if(tmp.scroll_time) clearTimeout(tmp.scroll_time);
|
1660 |
-
tmp.scroll_time = setTimeout( function() { tree2.scroll_check(event.pageX,event.pageY); }, 50);
|
1661 |
-
|
1662 |
-
var mov = false;
|
1663 |
-
var st = cnt.scrollTop();
|
1664 |
-
|
1665 |
-
if(event.target.tagName == "A" || event.target.tagName == "INS") {
|
1666 |
-
// just in case if hover is over the draggable
|
1667 |
-
if(et.is("#jstree-dragged")) return false;
|
1668 |
-
if(tree2.get_node(event.target).hasClass("closed")) {
|
1669 |
-
tmp.open_time = setTimeout( function () { tree2.open_branch(et); }, 500);
|
1670 |
-
}
|
1671 |
-
|
1672 |
-
var et_off = et.offset();
|
1673 |
-
var goTo = {
|
1674 |
-
x : (et_off.left - 1),
|
1675 |
-
y : (event.pageY - et_off.top)
|
1676 |
-
};
|
1677 |
-
|
1678 |
-
var arr = [];
|
1679 |
-
if(goTo.y < tree2.li_height/3 + 1 ) arr = ["before","inside","after"];
|
1680 |
-
else if(goTo.y > tree2.li_height*2/3 - 1 ) arr = ["after","inside","before"];
|
1681 |
-
else {
|
1682 |
-
if(goTo.y < tree2.li_height/2) arr = ["inside","before","after"];
|
1683 |
-
else arr = ["inside","after","before"];
|
1684 |
-
}
|
1685 |
-
var ok = false;
|
1686 |
-
var nn = (tmp.foreign == false) ? tmp.origin_tree.container.find("li.dragged") : tmp.f_type;
|
1687 |
-
$.each(arr, function(i, val) {
|
1688 |
-
if(tree2.check_move(nn, et, val)) {
|
1689 |
-
mov = val;
|
1690 |
-
ok = true;
|
1691 |
-
return false;
|
1692 |
-
}
|
1693 |
-
});
|
1694 |
-
if(ok) {
|
1695 |
-
switch(mov) {
|
1696 |
-
case "before":
|
1697 |
-
goTo.y = et_off.top - 2;
|
1698 |
-
tree_component.drag_drop.marker.attr("class","marker");
|
1699 |
-
break;
|
1700 |
-
case "after":
|
1701 |
-
goTo.y = et_off.top - 2 + tree2.li_height;
|
1702 |
-
tree_component.drag_drop.marker.attr("class","marker");
|
1703 |
-
break;
|
1704 |
-
case "inside":
|
1705 |
-
goTo.x -= 2;
|
1706 |
-
goTo.y = et_off.top - 2 + tree2.li_height/2;
|
1707 |
-
tree_component.drag_drop.marker.attr("class","marker_plus");
|
1708 |
-
break;
|
1709 |
-
}
|
1710 |
-
tmp.move_type = mov;
|
1711 |
-
tmp.ref_node = $(event.target);
|
1712 |
-
if(tmp.drag_help !== false) tmp.drag_help.find(".forbidden").removeClass("forbidden");
|
1713 |
-
tree_component.drag_drop.marker.css({ "left" : goTo.x , "top" : goTo.y }).show();
|
1714 |
-
}
|
1715 |
-
}
|
1716 |
-
|
1717 |
-
if( (et.is(".tree") || et.is("ul") ) && et.find("li:eq(0)").size() == 0) {
|
1718 |
-
var et_off = et.offset();
|
1719 |
-
tmp.move_type = "inside";
|
1720 |
-
tmp.ref_node = cnt.children("ul:eq(0)");
|
1721 |
-
if(tmp.drag_help !== false) tmp.drag_help.find(".forbidden").removeClass("forbidden");
|
1722 |
-
tree_component.drag_drop.marker.attr("class","marker_plus");
|
1723 |
-
tree_component.drag_drop.marker.css({ "left" : (et_off.left + 10) , "top" : et_off.top + 15 }).show();
|
1724 |
-
}
|
1725 |
-
else if( (event.target.tagName != "A" && event.target.tagName != "INS") || !ok) {
|
1726 |
-
if(tmp.drag_help !== false) tmp.drag_help.find("li:eq(0) ins").addClass("forbidden");
|
1727 |
-
tmp.move_type = false;
|
1728 |
-
tmp.ref_node = false;
|
1729 |
-
tree_component.drag_drop.marker.hide();
|
1730 |
-
}
|
1731 |
-
event.preventDefault();
|
1732 |
-
event.stopPropagation();
|
1733 |
-
return false;
|
1734 |
-
}
|
1735 |
-
return true;
|
1736 |
-
};
|
1737 |
-
$(function () {
|
1738 |
-
$(document).bind("mousemove.jstree", tree_component.mousemove);
|
1739 |
-
$(document).bind("mouseup.jstree", tree_component.mouseup);
|
1740 |
-
});
|
1741 |
-
|
1742 |
-
// cut, copy, paste stuff
|
1743 |
-
tree_component.cut_copy = {
|
1744 |
-
copy_nodes : false,
|
1745 |
-
cut_nodes : false
|
1746 |
-
};
|
1747 |
-
|
1748 |
-
// css stuff
|
1749 |
-
tree_component.css = false;
|
1750 |
-
tree_component.get_css = function(rule_name, delete_flag) {
|
1751 |
-
rule_name = rule_name.toLowerCase();
|
1752 |
-
var css_rules = tree_component.css.cssRules || tree_component.css.rules;
|
1753 |
-
var j = 0;
|
1754 |
-
do {
|
1755 |
-
if(css_rules.length && j > css_rules.length + 5) return false;
|
1756 |
-
if(css_rules[j].selectorText && css_rules[j].selectorText.toLowerCase() == rule_name) {
|
1757 |
-
if(delete_flag == true) {
|
1758 |
-
if(tree_component.css.removeRule) document.styleSheets[i].removeRule(j);
|
1759 |
-
if(tree_component.css.deleteRule) document.styleSheets[i].deleteRule(j);
|
1760 |
-
return true;
|
1761 |
-
}
|
1762 |
-
else return css_rules[j];
|
1763 |
-
}
|
1764 |
-
}
|
1765 |
-
while (css_rules[++j]);
|
1766 |
-
return false;
|
1767 |
-
};
|
1768 |
-
tree_component.add_css = function(rule_name) {
|
1769 |
-
if(tree_component.get_css(rule_name)) return false;
|
1770 |
-
(tree_component.css.insertRule) ? tree_component.css.insertRule(rule_name + ' { }', 0) : tree_component.css.addRule(rule_name, null, 0);
|
1771 |
-
return tree_component.get_css(rule_name);
|
1772 |
-
};
|
1773 |
-
tree_component.remove_css = function(rule_name) {
|
1774 |
-
return tree_component.get_css(rule_name, true);
|
1775 |
-
};
|
1776 |
-
tree_component.add_sheet = function(opts) {
|
1777 |
-
if(opts.str) {
|
1778 |
-
var tmp = document.createElement("style");
|
1779 |
-
tmp.setAttribute('type',"text/css");
|
1780 |
-
if(tmp.styleSheet) {
|
1781 |
-
document.getElementsByTagName("head")[0].appendChild(tmp);
|
1782 |
-
tmp.styleSheet.cssText = opts.str;
|
1783 |
-
}
|
1784 |
-
else {
|
1785 |
-
tmp.appendChild(document.createTextNode(opts.str));
|
1786 |
-
document.getElementsByTagName("head")[0].appendChild(tmp);
|
1787 |
-
}
|
1788 |
-
return tmp.sheet || tmp.styleSheet;
|
1789 |
-
}
|
1790 |
-
if(opts.url) {
|
1791 |
-
if(document.createStyleSheet) {
|
1792 |
-
try { document.createStyleSheet(opts.url); } catch (e) { };
|
1793 |
-
}
|
1794 |
-
else {
|
1795 |
-
var newSS = document.createElement('link');
|
1796 |
-
newSS.rel = 'stylesheet';
|
1797 |
-
newSS.type = 'text/css';
|
1798 |
-
newSS.media = "all";
|
1799 |
-
newSS.href = opts.url;
|
1800 |
-
// var styles = "@import url(' " + url + " ');";
|
1801 |
-
// newSS.href ='data:text/css,'+escape(styles);
|
1802 |
-
document.getElementsByTagName("head")[0].appendChild(newSS);
|
1803 |
-
return newSS.styleSheet;
|
1804 |
-
}
|
1805 |
-
}
|
1806 |
-
};
|
1807 |
-
$(function () {
|
1808 |
-
var u = navigator.userAgent.toLowerCase();
|
1809 |
-
var v = (u.match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [0,'0'])[1];
|
1810 |
-
|
1811 |
-
var css = '/* TREE LAYOUT */ .tree ul { margin:0 0 0 5px; padding:0 0 0 0; list-style-type:none; } .tree li { display:block; min-height:18px; line-height:18px; padding:0 0 0 15px; margin:0 0 0 0; /* Background fix */ clear:both; } .tree li ul { display:none; } .tree li a, .tree li span { display:inline-block;line-height:16px;height:16px;color:black;white-space:nowrap;text-decoration:none;padding:1px 4px 1px 4px;margin:0; } .tree li a:focus { outline: none; } .tree li a input, .tree li span input { margin:0;padding:0 0;display:inline-block;height:12px !important;border:1px solid white;background:white;font-size:10px;font-family:Verdana; } .tree li a input:not([class="xxx"]), .tree li span input:not([class="xxx"]) { padding:1px 0; } /* FOR DOTS */ .tree .ltr li.last { float:left; } .tree > ul li.last { overflow:visible; } /* OPEN OR CLOSE */ .tree li.open ul { display:block; } .tree li.closed ul { display:none !important; } /* FOR DRAGGING */ #jstree-dragged { position:absolute; top:-10px; left:-10px; margin:0; padding:0; } #jstree-dragged ul ul ul { display:none; } #jstree-marker { padding:0; margin:0; line-height:5px; font-size:1px; overflow:hidden; height:5px; position:absolute; left:-45px; top:-30px; z-index:1000; background-color:transparent; background-repeat:no-repeat; display:none; } #jstree-marker.marker { width:45px; background-position:-32px top; } #jstree-marker.marker_plus { width:5px; background-position:right top; } /* BACKGROUND DOTS */ .tree li li { overflow:hidden; } .tree > .ltr > li { display:table; } /* ICONS */ .tree ul ins { display:inline-block; text-decoration:none; width:16px; height:16px; } .tree .ltr ins { margin:0 4px 0 0px; } ';
|
1812 |
-
if($.browser.msie) {
|
1813 |
-
if($.browser.version == 6) css += '.tree li { height:18px; zoom:1; } .tree li li { overflow:visible; } .tree .ltr li.last { margin-top: expression( (this.previousSibling && /open/.test(this.previousSibling.className) ) ? "-2px" : "0"); } .marker { width:45px; background-position:-32px top; } .marker_plus { width:5px; background-position:right top; }';
|
1814 |
-
if($.browser.version == 7) css += '.tree li li { overflow:visible; } .tree .ltr li.last { margin-top: expression( (this.previousSibling && /open/.test(this.previousSibling.className) ) ? "-2px" : "0"); }';
|
1815 |
-
}
|
1816 |
-
if($.browser.opera) css += '.tree > ul > li.last:after { content:"."; display: block; height:1px; clear:both; visibility:hidden; }';
|
1817 |
-
if($.browser.mozilla && $.browser.version.indexOf("1.8") == 0) css += '.tree .ltr li a { display:inline; float:left; } .tree li ul { clear:both; }';
|
1818 |
-
tree_component.css = tree_component.add_sheet({ str : css });
|
1819 |
-
});
|
1820 |
-
})(jQuery);
|
1821 |
-
|
1822 |
-
// Datastores
|
1823 |
-
// HTML and JSON are included here by default
|
1824 |
-
(function ($) {
|
1825 |
-
$.extend($.tree.datastores, {
|
1826 |
-
"html" : function () {
|
1827 |
-
return {
|
1828 |
-
get : function(obj, tree, opts) {
|
1829 |
-
return obj && $(obj).size() ? $('<div>').append(tree.get_node(obj).clone()).html() : tree.container.children("ul:eq(0)").html();
|
1830 |
-
},
|
1831 |
-
parse : function(data, tree, opts, callback) {
|
1832 |
-
if(callback) callback.call(null, data);
|
1833 |
-
return data;
|
1834 |
-
},
|
1835 |
-
load : function(data, tree, opts, callback) {
|
1836 |
-
if(opts.url) {
|
1837 |
-
$.ajax({
|
1838 |
-
'type' : opts.method,
|
1839 |
-
'url' : opts.url,
|
1840 |
-
'data' : data,
|
1841 |
-
'dataType' : "html",
|
1842 |
-
'success' : function (d, textStatus) {
|
1843 |
-
callback.call(null, d);
|
1844 |
-
},
|
1845 |
-
'error' : function (xhttp, textStatus, errorThrown) {
|
1846 |
-
callback.call(null, false);
|
1847 |
-
tree.error(errorThrown + " " + textStatus);
|
1848 |
-
}
|
1849 |
-
});
|
1850 |
-
}
|
1851 |
-
else {
|
1852 |
-
callback.call(null, opts.static || tree.container.children("ul:eq(0)").html());
|
1853 |
-
}
|
1854 |
-
}
|
1855 |
-
};
|
1856 |
-
},
|
1857 |
-
"json" : function () {
|
1858 |
-
return {
|
1859 |
-
get : function(obj, tree, opts) {
|
1860 |
-
var _this = this;
|
1861 |
-
if(!obj || $(obj).size() == 0) obj = tree.container.children("ul").children("li");
|
1862 |
-
else obj = $(obj);
|
1863 |
-
|
1864 |
-
if(!opts) opts = {};
|
1865 |
-
if(!opts.outer_attrib) opts.outer_attrib = [ "id", "rel", "class" ];
|
1866 |
-
if(!opts.inner_attrib) opts.inner_attrib = [ ];
|
1867 |
-
|
1868 |
-
if(obj.size() > 1) {
|
1869 |
-
var arr = [];
|
1870 |
-
obj.each(function () {
|
1871 |
-
arr.push(_this.get(this, tree, opts));
|
1872 |
-
});
|
1873 |
-
return arr;
|
1874 |
-
}
|
1875 |
-
if(obj.size() == 0) return [];
|
1876 |
-
|
1877 |
-
var json = { attributes : {}, data : {} };
|
1878 |
-
if(obj.hasClass("open")) json.data.state = "open";
|
1879 |
-
if(obj.hasClass("closed")) json.data.state = "closed";
|
1880 |
-
|
1881 |
-
for(var i in opts.outer_attrib) {
|
1882 |
-
if(!opts.outer_attrib.hasOwnProperty(i)) continue;
|
1883 |
-
var val = (opts.outer_attrib[i] == "class") ? obj.attr(opts.outer_attrib[i]).replace(/(^| )last( |$)/ig," ").replace(/(^| )(leaf|closed|open)( |$)/ig," ") : obj.attr(opts.outer_attrib[i]);
|
1884 |
-
if(typeof val != "undefined" && val.toString().replace(" ","").length > 0) json.attributes[opts.outer_attrib[i]] = val;
|
1885 |
-
delete val;
|
1886 |
-
}
|
1887 |
-
|
1888 |
-
if(tree.settings.languages.length) {
|
1889 |
-
for(var i in tree.settings.languages) {
|
1890 |
-
if(!tree.settings.languages.hasOwnProperty(i)) continue;
|
1891 |
-
var a = obj.children("a." + tree.settings.languages[i]);
|
1892 |
-
if(opts.force || opts.inner_attrib.length || a.children("ins").get(0).style.backgroundImage.toString().length || a.children("ins").get(0).className.length) {
|
1893 |
-
json.data[tree.settings.languages[i]] = {};
|
1894 |
-
json.data[tree.settings.languages[i]].title = tree.get_text(obj,tree.settings.languages[i]);
|
1895 |
-
if(a.children("ins").get(0).style.className.length) {
|
1896 |
-
json.data[tree.settings.languages[i]].icon = a.children("ins").get(0).style.className;
|
1897 |
-
}
|
1898 |
-
if(a.children("ins").get(0).style.backgroundImage.length) {
|
1899 |
-
json.data[tree.settings.languages[i]].icon = a.children("ins").get(0).style.backgroundImage.replace("url(","").replace(")","");
|
1900 |
-
}
|
1901 |
-
if(opts.inner_attrib.length) {
|
1902 |
-
json.data[tree.settings.languages[i]].attributes = {};
|
1903 |
-
for(var j in opts.inner_attrib) {
|
1904 |
-
if(!opts.inner_attrib.hasOwnProperty(j)) continue;
|
1905 |
-
var val = a.attr(opts.inner_attrib[j]);
|
1906 |
-
if(typeof val != "undefined" && val.toString().replace(" ","").length > 0) json.data[tree.settings.languages[i]].attributes[opts.inner_attrib[j]] = val;
|
1907 |
-
delete val;
|
1908 |
-
}
|
1909 |
-
}
|
1910 |
-
}
|
1911 |
-
else {
|
1912 |
-
json.data[tree.settings.languages[i]] = tree.get_text(obj,tree.settings.languages[i]);
|
1913 |
-
}
|
1914 |
-
}
|
1915 |
-
}
|
1916 |
-
else {
|
1917 |
-
var a = obj.children("a");
|
1918 |
-
json.data.title = tree.get_text(obj);
|
1919 |
-
|
1920 |
-
if(a.children("ins").size() && a.children("ins").get(0).className.length) {
|
1921 |
-
json.data.icon = a.children("ins").get(0).className;
|
1922 |
-
}
|
1923 |
-
if(a.children("ins").size() && a.children("ins").get(0).style.backgroundImage.length) {
|
1924 |
-
json.data.icon = a.children("ins").get(0).style.backgroundImage.replace("url(","").replace(")","");
|
1925 |
-
}
|
1926 |
-
|
1927 |
-
if(opts.inner_attrib.length) {
|
1928 |
-
json.data.attributes = {};
|
1929 |
-
for(var j in opts.inner_attrib) {
|
1930 |
-
if(!opts.inner_attrib.hasOwnProperty(j)) continue;
|
1931 |
-
var val = a.attr(opts.inner_attrib[j]);
|
1932 |
-
if(typeof val != "undefined" && val.toString().replace(" ","").length > 0) json.data.attributes[opts.inner_attrib[j]] = val;
|
1933 |
-
delete val;
|
1934 |
-
}
|
1935 |
-
}
|
1936 |
-
}
|
1937 |
-
|
1938 |
-
if(obj.children("ul").size() > 0) {
|
1939 |
-
json.children = [];
|
1940 |
-
obj.children("ul").children("li").each(function () {
|
1941 |
-
json.children.push(_this.get(this, tree, opts));
|
1942 |
-
});
|
1943 |
-
}
|
1944 |
-
return json;
|
1945 |
-
},
|
1946 |
-
parse : function(data, tree, opts, callback) {
|
1947 |
-
if(Object.prototype.toString.apply(data) === "[object Array]") {
|
1948 |
-
var str = '';
|
1949 |
-
for(var i = 0; i < data.length; i ++) {
|
1950 |
-
if(typeof data[i] == "function") continue;
|
1951 |
-
str += this.parse(data[i], tree, opts);
|
1952 |
-
}
|
1953 |
-
if(callback) callback.call(null, str);
|
1954 |
-
return str;
|
1955 |
-
}
|
1956 |
-
|
1957 |
-
if(!data || !data.data) {
|
1958 |
-
if(callback) callback.call(null, false);
|
1959 |
-
return "";
|
1960 |
-
}
|
1961 |
-
|
1962 |
-
var str = '';
|
1963 |
-
str += "<li ";
|
1964 |
-
var cls = false;
|
1965 |
-
if(data.attributes) {
|
1966 |
-
for(var i in data.attributes) {
|
1967 |
-
if(!data.attributes.hasOwnProperty(i)) continue;
|
1968 |
-
if(i == "class") {
|
1969 |
-
str += " class='" + data.attributes[i] + " ";
|
1970 |
-
if(data.state == "closed" || data.state == "open") str += " " + data.state + " ";
|
1971 |
-
str += "' ";
|
1972 |
-
cls = true;
|
1973 |
-
}
|
1974 |
-
else str += " " + i + "='" + data.attributes[i] + "' ";
|
1975 |
-
}
|
1976 |
-
}
|
1977 |
-
if(!cls && (data.state == "closed" || data.state == "open")) str += " class='" + data.state + "' ";
|
1978 |
-
str += ">";
|
1979 |
-
|
1980 |
-
if(tree.settings.languages.length) {
|
1981 |
-
for(var i = 0; i < tree.settings.languages.length; i++) {
|
1982 |
-
var attr = {};
|
1983 |
-
attr["href"] = "";
|
1984 |
-
attr["style"] = "";
|
1985 |
-
attr["class"] = tree.settings.languages[i];
|
1986 |
-
if(data.data[tree.settings.languages[i]] && (typeof data.data[tree.settings.languages[i]].attributes).toLowerCase() != "undefined") {
|
1987 |
-
for(var j in data.data[tree.settings.languages[i]].attributes) {
|
1988 |
-
if(!data.data[tree.settings.languages[i]].attributes.hasOwnProperty(j)) continue;
|
1989 |
-
if(j == "style" || j == "class") attr[j] += " " + data.data[tree.settings.languages[i]].attributes[j];
|
1990 |
-
else attr[j] = data.data[tree.settings.languages[i]].attributes[j];
|
1991 |
-
}
|
1992 |
-
}
|
1993 |
-
str += "<a";
|
1994 |
-
for(var j in attr) {
|
1995 |
-
if(!attr.hasOwnProperty(j)) continue;
|
1996 |
-
str += ' ' + j + '="' + attr[j] + '" ';
|
1997 |
-
}
|
1998 |
-
str += ">";
|
1999 |
-
if(data.data[tree.settings.languages[i]] && data.data[tree.settings.languages[i]].icon) {
|
2000 |
-
str += "<ins " + (data.data[tree.settings.languages[i]].icon.indexOf("/") == -1 ? " class='" + data.data[tree.settings.languages[i]].icon + "' " : " style='background-image:url(\"" + data.data[tree.settings.languages[i]].icon + "\");' " ) + "> </ins>";
|
2001 |
-
}
|
2002 |
-
else str += "<ins> </ins>";
|
2003 |
-
str += ( (typeof data.data[tree.settings.languages[i]].title).toLowerCase() != "undefined" ? data.data[tree.settings.languages[i]].title : data.data[tree.settings.languages[i]] ) + "</a>";
|
2004 |
-
}
|
2005 |
-
}
|
2006 |
-
else {
|
2007 |
-
var attr = {};
|
2008 |
-
attr["href"] = "";
|
2009 |
-
attr["style"] = "";
|
2010 |
-
attr["class"] = "";
|
2011 |
-
if((typeof data.data.attributes).toLowerCase() != "undefined") {
|
2012 |
-
for(var i in data.data.attributes) {
|
2013 |
-
if(!data.data.attributes.hasOwnProperty(i)) continue;
|
2014 |
-
if(i == "style" || i == "class") attr[i] += " " + data.data.attributes[i];
|
2015 |
-
else attr[i] = data.data.attributes[i];
|
2016 |
-
}
|
2017 |
-
}
|
2018 |
-
str += "<a";
|
2019 |
-
for(var i in attr) {
|
2020 |
-
if(!attr.hasOwnProperty(i)) continue;
|
2021 |
-
str += ' ' + i + '="' + attr[i] + '" ';
|
2022 |
-
}
|
2023 |
-
str += ">";
|
2024 |
-
if(data.data.icon) {
|
2025 |
-
str += "<ins " + (data.data.icon.indexOf("/") == -1 ? " class='" + data.data.icon + "' " : " style='background-image:url(\"" + data.data.icon + "\");' " ) + "> </ins>";
|
2026 |
-
}
|
2027 |
-
else str += "<ins> </ins>";
|
2028 |
-
str += ( (typeof data.data.title).toLowerCase() != "undefined" ? data.data.title : data.data ) + "</a>";
|
2029 |
-
}
|
2030 |
-
if(data.children && data.children.length) {
|
2031 |
-
str += '<ul>';
|
2032 |
-
for(var i = 0; i < data.children.length; i++) {
|
2033 |
-
str += this.parse(data.children[i], tree, opts);
|
2034 |
-
}
|
2035 |
-
str += '</ul>';
|
2036 |
-
}
|
2037 |
-
str += "</li>";
|
2038 |
-
if(callback) callback.call(null, str);
|
2039 |
-
return str;
|
2040 |
-
},
|
2041 |
-
load : function(data, tree, opts, callback) {
|
2042 |
-
if(opts.static) {
|
2043 |
-
callback.call(null, opts.static);
|
2044 |
-
}
|
2045 |
-
else {
|
2046 |
-
$.ajax({
|
2047 |
-
'type' : opts.method,
|
2048 |
-
'url' : opts.url,
|
2049 |
-
'data' : data,
|
2050 |
-
'dataType' : "json",
|
2051 |
-
'success' : function (d, textStatus) {
|
2052 |
-
callback.call(null, d);
|
2053 |
-
},
|
2054 |
-
'error' : function (xhttp, textStatus, errorThrown) {
|
2055 |
-
callback.call(null, false);
|
2056 |
-
tree.error(errorThrown + " " + textStatus);
|
2057 |
-
}
|
2058 |
-
});
|
2059 |
-
}
|
2060 |
-
}
|
2061 |
-
}
|
2062 |
-
}
|
2063 |
-
});
|
2064 |
-
})(jQuery);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
scripts/plugins/_jquery.tree.rtl.js
DELETED
@@ -1,32 +0,0 @@
|
|
1 |
-
(function ($) {
|
2 |
-
$.extend($.tree.plugins, {
|
3 |
-
"rtl" : {
|
4 |
-
defaults : {
|
5 |
-
attribute : "data"
|
6 |
-
},
|
7 |
-
callbacks : {
|
8 |
-
onload : function() {
|
9 |
-
this.container.css("direction","rtl").children("ul:eq(0)").removeClass("ltr").addClass("rtl");
|
10 |
-
},
|
11 |
-
oninit : function() {
|
12 |
-
if(!$.tree.plugins.rtl.css) {
|
13 |
-
var css = '.tree .rtl li.last { float:right; } #jstree-dragged .rtl { margin:0; padding:0; } #jstree-marker.marker_rtl { width:40px; background-position:right center; } /* RTL modification */ .tree .rtl, .tree .rtl ul { margin:0 10px 0 0; } .tree .rtl li { padding:0 10px 0 0; } .tree .rtl li a, .tree .rtl li span { padding:1px 4px 1px 4px; } .tree > .rtl > li { display:table; } .tree .rtl ins { margin:0 0px 0 4px; }';
|
14 |
-
if(/msie/.test(u) && !/opera/.test(u)) {
|
15 |
-
if(parseInt(v) == 6) css += '#jstree-dragged .rtl { width:20px; } .tree .rtl li.last { margin-top: expression( (this.previousSibling && /open/.test(this.previousSibling.className) ) ? "-2px" : "0"); } .marker_rtl { width:40px; background-position:right center; } ';
|
16 |
-
if(parseInt(v) == 7) css += '.tree .rtl li.last { float:none; } #jstree-dragged .rtl { width:200px; }';
|
17 |
-
}
|
18 |
-
if(/mozilla/.test(u) && !/(compatible|webkit)/.test(u) && v.indexOf("1.8") == 0) css += '.tree .rtl li a { display:inline; float:right; }';
|
19 |
-
$.tree.plugins.rtl.css = this.add_sheet({ str : css });
|
20 |
-
}
|
21 |
-
}
|
22 |
-
}
|
23 |
-
}
|
24 |
-
});
|
25 |
-
})(jQuery);
|
26 |
-
|
27 |
-
// in mousemove:
|
28 |
-
// tmp.drag_help.css({ "left" : (event.pageX - (tmp.origin_tree.settings.ui.rtl ? tmp.w : -5 ) ), "top" : (event.pageY + 15) });
|
29 |
-
// if(cnt.children("ul:eq(0)").hasClass("rtl")) goTo.x += et.width() - 28;
|
30 |
-
// if(cnt.children("ul:eq(0)").hasClass("rtl")) { tree_component.drag_drop.marker.attr("class","marker_rtl"); }
|
31 |
-
// if(cnt.children("ul:eq(0)").hasClass("rtl")) goTo.x += 36;
|
32 |
-
// tree_component.drag_drop.marker.css({ "left" : et_off.left + ( cnt.children("ul:eq(0)").hasClass("rtl") ? (cnt.width() - 10) : 10 ) , "top" : et_off.top + 15 }).show();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
scripts/plugins/jquery.tree.cookie.js
DELETED
@@ -1,70 +0,0 @@
|
|
1 |
-
(function ($) {
|
2 |
-
if(typeof $.cookie == "undefined") throw "jsTree cookie: jQuery cookie plugin not included.";
|
3 |
-
|
4 |
-
$.extend($.tree.plugins, {
|
5 |
-
"cookie" : {
|
6 |
-
defaults : {
|
7 |
-
prefix : "", // a prefix that will be used for all cookies for this tree
|
8 |
-
options : {
|
9 |
-
expires: false,
|
10 |
-
path: false,
|
11 |
-
domain: false,
|
12 |
-
secure: false
|
13 |
-
},
|
14 |
-
types : {
|
15 |
-
selected : true, // should we set the selected cookie
|
16 |
-
open : true // should we set the open cookie
|
17 |
-
},
|
18 |
-
keep_selected : false, // should we merge with the selected option or overwrite it
|
19 |
-
keep_opened : false // should we merge with the opened option or overwrite it
|
20 |
-
},
|
21 |
-
set_cookie : function (type) {
|
22 |
-
var opts = $.extend(true, {}, $.tree.plugins.cookie.defaults, this.settings.plugins.cookie);
|
23 |
-
if(opts.types[type] !== true) return false;
|
24 |
-
switch(type) {
|
25 |
-
case "selected":
|
26 |
-
if(this.settings.rules.multiple != false && this.selected_arr.length > 1) {
|
27 |
-
var val = Array();
|
28 |
-
$.each(this.selected_arr, function () {
|
29 |
-
if(this.attr("id")) { val.push(this.attr("id")); }
|
30 |
-
});
|
31 |
-
val = val.join(",");
|
32 |
-
}
|
33 |
-
else var val = this.selected ? this.selected.attr("id") : false;
|
34 |
-
$.cookie(opts.prefix + 'selected', val, opts.options);
|
35 |
-
break;
|
36 |
-
case "open":
|
37 |
-
var str = "";
|
38 |
-
this.container.find("li.open").each(function (i) { if(this.id) { str += this.id + ","; } });
|
39 |
-
$.cookie(opts.prefix + 'open', str.replace(/,$/ig,""), opts.options);
|
40 |
-
break;
|
41 |
-
}
|
42 |
-
},
|
43 |
-
callbacks : {
|
44 |
-
oninit : function (t) {
|
45 |
-
var opts = $.extend(true, {}, $.tree.plugins.cookie.defaults, this.settings.plugins.cookie);
|
46 |
-
var tmp = false;
|
47 |
-
tmp = $.cookie(opts.prefix + 'open');
|
48 |
-
if(tmp) {
|
49 |
-
tmp = tmp.split(",");
|
50 |
-
if(opts.keep_opened) this.settings.opened = $.unique($.merge(tmp, this.settings.opened));
|
51 |
-
else this.settings.opened = tmp;
|
52 |
-
}
|
53 |
-
tmp = $.cookie(opts.prefix + 'selected');
|
54 |
-
if(tmp) {
|
55 |
-
tmp = tmp.split(",");
|
56 |
-
if(opts.keep_selected) this.settings.selected = $.unique($.merge(tmp, this.settings.opened));
|
57 |
-
else this.settings.selected = tmp;
|
58 |
-
}
|
59 |
-
},
|
60 |
-
onchange : function() { $.tree.plugins.cookie.set_cookie.apply(this, ["selected"]); },
|
61 |
-
onopen : function() { $.tree.plugins.cookie.set_cookie.apply(this, ["open"]); },
|
62 |
-
onclose : function() { $.tree.plugins.cookie.set_cookie.apply(this, ["open"]); },
|
63 |
-
ondelete : function() { $.tree.plugins.cookie.set_cookie.apply(this, ["open"]); },
|
64 |
-
oncopy : function() { $.tree.plugins.cookie.set_cookie.apply(this, ["open"]); },
|
65 |
-
oncreate : function() { $.tree.plugins.cookie.set_cookie.apply(this, ["open"]); },
|
66 |
-
onmoved : function() { $.tree.plugins.cookie.set_cookie.apply(this, ["open"]); }
|
67 |
-
}
|
68 |
-
}
|
69 |
-
});
|
70 |
-
})(jQuery);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
scripts/themes/default/style.css
DELETED
@@ -1,30 +0,0 @@
|
|
1 |
-
/* LOCKED */
|
2 |
-
.tree-default .locked li a { color:gray; }
|
3 |
-
/* DOTS */
|
4 |
-
.tree-default ul { background-position:6px 1px; background-repeat:repeat-y; background-image:url(data:image/gif;base64,R0lGODlhAgACAIAAAB4dGf///yH5BAEAAAEALAAAAAACAAIAAAICRF4AOw==); _background-image:url("dot_for_ie.gif"); *background-image:url("dot_for_ie.gif"); }
|
5 |
-
.tree-default li { background-position:-64px -16px; background-repeat:no-repeat; background-image:url("icons.png"); }
|
6 |
-
/* NO DOTS */
|
7 |
-
.tree-default .no_dots, .tree-default .no_dots ul { background:transparent; }
|
8 |
-
.tree-default .no_dots li.leaf { background-image:none; background-color:transparent; }
|
9 |
-
/* OPEN or CLOSED */
|
10 |
-
.tree-default li.open { background:url("icons.png") -32px -48px no-repeat; }
|
11 |
-
.tree-default li.closed, #jstree-dragged.tree-default li li.open { background:url("icons.png") -48px -32px no-repeat; }
|
12 |
-
#jstree-marker { background-image:url("icons.png"); }
|
13 |
-
/* DEFAULT, HOVER, CLICKED, LOADING STATES */
|
14 |
-
.tree-default li a, .tree-default li span { border-radius:3px; -moz-border-radius:3px; -webkit-border-radius:3px; }
|
15 |
-
.tree-default li a:hover, .tree-default li a.hover, .tree-default li span { background: #e7f4f9; border:1px solid #d8f0fa; padding:0px 3px 0px 3px; }
|
16 |
-
.tree-default li a.clicked, .tree-default li a.clicked:hover, .tree-default li span.clicked { background: #beebff; border:1px solid #99defd; padding:0px 3px 0px 3px; }
|
17 |
-
/* ICONS */
|
18 |
-
.tree-default ins { background-image:url("icons.png"); background-position:0 0; background-repeat:no-repeat; }
|
19 |
-
.tree-default ul li a.loading ins { background-image:url("throbber.gif") !important; background-position:0 0 !important; } /* UL is added to make selector stronger */
|
20 |
-
.tree-default li a ins.forbidden { background-position:-16px -16px; }
|
21 |
-
.tree-default .locked li a ins { background-position:0 -48px; }
|
22 |
-
.tree-default li span ins { background-position:-16px 0; }
|
23 |
-
#jstree-dragged.tree-default ins { background:url("icons.png") -16px -32px no-repeat; }
|
24 |
-
#jstree-dragged.tree-default ins.forbidden { background:url("icons.png") -16px -16px no-repeat; }
|
25 |
-
|
26 |
-
/* CONTEXT MENU */
|
27 |
-
.tree-default-context a ins { background-image:url("icons.png"); background-repeat:no-repeat; background-position:-64px -64px; }
|
28 |
-
.tree-default-context a ins.create { background-position:0 -16px; }
|
29 |
-
.tree-default-context a ins.rename { background-position:-16px 0px; }
|
30 |
-
.tree-default-context a ins.remove { background-position:0 -32px; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
scripts/themes/default/throbber.gif
DELETED
Binary file
|
scripts/themes/wordpress/d.png
ADDED
Binary file
|
scripts/themes/{default → wordpress}/dot_for_ie.gif
RENAMED
File without changes
|
scripts/themes/{default/icons.png → wordpress/iconsxx.png}
RENAMED
File without changes
|
scripts/themes/wordpress/style.css
ADDED
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*
|
2 |
+
* jsTree default theme 1.0
|
3 |
+
* Supported features: dots/no-dots, icons/no-icons, focused, loading
|
4 |
+
* Supported plugins: ui (hovered, clicked), checkbox, contextmenu, search
|
5 |
+
*/
|
6 |
+
|
7 |
+
.jstree-wordpress li,
|
8 |
+
.jstree-wordpress ins { background-image:url("d.png"); background-repeat:no-repeat; background-color:transparent; }
|
9 |
+
.jstree-wordpress li { background-position:-90px 0; background-repeat:repeat-y; }
|
10 |
+
.jstree-wordpress li.jstree-last { background:transparent; }
|
11 |
+
.jstree-wordpress .jstree-open > ins { background-position:-72px 0; }
|
12 |
+
.jstree-wordpress .jstree-closed > ins { background-position:-54px 0; }
|
13 |
+
.jstree-wordpress .jstree-leaf > ins { background-position:-36px 0; }
|
14 |
+
|
15 |
+
.jstree-wordpress .jstree-hovered { background:#e7f4f9; border:1px solid #d8f0fa; padding:0 2px 0 1px; }
|
16 |
+
.jstree-wordpress .jstree-clicked { background:#beebff; border:1px solid #99defd; padding:0 2px 0 1px; }
|
17 |
+
.jstree-wordpress a .jstree-icon { background-position:-56px -19px; }
|
18 |
+
.jstree-wordpress a.jstree-loading .jstree-icon { background:url("throbber.gif") center center no-repeat !important; }
|
19 |
+
|
20 |
+
.jstree-wordpress.jstree-focused { /* background:#ffffee; */ }
|
21 |
+
|
22 |
+
.jstree-wordpress .jstree-no-dots li,
|
23 |
+
.jstree-wordpress .jstree-no-dots .jstree-leaf > ins { background:transparent; }
|
24 |
+
.jstree-wordpress .jstree-no-dots .jstree-open > ins { background-position:-18px 0; }
|
25 |
+
.jstree-wordpress .jstree-no-dots .jstree-closed > ins { background-position:0 0; }
|
26 |
+
|
27 |
+
.jstree-wordpress .jstree-no-icons a .jstree-icon { display:none; }
|
28 |
+
|
29 |
+
.jstree-wordpress .jstree-search { /* font-style:italic; */ }
|
30 |
+
|
31 |
+
.jstree-wordpress .jstree-no-icons .checkbox { display:inline-block; }
|
32 |
+
.jstree-wordpress .jstree-no-checkboxes .checkbox { display:none !important; }
|
33 |
+
.jstree-wordpress .jstree-checked > a > .checkbox { background-position:-38px -19px; }
|
34 |
+
.jstree-wordpress .jstree-unchecked > a > .checkbox { background-position:-2px -19px; }
|
35 |
+
.jstree-wordpress .jstree-undetermined > a > .checkbox { background-position:-20px -19px; }
|
36 |
+
.jstree-wordpress .jstree-checked > a > .checkbox:hover { background-position:-38px -37px; }
|
37 |
+
.jstree-wordpress .jstree-unchecked > a > .checkbox:hover { background-position:-2px -37px; }
|
38 |
+
.jstree-wordpress .jstree-undetermined > a > .checkbox:hover { background-position:-20px -37px; }
|
39 |
+
|
40 |
+
#vakata-dragged.jstree-wordpress ins { background:transparent !important; }
|
41 |
+
#vakata-dragged.jstree-wordpress .jstree-ok { background:url("d.png") -2px -53px no-repeat !important; }
|
42 |
+
#vakata-dragged.jstree-wordpress .jstree-invalid { background:url("d.png") -18px -53px no-repeat !important; }
|
43 |
+
#jstree-marker.jstree-wordpress { background:url("d.png") -41px -57px no-repeat !important; }
|
44 |
+
|
45 |
+
.jstree-wordpress a.jstree-search { font-weight: bold; background-color: #FFEFBA; }
|
46 |
+
|
47 |
+
#vakata-contextmenu.jstree-wordpress-context,
|
48 |
+
#vakata-contextmenu.jstree-wordpress-context li ul { background:#f0f0f0; border:1px solid #979797; -moz-box-shadow: 1px 1px 2px #999; -webkit-box-shadow: 1px 1px 2px #999; box-shadow: 1px 1px 2px #999; }
|
49 |
+
#vakata-contextmenu.jstree-wordpress-context li { }
|
50 |
+
#vakata-contextmenu.jstree-wordpress-context a { color:black; }
|
51 |
+
#vakata-contextmenu.jstree-wordpress-context a:hover,
|
52 |
+
#vakata-contextmenu.jstree-wordpress-context .vakata-hover > a { padding:0 5px; background:#e8eff7; border:1px solid #aecff7; color:black; -moz-border-radius:2px; -webkit-border-radius:2px; border-radius:2px; }
|
53 |
+
#vakata-contextmenu.jstree-wordpress-context li.vakata-separator { background:white; border-top:1px solid #e0e0e0; margin:0; }
|
54 |
+
#vakata-contextmenu.jstree-wordpress-context li ul { margin-left:-4px; }
|
55 |
+
|
56 |
+
/* added by pär */
|
57 |
+
.jstree-wordpress li {
|
58 |
+
padding-top: 2px;
|
59 |
+
padding-bottom: 2px;
|
60 |
+
position: relative;
|
61 |
+
}
|
62 |
+
.jstree li.jstree-closed,
|
63 |
+
.jstree li.jstree-open
|
64 |
+
{
|
65 |
+
padding-top: 4px;
|
66 |
+
padding-bottom: 4px;
|
67 |
+
}
|
68 |
+
.jstree a:hover {
|
69 |
+
background-color: #e7f4f9;
|
70 |
+
}
|
71 |
+
|
72 |
+
/* TODO: IE6 support - the `>` selectors */
|
scripts/themes/wordpress/throbber.gif
ADDED
Binary file
|
styles/styles.css
CHANGED
@@ -32,16 +32,10 @@
|
|
32 |
clear: both;
|
33 |
}
|
34 |
|
35 |
-
.
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
.tree li span.cms_tpv_action_edit,
|
42 |
-
.tree li span.cms_tpv_action_view,
|
43 |
-
.tree li span.cms_tpv_action_add_page_after,
|
44 |
-
.tree li span.cms_tpv_action_add_page_inside
|
45 |
{
|
46 |
display: none;
|
47 |
text-decoration: underline;
|
@@ -52,14 +46,13 @@
|
|
52 |
padding: 0 0 0 .5ex;
|
53 |
|
54 |
}
|
55 |
-
|
56 |
display: none;
|
57 |
border: 0;
|
58 |
padding: 0 0 0 .5em;
|
59 |
color: #666;
|
60 |
}
|
61 |
|
62 |
-
.tree li a.search,
|
63 |
.cms-tree-view-search
|
64 |
{
|
65 |
background-color: #ffefba;
|
@@ -85,7 +78,7 @@
|
|
85 |
color: #d54e21 !important;
|
86 |
}
|
87 |
|
88 |
-
.
|
89 |
cursor: move;
|
90 |
}
|
91 |
|
@@ -102,16 +95,14 @@
|
|
102 |
color: #999;
|
103 |
border: none;
|
104 |
font-size: .8em;
|
105 |
-
|
106 |
-
|
107 |
-
.tree li:nth-child(odd) {
|
108 |
}
|
109 |
|
110 |
.tree-default span.post_type {
|
111 |
background-color: #f85b11;
|
112 |
-
-moz-border-radius:
|
113 |
-
-webkit-border-radius:
|
114 |
-
border-radius:
|
115 |
padding: 1px 4px 1px 4px;
|
116 |
color: white;
|
117 |
border: none;
|
@@ -140,8 +131,7 @@
|
|
140 |
opacity: .9;
|
141 |
}
|
142 |
|
143 |
-
#cms_tpv_open_all
|
144 |
-
{
|
145 |
margin-left: 1em;
|
146 |
}
|
147 |
|
@@ -181,4 +171,22 @@
|
|
181 |
position: absolute;
|
182 |
line-height: 1;
|
183 |
display: none;
|
184 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
clear: both;
|
33 |
}
|
34 |
|
35 |
+
span.cms_tpv_action_edit,
|
36 |
+
li span.cms_tpv_action_view,
|
37 |
+
li span.cms_tpv_action_add_page_after,
|
38 |
+
li span.cms_tpv_action_add_page_inside
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
{
|
40 |
display: none;
|
41 |
text-decoration: underline;
|
46 |
padding: 0 0 0 .5ex;
|
47 |
|
48 |
}
|
49 |
+
li span.cms_tpv_action_add_page {
|
50 |
display: none;
|
51 |
border: 0;
|
52 |
padding: 0 0 0 .5em;
|
53 |
color: #666;
|
54 |
}
|
55 |
|
|
|
56 |
.cms-tree-view-search
|
57 |
{
|
58 |
background-color: #ffefba;
|
78 |
color: #d54e21 !important;
|
79 |
}
|
80 |
|
81 |
+
.jstree a ins {
|
82 |
cursor: move;
|
83 |
}
|
84 |
|
95 |
color: #999;
|
96 |
border: none;
|
97 |
font-size: .8em;
|
98 |
+
margin-left: .5em;
|
|
|
|
|
99 |
}
|
100 |
|
101 |
.tree-default span.post_type {
|
102 |
background-color: #f85b11;
|
103 |
+
-moz-border-radius: 3px;
|
104 |
+
-webkit-border-radius: 3px;
|
105 |
+
border-radius: 3px;
|
106 |
padding: 1px 4px 1px 4px;
|
107 |
color: white;
|
108 |
border: none;
|
131 |
opacity: .9;
|
132 |
}
|
133 |
|
134 |
+
#cms_tpv_open_all {
|
|
|
135 |
margin-left: 1em;
|
136 |
}
|
137 |
|
171 |
position: absolute;
|
172 |
line-height: 1;
|
173 |
display: none;
|
174 |
+
}
|
175 |
+
|
176 |
+
#cms_tree_view_search_form_reset {
|
177 |
+
display: none;
|
178 |
+
position: absolute;
|
179 |
+
top: 2px;
|
180 |
+
left: 112px;
|
181 |
+
width: 16px;
|
182 |
+
height: 16px;
|
183 |
+
background: transparent url(http://jquery-ui.googlecode.com/svn/trunk/themes/base/images/ui-icons_888888_256x240.png) no-repeat -32px -194px;
|
184 |
+
text-indent: -9999px;
|
185 |
+
}
|
186 |
+
#cms_tpv_dashboard_widget #cms_tree_view_search_form_reset {
|
187 |
+
top: 8px;
|
188 |
+
}
|
189 |
+
#cms_tree_view_search_form_reset:hover {
|
190 |
+
background: transparent url(http://jquery-ui.googlecode.com/svn/trunk/themes/base/images/ui-icons_454545_256x240.png) no-repeat -32px -194px;
|
191 |
+
}
|
192 |
+
|