From 3473b0878c24c591a4aa2b4f5a077dab5a1783dd Mon Sep 17 00:00:00 2001 From: AntonioTerceiro Date: Wed, 16 Jan 2008 17:28:17 +0000 Subject: [PATCH] ActionItem152: moving javascript code to application.js --- app/views/layouts/application.rhtml | 5 +---- public/javascripts/application.js | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/app/views/layouts/application.rhtml b/app/views/layouts/application.rhtml index 52534bc..08ded08 100644 --- a/app/views/layouts/application.rhtml +++ b/app/views/layouts/application.rhtml @@ -24,10 +24,7 @@ <% end %> - - + <% unless flash[:notice].nil? %>
diff --git a/public/javascripts/application.js b/public/javascripts/application.js index fe45776..688b866 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -1,2 +1,34 @@ // Place your application-specific JavaScript functions and classes here // This file is automatically included by javascript_include_tag :defaults + +function noosfero_init() { + focus_first_field(); + detect_internet_explorer(); +} + +/* Adds a class to "msie" to the body element if a Microsoft browser is + * detected. This is needed to workaround several of their limitations. + */ +function detect_internet_explorer() { + if ( navigator.appName.indexOf("Microsoft") > -1 ) { + document.body.className += " msie"; + } +} + +/* If applicable, find the first field in which the user can type and move the + * keyboard focus to it. + */ +function focus_first_field() { + form = document.forms[0]; + if (form == undefined) { + return; + } + + for (var i = 0; i < form.elements.length; i++) { + field = form.elements[i]; + if (field.type == 'text' || field.type == 'textarea') { + field.focus(); + return; + } + } +} -- libgit2 0.21.2