External Link Choice Provider Plugin

0 vote
Dependency :
compile ":extlinkchoice:0.11"

Documentation Source Issues

Summary

Displays external link or internal controller/action as a modalbox popup, Users can choose how they wish for these links to be opened.

Installation

grails install-plugin extlinkchoice

Description

Grails plugin which gives your app easy ways of either giving the end user or setting the end user External Link choice to either use Modal to show the link in a popup window, same window, new tab. There is a small menu that can be added to your main.gsp or where required to let user change their choice. The choice is stored in session and so long as further link calls use the same method all links will then open according to set value. There is a little configuration required on your own app and I will provide a sample app as well as this walk through

Please refer to example which has a very basic example.

0.11 moved multi modalbox calls back into one call - modified to include all the goodies from previous version, Controller+Action calls added.
0.10 fix bug from 0.9 working plugin and added extra comments to taglib
0.9 0.8 not resolving hostnames - changed resolv call back to original has a bug 
0.8 converted all fixed values to attributes passed as optional values via taglib
0.7 issues with low resolution and capped content fixed. 
0.6 minor modification to loadmodalbox template - tested and working against standard grails site and kickstart with boostrap
0.5 re-write of most of the plugin.

main.gsp requirements (jquery and if you have no bootstrap enabled extlink:loadbootstrap

<g:layoutHead/>
<g:javascript library="jquery"/>
<r:layoutResources />
<extlink:loadbootstrap/>

Jquery is called as well as extlink:loadbootstrap, you need to add this to your main.gsp for things to work, if your site is already bootstrapped then no need to do this, you need to call:

<extlink:loadplugincss/>

rather than

<extlink:loadbootstrap/>

Advanced calls to either loadbootstrap or loadplugincss :

<extlink:loadbootstrap
calctype="*"         
height="0.6"         
width="0.6"         
bodyheight="0.4"    
bodywidth='98%'     
overflow="hidden"   
position="fixed"    
top="0"    
margintop='10em' 
marginright='auto' 
left='auto'        
right='auto'       
iframescrolling='auto' 
iframetransparency='true' 
iframezoom='1'  
iframewidth='100%' 
iframeheight='100%'  
iframemargin='0'     
iframepadding='0'    
/>

Method 1: Providing link choice

<extlink:userPref update="linkPanel" 
updateShow="linkChooser"/>
<a href="#" id="linkChooser">Link Choice Chooser</a>
<div id="linkPanel" name="linkPanel" >
</div>

Method 2 : Providing link choice:

<extlink:selectPref id='autolinkUpdater' 
noSelection="['null': 'Choose Link Method']" />

Choose either method 1 or 2 not both..

Providing actual link on the page: (2 examples)

<extlink:returnLink 
link="http://www.example.com" 
description="example.com" 
choice="${session.linkchoice }" 
/>

<extlink:returnLink link="http://www.example.com" description="example.com" choice="${session.linkchoice }" title="example.com website" />

Internal Links (Controllers/Actions)

<extlink:returnLink 
controller="tester"
action="index"
description="Tester Controller" 
choice="${session.linkchoice }" 
title="index of Tester Controller" 
/>

The above will produce a link for your controller tester and open index as a link

Resolving External Links resolving hostnames within URL

<extlink:returnLink 
link="http://hostname/folder1/folder2/file.html" 
resolvit="1"
description="Grails information Site" 
choice="${session.linkchoice }" 
title="Grails.INFO" 
/>

Manually creating your own controller / actions

This may come in handy if you want to pass loads of variables across to your modal box:

<% def g = new org.codehaus.groovy.grails.plugins.web.taglib.ApplicationTagLib() %>
<g:set var="myAttachparams" 
value="[formId:'AttachForm',title:'Attache a file', 
controller: 'mailingListAttachments', 
callPage: 'formAjax' , 
divId: 'mailerAttachments', 
id: 'ATTACH']" />

<% def confirmURL= g.createLink(controller: 'MYController', action: 'MyAction', params:myAttachparams, absolute: 'true' ) %>

<extlink:returnLink link="${confirmURL}" description="My created url" choice="${session.linkchoice}" title="whatever" id="MyModal5" modalLabel="MyModalLabel5" />

Enhanced configuration options for main call to loadboostrap or sitecss explained:

calctype="*" 			[ModalBox: choices : */-+ ]
height="0.6"			[ModalBox: ScreenSize * 0.6 = modalbox height ]
width="0.6"			[ ModalBox: ScreenSize * 0.6 = modalbox width ]
bodyheight="0.4"	[ modal-body: container height default is 0.2 down from actual height ]
bodywidth='98%'		[ modal-body: container width default is 98%]
overflow="hidden"	[ ModalBox: css value for overflow(scrollbars) to display modalbox ]
position="fixed"	[ ModalBox: css value for position to display modalbox ]
top="0"		[ ModalBox: css value for top to display modalbox from ]
margintop='10em'	[ ModalBox: css value for margintop to display modalbox from ]
marginright='auto'	[ ModalBox: css value for marginright to display modalbox from ]
left='auto'			[ ModalBox: css value for left to display modalbox from ]
right='auto'		[ ModalBox: css value for right to display modalbox from ]
iframescrolling='auto' 	[ modal-body: iframe scrolling value ]
iframetransparency='true' [ modal-body: iframe transparency value ]
iframezoom='1'	[ modal-body: iframe zoom  value ]
iframewidth='100%'	[ modal-body: iframe width ]
iframeheight='100%'	[ modal-body: iframe height ] 
iframemargin='0'	[ modal-body: iframe margin ] 
iframepadding='0'	[ modal-body: iframe padding ]

For documentation on how to use this plugin, please visit documentation