can3p (can3p) wrote in changelog,
can3p
can3p
changelog

[ljcom] r11131: OPSC-386: Implement JS API and layout fo...

Committer: dpetrov
OPSC-386: Implement JS API and layout for popup application views
U   trunk/htdocs/js/apps/ljifrgadgetservice.js
A   trunk/htdocs/js/apps/widgets/
A   trunk/htdocs/js/apps/widgets/opengadget.js
Modified: trunk/htdocs/js/apps/ljifrgadgetservice.js
===================================================================
--- trunk/htdocs/js/apps/ljifrgadgetservice.js	2011-10-31 14:20:38 UTC (rev 11130)
+++ trunk/htdocs/js/apps/ljifrgadgetservice.js	2011-11-01 09:10:18 UTC (rev 11131)
@@ -50,15 +50,10 @@
  * @param {Number} The height in px.
  */
 shindig.LJIfrGadgetService.prototype.setHeight = function(height) {
-	var frame = jQuery( '#' + this.f );
+	var id = shindig.container.gadgetService.getGadgetIdFromModuleId(this.f),
+		gadget = shindig.container.getGadget(id);
 
-	if (height > shindig.container.maxheight_) {
-		height = shindig.container.maxheight_;
-	}
-
-	if( frame.length > 0 ) {
-		frame.height( height );
-	}
+	gadget.setHeight(height);
 };
 
 /**
@@ -66,11 +61,10 @@
  *     element for all applications.
  */
 shindig.LJIfrGadgetService.prototype.setTitle = function(title) {
-	var element = jQuery('.b-catalogue-app h1');
-	if (element.length > 0) {
-		// update the title, and make sure we don't break it's html
-		element.text(title.replace(/&/g, '&amp;').replace(/</g, '&lt;'));
-	}
+	var id = shindig.container.gadgetService.getGadgetIdFromModuleId(this.f),
+		gadget = shindig.container.getGadget(id);
+
+	gadget.setTitle(title);
 };
 
 /**
@@ -189,6 +183,12 @@
 	widget.loadContent();
 }
 
+/**
+ * Retreive new security token from the server.
+ *
+ * @param {String} cId Callback id.
+ * @param {String} st Security token of the application.
+ */
 shindig.LJIfrGadgetService.prototype.refreshSecurityToken = function(cId, st) {
 	var frame = this.f;
 

Added: trunk/htdocs/js/apps/widgets/opengadget.js
===================================================================
--- trunk/htdocs/js/apps/widgets/opengadget.js	                        (rev 0)
+++ trunk/htdocs/js/apps/widgets/opengadget.js	2011-11-01 09:10:18 UTC (rev 11131)
@@ -0,0 +1,79 @@
+LJAppWidget_OpenGadget = new Class(LJAppWidget, {
+	init: function (opts, params) {
+		opts.templateID = 'ljappippu_open_gadget';
+		opts.widgetName = 'open_gadget';
+
+		LJAppWidget_OpenGadget.superClass.init.apply(this, arguments);
+		this.dialogId = opts.dialogId;
+		this._iframe;
+	},
+
+	onData: function(data) {
+		this.onReturn("OK", data, true);
+	},
+
+	close: function() {
+		LJAppWidget_OpenGadget.superClass.close.apply(this, arguments);
+	},
+
+	cancel: function() {
+		shindig.container.gadgetService.close(this.dialogId);
+	},
+
+	contentLoaded: function(data) {
+		LJAppWidget_OpenGadget.superClass.contentLoaded.apply(this, arguments);
+
+		var iframe = this._iframe = jQuery(data.element),
+			$widget = jQuery(this.getWidget());
+
+		this.frameId = iframe.prop('id');
+
+		$widget.append(iframe);
+		this.setHeight();
+
+		shindig.container.createGadget(iframe, 'popup', this);
+
+		var id = shindig.container.gadgetService.getGadgetIdFromModuleId(iframe.prop('id')),
+			gadget = shindig.container.getGadget(id);
+		gadget.dialog_id = this.dialogId;
+		gadget.frame_id = id;
+	},
+
+	setHeight: function(val) {
+		var minHeight = 300,
+			height;
+
+		if (val && val >= minHeight) {
+			val = (val >= minHeight) ? val : minHeight;
+			this._iframe.height(val);
+			height = val;
+		} else {
+			height = this._iframe.height();
+		}
+
+		var wOffset = 100, //we should leave a little space around an app
+			iframeWidth = this._iframe.width(),
+			$widget = jQuery(this.getWidget()),
+			wHeight = jQuery(window).height(),
+			wOffset = 100; //we should leave a little space around an app
+
+		if (height > wHeight - wOffset) {
+			this._iframe.height(wHeight - wOffset);
+		}
+
+		this.ippu.setDimensions(iframeWidth, 'auto');
+		this.ippu.center();
+	},
+
+	setWidth: function(val) {
+	},
+
+	setTitle: function(title) {
+		this.ippu.setTitle(title);
+	},
+
+	refreshDialog: function() {
+		this.loadContent('preview');
+	}
+});
+

Tags: can3p, dpetrov, js, ljcom
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments