/* Copyright 2009 Palm, Inc.  All rights reserved. */

Photos.Scene.Cropscale = Class.create(Photos.Scene.Base, {
	initialize: function($super, passedArg) {
		$super(passedArg);
		this.cameFromFullScreen = passedArg.cameFromFullScreen;
		Mojo.Log.info("Passed crop url of:", this.url);
	},

	setup: function($super) {
		$super();
		this.flipviewElement = this.controller.get('image_cropview');

		// always fullscreen...
		this.flipviewElement.width =
			Mojo.Environment.DeviceInfo.screenWidth;
		this.flipviewElement.height =
			Mojo.Environment.DeviceInfo.screenHeight;
		this.flipviewElement.style.width =
					this.flipviewElement.width + "px";
		this.flipviewElement.style.height =
					this.flipviewElement.height + "px";

		this.controller.enableFullScreenMode(true);

		this.controller.setupWidget('image_cropview', {
			source: this.sceneModel.getUrl(),
			text: this.sceneModel.getText(),
			width: this.sceneModel.getWidth(),
			height: this.sceneModel.getHeight(),
			limitZoom: this.sceneModel.getZoomLimit(),
			backgroundColor: this.sceneModel.getBackground(),
			callback: this.sceneModel.getAccepted()
		});
	},

	aboutToActivate: function($super, callback) {
		$super(callback);
		this.ready.bind(this).defer();
	},

	cleanup: function($super) {
		$super();
		if (!this.cameFromFullScreen) {
			this.controller.enableFullScreenMode(false);
		}
	}
});

