web/data/jquery-treeview/jquery.treeview.edit.js
author Julien Cristau <julien.cristau@logilab.fr>
Thu, 23 Oct 2014 11:42:20 +0200
changeset 10100 6718c03f8938
permissions -rw-r--r--
[web] Update jquery-treeview to the latest version Files copied from commit 61f230828ace1b54c2cc54bc549ece261b11842e of https://github.com/jzaefferer/jquery-treeview
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10100
6718c03f8938 [web] Update jquery-treeview to the latest version
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
     1
(function($) {
6718c03f8938 [web] Update jquery-treeview to the latest version
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
     2
	var CLASSES = $.treeview.classes;
6718c03f8938 [web] Update jquery-treeview to the latest version
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
     3
	var proxied = $.fn.treeview;
6718c03f8938 [web] Update jquery-treeview to the latest version
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
     4
	$.fn.treeview = function(settings) {
6718c03f8938 [web] Update jquery-treeview to the latest version
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
     5
		settings = $.extend({}, settings);
6718c03f8938 [web] Update jquery-treeview to the latest version
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
     6
		if (settings.add) {
6718c03f8938 [web] Update jquery-treeview to the latest version
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
     7
			return this.trigger("add", [settings.add]);
6718c03f8938 [web] Update jquery-treeview to the latest version
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
     8
		}
6718c03f8938 [web] Update jquery-treeview to the latest version
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
     9
		if (settings.remove) {
6718c03f8938 [web] Update jquery-treeview to the latest version
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    10
			return this.trigger("remove", [settings.remove]);
6718c03f8938 [web] Update jquery-treeview to the latest version
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    11
		}
6718c03f8938 [web] Update jquery-treeview to the latest version
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    12
		return proxied.apply(this, arguments).bind("add", function(event, branches) {
6718c03f8938 [web] Update jquery-treeview to the latest version
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    13
			$(branches).prev()
6718c03f8938 [web] Update jquery-treeview to the latest version
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    14
				.removeClass(CLASSES.last)
6718c03f8938 [web] Update jquery-treeview to the latest version
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    15
				.removeClass(CLASSES.lastCollapsable)
6718c03f8938 [web] Update jquery-treeview to the latest version
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    16
				.removeClass(CLASSES.lastExpandable)
6718c03f8938 [web] Update jquery-treeview to the latest version
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    17
			.find(">.hitarea")
6718c03f8938 [web] Update jquery-treeview to the latest version
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    18
				.removeClass(CLASSES.lastCollapsableHitarea)
6718c03f8938 [web] Update jquery-treeview to the latest version
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    19
				.removeClass(CLASSES.lastExpandableHitarea);
6718c03f8938 [web] Update jquery-treeview to the latest version
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    20
			$(branches).find("li").andSelf().prepareBranches(settings).applyClasses(settings, $(this).data("toggler"));
6718c03f8938 [web] Update jquery-treeview to the latest version
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    21
		}).bind("remove", function(event, branches) {
6718c03f8938 [web] Update jquery-treeview to the latest version
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    22
			var prev = $(branches).prev();
6718c03f8938 [web] Update jquery-treeview to the latest version
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    23
			var parent = $(branches).parent();
6718c03f8938 [web] Update jquery-treeview to the latest version
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    24
			$(branches).remove();
6718c03f8938 [web] Update jquery-treeview to the latest version
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    25
			prev.filter(":last-child").addClass(CLASSES.last)
6718c03f8938 [web] Update jquery-treeview to the latest version
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    26
				.filter("." + CLASSES.expandable).replaceClass(CLASSES.last, CLASSES.lastExpandable).end()
6718c03f8938 [web] Update jquery-treeview to the latest version
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    27
				.find(">.hitarea").replaceClass(CLASSES.expandableHitarea, CLASSES.lastExpandableHitarea).end()
6718c03f8938 [web] Update jquery-treeview to the latest version
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    28
				.filter("." + CLASSES.collapsable).replaceClass(CLASSES.last, CLASSES.lastCollapsable).end()
6718c03f8938 [web] Update jquery-treeview to the latest version
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    29
				.find(">.hitarea").replaceClass(CLASSES.collapsableHitarea, CLASSES.lastCollapsableHitarea);
6718c03f8938 [web] Update jquery-treeview to the latest version
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    30
			if (parent.is(":not(:has(>))") && parent[0] != this) {
6718c03f8938 [web] Update jquery-treeview to the latest version
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    31
				parent.parent().removeClass(CLASSES.collapsable).removeClass(CLASSES.expandable)
6718c03f8938 [web] Update jquery-treeview to the latest version
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    32
				parent.siblings(".hitarea").andSelf().remove();
6718c03f8938 [web] Update jquery-treeview to the latest version
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    33
			}
6718c03f8938 [web] Update jquery-treeview to the latest version
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    34
		});
6718c03f8938 [web] Update jquery-treeview to the latest version
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    35
	};
6718c03f8938 [web] Update jquery-treeview to the latest version
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    36
6718c03f8938 [web] Update jquery-treeview to the latest version
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    37
})(jQuery);