Hi Caleb,

This commit has broken a functional test, please see:
http://bit.ly/aNzmAF

Thanks
-Vincent

On Tue, Feb 9, 2010 at 6:49 AM, cjdelisle
<[email protected]> wrote:
> Author: cjdelisle
> Date: 2010-02-09 06:49:32 +0100 (Tue, 09 Feb 2010)
> New Revision: 26828
>
> Modified:
>   
> platform/xwiki-applications/trunk/administration/src/main/resources/XWiki/Registration.xml
> Log:
> XAADMINISTRATION-103: Make registration page support lightbox so 
> administrator can use it to add users in admin users sheet. - Modified 
> registration page to be compatable with lightbox, also moved form tags and 
> submit button outside of generateHtml macro.
>
> Modified: 
> platform/xwiki-applications/trunk/administration/src/main/resources/XWiki/Registration.xml
> ===================================================================
> --- 
> platform/xwiki-applications/trunk/administration/src/main/resources/XWiki/Registration.xml
>   2010-02-09 05:46:48 UTC (rev 26827)
> +++ 
> platform/xwiki-applications/trunk/administration/src/main/resources/XWiki/Registration.xml
>   2010-02-09 05:49:32 UTC (rev 26828)
> @@ -74,6 +74,11 @@
>  #set($loginPage = 'XWiki.XWikiLogin')
>  #set($loginAction = 'loginsubmit')
>  ##
> +## If this is true, then assume the registration page is being viewed inside 
> of a lightbox
> +#if($request.get('xpage'))
> +  #set($assumeLightbox = true)
> +#end
> +##
>  ## Use javascript based live validation see: http://www.livevalidation.com
>  ## Set false to stop using LiveValidation
>  #set($useLiveValidation = true)
> @@ -457,16 +462,68 @@
>  ## Then we display the registration form.
>  #if(!$registrationDone)
>   $welcomeMessage
> -  {{html clean=false}}
> -    ## I do not want to put this inside of a paragraph block so I end the 
> block here and
> -    ## start it at the end.
> -    &lt;/p&gt;
> +  {{html clean=false wiki=false}}
> +    &lt;div&gt;
> +    &lt;form id="register" action="" method="post"&gt;
> +    &lt;div&gt;
>     #generateHtml($fields, $fieldMandatoryStar, $failureMessageParams)
> +    &lt;span class="buttonwrapper"&gt;
> +    #if($assumeLightbox)
> +      ## LightBox detected...
> +      &lt;script type="text/javascript"&gt;
> +        ## Make the X button not reload the page. (overriding LbClose)
> +        window.lb.lbClose = function() {
> +          this.lbHide();
> +          this.lbClearData();
> +          ##return false;
> +        }
> +        ## Post the form entry to the page and load the result. (we override 
> lbSaveForm)
> +        window.lb.lbSaveForm = function() {
> +          var formParams = Form.serialize(this.form);
> +          Form.disable(this.form);
> +          var ajaxRequest = new Ajax.Request(this.saveUrl, {
> +            parameters: formParams,
> +            asynchronous: false
> +          });
> +          window.lb.lbFormDataLoaded(ajaxRequest.transport);
> +        }
> +      &lt;/script&gt;
> +      ## It doesn't really matter where these are, the scripts will be 
> relocated to the head.
> +      &lt;!-- com.xpn.xwiki.plugin.skinx.CssSkinFileExtensionPlugin --&gt;
> +      &lt;!-- com.xpn.xwiki.plugin.skinx.JsSkinFileExtensionPlugin --&gt;
> +      ##
> +      &lt;input class="button" type="submit" value="$msg.get('save')" 
> onclick="window.lb.lbSaveForm();"/&gt;
> +      &lt;/span&gt;#* End ButtonWrapper then start another...*#&lt;span 
> class="buttonwrapper"&gt;
> +      &lt;input class="button" type="submit" value="$msg.get("cancel")" 
> onclick="Form.disable(window.lb.form); window.lb.lbClose();"/&gt;
> +    #else
> +      ## Not using the LightBox
> +      &lt;input type="submit" value="$msg.get('core.register.submit')" 
> class="button"/&gt;
> +    #end
> +    &lt;/span&gt;## ButtonWrapper
> +    &lt;/div&gt;
> +    &lt;/form&gt;
>     #if($useLiveValidation)
>       #generateJavascript($fields)
>     #end
> -    &lt;p&gt;
> +    &lt;/div&gt;
>   {{/html}}
> +## If the registration is done (successful) and we detect the Lightbox 
> simply send the user back to the original page.
> +#elseif($assumeLightbox)
> +  {{html clean=false wiki=false}}
> +    &lt;script type="text/javascript"&gt;
> +        var url = window.lb.redirectUrl;
> +        window.lb.lbClose;
> +        if (url != undefined) {
> +          if(window.location.pathname + window.location.search == url) {
> +            ## Under certain circumstances (bug) Opera will not load a page 
> if the location is the same as the current page.
> +            ## In these cases, location.reload() doesn't work either, the 
> only solution (I could find) was to change the URL.
> +            window.location.href = url + "&amp;";
> +          } else {
> +            window.location.href = url;
> +          }
> +        }
> +    &lt;/script&gt;
> +  {{/html}}
>  #end
>  ##
>  ####### The Macros (nothing below this point is run directly) #########
> @@ -608,7 +665,8 @@
>           &lt;/span&gt;
>           &lt;/div&gt;
>         &lt;/form&gt;
> -        #if($autoLogin)
> +        ## We don't want autoLogin if we are administrators adding users...
> +        #if($autoLogin &amp;&amp; !$assumeLightbox)
>           &lt;script type='text/javascript'&gt;
>             document.observe('dom:loaded', function() {
>               document.forms['loginForm'].submit();
> @@ -632,59 +690,54 @@
>     ## Put the same values back into the fields.
>     #getParams($fields)
>     ##
> -    &lt;form id="register" action="" method="post"&gt;
> -    &lt;div&gt;&lt;dl&gt;
> -      ##
> -      #foreach($field in $fields)
> -        #if($field.get('name'))
> -          #set($fieldName = $field.get('name'))
> -          #if($field.get('label'))
> -            #set($label = $field.get('label'))
> -            &lt;dt&gt;&lt;label for="$fieldName"&gt;$label&lt;/label&gt;
> -            #if($field.get('validate').get('mandatory'))
> -              &lt;span
> -              #foreach($entry in $fieldMandatoryStar.entrySet())
> -                $entry.getKey()="$entry.getValue()"
> -              #end
> -              &gt;*&lt;/span&gt;
> +    &lt;dl&gt;
> +    #foreach($field in $fields)
> +      #if($field.get('name'))
> +        #set($fieldName = $field.get('name'))
> +        #if($field.get('label'))
> +          #set($label = $field.get('label'))
> +          &lt;dt&gt;&lt;label for="$fieldName"&gt;$label&lt;/label&gt;
> +          #if($field.get('validate').get('mandatory'))
> +            &lt;span
> +            #foreach($entry in $fieldMandatoryStar.entrySet())
> +              $entry.getKey()="$entry.getValue()"
>             #end
> -            &lt;/dt&gt;
> +            &gt;*&lt;/span&gt;
>           #end
> -          ## If no tag then default tag is &lt;input&gt;
> -          #if($field.get('tag'))
> -            #set($tag = $field.get('tag'))
> -          #else
> -            #set($tag = 'input')
> +          &lt;/dt&gt;
> +        #end
> +        ## If no tag then default tag is &lt;input&gt;
> +        #if($field.get('tag'))
> +          #set($tag = $field.get('tag'))
> +        #else
> +          #set($tag = 'input')
> +        #end
> +        &lt;dd&gt;&lt;$tag id="$fieldName"
> +        #set($params = $field.get('params'))
> +        ## If no name parameter is spacified, then we use the field name
> +        #if(!$params.get('name'))
> +          #set($discard = $params.put('name', $fieldName))
> +        #end
> +        #foreach($entry in $params.entrySet())
> +          ## If a parameter is specified as '' then we don't include it.
> +          #if($entry.getValue() != '')
> +            $entry.getKey()="$escapetool.html($entry.getValue())"
>           #end
> -          &lt;dd&gt;&lt;$tag id="$fieldName"
> -          #set($params = $field.get('params'))
> -          ## If no name parameter is spacified, then we use the field name
> -          #if(!$params.get('name'))
> -            #set($discard = $params.put('name', $fieldName))
> +        #end
> +        &gt;&lt;/$tag&gt;
> +        #if($field.get('error'))
> +          &lt;span
> +          #foreach($entry in $failureMessageParams.entrySet())
> +            $entry.getKey()="$entry.getValue()"
>           #end
> -          #foreach($entry in $params.entrySet())
> -            ## If a parameter is specified as '' then we don't include it.
> -            #if($entry.getValue() != '')
> -              $entry.getKey()="$escapetool.html($entry.getValue())"
> -            #end
> -          #end
> -          &gt;&lt;/$tag&gt;
> -          #if($field.get('error'))
> -            &lt;span
> -            #foreach($entry in $failureMessageParams.entrySet())
> -              $entry.getKey()="$entry.getValue()"
> -            #end
> -            &gt;$field.get('error')&lt;/span&gt;
> -          #end
> -          &lt;/dd&gt;
> -        #else
> -          ERROR: Field with no name.
> -        #end##if fieldName exists
> -      #end
> -      &lt;/dl&gt;
> -    &lt;span class="buttonwrapper"&gt;&lt;input type="submit" 
> value="$msg.get('core.register.submit')" class="button"/&gt;&lt;/span&gt;
> -    &lt;/div&gt;
> -  &lt;/form&gt;
> +          &gt;$field.get('error')&lt;/span&gt;
> +        #end
> +        &lt;/dd&gt;
> +      #else
> +        ERROR: Field with no name.
> +      #end##if fieldName exists
> +    #end
> +    &lt;/dl&gt;
>   #end
>   ##
>   ## Remove newlines inside of tags because tags are generated by loops.
_______________________________________________
devs mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/devs

Reply via email to