[Pkg-javascript-commits] [SCM] mootools branch, master, updated. upstream/1.4.0-27-gb1b1168
Marcelo Jorge Vieira
metal at alucinados.com
Wed Sep 14 21:50:08 UTC 2011
The following commit has been merged in the master branch:
commit 3dad5ef31365f96e94e8efb8dac3da8bac7e9d34
Author: Marcelo Jorge Vieira <metal at alucinados.com>
Date: Tue Sep 13 00:13:58 2011 -0300
Imported Upstream version 1.4.0
diff --git a/mootools-core/mootools-core-nc.js b/mootools-core/mootools-core-nc.js
index ba62ffc..6f28856 100644
--- a/mootools-core/mootools-core-nc.js
+++ b/mootools-core/mootools-core-nc.js
@@ -3,10 +3,10 @@
MooTools: the javascript framework
web build:
- - http://mootools.net/core/7c56cfef9dddcf170a5d68e3fb61cfd7
+ - http://mootools.net/core/76bf47062d6c1983d66ce47ad66aa0e0
packager build:
- - packager build Core/Core Core/Array Core/String Core/Number Core/Function Core/Object Core/Event Core/Browser Core/Class Core/Class.Extras Core/Slick.Parser Core/Slick.Finder Core/Element Core/Element.Style Core/Element.Event Core/Element.Dimensions Core/Fx Core/Fx.CSS Core/Fx.Tween Core/Fx.Morph Core/Fx.Transitions Core/Request Core/Request.HTML Core/Request.JSON Core/Cookie Core/JSON Core/DOMReady Core/Swiff
+ - packager build Core/Core Core/Array Core/String Core/Number Core/Function Core/Object Core/Event Core/Browser Core/Class Core/Class.Extras Core/Slick.Parser Core/Slick.Finder Core/Element Core/Element.Style Core/Element.Event Core/Element.Delegation Core/Element.Dimensions Core/Fx Core/Fx.CSS Core/Fx.Tween Core/Fx.Morph Core/Fx.Transitions Core/Request Core/Request.HTML Core/Request.JSON Core/Cookie Core/JSON Core/DOMReady Core/Swiff
/*
---
@@ -33,8 +33,8 @@ provides: [Core, MooTools, Type, typeOf, instanceOf, Native]
(function(){
this.MooTools = {
- version: '1.3.2',
- build: 'c9f1ff10e9e7facb65e9481049ed1b450959d587'
+ version: '1.4.0',
+ build: 'a15e35b4dbd12e8d86d9b50aa67a27e8e0071ea3'
};
// typeOf, instanceOf
@@ -205,7 +205,7 @@ var implement = function(name, method){
if (typeOf(hook) == 'type') implement.call(hook, name, method);
else hook.call(this, name, method);
}
-
+
var previous = this.prototype[name];
if (previous == null || !previous.$protected) this.prototype[name] = method;
@@ -267,7 +267,7 @@ var force = function(name, object, methods){
force('String', String, [
'charAt', 'charCodeAt', 'concat', 'indexOf', 'lastIndexOf', 'match', 'quote', 'replace', 'search',
- 'slice', 'split', 'substr', 'substring', 'toLowerCase', 'toUpperCase'
+ 'slice', 'split', 'substr', 'substring', 'trim', 'toLowerCase', 'toUpperCase'
])('Array', Array, [
'pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift', 'concat', 'join', 'slice',
'indexOf', 'lastIndexOf', 'filter', 'forEach', 'every', 'map', 'some', 'reduce', 'reduceRight'
@@ -541,7 +541,7 @@ Array.implement({
/*<!ES5>*/
every: function(fn, bind){
- for (var i = 0, l = this.length; i < l; i++){
+ for (var i = 0, l = this.length >>> 0; i < l; i++){
if ((i in this) && !fn.call(bind, this[i], i, this)) return false;
}
return true;
@@ -549,30 +549,30 @@ Array.implement({
filter: function(fn, bind){
var results = [];
- for (var i = 0, l = this.length; i < l; i++){
+ for (var i = 0, l = this.length >>> 0; i < l; i++){
if ((i in this) && fn.call(bind, this[i], i, this)) results.push(this[i]);
}
return results;
},
indexOf: function(item, from){
- var len = this.length;
- for (var i = (from < 0) ? Math.max(0, len + from) : from || 0; i < len; i++){
+ var length = this.length >>> 0;
+ for (var i = (from < 0) ? Math.max(0, length + from) : from || 0; i < length; i++){
if (this[i] === item) return i;
}
return -1;
},
map: function(fn, bind){
- var results = [];
- for (var i = 0, l = this.length; i < l; i++){
+ var length = this.length >>> 0, results = Array(length);
+ for (var i = 0; i < length; i++){
if (i in this) results[i] = fn.call(bind, this[i], i, this);
}
return results;
},
some: function(fn, bind){
- for (var i = 0, l = this.length; i < l; i++){
+ for (var i = 0, l = this.length >>> 0; i < l; i++){
if ((i in this) && fn.call(bind, this[i], i, this)) return true;
}
return false;
@@ -724,37 +724,37 @@ String.implement({
},
contains: function(string, separator){
- return (separator) ? (separator + this + separator).indexOf(separator + string + separator) > -1 : this.indexOf(string) > -1;
+ return (separator) ? (separator + this + separator).indexOf(separator + string + separator) > -1 : String(this).indexOf(string) > -1;
},
trim: function(){
- return this.replace(/^\s+|\s+$/g, '');
+ return String(this).replace(/^\s+|\s+$/g, '');
},
clean: function(){
- return this.replace(/\s+/g, ' ').trim();
+ return String(this).replace(/\s+/g, ' ').trim();
},
camelCase: function(){
- return this.replace(/-\D/g, function(match){
+ return String(this).replace(/-\D/g, function(match){
return match.charAt(1).toUpperCase();
});
},
hyphenate: function(){
- return this.replace(/[A-Z]/g, function(match){
+ return String(this).replace(/[A-Z]/g, function(match){
return ('-' + match.charAt(0).toLowerCase());
});
},
capitalize: function(){
- return this.replace(/\b[a-z]/g, function(match){
+ return String(this).replace(/\b[a-z]/g, function(match){
return match.toUpperCase();
});
},
escapeRegExp: function(){
- return this.replace(/([-.*+?^${}()|[\]\/\\])/g, '\\$1');
+ return String(this).replace(/([-.*+?^${}()|[\]\/\\])/g, '\\$1');
},
toInt: function(base){
@@ -766,17 +766,17 @@ String.implement({
},
hexToRgb: function(array){
- var hex = this.match(/^#?(\w{1,2})(\w{1,2})(\w{1,2})$/);
+ var hex = String(this).match(/^#?(\w{1,2})(\w{1,2})(\w{1,2})$/);
return (hex) ? hex.slice(1).hexToRgb(array) : null;
},
rgbToHex: function(array){
- var rgb = this.match(/\d{1,3}/g);
+ var rgb = String(this).match(/\d{1,3}/g);
return (rgb) ? rgb.rgbToHex(array) : null;
},
substitute: function(object, regexp){
- return this.replace(regexp || (/\\?\{([^{}]+)\}/g), function(match, name){
+ return String(this).replace(regexp || (/\\?\{([^{}]+)\}/g), function(match, name){
if (match.charAt(0) == '\\') return match.slice(1);
return (object[name] != null) ? object[name] : '';
});
@@ -874,22 +874,30 @@ Function.implement({
try {
return this.apply(bind, Array.from(args));
} catch (e){}
-
+
return null;
},
- /*<!ES5>*/
- bind: function(bind){
+ /*<!ES5-bind>*/
+ bind: function(that){
var self = this,
- args = (arguments.length > 1) ? Array.slice(arguments, 1) : null;
-
- return function(){
- if (!args && !arguments.length) return self.call(bind);
- if (args && arguments.length) return self.apply(bind, args.concat(Array.from(arguments)));
- return self.apply(bind, args || arguments);
+ args = arguments.length > 1 ? Array.slice(arguments, 1) : null,
+ F = function(){};
+
+ var bound = function(){
+ var context = that, length = arguments.length;
+ if (this instanceof bound){
+ F.prototype = self.prototype;
+ context = new F;
+ }
+ var result = (!args && !length)
+ ? self.call(context)
+ : self.apply(context, args && length ? args.concat(Array.slice(arguments)) : args || arguments);
+ return context == that ? result : context;
};
+ return bound;
},
- /*</!ES5>*/
+ /*</!ES5-bind>*/
pass: function(args, bind){
var self = this;
@@ -954,6 +962,8 @@ Function.implement({
});
+if (Object.create == Function.prototype.create) Object.create = null;
+
var $try = Function.attempt;
//</1.2compat>
@@ -1441,7 +1451,7 @@ this.$exec = Browser.exec;
name: Event
-description: Contains the Event Class, to make the event object cross-browser.
+description: Contains the Event Type, to make the event object cross-browser.
license: MIT-style license.
@@ -1452,52 +1462,54 @@ provides: Event
...
*/
-var Event = new Type('Event', function(event, win){
+(function() {
+
+var _keys = {};
+
+var DOMEvent = this.DOMEvent = new Type('DOMEvent', function(event, win){
if (!win) win = window;
- var doc = win.document;
event = event || win.event;
if (event.$extended) return event;
+ this.event = event;
this.$extended = true;
- var type = event.type,
- target = event.target || event.srcElement,
- page = {},
- client = {},
- related = null,
- rightClick, wheel, code, key;
+ this.shift = event.shiftKey;
+ this.control = event.ctrlKey;
+ this.alt = event.altKey;
+ this.meta = event.metaKey;
+ var type = this.type = event.type;
+ var target = event.target || event.srcElement;
while (target && target.nodeType == 3) target = target.parentNode;
+ this.target = document.id(target);
- if (type.indexOf('key') != -1){
- code = event.which || event.keyCode;
- key = Object.keyOf(Event.Keys, code);
+ if (type.indexOf('key') == 0){
+ var code = this.code = (event.which || event.keyCode);
+ this.key = _keys[code]/*<1.3compat>*/ || Object.keyOf(Event.Keys, code)/*</1.3compat>*/;
if (type == 'keydown'){
- var fKey = code - 111;
- if (fKey > 0 && fKey < 13) key = 'f' + fKey;
+ if (code > 111 && code < 124) this.key = 'f' + (code - 111);
+ else if (code > 95 && code < 106) this.key = code - 96;
}
- if (!key) key = String.fromCharCode(code).toLowerCase();
- } else if ((/click|mouse|menu/i).test(type)){
+ if (this.key == null) this.key = String.fromCharCode(code).toLowerCase();
+ } else if (type == 'click' || type == 'dblclick' || type == 'contextmenu' || type.indexOf('mouse') == 0){
+ var doc = win.document;
doc = (!doc.compatMode || doc.compatMode == 'CSS1Compat') ? doc.html : doc.body;
- page = {
+ this.page = {
x: (event.pageX != null) ? event.pageX : event.clientX + doc.scrollLeft,
y: (event.pageY != null) ? event.pageY : event.clientY + doc.scrollTop
};
- client = {
+ this.client = {
x: (event.pageX != null) ? event.pageX - win.pageXOffset : event.clientX,
y: (event.pageY != null) ? event.pageY - win.pageYOffset : event.clientY
};
- if ((/DOMMouseScroll|mousewheel/).test(type)){
- wheel = (event.wheelDelta) ? event.wheelDelta / 120 : -(event.detail || 0) / 3;
- }
- rightClick = (event.which == 3) || (event.button == 2);
- if ((/over|out/).test(type)){
- related = event.relatedTarget || event[(type == 'mouseover' ? 'from' : 'to') + 'Element'];
- var testRelated = function(){
- while (related && related.nodeType == 3) related = related.parentNode;
- return true;
- };
- var hasRelated = (Browser.firefox2) ? testRelated.attempt() : testRelated();
- related = (hasRelated) ? related : null;
+ if (type == 'DOMMouseScroll' || type == 'mousewheel')
+ this.wheel = (event.wheelDelta) ? event.wheelDelta / 120 : -(event.detail || 0) / 3;
+
+ this.rightClick = (event.which == 3 || event.button == 2);
+ if (type == 'mouseover' || type == 'mouseout'){
+ var related = event.relatedTarget || event[(type == 'mouseover' ? 'from' : 'to') + 'Element'];
+ while (related && related.nodeType == 3) related = related.parentNode;
+ this.relatedTarget = document.id(related);
}
- } else if ((/gesture|touch/i).test(type)){
+ } else if (type.indexOf('touch') == 0 || type.indexOf('gesture') == 0){
this.rotation = event.rotation;
this.scale = event.scale;
this.targetTouches = event.targetTouches;
@@ -1505,57 +1517,19 @@ var Event = new Type('Event', function(event, win){
var touches = this.touches = event.touches;
if (touches && touches[0]){
var touch = touches[0];
- page = {x: touch.pageX, y: touch.pageY};
- client = {x: touch.clientX, y: touch.clientY};
+ this.page = {x: touch.pageX, y: touch.pageY};
+ this.client = {x: touch.clientX, y: touch.clientY};
}
}
- return Object.append(this, {
- event: event,
- type: type,
-
- page: page,
- client: client,
- rightClick: rightClick,
-
- wheel: wheel,
-
- relatedTarget: document.id(related),
- target: document.id(target),
-
- code: code,
- key: key,
-
- shift: event.shiftKey,
- control: event.ctrlKey,
- alt: event.altKey,
- meta: event.metaKey
- });
+ if (!this.client) this.client = {};
+ if (!this.page) this.page = {};
});
-Event.Keys = {
- 'enter': 13,
- 'up': 38,
- 'down': 40,
- 'left': 37,
- 'right': 39,
- 'esc': 27,
- 'space': 32,
- 'backspace': 8,
- 'tab': 9,
- 'delete': 46
-};
-
-//<1.2compat>
-
-Event.Keys = new Hash(Event.Keys);
-
-//</1.2compat>
-
-Event.implement({
+DOMEvent.implement({
stop: function(){
- return this.stopPropagation().preventDefault();
+ return this.preventDefault().stopPropagation();
},
stopPropagation: function(){
@@ -1572,6 +1546,32 @@ Event.implement({
});
+DOMEvent.defineKey = function(code, key){
+ _keys[code] = key;
+ return this;
+};
+
+DOMEvent.defineKeys = DOMEvent.defineKey.overloadSetter(true);
+
+DOMEvent.defineKeys({
+ '38': 'up', '40': 'down', '37': 'left', '39': 'right',
+ '27': 'esc', '32': 'space', '8': 'backspace', '9': 'tab',
+ '46': 'delete', '13': 'enter'
+});
+
+})();
+
+/*<1.3compat>*/
+var Event = DOMEvent;
+Event.Keys = {};
+/*</1.3compat>*/
+
+/*<1.2compat>*/
+
+Event.Keys = new Hash(Event.Keys);
+
+/*</1.2compat>*/
+
/*
---
@@ -1766,7 +1766,7 @@ this.Events = new Class({
}, this);
return this;
},
-
+
removeEvent: function(type, fn){
type = removeOn(type);
var events = this.$events[type];
@@ -2121,7 +2121,7 @@ local.setDocument = function(document){
var selected, id = 'slick_uniqueid';
var testNode = document.createElement('div');
-
+
var testRoot = document.body || document.getElementsByTagName('body')[0] || root;
testRoot.appendChild(testNode);
@@ -2172,7 +2172,7 @@ local.setDocument = function(document){
features.brokenGEBCN = cachedGetElementsByClassName || brokenSecondClassNameGEBCN;
}
-
+
if (testNode.querySelectorAll){
// IE 8 returns closed nodes (EG:"</foo>") for querySelectorAll('*') for some documents
try {
@@ -2298,7 +2298,7 @@ var reSimpleSelector = /^([#.]?)((?:[\w-]+|\*))$/,
local.search = function(context, expression, append, first){
var found = this.found = (first) ? null : (append || []);
-
+
if (!context) return found;
else if (context.navigator) context = context.document; // Convert the node from a window to a document
else if (!context.nodeType) return found;
@@ -2604,12 +2604,12 @@ local.matchNode = function(node, selector){
return this.nativeMatchesSelector.call(node, selector.replace(/\[([^=]+)=\s*([^'"\]]+?)\s*\]/g, '[$1="$2"]'));
} catch(matchError) {}
}
-
+
var parsed = this.Slick.parse(selector);
if (!parsed) return true;
// simple (single) selectors
- var expressions = parsed.expressions, reversedExpressions, simpleExpCounter = 0, i;
+ var expressions = parsed.expressions, simpleExpCounter = 0, i;
for (i = 0; (currentExpression = expressions[i]); i++){
if (currentExpression.length == 1){
var exp = currentExpression[0];
@@ -2683,7 +2683,7 @@ var combinators = {
this.push(item, tag, null, classes, attributes, pseudos);
break;
}
- }
+ }
return;
}
if (!item){
@@ -2892,7 +2892,7 @@ var pseudos = {
'root': function(node){
return (node === this.root);
},
-
+
'selected': function(node){
return node.selected;
}
@@ -2904,7 +2904,7 @@ for (var p in pseudos) local['pseudo:' + p] = pseudos[p];
// attributes methods
-local.attributeGetters = {
+var attributeGetters = local.attributeGetters = {
'class': function(){
return this.getAttribute('class') || this.className;
@@ -2921,7 +2921,7 @@ local.attributeGetters = {
'style': function(){
return (this.style) ? this.style.cssText : this.getAttribute('style');
},
-
+
'tabindex': function(){
var attributeNode = this.getAttributeNode('tabindex');
return (attributeNode && attributeNode.specified) ? attributeNode.nodeValue : null;
@@ -2929,15 +2929,22 @@ local.attributeGetters = {
'type': function(){
return this.getAttribute('type');
+ },
+
+ 'maxlength': function(){
+ var attributeNode = this.getAttributeNode('maxLength');
+ return (attributeNode && attributeNode.specified) ? attributeNode.nodeValue : null;
}
};
+attributeGetters.MAXLENGTH = attributeGetters.maxLength = attributeGetters.maxlength;
+
// Slick
var Slick = local.Slick = (this.Slick || {});
-Slick.version = '1.1.5';
+Slick.version = '1.1.6';
// Slick finder
@@ -2959,9 +2966,15 @@ Slick.contains = function(container, node){
// Slick attribute getter
Slick.getAttribute = function(node, name){
+ local.setDocument(node);
return local.getAttribute(node, name);
};
+Slick.hasAttribute = function(node, name){
+ local.setDocument(node);
+ return local.hasAttribute(node, name);
+};
+
// Slick matcher
Slick.match = function(node, selector){
@@ -3026,7 +3039,7 @@ description: One of the most important items in MooTools. Contains the dollar fu
license: MIT-style license.
-requires: [Window, Document, Array, String, Function, Number, Slick.Parser, Slick.Finder]
+requires: [Window, Document, Array, String, Function, Object, Number, Slick.Parser, Slick.Finder]
provides: [Element, Elements, $, $$, Iframe, Selectors]
@@ -3046,8 +3059,8 @@ var Element = function(tag, props){
if (parsed.id && props.id == null) props.id = parsed.id;
var attributes = parsed.attributes;
- if (attributes) for (var i = 0, l = attributes.length; i < l; i++){
- var attr = attributes[i];
+ if (attributes) for (var attr, i = 0, l = attributes.length; i < l; i++){
+ attr = attributes[i];
if (props[attr.key] != null) continue;
if (attr.value != null && attr.operator == '=') props[attr.key] = attr.value;
@@ -3199,9 +3212,9 @@ var splice = Array.prototype.splice, object = {'0': 0, '1': 1, length: 2};
splice.call(object, 1, 1);
if (object[1] == 1) Elements.implement('splice', function(){
var length = this.length;
- splice.apply(this, arguments);
+ var result = splice.apply(this, arguments);
while (length >= this.length) delete this[length--];
- return this;
+ return result;
}.protect());
Elements.implement(Array.prototype);
@@ -3321,8 +3334,19 @@ Window.implement({
});
+var contains = {contains: function(element){
+ return Slick.contains(this, element);
+}};
+
+if (!document.contains) Document.implement(contains);
+if (!document.createElement('div').contains) Element.implement(contains);
+
//<1.2compat>
+Element.implement('hasChild', function(element){
+ return this !== element && this.contains(element);
+});
+
(function(search, find, match){
this.Selectors = {};
@@ -3352,6 +3376,74 @@ Window.implement({
})(Slick.search, Slick.find, Slick.match);
+//</1.2compat>
+
+// tree walking
+
+var injectCombinator = function(expression, combinator){
+ if (!expression) return combinator;
+
+ expression = Object.clone(Slick.parse(expression));
+
+ var expressions = expression.expressions;
+ for (var i = expressions.length; i--;)
+ expressions[i][0].combinator = combinator;
+
+ return expression;
+};
+
+Object.forEach({
+ getNext: '~',
+ getPrevious: '!~',
+ getParent: '!'
+}, function(combinator, method){
+ Element.implement(method, function(expression){
+ return this.getElement(injectCombinator(expression, combinator));
+ });
+});
+
+Object.forEach({
+ getAllNext: '~',
+ getAllPrevious: '!~',
+ getSiblings: '~~',
+ getChildren: '>',
+ getParents: '!'
+}, function(combinator, method){
+ Element.implement(method, function(expression){
+ return this.getElements(injectCombinator(expression, combinator));
+ });
+});
+
+Element.implement({
+
+ getFirst: function(expression){
+ return document.id(Slick.search(this, injectCombinator(expression, '>'))[0]);
+ },
+
+ getLast: function(expression){
+ return document.id(Slick.search(this, injectCombinator(expression, '>')).getLast());
+ },
+
+ getWindow: function(){
+ return this.ownerDocument.window;
+ },
+
+ getDocument: function(){
+ return this.ownerDocument;
+ },
+
+ getElementById: function(id){
+ return document.id(Slick.find(this, '#' + ('' + id).replace(/(\W)/g, '\\$1')));
+ },
+
+ match: function(expression){
+ return !expression || Slick.match(this, expression);
+ }
+
+});
+
+//<1.2compat>
+
if (window.$$ == null) Window.implement('$$', function(selector){
var elements = new Elements;
if (arguments.length == 1 && typeof selector == 'string') return Slick.search(this.document, selector, elements);
@@ -3378,48 +3470,7 @@ if (window.$$ == null) Window.implement('$$', function(selector){
(function(){
-var collected = {}, storage = {};
-var formProps = {input: 'checked', option: 'selected', textarea: 'value'};
-
-var get = function(uid){
- return (storage[uid] || (storage[uid] = {}));
-};
-
-var clean = function(item){
- var uid = item.uid;
- if (item.removeEvents) item.removeEvents();
- if (item.clearAttributes) item.clearAttributes();
- if (uid != null){
- delete collected[uid];
- delete storage[uid];
- }
- return item;
-};
-
-var camels = ['defaultValue', 'accessKey', 'cellPadding', 'cellSpacing', 'colSpan', 'frameBorder', 'maxLength', 'readOnly',
- 'rowSpan', 'tabIndex', 'useMap'
-];
-var bools = ['compact', 'nowrap', 'ismap', 'declare', 'noshade', 'checked', 'disabled', 'readOnly', 'multiple', 'selected',
- 'noresize', 'defer', 'defaultChecked'
-];
- var attributes = {
- 'html': 'innerHTML',
- 'class': 'className',
- 'for': 'htmlFor',
- 'text': (function(){
- var temp = document.createElement('div');
- return (temp.textContent == null) ? 'innerText' : 'textContent';
- })()
-};
-var readOnly = ['type'];
-var expandos = ['value', 'defaultValue'];
-var uriAttrs = /^(?:href|src|usemap)$/i;
-
-bools = bools.associate(bools);
-camels = camels.associate(camels.map(String.toLowerCase));
-readOnly = readOnly.associate(readOnly);
-
-Object.append(attributes, expandos.associate(expandos));
+// Inserters
var inserters = {
@@ -3469,42 +3520,84 @@ Object.each(inserters, function(inserter, where){
//</1.2compat>
-var injectCombinator = function(expression, combinator){
- if (!expression) return combinator;
+// getProperty / setProperty
- expression = Object.clone(Slick.parse(expression));
+var propertyGetters = {}, propertySetters = {};
- var expressions = expression.expressions;
- for (var i = expressions.length; i--;)
- expressions[i][0].combinator = combinator;
+// properties
- return expression;
-};
+var properties = {};
+Array.forEach([
+ 'type', 'value', 'defaultValue', 'accessKey', 'cellPadding', 'cellSpacing', 'colSpan',
+ 'frameBorder', 'readOnly', 'rowSpan', 'tabIndex', 'useMap'
+], function(property){
+ properties[property.toLowerCase()] = property;
+});
-Element.implement({
+Object.append(properties, {
+ 'html': 'innerHTML',
+ 'text': (function(){
+ var temp = document.createElement('div');
+ return (temp.innerText == null) ? 'textContent' : 'innerText';
+ })()
+});
- set: function(prop, value){
- var property = Element.Properties[prop];
- (property && property.set) ? property.set.call(this, value) : this.setProperty(prop, value);
- }.overloadSetter(),
+Object.forEach(properties, function(real, key){
+ propertySetters[key] = function(node, value){
+ node[real] = value;
+ };
+ propertyGetters[key] = function(node){
+ return node[real];
+ };
+});
- get: function(prop){
- var property = Element.Properties[prop];
- return (property && property.get) ? property.get.apply(this) : this.getProperty(prop);
- }.overloadGetter(),
+// Booleans
- erase: function(prop){
- var property = Element.Properties[prop];
- (property && property.erase) ? property.erase.apply(this) : this.removeProperty(prop);
- return this;
+var bools = [
+ 'compact', 'nowrap', 'ismap', 'declare', 'noshade', 'checked',
+ 'disabled', 'readOnly', 'multiple', 'selected', 'noresize',
+ 'defer', 'defaultChecked', 'autofocus', 'controls', 'autoplay',
+ 'loop'
+];
+
+var booleans = {};
+Array.forEach(bools, function(bool){
+ var lower = bool.toLowerCase();
+ booleans[lower] = bool;
+ propertySetters[lower] = function(node, value){
+ node[bool] = !!value;
+ };
+ propertyGetters[lower] = function(node){
+ return !!node[bool];
+ };
+});
+
+// Special cases
+
+Object.append(propertySetters, {
+
+ 'class': function(node, value){
+ ('className' in node) ? node.className = value : node.setAttribute('class', value);
},
- setProperty: function(attribute, value){
- attribute = camels[attribute] || attribute;
- if (value == null) return this.removeProperty(attribute);
- var key = attributes[attribute];
- (key) ? this[key] = value :
- (bools[attribute]) ? this[attribute] = !!value : this.setAttribute(attribute, '' + value);
+ 'for': function(node, value){
+ ('htmlFor' in node) ? node.htmlFor = value : node.setAttribute('for', value);
+ },
+
+ 'style': function(node, value){
+ (node.style) ? node.style.cssText = value : node.setAttribute('style', value);
+ }
+
+});
+
+/* getProperty, setProperty */
+
+Element.implement({
+
+ setProperty: function(name, value){
+ var setter = propertySetters[name.toLowerCase()];
+ if (setter) setter(this, value);
+ else this.setAttribute(name, value);
return this;
},
@@ -3513,13 +3606,11 @@ Element.implement({
return this;
},
- getProperty: function(attribute){
- attribute = camels[attribute] || attribute;
- var key = attributes[attribute] || readOnly[attribute];
- return (key) ? this[key] :
- (bools[attribute]) ? !!this[attribute] :
- (uriAttrs.test(attribute) ? this.getAttribute(attribute, 2) :
- (key = this.getAttributeNode(attribute)) ? key.nodeValue : null) || null;
+ getProperty: function(name){
+ var getter = propertyGetters[name.toLowerCase()];
+ if (getter) return getter(this);
+ var result = Slick.getAttribute(this, name);
+ return (!result && !Slick.hasAttribute(this, name)) ? null : result;
},
getProperties: function(){
@@ -3527,11 +3618,10 @@ Element.implement({
return args.map(this.getProperty, this).associate(args);
},
- removeProperty: function(attribute){
- attribute = camels[attribute] || attribute;
- var key = attributes[attribute];
- (key) ? this[key] = '' :
- (bools[attribute]) ? this[attribute] = false : this.removeAttribute(attribute);
+ removeProperty: function(name){
+ name = name.toLowerCase();
+ if (booleans[name]) this.setProperty(name, false);
+ this.removeAttribute(name);
return this;
},
@@ -3540,6 +3630,22 @@ Element.implement({
return this;
},
+ set: function(prop, value){
+ var property = Element.Properties[prop];
+ (property && property.set) ? property.set.call(this, value) : this.setProperty(prop, value);
+ }.overloadSetter(),
+
+ get: function(prop){
+ var property = Element.Properties[prop];
+ return (property && property.get) ? property.get.apply(this) : this.getProperty(prop);
+ }.overloadGetter(),
+
+ erase: function(prop){
+ var property = Element.Properties[prop];
+ (property && property.erase) ? property.erase.apply(this) : this.removeProperty(prop);
+ return this;
+ },
+
hasClass: function(className){
return this.className.clean().contains(className, ' ');
},
@@ -3598,58 +3704,6 @@ Element.implement({
return this.replaces(el).grab(el, where);
},
- getPrevious: function(expression){
- return document.id(Slick.find(this, injectCombinator(expression, '!~')));
- },
-
- getAllPrevious: function(expression){
- return Slick.search(this, injectCombinator(expression, '!~'), new Elements);
- },
-
- getNext: function(expression){
- return document.id(Slick.find(this, injectCombinator(expression, '~')));
- },
-
- getAllNext: function(expression){
- return Slick.search(this, injectCombinator(expression, '~'), new Elements);
- },
-
- getFirst: function(expression){
- return document.id(Slick.search(this, injectCombinator(expression, '>'))[0]);
- },
-
- getLast: function(expression){
- return document.id(Slick.search(this, injectCombinator(expression, '>')).getLast());
- },
-
- getParent: function(expression){
- return document.id(Slick.find(this, injectCombinator(expression, '!')));
- },
-
- getParents: function(expression){
- return Slick.search(this, injectCombinator(expression, '!'), new Elements);
- },
-
- getSiblings: function(expression){
- return Slick.search(this, injectCombinator(expression, '~~'), new Elements);
- },
-
- getChildren: function(expression){
- return Slick.search(this, injectCombinator(expression, '>'), new Elements);
- },
-
- getWindow: function(){
- return this.ownerDocument.window;
- },
-
- getDocument: function(){
- return this.ownerDocument;
- },
-
- getElementById: function(id){
- return document.id(Slick.find(this, '#' + ('' + id).replace(/(\W)/g, '\\$1')));
- },
-
getSelected: function(){
this.selectedIndex; // Safari 3.2.1
return new Elements(Array.from(this.options).filter(function(option){
@@ -3673,7 +3727,30 @@ Element.implement({
});
});
return queryString.join('&');
- },
+ }
+
+});
+
+var collected = {}, storage = {};
+
+var get = function(uid){
+ return (storage[uid] || (storage[uid] = {}));
+};
+
+var clean = function(item){
+ var uid = item.uid;
+ if (item.removeEvents) item.removeEvents();
+ if (item.clearAttributes) item.clearAttributes();
+ if (uid != null){
+ delete collected[uid];
+ delete storage[uid];
+ }
+ return item;
+};
+
+var formProps = {input: 'checked', option: 'selected', textarea: 'value'};
+
+Element.implement({
destroy: function(){
var children = clean(this).getElementsByTagName('*');
@@ -3691,61 +3768,44 @@ Element.implement({
return (this.parentNode) ? this.parentNode.removeChild(this) : this;
},
- match: function(expression){
- return !expression || Slick.match(this, expression);
- }
-
-});
+ clone: function(contents, keepid){
+ contents = contents !== false;
+ var clone = this.cloneNode(contents), ce = [clone], te = [this], i;
-var cleanClone = function(node, element, keepid){
- if (!keepid) node.setAttributeNode(document.createAttribute('id'));
- if (node.clearAttributes){
- node.clearAttributes();
- node.mergeAttributes(element);
- node.removeAttribute('uid');
- if (node.options){
- var no = node.options, eo = element.options;
- for (var i = no.length; i--;) no[i].selected = eo[i].selected;
+ if (contents){
+ ce.append(Array.from(clone.getElementsByTagName('*')));
+ te.append(Array.from(this.getElementsByTagName('*')));
}
- }
- var prop = formProps[element.tagName.toLowerCase()];
- if (prop && element[prop]) node[prop] = element[prop];
-};
-
-Element.implement('clone', function(contents, keepid){
- contents = contents !== false;
- var clone = this.cloneNode(contents), i;
+ for (i = ce.length; i--;){
+ var node = ce[i], element = te[i];
+ if (!keepid) node.removeAttribute('id');
+ /*<ltIE9>*/
+ if (node.clearAttributes){
+ node.clearAttributes();
+ node.mergeAttributes(element);
+ node.removeAttribute('uid');
+ if (node.options){
+ var no = node.options, eo = element.options;
+ for (var j = no.length; j--;) no[j].selected = eo[j].selected;
+ }
+ }
+ /*</ltIE9>*/
+ var prop = formProps[element.tagName.toLowerCase()];
+ if (prop && element[prop]) node[prop] = element[prop];
+ }
- if (contents){
- var ce = clone.getElementsByTagName('*'), te = this.getElementsByTagName('*');
- for (i = ce.length; i--;) cleanClone(ce[i], te[i], keepid);
+ /*<ltIE9>*/
+ if (Browser.ie){
+ var co = clone.getElementsByTagName('object'), to = this.getElementsByTagName('object');
+ for (i = co.length; i--;) co[i].outerHTML = to[i].outerHTML;
+ }
+ /*</ltIE9>*/
+ return document.id(clone);
}
- cleanClone(clone, this, keepid);
-
- if (Browser.ie){
- var co = clone.getElementsByTagName('object'), to = this.getElementsByTagName('object');
- for (i = co.length; i--;) co[i].outerHTML = to[i].outerHTML;
- }
- return document.id(clone);
});
-var contains = {contains: function(element){
- return Slick.contains(this, element);
-}};
-
-if (!document.contains) Document.implement(contains);
-if (!document.createElement('div').contains) Element.implement(contains);
-
-//<1.2compat>
-
-Element.implement('hasChild', function(element){
- return this !== element && this.contains(element);
-});
-
-//</1.2compat>
-
[Element, Window, Document].invoke('implement', {
addListener: function(type, fn){
@@ -3796,8 +3856,6 @@ if (window.attachEvent && !window.addEventListener) window.addListener('unload',
});
/*</ltIE9>*/
-})();
-
Element.Properties = {};
//<1.2compat>
@@ -3830,17 +3888,6 @@ Element.Properties.tag = {
};
-/*<ltIE9>*/
-(function(maxLength){
- if (maxLength != null) Element.Properties.maxlength = Element.Properties.maxLength = {
- get: function(){
- var maxlength = this.getAttribute('maxLength');
- return maxlength == maxLength ? null : maxlength;
- }
- };
-})(document.createElement('input').getAttribute('maxLength'));
-/*</ltIE9>*/
-
/*<!webkit>*/
Element.Properties.html = (function(){
@@ -3859,10 +3906,26 @@ Element.Properties.html = (function(){
};
translations.thead = translations.tfoot = translations.tbody;
+ /*<ltIE9>*/
+ // technique by jdbarlett - http://jdbartlett.com/innershiv/
+ wrapper.innerHTML = '<nav></nav>';
+ var HTML5Test = wrapper.childNodes.length == 1;
+ if (!HTML5Test){
+ var tags = 'abbr article aside audio canvas datalist details figcaption figure footer header hgroup mark meter nav output progress section summary time video'.split(' '),
+ fragment = document.createDocumentFragment(), l = tags.length;
+ while (l--) fragment.createElement(tags[l]);
+ fragment.appendChild(wrapper);
+ }
+ /*</ltIE9>*/
+
var html = {
- set: function(){
- var html = Array.flatten(arguments).join('');
+ set: function(html){
+ if (typeOf(html) == 'array') html = html.join('');
+
var wrap = (!tableTest && translations[this.get('tag')]);
+ /*<ltIE9>*/
+ if (!wrap && !HTML5Test) wrap = [0, '', ''];
+ /*</ltIE9>*/
if (wrap){
var first = wrapper;
first.innerHTML = wrap[1] + html + wrap[2];
@@ -3880,6 +3943,40 @@ Element.Properties.html = (function(){
})();
/*</!webkit>*/
+/*<ltIE9>*/
+var testForm = document.createElement('form');
+testForm.innerHTML = '<select><option>s</option></select>';
+
+if (testForm.firstChild.value != 's') Element.Properties.value = {
+
+ set: function(value){
+ var tag = this.get('tag');
+ if (tag != 'select') return this.setProperty('value', value);
+ var options = this.getElements('option');
+ for (var i = 0; i < options.length; i++){
+ var option = options[i],
+ attr = option.getAttributeNode('value'),
+ optionValue = (attr && attr.specified) ? option.value : option.get('text');
+ if (optionValue == value) return option.selected = true;
+ }
+ },
+
+ get: function(){
+ var option = this, tag = option.get('tag');
+
+ if (tag != 'select' && tag != 'option') return this.getProperty('value');
+
+ if (tag == 'select' && !(option = option.getSelected()[0])) return '';
+
+ var attr = option.getAttributeNode('value');
+ return (attr && attr.specified) ? option.value : option.get('text');
+ }
+
+};
+/*</ltIE9>*/
+
+})();
+
/*
---
@@ -3905,41 +4002,38 @@ Element.Properties.styles = {set: function(styles){
this.setStyles(styles);
}};
-var hasOpacity = (html.style.opacity != null);
-var reAlpha = /alpha\(opacity=([\d.]+)\)/i;
+var hasOpacity = (html.style.opacity != null),
+ hasFilter = (html.style.filter != null),
+ reAlpha = /alpha\(opacity=([\d.]+)\)/i;
-var setOpacity = function(element, opacity){
- if (!element.currentStyle || !element.currentStyle.hasLayout) element.style.zoom = 1;
- if (hasOpacity){
- element.style.opacity = opacity;
- } else {
- opacity = (opacity * 100).limit(0, 100).round();
- opacity = (opacity == 100) ? '' : 'alpha(opacity=' + opacity + ')';
- var filter = element.style.filter || element.getComputedStyle('filter') || '';
- element.style.filter = reAlpha.test(filter) ? filter.replace(reAlpha, opacity) : filter + opacity;
- }
+var setVisibility = function(element, opacity){
+ element.store('$opacity', opacity);
+ element.style.visibility = opacity > 0 ? 'visible' : 'hidden';
};
-Element.Properties.opacity = {
-
- set: function(opacity){
- var visibility = this.style.visibility;
- if (opacity == 0 && visibility != 'hidden') this.style.visibility = 'hidden';
- else if (opacity != 0 && visibility != 'visible') this.style.visibility = 'visible';
-
- setOpacity(this, opacity);
- },
-
- get: (hasOpacity) ? function(){
- var opacity = this.style.opacity || this.getComputedStyle('opacity');
- return (opacity == '') ? 1 : opacity;
- } : function(){
- var opacity, filter = (this.style.filter || this.getComputedStyle('filter'));
- if (filter) opacity = filter.match(reAlpha);
- return (opacity == null || filter == null) ? 1 : (opacity[1] / 100);
- }
-
-};
+var setOpacity = (hasOpacity ? function(element, opacity){
+ element.style.opacity = opacity;
+} : (hasFilter ? function(element, opacity){
+ if (!element.currentStyle || !element.currentStyle.hasLayout) element.style.zoom = 1;
+ opacity = (opacity * 100).limit(0, 100).round();
+ opacity = (opacity == 100) ? '' : 'alpha(opacity=' + opacity + ')';
+ var filter = element.style.filter || element.getComputedStyle('filter') || '';
+ element.style.filter = reAlpha.test(filter) ? filter.replace(reAlpha, opacity) : filter + opacity;
+} : setVisibility));
+
+var getOpacity = (hasOpacity ? function(element){
+ var opacity = element.style.opacity || element.getComputedStyle('opacity');
+ return (opacity == '') ? 1 : opacity.toFloat();
+} : (hasFilter ? function(element){
+ var filter = (element.style.filter || element.getComputedStyle('filter')),
+ opacity;
+ if (filter) opacity = filter.match(reAlpha);
+ return (opacity == null || filter == null) ? 1 : (opacity[1] / 100);
+} : function(element){
+ var opacity = element.retrieve('$opacity');
+ if (opacity == null) opacity = (element.style.visibility == 'hidden' ? 0 : 1);
+ return opacity;
+}));
var floatName = (html.style.cssFloat == null) ? 'styleFloat' : 'cssFloat';
@@ -3952,21 +4046,12 @@ Element.implement({
return (computed) ? computed.getPropertyValue((property == floatName) ? 'float' : property.hyphenate()) : null;
},
- setOpacity: function(value){
- setOpacity(this, value);
- return this;
- },
-
- getOpacity: function(){
- return this.get('opacity');
- },
-
setStyle: function(property, value){
- switch (property){
- case 'opacity': return this.set('opacity', parseFloat(value));
- case 'float': property = floatName;
+ if (property == 'opacity'){
+ setOpacity(this, parseFloat(value));
+ return this;
}
- property = property.camelCase();
+ property = (property == 'float' ? floatName : property).camelCase();
if (typeOf(value) != 'string'){
var map = (Element.Styles[property] || '@').split(' ');
value = Array.from(value).map(function(val, i){
@@ -3981,11 +4066,8 @@ Element.implement({
},
getStyle: function(property){
- switch (property){
- case 'opacity': return this.get('opacity');
- case 'float': property = floatName;
- }
- property = property.camelCase();
+ if (property == 'opacity') return getOpacity(this);
+ property = (property == 'float' ? floatName : property).camelCase();
var result = this.style[property];
if (!result || property == 'zIndex'){
result = [];
@@ -4040,6 +4122,36 @@ Element.Styles = {
zIndex: '@', 'zoom': '@', fontWeight: '@', textIndent: '@px', opacity: '@'
};
+//<1.3compat>
+
+Element.implement({
+
+ setOpacity: function(value){
+ setOpacity(this, value);
+ return this;
+ },
+
+ getOpacity: function(){
+ return getOpacity(this);
+ }
+
+});
+
+Element.Properties.opacity = {
+
+ set: function(opacity){
+ setOpacity(this, opacity);
+ setVisibility(this, opacity);
+ },
+
+ get: function(){
+ return getOpacity(this);
+ }
+
+};
+
+//</1.3compat>
+
//<1.2compat>
Element.Styles = new Hash(Element.Styles);
@@ -4101,14 +4213,14 @@ Element.Properties.events = {set: function(events){
condition = fn,
self = this;
if (custom){
- if (custom.onAdd) custom.onAdd.call(this, fn);
+ if (custom.onAdd) custom.onAdd.call(this, fn, type);
if (custom.condition){
condition = function(event){
- if (custom.condition.call(this, event)) return fn.call(this, event);
+ if (custom.condition.call(this, event, type)) return fn.call(this, event);
return true;
};
}
- realType = custom.base || realType;
+ if (custom.base) realType = Function.from(custom.base).call(this, type);
}
var defn = function(){
return fn.call(self);
@@ -4117,7 +4229,7 @@ Element.Properties.events = {set: function(events){
if (nativeEvent){
if (nativeEvent == 2){
defn = function(event){
- event = new Event(event, self.getWindow());
+ event = new DOMEvent(event, self.getWindow());
if (condition.call(self, event) === false) event.stop();
};
}
@@ -4138,8 +4250,8 @@ Element.Properties.events = {set: function(events){
delete list.values[index];
var custom = Element.Events[type];
if (custom){
- if (custom.onRemove) custom.onRemove.call(this, fn);
- type = custom.base || type;
+ if (custom.onRemove) custom.onRemove.call(this, fn, type);
+ if (custom.base) type = Function.from(custom.base).call(this, type);
}
return (Element.NativeEvents[type]) ? this.removeListener(type, value, arguments[2]) : this;
},
@@ -4205,7 +4317,7 @@ Element.NativeEvents = {
orientationchange: 2, // mobile
touchstart: 2, touchmove: 2, touchend: 2, touchcancel: 2, // touch
gesturestart: 2, gesturechange: 2, gestureend: 2, // gesture
- focus: 2, blur: 2, change: 2, reset: 2, select: 2, submit: 2, //form elements
+ focus: 2, blur: 2, change: 2, reset: 2, select: 2, submit: 2, paste: 2, oninput: 2, //form elements
load: 2, unload: 1, beforeunload: 2, resize: 1, move: 1, DOMContentLoaded: 1, readystatechange: 1, //window
error: 1, abort: 1, scroll: 1 //misc
};
@@ -4235,6 +4347,21 @@ Element.Events = {
};
+/*<ltIE9>*/
+if (!window.addEventListener){
+ Element.NativeEvents.propertychange = 2;
+ Element.Events.change = {
+ base: function(){
+ var type = this.type;
+ return (this.get('tag') == 'input' && (type == 'radio' || type == 'checkbox')) ? 'propertychange' : 'change'
+ },
+ condition: function(event){
+ return !!(this.type != 'radio' || this.checked);
+ }
+ }
+}
+/*</ltIE9>*/
+
//<1.2compat>
Element.Events = new Hash(Element.Events);
@@ -4247,6 +4374,206 @@ Element.Events = new Hash(Element.Events);
/*
---
+name: Element.Delegation
+
+description: Extends the Element native object to include the delegate method for more efficient event management.
+
+license: MIT-style license.
+
+requires: [Element.Event]
+
+provides: [Element.Delegation]
+
+...
+*/
+
+(function(){
+
+var eventListenerSupport = !!window.addEventListener;
+
+Element.NativeEvents.focusin = Element.NativeEvents.focusout = 2;
+
+var bubbleUp = function(self, match, fn, event){
+ var target = event.target;
+ while (target && target != self){
+ if (match(target, event)) return fn.call(target, event, target);
+ target = document.id(target.parentNode);
+ }
+};
+
+var map = {
+ mouseenter: {
+ base: 'mouseover'
+ },
+ mouseleave: {
+ base: 'mouseout'
+ },
+ focus: {
+ base: 'focus' + (eventListenerSupport ? '' : 'in'),
+ capture: true
+ },
+ blur: {
+ base: eventListenerSupport ? 'blur' : 'focusout',
+ capture: true
+ }
+};
+
+/*<ltIE9>*/
+var _key = '$delegation:';
+var formObserver = function(type){
+
+ return {
+
+ base: 'focusin',
+
+ remove: function(self, uid){
+ var list = self.retrieve(_key + type + 'listeners', {})[uid];
+ if (list && list.forms) for (var i = list.forms.length; i--;){
+ list.forms[i].removeEvent(type, list.fns[i]);
+ }
+ },
+
+ listen: function(self, match, fn, event, uid){
+ var target = event.target,
+ form = (target.get('tag') == 'form') ? target : event.target.getParent('form');
+ if (!form) return;
+
+ var listeners = self.retrieve(_key + type + 'listeners', {}),
+ listener = listeners[uid] || {forms: [], fns: []},
+ forms = listener.forms, fns = listener.fns;
+
+ if (forms.indexOf(form) != -1) return;
+ forms.push(form);
+
+ var _fn = function(event){
+ bubbleUp(self, match, fn, event);
+ };
+ form.addEvent(type, _fn);
+ fns.push(_fn);
+
+ listeners[uid] = listener;
+ self.store(_key + type + 'listeners', listeners);
+ }
+ };
+};
+
+var inputObserver = function(type){
+ return {
+ base: 'focusin',
+ listen: function(self, match, fn, event){
+ var events = {blur: function(){
+ this.removeEvents(events);
+ }};
+ events[type] = function(event){
+ bubbleUp(self, match, fn, event);
+ };
+ event.target.addEvents(events);
+ }
+ };
+};
+
+if (!eventListenerSupport) Object.append(map, {
+ submit: formObserver('submit'),
+ reset: formObserver('reset'),
+ change: inputObserver('change'),
+ select: inputObserver('select')
+});
+/*</ltIE9>*/
+
+var proto = Element.prototype,
+ addEvent = proto.addEvent,
+ removeEvent = proto.removeEvent;
+
+var relay = function(old, method){
+ return function(type, fn, useCapture){
+ if (type.indexOf(':relay') == -1) return old.call(this, type, fn, useCapture);
+ var parsed = Slick.parse(type).expressions[0][0];
+ if (parsed.pseudos[0].key != 'relay') return old.call(this, type, fn, useCapture);
+ var newType = parsed.tag;
+ parsed.pseudos.slice(1).each(function(pseudo){
+ newType += ':' + pseudo.key + (pseudo.value ? '(' + pseudo.value + ')' : '');
+ });
+ return method.call(this, newType, parsed.pseudos[0].value, fn);
+ };
+};
+
+var delegation = {
+
+ addEvent: function(type, match, fn){
+ var storage = this.retrieve('$delegates', {}), stored = storage[type];
+ if (stored) for (var _uid in stored){
+ if (stored[_uid].fn == fn && stored[_uid].match == match) return this;
+ }
+
+ var _type = type, _match = match, _fn = fn, _map = map[type] || {};
+ type = _map.base || _type;
+
+ match = function(target){
+ return Slick.match(target, _match);
+ };
+
+ var elementEvent = Element.Events[_type];
+ if (elementEvent && elementEvent.condition){
+ var __match = match, condition = elementEvent.condition;
+ match = function(target, event){
+ return __match(target, event) && condition.call(target, event, type);
+ };
+ }
+
+ var self = this, uid = String.uniqueID();
+ var delegator = _map.listen ? function(event){
+ _map.listen(self, match, fn, event, uid);
+ } : function(event){
+ bubbleUp(self, match, fn, event);
+ };
+
+ if (!stored) stored = {};
+ stored[uid] = {
+ match: _match,
+ fn: _fn,
+ delegator: delegator
+ };
+ storage[_type] = stored;
+ return addEvent.call(this, type, delegator, _map.capture);
+ },
+
+ removeEvent: function(type, match, fn, _uid){
+ var storage = this.retrieve('$delegates', {}), stored = storage[type];
+ if (!stored) return this;
+
+ if (_uid){
+ var _type = type, delegator = stored[_uid].delegator, _map = map[type] || {};
+ type = _map.base || _type;
+ if (_map.remove) _map.remove(this, _uid);
+ delete stored[_uid];
+ storage[_type] = stored;
+ return removeEvent.call(this, type, delegator);
+ }
+
+ var __uid, s;
+ if (fn) for (__uid in stored){
+ s = stored[__uid];
+ if (s.match == match && s.fn == fn) return delegation.removeEvent.call(this, type, match, fn, __uid);
+ } else for (__uid in stored){
+ s = stored[__uid];
+ if (s.match == match) delegation.removeEvent.call(this, type, match, s.fn, __uid);
+ }
+ return this;
+ }
+
+};
+
+[Element, Window, Document].invoke('implement', {
+ addEvent: relay(addEvent, delegation.addEvent),
+ removeEvent: relay(removeEvent, delegation.removeEvent)
+});
+
+})();
+
+
+/*
+---
+
name: Element.Dimensions
description: Contains methods to work with size, scroll, or positioning of Elements and the window object.
@@ -4383,14 +4710,13 @@ Element.implement({
},
getPosition: function(relative){
- if (isBody(this)) return {x: 0, y: 0};
var offset = this.getOffsets(),
scroll = this.getScrolls();
var position = {
x: offset.x - scroll.x,
y: offset.y - scroll.y
};
-
+
if (relative && (relative = document.id(relative))){
var relativePosition = relative.getPosition();
return {x: position.x - relativePosition.x - leftBorder(relative), y: position.y - relativePosition.y - topBorder(relative)};
@@ -4584,7 +4910,7 @@ var Fx = this.Fx = new Class({
} else {
this.frame++;
}
-
+
if (this.frame < this.frames){
var delta = this.transition(this.frame / this.frames);
this.set(this.compute(this.from, this.to, delta));
@@ -4627,7 +4953,7 @@ var Fx = this.Fx = new Class({
pushInstance.call(this, fps);
return this;
},
-
+
stop: function(){
if (this.isRunning()){
this.time = null;
@@ -4641,7 +4967,7 @@ var Fx = this.Fx = new Class({
}
return this;
},
-
+
cancel: function(){
if (this.isRunning()){
this.time = null;
@@ -4651,7 +4977,7 @@ var Fx = this.Fx = new Class({
}
return this;
},
-
+
pause: function(){
if (this.isRunning()){
this.time = null;
@@ -4659,12 +4985,12 @@ var Fx = this.Fx = new Class({
}
return this;
},
-
+
resume: function(){
if ((this.frame < this.frames) && !this.isRunning()) pushInstance.call(this, this.options.fps);
return this;
},
-
+
isRunning: function(){
var list = instances[this.options.fps];
return list && list.contains(this);
@@ -4939,7 +5265,7 @@ Element.implement({
case 'show': fade.set(o, 1); break;
case 'hide': fade.set(o, 0); break;
case 'toggle':
- var flag = this.retrieve('fade:flag', this.get('opacity') == 1);
+ var flag = this.retrieve('fade:flag', this.getStyle('opacity') == 1);
fade.start(o, (flag) ? 0 : 1);
this.store('fade:flag', !flag);
toggle = true;
@@ -5235,7 +5561,7 @@ var Request = this.Request = new Class({
xhr.onreadystatechange = empty;
if (progressSupport) xhr.onprogress = xhr.onloadstart = empty;
clearTimeout(this.timer);
-
+
this.response = {text: this.xhr.responseText || '', xml: this.xhr.responseXML};
if (this.options.isSuccess.call(this, this.status))
this.success(this.response.text, this.response.xml);
@@ -5272,15 +5598,15 @@ var Request = this.Request = new Class({
onFailure: function(){
this.fireEvent('complete').fireEvent('failure', this.xhr);
},
-
+
loadstart: function(event){
this.fireEvent('loadstart', [event, this.xhr]);
},
-
+
progress: function(event){
this.fireEvent('progress', [event, this.xhr]);
},
-
+
timeout: function(){
this.fireEvent('timeout', this.xhr);
},
@@ -5304,7 +5630,7 @@ var Request = this.Request = new Class({
}
return false;
},
-
+
send: function(options){
if (!this.check(options)) return this;
@@ -5340,7 +5666,7 @@ var Request = this.Request = new Class({
}
if (!url) url = document.location.pathname;
-
+
var trimPosition = url.lastIndexOf('/');
if (trimPosition > -1 && (trimPosition = url.indexOf('#')) > -1) url = url.substr(0, trimPosition);
@@ -5360,7 +5686,7 @@ var Request = this.Request = new Class({
xhr.open(method.toUpperCase(), url, this.options.async, this.options.user, this.options.password);
if (this.options.user && 'withCredentials' in xhr) xhr.withCredentials = true;
-
+
xhr.onreadystatechange = this.onStateChange.bind(this);
Object.each(this.headers, function(value, key){
@@ -5481,11 +5807,18 @@ Request.HTML = new Class({
var temp = new Element('div').set('html', response.html);
response.tree = temp.childNodes;
- response.elements = temp.getElements('*');
-
- if (options.filter) response.tree = response.elements.filter(options.filter);
- if (options.update) document.id(options.update).empty().set('html', response.html);
- else if (options.append) document.id(options.append).adopt(temp.getChildren());
+ response.elements = temp.getElements(options.filter || '*');
+
+ if (options.filter) response.tree = response.elements;
+ if (options.update){
+ var update = document.id(options.update).empty();
+ if (options.filter) update.adopt(response.elements);
+ else update.set('html', response.html);
+ } else if (options.append){
+ var append = document.id(options.append);
+ if (options.filter) response.elements.reverse().inject(append);
+ else append.adopt(temp.getChildren());
+ }
if (options.evalScripts) Browser.exec(response.javascript);
this.onSuccess(response.tree, response.elements, response.html, response.javascript);
@@ -5531,7 +5864,7 @@ description: JSON encoder and decoder.
license: MIT-style license.
-See Also: <http://www.json.org/>
+SeeAlso: <http://www.json.org/>
requires: [Array, String, Number, Function]
@@ -5759,7 +6092,7 @@ var domready = function(){
if (ready) return;
Browser.loaded = ready = true;
document.removeListener('DOMContentLoaded', domready).removeListener('readystatechange', check);
-
+
document.fireEvent('domready');
window.fireEvent('domready');
};
@@ -5788,7 +6121,7 @@ var doScrollWorks = function(){
return true;
} catch (e){}
return false;
-}
+};
// If doScroll works already, it can't be used to determine domready
// e.g. in an iframe
if (testElement.doScroll && !doScrollWorks()){
diff --git a/mootools-core/mootools-core-server-nc.js b/mootools-core/mootools-core-server-nc.js
index 7e32862..7dad15b 100644
--- a/mootools-core/mootools-core-server-nc.js
+++ b/mootools-core/mootools-core-server-nc.js
@@ -33,8 +33,8 @@ provides: [Core, MooTools, Type, typeOf, instanceOf, Native]
(function(){
this.MooTools = {
- version: '1.3.2',
- build: 'c9f1ff10e9e7facb65e9481049ed1b450959d587'
+ version: '1.4.0',
+ build: 'a15e35b4dbd12e8d86d9b50aa67a27e8e0071ea3'
};
// typeOf, instanceOf
@@ -203,7 +203,7 @@ var implement = function(name, method){
if (typeOf(hook) == 'type') implement.call(hook, name, method);
else hook.call(this, name, method);
}
-
+
var previous = this.prototype[name];
if (previous == null || !previous.$protected) this.prototype[name] = method;
@@ -265,7 +265,7 @@ var force = function(name, object, methods){
force('String', String, [
'charAt', 'charCodeAt', 'concat', 'indexOf', 'lastIndexOf', 'match', 'quote', 'replace', 'search',
- 'slice', 'split', 'substr', 'substring', 'toLowerCase', 'toUpperCase'
+ 'slice', 'split', 'substr', 'substring', 'trim', 'toLowerCase', 'toUpperCase'
])('Array', Array, [
'pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift', 'concat', 'join', 'slice',
'indexOf', 'lastIndexOf', 'filter', 'forEach', 'every', 'map', 'some', 'reduce', 'reduceRight'
@@ -421,7 +421,7 @@ Array.implement({
/*<!ES5>*/
every: function(fn, bind){
- for (var i = 0, l = this.length; i < l; i++){
+ for (var i = 0, l = this.length >>> 0; i < l; i++){
if ((i in this) && !fn.call(bind, this[i], i, this)) return false;
}
return true;
@@ -429,30 +429,30 @@ Array.implement({
filter: function(fn, bind){
var results = [];
- for (var i = 0, l = this.length; i < l; i++){
+ for (var i = 0, l = this.length >>> 0; i < l; i++){
if ((i in this) && fn.call(bind, this[i], i, this)) results.push(this[i]);
}
return results;
},
indexOf: function(item, from){
- var len = this.length;
- for (var i = (from < 0) ? Math.max(0, len + from) : from || 0; i < len; i++){
+ var length = this.length >>> 0;
+ for (var i = (from < 0) ? Math.max(0, length + from) : from || 0; i < length; i++){
if (this[i] === item) return i;
}
return -1;
},
map: function(fn, bind){
- var results = [];
- for (var i = 0, l = this.length; i < l; i++){
+ var length = this.length >>> 0, results = Array(length);
+ for (var i = 0; i < length; i++){
if (i in this) results[i] = fn.call(bind, this[i], i, this);
}
return results;
},
some: function(fn, bind){
- for (var i = 0, l = this.length; i < l; i++){
+ for (var i = 0, l = this.length >>> 0; i < l; i++){
if ((i in this) && fn.call(bind, this[i], i, this)) return true;
}
return false;
@@ -596,37 +596,37 @@ String.implement({
},
contains: function(string, separator){
- return (separator) ? (separator + this + separator).indexOf(separator + string + separator) > -1 : this.indexOf(string) > -1;
+ return (separator) ? (separator + this + separator).indexOf(separator + string + separator) > -1 : String(this).indexOf(string) > -1;
},
trim: function(){
- return this.replace(/^\s+|\s+$/g, '');
+ return String(this).replace(/^\s+|\s+$/g, '');
},
clean: function(){
- return this.replace(/\s+/g, ' ').trim();
+ return String(this).replace(/\s+/g, ' ').trim();
},
camelCase: function(){
- return this.replace(/-\D/g, function(match){
+ return String(this).replace(/-\D/g, function(match){
return match.charAt(1).toUpperCase();
});
},
hyphenate: function(){
- return this.replace(/[A-Z]/g, function(match){
+ return String(this).replace(/[A-Z]/g, function(match){
return ('-' + match.charAt(0).toLowerCase());
});
},
capitalize: function(){
- return this.replace(/\b[a-z]/g, function(match){
+ return String(this).replace(/\b[a-z]/g, function(match){
return match.toUpperCase();
});
},
escapeRegExp: function(){
- return this.replace(/([-.*+?^${}()|[\]\/\\])/g, '\\$1');
+ return String(this).replace(/([-.*+?^${}()|[\]\/\\])/g, '\\$1');
},
toInt: function(base){
@@ -638,17 +638,17 @@ String.implement({
},
hexToRgb: function(array){
- var hex = this.match(/^#?(\w{1,2})(\w{1,2})(\w{1,2})$/);
+ var hex = String(this).match(/^#?(\w{1,2})(\w{1,2})(\w{1,2})$/);
return (hex) ? hex.slice(1).hexToRgb(array) : null;
},
rgbToHex: function(array){
- var rgb = this.match(/\d{1,3}/g);
+ var rgb = String(this).match(/\d{1,3}/g);
return (rgb) ? rgb.rgbToHex(array) : null;
},
substitute: function(object, regexp){
- return this.replace(regexp || (/\\?\{([^{}]+)\}/g), function(match, name){
+ return String(this).replace(regexp || (/\\?\{([^{}]+)\}/g), function(match, name){
if (match.charAt(0) == '\\') return match.slice(1);
return (object[name] != null) ? object[name] : '';
});
@@ -746,22 +746,30 @@ Function.implement({
try {
return this.apply(bind, Array.from(args));
} catch (e){}
-
+
return null;
},
- /*<!ES5>*/
- bind: function(bind){
+ /*<!ES5-bind>*/
+ bind: function(that){
var self = this,
- args = (arguments.length > 1) ? Array.slice(arguments, 1) : null;
-
- return function(){
- if (!args && !arguments.length) return self.call(bind);
- if (args && arguments.length) return self.apply(bind, args.concat(Array.from(arguments)));
- return self.apply(bind, args || arguments);
+ args = arguments.length > 1 ? Array.slice(arguments, 1) : null,
+ F = function(){};
+
+ var bound = function(){
+ var context = that, length = arguments.length;
+ if (this instanceof bound){
+ F.prototype = self.prototype;
+ context = new F;
+ }
+ var result = (!args && !length)
+ ? self.call(context)
+ : self.apply(context, args && length ? args.concat(Array.slice(arguments)) : args || arguments);
+ return context == that ? result : context;
};
+ return bound;
},
- /*</!ES5>*/
+ /*</!ES5-bind>*/
pass: function(args, bind){
var self = this;
@@ -1098,7 +1106,7 @@ this.Events = new Class({
}, this);
return this;
},
-
+
removeEvent: function(type, fn){
type = removeOn(type);
var events = this.$events[type];
@@ -1154,7 +1162,7 @@ description: JSON encoder and decoder.
license: MIT-style license.
-See Also: <http://www.json.org/>
+SeeAlso: <http://www.json.org/>
requires: [Array, String, Number, Function]
diff --git a/mootools-more/mootools-more-nc.js b/mootools-more/mootools-more-nc.js
index d5f9dd1..ae99f77 100644
--- a/mootools-more/mootools-more-nc.js
+++ b/mootools-more/mootools-more-nc.js
@@ -1,6 +1,6 @@
// MooTools: the javascript framework.
-// Load this file's selection again by visiting: http://mootools.net/more/9cc6f160bc261365539063600b3d6bfe
-// Or build this file again with packager using: packager build More/More More/Events.Pseudos More/Class.Refactor More/Class.Binds More/Class.Occlude More/Chain.Wait More/Array.Extras More/Date More/Date.Extras More/Number.Format More/Object.Extras More/String.Extras More/String.QueryString More/URI More/URI.Relative More/Hash More/Hash.Extras More/Element.Forms More/Elements.From More/Element.Event.Pseudos More/Element.Event.Pseudos.Keys More/Element.Delegation More/Element.Measure More/Element.Pin More/Element.Position More/Element.Shortcuts More/Form.Request More/Form.Request.Append More/Form.Validator More/Form.Validator.Inline More/Form.Validator.Extras More/OverText More/Fx.Elements More/Fx.Accordion More/Fx.Move More/Fx.Reveal More/Fx.Scroll More/Fx.Slide More/Fx.SmoothScroll More/Fx.Sort More/Drag More/Drag.Move More/Slider More/Sortables More/Request.JSONP More/Request.Queue More/Request.Periodical More/Assets More/Color More/Group More/Hash.Cookie More/IframeShim More/Table More/HtmlTable More/HtmlTable.Zebra More/HtmlTable.Sort More/HtmlTable.Select More/Keyboard More/Keyboard.Extras More/Mask More/Scroller More/Tips More/Spinner More/Locale More/Locale.Set.From More/Locale.en-US.Date More/Locale.en-US.Form.Validator More/Locale.en-US.Number More/Locale.ar.Date More/Locale.ar.Form.Validator More/Locale.ca-CA.Date More/Locale.ca-CA.Form.Validator More/Locale.cs-CZ.Date More/Locale.cs-CZ.Form.Validator More/Locale.da-DK.Date More/Locale.da-DK.Form.Validator More/Locale.de-CH.Date More/Locale.de-CH.Form.Validator More/Locale.de-DE.Date More/Locale.de-DE.Form.Validator More/Locale.de-DE.Number More/Locale.en-GB.Date More/Locale.es-AR.Date More/Locale.es-AR.Form.Validator More/Locale.es-ES.Date More/Locale.es-ES.Form.Validator More/Locale.et-EE.Date More/Locale.et-EE.Form.Validator More/Locale.EU.Number More/Locale.fa.Date More/Locale.fa.Form.Validator More/Locale.fi-FI.Date More/Locale.fi-FI.Form.Validator More/Locale.fi-FI.Number More/Locale.fr-FR.Date More/Locale.fr-FR.Form.Validator More/Locale.fr-FR.Number More/Locale.he-IL.Date More/Locale.he-IL.Form.Validator More/Locale.he-IL.Number More/Locale.hu-HU.Date More/Locale.hu-HU.Form.Validator More/Locale.it-IT.Date More/Locale.it-IT.Form.Validator More/Locale.ja-JP.Date More/Locale.ja-JP.Form.Validator More/Locale.ja-JP.Number More/Locale.nl-NL.Date More/Locale.nl-NL.Form.Validator More/Locale.nl-NL.Number More/Locale.no-NO.Date More/Locale.no-NO.Form.Validator More/Locale.pl-PL.Date More/Locale.pl-PL.Form.Validator More/Locale.pt-BR.Date More/Locale.pt-BR.Form.Validator More/Locale.pt-PT.Date More/Locale.pt-PT.Form.Validator More/Locale.ru-RU-unicode.Date More/Locale.ru-RU-unicode.Form.Validator More/Locale.si-SI.Date More/Locale.si-SI.Form.Validator More/Locale.sv-SE.Date More/Locale.sv-SE.Form.Validator More/Locale.uk-UA.Date More/Locale.uk-UA.Form.Validator More/Locale.zh-CH.Date More/Locale.zh-CH.Form.Validator
+// Load this file's selection again by visiting: http://mootools.net/more/065f2f092ece4e3b32bb5214464cf926
+// Or build this file again with packager using: packager build More/More More/Events.Pseudos More/Class.Refactor More/Class.Binds More/Class.Occlude More/Chain.Wait More/Array.Extras More/Date More/Date.Extras More/Number.Format More/Object.Extras More/String.Extras More/String.QueryString More/URI More/URI.Relative More/Hash More/Hash.Extras More/Element.Forms More/Elements.From More/Element.Event.Pseudos More/Element.Event.Pseudos.Keys More/Element.Measure More/Element.Pin More/Element.Position More/Element.Shortcuts More/Form.Request More/Form.Request.Append More/Form.Validator More/Form.Validator.Inline More/Form.Validator.Extras More/OverText More/Fx.Elements More/Fx.Accordion More/Fx.Move More/Fx.Reveal More/Fx.Scroll More/Fx.Slide More/Fx.SmoothScroll More/Fx.Sort More/Drag More/Drag.Move More/Slider More/Sortables More/Request.JSONP More/Request.Queue More/Request.Periodical More/Assets More/Color More/Group More/Hash.Cookie More/IframeShim More/Table More/HtmlTable More/HtmlTable.Zebra More/HtmlTable.Sort More/HtmlTable.Select More/Keyboard More/Keyboard.Extras More/Mask More/Scroller More/Tips More/Spinner More/Locale More/Locale.Set.From More/Locale.en-US.Date More/Locale.en-US.Form.Validator More/Locale.en-US.Number More/Locale.ar.Date More/Locale.ar.Form.Validator More/Locale.ca-CA.Date More/Locale.ca-CA.Form.Validator More/Locale.cs-CZ.Date More/Locale.cs-CZ.Form.Validator More/Locale.da-DK.Date More/Locale.da-DK.Form.Validator More/Locale.de-CH.Date More/Locale.de-CH.Form.Validator More/Locale.de-DE.Date More/Locale.de-DE.Form.Validator More/Locale.de-DE.Number More/Locale.en-GB.Date More/Locale.es-AR.Date More/Locale.es-AR.Form.Validator More/Locale.es-ES.Date More/Locale.es-ES.Form.Validator More/Locale.et-EE.Date More/Locale.et-EE.Form.Validator More/Locale.EU.Number More/Locale.fa.Date More/Locale.fa.Form.Validator More/Locale.fi-FI.Date More/Locale.fi-FI.Form.Validator More/Locale.fi-FI.Number More/Locale.fr-FR.Date More/Locale.fr-FR.Form.Validator More/Locale.fr-FR.Number More/Locale.he-IL.Date More/Locale.he-IL.Form.Validator More/Locale.he-IL.Number More/Locale.hu-HU.Date More/Locale.hu-HU.Form.Validator More/Locale.it-IT.Date More/Locale.it-IT.Form.Validator More/Locale.ja-JP.Date More/Locale.ja-JP.Form.Validator More/Locale.ja-JP.Number More/Locale.nl-NL.Date More/Locale.nl-NL.Form.Validator More/Locale.nl-NL.Number More/Locale.no-NO.Date More/Locale.no-NO.Form.Validator More/Locale.pl-PL.Date More/Locale.pl-PL.Form.Validator More/Locale.pt-BR.Date More/Locale.pt-BR.Form.Validator More/Locale.pt-PT.Date More/Locale.pt-PT.Form.Validator More/Locale.ru-RU-unicode.Date More/Locale.ru-RU-unicode.Form.Validator More/Locale.si-SI.Date More/Locale.si-SI.Form.Validator More/Locale.sv-SE.Date More/Locale.sv-SE.Form.Validator More/Locale.uk-UA.Date More/Locale.uk-UA.Form.Validator More/Locale.zh-CH.Date More/Locale.zh-CH.Form.Validator
/*
---
@@ -31,8 +31,8 @@ provides: [MooTools.More]
*/
MooTools.More = {
- 'version': '1.3.2.1',
- 'build': 'e586bcd2496e9b22acfde32e12f84d49ce09e59d'
+ 'version': '1.4.0.1',
+ 'build': 'a4244edf2aa97ac8a196fc96082dd35af1abab87'
};
@@ -55,22 +55,24 @@ provides: [Events.Pseudos]
...
*/
+(function(){
+
Events.Pseudos = function(pseudos, addEvent, removeEvent){
- var storeKey = 'monitorEvents:';
+ var storeKey = '_monitorEvents:';
var storageOf = function(object){
return {
store: object.store ? function(key, value){
object.store(storeKey + key, value);
} : function(key, value){
- (object.$monitorEvents || (object.$monitorEvents = {}))[key] = value;
+ (object._monitorEvents || (object._monitorEvents = {}))[key] = value;
},
retrieve: object.retrieve ? function(key, dflt){
return object.retrieve(storeKey + key, dflt);
} : function(key, dflt){
- if (!object.$monitorEvents) return dflt;
- return object.$monitorEvents[key] || dflt;
+ if (!object._monitorEvents) return dflt;
+ return object._monitorEvents[key] || dflt;
}
};
};
@@ -83,24 +85,20 @@ Events.Pseudos = function(pseudos, addEvent, removeEvent){
l = parsedPseudos.length,
splits = [];
- while (l--) if (pseudos[parsedPseudos[l].key]){
- splits.push({
+ while (l--){
+ var pseudo = parsedPseudos[l].key,
+ listener = pseudos[pseudo];
+ if (listener != null) splits.push({
event: parsed.tag,
value: parsedPseudos[l].value,
- pseudo: parsedPseudos[l].key,
- original: type
+ pseudo: pseudo,
+ original: type,
+ listener: listener
});
}
-
return splits.length ? splits : null;
};
- var mergePseudoOptions = function(split){
- return Object.merge.apply(this, split.map(function(item){
- return pseudos[item.pseudo].options || {};
- }));
- };
-
return {
addEvent: function(type, fn, internal){
@@ -110,30 +108,24 @@ Events.Pseudos = function(pseudos, addEvent, removeEvent){
var storage = storageOf(this),
events = storage.retrieve(type, []),
eventType = split[0].event,
- options = mergePseudoOptions(split),
- stack = fn,
- eventOptions = options[eventType] || {},
args = Array.slice(arguments, 2),
- self = this,
- monitor;
-
- if (eventOptions.args) args.append(Array.from(eventOptions.args));
- if (eventOptions.base) eventType = eventOptions.base;
- if (eventOptions.onAdd) eventOptions.onAdd(this);
+ stack = fn,
+ self = this;
split.each(function(item){
- var stackFn = stack;
- stack = function(){
- (eventOptions.listener || pseudos[item.pseudo].listener).call(self, item, stackFn, arguments, monitor, options);
+ var listener = item.listener,
+ stackFn = stack;
+ if (listener == false) eventType += ':' + item.pseudo + '(' + item.value + ')';
+ else stack = function(){
+ listener.call(self, item, stackFn, arguments, stack);
};
});
- monitor = stack.bind(this);
- events.include({event: fn, monitor: monitor});
+ events.include({type: eventType, event: fn, monitor: stack});
storage.store(type, events);
- addEvent.apply(this, [type, fn].concat(args));
- return addEvent.apply(this, [eventType, monitor].concat(args));
+ if (type != eventType) addEvent.apply(this, [type, fn].concat(args));
+ return addEvent.apply(this, [eventType, stack].concat(args));
},
removeEvent: function(type, fn){
@@ -144,18 +136,11 @@ Events.Pseudos = function(pseudos, addEvent, removeEvent){
events = storage.retrieve(type);
if (!events) return this;
- var eventType = split[0].event,
- options = mergePseudoOptions(split),
- eventOptions = options[eventType] || {},
- args = Array.slice(arguments, 2);
-
- if (eventOptions.args) args.append(Array.from(eventOptions.args));
- if (eventOptions.base) eventType = eventOptions.base;
- if (eventOptions.onRemove) eventOptions.onRemove(this);
+ var args = Array.slice(arguments, 2);
removeEvent.apply(this, [type, fn].concat(args));
events.each(function(monitor, i){
- if (!fn || monitor.event == fn) removeEvent.apply(this, [eventType, monitor.monitor].concat(args));
+ if (!fn || monitor.event == fn) removeEvent.apply(this, [monitor.type, monitor.monitor].concat(args));
delete events[i];
}, this);
@@ -167,40 +152,32 @@ Events.Pseudos = function(pseudos, addEvent, removeEvent){
};
-(function(){
-
var pseudos = {
- once: {
- listener: function(split, fn, args, monitor){
- fn.apply(this, args);
- this.removeEvent(split.event, monitor)
- .removeEvent(split.original, fn);
- }
+ once: function(split, fn, args, monitor){
+ fn.apply(this, args);
+ this.removeEvent(split.event, monitor)
+ .removeEvent(split.original, fn);
},
- throttle: {
- listener: function(split, fn, args){
- if (!fn._throttled){
- fn.apply(this, args);
- fn._throttled = setTimeout(function(){
- fn._throttled = false;
- }, split.value || 250);
- }
+ throttle: function(split, fn, args){
+ if (!fn._throttled){
+ fn.apply(this, args);
+ fn._throttled = setTimeout(function(){
+ fn._throttled = false;
+ }, split.value || 250);
}
},
- pause: {
- listener: function(split, fn, args){
- clearTimeout(fn._pause);
- fn._pause = fn.delay(split.value || 250, this, args);
- }
+ pause: function(split, fn, args){
+ clearTimeout(fn._pause);
+ fn._pause = fn.delay(split.value || 250, this, args);
}
};
Events.definePseudo = function(key, listener){
- pseudos[key] = Type.isFunction(listener) ? {listener: listener} : listener;
+ pseudos[key] = listener;
return this;
};
@@ -1023,19 +1000,19 @@ Date.implement({
},
isValid: function(date){
- return !isNaN((date || this).valueOf());
+ if (!date) date = this;
+ return typeOf(date) == 'date' && !isNaN(date.valueOf());
},
- format: function(f){
+ format: function(format){
if (!this.isValid()) return 'invalid date';
- if (!f) f = '%x %X';
- var formatLower = f.toLowerCase();
- if (formatters[formatLower]) return formatters[formatLower](this); // it's a formatter!
- f = formats[formatLower] || f; // replace short-hand with actual format
+ if (!format) format = '%x %X';
+ if (typeof format == 'string') format = formats[format.toLowerCase()] || format;
+ if (typeof format == 'function') return format(this);
var d = this;
- return f.replace(/%([a-z%])/gi,
+ return format.replace(/%([a-z%])/gi,
function($0, $1){
switch ($1){
case 'a': return Date.getMsg('days_abbr')[d.get('day')];
@@ -1082,18 +1059,15 @@ Date.implement({
strftime: 'format'
});
-var formats = {
- db: '%Y-%m-%d %H:%M:%S',
- compact: '%Y%m%dT%H%M%S',
- 'short': '%d %b %H:%M',
- 'long': '%B %d, %Y %H:%M'
-};
-
// The day and month abbreviations are standardized, so we cannot use simply %a and %b because they will get localized
var rfcDayAbbr = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
rfcMonthAbbr = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
-var formatters = {
+var formats = {
+ db: '%Y-%m-%d %H:%M:%S',
+ compact: '%Y%m%dT%H%M%S',
+ 'short': '%d %b %H:%M',
+ 'long': '%B %d, %Y %H:%M',
rfc822: function(date){
return rfcDayAbbr[date.get('day')] + date.format(', %d ') + rfcMonthAbbr[date.get('month')] + date.format(' %Y %H:%M:%S %Z');
},
@@ -1113,7 +1087,6 @@ var formatters = {
}
};
-
var parsePatterns = [],
nativeParse = Date.parse;
@@ -1225,11 +1198,6 @@ Date.extend({
return this;
},
- defineFormats: function(formats){
- for (var name in formats) Date.defineFormat(name, formats[name]);
- return this;
- },
-
//<1.2compat>
parsePatterns: parsePatterns,
//</1.2compat>
@@ -1250,6 +1218,8 @@ Date.extend({
return this;
}
+}).extend({
+ defineFormats: Date.defineFormat.overloadSetter()
});
var regexOf = function(type){
@@ -1645,18 +1615,20 @@ Number.implement({
return value;
},
- formatCurrency: function(){
+ formatCurrency: function(decimals){
var locale = Locale.get('Number.currency') || {};
if (locale.scientific == null) locale.scientific = false;
- if (locale.decimals == null) locale.decimals = 2;
+ locale.decimals = decimals != null ? decimals
+ : (locale.decimals == null ? 2 : locale.decimals);
return this.format(locale);
},
- formatPercentage: function(){
+ formatPercentage: function(decimals){
var locale = Locale.get('Number.percentage') || {};
if (locale.suffix == null) locale.suffix = '%';
- if (locale.decimals == null) locale.decimals = 2;
+ locale.decimals = decimals != null ? decimals
+ : (locale.decimals == null ? 2 : locale.decimals);
return this.format(locale);
}
@@ -2497,23 +2469,23 @@ license: MIT-style license
authors:
- Arian Stolwijk
-requires: [Core/Element.Event, Events.Pseudos]
+requires: [Core/Element.Event, Core/Element.Delegation, Events.Pseudos]
-provides: [Element.Event.Pseudos]
+provides: [Element.Event.Pseudos, Element.Delegation]
...
*/
(function(){
-var pseudos = {},
+var pseudos = {relay: false},
copyFromEvents = ['once', 'throttle', 'pause'],
count = copyFromEvents.length;
while (count--) pseudos[copyFromEvents[count]] = Events.lookupPseudo(copyFromEvents[count]);
-Event.definePseudo = function(key, listener){
- pseudos[key] = Type.isFunction(listener) ? {listener: listener} : listener;
+DOMEvent.definePseudo = function(key, listener){
+ pseudos[key] = listener;
return this;
};
@@ -2548,7 +2520,7 @@ var keysStoreKey = '$moo:keys-pressed',
keysKeyupStoreKey = '$moo:keys-keyup';
-Event.definePseudo('keys', function(split, fn, args){
+DOMEvent.definePseudo('keys', function(split, fn, args){
var event = args[0],
keys = [],
@@ -2579,172 +2551,29 @@ Event.definePseudo('keys', function(split, fn, args){
});
-Object.append(Event.Keys, {
- 'shift': 16,
- 'control': 17,
- 'alt': 18,
- 'capslock': 20,
- 'pageup': 33,
- 'pagedown': 34,
- 'end': 35,
- 'home': 36,
- 'numlock': 144,
- 'scrolllock': 145,
- ';': 186,
- '=': 187,
- ',': 188,
- '-': Browser.firefox ? 109 : 189,
- '.': 190,
- '/': 191,
- '`': 192,
- '[': 219,
- '\\': 220,
- ']': 221,
- "'": 222,
- '+': 107
-});
-
-})();
-
-
-/*
----
-
-script: Element.Delegation.js
-
-name: Element.Delegation
-
-description: Extends the Element native object to include the delegate method for more efficient event management.
-
-credits:
- - "Event checking based on the work of Daniel Steigerwald. License: MIT-style license. Copyright: Copyright (c) 2008 Daniel Steigerwald, daniel.steigerwald.cz"
-
-license: MIT-style license
-
-authors:
- - Aaron Newton
- - Daniel Steigerwald
-
-requires: [/MooTools.More, Element.Event.Pseudos]
-
-provides: [Element.Delegation]
-
-...
-*/
-
-(function(){
-
-var eventListenerSupport = !(window.attachEvent && !window.addEventListener),
- nativeEvents = Element.NativeEvents;
-
-nativeEvents.focusin = 2;
-nativeEvents.focusout = 2;
-
-var check = function(split, target, event){
- var elementEvent = Element.Events[split.event], condition;
- if (elementEvent) condition = elementEvent.condition;
- return Slick.match(target, split.value) && (!condition || condition.call(target, event));
-};
-
-var bubbleUp = function(split, event, fn){
- for (var target = event.target; target && target != this; target = document.id(target.parentNode)){
- if (target && check(split, target, event)) return fn.call(target, event, target);
- }
-};
-
-var formObserver = function(eventName){
-
- var $delegationKey = '$delegation:';
-
- return {
- base: 'focusin',
-
- onRemove: function(element){
- element.retrieve($delegationKey + 'forms', []).each(function(el){
- el.retrieve($delegationKey + 'listeners', []).each(function(listener){
- el.removeEvent(eventName, listener);
- });
- el.eliminate($delegationKey + eventName + 'listeners')
- .eliminate($delegationKey + eventName + 'originalFn');
- });
- },
-
- listener: function(split, fn, args, monitor, options){
- var event = args[0],
- forms = this.retrieve($delegationKey + 'forms', []),
- target = event.target,
- form = (target.get('tag') == 'form') ? target : event.target.getParent('form');
-
- if (!form) return;
-
- var formEvents = form.retrieve($delegationKey + 'originalFn', []),
- formListeners = form.retrieve($delegationKey + 'listeners', []),
- self = this;
-
- forms.include(form);
- this.store($delegationKey + 'forms', forms);
-
- if (!formEvents.contains(fn)){
- var formListener = function(event){
- bubbleUp.call(self, split, event, fn);
- };
- form.addEvent(eventName, formListener);
-
- formEvents.push(fn);
- formListeners.push(formListener);
-
- form.store($delegationKey + eventName + 'originalFn', formEvents)
- .store($delegationKey + eventName + 'listeners', formListeners);
- }
- }
- };
-};
-
-var inputObserver = function(eventName){
- return {
- base: 'focusin',
- listener: function(split, fn, args){
- var events = {blur: function(){
- this.removeEvents(events);
- }}, self = this;
- events[eventName] = function(event){
- bubbleUp.call(self, split, event, fn);
- };
- args[0].target.addEvents(events);
- }
- };
-};
-
-var eventOptions = {
- mouseenter: {
- base: 'mouseover'
- },
- mouseleave: {
- base: 'mouseout'
- },
- focus: {
- base: 'focus' + (eventListenerSupport ? '' : 'in'),
- args: [true]
- },
- blur: {
- base: eventListenerSupport ? 'blur' : 'focusout',
- args: [true]
- }
-};
-
-if (!eventListenerSupport) Object.append(eventOptions, {
- submit: formObserver('submit'),
- reset: formObserver('reset'),
- change: inputObserver('change'),
- select: inputObserver('select')
-});
-
-Event.definePseudo('relay', {
- listener: function(split, fn, args){
- bubbleUp.call(this, split, args[0], fn);
- },
- options: eventOptions
-});
+DOMEvent.defineKeys({
+ '16': 'shift',
+ '17': 'control',
+ '18': 'alt',
+ '20': 'capslock',
+ '33': 'pageup',
+ '34': 'pagedown',
+ '35': 'end',
+ '36': 'home',
+ '144': 'numlock',
+ '145': 'scrolllock',
+ '186': ';',
+ '187': '=',
+ '188': ',',
+ '190': '.',
+ '191': '/',
+ '192': '`',
+ '219': '[',
+ '220': '\\',
+ '221': ']',
+ '222': "'",
+ '107': '+'
+}).defineKey(Browser.firefox ? 109 : 189, '-');
})();
@@ -3274,7 +3103,7 @@ var local = Element.Position = {
Element.implement({
position: function(options){
- if (options && (options.x != null || options.y != null)) {
+ if (options && (options.x != null || options.y != null)){
return (original ? original.apply(this, arguments) : this);
}
var position = this.setStyle('position', 'absolute').calculatePosition(options);
@@ -4123,7 +3952,7 @@ if (!window.Form) window.Form = {};
Element.implement('formUpdate', function(update, options){
var fq = this.retrieve('form.request');
- if (!fq) {
+ if (!fq){
fq = new Form.Request(this, update, options);
} else {
if (update) fq.setTarget(update);
@@ -4486,6 +4315,7 @@ provides: [Locale.en-US.Form.Validator]
Locale.define('en-US', 'FormValidator', {
required: 'This field is required.',
+ length: 'Please enter {length} characters (you entered {elLength} characters)',
minLength: 'Please enter at least {minLength} characters (you entered {length} characters).',
maxLength: 'Please enter no more than {maxLength} characters (you entered {length} characters).',
integer: 'Please enter an integer in this field. Numbers with decimals (e.g. 1.25) are not permitted.',
@@ -4875,10 +4705,22 @@ Form.Validator.addAllThese([
}
}],
+ ['length', {
+ errorMsg: function(element, props){
+ if (typeOf(props.length) != 'null')
+ return Form.Validator.getMsg('length').substitute({length: props.length, elLength: element.get('value').length});
+ else return '';
+ },
+ test: function(element, props){
+ if (typeOf(props.length) != 'null') return (element.get('value').length == props.length || element.get('value').length == 0);
+ else return true;
+ }
+ }],
+
['minLength', {
errorMsg: function(element, props){
if (typeOf(props.minLength) != 'null')
- return Form.Validator.getMsg('minLength').substitute({minLength:props.minLength,length:element.get('value').length });
+ return Form.Validator.getMsg('minLength').substitute({minLength: props.minLength, length: element.get('value').length});
else return '';
},
test: function(element, props){
@@ -4891,7 +4733,7 @@ Form.Validator.addAllThese([
errorMsg: function(element, props){
//props is {maxLength:10}
if (typeOf(props.maxLength) != 'null')
- return Form.Validator.getMsg('maxLength').substitute({maxLength:props.maxLength,length:element.get('value').length });
+ return Form.Validator.getMsg('maxLength').substitute({maxLength: props.maxLength, length: element.get('value').length});
else return '';
},
test: function(element, props){
@@ -5605,7 +5447,6 @@ var OverText = new Class({
change: this.assert
});
window.addEvent('resize', this.reposition);
- this.assert(true);
this.reposition();
return this;
},
@@ -7533,7 +7374,7 @@ var Sortables = new Class({
if (
!this.idle ||
event.rightClick ||
- ['button', 'input', 'a'].contains(event.target.get('tag'))
+ ['button', 'input', 'a', 'textarea'].contains(event.target.get('tag'))
) return;
this.idle = false;
@@ -8059,23 +7900,23 @@ var Asset = {
var script = new Element('script', {src: source, type: 'text/javascript'}),
doc = properties.document || document,
- loaded = 0,
- loadEvent = properties.onload || properties.onLoad;
-
- var load = loadEvent ? function(){ // make sure we only call the event once
- if (++loaded == 1) loadEvent.call(this);
- } : function(){};
+ load = properties.onload || properties.onLoad;
delete properties.onload;
delete properties.onLoad;
delete properties.document;
- return script.addEvents({
- load: load,
- readystatechange: function(){
- if (['loaded', 'complete'].contains(this.readyState)) load.call(this);
+ if (load){
+ if (typeof script.onreadystatechange != 'undefined'){
+ script.addEvent('readystatechange', function(){
+ if (['loaded', 'complete'].contains(this.readyState)) load.call(this);
+ });
+ } else {
+ script.addEvent('load', load);
}
- }).set(properties).inject(doc.head);
+ }
+
+ return script.set(properties).inject(doc.head);
},
css: function(source, properties){
@@ -8355,31 +8196,26 @@ this.Group = new Class({
initialize: function(){
this.instances = Array.flatten(arguments);
- this.events = {};
- this.checker = {};
},
addEvent: function(type, fn){
- this.checker[type] = this.checker[type] || {};
- this.events[type] = this.events[type] || [];
- if (this.events[type].contains(fn)) return false;
- else this.events[type].push(fn);
- this.instances.each(function(instance, i){
- instance.addEvent(type, this.check.pass([type, instance, i], this));
- }, this);
- return this;
- },
-
- check: function(type, instance, i){
- this.checker[type][i] = true;
- var every = this.instances.every(function(current, j){
- return this.checker[type][j] || false;
- }, this);
- if (!every) return;
- this.checker[type] = {};
- this.events[type].each(function(event){
- event.call(this, this.instances, instance);
- }, this);
+ var instances = this.instances,
+ len = instances.length,
+ togo = len,
+ args = new Array(len),
+ self = this;
+
+ instances.each(function(instance, i){
+ instance.addEvent(type, function(){
+ if (!args[i]) togo--;
+ args[i] = arguments;
+ if (!togo){
+ fn.call(self, instances, instance, args);
+ togo = len;
+ args = new Array(len);
+ }
+ });
+ });
}
});
@@ -8387,7 +8223,6 @@ this.Group = new Class({
})();
-
/*
---
@@ -8617,30 +8452,43 @@ var HtmlTable = new Class({
return this;
},
- push: function(row, rowProperties, target, tag, where){
- if (typeOf(row) == 'element' && row.get('tag') == 'tr'){
- row.inject(target || this.body, where);
- return {
- tr: row,
- tds: row.getChildren('td')
- };
- }
+ update: function(tr, row, tag){
+ var tds = tr.getChildren(tag || 'td'), last = tds.length - 1;
- var tds = row.map(function(data){
- var td = new Element(tag || 'td', data ? data.properties : {}),
+ row.each(function(data, index){
+ var td = tds[index] || new Element(tag || 'td').inject(tr),
content = (data ? data.content : '') || data,
type = typeOf(content);
- if (['element', 'array', 'collection', 'elements'].contains(type)) td.adopt(content);
+ if (data && data.properties) td.set(data.properties);
+ if (/(element(s?)|array|collection)/.test(type)) td.empty().adopt(content);
else td.set('html', content);
- return td;
+ if (index > last) tds.push(td);
+ else tds[index] = td;
});
return {
- tr: new Element('tr', rowProperties).inject(target || this.body, where).adopt(tds),
+ tr: tr,
tds: tds
};
+ },
+
+ push: function(row, rowProperties, target, tag, where){
+ if (typeOf(row) == 'element' && row.get('tag') == 'tr'){
+ row.inject(target || this.body, where);
+ return {
+ tr: row,
+ tds: row.getChildren('td')
+ };
+ }
+ return this.update(new Element('tr', rowProperties).inject(target || this.body, where), row, tag);
+ },
+
+ pushMany: function(rows, rowProperties, target, tag, where){
+ return rows.map(function(row){
+ return this.push(row, rowProperties, target, tag, where);
+ }, this);
}
});
@@ -8673,6 +8521,7 @@ authors:
requires:
- /HtmlTable
+ - /Element.Shortcuts
- /Class.refactor
provides: [HtmlTable.Zebra]
@@ -8684,7 +8533,8 @@ HtmlTable = Class.refactor(HtmlTable, {
options: {
classZebra: 'table-tr-odd',
- zebra: true
+ zebra: true,
+ zebraOnlyVisibleRows: true
},
initialize: function(){
@@ -8694,7 +8544,12 @@ HtmlTable = Class.refactor(HtmlTable, {
},
updateZebras: function(){
- Array.each(this.body.rows, this.zebra, this);
+ var index = 0;
+ Array.each(this.body.rows, function(row){
+ if (!this.options.zebraOnlyVisibleRows || row.isDisplayed()){
+ this.zebra(row, index++);
+ }
+ }, this);
},
setRowStyle: function(row, i){
@@ -8768,9 +8623,8 @@ HtmlTable = Class.refactor(HtmlTable, {
this.previous.apply(this, arguments);
if (this.occluded) return this.occluded;
this.sorted = {index: null, dir: 1};
- this.bound = {
- headClick: this.headClick.bind(this)
- };
+ if (!this.bound) this.bound = {};
+ this.bound.headClick = this.headClick.bind(this);
this.sortSpans = new Elements();
if (this.options.sortable){
this.enableSort();
@@ -8838,17 +8692,17 @@ HtmlTable = Class.refactor(HtmlTable, {
return this.sort(Array.indexOf(this.head.getElements(this.options.thSelector).flatten(), el) % this.body.rows[0].cells.length);
},
- serialize: function() {
+ serialize: function(){
var previousSerialization = this.previous.apply(this, arguments) || {};
- if (this.options.sortable) {
+ if (this.options.sortable){
previousSerialization.sortIndex = this.sorted.index;
previousSerialization.sortReverse = this.sorted.reverse;
}
return previousSerialization;
},
- restore: function(tableState) {
- if(this.options.sortable && tableState.sortIndex) {
+ restore: function(tableState){
+ if(this.options.sortable && tableState.sortIndex){
this.sort(tableState.sortIndex, tableState.sortReverse);
}
this.previous.apply(this, arguments);
@@ -9461,7 +9315,8 @@ HtmlTable = Class.refactor(HtmlTable, {
classSelectable: 'table-selectable',
shiftForMultiSelect: true,
allowMultiSelect: true,
- selectable: false
+ selectable: false,
+ selectHiddenRows: false
},
initialize: function(){
@@ -9470,13 +9325,12 @@ HtmlTable = Class.refactor(HtmlTable, {
this.selectedRows = new Elements();
- this.bound = {
- mouseleave: this.mouseleave.bind(this),
- clickRow: this.clickRow.bind(this),
- activateKeyboard: function() {
- if (this.keyboard && this.selectEnabled) this.keyboard.activate();
- }.bind(this)
- };
+ if (!this.bound) this.bound = {};
+ this.bound.mouseleave = this.mouseleave.bind(this);
+ this.bound.clickRow = this.clickRow.bind(this);
+ this.bound.activateKeyboard = function(){
+ if (this.keyboard && this.selectEnabled) this.keyboard.activate();
+ }.bind(this);
if (this.options.selectable) this.enableSelect();
},
@@ -9506,10 +9360,6 @@ HtmlTable = Class.refactor(HtmlTable, {
return ret;
},
- isSelected: function(row){
- return this.selectedRows.contains(row);
- },
-
toggleRow: function(row){
return this[(this.isSelected(row) ? 'de' : '') + 'selectRow'](row);
},
@@ -9533,23 +9383,31 @@ HtmlTable = Class.refactor(HtmlTable, {
return this;
},
+ isSelected: function(row){
+ return this.selectedRows.contains(row);
+ },
+
+ getSelected: function(){
+ return this.selectedRows;
+ },
+
getSelected: function(){
return this.selectedRows;
},
- serialize: function() {
+ serialize: function(){
var previousSerialization = this.previous.apply(this, arguments) || {};
- if (this.options.selectable) {
- previousSerialization.selectedRows = this.selectedRows.map(function(row) {
+ if (this.options.selectable){
+ previousSerialization.selectedRows = this.selectedRows.map(function(row){
return Array.indexOf(this.body.rows, row);
}.bind(this));
}
return previousSerialization;
},
- restore: function(tableState) {
- if(this.options.selectable && tableState.selectedRows) {
- tableState.selectedRows.each(function(index) {
+ restore: function(tableState){
+ if(this.options.selectable && tableState.selectedRows){
+ tableState.selectedRows.each(function(index){
this.selectRow(this.body.rows[index]);
}.bind(this));
}
@@ -9591,7 +9449,9 @@ HtmlTable = Class.refactor(HtmlTable, {
endRow = tmp;
}
- for (var i = startRow; i <= endRow; i++) this[method](rows[i], true);
+ for (var i = startRow; i <= endRow; i++){
+ if (this.options.selectHiddenRows || rows[i].isDisplayed()) this[method](rows[i], true);
+ }
return this;
},
@@ -9635,7 +9495,7 @@ HtmlTable = Class.refactor(HtmlTable, {
shiftFocus: function(offset, event){
if (!this.focused) return this.selectRow(this.body.rows[0], event);
- var to = this.getRowByOffset(offset);
+ var to = this.getRowByOffset(offset, this.options.selectHiddenRows);
if (to === null || this.focused == this.body.rows[to]) return this;
this.toggleRow(this.body.rows[to], event);
},
@@ -9654,14 +9514,25 @@ HtmlTable = Class.refactor(HtmlTable, {
this.rangeStart = row;
},
- getRowByOffset: function(offset){
+ getRowByOffset: function(offset, includeHiddenRows){
if (!this.focused) return 0;
- var rows = Array.clone(this.body.rows),
- index = rows.indexOf(this.focused) + offset;
-
- if (index < 0) index = null;
- if (index >= rows.length) index = null;
-
+ var index = Array.indexOf(this.body.rows, this.focused);
+ if ((index == 0 && offset < 0) || (index == this.body.rows.length -1 && offset > 0)) return null;
+ if (includeHiddenRows){
+ index += offset;
+ } else {
+ var limit = 0,
+ count = 0;
+ if (offset > 0){
+ while (count < offset && index < this.body.rows.length -1){
+ if (this.body.rows[++index].isDisplayed()) count++;
+ }
+ } else {
+ while (count > offset && index > 0){
+ if (this.body.rows[--index].isDisplayed()) count--;
+ }
+ }
+ }
return index;
},
@@ -9681,7 +9552,7 @@ HtmlTable = Class.refactor(HtmlTable, {
if (this.options.useKeyboard || this.keyboard){
if (!this.keyboard) this.keyboard = new Keyboard();
- if (!this.selectKeysDefined) {
+ if (!this.selectKeysDefined){
this.selectKeysDefined = true;
var timer, held;
@@ -9689,8 +9560,7 @@ HtmlTable = Class.refactor(HtmlTable, {
var mover = function(e){
clearTimeout(timer);
e.preventDefault();
-
- var to = this.body.rows[this.getRowByOffset(offset)];
+ var to = this.body.rows[this.getRowByOffset(offset, this.options.selectHiddenRows)];
if (e.shift && to && this.isSelected(to)){
this.deselectRow(this.focused);
this.focused = to;
@@ -9717,7 +9587,7 @@ HtmlTable = Class.refactor(HtmlTable, {
clearTimeout(timer);
held = false;
};
-
+
this.keyboard.addEvents({
'keydown:shift+up': move(-1),
'keydown:shift+down': move(1),
@@ -9906,6 +9776,7 @@ this.Tips = new Class({
Implements: [Events, Options],
options: {/*
+ id: null,
onAttach: function(element){},
onDetach: function(element){},
onBound: function(coords){},*/
@@ -9924,7 +9795,8 @@ this.Tips = new Class({
className: 'tip-wrap',
offset: {x: 16, y: 16},
windowPadding: {x:0, y:0},
- fixed: false
+ fixed: false,
+ waiAria: true
},
initialize: function(){
@@ -9937,6 +9809,11 @@ this.Tips = new Class({
this.setOptions(params.options);
if (params.elements) this.attach(params.elements);
this.container = new Element('div', {'class': 'tip'});
+
+ if (this.options.id){
+ this.container.set('id', this.options.id);
+ if (this.options.waiAria) this.attachWaiAria();
+ }
},
toElement: function(){
@@ -9958,6 +9835,33 @@ this.Tips = new Class({
return this.tip;
},
+ attachWaiAria: function(){
+ var id = this.options.id;
+ this.container.set('role', 'tooltip');
+
+ if (!this.waiAria){
+ this.waiAria = {
+ show: function(element){
+ if (id) element.set('aria-describedby', id);
+ this.container.set('aria-hidden', 'false');
+ },
+ hide: function(element){
+ if (id) element.erase('aria-describedby');
+ this.container.set('aria-hidden', 'true');
+ }
+ };
+ }
+ this.addEvents(this.waiAria);
+ },
+
+ detachWaiAria: function(){
+ if (this.waiAria){
+ this.container.erase('role');
+ this.container.erase('aria-hidden');
+ this.removeEvents(this.waiAria);
+ }
+ },
+
attach: function(elements){
$$(elements).each(function(element){
var title = read(this.options.title, element),
@@ -11608,6 +11512,7 @@ provides: [Locale.fr-FR.Form.Validator]
Locale.define('fr-FR', 'FormValidator', {
required: 'Ce champ est obligatoire.',
+ length: 'Veuillez saisir {length} caractère(s) (vous avez saisi {elLength} caractère(s)',
minLength: 'Veuillez saisir un minimum de {minLength} caractère(s) (vous avez saisi {length} caractère(s)).',
maxLength: 'Veuillez saisir un maximum de {maxLength} caractère(s) (vous avez saisi {length} caractère(s)).',
integer: 'Veuillez saisir un nombre entier dans ce champ. Les nombres décimaux (ex : "1,25") ne sont pas autorisés.',
@@ -12001,6 +11906,12 @@ Locale.define('it-IT', 'Date', {
hoursAgo: 'circa {delta} ore fa',
dayAgo: 'circa 1 giorno fa',
daysAgo: 'circa {delta} giorni fa',
+ weekAgo: 'una settimana fa',
+ weeksAgo: '{delta} settimane fa',
+ monthAgo: 'un mese fa',
+ monthsAgo: '{delta} mesi fa',
+ yearAgo: 'un anno fa',
+ yearsAgo: '{delta} anni fa',
lessThanMinuteUntil: 'tra meno di un minuto',
minuteUntil: 'tra circa un minuto',
@@ -12008,7 +11919,13 @@ Locale.define('it-IT', 'Date', {
hourUntil: "tra circa un'ora",
hoursUntil: 'tra circa {delta} ore',
dayUntil: 'tra circa un giorno',
- daysUntil: 'tra circa {delta} giorni'
+ daysUntil: 'tra circa {delta} giorni',
+ weekUntil: 'tra una settimana',
+ weeksUntil: 'tra {delta} settimane',
+ monthUntil: 'tra un mese',
+ monthsUntil: 'tra {delta} mesi',
+ yearUntil: 'tra un anno',
+ yearsUntil: 'tra {delta} anni'
});
@@ -12323,6 +12240,7 @@ provides: [Locale.nl-NL.Form.Validator]
Locale.define('nl-NL', 'FormValidator', {
required: 'Dit veld is verplicht.',
+ length: 'Vul precies {length} karakters in (je hebt {elLength} karakters ingevoerd).',
minLength: 'Vul minimaal {minLength} karakters in (je hebt {length} karakters ingevoerd).',
maxLength: 'Vul niet meer dan {maxLength} karakters in (je hebt {length} karakters ingevoerd).',
integer: 'Vul een getal in. Getallen met decimalen (bijvoorbeeld 1.25) zijn niet toegestaan.',
--
mootools
More information about the Pkg-javascript-commits
mailing list