ComicController.js
Summary
No overview generated for 'ComicController.js'
TKComicController.inherits = TKController;
TKComicController.synthetizes = ['comicViewData'];
function TKComicController (data) {
this.comicView = new TKComicView();
this.comicView.delegate = this;
this._previousButton = null;
this._nextButton = null;
this.callSuper(data);
};
TKComicController.prototype.processView = function () {
this.callSuper();
this._view.appendChild(this.comicView.element);
if (this.previousButton !== null) {
this._previousButton = this.view.querySelector(this.previousButton);
if (this._previousButton !== null) {
this._previousButton.addEventListener('click', this, false);
}
}
if (this.nextButton !== null) {
this._nextButton = this.view.querySelector(this.nextButton);
if (this._nextButton !== null) {
this._nextButton.addEventListener('click', this, false);
}
}
this.addKeyboardElement(this._view);
};
TKComicController.prototype.setComicViewData = function (data) {
if (!TKUtils.objectIsUndefined(data.elements)) {
this.comicView.dataSource = new TKComicViewDataSourceHelper(data.elements);
}
TKUtils.copyPropertiesFromSourceToTarget(data, this.comicView);
this.comicView.init();
this.syncPageButtons();
};
TKComicController.prototype.syncPageButtons = function () {
if (this._previousButton !== null) {
this._previousButton[(this.comicView.currentPanelIndex <= 0 ? 'add' : 'remove') + 'ClassName']('inactive');
}
if (this._nextButton !== null) {
this._nextButton[(this.comicView.currentPanelIndex >= this.comicView.numberOfPanels - 1 ? 'add' : 'remove') + 'ClassName']('inactive');
}
};
TKComicController.prototype.wantsToHandleKeyboardEvent = function (event) {
return (this.wantsCustomHandlingOfKeyboardEvent(event) || this.callSuper(event));
};
TKComicController.prototype.wantsCustomHandlingOfKeyboardEvent = function (event) {
return false;
var key = event.keyCode;
return (
(key == KEYBOARD_LEFT && this.positioningView.activeElementIndex > 0) ||
(key == KEYBOARD_RIGHT && this.positioningView.activeElementIndex < this.positioningView.numberOfElements - 1)
);
};
TKComicController.prototype.handleKeydown = function (event) {
if (!this.wantsCustomHandlingOfKeyboardEvent(event)) {
this.callSuper(event);
return;
}
switch (event.keyCode) {
case KEYBOARD_RIGHT:
this.positioningView.activeElementIndex++;
break;
case KEYBOARD_LEFT:
this.positioningView.activeElementIndex--;
break;
}
};
TKComicController.prototype.handleEvent = function (event) {
this.callSuper(event);
if (event.currentTarget === this._previousButton) {
this.comicView.showPreviousPanel();
}
else if (event.currentTarget === this._nextButton) {
this.comicView.showNextPanel();
}
};
TKComicController.prototype.comicViewDidShowPanelAtIndex = function (view, index) {
this.panelWasShown(index);
this.syncPageButtons();
};
TKComicController.prototype.panelWasShown = function (index) {};
TKClass(TKComicController);
Documentation generated by
JSDoc on Tue Sep 15 21:24:36 2009