[prev in list] [next in list] [prev in thread] [next in thread]
List: php-doc-cvs
Subject: [DOC-CVS] com web/doc-editor: Create main menu and many small improvements: js/controller/main.js js
From: Alexander Moskaliov <irker () php ! net>
Date: 2012-05-22 6:07:37
Message-ID: php-mail-a8a71c1be5e88f42d85513626cfa43e01266055679 () git ! php ! net
[Download RAW message or body]
Commit: 930c527c6f934fbb491fa1fadd54edbcc1d165cf
Author: Alexander Moskaliov <irker@php.net> Tue, 22 May 2012 10:07:37 \
+0400
Parents: e6c92130645dbe8a3bb7cd9fd7f9677be6f6a7f2
Branches: ExtJS
Link: http://git.php.net/?p=web/doc-editor.git;a=commitdiff;h=930c527c6f934fbb491fa1fadd54edbcc1d165cf
Log:
Create main menu and many small improvements
Changed paths:
M js/controller/main.js
M js/controller/main/menu.js
M js/locale/lang-en.js
M js/locale/lang-ru.js
M js/main.js
M js/util/ajax.js
M js/view/main/menu.js
A js/view/window/msg.js
["diff_930c527c6f934fbb491fa1fadd54edbcc1d165cf.txt" (text/plain)]
diff --git a/js/controller/main.js b/js/controller/main.js
index 09d3e30..4df9e84 100644
--- a/js/controller/main.js
+++ b/js/controller/main.js
@@ -1,5 +1,6 @@
Ext.define('phpdoe.controller.main', {
extend: 'Ext.app.Controller',
+
init: function() {
this.loadStores(['Languages']);
},
diff --git a/js/controller/main/menu.js b/js/controller/main/menu.js
index 31ed0b9..9e7747b 100644
--- a/js/controller/main/menu.js
+++ b/js/controller/main/menu.js
@@ -1,11 +1,12 @@
Ext.define('phpdoe.controller.main.menu', {
extend: 'Ext.app.Controller',
- requires : ['Ext.window.MessageBox'],
-
aboutWindow : null,
init: function() {
this.control({
+ '#main-menu-erase-personal': {
+ click: this.erasePersonalData
+ },
'#main-menu-logout': {
click: this.logout
},
@@ -16,6 +17,27 @@ Ext.define('phpdoe.controller.main.menu', {
},
+ erasePersonalData: function(menuitem) {
+ Msg.confirm('eraseData', function() {
+
+ Msg.wait('PleaseWait');
+
+ Ext.Ajax.request({
+ task : 'erasePersonalData',
+ success: function () {
+ Msg.hide();
+ Msg.info('thanks', function(){
+ window.location.href = './do/logout?csrfToken=' + csrfToken;
+ });
+ },
+ failure: function() {
+ Msg.hide();
+ Msg.alert('forbidden');
+ }
+ });
+
+ });
+ },
showAbout: function(menuItem) {
@@ -39,17 +61,9 @@ Ext.define('phpdoe.controller.main.menu', {
logout: function(menuItem) {
- // TODO: create class extend Ext.Msg with locale confirm/forbidden messages \
special for our project
- Ext.Msg.confirm(
- menuItem.parentMenu.ownerButton.itemText.confirm,
- menuItem.parentMenu.ownerButton.itemText.confirmLogout,
- function(btn)
- {
- if (btn === 'yes') {
- window.location.href = './do/logout?csrfToken=' + csrfToken;
- }
- }
- );
+ Msg.confirm('logout', function() {
+ window.location.href = './do/logout?csrfToken=' + csrfToken;
+ });
}
});
\ No newline at end of file
diff --git a/js/locale/lang-en.js b/js/locale/lang-en.js
index 641b49b..9d80b55 100644
--- a/js/locale/lang-en.js
+++ b/js/locale/lang-en.js
@@ -36,6 +36,39 @@
Ext.onReady(function() {
+ Ext.define("phpdoe.locale.view.window.msg", {
+ override: "phpdoe.view.window.msg",
+ initComponent: function () {
+ this.itemText = Ext.Object.merge(
+ {
+ // wait section
+ PleaseWait: 'Please wait...',
+
+ // confirm/info/alert section
+ thanks: {
+ title: 'Thanks!',
+ text: 'Thank you for using this application!'
+ },
+ logout: {
+ title: 'Confirm',
+ text: 'Are you sure you want to logout?'
+ },
+ eraseData: {
+ title: 'Confirm',
+ text: 'This action will erase your personal data. All \
content about this account will be deleted definitively. Are you sure you want to do \
that?' + },
+ forbidden: {
+ title: 'Forbidden',
+ text: ''
+ }
+ },
+ this.itemText
+ );
+ this.callParent();
+ }
+ });
+
+
Ext.define("phpdoe.locale.view.main.menu", {
override: "phpdoe.view.main.menu",
text: "Main menu",
@@ -43,10 +76,22 @@ Ext.onReady(function() {
this.itemText = Ext.Object.merge(
{
+ RefreshAllData: 'Refresh all data',
+ BuildTools: 'Build tools',
+ CheckBuild: 'Check build',
+ LastFailedBuild: 'Show last failed build',
+ EnTools: 'EN tools',
+ CheckEntities: 'Script check entities',
+ LastResult: 'View the last result',
+ RunScript: 'Run this script',
+ CheckDoc: 'Script check documentation',
+ Configure: 'Configure',
SwitchLang: 'Switch to language...',
+ ErasePersonalData: 'Erase my personal data',
LogOut: 'Log out',
- confirm: 'Confirm',
- confirmLogout: 'Are you sure you want to logout?',
+ ReportBug: 'Report bugs',
+ Documentation: 'Documentation',
+ Chat: 'Chat with us on IRC!',
About: 'About'
},
this.itemText
@@ -55,7 +100,6 @@ Ext.onReady(function() {
}
});
-
Ext.define("phpdoe.locale.view.main.about", {
override: "phpdoe.view.main.about",
title: "About {0}",
diff --git a/js/locale/lang-ru.js b/js/locale/lang-ru.js
index 860d5a2..9254efd 100644
--- a/js/locale/lang-ru.js
+++ b/js/locale/lang-ru.js
@@ -1,13 +1,50 @@
Ext.onReady(function() {
+ Ext.define("phpdoe.locale.view.window.msg", {
+ override: "phpdoe.view.window.msg",
+ itemText : {
+
+ // wait section
+ PleaseWait: 'Пожалуйста, подождите...',
+
+ // confirm/info/alert section
+ thanks: {
+ title: 'Спасибо!',
+ text: 'Спасибо, что пользовались этим \
приложением!' + },
+ logout: {
+ title: 'Подтверждение',
+ text: 'Вы уверены, что хотите выйти?'
+ },
+ eraseData: {
+ title: 'Подтверждение',
+ text: 'Это действие сотрет ваши личные \
данные. Все содержание об этом аккаунте будет \
полностью удалено. Вы уверены в том, что хотите \
этого?' + }
+ }
+ });
+
+
+
Ext.define("phpdoe.locale.view.main.menu", {
override: "phpdoe.view.main.menu",
text: "Основное меню",
itemText: {
- SwitchLang: 'Переключиться на другой язык',
+ RefreshAllData: 'Обновить все данные',
+ BuildTools: 'Инструменты сборки',
+ CheckBuild: 'Проверить билд',
+ LastFailedBuild: 'Показать последний сломанный \
билд', + EnTools: 'Инструменты английского \
языка', + CheckEntities: 'Скрипт проверки \
сущностей', + LastResult: 'Показать последние \
результаты', + RunScript: 'Запустить данный \
скрипт', + CheckDoc: 'Скрипт проверки \
документации', + Configure: 'Настройки',
+ SwitchLang: 'Переключиться на язык...',
+ ErasePersonalData: 'Стереть мои личные данные',
LogOut: 'Выйти',
- confirm: 'Подтверждение',
- confirmLogout: 'Вы уверены, что хотите выйти?',
+ ReportBug: 'Сообщить об ошибках',
+ Documentation: 'Документация',
+ Chat: 'Заходите к нам в IRC чат!',
About: 'О программе'
}
});
diff --git a/js/main.js b/js/main.js
index ef5f06c..b66a7e6 100644
--- a/js/main.js
+++ b/js/main.js
@@ -3,11 +3,12 @@ Ext.application({
appFolder : 'js',
stores: ['Files', 'Languages'],
models: ['File', 'Language'],
- requires : ['phpdoe.util.ajax' , 'phpdoe.util.config'],
+ requires : ['phpdoe.util.ajax' , 'phpdoe.util.config', \
'phpdoe.view.window.msg'], controllers: ['main', 'main.menu'],
launch : function () {
Ext.create('phpdoe.view.main').show();
+ Msg = Ext.create('phpdoe.view.window.msg');
}
});
\ No newline at end of file
diff --git a/js/util/ajax.js b/js/util/ajax.js
index fc8f085..7d49c9d 100644
--- a/js/util/ajax.js
+++ b/js/util/ajax.js
@@ -4,10 +4,42 @@ Ext.define('phpdoe.util.ajax', {
request: function(options) {
if (options.task) {
- options.url = './do/' + options.task;
- options.params.csrfToken = csrfToken;
+
+ var success_cb = options.success,
+ failure_cb = options.failure,
+ original_cb = options.callback;
+
+ options = Ext.Object.merge(options, {
+ url: './do/' + options.task,
+ params: {
+ csrfToken: csrfToken
+ },
+ callback: function(options, success, response)
+ {
+ var o = null;
+ try {
+ o = Ext.decode(response.responseText);
+ } catch(e) {
+ Ext.log({level: 'error'}, "Invalid XHR JSON Response:" + \
response.responseText); + }
+
+ if (success && o && o.success) {
+ if (success_cb !== undefined) {
+ Ext.callback(success_cb, options.scope, [response, \
options]); + }
+ } else {
+ if (failure_cb !== undefined) {
+ Ext.callback(failure_cb, options.scope, [response, \
options]); + }
+ }
+
+ if (original_cb !== undefined) {
+ Ext.callback(original_cb, options.scope, [options, success, \
response]); + }
+ }
+ });
}
- this.callParent(arguments);
+ this.callParent([options]);
}
});
\ No newline at end of file
diff --git a/js/view/main/menu.js b/js/view/main/menu.js
index 150c231..ac48fe5 100644
--- a/js/view/main/menu.js
+++ b/js/view/main/menu.js
@@ -8,6 +8,62 @@ Ext.define('phpdoe.view.main.menu', {
// it's normal, see \
http://docs.sencha.com/ext-js/4-1/#!/guide/application_architecture \
"AM.view.user.Edit" declaration for example this.menu = [
{
+ id: 'main-menu-refresh',
+ text: this.itemText.RefreshAllData,
+ iconCls: 'iconRefresh'
+ },
+ {
+ id: 'main-menu-build',
+ text: this.itemText.BuildTools,
+ menu: [
+ {
+ id: 'main-menu-build-check',
+ text: this.itemText.CheckBuild,
+ iconCls: 'iconCheckBuild'
+ },
+ {
+ id: 'main-menu-build-failed',
+ text: this.itemText.LastFailedBuild,
+ iconCls: 'iconBuildStatus'
+ }
+ ]
+ },
+ {
+ id: 'main-menu-entools',
+ text: this.itemText.EnTools,
+ menu: [
+ {
+ id: 'main-menu-check-entities',
+ text: this.itemText.CheckEntities,
+ iconCls: 'iconCheckEntities',
+ menu: [
+ {
+ id: 'main-menu-entities-last-result',
+ text: this.itemText.LastResult,
+ iconCls: 'iconTabView'
+ },
+ {
+ id: 'main-menu-entities-run',
+ text: this.itemText.RunScript,
+ iconCls: 'iconRun'
+ }
+ ]
+ },
+ {
+ id: 'main-menu-check-document',
+ text: this.itemText.CheckDoc,
+ iconCls: 'iconCheckDoc'
+ }
+ ]
+ },
+ '-',
+ {
+ id: 'main-menu-config',
+ text: this.itemText.Configure,
+ iconCls: 'iconConf'
+ },
+ '-',
+ {
id: 'main-menu-switch-lang',
text: this.itemText.SwitchLang,
iconCls: 'iconSwitchLang',
@@ -16,12 +72,33 @@ Ext.define('phpdoe.view.main.menu', {
})
},
{
+ id: 'main-menu-erase-personal',
+ text: this.itemText.ErasePersonalData,
+ iconCls: 'iconErasePersonalData'
+ },
+ {
id: 'main-menu-logout',
text: this.itemText.LogOut,
iconCls: 'iconLogOut'
},
'-',
{
+ id: 'main-menu-report-bug',
+ text: this.itemText.ReportBug,
+ iconCls: 'iconBugs'
+ },
+ {
+ id: 'main-menu-doc',
+ text: this.itemText.Documentation,
+ iconCls: 'iconBook'
+ },
+ {
+ id: 'main-menu-chat',
+ text: this.itemText.Chat,
+ iconCls: 'iconChat'
+ },
+ '-',
+ {
id: 'main-menu-about',
text: this.itemText.About,
iconCls: 'iconHelp'
diff --git a/js/view/window/msg.js b/js/view/window/msg.js
new file mode 100644
index 0000000..e80570a
--- /dev/null
+++ b/js/view/window/msg.js
@@ -0,0 +1,44 @@
+Ext.define(
+ 'phpdoe.view.window.msg',
+ {
+ extend: 'Ext.window.MessageBox',
+ confirm: function(id, handler) {
+ if (this.itemText[id]) {
+ this.callParent([
+ this.itemText[id].title,
+ this.itemText[id].text,
+ function(btn) {
+ if (btn === 'yes') {
+ handler();
+ }
+ }
+ ]);
+ }
+ },
+ wait: function(id) {
+ if (this.itemText[id]) {
+ this.callParent([this.itemText[id]]);
+ }
+ },
+ info: function(id, handler) {
+ if (this.itemText[id]) {
+ this.show({
+ title: this.itemText[id].title,
+ msg: this.itemText[id].text,
+ icon : Ext.Msg.INFO,
+ buttons : Ext.Msg.OK,
+ fn: handler
+ });
+ }
+ },
+
+ alert: function(id) {
+ if (this.itemText[id]) {
+ this.callParent([
+ this.itemText[id].title,
+ this.itemText[id].text
+ ]);
+ }
+ }
+ }
+);
\ No newline at end of file
--
PHP Documentation Commits Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic