diff --git a/lib/WebGUI/Asset.pm b/lib/WebGUI/Asset.pm index 88d072a55..8d38feb4b 100644 --- a/lib/WebGUI/Asset.pm +++ b/lib/WebGUI/Asset.pm @@ -1857,7 +1857,7 @@ sub newPending { #------------------------------------------------------------------- -=head2 outputWidgetMarkup ( width, height, templateId ) +=head2 outputWidgetMarkup ( width, height, templateId, [styleTemplateId] ) Output the markup required for the widget view. Includes markup to handle the widget macro in the iframe holding the widgetized asset. This does the following: @@ -1909,12 +1909,20 @@ widget-in-widget function properly. =cut +=head3 styleTemplateId + +The style templateId for this widgetized asset to use. Not required for making +widget-in-widget function properly. + +=cut + sub outputWidgetMarkup { # get our parameters. - my $self = shift; - my $width = shift; - my $height = shift; - my $templateId = shift; + my $self = shift; + my $width = shift; + my $height = shift; + my $templateId = shift; + my $styleTemplateId = shift; # construct / retrieve the values we'll use later. my $assetId = $self->getId; @@ -1938,6 +1946,11 @@ sub outputWidgetMarkup { # we'll be serializing the content of the asset which is being widgetized. my $storage = WebGUI::Storage->get($session, $assetId); my $content = $self->view; + if($styleTemplateId eq '' or $styleTemplateId eq 'none'){ + $content = $self->session->style->userStyle($content); + }else{ + $content = $self->session->style->process($content,$styleTemplateId); + } WebGUI::Macro::process($session, \$content); my $jsonContent = to_json( { "asset$assetId" => { content => $content } } ); $storage->addFileFromScalar("$assetId.js", "data = $jsonContent"); @@ -2721,9 +2734,10 @@ sub www_widgetView { return $session->privilege->noAccess() unless $self->canView; - my $templateId = $session->form->process('templateId'); - my $width = $session->form->process('width'); - my $height = $session->form->process('height'); + my $templateId = $session->form->process('templateId'); + my $width = $session->form->process('width'); + my $height = $session->form->process('height'); + my $styleTemplateId = $session->form->process('styleTemplateId'); if($templateId eq 'none') { $self->prepareView; @@ -2731,7 +2745,7 @@ sub www_widgetView { else { $self->prepareWidgetView($templateId); } - return $self->outputWidgetMarkup($width, $height, $templateId); + return $self->outputWidgetMarkup($width, $height, $templateId, $styleTemplateId); } 1; diff --git a/lib/WebGUI/Macro/Widget.pm b/lib/WebGUI/Macro/Widget.pm index 4dd1bcc4a..e5047cf3f 100644 --- a/lib/WebGUI/Macro/Widget.pm +++ b/lib/WebGUI/Macro/Widget.pm @@ -21,6 +21,7 @@ sub process { my $width = shift || 600; my $height = shift || 400; my $templateId = shift || 'none'; + my $styleTemplateId = shift || 'none'; # Get location for CSS and JS files my $conf = $session->config; @@ -85,7 +86,7 @@ sub process { @@ -108,7 +109,7 @@ OUTPUT my $output = < EOHTML diff --git a/www/extras/wgwidget.js b/www/extras/wgwidget.js index b3504d16f..ce7f8eb30 100644 --- a/www/extras/wgwidget.js +++ b/www/extras/wgwidget.js @@ -30,7 +30,7 @@ WebGUI.widgetBox = { return widgetFrame; }, - widget : function( url, parentId, width, height, templateId ) { + widget : function( url, parentId, width, height, templateId, styleTemplateId ) { if(url == "") { return ""; } @@ -49,6 +49,7 @@ WebGUI.widgetBox = { this.url = url + "?func=widgetView&templateId=" + templateId; this.url += ";width=" + width; this.url += ";height=" + height; + this.url += ";styleTemplateId=" + styleTemplateId; } this.parentNodeId = parentId; @@ -111,7 +112,7 @@ WebGUI.widgetBox = { var jsCode = ""; jsCode += "<script type='text/javascript' src='" + params.wgWidgetPath + "'> </script>"; jsCode += "<script type='text/javascript'>"; - jsCode += "document.write(WebGUI.widgetBox.widget('" + params.fullUrl + "', '" + params.assetId + "', " + params.width + ", " + params.height + ", '" + params.templateId + "')); </script>"; + jsCode += "document.write(WebGUI.widgetBox.widget('" + params.fullUrl + "', '" + params.assetId + "', " + params.width + ", " + params.height + ", '" + params.templateId + "', '" + params.styleTemplateId + "')); </script>"; // Instantiate the Dialog codeGeneratorButton = new YAHOO.widget.SimpleDialog("codeGeneratorButton", {