vendor/assets/javascripts/mootools.js in mootools-rails-1.0.1 vs vendor/assets/javascripts/mootools.js in mootools-rails-2.0.0
- old
+ new
@@ -6,20 +6,23 @@
- 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.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
+...
+*/
+
/*
---
name: Core
description: The heart of MooTools.
license: MIT-style license.
-copyright: Copyright (c) 2006-2010 [Valerio Proietti](http://mad4milk.net/).
+copyright: Copyright (c) 2006-2012 [Valerio Proietti](http://mad4milk.net/).
authors: The MooTools production team (http://mootools.net/developers/)
inspiration:
- Class implementation inspired by [Base.js](http://dean.edwards.name/weblog/2006/03/base/) Copyright (c) 2006 Dean Edwards, [GNU Lesser General Public License](http://opensource.org/licenses/lgpl-license.php)
@@ -31,19 +34,19 @@
*/
(function(){
this.MooTools = {
- version: '1.4.1',
- build: 'd1fb25710e3c5482a219ab9dc675a4e0ad2176b6'
+ version: '1.4.5',
+ build: 'ab8ea8824dc3b24b6666867a2c4ed58ebb762cf0'
};
// typeOf, instanceOf
var typeOf = this.typeOf = function(item){
if (item == null) return 'null';
- if (item.$family) return item.$family();
+ if (item.$family != null) return item.$family();
if (item.nodeName){
if (item.nodeType == 1) return 'element';
if (item.nodeType == 3) return (/\S/).test(item.nodeValue) ? 'textnode' : 'whitespace';
} else if (typeof item.length == 'number'){
@@ -59,10 +62,13 @@
var constructor = item.$constructor || item.constructor;
while (constructor){
if (constructor === object) return true;
constructor = constructor.parent;
}
+ /*<ltIE8>*/
+ if (!item.hasOwnProperty) return false;
+ /*</ltIE8>*/
return item instanceof object;
};
// Function overloading
@@ -91,12 +97,13 @@
Function.prototype.overloadGetter = function(usePlural){
var self = this;
return function(a){
var args, result;
- if (usePlural || typeof a != 'string') args = a;
+ if (typeof a != 'string') args = a;
else if (arguments.length > 1) args = arguments;
+ else if (usePlural) args = [a];
if (args){
result = {};
for (var i = 0; i < args.length; i++) result[args[i]] = self.call(this, args[i]);
} else {
result = self.call(this, a);
@@ -249,19 +256,23 @@
var key = methods[i],
generic = object[key],
proto = prototype[key];
if (generic) generic.protect();
+ if (isType && proto) object.implement(key, proto.protect());
+ }
- if (isType && proto){
- delete prototype[key];
- prototype[key] = proto.protect();
- }
+ if (isType){
+ var methodsEnumerable = prototype.propertyIsEnumerable(methods[0]);
+ object.forEachMethod = function(fn){
+ if (!methodsEnumerable) for (var i = 0, l = methods.length; i < l; i++){
+ fn.call(prototype, prototype[methods[i]], methods[i]);
+ }
+ for (var key in prototype) fn.call(prototype, prototype[key], key)
+ };
}
- if (isType) object.implement(prototype);
-
return force;
};
force('String', String, [
'charAt', 'charCodeAt', 'concat', 'indexOf', 'lastIndexOf', 'match', 'quote', 'replace', 'search',
@@ -427,12 +438,13 @@
return true;
},
filter: function(fn, bind){
var results = [];
- 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]);
+ for (var value, i = 0, l = this.length >>> 0; i < l; i++) if (i in this){
+ value = this[i];
+ if (fn.call(bind, value, i, this)) results.push(value);
}
return results;
},
indexOf: function(item, from){
@@ -934,21 +946,10 @@
(function(){
var document = this.document;
var window = document.window = this;
-var UID = 1;
-
-this.$uid = (window.ActiveXObject) ? function(item){
- return (item.uid || (item.uid = [UID++]))[0];
-} : function(item){
- return item.uid || (item.uid = UID++);
-};
-
-$uid(window);
-$uid(document);
-
var ua = navigator.userAgent.toLowerCase(),
platform = navigator.platform.toLowerCase(),
UA = ua.match(/(opera|ie|firefox|chrome|version)[\s\/:]([\w\d\.]+)?.*?(safari|version[\s\/:]([\w\d\.]+)|$)/) || [null, 'unknown', 0],
mode = UA[1] == 'ie' && document.documentMode;
@@ -1916,12 +1917,18 @@
return !!(node && (node.specified || node.nodeValue));
};
// contains
// FIXME: Add specs: local.contains should be different for xml and html documents?
- features.contains = (root && this.isNativeCode(root.contains)) ? function(context, node){
+ var nativeRootContains = root && this.isNativeCode(root.contains),
+ nativeDocumentContains = document && this.isNativeCode(document.contains);
+
+ features.contains = (nativeRootContains && nativeDocumentContains) ? function(context, node){
return context.contains(node);
+ } : (nativeRootContains && !nativeDocumentContains) ? function(context, node){
+ // IE8 does not have .contains on document.
+ return context === node || ((context === document) ? document.documentElement : context).contains(node);
} : (root && root.compareDocumentPosition) ? function(context, node){
return context === node || !!(context.compareDocumentPosition(node) & 16);
} : function(context, node){
if (node) do {
if (node === context) return true;
@@ -2312,11 +2319,11 @@
if (id && node.getAttribute('id') != id) return false;
var i, part, cls;
if (classes) for (i = classes.length; i--;){
- cls = node.getAttribute('class') || node.className;
+ cls = this.getAttribute(node, 'class');
if (!(cls && classes[i].regexp.test(cls))) return false;
}
if (attributes) for (i = attributes.length; i--;){
part = attributes[i];
if (part.operator ? !part.test(this.getAttribute(node, part.key)) : !this.hasAttribute(node, part.key)) return false;
@@ -2498,11 +2505,11 @@
'nth-of-type': local.createNTHPseudo('firstChild', 'nextSibling', 'posNTHType', true),
'nth-last-of-type': local.createNTHPseudo('lastChild', 'previousSibling', 'posNTHTypeLast', true),
'index': function(node, index){
- return this['pseudo:nth-child'](node, '' + index + 1);
+ return this['pseudo:nth-child'](node, '' + (index + 1));
},
'even': function(node){
return this['pseudo:nth-child'](node, '2n');
},
@@ -2570,14 +2577,10 @@
// attributes methods
var attributeGetters = local.attributeGetters = {
- 'class': function(){
- return this.getAttribute('class') || this.className;
- },
-
'for': function(){
return ('htmlFor' in this) ? this.htmlFor : this.getAttribute('for');
},
'href': function(){
@@ -2608,11 +2611,11 @@
// Slick
var Slick = local.Slick = (this.Slick || {});
-Slick.version = '1.1.6';
+Slick.version = '1.1.7';
// Slick finder
Slick.search = function(context, expression, append){
return local.search(context, expression, append);
@@ -2737,12 +2740,21 @@
}
return document.newElement(tag, props);
};
-if (Browser.Element) Element.prototype = Browser.Element.prototype;
+if (Browser.Element){
+ Element.prototype = Browser.Element.prototype;
+ // IE8 and IE9 require the wrapping.
+ Element.prototype._fireEvent = (function(fireEvent){
+ return function(type, event){
+ return fireEvent.call(this, type, event);
+ };
+ })(Element.prototype.fireEvent);
+}
+
new Type('Element', Element).mirror(function(name){
if (Array.prototype[name]) return;
var obj = {};
obj[name] = function(){
@@ -2758,11 +2770,14 @@
});
if (!Browser.Element){
Element.parent = Object;
- Element.Prototype = {'$family': Function.from('element').hide()};
+ Element.Prototype = {
+ '$constructor': Element,
+ '$family': Function.from('element').hide()
+ };
Element.mirror(function(name, method){
Element.Prototype[name] = method;
});
}
@@ -2873,20 +2888,21 @@
var result = splice.apply(this, arguments);
while (length >= this.length) delete this[length--];
return result;
}.protect());
-Elements.implement(Array.prototype);
+Array.forEachMethod(function(method, name){
+ Elements.implement(name, method);
+});
Array.mirror(Elements);
/*<ltIE8>*/
var createElementAcceptsHTML;
try {
- var x = document.createElement('<input name=x>');
- createElementAcceptsHTML = (x.name == 'x');
-} catch(e){}
+ createElementAcceptsHTML = (document.createElement('<input name=x>').name == 'x');
+} catch (e){}
var escapeQuotes = function(html){
return ('' + html).replace(/&/g, '&').replace(/"/g, '"');
};
/*</ltIE8>*/
@@ -2910,10 +2926,15 @@
});
})();
+(function(){
+
+Slick.uidOf(window);
+Slick.uidOf(document);
+
Document.implement({
newTextNode: function(text){
return this.createTextNode(text);
},
@@ -2934,12 +2955,17 @@
id = Slick.find(doc, '#' + id.replace(/(\W)/g, '\\$1'));
return (id) ? types.element(id, nocash) : null;
},
element: function(el, nocash){
- $uid(el);
+ Slick.uidOf(el);
if (!nocash && !el.$family && !(/^(?:object|embed)$/i).test(el.tagName)){
+ var fireEvent = el.fireEvent;
+ // wrapping needed in IE7, or else crash
+ el._fireEvent = function(type, event){
+ return fireEvent(type, event);
+ };
Object.append(el, Element.Prototype);
}
return el;
},
@@ -2953,11 +2979,11 @@
types.textnode = types.whitespace = types.window = types.document = function(zero){
return zero;
};
return function(el, nocash, doc){
- if (el && el.$family && el.uid) return el;
+ if (el && el.$family && el.uniqueNumber) return el;
var type = typeOf(el);
return (types[type]) ? types[type](el, nocash, doc || document) : null;
};
})()
@@ -3073,12 +3099,10 @@
else if (Type.isEnumerable(selector)) return new Elements(selector);
}
return new Elements(arguments);
});
-(function(){
-
// Inserters
var inserters = {
before: function(context, element){
@@ -3112,22 +3136,17 @@
// properties
var properties = {};
Array.forEach([
'type', 'value', 'defaultValue', 'accessKey', 'cellPadding', 'cellSpacing', 'colSpan',
- 'frameBorder', 'readOnly', 'rowSpan', 'tabIndex', 'useMap'
+ 'frameBorder', 'rowSpan', 'tabIndex', 'useMap'
], function(property){
properties[property.toLowerCase()] = property;
});
-Object.append(properties, {
- 'html': 'innerHTML',
- 'text': (function(){
- var temp = document.createElement('div');
- return (temp.textContent == null) ? 'innerText': 'textContent';
- })()
-});
+properties.html = 'innerHTML';
+properties.text = (document.createElement('div').textContent == null) ? 'innerText': 'textContent';
Object.forEach(properties, function(real, key){
propertySetters[key] = function(node, value){
node[real] = value;
};
@@ -3160,39 +3179,86 @@
// Special cases
Object.append(propertySetters, {
'class': function(node, value){
- ('className' in node) ? node.className = value : node.setAttribute('class', value);
+ ('className' in node) ? node.className = (value || '') : node.setAttribute('class', 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);
+ },
+
+ 'value': function(node, value){
+ node.value = (value != null) ? value : '';
}
});
+propertyGetters['class'] = function(node){
+ return ('className' in node) ? node.className || null : node.getAttribute('class');
+};
+
+/* <webkit> */
+var el = document.createElement('button');
+// IE sets type as readonly and throws
+try { el.type = 'button'; } catch(e){}
+if (el.type != 'button') propertySetters.type = function(node, value){
+ node.setAttribute('type', value);
+};
+el = null;
+/* </webkit> */
+
+/*<IE>*/
+var input = document.createElement('input');
+input.value = 't';
+input.type = 'submit';
+if (input.value != 't') propertySetters.type = function(node, type){
+ var value = node.value;
+ node.type = type;
+ node.value = value;
+};
+input = null;
+/*</IE>*/
+
/* getProperty, setProperty */
+/* <ltIE9> */
+var pollutesGetAttribute = (function(div){
+ div.random = 'attribute';
+ return (div.getAttribute('random') == 'attribute');
+})(document.createElement('div'));
+
+/* <ltIE9> */
+
Element.implement({
setProperty: function(name, value){
- var lower = name.toLowerCase();
- if (value == null){
- if (!booleans[lower]){
+ var setter = propertySetters[name.toLowerCase()];
+ if (setter){
+ setter(this, value);
+ } else {
+ /* <ltIE9> */
+ if (pollutesGetAttribute) var attributeWhiteList = this.retrieve('$attributeWhiteList', {});
+ /* </ltIE9> */
+
+ if (value == null){
this.removeAttribute(name);
- return this;
+ /* <ltIE9> */
+ if (pollutesGetAttribute) delete attributeWhiteList[name];
+ /* </ltIE9> */
+ } else {
+ this.setAttribute(name, '' + value);
+ /* <ltIE9> */
+ if (pollutesGetAttribute) attributeWhiteList[name] = true;
+ /* </ltIE9> */
}
- value = false;
}
- var setter = propertySetters[lower];
- if (setter) setter(this, value);
- else this.setAttribute(name, value);
return this;
},
setProperties: function(attributes){
for (var attribute in attributes) this.setProperty(attribute, attributes[attribute]);
@@ -3200,10 +3266,22 @@
},
getProperty: function(name){
var getter = propertyGetters[name.toLowerCase()];
if (getter) return getter(this);
+ /* <ltIE9> */
+ if (pollutesGetAttribute){
+ var attr = this.getAttributeNode(name), attributeWhiteList = this.retrieve('$attributeWhiteList', {});
+ if (!attr) return null;
+ if (attr.expando && !attributeWhiteList[name]){
+ var outer = this.outerHTML;
+ // segment by the opening tag and find mention of attribute name
+ if (outer.substr(0, outer.search(/\/?['"]?>(?![^<]*<['"])/)).indexOf(name) < 0) return null;
+ attributeWhiteList[name] = true;
+ }
+ }
+ /* </ltIE9> */
var result = Slick.getAttribute(this, name);
return (!result && !Slick.hasAttribute(this, name)) ? null : result;
},
getProperties: function(){
@@ -3326,11 +3404,11 @@
var get = function(uid){
return (storage[uid] || (storage[uid] = {}));
};
var clean = function(item){
- var uid = item.uid;
+ var uid = item.uniqueNumber;
if (item.removeEvents) item.removeEvents();
if (item.clearAttributes) item.clearAttributes();
if (uid != null){
delete collected[uid];
delete storage[uid];
@@ -3372,11 +3450,11 @@
if (!keepid) node.removeAttribute('id');
/*<ltIE9>*/
if (node.clearAttributes){
node.clearAttributes();
node.mergeAttributes(element);
- node.removeAttribute('uid');
+ node.removeAttribute('uniqueNumber');
if (node.options){
var no = node.options, eo = element.options;
for (var j = no.length; j--;) no[j].selected = eo[j].selected;
}
}
@@ -3404,11 +3482,11 @@
fn = function(){
self.removeListener('unload', fn);
old();
};
} else {
- collected[$uid(this)] = this;
+ collected[Slick.uidOf(this)] = this;
}
if (this.addEventListener) this.addEventListener(type, fn, !!arguments[2]);
else this.attachEvent('on' + type, fn);
return this;
},
@@ -3418,23 +3496,23 @@
else this.detachEvent('on' + type, fn);
return this;
},
retrieve: function(property, dflt){
- var storage = get($uid(this)), prop = storage[property];
+ var storage = get(Slick.uidOf(this)), prop = storage[property];
if (dflt != null && prop == null) prop = storage[property] = dflt;
return prop != null ? prop : null;
},
store: function(property, value){
- var storage = get($uid(this));
+ var storage = get(Slick.uidOf(this));
storage[property] = value;
return this;
},
eliminate: function(property){
- var storage = get($uid(this));
+ var storage = get(Slick.uidOf(this));
delete storage[property];
return this;
}
});
@@ -3472,65 +3550,82 @@
return this.tagName.toLowerCase();
}
};
-/*<!webkit>*/
-Element.Properties.html = (function(){
+Element.Properties.html = {
- var tableTest = Function.attempt(function(){
- var table = document.createElement('table');
- table.innerHTML = '<tr><td></td></tr>';
- });
+ set: function(html){
+ if (html == null) html = '';
+ else if (typeOf(html) == 'array') html = html.join('');
+ this.innerHTML = html;
+ },
- var wrapper = document.createElement('div');
+ erase: function(){
+ this.innerHTML = '';
+ }
- var translations = {
- table: [1, '<table>', '</table>'],
- select: [1, '<select>', '</select>'],
- tbody: [2, '<table><tbody>', '</tbody></table>'],
- tr: [3, '<table><tbody><tr>', '</tr></tbody></table>']
- };
- 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>*/
+/*<ltIE9>*/
+// technique by jdbarlett - http://jdbartlett.com/innershiv/
+var div = document.createElement('div');
+div.innerHTML = '<nav></nav>';
+var supportsHTML5Elements = (div.childNodes.length == 1);
+if (!supportsHTML5Elements){
+ 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]);
+}
+div = null;
+/*</ltIE9>*/
- var html = {
- set: function(html){
- if (typeOf(html) == 'array') html = html.join('');
+/*<IE>*/
+var supportsTableInnerHTML = Function.attempt(function(){
+ var table = document.createElement('table');
+ table.innerHTML = '<tr><td></td></tr>';
+ return true;
+});
- 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];
- for (var i = wrap[0]; i--;) first = first.firstChild;
- this.empty().adopt(first.childNodes);
- } else {
- this.innerHTML = html;
- }
- }
- };
+/*<ltFF4>*/
+var tr = document.createElement('tr'), html = '<td></td>';
+tr.innerHTML = html;
+var supportsTRInnerHTML = (tr.innerHTML == html);
+tr = null;
+/*</ltFF4>*/
- html.erase = html.set;
+if (!supportsTableInnerHTML || !supportsTRInnerHTML || !supportsHTML5Elements){
- return html;
-})();
-/*</!webkit>*/
+ Element.Properties.html.set = (function(set){
+ var translations = {
+ table: [1, '<table>', '</table>'],
+ select: [1, '<select>', '</select>'],
+ tbody: [2, '<table><tbody>', '</tbody></table>'],
+ tr: [3, '<table><tbody><tr>', '</tr></tbody></table>']
+ };
+
+ translations.thead = translations.tfoot = translations.tbody;
+
+ return function(html){
+ var wrap = translations[this.get('tag')];
+ if (!wrap && !supportsHTML5Elements) wrap = [0, '', ''];
+ if (!wrap) return set.call(this, html);
+
+ var level = wrap[0], wrapper = document.createElement('div'), target = wrapper;
+ if (!supportsHTML5Elements) fragment.appendChild(wrapper);
+ wrapper.innerHTML = [wrap[1], html, wrap[2]].flatten().join('');
+ while (level--) target = target.firstChild;
+ this.empty().adopt(target.childNodes);
+ if (!supportsHTML5Elements) fragment.removeChild(wrapper);
+ wrapper = null;
+ };
+
+ })(Element.Properties.html.set);
+}
+/*</IE>*/
+
/*<ltIE9>*/
var testForm = document.createElement('form');
testForm.innerHTML = '<select><option>s</option></select>';
if (testForm.firstChild.value != 's') Element.Properties.value = {
@@ -3557,12 +3652,27 @@
var attr = option.getAttributeNode('value');
return (attr && attr.specified) ? option.value : option.get('text');
}
};
+testForm = null;
/*</ltIE9>*/
+/*<IE>*/
+if (document.createElement('div').getAttributeNode('id')) Element.Properties.id = {
+ set: function(id){
+ this.id = this.getAttributeNode('id').value = id;
+ },
+ get: function(){
+ return this.id || null;
+ },
+ erase: function(){
+ this.id = this.getAttributeNode('id').value = '';
+ }
+};
+/*</IE>*/
+
})();
/*
---
@@ -3582,31 +3692,42 @@
(function(){
var html = document.html;
+//<ltIE9>
+// Check for oldIE, which does not remove styles when they're set to null
+var el = document.createElement('div');
+el.style.color = 'red';
+el.style.color = null;
+var doesNotRemoveStyles = el.style.color == 'red';
+el = null;
+//</ltIE9>
+
Element.Properties.styles = {set: function(styles){
this.setStyles(styles);
}};
var hasOpacity = (html.style.opacity != null),
hasFilter = (html.style.filter != null),
reAlpha = /alpha\(opacity=([\d.]+)\)/i;
var setVisibility = function(element, opacity){
element.store('$opacity', opacity);
- element.style.visibility = opacity > 0 ? 'visible' : 'hidden';
+ element.style.visibility = opacity > 0 || opacity == null ? 'visible' : 'hidden';
};
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;
+ var style = element.style;
+ if (!element.currentStyle || !element.currentStyle.hasLayout) style.zoom = 1;
+ if (opacity == null || opacity == 1) opacity = '';
+ else opacity = 'alpha(opacity=' + (opacity * 100).limit(0, 100).round() + ')';
+ var filter = style.filter || element.getComputedStyle('filter') || '';
+ style.filter = reAlpha.test(filter) ? filter.replace(reAlpha, opacity) : filter + opacity;
+ if (!style.filter) style.removeAttribute('filter');
} : setVisibility));
var getOpacity = (hasOpacity ? function(element){
var opacity = element.style.opacity || element.getComputedStyle('opacity');
return (opacity == '') ? 1 : opacity.toFloat();
@@ -3632,11 +3753,12 @@
return (computed) ? computed.getPropertyValue((property == floatName) ? 'float' : property.hyphenate()) : null;
},
setStyle: function(property, value){
if (property == 'opacity'){
- setOpacity(this, parseFloat(value));
+ if (value != null) value = parseFloat(value);
+ setOpacity(this, value);
return this;
}
property = (property == 'float' ? floatName : property).camelCase();
if (typeOf(value) != 'string'){
var map = (Element.Styles[property] || '@').split(' ');
@@ -3646,10 +3768,15 @@
}).join(' ');
} else if (value == String(Number(value))){
value = Math.round(value);
}
this.style[property] = value;
+ //<ltIE9>
+ if ((value == '' || value == null) && doesNotRemoveStyles && this.style.removeAttribute){
+ this.style.removeAttribute(property);
+ }
+ //</ltIE9>
return this;
},
getStyle: function(property){
if (property == 'opacity') return getOpacity(this);
@@ -3667,20 +3794,21 @@
if (result){
result = String(result);
var color = result.match(/rgba?\([\d\s,]+\)/);
if (color) result = result.replace(color[0], color[0].rgbToHex());
}
- if (Browser.opera || (Browser.ie && isNaN(parseFloat(result)))){
- if ((/^(height|width)$/).test(property)){
+ if (Browser.opera || Browser.ie){
+ if ((/^(height|width)$/).test(property) && !(/px$/.test(result))){
var values = (property == 'width') ? ['left', 'right'] : ['top', 'bottom'], size = 0;
values.each(function(value){
size += this.getStyle('border-' + value + '-width').toInt() + this.getStyle('padding-' + value).toInt();
}, this);
return this['offset' + property.capitalize()] - size + 'px';
}
- if (Browser.opera && String(result).indexOf('px') != -1) return result;
- if ((/^border(.+)Width|margin|padding/).test(property)) return '0px';
+ if (Browser.ie && (/^border(.+)Width|margin|padding/).test(property) && isNaN(parseFloat(result))){
+ return '0px';
+ }
}
return result;
},
setStyles: function(styles){
@@ -3736,11 +3864,11 @@
/*
---
name: Element.Event
-description: Contains Element methods for dealing with events. This file also includes mouseenter and mouseleave custom Element Events.
+description: Contains Element methods for dealing with events. This file also includes mouseenter and mouseleave custom Element Events, if necessary.
license: MIT-style license.
requires: [Element, Event]
@@ -3874,45 +4002,45 @@
focus: 2, blur: 2, change: 2, reset: 2, select: 2, submit: 2, paste: 2, input: 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
};
-var check = function(event){
- var related = event.relatedTarget;
- if (related == null) return true;
- if (!related) return false;
- return (related != this && related.prefix != 'xul' && typeOf(this) != 'document' && !this.contains(related));
-};
+Element.Events = {mousewheel: {
+ base: (Browser.firefox) ? 'DOMMouseScroll' : 'mousewheel'
+}};
-Element.Events = {
+if ('onmouseenter' in document.documentElement){
+ Element.NativeEvents.mouseenter = Element.NativeEvents.mouseleave = 2;
+} else {
+ var check = function(event){
+ var related = event.relatedTarget;
+ if (related == null) return true;
+ if (!related) return false;
+ return (related != this && related.prefix != 'xul' && typeOf(this) != 'document' && !this.contains(related));
+ };
- mouseenter: {
+ Element.Events.mouseenter = {
base: 'mouseover',
condition: check
- },
+ };
- mouseleave: {
+ Element.Events.mouseleave = {
base: 'mouseout',
condition: check
- },
+ };
+}
- mousewheel: {
- base: (Browser.firefox) ? 'DOMMouseScroll' : 'mousewheel'
- }
-
-};
-
/*<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);
+ return this.type != 'radio' || (event.event.propertyName == 'checked' && this.checked);
}
}
}
/*</ltIE9>*/
@@ -4609,16 +4737,35 @@
//prepares the base from/to object
prepare: function(element, property, values){
values = Array.from(values);
- if (values[1] == null){
- values[1] = values[0];
- values[0] = element.getStyle(property);
+ var from = values[0], to = values[1];
+ if (to == null){
+ to = from;
+ from = element.getStyle(property);
+ var unit = this.options.unit;
+ // adapted from: https://github.com/ryanmorr/fx/blob/master/fx.js#L299
+ if (unit && from.slice(-unit.length) != unit && parseFloat(from) != 0){
+ element.setStyle(property, to + unit);
+ var value = element.getComputedStyle(property);
+ // IE and Opera support pixelLeft or pixelWidth
+ if (!(/px$/.test(value))){
+ value = element.style[('pixel-' + property).camelCase()];
+ if (value == null){
+ // adapted from Dean Edwards' http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
+ var left = element.style.left;
+ element.style.left = to + unit;
+ value = element.style.pixelLeft;
+ element.style.left = left;
+ }
+ }
+ from = (to || 1) / (parseFloat(value) || 1) * (parseFloat(from) || 0);
+ element.setStyle(property, from + unit);
+ }
}
- var parsed = values.map(this.parse);
- return {from: parsed[0], to: parsed[1]};
+ return {from: this.parse(from), to: this.parse(to)};
},
//parses a value into an array
parse: function(value){
@@ -4802,31 +4949,33 @@
this.get('tween').start(property, from, to);
return this;
},
fade: function(how){
- var fade = this.get('tween'), method, to, toggle;
- if (how == null) how = 'toggle';
- switch (how){
- case 'in': method = 'start'; to = 1; break;
- case 'out': method = 'start'; to = 0; break;
- case 'show': method = 'set'; to = 1; break;
- case 'hide': method = 'set'; to = 0; break;
+ var fade = this.get('tween'), method, args = ['opacity'].append(arguments), toggle;
+ if (args[1] == null) args[1] = 'toggle';
+ switch (args[1]){
+ case 'in': method = 'start'; args[1] = 1; break;
+ case 'out': method = 'start'; args[1] = 0; break;
+ case 'show': method = 'set'; args[1] = 1; break;
+ case 'hide': method = 'set'; args[1] = 0; break;
case 'toggle':
var flag = this.retrieve('fade:flag', this.getStyle('opacity') == 1);
method = 'start';
- to = flag ? 0 : 1;
+ args[1] = flag ? 0 : 1;
this.store('fade:flag', !flag);
toggle = true;
break;
- default: method = 'start'; to = how;
+ default: method = 'start';
}
if (!toggle) this.eliminate('fade:flag');
- fade[method]('opacity', to);
+ fade[method].apply(fade, args);
+ var to = args[args.length - 1];
if (method == 'set' || to != 0) this.setStyle('visibility', to == 0 ? 'hidden' : 'visible');
else fade.chain(function(){
this.element.setStyle('visibility', 'hidden');
+ this.callChain();
});
return this;
},
highlight: function(start, end){
@@ -5247,11 +5396,11 @@
}, this);
this.fireEvent('request');
xhr.send(data);
if (!this.options.async) this.onStateChange();
- if (this.options.timeout) this.timer = this.timeout.delay(this.options.timeout, this);
+ else if (this.options.timeout) this.timer = this.timeout.delay(this.options.timeout, this);
return this;
},
cancel: function(){
if (!this.running) return this;
@@ -5312,10 +5461,11 @@
});
})();
+
/*
---
name: Request.HTML
@@ -5822,5 +5972,6 @@
var rs = obj.CallFunction('<invoke name="' + fn + '" returntype="javascript">' + __flash__argumentsToXML(arguments, 2) + '</invoke>');
return eval(rs);
};
})();
+