Move some javascript from the layout to application.js

This commit is contained in:
Tom Hughes 2012-08-28 19:47:20 +01:00
parent 96a4fb0805
commit d9054cfe29
2 changed files with 17 additions and 9 deletions

View file

@ -254,3 +254,20 @@ $(document).ready(function () {
$(".richtext_doedit").click(editRichtext); $(".richtext_doedit").click(editRichtext);
$(".richtext_dopreview").click(previewRichtext); $(".richtext_dopreview").click(previewRichtext);
}); });
/*
* Forms which have been cached by rails may have he wrong
* authenticity token, so patch up any forms with the correct
* token taken from the page header.
*/
$(document).ready(function () {
var auth_token = $("meta[name=csrf-token]").attr("content");
$("form input[name=authenticity_token]").val(auth_token);
});
/*
* Enable auto expansion for all text areas
*/
$(document).ready(function () {
$("textarea").autoGrow();
});

View file

@ -143,15 +143,6 @@
</div> </div>
</div> </div>
<script type="text/javascript">
$(document).ready(function () {
var auth_token = $("meta[name=csrf-token]").attr("content");
$("form input[name=authenticity_token]").val(auth_token);
$("textarea").autoGrow();
});
</script>
<% if defined?(PIWIK_LOCATION) and defined?(PIWIK_SITE) -%> <% if defined?(PIWIK_LOCATION) and defined?(PIWIK_SITE) -%>
<%= render :partial => "layouts/piwik" %> <%= render :partial => "layouts/piwik" %>
<% end -%> <% end -%>