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
+3 -3
View File
@@ -54,7 +54,7 @@
}, },
pushState: function(e){ 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(); (e).preventDefault();
var url = e.target.get('href'); var url = e.target.get('href');
if(History.getPath() != url) if(History.getPath() != url)
@@ -63,7 +63,7 @@
}, },
isMac: function(){ isMac: function(){
return Browser.Platform.mac return Browser.platform.mac
}, },
createLayout: function(){ createLayout: function(){
@@ -322,7 +322,7 @@
var url = 'http://www.dereferer.org/?' + el.get('href'); 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); window.open(url);
else else
window.location = url; window.location = url;
+252 -137
View File
@@ -20,7 +20,7 @@ description: The heart of MooTools.
license: MIT-style license. 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/) authors: The MooTools production team (http://mootools.net/developers/)
@@ -36,8 +36,8 @@ provides: [Core, MooTools, Type, typeOf, instanceOf, Native]
(function(){ (function(){
this.MooTools = { this.MooTools = {
version: '1.4.5', version: '1.5.0',
build: 'ab8ea8824dc3b24b6666867a2c4ed58ebb762cf0' build: '0f7b690afee9349b15909f33016a25d2e4d9f4e3'
}; };
// typeOf, instanceOf // typeOf, instanceOf
@@ -50,7 +50,7 @@ var typeOf = this.typeOf = function(item){
if (item.nodeType == 1) return 'element'; if (item.nodeType == 1) return 'element';
if (item.nodeType == 3) return (/\S/).test(item.nodeValue) ? 'textnode' : 'whitespace'; if (item.nodeType == 3) return (/\S/).test(item.nodeValue) ? 'textnode' : 'whitespace';
} else if (typeof item.length == 'number'){ } else if (typeof item.length == 'number'){
if (item.callee) return 'arguments'; if ('callee' in item) return 'arguments';
if ('item' in item) return 'collection'; 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++){ if (!methodsEnumerable) for (var i = 0, l = methods.length; i < l; i++){
fn.call(prototype, prototype[methods[i]], methods[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, [ 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' 'slice', 'split', 'substr', 'substring', 'trim', 'toLowerCase', 'toUpperCase'
])('Array', Array, [ ])('Array', Array, [
'pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift', 'concat', 'join', 'slice', 'pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift', 'concat', 'join', 'slice',
@@ -325,11 +325,13 @@ Object.each = Object.forEach;
Array.implement({ Array.implement({
/*<!ES5>*/
forEach: function(fn, bind){ forEach: function(fn, bind){
for (var i = 0, l = this.length; i < l; i++){ for (var i = 0, l = this.length; i < l; i++){
if (i in this) fn.call(bind, this[i], i, this); if (i in this) fn.call(bind, this[i], i, this);
} }
}, },
/*</!ES5>*/
each: function(fn, bind){ each: function(fn, bind){
Array.forEach(this, fn, bind); Array.forEach(this, fn, bind);
@@ -421,7 +423,7 @@ description: Contains Array Prototypes like each, contains, and erase.
license: MIT-style license. license: MIT-style license.
requires: Type requires: [Type]
provides: Array provides: Array
@@ -564,7 +566,7 @@ Array.implement({
if (this.length != 3) return null; if (this.length != 3) return null;
var rgb = this.map(function(value){ var rgb = this.map(function(value){
if (value.length == 1) value += value; if (value.length == 1) value += value;
return value.toInt(16); return parseInt(value, 16);
}); });
return (array) ? rgb : 'rgb(' + rgb + ')'; return (array) ? rgb : 'rgb(' + rgb + ')';
}, },
@@ -594,7 +596,7 @@ description: Contains String Prototypes like camelCase, capitalize, test, and to
license: MIT-style license. license: MIT-style license.
requires: Type requires: [Type, Array]
provides: String provides: String
@@ -603,14 +605,16 @@ provides: String
String.implement({ String.implement({
//<!ES6>
contains: function(string, index){
return (index ? String(this).slice(index) : String(this)).indexOf(string) > -1;
},
//</!ES6>
test: function(regex, params){ test: function(regex, params){
return ((typeOf(regex) == 'regexp') ? regex : new RegExp('' + regex, params)).test(this); 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(){ trim: function(){
return String(this).replace(/^\s+|\s+$/g, ''); 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 document = this.document;
var window = document.window = this; var window = document.window = this;
var ua = navigator.userAgent.toLowerCase(), var parse = function(ua, platform){
platform = navigator.platform.toLowerCase(), ua = ua.toLowerCase();
UA = ua.match(/(opera|ie|firefox|chrome|version)[\s\/:]([\w\d\.]+)?.*?(safari|version[\s\/:]([\w\d\.]+)|$)/) || [null, 'unknown', 0], platform = (platform ? platform.toLowerCase() : '');
mode = UA[1] == 'ie' && document.documentMode;
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: { var Browser = this.Browser = parse(navigator.userAgent, navigator.platform);
name: ua.match(/ip(?:ad|od|hone)/) ? 'ios' : (ua.match(/(?:webos|android)/) || platform.match(/mac|win|linux/) || ['other'])[0]
},
if (Browser.ie){
Browser.version = document.documentMode;
}
Browser.extend({
Features: { Features: {
xpath: !!(document.evaluate), xpath: !!(document.evaluate),
air: !!(window.runtime), air: !!(window.runtime),
query: !!(document.querySelector), query: !!(document.querySelector),
json: !!(window.JSON) 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 // Request
@@ -1126,18 +1142,7 @@ Browser.Request = (function(){
Browser.Features.xhr = !!(Browser.Request); 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 // String scripts
@@ -1756,7 +1761,7 @@ local.setDocument = function(document){
// native matchesSelector function // 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 (features.nativeMatchesSelector) try {
// if matchesSelector trows errors on incorrect sintaxes we can use it // if matchesSelector trows errors on incorrect sintaxes we can use it
features.nativeMatchesSelector.call(root, ':slick'); 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] 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]; var konstructor = Element.Constructors[tag];
if (konstructor) return konstructor(props); if (konstructor) return konstructor(props);
if (typeof tag != 'string') return document.id(tag).set(props); if (typeof tag != 'string') return document.id(tag).set(props);
@@ -2779,7 +2784,7 @@ Array.mirror(Elements);
/*<ltIE8>*/ /*<ltIE8>*/
var createElementAcceptsHTML; var createElementAcceptsHTML;
try { try {
createElementAcceptsHTML = (document.createElement('<input name=x>').name == 'x'); createElementAcceptsHTML = (document.createElement('<input name=x>').name == 'x');
} catch (e){} } catch (e){}
var escapeQuotes = function(html){ var escapeQuotes = function(html){
@@ -3112,7 +3117,28 @@ var pollutesGetAttribute = (function(div){
return (div.getAttribute('random') == 'attribute'); return (div.getAttribute('random') == 'attribute');
})(document.createElement('div')); })(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({ Element.implement({
@@ -3122,7 +3148,8 @@ Element.implement({
setter(this, value); setter(this, value);
} else { } else {
/* <ltIE9> */ /* <ltIE9> */
if (pollutesGetAttribute) var attributeWhiteList = this.retrieve('$attributeWhiteList', {}); var attributeWhiteList;
if (pollutesGetAttribute) attributeWhiteList = this.retrieve('$attributeWhiteList', {});
/* </ltIE9> */ /* </ltIE9> */
if (value == null){ if (value == null){
@@ -3194,17 +3221,27 @@ Element.implement({
return this; return this;
}, },
hasClass: function(className){ hasClass: hasClassList ? function(className){
return this.classList.contains(className);
} : function(className){
return this.className.clean().contains(className, ' '); return this.className.clean().contains(className, ' ');
}, },
addClass: function(className){ addClass: hasClassList ? function(className){
if (!this.hasClass(className)) this.className = (this.className + ' ' + className).clean(); classes(className).forEach(addToClassList, this);
return this;
} : function(className){
this.className = classes(className + ' ' + this.className).join(' ');
return this; return this;
}, },
removeClass: function(className){ removeClass: hasClassList ? function(className){
this.className = this.className.replace(new RegExp('(^|\\s)' + className + '(?:\\s|$)'), '$1'); 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; 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 collected = {}, storage = {};
var get = function(uid){ var get = function(uid){
@@ -3344,7 +3412,7 @@ Element.implement({
} }
/*<ltIE9>*/ /*<ltIE9>*/
if (Browser.ie){ if (hasCloneBug){
var co = clone.getElementsByTagName('object'), to = this.getElementsByTagName('object'); var co = clone.getElementsByTagName('object'), to = this.getElementsByTagName('object');
for (i = co.length; i--;) co[i].outerHTML = to[i].outerHTML; for (i = co.length; i--;) co[i].outerHTML = to[i].outerHTML;
} }
@@ -3357,13 +3425,7 @@ Element.implement({
[Element, Window, Document].invoke('implement', { [Element, Window, Document].invoke('implement', {
addListener: function(type, fn){ addListener: function(type, fn){
if (type == 'unload'){ if (window.attachEvent && !window.addEventListener){
var old = fn, self = this;
fn = function(){
self.removeListener('unload', fn);
old();
};
} else {
collected[Slick.uidOf(this)] = this; collected[Slick.uidOf(this)] = this;
} }
if (this.addEventListener) this.addEventListener(type, fn, !!arguments[2]); if (this.addEventListener) this.addEventListener(type, fn, !!arguments[2]);
@@ -3398,10 +3460,14 @@ Element.implement({
}); });
/*<ltIE9>*/ /*<ltIE9>*/
if (window.attachEvent && !window.addEventListener) window.addListener('unload', function(){ if (window.attachEvent && !window.addEventListener){
Object.each(collected, clean); var gc = function(){
if (window.CollectGarbage) CollectGarbage(); Object.each(collected, clean);
}); if (window.CollectGarbage) CollectGarbage();
window.removeListener('unload', gc);
}
window.addListener('unload', gc);
}
/*</ltIE9>*/ /*</ltIE9>*/
Element.Properties = {}; Element.Properties = {};
@@ -3446,11 +3512,13 @@ Element.Properties.html = {
}; };
var supportsHTML5Elements = true, supportsTableInnerHTML = true, supportsTRInnerHTML = true;
/*<ltIE9>*/ /*<ltIE9>*/
// technique by jdbarlett - http://jdbartlett.com/innershiv/ // technique by jdbarlett - http://jdbartlett.com/innershiv/
var div = document.createElement('div'); var div = document.createElement('div');
div.innerHTML = '<nav></nav>'; div.innerHTML = '<nav></nav>';
var supportsHTML5Elements = (div.childNodes.length == 1); supportsHTML5Elements = (div.childNodes.length == 1);
if (!supportsHTML5Elements){ 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(' '), 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; fragment = document.createDocumentFragment(), l = tags.length;
@@ -3460,7 +3528,7 @@ div = null;
/*</ltIE9>*/ /*</ltIE9>*/
/*<IE>*/ /*<IE>*/
var supportsTableInnerHTML = Function.attempt(function(){ supportsTableInnerHTML = Function.attempt(function(){
var table = document.createElement('table'); var table = document.createElement('table');
table.innerHTML = '<tr><td></td></tr>'; table.innerHTML = '<tr><td></td></tr>';
return true; return true;
@@ -3469,7 +3537,7 @@ var supportsTableInnerHTML = Function.attempt(function(){
/*<ltFF4>*/ /*<ltFF4>*/
var tr = document.createElement('tr'), html = '<td></td>'; var tr = document.createElement('tr'), html = '<td></td>';
tr.innerHTML = html; tr.innerHTML = html;
var supportsTRInnerHTML = (tr.innerHTML == html); supportsTRInnerHTML = (tr.innerHTML == html);
tr = null; tr = null;
/*</ltFF4>*/ /*</ltFF4>*/
@@ -3514,11 +3582,12 @@ if (testForm.firstChild.value != 's') Element.Properties.value = {
var tag = this.get('tag'); var tag = this.get('tag');
if (tag != 'select') return this.setProperty('value', value); if (tag != 'select') return this.setProperty('value', value);
var options = this.getElements('option'); var options = this.getElements('option');
value = String(value);
for (var i = 0; i < options.length; i++){ for (var i = 0; i < options.length; i++){
var option = options[i], var option = options[i],
attr = option.getAttributeNode('value'), attr = option.getAttributeNode('value'),
optionValue = (attr && attr.specified) ? option.value : option.get('text'); 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(){ (function(){
var html = document.html; var html = document.html, el;
//<ltIE9> //<ltIE9>
// Check for oldIE, which does not remove styles when they're set to null // 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 = 'red';
el.style.color = null; el.style.color = null;
var doesNotRemoveStyles = el.style.color == 'red'; 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; el = null;
//</ltIE9> //</ltIE9>
var hasGetComputedStyle = !!window.getComputedStyle;
Element.Properties.styles = {set: function(styles){ Element.Properties.styles = {set: function(styles){
this.setStyles(styles); this.setStyles(styles);
}}; }};
@@ -3596,16 +3672,25 @@ var setVisibility = function(element, opacity){
element.style.visibility = opacity > 0 || opacity == null ? 'visible' : 'hidden'; 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){ var setOpacity = (hasOpacity ? function(element, opacity){
element.style.opacity = opacity; element.style.opacity = opacity;
} : (hasFilter ? function(element, opacity){ } : (hasFilter ? function(element, opacity){
var style = element.style; if (!element.currentStyle || !element.currentStyle.hasLayout) element.style.zoom = 1;
if (!element.currentStyle || !element.currentStyle.hasLayout) style.zoom = 1; if (opacity == null || opacity == 1){
if (opacity == null || opacity == 1) opacity = ''; setFilter(element, reAlpha, '');
else opacity = 'alpha(opacity=' + (opacity * 100).limit(0, 100).round() + ')'; if (opacity == 1 && getOpacity(element) != 1) setFilter(element, reAlpha, 'alpha(opacity=100)');
var filter = style.filter || element.getComputedStyle('filter') || ''; } else {
style.filter = reAlpha.test(filter) ? filter.replace(reAlpha, opacity) : filter + opacity; setFilter(element, reAlpha, 'alpha(opacity=' + (opacity * 100).limit(0, 100).round() + ')');
if (!style.filter) style.removeAttribute('filter'); }
} : setVisibility)); } : setVisibility));
var getOpacity = (hasOpacity ? function(element){ var getOpacity = (hasOpacity ? function(element){
@@ -3622,15 +3707,27 @@ var getOpacity = (hasOpacity ? function(element){
return opacity; 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({ Element.implement({
getComputedStyle: function(property){ 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, var defaultView = Element.getDocument(this).defaultView,
computed = defaultView ? defaultView.getComputedStyle(this, null) : null; 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){ setStyle: function(property, value){
@@ -3652,7 +3749,7 @@ Element.implement({
this.style[property] = value; this.style[property] = value;
//<ltIE9> //<ltIE9>
if ((value == '' || value == null) && doesNotRemoveStyles && this.style.removeAttribute){ if ((value == '' || value == null) && doesNotRemoveStyles && this.style.removeAttribute){
this.style.removeAttribute(property); removeStyle(this.style, property);
} }
//</ltIE9> //</ltIE9>
return this; return this;
@@ -3663,20 +3760,25 @@ Element.implement({
property = (property == 'float' ? floatName : property).camelCase(); property = (property == 'float' ? floatName : property).camelCase();
var result = this.style[property]; var result = this.style[property];
if (!result || property == 'zIndex'){ if (!result || property == 'zIndex'){
result = []; if (Element.ShortStyles.hasOwnProperty(property)){
for (var style in Element.ShortStyles){ result = [];
if (property != style) continue; for (var s in Element.ShortStyles[property]) result.push(this.getStyle(s));
for (var s in Element.ShortStyles[style]) result.push(this.getStyle(s));
return result.join(' '); return result.join(' ');
} }
result = this.getComputedStyle(property); 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){ if (result){
result = String(result); result = String(result);
var color = result.match(/rgba?\([\d\s,]+\)/); var color = result.match(/rgba?\([\d\s,]+\)/);
if (color) result = result.replace(color[0], color[0].rgbToHex()); 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))){ if ((/^(height|width)$/).test(property) && !(/px$/.test(result))){
var values = (property == 'width') ? ['left', 'right'] : ['top', 'bottom'], size = 0; var values = (property == 'width') ? ['left', 'right'] : ['top', 'bottom'], size = 0;
values.each(function(value){ values.each(function(value){
@@ -3684,10 +3786,15 @@ Element.implement({
}, this); }, this);
return this['offset' + property.capitalize()] - size + 'px'; 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'; 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; return result;
}, },
@@ -3709,7 +3816,7 @@ Element.implement({
Element.Styles = { Element.Styles = {
left: '@px', top: '@px', bottom: '@px', right: '@px', left: '@px', top: '@px', bottom: '@px', right: '@px',
width: '@px', height: '@px', maxWidth: '@px', maxHeight: '@px', minWidth: '@px', minHeight: '@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)', 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(@, @, @)', 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(@, @, @)', 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(@, @, @)'; 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){ if (type.indexOf('key') == 0){
var code = this.code = (event.which || event.keyCode); var code = this.code = (event.which || event.keyCode);
this.key = _keys[code]; this.key = _keys[code];
if (type == 'keydown'){ if (type == 'keydown' || type == 'keyup'){
if (code > 111 && code < 124) this.key = 'f' + (code - 111); if (code > 111 && code < 124) this.key = 'f' + (code - 111);
else if (code > 95 && code < 106) this.key = code - 96; else if (code > 95 && code < 106) this.key = code - 96;
} }
@@ -4001,23 +4109,27 @@ Element.NativeEvents = {
gesturestart: 2, gesturechange: 2, gestureend: 2, // gesture 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 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 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 error: 1, abort: 1, scroll: 1 //misc
}; };
Element.Events = {mousewheel: { Element.Events = {
base: (Browser.firefox) ? 'DOMMouseScroll' : 'mousewheel' 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){ if ('onmouseenter' in document.documentElement){
Element.NativeEvents.mouseenter = Element.NativeEvents.mouseleave = 2; Element.NativeEvents.mouseenter = Element.NativeEvents.mouseleave = 2;
Element.MouseenterCheck = check;
} else { } 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 = { Element.Events.mouseenter = {
base: 'mouseover', base: 'mouseover',
condition: check condition: check
@@ -4035,12 +4147,12 @@ if (!window.addEventListener){
Element.Events.change = { Element.Events.change = {
base: function(){ base: function(){
var type = this.type; 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){ condition: function(event){
return this.type != 'radio' || (event.event.propertyName == 'checked' && this.checked); return event.type != 'propertychange' || event.event.propertyName == 'checked';
} }
} };
} }
/*</ltIE9>*/ /*</ltIE9>*/
@@ -4080,10 +4192,12 @@ var bubbleUp = function(self, match, fn, event, target){
var map = { var map = {
mouseenter: { mouseenter: {
base: 'mouseover' base: 'mouseover',
condition: Element.MouseenterCheck
}, },
mouseleave: { mouseleave: {
base: 'mouseout' base: 'mouseout',
condition: Element.MouseenterCheck
}, },
focus: { focus: {
base: 'focus' + (eventListenerSupport ? '' : 'in'), base: 'focus' + (eventListenerSupport ? '' : 'in'),
@@ -4190,8 +4304,8 @@ var delegation = {
}; };
var elementEvent = Element.Events[_type]; var elementEvent = Element.Events[_type];
if (elementEvent && elementEvent.condition){ if (_map.condition || elementEvent && elementEvent.condition){
var __match = match, condition = elementEvent.condition; var __match = match, condition = _map.condition || elementEvent.condition;
match = function(target, event){ match = function(target, event){
return __match(target, event) && condition.call(target, event, type); return __match(target, event) && condition.call(target, event, type);
}; };
@@ -4226,7 +4340,7 @@ var delegation = {
if (_map.remove) _map.remove(this, _uid); if (_map.remove) _map.remove(this, _uid);
delete stored[_uid]; delete stored[_uid];
storage[_type] = stored; storage[_type] = stored;
return removeEvent.call(this, type, delegator); return removeEvent.call(this, type, delegator, _map.capture);
} }
var __uid, s; var __uid, s;
@@ -4344,7 +4458,9 @@ Element.implement({
}, },
getOffsets: function(){ getOffsets: function(){
if (this.getBoundingClientRect && !Browser.Platform.ios){ var hasGetBoundingClientRect = this.getBoundingClientRect;
if (hasGetBoundingClientRect){
var bound = this.getBoundingClientRect(), var bound = this.getBoundingClientRect(),
html = document.id(this.getDocument().documentElement), html = document.id(this.getDocument().documentElement),
htmlScroll = html.getScroll(), htmlScroll = html.getScroll(),
@@ -4364,27 +4480,9 @@ Element.implement({
position.x += element.offsetLeft; position.x += element.offsetLeft;
position.y += element.offsetTop; 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; element = element.offsetParent;
} }
if (Browser.firefox && !borderBox(this)){
position.x -= leftBorder(this);
position.y -= topBorder(this);
}
return position; return position;
}, },
@@ -4666,13 +4764,17 @@ var Fx = this.Fx = new Class({
}, },
resume: function(){ 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; return this;
}, },
isRunning: function(){ isRunning: function(){
var list = instances[this.options.fps]; var list = instances[this.options.fps];
return list && list.contains(this); 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); from = element.getStyle(property);
var unit = this.options.unit; var unit = this.options.unit;
// adapted from: https://github.com/ryanmorr/fx/blob/master/fx.js#L299 // 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); element.setStyle(property, to + unit);
var value = element.getComputedStyle(property); var value = element.getComputedStyle(property);
// IE and Opera support pixelLeft or pixelWidth // IE and Opera support pixelLeft or pixelWidth
@@ -4817,11 +4919,13 @@ Fx.CSS = new Class({
search: function(selector){ search: function(selector){
if (Fx.CSS.Cache[selector]) return Fx.CSS.Cache[selector]; if (Fx.CSS.Cache[selector]) return Fx.CSS.Cache[selector];
var to = {}, selectorTest = new RegExp('^' + selector.escapeRegExp() + '$'); var to = {}, selectorTest = new RegExp('^' + selector.escapeRegExp() + '$');
Array.each(document.styleSheets, function(sheet, j){
var href = sheet.href; var searchStyles = function(rules){
if (href && href.contains('://') && !href.contains(document.domain)) return;
var rules = sheet.rules || sheet.cssRules;
Array.each(rules, function(rule, i){ Array.each(rules, function(rule, i){
if (rule.media){
searchStyles(rule.rules || rule.cssRules);
return;
}
if (!rule.style) return; if (!rule.style) return;
var selectorText = (rule.selectorText) ? rule.selectorText.replace(/^\w+/, function(m){ var selectorText = (rule.selectorText) ? rule.selectorText.replace(/^\w+/, function(m){
return m.toLowerCase(); return m.toLowerCase();
@@ -4833,6 +4937,13 @@ Fx.CSS = new Class({
to[style] = ((/^rgb/).test(value)) ? value.rgbToHex() : value; 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; 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 (trimPosition > -1 && (trimPosition = url.indexOf('#')) > -1) url = url.substr(0, trimPosition);
if (this.options.noCache) if (this.options.noCache)
url += (url.contains('?') ? '&' : '?') + String.uniqueID(); url += (url.indexOf('?') > -1 ? '&' : '?') + String.uniqueID();
if (data && method == 'get'){ if (data && (method == 'get' || method == 'delete')){
url += (url.contains('?') ? '&' : '?') + data; url += (url.indexOf('?') > -1 ? '&' : '?') + data;
data = null; data = null;
} }
@@ -5526,10 +5637,14 @@ JSON.encode = JSON.stringify ? function(obj){
return null; return null;
}; };
JSON.secure = true;
JSON.decode = function(string, secure){ JSON.decode = function(string, secure){
if (!string || typeOf(string) != 'string') return null; 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.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.'); if (!JSON.validate(string)) throw new Error('JSON could not decode the input; security is enabled and the value is not secure.');
} }
@@ -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 = { MooTools.More = {
'version': '1.4.0.1', version: '1.5.0',
'build': 'a4244edf2aa97ac8a196fc96082dd35af1abab87' build: '73db5e24e6e9c5c87b3a27aebef2248053f7db37'
}; };
@@ -48,7 +58,7 @@ license: MIT-style license
authors: authors:
- Arian Stolwijk - Arian Stolwijk
requires: [Core/Class.Extras, Core/Slick.Parser, More/MooTools.More] requires: [Core/Class.Extras, Core/Slick.Parser, MooTools.More]
provides: [Events.Pseudos] provides: [Events.Pseudos]
@@ -211,7 +221,7 @@ authors:
requires: requires:
- Core/Object - Core/Object
- /MooTools.More - MooTools.More
provides: [Object.Extras] provides: [Object.Extras]
@@ -280,8 +290,8 @@ authors:
requires: requires:
- Core/Events - Core/Events
- /Object.Extras - Object.Extras
- /MooTools.More - MooTools.More
provides: [Locale, Lang] provides: [Locale, Lang]
@@ -444,7 +454,7 @@ authors:
- Aaron Newton - Aaron Newton
requires: requires:
- /Locale - Locale
provides: [Locale.en-US.Date] provides: [Locale.en-US.Date]
@@ -1079,7 +1089,7 @@ authors:
- Scott Kyle - Scott Kyle
requires: requires:
- /Date - Date
provides: [Date.Extras] provides: [Date.Extras]
@@ -1235,10 +1245,8 @@ var special = {
'S': /[ŠŞŚ]/g, 'S': /[ŠŞŚ]/g,
't': /[ťţ]/g, 't': /[ťţ]/g,
'T': /[ŤŢ]/g, 'T': /[ŤŢ]/g,
'ue': /[ü]/g, 'u': /[ùúûůüµ]/g,
'UE': /[Ü]/g, 'U': /[ÙÚÛŮÜ]/g,
'u': /[ùúûůµ]/g,
'U': /[ÙÚÛŮ]/g,
'y': /[ÿý]/g, 'y': /[ÿý]/g,
'Y': /[ŸÝ]/g, 'Y': /[ŸÝ]/g,
'z': /[žźż]/g, 'z': /[žźż]/g,
@@ -1263,7 +1271,16 @@ tidy = {
'-': /[\u2013]/g, '-': /[\u2013]/g,
// '--': /[\u2014]/g, // '--': /[\u2014]/g,
'&raquo;': /[\uFFFD]/g '&raquo;': /[\uFFFD]/g
}; },
conversions = {
ms: 1,
s: 1000,
m: 6e4,
h: 36e5
},
findUnits = /(\d*.?\d+)([msh]+)/;
var walk = function(string, replacements){ var walk = function(string, replacements){
var result = string, key; var result = string, key;
@@ -1325,6 +1342,13 @@ String.implement({
if (trail) string += trail; if (trail) string += trail;
} }
return string; 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: requires:
- Core/Element - Core/Element
- /String.Extras - String.Extras
- /MooTools.More - MooTools.More
provides: [Element.Forms] provides: [Element.Forms]
@@ -1493,7 +1517,7 @@ authors:
requires: requires:
- Core/Element.Style - Core/Element.Style
- Core/Element.Dimensions - Core/Element.Dimensions
- /MooTools.More - MooTools.More
provides: [Element.Measure] provides: [Element.Measure]
@@ -1710,13 +1734,15 @@ var local = Element.Position = {
}, },
setOffsetOption: function(element, options){ setOffsetOption: function(element, options){
var parentOffset = {x: 0, y: 0}, var parentOffset = {x: 0, y: 0};
offsetParent = element.measure(function(){ var parentScroll = {x: 0, y: 0};
return document.id(this.getOffsetParent()); var offsetParent = element.measure(function(){
}), return document.id(this.getOffsetParent());
parentScroll = offsetParent.getScroll(); });
if (!offsetParent || offsetParent == element.getDocument().body) return; if (!offsetParent || offsetParent == element.getDocument().body) return;
parentScroll = offsetParent.getScroll();
parentOffset = offsetParent.measure(function(){ parentOffset = offsetParent.measure(function(){
var position = this.getPosition(); var position = this.getPosition();
if (this.getStyle('position') == 'fixed'){ if (this.getStyle('position') == 'fixed'){
@@ -1896,7 +1922,7 @@ authors:
requires: requires:
- Core/Element.Style - Core/Element.Style
- /MooTools.More - MooTools.More
provides: [Element.Shortcuts] provides: [Element.Shortcuts]
@@ -1976,7 +2002,7 @@ requires:
- Core/Fx - Core/Fx
- Core/Element.Event - Core/Element.Event
- Core/Element.Dimensions - Core/Element.Dimensions
- /MooTools.More - MooTools.More
provides: [Fx.Scroll] provides: [Fx.Scroll]
@@ -2014,7 +2040,6 @@ Fx.Scroll = new Class({
set: function(){ set: function(){
var now = Array.flatten(arguments); 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]); this.element.scrollTo(now[0], now[1]);
return this; return this;
}, },
@@ -2148,7 +2173,7 @@ authors:
requires: requires:
- Core/Fx - Core/Fx
- Core/Element.Style - Core/Element.Style
- /MooTools.More - MooTools.More
provides: [Fx.Slide] provides: [Fx.Slide]
@@ -2325,7 +2350,7 @@ requires:
- Core/Element.Event - Core/Element.Event
- Core/Element.Style - Core/Element.Style
- Core/Element.Dimensions - Core/Element.Dimensions
- /MooTools.More - MooTools.More
provides: [Drag] provides: [Drag]
... ...
@@ -2371,10 +2396,10 @@ var Drag = new Class({
this.mouse = {'now': {}, 'pos': {}}; this.mouse = {'now': {}, 'pos': {}};
this.value = {'start': {}, 'now': {}}; 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); document.ondragstart = Function.from(false);
Drag.ondragstartFixed = true; Drag.ondragstartFixed = true;
} }
@@ -2559,7 +2584,7 @@ authors:
requires: requires:
- Core/Element.Dimensions - Core/Element.Dimensions
- /Drag - Drag
provides: [Drag.Move] provides: [Drag.Move]
@@ -2586,10 +2611,7 @@ Drag.Move = new Class({
element = this.element; element = this.element;
this.droppables = $$(this.options.droppables); this.droppables = $$(this.options.droppables);
this.container = document.id(this.options.container); this.setContainer(this.options.container);
if (this.container && typeOf(this.container) != 'element')
this.container = document.id(this.container.getDocument().body);
if (this.options.style){ if (this.options.style){
if (this.options.modifiers.x == 'left' && this.options.modifiers.y == 'top'){ if (this.options.modifiers.x == 'left' && this.options.modifiers.y == 'top'){
@@ -2607,6 +2629,13 @@ Drag.Move = new Class({
this.overed = null; 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){ start: function(event){
if (this.container) this.options.limit = this.calculateLimit(); if (this.container) this.options.limit = this.calculateLimit();
@@ -2670,7 +2699,9 @@ Drag.Move = new Class({
if (container != offsetParent){ if (container != offsetParent){
left += containerMargin.left + offsetParentPadding.left; 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 { } else {
left -= elementMargin.left; left -= elementMargin.left;
@@ -2754,7 +2785,7 @@ authors:
requires: requires:
- Core/Fx.Morph - Core/Fx.Morph
- /Drag.Move - Drag.Move
provides: [Sortables] provides: [Sortables]
@@ -2773,7 +2804,8 @@ var Sortables = new Class({
clone: false, clone: false,
revert: false, revert: false,
handle: false, handle: false,
dragOptions: {} dragOptions: {},
unDraggableTags: ['button', 'input', 'a', 'textarea', 'select', 'option']
}, },
initialize: function(lists, options){ initialize: function(lists, options){
@@ -2840,6 +2872,24 @@ var Sortables = new Class({
}, this)); }, 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){ getClone: function(event, element){
if (!this.options.clone) return new Element(element.tagName).inject(document.body); if (!this.options.clone) return new Element(element.tagName).inject(document.body);
if (typeOf(this.options.clone) == 'function') return this.options.clone.call(this, event, element, this.list); if (typeOf(this.options.clone) == 'function') return this.options.clone.call(this, event, element, this.list);
@@ -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(){ getDroppables: function(){
@@ -2884,7 +2934,7 @@ var Sortables = new Class({
if ( if (
!this.idle || !this.idle ||
event.rightClick || event.rightClick ||
['button', 'input', 'a', 'textarea'].contains(event.target.get('tag')) (!this.options.handle && this.options.unDraggableTags.contains(event.target.get('tag')))
) return; ) return;
this.idle = false; this.idle = false;
@@ -2915,14 +2965,16 @@ var Sortables = new Class({
end: function(){ end: function(){
this.drag.detach(); this.drag.detach();
this.element.setStyle('opacity', this.opacity); this.element.setStyle('opacity', this.opacity);
var self = this;
if (this.effect){ if (this.effect){
var dim = this.element.getStyles('width', 'height'), var dim = this.element.getStyles('width', 'height'),
clone = this.clone, clone = this.clone,
pos = clone.computePosition(this.element.getPosition(this.clone.getOffsetParent())); pos = clone.computePosition(this.getDroppableCoordinates(clone));
var destroy = function(){ var destroy = function(){
this.removeEvent('cancel', destroy); this.removeEvent('cancel', destroy);
clone.destroy(); clone.destroy();
self.reset();
}; };
this.effect.element = clone; this.effect.element = clone;
@@ -2935,8 +2987,9 @@ var Sortables = new Class({
}).addEvent('cancel', destroy).chain(destroy); }).addEvent('cancel', destroy).chain(destroy);
} else { } else {
this.clone.destroy(); this.clone.destroy();
self.reset();
} }
this.reset();
}, },
reset: function(){ reset: function(){
@@ -3125,7 +3178,7 @@ authors:
requires: requires:
- Core/Request - Core/Request
- /MooTools.More - MooTools.More
provides: [Request.Periodical] provides: [Request.Periodical]