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