-
Notifications
You must be signed in to change notification settings - Fork 660
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrated the equalheights plugin to the new template.
- Loading branch information
1 parent
a4c79d4
commit 4ee4cfa
Showing
9 changed files
with
485 additions
and
317 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,62 @@ | ||
/* | ||
Web Experience Toolkit (WET) / Boîte à outils de l\'expérience Web (BOEW) | ||
_plugin : Ajax Fetch [ ajax-fetch ] | ||
_author : World Wide Web | ||
_notes : A basic AjaxLoader wrapper for WET-BOEW that appends to elements | ||
_licence: wet-boew.github.io/wet-boew/License-en.html / wet-boew.github.io/wet-boew/Licence-fr.html | ||
*/ | ||
|
||
(function ( $, window, vapour ) { | ||
|
||
"use strict"; | ||
|
||
$.ajaxSettings.cache = false; | ||
|
||
var $document = vapour.doc, | ||
generateSerial; | ||
|
||
generateSerial = function ( len ) { //internal core functions | ||
|
||
var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz", | ||
string_length = len, | ||
randomstring = "", | ||
counter = 0, | ||
letterOrNumber, | ||
newNum, | ||
rnum; | ||
|
||
while ( counter < string_length ) { | ||
letterOrNumber = Math.floor( Math.random( ) * 2 ); | ||
if ( letterOrNumber === 0 ) { | ||
newNum = Math.floor( Math.random( ) * 9 ); | ||
randomstring += newNum; | ||
} | ||
else { | ||
rnum = Math.floor( Math.random( ) * chars.length ); | ||
randomstring += chars.substring( rnum, rnum + 1 ); | ||
} | ||
counter++; | ||
} | ||
return randomstring; | ||
}; | ||
|
||
//Event binding | ||
$document.on( "ajax-fetch.wb", function ( event ) { | ||
var _caller = event.element, | ||
_url = event.fetch, | ||
_id = "wb" + ( generateSerial( 8 ) ); | ||
|
||
$( "<div id='" + _id + "' />" ) | ||
.load( _url, function () { | ||
$( _caller ) | ||
.trigger( { | ||
type: "ajax-fetched.wb", | ||
pointer: $( this ) | ||
} ); | ||
} ); | ||
|
||
}); | ||
|
||
})( jQuery, window, vapour ); | ||
* @title WET-BOEW Ajax Fetch [ ajax-fetch ] | ||
* @overview A basic AjaxLoader wrapper for WET-BOEW | ||
* @license wet-boew.github.io/wet-boew/License-en.html / wet-boew.github.io/wet-boew/Licence-fr.html | ||
* @author WET Community | ||
*/ | ||
(function ( $, vapour ) { | ||
"use strict"; | ||
|
||
$.ajaxSettings.cache = false; | ||
|
||
/* | ||
* Variable and function definitions. | ||
* These are global to the plugin - meaning that they will be initialized once per page, | ||
* not once per instance of plugin on the page. So, this is a good place to define | ||
* variables that are common to all instances of the plugin on a page. | ||
*/ | ||
var $document = vapour.doc, | ||
|
||
/* | ||
* @method generateSerial | ||
* @param {integer} Length of the random string to be generated | ||
*/ | ||
generateSerial = function ( len ) { | ||
var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz", | ||
string_length = len, | ||
randomstring = "", | ||
counter = 0, | ||
letterOrNumber, | ||
newNum, | ||
rnum; | ||
|
||
for ( counter; counter !== string_length; counter += 1 ) { | ||
letterOrNumber = Math.floor( Math.random( ) * 2 ); | ||
if ( letterOrNumber === 0 ) { | ||
newNum = Math.floor( Math.random( ) * 9 ); | ||
randomstring += newNum; | ||
} else { | ||
rnum = Math.floor( Math.random( ) * chars.length ); | ||
randomstring += chars.substring( rnum, rnum + 1 ); | ||
} | ||
} | ||
return randomstring; | ||
}; | ||
|
||
// Event binding | ||
$document.on( "ajax-fetch.wb", function ( event ) { | ||
var _caller = event.element, | ||
_url = event.fetch, | ||
_id = "wb" + ( generateSerial( 8 ) ); | ||
|
||
$( "<div id='" + _id + "' />" ) | ||
.load( _url, function () { | ||
$( _caller ) | ||
.trigger( { | ||
type: "ajax-fetched.wb", | ||
pointer: $( this ) | ||
} ); | ||
} ); | ||
} ); | ||
|
||
} )( jQuery, vapour ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,65 @@ | ||
/* | ||
Web Experience Toolkit (WET) / Boîte à outils de l\'expérience Web (BOEW) | ||
_plugin : Ajax Loader [ data-append ] | ||
_author : World Wide Web | ||
_notes : A basic AjaxLoader wrapper for WET-BOEW that appends to elements | ||
_licence: wet-boew.github.io/wet-boew/License-en.html / wet-boew.github.io/wet-boew/Licence-fr.html | ||
*/ | ||
|
||
* @title WET-BOEW Ajax Loader [ data-append ] | ||
* @overview A basic AjaxLoader wrapper for WET-BOEW that inserts content after elements | ||
* @license wet-boew.github.io/wet-boew/License-en.html / wet-boew.github.io/wet-boew/Licence-fr.html | ||
* @author WET Community | ||
*/ | ||
(function ( $, window, vapour ) { | ||
"use strict"; | ||
|
||
$.ajaxSettings.cache = false; | ||
|
||
/* | ||
* Variable and function definitions. | ||
* These are global to the plugin - meaning that they will be initialized once per page, | ||
* not once per instance of plugin on the page. So, this is a good place to define | ||
* variables that are common to all instances of the plugin on a page. | ||
*/ | ||
var selector = "[data-ajax-after]", | ||
$document = vapour.doc, | ||
|
||
/* | ||
* Init runs once per plugin element on the page. There may be multiple elements. | ||
* It will run more than once per plugin if you don't remove the selector from the timer. | ||
* @method init | ||
* @param {jQuery DOM element} $elm The plugin element being initialized | ||
*/ | ||
init = function ( $elm ) { | ||
|
||
"use strict"; | ||
var _url = $elm.data( "ajax-after" ); | ||
|
||
$.ajaxSettings.cache = false; | ||
// All plugins need to remove their reference from the timer in the init sequence unless they have a requirement to be poked every 0.5 seconds | ||
window._timer.remove( selector ); | ||
|
||
var $document = vapour.doc; | ||
$document.trigger( { | ||
type: "ajax-fetch.wb", | ||
element: $elm, | ||
fetch: _url | ||
} ); | ||
}; | ||
|
||
$document.on( "timerpoke.wb ajax-fetched.wb", "[data-ajax-append]", function ( | ||
event ) { | ||
var eventType = event.type, | ||
_elm = $( this ), | ||
_url; | ||
$document.on( "timerpoke.wb ajax-fetched.wb", selector, function ( event ) { | ||
var eventType = event.type, | ||
$elm = $( this ); | ||
|
||
switch ( eventType ) { | ||
case "timerpoke": | ||
window._timer.remove( "[data-ajax-after]" ); | ||
_url = _elm.data( "ajax-after" ); | ||
$document.trigger({ | ||
type: "ajax-fetch.wb", | ||
element: _elm, | ||
fetch: _url | ||
}); | ||
break; | ||
case "ajax-fetched": | ||
_elm.after( event.pointer.html() ); | ||
_elm.trigger( "ajax-after-loaded.wb" ); | ||
break; | ||
switch ( eventType ) { | ||
case "timerpoke": | ||
init( $elm ); | ||
break; | ||
case "ajax-fetched": | ||
$elm.after( event.pointer.html() ) | ||
.trigger( "ajax-after-loaded.wb" ); | ||
break; | ||
} | ||
|
||
} | ||
return false; | ||
} ); | ||
/* | ||
* Since we are working with events we want to ensure that we are being passive about our control, | ||
* so returning true allows for events to always continue | ||
*/ | ||
return true; | ||
} ); | ||
|
||
window._timer.add( "[data-ajax-after]" ); | ||
// Add the timer poke to initialize the plugin | ||
window._timer.add( selector ); | ||
|
||
})( jQuery, window, vapour ); | ||
} )( jQuery, window, vapour ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,65 @@ | ||
/* | ||
Web Experience Toolkit (WET) / Boîte à outils de l\'expérience Web (BOEW) | ||
_plugin : Ajax Loader [ data-append ] | ||
_author : World Wide Web | ||
_notes : A basic AjaxLoader wrapper for WET-BOEW that appends to elements | ||
_licence: wet-boew.github.io/wet-boew/License-en.html / wet-boew.github.io/wet-boew/Licence-fr.html | ||
*/ | ||
|
||
* @title WET-BOEW Ajax Loader [ data-append ] | ||
* @overview A basic AjaxLoader wrapper for WET-BOEW that appends to elements | ||
* @license wet-boew.github.io/wet-boew/License-en.html / wet-boew.github.io/wet-boew/Licence-fr.html | ||
* @author WET Community | ||
*/ | ||
(function ( $, window, vapour ) { | ||
"use strict"; | ||
|
||
"use strict"; | ||
|
||
$.ajaxSettings.cache = false; | ||
$.ajaxSettings.cache = false; | ||
|
||
var $document = vapour.doc; | ||
/* | ||
* Variable and function definitions. | ||
* These are global to the plugin - meaning that they will be initialized once per page, | ||
* not once per instance of plugin on the page. So, this is a good place to define | ||
* variables that are common to all instances of the plugin on a page. | ||
*/ | ||
var selector = "[data-ajax-append]", | ||
$document = vapour.doc, | ||
|
||
$document.on( "timerpoke.wb ajax-fetched.wb", "[data-ajax-append]", function ( | ||
event ) { | ||
/* | ||
* Init runs once per plugin element on the page. There may be multiple elements. | ||
* It will run more than once per plugin if you don't remove the selector from the timer. | ||
* @method init | ||
* @param {jQuery DOM element} $elm The plugin element being initialized | ||
*/ | ||
init = function ( $elm ) { | ||
|
||
var eventType = event.type, | ||
_elm = $( this ), | ||
_url; | ||
var _url = $elm.data( "ajax-append" ); | ||
|
||
switch ( eventType ) { | ||
case "timerpoke": | ||
// All plugins need to remove their reference from the timer in the init sequence unless they have a requirement to be poked every 0.5 seconds | ||
window._timer.remove( selector ); | ||
|
||
window._timer.remove( "[data-ajax-append]" ); | ||
_url = _elm.data( "ajax-append" ); | ||
$document.trigger( { | ||
type: "ajax-fetch.wb", | ||
element: _elm, | ||
fetch: _url | ||
} ); | ||
break; | ||
$document.trigger( { | ||
type: "ajax-fetch.wb", | ||
element: $elm, | ||
fetch: _url | ||
} ); | ||
}; | ||
|
||
case "ajax-fetched": | ||
$document.on( "timerpoke.wb ajax-fetched.wb", selector, function ( event ) { | ||
var eventType = event.type, | ||
$elm = $( this ); | ||
|
||
_elm.append( event.pointer.html() ); | ||
_elm.trigger( "ajax-append-loaded.wb" ); | ||
break; | ||
switch ( eventType ) { | ||
case "timerpoke": | ||
init( $elm ); | ||
break; | ||
case "ajax-fetched": | ||
$elm.append( event.pointer.html() ) | ||
.trigger( "ajax-append-loaded.wb" ); | ||
break; | ||
} | ||
|
||
} | ||
return false; | ||
} ); | ||
/* | ||
* Since we are working with events we want to ensure that we are being passive about our control, | ||
* so returning true allows for events to always continue | ||
*/ | ||
return true; | ||
} ); | ||
|
||
window._timer.add( "[data-ajax-append]" ); | ||
// Add the timer poke to initialize the plugin | ||
window._timer.add( selector ); | ||
|
||
})( jQuery, window, vapour ); | ||
} )( jQuery, window, vapour ); |
Oops, something went wrong.