Browse files

* Dropping Core 1.2 compat

  • Loading branch information...
1 parent 1f2a739 commit 0cda545a7f9c97053e22aa30a8c9fb98b50cf529 @cpojer cpojer committed Oct 9, 2010
Showing with 2 additions and 431 deletions.
  1. +2 −431 Demos/mootools-core.js
View
433 Demos/mootools-core.js
@@ -157,9 +157,7 @@ var Type = this.Type = function(name, object){
object.prototype.$family = (function(){
return lower;
}).hide();
- //<1.2compat>
- object.type = typeCheck;
- //</1.2compat>
+
}
}
@@ -390,125 +388,7 @@ String.extend('generateUID', function(){
return (UID++).toString(36);
});
-//<1.2compat>
-var Hash = this.Hash = new Type('Hash', function(object){
- if (typeOf(object) == 'hash') object = Object.clone(object.getClean());
- for (var key in object) this[key] = object[key];
- return this;
-});
-
-Hash.implement({
-
- forEach: function(fn, bind){
- Object.forEach(this, fn, bind);
- },
-
- getClean: function(){
- var clean = {};
- for (var key in this){
- if (this.hasOwnProperty(key)) clean[key] = this[key];
- }
- return clean;
- },
-
- getLength: function(){
- var length = 0;
- for (var key in this){
- if (this.hasOwnProperty(key)) length++;
- }
- return length;
- }
-
-});
-
-Hash.alias('each', 'forEach');
-
-Object.type = Type.isObject;
-
-var Native = this.Native = function(properties){
- return new Type(properties.name, properties.initialize);
-};
-
-Native.type = Type.type;
-
-Native.implement = function(objects, methods){
- for (var i = 0; i < objects.length; i++) objects[i].implement(methods);
- return Native;
-};
-
-var arrayType = Array.type;
-Array.type = function(item){
- return instanceOf(item, Array) || arrayType(item);
-};
-
-this.$A = function(item){
- return Array.from(item).slice();
-};
-
-this.$arguments = function(i){
- return function(){
- return arguments[i];
- };
-};
-
-this.$chk = function(obj){
- return !!(obj || obj === 0);
-};
-
-this.$clear = function(timer){
- clearTimeout(timer);
- clearInterval(timer);
- return null;
-};
-
-this.$defined = function(obj){
- return (obj != null);
-};
-
-this.$each = function(iterable, fn, bind){
- var type = typeOf(iterable);
- ((type == 'arguments' || type == 'collection' || type == 'array' || type == 'elements') ? Array : Object).each(iterable, fn, bind);
-};
-
-this.$empty = function(){};
-
-this.$extend = function(original, extended){
- return Object.append(original, extended);
-};
-
-this.$H = function(object){
- return new Hash(object);
-};
-
-this.$merge = function(){
- var args = Array.slice(arguments);
- args.unshift({});
- return Object.merge.apply(null, args);
-};
-
-this.$lambda = Function.from;
-this.$mixin = Object.merge;
-this.$random = Number.random;
-this.$splat = Array.from;
-this.$time = Date.now;
-
-this.$type = function(object){
- var type = typeOf(object);
- if (type == 'elements') return 'array';
- return (type == 'null') ? false : type;
-};
-
-this.$unlink = function(object){
- switch (typeOf(object)){
- case 'object': return Object.clone(object);
- case 'array': return Array.clone(object);
- case 'hash': return new Hash(object);
- default: return object;
- }
-};
-
-//</1.2compat>
})();
@@ -680,15 +560,7 @@ Array.implement({
});
-//<1.2compat>
-Array.alias('extend', 'append');
-
-var $pick = function(){
- return Array.from(arguments).pick();
-};
-
-//</1.2compat>
/*
@@ -759,54 +631,7 @@ Function.implement({
});
-//<1.2compat>
-delete Function.prototype.bind;
-
-Function.implement({
-
- create: function(options){
- var self = this;
- options = options || {};
- return function(event){
- var args = options.arguments;
- args = (args != null) ? Array.from(args) : Array.slice(arguments, (options.event) ? 1 : 0);
- if (options.event) args = [event || window.event].extend(args);
- var returns = function(){
- return self.apply(options.bind || null, args);
- };
- if (options.delay) return setTimeout(returns, options.delay);
- if (options.periodical) return setInterval(returns, options.periodical);
- if (options.attempt) return Function.attempt(returns);
- return returns();
- };
- },
-
- bind: function(bind, args){
- var self = this;
- if (args != null) args = Array.from(args);
- return function(){
- return self.apply(bind, args || arguments);
- };
- },
-
- bindWithEvent: function(bind, args){
- var self = this;
- if (args != null) args = Array.from(args);
- return function(event){
- return self.apply(bind, (args == null) ? arguments : [event].concat(args));
- };
- },
-
- run: function(args, bind){
- return this.apply(bind, Array.from(args));
- }
-
-});
-
-var $try = Function.attempt;
-
-//</1.2compat>
/*
@@ -1146,67 +971,7 @@ try {
});
}
-//<1.2compat>
-
-if (Browser.Platform.ios) Browser.Platform.ipod = true;
-
-Browser.Engine = {};
-
-var setEngine = function(name, version){
- Browser.Engine.name = name;
- Browser.Engine[name + version] = true;
- Browser.Engine.version = version;
-};
-
-if (Browser.ie){
- Browser.Engine.trident = true;
-
- switch (Browser.version){
- case 6: setEngine('trident', 4); break;
- case 7: setEngine('trident', 5); break;
- case 8: setEngine('trident', 6);
- }
-}
-
-if (Browser.firefox){
- Browser.Engine.gecko = true;
-
- if (Browser.version >= 3) setEngine('gecko', 19);
- else setEngine('gecko', 18);
-}
-
-if (Browser.safari || Browser.chrome){
- Browser.Engine.webkit = true;
-
- switch (Browser.version){
- case 2: setEngine('webkit', 419); break;
- case 3: setEngine('webkit', 420); break;
- case 4: setEngine('webkit', 525);
- }
-}
-
-if (Browser.opera){
- Browser.Engine.presto = true;
-
- if (Browser.version >= 9.6) setEngine('presto', 960);
- else if (Browser.version >= 9.5) setEngine('presto', 950);
- else setEngine('presto', 925);
-}
-
-if (Browser.name == 'unknown'){
- switch ((ua.match(/(?:webkit|khtml|gecko)/) || [])[0]){
- case 'webkit':
- case 'khtml':
- Browser.Engine.webkit = true;
- break;
- case 'gecko':
- Browser.Engine.gecko = true;
- }
-}
-this.$exec = Browser.exec;
-
-//</1.2compat>
})();
@@ -2417,11 +2182,7 @@ if (!Browser.Element){
Element.Constructors = {};
-//<1.2compat>
-
-Element.Constructors = new Hash;
-//</1.2compat>
var IFrame = new Type('IFrame', function(){
var params = Array.link(arguments, {
@@ -2633,52 +2394,7 @@ Window.implement({
});
-//<1.2compat>
-
-(function(search, find, match){
- this.Selectors = {};
- var pseudos = this.Selectors.Pseudo = new Hash();
-
- var addSlickPseudos = function(){
- for (var name in pseudos) if (pseudos.hasOwnProperty(name)){
- Slick.definePseudo(name, pseudos[name]);
- delete pseudos[name];
- }
- };
-
- Slick.search = function(context, expression, append){
- addSlickPseudos();
- return search.call(this, context, expression, append);
- };
-
- Slick.find = function(context, expression){
- addSlickPseudos();
- return find.call(this, context, expression);
- };
-
- Slick.match = function(node, selector){
- addSlickPseudos();
- return match.call(this, node, selector);
- };
-
-})(Slick.search, Slick.find, Slick.match);
-
-if (window.$$ == null) Window.implement('$$', function(selector){
- var elements = new Elements;
- if (arguments.length == 1 && typeof selector == 'string') return Slick.search(this.document, selector, elements);
- var args = Array.flatten(arguments);
- for (var i = 0, l = args.length; i < l; i++){
- var item = args[i];
- switch (typeOf(item)){
- case 'element': elements.push(item); break;
- case 'string': Slick.search(this.document, item, elements);
- }
- }
- return elements;
-});
-
-//</1.2compat>
if (window.$$ == null) Window.implement('$$', function(selector){
if (arguments.length == 1){
@@ -2757,29 +2473,7 @@ var inserters = {
inserters.inside = inserters.bottom;
-//<1.2compat>
-
-Object.each(inserters, function(inserter, where){
- where = where.capitalize();
-
- var methods = {};
-
- methods['inject' + where] = function(el){
- inserter(this, document.id(el, true));
- return this;
- };
-
- methods['grab' + where] = function(el){
- inserter(document.id(el, true), this);
- return this;
- };
-
- Element.implement(methods);
-
-});
-
-//</1.2compat>
var injectCombinator = function(expression, combinator){
if (!expression) return combinator;
@@ -3051,13 +2745,7 @@ var contains = {contains: function(element){
if (!document.contains) Document.implement(contains);
if (!document.createElement('div').contains) Element.implement(contains);
-//<1.2compat>
-
-Element.implement('hasChild', function(element){
- return this !== element && this.contains(element);
-});
-//</1.2compat>
[Element, Window, Document].invoke('implement', {
@@ -3112,11 +2800,7 @@ if (window.attachEvent && !window.addEventListener) window.addListener('unload',
Element.Properties = {};
-//<1.2compat>
-
-Element.Properties = new Hash;
-//</1.2compat>
Element.Properties.style = {
@@ -3347,11 +3031,7 @@ Element.Styles = {
zIndex: '@', 'zoom': '@', fontWeight: '@', textIndent: '@px', opacity: '@'
};
-//<1.2compat>
-
-Element.Styles = new Hash(Element.Styles);
-//</1.2compat>
Element.ShortStyles = {margin: {}, padding: {}, border: {}, borderWidth: {}, borderStyle: {}, borderColor: {}};
@@ -3750,95 +3430,7 @@ Object.extend({
});
-//<1.2compat>
-
-Hash.implement({
-
- has: Object.prototype.hasOwnProperty,
-
- keyOf: function(value){
- return Object.keyOf(this, value);
- },
-
- hasValue: function(value){
- return Object.contains(this, value);
- },
-
- extend: function(properties){
- Hash.each(properties || {}, function(value, key){
- Hash.set(this, key, value);
- }, this);
- return this;
- },
-
- combine: function(properties){
- Hash.each(properties || {}, function(value, key){
- Hash.include(this, key, value);
- }, this);
- return this;
- },
-
- erase: function(key){
- if (this.hasOwnProperty(key)) delete this[key];
- return this;
- },
-
- get: function(key){
- return (this.hasOwnProperty(key)) ? this[key] : null;
- },
-
- set: function(key, value){
- if (!this[key] || this.hasOwnProperty(key)) this[key] = value;
- return this;
- },
-
- empty: function(){
- Hash.each(this, function(value, key){
- delete this[key];
- }, this);
- return this;
- },
-
- include: function(key, value){
- if (this[key] == null) this[key] = value;
- return this;
- },
-
- map: function(fn, bind){
- return new Hash(Object.map(this, fn, bind));
- },
-
- filter: function(fn, bind){
- return new Hash(Object.filter(this, fn, bind));
- },
-
- every: function(fn, bind){
- return Object.every(this, fn, bind);
- },
-
- some: function(fn, bind){
- return Object.some(this, fn, bind);
- },
-
- getKeys: function(){
- return Object.keys(this);
- },
-
- getValues: function(){
- return Object.values(this);
- },
-
- toQueryString: function(base){
- return Object.toQueryString(this, base);
- }
-
-});
-
-Hash.extend = Object.append;
-
-Hash.alias({indexOf: 'keyOf', contains: 'hasValue'});
-//</1.2compat>
/*
@@ -3950,11 +3542,7 @@ Event.Keys = {
'delete': 46
};
-//<1.2compat>
-Event.Keys = new Hash(Event.Keys);
-
-//</1.2compat>
Event.implement({
@@ -4151,11 +3739,7 @@ Element.Events = {
};
-//<1.2compat>
-
-Element.Events = new Hash(Element.Events);
-//</1.2compat>
})();
@@ -4438,9 +4022,7 @@ this.Events = new Class({
addEvent: function(type, fn, internal){
type = removeOn(type);
- /*<1.2compat>*/
- if (fn == $empty) return this;
- /*</1.2compat>*/
+
this.$events[type] = (this.$events[type] || []).include(fn);
if (internal) fn.internal = true;
@@ -4899,11 +4481,7 @@ Fx.CSS.Parsers = {
};
-//<1.2compat>
-Fx.CSS.Parsers = new Hash(Fx.CSS.Parsers);
-
-//</1.2compat>
/*
@@ -5031,14 +4609,7 @@ provides: JSON
if (!this.JSON) this.JSON = {};
-//<1.2compat>
-
-JSON = new Hash({
- stringify: JSON.stringify,
- parse: JSON.parse
-});
-//</1.2compat>
Object.append(JSON, {

0 comments on commit 0cda545

Please sign in to comment.