Skip to content

Commit

Permalink
Migrated the equalheights plugin to the new template.
Browse files Browse the repository at this point in the history
  • Loading branch information
pjackson28 committed Oct 9, 2013
1 parent a4c79d4 commit 4ee4cfa
Show file tree
Hide file tree
Showing 9 changed files with 485 additions and 317 deletions.
120 changes: 61 additions & 59 deletions src/plugins/ajax-fetch/ajax-fetch.js
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 );
37 changes: 18 additions & 19 deletions src/plugins/carousel/carousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
* @author WET Community
*/
(function ( $, window, vapour ) {
"use strict";

/*
* 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.
*/
"use strict";

/*
* 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 = ".wb-carousel",
$document = vapour.doc,
controls = selector + " .prv, " + selector + " .nxt, " + selector + " .plypause",
Expand Down Expand Up @@ -101,7 +101,6 @@
var eventType = event.type,

// "this" is cached for all events to utilize

$elm = $( this );

switch ( eventType ) {
Expand All @@ -124,10 +123,10 @@
break;
}

/*
* 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
*/
/*
* 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;
} );

Expand All @@ -152,14 +151,14 @@
}
_sldr.attr( "data-ctime", 0 );

/*
* 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
*/
/*
* 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;
} );

// Add the timer poke to initialize the plugin

window._timer.add( ".wb-carousel" );
})( jQuery, window, vapour );

} )( jQuery, window, vapour );
89 changes: 55 additions & 34 deletions src/plugins/data-after/data-after.js
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 );
87 changes: 52 additions & 35 deletions src/plugins/data-append/data-append.js
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 );
Loading

0 comments on commit 4ee4cfa

Please sign in to comment.