Comparing version 0.2.9 to 0.3.0
42
jymin.js
/** | ||
* _ _ ___ ____ ___ | ||
* | |_ _ _ __ ___ (_)_ __ __ __/ _ \ |___ \ / _ \ | ||
* _ | | | | | '_ ` _ \| | '_ \ \ \ / / | | | __) | (_) | | ||
* | |_| | |_| | | | | | | | | | | \ V /| |_| | / __/ \__, | | ||
* \___/ \__, |_| |_| |_|_|_| |_| \_/ \___(_)_____(_)/_/ | ||
* _ _ ___ _____ ___ | ||
* | |_ _ _ __ ___ (_)_ __ __ __/ _ \ |___ / / _ \ | ||
* _ | | | | | '_ ` _ \| | '_ \ \ \ / / | | | |_ \| | | | | ||
* | |_| | |_| | | | | | | | | | | \ V /| |_| | ___) | |_| | | ||
* \___/ \__, |_| |_| |_|_|_| |_| \_/ \___(_)____(_)___/ | ||
* |___/ | ||
@@ -33,3 +33,3 @@ * | ||
this.jymin = {version: '0.2.9'}; | ||
this.jymin = {version: '0.3.0'}; | ||
@@ -1013,2 +1013,9 @@ /** | ||
}; | ||
var CLICK = 'click'; | ||
var MOUSEDOWN = 'mousedown'; | ||
var MOUSEUP = 'mouseup'; | ||
var KEYDOWN = 'keydown'; | ||
var KEYUP = 'keyup'; | ||
var KEYPRESS = 'keypress'; | ||
/** | ||
@@ -1019,3 +1026,3 @@ * Bind a handler to listen for a particular event on an element. | ||
element, // DOMElement|string: Element or ID of element to bind to. | ||
eventName, // string: Name of event (e.g. "click", "mouseover", "keyup"). | ||
eventName, // string|Array: Name of event (e.g. "click", "mouseover", "keyup"). | ||
eventHandler, // function: Function to run when the event is triggered. `eventHandler(element, event, target, customData)` | ||
@@ -1025,4 +1032,5 @@ customData // object|: Custom data to pass through to the event handler when it's triggered. | ||
// Allow multiple events to be bound at once using a space-delimited string. | ||
if (contains(eventName, ' ')) { | ||
var eventNames = splitBySpaces(eventName); | ||
var isEventArray = isArray(eventNames); | ||
if (isEventArray || contains(eventName, ' ')) { | ||
var eventNames = isEventArray ? eventName : splitBySpaces(eventName); | ||
forEach(eventNames, function (singleEventName) { | ||
@@ -1089,4 +1097,10 @@ bind(element, singleEventName, eventHandler, customData); | ||
) { | ||
// If there's no parent element, assume it's the document. | ||
if (isFunction(eventName)) { | ||
if (isFunction(selector)) { | ||
customData = eventName; | ||
eventHandler = selector; | ||
eventName = element; | ||
selector = ''; | ||
element = document; | ||
} | ||
else if (isFunction(eventName)) { | ||
customData = eventHandler; | ||
@@ -1446,3 +1460,3 @@ eventHandler = eventName; | ||
*/ | ||
var pushHistory = function ( | ||
var historyPush = function ( | ||
href | ||
@@ -1456,3 +1470,3 @@ ) { | ||
*/ | ||
var replaceHistory = function ( | ||
var historyReplace = function ( | ||
href | ||
@@ -1466,3 +1480,3 @@ ) { | ||
*/ | ||
var popHistory = function ( | ||
var historyPop = function ( | ||
href | ||
@@ -1469,0 +1483,0 @@ ) { |
@@ -15,3 +15,3 @@ { | ||
], | ||
"version": "0.2.9", | ||
"version": "0.3.0", | ||
"main": "chug/chug.js", | ||
@@ -18,0 +18,0 @@ "homepage": "http://lighter.io/jymin", |
@@ -0,1 +1,8 @@ | ||
var CLICK = 'click'; | ||
var MOUSEDOWN = 'mousedown'; | ||
var MOUSEUP = 'mouseup'; | ||
var KEYDOWN = 'keydown'; | ||
var KEYUP = 'keyup'; | ||
var KEYPRESS = 'keypress'; | ||
/** | ||
@@ -6,3 +13,3 @@ * Bind a handler to listen for a particular event on an element. | ||
element, // DOMElement|string: Element or ID of element to bind to. | ||
eventName, // string: Name of event (e.g. "click", "mouseover", "keyup"). | ||
eventName, // string|Array: Name of event (e.g. "click", "mouseover", "keyup"). | ||
eventHandler, // function: Function to run when the event is triggered. `eventHandler(element, event, target, customData)` | ||
@@ -12,4 +19,5 @@ customData // object|: Custom data to pass through to the event handler when it's triggered. | ||
// Allow multiple events to be bound at once using a space-delimited string. | ||
if (contains(eventName, ' ')) { | ||
var eventNames = splitBySpaces(eventName); | ||
var isEventArray = isArray(eventNames); | ||
if (isEventArray || contains(eventName, ' ')) { | ||
var eventNames = isEventArray ? eventName : splitBySpaces(eventName); | ||
forEach(eventNames, function (singleEventName) { | ||
@@ -76,4 +84,10 @@ bind(element, singleEventName, eventHandler, customData); | ||
) { | ||
// If there's no parent element, assume it's the document. | ||
if (isFunction(eventName)) { | ||
if (isFunction(selector)) { | ||
customData = eventName; | ||
eventHandler = selector; | ||
eventName = element; | ||
selector = ''; | ||
element = document; | ||
} | ||
else if (isFunction(eventName)) { | ||
customData = eventHandler; | ||
@@ -80,0 +94,0 @@ eventHandler = eventName; |
@@ -22,3 +22,3 @@ /** | ||
*/ | ||
var pushHistory = function ( | ||
var historyPush = function ( | ||
href | ||
@@ -32,3 +32,3 @@ ) { | ||
*/ | ||
var replaceHistory = function ( | ||
var historyReplace = function ( | ||
href | ||
@@ -42,3 +42,3 @@ ) { | ||
*/ | ||
var popHistory = function ( | ||
var historyPop = function ( | ||
href | ||
@@ -45,0 +45,0 @@ ) { |
104623
25
3881