SlideShare ist ein Scribd-Unternehmen logo
1 von 15
Downloaden Sie, um offline zu lesen
Alonzo Turner



Leveraging JavaScript
Frameworks in your
    Joomla Sites
A Quick History
    Why we need JavaScript
 Frameworks in the first place.

First, there was the Internet, and it was good.

Then there was Netscape, and it had a <blink> tag.

And, then came Internet Explorer.

Then came Firefox and things got a lot better but...

It was complicated.
What Frameworks Provide
      DOM Manipulation

      Class Structures

      Event Listeners

      AJAX

      Binding

      Effects
The Default JavaScript Framework
      Provided by Joomla

jimport('joomla.html.html.behavior');
JHtmlBehavior::framework(boolean);

/media/system/js/mootools-core.js
/media/system/js/mootools-more.js
MooTools Libraries
            DOM Manipulation
  $(selector) //returns extended element
  $$(selector) //returns an array of elements

                   Classes
        var someObject = new Class({
           initialize: function(){
              // some constructor actions
            }
        });

              Event Listeners
$$('a').invoke('addEvent', 'click' function(evt){
   var someAnchor = evt.target;
   window.console.log(someAnchor.href);
});
MooTools Libraries
                    AJAX
var someRequest = new Request({
    method: 'post',
    url: '/index.php',
    onSuccess: function(textResult, xmlResult){},
    onFailure: function(xhr){}
});
someRequest.send({'data': obj});



                  Binding
var myObject = {name: 'Alonzo', title: 'dev'};
var myFunction = function(){
   window.console.log(this.name);
}
var bound = myFunction.bind(myObject);
bound(); // OUTPUTS: Alonzo
MooTools Libraries
                    Effects
          Tween A single Property
var myTween = new Fx.Tween('someElement', {
   duration: 1000.0,
   property: 'left'
});
myTween.start(0,400);



Morph any number of styles in tandem
var myMorph = new Fx.Morph('someElement', {
   duration: 2500.0,
   transition: Fx.Transitions.Sine.easeInOut,
   chain: 'cancel'
});
myMorph.start({'height': 300, 'width': 100});
MooTools Libraries
          Putting It All Together

var myInterface = new Class({
   initialize: function(){
       this.links = this.listenToLinks.bind(this);
        this.buttons = this.listenToButtons.bind(this);
        this.startListening();
    },
   startListening: function(){
       $$('a').invoke('addEvent', this.links);
       $$('button').invoke('addEvent', this.buttons);
    },
   listenToLinks: function(evt){
       // do something with links
    },
   listenToButtons: function(evt){
       // do something with buttons
    }
});
JHtml Behaviors
             Loading the Built-In
              Javascript Libraries
Form Validation                        No-Frames
JHtml::_(‘behavior.formvalidation’);   JHtml::_(‘behavior.noframes’);


Modal Windows                          Calendar
JHtml::_(‘behavior.modal’);            JHtml::_(‘behavior.calendar’);


ToolTips                               Uploader
JHtml::_(‘behavior.tooltip’);          JHtml::_(‘behavior.uploader’);
Inserting Javascript
             Template index.php file
$doc =& JFactory::getDocument();
$doc->addScript('path/to/script');
$doc->addScriptDeclaration('script as text');



// FILTER OUT MOOTOOLS JAVASCRIPT
$header = $this->getHeadData();
$scripts = $header['scripts'];
$allow = array();
foreach($scripts as $script => $type){
   if(strpos($script, "/media/system/js") === FALSE){
      $allow[$script] = $type;
   }
}
// RESET THE PRELOADED JAVASCRIPT LIBRARIES
$header['scripts'] = $allow;
$this->setHeadData($header);
Google Loader API
       Decrease page load times and offset
       network traffic by implementing the
                   loader API

             First, sign up for an API key
     http://code.google.com/apis/loader/signup.html


             Implement the google loader
<script type="text/javascript"
      src="http://www.google.com/jsapi?key=xxxx"></script>
<script type="text/javascript">google.load(script, version)</script>
Google Loader API
      Implement the Google Loader in your
            Template index.php file


// USE GOOGLE LOADER API TO PRELOAD COMMON JAVASCRIPT LIBRARIES
$js = '{"modules":{"name":"mootools","version":"1.4.1"}}';
$key = $this->params->get('google_api');
if($key){
   $source = "www.google.com/jsapi?autoload=".urlencode($js)."&amp;key=";
   $document->addScript(HTTP_PROTOCOL.$source.$key);
}else{
   $document->addScript("templates/yourtemplate/javascript/mootools.js");
   $document->addScript("templates/inkandpaper/javascript/swfobject.js");
}
Additional
             Resources

http://code.google.com/apis/loader
https://groups.google.com/group/joomla-dev-general
http://docs.joomla.org/Developers
http://mootools.net/docs/core
http://jquery.com
http://www.prototypejs.org
Special Thanks

  Lokesh Dhakar - lightbox
 Sam Stephenson - prototype
Thomas Fuchs - scriptaculous
 Valerio Proietti - mootools
     John Resig - jquery


The Joomla and Open Source
       Communities
https://www.subtextproductions.com

alonzo.turner@subtextproductions.com

Weitere ähnliche Inhalte

Was ist angesagt?

Sprout core and performance
Sprout core and performanceSprout core and performance
Sprout core and performance
Yehuda Katz
 
Powerful and flexible templates with Twig
Powerful and flexible templates with Twig Powerful and flexible templates with Twig
Powerful and flexible templates with Twig
Michael Peacock
 
The Open Web and what it means
The Open Web and what it meansThe Open Web and what it means
The Open Web and what it means
Robert Nyman
 

Was ist angesagt? (20)

Javascript - Beyond-jQuery
Javascript - Beyond-jQueryJavascript - Beyond-jQuery
Javascript - Beyond-jQuery
 
AngularJS Architecture
AngularJS ArchitectureAngularJS Architecture
AngularJS Architecture
 
Building Single Page Apps with Backbone.js, Coffeescript and Rails 3.1
Building Single Page Apps with Backbone.js, Coffeescript and Rails 3.1Building Single Page Apps with Backbone.js, Coffeescript and Rails 3.1
Building Single Page Apps with Backbone.js, Coffeescript and Rails 3.1
 
AngularJS Compile Process
AngularJS Compile ProcessAngularJS Compile Process
AngularJS Compile Process
 
Testable, Object-Oriented JavaScript
Testable, Object-Oriented JavaScriptTestable, Object-Oriented JavaScript
Testable, Object-Oriented JavaScript
 
Perkenalan ReasonML
Perkenalan ReasonMLPerkenalan ReasonML
Perkenalan ReasonML
 
Sprout core and performance
Sprout core and performanceSprout core and performance
Sprout core and performance
 
06 jQuery #burningkeyboards
06 jQuery  #burningkeyboards06 jQuery  #burningkeyboards
06 jQuery #burningkeyboards
 
The Beauty of Java Script
The Beauty of Java ScriptThe Beauty of Java Script
The Beauty of Java Script
 
Jquery Fundamentals
Jquery FundamentalsJquery Fundamentals
Jquery Fundamentals
 
jQuery: Events, Animation, Ajax
jQuery: Events, Animation, AjaxjQuery: Events, Animation, Ajax
jQuery: Events, Animation, Ajax
 
Getting classy with ES6
Getting classy with ES6Getting classy with ES6
Getting classy with ES6
 
Powerful and flexible templates with Twig
Powerful and flexible templates with Twig Powerful and flexible templates with Twig
Powerful and flexible templates with Twig
 
Building Large jQuery Applications
Building Large jQuery ApplicationsBuilding Large jQuery Applications
Building Large jQuery Applications
 
05 JavaScript #burningkeyboards
05 JavaScript #burningkeyboards05 JavaScript #burningkeyboards
05 JavaScript #burningkeyboards
 
Introduction to ReasonML
Introduction to ReasonMLIntroduction to ReasonML
Introduction to ReasonML
 
How Kris Writes Symfony Apps
How Kris Writes Symfony AppsHow Kris Writes Symfony Apps
How Kris Writes Symfony Apps
 
The Open Web and what it means
The Open Web and what it meansThe Open Web and what it means
The Open Web and what it means
 
Drupal 8: Fields reborn
Drupal 8: Fields rebornDrupal 8: Fields reborn
Drupal 8: Fields reborn
 
Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...
Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...
Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...
 

Andere mochten auch (6)

FELICIDADES JUANMI
FELICIDADES JUANMIFELICIDADES JUANMI
FELICIDADES JUANMI
 
Joomla e commerce gabe wahhab
Joomla e commerce gabe wahhabJoomla e commerce gabe wahhab
Joomla e commerce gabe wahhab
 
Proud of who we are
Proud of who we areProud of who we are
Proud of who we are
 
Strategic planning
Strategic planningStrategic planning
Strategic planning
 
Template frameworks
Template frameworksTemplate frameworks
Template frameworks
 
Microbiology (major microbial diseases)
Microbiology (major microbial diseases)Microbiology (major microbial diseases)
Microbiology (major microbial diseases)
 

Ähnlich wie Javascript Frameworks for Joomla

Week 4 - jQuery + Ajax
Week 4 - jQuery + AjaxWeek 4 - jQuery + Ajax
Week 4 - jQuery + Ajax
baygross
 
international PHP2011_Bastian Feder_jQuery's Secrets
international PHP2011_Bastian Feder_jQuery's Secretsinternational PHP2011_Bastian Feder_jQuery's Secrets
international PHP2011_Bastian Feder_jQuery's Secrets
smueller_sandsmedia
 
JavaScript Growing Up
JavaScript Growing UpJavaScript Growing Up
JavaScript Growing Up
David Padbury
 
How and why i roll my own node.js framework
How and why i roll my own node.js frameworkHow and why i roll my own node.js framework
How and why i roll my own node.js framework
Ben Lin
 
Avinash Kundaliya: Javascript and WordPress
Avinash Kundaliya: Javascript and WordPressAvinash Kundaliya: Javascript and WordPress
Avinash Kundaliya: Javascript and WordPress
wpnepal
 
J Query The Write Less Do More Javascript Library
J Query   The Write Less Do More Javascript LibraryJ Query   The Write Less Do More Javascript Library
J Query The Write Less Do More Javascript Library
rsnarayanan
 

Ähnlich wie Javascript Frameworks for Joomla (20)

Week 4 - jQuery + Ajax
Week 4 - jQuery + AjaxWeek 4 - jQuery + Ajax
Week 4 - jQuery + Ajax
 
international PHP2011_Bastian Feder_jQuery's Secrets
international PHP2011_Bastian Feder_jQuery's Secretsinternational PHP2011_Bastian Feder_jQuery's Secrets
international PHP2011_Bastian Feder_jQuery's Secrets
 
jQuery secrets
jQuery secretsjQuery secrets
jQuery secrets
 
Rails is not just Ruby
Rails is not just RubyRails is not just Ruby
Rails is not just Ruby
 
Writing Maintainable JavaScript
Writing Maintainable JavaScriptWriting Maintainable JavaScript
Writing Maintainable JavaScript
 
jQuery and Rails: Best Friends Forever
jQuery and Rails: Best Friends ForeverjQuery and Rails: Best Friends Forever
jQuery and Rails: Best Friends Forever
 
Bonnes pratiques de développement avec Node js
Bonnes pratiques de développement avec Node jsBonnes pratiques de développement avec Node js
Bonnes pratiques de développement avec Node js
 
JavaScript Growing Up
JavaScript Growing UpJavaScript Growing Up
JavaScript Growing Up
 
J query training
J query trainingJ query training
J query training
 
jQuery for beginners
jQuery for beginnersjQuery for beginners
jQuery for beginners
 
How and why i roll my own node.js framework
How and why i roll my own node.js frameworkHow and why i roll my own node.js framework
How and why i roll my own node.js framework
 
jQuery
jQueryjQuery
jQuery
 
jQuery for web development
jQuery for web developmentjQuery for web development
jQuery for web development
 
Avinash Kundaliya: Javascript and WordPress
Avinash Kundaliya: Javascript and WordPressAvinash Kundaliya: Javascript and WordPress
Avinash Kundaliya: Javascript and WordPress
 
Clean Javascript
Clean JavascriptClean Javascript
Clean Javascript
 
Workshop 23: ReactJS, React & Redux testing
Workshop 23: ReactJS, React & Redux testingWorkshop 23: ReactJS, React & Redux testing
Workshop 23: ReactJS, React & Redux testing
 
J Query The Write Less Do More Javascript Library
J Query   The Write Less Do More Javascript LibraryJ Query   The Write Less Do More Javascript Library
J Query The Write Less Do More Javascript Library
 
jQuery secrets
jQuery secretsjQuery secrets
jQuery secrets
 
Javascript first-class citizenery
Javascript first-class citizeneryJavascript first-class citizenery
Javascript first-class citizenery
 
Introduction to jQuery
Introduction to jQueryIntroduction to jQuery
Introduction to jQuery
 

Mehr von Luke Summerfield

Improving joomla's backend user experience
Improving joomla's backend user experienceImproving joomla's backend user experience
Improving joomla's backend user experience
Luke Summerfield
 
Joomla e commerce gabe wahhab
Joomla e commerce gabe wahhabJoomla e commerce gabe wahhab
Joomla e commerce gabe wahhab
Luke Summerfield
 
Joomla e commerce gabe wahhab
Joomla e commerce gabe wahhabJoomla e commerce gabe wahhab
Joomla e commerce gabe wahhab
Luke Summerfield
 
Harnessing the cloud_for_saa_s_hosted_platfor
Harnessing the cloud_for_saa_s_hosted_platforHarnessing the cloud_for_saa_s_hosted_platfor
Harnessing the cloud_for_saa_s_hosted_platfor
Luke Summerfield
 

Mehr von Luke Summerfield (10)

Supercharge Your Wordpress Website With Inbound Marketing: A Complete Guide
Supercharge Your Wordpress Website With Inbound Marketing: A Complete GuideSupercharge Your Wordpress Website With Inbound Marketing: A Complete Guide
Supercharge Your Wordpress Website With Inbound Marketing: A Complete Guide
 
Supercharge your Sales with Inbound Marketing: A Complete Guide
Supercharge your Sales with Inbound Marketing: A Complete Guide Supercharge your Sales with Inbound Marketing: A Complete Guide
Supercharge your Sales with Inbound Marketing: A Complete Guide
 
Supercharge Your Local SEO: The Complete Guide
Supercharge Your Local SEO: The Complete GuideSupercharge Your Local SEO: The Complete Guide
Supercharge Your Local SEO: The Complete Guide
 
SEOMoz Mozcation:
SEOMoz Mozcation: SEOMoz Mozcation:
SEOMoz Mozcation:
 
Improving joomla's backend user experience
Improving joomla's backend user experienceImproving joomla's backend user experience
Improving joomla's backend user experience
 
Joomla e commerce gabe wahhab
Joomla e commerce gabe wahhabJoomla e commerce gabe wahhab
Joomla e commerce gabe wahhab
 
Template frameworks
Template frameworksTemplate frameworks
Template frameworks
 
Joomla e commerce gabe wahhab
Joomla e commerce gabe wahhabJoomla e commerce gabe wahhab
Joomla e commerce gabe wahhab
 
Harnessing the cloud_for_saa_s_hosted_platfor
Harnessing the cloud_for_saa_s_hosted_platforHarnessing the cloud_for_saa_s_hosted_platfor
Harnessing the cloud_for_saa_s_hosted_platfor
 
Mobile app development
Mobile app development  Mobile app development
Mobile app development
 

Kürzlich hochgeladen

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Kürzlich hochgeladen (20)

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 

Javascript Frameworks for Joomla

  • 2. A Quick History Why we need JavaScript Frameworks in the first place. First, there was the Internet, and it was good. Then there was Netscape, and it had a <blink> tag. And, then came Internet Explorer. Then came Firefox and things got a lot better but... It was complicated.
  • 3. What Frameworks Provide DOM Manipulation Class Structures Event Listeners AJAX Binding Effects
  • 4. The Default JavaScript Framework Provided by Joomla jimport('joomla.html.html.behavior'); JHtmlBehavior::framework(boolean); /media/system/js/mootools-core.js /media/system/js/mootools-more.js
  • 5. MooTools Libraries DOM Manipulation $(selector) //returns extended element $$(selector) //returns an array of elements Classes var someObject = new Class({ initialize: function(){ // some constructor actions } }); Event Listeners $$('a').invoke('addEvent', 'click' function(evt){ var someAnchor = evt.target; window.console.log(someAnchor.href); });
  • 6. MooTools Libraries AJAX var someRequest = new Request({ method: 'post', url: '/index.php', onSuccess: function(textResult, xmlResult){}, onFailure: function(xhr){} }); someRequest.send({'data': obj}); Binding var myObject = {name: 'Alonzo', title: 'dev'}; var myFunction = function(){ window.console.log(this.name); } var bound = myFunction.bind(myObject); bound(); // OUTPUTS: Alonzo
  • 7. MooTools Libraries Effects Tween A single Property var myTween = new Fx.Tween('someElement', { duration: 1000.0, property: 'left' }); myTween.start(0,400); Morph any number of styles in tandem var myMorph = new Fx.Morph('someElement', { duration: 2500.0, transition: Fx.Transitions.Sine.easeInOut, chain: 'cancel' }); myMorph.start({'height': 300, 'width': 100});
  • 8. MooTools Libraries Putting It All Together var myInterface = new Class({ initialize: function(){ this.links = this.listenToLinks.bind(this); this.buttons = this.listenToButtons.bind(this); this.startListening(); }, startListening: function(){ $$('a').invoke('addEvent', this.links); $$('button').invoke('addEvent', this.buttons); }, listenToLinks: function(evt){ // do something with links }, listenToButtons: function(evt){ // do something with buttons } });
  • 9. JHtml Behaviors Loading the Built-In Javascript Libraries Form Validation No-Frames JHtml::_(‘behavior.formvalidation’); JHtml::_(‘behavior.noframes’); Modal Windows Calendar JHtml::_(‘behavior.modal’); JHtml::_(‘behavior.calendar’); ToolTips Uploader JHtml::_(‘behavior.tooltip’); JHtml::_(‘behavior.uploader’);
  • 10. Inserting Javascript Template index.php file $doc =& JFactory::getDocument(); $doc->addScript('path/to/script'); $doc->addScriptDeclaration('script as text'); // FILTER OUT MOOTOOLS JAVASCRIPT $header = $this->getHeadData(); $scripts = $header['scripts']; $allow = array(); foreach($scripts as $script => $type){ if(strpos($script, "/media/system/js") === FALSE){ $allow[$script] = $type; } } // RESET THE PRELOADED JAVASCRIPT LIBRARIES $header['scripts'] = $allow; $this->setHeadData($header);
  • 11. Google Loader API Decrease page load times and offset network traffic by implementing the loader API First, sign up for an API key http://code.google.com/apis/loader/signup.html Implement the google loader <script type="text/javascript" src="http://www.google.com/jsapi?key=xxxx"></script> <script type="text/javascript">google.load(script, version)</script>
  • 12. Google Loader API Implement the Google Loader in your Template index.php file // USE GOOGLE LOADER API TO PRELOAD COMMON JAVASCRIPT LIBRARIES $js = '{"modules":{"name":"mootools","version":"1.4.1"}}'; $key = $this->params->get('google_api'); if($key){ $source = "www.google.com/jsapi?autoload=".urlencode($js)."&amp;key="; $document->addScript(HTTP_PROTOCOL.$source.$key); }else{ $document->addScript("templates/yourtemplate/javascript/mootools.js"); $document->addScript("templates/inkandpaper/javascript/swfobject.js"); }
  • 13. Additional Resources http://code.google.com/apis/loader https://groups.google.com/group/joomla-dev-general http://docs.joomla.org/Developers http://mootools.net/docs/core http://jquery.com http://www.prototypejs.org
  • 14. Special Thanks Lokesh Dhakar - lightbox Sam Stephenson - prototype Thomas Fuchs - scriptaculous Valerio Proietti - mootools John Resig - jquery The Joomla and Open Source Communities