Sha256: 2fe48ed20785333d9e61a82065b87c73fc331e8d7f1d3044576865b8e2f0d0c2

Contents?: true

Size: 1.58 KB

Versions: 6

Compression:

Stored size: 1.58 KB

Contents

// console.log('Loading Preview...');

Spontaneous.Preview = (function($, S) {
	var dom = S.Dom, goto_id = 0;
	var click_param = function() {
		return "?__click="+(++goto_id);
	};
	var Preview = new JS.Singleton({
		include: Spontaneous.Properties,

		element: function() {
			return wrap;
		},

		title: function() {
			return this.get('title') || "";
		},
		init: function(container) {
			this.iframe = dom.iframe("#preview_pane", {'src':'about:blank'})
			this.iframe.hide();
			container.append(this.iframe);
			return this;
		},
		display: function(page) {

			// HACK: must be a better way of making sure that updates to the path are
			// propagated throughout entrie interface
			var path = S.Location.get('path');
			this.iframe.show().fadeOut(0)
			this.iframe.bind('load.preview', function() {
				var _iframe = this;
				$(this.contentWindow.document).ready(function() {
					$(_iframe).fadeIn(100);
				})
				S.Preview.set({
					'title': this.contentWindow.document.title,
					'path': this.contentWindow.location.pathname
				});
				S.Location.load_path(this.contentWindow.location.pathname)
			});
			this.goto_path(path);
		},
		goto_path: function(path) {
			if (path) {
				// path += click_param();
				this.iframe[0].contentWindow.location.href = path;
			}
		},
		goto_page: function(page) {
			var current = this.get('path');
			if (!current || (page && (page.path !== current))) {
				this.goto_path(page.path);
			}
		},
		hide: function() {
			this.iframe.unbind('load.preview').hide();
		},
		show: function() {
			this.iframe.show();
		}
	});
	return Preview;
})(jQuery, Spontaneous);

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
spontaneous-0.2.0.beta1 application/js/preview.js
spontaneous-0.2.0.alpha7 application/js/preview.js
spontaneous-0.2.0.alpha6 application/js/preview.js
spontaneous-0.2.0.alpha5 application/js/preview.js
spontaneous-0.2.0.alpha4 application/js/preview.js
spontaneous-0.2.0.alpha3 application/js/preview.js