Skip to content

Commit

Permalink
Fixed a bug with scaffold index where the superclass's initEvents was…
Browse files Browse the repository at this point in the history
… not being called
  • Loading branch information
Ed Spencer committed Aug 20, 2009
1 parent 47a8c66 commit 6544112
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 129 deletions.
74 changes: 11 additions & 63 deletions MVC.js
Expand Up @@ -75,9 +75,13 @@ ExtMVC = Ext.extend(Ext.util.Observable, {

/**
* Boots up the application.
* TODO: When it works, document this :)
* @param {Object} config Optional config object.
*/
boot: function() {
boot: function(config) {
Ext.apply(this.bootParams, config || {}, {
callback: Ext.emptyFn
});

var args = window.location.href.split("?")[1];

/**
Expand All @@ -93,7 +97,6 @@ ExtMVC = Ext.extend(Ext.util.Observable, {
}, this);
}


//load up the environment
Ext.Ajax.request({
url: '../config/environment.json',
Expand Down Expand Up @@ -216,57 +219,9 @@ ExtMVC = Ext.extend(Ext.util.Observable, {
controllerFiles = [],
viewFiles = [];

var loadFiles = function(fileList, onLoadFn, scope) {
var fragment = document.createDocumentFragment(),
numFiles = fileList.length,
loadedFiles = 0;

Ext.each(fileList, function(file, index) {
var script = document.createElement('script');
script.type = "text/javascript";
script.src = file;

script.onload = function() {
loadedFiles ++;

// console.log(loadedFiles + " of " + numFiles);
if (numFiles == loadedFiles && Ext.isFunction(onLoadFn)) {
onLoadFn.call(scope || this);
}
};

fragment.appendChild(script);
}, this);

document.getElementsByTagName("head")[0].appendChild(fragment);
};

var loadFilesInOrder = function(fileList, onLoadFn, scope) {
if (Ext.isSafari) {
var numFiles = fileList.length,
loadedFiles = 0;

var loadFileIndex = function(index) {
loadFiles([fileList[index]], onFileLoaded);
};

var onFileLoaded = function(response) {
loadedFiles ++;

// console.log(loadedFiles + " !!of " + numFiles);
if (numFiles == loadedFiles && Ext.isFunction(onLoadFn)) {
onLoadFn.call(scope || this);
} else {
loadFileIndex(loadedFiles);
}
};

loadFileIndex(0);

} else {
loadFiles.apply(this, arguments);
}
};
// var groups = {
// 'base': {preserveOrder: false, }
// };

Ext.each(env.overrides, function(file) {
baseFiles.push(String.format("{0}/{1}.js", env.overridesDir, file));
Expand Down Expand Up @@ -299,16 +254,9 @@ ExtMVC = Ext.extend(Ext.util.Observable, {
this.loadFiles(modelFiles, false, function() {
this.loadFiles(controllerFiles, true, function() {
this.loadFiles(viewFiles, true, function() {
// console.log(Ext.app);
// console.log(Ext.isReady);
//
// console.log(GetIt);
// console.log(GetIt.models);
// console.log(GetIt.controllers);
// console.log(GetIt.views);
//
// console.log(ExtMVC.app);
ExtMVC.app.onReady();

this.bootParams.callback();
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion ext-mvc-all-min.js

Large diffs are not rendered by default.

77 changes: 13 additions & 64 deletions ext-mvc-all.js
Expand Up @@ -75,9 +75,13 @@ ExtMVC = Ext.extend(Ext.util.Observable, {

/**
* Boots up the application.
* TODO: When it works, document this :)
* @param {Object} config Optional config object.
*/
boot: function() {
boot: function(config) {
Ext.apply(this.bootParams, config || {}, {
callback: Ext.emptyFn
});

var args = window.location.href.split("?")[1];

/**
Expand All @@ -93,7 +97,6 @@ ExtMVC = Ext.extend(Ext.util.Observable, {
}, this);
}


//load up the environment
Ext.Ajax.request({
url: '../config/environment.json',
Expand Down Expand Up @@ -216,57 +219,9 @@ ExtMVC = Ext.extend(Ext.util.Observable, {
controllerFiles = [],
viewFiles = [];

var loadFiles = function(fileList, onLoadFn, scope) {
var fragment = document.createDocumentFragment(),
numFiles = fileList.length,
loadedFiles = 0;

Ext.each(fileList, function(file, index) {
var script = document.createElement('script');
script.type = "text/javascript";
script.src = file;

script.onload = function() {
loadedFiles ++;

// console.log(loadedFiles + " of " + numFiles);
if (numFiles == loadedFiles && Ext.isFunction(onLoadFn)) {
onLoadFn.call(scope || this);
}
};

fragment.appendChild(script);
}, this);

document.getElementsByTagName("head")[0].appendChild(fragment);
};

var loadFilesInOrder = function(fileList, onLoadFn, scope) {
if (Ext.isSafari) {
var numFiles = fileList.length,
loadedFiles = 0;

var loadFileIndex = function(index) {
loadFiles([fileList[index]], onFileLoaded);
};

var onFileLoaded = function(response) {
loadedFiles ++;

// console.log(loadedFiles + " !!of " + numFiles);
if (numFiles == loadedFiles && Ext.isFunction(onLoadFn)) {
onLoadFn.call(scope || this);
} else {
loadFileIndex(loadedFiles);
}
};

loadFileIndex(0);

} else {
loadFiles.apply(this, arguments);
}
};
// var groups = {
// 'base': {preserveOrder: false, }
// };

Ext.each(env.overrides, function(file) {
baseFiles.push(String.format("{0}/{1}.js", env.overridesDir, file));
Expand Down Expand Up @@ -299,16 +254,9 @@ ExtMVC = Ext.extend(Ext.util.Observable, {
this.loadFiles(modelFiles, false, function() {
this.loadFiles(controllerFiles, true, function() {
this.loadFiles(viewFiles, true, function() {
// console.log(Ext.app);
// console.log(Ext.isReady);
//
// console.log(GetIt);
// console.log(GetIt.models);
// console.log(GetIt.controllers);
// console.log(GetIt.views);
//
// console.log(ExtMVC.app);
ExtMVC.app.onReady();

this.bootParams.callback();
});
});
});
Expand Down Expand Up @@ -4032,7 +3980,6 @@ ExtMVC.view.scaffold.Index = Ext.extend(Ext.grid.GridPanel, {

ExtMVC.view.scaffold.Index.superclass.constructor.call(this, config);

this.initEvents();
this.initListeners();
},

Expand Down Expand Up @@ -4092,6 +4039,8 @@ ExtMVC.view.scaffold.Index = Ext.extend(Ext.grid.GridPanel, {
*/
'delete'
);

ExtMVC.view.scaffold.Index.superclass.initEvents.apply(this, arguments);
},

/**
Expand Down
3 changes: 2 additions & 1 deletion view/scaffold/Index.js
Expand Up @@ -28,7 +28,6 @@ ExtMVC.view.scaffold.Index = Ext.extend(Ext.grid.GridPanel, {

ExtMVC.view.scaffold.Index.superclass.constructor.call(this, config);

this.initEvents();
this.initListeners();
},

Expand Down Expand Up @@ -88,6 +87,8 @@ ExtMVC.view.scaffold.Index = Ext.extend(Ext.grid.GridPanel, {
*/
'delete'
);

ExtMVC.view.scaffold.Index.superclass.initEvents.apply(this, arguments);
},

/**
Expand Down

0 comments on commit 6544112

Please sign in to comment.