Toc.TreePanel = function(config) {
config = config || {};
config.layout = 'fit';
config.modal = true;
config.collapsible = true;
config.autoScroll = true;
config.region = 'west';
config.title = 'Languages';
config.width = 250;
config.height = 200;
config.items = this.buildForm();
Toc.TreePanel.superclass.constructor.call(this, config);
};
Ext.extend(Toc.TreePanel, Ext.Panel, {
setParam: function(userId, userName, languages, isAdmin, moderator){
this.userId = userId;
this.userName = userName;
this.languages = languages;
this.isAdmin = isAdmin;
this.moderator = moderator;
},
buildForm: function() {
this.root = new Ext.tree.AsyncTreeNode({
text: 'Languages',
id: 'root',
loader: new Ext.tree.TreeLoader({
dataUrl: Toc.CONF.CONN_URL,
baseParams: {
module: 'translator',
action: 'listLanguageNodes'
}
})
});
this.treePanel = new Ext.tree.TreePanel({
width: 150,
rootVisible: false,
border: false,
autoHeight: true,
listeners: {
click: function(node){
this.onChange(node.attributes.languageId, node.attributes.site, node.attributes.name, node.attributes.sitename, node.attributes.code);
},
scope: this
},
root: this.root
});
this.treePanel.on('contextmenu',function(node,event){
event.preventDefault();
setLanguageId(node);
rightClick.showAt(event.getXY());
});
var rightClick = new Ext.menu.Menu({
id : 'rightClickCont',
languageId: this.languageId,
items : [
{
id:'menu-export',
text : 'Export',
handler: rMenuExport,
scope:this
}
]
});
var languageCode;
function setLanguageId(node){
languageCode = node.attributes.code;
}
function rMenuExport() {
new Toc.ExportDialog().show(languageCode, this.userName);
}
return this.treePanel;
},
onRefresh: function (userId, loginDate) {
this.loader = new Ext.tree.TreeLoader({
dataUrl: Toc.CONF.CONN_URL,
preloadChildren: true,
baseParams: {
module: 'translator',
action: 'listLanguageNodes',
users_id: userId,
login_date: loginDate
}
});
this.loader.load(this.root);
},
onChange: function(languageId, site, languageName, siteName, code){
var newPanelId = languageId+"_"+site;
var newPanelTitle = languageName+": "+siteName;
var iconCls = "lan_"+code.split("_")[1]+"_icon";
var ableEdit = false;
if(this.isAdmin == 1){
ableEdit = true;
}else {
if(this.languages){
this.languages = this.languages.toString();
var arr=this.languages.split(",");
for(var i=0; i < arr.length;i++){
if(arr[i] == languageId){
ableEdit = true;
break;
}
}
}
}
if( !(this.tablePanel.tabPanel.findById(newPanelId)) && siteName!=null ){
pnlNewGrid = new Toc.GridPanel({id:newPanelId, languageId: languageId, site: site, title: newPanelTitle, iconCls: iconCls, languageName: languageName, userId: this.userId, ableEdit: ableEdit, isAdmin: this.isAdmin, moderator: this.moderator});
this.tablePanel.tabPanel.add(pnlNewGrid);
this.tablePanel.tabPanel.setActiveTab(pnlNewGrid);
} else if(this.tablePanel.tabPanel.findById(newPanelId)){
this.tablePanel.tabPanel.setActiveTab(this.tablePanel.tabPanel.findById(newPanelId));
}
}
});
Toc.TablePanel = function(config) {
config = config || {};
config.layout = 'fit';
config.region = 'center';
config.border = false;
config.items = this.buildForm();
Toc.TablePanel.superclass.constructor.call(this, config);
};
Ext.extend(Toc.TablePanel, Ext.Panel, {
buildForm: function() {
this.groupPanel = new Toc.GroupPanel({owner: this});
this.tabPanel = new Ext.TabPanel({
activeTab: 0,
activate: true,
autoShow: true,
autoTabs: true,
enableTabScroll: true,
layoutOnTabChange: true,
defaults:{autoScroll: true},
items: [
this.groupPanel
]
});
return this.tabPanel;
},
tabchange: function(tabPanel , panel){
tabPanel.add(panel);
tabPanel.activate(panel);
this.doLayout();
}
});
Toc.GroupPanel = function(config) {
config = config || {};
config.layout = 'fit';
config.title = 'Home';
config.modal = true;
config.border = false;
config.iconCls = 'lan_home_icon';
config.items = this.buildForm();
Toc.GroupPanel.superclass.constructor.call(this, config);
};
Ext.extend(Toc.GroupPanel, Ext.Panel, {
setParam: function(userId, userName, languages, isAdmin, moderator){
this.userId = userId;
this.userName = userName;
this.languages = languages;
this.isAdmin = isAdmin;
this.moderator = moderator;
},
buildForm: function() {
this.ds = new Ext.data.GroupingStore({
url: Toc.CONF.CONN_URL,
baseParams: {
module: 'translator',
action: 'listGroupPanelLanguages'
},
reader: new Ext.data.JsonReader({
root: Toc.CONF.JSON_READER_ROOT,
totalProperty: Toc.CONF.JSON_READER_TOTAL_PROPERTY
},
[
'languages_id',
'languages_name',
'site',
'image',
'code',
'status',
'total_definition',
'editors'
]
),
sortInfo:{field: 'languages_id', direction: "ASC"},
groupField: 'languages_name',
autoLoad: true
});
var languageCode;
function setRecord(record){
languageCode = record.get('code');
}
this.grdPanel = new Ext.grid.GridPanel({
width: 600,
height: 500,
store: this.ds,
border: false,
viewConfig: new Ext.grid.GroupingView({
forceFit: true,
groupTextTpl: "
{text}
",
showGroupName: false,
startCollapsed: false,
hideGroupedColumn: true
}),
columns: [{header: 'Languages', width: 300, dataIndex: 'site'},
{header: '', width: 320, dataIndex: 'languages_name'},
{width: 30, dataIndex: 'image'},
{header: 'Total Definitions', width: 300, dataIndex: 'total_definition'},
{header: 'Code', width: 300, dataIndex: 'code'},
{header: 'Translation Status', width: 300, dataIndex: 'status'},
{header: 'Editors', width: 300, dataIndex: 'editors'}
],
listeners: {
cellclick: function(grid, rowIndex, columnIndex, e){
var record = grid.getStore().getAt(rowIndex);
var siteName = record.get('site');
var site = '';
setRecord(record);
if(siteName == 'Admin Panel'){
site = 'admin';
} else if(siteName == 'Store Front'){
site = 'front';
} else if(siteName == 'Installation'){
site = 'install';
} else if(siteName == 'Table'){
site = 'table';
} else if(siteName == 'Button'){
site = 'button';
}
this.onChange(record.get('languages_id'), site, record.get('languages_name'), siteName, record.get('code'));
},
scope: this
}
});
return this.grdPanel;
},
onChange: function(languageId, site, languageName, siteName, code){
var newPanelId = languageId+"_"+site;
var newPanelTitle = languageName+": "+siteName;
var iconCls = "lan_"+code.split("_")[1]+"_icon";
var ableEdit = false;
if(this.isAdmin == 1){
ableEdit = true;
}else {
if(this.languages){
this.languages = this.languages.toString();
var arr=this.languages.split(',');
for(var i=0; i< arr.length;i++){
if(arr[i] == languageId){
ableEdit = true;
break;
}
}
}
}
if( !(this.owner.tabPanel.findById(newPanelId)) && siteName!=null ){
pnlNewGrid = new Toc.GridPanel({id:newPanelId, languageId: languageId, site: site, title: newPanelTitle, iconCls: iconCls, languageName: languageName, userId: this.userId, ableEdit: ableEdit, isAdmin: this.isAdmin, moderator: this.moderator});
this.owner.tabPanel.add(pnlNewGrid);
this.owner.tabPanel.setActiveTab(pnlNewGrid);
} else if(this.owner.tabPanel.findById(newPanelId)){
this.owner.tabPanel.setActiveTab(this.owner.tabPanel.findById(newPanelId));
}
}
});
Toc.GridPanel = function(config) {
config = config || {};
config.layout = 'fit';
config.closable = true;
config.border = false;
config.tools = [{id:"close"}];
config.items = this.buildForm(config.languageId, config.site, config.languageName, config.ableEdit, config.userId, config.isAdmin, config.moderator);
dsGroups = new Ext.data.Store({
url: Toc.CONF.CONN_URL,
baseParams: {
module: 'translator',
action: 'listGroup',
site: config.site,
'languages_id': config.languageId
},
autoLoad: true,
reader: new Ext.data.JsonReader({
root: Toc.CONF.JSON_READER_ROOT,
totalProperty: Toc.CONF.JSON_READER_TOTAL_PROPERTY
},
[
'content_group'
]
)
});
config.cboGroups = new Ext.form.ComboBox({
store: dsGroups,
valueField: 'content_group',
displayField: 'content_group',
triggerAction: 'all',
mode: 'remote',
width: 300,
emptyText: '---All---',
readOnly: true,
listeners: {
select: this.onFilter,
scope: this
}
});
config.txtSearch = new Ext.form.TextField({
width: 100,
hideLabel: true
});
config.tbar = [
'->',
{text: 'Key:'},
config.txtSearch,
' ',
config.cboGroups,
' ',
{
iconCls: 'search',
handler: this.onSearch,
scope: this
}
];
Toc.GridPanel.superclass.constructor.call(this, config);
};
Ext.extend(Toc.GridPanel, Ext.Panel, {
buildForm: function(languageId, site, languageName, ableEdit, userId, isAdmin, moderator) {
this.languageId = languageId;
this.languageName = languageName;
this.ableEdit = ableEdit;
this.userId = userId;
this.isAdmin = isAdmin;
this.moderator = moderator;
this.onSetGroup(languageId, site);
if (site == 'table') {
ableEdit = false;
}
this.ds = new Ext.data.JsonStore({
url: Toc.CONF.CONN_URL,
baseParams: {
module: 'translator',
action: 'listTranslations',
languages_id: languageId,
site: site,
group: 'general'
},
root: Toc.CONF.JSON_READER_ROOT,
totalProperty: Toc.CONF.JSON_READER_TOTAL_PROPERTY,
autoLoad: true,
id: 'languages_definitions_id',
fields: [
'languages_definitions_id',
'languages_definitions_history_id',
'content_group',
'definition_key',
'definition_value_us',
'definition_value',
'user_name',
'last_modified_date',
'definition_version'
]
});
rowActions = new Ext.ux.grid.RowActions({
header: '',
widthSlope: 30,
actions: [
{iconCls: 'edit', qtip: 'edit'},
{iconCls: 'history', qtip: 'history'}
],
widthIntercept: Ext.isSafari ? 4 : 2
});
this.grdPanel = new Ext.grid.EditorGridPanel({
store: this.ds,
clicksToEdit: 1,
owner: this,
loadMask: true,
plugins: rowActions,
viewConfig: {forceFit: true },
cm: new Ext.grid.ColumnModel([
{header: 'Key', width: 200, dataIndex: 'definition_key'},
{header: 'English', width: 250, dataIndex: 'definition_value_us', id: 'english-translation'},
{header: languageName, width: 350, dataIndex: 'definition_value', editor: ableEdit ? new Ext.form.TextArea({height: 200}) : '', id: 'translation', sortable: true},
{header: 'Last Editor', width: 100, dataIndex: 'user_name', align: 'center'},
{header: 'Last Modified', width: 120, dataIndex: 'last_modified_date', align: 'center'},
{header: 'Version', width: 70, dataIndex: 'definition_version', align: 'center'},
rowActions
])
});
rowActions.on('action', this.onRowAction, this);
this.grdPanel.on("afteredit", afterEdit, this.grdPanel);
function afterEdit(obj){
var record = obj.record;
var languagesDefinitionsHistoryId = record.get('languages_definitions_history_id');
var languagesDefinitionsId = record.get("languages_definitions_id");
var definitionValue = record.get("definition_value");
Ext.Ajax.request({
url: Toc.CONF.CONN_URL,
params: {
module: 'translator',
action: 'insertTranslation',
definitionValue: definitionValue,
languagesDefinitionsHistoryId: languagesDefinitionsHistoryId,
languages_definitions_id: languagesDefinitionsId,
languages_id: languageId,
user_id: userId
},
callback: function(options, success, response) {
result = Ext.decode(response.responseText);
if (result.success == true) {
obj.grid.getStore().getById(languagesDefinitionsId).set('definition_value', definitionValue);
obj.grid.getStore().getById(languagesDefinitionsId).set('user_name', result.user_name);
obj.grid.getStore().getById(languagesDefinitionsId).set('last_modified_date', '2010-07-30 18:09:19');
obj.grid.getStore().getById(languagesDefinitionsId).commit();
}
},
scope: this
});
}
return this.grdPanel;
},
onFilter: function(){
this.grdPanel.getStore().baseParams['group'] = (this.cboGroups.getValue().split('('))[0];
this.grdPanel.getStore().reload();
},
onSearch: function(){
var store = this.grdPanel.getStore();
store.baseParams['search'] = this.txtSearch.getValue();
store.baseParams['group'] = (this.cboGroups.getValue().split('('))[0];
store.reload();
},
onPreview: function(record){
new Toc.HistoryDialog({owner: this.grdPanel, languagesDefinitionsId: record.get("languages_definitions_id"), languageId: this.languageId, isAdmin: this.isAdmin, moderator: this.moderator}).show();
},
onEdit: function(record){
if( this.ableEdit && this.site != 'table' ){
new Toc.RecordEditDialog({userId: this.userId, languageName: this.languageName, owner: this.grdPanel}).show(record.get('languages_definitions_id'), this.languageId, record.get('definition_value'));
} else if( this.ableEdit && this.site == 'table' ) {
var dlg = new Toc.RecordTableEditDialog({userId: this.userId, languageName: this.languageName, owner: this.grdPanel, languagesDefinitionsId: record.get('languages_definitions_id'), languageId:this.languageId, languagesDefinitionsHistoryId: record.get('languages_definitions_history_id')});
dlg.show();
}else {
Ext.MessageBox.alert('Warning', 'You do not have the right to modify the language.');
}
},
onSetGroup: function(languageId, site){
if(site != 'table'){
Ext.Ajax.request({
url: Toc.CONF.CONN_URL,
params: {
module: 'translator',
action: 'getGroup',
languages_id: languageId,
site: site
},
callback: function(options, success, response) {
result = Ext.decode(response.responseText);
if (result.success == true) {
this.cboGroups.setValue(result.data);
}
},
scope: this
});
}
},
onRowAction: function(grid, record, action, row, col) {
switch(action) {
case 'history':
this.onPreview(record);
break;
case 'edit':
this.onEdit(record);
break;
}
}
});
Toc.LoginDialog = function(config) {
config = config || {};
config.title = 'Login';
config.width = 300;
config.height = 150;
config.border = false;
config.modal = true;
config.layout = 'fit';
config.closable = false;
config.items = this.buildForm();
config.buttons = [
{
text: 'Get An Account',
handler: function () {
this.onGetAnAccount();
},
scope: this
},
{
text: 'Login',
handler: function () {
this.submitForm();
},
scope: this
},
{
text: 'Login as Guest',
handler: function () {
this.guestLogin();
},
scope: this
}
];
Toc.LoginDialog.superclass.constructor.call(this, config);
}
Ext.extend(Toc.LoginDialog, Ext.Window, {
show: function(){
Toc.LoginDialog.superclass.show.call(this);
},
buildForm: function(){
this.pnlLogin = new Ext.form.FormPanel({
defaults: {anchor: '90%'},
items: [
{
xtype: 'panel',
id: 'error_msg',
width: '150',
border: false,
height: 10
},
{
xtype: 'textfield',
name: 'username',
width: '150',
allowBlank: false,
fieldLabel: 'Username',
labelStyle: 'padding-left: 15px'
},
{
xtype: 'textfield',
name: 'password',
inputType : 'password',
width: '150',
allowBlank: false,
fieldLabel: 'Password',
labelStyle: 'padding-left: 15px'
},
{
xtype: 'panel',
width: '150',
border: false,
style: 'padding-left: 100px',
html: "Forget your password ?
"
}
],
keys:[{
key: Ext.EventObject.ENTER,
fn: this.submitForm,
scope: this
}]
})
return this.pnlLogin;
},
submitForm: function() {
this.pnlLogin.form.submit({
url: Toc.CONF.CONN_URL,
params: {
module: 'system',
action: 'login'
},
waitMsg: 'waiting...',
success: function(form, action) {
this.btnGetAccount.setDisabled(true);
this.btnGetAccount.setVisible(false);
this.btnLogout.setDisabled(false);
this.btnLogout.setVisible(true);
this.btnMyAccount.setDisabled(false);
this.btnMyAccount.setVisible(true);
this.btnModerator.setDisabled(false);
this.btnModerator.setVisible(true);
this.btnMyAccount.userId = action.result.records.user_id;
this.btnModerator.userId = action.result.records.user_id;
this.btnModerator.isAdmin = action.result.records.is_admin;
this.btnModerator.moderatorLanguage = action.result.records.moderator;
this.btnModerator.editLanguages = action.result.records.languages;
this.btnExport.userName = action.result.records.user_name;
this.tablePanel.owner.btnExport.userName = action.result.records.user_name;
this.treePanel.onRefresh(action.result.records.user_id, action.result.records.login_date);
this.treePanel.setParam(action.result.records.user_id, action.result.records.user_name, action.result.records.languages, action.result.records.is_admin, action.result.records.moderator);
this.tablePanel.groupPanel.setParam(action.result.records.user_id, action.result.records.user_name, action.result.records.languages, action.result.records.is_admin, action.result.records.moderator);
if(action.result.records.is_admin == 1){
this.btnImport.setDisabled(false);
this.btnImport.setVisible(true);
this.btnAddLanguage.setDisabled(false);
this.btnAddLanguage.setVisible(true);
// this.btnImportOtherLanguage.setDisabled(false);
// this.btnImportOtherLanguage.setVisible(true);
this.btnDownloader.setDisabled(false);
this.btnDownloader.setVisible(true);
this.btnEmail.setDisabled(false);
this.btnEmail.setVisible(true);
this.btnGetUser.setDisabled(false);
this.btnGetUser.setVisible(true);
}
this.labWelcome.setText('Hello '+action.result.records.user_name + '! Welcome to Tomatocart Online Translator.');
this.close();
},
failure: function(form, action) {
Ext.Msg.alert('Tips','The username and password do not match!');
},
scope: this
});
},
getPassword: function(){
new Toc.GetToken().show();
},
guestLogin: function() {
Ext.Ajax.request({
url: Toc.CONF.CONN_URL,
params: {
module: 'system',
action: 'guestLogin'
},
scope: this
});
this.tablePanel.owner.btnExport.userName = 'Guset';
this.close();
},
onGetAnAccount: function(){
new Toc.NewDialog().show();
}
});
Toc.NewDialog = function(config) {
config = config || {};
config.id = 'get_account_dialog-win';
config.title = 'Get An Account';
config.width = 400;
config.height = 450;
config.border = true;
config.modal = true;
config.layout = 'fit';
config.items = this.buildForm();
config.buttons = [
{
text: 'OK',
handler: function () {
this.submitForm();
},
scope: this
},
{
text: 'Close',
handler: function () {
this.close();
},
scope: this
}
];
Toc.NewDialog.superclass.constructor.call(this, config);
}
Ext.extend(Toc.NewDialog, Ext.Window, {
show: function(){
Toc.NewDialog.superclass.show.call(this);
},
buildForm: function(){
dsCountries = new Ext.data.Store({
url: Toc.CONF.CONN_URL,
baseParams: {
module: 'translator',
action: 'listLanguageNames'
},
reader: new Ext.data.JsonReader({
root: Toc.CONF.JSON_READER_ROOT,
totalProperty: Toc.CONF.JSON_READER_TOTAL_PROPERTY,
languages_id: 'languages_id'
},
[
'languages_id',
'language_name'
]
),
autoLoad: true
});
this.lstLanguages = new Ext.ux.Multiselect({
fieldLabel: 'Languages',
labelStyle: 'padding-left: 15px',
name: "languages",
width: 240,
height: 150,
style: 'margin-bottom: 10px',
store: dsCountries,
legend: 'Languages',
displayField: 'language_name',
valueField: 'languages_id',
isFormField: true
});
this.pnlNewAccount = new Ext.form.FormPanel({
labelWidth:105,
defaults: {anchor: '95%'},
items: [
{xtype: 'panel', border: false, height: 10},
{
xtype: 'textfield',
name: 'user_name',
width: '260',
labelStyle: 'padding-left: 10px',
allowBlank: false,
fieldLabel: 'Username'
},
{
xtype: 'textfield',
name: 'name',
width: '260',
labelStyle: 'padding-left: 10px;',
allowBlank: false,
fieldLabel: 'Name'
},
{
xtype: 'textfield',
regex: /\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/,
name: 'email',
width: '260',
labelStyle: 'padding-left: 10px',
allowBlank: false,
fieldLabel: 'E-mail'
},
{
xtype: 'textfield',
name: 'password',
inputType : 'password',
width: '260',
labelStyle: 'padding-left: 10px',
allowBlank: false,
fieldLabel: 'Password'
},
{
xtype: 'textfield',
name: 'verify_password',
inputType : 'password',
width: '260',
labelStyle: 'padding-left: 10px',
allowBlank: false,
fieldLabel: 'Verify Password'
},
{
border: false,
html: '
Please specify the language which you would like to translate. If you want to translate more than one, please hold down the CTRL (PC) or Command (Mac) key and click to select more than one value.
'
},
this.lstLanguages
]
})
return this.pnlNewAccount;
},
submitForm : function() {
this.pnlNewAccount.form.submit({
url: Toc.CONF.CONN_URL,
params: {
module: 'users',
action: 'getAccount'
},
waitMsg: 'waiting...',
success: function(form, action) {
Ext.Ajax.request({
url: Toc.CONF.CONN_URL,
params: {
module: 'system',
action: 'guestLogin'
},
scope: this
});
Ext.Msg.alert('Registration Success', 'Thank you for helping Tomatocart with translation. We will contact you in email and activate your account as soon as possible!');
this.close();
},
failure: function(form, action) {
Ext.MessageBox.alert('Tips', action.result.feedback);
},
scope: this
});
}
});
Toc.ExportDialog = function(config) {
config = config || {};
config.id = 'export_dialog-win';
config.title = 'Export';
config.width = 300;
config.height = 150;
config.border = false;
config.modal = true;
config.layout = 'fit';
config.items = this.buildForm();
config.buttons = [
{
text: 'Export',
handler: function () {
this.submitForm();
},
scope: this
},
{
text: 'Close',
handler: function () {
this.close();
},
scope: this
}
];
Toc.ExportDialog.superclass.constructor.call(this, config);
}
Ext.extend(Toc.ExportDialog, Ext.Window, {
show: function(code, userName){
this.userName = userName || null;
this.dsCountry.on('load', function() {
this.cboLanguageCode.setValue(code);
}, this);
Toc.ExportDialog.superclass.show.call(this);
},
buildForm: function(){
this.dsCountry = new Ext.data.JsonStore({
url: Toc.CONF.CONN_URL,
baseParams: {
module: 'translator',
action: 'listLanguageNames'
},
totalProperty: 'total',
root: 'records',
autoLoad: true,
fields: [
'languages_id',
'language_name',
'code'
]
});
this.cboLanguageCode = new Ext.form.ComboBox({
store: this.dsCountry,
valueField: 'code',
displayField: 'language_name',
value: 'English',
triggerAction: 'all',
fieldLabel: 'Languages',
labelStyle: 'padding-left: 15px; padding-left: 15px',
mode: 'remote',
width: 150,
allowBlank: false,
readOnly: true,
editable: false
});
this.dsVersionName = new Ext.data.JsonStore({
url: Toc.CONF.CONN_URL,
baseParams: {
module: 'translator',
action: 'listLanguageVersion'
},
totalProperty: 'total',
root: 'records',
fields: [
'versions_id',
'versions_name'
]
});
this.cboLanguageVersion = new Ext.form.ComboBox({
store: this.dsVersionName,
valueField: 'versions_id',
value: '1.0stable',
displayField: 'versions_name',
triggerAction: 'all',
fieldLabel: 'Versions',
labelStyle: 'padding-left: 15px; padding-left: 15px',
mode: 'remote',
width: 150,
emptyText: 'Languages Version',
editable: false
});
this.pnlExport = new Ext.form.FormPanel({
url: Toc.CONF.CONN_URL,
baseParams: {
module: 'translator',
action: 'export'
},
width: 200,
height: 100,
items: [
{
xtype: 'panel',
id: 'error_msg',
width: '100',
border: false,
height: 20
},
this.cboLanguageCode,
this.cboLanguageVersion
]
})
return this.pnlExport;
},
submitForm : function() {
var code = this.cboLanguageCode.getValue();
if( code == 'English'){
code = 'en_US';
}
this.pnlExport.form.baseParams['language_code'] = code;
this.pnlExport.form.baseParams['language_version'] = this.cboLanguageVersion.getValue();
this.pnlExport.form.baseParams['user'] = this.userName;
this.pnlExport.form.submit({
waitMsg: 'export data, please waiting...',
success: function(form, action) {
Ext.Msg.alert('Export the language successfully !', 'The download URL is -->' + '' + action.result.feedback + '');
this.close();
},
failure: function(form, action) {
Ext.Msg.alert('Tips', action.result.feedback);
},
scope: this
});
}
});
Toc.ImportDialog = function(config) {
config = config || {};
config.id = 'import_dialog-win';
config.title = 'Import';
config.width = 300;
config.height = 150;
config.border = true;
config.modal = true;
config.layout = 'fit';
config.items = this.buildForm();
config.buttons = [
{
text: 'Import',
handler: function () {
this.submitForm();
},
scope: this
},
{
text: 'Close',
handler: function () {
this.close();
},
scope: this
}
];
Toc.ImportDialog.superclass.constructor.call(this, config);
}
Ext.extend(Toc.ImportDialog, Ext.Window, {
show: function(){
Toc.ImportDialog.superclass.show.call(this);
},
buildForm: function(){
this.dsVersionName = new Ext.data.JsonStore({
url: Toc.CONF.CONN_URL,
baseParams: {
module: 'translator',
action: 'listLanguageVersion'
},
totalProperty: 'total',
root: 'records',
fields: [
'versions_id',
'versions_name'
]
});
this.cboLanguageVersion = new Ext.form.ComboBox({
store: this.dsVersionName,
valueField: 'versions_id',
displayField: 'versions_name',
triggerAction: 'all',
fieldLabel: 'Versions',
labelStyle: 'padding-left: 15px; padding-left: 15px',
mode: 'remote',
width: 150,
emptyText: 'Languages Version',
name: 'version',
editable: false,
allowBlank: false
});
this.pnlImport = new Ext.form.FormPanel({
width: 200,
height: 100,
items: [
{
xtype: 'panel',
id: 'error_msg',
width: '100',
border: false,
height: 10
},
{
border: false,
html: 'If you want to import the data, please click Import, otherwise please click Close!
'
},
this.cboLanguageVersion
]
})
return this.pnlImport;
},
submitForm : function() {
this.pnlImport.form.submit({
url: Toc.CONF.CONN_URL,
params: {
module: 'translator',
action: 'import'
},
waitMsg: 'waiting...',
success: function(form, action) {
Ext.Msg.alert('Success', 'import data success !');
this.close();
setTimeout( function(){location.reload();}, 2000);
},
failure: function(form, action) {
Ext.Msg.alert('Error', 'The Version is empty or import languages data error!');
this.close();
},
scope: this
});
}
});
Toc.HistoryDialog = function(config) {
config = config || {};
config.layout = 'fit';
config.title = 'Translation History';
config.id = 'translator-history-dialog';
config.modal = true;
config.width = 800;
config.height = 300;
config.items = this.buildForm(this.owner, config.languagesDefinitionsId, config.languageId, config.isAdmin, config.moderator);
config.buttons = [
{
text: 'Close',
handler: function () {
this.close();
},
scope: this
}
];
Toc.HistoryDialog.superclass.constructor.call(this, config);
};
Ext.extend(Toc.HistoryDialog, Ext.Window, {
buildForm: function(owner, languagesDefinitionsId, languageId, isAdmin, moderator) {
this.owner = owner;
this.isAdmin = isAdmin;
this.moderator = moderator;
this.languageId = languageId;
this.ds = new Ext.data.JsonStore({
url: Toc.CONF.CONN_URL,
baseParams: {
module: 'translator',
action: 'listTranslationHistory',
languages_definitions_id: languagesDefinitionsId,
languages_id: languageId
},
root: Toc.CONF.JSON_READER_ROOT,
totalProperty: Toc.CONF.JSON_READER_TOTAL_PROPERTY,
autoLoad: true,
id: 'languages_definitions_history_id',
fields: [
'languages_definitions_history_id',
'user_name',
'definition_key',
'definition_value',
'date_added'
]
});
rowActions = new Ext.ux.grid.RowActions({
header: '',
widthSlope: 30,
actions: [
{iconCls: 'delete', qtip: 'delete'}
],
widthIntercept: Ext.isSafari ? 4 : 2
});
this.grdPanel = new Ext.grid.GridPanel({
store: this.ds,
viewConfig: {forceFit: true, emptyText: 'No Records'},
languageId: languageId,
owner: this,
plugins: rowActions,
cm: new Ext.grid.ColumnModel([
{id:'languages_definitions_history_id', header: 'Users', width: 100, dataIndex: 'user_name'},
{header: 'Definition Key', width: 150, dataIndex: 'definition_key'},
{header: 'Translation', width: 220, dataIndex: 'definition_value'},
{header: 'Date Added', width: 220, dataIndex: 'date_added'},
rowActions
])
});
rowActions.on('action', this.onRowAction, this.grdPanel);
return this.grdPanel;
},
onRowAction: function(grid, record, action, row, col) {
switch(action) {
case 'delete':
grid.owner.onDelete(record);
break;
}
},
onDelete: function(record) {
if( this.isAdmin == 1 || this.languageId == this.moderator ){
Ext.MessageBox.confirm(
'Warning',
'Do you want to delete the record!',
function(btn) {
if ( btn == 'yes' ) {
Ext.Ajax.request({
url: Toc.CONF.CONN_URL,
params: {
module: 'translator',
action: 'deleteRecordHistory',
languages_definitions_history_id: record.get('languages_definitions_history_id')
},
callback: function(options, success, response) {
result = Ext.decode(response.responseText);
if (result.success == true) {
this.grdPanel.getStore().reload();
this.owner.getStore().reload();
} else {
Ext.MessageBox.alert('Tips', result.feedback);
}
},
scope: this
});
}
},
this
);
} else {
Ext.MessageBox.alert('Tips', 'Only super administrators or the coordinator can perform this operation.');
}
}
});
Toc.UserListDialog = function(config) {
config = config || {};
config.layout = 'fit';
config.title = 'Manage users';
config.modal = true;
config.width = 700;
config.height = 500;
config.closable = true;
config.items = this.buildForm();
config.buttons = [
{
text: 'Close',
handler: function () {
this.close();
},
scope: this
}
];
Toc.UserListDialog.superclass.constructor.call(this, config);
};
Ext.extend(Toc.UserListDialog, Ext.Window, {
buildForm: function() {
this.store = new Ext.data.Store({
url: Toc.CONF.CONN_URL,
baseParams: {
module: 'users',
action: 'listUsers'
},
reader: new Ext.data.JsonReader({
root: Toc.CONF.JSON_READER_ROOT,
totalProperty: Toc.CONF.JSON_READER_TOTAL_PROPERTY,
'users_id': 'users_id'
},
[
'users_id',
'user_name',
'name',
'is_admin',
'status',
'email',
'languages'
]
),
autoLoad: true
});
rowActions = new Ext.ux.grid.RowActions({
header: '',
widthSlope: 25,
actions: [
{iconCls: 'edit', qtip: 'edit'},
{iconCls: 'delete', qtip: 'delete'}
],
widthIntercept: Ext.isSafari ? 4 : 2
});
this.search = new Ext.form.TextField({name: 'search', width: 130});
this.grdPanel = new Ext.grid.GridPanel({
height: 500,
store: this.store,
owner: this,
viewConfig: {forceFit: true, emptyText: 'No Records'},
plugins: rowActions,
cm: new Ext.grid.ColumnModel([
{header: 'Username', width: 100, dataIndex: 'user_name', sortable: true},
{header: 'Name', width: 100, dataIndex: 'name', sortable: true},
{header: 'Super Admin', width: 100, dataIndex: 'is_admin', sortable: true},
{header: 'Status', width: 80, dataIndex: 'status', sortable: true},
{header: 'E-mail', width: 150, dataIndex: 'email', sortable: true},
{header: 'Languages', width: 100, dataIndex: 'languages'},
rowActions
]),
tbar: [
'->',
this.search,
'',
{
iconCls: 'search',
handler: this.onSearch,
scope: this
}],
bbar: new Ext.PageToolbar({
pageSize: 20,
store: this.store,
beforePageText: '',
firstText: 'First Page',
lastText: 'Last Page',
nextText: 'Next Page',
prevText: 'Previous Page',
afterPageText: '',
refreshText: 'Refresh',
displayInfo: true,
displayMsg: 'current {0} - {1} total: {2}',
emptyMsg: 'No data available.',
prevStepText: 'Preview Page',
nextStepText: 'Next Page'
})
});
rowActions.on('action', this.onRowAction, this.grdPanel);
return this.grdPanel;
},
onSearch: function () {
this.store.baseParams['search'] = this.search.getValue() || null;
this.store.reload();
},
onRowAction: function(grid, record, action, row, col) {
switch(action) {
case 'edit':
grid.owner.onEdit(record);
break;
case 'delete':
grid.owner.onDelete(record);
break;
}
},
onEdit: function(record){
new Toc.UserEditDialog({owner: this}).show(record.get('users_id'));
},
onDelete: function(record) {
Ext.MessageBox.confirm(
'Warning',
'Do you want delete the selected record!',
function(btn) {
if ( btn == 'yes' ) {
Ext.Ajax.request({
url: Toc.CONF.CONN_URL,
params: {
module: 'users',
action: 'deleteUser',
user_id: record.get('users_id')
},
callback: function(options, success, response) {
result = Ext.decode(response.responseText);
if (result.success == true) {
this.grdPanel.getStore().reload();
} else {
Ext.MessageBox.alert('Tips', result.feedback);
}
},
scope: this
});
}
},
this
);
}
});
Toc.UserEditDialog = function(config) {
config = config || {};
config.title = 'User Edit';
config.width = 450;
config.height = 425;
config.border = true;
config.modal = true;
config.layout = 'fit';
config.items = this.buildForm(config.owner);
config.buttons = [
{
text: 'OK',
handler: function () {
this.submitForm();
},
scope: this
},
{
text: 'Close',
handler: function () {
this.close();
},
scope: this
}
];
Toc.UserEditDialog.superclass.constructor.call(this, config);
}
Ext.extend(Toc.UserEditDialog, Ext.Window, {
show: function(userId){
this.userId = userId || null;
this.frmPanel.form.reset();
this.frmPanel.form.baseParams['user_id'] = this.userId;
if (this.userId > 0) {
this.frmPanel.load({
url: Toc.CONF.CONN_URL,
params: {
module: 'users',
action: 'loadUser',
actionType: 'get'
},
success: function(form, action) {
this.cboStatus.setValue(action.result.data.status);
this.cboIsAdmin.setValue(action.result.data.is_admin);
this.lstLanguages.setValue(action.result.data.languages);
Toc.UserEditDialog.superclass.show.call(this);
},
failure: function() {
Ext.Msg.alert('Tips', 'error');
},
scope: this
});
Toc.UserEditDialog.superclass.show.call(this);
}
},
buildForm: function(owner){
this.owner = owner;
dsStatus =new Ext.data.SimpleStore({
fields:['status','status_value'],
data:[
['Inactive','0'],
['Active','1']
]
});
this.cboStatus = new Ext.form.ComboBox({
store: dsStatus,
valueField: 'status_value',
displayField: 'status',
triggerAction: 'all',
mode: 'local',
width: 150,
value: 'Active',
readOnly: true,
fieldLabel: 'Status',
labelStyle: 'padding-left: 15px'
});
dsIsAdmin =new Ext.data.SimpleStore({
fields:['is_admin','is_admin_value'],
data:[
['True','1'],
['False','0']
]
});
this.cboIsAdmin = new Ext.form.ComboBox({
store: dsIsAdmin,
valueField: 'is_admin_value',
displayField: 'is_admin',
triggerAction: 'all',
mode: 'local',
width: 150,
value: 'False',
readOnly: true,
fieldLabel: 'Super Admin',
labelStyle: 'padding-left: 15px'
});
dsCountries = new Ext.data.Store({
url: Toc.CONF.CONN_URL,
baseParams: {
module: 'translator',
action: 'listLanguageNames'
},
reader: new Ext.data.JsonReader({
root: Toc.CONF.JSON_READER_ROOT,
totalProperty: Toc.CONF.JSON_READER_TOTAL_PROPERTY,
languages_id: 'languages_id'
},
[
'languages_id',
'language_name'
]
),
autoLoad: true
});
this.lstLanguages = new Ext.ux.Multiselect({
fieldLabel: 'Languages',
labelStyle: 'padding-left: 15px',
name: "groups[]",
width: 240,
height: 150,
style: 'margin-bottom: 10px',
store: dsCountries,
legend: 'Languages',
displayField: 'language_name',
valueField: 'languages_id',
isFormField: true
});
this.frmPanel = new Ext.form.FormPanel({
defaults: {anchor: '90%'},
url: Toc.CONF.CONN_URL,
baseParams: {
module: 'translator'
},
items: [
{
xtype: 'panel',
border: false,
style: 'padding-top: 10px'
},
{
xtype: 'textfield',
name: 'user_name',
width: '150',
labelStyle: 'padding-left: 15px',
fieldLabel: 'Username'
},
{
xtype: 'textfield',
name: 'name',
width: '150',
labelStyle: 'padding-left: 15px',
fieldLabel: 'Name'
},
{
xtype: 'textfield',
name: 'password',
inputType : 'password',
width: '260',
labelStyle: 'padding-left: 15px',
fieldLabel: 'Password'
},
{
xtype: 'textfield',
name: 'confirm_password',
inputType : 'password',
width: '260',
labelStyle: 'padding-left: 15px',
fieldLabel: 'Confirm Password'
},
this.cboIsAdmin,
this.cboStatus,
{
xtype: 'textfield',
name: 'email',
width: '150',
labelStyle: 'padding-left: 15px',
fieldLabel: 'E-mail'
},
this.lstLanguages
]
})
return this.frmPanel;
},
submitForm : function() {
if(this.cboStatus.value == 'Active') {
this.frmPanel.form.baseParams['status'] = 1;
} else {
this.frmPanel.form.baseParams['status'] = this.cboStatus.value;
}
if(this.cboIsAdmin.value == 'False') {
this.frmPanel.form.baseParams['is_admin'] = 0;
} else {
this.frmPanel.form.baseParams['is_admin'] = this.cboIsAdmin.value;
}
if(this.lstLanguages.getValue()){
this.frmPanel.form.baseParams['languages'] = this.lstLanguages.getValue();
}else {
this.frmPanel.form.baseParams['languages'] = 0;
}
this.frmPanel.form.submit({
url: Toc.CONF.CONN_URL,
params: {
module: 'users',
action: 'userUpdate'
},
waitMsg: 'waiting...',
success: function(form, action) {
this.owner.grdPanel.getStore().reload();
this.close();
},
failure: function(form, action) {
Ext.MessageBox.alert('Tips', action.result.feedback);
},
scope: this
});
}
});
Toc.RecordEditDialog = function(config) {
config = config || {};
config.title = 'Record Edit';
config.width = 600;
config.height = 480;
config.border = false;
config.modal = true;
config.layout = 'form';
config.items = this.buildForm(config.userId, config.languageName, config.owner);
config.buttons = [
{
text: 'OK',
handler: function () {
this.submitForm();
},
scope: this
},
{
text: 'Close',
handler: function () {
this.close();
},
scope: this
}
];
Toc.RecordEditDialog.superclass.constructor.call(this, config);
}
Ext.extend(Toc.RecordEditDialog, Ext.Window, {
show: function(languagesDefinitionsId, languageId, definitionValue){
this.languagesDefinitionsId = languagesDefinitionsId || null;
this.languageId = languageId || null;
this.definitionValue = definitionValue || null;
this.frmRecordEdit.form.reset();
this.frmRecordEdit.form.baseParams['languages_definitions_id'] = this.languagesDefinitionsId;
this.frmRecordEdit.form.baseParams['languages_id'] = this.languageId;
if (this.languagesDefinitionsId > 0) {
this.frmRecordEdit.load({
url: Toc.CONF.CONN_URL,
params: {
module: 'translator',
action: 'loadRecord'
},
success: function(form, action) {
this.txaEnglish.setValue(action.result.data.english);
this.txaLanguage.setValue(this.definitionValue);
this.frmRecordEdit.form.baseParams['default_value'] = action.result.data.definitionValue;
Toc.RecordEditDialog.superclass.show.call(this);
},
failure: function() {
Ext.Msg.alert('Tips', 'error');
},
scope: this
});
Toc.RecordEditDialog.superclass.show.call(this);
}
},
buildForm: function(userId, languageName, owner){
this.userId = userId;
this.owner = owner;
this.txaEnglish = new Ext.form.TextArea({
fieldLabel: 'English',
name: 'language',
width: 560,
height: '140'
});
this.txaLanguage = new Ext.form.TextArea({
fieldLabel: languageName,
emptyText: 'No Record!',
name: 'definitionValue',
allowBlank: false,
width: 560,
height: '180'
});
this.frmRecordEdit = new Ext.form.FormPanel({
layout: 'form',
border: false,
labelAlign: 'top',
height: 500,
url: Toc.CONF.CONN_URL,
baseParams: {
module: 'translator'
},
items: [
{
xtype: 'panel',
autoWidth: true,
layout: 'form',
labelSeparator: ' ',
style: 'padding-left: 15px; padding-top: 10px',
border: false,
items: [
this.txaEnglish
]
},
{
xtype: 'panel',
autoWidth: true,
layout: 'form',
labelSeparator: ' ',
style: 'padding-left: 15px; padding-top: 10px',
border: false,
items: [
this.txaLanguage
]
}
]
});
return this.frmRecordEdit;
},
submitForm : function() {
this.frmRecordEdit.form.submit({
url: Toc.CONF.CONN_URL,
params: {
module: 'translator',
action: 'insertTranslation',
user_id: this.userId
},
waitMsg: 'waiting...',
success: function(form, action) {
this.owner.getStore().getById(this.languagesDefinitionsId).set('definition_value', this.txaLanguage.getValue());
this.owner.getStore().getById(this.languagesDefinitionsId).set('user_name', action.result.user_name);
this.owner.getStore().getById(this.languagesDefinitionsId).set('last_modified_date', '2010-07-30 18:09:19');
this.owner.getStore().getById(this.languagesDefinitionsId).commit();
this.close();
},
failure: function(form, action) {
Ext.MessageBox.alert('Error', 'Errors encountered on the server.');
},
scope: this
});
}
});
Toc.MyAccountDialog = function(config) {
config = config || {};
config.title = 'My Account';
config.width = 400;
config.height = 200;
config.border = false;
config.modal = true;
config.layout = 'fit';
config.items = this.buildForm();
config.buttons = [
{
text: 'Change Password',
handler: function () {
this.onChangePassword();
},
scope: this
},
{
text: 'Close',
handler: function () {
this.close();
},
scope: this
}
];
Toc.MyAccountDialog.superclass.constructor.call(this, config);
}
Ext.extend(Toc.MyAccountDialog, Ext.Window, {
show: function(userId){
this.userId = userId || null;
this.frmMyAccount.form.reset();
this.frmMyAccount.form.baseParams['user_id'] = this.userId;
if (this.userId > 0) {
this.frmMyAccount.load({
url: Toc.CONF.CONN_URL,
params: {
module: 'users',
action: 'loadUser',
actionType: 'load'
},
success: function(form, action) {
this.frmMyAccount.findById('user_name').setText(action.result.data.user_name);
this.frmMyAccount.findById('name').setText(action.result.data.name);
this.frmMyAccount.findById('email').setText(action.result.data.email);
this.frmMyAccount.findById('languages').setText(action.result.data.languages);
Toc.UserEditDialog.superclass.show.call(this);
},
failure: function() {
Ext.Msg.alert('Tips', 'error');
},
scope: this
});
Toc.UserEditDialog.superclass.show.call(this);
}
},
buildForm: function(){
this.frmMyAccount = new Ext.form.FormPanel({
height: 200,
url: Toc.CONF.CONN_URL,
baseParams: {
module: 'translator'
},
items: [
{
xtype: 'panel',
border: false,
height: 10
},
{
xtype: 'panel',
border: false,
layout: 'column',
items: [
{xtype: 'label', width: 100, height: 25, style: 'padding-left: 15px', text: 'Username:'},
{xtype: 'label', id: 'user_name',width: 250, height: 20}
]
},
{
xtype: 'panel',
border: false,
layout: 'column',
items: [
{xtype: 'label', width: 100, height: 25, style: 'padding-left: 15px', text: 'Name:'},
{xtype: 'label', id: 'name', width: 250, height: 25}
]
},
{
xtype: 'panel',
border: false,
layout: 'column',
items: [
{xtype: 'label', width: 100, height: 25, style: 'padding-left: 15px', text: 'E-mail:'},
{xtype: 'label', id: 'email', width: 250, height: 25}
]
},
{
xtype: 'panel',
border: false,
layout: 'column',
items: [
{xtype: 'label', width: 100, height: 25, style: 'padding-left: 15px', text: 'Languages:'},
{xtype: 'label', id: 'languages', width: 250, height: 25}
]
}
]
})
return this.frmMyAccount;
},
onChangePassword: function(){
new Toc.ChangePassword().show(this.userId);
}
});
Toc.ModeratorDialog = function(config) {
config = config || {};
config.layout = 'fit';
config.title = 'Coordinator';
config.modal = true;
config.width = 700;
config.height = 500;
config.closable = true;
config.items = this.buildForm();
config.buttons = [
{
text: 'Close',
handler: function () {
this.close();
},
scope: this
}
];
Toc.ModeratorDialog.superclass.constructor.call(this, config);
};
Ext.extend(Toc.ModeratorDialog, Ext.Window, {
show: function(userId, isAdmin, moderatorLanguage, editLanguages){
this.userId = userId || null;
this.isAdmin = isAdmin || null;
this.moderatorLanguage = moderatorLanguage || null;
this.editLanguages = editLanguages || null;
if (this.isAdmin > 0) {
Toc.ModeratorDialog.superclass.show.call(this);
} else {
this.store.baseParams['user_id'] = this.userId;
Toc.ModeratorDialog.superclass.show.call(this);
}
},
buildForm: function() {
this.store = new Ext.data.Store({
url: Toc.CONF.CONN_URL,
baseParams: {
module: 'users',
action: 'listModerator'
},
reader: new Ext.data.JsonReader({
root: Toc.CONF.JSON_READER_ROOT,
totalProperty: Toc.CONF.JSON_READER_TOTAL_PROPERTY,
'languages_id': 'languages_id'
},
[
'languages_id',
'languages_name',
'moderator_name',
'moderator_id',
'users_name',
'email'
]
),
autoLoad: true
});
rowActions = new Ext.ux.grid.RowActions({
header: '',
widthSlope: 25,
actions: [
{iconCls: 'edit', qtip: 'edit'},
{iconCls: 'add', qtip: 'add'},
{iconCls: 'email', qtip: 'email'}
],
widthIntercept: Ext.isSafari ? 4 : 2
});
this.grdPanel = new Ext.grid.GridPanel({
height: 500,
store: this.store,
owner: this,
viewConfig: {forceFit: true, emptyText: 'No Records'},
plugins: rowActions,
cm: new Ext.grid.ColumnModel([
{header: 'Language', width: 120, dataIndex: 'languages_name', sortable: true},
{header: 'Coordinator', width: 120, dataIndex: 'moderator_name', sortable: true},
{header: 'Username', width: 100, dataIndex: 'users_name'},
{header: 'E-mail', width: 130, dataIndex: 'email'},
rowActions
]),
bbar: new Ext.PageToolbar({
pageSize: 20,
store: this.store,
beforePageText: '',
firstText: 'First Page',
lastText: 'Last Page',
nextText: 'Next Page',
prevText: 'Previous Page',
afterPageText: '',
refreshText: 'Refresh',
displayInfo: true,
displayMsg: 'current {0} - {1} total: {2}',
emptyMsg: 'No data available.',
prevStepText: 'Preview Page',
nextStepText: 'Next Page'
})
});
rowActions.on('action', this.onRowAction, this.grdPanel);
return this.grdPanel;
},
onRowAction: function(grid, record, action, row, col) {
switch(action) {
case 'edit':
grid.owner.onEdit(record);
break;
case 'add':
grid.owner.onAdd(record);
break;
case 'email':
grid.owner.onEmail(record);
break;
}
},
onEdit: function(record){
var ableEdit = false;
if (this.isAdmin == 1) {
ableEdit = true;
} else {
if (this.moderatorLanguage) {
this.moderatorLanguage = this.moderatorLanguage.toString();
if (this.moderatorLanguage == record.get('languages_id')) {
ableEdit = true;
}
}
}
if (ableEdit == true) {
new Toc.ModeratorEditDialog({owner: this}).show(record.get('languages_name'), record.get('languages_id'));
} else {
Ext.MessageBox.alert('Warning', 'You do not have the right to modify the language.');
}
},
onAdd: function(record){
if(this.isAdmin){
new Toc.ModeratorAddDialog({owner: this.grdPanel}).show(record.get('languages_id'), record.get('moderator_id'));
} else {
Ext.MessageBox.alert('Warning', 'Only super administrators can perform this operation.');
}
},
onEmail: function(record){
var ableEmail = false;
if (this.isAdmin == 1) {
ableEmail = true;
} else {
if (this.moderatorLanguage) {
this.moderatorLanguage = this.moderatorLanguage.toString();
if (this.moderatorLanguage == record.get('languages_id')) {
ableEmail = true;
}
}
}
if(this.editLanguages){
this.editLanguages = this.editLanguages.toString();
var arr=this.editLanguages.split(',');
for(var i=0; i< arr.length;i++){
if(arr[i] == record.get('languages_id')){
ableEmail = true;
break;
}
}
}
if (ableEmail == true) {
new Toc.NewLetterDialog().show(null, null, record.get('users_name'), record.get('email'));
} else {
Ext.MessageBox.alert('Warning', 'You do not have the right to send Email.');
}
}
});
Toc.ModeratorAddDialog = function(config) {
config = config || {};
config.title = 'Add Coordinator';
config.width = 300;
config.border = false;
config.modal = true;
config.layout = 'fit';
config.items = this.buildForm();
config.buttons = [
{
text: 'Add',
handler: function () {
this.submitForm();
},
scope: this
},
{
text: 'Close',
handler: function () {
this.close();
},
scope: this
}
];
Toc.ModeratorAddDialog.superclass.constructor.call(this, config);
}
Ext.extend(Toc.ModeratorAddDialog, Ext.Window, {
show: function(languagesId, moderatorId){
this.languagesId = languagesId || null;
this.moderatorId = moderatorId || null;
this.dsUsers.baseParams['languages_id'] = this.languagesId;
this.dsUsers.on('load', function() {
if(this.moderatorId != null){
this.cboUsers.setValue(moderatorId);
}
}, this);
Toc.ModeratorAddDialog.superclass.show.call(this);
},
buildForm: function(){
this.dsUsers = new Ext.data.JsonStore({
url: Toc.CONF.CONN_URL,
baseParams: {
module: 'translator',
action: 'listLanguageUsers'
},
totalProperty: 'total',
root: 'records',
autoLoad: true,
fields: [
'users_id',
'users_name',
'moderator'
]
});
this.cboUsers = new Ext.form.ComboBox({
store: this.dsUsers,
valueField: 'users_id',
displayField: 'users_name',
triggerAction: 'all',
fieldLabel: 'Users',
labelStyle: 'padding-left: 15px; padding-left: 15px',
mode: 'remote',
width: 150,
allowBlank: false,
readOnly: true,
editable: false
});
this.pnlModerator = new Ext.form.FormPanel({
url: Toc.CONF.CONN_URL,
baseParams: {
module: 'translator',
action: 'addModerator'
},
width: 200,
height: 60,
items: [
{
xtype: 'panel',
id: 'error_msg',
width: '100',
border: false,
height: 20
},
this.cboUsers
]
})
return this.pnlModerator;
},
submitForm : function() {
var userId = this.cboUsers.getValue();
this.pnlModerator.form.baseParams['users_id'] = userId;
this.pnlModerator.form.baseParams['languages_id'] = this.languagesId;
this.pnlModerator.form.submit({
waitMsg: 'Add the coordinator. Please wait!',
success: function(form, action) {
Ext.Msg.alert('Success', 'Add the coordinator successfully !');
this.owner.getStore().reload();
this.close();
},
failure: function(form, action) {
Ext.Msg.alert('Error', 'Add coordinator error!');
},
scope: this
});
}
});
Toc.ModeratorEditDialog = function(config) {
config = config || {};
config.layout = 'fit';
config.title = 'Register Account Management';
config.modal = true;
config.width = 600;
config.height = 400;
config.closable = true;
config.items = this.buildForm();
config.buttons = [
{
text: 'Close',
handler: function () {
this.close();
},
scope: this
}
];
Toc.ModeratorEditDialog.superclass.constructor.call(this, config);
};
Ext.extend(Toc.ModeratorEditDialog, Ext.Window, {
show: function(languagesName, languagesId){
this.languagesName = languagesName || null;
this.languagesId = languagesId || null;
this.store.baseParams['languages_Name'] = this.languagesName;
Toc.ModeratorEditDialog.superclass.show.call(this);
},
buildForm: function() {
this.store = new Ext.data.Store({
url: Toc.CONF.CONN_URL,
baseParams: {
module: 'translator',
action: 'listLanguageRegisters'
},
reader: new Ext.data.JsonReader({
root: Toc.CONF.JSON_READER_ROOT,
totalProperty: Toc.CONF.JSON_READER_TOTAL_PROPERTY,
'users_id': 'users_id'
},
[
'users_id',
'user_name',
'name',
'status',
'email'
]
),
autoLoad: true
});
rowActions = new Ext.ux.grid.RowActions({
header: '',
widthSlope: 25,
actions: [
{iconCls: 'edit', qtip: 'edit'},
{iconCls: 'email', qtip: 'email'}
],
widthIntercept: Ext.isSafari ? 4 : 2
});
this.grdPanel = new Ext.grid.GridPanel({
height: 500,
store: this.store,
owner: this,
viewConfig: {forceFit: true, emptyText: 'No accounts to be activated yet.'},
plugins: rowActions,
cm: new Ext.grid.ColumnModel([
{header: 'Username', width: 100, dataIndex: 'user_name', sortable: true},
{header: 'Name', width: 100, dataIndex: 'name', sortable: true},
{header: 'Status', width: 80, dataIndex: 'status', sortable: true},
{header: 'E-mail', width: 150, dataIndex: 'email'},
rowActions
])
});
rowActions.on('action', this.onRowAction, this.grdPanel);
return this.grdPanel;
},
onRowAction: function(grid, record, action, row, col) {
switch(action) {
case 'edit':
grid.owner.onEdit(record);
break;
case 'email':
grid.owner.onEmail(record);
break;
}
},
onEdit: function(record){
new Toc.ModeratorAccountEditDialog({owner: this}).show(record.get('users_id'), this.languagesId, record.get('status'));
},
onEmail: function(record){
new Toc.NewLetterDialog().show(null, null, record.get('user_name'), record.get('email'));
}
});
Toc.ModeratorAccountEditDialog = function(config) {
config = config || {};
config.title = 'User Edit';
config.width = 300;
config.height = 120;
config.border = true;
config.modal = true;
config.layout = 'fit';
config.items = this.buildForm(config.owner);
config.buttons = [
{
text: 'OK',
handler: function () {
this.submitForm();
},
scope: this
},
{
text: 'Close',
handler: function () {
this.close();
},
scope: this
}
];
Toc.ModeratorAccountEditDialog.superclass.constructor.call(this, config);
}
Ext.extend(Toc.ModeratorAccountEditDialog, Ext.Window, {
show: function(usersId, languagesId, lastStatus){
this.usersId = usersId || null;
this.languagesId = languagesId || null;
this.lastStatus = lastStatus || null;
this.frmPanel.form.baseParams['users_id'] = this.usersId;
this.frmPanel.form.baseParams['languages_id'] = this.languagesId;
this.frmPanel.form.baseParams['last_status'] = this.lastStatus;
if (this.usersId > 0) {
Toc.ModeratorAccountEditDialog.superclass.show.call(this);
}
},
buildForm: function(owner){
this.owner = owner;
dsStatus =new Ext.data.SimpleStore({
fields:['status','status_value'],
data:[
['Inactive','0'],
['Active','1']
]
});
this.cboStatus = new Ext.form.ComboBox({
store: dsStatus,
valueField: 'status_value',
displayField: 'status',
triggerAction: 'all',
mode: 'local',
width: 100,
value: 'Active',
readOnly: true,
fieldLabel: 'Status',
labelStyle: 'padding-left: 15px'
});
this.frmPanel = new Ext.form.FormPanel({
defaults: {anchor: '90%'},
url: Toc.CONF.CONN_URL,
baseParams: {
module: 'translator'
},
items: [
{
xtype: 'panel',
border: false,
style: 'padding-top: 10px'
},
this.cboStatus
]
})
return this.frmPanel;
},
submitForm : function() {
if(this.cboStatus.value == 'Active') {
this.frmPanel.form.baseParams['status'] = 1;
this.frmPanel.form.submit({
url: Toc.CONF.CONN_URL,
params: {
module: 'translator',
action: 'moderatorAccountEdit'
},
waitMsg: 'waiting...',
success: function(form, action) {
this.owner.grdPanel.getStore().reload();
this.close();
},
failure: function(form, action) {
Ext.MessageBox.alert('Tips', action.result.feedback);
this.close();
},
scope: this
});
} else {
Ext.MessageBox.alert('Tips', 'Operation not Allowed');
this.close();
}
}
});
Toc.GetPassword = function(config) {
config = config || {};
config.title = 'Get Password';
config.width = 400;
config.height = 260;
config.border = false;
config.modal = true;
config.layout = 'fit';
config.closable = false;
config.items = this.buildForm();
config.buttons = [
{
text: 'OK',
handler: function () {
this.submitForm();
},
scope: this
},
{
text: 'Cancel',
handler: function () {
this.close();
},
scope: this
}
];
Toc.GetPassword.superclass.constructor.call(this, config);
}
Ext.extend(Toc.GetPassword, Ext.Window, {
show: function(userId){
this.userId = userId || null;
Toc.GetPassword.superclass.show.call(this);
},
buildForm: function(){
this.pnlGetPassword = new Ext.form.FormPanel({
defaults: {anchor: '90%'},
labelWidth: 150,
items: [
{
xtype: 'panel',
width: '200',
border: false,
height: 90,
style: 'padding-left: 15px;padding-top: 15px',
html: 'Put in the verification token you\'ve received. Reset the new password. The new password will work only when the correct token is written down.
Notice: Do not leave this window before login!
'
},
{
xtype: 'textfield',
name: 'token',
width: '200',
allowBlank: false,
fieldLabel: 'Token',
labelStyle: 'padding-left: 15px'
},
{
xtype: 'textfield',
name: 'new_password',
inputType : 'password',
width: '200',
allowBlank: false,
fieldLabel: 'New Password',
labelStyle: 'padding-left: 15px'
},
{
xtype: 'textfield',
name: 'password_confirmation',
inputType : 'password',
width: '200',
allowBlank: false,
fieldLabel: 'Password Confirmation',
labelStyle: 'padding-left: 15px'
}
],
keys:[{
key: Ext.EventObject.ENTER,
fn: this.submitForm,
scope: this
}]
})
return this.pnlGetPassword;
},
submitForm : function() {
this.pnlGetPassword.form.submit({
url: Toc.CONF.CONN_URL,
params: {
module: 'users',
action: 'getPassword',
user_id: this.userId
},
waitMsg: 'waiting...',
success: function(form, action) {
Ext.Msg.alert('Success', action.result.feedback);
this.close();
},
failure: function(form, action) {
if(action.failureType != 'client') {
Ext.MessageBox.alert('Tips', action.result.feedback);
}
},
scope: this
});
}
});
Toc.NewTranslationDialog = function(config) {
config = config || {};
config.title = 'Contact Us';
config.width = 430;
config.height = 220;
config.border = false;
config.modal = true;
config.layout = 'fit';
config.items = this.buildForm();
config.buttons = [
{
text: 'Email Us',
handler: function () {
new Toc.NewLetterDialog().show(null, null, 'Tomatocart Online Translator System', 'translator@tomatocart.com');
},
scope: this
},
{
text: 'Close',
handler: function () {
this.close();
},
scope: this
}
];
Toc.NewTranslationDialog.superclass.constructor.call(this, config);
}
Ext.extend(Toc.NewTranslationDialog, Ext.Window, {
show: function(){
Toc.NewTranslationDialog.superclass.show.call(this);
},
buildForm: function(){
this.pnlNewtranslation = new Ext.form.FormPanel({
width: 200,
height: 100,
encodeHtml: false,
html: "Contact us (translator@tomatocart.com) for any of the following reasons, or for no reason at all:
1. To add a new language to TomatoCart's translation list;
2. To add a new language to your translation list;
3. Suggestions about Online Translator or TomatoCart.
"
})
return this.pnlNewtranslation;
}
});
Toc.RecordTableEditDialog = function(config) {
config = config || {};
config.id = 'translator_table_edit_dialog-win';
config.title = 'Record Table Edit';
config.width = 800;
config.height = 400;
config.modal = true;
config.layout = 'fit';
config.items = this.buildGrid(config.userId, config.languageName, config.owner, config.languagesDefinitionsId, config.languageId, config.languagesDefinitionsHistoryId);
config.source = {};
config.clicksToEdit = 1;
Toc.RecordTableEditDialog.superclass.constructor.call(this, config);
};
Ext.extend(Toc.RecordTableEditDialog, Ext.Window, {
buildGrid: function(userId, languageName, owner, languagesDefinitionsId, languageId, languagesDefinitionsHistoryId){
this.ds = new Ext.data.JsonStore({
url: Toc.CONF.CONN_URL,
baseParams: {
module: 'translator',
action: 'loadTableRecord',
languages_definitions_id: languagesDefinitionsId,
languages_id: languageId
},
root: Toc.CONF.JSON_READER_ROOT,
totalProperty: Toc.CONF.JSON_READER_TOTAL_PROPERTY,
autoLoad: true,
id: 'key',
fields: [
'key',
'default_value',
'value'
]
});
this.grdPanel = new Ext.grid.EditorGridPanel({
store: this.ds,
clicksToEdit: 1,
owner: this,
loadMask: true,
viewConfig: {forceFit: true },
cm: new Ext.grid.ColumnModel([
{header: 'Key', width: 250, dataIndex: 'key'},
{header: 'English', width: 250, dataIndex: 'default_value'},
{
header: languageName,
width: 450,
dataIndex: 'value',
editor: new Ext.form.TextArea({height: 200})
}
])
});
this.grdPanel.on("afteredit", afterEdit, this.grdPanel);
function afterEdit(obj){
var record = obj.record;
Ext.Ajax.request({
url: Toc.CONF.CONN_URL,
params: {
module: 'translator',
action: 'insertTableSiteTranslation',
definition_value: record.get("value"),
definition_key: record.get("key"),
languages_definitions_id: languagesDefinitionsId,
languages_definitions_history_id: languagesDefinitionsHistoryId,
language_id: languageId,
user_id: userId
},
scope: this
});
owner.getStore().reload();
}
return this.grdPanel;
}
});
Toc.DownloaderDialog = function(config) {
config = config || {};
config.layout = 'fit';
config.title = 'Downloader List';
config.modal = true;
config.width = 700;
config.height = 500;
config.closable = true;
config.items = this.buildForm();
config.buttons = [
{
text: 'Close',
handler: function () {
this.close();
},
scope: this
}
];
Toc.DownloaderDialog.superclass.constructor.call(this, config);
};
Ext.extend(Toc.DownloaderDialog, Ext.Window, {
buildForm: function(userId) {
this.store = new Ext.data.Store({
url: Toc.CONF.CONN_URL,
baseParams: {
module: 'users',
action: 'listDownloaders'
},
reader: new Ext.data.JsonReader({
root: Toc.CONF.JSON_READER_ROOT,
totalProperty: Toc.CONF.JSON_READER_TOTAL_PROPERTY,
'id': 'id'
},
[
'id',
'users_name',
'ip_address',
'download_date',
'definition_version',
'language_name'
]
),
autoLoad: true
});
rowActions = new Ext.ux.grid.RowActions({
header: '',
widthSlope: 25,
actions: [
{iconCls: 'delete', qtip: 'delete'}
],
widthIntercept: Ext.isSafari ? 4 : 2
});
this.grdPanel = new Ext.grid.GridPanel({
height: 500,
store: this.store,
owner: this,
viewConfig: {forceFit: true, emptyText: 'No Records'},
plugins: rowActions,
cm: new Ext.grid.ColumnModel([
{header: 'Downloader', width: 100, dataIndex: 'users_name', sortable: true},
{header: 'Language', width: 100, dataIndex: 'language_name', sortable: true},
{header: 'Version', width: 100, dataIndex: 'definition_version', sortable: true},
{header: 'Address', width: 80, dataIndex: 'ip_address'},
{header: 'Date', width: 150, dataIndex: 'download_date'},
rowActions
]),
bbar: new Ext.PageToolbar({
pageSize: 20,
store: this.store,
beforePageText: '',
firstText: 'First Page',
lastText: 'Last Page',
nextText: 'Next Page',
prevText: 'Previous Page',
afterPageText: '',
refreshText: 'Refresh',
displayInfo: true,
displayMsg: 'current {0} - {1} total: {2}',
emptyMsg: 'No data available.',
prevStepText: 'Preview Page',
nextStepText: 'Next Page'
})
});
rowActions.on('action', this.onRowAction, this.grdPanel);
return this.grdPanel;
},
onRowAction: function(grid, record, action, row, col) {
switch(action) {
case 'delete':
grid.owner.onDelete(record);
break;
}
},
onDelete: function(record) {
Ext.MessageBox.confirm(
'Warning',
'Do you want delete the selected record!',
function(btn) {
if ( btn == 'yes' ) {
Ext.Ajax.request({
url: Toc.CONF.CONN_URL,
params: {
module: 'users',
action: 'deleteDownloader',
downloader_id: record.get('id')
},
callback: function(options, success, response) {
result = Ext.decode(response.responseText);
if (result.success == true) {
this.grdPanel.getStore().reload();
} else {
Ext.MessageBox.alert('Tips', result.feedback);
}
},
scope: this
});
}
},
this
);
}
});
Toc.EmailComposerDialog = function(config) {
config = config || {};
config.id = 'composer_dialog-win';
config.layout = 'fit';
config.title = 'Compose Email';
config.width = 700;
config.height = 460;
config.modal = true;
config.items = this.buildComposerForm();
Toc.EmailComposerDialog.superclass.constructor.call(this, config);
this.accountsId = null;
this.messagesId = null;
this.contentType = 'html';
this.attachments = [];
};
Ext.extend(Toc.EmailComposerDialog, Ext.Window, {
buildComposerForm: function(){
this.ds = new Ext.data.JsonStore({
url: Toc.CONF.CONN_URL,
baseParams: {
module: 'translator',
action: 'listComposerTo'
},
totalProperty: 'total',
root: 'records',
autoLoad: true,
fields: [
'signature',
'email_address'
],
autoLoad: true
});
this.frmComposer = new Ext.form.FormPanel({
url: Toc.CONF.CONN_URL,
border: false,
labelSeparator: ' ',
timeout: 300,
defaults: {
anchor: '99%',
labelStyle: 'padding-left: 3px'
},
items: [
this.txtFrom = new Ext.form.TextField({fieldLabel: 'From:', name: 'from', value: 'Tomatocart Online Translator System', allowBlank: false}),
this.cboTo = new Ext.form.ComboBox({
fieldLabel: 'Send To:',
store: this.ds,
displayField: 'signature',
valueField: 'email_address',
editable: false,
allowBlank: false,
triggerAction: 'all',
hiddenName: 'to'
}),
this.cboCc = new Ext.form.ComboBox({
fieldLabel:'Cc:',
store: this.ds,
hiddenName: 'cc',
valueField: 'email_address',
displayField: 'signature',
editable: false,
triggerAction: 'all'
}),
this.txtSubject = new Ext.form.TextField({fieldLabel: 'Subject:', name: 'subject', allowBlank: false}),
this.stxAttachments = new Ext.ux.form.StaticTextField({fieldLabel: 'Attachments:', submitValue: false}),
this.txtContent = new Ext.form.HtmlEditor({
hideLabel: true,
name: 'body',
listeners: {
editmodechange: this.onEditModeChange,
scope: this
}
})
],
tbar:[
{text: 'Send', iconCls: 'send', handler: this.sendMail, scope: this},
'-',
{text: 'Show', iconCls: 'show', menu: this.buildShowMenu()},
'-',
{text: 'Attachments', iconCls: 'attachment', handler: this.onAttachments, scope: this}
]
});
return this.frmComposer;
},
buildShowMenu: function(){
return new Ext.menu.Menu({
defaults: {xtype: 'menucheckitem'},
items: [
this.chkShowSenders = new Ext.menu.CheckItem({text: 'Sender', checked: true, checkHandler: this.onShowFieldCheck, scope: this}),
this.chkShowCcField = new Ext.menu.CheckItem({text: 'CCField', checked: false, checkHandler: this.onShowFieldCheck, scope: this})
]
});
},
onEditModeChange: function(htmlEditor, sourceEdit) {
if (sourceEdit === true) {
this.contentType = 'text';
} else {
this.contentType = 'html';
}
},
showCC: function (show) {
this.cboCc.getEl().up('.x-form-item').setDisplayed(show);
},
showAttachments: function(show) {
this.stxAttachments.getEl().up('.x-form-item').setDisplayed(show);
},
onShowFieldCheck: function (check, checked) {
switch (check.id) {
case this.chkShowSenders.id:
this.cboTo.getEl().up('.x-form-item').setDisplayed(checked);
break;
case this.chkShowCcField.id:
this.showCC(checked);
break;
}
},
show: function (id) {
this.messagesId = id || null;
this.frmComposer.form.reset();
Toc.EmailComposerDialog.superclass.show.call(this);
this.showCC(false);
this.showAttachments(false);
},
onAttachments: function(){
var dlg = new Toc.AttachmentsDialog({owner: this});
dlg.on('close', function() {
this.attachments = dlg.getAttachments();
this.stxAttachments.setValue(this.attachments.join(';'));
this.showAttachments((this.attachments.length > 0) ? true : false);
}, this);
dlg.show();
},
sendMail: function(){
this.frmComposer.form.submit({
params: {
module: 'translator',
action: 'sendMail',
content_type: this.contentType,
attachments: this.attachments.join(';')
},
waitMsg: 'Please waiting ...',
success: function(form, action) {
Ext.MessageBox.alert('Success !', action.result.feedback);
Toc.EmailComposerDialog.superclass.close.call(this);
},
failure: function(form, action) {
if (action.failureType != 'client') {
Ext.MessageBox.alert('Error', action.result.feedback);
}
},
scope: this
});
},
setAccountsId: function(accountsId) {
this.accountsId = accountsId;
},
setTo: function(to) {
this.txtTo.setValue(to);
},
setCc: function(cc) {
this.cboCc.setValue(cc);
this.showCC(true);
},
setBody: function(body) {
this.txtContent.setValue(body);
},
setSubject: function(subject) {
this.txtSubject.setValue(subject);
},
setAttachments: function(attachments) {
this.attachments = attachments;
this.stxAttachments.setValue(this.attachments.join(';'));
this.showAttachments(true);
}
});
Toc.NewLetterDialog = function(config) {
config = config || {};
config.title = 'Email';
config.width = 740;
config.height = 450;
config.border = true;
config.modal = true;
config.layout = 'fit';
config.items = this.buildForm();
config.buttons = [
{
text: 'Send',
handler: function () {
this.submitForm();
},
scope: this
},
{
text: 'Close',
handler: function () {
this.close();
},
scope: this
}
];
Toc.NewLetterDialog.superclass.constructor.call(this, config);
this.contentType = 'html';
}
Ext.extend(Toc.NewLetterDialog, Ext.Window, {
show: function(fromName, fromAddress, toName, toAddress){
this.fromName = fromName || null;
this.fromAddress = fromAddress || null;
this.toName = toName || null;
this.toAddress = toAddress || null;
if(this.fromName != null) {
this.txtFromName.setValue(this.fromName);
}
if(this.fromAddress != null) {
this.txtFromAddress.setValue(this.fromAddress);
}
if(this.toName != null) {
this.txtToName.setValue(this.toName);
}
if(this.toAddress != null) {
this.txtToAddress.setValue(this.toAddress);
}
Toc.NewLetterDialog.superclass.show.call(this);
},
buildForm: function(){
this.pnlNewLetter = new Ext.form.FormPanel({
labelWidth:120,
defaults: {
anchor: '99%',
labelStyle: 'padding-left: 10px'
},
items: [
{xtype: 'panel', border: false, height: 10},
this.txtFromName = new Ext.form.TextField({fieldLabel: 'From Name', name: 'from_name', allowBlank: false}),
this.txtFromAddress = new Ext.form.TextField({fieldLabel: 'From Address', name: 'from_address', vtype: 'email', allowBlank: false}),
this.txtToName = new Ext.form.TextField({fieldLabel: 'To Name', name: 'to_name', allowBlank: false, readOnly: true}),
this.txtToAddress = new Ext.form.TextField({fieldLabel: 'To Address', name: 'to_address', vtype: 'email', allowBlank: false, readOnly: true}),
this.txtSubject = new Ext.form.TextField({fieldLabel: 'Subject', name: 'subject', allowBlank: false}),
this.txtContent = new Ext.form.HtmlEditor({
hideLabel: true,
name: 'body',
listeners: {
editmodechange: this.onEditModeChange,
scope: this
}
})
]
})
return this.pnlNewLetter;
},
onEditModeChange: function(htmlEditor, sourceEdit) {
if (sourceEdit === true) {
this.contentType = 'text';
} else {
this.contentType = 'html';
}
},
submitForm : function() {
this.pnlNewLetter.form.submit({
url: Toc.CONF.CONN_URL,
params: {
module: 'translator',
action: 'SendNewsLetter',
content_type: this.contentType
},
waitMsg: 'waiting...',
success: function(form, action) {
Ext.MessageBox.alert('Success !', action.result.feedback);
this.close();
},
failure: function(form, action) {
if(action.failureType != 'client') {
Ext.MessageBox.alert('Tips', action.result.feedback);
}
},
scope: this
});
}
});
Toc.AttachmentsDialog = function(config) {
config = config || {};
config.id = 'attachments_dialog-win';
config.title = 'Attachment';
config.width = 400;
config.height = 260;
config.layout = 'fit';
config.modal = true;
config.items = this.buildGrid();
config.buttons = [
{
text: 'Add',
handler: this.onAdd,
scope: this
},
{
text: 'Close',
handler: function() {
this.close();
},
scope: this
}
];
Toc.AttachmentsDialog.superclass.constructor.call(this, config);
}
Ext.extend(Toc.AttachmentsDialog, Ext.Window, {
buildGrid: function() {
var rowActions = new Ext.ux.grid.RowActions({
actions:[
{iconCls: 'delete', qtip: 'delete'}
],
widthIntercept: Ext.isSafari ? 4 : 2
});
rowActions.on('action', this.onRowAction, this);
this.grdAttachments = new Ext.grid.GridPanel({
ds: new Ext.data.Store({
url: Toc.CONF.CONN_URL,
baseParams: {
module: 'translator',
action: 'listAttachments'
},
reader: new Ext.data.JsonReader(
{
root: 'records',
totalProperty: 'total',
id: 'name'
},
['name']
),
autoLoad: true
}),
cm: new Ext.grid.ColumnModel([
{header: 'Name', dataIndex: 'name', sortable: true},
rowActions
]),
plugins: rowActions,
view: new Ext.grid.GridView({
forceFit: true,
emptyText: 'There is no record to display !'
})
});
return this.grdAttachments;
},
onAdd: function() {
var dlg = new Toc.FileUploadDialog();
dlg.on('saveSuccess', function(feedback, fileName){
this.grdAttachments.getStore().reload();
}, this);
dlg.show();
},
onDelete: function(record) {
var attachment = record.get('name');
Ext.Ajax.request({
url: Toc.CONF.CONN_URL,
params: {
module: 'translator',
action: 'removeAttachment',
name: attachment
},
callback: function(options, success, response) {
var result = Ext.decode(response.responseText);
if (result.success == false) {
Ext.MessageBox.alert('Error', result.feedback);
}
this.grdAttachments.getStore().reload();
},
scope: this
});
},
onRowAction: function(grid, record, action, row, col) {
this.onDelete(record);
},
getAttachments: function () {
var store = this.grdAttachments.getStore();
var attachments = [];
for (var i = 0; i < store.getTotalCount(); i++) {
attachments.push(store.getAt(i).get('name'));
}
return attachments;
}
});
Toc.FileUploadDialog = function(config) {
config = config || {};
config.id = 'upload_dialog-win';
config.title = 'Upload';
config.width = 400;
config.modal = true;
config.items = this.buildForm();
config.buttons = [
{
text: 'Save',
handler: this.submitForm,
scope: this
},
{
text: 'Close',
handler: function() {
this.close();
},
scope: this
}
];
this.addEvents({'saveSuccess': true});
Toc.FileUploadDialog.superclass.constructor.call(this, config);
}
Ext.extend(Toc.FileUploadDialog, Ext.Window, {
buildForm: function() {
this.frmUpload = new Ext.form.FormPanel({
url: Toc.CONF.CONN_URL,
baseParams: {
module: 'translator',
action: 'uploadAttachment'
},
fileUpload: true,
items: [
{xtype: 'statictextfield', hideLabel: true, value: 'Please select the files to upload to the server. '},
{xtype: 'fileuploadfield', fieldLabel: 'File', name: 'file_upload', anchor: '97%', allowBlank: false}
]
});
return this.frmUpload;
},
submitForm: function() {
this.frmUpload.form.submit({
waitMsg: 'Please waiting ...',
success: function(form, action) {
this.fireEvent('saveSuccess', action.result.feedback);
this.close();
},
failure: function(form, action) {
if (action.failureType != 'client') {
Ext.MessageBox.alert('Error', action.result.feedback);
}
},
scope: this
});
}
});
Toc.LanguagesAddDialog = function(config) {
config = config || {};
config.id = 'languages-edit-dialog-win';
config.title = 'Add Languages';
config.width = 600;
config.modal = true;
config.items = this.buildForm();
config.buttons = [
{
text: 'OK',
handler: function() {
this.submitForm();
},
scope: this
},
{
text: 'Close',
handler: function() {
this.close();
},
scope: this
}
];
Toc.LanguagesAddDialog.superclass.constructor.call(this, config);
}
Ext.extend(Toc.LanguagesAddDialog, Ext.Window, {
show: function () {
Toc.LanguagesAddDialog.superclass.show.call(this);
},
buildForm: function() {
this.dsTextDirections = new Ext.data.JsonStore({
root: 'rows',
data: {
rows : [
{id: 'ltr', text: 'ltr'},
{id: 'rtl', 'text': 'rtl'}
]
},
fields: [
{name: 'id', mapping: 'id'},
{name: 'text', mapping: 'text'}
],
autoLoad: true
});
this.dsParentLanguages = new Ext.data.Store({
url: Toc.CONF.CONN_URL,
baseParams: {
module: 'translator',
action: 'listLanguages'
},
reader: new Ext.data.JsonReader({
root: Toc.CONF.JSON_READER_ROOT,
fields: ['languages_id', 'language_name']
}),
autoLoad: true
});
this.frmEditLanguage = new Ext.form.FormPanel({
url: Toc.CONF.CONN_URL,
baseParams: {
module: 'translator',
action: 'saveLanguage'
},
layoutConfig: {
labelSeparator: ''
},
defaults: {
anchor: '99%'
},
labelWidth: 180,
items: [
{
xtype: 'textfield',
fieldLabel: 'Name:',
name: 'name',
allowBlank: false
},
{
xtype: 'textfield',
fieldLabel: 'Code:',
name: 'code',
allowBlank: false
},
{
xtype: 'textfield',
fieldLabel: 'Local:',
name: 'locale',
allowBlank: false
},
{
xtype: 'textfield',
fieldLabel: 'Character Set:',
name: 'charset',
allowBlank: false
},
{
xtype: 'combo',
fieldLabel: 'Text Direction:',
name: 'text_direction',
id: 'text_direction',
mode: 'local',
store: this.dsTextDirections,
value: 'ltr',
displayField: 'text',
valueField: 'id',
triggerAction: 'all',
hiddenName: 'text_id',
allowBlank: false
},
{
xtype: 'textfield',
fieldLabel: 'Short Date Format:',
name: 'date_format_short',
allowBlank: false
},
{
xtype: 'textfield',
fieldLabel: 'Long Date Format:',
name: 'date_format_long',
allowBlank: false
},
{
xtype: 'textfield',
fieldLabel: 'Time Format:',
name: 'time_format',
allowBlank: false
},
{
xtype: 'textfield',
fieldLabel: 'Default Currency:',
name: 'currencies_id',
allowBlank: false
},
{
xtype: 'textfield',
fieldLabel: 'Currency Decimal Separator:',
name: 'numeric_separator_decimal',
allowBlank: false
},
{
xtype: 'textfield',
fieldLabel: 'Currency Thousands Separator:',
name: 'numeric_separator_thousands',
allowBlank: false
},
{
xtype: 'combo',
fieldLabel: 'Parent Language:',
mode: 'model',
store: this.dsParentLanguages,
displayField: 'language_name',
valueField: 'languages_id',
triggerAction: 'all',
hiddenName: 'parent_id'
},
{
xtype: 'numberfield',
fieldLabel: 'Sort Order:',
name: 'sort_order'
}
]
});
return this.frmEditLanguage;
},
submitForm : function() {
this.frmEditLanguage.form.submit({
waitMsg: 'Please waiting ...',
success: function(form, action){
this.close();
setTimeout( function(){location.reload();}, 2000);
},
failure: function(form, action) {
if (action.failureType != 'client') {
Ext.Msg.alert('Error', 'Add a language error !');
}
},
scope: this
});
}
});
Toc.ProgressDialog = function(config) {
config = config || {};
config.layout = 'fit';
config.title = 'Translate Progress';
config.modal = true;
config.width = 700;
config.height = 450;
config.closable = true;
config.items = this.buildForm();
config.buttons = [
{
text: 'Close',
handler: function () {
this.close();
},
scope: this
}
];
Toc.ProgressDialog.superclass.constructor.call(this, config);
};
Ext.extend(Toc.ProgressDialog, Ext.Window, {
buildForm: function(userId) {
this.store = new Ext.data.Store({
url: Toc.CONF.CONN_URL,
baseParams: {
module: 'translator',
action: 'listProgress'
},
reader: new Ext.data.JsonReader({
root: Toc.CONF.JSON_READER_ROOT,
totalProperty: Toc.CONF.JSON_READER_TOTAL_PROPERTY
},
[
'languages_name',
'definition_version',
'status',
'last_modified'
]
),
autoLoad: true
});
this.grdPanel = new Ext.grid.GridPanel({
store: this.store,
owner: this,
viewConfig: {forceFit: true, emptyText: 'No Records'},
loadMask:{mask: 'Loading...'},
cm: new Ext.grid.ColumnModel([
{header: 'Languages Name', width: 100, dataIndex: 'languages_name', sortable: true},
{header: 'Definition Version', width: 100, dataIndex: 'definition_version', align: 'center', sortable: true},
{header: 'Status', width: 100, dataIndex: 'status', align: 'center', sortable: true},
{header: 'Last Modified', width: 150, dataIndex: 'last_modified', align: 'center', sortable: true}
])
});
return this.grdPanel;
}
});
Toc.FaqListDialog = function(config) {
config = config || {};
config.layout = 'fit';
config.title = 'Help';
config.modal = true;
config.width = 800;
config.height = 500;
config.closable = true;
config.items = this.buildForm();
config.buttons = [
{
text: 'Add',
handler: function () {
this.onAdd();
},
scope: this
},
{
text: 'Close',
handler: function () {
this.close();
},
scope: this
}
];
Toc.FaqListDialog.superclass.constructor.call(this, config);
};
Ext.extend(Toc.FaqListDialog, Ext.Window, {
show: function(isAdmin) {
this.isAdmin = isAdmin || null;
Toc.FaqListDialog.superclass.show.call(this);
},
buildForm: function() {
this.store = new Ext.data.Store({
url: Toc.CONF.CONN_URL,
baseParams: {
module: 'translator',
action: 'listFaqs'
},
reader: new Ext.data.JsonReader({
root: Toc.CONF.JSON_READER_ROOT,
totalProperty: Toc.CONF.JSON_READER_TOTAL_PROPERTY,
'faqs_id': 'faqs_id'
},
[
'faqs_id',
'languages_id',
'faqs_question',
'faqs_short_answer',
'faqs_answer',
'faqs_date_added',
'faqs_last_modified'
]
),
autoLoad: true
});
rowActions = new Ext.ux.grid.RowActions({
header: '',
widthSlope: 25,
actions: [
{iconCls: 'info', qtip: 'info'},
{iconCls: 'edit', qtip: 'edit'},
{iconCls: 'delete', qtip: 'delete'}
],
widthIntercept: Ext.isSafari ? 4 : 2
});
this.search = new Ext.form.TextField({name: 'search', width: 130});
this.grdPanel = new Ext.grid.GridPanel({
height: 500,
store: this.store,
owner: this,
viewConfig: {forceFit: true, emptyText: 'No Records'},
plugins: rowActions,
cm: new Ext.grid.ColumnModel([
{header: 'ID', width: 20, dataIndex: 'faqs_id', sortable: true},
{header: 'Question', width: 100, dataIndex: 'faqs_question', sortable: true},
{header: 'Short Answer', width: 100, dataIndex: 'faqs_short_answer'},
rowActions
]),
tbar: [
'->',
this.search,
'',
{
iconCls: 'search',
handler: this.onSearch,
scope: this
}],
bbar: new Ext.PageToolbar({
pageSize: 20,
store: this.store,
beforePageText: '',
firstText: 'First Page',
lastText: 'Last Page',
nextText: 'Next Page',
prevText: 'Previous Page',
afterPageText: '',
refreshText: 'Refresh',
displayInfo: true,
displayMsg: 'current {0} - {1} total: {2}',
emptyMsg: 'No data available.',
prevStepText: 'Preview Page',
nextStepText: 'Next Page'
})
});
rowActions.on('action', this.onRowAction, this.grdPanel);
return this.grdPanel;
},
onSearch: function () {
this.store.baseParams['search'] = this.search.getValue() || null;
this.store.reload();
},
onRowAction: function(grid, record, action, row, col) {
switch(action) {
case 'info':
grid.owner.onInfo(record);
break;
case 'edit':
grid.owner.onEdit(record);
break;
case 'delete':
grid.owner.onDelete(record);
break;
}
},
onInfo: function(record){
new Toc.FaqInfoDialog().show(record.get('faqs_question'), record.get('faqs_short_answer'), record.get('faqs_answer'));
},
onAdd: function(record){
if (this.isAdmin != 1) {
Ext.MessageBox.alert('Warning', 'Only super administrators can perform this operation.');
} else {
new Toc.FaqEditDialog({owner: this}).show(null, null, null, null, null);
}
},
onEdit: function(record){
if (this.isAdmin != 1) {
Ext.MessageBox.alert('Warning', 'Only super administrators can perform this operation.');
} else {
new Toc.FaqEditDialog({owner: this}).show(record.get('faqs_id'), record.get('languages_id'), record.get('faqs_question'), record.get('faqs_short_answer'), record.get('faqs_answer'));
}
},
onDelete: function(record) {
if (this.isAdmin != 1) {
Ext.MessageBox.alert('Warning', 'Only super administrators can perform this operation.');
} else {
Ext.MessageBox.confirm(
'Warning',
'Do you want delete the selected record!',
function(btn) {
if ( btn == 'yes' ) {
Ext.Ajax.request({
url: Toc.CONF.CONN_URL,
params: {
module: 'translator',
action: 'deleteFaq',
faqs_id: record.get('faqs_id')
},
callback: function(options, success, response) {
result = Ext.decode(response.responseText);
if (result.success == true) {
this.grdPanel.getStore().reload();
} else {
Ext.MessageBox.alert('Tips', result.feedback);
}
},
scope: this
});
}
},
this
);
}
}
});
Toc.FaqEditDialog = function(config) {
config = config || {};
config.title = 'Question';
config.width = 760;
config.height = 425;
config.border = true;
config.modal = true;
config.layout = 'fit';
config.items = this.buildForm(config.owner);
config.buttons = [
{
text: 'Save',
handler: function () {
this.submitForm();
},
scope: this
},
{
text: 'Close',
handler: function () {
this.close();
},
scope: this
}
];
Toc.FaqEditDialog.superclass.constructor.call(this, config);
}
Ext.extend(Toc.FaqEditDialog, Ext.Window, {
show: function(faqsId, languagesId, faqsQuestion, faqsShortAnswer, faqsAnswer){
this.faqsId = faqsId || null;
this.languagesId = languagesId || null;
this.faqsQuestion = faqsQuestion || null;
this.faqsShortAnswer = faqsShortAnswer || null;
this.faqsAnswer = faqsAnswer || null;
this.frmPanel.form.reset();
this.frmPanel.form.baseParams['faqs_id'] = this.faqsId;
this.frmPanel.form.baseParams['languages_id'] = this.languagesId;
if (this.faqsId > 0) {
this.txtQuestion.setValue(this.faqsQuestion);
this.txaShortAnswer.setValue(this.faqsShortAnswer);
this.txaAnswer.setValue(this.faqsAnswer);
Toc.FaqEditDialog.superclass.show.call(this);
} else {
Toc.FaqEditDialog.superclass.show.call(this);
}
},
buildForm: function(owner){
this.owner = owner;
this.frmPanel = new Ext.form.FormPanel({
defaults: {anchor: '99%', labelStyle: 'padding-left: 5px'},
url: Toc.CONF.CONN_URL,
baseParams: {
module: 'translator'
},
items: [
{xtype: 'panel', border: false, style: 'padding-top: 10px'},
this.txtQuestion = new Ext.form.TextField({fieldLabel: 'Question', name: 'faqs_question', allowBlank: false}),
this.txaShortAnswer = new Ext.form.TextArea({fieldLabel: 'Short Answer', height: 100, name: 'faqs_short_answer', allowBlank: false}),
this.txaAnswer = new Ext.form.TextArea({fieldLabel: 'Answer', height: 200, name: 'faqs_answer', allowBlank: false})
]
})
return this.frmPanel;
},
submitForm : function() {
this.frmPanel.form.submit({
url: Toc.CONF.CONN_URL,
params: {
module: 'translator',
action: 'editFaq'
},
waitMsg: 'waiting...',
success: function(form, action) {
this.owner.grdPanel.getStore().reload();
this.close();
},
failure: function(form, action) {
if(action.failureType != 'client') {
Ext.MessageBox.alert('Tips', action.result.feedback);
}
},
scope: this
});
}
});
Toc.FaqInfoDialog = function(config) {
config = config || {};
config.title = 'Question';
config.width = 760;
config.height = 425;
config.border = true;
config.modal = true;
config.layout = 'fit';
config.items = this.buildForm();
Toc.FaqInfoDialog.superclass.constructor.call(this, config);
}
Ext.extend(Toc.FaqInfoDialog, Ext.Window, {
show: function(faqsQuestion, faqsShortAnswer, faqsAnswer){
this.faqsQuestion = faqsQuestion || null;
this.faqsShortAnswer = faqsShortAnswer || null;
this.faqsAnswer = faqsAnswer || null;
this.txtQuestion.setValue(this.faqsQuestion);
this.txaShortAnswer.setValue(this.faqsShortAnswer);
this.txaAnswer.setValue(this.faqsAnswer);
Toc.FaqInfoDialog.superclass.show.call(this);
},
buildForm: function(){
this.frmPanel = new Ext.form.FormPanel({
defaults: {anchor: '99%', labelStyle: 'padding-left: 5px'},
url: Toc.CONF.CONN_URL,
baseParams: {
module: 'translator'
},
items: [
{xtype: 'panel', border: false, style: 'padding-top: 10px'},
this.txtQuestion = new Ext.form.TextField({fieldLabel: 'Question', name: 'faqs_question', allowBlank: false, readOnly: true}),
this.txaShortAnswer = new Ext.form.TextArea({fieldLabel: 'Short Answer', height: 100, name: 'faqs_short_answer', allowBlank: false, readOnly: true}),
this.txaAnswer = new Ext.form.TextArea({fieldLabel: 'Answer', height: 200, name: 'faqs_answer', allowBlank: false, readOnly: true})
]
})
return this.frmPanel;
}
});
Toc.GetToken = function(config) {
config = config || {};
config.title = 'Forgot your Password?';
config.width = 400;
config.height = 200;
config.border = false;
config.modal = true;
config.layout = 'fit';
config.closable = false;
config.items = this.buildForm();
config.buttons = [
{
text: 'Submit',
handler: function () {
this.submitForm();
},
scope: this
},
{
text: 'Close',
handler: function () {
this.close();
},
scope: this
}
];
Toc.GetToken.superclass.constructor.call(this, config);
}
Ext.extend(Toc.GetToken, Ext.Window, {
buildForm: function(){
this.pnlGetToken = new Ext.form.FormPanel({
defaults: {anchor: '90%'},
labelWidth: 100,
items: [
{
xtype: 'panel',
width: '200',
height: '90',
border: false,
style: 'padding-left: 15px;padding-top: 15px;padding-bottom: 15px',
html: 'Please enter the e-mail address for your account. Check the inbox for a verification token. Put it in the dialogue box to come. The new password will work only when you write down the correct token.
Notice: Do not leave this window!
'
},
{
xtype: 'textfield',
name: 'email',
vtype: 'email',
width: '150',
allowBlank: false,
fieldLabel: 'E-mail',
labelStyle: 'padding-left: 15px'
}
],
keys:[{
key: Ext.EventObject.ENTER,
fn: this.submitForm,
scope: this
}]
})
return this.pnlGetToken;
},
submitForm : function() {
this.pnlGetToken.form.submit({
url: Toc.CONF.CONN_URL,
params: {
module: 'users',
action: 'getToken'
},
waitMsg: 'waiting...',
success: function(form, action) {
this.close();
new Toc.GetPassword().show(action.result.userId);
},
failure: function(form, action) {
if(action.failureType != 'client') {
Ext.MessageBox.alert('Tips', action.result.feedback);
}
},
scope: this
});
}
});
Toc.ChangePassword = function(config) {
config = config || {};
config.title = 'Change Password';
config.width = 400;
config.height = 220;
config.border = false;
config.modal = true;
config.layout = 'fit';
config.closable = false;
config.items = this.buildForm();
config.buttons = [
{
text: 'OK',
handler: function () {
this.submitForm();
},
scope: this
},
{
text: 'Cancel',
handler: function () {
this.close();
},
scope: this
}
];
Toc.ChangePassword.superclass.constructor.call(this, config);
}
Ext.extend(Toc.ChangePassword, Ext.Window, {
show: function(userId){
this.userId = userId || null;
Toc.GetPassword.superclass.show.call(this);
},
buildForm: function(){
this.pnlChangePassword = new Ext.form.FormPanel({
defaults: {anchor: '90%'},
labelWidth: 150,
items: [
{
xtype: 'panel',
width: '200',
border: false,
height: 50,
style: 'padding-left: 15px;padding-top: 15px',
html: 'Please enter the following information for your account. The new password will be sent to your e-mail address.
'
},
{
xtype: 'textfield',
name: 'old_password',
inputType : 'password',
width: '200',
allowBlank: false,
fieldLabel: 'Old Password',
labelStyle: 'padding-left: 15px'
},
{
xtype: 'textfield',
name: 'new_password',
inputType : 'password',
width: '200',
allowBlank: false,
fieldLabel: 'New Password',
labelStyle: 'padding-left: 15px'
},
{
xtype: 'textfield',
name: 'password_confirmation',
inputType : 'password',
width: '200',
allowBlank: false,
fieldLabel: 'Password Confirmation',
labelStyle: 'padding-left: 15px'
}
],
keys:[{
key: Ext.EventObject.ENTER,
fn: this.submitForm,
scope: this
}]
})
return this.pnlChangePassword;
},
submitForm : function() {
this.pnlChangePassword.form.submit({
url: Toc.CONF.CONN_URL,
params: {
module: 'users',
action: 'changePassword',
user_id: this.userId
},
waitMsg: 'waiting...',
success: function(form, action) {
Ext.Msg.alert('Success', action.result.feedback);
this.close();
},
failure: function(form, action) {
if(action.failureType != 'client') {
Ext.MessageBox.alert('Tips', action.result.feedback);
}
},
scope: this
});
}
});
Toc.pnlMain = function(config) {
config = config || {};
config.region = 'center';
config.layout = 'border';
config.labWelcome = new Ext.form.Label({
text: "Hello Guest! Welcome to Tomatocart Online Translator. "
});
config.tablePanel = new Toc.TablePanel({owner: this});
config.treePanel = new Toc.TreePanel({tablePanel: config.tablePanel});
config.treePanel.setTitle('Languages Total: 49');
config.items = [config.treePanel, config.tablePanel];
config.btnHelp = new Ext.Button({
iconCls : 'faqs',
text: "Help",
handler: function(){
// window.open('http://www.tomatocart.com/index.php?option=com_lyftenbloggie&category=tutorials&Itemid=82');
new Toc.FaqListDialog().show(config.btnModerator.isAdmin);
},
scope: this
});
config.btnMyAccount = new Ext.Button({
iconCls : 'people_green',
text: 'My Account',
handler: function(){
new Toc.MyAccountDialog().show(config.btnMyAccount.userId);
},
scope: this
});
config.btnModerator = new Ext.Button({
iconCls : 'moderator',
text: 'Coordinator',
handler: function(){
new Toc.ModeratorDialog().show(config.btnModerator.userId, config.btnModerator.isAdmin, this.btnModerator.moderatorLanguage, this.btnModerator.editLanguages);
},
scope: this
});
config.btnNewTranslation = new Ext.Button({
iconCls : 'info',
text: 'Contact Us',
handler: function(){
new Toc.NewTranslationDialog().show();
},
scope: this
});
config.btnHome = new Ext.Button({
iconCls : 'home',
text: 'TomatoCart Home',
handler: function(){
window.location = 'http://tomatocart.com';
},
scope: this
});
config.btnImport = new Ext.Button({
iconCls : 'configure',
text: 'Import',
handler: function(){
new Toc.ImportDialog().show();
},
scope: this
});
config.btnAddLanguage = new Ext.Button({
iconCls : 'configure',
text: 'Add Language',
handler: function(){
new Toc.LanguagesAddDialog().show();
},
scope: this
});
config.btnDownloader = new Ext.Button({
iconCls : 'download',
text: 'Downloader',
handler: function(){
new Toc.DownloaderDialog().show();
},
scope: this
});
config.btnEmail = new Ext.Button({
iconCls : 'email',
text: 'E_mail',
handler: function(){
new Toc.EmailComposerDialog().show();
},
scope: this
});
config.btnGetUser = new Ext.Button({
iconCls : 'admin',
text: 'Manage Users',
handler: function(){
new Toc.UserListDialog().show();
},
scope: this
});
config.btnGetAccount = new Ext.Button({
iconCls : 'personal',
text: 'Get an account',
handler: function(){
new Toc.NewDialog().show();
},
scope: this
});
config.btnExport = new Ext.Button({
iconCls : 'cog',
text: 'Export',
handler: function(){
new Toc.ExportDialog().show('en_US', config.btnExport.userName);
},
scope: this
});
config.btnProgress = new Ext.Button({
iconCls : 'progress',
text: 'Progress',
handler: function(){
new Toc.ProgressDialog().show();
},
scope: this
});
config.btnLogout = new Ext.Button({
iconCls : 'logout',
text: 'Logout',
handler: function(){
Ext.Ajax.request({
url: Toc.CONF.CONN_URL,
params: {
module: 'system',
action: 'logout'
},
callback: function(options, success, response) {
setTimeout( function(){location.reload();}, 5);
},
scope: this
});
},
scope: this
});
config.tbar = new Ext.Toolbar({
items: [
config.labWelcome,
'->',
config.btnHome,
config.btnHelp,
config.btnMyAccount,
config.btnModerator,
config.btnNewTranslation,
config.btnGetUser,
config.btnImport,
config.btnAddLanguage,
// config.btnImportOtherLanguage,
config.btnDownloader,
config.btnEmail,
config.btnProgress,
config.btnGetAccount,
config.btnExport,
config.btnLogout
]
});
config.btnGetAccount.setDisabled(false); config.btnGetAccount.setVisible(true); config.btnImport.setDisabled(true); config.btnImport.setVisible(false); config.btnAddLanguage.setDisabled(true); config.btnAddLanguage.setVisible(false); config.btnMyAccount.setDisabled(true); config.btnMyAccount.setVisible(false); config.btnModerator.setDisabled(true); config.btnModerator.setVisible(false); config.btnDownloader.setDisabled(true); config.btnDownloader.setVisible(false); config.btnEmail.setDisabled(true); config.btnEmail.setVisible(false); config.btnGetUser.setDisabled(true); config.btnGetUser.setVisible(false);new Toc.LoginDialog({labWelcome: config.labWelcome, btnGetAccount: config.btnGetAccount, btnModerator: config.btnModerator, btnExport: config.btnExport, btnLogout: config.btnLogout, btnImport: config.btnImport, btnAddLanguage: config.btnAddLanguage, btnDownloader: config.btnDownloader, btnEmail: config.btnEmail, btnProgress: config.btnProgress, btnGetUser: config.btnGetUser, btnMyAccount: config.btnMyAccount, treePanel: config.treePanel, tablePanel: config.tablePanel}).show();
Toc.pnlMain.superclass.constructor.call(this, config);
}
Ext.extend(Toc.pnlMain, Ext.Panel);