silverstripe-framework/admin/thirdparty/history-js/scripts/uncompressed/history.adapter.right.js

79 lines
1.8 KiB
JavaScript
Raw Normal View History

2011-05-20 05:49:30 +02:00
/**
2011-12-13 10:34:25 +01:00
* History.js RightJS Adapter
2011-05-20 05:49:30 +02:00
* @author Benjamin Arthur Lupton <contact@balupton.com>
* @copyright 2010-2011 Benjamin Arthur Lupton <contact@balupton.com>
* @license New BSD License <http://creativecommons.org/licenses/BSD/>
*/
// Closure
(function(window,undefined){
2011-12-13 10:34:25 +01:00
"use strict";
2011-05-20 05:49:30 +02:00
// Localise Globals
var
History = window.History = window.History||{},
2011-12-13 10:34:25 +01:00
document = window.document,
RightJS = window.RightJS,
$ = RightJS.$;
2011-05-20 05:49:30 +02:00
// Check Existence
if ( typeof History.Adapter !== 'undefined' ) {
throw new Error('History.js Adapter has already been loaded...');
}
// Add the Adapter
History.Adapter = {
/**
* History.Adapter.bind(el,event,callback)
* @param {Element|Selector} el
* @param {String} event - custom and standard events
* @param {Function} callback
2011-12-13 10:34:25 +01:00
* @return
2011-05-20 05:49:30 +02:00
*/
bind: function(el,event,callback){
2011-12-13 10:34:25 +01:00
$(el).on(event,callback);
2011-05-20 05:49:30 +02:00
},
/**
* History.Adapter.trigger(el,event)
* @param {Element|Selector} el
* @param {String} event - custom and standard events
2011-12-13 10:34:25 +01:00
* @param {Object} extraEventData - a object of extra event data
* @return
2011-05-20 05:49:30 +02:00
*/
2011-12-13 10:34:25 +01:00
trigger: function(el,event,extraEventData){
$(el).fire(event,extraEventData);
},
/**
* History.Adapter.extractEventData(key,event,extra)
* @param {String} key - key for the event data to extract
* @param {String} event - custom and standard events
* @return {mixed}
*/
extractEventData: function(key,event){
// Right.js Native
// Right.js Custom
var result = (event && event._ && event._[key]) || undefined;
// Return
return result;
2011-05-20 05:49:30 +02:00
},
/**
2011-12-13 10:34:25 +01:00
* History.Adapter.onDomLoad(callback)
2011-05-20 05:49:30 +02:00
* @param {Function} callback
2011-12-13 10:34:25 +01:00
* @return
2011-05-20 05:49:30 +02:00
*/
onDomLoad: function(callback) {
2011-12-13 10:34:25 +01:00
$(document).onReady(callback);
2011-05-20 05:49:30 +02:00
}
};
// Try and Initialise History
if ( typeof History.init !== 'undefined' ) {
History.init();
}
})(window);