Skip to content

Commit

Permalink
Fixes for production mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Ed Spencer committed Aug 31, 2009
1 parent 5775ecb commit c0786f5
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 55 deletions.
10 changes: 10 additions & 0 deletions MVC.js
Expand Up @@ -246,6 +246,16 @@ ExtMVC = Ext.extend(Ext.util.Observable, {

ExtMVC = new ExtMVC();

//set a few shortcuts
Ext.apply(ExtMVC, {
regM: ExtMVC.registerModel,
regV: ExtMVC.registerView,
regC: ExtMVC.registerController,
getM: ExtMVC.getModel,
getV: ExtMVC.getView,
getC: ExtMVC.getController
});

// ExtMVC.initializeClassManagers();

Ext.onReady(function() {
Expand Down
52 changes: 52 additions & 0 deletions Presenter.js
@@ -0,0 +1,52 @@
/**
* @class ExtMVC.Presenter
* @extends Ext.util.Observable
* Used as an interface between a controller and its views
*/
ExtMVC.Presenter = Ext.extend(Ext.util.Observable, {

constructor: function(config) {
ExtMVC.Presenter.superclass.constructor.apply(this, arguments);

this.addEvents(
/**
* @event load
* Fires when all items in the Presenter have been loaded
*/
'load'
);

/**
* @property loaded
* @type Boolean
* True if all items that must be loaded before rendering have been
*/
this.loaded = false;

/**
* @property loading
* @type Boolean
* True while the loader is loading
*/
this.loading = false;
},

load: function() {
if (this.loaded || this.loading) return;

this.each(function(item, index, length) {
var callback = function(index) {
return function() {
if (index == length) {
this.loaded = true;
this.loading = false;

this.fireEvent('load');
}
};
}(index);

item.on('load', callback, this, {single: true});
}, this);
}
});
25 changes: 4 additions & 21 deletions controller/Controller.js
Expand Up @@ -157,8 +157,8 @@ ExtMVC.registerController('controller', {
* Adds the default strategies for panel and tabpanel
*/
registerDefaultRenderStrategies: function() {
this.registerRenderStrategy('panel', this.panelRenderStragegy);
this.registerRenderStrategy('tabpanel', this.tabPanelRenderStragegy);
this.registerRenderStrategy('panel', this.panelRenderStrategy);
this.registerRenderStrategy('tabpanel', this.tabPanelRenderStrategy);
},

/**
Expand Down Expand Up @@ -252,7 +252,7 @@ ExtMVC.registerController('controller', {
* @private
* The tabpanel render strategy
*/
tabPanelRenderStragegy: function(container, view) {
tabPanelRenderStrategy: function(container, view) {
container.add(view);
container.doLayout();
container.activate(view);
Expand All @@ -262,26 +262,9 @@ ExtMVC.registerController('controller', {
* @private
* The panel render strategy
*/
panelRenderStragegy: function(container, view) {
panelRenderStrategy: function(container, view) {
container.removeAll();
container.add(view);
container.doLayout();
}

// /**
// * Adds the given component to this application's main container. This is usually a TabPanel
// * or similar, and must be assigned to the controllers addTo property. By default,
// * this method removes any other items from the container first, then adds the new component
// * and calls doLayout
// * @param {Ext.Component} component The component to add to the controller's container
// */
// renderViaAddTo: function renderViaAddTo(component) {
// if (this.addTo != undefined) {
// this.addTo.removeAll();
// this.addTo.doLayout();
//
// this.addTo.add(component);
// this.addTo.doLayout();
// }
// }
});
2 changes: 1 addition & 1 deletion ext-mvc-all-min.js

Large diffs are not rendered by default.

51 changes: 24 additions & 27 deletions ext-mvc-all.js
Expand Up @@ -246,6 +246,16 @@ ExtMVC = Ext.extend(Ext.util.Observable, {

ExtMVC = new ExtMVC();

//set a few shortcuts
Ext.apply(ExtMVC, {
regM: ExtMVC.registerModel,
regV: ExtMVC.registerView,
regC: ExtMVC.registerController,
getM: ExtMVC.getModel,
getV: ExtMVC.getView,
getC: ExtMVC.getController
});

// ExtMVC.initializeClassManagers();

Ext.onReady(function() {
Expand Down Expand Up @@ -830,10 +840,14 @@ ExtMVC.lib.Booter = Ext.extend(Ext.util.Observable, {
this.loadStylesheets(env);

//if the 'scripts' property on the Environment is present then models, controllers, plugins etc are ignored
if (Ext.isArray(env.scripts) && env.scripts.length > 0) {
this.loadFiles(env.scripts, false, function() {
if (Ext.isArray(env.scripts)) { //&& env.scripts.length > 0) {
if (env.scripts.length == 0) {
this.fireEvent('application-files-loaded');
}, this);
} else {
this.loadFiles(env.scripts, false, function() {
this.fireEvent('application-files-loaded');
}, this);
}

return;
}
Expand Down Expand Up @@ -2690,8 +2704,8 @@ ExtMVC.registerController('controller', {
* Adds the default strategies for panel and tabpanel
*/
registerDefaultRenderStrategies: function() {
this.registerRenderStrategy('panel', this.panelRenderStragegy);
this.registerRenderStrategy('tabpanel', this.tabPanelRenderStragegy);
this.registerRenderStrategy('panel', this.panelRenderStrategy);
this.registerRenderStrategy('tabpanel', this.tabPanelRenderStrategy);
},

/**
Expand Down Expand Up @@ -2785,7 +2799,7 @@ ExtMVC.registerController('controller', {
* @private
* The tabpanel render strategy
*/
tabPanelRenderStragegy: function(container, view) {
tabPanelRenderStrategy: function(container, view) {
container.add(view);
container.doLayout();
container.activate(view);
Expand All @@ -2795,28 +2809,11 @@ ExtMVC.registerController('controller', {
* @private
* The panel render strategy
*/
panelRenderStragegy: function(container, view) {
panelRenderStrategy: function(container, view) {
container.removeAll();
container.add(view);
container.doLayout();
}

// /**
// * Adds the given component to this application's main container. This is usually a TabPanel
// * or similar, and must be assigned to the controllers addTo property. By default,
// * this method removes any other items from the container first, then adds the new component
// * and calls doLayout
// * @param {Ext.Component} component The component to add to the controller's container
// */
// renderViaAddTo: function renderViaAddTo(component) {
// if (this.addTo != undefined) {
// this.addTo.removeAll();
// this.addTo.doLayout();
//
// this.addTo.add(component);
// this.addTo.doLayout();
// }
// }
});

/**
Expand Down Expand Up @@ -6503,7 +6500,7 @@ ExtMVC.test.TestClient = Ext.extend(Ext.util.Observable, {
interval: 1000,
scope : this,
run : function() {
this.jsonpRequest("http://192.168.4.3:5000/changes", {
this.jsonpRequest("http://192.168.3.2:5000/changes", {
since: Math.floor(this.lastChangesReceived.getTime() / 1000)
}, this.onChangePoll);
}
Expand Down Expand Up @@ -6544,7 +6541,7 @@ ExtMVC.test.TestClient = Ext.extend(Ext.util.Observable, {
* @param {Boolean} autoRun True to run test files as soon as they are loaded (defaults to true)
*/
loadTestFiles: function() {
this.jsonpRequest('http://192.168.4.3:5000/all_test_files', {}, function(response) {
this.jsonpRequest('http://192.168.3.2:5000/all_test_files', {}, function(response) {
this.runner.addTests(response.files);
this.runner.runTests();
});
Expand All @@ -6555,7 +6552,7 @@ ExtMVC.test.TestClient = Ext.extend(Ext.util.Observable, {
* @param {Object} stats Stats object
*/
postResults: function(stats) {
this.jsonpRequest('http://192.168.4.3:5000/results', stats, function() {
this.jsonpRequest('http://192.168.3.2:5000/results', stats, function() {
this.fireEvent('results-posted', stats);

var runner = this.runner;
Expand Down
10 changes: 7 additions & 3 deletions lib/Booter.js
Expand Up @@ -133,10 +133,14 @@ ExtMVC.lib.Booter = Ext.extend(Ext.util.Observable, {
this.loadStylesheets(env);

//if the 'scripts' property on the Environment is present then models, controllers, plugins etc are ignored
if (Ext.isArray(env.scripts) && env.scripts.length > 0) {
this.loadFiles(env.scripts, false, function() {
if (Ext.isArray(env.scripts)) { //&& env.scripts.length > 0) {
if (env.scripts.length == 0) {
this.fireEvent('application-files-loaded');
}, this);
} else {
this.loadFiles(env.scripts, false, function() {
this.fireEvent('application-files-loaded');
}, this);
}

return;
}
Expand Down
6 changes: 3 additions & 3 deletions testrunner/TestClient.js
Expand Up @@ -45,7 +45,7 @@ ExtMVC.test.TestClient = Ext.extend(Ext.util.Observable, {
interval: 1000,
scope : this,
run : function() {
this.jsonpRequest("http://192.168.4.3:5000/changes", {
this.jsonpRequest("http://192.168.3.2:5000/changes", {
since: Math.floor(this.lastChangesReceived.getTime() / 1000)
}, this.onChangePoll);
}
Expand Down Expand Up @@ -86,7 +86,7 @@ ExtMVC.test.TestClient = Ext.extend(Ext.util.Observable, {
* @param {Boolean} autoRun True to run test files as soon as they are loaded (defaults to true)
*/
loadTestFiles: function() {
this.jsonpRequest('http://192.168.4.3:5000/all_test_files', {}, function(response) {
this.jsonpRequest('http://192.168.3.2:5000/all_test_files', {}, function(response) {
this.runner.addTests(response.files);
this.runner.runTests();
});
Expand All @@ -97,7 +97,7 @@ ExtMVC.test.TestClient = Ext.extend(Ext.util.Observable, {
* @param {Object} stats Stats object
*/
postResults: function(stats) {
this.jsonpRequest('http://192.168.4.3:5000/results', stats, function() {
this.jsonpRequest('http://192.168.3.2:5000/results', stats, function() {
this.fireEvent('results-posted', stats);

var runner = this.runner;
Expand Down

0 comments on commit c0786f5

Please sign in to comment.