/* Redmine - project management software Copyright (C) 2006-2012 Jean-Philippe Lang */ function checkAll (id, checked) { var els = Element.descendants(id); for (var i = 0; i < els.length; i++) { if (els[i].disabled==false) { els[i].checked = checked; } } } function toggleCheckboxesBySelector(selector) { boxes = $$(selector); var all_checked = true; for (i = 0; i < boxes.length; i++) { if (boxes[i].checked == false) { all_checked = false; } } for (i = 0; i < boxes.length; i++) { boxes[i].checked = !all_checked; } } function setCheckboxesBySelector(checked, selector) { var boxes = $$(selector); boxes.each(function(ele) { ele.checked = checked; }); } function showAndScrollTo(id, focus) { Element.show(id); if (focus!=null) { Form.Element.focus(focus); } Element.scrollTo(id); } function toggleRowGroup(el) { var tr = Element.up(el, 'tr'); var n = Element.next(tr); tr.toggleClassName('open'); while (n != undefined && !n.hasClassName('group')) { Element.toggle(n); n = Element.next(n); } } function collapseAllRowGroups(el) { var tbody = Element.up(el, 'tbody'); tbody.childElements('tr').each(function(tr) { if (tr.hasClassName('group')) { tr.removeClassName('open'); } else { tr.hide(); } }) } function expandAllRowGroups(el) { var tbody = Element.up(el, 'tbody'); tbody.childElements('tr').each(function(tr) { if (tr.hasClassName('group')) { tr.addClassName('open'); } else { tr.show(); } }) } function toggleAllRowGroups(el) { var tr = Element.up(el, 'tr'); if (tr.hasClassName('open')) { collapseAllRowGroups(el); } else { expandAllRowGroups(el); } } function toggleFieldset(el) { var fieldset = Element.up(el, 'fieldset'); fieldset.toggleClassName('collapsed'); Effect.toggle(fieldset.down('div'), 'slide', {duration:0.2}); } function hideFieldset(el) { var fieldset = Element.up(el, 'fieldset'); fieldset.toggleClassName('collapsed'); fieldset.down('div').hide(); } function add_filter() { select = $('add_filter_select'); field = select.value Element.show('tr_' + field); check_box = $('cb_' + field); check_box.checked = true; toggle_filter(field); select.selectedIndex = 0; for (i=0; i 0) { Element.show("div_values_" + field); } else { Element.hide("div_values_" + field); } } function toggle_operator(field) { operator = $("operators_" + field); switch (operator.value) { case "!*": case "*": case "t": case "w": case "o": case "c": enableValues(field, []); break; case "><": enableValues(field, [0,1]); break; case "t+": case "t+": case ">t-": case "= 10) return false; fileFieldCount++; var s = new Element('span'); s.update(fields.down('span').innerHTML); s.down('input.file').name = "attachments[" + fileFieldCount + "][file]"; s.down('input.description').name = "attachments[" + fileFieldCount + "][description]"; fields.appendChild(s); } function removeFileField(el) { var fields = $('attachments_fields'); var s = Element.up(el, 'span'); if (fields.childElements().length > 1) { s.remove(); } else { s.update(s.innerHTML); } } function checkFileSize(el, maxSize, message) { var files = el.files; if (files) { for (var i=0; i maxSize) { alert(message); el.value = ""; } } } } function showTab(name) { var f = $$('div#content .tab-content'); for(var i=0; i0) { lis[i-1].show(); } } function displayTabsButtons() { var lis; var tabsWidth = 0; var i; $$('div.tabs').each(function(el) { lis = el.down('ul').childElements(); for (i=0; i 0 && $$('input.ajax-loading').size() == 0) { Element.show('ajax-indicator'); } }, onComplete: function(){ if ($('ajax-indicator') && Ajax.activeRequestCount == 0) { Element.hide('ajax-indicator'); } } }); function hideOnLoad() { $$('.hol').each(function(el) { el.hide(); }); } function addFormObserversForDoubleSubmit() { $$('form[method=post]').each(function(el) { Event.observe(el, 'submit', function(e) { var form = Event.element(e); form.select('input[type=submit]').each(function(btn) { btn.disable(); }); }); }); } Event.observe(window, 'load', hideOnLoad); Event.observe(window, 'load', addFormObserversForDoubleSubmit);