Move profile/edit javascript in .js files and activate PlWizard eye-candies
[platal.git] / templates / core / plwizard.tpl
index 3a0d2ad..a1ea50e 100644 (file)
 {*  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA               *}
 {*                                                                        *}
 {**************************************************************************}
+{javascript name="jquery"}
+<script type="text/javascript">//<![CDATA[
+  {if ($stateless || $id gt $current) && $wiz_ajax}
+  {literal}
+  function changePage(obj, id)
+  {
+    var myUrl = obj.href;
+    $.ajax({ url: myUrl + "/ajax",
+             global: false,
+             dataTye: 'html',
+             error: function(request, error) {
+                      document.location = myUrl;
+                    },
+             success: function(data) {
+                        $(".wiz_content").fadeOut('normal',
+                            function() {
+                              $(".wiz_tab").removeClass("active");
+                              $("#wiz_tab_" + id).addClass("active");
+                              $(".wiz_content").html(data).fadeIn('normal');
+                              if (typeof wizPage_onLoad == 'function') {
+                                wizPage_onLoad(id);
+                              }
+                            });
+                      }
+          });
+    return false;
+  }
+  {/literal}
+  {else}
+  {literal}
+  function changePage(obj)
+  {
+    return true;
+  }
+  {/literal}
+  {/if}
+  {literal}
+  $(document).ready(
+    function() {
+      if (typeof wizPage_onLoad == 'function') {
+        wizPage_onLoad({/literal}'{$lookup[$current]}'{literal});
+      }
+    });
+  {/literal}
+//]]></script>
 
 <div class="wizard" style="clear: both">
   <div class="wiz_header">
     {foreach from=$pages item=title key=id}
-    <div class="wiz_tab {if $id eq $current}active{/if} {if !$stateless && $current gt $id}grayed{/if}"
-         style="float: left; width: {$tab_width}%">
-      {if $stateless || $id gt $current}<a href="{$wiz_baseurl}/{$lookup[$id]}">{/if}
-      {$title}
-      {if $stateless || $id gt $current}</a>{/if}
-    </div>
+    {if $stateless || $id gt $current}
+    {assign var=tag value="a"}
+    {else}
+    {assign var=tag value="div"}
+    {/if}
+    <{$tag} class="wiz_tab {if $id eq $current}active{/if} {if !$stateless && $current gt $id}grayed{/if}"
+            style="display: block; float: left; width: {$tab_width}%; vertical-align: middle"
+            id="wiz_tab_{$lookup[$id]}"
+            {if $tag eq "a"}
+            href="{$wiz_baseurl}/{$lookup[$id]}"
+            onclick="return changePage(this, '{$lookup[$id]}')"
+            {/if}
+            >
+      <span style="vertical-align: middle">{$title}</span>
+    </{$tag}>
     {/foreach}
     <div style="clear: both"></div>
   </div>