1 | (function() { |
---|
2 | |
---|
3 | function setCurrentTab() { |
---|
4 | $(".image-metadata-tab").hide(); |
---|
5 | var cur_tab = window.location.hash; |
---|
6 | if (cur_tab) {} else { cur_tab = "#" + $(".image-metadata li.active").attr("rel"); } |
---|
7 | if (cur_tab !== "#undefined") { |
---|
8 | if ((cur_tab == '#comments') || (cur_tab == '#edit_comment')) { cur_tab = "#tab-comment"; } |
---|
9 | var cur_tab_rel = cur_tab.replace("#", ""); |
---|
10 | $("ul.image-metadata li").removeClass("active"); |
---|
11 | $("ul.image-metadata li[rel='" + cur_tab_rel + "']").addClass("active"); |
---|
12 | if (cur_tab == "#tab-comment") { normalizeComments("tab-comment"); } |
---|
13 | $(cur_tab).show(); |
---|
14 | } else { |
---|
15 | $(".image-metadata-tab").first().show(); |
---|
16 | } |
---|
17 | } |
---|
18 | |
---|
19 | function normalizeComments(activeTab) { |
---|
20 | if (activeTab == 'tab-comment') { |
---|
21 | $("li.commentElement .actions a").each(function( index ) { |
---|
22 | if ($(this).is('a[href*="#"]')) { |
---|
23 | } else { |
---|
24 | var href = $(this).attr("href") + "#tab-comment"; |
---|
25 | $(this).attr("href", href); |
---|
26 | } |
---|
27 | }); |
---|
28 | } |
---|
29 | } |
---|
30 | |
---|
31 | function switchTab(tab) { |
---|
32 | $("ul.image-metadata li").removeClass("active"); |
---|
33 | $(tab).addClass("active"); |
---|
34 | $(".image-metadata-tab").hide(); |
---|
35 | var activeTab = $(tab).attr("rel"); |
---|
36 | window.location.hash = '#' + activeTab; |
---|
37 | if (p_pict_tab_anim == "on") { |
---|
38 | $("#" + activeTab).fadeIn(); |
---|
39 | }else{ |
---|
40 | $("#" + activeTab).show(); |
---|
41 | } |
---|
42 | normalizeComments(activeTab); |
---|
43 | } |
---|
44 | |
---|
45 | jQuery(function(){ |
---|
46 | setCurrentTab(); |
---|
47 | |
---|
48 | $("ul.image-metadata li").click(function() { switchTab(this); }); |
---|
49 | }); |
---|
50 | }()); |
---|