/* redMine - project management software Copyright (C) 2006-2008 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(); } var fileFieldCount = 1; function addFileField() { if (fileFieldCount >= 10) return false fileFieldCount++; var f = document.createElement("input"); f.type = "file"; f.name = "attachments[" + fileFieldCount + "][file]"; f.size = 30; var d = document.createElement("input"); d.type = "text"; d.name = "attachments[" + fileFieldCount + "][description]"; d.size = 60; var dLabel = new Element('label'); dLabel.addClassName('inline'); // Pulls the languge value used for Optional Description dLabel.update($('attachment_description_label_content').innerHTML) p = document.getElementById("attachments_fields"); p.appendChild(document.createElement("br")); p.appendChild(f); p.appendChild(dLabel); dLabel.appendChild(d); } 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) { Element.show('ajax-indicator'); } }, onComplete: function(){ if ($('ajax-indicator') && Ajax.activeRequestCount == 0) { Element.hide('ajax-indicator'); } } }); function hideOnLoad() { $$('.hol').each(function(el) { el.hide(); }); } Event.observe(window, 'load', hideOnLoad); /* jQuery code from #263 */ /* TODO: integrate with existing code and/or refactor */ jQuery(document).ready(function($) { // a few constants for animations speeds, etc. var animRate = 100; // header menu hovers $("#account .drop-down").hover(function() { $(this).addClass("open").find("ul").slideDown(animRate); $("#top-menu").toggleClass("open"); }, function() { $(this).removeClass("open").find("ul").slideUp(animRate); $("#top-menu").toggleClass("open"); }); // show/hide header search box // TODO: switch to live after upgrading jQuery version. "flicker" bug. $("#account a.search").click(function() { var searchWidth = $("#account-nav").width(); $(this).toggleClass("open"); $("#nav-search").width(searchWidth).slideToggle(animRate, function(){ $("#nav-search-box").select(); }); return false; }); // file table thumbnails $("table a.has-thumb").hover(function() { $(this).removeAttr("title").toggleClass("active"); // grab the image dimensions to position it properly var thumbImg = $(this).find("img"); var thumbImgLeft = -(thumbImg.outerWidth() ); var thumbImgTop = -(thumbImg.height() / 2 ); thumbImg.css({top: thumbImgTop, left: thumbImgLeft}).show(); }, function() { $(this).toggleClass("active").find("img").hide(); }); // show/hide the files table $(".attachments h4").click(function() { $(this).toggleClass("closed").next().slideToggle(animRate); }); // custom function for sliding the main-menu. IE6 & IE7 don't handle sliding very well $.fn.mySlide = function() { if (parseInt($.browser.version, 10) < 8 && $.browser.msie) { // no animations, just toggle this.toggle(); // this forces IE to redraw the menu area, un-bollocksing things $("#main-menu").css({paddingBottom:5}).animate({paddingBottom:0}, 10); } else { this.slideToggle(animRate); } return this; }; // open and close the main-menu sub-menus $("#main-menu li:has(ul) > a").not("ul ul a") .append("") .click(function() { $(this).toggleClass("open").parent().find("ul").not("ul ul ul").mySlide(); return false; }); // submenu flyouts $("#main-menu li li:has(ul)").hover(function() { $(this).find(".profile-box").show(); $(this).find("ul").slideDown(animRate); }, function() { $(this).find("ul").slideUp(animRate); }); // add filter dropdown menu $(".button-large:has(ul) > a").click(function(event) { var tgt = $(event.target); // is this inside the title bar? if (tgt.parents().is(".title-bar")) { $(".title-bar-extras:hidden").slideDown(animRate); } $(this).parent().find("ul").slideToggle(animRate); return false; }); }); /* Appended 2009-07-07 */ var animRate = 100; // returns viewport height jQuery.viewportHeight = function() { return self.innerHeight || jQuery.boxModel && document.documentElement.clientHeight || document.body.clientHeight; }; jQuery(document).ready(function($) { // header animation replacement - no animation, straight appear/hide $("#account .drop-down").unbind('mouseenter').unbind("mouseleave"); //remove the current animated handlers // remove .drop-down class from empty dropdowns $("#account .drop-down").each(function(index) { if ($(this).find("li").size() < 1) { $(this).removeClass("drop-down"); } }); $("#account .drop-down").hover(function() { $(this).addClass("open").find("ul").show(); $("#top-menu").addClass("open"); // wraps long dropdown menu in an overflow:auto div to keep long project lists on the page var $projectDrop = $("#account .drop-down:has(.projects) ul"); // only do the wrapping if it's the project dropdown, and more than 15 items if ( $projectDrop.children().size() > 15 && $(this).find("> a").hasClass("projects") ) { var overflowHeight = 15 * $projectDrop.find("li:eq(1)").outerHeight() - 2; $projectDrop .wrapInner("
").end() .find(".overflow").css({overflow: 'auto', height: overflowHeight, position: 'relative'}) .find("li a").css('paddingRight', '25px'); // do hack-y stuff for IE6 & 7. don't ask why, I don't know. if (parseInt($.browser.version, 10) < 8 && $.browser.msie) { $projectDrop.find(".overflow").css({width: 325, zoom: '1'}); $projectDrop.find("li a").css('marginLeft', '-15px'); $("#top-menu").css('z-index', '10000'); } } }, function() { $(this).removeClass("open").find("ul").hide(); $("#top-menu").removeClass("open"); }); // deal with potentially problematic super-long titles $(".title-bar h2").css({paddingRight: $(".title-bar-actions").outerWidth() + 15 }); // move email checkbox inside div.box $("#issue-form > p").clone().appendTo("#issue-form .box"); $("#issue-form > p").remove(); // move preview area inside div.box if ($("form#issue-list").size() > 0 ) { // only do this on the issue list page $("#issue-form-wrap #preview").remove(); $("#issue-form .box").append("
"); } // rejigger the main-menu sub-menu functionality. $("#main-menu .toggler").remove(); // remove the togglers so they're inserted properly later. $("#main-menu li:has(ul) > a").not("ul ul a") // 1. unbind the current click functions .unbind("click") // 2. wrap each in a span that we'll use for the new click element .wrapInner("") // 3. reinsert the so that it sits outside of the above .append("") // 4. attach a new click function that will follow the link if you clicked on the span itself and toggle if not .click(function(event) { if (!$(event.target).hasClass("toggle-follow") ) { $(this).toggleClass("open").parent().find("ul").not("ul ul ul").mySlide(); return false; } }); });