lipsiadmin_generators/backend/templates/views/javascripts/backend.js.erb in lipsiadmin-5.0.6 vs lipsiadmin_generators/backend/templates/views/javascripts/backend.js.erb in lipsiadmin-5.0.7
- old
+ new
@@ -4,14 +4,10 @@
//
Ext.BLANK_IMAGE_URL = '/images/ext/default/s.gif';
Ext.namespace('Backend');
Ext.namespace('Backend.util.Format');
-Ext.Updater.defaults.loadScripts = false;
-Ext.Updater.defaults.showLoadIndicator = false;
-Ext.Updater.defaults.disableCaching = true;
-
// How it works?
//
// Basically we can load (async) contents in 3 ways:
//
// * Loading a file .js (javascript)
@@ -61,18 +57,17 @@
// Used for history the browsing
Ext.History.init();
Ext.History.on('change', function(token){ if(token != Backend.app.oldUrl) { Backend.app.load(token) } });
this.cache = {};
- var header = undefined;
+ var header;
<% if params[:small] != "1" %>
var header = new Ext.Panel({
- contentEl:'header',
- region:'north',
+ contentEl: 'header',
+ region: 'north',
border: false,
- height: 40,
bbar: <%= backend_menu %>
});
<% end %>
this.contentDynamic = new Ext.Panel({
@@ -87,12 +82,10 @@
this.viewport = new Ext.Viewport({
layout:'border',
items: header ? [header, this.contentDynamic] : [this.contentDynamic]
});
- this.contentDynamic.getUpdater().on('beforeupdate', function(){ this.cleanScripts(); this.clean(); }, this);
- this.contentDynamic.getUpdater().on('update', this.inspectContent, this);
this.load(loadUrl ? loadUrl : '/backend/base/welcome');
setTimeout(function(){
Ext.get('loading').remove();
Ext.get('loading-mask').fadeOut({remove:true});
}, 250);
@@ -129,11 +122,16 @@
s.src = url;
s.type = 'text/javascript';
// Now we can append the child.
hd.appendChild(s);
} else if (ext == 'html'){
- this.contentDynamic.getUpdater().update({ url: url, headers: { 'Accept': 'text/html, text/javascript, application/xml, text/xml, */*' } });
+ // Clean the html and scripts if requested
+ Ext.Ajax.request({
+ url: url,
+ headers: { 'Accept': 'text/html' },
+ success: function(response) { Backend.app.update(response.responseText) }
+ });
} else {
Ext.Msg.alert(Backend.locale.messages.alert.title, Backend.locale.messages.alert.message);
}
}, // load
@@ -146,12 +144,12 @@
},// back
update : function(html){
this.cleanScripts();
this.clean();
- var el = this.contentDynamic.body.update(html, true);
- this.inspectContent(el);
+ var el = this.contentDynamic.body.update(html);
+ this.inspectContent(el, html);
}, // update
cleanScripts: function(){
Ext.select('head > script').each(function(el){ el.remove(); });
}, // cleanScripts
@@ -179,13 +177,12 @@
setTitle: function(title){
this.contentDynamic.setTitle(title);
}, // SetTitle
- inspectContent: function(el, oResponseObject){
+ inspectContent: function(el, originalHtml){
try {
-
// Search for forms (except ajax-frame) in the page, usually only one.
el.select('form').each(function(form){
if (form.id != 'ajax-iframe'){
form.dom.target = 'ajax-iframe';
}
@@ -245,19 +242,16 @@
// Need to use this because some times we add tabs from inline scripts
this.tabPanel.on('add', function(container, tab){ if (tab.id == activeTab) { Backend.app.tabPanel.setActiveTab(activeTab); } });
}
- // Now we can load scripts an eval scripts
- var html = el.dom.innerHTML;
- var dom = this.contentDynamic.body.dom;
-
+ // Now we can load scripts an eval scripts from the original html
var re = /(?:<script([^>]*)?>)((\n|\r|.)*?)(?:<\/script>)/ig;
var srcRe = /\ssrc=([\'\"])(.*?)\1/i;
var typeRe = /\stype=([\'\"])(.*?)\1/i;
var match;
- while(match = re.exec(html)){
+ while(match = re.exec(originalHtml)){
var attrs = match[1];
var srcMatch = attrs ? attrs.match(srcRe) : false;
if(srcMatch && srcMatch[2]){
// We append the js into the head so we can easy inspect errors
var hd = document.getElementsByTagName("head")[0];
\ No newline at end of file