Commit c523fd74af1b91a0be90c191f06f5c90a91f8852
1 parent
0acacf51
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
adding fullscreen scripts
Showing
1 changed file
with
38 additions
and
0 deletions
Show diff stats
public/javascripts/application.js
| ... | ... | @@ -1138,4 +1138,42 @@ function stop_fetching(element){ |
| 1138 | 1138 | jQuery('.fetching-overlay', element).remove(); |
| 1139 | 1139 | } |
| 1140 | 1140 | |
| 1141 | +function getQueryParams(qs) { | |
| 1142 | + qs = qs.split("+").join(" "); | |
| 1143 | + var params = {}, | |
| 1144 | + tokens, | |
| 1145 | + re = /[?&]?([^=]+)=([^&]*)/g; | |
| 1146 | + while (tokens = re.exec(qs)) { | |
| 1147 | + params[decodeURIComponent(tokens[1])] | |
| 1148 | + = decodeURIComponent(tokens[2]); | |
| 1149 | + } | |
| 1150 | + return params; | |
| 1151 | +} | |
| 1152 | + | |
| 1153 | +var fullwidth=false; | |
| 1154 | +function toggle_fullwidth(itemId){ | |
| 1155 | + if(fullwidth){ | |
| 1156 | + jQuery(itemId).removeClass("fullwidth"); | |
| 1157 | + jQuery("#fullscreen-btn").show() | |
| 1158 | + jQuery("#exit-fullscreen-btn").hide() | |
| 1159 | + fullwidth = false; | |
| 1160 | + } | |
| 1161 | + else{ | |
| 1162 | + jQuery(itemId).addClass("fullwidth"); | |
| 1163 | + jQuery("#exit-fullscreen-btn").show() | |
| 1164 | + jQuery("#fullscreen-btn").hide() | |
| 1165 | + fullwidth = true; | |
| 1166 | + } | |
| 1167 | + jQuery(window).trigger("toggleFullwidth", fullwidth); | |
| 1168 | +} | |
| 1169 | + | |
| 1170 | +function fullscreenPageLoad(itemId){ | |
| 1171 | + jQuery(document).ready(function(){ | |
| 1172 | + var $_GET = getQueryParams(document.location.search); | |
| 1173 | + if ($_GET['fullscreen']==1){ | |
| 1174 | + toggle_fullwidth(itemId); | |
| 1175 | + } | |
| 1176 | + }); | |
| 1177 | +} | |
| 1178 | + | |
| 1141 | 1179 | window.isHidden = function isHidden() { return (typeof(document.hidden) != 'undefined') ? document.hidden : !document.hasFocus() }; | ... | ... |