Comparing version
/*! | ||
* Ender.js: next-level JavaScript | ||
* Ender: open module JavaScript framework | ||
* copyright Dustin Diaz & Jacob Thornton 2011 (@ded @fat) | ||
* https://github.com/ded/Ender.js | ||
* https://github.com/ender-js/ender | ||
* License MIT | ||
* Build: ender -j domready bean qwery | ||
*/ | ||
@@ -11,3 +12,3 @@ !function (context) { | ||
for (var k in o2) { | ||
o[k] = o2[k]; | ||
k != 'noConflict' && (o[k] = o2[k]); | ||
} | ||
@@ -17,3 +18,3 @@ } | ||
function _$(s, r) { | ||
this.elements = $._select(s, r); | ||
this.elements = typeof s !== 'string' && !s.nodeType && typeof s.length !== 'undefined' ? s : $._select(s, r); | ||
this.length = this.elements.length; | ||
@@ -48,318 +49,435 @@ for (var i = 0; i < this.length; i++) { | ||
}(this);/*! | ||
* bonzo.js - copyright @dedfat 2011 | ||
* https://github.com/ded/bonzo | ||
* Follow our software http://twitter.com/dedfat | ||
* MIT License | ||
*/ | ||
!function (context) { | ||
}(this); | ||
!function () { var module = { exports: {} }; !function (doc) { | ||
var loaded = 0, fns = [], ol, f = false, | ||
testEl = doc.createElement('a'), | ||
domContentLoaded = 'DOMContentLoaded', | ||
addEventListener = 'addEventListener', | ||
onreadystatechange = 'onreadystatechange'; | ||
var doc = document, | ||
html = (doc.compatMode == 'CSS1Compat') ? | ||
doc.documentElement : | ||
doc.body, | ||
specialAttributes = /^checked|value|selected$/, | ||
stateAttributes = /^checked|selected$/, | ||
ie = /msie/.test(navigator.userAgent); | ||
/^loade|c/.test(doc.readyState) && (loaded = 1); | ||
function classReg(c) { | ||
return new RegExp("(^|\\s+)" + c + "(\\s+|$)"); | ||
function flush() { | ||
loaded = 1; | ||
for (var i = 0, l = fns.length; i < l; i++) { | ||
fns[i](); | ||
} | ||
} | ||
doc[addEventListener] && doc[addEventListener](domContentLoaded, function fn() { | ||
doc.removeEventListener(domContentLoaded, fn, f); | ||
flush(); | ||
}, f); | ||
function each(ar, fn) { | ||
for (i = 0, len = ar.length; i < len; i++) { | ||
fn(ar[i]); | ||
testEl.doScroll && doc.attachEvent(onreadystatechange, (ol = function ol() { | ||
if (/^c/.test(doc.readyState)) { | ||
doc.detachEvent(onreadystatechange, ol); | ||
flush(); | ||
} | ||
} | ||
})); | ||
function trim(s) { | ||
return s.replace(/(^\s*|\s*$)/g, ''); | ||
} | ||
var domReady = testEl.doScroll ? | ||
function (fn) { | ||
self != top ? | ||
!loaded ? | ||
fns.push(fn) : | ||
fn() : | ||
!function () { | ||
try { | ||
testEl.doScroll('left'); | ||
} catch (e) { | ||
return setTimeout(function() { | ||
domReady(fn); | ||
}, 50); | ||
} | ||
fn(); | ||
}(); | ||
} : | ||
function (fn) { | ||
loaded ? fn() : fns.push(fn); | ||
}; | ||
function camelize(s) { | ||
return s.replace(/-(.)/g, function (m, m1) { | ||
return m1.toUpperCase(); | ||
}); | ||
} | ||
(typeof module !== 'undefined') && module.exports ? | ||
(module.exports = {domReady: domReady}) : | ||
(window.domReady = domReady); | ||
function is(node) { | ||
return node && node.nodeName && node.nodeType == 1; | ||
} | ||
}(document); $.ender(module.exports); }(); | ||
/*! | ||
* bean.js - copyright @dedfat | ||
* https://github.com/fat/bean | ||
* Follow our software http://twitter.com/dedfat | ||
* MIT License | ||
* special thanks to: | ||
* dean edwards: http://dean.edwards.name/ | ||
* dperini: https://github.com/dperini/nwevents | ||
* the entire mootools team: github.com/mootools/mootools-core | ||
*/ | ||
!function (context) { | ||
var __uid = 1, registry = {}, collected = {}, | ||
overOut = /over|out/, | ||
namespace = /[^\.]*(?=\..*)\.|.*/, | ||
stripName = /\..*/, | ||
addEvent = 'addEventListener', | ||
attachEvent = 'attachEvent', | ||
removeEvent = 'removeEventListener', | ||
detachEvent = 'detachEvent', | ||
doc = context.document || {}, | ||
root = doc.documentElement || {}, | ||
W3C_MODEL = root[addEvent], | ||
eventSupport = W3C_MODEL ? addEvent : attachEvent, | ||
function some(ar, fn, scope) { | ||
for (var i = 0, j = ar.length; i < j; ++i) { | ||
if (fn.call(scope, ar[i], i, ar)) { | ||
isDescendant = function (parent, child) { | ||
var node = child.parentNode; | ||
while (node != null) { | ||
if (node == parent) { | ||
return true; | ||
} | ||
node = node.parentNode; | ||
} | ||
return false; | ||
} | ||
}, | ||
function _bonzo(elements) { | ||
this.elements = elements && Object.prototype.hasOwnProperty.call(elements, 'length') ? elements : [elements]; | ||
} | ||
retrieveUid = function (obj, uid) { | ||
return (obj.__uid = uid || obj.__uid || __uid++); | ||
}, | ||
_bonzo.prototype = { | ||
retrieveEvents = function (element) { | ||
var uid = retrieveUid(element); | ||
return (registry[uid] = registry[uid] || {}); | ||
}, | ||
each: function (fn) { | ||
for (var i = 0; i < this.elements.length; i++) { | ||
fn.call(this, this.elements[i]); | ||
listener = W3C_MODEL ? function (element, type, fn, add) { | ||
element[add ? addEvent : removeEvent](type, fn, false); | ||
} : function (element, type, fn, add, custom) { | ||
custom && add && (element['_on' + custom] = element['_on' + custom] || 0); | ||
element[add ? attachEvent : detachEvent]('on' + type, fn); | ||
}, | ||
nativeHandler = function (element, fn, args) { | ||
return function (event) { | ||
event = fixEvent(event || ((this.ownerDocument || this.document || this).parentWindow || context).event); | ||
return fn.apply(element, [event].concat(args)); | ||
}; | ||
}, | ||
customHandler = function (element, fn, type, condition, args) { | ||
return function (event) { | ||
if (condition ? condition.call(this, event) : event && event.propertyName == '_on' + type || !event) { | ||
fn.apply(element, [event].concat(args)); | ||
} | ||
return this; | ||
}, | ||
}; | ||
}, | ||
map: function (fn) { | ||
var m = []; | ||
for (var i = 0; i < this.elements.length; i++) { | ||
m.push(fn.call(this, this.elements[i])); | ||
addListener = function (element, orgType, fn, args) { | ||
var type = orgType.replace(stripName, ''), | ||
events = retrieveEvents(element), | ||
handlers = events[type] || (events[type] = {}), | ||
uid = retrieveUid(fn, orgType.replace(namespace, '')); | ||
if (handlers[uid]) { | ||
return element; | ||
} | ||
var custom = customEvents[type]; | ||
if (custom) { | ||
fn = custom.condition ? customHandler(element, fn, type, custom.condition) : fn; | ||
type = custom.base || type; | ||
} | ||
var isNative = W3C_MODEL || nativeEvents.indexOf(type) > -1; | ||
fn = isNative ? nativeHandler(element, fn, args) : customHandler(element, fn, type, false, args); | ||
if (type == 'unload') { | ||
var org = fn; | ||
fn = function () { | ||
removeListener(element, type, fn) && org(); | ||
}; | ||
} | ||
element[eventSupport] && listener(element, isNative ? type : 'propertychange', fn, true, !isNative && type); | ||
handlers[uid] = fn; | ||
fn.__uid = uid; | ||
return type == 'unload' ? element : (collected[retrieveUid(element)] = element); | ||
}, | ||
removeListener = function (element, orgType, handler) { | ||
var uid, names, uids, i, events = retrieveEvents(element), type = orgType.replace(stripName, ''); | ||
if (!events || !events[type]) { | ||
return element; | ||
} | ||
names = orgType.replace(namespace, ''); | ||
uids = names ? names.split('.') : [handler.__uid]; | ||
for (i = uids.length; i--;) { | ||
uid = uids[i]; | ||
handler = events[type][uid]; | ||
delete events[type][uid]; | ||
if (element[eventSupport]) { | ||
type = customEvents[type] ? customEvents[type].base : type; | ||
var isNative = element[addEvent] || nativeEvents.indexOf(type) > -1; | ||
listener(element, isNative ? type : 'propertychange', handler, false, !isNative && type); | ||
} | ||
return m; | ||
}, | ||
} | ||
return element; | ||
}, | ||
first: function () { | ||
return this.elements[0]; | ||
}, | ||
del = function (selector, fn, $) { | ||
return function (e) { | ||
var array = typeof selector == 'string' ? $(selector, this) : selector; | ||
for (var target = e.target; target && target != this; target = target.parentNode) { | ||
for (var i = array.length; i--;) { | ||
if (array[i] == target) { | ||
return fn.apply(target, arguments); | ||
} | ||
} | ||
} | ||
}; | ||
}, | ||
last: function () { | ||
return this.elements[this.elements.length - 1]; | ||
}, | ||
add = function (element, events, fn, delfn, $) { | ||
if (typeof events == 'object' && !fn) { | ||
for (var type in events) { | ||
events.hasOwnProperty(type) && add(element, type, events[type]); | ||
} | ||
} else { | ||
var isDel = typeof fn == 'string', types = (isDel ? fn : events).split(' '); | ||
fn = isDel ? del(events, delfn, $) : fn; | ||
for (var i = types.length; i--;) { | ||
addListener(element, types[i], fn, Array.prototype.slice.call(arguments, isDel ? 4 : 3)); | ||
} | ||
} | ||
return element; | ||
}, | ||
html: function (html) { | ||
return typeof html == 'string' ? | ||
this.each(function (el) { | ||
el.innerHTML = html; | ||
}) : | ||
this.elements[0].innerHTML; | ||
}, | ||
remove = function (element, orgEvents, fn) { | ||
var k, type, events, | ||
isString = typeof(orgEvents) == 'string', | ||
names = isString && orgEvents.replace(namespace, ''), | ||
rm = removeListener, | ||
attached = retrieveEvents(element); | ||
if (isString && /\s/.test(orgEvents)) { | ||
orgEvents = orgEvents.split(' '); | ||
var i = orgEvents.length - 1; | ||
while (remove(element, orgEvents[i]) && i--) {} | ||
return element; | ||
} | ||
events = isString ? orgEvents.replace(stripName, '') : orgEvents; | ||
if (!attached || (isString && !attached[events])) { | ||
return element; | ||
} | ||
if (typeof fn == 'function') { | ||
rm(element, events, fn); | ||
} else if (names) { | ||
rm(element, orgEvents); | ||
} else { | ||
rm = events ? rm : remove; | ||
type = isString && events; | ||
events = events ? (fn || attached[events] || events) : attached; | ||
for (k in events) { | ||
events.hasOwnProperty(k) && rm(element, type || k, events[k]); | ||
} | ||
} | ||
return element; | ||
}, | ||
addClass: function (c) { | ||
return this.each(function (el) { | ||
this.hasClass(el, c) || (el.className = trim(el.className + ' ' + c)); | ||
}); | ||
}, | ||
fire = function (element, type) { | ||
var evt, k, i, types = type.split(' '); | ||
for (i = types.length; i--;) { | ||
type = types[i].replace(stripName, ''); | ||
var isNative = nativeEvents.indexOf(type) > -1, | ||
isNamespace = types[i].replace(namespace, ''), | ||
handlers = retrieveEvents(element)[type]; | ||
if (isNamespace) { | ||
isNamespace = isNamespace.split('.'); | ||
for (k = isNamespace.length; k--;) { | ||
handlers[isNamespace[k]] && handlers[isNamespace[k]](); | ||
} | ||
} else if (element[eventSupport]) { | ||
fireListener(isNative, type, element); | ||
} else { | ||
for (k in handlers) { | ||
handlers.hasOwnProperty(k) && handlers[k](); | ||
} | ||
} | ||
} | ||
return element; | ||
}, | ||
removeClass: function (c) { | ||
return this.each(function (el) { | ||
this.hasClass(el, c) && (el.className = trim(el.className.replace(classReg(c), ' '))); | ||
}); | ||
}, | ||
fireListener = W3C_MODEL ? function (isNative, type, element) { | ||
evt = document.createEvent(isNative ? "HTMLEvents" : "UIEvents"); | ||
evt[isNative ? 'initEvent' : 'initUIEvent'](type, true, true, context, 1); | ||
element.dispatchEvent(evt); | ||
} : function (isNative, type, element) { | ||
isNative ? element.fireEvent('on' + type, document.createEventObject()) : element['_on' + type]++; | ||
}, | ||
hasClass: function (el, c) { | ||
return typeof c == 'undefined' ? | ||
some(this.elements, function (i) { | ||
return classReg(el).test(i.className); | ||
}) : | ||
classReg(c).test(el.className); | ||
}, | ||
clone = function (element, from, type) { | ||
var events = retrieveEvents(from), obj, k; | ||
obj = type ? events[type] : events; | ||
for (k in obj) { | ||
obj.hasOwnProperty(k) && (type ? add : clone)(element, type || from, type ? obj[k] : k); | ||
} | ||
return element; | ||
}, | ||
show: function (elements) { | ||
return this.each(function (el) { | ||
el.style.display = ''; | ||
}); | ||
}, | ||
fixEvent = function (e) { | ||
var result = {}; | ||
if (!e) { | ||
return result; | ||
} | ||
var type = e.type, target = e.target || e.srcElement; | ||
result.preventDefault = fixEvent.preventDefault(e); | ||
result.stopPropagation = fixEvent.stopPropagation(e); | ||
result.target = target && target.nodeType == 3 ? target.parentNode : target; | ||
if (type.indexOf('key') != -1) { | ||
result.keyCode = e.which || e.keyCode; | ||
} else if ((/click|mouse|menu/i).test(type)) { | ||
result.rightClick = e.which == 3 || e.button == 2; | ||
result.pos = { x: 0, y: 0 }; | ||
if (e.pageX || e.pageY) { | ||
result.clientX = e.pageX; | ||
result.clientY = e.pageY; | ||
} else if (e.clientX || e.clientY) { | ||
result.clientX = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft; | ||
result.clientY = e.clientY + document.body.scrollTop + document.documentElement.scrollTop; | ||
} | ||
overOut.test(type) && (result.relatedTarget = e.relatedTarget || e[(type == 'mouseover' ? 'from' : 'to') + 'Element']); | ||
} | ||
for (var k in e) { | ||
if (!(k in result)) { | ||
result[k] = e[k]; | ||
} | ||
} | ||
return result; | ||
}; | ||
hide: function (elements) { | ||
return this.each(function (el) { | ||
el.style.display = 'none'; | ||
}); | ||
}, | ||
fixEvent.preventDefault = function (e) { | ||
return function () { | ||
if (e.preventDefault) { | ||
e.preventDefault(); | ||
} | ||
else { | ||
e.returnValue = false; | ||
} | ||
}; | ||
}; | ||
create: function (node) { | ||
return typeof node == 'string' ? | ||
function () { | ||
var el = doc.createElement('div'), els = []; | ||
el.innerHTML = node; | ||
var nodes = el.childNodes; | ||
el = el.firstChild; | ||
els.push(el); | ||
while (el = el.nextSibling) { | ||
(el.nodeType == 1) && els.push(el); | ||
} | ||
return els; | ||
fixEvent.stopPropagation = function (e) { | ||
return function () { | ||
if (e.stopPropagation) { | ||
e.stopPropagation(); | ||
} else { | ||
e.cancelBubble = true; | ||
} | ||
}; | ||
}; | ||
}() : is(node) ? [node.cloneNode(true)] : []; | ||
}, | ||
var nativeEvents = 'click,dblclick,mouseup,mousedown,contextmenu,' + //mouse buttons | ||
'mousewheel,DOMMouseScroll,' + //mouse wheel | ||
'mouseover,mouseout,mousemove,selectstart,selectend,' + //mouse movement | ||
'keydown,keypress,keyup,' + //keyboard | ||
'orientationchange,' + // mobile | ||
'touchstart,touchmove,touchend,touchcancel,' + // touch | ||
'gesturestart,gesturechange,gestureend,' + // gesture | ||
'focus,blur,change,reset,select,submit,' + //form elements | ||
'load,unload,beforeunload,resize,move,DOMContentLoaded,readystatechange,' + //window | ||
'error,abort,scroll'.split(','); //misc | ||
append: function (node) { | ||
return this.each(function (el) { | ||
each(this.create(node), function (i) { | ||
el.appendChild(i); | ||
}); | ||
}); | ||
}, | ||
function check(event) { | ||
var related = event.relatedTarget; | ||
if (!related) { | ||
return related == null; | ||
} | ||
return (related != this && related.prefix != 'xul' && !/document/.test(this.toString()) && !isDescendant(this, related)); | ||
} | ||
prepend: function (node) { | ||
return this.each(function (el) { | ||
var first = el.firstChild; | ||
each(this.create(node), function (i) { | ||
el.insertBefore(i, first); | ||
}); | ||
}); | ||
}, | ||
var customEvents = { | ||
mouseenter: { base: 'mouseover', condition: check }, | ||
mouseleave: { base: 'mouseout', condition: check }, | ||
mousewheel: { base: /Firefox/.test(navigator.userAgent) ? 'DOMMouseScroll' : 'mousewheel' } | ||
}; | ||
before: function (node) { | ||
return this.each(function (el) { | ||
each(this.create(node), function (i) { | ||
el.parentNode.insertBefore(i, el); | ||
}); | ||
}); | ||
}, | ||
var bean = { add: add, remove: remove, clone: clone, fire: fire }; | ||
after: function (node) { | ||
return this.each(function (el) { | ||
each(this.create(node), function (i) { | ||
el.parentNode.insertBefore(i, el.nextSibling); | ||
}); | ||
}); | ||
}, | ||
var clean = function (el) { | ||
var uid = remove(el).__uid; | ||
if (uid) { | ||
delete collected[uid]; | ||
delete registry[uid]; | ||
} | ||
}; | ||
css: function (o, v) { | ||
var fn = typeof o == 'string' ? | ||
function (el) { | ||
el.style[camelize(o)] = v; | ||
} : | ||
function (el) { | ||
for (var k in o) { | ||
o.hasOwnProperty(k) && (el.style[camelize(k)] = o[k]); | ||
} | ||
}; | ||
return this.each(fn); | ||
}, | ||
offset: function () { | ||
var el = this.first(); | ||
var width = el.offsetWidth; | ||
var height = el.offsetHeight; | ||
var top = el.offsetTop; | ||
var left = el.offsetLeft; | ||
while (el = el.offsetParent) { | ||
top = top + el.offsetTop; | ||
left = left + el.offsetLeft; | ||
if (context[attachEvent]) { | ||
add(context, 'unload', function () { | ||
for (var k in collected) { | ||
collected.hasOwnProperty(k) && clean(collected[k]); | ||
} | ||
context.CollectGarbage && CollectGarbage(); | ||
}); | ||
} | ||
return { | ||
top: top, | ||
left: left, | ||
height: height, | ||
width: width | ||
}; | ||
}, | ||
var oldBean = context.bean; | ||
bean.noConflict = function () { | ||
context.bean = oldBean; | ||
return this; | ||
}; | ||
attr: function (k, v) { | ||
var el = this.first(); | ||
return typeof v == 'undefined' ? | ||
specialAttributes.test(k) ? | ||
stateAttributes.test(k) && typeof el[k] == 'string' ? | ||
true : el[k] : el.getAttribute(k) : | ||
this.each(function (el) { | ||
el.setAttribute(k, v); | ||
}); | ||
}, | ||
(typeof module !== 'undefined' && module.exports) ? | ||
(module.exports = bean) : | ||
(context.bean = bean); | ||
remove: function () { | ||
return this.each(function (el) { | ||
el.parentNode.removeChild(el); | ||
}); | ||
}, | ||
}(this);!function () { | ||
var b = bean.noConflict(), | ||
integrate = function (method, type, method2) { | ||
var _args = type ? [type] : []; | ||
return function () { | ||
for (var args, i = 0, l = this.elements.length; i < l; i++) { | ||
args = [this.elements[i]].concat(_args, Array.prototype.slice.call(arguments, 0)); | ||
args.length == 4 && args.push($); | ||
!arguments.length && method == 'add' && type && (method = 'fire'); | ||
b[method].apply(this, args); | ||
} | ||
return this; | ||
}; | ||
}; | ||
empty: function () { | ||
return this.each(function (el) { | ||
while (el.firstChild) { | ||
el.removeChild(el.firstChild); | ||
} | ||
}); | ||
}, | ||
var add = integrate('add'), | ||
remove = integrate('remove'), | ||
fire = integrate('fire'); | ||
detach: function () { | ||
return this.map(function (el) { | ||
return el.parentNode.removeChild(el); | ||
}); | ||
}, | ||
var methods = { | ||
scrollTop: function (y) { | ||
return scroll.call(this, null, y, 'y'); | ||
}, | ||
on: add, | ||
addListener: add, | ||
bind: add, | ||
listen: add, | ||
delegate: add, | ||
scrollLeft: function (x) { | ||
return scroll.call(this, x, null, 'x'); | ||
} | ||
unbind: remove, | ||
unlisten: remove, | ||
removeListener: remove, | ||
undelegate: remove, | ||
}; | ||
emit: fire, | ||
trigger: fire, | ||
function scroll(x, y, type) { | ||
var el = this.first(); | ||
if (x == null && y == null) { | ||
return (isBody(el) ? getWindowScroll() : { x: el.scrollLeft, y: el.scrollTop })[type]; | ||
} | ||
if (isBody(el)) { | ||
window.scrollTo(x, y); | ||
} else { | ||
x != null && (el.scrollLeft = x); | ||
y != null && (el.scrollTop = y); | ||
} | ||
return this; | ||
} | ||
cloneEvents: integrate('clone'), | ||
function isBody(element) { | ||
return element === window || (/^(?:body|html)$/i).test(element.tagName); | ||
} | ||
function getWindowScroll() { | ||
return { x: window.pageXOffset || html.scrollLeft, y: window.pageYOffset || html.scrollTop }; | ||
} | ||
function bonzo(els) { | ||
return new _bonzo(els); | ||
} | ||
bonzo.aug = function (o, target) { | ||
for (var k in o) { | ||
o.hasOwnProperty(k) && ((target || _bonzo.prototype)[k] = o[k]); | ||
hover: function (enter, leave) { | ||
for (var i = 0, l = this.elements.length; i < l; i++) { | ||
b.add.call(this, this.elements[i], 'mouseenter', enter); | ||
b.add.call(this, this.elements[i], 'mouseleave', leave); | ||
} | ||
return this; | ||
} | ||
}; | ||
bonzo.doc = function () { | ||
var w = html.scrollWidth, | ||
h = html.scrollHeight, | ||
vp = this.viewport(); | ||
return { | ||
width: Math.max(w, vp.width), | ||
height: Math.max(h, vp.height) | ||
}; | ||
}; | ||
var shortcuts = [ | ||
'blur', 'change', 'click', 'dbltclick', 'error', 'focus', 'focusin', | ||
'focusout', 'keydown', 'keypress', 'keyup', 'load', 'mousedown', | ||
'mouseenter', 'mouseleave', 'mouseout', 'mouseover', 'mouseup', | ||
'resize', 'scroll', 'select', 'submit', 'unload' | ||
]; | ||
bonzo.viewport = function () { | ||
var h = self.innerHeight, | ||
w = self.innerWidth; | ||
ie && (h = html.clientHeight) && (w = html.clientWidth); | ||
return { | ||
width: w, | ||
height: h | ||
}; | ||
}; | ||
for (var i = shortcuts.length; i--;) { | ||
var shortcut = shortcuts[i]; | ||
methods[shortcut] = integrate('add', shortcut); | ||
} | ||
bonzo.contains = 'compareDocumentPosition' in html ? | ||
function (container, element) { | ||
return (container.compareDocumentPosition(element) & 16) == 16; | ||
} : 'contains' in html ? | ||
function (container, element) { | ||
return container !== element && container.contains(element); | ||
} : | ||
function (container, element) { | ||
while (element = element.parentNode) { | ||
if (element === container) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
}; | ||
var old = context.bonzo; | ||
bonzo.noConflict = function () { | ||
context.bonzo = old; | ||
return this; | ||
}; | ||
context.bonzo = bonzo; | ||
}(this);/*! | ||
$.ender(methods, true); | ||
}(); | ||
/*! | ||
* qwery.js - copyright @dedfat | ||
@@ -529,3 +647,10 @@ * https://github.com/ded/qwery | ||
function boilerPlate(selector, root) { | ||
function boilerPlate(selector, _root, fn) { | ||
var root = (typeof _root == 'string') ? fn(_root)[0] : (_root || doc); | ||
if (isNode(selector)) { | ||
return !_root || (isNode(root) && isAncestor(selector, root)) ? [selector] : []; | ||
} | ||
if (selector && typeof selector === 'object' && selector.length && isFinite(selector.length)) { | ||
return array(selector); | ||
} | ||
if (m = selector.match(idOnly)) { | ||
@@ -546,9 +671,6 @@ return (el = doc.getElementById(m[1])) ? [el] : []; | ||
var root = (typeof _root == 'string') ? qsa(_root)[0] : (_root || doc); | ||
if (isNode(selector)) { | ||
return !_root || isAncestor(selector, root) ? [selector] : []; | ||
} | ||
if (!root) { | ||
return []; | ||
} | ||
if (m = boilerPlate(selector, root)) { | ||
if (m = boilerPlate(selector, _root, qsa)) { | ||
return m; | ||
@@ -583,5 +705,2 @@ } | ||
var root = (typeof _root == 'string') ? qwery(_root)[0] : (_root || doc); | ||
if (isNode(selector)) { | ||
return !_root || isAncestor(selector, root) ? [selector] : []; | ||
} | ||
if (!root) { | ||
@@ -591,3 +710,3 @@ return []; | ||
var i, l, result = [], collections = [], element; | ||
if (m = boilerPlate(selector, root)) { | ||
if (m = boilerPlate(selector, _root, qwery)) { | ||
return m; | ||
@@ -621,3 +740,3 @@ } | ||
// being nice | ||
qwery.uniq = uniq; | ||
var oldQwery = context.qwery; | ||
@@ -631,161 +750,17 @@ qwery.noConflict = function () { | ||
}(this, document); | ||
/*! | ||
* $script.js v1.3 | ||
* https://github.com/ded/script.js | ||
* Copyright: @ded & @fat - Dustin Diaz, Jacob Thornton 2011 | ||
* Follow our software http://twitter.com/dedfat | ||
* License: MIT | ||
*/ | ||
/*! | ||
* $script.js v1.3 | ||
* https://github.com/ded/script.js | ||
* Copyright: @ded & @fat - Dustin Diaz, Jacob Thornton 2011 | ||
* Follow our software http://twitter.com/dedfat | ||
* License: MIT | ||
*/ | ||
!function(win, doc, timeout) { | ||
var script = doc.getElementsByTagName("script")[0], | ||
list = {}, ids = {}, delay = {}, re = /^i|c/, loaded = 0, fns = [], ol, | ||
scripts = {}, s = 'string', f = false, i, testEl = doc.createElement('a'), | ||
push = 'push', domContentLoaded = 'DOMContentLoaded', readyState = 'readyState', | ||
addEventListener = 'addEventListener', onreadystatechange = 'onreadystatechange', | ||
every = function(ar, fn) { | ||
for (i = 0, j = ar.length; i < j; ++i) { | ||
if (!fn(ar[i])) { | ||
return 0; | ||
} | ||
!function () { | ||
var q = qwery.noConflict(); | ||
$._select = q; | ||
$.ender({ | ||
find: function (s) { | ||
var r = [], i, l, j, k, els; | ||
for (i = 0, l = this.length; i < l; i++) { | ||
els = q(s, this[i]); | ||
for (j = 0, k = els.length; j < k; j++) { | ||
r.push(els[j]); | ||
} | ||
return 1; | ||
}; | ||
function each(ar, fn) { | ||
every(ar, function(el) { | ||
return !fn(el); | ||
}); | ||
} | ||
if (!doc[readyState] && doc[addEventListener]) { | ||
doc[addEventListener](domContentLoaded, function fn() { | ||
doc.removeEventListener(domContentLoaded, fn, f); | ||
doc[readyState] = "complete"; | ||
}, f); | ||
doc[readyState] = "loading"; | ||
} | ||
var $script = function(paths, idOrDone, optDone) { | ||
paths = paths[push] ? paths : [paths]; | ||
var idOrDoneIsDone = idOrDone && idOrDone.call, | ||
done = idOrDoneIsDone ? idOrDone : optDone, | ||
id = idOrDoneIsDone ? paths.join('') : idOrDone, | ||
queue = paths.length; | ||
function loopFn(item) { | ||
return item.call ? item() : list[item]; | ||
} | ||
function callback() { | ||
if (!--queue) { | ||
list[id] = 1; | ||
done && done(); | ||
for (var dset in delay) { | ||
every(dset.split('|'), loopFn) && !each(delay[dset], loopFn) && (delay[dset] = []); | ||
} | ||
} | ||
} | ||
if (id && ids[id]) { | ||
return; | ||
return $(q.uniq(r)); | ||
} | ||
timeout(function() { | ||
each(paths, function(path) { | ||
if (scripts[path]) { | ||
return; | ||
} | ||
scripts[path] = 1; | ||
id && (ids[id] = 1); | ||
var el = doc.createElement("script"), | ||
loaded = 0; | ||
el.onload = el[onreadystatechange] = function () { | ||
if ((el[readyState] && !(!re.test(el[readyState]))) || loaded) { | ||
return; | ||
} | ||
el.onload = el[onreadystatechange] = null; | ||
loaded = 1; | ||
callback(); | ||
}; | ||
el.async = 1; | ||
el.src = path; | ||
script.parentNode.insertBefore(el, script); | ||
}); | ||
}, 0); | ||
return $script; | ||
}; | ||
$script.ready = function(deps, ready, req) { | ||
deps = deps[push] ? deps : [deps]; | ||
var missing = []; | ||
!each(deps, function(dep) { | ||
list[dep] || missing[push](dep); | ||
}) && every(deps, function(dep) { | ||
return list[dep]; | ||
}) ? ready() : !function(key) { | ||
delay[key] = delay[key] || []; | ||
delay[key][push](ready); | ||
req && req(missing); | ||
}(deps.join('|')); | ||
return $script; | ||
}; | ||
function again(fn) { | ||
timeout(function() { | ||
domReady(fn); | ||
}, 50); | ||
} | ||
testEl.doScroll && doc.attachEvent(onreadystatechange, (ol = function ol() { | ||
/^c/.test(doc[readyState]) && | ||
(loaded = 1) && | ||
!doc.detachEvent(onreadystatechange, ol) && | ||
each(fns, function (f) { | ||
f(); | ||
}); | ||
})); | ||
var domReady = testEl.doScroll ? | ||
function (fn) { | ||
self != top ? | ||
!loaded ? | ||
fns[push](fn) : | ||
fn() : | ||
!function () { | ||
try { | ||
testEl.doScroll('left'); | ||
} catch (e) { | ||
return again(fn); | ||
} | ||
fn(); | ||
}(); | ||
} : | ||
function (fn) { | ||
re.test(doc[readyState]) ? fn() : again(fn); | ||
}; | ||
$script.domReady = domReady; | ||
var old = win.$script; | ||
$script.noConflict = function () { | ||
win.$script = old; | ||
return this; | ||
}; | ||
(typeof module !== 'undefined' && module.exports) ? | ||
(module.exports = $script) : | ||
(win.$script = $script); | ||
}(this, document, setTimeout);$.ender(bonzo); | ||
$.ender(bonzo(), true); | ||
bonzo.noConflict();$._select = qwery.noConflict();!function () { | ||
var s = $script.noConflict(); | ||
$.ender({ | ||
script: s, | ||
domReady: s.domReady | ||
}); | ||
}, true); | ||
}(); |
{ | ||
"name": "bean", | ||
"description": "an events api for javascript", | ||
"version": "0.0.8", | ||
"version": "0.0.9", | ||
"homepage": "https://github.com/fat/bean", | ||
@@ -6,0 +6,0 @@ "authors": ["Jacob Thornton <@fat>"], |
@@ -6,4 +6,4 @@ !function () { | ||
return function () { | ||
for (var args, i = 0, l = this.elements.length; i < l; i++) { | ||
args = [this.elements[i]].concat(_args, Array.prototype.slice.call(arguments, 0)); | ||
for (var args, i = 0, l = this.length; i < l; i++) { | ||
args = [this[i]].concat(_args, Array.prototype.slice.call(arguments, 0)); | ||
args.length == 4 && args.push($); | ||
@@ -40,5 +40,5 @@ !arguments.length && method == 'add' && type && (method = 'fire'); | ||
hover: function (enter, leave) { | ||
for (var i = 0, l = this.elements.length; i < l; i++) { | ||
b.add.call(this, this.elements[i], 'mouseenter', enter); | ||
b.add.call(this, this.elements[i], 'mouseleave', leave); | ||
for (var i = 0, l = this.length; i < l; i++) { | ||
b.add.call(this, this[i], 'mouseenter', enter); | ||
b.add.call(this, this[i], 'mouseleave', leave); | ||
} | ||
@@ -45,0 +45,0 @@ return this; |
@@ -10,5 +10,5 @@ (function(){ | ||
// this is for opera, so we don't have to focus to type how we think we would | ||
if(document.activeElement | ||
&& document.activeElement != el | ||
&& el.selectionStart == el.selectionEnd | ||
if(document.activeElement | ||
&& document.activeElement != el | ||
&& el.selectionStart == el.selectionEnd | ||
&& el.selectionStart == 0){ | ||
@@ -21,4 +21,4 @@ return {start: el.value.length, end: el.value.length}; | ||
//if(document.activeElement && document.activeElement != el){ | ||
//} | ||
@@ -30,3 +30,3 @@ try { | ||
r.setEndPoint("EndToStart", real); | ||
var start = r.text.length | ||
@@ -64,3 +64,3 @@ return { | ||
} | ||
} | ||
} | ||
}, | ||
@@ -74,3 +74,3 @@ // gets all focusable elements | ||
len = els.length; | ||
for(var i=0; i< len; i++){ | ||
@@ -80,4 +80,4 @@ Syn.isFocusable(els[i]) && els[i] != document.documentElement && res.push(els[i]) | ||
return res; | ||
}; | ||
@@ -95,8 +95,8 @@ | ||
* Syn('key','delete','title'); | ||
* | ||
* //or | ||
* | ||
* | ||
* //or | ||
* | ||
* Syn('type','One Two Three[left][left][delete]','title') | ||
* @codeend | ||
* | ||
* | ||
* The following are a list of keys you can type: | ||
@@ -133,12 +133,12 @@ * @codestart text | ||
'\b':'8', | ||
//tab | ||
'\t':'9', | ||
//enter | ||
'\r':'13', | ||
//special | ||
'shift':'16','ctrl':'17','alt':'18', | ||
//weird | ||
@@ -151,7 +151,7 @@ 'pause-break':'19', | ||
'print' : '44', | ||
//navigation | ||
'page-up':'33','page-down':'34','end':'35','home':'36', | ||
'left':'37','up':'38','right':'39','down':'40','insert':'45','delete':'46', | ||
//normal characters | ||
@@ -178,14 +178,14 @@ ' ':'32', | ||
"'":'222', | ||
//ignore these, you shouldn't use them | ||
'left window key':'91','right window key':'92','select key':'93', | ||
'f1':'112','f2':'113','f3':'114','f4':'115','f5':'116','f6':'117', | ||
'f7':'118','f8':'119','f9':'120','f10':'121','f11':'122','f12':'123' | ||
}, | ||
// what we can type in | ||
typeable : /input|textarea/i, | ||
// selects text on an element | ||
@@ -207,5 +207,5 @@ selectText: function( el, start, end ) { | ||
r.moveEnd('character', end - el.value.length); | ||
r.select(); | ||
} | ||
} | ||
}, | ||
@@ -247,3 +247,3 @@ getText: function( el ) { | ||
}, | ||
//returns the special key if special | ||
@@ -266,3 +266,3 @@ isSpecial: function( keyCode ) { | ||
var keyData = Syn.key.data(key); | ||
if(!keyData[event]){ | ||
@@ -272,7 +272,7 @@ //we shouldn't be creating this event | ||
} | ||
var charCode = keyData[event][0], | ||
keyCode = keyData[event][1], | ||
result = {}; | ||
if(keyCode == 'key'){ | ||
@@ -285,3 +285,3 @@ result.keyCode = Syn.keycodes[key] | ||
} | ||
if(charCode == 'char'){ | ||
@@ -292,4 +292,4 @@ result.charCode = key.charCodeAt(0) | ||
} | ||
return result | ||
@@ -323,3 +323,3 @@ }, | ||
} | ||
if(force || (!S.support.keyCharacters && Syn.typeable.test(this.nodeName))){ | ||
@@ -330,4 +330,4 @@ var current = this.value, | ||
character = key; | ||
console.log("setting",this.value,before, character, after) | ||
this.value = before+character+after; | ||
@@ -337,3 +337,3 @@ //handle IE inserting \r\n | ||
Syn.selectText(this, before.length + charLength) | ||
} | ||
} | ||
}, | ||
@@ -402,3 +402,3 @@ 'c' : function( options, scope, key, force, sel ) { | ||
after = current.substr(sel.end); | ||
if(sel.start == sel.end && sel.start > 0){ | ||
@@ -412,5 +412,5 @@ //remove a character | ||
} | ||
//set back the selection | ||
} | ||
} | ||
}, | ||
@@ -426,9 +426,9 @@ 'delete' : function( options, scope, key, force, sel ) { | ||
this.value = before+after; | ||
} | ||
Syn.selectText(this, sel.start) | ||
} | ||
} | ||
}, | ||
'\r' : function( options, scope, key, force, sel ) { | ||
var nodeName = this.nodeName.toLowerCase() | ||
@@ -441,3 +441,3 @@ // submit a form | ||
} | ||
} | ||
@@ -453,10 +453,10 @@ //newline in textarea | ||
}, | ||
// | ||
// | ||
// Gets all focusable elements. If the element (this) | ||
// doesn't have a tabindex, finds the next element after. | ||
// If the element (this) has a tabindex finds the element | ||
// If the element (this) has a tabindex finds the element | ||
// with the next higher tabindex OR the element with the same | ||
// tabindex after it in the document. | ||
// @return the next element | ||
// | ||
// | ||
'\t' : function( options, scope ) { | ||
@@ -474,3 +474,3 @@ // focusable elements | ||
i = 0, | ||
el, | ||
el, | ||
//the tabindex of the tabable element we are looking at | ||
@@ -517,6 +517,6 @@ elIndex, | ||
} | ||
} | ||
} | ||
//restart if we didn't find anything | ||
@@ -545,7 +545,7 @@ if(!current){ | ||
} | ||
} | ||
} | ||
}, | ||
'up' : function() { | ||
if(/select/i.test(this.nodeName)){ | ||
this.selectedIndex = this.selectedIndex ? this.selectedIndex-1 : 0; | ||
@@ -601,3 +601,3 @@ //set this to change on blur? | ||
} : options; | ||
//don't change the orignial | ||
@@ -609,3 +609,3 @@ options = h.extend({}, options) | ||
} | ||
options = h.extend({ | ||
@@ -617,3 +617,3 @@ ctrlKey: !!Syn.key.ctrlKey, | ||
}, options) | ||
return options; | ||
@@ -626,8 +626,8 @@ }, | ||
var event; | ||
try { | ||
event = element.ownerDocument.createEvent("KeyEvents"); | ||
event.initKeyEvent(type, true, true, window, options.ctrlKey, options.altKey, options.shiftKey, options.metaKey, options.keyCode, options.charCode); | ||
} | ||
} | ||
catch (e) { | ||
@@ -642,3 +642,3 @@ event = h.createBasicStandardEvent(type, options, doc); | ||
h.extend(event, options) | ||
return event; | ||
@@ -665,5 +665,5 @@ } | ||
* Types a single key. The key should be | ||
* a string that matches a | ||
* a string that matches a | ||
* [Syn.static.keycodes]. | ||
* | ||
* | ||
* The following sends a carridge return | ||
@@ -683,3 +683,3 @@ * to the 'name' element. | ||
//first check if it is a special up | ||
if(/-up$/.test(options) | ||
if(/-up$/.test(options) | ||
&& h.inArray(options.replace("-up",""),Syn.key.kinds.special )!= -1){ | ||
@@ -690,4 +690,4 @@ Syn.trigger('keyup',options.replace("-up",""), element ) | ||
} | ||
var caret = Syn.typeable.test(element.nodeName) && getSelection(element), | ||
@@ -697,16 +697,16 @@ key = convert[options] || options, | ||
runDefaults = Syn.trigger('keydown',key, element ), | ||
// a function that gets the default behavior for a key | ||
getDefault = Syn.key.getDefault, | ||
// how this browser handles preventing default events | ||
prevent = Syn.key.browser.prevent, | ||
// the result of the default event | ||
defaultResult, | ||
// options for keypress | ||
keypressOptions = Syn.key.options(key, 'keypress') | ||
if(runDefaults){ | ||
@@ -732,3 +732,3 @@ //if the browser doesn't create keypresses for this key, run default | ||
} | ||
if(defaultResult !== null){ | ||
@@ -742,10 +742,10 @@ setTimeout(function(){ | ||
} | ||
//do mouseup | ||
return element; | ||
// is there a keypress? .. if not , run default | ||
// yes -> did we prevent it?, if not run ... | ||
}, | ||
@@ -758,3 +758,3 @@ /** | ||
* enclosed in square brackents. | ||
* | ||
* | ||
* The following types 'JavaScript MVC' then deletes the space. | ||
@@ -764,5 +764,5 @@ * @codestart | ||
* @codeend | ||
* | ||
* Type is able to handle (and move with) tabs (\t). | ||
* The following simulates tabing and entering values in a form and | ||
* | ||
* Type is able to handle (and move with) tabs (\t). | ||
* The following simulates tabing and entering values in a form and | ||
* eventually submitting the form. | ||
@@ -793,5 +793,5 @@ * @codestart | ||
} | ||
runNextPart(); | ||
} | ||
@@ -808,7 +808,7 @@ }); | ||
var div = document.createElement("div"), | ||
checkbox, | ||
submit, | ||
form, | ||
input, | ||
var div = document.createElement("div"), | ||
checkbox, | ||
submit, | ||
form, | ||
input, | ||
submitted = false, | ||
@@ -818,3 +818,3 @@ anchor, | ||
inputter; | ||
div.innerHTML = "<form id='outer'>"+ | ||
@@ -830,3 +830,3 @@ "<input name='checkbox' type='checkbox'/>"+ | ||
"</form>"; | ||
document.documentElement.appendChild(div); | ||
@@ -839,5 +839,5 @@ form = div.firstChild; | ||
inputter = form.childNodes[3]; | ||
form.onsubmit = function(ev){ | ||
if (ev.preventDefault) | ||
if (ev.preventDefault) | ||
ev.preventDefault(); | ||
@@ -851,14 +851,14 @@ S.support.keypressSubmits = true; | ||
Syn.trigger("keypress", "\r", inputter); | ||
Syn.trigger("keypress", "a", inputter); | ||
S.support.keyCharacters = inputter.value == "a"; | ||
inputter.value = "a"; | ||
Syn.trigger("keypress", "\b", inputter); | ||
S.support.backspaceWorks = inputter.value == ""; | ||
inputter.onchange = function(){ | ||
@@ -870,9 +870,9 @@ S.support.focusChanges = true; | ||
form.childNodes[5].focus(); // this will throw a change event | ||
Syn.trigger("keypress", "b", inputter); | ||
S.support.keysOnNotFocused = inputter.value == "ab"; | ||
S.support.keysOnNotFocused = inputter.value == "ab"; | ||
//test keypress \r on anchor submits | ||
S.bind(anchor,"click",function(ev){ | ||
if (ev.preventDefault) | ||
if (ev.preventDefault) | ||
ev.preventDefault(); | ||
@@ -884,8 +884,8 @@ S.support.keypressOnAnchorClicks = true; | ||
Syn.trigger("keypress", "\r", anchor); | ||
S.support.textareaCarriage = textarea.value.length == 4 | ||
document.documentElement.removeChild(div); | ||
S.support.ready++; | ||
})(); | ||
}()) |
644626
2.1%106
0.95%17608
-0.03%