📄 qo-preferences-override.js
字号:
/*
* qWikiOffice Desktop 0.8.1
* Copyright(c) 2007-2008, Integrated Technologies, Inc.
* licensing@qwikioffice.com
*
* http://www.qwikioffice.com/license
*/
Ext.override(QoDesk.QoPreferences, {
actions : null,
cards : [
'pref-win-card-1', // navigation
'pref-win-card-2', // quickstart
'pref-win-card-3', // color and appearance
'pref-win-card-4', // wallpaper
'pref-win-card-5', // autorun
'pref-win-card-6' // shortcuts
],
contentPanel : null,
cardHistory : [
'pref-win-card-1' // default
],
layout: null,
win : null,
createWindow : function(){
var desktop = this.app.getDesktop();
this.win = desktop.getWindow(this.moduleId);
if(!this.win){
var winWidth = 610;
var winHeight = 460;
this.contentPanel = new Ext.Panel({
activeItem: 0,
border: false,
id: 'pref-win-content',
items: [
new QoDesk.QoPreferences.NavPanel({owner: this, id: 'pref-win-card-1'}),
new QoDesk.QoPreferences.Shortcuts({owner: this, id: 'pref-win-card-6'}),
new QoDesk.QoPreferences.AutoRun({owner: this, id: 'pref-win-card-5'}),
new QoDesk.QoPreferences.QuickStart({owner: this, id: 'pref-win-card-2'}),
new QoDesk.QoPreferences.Appearance({owner: this, id: 'pref-win-card-3'}),
new QoDesk.QoPreferences.Background({owner: this, id: 'pref-win-card-4'})
],
layout: 'card',
tbar: [{
disabled: true,
handler: this.navHandler.createDelegate(this, [-1]),
id: 'back',
scope: this,
text: 'Back'
},{
disabled: true,
handler: this.navHandler.createDelegate(this, [1]),
id: 'next',
scope: this,
text: 'Next'
}]
});
this.win = desktop.createWindow({
animCollapse: false,
constrainHeader: true,
id: this.moduleId,
height: winHeight,
iconCls: 'pref-icon',
items: this.contentPanel,
layout: 'fit',
shim: false,
taskbuttonTooltip: '<b>Preferences</b><br />Allows you to modify your desktop',
title: 'Preferences',
width: winWidth
});
this.layout = this.contentPanel.getLayout();
}
this.win.show();
},
handleButtonState : function(){
var cards = this.cardHistory, activeId = this.layout.activeItem.id,
items = this.contentPanel.getTopToolbar().items, back = items.get(0), next = items.get(1);
for(var i = 0, len = cards.length; i < len; i++){
if(cards[i] === activeId){
if(i <= 0){
back.disable();
next.enable();
}else if(i >= (len-1)){
back.enable();
next.disable();
}else{
back.enable();
next.enable();
}
break;
}
}
},
navHandler : function(index){
var cards = this.cardHistory,
activeId = this.layout.activeItem.id,
nextId;
for(var i = 0, len = cards.length; i < len; i++){
if(cards[i] === activeId){
nextId = cards[i+index];
break;
}
}
this.layout.setActiveItem(nextId);
this.handleButtonState();
},
save : function(params){
var desktop = this.app.getDesktop();
var notifyWin = desktop.showNotification({
html: 'Saving your data...'
, title: 'Please wait'
});
var callback = params.callback || null;
var callbackScope = params.callbackScope || this;
params.moduleId = this.moduleId;
Ext.Ajax.request({
url: this.app.connection,
/* Could also pass moduleId and action in querystring like this
* instead of in the params config option.
*
* url: this.app.connection+'?moduleId='+this.id+'&action=myAction', */
params: params,
success: function(o){
if(o && o.responseText && Ext.decode(o.responseText).success){
saveComplete('Finished', 'Save complete.');
}else{
saveComplete('Error', 'Errors encountered on the server.');
}
},
failure: function(){
saveComplete('Error', 'Lost connection to server.');
},
scope: this
});
function saveComplete(title, msg){
notifyWin.setIconClass('x-icon-done');
notifyWin.setTitle(title);
notifyWin.setMessage(msg);
desktop.hideNotification(notifyWin);
if(callback){
callback.call(callbackScope);
}
}
},
viewCard : function(card){
this.layout.setActiveItem(card);
if(this.cardHistory.length > 1){
this.cardHistory.pop();
}
this.cardHistory.push(card);
this.handleButtonState();
}
});
QoDesk.QoPreferences.NavPanel = function(config){
this.owner = config.owner;
QoDesk.QoPreferences.NavPanel.superclass.constructor.call(this, {
autoScroll: true,
bodyStyle: 'padding:15px',
border: false,
html: '<ul id="pref-nav-panel"> \
<li> \
<img src="'+Ext.BLANK_IMAGE_URL+'" class="icon-pref-autorun"/> \
<a id="viewShortcuts" href="#">Shortcuts</a><br /> \
<span>Choose which applications appear in your shortcuts.</span> \
</li> \
<li> \
<img src="'+Ext.BLANK_IMAGE_URL+'" class="icon-pref-autorun"/> \
<a id="viewAutoRun" href="#">Auto Run Apps</a><br /> \
<span>Choose which applications open automatically once logged in.</span> \
</li> \
<li> \
<img src="'+Ext.BLANK_IMAGE_URL+'" class="icon-pref-quickstart"/> \
<a id="viewQuickstart" href="#">Quick Start Apps</a><br /> \
<span>Choose which applications appear in your Quick Start panel.</span> \
</li> \
<li> \
<img src="'+Ext.BLANK_IMAGE_URL+'" class="icon-pref-appearance"/> \
<a id="viewAppearance" href="#">Window Color and Appearance</a><br /> \
<span>Fine tune window color and style of your windows.</span> \
</li> \
<li> \
<img src="'+Ext.BLANK_IMAGE_URL+'" class="icon-pref-wallpaper"/> \
<a id="viewWallpapers" href="#">Desktop Background</a><br /> \
<span>Choose from available wallpapers or colors to decorate you desktop.</span> \
</li> \
</ul>',
id: config.id
});
this.actions = {
'viewShortcuts' : function(owner){
owner.viewCard('pref-win-card-6');
},
'viewAutoRun' : function(owner){
owner.viewCard('pref-win-card-5');
},
'viewQuickstart' : function(owner){
owner.viewCard('pref-win-card-2');
},
'viewAppearance' : function(owner){
owner.viewCard('pref-win-card-3');
},
'viewWallpapers' : function(owner){
owner.viewCard('pref-win-card-4');
}
};
};
Ext.extend(QoDesk.QoPreferences.NavPanel, Ext.Panel, {
afterRender : function(){
this.body.on({
'mousedown': {
fn: this.doAction,
scope: this,
delegate: 'a'
},
'click': {
fn: Ext.emptyFn,
scope: null,
delegate: 'a',
preventDefault: true
}
});
QoDesk.QoPreferences.NavPanel.superclass.afterRender.call(this); // do sizing calcs last
},
doAction : function(e, t){
e.stopEvent();
this.actions[t.id](this.owner); // pass owner for scope
}
});
QoDesk.QoPreferences.AutoRun = function(config){
this.owner = config.owner;
this.app = this.owner.app;
var ms = this.app.modules,
ids = this.app.launchers.autorun,
nodes = expandNodes(ms, ids);
QoDesk.QoPreferences.AutoRun.superclass.constructor.call(this, {
autoScroll: true,
bodyStyle: 'padding:10px',
border: false,
buttons: [{
disabled: this.app.isAllowedTo('saveAutorun', this.owner.moduleId) ? false : true,
handler: onSave,
scope: this,
text: 'Save'
},{
handler: onClose,
scope: this,
text: 'Close'
}],
cls: 'pref-card pref-check-tree',
id: config.id,
lines: false,
listeners: {
'checkchange': {
fn: onCheckChange,
scope: this
}
},
loader: new Ext.tree.TreeLoader(),
rootVisible: false,
root: new Ext.tree.AsyncTreeNode({
text: 'Auto Run Apps',
children: nodes
}),
title: 'Auto Run Apps'
});
new Ext.tree.TreeSorter(this, {dir: "asc"});
function expandNodes(ms, ids){
var nodes = [];
for(var i = 0, len = ms.length; i < len; i++){
if(ms[i].moduleType === 'menu'){
/* nodes.push({
leaf: false,
text: ms[i].launcher.text,
children: this.expandNodes(o.menu.items, ids)
}); */
}else{
nodes.push({
checked: isChecked(ms[i].moduleId, ids) ? true : false,
iconCls: ms[i].launcher.iconCls,
id: ms[i].moduleId,
leaf: true,
selected: true,
text: ms[i].launcher.text
});
}
}
return nodes;
}
function isChecked(id, ids){
for(var i = 0, len = ids.length; i < len; i++){
if(id == ids[i]){
return true;
}
}
}
function onCheckChange(node, checked){
if(node.leaf && node.id){
if(checked){
this.app.desktop.addAutoRun(node.id, true);
}else{
this.app.desktop.removeAutoRun(node.id, true);
}
}
node.ownerTree.selModel.select(node);
}
function onClose(){
this.owner.win.close();
}
function onSave(){
this.buttons[0].disable();
this.owner.save({
action: 'saveAutorun'
, callback: function(){
this.buttons[0].enable();
}
, callbackScope: this
, ids: Ext.encode(this.app.launchers.autorun)
});
}
};
Ext.extend(QoDesk.QoPreferences.AutoRun, Ext.tree.TreePanel);
QoDesk.QoPreferences.Shortcuts = function(config){
this.owner = config.owner;
this.app = this.owner.app;
var ms = this.app.modules,
ids = this.app.launchers.shortcut,
nodes = expandNodes(ms, ids);
QoDesk.QoPreferences.Shortcuts.superclass.constructor.call(this, {
autoScroll: true,
bodyStyle: 'padding:10px',
border: false,
buttons: [{
disabled: this.app.isAllowedTo('saveShortcut', this.owner.moduleId) ? false : true,
handler: onSave,
scope: this,
text: 'Save'
},{
handler: onClose,
scope: this,
text: 'Close'
}],
cls: 'pref-card pref-check-tree',
id: config.id,
lines: false,
listeners: {
'checkchange': {
fn: onCheckChange,
scope: this
}
},
loader: new Ext.tree.TreeLoader(),
rootVisible: false,
root: new Ext.tree.AsyncTreeNode({
text: 'Shortcuts',
children: nodes
}),
title: 'Shortcuts'
});
new Ext.tree.TreeSorter(this, {dir: "asc"});
function expandNodes(ms, ids){
var nodes = [];
for(var i = 0, len = ms.length; i < len; i++){
if(ms[i].moduleType === 'menu'){
/* nodes.push({
leaf: false,
text: ms[i].launcher.text,
children: this.expandNodes(o.menu.items, ids)
}); */
}else{
nodes.push({
checked: isChecked(ms[i].moduleId, ids) ? true : false,
iconCls: ms[i].launcher.iconCls,
id: ms[i].moduleId,
leaf: true,
selected: true,
text: ms[i].launcher.text
});
}
}
return nodes;
}
function isChecked(id, ids){
for(var i = 0, len = ids.length; i < len; i++){
if(id == ids[i]){
return true;
}
}
}
function onCheckChange(node, checked){
if(node.leaf && node.id){
if(checked){
this.app.desktop.addShortcut(node.id, true);
}else{
this.app.desktop.removeShortcut(node.id, true);
}
}
node.ownerTree.selModel.select(node);
}
function onClose(){
this.owner.win.close();
}
function onSave(){
this.buttons[0].disable();
this.owner.save({
action: 'saveShortcut'
, callback: function(){
this.buttons[0].enable();
}
, callbackScope: this
, ids: Ext.encode(this.app.launchers.shortcut)
});
}
};
Ext.extend(QoDesk.QoPreferences.Shortcuts, Ext.tree.TreePanel);
QoDesk.QoPreferences.QuickStart = function(config){
this.owner = config.owner;
this.app = this.owner.app;
var ms = this.app.modules,
ids = this.app.launchers.quickstart,
nodes = expandNodes(ms, ids);
QoDesk.QoPreferences.QuickStart.superclass.constructor.call(this, {
autoScroll: true,
bodyStyle: 'padding:10px',
border: false,
buttons: [{
disabled: this.app.isAllowedTo('saveQuickstart', this.owner.moduleId) ? false : true,
handler: onSave,
scope: this,
text: 'Save'
},{
handler: onClose,
scope: this,
text: 'Close'
}],
cls: 'pref-card pref-check-tree',
id: config.id,
lines: false,
listeners: {
'checkchange': {
fn: onCheckChange,
scope: this
}
},
loader: new Ext.tree.TreeLoader(),
rootVisible: false,
root: new Ext.tree.AsyncTreeNode({
text: 'Quick Start Apps',
children: nodes
}),
title: 'Quick Start Apps'
});
new Ext.tree.TreeSorter(this, {dir: "asc"});
function expandNodes(ms, ids){
var nodes = [];
for(var i = 0, len = ms.length; i < len; i++){
if(ms[i].moduleType === 'menu'){
/* nodes.push({
leaf: false,
text: ms[i].launcher.text,
children: this.expandNodes(o.menu.items, ids)
}); */
}else{
nodes.push({
checked: isChecked(ms[i].moduleId, ids) ? true : false,
iconCls: ms[i].launcher.iconCls,
id: ms[i].moduleId,
leaf: true,
selected: true,
text: ms[i].launcher.text
});
}
}
return nodes;
}
function isChecked(id, ids){
for(var i = 0, len = ids.length; i < len; i++){
if(id == ids[i]){
return true;
}
}
}
function onCheckChange(node, checked){
if(node.leaf && node.id){
if(checked){
this.app.desktop.addQuickStartButton(node.id, true);
}else{
this.app.desktop.removeQuickStartButton(node.id, true);
}
}
node.ownerTree.selModel.select(node);
}
function onClose(){
this.owner.win.close();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -