Macro Widgets now take a style, defaulting to the users.
This commit is contained in:
parent
0c91491ed0
commit
d8127aec73
3 changed files with 29 additions and 13 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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 {
|
|||
<script type='text/javascript'>
|
||||
function setupPage() {
|
||||
WebGUI.widgetBox.retargetLinksAndForms();
|
||||
WebGUI.widgetBox.initButton( { 'wgWidgetPath' : '$wgWidgetPath', 'fullUrl' : '$fullUrl', 'assetId' : '$assetId', 'width' : $width, 'height' : $height, 'templateId' : '$templateId' } );
|
||||
WebGUI.widgetBox.initButton( { 'wgWidgetPath' : '$wgWidgetPath', 'fullUrl' : '$fullUrl', 'assetId' : '$assetId', 'width' : $width, 'height' : $height, 'templateId' : '$templateId', 'styleTemplateId' : $styleTemplateId } );
|
||||
}
|
||||
YAHOO.util.Event.addListener(window, 'load', setupPage);
|
||||
</script>
|
||||
|
|
@ -108,7 +109,7 @@ OUTPUT
|
|||
my $output = <<EOHTML;
|
||||
<a href="#$assetId" id="show$assetId" name="show$assetId"><img src="$imgSrc" /></a>
|
||||
<script type="text/javascript">
|
||||
YAHOO.util.Event.addListener(window, 'load', WebGUI.widgetBox.initButton, { 'wgWidgetPath' : '$wgWidgetPath', 'fullUrl' : '$fullUrl', 'assetId' : '$assetId', 'width' : $width, 'height' : $height, 'templateId' : '$templateId' } );
|
||||
YAHOO.util.Event.addListener(window, 'load', WebGUI.widgetBox.initButton, { 'wgWidgetPath' : '$wgWidgetPath', 'fullUrl' : '$fullUrl', 'assetId' : '$assetId', 'width' : $width, 'height' : $height, 'templateId' : '$templateId', 'styleTemplateId' : '$styleTemplateId' } );
|
||||
</script>
|
||||
EOHTML
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue