View Single Post
Old 04-05-2012, 03:12 PM   #3606
Mark Nord
2B || !2B
Mark Nord ought to be getting tired of karma fortunes by now.Mark Nord ought to be getting tired of karma fortunes by now.Mark Nord ought to be getting tired of karma fortunes by now.Mark Nord ought to be getting tired of karma fortunes by now.Mark Nord ought to be getting tired of karma fortunes by now.Mark Nord ought to be getting tired of karma fortunes by now.Mark Nord ought to be getting tired of karma fortunes by now.Mark Nord ought to be getting tired of karma fortunes by now.Mark Nord ought to be getting tired of karma fortunes by now.Mark Nord ought to be getting tired of karma fortunes by now.Mark Nord ought to be getting tired of karma fortunes by now.
 
Posts: 854
Karma: 327896
Join Date: Feb 2010
Location: Austria
Device: Sony PRS505/650/T1/tolino vision 5
Analogus,

obvious difference between your definition and the Sony/kinoma one is their use of
variableUpdate="VAR_UPDATE_FONTSIZE"

I would digg into de-fsked kbook.xs to learn more.

For your info please find the de-fsked sourcecode of this.pageSizeOverlayModel in the spoiler.
(No guaranty that there is something useful)

Spoiler:
Code:
	this.pageSizeOverlayModel = new this.pageOverlayModel
	this.pageSizeOverlayModel.VAR_MAX_FONTSCALE = this.__xs__number.parse('0');
	this.pageSizeOverlayModel.VAR_MIN_FONTSCALE = this.__xs__number.parse('0');
	this.pageSizeOverlayModel.VAR_RADIO_FONTSIZE = this.__xs__number.parse('0');
	this.pageSizeOverlayModel.VAR_ENABLE_ZOOM = this.__xs__boolean.parse('true');
	this.pageSizeOverlayModel.VAR_ENABLE_STYLE = this.__xs__boolean.parse('true');
	this.pageSizeOverlayModel.VAR_UPDATE_FONTSIZE = this.__xs__boolean.parse('false');
	this.pageSizeOverlayModel.zoomModel = this.pageZoomOverlayModel;
	this.pageSizeOverlayModel.selectStyle = this.pageSelectStyleOverlayModel;
	this.pageSizeOverlayModel.commonMinScale = this.__xs__number.parse('0');
	this.pageSizeOverlayModel.commonMaxScale = this.__xs__number.parse('3');
	this.pageSizeOverlayModel.SHOW = this.__xs__boolean.parse('false');
	this.pageSizeOverlayModel.initialized = function () {
		<global>.pageOverlayModel.initialized.call(this);
		this.SetSub('SIZE', this);
		this.commonMinScale = <global>.parseInt(<global>.System.applyEnvironment('[kFskDocumentViewerMinTextScale]'));
		this.commonMaxScale = <global>.parseInt(<global>.System.applyEnvironment('[kFskDocumentViewerMaxTextScale]'));
	};
	this.pageSizeOverlayModel.closeCurrentOverlay = function () {
		this.zoomModel.closeCurrentOverlay();
		if (this.SHOW == true) {
			this.setVariable('SHOW', false);
			this.targetModel.setVariable('OVERLAY', false);
		}
	};
	this.pageSizeOverlayModel.openCurrentOverlay = function () {
		this.closeCurrentOverlay();
		this.initSizeMenu();
		<global>.Fskin.overlayTool.setShowHide(this);
		this.targetModel.setVariable('OVERLAY', true);
		this.setVariable('SHOW', true);
	};
	this.pageSizeOverlayModel.UpdateModel = function () {
		this.initModel();
	};
	this.pageSizeOverlayModel.onSize = function () {
		<global>.kbook.model.dictionaryMode.clearPopup();
		if (this.zoomModel.SHOW) {
			this.zoomModel.closeCurrentOverlay();
		}
		else {
			if (this.selectStyle.SHOW) {
				this.selectStyle.doCloseSelectStyle();
				this.openCurrentOverlay();
			}
			else {
				if (this.SHOW) {
					this.closeCurrentOverlay();
				}
				else {
					this.openCurrentOverlay();
				}
			}
		}
	};
	this.pageSizeOverlayModel.onInstantZoom = function (zoomPlus) {
		if (this.zoomModel.SHOW) {
			if (zoomPlus) {
				if (!this.zoomModel.checkZoomLock()) {
					this.zoomModel.zoomRateChanged(10);
				}
				else {
					this.targetModel.doSomething('doBlink');
				}
			}
			else {
				if (!this.zoomModel.checkZoomLock()) {
					this.zoomModel.zoomRateChanged(-10);
				}
				else {
					this.targetModel.doSomething('doBlink');
				}
			}
		}
		else {
			if (zoomPlus) {
				this.targetModel.overlayModel.onZoomUp(10);
			}
			else {
				this.targetModel.overlayModel.onZoomUp(-10);
			}
		}
	};
	this.pageSizeOverlayModel.changeFontSize = function () {
		var scale;
		if (this.SHOW == true) {
			scale = <global>.parseInt(this.VAR_RADIO_FONTSIZE);
			scale = scale + this.commonMinScale;
			if (this.isDictionaryShown()) {
				this.setDictionaryScale(scale);
			}
			else {
				this.targetModel.doSomething('sizeTo', scale);
			}
		}
	};
	this.pageSizeOverlayModel.goZoomMode = function () {
		if (this.SHOW == true) {
			this.closeCurrentOverlay();
			this.zoomModel.onZoom();
		}
	};
	this.pageSizeOverlayModel.doSelectStyle = function () {
		if (this.SHOW == true) {
			this.selectStyle.openSelectStyle();
			this.closeCurrentOverlay();
		}
	};
	this.pageSizeOverlayModel.initSizeMenu = function () {
		var model, scale, minScale, maxScale, target;
		model = <global>.kbook.model;
		if (model) {
			switch (model.STATE) {
			case 'PAGE':
			case 'DICTIONARY':
				target = this.container;
				if (this.isDictionaryShown()) {
					scale = <global>.kbook.model.dictionaryCurrentScale;
					maxScale = this.commonMaxScale;
					minScale = this.commonMinScale;
					target.sandbox.initBtnShowHide(true);
					this.setVariable('VAR_ENABLE_ZOOM', false);
					this.setVariable('VAR_ENABLE_STYLE', false);
				}
				else {
					scale = <global>.parseInt(this.targetModel.doSomething('getAbsoluteScale'));
					maxScale = <global>.parseInt(this.targetModel.doSomething('getMaxScale'));
					minScale = <global>.parseInt(this.targetModel.doSomething('getMinScale'));
					target.sandbox.initBtnShowHide(false);
					this.setVariable('VAR_ENABLE_ZOOM', true);
					this.setVariable('VAR_ENABLE_STYLE', true);
				}
				scale = scale - this.commonMinScale;
				minScale = minScale - this.commonMinScale;
				maxScale = maxScale - this.commonMinScale;
				this.setVariable('VAR_RADIO_FONTSIZE', scale);
				this.setVariable('VAR_MAX_FONTSCALE', maxScale);
				this.setVariable('VAR_MIN_FONTSCALE', minScale);
				this.setVariable('VAR_UPDATE_FONTSIZE', false);
				this.setVariable('VAR_UPDATE_FONTSIZE', true);
			}
		}
	};
	this.pageSizeOverlayModel.initModel = function () {
		var model;
		model = <global>.kbook.model;
		if (model) {
			switch (model.STATE) {
			case 'PAGE':
			case 'DICTIONARY':
				if (model.STATE == 'PAGE') {
					this.setVariable('VAR_ENABLE_ZOOM', true);
					this.setVariable('VAR_ENABLE_STYLE', true);
				}
				else {
					this.setVariable('VAR_ENABLE_ZOOM', false);
					this.setVariable('VAR_ENABLE_STYLE', false);
				}
			case 'PICTURE':
				this.setVariable('VAR_RADIO_FONTSIZE', -1);
				this.setVariable('VAR_MAX_FONTSCALE', -1);
				this.setVariable('VAR_MIN_FONTSCALE', -1);
				this.setVariable('VAR_ENABLE_ZOOM', true);
				this.setVariable('VAR_ENABLE_STYLE', false);
			case 'MENU':
			case 'MENU_HOME':
			default:
				this.setVariable('VAR_RADIO_FONTSIZE', -1);
				this.setVariable('VAR_MAX_FONTSCALE', -1);
				this.setVariable('VAR_MIN_FONTSCALE', -1);
				this.setVariable('VAR_ENABLE_ZOOM', false);
				this.setVariable('VAR_ENABLE_STYLE', false);
			}
		}
		return true;
	};
	this.pageSizeOverlayModel.zoomChange = function () {
		this.zoomModel.onZoom();
	};
	this.pageSizeOverlayModel.doNext = function () {
		if (this.targetModel.overlayModel.onNextInstantZoom()) {
			return;
		}
		this.targetModel.doSomething('doBlink');
	};
	this.pageSizeOverlayModel.doPrevious = function () {
		if (this.targetModel.overlayModel.onPreviousInstantZoom()) {
			return;
		}
		this.targetModel.doSomething('doBlink');
	};
	this.pageSizeOverlayModel.doRoot = function () {
		this.closeCurrentOverlay();
		this.targetModel.doSomething('doRoot');
	};
	this.pageSizeOverlayModel;


6.4.2012 after some thinking:

SizeOverlay is loaded and initialized each time you press the size-button.
So your xml-variables will get initialized too.
If you look in the function initSizeMenu, in the spoiler above, you will notice this.setVariable('VAR_RADIO_FONTSIZE', scale); where scale is a variable outside the xml, preserving the state.

So you will have to add simillar to your JS code.
Define a var to hold your custom value lets name it myFontSize,
write a function myInitSizeMenu with a line
Code:
this.setVariable('VAR_RADIO_CSS_FONTSIZE', myFontSize);
and hook that new function to initSizeMenu, so that it will be executed right after.
Code:
Core.hook.hookAfter(..context to be found.. pageSizeOverlayModel, "initSizeMenu", myInitSizeMenu  );
Another notice:
the sending object is passed to every button-action.
So there is no need for different functions doFontSize5/7/6/8

You can go for: doFineFontSize = function (sender)
and within check for sender.id. It's the id defined in the xml.

Last edited by Mark Nord; 04-06-2012 at 08:33 AM. Reason: Additions 6.4.2012
Mark Nord is offline   Reply With Quote