lipsiadmin_generators/backend/templates/views/javascripts/backend.js.erb in lipsiadmin-5.1.0 vs lipsiadmin_generators/backend/templates/views/javascripts/backend.js.erb in lipsiadmin-5.1.1
- old
+ new
@@ -55,32 +55,32 @@
}
// 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;
-
+
<% if params[:small] != "1" %>
var header = new Ext.Panel({
contentEl: 'header',
region: 'north',
border: false,
bbar: <%= backend_menu %>
});
<% end %>
-
+
this.contentDynamic = new Ext.Panel({
id:'dynamic',
region:'center',
border:false,
bodyStyle: 'background: #FFF url(/images/backend/bg-content.png) repeat-x top;',
title: this.title() ? ' ' : '',
layout:'fit'
});
-
+
this.viewport = new Ext.Viewport({
layout:'border',
items: header ? [header, this.contentDynamic] : [this.contentDynamic]
});
@@ -88,23 +88,23 @@
setTimeout(function(){
Ext.get('loading').remove();
Ext.get('loading-mask').fadeOut({remove:true});
}, 250);
}, // init
-
+
smallView : function(){
return window.location.search ? Ext.urlDecode(window.location.search.substring(1)).small : false;
}, // smalloallProductsGroupingStore
-
+
toolbar: function(){
return window.location.search ? Ext.urlDecode(window.location.search.substring(1)).toolbar!="0" : true;
}, // hideToolbar
-
+
title: function(){
return window.location.search ? Ext.urlDecode(window.location.search.substring(1)).title!="0" : true;
}, // hideTite
-
+
load : function(url){
var ext = (/[.]/.exec(url)) ? /[^.]+$/.exec(url) : 'html';
// Now we need to store the url in the history
if (!this.smallView()){
@@ -123,109 +123,103 @@
s.type = 'text/javascript';
// Now we can append the child.
hd.appendChild(s);
} else if (ext == 'html'){
// Clean the html and scripts if requested
+ this.mask();
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
-
+
back: function(){
if (Backend.app.smallView()){
window.location.reload(true);
} else {
Ext.History.back();
}
},// back
-
+
update : function(html){
this.cleanScripts();
this.clean();
var el = this.contentDynamic.body.update(html);
this.inspectContent(el, html);
}, // update
-
+
cleanScripts: function(){
Ext.select('head > script').each(function(el){ el.remove(); });
}, // cleanScripts
-
+
clean : function(){
this.mask();
this.contentDynamic.items.each(function(i){ i.destroy(); });
this.contentDynamic.removeAll(true);
this.contentDynamic.body.update(''); // Another check ;)
this.contentDynamic.doLayout();
}, // clean
-
+
addItem : function(item){
this.contentDynamic.add(item);
this.contentDynamic.doLayout();
}, // addItem
-
+
submitForm : function(){
Backend.app.mask(Backend.locale.messages.wait.message);
Backend.app.contentDynamic.findByType('tabpanel').each(function(tabpanel){
cache.activeTab = tabpanel.activeTab.id;
});
Ext.select('form[target=ajax-iframe]').each(function(form){ form.dom.submit(); });
}, // submitForms
-
+
setTitle: function(title){
this.contentDynamic.setTitle(title);
}, // SetTitle
-
+
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';
- }
+ el.select('form[id!=ajax-iframe]').each(function(form){
+ form.dom.target = 'ajax-iframe';
});
// Search for tabs in the page
var tabs = el.select('div[tabbed=true]');
if (tabs.elements.length > 0){
// Build Tabs
var items = tabs.elements.collect(function(tab){
- return { id: tab.id, contentEl: tab.id, title: tab.title };
+ return { id: tab.id+'-tabbed', contentEl: tab.id, title: tab.title };
});
// Get ActiveTab
var activeTab = (cache.activeTab || 0);
+ // We select the first form in the dom
var form = el.select('form[target=ajax-iframe]').first();
-
- this.tabPanel = new Ext.TabPanel({
- applyTo: form,
- xtype:'tabpanel',
+
+ // We need this for IE8
+ var formId = Ext.id(form, 'ajax-form-');
+
+ var tabConfig = {
+ applyTo: formId,
activeTab: activeTab,
border:false,
items: items,
- deferredRender: true,
+ deferredRender: false,
layoutOnTabChange: true,
enableTabScroll: true,
defaults: { autoScroll:true, layout:'fit' }
- });
-
- // We need to add an extra container for maximize compatibility with
- // lastest safari builds.
- var panelConfig = {
- border:false,
- layout:'fit',
- items: this.tabPanel
};
if (this.toolbar()){
- Ext.apply(panelConfig, {
+ Ext.apply(tabConfig, {
bbar: [{
text: Backend.locale.buttons.back,
cls: 'x-btn-text-icon back',
handler: Backend.app.back
}, '->',{
@@ -234,18 +228,20 @@
handler: Backend.app.submitForm
}]
});
}
- // Build the Container
- var panel = new Ext.Panel(panelConfig);
- this.addItem(panel);
-
+ // We can build the tabPanel
+ this.tabPanel = new Ext.TabPanel(tabConfig);
+
+ // Now we add the tab panel to our main container
+ this.addItem(this.tabPanel);
+
// 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 from the original html
var re = /(?:<script([^>]*)?>)((\n|\r|.)*?)(?:<\/script>)/ig;
var srcRe = /\ssrc=([\'\"])(.*?)\1/i;
var typeRe = /\stype=([\'\"])(.*?)\1/i;
@@ -275,19 +271,19 @@
cache = {};
} catch(e){
throw this.error(e)
}
},//inspectContent
-
+
error: function(e){
if (typeof console != 'undefined') {
console.error(e);
} else {
Ext.Msg.alert(Backend.locale.messages.alert.title, e);
}
}, // error
-
+
openHelp: function(){
var form = new Ext.FormPanel({
baseCls: 'x-plain',
labelAlign: 'top',
items: [{
@@ -298,11 +294,12 @@
name: 'message'
}]
});
var formDialog = new Ext.Window({
- title: Backend.locale.help.title,
+ id: 'help-window',
+ title: Backend.locale.help.title,
items: form,
width: 500,
height: 300,
minWidth: 300,
minHeight: 150,
@@ -328,32 +325,32 @@
Ext.Msg.alert(Backend.locale.messages.alert.title, action.result.msg);
}
}
});
}, this);
-
+
formDialog.addButton(Backend.locale.buttons.close, formDialog.close, formDialog);
formDialog.show();
}, // openHelp
-
+
doLayout : function(){
this.contentDynamic.doLayout();
}, //doLayout
mask : function(text){
if (this.contentDynamic){
if (text == null || text.length == 0) { text = Ext.LoadMask.prototype.msg; }
this.contentDynamic.el.mask(text);
}
}, // mask
-
+
unmask : function(){
if (this.contentDynamic){
this.contentDynamic.el.unmask();
}
}, // unmask
-
+
collapseBoxes : function(current){
var el = current.up().down('div.x-box-collapsible');
var currentEl = Ext.get(el);
currentEl.isDisplayed() ? currentEl.slideOut('t', {duration:.2, useDisplay:true}) : currentEl.slideIn('t', {duration:.2, useDisplay:true});
Ext.select('div.x-box-collapsible').each(function(el){
@@ -395,28 +392,28 @@
handler: this.saveForm.createDelegate(this, [])}
);
}
this.html = '<iframe id="'+this.iframeId+'" class="windowed" src="/backend/base/?small=1&toolbar='+(this.form?0:1)+'&load='+this.url+'" frameBorder="0" width="100%" height="100%" />';
}, // initComponent
-
+
afterShow : function(afterShow){
Backend.window.superclass.afterShow.call(this);
this.contentWindow = Ext.fly(this.iframeId).dom.contentWindow;
}, // onRender
-
+
getSelections: function(){
return this.contentWindow[this.grid].getSelectionModel().getSelections();
}, // getSelections
-
+
closeWithSelections: function(){
if (this.getSelections().length > 0){
this.fireEvent('selected', this, this.getSelections());
this[this.closeAction]();
} else {
Ext.Msg.alert(Backend.locale.messages.alert.title, Backend.locale.messages.alert.notSelected);
}
}, // closeWithSelections
-
+
saveForm: function(){
this.contentWindow.Backend.app.submitForm();
this.fireEvent('saved', this);
} // saveForm
});
\ No newline at end of file