Mercurial > hg > soundsoftware-site
diff public/javascripts/application.js @ 1298:4f746d8966dd redmine_2.3_integration
Merge from redmine-2.3 branch to create new branch redmine-2.3-integration
author | Chris Cannam |
---|---|
date | Fri, 14 Jun 2013 09:28:30 +0100 |
parents | bb32da3bea34 622f24f53b42 |
children |
line wrap: on
line diff
--- a/public/javascripts/application.js Fri Jun 14 09:07:32 2013 +0100 +++ b/public/javascripts/application.js Fri Jun 14 09:28:30 2013 +0100 @@ -1,5 +1,5 @@ /* Redmine - project management software - Copyright (C) 2006-2012 Jean-Philippe Lang */ + Copyright (C) 2006-2013 Jean-Philippe Lang */ function checkAll(id, checked) { if (checked) { @@ -14,12 +14,12 @@ $(selector).each(function(index) { if (!$(this).is(':checked')) { all_checked = false; } }); - $(selector).attr('checked', !all_checked) + $(selector).attr('checked', !all_checked); } function showAndScrollTo(id, focus) { $('#'+id).show(); - if (focus!=null) { + if (focus !== null) { $('#'+focus).focus(); } $('html, body').animate({scrollTop: $('#'+id).offset().top}, 100); @@ -131,10 +131,10 @@ select = tr.find('td.operator select'); for (i=0;i<operators.length;i++){ var option = $('<option>').val(operators[i]).text(operatorLabels[operators[i]]); - if (operators[i] == operator) {option.attr('selected', true)}; + if (operators[i] == operator) { option.attr('selected', true); } select.append(option); } - select.change(function(){toggleOperator(field)}); + select.change(function(){ toggleOperator(field); }); switch (filterOptions['type']){ case "list": @@ -146,7 +146,7 @@ ' <span class="toggle-multiselect"> </span></span>' ); select = tr.find('td.values select'); - if (values.length > 1) {select.attr('multiple', true)}; + if (values.length > 1) { select.attr('multiple', true); } for (i=0;i<filterValues.length;i++){ var filterValue = filterValues[i]; var option = $('<option>'); @@ -189,7 +189,7 @@ var filterValue = allProjects[i]; var option = $('<option>'); option.val(filterValue[1]).text(filterValue[0]); - if (values[0] == filterValue[1]) {option.attr('selected', true)}; + if (values[0] == filterValue[1]) { option.attr('selected', true); } select.append(option); } case "integer": @@ -242,7 +242,13 @@ case "!*": case "*": case "t": + case "ld": case "w": + case "lw": + case "l2w": + case "m": + case "lm": + case "y": case "o": case "c": enableValues(field, []); @@ -284,40 +290,6 @@ $('#'+id).submit(); } -var fileFieldCount = 1; -function addFileField() { - var fields = $('#attachments_fields'); - if (fields.children().length >= 10) return false; - fileFieldCount++; - var s = fields.children('span').first().clone(); - s.children('input.file').attr('name', "attachments[" + fileFieldCount + "][file]").val(''); - s.children('input.description').attr('name', "attachments[" + fileFieldCount + "][description]").val(''); - fields.append(s); -} - -function removeFileField(el) { - var fields = $('#attachments_fields'); - var s = $(el).parents('span').first(); - if (fields.children().length > 1) { - s.remove(); - } else { - s.children('input.file').val(''); - s.children('input.description').val(''); - } -} - -function checkFileSize(el, maxSize, message) { - var files = el.files; - if (files) { - for (var i=0; i<files.length; i++) { - if (files[i].size > maxSize) { - alert(message); - el.value = ""; - } - } - } -} - function showTab(name) { $('div#content .tab-content').hide(); $('div.tabs a').removeClass('selected'); @@ -380,7 +352,7 @@ function showModal(id, width) { var el = $('#'+id).first(); - if (el.length == 0 || el.is(':visible')) {return;} + if (el.length === 0 || el.is(':visible')) {return;} var title = el.find('h3.title').text(); el.dialog({ width: width, @@ -484,18 +456,22 @@ }); } -function observeAutocompleteField(fieldId, url) { +function observeAutocompleteField(fieldId, url, options) { $(document).ready(function() { - $('#'+fieldId).autocomplete({ + $('#'+fieldId).autocomplete($.extend({ source: url, - minLength: 2 - }); + minLength: 2, + search: function(){$('#'+fieldId).addClass('ajax-loading');}, + response: function(){$('#'+fieldId).removeClass('ajax-loading');} + }, options)); + $('#'+fieldId).addClass('autocomplete'); }); } function observeSearchfield(fieldId, targetId, url) { $('#'+fieldId).each(function() { var $this = $(this); + $this.addClass('autocomplete'); $this.attr('data-value-was', $this.val()); var check = function() { var val = $this.val(); @@ -505,7 +481,7 @@ url: url, type: 'get', data: {q: $this.val()}, - success: function(data){ $('#'+targetId).html(data); }, + success: function(data){ if(targetId) $('#'+targetId).html(data); }, beforeSend: function(){ $this.addClass('ajax-loading'); }, complete: function(){ $this.removeClass('ajax-loading'); } }); @@ -570,18 +546,21 @@ }); if (warn) {return warnLeavingUnsavedMessage;} }; -}; +} -$(document).ready(function(){ - $('#ajax-indicator').bind('ajaxSend', function(){ - if ($('.ajax-loading').length == 0) { +function setupAjaxIndicator() { + + $('#ajax-indicator').bind('ajaxSend', function(event, xhr, settings) { + + if ($('.ajax-loading').length === 0 && settings.contentType != 'application/octet-stream') { $('#ajax-indicator').show(); } }); - $('#ajax-indicator').bind('ajaxStop', function(){ + + $('#ajax-indicator').bind('ajaxStop', function() { $('#ajax-indicator').hide(); }); -}); +} function hideOnLoad() { $('.hol').hide(); @@ -601,6 +580,12 @@ }); } +function blockEventPropagation(event) { + event.stopPropagation(); + event.preventDefault(); +} + +$(document).ready(setupAjaxIndicator); $(document).ready(hideOnLoad); $(document).ready(addFormObserversForDoubleSubmit);