Skip to content

Commit

Permalink
Fix inhertitance and allow single require
Browse files Browse the repository at this point in the history
The original inhertitance was naive and it didn't allow for a single
require('extjs-custom') to get the entire library. That is fixed by
letting Ext.js requiring the rest before exporting itself. For class
extending Ext.extend is used.
  • Loading branch information
christiaanwesterbeek committed Nov 28, 2014
1 parent acbaff8 commit 0374ffd
Show file tree
Hide file tree
Showing 9 changed files with 1,231 additions and 1,166 deletions.
33 changes: 31 additions & 2 deletions Ext.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,36 @@ var Ext = { //based on 4.2.1.833 only rewritten to fit node
},
log : console.log,
util: {},
dom : {}
};
dom : {},

/**
* Customized version of Ext's define method to extend a Class
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/create
* http://stackoverflow.com/questions/15192722/javascript-extending-class
*/
extend: function(Parent) {
//define the new class that extends the parent
function F() {
// Call the parent constructor
Parent.apply(this, arguments);
}
// inherit parent
F.prototype = Object.create(Parent.prototype);//alternative: new Parent();

// correct the constructor pointer because it points to the parent
F.prototype.constructor = F;

return F;
}
}

Ext.String = require('./String')(Ext);
Ext.util.Format = require('./util/Format')(Ext);

Ext.XTemplateParser = require('./XTemplateParser')(Ext);
Ext.XTemplateCompiler = require('./XTemplateCompiler')(Ext);

Ext.Template = require('./Template')(Ext);
Ext.XTemplate = require('./XTemplate')(Ext);

module.exports = Ext;
17 changes: 10 additions & 7 deletions String.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
var Ext = {};
module.exports = function(Ext) {
if (!Ext) {
throw(new Error('Dependencies missing'));
}
// @tag foundation,core
// @require ../version/Version.js
// @define Ext.String
Expand All @@ -9,7 +12,6 @@ var Ext = {};
* A collection of useful static methods to deal with strings.
* @singleton
*/
Ext.String = (function() {
var trimRegex = /^[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u2028\u2029\u202f\u205f\u3000]+|[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u2028\u2029\u202f\u205f\u3000]+$/g,
escapeRe = /('|\\)/g,
formatRe = /\{(\d+)\}/g,
Expand All @@ -35,7 +37,7 @@ Ext.String = (function() {
return other.length <= s.length;
};

return {
var returnObject = {

/**
* Inserts a substring into a string.
Expand Down Expand Up @@ -396,12 +398,13 @@ Ext.String = (function() {
return words || [];
}
};
}());

// initialize the default encode / decode entities
Ext.String.resetCharacterEntities();
// initialize the default encode / decode entities
returnObject.resetCharacterEntities();

return returnObject;
};

module.exports = Ext.String;
/**
* Old alias to {@link Ext.String#htmlEncode}
* @deprecated Use {@link Ext.String#htmlEncode} instead
Expand Down
Loading

0 comments on commit 0374ffd

Please sign in to comment.