aboutsummaryrefslogtreecommitdiffstats
path: root/mcc/9/common/jquery/treeview/jquery.treeview.async.js
diff options
context:
space:
mode:
authorPapoteur <papoteur@mageia.org>2023-08-25 09:41:13 +0200
committerPapoteur <papoteur@mageia.org>2023-08-25 09:42:18 +0200
commit2b69ca284b4e25836263faace4727f5e480fc70a (patch)
tree716fa0ba3eee8270c25860470e62162ed8dbfb1c /mcc/9/common/jquery/treeview/jquery.treeview.async.js
parent5cb5c79cf5e1c11ef73e1ca2ef5e61097d5c686c (diff)
downloaddoc-2b69ca284b4e25836263faace4727f5e480fc70a.tar
doc-2b69ca284b4e25836263faace4727f5e480fc70a.tar.gz
doc-2b69ca284b4e25836263faace4727f5e480fc70a.tar.bz2
doc-2b69ca284b4e25836263faace4727f5e480fc70a.tar.xz
doc-2b69ca284b4e25836263faace4727f5e480fc70a.zip
Add common files
Diffstat (limited to 'mcc/9/common/jquery/treeview/jquery.treeview.async.js')
-rw-r--r--mcc/9/common/jquery/treeview/jquery.treeview.async.js72
1 files changed, 72 insertions, 0 deletions
diff --git a/mcc/9/common/jquery/treeview/jquery.treeview.async.js b/mcc/9/common/jquery/treeview/jquery.treeview.async.js
new file mode 100644
index 00000000..2597dde1
--- /dev/null
+++ b/mcc/9/common/jquery/treeview/jquery.treeview.async.js
@@ -0,0 +1,72 @@
+/*
+ * Async Treeview 0.1 - Lazy-loading extension for Treeview
+ *
+ * http://bassistance.de/jquery-plugins/jquery-plugin-treeview/
+ *
+ * Copyright (c) 2007 Jörn Zaefferer
+ *
+ * Dual licensed under the MIT and GPL licenses:
+ * http://www.opensource.org/licenses/mit-license.php
+ * http://www.gnu.org/licenses/gpl.html
+ *
+ * Revision: $Id$
+ *
+ */
+
+;(function($) {
+
+function load(settings, root, child, container) {
+ $.getJSON(settings.url, {root: root}, function(response) {
+ function createNode(parent) {
+ var current = $("<li/>").attr("id", this.id || "").html("<span>" + this.text + "</span>").appendTo(parent);
+ if (this.classes) {
+ current.children("span").addClass(this.classes);
+ }
+ if (this.expanded) {
+ current.addClass("open");
+ }
+ if (this.hasChildren || this.children && this.children.length) {
+ var branch = $("<ul/>").appendTo(current);
+ if (this.hasChildren) {
+ current.addClass("hasChildren");
+ createNode.call({
+ text:"placeholder",
+ id:"placeholder",
+ children:[]
+ }, branch);
+ }
+ if (this.children && this.children.length) {
+ $.each(this.children, createNode, [branch])
+ }
+ }
+ }
+ $.each(response, createNode, [child]);
+ $(container).treeview({add: child});
+ });
+}
+
+var proxied = $.fn.treeview;
+$.fn.treeview = function(settings) {
+ if (!settings.url) {
+ return proxied.apply(this, arguments);
+ }
+ var container = this;
+ load(settings, "source", this, container);
+ var userToggle = settings.toggle;
+ return proxied.call(this, $.extend({}, settings, {
+ collapsed: true,
+ toggle: function() {
+ var $this = $(this);
+ if ($this.hasClass("hasChildren")) {
+ var childList = $this.removeClass("hasChildren").find("ul");
+ childList.empty();
+ load(settings, this.id, childList, container);
+ }
+ if (userToggle) {
+ userToggle.apply(this, arguments);
+ }
+ }
+ }));
+};
+
+})(jQuery); \ No newline at end of file