Return to Snippet

Revision: 23756
at February 12, 2010 09:29 by ReeceMarsland


Initial Code
Drupal.behaviors.themeNameSpace = function(){ 
	
	/**
	  * Set namespace 
	  */
	var namespace = {
		/**
		  * Initialise functions within the  namespace
		  */
		init : function() {
			namespace.function1();
			namespace.function2();
			namespace.function3.fInit();
			namespace.function4();
		},
		
		/**
		  *  function 1 
		  */
		function1 : function() {
			//code here
	 	},
		
		/**
		  *  function 2 
		  */
		function2 : function() {
			//code here
	 	},
		
		/**
		  *  function 3
		  */
		function3 : {
			fInit : function() {
				//initialise function 3
				namespace.function3.helperfunction1();
				namespace.function3.helperfunction2();
			},
			
			helperfunction1 : function() {
				//code here
			},
			
			helperfunction2 : function() {
				//code here
			}
	 	},
		
		/**
		  *  function 4 
		  */
		function4 : function() {
			//code here
	 	}
	} //end of namespace
	
	/**
	  *  Initialise namespace
	  */
	namespace.init();

}

Initial URL

                                

Initial Description

                                

Initial Title
Drupal JS Namespacing Blueprint

Initial Tags
jquery, drupal

Initial Language
jQuery