mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-20 22:39:50 -05:00
Move Base.capitalize() and Base.read() out of Bootstrap core into Paper.js, so normal Bootstrap libs can work with it too.
This commit is contained in:
parent
352b3f0d40
commit
8e25a951bc
2 changed files with 35 additions and 28 deletions
27
lib/bootstrap.js
vendored
27
lib/bootstrap.js
vendored
|
@ -188,10 +188,12 @@ var Base = this.Base = new function() {
|
|||
inject: function(src) {
|
||||
if (src) {
|
||||
var proto = this.prototype,
|
||||
base = proto.__proto__ && proto.__proto__.constructor;
|
||||
base = proto.__proto__ && proto.__proto__.constructor,
|
||||
statics = src.statics == true ? src : src.statics;
|
||||
if (statics != src)
|
||||
inject(proto, src, src.enumerable, base && base.prototype,
|
||||
src.preserve, src.generics && this);
|
||||
inject(this, src.statics, true, base, src.preserve);
|
||||
inject(this, statics, true, base, src.preserve);
|
||||
}
|
||||
for (var i = 1, l = arguments.length; i < l; i++)
|
||||
this.inject(arguments[i]);
|
||||
|
@ -257,27 +259,6 @@ var Base = this.Base = new function() {
|
|||
return null;
|
||||
},
|
||||
|
||||
read: function(args, index, length) {
|
||||
var index = index || 0, length = length || args.length - index;
|
||||
if (length <= 1) {
|
||||
var arg = args[index];
|
||||
// Return null when nothing was provided
|
||||
if (arg instanceof this || arg == null)
|
||||
return arg;
|
||||
}
|
||||
var obj = new this(this.dont);
|
||||
obj = obj.initialize.apply(obj, index > 0 || length < args.length
|
||||
? slice.call(args, index, index + length)
|
||||
: args) || obj;
|
||||
return obj;
|
||||
},
|
||||
|
||||
capitalize: function(str) {
|
||||
return str.replace(/\b[a-z]/g, function(match) {
|
||||
return match.toUpperCase();
|
||||
});
|
||||
},
|
||||
|
||||
stop: {}
|
||||
}
|
||||
});
|
||||
|
|
26
src/paper.js
26
src/paper.js
|
@ -12,6 +12,32 @@ this.install = function(scope) {
|
|||
// Inline Base core inside the paper scope first:
|
||||
//#include "../lib/bootstrap.js"
|
||||
|
||||
Base.inject({
|
||||
statics: {
|
||||
read: function(args, index, length) {
|
||||
var index = index || 0, length = length || args.length - index;
|
||||
if (length <= 1) {
|
||||
var arg = args[index];
|
||||
// Return null when nothing was provided
|
||||
if (arg instanceof this || arg == null)
|
||||
return arg;
|
||||
}
|
||||
var obj = new this(this.dont);
|
||||
obj = obj.initialize.apply(obj, index > 0 || length < args.length
|
||||
? slice.call(args, index, index + length)
|
||||
: args) || obj;
|
||||
return obj;
|
||||
},
|
||||
|
||||
capitalize: function(str) {
|
||||
return str.replace(/\b[a-z]/g, function(match) {
|
||||
return match.toUpperCase();
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
//#include "basic/Point.js"
|
||||
//#include "basic/Size.js"
|
||||
//#include "basic/Rectangle.js"
|
||||
|
|
Loading…
Reference in a new issue