Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: ibolmo/mootools-1-vs-2
base: 1.3.x
...
head fork: ibolmo/mootools-1-vs-2
compare: 2.y.x
Checking mergeability… Don't worry, you can still create the pull request.
  • 3 commits
  • 5 files changed
  • 0 commit comments
  • 1 contributor
View
18 Database.js
@@ -19,7 +19,7 @@ provides: Database
...
*/
-(function(){
+define(‘Database’, [‘Class’, ‘Options’, ‘Events’, ‘Chain’, ‘Function’, ‘Object’, ‘Array’], function(Class, Options, Events, Chain, Function, Object, Array){
var errorTypes = {
1: 'unknown',
@@ -74,7 +74,7 @@ provides: Database
var range = {};
this.each(function(v, k){
range[k] = v;
- }, this, IDBKeyRange.bound(start, end, false, false), fn.bind(bind, range));
+ }, this, IDBKeyRange.bound(start, end, false, false), Function.bind(fn, bind, range));
return this;
},
@@ -104,13 +104,13 @@ provides: Database
return object = revived;
};
- [
+ Array.forEach([
{ type: 'IDBObjectStore', methods: IDBMethods },
{ type: 'IDBIndex', methods: Object.subset(IDBMethods, ['retrieve', 'each', 'getRange', 'getKeys', 'getValues']) }
- ].each(function(object){
+ ], function(object){
var global = window[object.type];
global.extend = Object.extend;
- new Type(object.type, global);
+ //new Type(object.type, global);
global.implement(new Chain).implement(Object.map(object.methods, function(method){
return function(){
return method.apply(((this.objectStore || this).inactive) ? revive(this) : this, arguments);
@@ -208,12 +208,12 @@ provides: Database
setVersion: function(version, fn) {
this.previousVersion = this.db.version;
- this.db.setVersion(version || this.db.version).onsuccess = (fn || function(){}).bind(this);
+ this.db.setVersion(version || this.db.version).onsuccess = Function.bind(fn || function(){}, this);
return this;
},
create: function(name, options){
- return(!this.db.objectStoreNames.contains(name)) ? this.db.createObjectStore(name, options || {}) : this.getObject(name);
+ return(!Array.contains(this.db.objectStoreNames, name)) ? this.db.createObjectStore(name, options || {}) : this.getObject(name);
},
getObject: function(name){
@@ -232,4 +232,6 @@ provides: Database
});
-})();
+return Database;
+
+});
View
3  Examples/001.js
@@ -1,3 +1,5 @@
+require([‘Request’], function(Request){
+
var myRequest = new Request({
url: 'image.jpg',
onProgress: function(event, xhr){
@@ -9,3 +11,4 @@ var myRequest = new Request({
myRequest.send();
+});
View
8 Examples/002.js
@@ -1,4 +1,6 @@
-var myElement = document.id('myElement');
+require([‘DOM/Node’, ‘Request’], function(Node, Request){
+
+var myElement = Node.select('myElement');
var myRequest = new Request({
url: 'getMyText.php',
@@ -14,7 +16,9 @@ var myRequest = new Request({
}
});
-document.id('myLink').addEvent('click', function(event){
+Node.select('myLink').addEvent('click', function(event){
event.stop();
myRequest.send('userid=' + this.get('data-userid'));
});
+
+});
View
80 Request.js
@@ -3,23 +3,19 @@
name: Request
-description: Powerful all purpose Request Class. Uses XMLHTTPRequest.
+description: Powerful all purpose Request Class. Uses XMLHTTPRequest. Now using 2.0.
license: MIT-style license.
-requires: [Object, Element, Chain, Events, Options, Browser]
-
-provides: Request
-
...
*/
-(function(){
+define(‘Request’, [‘typeOf’, ‘Object’, ‘DOM/Node’, ‘Chain’, ‘Events’, ‘Options’, ‘Browser’], function(typeOf, Object, Node, Chain, Events, Options, Browser){
var empty = function(){},
progressSupport = ('onprogress' in new Browser.Request);
-var Request = this.Request = new Class({
+var Request = new Class({
Implements: [Chain, Events, Options],
@@ -66,10 +62,10 @@ var Request = this.Request = new Class({
if (xhr.readyState != 4 || !this.running) return;
this.running = false;
this.status = 0;
- Function.attempt(function(){
+ Function.attempt(Function.bind(function(){
var status = xhr.status;
this.status = (status == 1223) ? 204 : status;
- }.bind(this));
+ }, this));
xhr.onreadystatechange = empty;
if (progressSupport) xhr.onprogress = xhr.onloadstart = empty;
clearTimeout(this.timer);
@@ -92,7 +88,7 @@ var Request = this.Request = new Class({
processScripts: function(text){
if (this.options.evalResponse || (/(ecma|java)script/).test(this.getHeader('Content-type'))) return Browser.exec(text);
- return text.stripScripts(this.options.evalScripts);
+ return String.stripScripts(text, this.options.evalScripts);
},
success: function(text, xml){
@@ -129,16 +125,16 @@ var Request = this.Request = new Class({
},
getHeader: function(name){
- return Function.attempt(function(){
+ return Function.attempt(Function.bind(function(){
return this.xhr.getResponseHeader(name);
- }.bind(this));
+ }, this));
},
check: function(){
if (!this.running) return true;
switch (this.options.link){
case 'cancel': this.cancel(); return true;
- case 'chain': this.chain(this.caller.pass(arguments, this)); return false;
+ case 'chain': this.chain(Function.pass(this.caller, arguments, this)); return false;
}
return false;
},
@@ -157,7 +153,7 @@ var Request = this.Request = new Class({
var data = options.data, url = String(options.url), method = options.method.toLowerCase();
switch (typeOf(data)){
- case 'element': data = document.id(data).toQueryString(); break;
+ case 'element': data = DOM.Element.toQueryString(data); break;
case 'object': case 'hash': data = Object.toQueryString(data);
}
@@ -166,13 +162,13 @@ var Request = this.Request = new Class({
data = (data) ? format + '&' + data : format;
}
- if (this.options.emulation && !['get', 'post'].contains(method)){
+ if (this.options.emulation && !Array.contains(['get', 'post'], method)){
var _method = '_method=' + method;
data = (data) ? _method + '&' + data : _method;
method = 'post';
}
- if (this.options.urlEncoded && ['post', 'put'].contains(method)){
+ if (this.options.urlEncoded && Array.contains(['post', 'put'], method)){
var encoding = (this.options.encoding) ? '; charset=' + this.options.encoding : '';
this.headers['Content-type'] = 'application/x-www-form-urlencoded' + encoding;
}
@@ -183,17 +179,17 @@ var Request = this.Request = new Class({
if (trimPosition > -1 && (trimPosition = url.indexOf('#')) > -1) url = url.substr(0, trimPosition);
if (this.options.noCache)
- url += (url.contains('?') ? '&' : '?') + String.uniqueID();
+ url += (String.contains(url, '?') ? '&' : '?') + String.uniqueID();
if (data && method == 'get'){
- url += (url.contains('?') ? '&' : '?') + data;
+ url += (String.contains(url, '?') ? '&' : '?') + data;
data = null;
}
var xhr = this.xhr;
if (progressSupport){
- xhr.onloadstart = this.loadstart.bind(this);
- xhr.onprogress = this.progress.bind(this);
+ xhr.onloadstart = Function.bind(this.loadstart, this);
+ xhr.onprogress = Function.bind(this.progress, this);
}
xhr.open(method.toUpperCase(), url, this.options.async, this.options.user, this.options.password);
@@ -201,7 +197,7 @@ var Request = this.Request = new Class({
xhr.onreadystatechange = this.onStateChange.bind(this);
- Object.each(this.headers, function(value, key){
+ Object.forEach(this.headers, function(value, key){
try {
xhr.setRequestHeader(key, value);
} catch (e){
@@ -212,7 +208,7 @@ var Request = this.Request = new Class({
this.fireEvent('request');
xhr.send(data);
if (!this.options.async) this.onStateChange();
- if (this.options.timeout) this.timer = this.timeout.delay(this.options.timeout, this);
+ if (this.options.timeout) this.timer = setTimeout(this.timeout, this.options.timeout, this);
return this;
},
@@ -232,7 +228,7 @@ var Request = this.Request = new Class({
});
var methods = {};
-['get', 'post', 'put', 'delete', 'GET', 'POST', 'PUT', 'DELETE'].each(function(method){
+Array.forEach(['get', 'post', 'put', 'delete', 'GET', 'POST', 'PUT', 'DELETE'], function(method){
methods[method] = function(data){
var object = {
method: method
@@ -244,28 +240,22 @@ var methods = {};
Request.implement(methods);
-Element.Properties.send = {
-
- set: function(options){
- var send = this.get('send').cancel();
- send.setOptions(options);
- return this;
- },
-
- get: function(){
- var send = this.retrieve('send');
- if (!send){
- send = new Request({
- data: this, link: 'cancel', method: this.get('method') || 'post', url: this.get('action')
- });
- this.store('send', send);
- }
- return send;
+Node.Element.defineSetter('send', function(options){
+ var send = this.get('send').cancel();
+ send.setOptions(options);
+ return this;
+}).defineGetter('send', function(){
+ var send = this.retrieve('send');
+ if (!send){
+ send = new Request({
+ data: this, link: 'cancel', method: this.get('method') || 'post', url: this.get('action')
+ });
+ this.store('send', send);
}
+ return send;
+});
-};
-
-Element.implement({
+Node.Element.implement({
send: function(url){
var sender = this.get('send');
@@ -275,4 +265,6 @@ Element.implement({
});
-})();
+return Request;
+
+});
View
15 ScrollSpy.js
@@ -7,14 +7,11 @@ authors:
license:
- MIT-style license
-
-requires:
- core/1.2.1: '*'
-
-provides:
- - ScrollSpy
...
*/
+
+define(‘ScrollSpy’, [‘Class’, ‘Options’ ‘Events’, ‘DOM/Node’], function(Class, Options, Events, Node){
+
var ScrollSpy = new Class({
/* implements */
@@ -37,7 +34,7 @@ var ScrollSpy = new Class({
initialize: function(options) {
/* set options */
this.setOptions(options);
- this.container = document.id(this.options.container);
+ this.container = Node.select(this.options.container);
this.enters = this.leaves = 0;
this.inside = false;
@@ -89,3 +86,7 @@ var ScrollSpy = new Class({
this.start();
}
});
+
+return ScrollSpy;
+
+});

No commit comments for this range

Something went wrong with that request. Please try again.