Update Mootools

This commit is contained in:
Ruud
2014-06-11 10:34:52 +02:00
parent ba9c975335
commit 79cb716ced
3 changed files with 353 additions and 185 deletions

View File

@@ -54,7 +54,7 @@
},
pushState: function(e){
if((!e.meta && Browser.Platform.mac) || (!e.control && !Browser.Platform.mac)){
if((!e.meta && Browser.platform.mac) || (!e.control && !Browser.platform.mac)){
(e).preventDefault();
var url = e.target.get('href');
if(History.getPath() != url)
@@ -63,7 +63,7 @@
},
isMac: function(){
return Browser.Platform.mac
return Browser.platform.mac
},
createLayout: function(){
@@ -322,7 +322,7 @@
var url = 'http://www.dereferer.org/?' + el.get('href');
if(el.get('target') == '_blank' || (e.meta && Browser.Platform.mac) || (e.control && !Browser.Platform.mac))
if(el.get('target') == '_blank' || (e.meta && Browser.platform.mac) || (e.control && !Browser.platform.mac))
window.open(url);
else
window.location = url;

View File

@@ -20,7 +20,7 @@ description: The heart of MooTools.
license: MIT-style license.
copyright: Copyright (c) 2006-2012 [Valerio Proietti](http://mad4milk.net/).
copyright: Copyright (c) 2006-2014 [Valerio Proietti](http://mad4milk.net/).
authors: The MooTools production team (http://mootools.net/developers/)
@@ -36,8 +36,8 @@ provides: [Core, MooTools, Type, typeOf, instanceOf, Native]
(function(){
this.MooTools = {
version: '1.4.5',
build: 'ab8ea8824dc3b24b6666867a2c4ed58ebb762cf0'
version: '1.5.0',
build: '0f7b690afee9349b15909f33016a25d2e4d9f4e3'
};
// typeOf, instanceOf
@@ -50,7 +50,7 @@ var typeOf = this.typeOf = function(item){
if (item.nodeType == 1) return 'element';
if (item.nodeType == 3) return (/\S/).test(item.nodeValue) ? 'textnode' : 'whitespace';
} else if (typeof item.length == 'number'){
if (item.callee) return 'arguments';
if ('callee' in item) return 'arguments';
if ('item' in item) return 'collection';
}
@@ -267,7 +267,7 @@ var force = function(name, object, methods){
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)
for (var key in prototype) fn.call(prototype, prototype[key], key);
};
}
@@ -275,7 +275,7 @@ var force = function(name, object, methods){
};
force('String', String, [
'charAt', 'charCodeAt', 'concat', 'indexOf', 'lastIndexOf', 'match', 'quote', 'replace', 'search',
'charAt', 'charCodeAt', 'concat', 'contains', 'indexOf', 'lastIndexOf', 'match', 'quote', 'replace', 'search',
'slice', 'split', 'substr', 'substring', 'trim', 'toLowerCase', 'toUpperCase'
])('Array', Array, [
'pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift', 'concat', 'join', 'slice',
@@ -325,11 +325,13 @@ Object.each = Object.forEach;
Array.implement({
/*<!ES5>*/
forEach: function(fn, bind){
for (var i = 0, l = this.length; i < l; i++){
if (i in this) fn.call(bind, this[i], i, this);
}
},
/*</!ES5>*/
each: function(fn, bind){
Array.forEach(this, fn, bind);
@@ -421,7 +423,7 @@ description: Contains Array Prototypes like each, contains, and erase.
license: MIT-style license.
requires: Type
requires: [Type]
provides: Array
@@ -564,7 +566,7 @@ Array.implement({
if (this.length != 3) return null;
var rgb = this.map(function(value){
if (value.length == 1) value += value;
return value.toInt(16);
return parseInt(value, 16);
});
return (array) ? rgb : 'rgb(' + rgb + ')';
},
@@ -594,7 +596,7 @@ description: Contains String Prototypes like camelCase, capitalize, test, and to
license: MIT-style license.
requires: Type
requires: [Type, Array]
provides: String
@@ -603,14 +605,16 @@ provides: String
String.implement({
//<!ES6>
contains: function(string, index){
return (index ? String(this).slice(index) : String(this)).indexOf(string) > -1;
},
//</!ES6>
test: function(regex, params){
return ((typeOf(regex) == 'regexp') ? regex : new RegExp('' + regex, params)).test(this);
},
contains: function(string, separator){
return (separator) ? (separator + this + separator).indexOf(separator + string + separator) > -1 : String(this).indexOf(string) > -1;
},
trim: function(){
return String(this).replace(/^\s+|\s+$/g, '');
},
@@ -669,6 +673,8 @@ String.implement({
});
/*
---
@@ -1063,37 +1069,47 @@ provides: [Browser, Window, Document]
var document = this.document;
var window = document.window = this;
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;
var parse = function(ua, platform){
ua = ua.toLowerCase();
platform = (platform ? platform.toLowerCase() : '');
var Browser = this.Browser = {
var UA = ua.match(/(opera|ie|firefox|chrome|trident|crios|version)[\s\/:]([\w\d\.]+)?.*?(safari|(?:rv[\s\/:]|version[\s\/:])([\w\d\.]+)|$)/) || [null, 'unknown', 0];
extend: Function.prototype.extend,
if (UA[1] == 'trident'){
UA[1] = 'ie';
if (UA[4]) UA[2] = UA[4];
} else if (UA[1] == 'crios') {
UA[1] = 'chrome';
}
name: (UA[1] == 'version') ? UA[3] : UA[1],
var platform = ua.match(/ip(?:ad|od|hone)/) ? 'ios' : (ua.match(/(?:webos|android)/) || platform.match(/mac|win|linux/) || ['other'])[0];
if (platform == 'win') platform = 'windows';
version: mode || parseFloat((UA[1] == 'opera' && UA[4]) ? UA[4] : UA[2]),
return {
extend: Function.prototype.extend,
name: (UA[1] == 'version') ? UA[3] : UA[1],
version: parseFloat((UA[1] == 'opera' && UA[4]) ? UA[4] : UA[2]),
platform: platform
};
};
Platform: {
name: ua.match(/ip(?:ad|od|hone)/) ? 'ios' : (ua.match(/(?:webos|android)/) || platform.match(/mac|win|linux/) || ['other'])[0]
},
var Browser = this.Browser = parse(navigator.userAgent, navigator.platform);
if (Browser.ie){
Browser.version = document.documentMode;
}
Browser.extend({
Features: {
xpath: !!(document.evaluate),
air: !!(window.runtime),
query: !!(document.querySelector),
json: !!(window.JSON)
},
parseUA: parse
});
Plugins: {}
};
Browser[Browser.name] = true;
Browser[Browser.name + parseInt(Browser.version, 10)] = true;
Browser.Platform[Browser.Platform.name] = true;
// Request
@@ -1126,18 +1142,7 @@ Browser.Request = (function(){
Browser.Features.xhr = !!(Browser.Request);
// Flash detection
var version = (Function.attempt(function(){
return navigator.plugins['Shockwave Flash'].description;
}, function(){
return new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version');
}) || '0 r0').match(/\d+/g);
Browser.Plugins.Flash = {
version: Number(version[0] || '0.' + version[1]) || 0,
build: Number(version[2]) || 0
};
// String scripts
@@ -1756,7 +1761,7 @@ local.setDocument = function(document){
// native matchesSelector function
features.nativeMatchesSelector = root.matchesSelector || /*root.msMatchesSelector ||*/ root.mozMatchesSelector || root.webkitMatchesSelector;
features.nativeMatchesSelector = root.matches || /*root.msMatchesSelector ||*/ root.mozMatchesSelector || root.webkitMatchesSelector;
if (features.nativeMatchesSelector) try {
// if matchesSelector trows errors on incorrect sintaxes we can use it
features.nativeMatchesSelector.call(root, ':slick');
@@ -2590,12 +2595,12 @@ license: MIT-style license.
requires: [Window, Document, Array, String, Function, Object, Number, Slick.Parser, Slick.Finder]
provides: [Element, Elements, $, $$, Iframe, Selectors]
provides: [Element, Elements, $, $$, IFrame, Selectors]
...
*/
var Element = function(tag, props){
var Element = this.Element = function(tag, props){
var konstructor = Element.Constructors[tag];
if (konstructor) return konstructor(props);
if (typeof tag != 'string') return document.id(tag).set(props);
@@ -2779,7 +2784,7 @@ Array.mirror(Elements);
/*<ltIE8>*/
var createElementAcceptsHTML;
try {
createElementAcceptsHTML = (document.createElement('<input name=x>').name == 'x');
createElementAcceptsHTML = (document.createElement('<input name=x>').name == 'x');
} catch (e){}
var escapeQuotes = function(html){
@@ -3112,7 +3117,28 @@ var pollutesGetAttribute = (function(div){
return (div.getAttribute('random') == 'attribute');
})(document.createElement('div'));
/* <ltIE9> */
var hasCloneBug = (function(test){
test.innerHTML = '<object><param name="should_fix" value="the unknown"></object>';
return test.cloneNode(true).firstChild.childNodes.length != 1;
})(document.createElement('div'));
/* </ltIE9> */
var hasClassList = !!document.createElement('div').classList;
var classes = function(className){
var classNames = (className || '').clean().split(" "), uniques = {};
return classNames.filter(function(className){
if (className !== "" && !uniques[className]) return uniques[className] = className;
});
};
var addToClassList = function(name){
this.classList.add(name);
};
var removeFromClassList = function(name){
this.classList.remove(name);
};
Element.implement({
@@ -3122,7 +3148,8 @@ Element.implement({
setter(this, value);
} else {
/* <ltIE9> */
if (pollutesGetAttribute) var attributeWhiteList = this.retrieve('$attributeWhiteList', {});
var attributeWhiteList;
if (pollutesGetAttribute) attributeWhiteList = this.retrieve('$attributeWhiteList', {});
/* </ltIE9> */
if (value == null){
@@ -3194,17 +3221,27 @@ Element.implement({
return this;
},
hasClass: function(className){
hasClass: hasClassList ? function(className){
return this.classList.contains(className);
} : function(className){
return this.className.clean().contains(className, ' ');
},
addClass: function(className){
if (!this.hasClass(className)) this.className = (this.className + ' ' + className).clean();
addClass: hasClassList ? function(className){
classes(className).forEach(addToClassList, this);
return this;
} : function(className){
this.className = classes(className + ' ' + this.className).join(' ');
return this;
},
removeClass: function(className){
this.className = this.className.replace(new RegExp('(^|\\s)' + className + '(?:\\s|$)'), '$1');
removeClass: hasClassList ? function(className){
classes(className).forEach(removeFromClassList, this);
return this;
} : function(className){
var classNames = classes(this.className);
classes(className).forEach(classNames.erase, classNames);
this.className = classNames.join(' ');
return this;
},
@@ -3279,6 +3316,37 @@ Element.implement({
});
// appendHTML
var appendInserters = {
before: 'beforeBegin',
after: 'afterEnd',
bottom: 'beforeEnd',
top: 'afterBegin',
inside: 'beforeEnd'
};
Element.implement('appendHTML', ('insertAdjacentHTML' in document.createElement('div')) ? function(html, where){
this.insertAdjacentHTML(appendInserters[where || 'bottom'], html);
return this;
} : function(html, where){
var temp = new Element('div', {html: html}),
children = temp.childNodes,
fragment = temp.firstChild;
if (!fragment) return this;
if (children.length > 1){
fragment = document.createDocumentFragment();
for (var i = 0, l = children.length; i < l; i++){
fragment.appendChild(children[i]);
}
}
inserters[where || 'bottom'](fragment, this);
return this;
});
var collected = {}, storage = {};
var get = function(uid){
@@ -3344,7 +3412,7 @@ Element.implement({
}
/*<ltIE9>*/
if (Browser.ie){
if (hasCloneBug){
var co = clone.getElementsByTagName('object'), to = this.getElementsByTagName('object');
for (i = co.length; i--;) co[i].outerHTML = to[i].outerHTML;
}
@@ -3357,13 +3425,7 @@ Element.implement({
[Element, Window, Document].invoke('implement', {
addListener: function(type, fn){
if (type == 'unload'){
var old = fn, self = this;
fn = function(){
self.removeListener('unload', fn);
old();
};
} else {
if (window.attachEvent && !window.addEventListener){
collected[Slick.uidOf(this)] = this;
}
if (this.addEventListener) this.addEventListener(type, fn, !!arguments[2]);
@@ -3398,10 +3460,14 @@ Element.implement({
});
/*<ltIE9>*/
if (window.attachEvent && !window.addEventListener) window.addListener('unload', function(){
Object.each(collected, clean);
if (window.CollectGarbage) CollectGarbage();
});
if (window.attachEvent && !window.addEventListener){
var gc = function(){
Object.each(collected, clean);
if (window.CollectGarbage) CollectGarbage();
window.removeListener('unload', gc);
}
window.addListener('unload', gc);
}
/*</ltIE9>*/
Element.Properties = {};
@@ -3446,11 +3512,13 @@ Element.Properties.html = {
};
var supportsHTML5Elements = true, supportsTableInnerHTML = true, supportsTRInnerHTML = true;
/*<ltIE9>*/
// technique by jdbarlett - http://jdbartlett.com/innershiv/
var div = document.createElement('div');
div.innerHTML = '<nav></nav>';
var supportsHTML5Elements = (div.childNodes.length == 1);
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;
@@ -3460,7 +3528,7 @@ div = null;
/*</ltIE9>*/
/*<IE>*/
var supportsTableInnerHTML = Function.attempt(function(){
supportsTableInnerHTML = Function.attempt(function(){
var table = document.createElement('table');
table.innerHTML = '<tr><td></td></tr>';
return true;
@@ -3469,7 +3537,7 @@ var supportsTableInnerHTML = Function.attempt(function(){
/*<ltFF4>*/
var tr = document.createElement('tr'), html = '<td></td>';
tr.innerHTML = html;
var supportsTRInnerHTML = (tr.innerHTML == html);
supportsTRInnerHTML = (tr.innerHTML == html);
tr = null;
/*</ltFF4>*/
@@ -3514,11 +3582,12 @@ if (testForm.firstChild.value != 's') Element.Properties.value = {
var tag = this.get('tag');
if (tag != 'select') return this.setProperty('value', value);
var options = this.getElements('option');
value = String(value);
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;
if (optionValue === value) return option.selected = true;
}
},
@@ -3572,17 +3641,24 @@ provides: Element.Style
(function(){
var html = document.html;
var html = document.html, el;
//<ltIE9>
// Check for oldIE, which does not remove styles when they're set to null
var el = document.createElement('div');
el = document.createElement('div');
el.style.color = 'red';
el.style.color = null;
var doesNotRemoveStyles = el.style.color == 'red';
// check for oldIE, which returns border* shorthand styles in the wrong order (color-width-style instead of width-style-color)
var border = '1px solid #123abc';
el.style.border = border;
var returnsBordersInWrongOrder = el.style.border != border;
el = null;
//</ltIE9>
var hasGetComputedStyle = !!window.getComputedStyle;
Element.Properties.styles = {set: function(styles){
this.setStyles(styles);
}};
@@ -3596,16 +3672,25 @@ var setVisibility = function(element, opacity){
element.style.visibility = opacity > 0 || opacity == null ? 'visible' : 'hidden';
};
//<ltIE9>
var setFilter = function(element, regexp, value){
var style = element.style,
filter = style.filter || element.getComputedStyle('filter') || '';
style.filter = (regexp.test(filter) ? filter.replace(regexp, value) : filter + ' ' + value).trim();
if (!style.filter) style.removeAttribute('filter');
};
//</ltIE9>
var setOpacity = (hasOpacity ? function(element, opacity){
element.style.opacity = opacity;
} : (hasFilter ? function(element, 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');
if (!element.currentStyle || !element.currentStyle.hasLayout) element.style.zoom = 1;
if (opacity == null || opacity == 1){
setFilter(element, reAlpha, '');
if (opacity == 1 && getOpacity(element) != 1) setFilter(element, reAlpha, 'alpha(opacity=100)');
} else {
setFilter(element, reAlpha, 'alpha(opacity=' + (opacity * 100).limit(0, 100).round() + ')');
}
} : setVisibility));
var getOpacity = (hasOpacity ? function(element){
@@ -3622,15 +3707,27 @@ var getOpacity = (hasOpacity ? function(element){
return opacity;
}));
var floatName = (html.style.cssFloat == null) ? 'styleFloat' : 'cssFloat';
var floatName = (html.style.cssFloat == null) ? 'styleFloat' : 'cssFloat',
namedPositions = {left: '0%', top: '0%', center: '50%', right: '100%', bottom: '100%'},
hasBackgroundPositionXY = (html.style.backgroundPositionX != null);
//<ltIE9>
var removeStyle = function(style, property){
if (property == 'backgroundPosition'){
style.removeAttribute(property + 'X');
property += 'Y';
}
style.removeAttribute(property);
};
//</ltIE9>
Element.implement({
getComputedStyle: function(property){
if (this.currentStyle) return this.currentStyle[property.camelCase()];
if (!hasGetComputedStyle && this.currentStyle) return this.currentStyle[property.camelCase()];
var defaultView = Element.getDocument(this).defaultView,
computed = defaultView ? defaultView.getComputedStyle(this, null) : null;
return (computed) ? computed.getPropertyValue((property == floatName) ? 'float' : property.hyphenate()) : null;
return (computed) ? computed.getPropertyValue((property == floatName) ? 'float' : property.hyphenate()) : '';
},
setStyle: function(property, value){
@@ -3652,7 +3749,7 @@ Element.implement({
this.style[property] = value;
//<ltIE9>
if ((value == '' || value == null) && doesNotRemoveStyles && this.style.removeAttribute){
this.style.removeAttribute(property);
removeStyle(this.style, property);
}
//</ltIE9>
return this;
@@ -3663,20 +3760,25 @@ Element.implement({
property = (property == 'float' ? floatName : property).camelCase();
var result = this.style[property];
if (!result || property == 'zIndex'){
result = [];
for (var style in Element.ShortStyles){
if (property != style) continue;
for (var s in Element.ShortStyles[style]) result.push(this.getStyle(s));
if (Element.ShortStyles.hasOwnProperty(property)){
result = [];
for (var s in Element.ShortStyles[property]) result.push(this.getStyle(s));
return result.join(' ');
}
result = this.getComputedStyle(property);
}
if (hasBackgroundPositionXY && /^backgroundPosition[XY]?$/.test(property)){
return result.replace(/(top|right|bottom|left)/g, function(position){
return namedPositions[position];
}) || '0px';
}
if (!result && property == 'backgroundPosition') return '0px 0px';
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){
if (!hasGetComputedStyle && !this.style[property]){
if ((/^(height|width)$/).test(property) && !(/px$/.test(result))){
var values = (property == 'width') ? ['left', 'right'] : ['top', 'bottom'], size = 0;
values.each(function(value){
@@ -3684,10 +3786,15 @@ Element.implement({
}, this);
return this['offset' + property.capitalize()] - size + 'px';
}
if (Browser.ie && (/^border(.+)Width|margin|padding/).test(property) && isNaN(parseFloat(result))){
if ((/^border(.+)Width|margin|padding/).test(property) && isNaN(parseFloat(result))){
return '0px';
}
}
//<ltIE9>
if (returnsBordersInWrongOrder && /^border(Top|Right|Bottom|Left)?$/.test(property) && /^#/.test(result)){
return result.replace(/^(.+)\s(.+)\s(.+)$/, '$2 $3 $1');
}
//</ltIE9>
return result;
},
@@ -3709,7 +3816,7 @@ Element.implement({
Element.Styles = {
left: '@px', top: '@px', bottom: '@px', right: '@px',
width: '@px', height: '@px', maxWidth: '@px', maxHeight: '@px', minWidth: '@px', minHeight: '@px',
backgroundColor: 'rgb(@, @, @)', backgroundPosition: '@px @px', color: 'rgb(@, @, @)',
backgroundColor: 'rgb(@, @, @)', backgroundSize: '@px', backgroundPosition: '@px @px', color: 'rgb(@, @, @)',
fontSize: '@px', letterSpacing: '@px', lineHeight: '@px', clip: 'rect(@px @px @px @px)',
margin: '@px @px @px @px', padding: '@px @px @px @px', border: '@px @ rgb(@, @, @) @px @ rgb(@, @, @) @px @ rgb(@, @, @)',
borderWidth: '@px @px @px @px', borderStyle: '@ @ @ @', borderColor: 'rgb(@, @, @) rgb(@, @, @) rgb(@, @, @) rgb(@, @, @)',
@@ -3738,6 +3845,7 @@ Element.ShortStyles = {margin: {}, padding: {}, border: {}, borderWidth: {}, bor
Short.borderColor[bdc] = Short[bd][bdc] = All[bdc] = 'rgb(@, @, @)';
});
if (hasBackgroundPositionXY) Element.ShortStyles.backgroundPosition = {backgroundPositionX: '@', backgroundPositionY: '@'};
})();
@@ -3779,7 +3887,7 @@ var DOMEvent = this.DOMEvent = new Type('DOMEvent', function(event, win){
if (type.indexOf('key') == 0){
var code = this.code = (event.which || event.keyCode);
this.key = _keys[code];
if (type == 'keydown'){
if (type == 'keydown' || type == 'keyup'){
if (code > 111 && code < 124) this.key = 'f' + (code - 111);
else if (code > 95 && code < 106) this.key = code - 96;
}
@@ -4001,23 +4109,27 @@ Element.NativeEvents = {
gesturestart: 2, gesturechange: 2, gestureend: 2, // gesture
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
hashchange: 1, popstate: 2, // history
error: 1, abort: 1, scroll: 1 //misc
};
Element.Events = {mousewheel: {
base: (Browser.firefox) ? 'DOMMouseScroll' : 'mousewheel'
}};
Element.Events = {
mousewheel: {
base: 'onwheel' in document ? 'wheel' : 'onmousewheel' in document ? 'mousewheel' : 'DOMMouseScroll'
}
};
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));
};
if ('onmouseenter' in document.documentElement){
Element.NativeEvents.mouseenter = Element.NativeEvents.mouseleave = 2;
Element.MouseenterCheck = check;
} 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));
};
Element.Events.mouseenter = {
base: 'mouseover',
condition: check
@@ -4035,12 +4147,12 @@ if (!window.addEventListener){
Element.Events.change = {
base: function(){
var type = this.type;
return (this.get('tag') == 'input' && (type == 'radio' || type == 'checkbox')) ? 'propertychange' : 'change'
return (this.get('tag') == 'input' && (type == 'radio' || type == 'checkbox')) ? 'propertychange' : 'change';
},
condition: function(event){
return this.type != 'radio' || (event.event.propertyName == 'checked' && this.checked);
return event.type != 'propertychange' || event.event.propertyName == 'checked';
}
}
};
}
/*</ltIE9>*/
@@ -4080,10 +4192,12 @@ var bubbleUp = function(self, match, fn, event, target){
var map = {
mouseenter: {
base: 'mouseover'
base: 'mouseover',
condition: Element.MouseenterCheck
},
mouseleave: {
base: 'mouseout'
base: 'mouseout',
condition: Element.MouseenterCheck
},
focus: {
base: 'focus' + (eventListenerSupport ? '' : 'in'),
@@ -4190,8 +4304,8 @@ var delegation = {
};
var elementEvent = Element.Events[_type];
if (elementEvent && elementEvent.condition){
var __match = match, condition = elementEvent.condition;
if (_map.condition || elementEvent && elementEvent.condition){
var __match = match, condition = _map.condition || elementEvent.condition;
match = function(target, event){
return __match(target, event) && condition.call(target, event, type);
};
@@ -4226,7 +4340,7 @@ var delegation = {
if (_map.remove) _map.remove(this, _uid);
delete stored[_uid];
storage[_type] = stored;
return removeEvent.call(this, type, delegator);
return removeEvent.call(this, type, delegator, _map.capture);
}
var __uid, s;
@@ -4344,7 +4458,9 @@ Element.implement({
},
getOffsets: function(){
if (this.getBoundingClientRect && !Browser.Platform.ios){
var hasGetBoundingClientRect = this.getBoundingClientRect;
if (hasGetBoundingClientRect){
var bound = this.getBoundingClientRect(),
html = document.id(this.getDocument().documentElement),
htmlScroll = html.getScroll(),
@@ -4364,27 +4480,9 @@ Element.implement({
position.x += element.offsetLeft;
position.y += element.offsetTop;
if (Browser.firefox){
if (!borderBox(element)){
position.x += leftBorder(element);
position.y += topBorder(element);
}
var parent = element.parentNode;
if (parent && styleString(parent, 'overflow') != 'visible'){
position.x += leftBorder(parent);
position.y += topBorder(parent);
}
} else if (element != this && Browser.safari){
position.x += leftBorder(element);
position.y += topBorder(element);
}
element = element.offsetParent;
}
if (Browser.firefox && !borderBox(this)){
position.x -= leftBorder(this);
position.y -= topBorder(this);
}
return position;
},
@@ -4666,13 +4764,17 @@ var Fx = this.Fx = new Class({
},
resume: function(){
if ((this.frame < this.frames) && !this.isRunning()) pushInstance.call(this, this.options.fps);
if (this.isPaused()) pushInstance.call(this, this.options.fps);
return this;
},
isRunning: function(){
var list = instances[this.options.fps];
return list && list.contains(this);
},
isPaused: function(){
return (this.frame < this.frames) && !this.isRunning();
}
});
@@ -4745,7 +4847,7 @@ Fx.CSS = new Class({
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){
if (unit && from && typeof from == 'string' && 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
@@ -4817,11 +4919,13 @@ Fx.CSS = new Class({
search: function(selector){
if (Fx.CSS.Cache[selector]) return Fx.CSS.Cache[selector];
var to = {}, selectorTest = new RegExp('^' + selector.escapeRegExp() + '$');
Array.each(document.styleSheets, function(sheet, j){
var href = sheet.href;
if (href && href.contains('://') && !href.contains(document.domain)) return;
var rules = sheet.rules || sheet.cssRules;
var searchStyles = function(rules){
Array.each(rules, function(rule, i){
if (rule.media){
searchStyles(rule.rules || rule.cssRules);
return;
}
if (!rule.style) return;
var selectorText = (rule.selectorText) ? rule.selectorText.replace(/^\w+/, function(m){
return m.toLowerCase();
@@ -4833,6 +4937,13 @@ Fx.CSS = new Class({
to[style] = ((/^rgb/).test(value)) ? value.rgbToHex() : value;
});
});
};
Array.each(document.styleSheets, function(sheet, j){
var href = sheet.href;
if (href && href.indexOf('://') > -1 && href.indexOf(document.domain) == -1) return;
var rules = sheet.rules || sheet.cssRules;
searchStyles(rules);
});
return Fx.CSS.Cache[selector] = to;
}
@@ -5369,10 +5480,10 @@ var Request = this.Request = new Class({
if (trimPosition > -1 && (trimPosition = url.indexOf('#')) > -1) url = url.substr(0, trimPosition);
if (this.options.noCache)
url += (url.contains('?') ? '&' : '?') + String.uniqueID();
url += (url.indexOf('?') > -1 ? '&' : '?') + String.uniqueID();
if (data && method == 'get'){
url += (url.contains('?') ? '&' : '?') + data;
if (data && (method == 'get' || method == 'delete')){
url += (url.indexOf('?') > -1 ? '&' : '?') + data;
data = null;
}
@@ -5526,10 +5637,14 @@ JSON.encode = JSON.stringify ? function(obj){
return null;
};
JSON.secure = true;
JSON.decode = function(string, secure){
if (!string || typeOf(string) != 'string') return null;
if (secure || JSON.secure){
if (secure == null) secure = JSON.secure;
if (secure){
if (JSON.parse) return JSON.parse(string);
if (!JSON.validate(string)) throw new Error('JSON could not decode the input; security is enabled and the value is not secure.');
}

View File

@@ -1,6 +1,16 @@
// MooTools: the javascript framework.
// Load this file's selection again by visiting: http://mootools.net/more/0f75cfbac1aabbedaba7630beef8d10c
// Or build this file again with packager using: packager build More/Events.Pseudos More/Date More/Date.Extras More/Element.Forms More/Element.Position More/Element.Shortcuts More/Fx.Scroll More/Fx.Slide More/Sortables More/Request.JSONP More/Request.Periodical
/*
---
MooTools: the javascript framework
web build:
- http://mootools.net/more/0f75cfbac1aabbedaba7630beef8d10c
packager build:
- packager build More/Events.Pseudos More/Date More/Date.Extras More/Element.Forms More/Element.Position More/Element.Shortcuts More/Fx.Scroll More/Fx.Slide More/Sortables More/Request.JSONP More/Request.Periodical
...
*/
/*
---
@@ -31,8 +41,8 @@ provides: [MooTools.More]
*/
MooTools.More = {
'version': '1.4.0.1',
'build': 'a4244edf2aa97ac8a196fc96082dd35af1abab87'
version: '1.5.0',
build: '73db5e24e6e9c5c87b3a27aebef2248053f7db37'
};
@@ -48,7 +58,7 @@ license: MIT-style license
authors:
- Arian Stolwijk
requires: [Core/Class.Extras, Core/Slick.Parser, More/MooTools.More]
requires: [Core/Class.Extras, Core/Slick.Parser, MooTools.More]
provides: [Events.Pseudos]
@@ -211,7 +221,7 @@ authors:
requires:
- Core/Object
- /MooTools.More
- MooTools.More
provides: [Object.Extras]
@@ -280,8 +290,8 @@ authors:
requires:
- Core/Events
- /Object.Extras
- /MooTools.More
- Object.Extras
- MooTools.More
provides: [Locale, Lang]
@@ -444,7 +454,7 @@ authors:
- Aaron Newton
requires:
- /Locale
- Locale
provides: [Locale.en-US.Date]
@@ -1079,7 +1089,7 @@ authors:
- Scott Kyle
requires:
- /Date
- Date
provides: [Date.Extras]
@@ -1235,10 +1245,8 @@ var special = {
'S': /[ŠŞŚ]/g,
't': /[ťţ]/g,
'T': /[ŤŢ]/g,
'ue': /[ü]/g,
'UE': /[Ü]/g,
'u': /[ùúûůµ]/g,
'U': /[ÙÚÛŮ]/g,
'u': /[ùúûůüµ]/g,
'U': /[ÙÚÛŮÜ]/g,
'y': /[ÿý]/g,
'Y': /[ŸÝ]/g,
'z': /[žźż]/g,
@@ -1263,7 +1271,16 @@ tidy = {
'-': /[\u2013]/g,
// '--': /[\u2014]/g,
'&raquo;': /[\uFFFD]/g
};
},
conversions = {
ms: 1,
s: 1000,
m: 6e4,
h: 36e5
},
findUnits = /(\d*.?\d+)([msh]+)/;
var walk = function(string, replacements){
var result = string, key;
@@ -1325,6 +1342,13 @@ String.implement({
if (trail) string += trail;
}
return string;
},
ms: function(){
// "Borrowed" from https://gist.github.com/1503944
var units = findUnits.exec(this);
if (units == null) return Number(this);
return Number(units[1]) * conversions[units[2]];
}
});
@@ -1348,8 +1372,8 @@ authors:
requires:
- Core/Element
- /String.Extras
- /MooTools.More
- String.Extras
- MooTools.More
provides: [Element.Forms]
@@ -1493,7 +1517,7 @@ authors:
requires:
- Core/Element.Style
- Core/Element.Dimensions
- /MooTools.More
- MooTools.More
provides: [Element.Measure]
@@ -1710,13 +1734,15 @@ var local = Element.Position = {
},
setOffsetOption: function(element, options){
var parentOffset = {x: 0, y: 0},
offsetParent = element.measure(function(){
return document.id(this.getOffsetParent());
}),
parentScroll = offsetParent.getScroll();
var parentOffset = {x: 0, y: 0};
var parentScroll = {x: 0, y: 0};
var offsetParent = element.measure(function(){
return document.id(this.getOffsetParent());
});
if (!offsetParent || offsetParent == element.getDocument().body) return;
parentScroll = offsetParent.getScroll();
parentOffset = offsetParent.measure(function(){
var position = this.getPosition();
if (this.getStyle('position') == 'fixed'){
@@ -1896,7 +1922,7 @@ authors:
requires:
- Core/Element.Style
- /MooTools.More
- MooTools.More
provides: [Element.Shortcuts]
@@ -1976,7 +2002,7 @@ requires:
- Core/Fx
- Core/Element.Event
- Core/Element.Dimensions
- /MooTools.More
- MooTools.More
provides: [Fx.Scroll]
@@ -2014,7 +2040,6 @@ Fx.Scroll = new Class({
set: function(){
var now = Array.flatten(arguments);
if (Browser.firefox) now = [Math.round(now[0]), Math.round(now[1])]; // not needed anymore in newer firefox versions
this.element.scrollTo(now[0], now[1]);
return this;
},
@@ -2148,7 +2173,7 @@ authors:
requires:
- Core/Fx
- Core/Element.Style
- /MooTools.More
- MooTools.More
provides: [Fx.Slide]
@@ -2325,7 +2350,7 @@ requires:
- Core/Element.Event
- Core/Element.Style
- Core/Element.Dimensions
- /MooTools.More
- MooTools.More
provides: [Drag]
...
@@ -2371,10 +2396,10 @@ var Drag = new Class({
this.mouse = {'now': {}, 'pos': {}};
this.value = {'start': {}, 'now': {}};
this.selection = (Browser.ie) ? 'selectstart' : 'mousedown';
this.selection = 'selectstart' in document ? 'selectstart' : 'mousedown';
if (Browser.ie && !Drag.ondragstartFixed){
if ('ondragstart' in document && !('FileReader' in window) && !Drag.ondragstartFixed){
document.ondragstart = Function.from(false);
Drag.ondragstartFixed = true;
}
@@ -2559,7 +2584,7 @@ authors:
requires:
- Core/Element.Dimensions
- /Drag
- Drag
provides: [Drag.Move]
@@ -2586,10 +2611,7 @@ Drag.Move = new Class({
element = this.element;
this.droppables = $$(this.options.droppables);
this.container = document.id(this.options.container);
if (this.container && typeOf(this.container) != 'element')
this.container = document.id(this.container.getDocument().body);
this.setContainer(this.options.container);
if (this.options.style){
if (this.options.modifiers.x == 'left' && this.options.modifiers.y == 'top'){
@@ -2606,6 +2628,13 @@ Drag.Move = new Class({
this.addEvent('start', this.checkDroppables, true);
this.overed = null;
},
setContainer: function(container) {
this.container = document.id(container);
if (this.container && typeOf(this.container) != 'element'){
this.container = document.id(this.container.getDocument().body);
}
},
start: function(event){
if (this.container) this.options.limit = this.calculateLimit();
@@ -2670,7 +2699,9 @@ Drag.Move = new Class({
if (container != offsetParent){
left += containerMargin.left + offsetParentPadding.left;
top += ((Browser.ie6 || Browser.ie7) ? 0 : containerMargin.top) + offsetParentPadding.top;
if (!offsetParentPadding.left && left < 0) left = 0;
top += offsetParent == document.body ? 0 : containerMargin.top + offsetParentPadding.top;
if (!offsetParentPadding.top && top < 0) top = 0;
}
} else {
left -= elementMargin.left;
@@ -2754,7 +2785,7 @@ authors:
requires:
- Core/Fx.Morph
- /Drag.Move
- Drag.Move
provides: [Sortables]
@@ -2773,7 +2804,8 @@ var Sortables = new Class({
clone: false,
revert: false,
handle: false,
dragOptions: {}
dragOptions: {},
unDraggableTags: ['button', 'input', 'a', 'textarea', 'select', 'option']
},
initialize: function(lists, options){
@@ -2839,6 +2871,24 @@ var Sortables = new Class({
return list;
}, this));
},
getDroppableCoordinates: function (element){
var offsetParent = element.getOffsetParent();
var position = element.getPosition(offsetParent);
var scroll = {
w: window.getScroll(),
offsetParent: offsetParent.getScroll()
};
position.x += scroll.offsetParent.x;
position.y += scroll.offsetParent.y;
if (offsetParent.getStyle('position') == 'fixed'){
position.x -= scroll.w.x;
position.y -= scroll.w.y;
}
return position;
},
getClone: function(event, element){
if (!this.options.clone) return new Element(element.tagName).inject(document.body);
@@ -2859,7 +2909,7 @@ var Sortables = new Class({
});
}
return clone.inject(this.list).setPosition(element.getPosition(element.getOffsetParent()));
return clone.inject(this.list).setPosition(this.getDroppableCoordinates(this.element));
},
getDroppables: function(){
@@ -2884,7 +2934,7 @@ var Sortables = new Class({
if (
!this.idle ||
event.rightClick ||
['button', 'input', 'a', 'textarea'].contains(event.target.get('tag'))
(!this.options.handle && this.options.unDraggableTags.contains(event.target.get('tag')))
) return;
this.idle = false;
@@ -2915,14 +2965,16 @@ var Sortables = new Class({
end: function(){
this.drag.detach();
this.element.setStyle('opacity', this.opacity);
var self = this;
if (this.effect){
var dim = this.element.getStyles('width', 'height'),
clone = this.clone,
pos = clone.computePosition(this.element.getPosition(this.clone.getOffsetParent()));
pos = clone.computePosition(this.getDroppableCoordinates(clone));
var destroy = function(){
this.removeEvent('cancel', destroy);
clone.destroy();
self.reset();
};
this.effect.element = clone;
@@ -2935,8 +2987,9 @@ var Sortables = new Class({
}).addEvent('cancel', destroy).chain(destroy);
} else {
this.clone.destroy();
self.reset();
}
this.reset();
},
reset: function(){
@@ -3125,7 +3178,7 @@ authors:
requires:
- Core/Request
- /MooTools.More
- MooTools.More
provides: [Request.Periodical]