diff options
| author | Ivan Kohler <ivan@freeside.biz> | 2015-07-26 15:41:26 -0700 |
|---|---|---|
| committer | Ivan Kohler <ivan@freeside.biz> | 2015-07-26 15:41:26 -0700 |
| commit | 9aee669886202be7035e6c6049fc71bc99dd3013 (patch) | |
| tree | 2fd5bf6de74f3d99270587ffb1833e4188a6373d /rt/share/static/js/late.js | |
| parent | ac20214d38d9af00430423f147b5a0e50751b050 (diff) | |
| parent | 1add633372bdca3cc7163c2ce48363fed3984437 (diff) | |
Merge branch 'master' of git.freeside.biz:/home/git/freeside
Diffstat (limited to 'rt/share/static/js/late.js')
| -rw-r--r-- | rt/share/static/js/late.js | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/rt/share/static/js/late.js b/rt/share/static/js/late.js new file mode 100644 index 000000000..92a827906 --- /dev/null +++ b/rt/share/static/js/late.js @@ -0,0 +1,39 @@ +// Lower the speed limit for hover intent event +jQuery.event.special.hover.speed = 80; // pixels per second + +jQuery(function() { sync_grouped_custom_fields() } ); +function sync_grouped_custom_fields() { + var all_inputs = jQuery("input,textarea,select"); + var parse_cf = /^Object-([\w:]+)-(\d*)-CustomField(?::\w+)?-(\d+)-(.*)$/; + all_inputs.each(function() { + var elem = jQuery(this); + var parsed = parse_cf.exec(elem.attr("name")); + if (parsed == null) + return; + if (/-Magic$/.test(parsed[4])) + return; + var name_filter_regex = new RegExp( + "^Object-"+parsed[1]+"-"+parsed[2]+ + "-CustomField(?::\\w+)?-"+parsed[3]+"-"+parsed[4]+"$" + ); + var update_elems = all_inputs.filter(function () { + return name_filter_regex.test(jQuery(this).attr("name")); + }).not(elem); + if (update_elems.length == 0) + return; + var trigger_func = function() { + var curval = elem.val(); + if ((elem.attr("type") == "checkbox") || (elem.attr("type") == "radio")) { + curval = [ ]; + jQuery('[name="'+elem.attr("name")+'"]:checked').each( function() { + curval.push( jQuery(this).val() ); + }); + } + update_elems.val(curval); + }; + if ((elem.attr("type") == "text") || (elem.attr("tagName") == "TEXTAREA")) + elem.keyup( trigger_func ); + else + elem.change( trigger_func ); + }); +} |
