SlideShare a Scribd company logo
1 of 18
NGUYEN TUAN LAM

CWI Team
Advance Jquery Plugins


 - Overview Jquery Plugin

 - How to create a Jquery plugin

 - How to apply, custom Jquery plugins

 - Share some knowledge to debug issues related javascript/jquery




                    www.exoplatform.com - Copyright 2012 eXo Platform   2
Agenda

- Introduce some common jquery plugins

- Some rules of Jquery plugins development

- How to create a Jquery plugin

- How to custom Jquery plugins

- Share some knowledge related
javascript/jquery




             www.exoplatform.com - Copyright 2012 eXo Platform   3
Overview some jquery plugin


- Jquery plugin simple slideshow

- Jquery plugin rotator slider

- Jquery plugin modal/lightbox

- Jquery plugin dropdown menu




                       www.exoplatform.com - Copyright 2012 eXo Platform   4
Some rules of Jquery plugin development


    Naming your file


    Naming prefix for all related files with your plugin

jquery.myplugin.js

jquery.myplugin.css


    Register in Jquery.fn

(function($){
    //Attach this new method to jQuery
    $.fn.myplugin = function(instanceSettings) {
     // code plugin in here...
    }
})(jQuery);



                          www.exoplatform.com - Copyright 2012 eXo Platform   5
Some rules of Jquery plugin development (Continue...)


     Register in Jquery.fn(Continue...) :
(function($){
    //Attach this new method to jQuery
    $.fn.extend({
          // pluginname is myplugin – constructor should be myplugin
          myplugin: function() {
          }
    });
})(jQuery);




                            www.exoplatform.com - Copyright 2012 eXo Platform   6
Some rules of Jquery plugin development (Continue...)


     Jquery plugin name same the method constructor
(function($){
    $.fn.extend({
          // pluginname is myplugin – constructor should be myplugin
          myplugin: function() {
          }
    });
})(jQuery);




                            www.exoplatform.com - Copyright 2012 eXo Platform   7
Some rules of Jquery plugin development (Continue...)

     Be aware, when use $ instead of Jquery, should be make sure it noConflict
var $ = jQuery.noConflict();

     Recommend based on the fluent interface of Jquery plugin
(function($){
    $.fn.extend({
          myplugin: function() {
              return this.each(function() {
              });
          }
    });
})(jQuery);


                               www.exoplatform.com - Copyright 2012 eXo Platform   8
Some rules of Jquery plugin development (Continue...)

Handle sets one or multiple elements
(function($){
  $.fn.extend({
        myplugin: function() {
            return this.each(function() { //set for one or multiple elements
            });
        }
  });
})(jQuery);




                            www.exoplatform.com - Copyright 2012 eXo Platform   9
Some rules of Jquery plugin development (Continue...)


          Make default options accessible from outside
function($){

    $.fn.extend({

          myplugin: function(options) {

              var defaults = { speed: '500' ; color: '#ffff00'; }

              var options = $.extend(defaults, options);

              return this.each(function() {

                    var o = options;

                    alert(o.color);

              });

          }

    });

})(jQuery);
Create a JQuery plugin

Syntax:

(function($){
   //Attach this new method to jQuery
   $.fn.extend({

     //This is where you write your plugin's name
     pluginname: function() {

          //Iterate over the current set of matched elements
          return this.each(function() {
              //code to be here
          });
     }
    });
})(jQuery);



                        www.exoplatform.com - Copyright 2012 eXo Platform   11
Create a Jquery plugin (continue...)

Optional:

(function($){
    $.fn.extend({
        //pass the options variable to the function
        myplugin: function(options) {
           //Set the default values, use comma to separate the settings, example:
           var defaults = {
               'foo' : 'bar'
           }
           var options = $.extend(defaults, options);
           return this.each(function() {
               var o = options;
              alert(o.foo);
           });
        }
    });
})(jQuery);

                       www.exoplatform.com - Copyright 2012 eXo Platform            12
Create a Jquery Plugin (Continue...)

Another way to create a simple plugin :

var myplugin = {
  init: function() {
         // initialize options, trigger on here
   },
     overlay: function(options) {
         // Check options and call function with the option
   },
     withoutMask : function(object, option) {
         // Create overlay popup without mask
  },
     maskEffect : function(object) {
         // Cretae overlay popup with mask
     }
}



                       www.exoplatform.com - Copyright 2012 eXo Platform   13
Create a Jquery plugin (continue)

Use :

$(document).ready(function() {
     $('#selector').myplugin({foo: 'foobar'});
 });


$(document).ready(function() {
      $(“.links”).click(function(e){
           e.preventDefault();
           // do something here
     }) ;
 });




                         www.exoplatform.com - Copyright 2012 eXo Platform   14
Custom a Jquery plugin


- Use the unpack version of jquery plugin to custom.

- See the comment description default options of jquery plugin to understand what
does it mean.

- Try the function Constructor of the plugin to see initializations.

- Find the function animate to see how it works

- Custom jquery plugin follow your requirement.




                        www.exoplatform.com - Copyright 2012 eXo Platform      15
Custom a Jquery plugin (Continue...)

Example: Custom jquery scrollContent plugin:

http://swip.codylindley.com/scrollContentDemo.html


- Custom a scrollContent to simple jquery slideshow

demo by code



- Custom a scrollContent to jquery slider

demo by code

- Custom animations and transitions

demo by code



                    www.exoplatform.com - Copyright 2012 eXo Platform   16
Some ways debug and fixed issues related javascript


    Use Firebug


    Use function Console.log() to see the output


    Use alert message of javascript


    Demo by code




                        www.exoplatform.com - Copyright 2012 eXo Platform   17
Question & Answer




  www.exoplatform.com - Copyright 2012 eXo Platform   18

More Related Content

What's hot

Http Communication in Angular 2.0
Http Communication in Angular 2.0Http Communication in Angular 2.0
Http Communication in Angular 2.0Eyal Vardi
 
Angular 2 Architecture (Bucharest 26/10/2016)
Angular 2 Architecture (Bucharest 26/10/2016)Angular 2 Architecture (Bucharest 26/10/2016)
Angular 2 Architecture (Bucharest 26/10/2016)Eyal Vardi
 
Hidden in plain site – joomla! hidden secrets for code monkeys
Hidden in plain site – joomla! hidden secrets for code monkeysHidden in plain site – joomla! hidden secrets for code monkeys
Hidden in plain site – joomla! hidden secrets for code monkeysNicholas Dionysopoulos
 
jQuery Bay Area Conference 2010
jQuery Bay Area Conference 2010jQuery Bay Area Conference 2010
jQuery Bay Area Conference 2010mennovanslooten
 
Curso Symfony - Clase 4
Curso Symfony - Clase 4Curso Symfony - Clase 4
Curso Symfony - Clase 4Javier Eguiluz
 
Angular 2.0 Routing and Navigation
Angular 2.0 Routing and NavigationAngular 2.0 Routing and Navigation
Angular 2.0 Routing and NavigationEyal Vardi
 
Angular 2.0 forms
Angular 2.0 formsAngular 2.0 forms
Angular 2.0 formsEyal Vardi
 
Using Geeklog as a Web Application Framework
Using Geeklog as a Web Application FrameworkUsing Geeklog as a Web Application Framework
Using Geeklog as a Web Application FrameworkDirk Haun
 
Curso Symfony - Clase 2
Curso Symfony - Clase 2Curso Symfony - Clase 2
Curso Symfony - Clase 2Javier Eguiluz
 
Как получить чёрный пояс по WordPress?
Как получить чёрный пояс по WordPress?Как получить чёрный пояс по WordPress?
Как получить чёрный пояс по WordPress?Yevhen Kotelnytskyi
 
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years laterSymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years laterHaehnchen
 
Как получить чёрный пояс по WordPress? v2.0
Как получить чёрный пояс по WordPress? v2.0Как получить чёрный пояс по WordPress? v2.0
Как получить чёрный пояс по WordPress? v2.0Yevhen Kotelnytskyi
 

What's hot (20)

A dive into Symfony 4
A dive into Symfony 4A dive into Symfony 4
A dive into Symfony 4
 
java2 swing
java2 swingjava2 swing
java2 swing
 
Http Communication in Angular 2.0
Http Communication in Angular 2.0Http Communication in Angular 2.0
Http Communication in Angular 2.0
 
Introduction to jQuery
Introduction to jQueryIntroduction to jQuery
Introduction to jQuery
 
Angular 2 Architecture (Bucharest 26/10/2016)
Angular 2 Architecture (Bucharest 26/10/2016)Angular 2 Architecture (Bucharest 26/10/2016)
Angular 2 Architecture (Bucharest 26/10/2016)
 
Hidden in plain site – joomla! hidden secrets for code monkeys
Hidden in plain site – joomla! hidden secrets for code monkeysHidden in plain site – joomla! hidden secrets for code monkeys
Hidden in plain site – joomla! hidden secrets for code monkeys
 
jQuery Bay Area Conference 2010
jQuery Bay Area Conference 2010jQuery Bay Area Conference 2010
jQuery Bay Area Conference 2010
 
Curso Symfony - Clase 4
Curso Symfony - Clase 4Curso Symfony - Clase 4
Curso Symfony - Clase 4
 
Angular 2.0 Routing and Navigation
Angular 2.0 Routing and NavigationAngular 2.0 Routing and Navigation
Angular 2.0 Routing and Navigation
 
Sane Async Patterns
Sane Async PatternsSane Async Patterns
Sane Async Patterns
 
Nicolas Embleton, Advanced Angular JS
Nicolas Embleton, Advanced Angular JSNicolas Embleton, Advanced Angular JS
Nicolas Embleton, Advanced Angular JS
 
Web 11 | AJAX + JSON + PHP
Web 11 | AJAX + JSON + PHPWeb 11 | AJAX + JSON + PHP
Web 11 | AJAX + JSON + PHP
 
Angular 2.0 forms
Angular 2.0 formsAngular 2.0 forms
Angular 2.0 forms
 
Using Geeklog as a Web Application Framework
Using Geeklog as a Web Application FrameworkUsing Geeklog as a Web Application Framework
Using Geeklog as a Web Application Framework
 
Curso Symfony - Clase 2
Curso Symfony - Clase 2Curso Symfony - Clase 2
Curso Symfony - Clase 2
 
Web 10 | PHP with MySQL
Web 10 | PHP with MySQLWeb 10 | PHP with MySQL
Web 10 | PHP with MySQL
 
Как получить чёрный пояс по WordPress?
Как получить чёрный пояс по WordPress?Как получить чёрный пояс по WordPress?
Как получить чёрный пояс по WordPress?
 
Deep dive into Oracle ADF
Deep dive into Oracle ADFDeep dive into Oracle ADF
Deep dive into Oracle ADF
 
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years laterSymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
 
Как получить чёрный пояс по WordPress? v2.0
Как получить чёрный пояс по WordPress? v2.0Как получить чёрный пояс по WordPress? v2.0
Как получить чёрный пояс по WordPress? v2.0
 

Viewers also liked

Viewers also liked (7)

Wg11 automaive
Wg11 automaiveWg11 automaive
Wg11 automaive
 
E xo mobile_overview_best_practice_in_mobile_application_design
E xo mobile_overview_best_practice_in_mobile_application_designE xo mobile_overview_best_practice_in_mobile_application_design
E xo mobile_overview_best_practice_in_mobile_application_design
 
I os
I osI os
I os
 
Hadoop
HadoopHadoop
Hadoop
 
Jquery
JqueryJquery
Jquery
 
Memory and runtime analysis
Memory and runtime analysisMemory and runtime analysis
Memory and runtime analysis
 
Magento
MagentoMagento
Magento
 

Similar to Advance Jquery Plugins - How to Create and Customize Jquery Plugins

JQuery plugin development fundamentals
JQuery plugin development fundamentalsJQuery plugin development fundamentals
JQuery plugin development fundamentalsBastian Feder
 
Jquery plugin development
Jquery plugin developmentJquery plugin development
Jquery plugin developmentFaruk Hossen
 
jQuery Fundamentals
jQuery FundamentalsjQuery Fundamentals
jQuery FundamentalsGil Fink
 
Ditching JQuery
Ditching JQueryDitching JQuery
Ditching JQueryhowlowck
 
Javascript Frameworks for Joomla
Javascript Frameworks for JoomlaJavascript Frameworks for Joomla
Javascript Frameworks for JoomlaLuke Summerfield
 
symfony on action - WebTech 207
symfony on action - WebTech 207symfony on action - WebTech 207
symfony on action - WebTech 207patter
 
Construire une application JavaFX 8 avec gradle
Construire une application JavaFX 8 avec gradleConstruire une application JavaFX 8 avec gradle
Construire une application JavaFX 8 avec gradleThierry Wasylczenko
 
Converting your JS library to a jQuery plugin
Converting your JS library to a jQuery pluginConverting your JS library to a jQuery plugin
Converting your JS library to a jQuery pluginthehoagie
 
20150516 modern web_conf_tw
20150516 modern web_conf_tw20150516 modern web_conf_tw
20150516 modern web_conf_twTse-Ching Ho
 
Overlays, Accordions & Tabs, Oh My
Overlays, Accordions & Tabs, Oh MyOverlays, Accordions & Tabs, Oh My
Overlays, Accordions & Tabs, Oh MySteve McMahon
 
Beyond DOMReady: Ultra High-Performance Javascript
Beyond DOMReady: Ultra High-Performance JavascriptBeyond DOMReady: Ultra High-Performance Javascript
Beyond DOMReady: Ultra High-Performance Javascriptaglemann
 
Avinash Kundaliya: Javascript and WordPress
Avinash Kundaliya: Javascript and WordPressAvinash Kundaliya: Javascript and WordPress
Avinash Kundaliya: Javascript and WordPresswpnepal
 
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)arcware
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...Fabio Franzini
 
Prototype & jQuery
Prototype & jQueryPrototype & jQuery
Prototype & jQueryRemy Sharp
 
Ditching jQuery Madison
Ditching jQuery MadisonDitching jQuery Madison
Ditching jQuery MadisonHao Luo
 

Similar to Advance Jquery Plugins - How to Create and Customize Jquery Plugins (20)

JQuery plugin development fundamentals
JQuery plugin development fundamentalsJQuery plugin development fundamentals
JQuery plugin development fundamentals
 
Jquery plugin development
Jquery plugin developmentJquery plugin development
Jquery plugin development
 
jQuery Fundamentals
jQuery FundamentalsjQuery Fundamentals
jQuery Fundamentals
 
Making a simple jQuery plug-in
Making a simple jQuery plug-inMaking a simple jQuery plug-in
Making a simple jQuery plug-in
 
Ditching JQuery
Ditching JQueryDitching JQuery
Ditching JQuery
 
Javascript Frameworks for Joomla
Javascript Frameworks for JoomlaJavascript Frameworks for Joomla
Javascript Frameworks for Joomla
 
symfony on action - WebTech 207
symfony on action - WebTech 207symfony on action - WebTech 207
symfony on action - WebTech 207
 
Construire une application JavaFX 8 avec gradle
Construire une application JavaFX 8 avec gradleConstruire une application JavaFX 8 avec gradle
Construire une application JavaFX 8 avec gradle
 
Converting your JS library to a jQuery plugin
Converting your JS library to a jQuery pluginConverting your JS library to a jQuery plugin
Converting your JS library to a jQuery plugin
 
20150516 modern web_conf_tw
20150516 modern web_conf_tw20150516 modern web_conf_tw
20150516 modern web_conf_tw
 
Overlays, Accordions & Tabs, Oh My
Overlays, Accordions & Tabs, Oh MyOverlays, Accordions & Tabs, Oh My
Overlays, Accordions & Tabs, Oh My
 
jQuery secrets
jQuery secretsjQuery secrets
jQuery secrets
 
Beyond DOMReady: Ultra High-Performance Javascript
Beyond DOMReady: Ultra High-Performance JavascriptBeyond DOMReady: Ultra High-Performance Javascript
Beyond DOMReady: Ultra High-Performance Javascript
 
J query training
J query trainingJ query training
J query training
 
Avinash Kundaliya: Javascript and WordPress
Avinash Kundaliya: Javascript and WordPressAvinash Kundaliya: Javascript and WordPress
Avinash Kundaliya: Javascript and WordPress
 
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...
 
Prototype & jQuery
Prototype & jQueryPrototype & jQuery
Prototype & jQuery
 
Frontin like-a-backer
Frontin like-a-backerFrontin like-a-backer
Frontin like-a-backer
 
Ditching jQuery Madison
Ditching jQuery MadisonDitching jQuery Madison
Ditching jQuery Madison
 

More from adm_exoplatform

More from adm_exoplatform (8)

Development withforce
Development withforceDevelopment withforce
Development withforce
 
Jquery ui
Jquery uiJquery ui
Jquery ui
 
Cmsms
CmsmsCmsms
Cmsms
 
Java application server in the cloud
Java application server in the cloudJava application server in the cloud
Java application server in the cloud
 
Jvm mbeans jmxtran
Jvm mbeans jmxtranJvm mbeans jmxtran
Jvm mbeans jmxtran
 
Git training
Git trainingGit training
Git training
 
Cluster mode and plf cluster
Cluster mode and plf clusterCluster mode and plf cluster
Cluster mode and plf cluster
 
Cluster mode and plf cluster
Cluster mode and plf clusterCluster mode and plf cluster
Cluster mode and plf cluster
 

Recently uploaded

Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024TopCSSGallery
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...Karmanjay Verma
 
A Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxA Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxAna-Maria Mihalceanu
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
All These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDFAll These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDFMichael Gough
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
Landscape Catalogue 2024 Australia-1.pdf
Landscape Catalogue 2024 Australia-1.pdfLandscape Catalogue 2024 Australia-1.pdf
Landscape Catalogue 2024 Australia-1.pdfAarwolf Industries LLC
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Kaya Weers
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#Karmanjay Verma
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesThousandEyes
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...Nikki Chapple
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...itnewsafrica
 

Recently uploaded (20)

Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
 
A Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxA Glance At The Java Performance Toolbox
A Glance At The Java Performance Toolbox
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
All These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDFAll These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDF
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
Landscape Catalogue 2024 Australia-1.pdf
Landscape Catalogue 2024 Australia-1.pdfLandscape Catalogue 2024 Australia-1.pdf
Landscape Catalogue 2024 Australia-1.pdf
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
 

Advance Jquery Plugins - How to Create and Customize Jquery Plugins

  • 2. Advance Jquery Plugins - Overview Jquery Plugin - How to create a Jquery plugin - How to apply, custom Jquery plugins - Share some knowledge to debug issues related javascript/jquery www.exoplatform.com - Copyright 2012 eXo Platform 2
  • 3. Agenda - Introduce some common jquery plugins - Some rules of Jquery plugins development - How to create a Jquery plugin - How to custom Jquery plugins - Share some knowledge related javascript/jquery www.exoplatform.com - Copyright 2012 eXo Platform 3
  • 4. Overview some jquery plugin - Jquery plugin simple slideshow - Jquery plugin rotator slider - Jquery plugin modal/lightbox - Jquery plugin dropdown menu www.exoplatform.com - Copyright 2012 eXo Platform 4
  • 5. Some rules of Jquery plugin development  Naming your file  Naming prefix for all related files with your plugin jquery.myplugin.js jquery.myplugin.css  Register in Jquery.fn (function($){ //Attach this new method to jQuery $.fn.myplugin = function(instanceSettings) { // code plugin in here... } })(jQuery); www.exoplatform.com - Copyright 2012 eXo Platform 5
  • 6. Some rules of Jquery plugin development (Continue...)  Register in Jquery.fn(Continue...) : (function($){ //Attach this new method to jQuery $.fn.extend({ // pluginname is myplugin – constructor should be myplugin myplugin: function() { } }); })(jQuery); www.exoplatform.com - Copyright 2012 eXo Platform 6
  • 7. Some rules of Jquery plugin development (Continue...)  Jquery plugin name same the method constructor (function($){ $.fn.extend({ // pluginname is myplugin – constructor should be myplugin myplugin: function() { } }); })(jQuery); www.exoplatform.com - Copyright 2012 eXo Platform 7
  • 8. Some rules of Jquery plugin development (Continue...)  Be aware, when use $ instead of Jquery, should be make sure it noConflict var $ = jQuery.noConflict();  Recommend based on the fluent interface of Jquery plugin (function($){ $.fn.extend({ myplugin: function() { return this.each(function() { }); } }); })(jQuery); www.exoplatform.com - Copyright 2012 eXo Platform 8
  • 9. Some rules of Jquery plugin development (Continue...) Handle sets one or multiple elements (function($){ $.fn.extend({ myplugin: function() { return this.each(function() { //set for one or multiple elements }); } }); })(jQuery); www.exoplatform.com - Copyright 2012 eXo Platform 9
  • 10. Some rules of Jquery plugin development (Continue...)  Make default options accessible from outside function($){ $.fn.extend({ myplugin: function(options) { var defaults = { speed: '500' ; color: '#ffff00'; } var options = $.extend(defaults, options); return this.each(function() { var o = options; alert(o.color); }); } }); })(jQuery);
  • 11. Create a JQuery plugin Syntax: (function($){ //Attach this new method to jQuery $.fn.extend({ //This is where you write your plugin's name pluginname: function() { //Iterate over the current set of matched elements return this.each(function() { //code to be here }); } }); })(jQuery); www.exoplatform.com - Copyright 2012 eXo Platform 11
  • 12. Create a Jquery plugin (continue...) Optional: (function($){ $.fn.extend({ //pass the options variable to the function myplugin: function(options) { //Set the default values, use comma to separate the settings, example: var defaults = { 'foo' : 'bar' } var options = $.extend(defaults, options); return this.each(function() { var o = options; alert(o.foo); }); } }); })(jQuery); www.exoplatform.com - Copyright 2012 eXo Platform 12
  • 13. Create a Jquery Plugin (Continue...) Another way to create a simple plugin : var myplugin = { init: function() { // initialize options, trigger on here }, overlay: function(options) { // Check options and call function with the option }, withoutMask : function(object, option) { // Create overlay popup without mask }, maskEffect : function(object) { // Cretae overlay popup with mask } } www.exoplatform.com - Copyright 2012 eXo Platform 13
  • 14. Create a Jquery plugin (continue) Use : $(document).ready(function() { $('#selector').myplugin({foo: 'foobar'}); }); $(document).ready(function() { $(“.links”).click(function(e){ e.preventDefault(); // do something here }) ; }); www.exoplatform.com - Copyright 2012 eXo Platform 14
  • 15. Custom a Jquery plugin - Use the unpack version of jquery plugin to custom. - See the comment description default options of jquery plugin to understand what does it mean. - Try the function Constructor of the plugin to see initializations. - Find the function animate to see how it works - Custom jquery plugin follow your requirement. www.exoplatform.com - Copyright 2012 eXo Platform 15
  • 16. Custom a Jquery plugin (Continue...) Example: Custom jquery scrollContent plugin: http://swip.codylindley.com/scrollContentDemo.html - Custom a scrollContent to simple jquery slideshow demo by code - Custom a scrollContent to jquery slider demo by code - Custom animations and transitions demo by code www.exoplatform.com - Copyright 2012 eXo Platform 16
  • 17. Some ways debug and fixed issues related javascript  Use Firebug  Use function Console.log() to see the output  Use alert message of javascript  Demo by code www.exoplatform.com - Copyright 2012 eXo Platform 17
  • 18. Question & Answer www.exoplatform.com - Copyright 2012 eXo Platform 18