⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jquery.agiletable.1.0.js

📁 一个工作流OA
💻 JS
字号:
//	Version: 1.0
//	Author: Spring.Cheung(spring.cheung@163.com)
//	LastChangedDate: 2008-06-02
//	Requires: jquery.1.2.3.jsjQuery.fn.agileTable = function(options)	{		options = jQuery.extend(			{				container: $(this).attr("id"),				key: "title",				separator: "|",				target: "Ids"			}, options);
		if (options.container != null && options.container != "" && options.target != null && options.target != "")
		{
			//	refresh items
			var target = $("#" + options.target);
			var header = $("th > :checkbox", $("#" + options.container));
			$("td > :checkbox", $("#" + options.container)).each(
				function()
				{
					var key = $(this).attr(options.key);
					var checked = target.val().indexOf(options.separator + key) >= 0;
					$(this).attr("checked", checked);
				});
			var checkeds = $("td > :checked", $("#" + options.container)).length;
			if (checkeds == 0)
			{
				$(header).attr("checked", false);
				$(header).removeAttr("indeterminate");
			}
			else if (checkeds < $("td > :checkbox", $("#" + options.container)).length)
			{
				$(header).attr("checked", false);
				$(header).attr("indeterminate", true);
			}
			else
			{
				$(header).attr("checked", true);
				$(header).removeAttr("indeterminate");
			}
			//	choose header
			$("th > :checkbox", $("#" + options.container)).click(
				function()
				{
					var checked = $(this).attr("checked") != null;
					$("td > :checkbox", $("#" + options.container)).each(
						function()
						{
							var key = $(this).attr(options.key);
							$(this).attr("checked", checked);
							if (checked)
							{
								target.val(target.val() + options.separator + key);
							}
							else
							{
								target.val(target.val().replace(options.separator + key, ""));
							}
						});
				});
			//	choose item
			$("td > :checkbox", $("#" + options.container)).click(
				function()
				{
					//	deal with current item
					var key = $(this).attr(options.key);
					var checked = $(this).attr("checked") != null;
					if (checked)
					{
						target.val(target.val() + options.separator + key);
					}
					else
					{
						target.val(target.val().replace(options.separator + key, ""));
					}
					//	deal with parent item
					checkeds = $("td > :checked", $("#" + options.container)).length;
					if (checkeds == 0)
					{
						$(header).attr("checked", false);
						$(header).removeAttr("indeterminate");
					}
					else if (checkeds < $("td > :checkbox", $("#" + options.container)).length)
					{
						$(header).attr("checked", false);
						$(header).attr("indeterminate", true);
					}
					else
					{
						$(header).attr("checked", true);
						$(header).removeAttr("indeterminate");
					}
				});
		}
	};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -