PDA

View Full Version : [3.x] Theme and Language cyclebuttons



galdaka
11 Aug 2009, 4:08 AM
11/08/2009: First version.
11/08/2009: Capture http://www.jadacosta.es/contents/screencast/capture3.swf
11/08/2009: Added GNU and price: 20€. Included two files, Language and Cyclebutton. Contact to: galdaka@hotmail.com
03/11/2009: License changed. Reason: People use your work for comercial purposes without your permission.
03/11/2009: NEW LICENSE: http://creativecommons.org/licenses/by-nc/3.0/ (http://creativecommons.org/licenses/by-nc/3.0/). Thanks to cparker (http://www.extjs.com/forum/member.php?u=57967).


LanguageCyclebutton...




/**
* Ext.ux.LanguageCycleButton
* Copyright (c) 2009-2010, José Alfonso Dacosta Dominguez (galdaka@hotmail.com)
*
* Ext.ux.LanguageCycleButton is licensed http://creativecommons.org/licenses/by-nc/3.0/ license.
*
* Commercial use is prohibited. contact with galdaka@hotmail.com
* if you need to obtain a commercial license.
*
* Site: www.jadacosta.es
*/
Ext.ux.LanguageCycleButton = Ext.extend(Ext.CycleButton, {

languageItems: this.languageItems || [
{language: 'es', text: 'Español ', iconCls: Ext.ux.iconMgr.getIcon('/dev/common/icons.nsf/extjs/ux/icons/flags/', 'es')},
{language: 'en', text: 'Inglés ', iconCls: Ext.ux.iconMgr.getIcon('/dev/common/icons.nsf/extjs/ux/icons/flags/', 'fj')},
{language: 'ch', text: 'Euskera ', iconCls: Ext.ux.iconMgr.getIcon('/dev/common/icons.nsf/extjs/ux/icons/flags/', 'eu')}
],
languageVar: this.languageVar || 'lang',

initComponent: function() {
if(Ext.state.Manager){
var selectedLanguage = Ext.state.Manager.get(this.languageVar);
if(selectedLanguage){
for(var i=0; i<this.languageItems.length;i++){
if (this.languageItems[i].language == selectedLanguage){
this.languageItems[i].checked = true;
Ext.state.Manager.set(this.languageVar, this.languageItems[i].language);
break;
}
}
}else{
this.languageItems[0].checked = true;
}
}
Ext.apply(this, {
showText: true,
prependText: '&nbsp;',
items: this.languageItems
});
Ext.ux.LanguageCycleButton.superclass.initComponent.apply(this, arguments);
},

changeHandler: function(o, i){
if(Ext.state.Manager.getProvider()) {
Ext.state.Manager.set(this.languageVar, i.language);
}
var aux = '';
if(window.location.href.split('&l=')[1]){
if(window.location.href.split('&l=')[1].split('&')[1]){
aux = '&' + window.location.href.split('&l=')[1].split('&')[1];
}
}
window.location.href = window.location.href.split('&l=')[0] + '&l=' + i.language + aux;
}

});
Ext.reg('languagecyclebutton', Ext.ux.LanguageCycleButton);


And ThemeCyclebutton...




/**
* Ext.ux.ThemeCycleButton
* Copyright (c) 2009-2010, José Alfonso Dacosta Dominguez (galdaka@hotmail.com)
*
* Ext.ux.ThemeCycleButton is licensed http://creativecommons.org/licenses/by-nc/3.0/ license.
*
* Commercial use is prohibited. contact with galdaka@hotmail.com
* if you need to obtain a commercial license.
*
* Site: www.jadacosta.es
*/
Ext.ux.ThemeCycleButton = Ext.extend(Ext.CycleButton, {

cssItems: this.cssItems || [
{file: 'xtheme-blue.css', type: 'original', text: 'Azul&nbsp;', iconCls: Ext.ux.iconMgr.getIcon('/dev/common/icons.nsf/extjs/ux/icons/', 'blue-theme'), head: 'cabecera-Azul.jpg'},
{file: 'xtheme-gray-extend.css', type: 'ux', text: 'Gris extendido&nbsp;', iconCls: Ext.ux.iconMgr.getIcon('/dev/common/icons.nsf/extjs/ux/icons/', 'gray-theme'), head: 'cabecera-Gris.jpg'}
],
themeVar: this.themeVar || 'style',
headVar: this.headVar || 'head',
originalCSSPath: this.originalCSSPath || 'extjs/resources/css/',
uxCSSPath: this.uxCSSPath || 'extjs/resources/css/',
headsPath: this.headsPath || 'resources/img/',

initComponent: function() {
if(Ext.state.Manager){
var selectedTheme = Ext.state.Manager.get(this.themeVar);
if(selectedTheme){
for(var i=0; i<this.cssItems.length;i++){
if (this.cssItems[i].file == selectedTheme){
this.cssItems[i].checked = true;
this.changeHandler(this, this.cssItems[i]);
break;
}
}
}else{
this.cssItems[1].checked = true;
}
}
Ext.apply(this, {
showText: true,
prependText: '&nbsp;',
items: this.cssItems
});
Ext.ux.ThemeCycleButton.superclass.initComponent.apply(this, arguments);
},

changeHandler: function(o, i){
if(Ext.state.Manager.getProvider()) {
Ext.state.Manager.set(this.themeVar, i.file);
Ext.state.Manager.set(this.headVar, i.head);
}
i.type == 'ux' ? Ext.util.CSS.swapStyleSheet(this.themeVar, this.uxCSSPath + i.file) : Ext.util.CSS.swapStyleSheet(this.themeVar, this.originalCSSPath + i.file);
Ext.util.CSS.getRule('.header .x-panel-body', true).style.background = 'url(' + this.headsPath + i.head + ')';
if(Ext.getCmp('viewport')){
Ext.getCmp('viewport').layout.center.panel.setSize(Ext.getCmp('viewport').layout.center.getSize().width + 1);
Ext.getCmp('viewport').doLayout();
Ext.getCmp('viewport').layout.center.panel.setSize(Ext.getCmp('viewport').layout.center.getSize().width - 1);
Ext.getCmp('viewport').doLayout();
}
}

});
Ext.reg('themecyclebutton', Ext.ux.ThemeCycleButton);

galdaka
3 Nov 2009, 12:48 AM
Hi,

License changed. View first post.

Greetings,