| 1 | <!-- start html templates --> |
| 2 | <script id="details-menu-up-glyph" type="text/x-generic-html-template"> |
| 3 | <span class="glyphicon glyphicon-menu-up" style="margin-left: 5px;" |
| 4 | aria-hidden="true"></span> |
| 5 | </script> |
| 6 | <script id="details-menu-down-glyph" type="text/x-generic-html-template"> |
| 7 | <span class="glyphicon glyphicon-menu-down" style="margin-left: 5px;" |
| 8 | aria-hidden="true"></span> |
| 9 | </script> |
| 10 | <!-- end html templates --> |
| 11 | |
| 12 | <script> |
| 13 | $(window).ready(function() { |
| 14 | $('.collapse').removeClass('in'); |
| 15 | $('.program-session-room-details button').show(); |
| 16 | |
| 17 | init_toggle_all(); |
| 18 | |
| 19 | $('.session-desc') |
| 20 | .on('show.bs.collapse', function() { |
| 21 | var id = $(this).attr('id'); |
| 22 | // find corresponding "Details"/"Collapse details" button. |
| 23 | var btn = $('[data-target="#'+ id + '"]'); |
| 24 | var glyph = $('#details-menu-up-glyph').text(); |
| 25 | $(btn).text('Collapse details'); |
| 26 | $(glyph).appendTo(btn); |
| 27 | }); |
| 28 | |
| 29 | $('.session-desc') |
| 30 | .on('hide.bs.collapse', function() { |
| 31 | var id = $(this).attr('id'); |
| 32 | // find corresponding "Details"/"Collapse details" button. |
| 33 | var btn = $('[data-target="#'+ id + '"]'); |
| 34 | var glyph = $('#details-menu-down-glyph').text(); |
| 35 | $(btn).text('Show details'); |
| 36 | $(glyph).appendTo(btn); |
| 37 | }); |
| 38 | }); |
| 39 | |
| 40 | $(window).resize(function() { |
| 41 | reinit_toggle_all(); |
| 42 | }); |
| 43 | |
| 44 | $(window).scroll(function() { |
| 45 | position_toggle_all(); |
| 46 | }); |
| 47 | |
| 48 | function init_toggle_all(reinit=false) { |
| 49 | var block = '.program-session-details-toggle-all'; |
| 50 | // on click init. |
| 51 | if (!reinit) |
| 52 | toggle_all_click_init(); |
| 53 | |
| 54 | // positioning. |
| 55 | window.toggle_all_pos = $(block).offset(); |
| 56 | position_toggle_all(); |
| 57 | $(block).show(); |
| 58 | } |
| 59 | |
| 60 | function reinit_toggle_all() { |
| 61 | // make position static to know the real position of toggle all. |
| 62 | toggle_all_static(); |
| 63 | init_toggle_all(true); |
| 64 | } |
| 65 | |
| 66 | function toggle_all_fixed() { |
| 67 | $('.program-session-details-toggle-all button').addClass('fixed'); |
| 68 | } |
| 69 | |
| 70 | function toggle_all_static() { |
| 71 | $('.program-session-details-toggle-all button').removeClass('fixed'); |
| 72 | } |
| 73 | |
| 74 | function position_toggle_all() { |
| 75 | var toggle_all_btn = '.program-session-details-toggle-all button'; |
| 76 | var t_pos = window.toggle_all_pos; |
| 77 | var w_top = $(window).scrollTop(); |
| 78 | |
| 79 | if(w_top > t_pos.top) |
| 80 | toggle_all_fixed(); |
| 81 | else |
| 82 | toggle_all_static(); |
| 83 | |
| 84 | } |
| 85 | |
| 86 | function toggle_all_click_init() { |
| 87 | var toggle_all_btn = '.program-session-details-toggle-all button'; |
| 88 | var details_btn = '.program-session-room-details button'; |
| 89 | |
| 90 | // initially everything is collapsed. |
| 91 | window.toggle_all = { |
| 92 | 'collapsed': true, |
| 93 | 'clicked': false, |
| 94 | }; |
| 95 | |
| 96 | $(toggle_all_btn).click(function() { |
| 97 | |
| 98 | if (window.toggle_all.collapsed) { |
| 99 | $('.collapse').collapse('show'); |
| 100 | window.toggle_all.collapsed = false; |
| 101 | } else { |
| 102 | $('.collapse').collapse('hide'); |
| 103 | window.toggle_all.collapsed = true; |
| 104 | } |
| 105 | |
| 106 | // set toggle all clicked. |
| 107 | window.toggle_all.clicked = true; |
| 108 | }); |
| 109 | |
| 110 | $('.collapse').on('shown.bs.collapse', function() { |
| 111 | update_toggle_all_text('Collapse all'); |
| 112 | }); |
| 113 | |
| 114 | $('.collapse').on('hidden.bs.collapse', function() { |
| 115 | update_toggle_all_text('Expand all'); |
| 116 | }); |
| 117 | } |
| 118 | |
| 119 | function update_toggle_all_text(txt) { |
| 120 | var toggle_all_btn = '.program-session-details-toggle-all button'; |
| 121 | |
| 122 | // update text only when toggle all is clicked. |
| 123 | if (window.toggle_all.clicked) |
| 124 | $(toggle_all_btn).text(txt); |
| 125 | |
| 126 | // reset toggle clicked |
| 127 | window.toggle_all.clicked = false; |
| 128 | } |
| 129 | </script> |
| 130 | |
| 131 | <script type="text/javascript"> |
| 132 | $(".program-link").addClass("active"); |
| 133 | </script> |