﻿/********************************************************************
* jQuery Dependent plug-in      									*
*																	* 
* @version		2.5													*
* @copyright	(c) Bau Alexandru 2009 								*
* @author 		Bau Alexandru										*
* @email		bau.alexandru@gmail.com								*
*																	*
* @depends		jQuery									            *
* 																	*
* 																	*
* Do not delete or modify this header!								*
********************************************************************/
(function(c) { c.fn.dependent = function(d) { $param = c.extend({}, c.fn.dependent.defaults, d); this.each(function() { $this = c(this); var l = "#" + $param.parent; var j = $this; var k = c(j).attr("id"); var f = "." + k; if ($param.group != "") { var h = "." + $param.group } var e = 0; var i = "dpslctholder"; var g = "." + i; a(i, g, j, k, f); if (c(l).val() != 0) { $title = c(l).find("option:selected").attr("title"); c(j).find("option:not('option.'+$title)").remove(); c(j).prepend('<option value="">-- Any --</option>') } else { c(j).find("option").remove(); c(j).append('<option value="">-- Any --</option>') } b(l, j, h, g, f) }); return this }; function a(h, e, g, i, d) { var f = c(e + " " + i).size(); if (f == 0) { c("body").append('\n\n<select class="' + h + " " + i + '" style="display:none">\n</select>\n') } c(g).find("option[value!=]").each(function() { $value = c(this).attr("value"); $class = c(this).attr("class"); $title = c(this).attr("title"); $text = c(this).text(); c(e + d).append('<option value="' + $value + '" class="' + $class + '" title="' + $title + '">' + $text + "</option>\n") }) } function b(h, g, f, e, d) { c(h).bind("change", function() { c(g).find("option[value!=]").remove(); $index = c(f).index(c(this)); if ($param.group != "") { c(f + ":gt(" + $index + ")").find("option[value!=]").remove() } $title = c(this).find("option:selected").attr("title"); c(e + d).find("option." + $title).each(function() { $value = c(this).attr("value"); $class = c(this).attr("class"); $title = c(this).attr("title"); $text = c(this).attr("text"); if (c(g).find("option[value=" + $value + "]").size() == 0) { c(g).append('<option value="' + $value + '" class="' + $class + '" title="' + $title + '">' + $text + "</option>") } else { c(this).remove() } }) }) } c.fn.dependent.defaults = { parent: "parent_id"} })(jQuery);
