diff --git a/couchpotato/static/scripts/vendor/mootools.js b/couchpotato/static/scripts/vendor/mootools.js
index 838edee6..1e816e02 100644
--- a/couchpotato/static/scripts/vendor/mootools.js
+++ b/couchpotato/static/scripts/vendor/mootools.js
@@ -1,16 +1,7 @@
+/* MooTools: the javascript framework. license: MIT-style license. copyright: Copyright (c) 2006-2014 [Valerio Proietti](http://mad4milk.net/).*/
/*
----
-MooTools: the javascript framework
-
-web build:
- - http://mootools.net/core/f42fb6d73ea1a13146c5ad9502b442f0
-
-packager build:
- - packager build Core/Class Core/Class.Extras Core/Element Core/Element.Style Core/Element.Delegation Core/Element.Dimensions Core/Fx.Tween Core/Fx.Morph Core/Fx.Transitions Core/Request.JSON Core/Cookie Core/DOMReady
-
-...
+Web Build: http://mootools.net/core/builder/90d9ff9fd02e4de69368c13d49be4022
*/
-
/*
---
@@ -32,12 +23,12 @@ provides: [Core, MooTools, Type, typeOf, instanceOf, Native]
...
*/
-
+/*! MooTools: the javascript framework. license: MIT-style license. copyright: Copyright (c) 2006-2014 [Valerio Proietti](http://mad4milk.net/).*/
(function(){
this.MooTools = {
- version: '1.5.0',
- build: '0f7b690afee9349b15909f33016a25d2e4d9f4e3'
+ version: '1.5.1',
+ build: '0542c135fdeb7feed7d9917e01447a408f22c876'
};
// typeOf, instanceOf
@@ -413,7 +404,6 @@ String.extend('uniqueID', function(){
})();
-
/*
---
@@ -586,7 +576,6 @@ Array.implement({
-
/*
---
@@ -674,7 +663,6 @@ String.implement({
-
/*
---
@@ -755,7 +743,6 @@ Function.implement({
-
/*
---
@@ -809,7 +796,6 @@ Number.alias('each', 'times');
Number.implement(methods);
})(['abs', 'acos', 'asin', 'atan', 'atan2', 'ceil', 'cos', 'exp', 'floor', 'log', 'max', 'min', 'pow', 'sin', 'sqrt', 'tan']);
-
/*
---
@@ -926,7 +912,6 @@ Class.Mutators = {
})();
-
/*
---
@@ -1006,7 +991,7 @@ this.Events = new Class({
type = removeOn(type);
var events = this.$events[type];
if (events && !fn.internal){
- var index = events.indexOf(fn);
+ var index = events.indexOf(fn);
if (index != -1) delete events[index];
}
return this;
@@ -1047,7 +1032,6 @@ this.Options = new Class({
})();
-
/*
---
@@ -1078,11 +1062,11 @@ var parse = function(ua, platform){
if (UA[1] == 'trident'){
UA[1] = 'ie';
if (UA[4]) UA[2] = UA[4];
- } else if (UA[1] == 'crios') {
+ } else if (UA[1] == 'crios'){
UA[1] = 'chrome';
}
- var platform = ua.match(/ip(?:ad|od|hone)/) ? 'ios' : (ua.match(/(?:webos|android)/) || platform.match(/mac|win|linux/) || ['other'])[0];
+ platform = ua.match(/ip(?:ad|od|hone)/) ? 'ios' : (ua.match(/(?:webos|android)/) || platform.match(/mac|win|linux/) || ['other'])[0];
if (platform == 'win') platform = 'windows';
return {
@@ -1095,7 +1079,7 @@ var parse = function(ua, platform){
var Browser = this.Browser = parse(navigator.userAgent, navigator.platform);
-if (Browser.ie){
+if (Browser.name == 'ie'){
Browser.version = document.documentMode;
}
@@ -1208,6 +1192,7 @@ if (this.attachEvent && !this.addEventListener){
var unloadEvent = function(){
this.detachEvent('onunload', unloadEvent);
document.head = document.html = document.window = null;
+ window = this.Window = document = null;
};
this.attachEvent('onunload', unloadEvent);
}
@@ -1241,7 +1226,6 @@ try {
})();
-
/*
---
@@ -1364,7 +1348,6 @@ Object.extend({
-
/*
---
name: Slick.Parser
@@ -1596,7 +1579,6 @@ if (!this.Slick) this.Slick = Slick;
}).apply(/**/(typeof exports != 'undefined') ? exports : /**/this);
-
/*
---
name: Slick.Finder
@@ -1774,7 +1756,7 @@ local.setDocument = function(document){
root.slick_expando = 1;
delete root.slick_expando;
features.getUID = this.getUIDHTML;
- } catch(e) {
+ } catch(e){
features.getUID = this.getUIDXML;
}
@@ -1795,9 +1777,9 @@ local.setDocument = function(document){
// hasAttribute
- features.hasAttribute = (root && this.isNativeCode(root.hasAttribute)) ? function(node, attribute) {
+ features.hasAttribute = (root && this.isNativeCode(root.hasAttribute)) ? function(node, attribute){
return node.hasAttribute(attribute);
- } : function(node, attribute) {
+ } : function(node, attribute){
node = node.getAttributeNode(attribute);
return !!(node && (node.specified || node.nodeValue));
};
@@ -1879,7 +1861,7 @@ local.search = function(context, expression, append, first){
/**/
var simpleSelector = expression.match(reSimpleSelector);
- simpleSelectors: if (simpleSelector) {
+ simpleSelectors: if (simpleSelector){
var symbol = simpleSelector[1],
name = simpleSelector[2],
@@ -1932,7 +1914,7 @@ local.search = function(context, expression, append, first){
/**/
/**/
- querySelector: if (context.querySelectorAll) {
+ querySelector: if (context.querySelectorAll){
if (!this.isHTMLDocument
|| qsaFailExpCache[expression]
@@ -1961,7 +1943,7 @@ local.search = function(context, expression, append, first){
try {
if (first) return context.querySelector(_expression) || null;
else nodes = context.querySelectorAll(_expression);
- } catch(e) {
+ } catch(e){
qsaFailExpCache[expression] = 1;
break querySelector;
} finally {
@@ -2160,14 +2142,14 @@ local.matchNode = function(node, selector){
if (this.isHTMLDocument && this.nativeMatchesSelector){
try {
return this.nativeMatchesSelector.call(node, selector.replace(/\[([^=]+)=\s*([^'"\]]+?)\s*\]/g, '[$1="$2"]'));
- } catch(matchError) {}
+ } catch(matchError){}
}
var parsed = this.Slick.parse(selector);
if (!parsed) return true;
// simple (single) selectors
- var expressions = parsed.expressions, simpleExpCounter = 0, i;
+ var expressions = parsed.expressions, simpleExpCounter = 0, i, currentExpression;
for (i = 0; (currentExpression = expressions[i]); i++){
if (currentExpression.length == 1){
var exp = currentExpression[0];
@@ -2583,7 +2565,6 @@ if (!this.Slick) this.Slick = Slick;
}).apply(/**/(typeof exports != 'undefined') ? exports : /**/this);
-
/*
---
@@ -2792,20 +2773,44 @@ var escapeQuotes = function(html){
};
/**/
+/**/
+// #2479 - IE8 Cannot set HTML of style element
+var canChangeStyleHTML = (function(){
+ var div = document.createElement('style'),
+ flag = false;
+ try {
+ div.innerHTML = '#justTesing{margin: 0px;}';
+ flag = !!div.innerHTML;
+ } catch(e){}
+ return flag;
+})();
+/**/
+
Document.implement({
newElement: function(tag, props){
- if (props && props.checked != null) props.defaultChecked = props.checked;
- /**/// Fix for readonly name and type properties in IE < 8
- if (createElementAcceptsHTML && props){
- tag = '<' + tag;
- if (props.name) tag += ' name="' + escapeQuotes(props.name) + '"';
- if (props.type) tag += ' type="' + escapeQuotes(props.type) + '"';
- tag += '>';
- delete props.name;
- delete props.type;
+ if (props){
+ if (props.checked != null) props.defaultChecked = props.checked;
+ if ((props.type == 'checkbox' || props.type == 'radio') && props.value == null) props.value = 'on';
+ /**/ // IE needs the type to be set before changing content of style element
+ if (!canChangeStyleHTML && tag == 'style'){
+ var styleElement = document.createElement('style');
+ styleElement.setAttribute('type', 'text/css');
+ if (props.type) delete props.type;
+ return this.id(styleElement).set(props);
+ }
+ /**/
+ /**/// Fix for readonly name and type properties in IE < 8
+ if (createElementAcceptsHTML){
+ tag = '<' + tag;
+ if (props.name) tag += ' name="' + escapeQuotes(props.name) + '"';
+ if (props.type) tag += ' type="' + escapeQuotes(props.type) + '"';
+ tag += '>';
+ delete props.name;
+ delete props.type;
+ }
+ /**/
}
- /**/
return this.id(this.createElement(tag)).set(props);
}
@@ -3040,6 +3045,21 @@ Object.forEach(properties, function(real, key){
};
});
+/**/
+propertySetters.text = (function(setter){
+ return function(node, value){
+ if (node.get('tag') == 'style') node.set('html', value);
+ else node[properties.text] = value;
+ };
+})(propertySetters.text);
+
+propertyGetters.text = (function(getter){
+ return function(node){
+ return (node.get('tag') == 'style') ? node.innerHTML : getter(node);
+ };
+})(propertyGetters.text);
+/**/
+
// Booleans
var bools = [
@@ -3098,15 +3118,42 @@ el = null;
/* */
/**/
-var input = document.createElement('input');
+
+/**/
+// #2479 - IE8 Cannot set HTML of style element
+var canChangeStyleHTML = (function(){
+ var div = document.createElement('style'),
+ flag = false;
+ try {
+ div.innerHTML = '#justTesing{margin: 0px;}';
+ flag = !!div.innerHTML;
+ } catch(e){}
+ return flag;
+})();
+/**/
+
+var input = document.createElement('input'), volatileInputValue, html5InputSupport;
+
+// #2178
input.value = 't';
input.type = 'submit';
-if (input.value != 't') propertySetters.type = function(node, type){
- var value = node.value;
- node.type = type;
- node.value = value;
-};
+volatileInputValue = input.value != 't';
+
+// #2443 - IE throws "Invalid Argument" when trying to use html5 input types
+try {
+ input.type = 'email';
+ html5InputSupport = input.type == 'email';
+} catch(e){}
+
input = null;
+
+if (volatileInputValue || !html5InputSupport) propertySetters.type = function(node, type){
+ try {
+ var value = node.value;
+ node.type = type;
+ node.value = value;
+ } catch (e){}
+};
/**/
/* getProperty, setProperty */
@@ -3118,7 +3165,7 @@ var pollutesGetAttribute = (function(div){
})(document.createElement('div'));
var hasCloneBug = (function(test){
- test.innerHTML = '';
+ test.innerHTML = '';
return test.cloneNode(true).firstChild.childNodes.length != 1;
})(document.createElement('div'));
/* */
@@ -3224,7 +3271,7 @@ Element.implement({
hasClass: hasClassList ? function(className){
return this.classList.contains(className);
} : function(className){
- return this.className.clean().contains(className, ' ');
+ return classes(this.className).contains(className);
},
addClass: hasClassList ? function(className){
@@ -3503,11 +3550,13 @@ Element.Properties.html = {
set: function(html){
if (html == null) html = '';
else if (typeOf(html) == 'array') html = html.join('');
- this.innerHTML = html;
- },
+ /**/
+ if (this.styleSheet && !canChangeStyleHTML) this.styleSheet.cssText = html;
+ else /**/this.innerHTML = html;
+ },
erase: function(){
- this.innerHTML = '';
+ this.set('html', '');
}
};
@@ -3555,6 +3604,10 @@ if (!supportsTableInnerHTML || !supportsTRInnerHTML || !supportsHTML5Elements){
translations.thead = translations.tfoot = translations.tbody;
return function(html){
+
+ /**/
+ if (this.styleSheet) return set.call(this, html);
+ /**/
var wrap = translations[this.get('tag')];
if (!wrap && !supportsHTML5Elements) wrap = [0, '', ''];
if (!wrap) return set.call(this, html);
@@ -3622,233 +3675,6 @@ if (document.createElement('div').getAttributeNode('id')) Element.Properties.id
})();
-
-/*
----
-
-name: Element.Style
-
-description: Contains methods for interacting with the styles of Elements in a fashionable way.
-
-license: MIT-style license.
-
-requires: Element
-
-provides: Element.Style
-
-...
-*/
-
-(function(){
-
-var html = document.html, el;
-
-//
-// Check for oldIE, which does not remove styles when they're set to null
-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;
-//
-
-var hasGetComputedStyle = !!window.getComputedStyle;
-
-Element.Properties.styles = {set: function(styles){
- this.setStyles(styles);
-}};
-
-var hasOpacity = (html.style.opacity != null),
- hasFilter = (html.style.filter != null),
- reAlpha = /alpha\(opacity=([\d.]+)\)/i;
-
-var setVisibility = function(element, opacity){
- element.store('$opacity', opacity);
- element.style.visibility = opacity > 0 || opacity == null ? 'visible' : 'hidden';
-};
-
-//
-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');
-};
-//
-
-var setOpacity = (hasOpacity ? function(element, opacity){
- element.style.opacity = opacity;
-} : (hasFilter ? function(element, opacity){
- 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){
- var opacity = element.style.opacity || element.getComputedStyle('opacity');
- return (opacity == '') ? 1 : opacity.toFloat();
-} : (hasFilter ? function(element){
- var filter = (element.style.filter || element.getComputedStyle('filter')),
- opacity;
- if (filter) opacity = filter.match(reAlpha);
- return (opacity == null || filter == null) ? 1 : (opacity[1] / 100);
-} : function(element){
- var opacity = element.retrieve('$opacity');
- if (opacity == null) opacity = (element.style.visibility == 'hidden' ? 0 : 1);
- return opacity;
-}));
-
-var floatName = (html.style.cssFloat == null) ? 'styleFloat' : 'cssFloat',
- namedPositions = {left: '0%', top: '0%', center: '50%', right: '100%', bottom: '100%'},
- hasBackgroundPositionXY = (html.style.backgroundPositionX != null);
-
-//
-var removeStyle = function(style, property){
- if (property == 'backgroundPosition'){
- style.removeAttribute(property + 'X');
- property += 'Y';
- }
- style.removeAttribute(property);
-};
-//
-
-Element.implement({
-
- getComputedStyle: function(property){
- 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()) : '';
- },
-
- setStyle: function(property, value){
- if (property == 'opacity'){
- if (value != null) value = parseFloat(value);
- setOpacity(this, value);
- return this;
- }
- property = (property == 'float' ? floatName : property).camelCase();
- if (typeOf(value) != 'string'){
- var map = (Element.Styles[property] || '@').split(' ');
- value = Array.from(value).map(function(val, i){
- if (!map[i]) return '';
- return (typeOf(val) == 'number') ? map[i].replace('@', Math.round(val)) : val;
- }).join(' ');
- } else if (value == String(Number(value))){
- value = Math.round(value);
- }
- this.style[property] = value;
- //
- if ((value == '' || value == null) && doesNotRemoveStyles && this.style.removeAttribute){
- removeStyle(this.style, property);
- }
- //
- return this;
- },
-
- getStyle: function(property){
- if (property == 'opacity') return getOpacity(this);
- property = (property == 'float' ? floatName : property).camelCase();
- var result = this.style[property];
- if (!result || property == 'zIndex'){
- 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 (!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){
- size += this.getStyle('border-' + value + '-width').toInt() + this.getStyle('padding-' + value).toInt();
- }, this);
- return this['offset' + property.capitalize()] - size + 'px';
- }
- if ((/^border(.+)Width|margin|padding/).test(property) && isNaN(parseFloat(result))){
- return '0px';
- }
- }
- //
- if (returnsBordersInWrongOrder && /^border(Top|Right|Bottom|Left)?$/.test(property) && /^#/.test(result)){
- return result.replace(/^(.+)\s(.+)\s(.+)$/, '$2 $3 $1');
- }
- //
- return result;
- },
-
- setStyles: function(styles){
- for (var style in styles) this.setStyle(style, styles[style]);
- return this;
- },
-
- getStyles: function(){
- var result = {};
- Array.flatten(arguments).each(function(key){
- result[key] = this.getStyle(key);
- }, this);
- return result;
- }
-
-});
-
-Element.Styles = {
- left: '@px', top: '@px', bottom: '@px', right: '@px',
- width: '@px', height: '@px', maxWidth: '@px', maxHeight: '@px', minWidth: '@px', minHeight: '@px',
- 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(@, @, @)',
- zIndex: '@', 'zoom': '@', fontWeight: '@', textIndent: '@px', opacity: '@'
-};
-
-
-
-
-
-Element.ShortStyles = {margin: {}, padding: {}, border: {}, borderWidth: {}, borderStyle: {}, borderColor: {}};
-
-['Top', 'Right', 'Bottom', 'Left'].each(function(direction){
- var Short = Element.ShortStyles;
- var All = Element.Styles;
- ['margin', 'padding'].each(function(style){
- var sd = style + direction;
- Short[style][sd] = All[sd] = '@px';
- });
- var bd = 'border' + direction;
- Short.border[bd] = All[bd] = '@px @ rgb(@, @, @)';
- var bdw = bd + 'Width', bds = bd + 'Style', bdc = bd + 'Color';
- Short[bd] = {};
- Short.borderWidth[bdw] = Short[bd][bdw] = All[bdw] = '@px';
- Short.borderStyle[bds] = Short[bd][bds] = All[bds] = '@';
- Short.borderColor[bdc] = Short[bd][bdc] = All[bdc] = 'rgb(@, @, @)';
-});
-
-if (hasBackgroundPositionXY) Element.ShortStyles.backgroundPosition = {backgroundPositionX: '@', backgroundPositionY: '@'};
-})();
-
-
/*
---
@@ -3865,9 +3691,19 @@ provides: Event
...
*/
-(function() {
+(function(){
var _keys = {};
+var normalizeWheelSpeed = function(event){
+ var normalized;
+ if (event.wheelDelta){
+ normalized = event.wheelDelta % 120 == 0 ? event.wheelDelta / 120 : event.wheelDelta / 12;
+ } else {
+ var rawAmount = event.deltaY || event.detail || 0;
+ normalized = -(rawAmount % 3 == 0 ? rawAmount / 3 : rawAmount * 10);
+ }
+ return normalized;
+}
var DOMEvent = this.DOMEvent = new Type('DOMEvent', function(event, win){
if (!win) win = window;
@@ -3892,7 +3728,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 == 'DOMMouseScroll' || type.indexOf('mouse') == 0){
+ } else if (type == 'click' || type == 'dblclick' || type == 'contextmenu' || type == 'wheel' || type == 'DOMMouseScroll' || type.indexOf('mouse') == 0){
var doc = win.document;
doc = (!doc.compatMode || doc.compatMode == 'CSS1Compat') ? doc.html : doc.body;
this.page = {
@@ -3903,9 +3739,7 @@ var DOMEvent = this.DOMEvent = new Type('DOMEvent', function(event, win){
x: (event.pageX != null) ? event.pageX - win.pageXOffset : event.clientX,
y: (event.pageY != null) ? event.pageY - win.pageYOffset : event.clientY
};
- if (type == 'DOMMouseScroll' || type == 'mousewheel')
- this.wheel = (event.wheelDelta) ? event.wheelDelta / 120 : -(event.detail || 0) / 3;
-
+ if (type == 'DOMMouseScroll' || type == 'wheel' || type == 'mousewheel') this.wheel = normalizeWheelSpeed(event);
this.rightClick = (event.which == 3 || event.button == 2);
if (type == 'mouseover' || type == 'mouseout'){
var related = event.relatedTarget || event[(type == 'mouseover' ? 'from' : 'to') + 'Element'];
@@ -3968,7 +3802,6 @@ DOMEvent.defineKeys({
-
/*
---
@@ -4101,7 +3934,7 @@ Element.Properties.events = {set: function(events){
Element.NativeEvents = {
click: 2, dblclick: 2, mouseup: 2, mousedown: 2, contextmenu: 2, //mouse buttons
- mousewheel: 2, DOMMouseScroll: 2, //mouse wheel
+ wheel: 2, mousewheel: 2, DOMMouseScroll: 2, //mouse wheel
mouseover: 2, mouseout: 2, mousemove: 2, selectstart: 2, selectend: 2, //mouse movement
keydown: 2, keypress: 2, keyup: 2, //keyboard
orientationchange: 2, // mobile
@@ -4110,7 +3943,7 @@ Element.NativeEvents = {
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
+ error: 1, abort: 1, scroll: 1, message: 2 //misc
};
Element.Events = {
@@ -4160,7 +3993,6 @@ if (!window.addEventListener){
})();
-
/*
---
@@ -4220,7 +4052,10 @@ var formObserver = function(type){
remove: function(self, uid){
var list = self.retrieve(_key + type + 'listeners', {})[uid];
if (list && list.forms) for (var i = list.forms.length; i--;){
- list.forms[i].removeEvent(type, list.fns[i]);
+ // the form may have been destroyed, so it won't have the
+ // removeEvent method anymore. In that case the event was
+ // removed as well.
+ if (list.forms[i].removeEvent) list.forms[i].removeEvent(type, list.fns[i]);
}
},
@@ -4363,6 +4198,237 @@ var delegation = {
})();
+/*
+---
+
+name: Element.Style
+
+description: Contains methods for interacting with the styles of Elements in a fashionable way.
+
+license: MIT-style license.
+
+requires: Element
+
+provides: Element.Style
+
+...
+*/
+
+(function(){
+
+var html = document.html, el;
+
+//
+// Check for oldIE, which does not remove styles when they're set to null
+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;
+//
+
+var hasGetComputedStyle = !!window.getComputedStyle,
+ supportBorderRadius = document.createElement('div').style.borderRadius != null;
+
+Element.Properties.styles = {set: function(styles){
+ this.setStyles(styles);
+}};
+
+var hasOpacity = (html.style.opacity != null),
+ hasFilter = (html.style.filter != null),
+ reAlpha = /alpha\(opacity=([\d.]+)\)/i;
+
+var setVisibility = function(element, opacity){
+ element.store('$opacity', opacity);
+ element.style.visibility = opacity > 0 || opacity == null ? 'visible' : 'hidden';
+};
+
+//
+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');
+};
+//
+
+var setOpacity = (hasOpacity ? function(element, opacity){
+ element.style.opacity = opacity;
+} : (hasFilter ? function(element, opacity){
+ 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){
+ var opacity = element.style.opacity || element.getComputedStyle('opacity');
+ return (opacity == '') ? 1 : opacity.toFloat();
+} : (hasFilter ? function(element){
+ var filter = (element.style.filter || element.getComputedStyle('filter')),
+ opacity;
+ if (filter) opacity = filter.match(reAlpha);
+ return (opacity == null || filter == null) ? 1 : (opacity[1] / 100);
+} : function(element){
+ var opacity = element.retrieve('$opacity');
+ if (opacity == null) opacity = (element.style.visibility == 'hidden' ? 0 : 1);
+ return opacity;
+}));
+
+var floatName = (html.style.cssFloat == null) ? 'styleFloat' : 'cssFloat',
+ namedPositions = {left: '0%', top: '0%', center: '50%', right: '100%', bottom: '100%'},
+ hasBackgroundPositionXY = (html.style.backgroundPositionX != null);
+
+//
+var removeStyle = function(style, property){
+ if (property == 'backgroundPosition'){
+ style.removeAttribute(property + 'X');
+ property += 'Y';
+ }
+ style.removeAttribute(property);
+};
+//
+
+Element.implement({
+
+ getComputedStyle: function(property){
+ 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()) : '';
+ },
+
+ setStyle: function(property, value){
+ if (property == 'opacity'){
+ if (value != null) value = parseFloat(value);
+ setOpacity(this, value);
+ return this;
+ }
+ property = (property == 'float' ? floatName : property).camelCase();
+ if (typeOf(value) != 'string'){
+ var map = (Element.Styles[property] || '@').split(' ');
+ value = Array.from(value).map(function(val, i){
+ if (!map[i]) return '';
+ return (typeOf(val) == 'number') ? map[i].replace('@', Math.round(val)) : val;
+ }).join(' ');
+ } else if (value == String(Number(value))){
+ value = Math.round(value);
+ }
+ this.style[property] = value;
+ //
+ if ((value == '' || value == null) && doesNotRemoveStyles && this.style.removeAttribute){
+ removeStyle(this.style, property);
+ }
+ //
+ return this;
+ },
+
+ getStyle: function(property){
+ if (property == 'opacity') return getOpacity(this);
+ property = (property == 'float' ? floatName : property).camelCase();
+ if (supportBorderRadius && property.indexOf('borderRadius') != -1){
+ return ['borderTopLeftRadius', 'borderTopRightRadius', 'borderBottomRightRadius', 'borderBottomLeftRadius'].map(function(corner){
+ return this.style[corner] || '0px';
+ }, this).join(' ');
+ }
+ var result = this.style[property];
+ if (!result || property == 'zIndex'){
+ 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 (!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){
+ size += this.getStyle('border-' + value + '-width').toInt() + this.getStyle('padding-' + value).toInt();
+ }, this);
+ return this['offset' + property.capitalize()] - size + 'px';
+ }
+ if ((/^border(.+)Width|margin|padding/).test(property) && isNaN(parseFloat(result))){
+ return '0px';
+ }
+ }
+ //
+ if (returnsBordersInWrongOrder && /^border(Top|Right|Bottom|Left)?$/.test(property) && /^#/.test(result)){
+ return result.replace(/^(.+)\s(.+)\s(.+)$/, '$2 $3 $1');
+ }
+ //
+
+ return result;
+ },
+
+ setStyles: function(styles){
+ for (var style in styles) this.setStyle(style, styles[style]);
+ return this;
+ },
+
+ getStyles: function(){
+ var result = {};
+ Array.flatten(arguments).each(function(key){
+ result[key] = this.getStyle(key);
+ }, this);
+ return result;
+ }
+
+});
+
+Element.Styles = {
+ left: '@px', top: '@px', bottom: '@px', right: '@px',
+ width: '@px', height: '@px', maxWidth: '@px', maxHeight: '@px', minWidth: '@px', minHeight: '@px',
+ 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(@, @, @)',
+ zIndex: '@', 'zoom': '@', fontWeight: '@', textIndent: '@px', opacity: '@', borderRadius: '@px @px @px @px'
+};
+
+
+
+
+
+Element.ShortStyles = {margin: {}, padding: {}, border: {}, borderWidth: {}, borderStyle: {}, borderColor: {}};
+
+['Top', 'Right', 'Bottom', 'Left'].each(function(direction){
+ var Short = Element.ShortStyles;
+ var All = Element.Styles;
+ ['margin', 'padding'].each(function(style){
+ var sd = style + direction;
+ Short[style][sd] = All[sd] = '@px';
+ });
+ var bd = 'border' + direction;
+ Short.border[bd] = All[bd] = '@px @ rgb(@, @, @)';
+ var bdw = bd + 'Width', bds = bd + 'Style', bdc = bd + 'Color';
+ Short[bd] = {};
+ Short.borderWidth[bdw] = Short[bd][bdw] = All[bdw] = '@px';
+ Short.borderStyle[bds] = Short[bd][bds] = All[bds] = '@';
+ Short.borderColor[bdc] = Short[bd][bdc] = All[bdc] = 'rgb(@, @, @)';
+});
+
+if (hasBackgroundPositionXY) Element.ShortStyles.backgroundPosition = {backgroundPositionX: '@', backgroundPositionY: '@'};
+})();
/*
---
@@ -4393,6 +4459,23 @@ element.appendChild(child);
var brokenOffsetParent = (child.offsetParent === element);
element = child = null;
+var heightComponents = ['height', 'paddingTop', 'paddingBottom', 'borderTopWidth', 'borderBottomWidth'],
+ widthComponents = ['width', 'paddingLeft', 'paddingRight', 'borderLeftWidth', 'borderRightWidth'];
+
+var svgCalculateSize = function(el){
+
+ var gCS = window.getComputedStyle(el),
+ bounds = {x: 0, y: 0};
+
+ heightComponents.each(function(css){
+ bounds.y += parseFloat(gCS[css]);
+ });
+ widthComponents.each(function(css){
+ bounds.x += parseFloat(gCS[css]);
+ });
+ return bounds;
+};
+
var isOffset = function(el){
return styleString(el, 'position') != 'static' || isBody(el);
};
@@ -4415,7 +4498,18 @@ Element.implement({
getSize: function(){
if (isBody(this)) return this.getWindow().getSize();
- return {x: this.offsetWidth, y: this.offsetHeight};
+
+ //
+ // This if clause is because IE8- cannot calculate getBoundingClientRect of elements with visibility hidden.
+ if (!window.getComputedStyle) return {x: this.offsetWidth, y: this.offsetHeight};
+ //
+
+ // This svg section under, calling `svgCalculateSize()`, can be removed when FF fixed the svg size bug.
+ // Bug info: https://bugzilla.mozilla.org/show_bug.cgi?id=530985
+ if (this.get('tag') == 'svg') return svgCalculateSize(this);
+
+ var bounds = this.getBoundingClientRect();
+ return {x: bounds.width, y: bounds.height};
},
getScrollSize: function(){
@@ -4453,7 +4547,7 @@ Element.implement({
try {
return element.offsetParent;
- } catch(e) {}
+ } catch(e){}
return null;
},
@@ -4469,7 +4563,7 @@ Element.implement({
return {
x: bound.left.toInt() + elemScrolls.x + ((isFixed) ? 0 : htmlScroll.x) - html.clientLeft,
- y: bound.top.toInt() + elemScrolls.y + ((isFixed) ? 0 : htmlScroll.y) - html.clientTop
+ y: bound.top.toInt() + elemScrolls.y + ((isFixed) ? 0 : htmlScroll.y) - html.clientTop
};
}
@@ -4631,7 +4725,6 @@ Element.alias({position: 'setPosition'}); //compatability
});
-
/*
---
@@ -4816,7 +4909,6 @@ var pullInstance = function(fps){
})();
-
/*
---
@@ -4991,6 +5083,193 @@ Fx.CSS.Parsers = {
+/*
+---
+
+name: Fx.Morph
+
+description: Formerly Fx.Styles, effect to transition any number of CSS properties for an element using an object of rules, or CSS based selector rules.
+
+license: MIT-style license.
+
+requires: Fx.CSS
+
+provides: Fx.Morph
+
+...
+*/
+
+Fx.Morph = new Class({
+
+ Extends: Fx.CSS,
+
+ initialize: function(element, options){
+ this.element = this.subject = document.id(element);
+ this.parent(options);
+ },
+
+ set: function(now){
+ if (typeof now == 'string') now = this.search(now);
+ for (var p in now) this.render(this.element, p, now[p], this.options.unit);
+ return this;
+ },
+
+ compute: function(from, to, delta){
+ var now = {};
+ for (var p in from) now[p] = this.parent(from[p], to[p], delta);
+ return now;
+ },
+
+ start: function(properties){
+ if (!this.check(properties)) return this;
+ if (typeof properties == 'string') properties = this.search(properties);
+ var from = {}, to = {};
+ for (var p in properties){
+ var parsed = this.prepare(this.element, p, properties[p]);
+ from[p] = parsed.from;
+ to[p] = parsed.to;
+ }
+ return this.parent(from, to);
+ }
+
+});
+
+Element.Properties.morph = {
+
+ set: function(options){
+ this.get('morph').cancel().setOptions(options);
+ return this;
+ },
+
+ get: function(){
+ var morph = this.retrieve('morph');
+ if (!morph){
+ morph = new Fx.Morph(this, {link: 'cancel'});
+ this.store('morph', morph);
+ }
+ return morph;
+ }
+
+};
+
+Element.implement({
+
+ morph: function(props){
+ this.get('morph').start(props);
+ return this;
+ }
+
+});
+
+/*
+---
+
+name: Fx.Transitions
+
+description: Contains a set of advanced transitions to be used with any of the Fx Classes.
+
+license: MIT-style license.
+
+credits:
+ - Easing Equations by Robert Penner, , modified and optimized to be used with MooTools.
+
+requires: Fx
+
+provides: Fx.Transitions
+
+...
+*/
+
+Fx.implement({
+
+ getTransition: function(){
+ var trans = this.options.transition || Fx.Transitions.Sine.easeInOut;
+ if (typeof trans == 'string'){
+ var data = trans.split(':');
+ trans = Fx.Transitions;
+ trans = trans[data[0]] || trans[data[0].capitalize()];
+ if (data[1]) trans = trans['ease' + data[1].capitalize() + (data[2] ? data[2].capitalize() : '')];
+ }
+ return trans;
+ }
+
+});
+
+Fx.Transition = function(transition, params){
+ params = Array.from(params);
+ var easeIn = function(pos){
+ return transition(pos, params);
+ };
+ return Object.append(easeIn, {
+ easeIn: easeIn,
+ easeOut: function(pos){
+ return 1 - transition(1 - pos, params);
+ },
+ easeInOut: function(pos){
+ return (pos <= 0.5 ? transition(2 * pos, params) : (2 - transition(2 * (1 - pos), params))) / 2;
+ }
+ });
+};
+
+Fx.Transitions = {
+
+ linear: function(zero){
+ return zero;
+ }
+
+};
+
+
+
+Fx.Transitions.extend = function(transitions){
+ for (var transition in transitions) Fx.Transitions[transition] = new Fx.Transition(transitions[transition]);
+};
+
+Fx.Transitions.extend({
+
+ Pow: function(p, x){
+ return Math.pow(p, x && x[0] || 6);
+ },
+
+ Expo: function(p){
+ return Math.pow(2, 8 * (p - 1));
+ },
+
+ Circ: function(p){
+ return 1 - Math.sin(Math.acos(p));
+ },
+
+ Sine: function(p){
+ return 1 - Math.cos(p * Math.PI / 2);
+ },
+
+ Back: function(p, x){
+ x = x && x[0] || 1.618;
+ return Math.pow(p, 2) * ((x + 1) * p - x);
+ },
+
+ Bounce: function(p){
+ var value;
+ for (var a = 0, b = 1; 1; a += b, b /= 2){
+ if (p >= (7 - 4 * a) / 11){
+ value = b * b - Math.pow((11 - 6 * a - 11 * p) / 4, 2);
+ break;
+ }
+ }
+ return value;
+ },
+
+ Elastic: function(p, x){
+ return Math.pow(2, 10 * --p) * Math.cos(20 * p * Math.PI * (x && x[0] || 1) / 3);
+ }
+
+});
+
+['Quad', 'Cubic', 'Quart', 'Quint'].each(function(transition, i){
+ Fx.Transitions[transition] = new Fx.Transition(function(p){
+ return Math.pow(p, i + 2);
+ });
+});
/*
---
@@ -5104,197 +5383,6 @@ Element.implement({
});
-
-/*
----
-
-name: Fx.Morph
-
-description: Formerly Fx.Styles, effect to transition any number of CSS properties for an element using an object of rules, or CSS based selector rules.
-
-license: MIT-style license.
-
-requires: Fx.CSS
-
-provides: Fx.Morph
-
-...
-*/
-
-Fx.Morph = new Class({
-
- Extends: Fx.CSS,
-
- initialize: function(element, options){
- this.element = this.subject = document.id(element);
- this.parent(options);
- },
-
- set: function(now){
- if (typeof now == 'string') now = this.search(now);
- for (var p in now) this.render(this.element, p, now[p], this.options.unit);
- return this;
- },
-
- compute: function(from, to, delta){
- var now = {};
- for (var p in from) now[p] = this.parent(from[p], to[p], delta);
- return now;
- },
-
- start: function(properties){
- if (!this.check(properties)) return this;
- if (typeof properties == 'string') properties = this.search(properties);
- var from = {}, to = {};
- for (var p in properties){
- var parsed = this.prepare(this.element, p, properties[p]);
- from[p] = parsed.from;
- to[p] = parsed.to;
- }
- return this.parent(from, to);
- }
-
-});
-
-Element.Properties.morph = {
-
- set: function(options){
- this.get('morph').cancel().setOptions(options);
- return this;
- },
-
- get: function(){
- var morph = this.retrieve('morph');
- if (!morph){
- morph = new Fx.Morph(this, {link: 'cancel'});
- this.store('morph', morph);
- }
- return morph;
- }
-
-};
-
-Element.implement({
-
- morph: function(props){
- this.get('morph').start(props);
- return this;
- }
-
-});
-
-
-/*
----
-
-name: Fx.Transitions
-
-description: Contains a set of advanced transitions to be used with any of the Fx Classes.
-
-license: MIT-style license.
-
-credits:
- - Easing Equations by Robert Penner, , modified and optimized to be used with MooTools.
-
-requires: Fx
-
-provides: Fx.Transitions
-
-...
-*/
-
-Fx.implement({
-
- getTransition: function(){
- var trans = this.options.transition || Fx.Transitions.Sine.easeInOut;
- if (typeof trans == 'string'){
- var data = trans.split(':');
- trans = Fx.Transitions;
- trans = trans[data[0]] || trans[data[0].capitalize()];
- if (data[1]) trans = trans['ease' + data[1].capitalize() + (data[2] ? data[2].capitalize() : '')];
- }
- return trans;
- }
-
-});
-
-Fx.Transition = function(transition, params){
- params = Array.from(params);
- var easeIn = function(pos){
- return transition(pos, params);
- };
- return Object.append(easeIn, {
- easeIn: easeIn,
- easeOut: function(pos){
- return 1 - transition(1 - pos, params);
- },
- easeInOut: function(pos){
- return (pos <= 0.5 ? transition(2 * pos, params) : (2 - transition(2 * (1 - pos), params))) / 2;
- }
- });
-};
-
-Fx.Transitions = {
-
- linear: function(zero){
- return zero;
- }
-
-};
-
-
-
-Fx.Transitions.extend = function(transitions){
- for (var transition in transitions) Fx.Transitions[transition] = new Fx.Transition(transitions[transition]);
-};
-
-Fx.Transitions.extend({
-
- Pow: function(p, x){
- return Math.pow(p, x && x[0] || 6);
- },
-
- Expo: function(p){
- return Math.pow(2, 8 * (p - 1));
- },
-
- Circ: function(p){
- return 1 - Math.sin(Math.acos(p));
- },
-
- Sine: function(p){
- return 1 - Math.cos(p * Math.PI / 2);
- },
-
- Back: function(p, x){
- x = x && x[0] || 1.618;
- return Math.pow(p, 2) * ((x + 1) * p - x);
- },
-
- Bounce: function(p){
- var value;
- for (var a = 0, b = 1; 1; a += b, b /= 2){
- if (p >= (7 - 4 * a) / 11){
- value = b * b - Math.pow((11 - 6 * a - 11 * p) / 4, 2);
- break;
- }
- }
- return value;
- },
-
- Elastic: function(p, x){
- return Math.pow(2, 10 * --p) * Math.cos(20 * p * Math.PI * (x && x[0] || 1) / 3);
- }
-
-});
-
-['Quad', 'Cubic', 'Quart', 'Quint'].each(function(transition, i){
- Fx.Transitions[transition] = new Fx.Transition(function(p){
- return Math.pow(p, i + 2);
- });
-});
-
-
/*
---
@@ -5331,7 +5419,8 @@ var Request = this.Request = new Class({
onException: function(headerName, value){},
onTimeout: function(){},
user: '',
- password: '',*/
+ password: '',
+ withCredentials: false,*/
url: '',
data: '',
headers: {
@@ -5369,7 +5458,10 @@ var Request = this.Request = new Class({
}.bind(this));
xhr.onreadystatechange = empty;
if (progressSupport) xhr.onprogress = xhr.onloadstart = empty;
- clearTimeout(this.timer);
+ if (this.timer){
+ clearTimeout(this.timer);
+ delete this.timer;
+ }
this.response = {text: this.xhr.responseText || '', xml: this.xhr.responseXML};
if (this.options.isSuccess.call(this, this.status))
@@ -5494,7 +5586,7 @@ var Request = this.Request = new Class({
}
xhr.open(method.toUpperCase(), url, this.options.async, this.options.user, this.options.password);
- if (this.options.user && 'withCredentials' in xhr) xhr.withCredentials = true;
+ if ((this.options.withCredentials) && 'withCredentials' in xhr) xhr.withCredentials = true;
xhr.onreadystatechange = this.onStateChange.bind(this);
@@ -5518,7 +5610,10 @@ var Request = this.Request = new Class({
this.running = false;
var xhr = this.xhr;
xhr.abort();
- clearTimeout(this.timer);
+ if (this.timer){
+ clearTimeout(this.timer);
+ delete this.timer;
+ }
xhr.onreadystatechange = empty;
if (progressSupport) xhr.onprogress = xhr.onloadstart = empty;
this.xhr = new Browser.Request();
@@ -5529,7 +5624,7 @@ var Request = this.Request = new Class({
});
var methods = {};
-['get', 'post', 'put', 'delete', 'GET', 'POST', 'PUT', 'DELETE'].each(function(method){
+['get', 'post', 'put', 'delete', 'patch', 'head', 'GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'HEAD'].each(function(method){
methods[method] = function(data){
var object = {
method: method
@@ -5574,7 +5669,6 @@ Element.implement({
})();
-
/*
---
@@ -5654,7 +5748,6 @@ JSON.decode = function(string, secure){
})();
-
/*
---
@@ -5702,7 +5795,6 @@ Request.JSON = new Class({
});
-
/*
---
@@ -5778,7 +5870,6 @@ Cookie.dispose = function(key, options){
return new Cookie(key, options).dispose();
};
-
/*
---
@@ -5806,12 +5897,14 @@ var ready,
var domready = function(){
clearTimeout(timer);
- if (ready) return;
- Browser.loaded = ready = true;
- document.removeListener('DOMContentLoaded', domready).removeListener('readystatechange', check);
-
- document.fireEvent('domready');
- window.fireEvent('domready');
+ if (!ready) {
+ Browser.loaded = ready = true;
+ document.removeListener('DOMContentLoaded', domready).removeListener('readystatechange', check);
+ document.fireEvent('domready');
+ window.fireEvent('domready');
+ }
+ // cleanup scope vars
+ document = window = testElement = null;
};
var check = function(){
@@ -5884,4 +5977,3 @@ window.addEvent('load', function(){
});
})(window, document);
-
diff --git a/couchpotato/static/scripts/vendor/mootools_more.js b/couchpotato/static/scripts/vendor/mootools_more.js
index 2ff49cb3..a2b00975 100644
--- a/couchpotato/static/scripts/vendor/mootools_more.js
+++ b/couchpotato/static/scripts/vendor/mootools_more.js
@@ -1,16 +1,7 @@
+/* MooTools: the javascript framework. license: MIT-style license. copyright: Copyright (c) 2006-2014 [Valerio Proietti](http://mad4milk.net/).*/
/*
----
-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
-
-...
+Web Build: http://mootools.net/more/builder/c5d56f178d3e33908b4f47169e617a6c
*/
-
/*
---
@@ -41,11 +32,10 @@ provides: [MooTools.More]
*/
MooTools.More = {
- version: '1.5.0',
- build: '73db5e24e6e9c5c87b3a27aebef2248053f7db37'
+ version: '1.5.1',
+ build: '2dd695ba957196ae4b0275a690765d6636a61ccd'
};
-
/*
---
@@ -204,6 +194,1515 @@ Events.implement(Events.Pseudos(pseudos, proto.addEvent, proto.removeEvent));
})();
+/*
+---
+
+script: Drag.js
+
+name: Drag
+
+description: The base Drag Class. Can be used to drag and resize Elements using mouse events.
+
+license: MIT-style license
+
+authors:
+ - Valerio Proietti
+ - Tom Occhinno
+ - Jan Kassens
+
+requires:
+ - Core/Events
+ - Core/Options
+ - Core/Element.Event
+ - Core/Element.Style
+ - Core/Element.Dimensions
+ - MooTools.More
+
+provides: [Drag]
+...
+
+*/
+
+var Drag = new Class({
+
+ Implements: [Events, Options],
+
+ options: {/*
+ onBeforeStart: function(thisElement){},
+ onStart: function(thisElement, event){},
+ onSnap: function(thisElement){},
+ onDrag: function(thisElement, event){},
+ onCancel: function(thisElement){},
+ onComplete: function(thisElement, event){},*/
+ snap: 6,
+ unit: 'px',
+ grid: false,
+ style: true,
+ limit: false,
+ handle: false,
+ invert: false,
+ preventDefault: false,
+ stopPropagation: false,
+ compensateScroll: false,
+ modifiers: {x: 'left', y: 'top'}
+ },
+
+ initialize: function(){
+ var params = Array.link(arguments, {
+ 'options': Type.isObject,
+ 'element': function(obj){
+ return obj != null;
+ }
+ });
+
+ this.element = document.id(params.element);
+ this.document = this.element.getDocument();
+ this.setOptions(params.options || {});
+ var htype = typeOf(this.options.handle);
+ this.handles = ((htype == 'array' || htype == 'collection') ? $$(this.options.handle) : document.id(this.options.handle)) || this.element;
+ this.mouse = {'now': {}, 'pos': {}};
+ this.value = {'start': {}, 'now': {}};
+ this.offsetParent = (function(el){
+ var offsetParent = el.getOffsetParent();
+ var isBody = !offsetParent || (/^(?:body|html)$/i).test(offsetParent.tagName);
+ return isBody ? window : document.id(offsetParent);
+ })(this.element);
+ this.selection = 'selectstart' in document ? 'selectstart' : 'mousedown';
+
+ this.compensateScroll = {start: {}, diff: {}, last: {}};
+
+ if ('ondragstart' in document && !('FileReader' in window) && !Drag.ondragstartFixed){
+ document.ondragstart = Function.from(false);
+ Drag.ondragstartFixed = true;
+ }
+
+ this.bound = {
+ start: this.start.bind(this),
+ check: this.check.bind(this),
+ drag: this.drag.bind(this),
+ stop: this.stop.bind(this),
+ cancel: this.cancel.bind(this),
+ eventStop: Function.from(false),
+ scrollListener: this.scrollListener.bind(this)
+ };
+ this.attach();
+ },
+
+ attach: function(){
+ this.handles.addEvent('mousedown', this.bound.start);
+ if (this.options.compensateScroll) this.offsetParent.addEvent('scroll', this.bound.scrollListener);
+ return this;
+ },
+
+ detach: function(){
+ this.handles.removeEvent('mousedown', this.bound.start);
+ if (this.options.compensateScroll) this.offsetParent.removeEvent('scroll', this.bound.scrollListener);
+ return this;
+ },
+
+ scrollListener: function(){
+
+ if (!this.mouse.start) return;
+ var newScrollValue = this.offsetParent.getScroll();
+
+ if (this.element.getStyle('position') == 'absolute'){
+ var scrollDiff = this.sumValues(newScrollValue, this.compensateScroll.last, -1);
+ this.mouse.now = this.sumValues(this.mouse.now, scrollDiff, 1);
+ } else {
+ this.compensateScroll.diff = this.sumValues(newScrollValue, this.compensateScroll.start, -1);
+ }
+ if (this.offsetParent != window) this.compensateScroll.diff = this.sumValues(this.compensateScroll.start, newScrollValue, -1);
+ this.compensateScroll.last = newScrollValue;
+ this.render(this.options);
+ },
+
+ sumValues: function(alpha, beta, op){
+ var sum = {}, options = this.options;
+ for (z in options.modifiers){
+ if (!options.modifiers[z]) continue;
+ sum[z] = alpha[z] + beta[z] * op;
+ }
+ return sum;
+ },
+
+ start: function(event){
+ var options = this.options;
+
+ if (event.rightClick) return;
+
+ if (options.preventDefault) event.preventDefault();
+ if (options.stopPropagation) event.stopPropagation();
+ this.compensateScroll.start = this.compensateScroll.last = this.offsetParent.getScroll();
+ this.compensateScroll.diff = {x: 0, y: 0};
+ this.mouse.start = event.page;
+ this.fireEvent('beforeStart', this.element);
+
+ var limit = options.limit;
+ this.limit = {x: [], y: []};
+
+ var z, coordinates, offsetParent = this.offsetParent == window ? null : this.offsetParent;
+ for (z in options.modifiers){
+ if (!options.modifiers[z]) continue;
+
+ var style = this.element.getStyle(options.modifiers[z]);
+
+ // Some browsers (IE and Opera) don't always return pixels.
+ if (style && !style.match(/px$/)){
+ if (!coordinates) coordinates = this.element.getCoordinates(offsetParent);
+ style = coordinates[options.modifiers[z]];
+ }
+
+ if (options.style) this.value.now[z] = (style || 0).toInt();
+ else this.value.now[z] = this.element[options.modifiers[z]];
+
+ if (options.invert) this.value.now[z] *= -1;
+
+ this.mouse.pos[z] = event.page[z] - this.value.now[z];
+
+ if (limit && limit[z]){
+ var i = 2;
+ while (i--){
+ var limitZI = limit[z][i];
+ if (limitZI || limitZI === 0) this.limit[z][i] = (typeof limitZI == 'function') ? limitZI() : limitZI;
+ }
+ }
+ }
+
+ if (typeOf(this.options.grid) == 'number') this.options.grid = {
+ x: this.options.grid,
+ y: this.options.grid
+ };
+
+ var events = {
+ mousemove: this.bound.check,
+ mouseup: this.bound.cancel
+ };
+ events[this.selection] = this.bound.eventStop;
+ this.document.addEvents(events);
+ },
+
+ check: function(event){
+ if (this.options.preventDefault) event.preventDefault();
+ var distance = Math.round(Math.sqrt(Math.pow(event.page.x - this.mouse.start.x, 2) + Math.pow(event.page.y - this.mouse.start.y, 2)));
+ if (distance > this.options.snap){
+ this.cancel();
+ this.document.addEvents({
+ mousemove: this.bound.drag,
+ mouseup: this.bound.stop
+ });
+ this.fireEvent('start', [this.element, event]).fireEvent('snap', this.element);
+ }
+ },
+
+ drag: function(event){
+ var options = this.options;
+ if (options.preventDefault) event.preventDefault();
+ this.mouse.now = this.sumValues(event.page, this.compensateScroll.diff, -1);
+
+ this.render(options);
+ this.fireEvent('drag', [this.element, event]);
+ },
+
+ render: function(options){
+ for (var z in options.modifiers){
+ if (!options.modifiers[z]) continue;
+ this.value.now[z] = this.mouse.now[z] - this.mouse.pos[z];
+
+ if (options.invert) this.value.now[z] *= -1;
+ if (options.limit && this.limit[z]){
+ if ((this.limit[z][1] || this.limit[z][1] === 0) && (this.value.now[z] > this.limit[z][1])){
+ this.value.now[z] = this.limit[z][1];
+ } else if ((this.limit[z][0] || this.limit[z][0] === 0) && (this.value.now[z] < this.limit[z][0])){
+ this.value.now[z] = this.limit[z][0];
+ }
+ }
+ if (options.grid[z]) this.value.now[z] -= ((this.value.now[z] - (this.limit[z][0]||0)) % options.grid[z]);
+ if (options.style) this.element.setStyle(options.modifiers[z], this.value.now[z] + options.unit);
+ else this.element[options.modifiers[z]] = this.value.now[z];
+ }
+ },
+
+ cancel: function(event){
+ this.document.removeEvents({
+ mousemove: this.bound.check,
+ mouseup: this.bound.cancel
+ });
+ if (event){
+ this.document.removeEvent(this.selection, this.bound.eventStop);
+ this.fireEvent('cancel', this.element);
+ }
+ },
+
+ stop: function(event){
+ var events = {
+ mousemove: this.bound.drag,
+ mouseup: this.bound.stop
+ };
+ events[this.selection] = this.bound.eventStop;
+ this.document.removeEvents(events);
+ this.mouse.start = null;
+ if (event) this.fireEvent('complete', [this.element, event]);
+ }
+
+});
+
+Element.implement({
+
+ makeResizable: function(options){
+ var drag = new Drag(this, Object.merge({
+ modifiers: {
+ x: 'width',
+ y: 'height'
+ }
+ }, options));
+
+ this.store('resizer', drag);
+ return drag.addEvent('drag', function(){
+ this.fireEvent('resize', drag);
+ }.bind(this));
+ }
+
+});
+
+/*
+---
+
+script: Drag.Move.js
+
+name: Drag.Move
+
+description: A Drag extension that provides support for the constraining of draggables to containers and droppables.
+
+license: MIT-style license
+
+authors:
+ - Valerio Proietti
+ - Tom Occhinno
+ - Jan Kassens
+ - Aaron Newton
+ - Scott Kyle
+
+requires:
+ - Core/Element.Dimensions
+ - Drag
+
+provides: [Drag.Move]
+
+...
+*/
+
+Drag.Move = new Class({
+
+ Extends: Drag,
+
+ options: {/*
+ onEnter: function(thisElement, overed){},
+ onLeave: function(thisElement, overed){},
+ onDrop: function(thisElement, overed, event){},*/
+ droppables: [],
+ container: false,
+ precalculate: false,
+ includeMargins: true,
+ checkDroppables: true
+ },
+
+ initialize: function(element, options){
+ this.parent(element, options);
+ element = this.element;
+
+ this.droppables = $$(this.options.droppables);
+ this.setContainer(this.options.container);
+
+ if (this.options.style){
+ if (this.options.modifiers.x == 'left' && this.options.modifiers.y == 'top'){
+ var parent = element.getOffsetParent(),
+ styles = element.getStyles('left', 'top');
+ if (parent && (styles.left == 'auto' || styles.top == 'auto')){
+ element.setPosition(element.getPosition(parent));
+ }
+ }
+
+ if (element.getStyle('position') == 'static') element.setStyle('position', 'absolute');
+ }
+
+ 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();
+
+ if (this.options.precalculate){
+ this.positions = this.droppables.map(function(el){
+ return el.getCoordinates();
+ });
+ }
+
+ this.parent(event);
+ },
+
+ calculateLimit: function(){
+ var element = this.element,
+ container = this.container,
+
+ offsetParent = document.id(element.getOffsetParent()) || document.body,
+ containerCoordinates = container.getCoordinates(offsetParent),
+ elementMargin = {},
+ elementBorder = {},
+ containerMargin = {},
+ containerBorder = {},
+ offsetParentPadding = {},
+ offsetScroll = offsetParent.getScroll();
+
+ ['top', 'right', 'bottom', 'left'].each(function(pad){
+ elementMargin[pad] = element.getStyle('margin-' + pad).toInt();
+ elementBorder[pad] = element.getStyle('border-' + pad).toInt();
+ containerMargin[pad] = container.getStyle('margin-' + pad).toInt();
+ containerBorder[pad] = container.getStyle('border-' + pad).toInt();
+ offsetParentPadding[pad] = offsetParent.getStyle('padding-' + pad).toInt();
+ }, this);
+
+ var width = element.offsetWidth + elementMargin.left + elementMargin.right,
+ height = element.offsetHeight + elementMargin.top + elementMargin.bottom,
+ left = 0 + offsetScroll.x,
+ top = 0 + offsetScroll.y,
+ right = containerCoordinates.right - containerBorder.right - width + offsetScroll.x,
+ bottom = containerCoordinates.bottom - containerBorder.bottom - height + offsetScroll.y;
+
+ if (this.options.includeMargins){
+ left += elementMargin.left;
+ top += elementMargin.top;
+ } else {
+ right += elementMargin.right;
+ bottom += elementMargin.bottom;
+ }
+
+ if (element.getStyle('position') == 'relative'){
+ var coords = element.getCoordinates(offsetParent);
+ coords.left -= element.getStyle('left').toInt();
+ coords.top -= element.getStyle('top').toInt();
+
+ left -= coords.left;
+ top -= coords.top;
+ if (container.getStyle('position') != 'relative'){
+ left += containerBorder.left;
+ top += containerBorder.top;
+ }
+ right += elementMargin.left - coords.left;
+ bottom += elementMargin.top - coords.top;
+
+ if (container != offsetParent){
+ left += containerMargin.left + offsetParentPadding.left;
+ 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;
+ top -= elementMargin.top;
+ if (container != offsetParent){
+ left += containerCoordinates.left + containerBorder.left;
+ top += containerCoordinates.top + containerBorder.top;
+ }
+ }
+
+ return {
+ x: [left, right],
+ y: [top, bottom]
+ };
+ },
+
+ getDroppableCoordinates: function(element){
+ var position = element.getCoordinates();
+ if (element.getStyle('position') == 'fixed'){
+ var scroll = window.getScroll();
+ position.left += scroll.x;
+ position.right += scroll.x;
+ position.top += scroll.y;
+ position.bottom += scroll.y;
+ }
+ return position;
+ },
+
+ checkDroppables: function(){
+ var overed = this.droppables.filter(function(el, i){
+ el = this.positions ? this.positions[i] : this.getDroppableCoordinates(el);
+ var now = this.mouse.now;
+ return (now.x > el.left && now.x < el.right && now.y < el.bottom && now.y > el.top);
+ }, this).getLast();
+
+ if (this.overed != overed){
+ if (this.overed) this.fireEvent('leave', [this.element, this.overed]);
+ if (overed) this.fireEvent('enter', [this.element, overed]);
+ this.overed = overed;
+ }
+ },
+
+ drag: function(event){
+ this.parent(event);
+ if (this.options.checkDroppables && this.droppables.length) this.checkDroppables();
+ },
+
+ stop: function(event){
+ this.checkDroppables();
+ this.fireEvent('drop', [this.element, this.overed, event]);
+ this.overed = null;
+ return this.parent(event);
+ }
+
+});
+
+Element.implement({
+
+ makeDraggable: function(options){
+ var drag = new Drag.Move(this, options);
+ this.store('dragger', drag);
+ return drag;
+ }
+
+});
+
+/*
+---
+
+script: Sortables.js
+
+name: Sortables
+
+description: Class for creating a drag and drop sorting interface for lists of items.
+
+license: MIT-style license
+
+authors:
+ - Tom Occhino
+
+requires:
+ - Core/Fx.Morph
+ - Drag.Move
+
+provides: [Sortables]
+
+...
+*/
+
+var Sortables = new Class({
+
+ Implements: [Events, Options],
+
+ options: {/*
+ onSort: function(element, clone){},
+ onStart: function(element, clone){},
+ onComplete: function(element){},*/
+ opacity: 1,
+ clone: false,
+ revert: false,
+ handle: false,
+ dragOptions: {},
+ unDraggableTags: ['button', 'input', 'a', 'textarea', 'select', 'option']
+ },
+
+ initialize: function(lists, options){
+ this.setOptions(options);
+
+ this.elements = [];
+ this.lists = [];
+ this.idle = true;
+
+ this.addLists($$(document.id(lists) || lists));
+
+ if (!this.options.clone) this.options.revert = false;
+ if (this.options.revert) this.effect = new Fx.Morph(null, Object.merge({
+ duration: 250,
+ link: 'cancel'
+ }, this.options.revert));
+ },
+
+ attach: function(){
+ this.addLists(this.lists);
+ return this;
+ },
+
+ detach: function(){
+ this.lists = this.removeLists(this.lists);
+ return this;
+ },
+
+ addItems: function(){
+ Array.flatten(arguments).each(function(element){
+ this.elements.push(element);
+ var start = element.retrieve('sortables:start', function(event){
+ this.start.call(this, event, element);
+ }.bind(this));
+ (this.options.handle ? element.getElement(this.options.handle) || element : element).addEvent('mousedown', start);
+ }, this);
+ return this;
+ },
+
+ addLists: function(){
+ Array.flatten(arguments).each(function(list){
+ this.lists.include(list);
+ this.addItems(list.getChildren());
+ }, this);
+ return this;
+ },
+
+ removeItems: function(){
+ return $$(Array.flatten(arguments).map(function(element){
+ this.elements.erase(element);
+ var start = element.retrieve('sortables:start');
+ (this.options.handle ? element.getElement(this.options.handle) || element : element).removeEvent('mousedown', start);
+
+ return element;
+ }, this));
+ },
+
+ removeLists: function(){
+ return $$(Array.flatten(arguments).map(function(list){
+ this.lists.erase(list);
+ this.removeItems(list.getChildren());
+
+ 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);
+ if (typeOf(this.options.clone) == 'function') return this.options.clone.call(this, event, element, this.list);
+ var clone = element.clone(true).setStyles({
+ margin: 0,
+ position: 'absolute',
+ visibility: 'hidden',
+ width: element.getStyle('width')
+ }).addEvent('mousedown', function(event){
+ element.fireEvent('mousedown', event);
+ });
+ //prevent the duplicated radio inputs from unchecking the real one
+ if (clone.get('html').test('radio')){
+ clone.getElements('input[type=radio]').each(function(input, i){
+ input.set('name', 'clone_' + i);
+ if (input.get('checked')) element.getElements('input[type=radio]')[i].set('checked', true);
+ });
+ }
+
+ return clone.inject(this.list).setPosition(this.getDroppableCoordinates(this.element));
+ },
+
+ getDroppables: function(){
+ var droppables = this.list.getChildren().erase(this.clone).erase(this.element);
+ if (!this.options.constrain) droppables.append(this.lists).erase(this.list);
+ return droppables;
+ },
+
+ insert: function(dragging, element){
+ var where = 'inside';
+ if (this.lists.contains(element)){
+ this.list = element;
+ this.drag.droppables = this.getDroppables();
+ } else {
+ where = this.element.getAllPrevious().contains(element) ? 'before' : 'after';
+ }
+ this.element.inject(element, where);
+ this.fireEvent('sort', [this.element, this.clone]);
+ },
+
+ start: function(event, element){
+ if (
+ !this.idle ||
+ event.rightClick ||
+ (!this.options.handle && this.options.unDraggableTags.contains(event.target.get('tag')))
+ ) return;
+
+ this.idle = false;
+ this.element = element;
+ this.opacity = element.getStyle('opacity');
+ this.list = element.getParent();
+ this.clone = this.getClone(event, element);
+
+ this.drag = new Drag.Move(this.clone, Object.merge({
+
+ droppables: this.getDroppables()
+ }, this.options.dragOptions)).addEvents({
+ onSnap: function(){
+ event.stop();
+ this.clone.setStyle('visibility', 'visible');
+ this.element.setStyle('opacity', this.options.opacity || 0);
+ this.fireEvent('start', [this.element, this.clone]);
+ }.bind(this),
+ onEnter: this.insert.bind(this),
+ onCancel: this.end.bind(this),
+ onComplete: this.end.bind(this)
+ });
+
+ this.clone.inject(this.element, 'before');
+ this.drag.start(event);
+ },
+
+ 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.getDroppableCoordinates(clone));
+
+ var destroy = function(){
+ this.removeEvent('cancel', destroy);
+ clone.destroy();
+ self.reset();
+ };
+
+ this.effect.element = clone;
+ this.effect.start({
+ top: pos.top,
+ left: pos.left,
+ width: dim.width,
+ height: dim.height,
+ opacity: 0.25
+ }).addEvent('cancel', destroy).chain(destroy);
+ } else {
+ this.clone.destroy();
+ self.reset();
+ }
+
+ },
+
+ reset: function(){
+ this.idle = true;
+ this.fireEvent('complete', this.element);
+ },
+
+ serialize: function(){
+ var params = Array.link(arguments, {
+ modifier: Type.isFunction,
+ index: function(obj){
+ return obj != null;
+ }
+ });
+ var serial = this.lists.map(function(list){
+ return list.getChildren().map(params.modifier || function(element){
+ return element.get('id');
+ }, this);
+ }, this);
+
+ var index = params.index;
+ if (this.lists.length == 1) index = 0;
+ return (index || index === 0) && index >= 0 && index < this.lists.length ? serial[index] : serial;
+ }
+
+});
+
+/*
+---
+
+script: String.Extras.js
+
+name: String.Extras
+
+description: Extends the String native object to include methods useful in managing various kinds of strings (query strings, urls, html, etc).
+
+license: MIT-style license
+
+authors:
+ - Aaron Newton
+ - Guillermo Rauch
+ - Christopher Pitt
+
+requires:
+ - Core/String
+ - Core/Array
+ - MooTools.More
+
+provides: [String.Extras]
+
+...
+*/
+
+(function(){
+
+var special = {
+ 'a': /[àáâãäåăą]/g,
+ 'A': /[ÀÁÂÃÄÅĂĄ]/g,
+ 'c': /[ćčç]/g,
+ 'C': /[ĆČÇ]/g,
+ 'd': /[ďđ]/g,
+ 'D': /[ĎÐ]/g,
+ 'e': /[èéêëěę]/g,
+ 'E': /[ÈÉÊËĚĘ]/g,
+ 'g': /[ğ]/g,
+ 'G': /[Ğ]/g,
+ 'i': /[ìíîï]/g,
+ 'I': /[ÌÍÎÏ]/g,
+ 'l': /[ĺľł]/g,
+ 'L': /[ĹĽŁ]/g,
+ 'n': /[ñňń]/g,
+ 'N': /[ÑŇŃ]/g,
+ 'o': /[òóôõöøő]/g,
+ 'O': /[ÒÓÔÕÖØ]/g,
+ 'r': /[řŕ]/g,
+ 'R': /[ŘŔ]/g,
+ 's': /[ššş]/g,
+ 'S': /[ŠŞŚ]/g,
+ 't': /[ťţ]/g,
+ 'T': /[ŤŢ]/g,
+ 'u': /[ùúûůüµ]/g,
+ 'U': /[ÙÚÛŮÜ]/g,
+ 'y': /[ÿý]/g,
+ 'Y': /[ŸÝ]/g,
+ 'z': /[žźż]/g,
+ 'Z': /[ŽŹŻ]/g,
+ 'th': /[þ]/g,
+ 'TH': /[Þ]/g,
+ 'dh': /[ð]/g,
+ 'DH': /[Ð]/g,
+ 'ss': /[ß]/g,
+ 'oe': /[œ]/g,
+ 'OE': /[Œ]/g,
+ 'ae': /[æ]/g,
+ 'AE': /[Æ]/g
+},
+
+tidy = {
+ ' ': /[\xa0\u2002\u2003\u2009]/g,
+ '*': /[\xb7]/g,
+ '\'': /[\u2018\u2019]/g,
+ '"': /[\u201c\u201d]/g,
+ '...': /[\u2026]/g,
+ '-': /[\u2013]/g,
+// '--': /[\u2014]/g,
+ '»': /[\uFFFD]/g
+},
+
+conversions = {
+ ms: 1,
+ s: 1000,
+ m: 6e4,
+ h: 36e5
+},
+
+findUnits = /(\d*.?\d+)([msh]+)/;
+
+var walk = function(string, replacements){
+ var result = string, key;
+ for (key in replacements) result = result.replace(replacements[key], key);
+ return result;
+};
+
+var getRegexForTag = function(tag, contents){
+ tag = tag || '';
+ var regstr = contents ? "<" + tag + "(?!\\w)[^>]*>([\\s\\S]*?)<\/" + tag + "(?!\\w)>" : "<\/?" + tag + "([^>]+)?>",
+ reg = new RegExp(regstr, "gi");
+ return reg;
+};
+
+String.implement({
+
+ standardize: function(){
+ return walk(this, special);
+ },
+
+ repeat: function(times){
+ return new Array(times + 1).join(this);
+ },
+
+ pad: function(length, str, direction){
+ if (this.length >= length) return this;
+
+ var pad = (str == null ? ' ' : '' + str)
+ .repeat(length - this.length)
+ .substr(0, length - this.length);
+
+ if (!direction || direction == 'right') return this + pad;
+ if (direction == 'left') return pad + this;
+
+ return pad.substr(0, (pad.length / 2).floor()) + this + pad.substr(0, (pad.length / 2).ceil());
+ },
+
+ getTags: function(tag, contents){
+ return this.match(getRegexForTag(tag, contents)) || [];
+ },
+
+ stripTags: function(tag, contents){
+ return this.replace(getRegexForTag(tag, contents), '');
+ },
+
+ tidy: function(){
+ return walk(this, tidy);
+ },
+
+ truncate: function(max, trail, atChar){
+ var string = this;
+ if (trail == null && arguments.length == 1) trail = '…';
+ if (string.length > max){
+ string = string.substring(0, max);
+ if (atChar){
+ var index = string.lastIndexOf(atChar);
+ if (index != -1) string = string.substr(0, index);
+ }
+ 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]];
+ }
+
+});
+
+})();
+
+/*
+---
+
+script: Element.Forms.js
+
+name: Element.Forms
+
+description: Extends the Element native object to include methods useful in managing inputs.
+
+license: MIT-style license
+
+authors:
+ - Aaron Newton
+
+requires:
+ - Core/Element
+ - String.Extras
+ - MooTools.More
+
+provides: [Element.Forms]
+
+...
+*/
+
+Element.implement({
+
+ tidy: function(){
+ this.set('value', this.get('value').tidy());
+ },
+
+ getTextInRange: function(start, end){
+ return this.get('value').substring(start, end);
+ },
+
+ getSelectedText: function(){
+ if (this.setSelectionRange) return this.getTextInRange(this.getSelectionStart(), this.getSelectionEnd());
+ return document.selection.createRange().text;
+ },
+
+ getSelectedRange: function(){
+ if (this.selectionStart != null){
+ return {
+ start: this.selectionStart,
+ end: this.selectionEnd
+ };
+ }
+
+ var pos = {
+ start: 0,
+ end: 0
+ };
+ var range = this.getDocument().selection.createRange();
+ if (!range || range.parentElement() != this) return pos;
+ var duplicate = range.duplicate();
+
+ if (this.type == 'text'){
+ pos.start = 0 - duplicate.moveStart('character', -100000);
+ pos.end = pos.start + range.text.length;
+ } else {
+ var value = this.get('value');
+ var offset = value.length;
+ duplicate.moveToElementText(this);
+ duplicate.setEndPoint('StartToEnd', range);
+ if (duplicate.text.length) offset -= value.match(/[\n\r]*$/)[0].length;
+ pos.end = offset - duplicate.text.length;
+ duplicate.setEndPoint('StartToStart', range);
+ pos.start = offset - duplicate.text.length;
+ }
+ return pos;
+ },
+
+ getSelectionStart: function(){
+ return this.getSelectedRange().start;
+ },
+
+ getSelectionEnd: function(){
+ return this.getSelectedRange().end;
+ },
+
+ setCaretPosition: function(pos){
+ if (pos == 'end') pos = this.get('value').length;
+ this.selectRange(pos, pos);
+ return this;
+ },
+
+ getCaretPosition: function(){
+ return this.getSelectedRange().start;
+ },
+
+ selectRange: function(start, end){
+ if (this.setSelectionRange){
+ this.focus();
+ this.setSelectionRange(start, end);
+ } else {
+ var value = this.get('value');
+ var diff = value.substr(start, end - start).replace(/\r/g, '').length;
+ start = value.substr(0, start).replace(/\r/g, '').length;
+ var range = this.createTextRange();
+ range.collapse(true);
+ range.moveEnd('character', start + diff);
+ range.moveStart('character', start);
+ range.select();
+ }
+ return this;
+ },
+
+ insertAtCursor: function(value, select){
+ var pos = this.getSelectedRange();
+ var text = this.get('value');
+ this.set('value', text.substring(0, pos.start) + value + text.substring(pos.end, text.length));
+ if (select !== false) this.selectRange(pos.start, pos.start + value.length);
+ else this.setCaretPosition(pos.start + value.length);
+ return this;
+ },
+
+ insertAroundCursor: function(options, select){
+ options = Object.append({
+ before: '',
+ defaultMiddle: '',
+ after: ''
+ }, options);
+
+ var value = this.getSelectedText() || options.defaultMiddle;
+ var pos = this.getSelectedRange();
+ var text = this.get('value');
+
+ if (pos.start == pos.end){
+ this.set('value', text.substring(0, pos.start) + options.before + value + options.after + text.substring(pos.end, text.length));
+ this.selectRange(pos.start + options.before.length, pos.end + options.before.length + value.length);
+ } else {
+ var current = text.substring(pos.start, pos.end);
+ this.set('value', text.substring(0, pos.start) + options.before + current + options.after + text.substring(pos.end, text.length));
+ var selStart = pos.start + options.before.length;
+ if (select !== false) this.selectRange(selStart, selStart + current.length);
+ else this.setCaretPosition(selStart + text.length);
+ }
+ return this;
+ }
+
+});
+
+/*
+---
+
+script: Element.Measure.js
+
+name: Element.Measure
+
+description: Extends the Element native object to include methods useful in measuring dimensions.
+
+credits: "Element.measure / .expose methods by Daniel Steigerwald License: MIT-style license. Copyright: Copyright (c) 2008 Daniel Steigerwald, daniel.steigerwald.cz"
+
+license: MIT-style license
+
+authors:
+ - Aaron Newton
+
+requires:
+ - Core/Element.Style
+ - Core/Element.Dimensions
+ - MooTools.More
+
+provides: [Element.Measure]
+
+...
+*/
+
+(function(){
+
+var getStylesList = function(styles, planes){
+ var list = [];
+ Object.each(planes, function(directions){
+ Object.each(directions, function(edge){
+ styles.each(function(style){
+ list.push(style + '-' + edge + (style == 'border' ? '-width' : ''));
+ });
+ });
+ });
+ return list;
+};
+
+var calculateEdgeSize = function(edge, styles){
+ var total = 0;
+ Object.each(styles, function(value, style){
+ if (style.test(edge)) total = total + value.toInt();
+ });
+ return total;
+};
+
+var isVisible = function(el){
+ return !!(!el || el.offsetHeight || el.offsetWidth);
+};
+
+
+Element.implement({
+
+ measure: function(fn){
+ if (isVisible(this)) return fn.call(this);
+ var parent = this.getParent(),
+ toMeasure = [];
+ while (!isVisible(parent) && parent != document.body){
+ toMeasure.push(parent.expose());
+ parent = parent.getParent();
+ }
+ var restore = this.expose(),
+ result = fn.call(this);
+ restore();
+ toMeasure.each(function(restore){
+ restore();
+ });
+ return result;
+ },
+
+ expose: function(){
+ if (this.getStyle('display') != 'none') return function(){};
+ var before = this.style.cssText;
+ this.setStyles({
+ display: 'block',
+ position: 'absolute',
+ visibility: 'hidden'
+ });
+ return function(){
+ this.style.cssText = before;
+ }.bind(this);
+ },
+
+ getDimensions: function(options){
+ options = Object.merge({computeSize: false}, options);
+ var dim = {x: 0, y: 0};
+
+ var getSize = function(el, options){
+ return (options.computeSize) ? el.getComputedSize(options) : el.getSize();
+ };
+
+ var parent = this.getParent('body');
+
+ if (parent && this.getStyle('display') == 'none'){
+ dim = this.measure(function(){
+ return getSize(this, options);
+ });
+ } else if (parent){
+ try { //safari sometimes crashes here, so catch it
+ dim = getSize(this, options);
+ }catch(e){}
+ }
+
+ return Object.append(dim, (dim.x || dim.x === 0) ? {
+ width: dim.x,
+ height: dim.y
+ } : {
+ x: dim.width,
+ y: dim.height
+ }
+ );
+ },
+
+ getComputedSize: function(options){
+
+
+ options = Object.merge({
+ styles: ['padding','border'],
+ planes: {
+ height: ['top','bottom'],
+ width: ['left','right']
+ },
+ mode: 'both'
+ }, options);
+
+ var styles = {},
+ size = {width: 0, height: 0},
+ dimensions;
+
+ if (options.mode == 'vertical'){
+ delete size.width;
+ delete options.planes.width;
+ } else if (options.mode == 'horizontal'){
+ delete size.height;
+ delete options.planes.height;
+ }
+
+ getStylesList(options.styles, options.planes).each(function(style){
+ styles[style] = this.getStyle(style).toInt();
+ }, this);
+
+ Object.each(options.planes, function(edges, plane){
+
+ var capitalized = plane.capitalize(),
+ style = this.getStyle(plane);
+
+ if (style == 'auto' && !dimensions) dimensions = this.getDimensions();
+
+ style = styles[plane] = (style == 'auto') ? dimensions[plane] : style.toInt();
+ size['total' + capitalized] = style;
+
+ edges.each(function(edge){
+ var edgesize = calculateEdgeSize(edge, styles);
+ size['computed' + edge.capitalize()] = edgesize;
+ size['total' + capitalized] += edgesize;
+ });
+
+ }, this);
+
+ return Object.append(size, styles);
+ }
+
+});
+
+})();
+
+/*
+---
+
+script: Element.Position.js
+
+name: Element.Position
+
+description: Extends the Element native object to include methods useful positioning elements relative to others.
+
+license: MIT-style license
+
+authors:
+ - Aaron Newton
+ - Jacob Thornton
+
+requires:
+ - Core/Options
+ - Core/Element.Dimensions
+ - Element.Measure
+
+provides: [Element.Position]
+
+...
+*/
+
+(function(original){
+
+var local = Element.Position = {
+
+ options: {/*
+ edge: false,
+ returnPos: false,
+ minimum: {x: 0, y: 0},
+ maximum: {x: 0, y: 0},
+ relFixedPosition: false,
+ ignoreMargins: false,
+ ignoreScroll: false,
+ allowNegative: false,*/
+ relativeTo: document.body,
+ position: {
+ x: 'center', //left, center, right
+ y: 'center' //top, center, bottom
+ },
+ offset: {x: 0, y: 0}
+ },
+
+ getOptions: function(element, options){
+ options = Object.merge({}, local.options, options);
+ local.setPositionOption(options);
+ local.setEdgeOption(options);
+ local.setOffsetOption(element, options);
+ local.setDimensionsOption(element, options);
+ return options;
+ },
+
+ setPositionOption: function(options){
+ options.position = local.getCoordinateFromValue(options.position);
+ },
+
+ setEdgeOption: function(options){
+ var edgeOption = local.getCoordinateFromValue(options.edge);
+ options.edge = edgeOption ? edgeOption :
+ (options.position.x == 'center' && options.position.y == 'center') ? {x: 'center', y: 'center'} :
+ {x: 'left', y: 'top'};
+ },
+
+ setOffsetOption: function(element, options){
+ 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'){
+ var scroll = window.getScroll();
+ position.x += scroll.x;
+ position.y += scroll.y;
+ }
+ return position;
+ });
+
+ options.offset = {
+ parentPositioned: offsetParent != document.id(options.relativeTo),
+ x: options.offset.x - parentOffset.x + parentScroll.x,
+ y: options.offset.y - parentOffset.y + parentScroll.y
+ };
+ },
+
+ setDimensionsOption: function(element, options){
+ options.dimensions = element.getDimensions({
+ computeSize: true,
+ styles: ['padding', 'border', 'margin']
+ });
+ },
+
+ getPosition: function(element, options){
+ var position = {};
+ options = local.getOptions(element, options);
+ var relativeTo = document.id(options.relativeTo) || document.body;
+
+ local.setPositionCoordinates(options, position, relativeTo);
+ if (options.edge) local.toEdge(position, options);
+
+ var offset = options.offset;
+ position.left = ((position.x >= 0 || offset.parentPositioned || options.allowNegative) ? position.x : 0).toInt();
+ position.top = ((position.y >= 0 || offset.parentPositioned || options.allowNegative) ? position.y : 0).toInt();
+
+ local.toMinMax(position, options);
+
+ if (options.relFixedPosition || relativeTo.getStyle('position') == 'fixed') local.toRelFixedPosition(relativeTo, position);
+ if (options.ignoreScroll) local.toIgnoreScroll(relativeTo, position);
+ if (options.ignoreMargins) local.toIgnoreMargins(position, options);
+
+ position.left = Math.ceil(position.left);
+ position.top = Math.ceil(position.top);
+ delete position.x;
+ delete position.y;
+
+ return position;
+ },
+
+ setPositionCoordinates: function(options, position, relativeTo){
+ var offsetY = options.offset.y,
+ offsetX = options.offset.x,
+ calc = (relativeTo == document.body) ? window.getScroll() : relativeTo.getPosition(),
+ top = calc.y,
+ left = calc.x,
+ winSize = window.getSize();
+
+ switch(options.position.x){
+ case 'left': position.x = left + offsetX; break;
+ case 'right': position.x = left + offsetX + relativeTo.offsetWidth; break;
+ default: position.x = left + ((relativeTo == document.body ? winSize.x : relativeTo.offsetWidth) / 2) + offsetX; break;
+ }
+
+ switch(options.position.y){
+ case 'top': position.y = top + offsetY; break;
+ case 'bottom': position.y = top + offsetY + relativeTo.offsetHeight; break;
+ default: position.y = top + ((relativeTo == document.body ? winSize.y : relativeTo.offsetHeight) / 2) + offsetY; break;
+ }
+ },
+
+ toMinMax: function(position, options){
+ var xy = {left: 'x', top: 'y'}, value;
+ ['minimum', 'maximum'].each(function(minmax){
+ ['left', 'top'].each(function(lr){
+ value = options[minmax] ? options[minmax][xy[lr]] : null;
+ if (value != null && ((minmax == 'minimum') ? position[lr] < value : position[lr] > value)) position[lr] = value;
+ });
+ });
+ },
+
+ toRelFixedPosition: function(relativeTo, position){
+ var winScroll = window.getScroll();
+ position.top += winScroll.y;
+ position.left += winScroll.x;
+ },
+
+ toIgnoreScroll: function(relativeTo, position){
+ var relScroll = relativeTo.getScroll();
+ position.top -= relScroll.y;
+ position.left -= relScroll.x;
+ },
+
+ toIgnoreMargins: function(position, options){
+ position.left += options.edge.x == 'right'
+ ? options.dimensions['margin-right']
+ : (options.edge.x != 'center'
+ ? -options.dimensions['margin-left']
+ : -options.dimensions['margin-left'] + ((options.dimensions['margin-right'] + options.dimensions['margin-left']) / 2));
+
+ position.top += options.edge.y == 'bottom'
+ ? options.dimensions['margin-bottom']
+ : (options.edge.y != 'center'
+ ? -options.dimensions['margin-top']
+ : -options.dimensions['margin-top'] + ((options.dimensions['margin-bottom'] + options.dimensions['margin-top']) / 2));
+ },
+
+ toEdge: function(position, options){
+ var edgeOffset = {},
+ dimensions = options.dimensions,
+ edge = options.edge;
+
+ switch(edge.x){
+ case 'left': edgeOffset.x = 0; break;
+ case 'right': edgeOffset.x = -dimensions.x - dimensions.computedRight - dimensions.computedLeft; break;
+ // center
+ default: edgeOffset.x = -(Math.round(dimensions.totalWidth / 2)); break;
+ }
+
+ switch(edge.y){
+ case 'top': edgeOffset.y = 0; break;
+ case 'bottom': edgeOffset.y = -dimensions.y - dimensions.computedTop - dimensions.computedBottom; break;
+ // center
+ default: edgeOffset.y = -(Math.round(dimensions.totalHeight / 2)); break;
+ }
+
+ position.x += edgeOffset.x;
+ position.y += edgeOffset.y;
+ },
+
+ getCoordinateFromValue: function(option){
+ if (typeOf(option) != 'string') return option;
+ option = option.toLowerCase();
+
+ return {
+ x: option.test('left') ? 'left'
+ : (option.test('right') ? 'right' : 'center'),
+ y: option.test(/upper|top/) ? 'top'
+ : (option.test('bottom') ? 'bottom' : 'center')
+ };
+ }
+
+};
+
+Element.implement({
+
+ position: function(options){
+ if (options && (options.x != null || options.y != null)){
+ return (original ? original.apply(this, arguments) : this);
+ }
+ var position = this.setStyle('position', 'absolute').calculatePosition(options);
+ return (options && options.returnPos) ? position : this.setStyles(position);
+ },
+
+ calculatePosition: function(options){
+ return local.getPosition(this, options);
+ }
+
+});
+
+})(Element.prototype.position);
+
+/*
+---
+
+script: Element.Shortcuts.js
+
+name: Element.Shortcuts
+
+description: Extends the Element native object to include some shortcut methods.
+
+license: MIT-style license
+
+authors:
+ - Aaron Newton
+
+requires:
+ - Core/Element.Style
+ - MooTools.More
+
+provides: [Element.Shortcuts]
+
+...
+*/
+
+Element.implement({
+
+ isDisplayed: function(){
+ return this.getStyle('display') != 'none';
+ },
+
+ isVisible: function(){
+ var w = this.offsetWidth,
+ h = this.offsetHeight;
+ return (w == 0 && h == 0) ? false : (w > 0 && h > 0) ? true : this.style.display != 'none';
+ },
+
+ toggle: function(){
+ return this[this.isDisplayed() ? 'hide' : 'show']();
+ },
+
+ hide: function(){
+ var d;
+ try {
+ //IE fails here if the element is not in the dom
+ d = this.getStyle('display');
+ } catch(e){}
+ if (d == 'none') return this;
+ return this.store('element:_originalDisplay', d || '').setStyle('display', 'none');
+ },
+
+ show: function(display){
+ if (!display && this.isDisplayed()) return this;
+ display = display || this.retrieve('element:_originalDisplay') || 'block';
+ return this.setStyle('display', (display == 'none') ? 'block' : display);
+ },
+
+ swapClass: function(remove, add){
+ return this.removeClass(remove).addClass(add);
+ }
+
+});
+
+Document.implement({
+
+ clearSelection: function(){
+ if (window.getSelection){
+ var selection = window.getSelection();
+ if (selection && selection.removeAllRanges) selection.removeAllRanges();
+ } else if (document.selection && document.selection.empty){
+ try {
+ //IE fails here if selected element is not in dom
+ document.selection.empty();
+ } catch(e){}
+ }
+ }
+
+});
/*
---
@@ -272,7 +1771,6 @@ Object.extend({
})();
-
/*
---
@@ -440,7 +1938,6 @@ Locale.Set = new Class({
})();
-
/*
---
@@ -512,7 +2009,6 @@ Locale.define('en-US', 'Date', {
});
-
/*
---
@@ -1072,918 +2568,6 @@ Locale.addEvent('change', function(language){
})();
-
-/*
----
-
-script: Date.Extras.js
-
-name: Date.Extras
-
-description: Extends the Date native object to include extra methods (on top of those in Date.js).
-
-license: MIT-style license
-
-authors:
- - Aaron Newton
- - Scott Kyle
-
-requires:
- - Date
-
-provides: [Date.Extras]
-
-...
-*/
-
-Date.implement({
-
- timeDiffInWords: function(to){
- return Date.distanceOfTimeInWords(this, to || new Date);
- },
-
- timeDiff: function(to, separator){
- if (to == null) to = new Date;
- var delta = ((to - this) / 1000).floor().abs();
-
- var vals = [],
- durations = [60, 60, 24, 365, 0],
- names = ['s', 'm', 'h', 'd', 'y'],
- value, duration;
-
- for (var item = 0; item < durations.length; item++){
- if (item && !delta) break;
- value = delta;
- if ((duration = durations[item])){
- value = (delta % duration);
- delta = (delta / duration).floor();
- }
- vals.unshift(value + (names[item] || ''));
- }
-
- return vals.join(separator || ':');
- }
-
-}).extend({
-
- distanceOfTimeInWords: function(from, to){
- return Date.getTimePhrase(((to - from) / 1000).toInt());
- },
-
- getTimePhrase: function(delta){
- var suffix = (delta < 0) ? 'Until' : 'Ago';
- if (delta < 0) delta *= -1;
-
- var units = {
- minute: 60,
- hour: 60,
- day: 24,
- week: 7,
- month: 52 / 12,
- year: 12,
- eon: Infinity
- };
-
- var msg = 'lessThanMinute';
-
- for (var unit in units){
- var interval = units[unit];
- if (delta < 1.5 * interval){
- if (delta > 0.75 * interval) msg = unit;
- break;
- }
- delta /= interval;
- msg = unit + 's';
- }
-
- delta = delta.round();
- return Date.getMsg(msg + suffix, delta).substitute({delta: delta});
- }
-
-}).defineParsers(
-
- {
- // "today", "tomorrow", "yesterday"
- re: /^(?:tod|tom|yes)/i,
- handler: function(bits){
- var d = new Date().clearTime();
- switch (bits[0]){
- case 'tom': return d.increment();
- case 'yes': return d.decrement();
- default: return d;
- }
- }
- },
-
- {
- // "next Wednesday", "last Thursday"
- re: /^(next|last) ([a-z]+)$/i,
- handler: function(bits){
- var d = new Date().clearTime();
- var day = d.getDay();
- var newDay = Date.parseDay(bits[2], true);
- var addDays = newDay - day;
- if (newDay <= day) addDays += 7;
- if (bits[1] == 'last') addDays -= 7;
- return d.set('date', d.getDate() + addDays);
- }
- }
-
-).alias('timeAgoInWords', 'timeDiffInWords');
-
-
-/*
----
-
-script: String.Extras.js
-
-name: String.Extras
-
-description: Extends the String native object to include methods useful in managing various kinds of strings (query strings, urls, html, etc).
-
-license: MIT-style license
-
-authors:
- - Aaron Newton
- - Guillermo Rauch
- - Christopher Pitt
-
-requires:
- - Core/String
- - Core/Array
- - MooTools.More
-
-provides: [String.Extras]
-
-...
-*/
-
-(function(){
-
-var special = {
- 'a': /[àáâãäåăą]/g,
- 'A': /[ÀÁÂÃÄÅĂĄ]/g,
- 'c': /[ćčç]/g,
- 'C': /[ĆČÇ]/g,
- 'd': /[ďđ]/g,
- 'D': /[ĎÐ]/g,
- 'e': /[èéêëěę]/g,
- 'E': /[ÈÉÊËĚĘ]/g,
- 'g': /[ğ]/g,
- 'G': /[Ğ]/g,
- 'i': /[ìíîï]/g,
- 'I': /[ÌÍÎÏ]/g,
- 'l': /[ĺľł]/g,
- 'L': /[ĹĽŁ]/g,
- 'n': /[ñňń]/g,
- 'N': /[ÑŇŃ]/g,
- 'o': /[òóôõöøő]/g,
- 'O': /[ÒÓÔÕÖØ]/g,
- 'r': /[řŕ]/g,
- 'R': /[ŘŔ]/g,
- 's': /[ššş]/g,
- 'S': /[ŠŞŚ]/g,
- 't': /[ťţ]/g,
- 'T': /[ŤŢ]/g,
- 'u': /[ùúûůüµ]/g,
- 'U': /[ÙÚÛŮÜ]/g,
- 'y': /[ÿý]/g,
- 'Y': /[ŸÝ]/g,
- 'z': /[žźż]/g,
- 'Z': /[ŽŹŻ]/g,
- 'th': /[þ]/g,
- 'TH': /[Þ]/g,
- 'dh': /[ð]/g,
- 'DH': /[Ð]/g,
- 'ss': /[ß]/g,
- 'oe': /[œ]/g,
- 'OE': /[Œ]/g,
- 'ae': /[æ]/g,
- 'AE': /[Æ]/g
-},
-
-tidy = {
- ' ': /[\xa0\u2002\u2003\u2009]/g,
- '*': /[\xb7]/g,
- '\'': /[\u2018\u2019]/g,
- '"': /[\u201c\u201d]/g,
- '...': /[\u2026]/g,
- '-': /[\u2013]/g,
-// '--': /[\u2014]/g,
- '»': /[\uFFFD]/g
-},
-
-conversions = {
- ms: 1,
- s: 1000,
- m: 6e4,
- h: 36e5
-},
-
-findUnits = /(\d*.?\d+)([msh]+)/;
-
-var walk = function(string, replacements){
- var result = string, key;
- for (key in replacements) result = result.replace(replacements[key], key);
- return result;
-};
-
-var getRegexForTag = function(tag, contents){
- tag = tag || '';
- var regstr = contents ? "<" + tag + "(?!\\w)[^>]*>([\\s\\S]*?)<\/" + tag + "(?!\\w)>" : "<\/?" + tag + "([^>]+)?>",
- reg = new RegExp(regstr, "gi");
- return reg;
-};
-
-String.implement({
-
- standardize: function(){
- return walk(this, special);
- },
-
- repeat: function(times){
- return new Array(times + 1).join(this);
- },
-
- pad: function(length, str, direction){
- if (this.length >= length) return this;
-
- var pad = (str == null ? ' ' : '' + str)
- .repeat(length - this.length)
- .substr(0, length - this.length);
-
- if (!direction || direction == 'right') return this + pad;
- if (direction == 'left') return pad + this;
-
- return pad.substr(0, (pad.length / 2).floor()) + this + pad.substr(0, (pad.length / 2).ceil());
- },
-
- getTags: function(tag, contents){
- return this.match(getRegexForTag(tag, contents)) || [];
- },
-
- stripTags: function(tag, contents){
- return this.replace(getRegexForTag(tag, contents), '');
- },
-
- tidy: function(){
- return walk(this, tidy);
- },
-
- truncate: function(max, trail, atChar){
- var string = this;
- if (trail == null && arguments.length == 1) trail = '…';
- if (string.length > max){
- string = string.substring(0, max);
- if (atChar){
- var index = string.lastIndexOf(atChar);
- if (index != -1) string = string.substr(0, index);
- }
- 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]];
- }
-
-});
-
-})();
-
-
-/*
----
-
-script: Element.Forms.js
-
-name: Element.Forms
-
-description: Extends the Element native object to include methods useful in managing inputs.
-
-license: MIT-style license
-
-authors:
- - Aaron Newton
-
-requires:
- - Core/Element
- - String.Extras
- - MooTools.More
-
-provides: [Element.Forms]
-
-...
-*/
-
-Element.implement({
-
- tidy: function(){
- this.set('value', this.get('value').tidy());
- },
-
- getTextInRange: function(start, end){
- return this.get('value').substring(start, end);
- },
-
- getSelectedText: function(){
- if (this.setSelectionRange) return this.getTextInRange(this.getSelectionStart(), this.getSelectionEnd());
- return document.selection.createRange().text;
- },
-
- getSelectedRange: function(){
- if (this.selectionStart != null){
- return {
- start: this.selectionStart,
- end: this.selectionEnd
- };
- }
-
- var pos = {
- start: 0,
- end: 0
- };
- var range = this.getDocument().selection.createRange();
- if (!range || range.parentElement() != this) return pos;
- var duplicate = range.duplicate();
-
- if (this.type == 'text'){
- pos.start = 0 - duplicate.moveStart('character', -100000);
- pos.end = pos.start + range.text.length;
- } else {
- var value = this.get('value');
- var offset = value.length;
- duplicate.moveToElementText(this);
- duplicate.setEndPoint('StartToEnd', range);
- if (duplicate.text.length) offset -= value.match(/[\n\r]*$/)[0].length;
- pos.end = offset - duplicate.text.length;
- duplicate.setEndPoint('StartToStart', range);
- pos.start = offset - duplicate.text.length;
- }
- return pos;
- },
-
- getSelectionStart: function(){
- return this.getSelectedRange().start;
- },
-
- getSelectionEnd: function(){
- return this.getSelectedRange().end;
- },
-
- setCaretPosition: function(pos){
- if (pos == 'end') pos = this.get('value').length;
- this.selectRange(pos, pos);
- return this;
- },
-
- getCaretPosition: function(){
- return this.getSelectedRange().start;
- },
-
- selectRange: function(start, end){
- if (this.setSelectionRange){
- this.focus();
- this.setSelectionRange(start, end);
- } else {
- var value = this.get('value');
- var diff = value.substr(start, end - start).replace(/\r/g, '').length;
- start = value.substr(0, start).replace(/\r/g, '').length;
- var range = this.createTextRange();
- range.collapse(true);
- range.moveEnd('character', start + diff);
- range.moveStart('character', start);
- range.select();
- }
- return this;
- },
-
- insertAtCursor: function(value, select){
- var pos = this.getSelectedRange();
- var text = this.get('value');
- this.set('value', text.substring(0, pos.start) + value + text.substring(pos.end, text.length));
- if (select !== false) this.selectRange(pos.start, pos.start + value.length);
- else this.setCaretPosition(pos.start + value.length);
- return this;
- },
-
- insertAroundCursor: function(options, select){
- options = Object.append({
- before: '',
- defaultMiddle: '',
- after: ''
- }, options);
-
- var value = this.getSelectedText() || options.defaultMiddle;
- var pos = this.getSelectedRange();
- var text = this.get('value');
-
- if (pos.start == pos.end){
- this.set('value', text.substring(0, pos.start) + options.before + value + options.after + text.substring(pos.end, text.length));
- this.selectRange(pos.start + options.before.length, pos.end + options.before.length + value.length);
- } else {
- var current = text.substring(pos.start, pos.end);
- this.set('value', text.substring(0, pos.start) + options.before + current + options.after + text.substring(pos.end, text.length));
- var selStart = pos.start + options.before.length;
- if (select !== false) this.selectRange(selStart, selStart + current.length);
- else this.setCaretPosition(selStart + text.length);
- }
- return this;
- }
-
-});
-
-
-/*
----
-
-script: Element.Measure.js
-
-name: Element.Measure
-
-description: Extends the Element native object to include methods useful in measuring dimensions.
-
-credits: "Element.measure / .expose methods by Daniel Steigerwald License: MIT-style license. Copyright: Copyright (c) 2008 Daniel Steigerwald, daniel.steigerwald.cz"
-
-license: MIT-style license
-
-authors:
- - Aaron Newton
-
-requires:
- - Core/Element.Style
- - Core/Element.Dimensions
- - MooTools.More
-
-provides: [Element.Measure]
-
-...
-*/
-
-(function(){
-
-var getStylesList = function(styles, planes){
- var list = [];
- Object.each(planes, function(directions){
- Object.each(directions, function(edge){
- styles.each(function(style){
- list.push(style + '-' + edge + (style == 'border' ? '-width' : ''));
- });
- });
- });
- return list;
-};
-
-var calculateEdgeSize = function(edge, styles){
- var total = 0;
- Object.each(styles, function(value, style){
- if (style.test(edge)) total = total + value.toInt();
- });
- return total;
-};
-
-var isVisible = function(el){
- return !!(!el || el.offsetHeight || el.offsetWidth);
-};
-
-
-Element.implement({
-
- measure: function(fn){
- if (isVisible(this)) return fn.call(this);
- var parent = this.getParent(),
- toMeasure = [];
- while (!isVisible(parent) && parent != document.body){
- toMeasure.push(parent.expose());
- parent = parent.getParent();
- }
- var restore = this.expose(),
- result = fn.call(this);
- restore();
- toMeasure.each(function(restore){
- restore();
- });
- return result;
- },
-
- expose: function(){
- if (this.getStyle('display') != 'none') return function(){};
- var before = this.style.cssText;
- this.setStyles({
- display: 'block',
- position: 'absolute',
- visibility: 'hidden'
- });
- return function(){
- this.style.cssText = before;
- }.bind(this);
- },
-
- getDimensions: function(options){
- options = Object.merge({computeSize: false}, options);
- var dim = {x: 0, y: 0};
-
- var getSize = function(el, options){
- return (options.computeSize) ? el.getComputedSize(options) : el.getSize();
- };
-
- var parent = this.getParent('body');
-
- if (parent && this.getStyle('display') == 'none'){
- dim = this.measure(function(){
- return getSize(this, options);
- });
- } else if (parent){
- try { //safari sometimes crashes here, so catch it
- dim = getSize(this, options);
- }catch(e){}
- }
-
- return Object.append(dim, (dim.x || dim.x === 0) ? {
- width: dim.x,
- height: dim.y
- } : {
- x: dim.width,
- y: dim.height
- }
- );
- },
-
- getComputedSize: function(options){
-
-
- options = Object.merge({
- styles: ['padding','border'],
- planes: {
- height: ['top','bottom'],
- width: ['left','right']
- },
- mode: 'both'
- }, options);
-
- var styles = {},
- size = {width: 0, height: 0},
- dimensions;
-
- if (options.mode == 'vertical'){
- delete size.width;
- delete options.planes.width;
- } else if (options.mode == 'horizontal'){
- delete size.height;
- delete options.planes.height;
- }
-
- getStylesList(options.styles, options.planes).each(function(style){
- styles[style] = this.getStyle(style).toInt();
- }, this);
-
- Object.each(options.planes, function(edges, plane){
-
- var capitalized = plane.capitalize(),
- style = this.getStyle(plane);
-
- if (style == 'auto' && !dimensions) dimensions = this.getDimensions();
-
- style = styles[plane] = (style == 'auto') ? dimensions[plane] : style.toInt();
- size['total' + capitalized] = style;
-
- edges.each(function(edge){
- var edgesize = calculateEdgeSize(edge, styles);
- size['computed' + edge.capitalize()] = edgesize;
- size['total' + capitalized] += edgesize;
- });
-
- }, this);
-
- return Object.append(size, styles);
- }
-
-});
-
-})();
-
-
-/*
----
-
-script: Element.Position.js
-
-name: Element.Position
-
-description: Extends the Element native object to include methods useful positioning elements relative to others.
-
-license: MIT-style license
-
-authors:
- - Aaron Newton
- - Jacob Thornton
-
-requires:
- - Core/Options
- - Core/Element.Dimensions
- - Element.Measure
-
-provides: [Element.Position]
-
-...
-*/
-
-(function(original){
-
-var local = Element.Position = {
-
- options: {/*
- edge: false,
- returnPos: false,
- minimum: {x: 0, y: 0},
- maximum: {x: 0, y: 0},
- relFixedPosition: false,
- ignoreMargins: false,
- ignoreScroll: false,
- allowNegative: false,*/
- relativeTo: document.body,
- position: {
- x: 'center', //left, center, right
- y: 'center' //top, center, bottom
- },
- offset: {x: 0, y: 0}
- },
-
- getOptions: function(element, options){
- options = Object.merge({}, local.options, options);
- local.setPositionOption(options);
- local.setEdgeOption(options);
- local.setOffsetOption(element, options);
- local.setDimensionsOption(element, options);
- return options;
- },
-
- setPositionOption: function(options){
- options.position = local.getCoordinateFromValue(options.position);
- },
-
- setEdgeOption: function(options){
- var edgeOption = local.getCoordinateFromValue(options.edge);
- options.edge = edgeOption ? edgeOption :
- (options.position.x == 'center' && options.position.y == 'center') ? {x: 'center', y: 'center'} :
- {x: 'left', y: 'top'};
- },
-
- setOffsetOption: function(element, options){
- 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'){
- var scroll = window.getScroll();
- position.x += scroll.x;
- position.y += scroll.y;
- }
- return position;
- });
-
- options.offset = {
- parentPositioned: offsetParent != document.id(options.relativeTo),
- x: options.offset.x - parentOffset.x + parentScroll.x,
- y: options.offset.y - parentOffset.y + parentScroll.y
- };
- },
-
- setDimensionsOption: function(element, options){
- options.dimensions = element.getDimensions({
- computeSize: true,
- styles: ['padding', 'border', 'margin']
- });
- },
-
- getPosition: function(element, options){
- var position = {};
- options = local.getOptions(element, options);
- var relativeTo = document.id(options.relativeTo) || document.body;
-
- local.setPositionCoordinates(options, position, relativeTo);
- if (options.edge) local.toEdge(position, options);
-
- var offset = options.offset;
- position.left = ((position.x >= 0 || offset.parentPositioned || options.allowNegative) ? position.x : 0).toInt();
- position.top = ((position.y >= 0 || offset.parentPositioned || options.allowNegative) ? position.y : 0).toInt();
-
- local.toMinMax(position, options);
-
- if (options.relFixedPosition || relativeTo.getStyle('position') == 'fixed') local.toRelFixedPosition(relativeTo, position);
- if (options.ignoreScroll) local.toIgnoreScroll(relativeTo, position);
- if (options.ignoreMargins) local.toIgnoreMargins(position, options);
-
- position.left = Math.ceil(position.left);
- position.top = Math.ceil(position.top);
- delete position.x;
- delete position.y;
-
- return position;
- },
-
- setPositionCoordinates: function(options, position, relativeTo){
- var offsetY = options.offset.y,
- offsetX = options.offset.x,
- calc = (relativeTo == document.body) ? window.getScroll() : relativeTo.getPosition(),
- top = calc.y,
- left = calc.x,
- winSize = window.getSize();
-
- switch(options.position.x){
- case 'left': position.x = left + offsetX; break;
- case 'right': position.x = left + offsetX + relativeTo.offsetWidth; break;
- default: position.x = left + ((relativeTo == document.body ? winSize.x : relativeTo.offsetWidth) / 2) + offsetX; break;
- }
-
- switch(options.position.y){
- case 'top': position.y = top + offsetY; break;
- case 'bottom': position.y = top + offsetY + relativeTo.offsetHeight; break;
- default: position.y = top + ((relativeTo == document.body ? winSize.y : relativeTo.offsetHeight) / 2) + offsetY; break;
- }
- },
-
- toMinMax: function(position, options){
- var xy = {left: 'x', top: 'y'}, value;
- ['minimum', 'maximum'].each(function(minmax){
- ['left', 'top'].each(function(lr){
- value = options[minmax] ? options[minmax][xy[lr]] : null;
- if (value != null && ((minmax == 'minimum') ? position[lr] < value : position[lr] > value)) position[lr] = value;
- });
- });
- },
-
- toRelFixedPosition: function(relativeTo, position){
- var winScroll = window.getScroll();
- position.top += winScroll.y;
- position.left += winScroll.x;
- },
-
- toIgnoreScroll: function(relativeTo, position){
- var relScroll = relativeTo.getScroll();
- position.top -= relScroll.y;
- position.left -= relScroll.x;
- },
-
- toIgnoreMargins: function(position, options){
- position.left += options.edge.x == 'right'
- ? options.dimensions['margin-right']
- : (options.edge.x != 'center'
- ? -options.dimensions['margin-left']
- : -options.dimensions['margin-left'] + ((options.dimensions['margin-right'] + options.dimensions['margin-left']) / 2));
-
- position.top += options.edge.y == 'bottom'
- ? options.dimensions['margin-bottom']
- : (options.edge.y != 'center'
- ? -options.dimensions['margin-top']
- : -options.dimensions['margin-top'] + ((options.dimensions['margin-bottom'] + options.dimensions['margin-top']) / 2));
- },
-
- toEdge: function(position, options){
- var edgeOffset = {},
- dimensions = options.dimensions,
- edge = options.edge;
-
- switch(edge.x){
- case 'left': edgeOffset.x = 0; break;
- case 'right': edgeOffset.x = -dimensions.x - dimensions.computedRight - dimensions.computedLeft; break;
- // center
- default: edgeOffset.x = -(Math.round(dimensions.totalWidth / 2)); break;
- }
-
- switch(edge.y){
- case 'top': edgeOffset.y = 0; break;
- case 'bottom': edgeOffset.y = -dimensions.y - dimensions.computedTop - dimensions.computedBottom; break;
- // center
- default: edgeOffset.y = -(Math.round(dimensions.totalHeight / 2)); break;
- }
-
- position.x += edgeOffset.x;
- position.y += edgeOffset.y;
- },
-
- getCoordinateFromValue: function(option){
- if (typeOf(option) != 'string') return option;
- option = option.toLowerCase();
-
- return {
- x: option.test('left') ? 'left'
- : (option.test('right') ? 'right' : 'center'),
- y: option.test(/upper|top/) ? 'top'
- : (option.test('bottom') ? 'bottom' : 'center')
- };
- }
-
-};
-
-Element.implement({
-
- position: function(options){
- if (options && (options.x != null || options.y != null)){
- return (original ? original.apply(this, arguments) : this);
- }
- var position = this.setStyle('position', 'absolute').calculatePosition(options);
- return (options && options.returnPos) ? position : this.setStyles(position);
- },
-
- calculatePosition: function(options){
- return local.getPosition(this, options);
- }
-
-});
-
-})(Element.prototype.position);
-
-
-/*
----
-
-script: Element.Shortcuts.js
-
-name: Element.Shortcuts
-
-description: Extends the Element native object to include some shortcut methods.
-
-license: MIT-style license
-
-authors:
- - Aaron Newton
-
-requires:
- - Core/Element.Style
- - MooTools.More
-
-provides: [Element.Shortcuts]
-
-...
-*/
-
-Element.implement({
-
- isDisplayed: function(){
- return this.getStyle('display') != 'none';
- },
-
- isVisible: function(){
- var w = this.offsetWidth,
- h = this.offsetHeight;
- return (w == 0 && h == 0) ? false : (w > 0 && h > 0) ? true : this.style.display != 'none';
- },
-
- toggle: function(){
- return this[this.isDisplayed() ? 'hide' : 'show']();
- },
-
- hide: function(){
- var d;
- try {
- //IE fails here if the element is not in the dom
- d = this.getStyle('display');
- } catch(e){}
- if (d == 'none') return this;
- return this.store('element:_originalDisplay', d || '').setStyle('display', 'none');
- },
-
- show: function(display){
- if (!display && this.isDisplayed()) return this;
- display = display || this.retrieve('element:_originalDisplay') || 'block';
- return this.setStyle('display', (display == 'none') ? 'block' : display);
- },
-
- swapClass: function(remove, add){
- return this.removeClass(remove).addClass(add);
- }
-
-});
-
-Document.implement({
-
- clearSelection: function(){
- if (window.getSelection){
- var selection = window.getSelection();
- if (selection && selection.removeAllRanges) selection.removeAllRanges();
- } else if (document.selection && document.selection.empty){
- try {
- //IE fails here if selected element is not in dom
- document.selection.empty();
- } catch(e){}
- }
- }
-
-});
-
-
/*
---
@@ -2155,7 +2739,6 @@ function isBody(element){
})();
-
/*
---
@@ -2327,697 +2910,6 @@ Element.implement({
});
-
-/*
----
-
-script: Drag.js
-
-name: Drag
-
-description: The base Drag Class. Can be used to drag and resize Elements using mouse events.
-
-license: MIT-style license
-
-authors:
- - Valerio Proietti
- - Tom Occhinno
- - Jan Kassens
-
-requires:
- - Core/Events
- - Core/Options
- - Core/Element.Event
- - Core/Element.Style
- - Core/Element.Dimensions
- - MooTools.More
-
-provides: [Drag]
-...
-
-*/
-
-var Drag = new Class({
-
- Implements: [Events, Options],
-
- options: {/*
- onBeforeStart: function(thisElement){},
- onStart: function(thisElement, event){},
- onSnap: function(thisElement){},
- onDrag: function(thisElement, event){},
- onCancel: function(thisElement){},
- onComplete: function(thisElement, event){},*/
- snap: 6,
- unit: 'px',
- grid: false,
- style: true,
- limit: false,
- handle: false,
- invert: false,
- preventDefault: false,
- stopPropagation: false,
- modifiers: {x: 'left', y: 'top'}
- },
-
- initialize: function(){
- var params = Array.link(arguments, {
- 'options': Type.isObject,
- 'element': function(obj){
- return obj != null;
- }
- });
-
- this.element = document.id(params.element);
- this.document = this.element.getDocument();
- this.setOptions(params.options || {});
- var htype = typeOf(this.options.handle);
- this.handles = ((htype == 'array' || htype == 'collection') ? $$(this.options.handle) : document.id(this.options.handle)) || this.element;
- this.mouse = {'now': {}, 'pos': {}};
- this.value = {'start': {}, 'now': {}};
-
- this.selection = 'selectstart' in document ? 'selectstart' : 'mousedown';
-
-
- if ('ondragstart' in document && !('FileReader' in window) && !Drag.ondragstartFixed){
- document.ondragstart = Function.from(false);
- Drag.ondragstartFixed = true;
- }
-
- this.bound = {
- start: this.start.bind(this),
- check: this.check.bind(this),
- drag: this.drag.bind(this),
- stop: this.stop.bind(this),
- cancel: this.cancel.bind(this),
- eventStop: Function.from(false)
- };
- this.attach();
- },
-
- attach: function(){
- this.handles.addEvent('mousedown', this.bound.start);
- return this;
- },
-
- detach: function(){
- this.handles.removeEvent('mousedown', this.bound.start);
- return this;
- },
-
- start: function(event){
- var options = this.options;
-
- if (event.rightClick) return;
-
- if (options.preventDefault) event.preventDefault();
- if (options.stopPropagation) event.stopPropagation();
- this.mouse.start = event.page;
-
- this.fireEvent('beforeStart', this.element);
-
- var limit = options.limit;
- this.limit = {x: [], y: []};
-
- var z, coordinates;
- for (z in options.modifiers){
- if (!options.modifiers[z]) continue;
-
- var style = this.element.getStyle(options.modifiers[z]);
-
- // Some browsers (IE and Opera) don't always return pixels.
- if (style && !style.match(/px$/)){
- if (!coordinates) coordinates = this.element.getCoordinates(this.element.getOffsetParent());
- style = coordinates[options.modifiers[z]];
- }
-
- if (options.style) this.value.now[z] = (style || 0).toInt();
- else this.value.now[z] = this.element[options.modifiers[z]];
-
- if (options.invert) this.value.now[z] *= -1;
-
- this.mouse.pos[z] = event.page[z] - this.value.now[z];
-
- if (limit && limit[z]){
- var i = 2;
- while (i--){
- var limitZI = limit[z][i];
- if (limitZI || limitZI === 0) this.limit[z][i] = (typeof limitZI == 'function') ? limitZI() : limitZI;
- }
- }
- }
-
- if (typeOf(this.options.grid) == 'number') this.options.grid = {
- x: this.options.grid,
- y: this.options.grid
- };
-
- var events = {
- mousemove: this.bound.check,
- mouseup: this.bound.cancel
- };
- events[this.selection] = this.bound.eventStop;
- this.document.addEvents(events);
- },
-
- check: function(event){
- if (this.options.preventDefault) event.preventDefault();
- var distance = Math.round(Math.sqrt(Math.pow(event.page.x - this.mouse.start.x, 2) + Math.pow(event.page.y - this.mouse.start.y, 2)));
- if (distance > this.options.snap){
- this.cancel();
- this.document.addEvents({
- mousemove: this.bound.drag,
- mouseup: this.bound.stop
- });
- this.fireEvent('start', [this.element, event]).fireEvent('snap', this.element);
- }
- },
-
- drag: function(event){
- var options = this.options;
-
- if (options.preventDefault) event.preventDefault();
- this.mouse.now = event.page;
-
- for (var z in options.modifiers){
- if (!options.modifiers[z]) continue;
- this.value.now[z] = this.mouse.now[z] - this.mouse.pos[z];
-
- if (options.invert) this.value.now[z] *= -1;
-
- if (options.limit && this.limit[z]){
- if ((this.limit[z][1] || this.limit[z][1] === 0) && (this.value.now[z] > this.limit[z][1])){
- this.value.now[z] = this.limit[z][1];
- } else if ((this.limit[z][0] || this.limit[z][0] === 0) && (this.value.now[z] < this.limit[z][0])){
- this.value.now[z] = this.limit[z][0];
- }
- }
-
- if (options.grid[z]) this.value.now[z] -= ((this.value.now[z] - (this.limit[z][0]||0)) % options.grid[z]);
-
- if (options.style) this.element.setStyle(options.modifiers[z], this.value.now[z] + options.unit);
- else this.element[options.modifiers[z]] = this.value.now[z];
- }
-
- this.fireEvent('drag', [this.element, event]);
- },
-
- cancel: function(event){
- this.document.removeEvents({
- mousemove: this.bound.check,
- mouseup: this.bound.cancel
- });
- if (event){
- this.document.removeEvent(this.selection, this.bound.eventStop);
- this.fireEvent('cancel', this.element);
- }
- },
-
- stop: function(event){
- var events = {
- mousemove: this.bound.drag,
- mouseup: this.bound.stop
- };
- events[this.selection] = this.bound.eventStop;
- this.document.removeEvents(events);
- if (event) this.fireEvent('complete', [this.element, event]);
- }
-
-});
-
-Element.implement({
-
- makeResizable: function(options){
- var drag = new Drag(this, Object.merge({
- modifiers: {
- x: 'width',
- y: 'height'
- }
- }, options));
-
- this.store('resizer', drag);
- return drag.addEvent('drag', function(){
- this.fireEvent('resize', drag);
- }.bind(this));
- }
-
-});
-
-
-/*
----
-
-script: Drag.Move.js
-
-name: Drag.Move
-
-description: A Drag extension that provides support for the constraining of draggables to containers and droppables.
-
-license: MIT-style license
-
-authors:
- - Valerio Proietti
- - Tom Occhinno
- - Jan Kassens
- - Aaron Newton
- - Scott Kyle
-
-requires:
- - Core/Element.Dimensions
- - Drag
-
-provides: [Drag.Move]
-
-...
-*/
-
-Drag.Move = new Class({
-
- Extends: Drag,
-
- options: {/*
- onEnter: function(thisElement, overed){},
- onLeave: function(thisElement, overed){},
- onDrop: function(thisElement, overed, event){},*/
- droppables: [],
- container: false,
- precalculate: false,
- includeMargins: true,
- checkDroppables: true
- },
-
- initialize: function(element, options){
- this.parent(element, options);
- element = this.element;
-
- this.droppables = $$(this.options.droppables);
- this.setContainer(this.options.container);
-
- if (this.options.style){
- if (this.options.modifiers.x == 'left' && this.options.modifiers.y == 'top'){
- var parent = element.getOffsetParent(),
- styles = element.getStyles('left', 'top');
- if (parent && (styles.left == 'auto' || styles.top == 'auto')){
- element.setPosition(element.getPosition(parent));
- }
- }
-
- if (element.getStyle('position') == 'static') element.setStyle('position', 'absolute');
- }
-
- 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();
-
- if (this.options.precalculate){
- this.positions = this.droppables.map(function(el){
- return el.getCoordinates();
- });
- }
-
- this.parent(event);
- },
-
- calculateLimit: function(){
- var element = this.element,
- container = this.container,
-
- offsetParent = document.id(element.getOffsetParent()) || document.body,
- containerCoordinates = container.getCoordinates(offsetParent),
- elementMargin = {},
- elementBorder = {},
- containerMargin = {},
- containerBorder = {},
- offsetParentPadding = {};
-
- ['top', 'right', 'bottom', 'left'].each(function(pad){
- elementMargin[pad] = element.getStyle('margin-' + pad).toInt();
- elementBorder[pad] = element.getStyle('border-' + pad).toInt();
- containerMargin[pad] = container.getStyle('margin-' + pad).toInt();
- containerBorder[pad] = container.getStyle('border-' + pad).toInt();
- offsetParentPadding[pad] = offsetParent.getStyle('padding-' + pad).toInt();
- }, this);
-
- var width = element.offsetWidth + elementMargin.left + elementMargin.right,
- height = element.offsetHeight + elementMargin.top + elementMargin.bottom,
- left = 0,
- top = 0,
- right = containerCoordinates.right - containerBorder.right - width,
- bottom = containerCoordinates.bottom - containerBorder.bottom - height;
-
- if (this.options.includeMargins){
- left += elementMargin.left;
- top += elementMargin.top;
- } else {
- right += elementMargin.right;
- bottom += elementMargin.bottom;
- }
-
- if (element.getStyle('position') == 'relative'){
- var coords = element.getCoordinates(offsetParent);
- coords.left -= element.getStyle('left').toInt();
- coords.top -= element.getStyle('top').toInt();
-
- left -= coords.left;
- top -= coords.top;
- if (container.getStyle('position') != 'relative'){
- left += containerBorder.left;
- top += containerBorder.top;
- }
- right += elementMargin.left - coords.left;
- bottom += elementMargin.top - coords.top;
-
- if (container != offsetParent){
- left += containerMargin.left + offsetParentPadding.left;
- 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;
- top -= elementMargin.top;
- if (container != offsetParent){
- left += containerCoordinates.left + containerBorder.left;
- top += containerCoordinates.top + containerBorder.top;
- }
- }
-
- return {
- x: [left, right],
- y: [top, bottom]
- };
- },
-
- getDroppableCoordinates: function(element){
- var position = element.getCoordinates();
- if (element.getStyle('position') == 'fixed'){
- var scroll = window.getScroll();
- position.left += scroll.x;
- position.right += scroll.x;
- position.top += scroll.y;
- position.bottom += scroll.y;
- }
- return position;
- },
-
- checkDroppables: function(){
- var overed = this.droppables.filter(function(el, i){
- el = this.positions ? this.positions[i] : this.getDroppableCoordinates(el);
- var now = this.mouse.now;
- return (now.x > el.left && now.x < el.right && now.y < el.bottom && now.y > el.top);
- }, this).getLast();
-
- if (this.overed != overed){
- if (this.overed) this.fireEvent('leave', [this.element, this.overed]);
- if (overed) this.fireEvent('enter', [this.element, overed]);
- this.overed = overed;
- }
- },
-
- drag: function(event){
- this.parent(event);
- if (this.options.checkDroppables && this.droppables.length) this.checkDroppables();
- },
-
- stop: function(event){
- this.checkDroppables();
- this.fireEvent('drop', [this.element, this.overed, event]);
- this.overed = null;
- return this.parent(event);
- }
-
-});
-
-Element.implement({
-
- makeDraggable: function(options){
- var drag = new Drag.Move(this, options);
- this.store('dragger', drag);
- return drag;
- }
-
-});
-
-
-/*
----
-
-script: Sortables.js
-
-name: Sortables
-
-description: Class for creating a drag and drop sorting interface for lists of items.
-
-license: MIT-style license
-
-authors:
- - Tom Occhino
-
-requires:
- - Core/Fx.Morph
- - Drag.Move
-
-provides: [Sortables]
-
-...
-*/
-
-var Sortables = new Class({
-
- Implements: [Events, Options],
-
- options: {/*
- onSort: function(element, clone){},
- onStart: function(element, clone){},
- onComplete: function(element){},*/
- opacity: 1,
- clone: false,
- revert: false,
- handle: false,
- dragOptions: {},
- unDraggableTags: ['button', 'input', 'a', 'textarea', 'select', 'option']
- },
-
- initialize: function(lists, options){
- this.setOptions(options);
-
- this.elements = [];
- this.lists = [];
- this.idle = true;
-
- this.addLists($$(document.id(lists) || lists));
-
- if (!this.options.clone) this.options.revert = false;
- if (this.options.revert) this.effect = new Fx.Morph(null, Object.merge({
- duration: 250,
- link: 'cancel'
- }, this.options.revert));
- },
-
- attach: function(){
- this.addLists(this.lists);
- return this;
- },
-
- detach: function(){
- this.lists = this.removeLists(this.lists);
- return this;
- },
-
- addItems: function(){
- Array.flatten(arguments).each(function(element){
- this.elements.push(element);
- var start = element.retrieve('sortables:start', function(event){
- this.start.call(this, event, element);
- }.bind(this));
- (this.options.handle ? element.getElement(this.options.handle) || element : element).addEvent('mousedown', start);
- }, this);
- return this;
- },
-
- addLists: function(){
- Array.flatten(arguments).each(function(list){
- this.lists.include(list);
- this.addItems(list.getChildren());
- }, this);
- return this;
- },
-
- removeItems: function(){
- return $$(Array.flatten(arguments).map(function(element){
- this.elements.erase(element);
- var start = element.retrieve('sortables:start');
- (this.options.handle ? element.getElement(this.options.handle) || element : element).removeEvent('mousedown', start);
-
- return element;
- }, this));
- },
-
- removeLists: function(){
- return $$(Array.flatten(arguments).map(function(list){
- this.lists.erase(list);
- this.removeItems(list.getChildren());
-
- 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);
- if (typeOf(this.options.clone) == 'function') return this.options.clone.call(this, event, element, this.list);
- var clone = element.clone(true).setStyles({
- margin: 0,
- position: 'absolute',
- visibility: 'hidden',
- width: element.getStyle('width')
- }).addEvent('mousedown', function(event){
- element.fireEvent('mousedown', event);
- });
- //prevent the duplicated radio inputs from unchecking the real one
- if (clone.get('html').test('radio')){
- clone.getElements('input[type=radio]').each(function(input, i){
- input.set('name', 'clone_' + i);
- if (input.get('checked')) element.getElements('input[type=radio]')[i].set('checked', true);
- });
- }
-
- return clone.inject(this.list).setPosition(this.getDroppableCoordinates(this.element));
- },
-
- getDroppables: function(){
- var droppables = this.list.getChildren().erase(this.clone).erase(this.element);
- if (!this.options.constrain) droppables.append(this.lists).erase(this.list);
- return droppables;
- },
-
- insert: function(dragging, element){
- var where = 'inside';
- if (this.lists.contains(element)){
- this.list = element;
- this.drag.droppables = this.getDroppables();
- } else {
- where = this.element.getAllPrevious().contains(element) ? 'before' : 'after';
- }
- this.element.inject(element, where);
- this.fireEvent('sort', [this.element, this.clone]);
- },
-
- start: function(event, element){
- if (
- !this.idle ||
- event.rightClick ||
- (!this.options.handle && this.options.unDraggableTags.contains(event.target.get('tag')))
- ) return;
-
- this.idle = false;
- this.element = element;
- this.opacity = element.getStyle('opacity');
- this.list = element.getParent();
- this.clone = this.getClone(event, element);
-
- this.drag = new Drag.Move(this.clone, Object.merge({
-
- droppables: this.getDroppables()
- }, this.options.dragOptions)).addEvents({
- onSnap: function(){
- event.stop();
- this.clone.setStyle('visibility', 'visible');
- this.element.setStyle('opacity', this.options.opacity || 0);
- this.fireEvent('start', [this.element, this.clone]);
- }.bind(this),
- onEnter: this.insert.bind(this),
- onCancel: this.end.bind(this),
- onComplete: this.end.bind(this)
- });
-
- this.clone.inject(this.element, 'before');
- this.drag.start(event);
- },
-
- 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.getDroppableCoordinates(clone));
-
- var destroy = function(){
- this.removeEvent('cancel', destroy);
- clone.destroy();
- self.reset();
- };
-
- this.effect.element = clone;
- this.effect.start({
- top: pos.top,
- left: pos.left,
- width: dim.width,
- height: dim.height,
- opacity: 0.25
- }).addEvent('cancel', destroy).chain(destroy);
- } else {
- this.clone.destroy();
- self.reset();
- }
-
- },
-
- reset: function(){
- this.idle = true;
- this.fireEvent('complete', this.element);
- },
-
- serialize: function(){
- var params = Array.link(arguments, {
- modifier: Type.isFunction,
- index: function(obj){
- return obj != null;
- }
- });
- var serial = this.lists.map(function(list){
- return list.getChildren().map(params.modifier || function(element){
- return element.get('id');
- }, this);
- }, this);
-
- var index = params.index;
- if (this.lists.length == 1) index = 0;
- return (index || index === 0) && index >= 0 && index < this.lists.length ? serial[index] : serial;
- }
-
-});
-
-
/*
---
@@ -3161,7 +3053,6 @@ Request.JSONP = new Class({
Request.JSONP.counter = 0;
Request.JSONP.request_map = {};
-
/*
---
@@ -3214,3 +3105,120 @@ Request.implement({
});
+/*
+---
+
+script: Date.Extras.js
+
+name: Date.Extras
+
+description: Extends the Date native object to include extra methods (on top of those in Date.js).
+
+license: MIT-style license
+
+authors:
+ - Aaron Newton
+ - Scott Kyle
+
+requires:
+ - Date
+
+provides: [Date.Extras]
+
+...
+*/
+
+Date.implement({
+
+ timeDiffInWords: function(to){
+ return Date.distanceOfTimeInWords(this, to || new Date);
+ },
+
+ timeDiff: function(to, separator){
+ if (to == null) to = new Date;
+ var delta = ((to - this) / 1000).floor().abs();
+
+ var vals = [],
+ durations = [60, 60, 24, 365, 0],
+ names = ['s', 'm', 'h', 'd', 'y'],
+ value, duration;
+
+ for (var item = 0; item < durations.length; item++){
+ if (item && !delta) break;
+ value = delta;
+ if ((duration = durations[item])){
+ value = (delta % duration);
+ delta = (delta / duration).floor();
+ }
+ vals.unshift(value + (names[item] || ''));
+ }
+
+ return vals.join(separator || ':');
+ }
+
+}).extend({
+
+ distanceOfTimeInWords: function(from, to){
+ return Date.getTimePhrase(((to - from) / 1000).toInt());
+ },
+
+ getTimePhrase: function(delta){
+ var suffix = (delta < 0) ? 'Until' : 'Ago';
+ if (delta < 0) delta *= -1;
+
+ var units = {
+ minute: 60,
+ hour: 60,
+ day: 24,
+ week: 7,
+ month: 52 / 12,
+ year: 12,
+ eon: Infinity
+ };
+
+ var msg = 'lessThanMinute';
+
+ for (var unit in units){
+ var interval = units[unit];
+ if (delta < 1.5 * interval){
+ if (delta > 0.75 * interval) msg = unit;
+ break;
+ }
+ delta /= interval;
+ msg = unit + 's';
+ }
+
+ delta = delta.round();
+ return Date.getMsg(msg + suffix, delta).substitute({delta: delta});
+ }
+
+}).defineParsers(
+
+ {
+ // "today", "tomorrow", "yesterday"
+ re: /^(?:tod|tom|yes)/i,
+ handler: function(bits){
+ var d = new Date().clearTime();
+ switch (bits[0]){
+ case 'tom': return d.increment();
+ case 'yes': return d.decrement();
+ default: return d;
+ }
+ }
+ },
+
+ {
+ // "next Wednesday", "last Thursday"
+ re: /^(next|last) ([a-z]+)$/i,
+ handler: function(bits){
+ var d = new Date().clearTime();
+ var day = d.getDay();
+ var newDay = Date.parseDay(bits[2], true);
+ var addDays = newDay - day;
+ if (newDay <= day) addDays += 7;
+ if (bits[1] == 'last') addDays -= 7;
+ return d.set('date', d.getDate() + addDays);
+ }
+ }
+
+).alias('timeAgoInWords', 'timeDiffInWords');