Browse Source

Replace property functions with object/class method functions.

pull/3202/head
TheGoddessInari 6 years ago
parent
commit
07201f2b15
No known key found for this signature in database
GPG Key ID: 1209B1B7632D69A
  1. 4
      app.js
  2. 10
      app/Application.js
  3. 2
      app/store/Services.js
  4. 4
      app/util/Format.js
  5. 2
      app/util/IconLoader.js
  6. 2
      app/util/MD5.js
  7. 2
      app/util/Notifier.js
  8. 2
      app/util/UnreadCounter.js
  9. 80
      app/ux/WebView.js
  10. 4
      app/ux/mixin/Badge.js
  11. 6
      app/view/add/Add.js
  12. 8
      app/view/add/AddController.js
  13. 2
      app/view/main/About.js
  14. 10
      app/view/main/Main.js
  15. 48
      app/view/main/MainController.js
  16. 6
      app/view/preferences/Preferences.js
  17. 4
      app/view/preferences/PreferencesController.js
  18. 2
      overrides/Ext.js
  19. 4
      overrides/form/field/VTypes.js
  20. 2
      overrides/grid/column/Action.js
  21. 4
      overrides/layout/container/boxOverflow/Scroller.js

4
app.js

@ -54,7 +54,7 @@ ipc.on('autoUpdater:update-downloaded', function(e, releaseNotes, releaseName, r
,{ ,{
xtype: 'button' xtype: 'button'
,text: 'Relaunch Now' ,text: 'Relaunch Now'
,handler: function(btn) { ipc.send('autoUpdater:quit-and-install'); } ,handler(btn) { ipc.send('autoUpdater:quit-and-install'); }
} }
,{ ,{
xtype: 'button' xtype: 'button'
@ -67,7 +67,7 @@ ipc.on('autoUpdater:update-downloaded', function(e, releaseNotes, releaseName, r
glyph: 'XF00D@FontAwesome' glyph: 'XF00D@FontAwesome'
,baseCls: '' ,baseCls: ''
,style: 'cursor:pointer;' ,style: 'cursor:pointer;'
,handler: function(btn) { Ext.cq1('app-main').removeDocked(btn.up('toolbar'), true); } ,handler(btn) { Ext.cq1('app-main').removeDocked(btn.up('toolbar'), true); }
} }
] ]
}); });

10
app/Application.js

@ -20,7 +20,7 @@ Ext.define('Rambox.Application', {
,totalNotifications: 0 ,totalNotifications: 0
} }
,launch: function () { ,launch() {
// Load language for Ext JS library // Load language for Ext JS library
Ext.Loader.loadScript({url: Ext.util.Format.format("ext/packages/ext-locale/build/ext-locale-{0}.js", localStorage.getItem('locale') || 'en')}); Ext.Loader.loadScript({url: Ext.util.Format.format("ext/packages/ext-locale/build/ext-locale-{0}.js", localStorage.getItem('locale') || 'en')});
@ -60,7 +60,7 @@ Ext.define('Rambox.Application', {
Ext.get('spinner').destroy(); Ext.get('spinner').destroy();
} }
,updateTotalNotifications: function( newValue, oldValue ) { ,updateTotalNotifications( newValue, oldValue ) {
newValue = parseInt(newValue); newValue = parseInt(newValue);
if ( newValue > 0 ) { if ( newValue > 0 ) {
if ( Ext.cq1('app-main').getActiveTab().record ) { if ( Ext.cq1('app-main').getActiveTab().record ) {
@ -77,12 +77,12 @@ Ext.define('Rambox.Application', {
} }
} }
,checkUpdate: function(silence) { ,checkUpdate(silence) {
console.info('Checking for updates...'); console.info('Checking for updates...');
Ext.Ajax.request({ Ext.Ajax.request({
url: 'https://api.github.com/repos/TheGoddessInari/rambox/releases/latest' url: 'https://api.github.com/repos/TheGoddessInari/rambox/releases/latest'
,method: 'GET' ,method: 'GET'
,success: function(response) { ,success(response) {
var json = JSON.parse(response.responseText); var json = JSON.parse(response.responseText);
var appVersion = new Ext.Version(require('electron').remote.app.getVersion()); var appVersion = new Ext.Version(require('electron').remote.app.getVersion());
if ( appVersion.isLessThan(json.version) ) { if ( appVersion.isLessThan(json.version) ) {
@ -114,7 +114,7 @@ Ext.define('Rambox.Application', {
glyph: 'XF00D@FontAwesome' glyph: 'XF00D@FontAwesome'
,baseCls: '' ,baseCls: ''
,style: 'cursor:pointer;' ,style: 'cursor:pointer;'
,handler: function(btn) { Ext.cq1('app-main').removeDocked(btn.up('toolbar'), true); } ,handler(btn) { Ext.cq1('app-main').removeDocked(btn.up('toolbar'), true); }
} }
] ]
}); });

2
app/store/Services.js

@ -20,7 +20,7 @@ Ext.define('Rambox.store.Services', {
] ]
,listeners: { ,listeners: {
load: function( store, records, successful ) { load( store, records, successful ) {
Ext.cq1('app-main').suspendEvent('add'); Ext.cq1('app-main').suspendEvent('add');
var servicesLeft = []; var servicesLeft = [];

4
app/util/Format.js

@ -4,11 +4,11 @@
Ext.define('Rambox.util.Format', { Ext.define('Rambox.util.Format', {
singleton: true singleton: true
,formatNumber: function(n) { ,formatNumber(n) {
return n.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,"); return n.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,");
} }
,stripNumber: function(n) { ,stripNumber(n) {
return (typeof n == "number") ? n : n.match(/\d+/g) ? parseInt(n.match(/\d+/g).join("")) : 0; return (typeof n == "number") ? n : n.match(/\d+/g) ? parseInt(n.match(/\d+/g).join("")) : 0;
} }
}); });

2
app/util/IconLoader.js

@ -5,7 +5,7 @@ Ext.define('Rambox.util.IconLoader', {
singleton: true, singleton: true,
constructor: function(config) { constructor(config) {
config = config || {}; config = config || {};

2
app/util/MD5.js

@ -1,7 +1,7 @@
Ext.define('Rambox.util.MD5', { Ext.define('Rambox.util.MD5', {
singleton: true singleton: true
,encypt: function(s, raw, hexcase, chrsz) { ,encypt(s, raw, hexcase, chrsz) {
raw = raw || false; raw = raw || false;
hexcase = hexcase || false; hexcase = hexcase || false;
chrsz = chrsz || 8; chrsz = chrsz || 8;

2
app/util/Notifier.js

@ -6,7 +6,7 @@ Ext.define('Rambox.util.Notifier', {
singleton: true, singleton: true,
constructor: function(config) { constructor(config) {
config = config || {}; config = config || {};

2
app/util/UnreadCounter.js

@ -5,7 +5,7 @@ Ext.define('Rambox.util.UnreadCounter', {
singleton: true, singleton: true,
constructor: function(config) { constructor(config) {
config = config || {}; config = config || {};

80
app/ux/WebView.js

@ -18,7 +18,7 @@ Ext.define('Rambox.ux.WebView',{
// CONFIG // CONFIG
,hideMode: 'offsets' ,hideMode: 'offsets'
,initComponent: function(config) { ,initComponent(config) {
var me = this; var me = this;
function getLocation(href) { function getLocation(href) {
@ -48,7 +48,7 @@ Ext.define('Rambox.ux.WebView',{
,muted: me.record.get('muted') ,muted: me.record.get('muted')
,tabConfig: { ,tabConfig: {
listeners: { listeners: {
afterrender : function( btn ) { afterrender ( btn ) {
btn.el.on('contextmenu', function(e) { btn.el.on('contextmenu', function(e) {
btn.showMenu('contextmenu'); btn.showMenu('contextmenu');
e.stopEvent(); e.stopEvent();
@ -135,13 +135,13 @@ Ext.define('Rambox.ux.WebView',{
me.callParent(config); me.callParent(config);
} }
,onBeforeDestroy: function() { ,onBeforeDestroy() {
var me = this; var me = this;
me.setUnreadCount(0); me.setUnreadCount(0);
} }
,webViewConstructor: function( enabled ) { ,webViewConstructor( enabled ) {
var me = this; var me = this;
var cfg; var cfg;
@ -180,7 +180,7 @@ Ext.define('Rambox.ux.WebView',{
return cfg; return cfg;
} }
,statusBarConstructor: function(floating) { ,statusBarConstructor(floating) {
var me = this; var me = this;
return { return {
@ -216,7 +216,7 @@ Ext.define('Rambox.ux.WebView',{
}; };
} }
,onAfterRender: function() { ,onAfterRender() {
var me = this; var me = this;
if ( !me.record.get('enabled') ) return; if ( !me.record.get('enabled') ) return;
@ -349,7 +349,7 @@ Ext.define('Rambox.ux.WebView',{
} }
} }
,listeners: { ,listeners: {
show: function(win) { show(win) {
const webview = win.down('#webview').el.dom; const webview = win.down('#webview').el.dom;
webview.addEventListener('ipc-message', function(event) { webview.addEventListener('ipc-message', function(event) {
var channel = event.channel; var channel = event.channel;
@ -602,7 +602,7 @@ Ext.define('Rambox.ux.WebView',{
}); });
} }
,setUnreadCount: function(newUnreadCount) { ,setUnreadCount(newUnreadCount) {
var me = this; var me = this;
if ( !isNaN(newUnreadCount) && (function(x) { return (x | 0) === x; })(parseFloat(newUnreadCount)) && me.record.get('includeInGlobalUnreadCounter') === true) { if ( !isNaN(newUnreadCount) && (function(x) { return (x | 0) === x; })(parseFloat(newUnreadCount)) && me.record.get('includeInGlobalUnreadCounter') === true) {
@ -616,7 +616,7 @@ Ext.define('Rambox.ux.WebView',{
me.doManualNotification(parseInt(newUnreadCount)); me.doManualNotification(parseInt(newUnreadCount));
} }
,refreshUnreadCount: function() { ,refreshUnreadCount() {
this.setUnreadCount(this.currentUnreadCount); this.setUnreadCount(this.currentUnreadCount);
} }
@ -629,7 +629,7 @@ Ext.define('Rambox.ux.WebView',{
* *
* @param {int} count * @param {int} count
*/ */
,doManualNotification: function(count) { ,doManualNotification(count) {
var me = this; var me = this;
if (Ext.getStore('ServicesList').getById(me.type).get('manual_notifications') && if (Ext.getStore('ServicesList').getById(me.type).get('manual_notifications') &&
@ -647,7 +647,7 @@ Ext.define('Rambox.ux.WebView',{
* *
* @param {string} badgeText * @param {string} badgeText
*/ */
,setTabBadgeText: function(badgeText) { ,setTabBadgeText(badgeText) {
var me = this; var me = this;
if (me.record.get('displayTabUnreadCounter') === true) { if (me.record.get('displayTabUnreadCounter') === true) {
me.tab.setBadgeText(badgeText); me.tab.setBadgeText(badgeText);
@ -661,13 +661,13 @@ Ext.define('Rambox.ux.WebView',{
* clears the badge text * clears the badge text
* clears the global unread counter * clears the global unread counter
*/ */
,clearUnreadCounter: function() { ,clearUnreadCounter() {
var me = this; var me = this;
me.tab.setBadgeText(''); me.tab.setBadgeText('');
Rambox.util.UnreadCounter.clearUnreadCountForService(me.record.get('id')); Rambox.util.UnreadCounter.clearUnreadCountForService(me.record.get('id'));
} }
,reloadService: function(btn) { ,reloadService(btn) {
var me = this; var me = this;
var webview = me.getWebView(); var webview = me.getWebView();
@ -677,7 +677,7 @@ Ext.define('Rambox.ux.WebView',{
} }
} }
,toggleDevTools: function(btn) { ,toggleDevTools(btn) {
var me = this; var me = this;
var webview = me.getWebView(); var webview = me.getWebView();
@ -690,7 +690,7 @@ Ext.define('Rambox.ux.WebView',{
} }
} }
,setURL: function(url) { ,setURL(url) {
var me = this; var me = this;
var webview = me.getWebView(); var webview = me.getWebView();
@ -699,7 +699,7 @@ Ext.define('Rambox.ux.WebView',{
if ( me.record.get('enabled') ) webview.loadURL(url); if ( me.record.get('enabled') ) webview.loadURL(url);
} }
,setAudioMuted: function(muted, calledFromDisturb) { ,setAudioMuted(muted, calledFromDisturb) {
var me = this; var me = this;
var webview = me.getWebView(); var webview = me.getWebView();
@ -710,7 +710,7 @@ Ext.define('Rambox.ux.WebView',{
if ( me.record.get('enabled') ) webview.setAudioMuted(muted); if ( me.record.get('enabled') ) webview.setAudioMuted(muted);
} }
,closeStatusBar: function() { ,closeStatusBar() {
var me = this; var me = this;
me.down('statusbar').hide(); me.down('statusbar').hide();
@ -718,7 +718,7 @@ Ext.define('Rambox.ux.WebView',{
me.down('statusbar').keep = false; me.down('statusbar').keep = false;
} }
,setStatusBar: function(keep) { ,setStatusBar(keep) {
var me = this; var me = this;
me.removeDocked(me.down('statusbar'), true); me.removeDocked(me.down('statusbar'), true);
@ -731,7 +731,7 @@ Ext.define('Rambox.ux.WebView',{
me.down('statusbar').keep = keep; me.down('statusbar').keep = keep;
} }
,setNotifications: function(notification, calledFromDisturb) { ,setNotifications(notification, calledFromDisturb) {
var me = this; var me = this;
var webview = me.getWebView(); var webview = me.getWebView();
@ -742,7 +742,7 @@ Ext.define('Rambox.ux.WebView',{
if ( me.record.get('enabled') ) ipc.send('setServiceNotifications', webview.partition, notification); if ( me.record.get('enabled') ) ipc.send('setServiceNotifications', webview.partition, notification);
} }
,setEnabled: function(enabled) { ,setEnabled(enabled) {
var me = this; var me = this;
me.clearUnreadCounter(); me.clearUnreadCounter();
@ -760,25 +760,25 @@ Ext.define('Rambox.ux.WebView',{
} }
} }
,goBack: function() { ,goBack() {
var me = this; var me = this;
var webview = me.getWebView(); var webview = me.getWebView();
if ( me.record.get('enabled') ) webview.goBack(); if ( me.record.get('enabled') ) webview.goBack();
} }
,goForward: function() { ,goForward() {
var me = this; var me = this;
var webview = me.getWebView(); var webview = me.getWebView();
if ( me.record.get('enabled') ) webview.goForward(); if ( me.record.get('enabled') ) webview.goForward();
} }
,setZoomLevel: function(level) ,setZoomLevel(level)
{ {
this.getWebContents().setZoomLevel(level); this.getWebContents().setZoomLevel(level);
} }
,zoomIn: function() { ,zoomIn() {
var me = this; var me = this;
me.zoomLevel = me.zoomLevel + 1; me.zoomLevel = me.zoomLevel + 1;
@ -788,7 +788,7 @@ Ext.define('Rambox.ux.WebView',{
} }
} }
,zoomOut: function() { ,zoomOut() {
var me = this; var me = this;
me.zoomLevel = me.zoomLevel - 1; me.zoomLevel = me.zoomLevel - 1;
@ -798,7 +798,7 @@ Ext.define('Rambox.ux.WebView',{
} }
} }
,resetZoom: function() { ,resetZoom() {
var me = this; var me = this;
me.zoomLevel = 0; me.zoomLevel = 0;
@ -808,21 +808,21 @@ Ext.define('Rambox.ux.WebView',{
} }
} }
,getWebView: function() { ,getWebView() {
if ( this.record.get('enabled') ) { if ( this.record.get('enabled') ) {
return this.down('component').el.dom; return this.down('component').el.dom;
} else { } else {
return false; return false;
} }
} }
,getWebContents: function() { ,getWebContents() {
if ( this.record.get('enabled') ) { if ( this.record.get('enabled') ) {
return this.getWebView().getWebContents(); return this.getWebView().getWebContents();
} else { } else {
return false; return false;
} }
} }
,getUserAgent: function() { ,getUserAgent() {
const me = this; const me = this;
// TODO: Keep just in case we need our own User Agent builder. // TODO: Keep just in case we need our own User Agent builder.
// const default_ua = `Mozilla/5.0` + // const default_ua = `Mozilla/5.0` +
@ -836,7 +836,7 @@ Ext.define('Rambox.ux.WebView',{
const ua = service_ua ? service_ua : default_ua; const ua = service_ua ? service_ua : default_ua;
return ua; return ua;
} }
,getOSArch: function() { ,getOSArch() {
const me = this; const me = this;
const {remote} = require('electron'); const {remote} = require('electron');
const platform = remote.require('os').platform(); const platform = remote.require('os').platform();
@ -859,7 +859,7 @@ Ext.define('Rambox.ux.WebView',{
} }
return arch; return arch;
} }
,getOSArchType: function() { ,getOSArchType() {
let arch = require('electron').remote.require('os').arch(); let arch = require('electron').remote.require('os').arch();
switch(arch) { switch(arch) {
@ -890,7 +890,7 @@ Ext.define('Rambox.ux.WebView',{
} }
return arch; return arch;
} }
,getOSPlatform: function() { ,getOSPlatform() {
const me = this; const me = this;
let platform = require('electron').remote.require('os').platform(); let platform = require('electron').remote.require('os').platform();
switch (platform) { switch (platform) {
@ -914,36 +914,36 @@ Ext.define('Rambox.ux.WebView',{
} }
return platform; return platform;
} }
,isWindows: function() { ,isWindows() {
return require('electron').remote.require('os').platform() === 'win32'; return require('electron').remote.require('os').platform() === 'win32';
} }
,is32bit: function() { ,is32bit() {
const arch = require('electron').remote.require('os').arch(); const arch = require('electron').remote.require('os').arch();
if (arch === 'ia32' || arch === 'x32') if (arch === 'ia32' || arch === 'x32')
return true; return true;
else else
return false; return false;
} }
,getOSRelease: function() { ,getOSRelease() {
const me = this; const me = this;
const remote = require('electron'); const remote = require('electron');
return me.isWindows() ? return me.isWindows() ?
remote.require('os').release().match(/([0-9]+\.[0-9]+)/)[0] remote.require('os').release().match(/([0-9]+\.[0-9]+)/)[0]
: remote.require('os').release(); : remote.require('os').release();
} }
,getChromeVersion: function() { ,getChromeVersion() {
return require('electron').remote.require('process').versions['chrome']; return require('electron').remote.require('process').versions['chrome'];
} }
,getElectronVersion: function() { ,getElectronVersion() {
return require('process').versions['electron']; return require('process').versions['electron'];
} }
,getAppVersion: function() { ,getAppVersion() {
return require('electron').remote.app.getVersion(); return require('electron').remote.app.getVersion();
} }
,blur: function() { ,blur() {
this.getWebView().blur(); this.getWebView().blur();
} }
,focus: function() ,focus()
{ {
this.getWebView().focus(); this.getWebView().focus();
} }

4
app/ux/mixin/Badge.js

@ -20,7 +20,7 @@ Ext.define('Rambox.ux.mixin.Badge', {
badgeText: null badgeText: null
}, },
renderBadgeText: function() { renderBadgeText() {
var badgeText = this.getBadgeText(); var badgeText = this.getBadgeText();
if (badgeText) { if (badgeText) {
@ -28,7 +28,7 @@ Ext.define('Rambox.ux.mixin.Badge', {
} }
}, },
updateBadgeText: function(badgeText, oldBadgeText) { updateBadgeText(badgeText, oldBadgeText) {
var me = this, var me = this,
el = me.el; el = me.el;

6
app/view/add/Add.js

@ -25,7 +25,7 @@ Ext.define('Rambox.view.add.Add',{
,draggable: false ,draggable: false
,bodyPadding: 20 ,bodyPadding: 20
,initComponent: function() { ,initComponent() {
var me = this; var me = this;
me.title = (!me.edit ? locale['app.window[0]'] : locale['app.window[1]']) + ' ' + me.record.get('name'); me.title = (!me.edit ? locale['app.window[0]'] : locale['app.window[1]']) + ' ' + me.record.get('name');
@ -93,10 +93,10 @@ Ext.define('Rambox.view.add.Add',{
] ]
} }
// Fixes bug EXTJS-20094 for version Ext JS 5 // Fixes bug EXTJS-20094 for version Ext JS 5
,arrowHandler: function(cycleBtn, e) { ,arrowHandler(cycleBtn, e) {
if ( !cycleBtn.arrowVisible ) cycleBtn.hideMenu(); if ( !cycleBtn.arrowVisible ) cycleBtn.hideMenu();
} }
,changeHandler: function(cycleBtn, activeItem) { ,changeHandler(cycleBtn, activeItem) {
Ext.apply(cycleBtn.previousSibling(), { Ext.apply(cycleBtn.previousSibling(), {
emptyText: activeItem.custom ? 'https://' : ' ' emptyText: activeItem.custom ? 'https://' : ' '
,vtype: activeItem.custom ? 'url' : '' ,vtype: activeItem.custom ? 'url' : ''

8
app/view/add/AddController.js

@ -6,13 +6,13 @@ Ext.define('Rambox.view.add.AddController', {
'Rambox.util.UnreadCounter' 'Rambox.util.UnreadCounter'
], ],
doCancel: function( btn ) { doCancel( btn ) {
var me = this; var me = this;
me.getView().close(); me.getView().close();
} }
,doSave: function( btn ) { ,doSave( btn ) {
var me = this; var me = this;
var win = me.getView(); var win = me.getView();
@ -134,13 +134,13 @@ Ext.define('Rambox.view.add.AddController', {
win.close(); win.close();
} }
,onEnter: function(field, e) { ,onEnter(field, e) {
var me = this; var me = this;
if ( e.getKey() === e.ENTER && field.up('form').isValid() ) me.doSave(); if ( e.getKey() === e.ENTER && field.up('form').isValid() ) me.doSave();
} }
,onShow: function(win) { ,onShow(win) {
var me = this; var me = this;
// Make focus to the name field // Make focus to the name field

2
app/view/main/About.js

@ -9,7 +9,7 @@ Ext.define('Rambox.view.main.About', {
,width: 300 ,width: 300
,height: 450 ,height: 450
,bodyPadding: 10 ,bodyPadding: 10
,initComponent: function() { ,initComponent() {
var me = this; var me = this;
me.callParent(arguments); me.callParent(arguments);
me.data.buildversion = require('fs').readFileSync( __dirname + '/BUILDVERSION', 'utf8'); me.data.buildversion = require('fs').readFileSync( __dirname + '/BUILDVERSION', 'utf8');

10
app/view/main/Main.js

@ -172,14 +172,14 @@ Ext.define('Rambox.view.main.Main', {
{ {
glyph: 0xF1F7 glyph: 0xF1F7
,tooltip: locale['app.main[11]'] ,tooltip: locale['app.main[11]']
,getClass: function( value, metaData, record, rowIndex, colIndex, store, view ){ ,getClass( value, metaData, record, rowIndex, colIndex, store, view ){
if ( record.get('notifications') ) return 'x-hidden'; if ( record.get('notifications') ) return 'x-hidden';
} }
} }
,{ ,{
glyph: 0xF026 glyph: 0xF026
,tooltip: locale['app.main[12]'] ,tooltip: locale['app.main[12]']
,getClass: function( value, metaData, record, rowIndex, colIndex, store, view ){ ,getClass( value, metaData, record, rowIndex, colIndex, store, view ){
if ( !record.get('muted') ) return 'x-hidden'; if ( !record.get('muted') ) return 'x-hidden';
} }
} }
@ -194,13 +194,13 @@ Ext.define('Rambox.view.main.Main', {
glyph: 0xF013 glyph: 0xF013
,tooltip: locale['app.main[13]'] ,tooltip: locale['app.main[13]']
,handler: 'configureService' ,handler: 'configureService'
,getClass: function(){ return 'x-hidden-display'; } ,getClass(){ return 'x-hidden-display'; }
} }
,{ ,{
glyph: 0xF1F8 glyph: 0xF1F8
,tooltip: locale['app.main[14]'] ,tooltip: locale['app.main[14]']
,handler: 'removeService' ,handler: 'removeService'
,getClass: function(){ return 'x-hidden-display'; } ,getClass(){ return 'x-hidden-display'; }
} }
] ]
} }
@ -208,7 +208,7 @@ Ext.define('Rambox.view.main.Main', {
xtype: 'checkcolumn' xtype: 'checkcolumn'
,width: 40 ,width: 40
,dataIndex: 'enabled' ,dataIndex: 'enabled'
,renderer: function(value, metaData) { ,renderer(value, metaData) {
metaData.tdAttr = 'data-qtip="Service '+(value ? 'Enabled' : 'Disabled')+'"'; metaData.tdAttr = 'data-qtip="Service '+(value ? 'Enabled' : 'Disabled')+'"';
return this.defaultRenderer(value, metaData); return this.defaultRenderer(value, metaData);
} }

48
app/view/main/MainController.js

@ -3,7 +3,7 @@ Ext.define('Rambox.view.main.MainController', {
,alias: 'controller.main' ,alias: 'controller.main'
,initialize: function( tabPanel ) { ,initialize( tabPanel ) {
const config = ipc.sendSync('getConfig'); const config = ipc.sendSync('getConfig');
tabPanel.setTabPosition(config.tabbar_location); tabPanel.setTabPosition(config.tabbar_location);
@ -22,7 +22,7 @@ Ext.define('Rambox.view.main.MainController', {
} }
// Make focus on webview every time the user change tabs, to enable the autofocus in websites // Make focus on webview every time the user change tabs, to enable the autofocus in websites
,onTabChange: function( tabPanel, newTab, oldTab ) { ,onTabChange( tabPanel, newTab, oldTab ) {
var me = this; var me = this;
localStorage.setItem('last_active_service', newTab.id); localStorage.setItem('last_active_service', newTab.id);
@ -51,7 +51,7 @@ Ext.define('Rambox.view.main.MainController', {
} }
} }
,updatePositions: function(tabPanel, tab) { ,updatePositions(tabPanel, tab) {
if ( tab.id === 'ramboxTab' || tab.id === 'tbfill' ) return true; if ( tab.id === 'ramboxTab' || tab.id === 'tbfill' ) return true;
console.log('Updating Tabs positions...'); console.log('Updating Tabs positions...');
@ -77,13 +77,13 @@ Ext.define('Rambox.view.main.MainController', {
store.resumeEvent('childmove'); store.resumeEvent('childmove');
} }
,showServiceTab: function( grid, record, tr, rowIndex, e ) { ,showServiceTab( grid, record, tr, rowIndex, e ) {
if ( e.position.colIdx === 0 ) { // Service Logo if ( e.position.colIdx === 0 ) { // Service Logo
Ext.getCmp('tab_'+record.get('id')).show(); Ext.getCmp('tab_'+record.get('id')).show();
} }
} }
,onRenameService: function(editor, e) { ,onRenameService(editor, e) {
var me = this; var me = this;
e.record.commit(); e.record.commit();
@ -92,7 +92,7 @@ Ext.define('Rambox.view.main.MainController', {
Ext.getCmp('tab_'+e.record.get('id')).setTitle(e.record.get('name')); Ext.getCmp('tab_'+e.record.get('id')).setTitle(e.record.get('name'));
} }
,onEnableDisableService: function(cc, rowIndex, checked, obj, hideTab) { ,onEnableDisableService(cc, rowIndex, checked, obj, hideTab) {
var rec = Ext.getStore('Services').getAt(rowIndex); var rec = Ext.getStore('Services').getAt(rowIndex);
if ( !checked ) { if ( !checked ) {
@ -121,13 +121,13 @@ Ext.define('Rambox.view.main.MainController', {
} }
} }
,onNewServiceSelect: function( view, record, item, index, e ) { ,onNewServiceSelect( view, record, item, index, e ) {
Ext.create('Rambox.view.add.Add', { Ext.create('Rambox.view.add.Add', {
record: record record: record
}); });
} }
,removeServiceFn: function(serviceId, total, actual, resolve) { ,removeServiceFn(serviceId, total, actual, resolve) {
var me = this; var me = this;
if ( !serviceId ) return false; if ( !serviceId ) return false;
@ -173,7 +173,7 @@ Ext.define('Rambox.view.main.MainController', {
} }
} }
,removeService: function( gridView, rowIndex, colIndex, col, e, rec, rowEl ) { ,removeService( gridView, rowIndex, colIndex, col, e, rec, rowEl ) {
var me = this; var me = this;
Ext.Msg.confirm(locale['app.window[12]'], locale['app.window[13]']+' <b>'+rec.get('name')+'</b>?', function(btnId) { Ext.Msg.confirm(locale['app.window[12]'], locale['app.window[13]']+' <b>'+rec.get('name')+'</b>?', function(btnId) {
@ -184,7 +184,7 @@ Ext.define('Rambox.view.main.MainController', {
}); });
} }
,removeAllServices: function(btn, callback) { ,removeAllServices(btn, callback) {
var me = this; var me = this;
// Clear counter for unread messaging // Clear counter for unread messaging
@ -232,7 +232,7 @@ Ext.define('Rambox.view.main.MainController', {
} }
} }
,configureService: function( gridView, rowIndex, colIndex, col, e, rec, rowEl ) { ,configureService( gridView, rowIndex, colIndex, col, e, rec, rowEl ) {
Ext.create('Rambox.view.add.Add', { Ext.create('Rambox.view.add.Add', {
record: rec record: rec
,service: Ext.getStore('ServicesList').getById(rec.get('type')) ,service: Ext.getStore('ServicesList').getById(rec.get('type'))
@ -240,11 +240,11 @@ Ext.define('Rambox.view.main.MainController', {
}); });
} }
,onSearchRender: function( field ) { ,onSearchRender( field ) {
field.focus(false, 1000); field.focus(false, 1000);
} }
,onSearchEnter: function( field, e ) { ,onSearchEnter( field, e ) {
var me = this; var me = this;
if ( e.getKey() === e.ENTER && Ext.getStore('ServicesList').getCount() === 2 ) { // Two because we always shows Custom Service option if ( e.getKey() === e.ENTER && Ext.getStore('ServicesList').getCount() === 2 ) { // Two because we always shows Custom Service option
@ -253,17 +253,17 @@ Ext.define('Rambox.view.main.MainController', {
} }
} }
,doTypeFilter: function( cg, newValue, oldValue ) { ,doTypeFilter( cg, newValue, oldValue ) {
var me = this; var me = this;
Ext.getStore('ServicesList').getFilters().replaceAll({ Ext.getStore('ServicesList').getFilters().replaceAll({
fn: function(record) { fn(record) {
return Ext.Array.contains(Ext.Object.getKeys(cg.getValue()), record.get('type')) || record.get('type') === 'custom'; return Ext.Array.contains(Ext.Object.getKeys(cg.getValue()), record.get('type')) || record.get('type') === 'custom';
} }
}); });
} }
,onSearchServiceChange: function(field, newValue, oldValue) { ,onSearchServiceChange(field, newValue, oldValue) {
var me = this; var me = this;
var cg = field.up().down('checkboxgroup'); var cg = field.up().down('checkboxgroup');
@ -271,7 +271,7 @@ Ext.define('Rambox.view.main.MainController', {
field.getTrigger('clear').show(); field.getTrigger('clear').show();
Ext.getStore('ServicesList').getFilters().replaceAll({ Ext.getStore('ServicesList').getFilters().replaceAll({
fn: function(record) { fn(record) {
if ( record.get('type') === 'custom' ) return true; if ( record.get('type') === 'custom' ) return true;
if ( !Ext.Array.contains(Ext.Object.getKeys(cg.getValue()), record.get('type')) ) return false; if ( !Ext.Array.contains(Ext.Object.getKeys(cg.getValue()), record.get('type')) ) return false;
return record.get('name').toLowerCase().indexOf(newValue.toLowerCase()) > -1 ? true : false; return record.get('name').toLowerCase().indexOf(newValue.toLowerCase()) > -1 ? true : false;
@ -285,7 +285,7 @@ Ext.define('Rambox.view.main.MainController', {
field.updateLayout(); field.updateLayout();
} }
,onClearClick: function(field, trigger, e) { ,onClearClick(field, trigger, e) {
var me = this; var me = this;
var cg = field.up().down('checkboxgroup'); var cg = field.up().down('checkboxgroup');
@ -298,7 +298,7 @@ Ext.define('Rambox.view.main.MainController', {
me.doTypeFilter(cg); me.doTypeFilter(cg);
} }
,dontDisturb: function(btn, e, called) { ,dontDisturb(btn, e, called) {
console.info('Dont Disturb:', btn.pressed ? 'Enabled' : 'Disabled'); console.info('Dont Disturb:', btn.pressed ? 'Enabled' : 'Disabled');
Ext.Array.each(Ext.getStore('Services').collect('id'), function(serviceId) { Ext.Array.each(Ext.getStore('Services').collect('id'), function(serviceId) {
@ -331,7 +331,7 @@ Ext.define('Rambox.view.main.MainController', {
}); });
} }
,lockRambox: function(btn) { ,lockRambox(btn) {
var me = this; var me = this;
if ( ipc.sendSync('getConfig').master_password ) { if ( ipc.sendSync('getConfig').master_password ) {
@ -384,7 +384,7 @@ Ext.define('Rambox.view.main.MainController', {
} }
} }
,showLockWindow: function() { ,showLockWindow() {
var me = this; var me = this;
var validateFn = function() { var validateFn = function() {
@ -434,7 +434,7 @@ Ext.define('Rambox.view.main.MainController', {
,inputType: 'password' ,inputType: 'password'
,width: 256 ,width: 256
,listeners: { ,listeners: {
specialkey: function(field, e){ specialkey(field, e){
if ( e.getKey() === e.ENTER ) { if ( e.getKey() === e.ENTER ) {
validateFn(); validateFn();
} }
@ -453,7 +453,7 @@ Ext.define('Rambox.view.main.MainController', {
} }
] ]
,listeners: { ,listeners: {
render: function(win) { render(win) {
win.getEl().on('click', function() { win.getEl().on('click', function() {
win.down('textfield').focus(100); win.down('textfield').focus(100);
}); });
@ -463,7 +463,7 @@ Ext.define('Rambox.view.main.MainController', {
winLock.down('textfield').focus(1000); winLock.down('textfield').focus(1000);
} }
,openPreferences: function( btn ) { ,openPreferences( btn ) {
var me = this; var me = this;
Ext.create('Rambox.view.preferences.Preferences').show(); Ext.create('Rambox.view.preferences.Preferences').show();

6
app/view/preferences/Preferences.js

@ -35,7 +35,7 @@ Ext.define('Rambox.view.preferences.Preferences',{
} }
] ]
,initComponent: function() { ,initComponent() {
var config = ipc.sendSync('getConfig'); var config = ipc.sendSync('getConfig');
var defaultServiceOptions = []; var defaultServiceOptions = [];
@ -276,10 +276,10 @@ Ext.define('Rambox.view.preferences.Preferences',{
,itemId: 'pass' ,itemId: 'pass'
,flex: 1 ,flex: 1
,listeners: { ,listeners: {
validitychange: function(field) { validitychange(field) {
field.next().validate(); field.next().validate();
}, },
blur: function(field) { blur(field) {
field.next().validate(); field.next().validate();
} }
} }

4
app/view/preferences/PreferencesController.js

@ -2,13 +2,13 @@ Ext.define('Rambox.view.preferences.PreferencesController', {
extend: 'Ext.app.ViewController' extend: 'Ext.app.ViewController'
,alias: 'controller.preferences-preferences' ,alias: 'controller.preferences-preferences'
,cancel: function( btn ) { ,cancel( btn ) {
var me = this; var me = this;
me.getView().close(); me.getView().close();
} }
,save: function( btn ) { ,save( btn ) {
var me = this; var me = this;
var values = me.getView().down('form').getForm().getFieldValues(); var values = me.getView().down('form').getForm().getFieldValues();

2
overrides/Ext.js

@ -1,5 +1,5 @@
Ext.override(Ext, { Ext.override(Ext, {
cq1: function(selector) { cq1(selector) {
return Ext.ComponentQuery.query(selector)[0]; return Ext.ComponentQuery.query(selector)[0];
} }
}); });

4
overrides/form/field/VTypes.js

@ -1,5 +1,5 @@
Ext.apply(Ext.form.field.VTypes, { Ext.apply(Ext.form.field.VTypes, {
daterange: function(val, field) { daterange(val, field) {
var date = field.parseDate(val); var date = field.parseDate(val);
if (!date) { if (!date) {
@ -25,7 +25,7 @@ Ext.apply(Ext.form.field.VTypes, {
daterangeText: 'Start date must be less than end date', daterangeText: 'Start date must be less than end date',
password: function(val, field) { password(val, field) {
if (field.initialPassField) { if (field.initialPassField) {
var pwd = field.up('form').down('#' + field.initialPassField); var pwd = field.up('form').down('#' + field.initialPassField);
return (val == pwd.getValue()); return (val == pwd.getValue());

2
overrides/grid/column/Action.js

@ -2,7 +2,7 @@ Ext.define('Rambox.overrides.grid.column.Action', {
override: 'Ext.grid.column.Action', override: 'Ext.grid.column.Action',
// overridden to implement // overridden to implement
defaultRenderer: function(v, cellValues, record, rowIdx, colIdx, store, view) { defaultRenderer(v, cellValues, record, rowIdx, colIdx, store, view) {
var me = this, var me = this,
prefix = Ext.baseCSSPrefix, prefix = Ext.baseCSSPrefix,
scope = me.origScope || me, scope = me.origScope || me,

4
overrides/layout/container/boxOverflow/Scroller.js

@ -18,7 +18,7 @@ Ext.define('Rambox.overrides.layout.container.boxOverflow.Scroller', {
* @private * @private
* Scrolls to the left by the configured amount * Scrolls to the left by the configured amount
*/ */
scrollLeft: function() { scrollLeft() {
this.scrollBy(-this.scrollIncrement); this.scrollBy(-this.scrollIncrement);
}, },
@ -28,7 +28,7 @@ Ext.define('Rambox.overrides.layout.container.boxOverflow.Scroller', {
* @private * @private
* Scrolls to the right by the configured amount * Scrolls to the right by the configured amount
*/ */
scrollRight: function() { scrollRight() {
this.scrollBy(this.scrollIncrement); this.scrollBy(this.scrollIncrement);
} }
}); });

Loading…
Cancel
Save