Files
WebODF/programs/touchui/app/controller/Files.js
T

83 lines
2.4 KiB
JavaScript
Raw Normal View History

/*global Ext, runtime*/
2012-02-17 11:16:26 +01:00
Ext.define('WebODFApp.controller.Files', {
extend: 'Ext.app.Controller',
config: {
refs: {
mainView: 'mainview',
filesList: 'fileslist list',
fileDetail: 'filedetail',
openButton: '#openButton',
odfView: 'odfview',
title: 'titlebar'
},
control: {
mainView: {
pop: 'pop',
2012-03-02 17:13:24 +01:00
push: 'push',
back: 'back'
2012-02-17 11:16:26 +01:00
},
filesList: {
itemtap: 'show'
},
openButton: {
tap: 'open'
}
}
},
2012-03-02 17:13:24 +01:00
back: function () {
"use strict";
this.odfView.hideCanvas();
},
2012-02-17 11:16:26 +01:00
push: function (view, item) {
"use strict";
if (item.xtype === "filedetail") {
this.getOpenButton().show();
} else {
this.getOpenButton().hide();
}
},
pop: function (view, item) {
"use strict";
if (item.xtype === "odfview") { // going to filedetail
this.getOpenButton().show();
} else {
this.getOpenButton().hide();
}
2012-02-23 11:14:04 +01:00
this.getFilesList().deselectAll();
2012-02-17 11:16:26 +01:00
},
show: function (list, index, target, record, e) {
"use strict";
// set the record in the details view and the file view
// this way, document starts loading in the background
var c = this;
2012-02-17 11:16:26 +01:00
if (!this.fileDetail) {
this.fileDetail = Ext.create('WebODFApp.view.FileDetail');
}
if (!this.odfView) {
this.odfView = Ext.create('WebODFApp.view.OdfView');
this.odfView.addCanvasListener(this.fileDetail.canvasListener);
}
2012-03-02 17:13:24 +01:00
this.odfView.hideCanvas();
this.fileDetail.odfView = this.odfView;
2012-02-17 11:16:26 +01:00
this.fileDetail.setRecord(record);
this.getMainView().push(this.fileDetail);
runtime.setTimeout(function () {
c.odfView.setRecord(record);
}, 300);
2012-02-17 11:16:26 +01:00
},
open: function (options) {
"use strict";
var c = this;
2012-02-17 11:16:26 +01:00
if (!this.odfView) {
this.odfView = Ext.create('WebODFApp.view.OdfView');
}
this.odfView.hideCanvas();
2012-02-17 11:16:26 +01:00
this.odfView.setRecord(this.fileDetail.getRecord());
this.getMainView().push(this.odfView);
runtime.setTimeout(function () {
c.odfView.showCanvas();
}, 300);
2012-02-17 11:16:26 +01:00
}
});