PositioningController.js
Summary
No overview generated for 'PositioningController.js'
TKPositioningController.inherits = TKController;
TKPositioningController.synthetizes = ['positioningViewData'];
function TKPositioningController (data) {
this.positioningView = new TKPositioningView();
this.positioningView.delegate = this;
this._previousButton = null;
this._nextButton = null;
this.callSuper(data);
};
TKPositioningController.prototype.processView = function () {
this.callSuper();
this._view.appendChild(this.positioningView.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);
this.syncPageButtons();
};
TKPositioningController.prototype.setPositioningViewData = function (data) {
if (!TKUtils.objectIsUndefined(data.elements)) {
this.positioningView.dataSource = new TKPositioningViewDataSourceHelper(data.elements);
}
TKUtils.copyPropertiesFromSourceToTarget(data, this.positioningView);
this.positioningView.init();
this.syncPageButtons();
};
TKPositioningController.prototype.syncPageButtons = function () {
if (this._previousButton !== null) {
this._previousButton[(this.positioningView.activeElementIndex <= 0 ? 'add' : 'remove') + 'ClassName']('inactive');
}
if (this._nextButton !== null) {
this._nextButton[(this.positioningView.activeElementIndex >= this.positioningView.numberOfElements - 1 ? 'add' : 'remove') + 'ClassName']('inactive');
}
};
TKPositioningController.prototype.wantsToHandleKeyboardEvent = function (event) {
return (this.wantsCustomHandlingOfKeyboardEvent(event) || this.callSuper(event));
};
TKPositioningController.prototype.wantsCustomHandlingOfKeyboardEvent = function (event) {
var key = event.keyCode;
return (
(key == KEYBOARD_LEFT && this.positioningView.activeElementIndex > 0) ||
(key == KEYBOARD_RIGHT && this.positioningView.activeElementIndex < this.positioningView.numberOfElements - 1)
);
};
TKPositioningController.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;
}
};
TKPositioningController.prototype.handleEvent = function (event) {
this.callSuper(event);
if (event.currentTarget === this._previousButton) {
this.positioningView.activeElementIndex--;
}
else if (event.currentTarget === this._nextButton) {
this.positioningView.activeElementIndex++;
}
};
TKPositioningController.prototype.positioningViewDidFocusElementAtIndex = function (view, index) {
this.syncPageButtons();
};
TKPositioningController.prototype.positioningViewDidBlurElementAtIndex = function (view, index) {};
TKPositioningController.prototype.positioningViewDidSelectActiveElement = function (view, index) {
this.elementWasSelected(index);
};
TKPositioningController.prototype.elementWasSelected = function (index) {};
TKClass(TKPositioningController);
Documentation generated by
JSDoc on Tue Sep 15 21:24:36 2009