xref: /plugin/bez/scripts/tasks.js (revision de02284c1e90f3c0d8df29c1c019b3ef912eafd9)
1bez.ctl.tasks = function() {
2  	//bez_show_desc
3	jQuery(".bez_desc_row").hide();
4	jQuery("#bez_show_desc").on('click', function(e) {
5		if (jQuery(this).find(".show").is(":visible")) {
6			jQuery(".bez_desc_row").show();
7			jQuery(this).find(".hide").show();
8			jQuery(this).find(".show").hide();
9		} else {
10			jQuery(".bez_desc_row").hide();
11			jQuery(this).find(".hide").hide();
12			jQuery(this).find(".show").show();
13		}
14		e.preventDefault();
15	});
16
17	jQuery(".bez_show_single_desc").on('click', function(e) {
18		var $row = jQuery(this).parents('tr'),
19			row_id = $row.data('bez-row-id'),
20			$desc_rows = $row.parents('table').find('.task'+row_id);
21
22		if ($desc_rows.is(":visible")) {
23			$desc_rows.hide();
24		} else {
25			$desc_rows.show();
26		}
27		e.preventDefault();
28	});
29
30	//highlight filters
31	var highlight = function() {
32		var $this = jQuery(this);
33		if ($this.find('option:selected').index() !== 0) {
34			$this.css('outline', '2px solid #FB5A5A');
35		} else {
36			$this.css('outline', 'none');
37		}
38	};
39	var highlight_input = function() {
40		var $this = jQuery(this);
41		if ($this.val().length > 0) {
42			$this.css('outline', '2px solid #FB5A5A');
43		} else {
44			$this.css('outline', 'none');
45		}
46	};
47	jQuery(".bez_filter_form select").change(highlight).each(highlight);
48	jQuery(".bez_filter_form input:text").blur(highlight_input).each(highlight_input);
49};