Mercurial > hg > soundsoftware-site
diff public/javascripts/.svn/text-base/application.js.svn-base @ 441:cbce1fd3b1b7 redmine-1.2
Update to Redmine 1.2-stable branch (Redmine SVN rev 6000)
author | Chris Cannam |
---|---|
date | Mon, 06 Jun 2011 14:24:13 +0100 |
parents | 051f544170fe |
children | 0c939c159af4 |
line wrap: on
line diff
--- a/public/javascripts/.svn/text-base/application.js.svn-base Thu Mar 03 11:42:28 2011 +0000 +++ b/public/javascripts/.svn/text-base/application.js.svn-base Mon Jun 06 14:24:13 2011 +0100 @@ -40,6 +40,37 @@ } } +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'); @@ -299,9 +330,27 @@ } }); -/* shows and hides ajax indicator */ +/* + * 1 - registers a callback which copies the csrf token into the + * X-CSRF-Token header with each ajax request. Necessary to + * work with rails applications which have fixed + * CVE-2011-0447 + * 2 - shows and hides ajax indicator + */ Ajax.Responders.register({ - onCreate: function(){ + onCreate: function(request){ + var csrf_meta_tag = $$('meta[name=csrf-token]')[0]; + + if (csrf_meta_tag) { + var header = 'X-CSRF-Token', + token = csrf_meta_tag.readAttribute('content'); + + if (!request.options.requestHeaders) { + request.options.requestHeaders = {}; + } + request.options.requestHeaders[header] = token; + } + if ($('ajax-indicator') && Ajax.activeRequestCount > 0) { Element.show('ajax-indicator'); }