/ Published in: jQuery

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
Drupal.behaviors.template = function(){ /** * Set namespace */ var sitename = { /** * Initialise functions within the sitename namespace */ init : function() { sitename.searchReplace(); sitename.function2(); sitename.function3.fInit(); sitename.function4(); }, /** * Puts title text in the field on the search box */ searchReplace : function() { var searchBox = $("#edit-search-theme-form-1"); var searchBoxDefault = "Enter keywords"; searchBox.attr("value", searchBoxDefault); searchBox.focus(function(){ if(jQuery.trim($(this).attr("value")) == searchBoxDefault) $(this).attr("value", ""); }); searchBox.blur(function(){ if(jQuery.trim($(this).attr("value")) == "") $(this).attr("value", searchBoxDefault); }) }, /** * function 2 */ function2 : function() { //code here }, /** * function 3 */ function3 : { fInit : function() { //initialise function 3 sitename.function3.helperfunction1(); sitename.function3.helperfunction2(); }, helperfunction1 : function() { //code here }, helperfunction2 : function() { //code here } }, /** * function 4 */ function4 : function() { //code here } } //end of sitename /** * Initialise sitename */ sitename.init(); }
Comments
