Mootools update

This commit is contained in:
Ruud
2011-10-10 11:17:36 +02:00
parent f1815899b8
commit e154ee59d2
2 changed files with 222 additions and 37 deletions
+44 -32
View File
@@ -33,8 +33,8 @@ provides: [Core, MooTools, Type, typeOf, instanceOf, Native]
(function(){
this.MooTools = {
version: '1.4.0',
build: 'a15e35b4dbd12e8d86d9b50aa67a27e8e0071ea3'
version: '1.4.1',
build: 'd1fb25710e3c5482a219ab9dc675a4e0ad2176b6'
};
// typeOf, instanceOf
@@ -3003,7 +3003,7 @@ Object.append(properties, {
'html': 'innerHTML',
'text': (function(){
var temp = document.createElement('div');
return (temp.innerText == null) ? 'textContent' : 'innerText';
return (temp.textContent == null) ? 'innerText': 'textContent';
})()
});
@@ -3060,7 +3060,15 @@ Object.append(propertySetters, {
Element.implement({
setProperty: function(name, value){
var setter = propertySetters[name.toLowerCase()];
var lower = name.toLowerCase();
if (value == null){
if (!booleans[lower]){
this.removeAttribute(name);
return this;
}
value = false;
}
var setter = propertySetters[lower];
if (setter) setter(this, value);
else this.setAttribute(name, value);
return this;
@@ -3084,10 +3092,7 @@ Element.implement({
},
removeProperty: function(name){
name = name.toLowerCase();
if (booleans[name]) this.setProperty(name, false);
this.removeAttribute(name);
return this;
return this.setProperty(name, null);
},
removeProperties: function(){
@@ -3651,7 +3656,7 @@ var DOMEvent = this.DOMEvent = new Type('DOMEvent', function(event, win){
else if (code > 95 && code < 106) this.key = code - 96;
}
if (this.key == null) this.key = String.fromCharCode(code).toLowerCase();
} else if (type == 'click' || type == 'dblclick' || type == 'contextmenu' || type.indexOf('mouse') == 0){
} else if (type == 'click' || type == 'dblclick' || type == 'contextmenu' || type == 'DOMMouseScroll' || type.indexOf('mouse') == 0){
var doc = win.document;
doc = (!doc.compatMode || doc.compatMode == 'CSS1Compat') ? doc.html : doc.body;
this.page = {
@@ -3671,7 +3676,7 @@ var DOMEvent = this.DOMEvent = new Type('DOMEvent', function(event, win){
while (related && related.nodeType == 3) related = related.parentNode;
this.relatedTarget = document.id(related);
}
} else if (type.indexOf('touch') == 0 || type.indexOf('gesture') == 0){
} else if (type.indexOf('touch') == 0 || type.indexOf('gesture') == 0){
this.rotation = event.rotation;
this.scale = event.scale;
this.targetTouches = event.targetTouches;
@@ -3866,7 +3871,7 @@ Element.NativeEvents = {
orientationchange: 2, // mobile
touchstart: 2, touchmove: 2, touchend: 2, touchcancel: 2, // touch
gesturestart: 2, gesturechange: 2, gestureend: 2, // gesture
focus: 2, blur: 2, change: 2, reset: 2, select: 2, submit: 2, paste: 2, oninput: 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
error: 1, abort: 1, scroll: 1 //misc
};
@@ -3938,8 +3943,7 @@ var eventListenerSupport = !!window.addEventListener;
Element.NativeEvents.focusin = Element.NativeEvents.focusout = 2;
var bubbleUp = function(self, match, fn, event){
var target = event.target;
var bubbleUp = function(self, match, fn, event, target){
while (target && target != self){
if (match(target, event)) return fn.call(target, event, target);
target = document.id(target.parentNode);
@@ -3978,9 +3982,8 @@ var formObserver = function(type){
}
},
listen: function(self, match, fn, event, uid){
var target = event.target,
form = (target.get('tag') == 'form') ? target : event.target.getParent('form');
listen: function(self, match, fn, event, target, uid){
var form = (target.get('tag') == 'form') ? target : event.target.getParent('form');
if (!form) return;
var listeners = self.retrieve(_key + type + 'listeners', {}),
@@ -3991,7 +3994,7 @@ var formObserver = function(type){
forms.push(form);
var _fn = function(event){
bubbleUp(self, match, fn, event);
bubbleUp(self, match, fn, event, target);
};
form.addEvent(type, _fn);
fns.push(_fn);
@@ -4005,12 +4008,12 @@ var formObserver = function(type){
var inputObserver = function(type){
return {
base: 'focusin',
listen: function(self, match, fn, event){
listen: function(self, match, fn, event, target){
var events = {blur: function(){
this.removeEvents(events);
}};
events[type] = function(event){
bubbleUp(self, match, fn, event);
bubbleUp(self, match, fn, event, target);
};
event.target.addEvents(events);
}
@@ -4038,6 +4041,7 @@ var relay = function(old, method){
parsed.pseudos.slice(1).each(function(pseudo){
newType += ':' + pseudo.key + (pseudo.value ? '(' + pseudo.value + ')' : '');
});
old.call(this, type, fn);
return method.call(this, newType, parsed.pseudos[0].value, fn);
};
};
@@ -4066,10 +4070,12 @@ var delegation = {
}
var self = this, uid = String.uniqueID();
var delegator = _map.listen ? function(event){
_map.listen(self, match, fn, event, uid);
} : function(event){
bubbleUp(self, match, fn, event);
var delegator = _map.listen ? function(event, target){
if (!target && event && event.target) target = event.target;
if (target) _map.listen(self, match, fn, event, target, uid);
} : function(event, target){
if (!target && event && event.target) target = event.target;
if (target) bubbleUp(self, match, fn, event, target);
};
if (!stored) stored = {};
@@ -4793,27 +4799,33 @@ Element.Properties.tween = {
Element.implement({
tween: function(property, from, to){
this.get('tween').start(arguments);
this.get('tween').start(property, from, to);
return this;
},
fade: function(how){
var fade = this.get('tween'), o = 'opacity', toggle;
how = [how, 'toggle'].pick();
var fade = this.get('tween'), method, to, toggle;
if (how == null) how = 'toggle';
switch (how){
case 'in': fade.start(o, 1); break;
case 'out': fade.start(o, 0); break;
case 'show': fade.set(o, 1); break;
case 'hide': fade.set(o, 0); break;
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;
case 'toggle':
var flag = this.retrieve('fade:flag', this.getStyle('opacity') == 1);
fade.start(o, (flag) ? 0 : 1);
method = 'start';
to = flag ? 0 : 1;
this.store('fade:flag', !flag);
toggle = true;
break;
default: fade.start(o, arguments);
default: method = 'start'; to = how;
}
if (!toggle) this.eliminate('fade:flag');
fade[method]('opacity', to);
if (method == 'set' || to != 0) this.setStyle('visibility', to == 0 ? 'hidden' : 'visible');
else fade.chain(function(){
this.element.setStyle('visibility', 'hidden');
});
return this;
},
@@ -1,6 +1,6 @@
// MooTools: the javascript framework.
// Load this file's selection again by visiting: http://mootools.net/more/13115b95c0560a5c35a61ccf237f3ed9
// Or build this file again with packager using: packager build More/Element.Forms More/Element.Shortcuts More/Fx.Slide More/Sortables More/Request.JSONP More/Request.Periodical More/Spinner
// Load this file's selection again by visiting: http://mootools.net/more/2bb87efbb3e2cfe85537fcfe52571fb4
// Or build this file again with packager using: packager build More/Element.Forms More/Element.Shortcuts More/Fx.Scroll More/Fx.Slide More/Sortables More/Request.JSONP More/Request.Periodical More/Spinner
/*
---
@@ -406,6 +406,179 @@ Document.implement({
});
/*
---
script: Fx.Scroll.js
name: Fx.Scroll
description: Effect to smoothly scroll any element, including the window.
license: MIT-style license
authors:
- Valerio Proietti
requires:
- Core/Fx
- Core/Element.Event
- Core/Element.Dimensions
- /MooTools.More
provides: [Fx.Scroll]
...
*/
(function(){
Fx.Scroll = new Class({
Extends: Fx,
options: {
offset: {x: 0, y: 0},
wheelStops: true
},
initialize: function(element, options){
this.element = this.subject = document.id(element);
this.parent(options);
if (typeOf(this.element) != 'element') this.element = document.id(this.element.getDocument().body);
if (this.options.wheelStops){
var stopper = this.element,
cancel = this.cancel.pass(false, this);
this.addEvent('start', function(){
stopper.addEvent('mousewheel', cancel);
}, true);
this.addEvent('complete', function(){
stopper.removeEvent('mousewheel', cancel);
}, true);
}
},
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;
},
compute: function(from, to, delta){
return [0, 1].map(function(i){
return Fx.compute(from[i], to[i], delta);
});
},
start: function(x, y){
if (!this.check(x, y)) return this;
var scroll = this.element.getScroll();
return this.parent([scroll.x, scroll.y], [x, y]);
},
calculateScroll: function(x, y){
var element = this.element,
scrollSize = element.getScrollSize(),
scroll = element.getScroll(),
size = element.getSize(),
offset = this.options.offset,
values = {x: x, y: y};
for (var z in values){
if (!values[z] && values[z] !== 0) values[z] = scroll[z];
if (typeOf(values[z]) != 'number') values[z] = scrollSize[z] - size[z];
values[z] += offset[z];
}
return [values.x, values.y];
},
toTop: function(){
return this.start.apply(this, this.calculateScroll(false, 0));
},
toLeft: function(){
return this.start.apply(this, this.calculateScroll(0, false));
},
toRight: function(){
return this.start.apply(this, this.calculateScroll('right', false));
},
toBottom: function(){
return this.start.apply(this, this.calculateScroll(false, 'bottom'));
},
toElement: function(el, axes){
axes = axes ? Array.from(axes) : ['x', 'y'];
var scroll = isBody(this.element) ? {x: 0, y: 0} : this.element.getScroll();
var position = Object.map(document.id(el).getPosition(this.element), function(value, axis){
return axes.contains(axis) ? value + scroll[axis] : false;
});
return this.start.apply(this, this.calculateScroll(position.x, position.y));
},
toElementEdge: function(el, axes, offset){
axes = axes ? Array.from(axes) : ['x', 'y'];
el = document.id(el);
var to = {},
position = el.getPosition(this.element),
size = el.getSize(),
scroll = this.element.getScroll(),
containerSize = this.element.getSize(),
edge = {
x: position.x + size.x,
y: position.y + size.y
};
['x', 'y'].each(function(axis){
if (axes.contains(axis)){
if (edge[axis] > scroll[axis] + containerSize[axis]) to[axis] = edge[axis] - containerSize[axis];
if (position[axis] < scroll[axis]) to[axis] = position[axis];
}
if (to[axis] == null) to[axis] = scroll[axis];
if (offset && offset[axis]) to[axis] = to[axis] + offset[axis];
}, this);
if (to.x != scroll.x || to.y != scroll.y) this.start(to.x, to.y);
return this;
},
toElementCenter: function(el, axes, offset){
axes = axes ? Array.from(axes) : ['x', 'y'];
el = document.id(el);
var to = {},
position = el.getPosition(this.element),
size = el.getSize(),
scroll = this.element.getScroll(),
containerSize = this.element.getSize();
['x', 'y'].each(function(axis){
if (axes.contains(axis)){
to[axis] = position[axis] - (containerSize[axis] - size[axis]) / 2;
}
if (to[axis] == null) to[axis] = scroll[axis];
if (offset && offset[axis]) to[axis] = to[axis] + offset[axis];
}, this);
if (to.x != scroll.x || to.y != scroll.y) this.start(to.x, to.y);
return this;
}
});
function isBody(element){
return (/^(?:body|html)$/i).test(element.tagName);
}
})();
/*
---
@@ -1164,7 +1337,7 @@ var Sortables = new Class({
this.idle = false;
this.element = element;
this.opacity = element.get('opacity');
this.opacity = element.getStyle('opacity');
this.list = element.getParent();
this.clone = this.getClone(event, element);
@@ -1175,7 +1348,7 @@ var Sortables = new Class({
onSnap: function(){
event.stop();
this.clone.setStyle('visibility', 'visible');
this.element.set('opacity', this.options.opacity || 0);
this.element.setStyle('opacity', this.options.opacity || 0);
this.fireEvent('start', [this.element, this.clone]);
}.bind(this),
onEnter: this.insert.bind(this),
@@ -1189,7 +1362,7 @@ var Sortables = new Class({
end: function(){
this.drag.detach();
this.element.set('opacity', this.opacity);
this.element.setStyle('opacity', this.opacity);
if (this.effect){
var dim = this.element.getStyles('width', 'height'),
clone = this.clone,