Subversion Repositories wimsdev

Rev

Rev 10587 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
10587 obado 1
!! tabscript
11980 obado 2
!! Adds a javascript to activate tabs and memorize last selected tab in user browser.
10587 obado 3
!! INPUT : name of tag ID (it must be like #widget_$INPUT )
4
 
5
!! NB : You must be sure your ID is unique in the whole site to avoid activating wrong previously selected tag.
6
 
7
!! Put this in your .phtml to use it (sample):
8
!!
9
!!  <div id="widget_ID">
10
!!    <ul class="wims_summary">
11
!!        <li><a href="#wims_user_doc">$wims_name_Docs</a></li>
12
!!        <li><a href="#wims_user_sheet">$wims_name_Sheets</a></li>
13
!!    </ul>
14
!!    <div id="wims_user_doc">user docs</div>
15
!!    <div id="wims_user_sheet">user sheets</div>
16
!!  </div>
17
!!
18
!!  !if $jquery_defined=yes
19
!!    !read adm/tabscript ID
20
!!  !endif
21
 
10350 bpr 22
!set tmp=!word 1 of $wims_read_parm
23
 <script type="text/javascript">
24
     /*<![CDATA[*/
25
     jQuery(function($$) {
26
       // Get in sessionStorage if a tab was previously selected, and activate it.
27
       var selectedTabId = sessionStorage.getItem("$(tmp)_selectedTab");
28
       selectedTabId = selectedTabId === null ? 0 : selectedTabId; //default tab = 0
29
       $$("#widget_$tmp").tabs({
30
         active: selectedTabId,
31
         activate : function( event, ui ) {
32
             selectedTabId = $$("#widget_$tmp").tabs("option", "active");
33
             sessionStorage.setItem("$(tmp)_selectedTab", selectedTabId);
34
         }
35
       });
36
     });
37
     /*]]>*/
38
 </script>
39
!reset tmp