From c523fd74af1b91a0be90c191f06f5c90a91f8852 Mon Sep 17 00:00:00 2001 From: Leandro Nunes dos Santos Date: Fri, 27 Feb 2015 12:02:04 -0300 Subject: [PATCH] adding fullscreen scripts --- public/javascripts/application.js | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+), 0 deletions(-) diff --git a/public/javascripts/application.js b/public/javascripts/application.js index 21bbd79..6c95be2 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -1138,4 +1138,42 @@ function stop_fetching(element){ jQuery('.fetching-overlay', element).remove(); } +function getQueryParams(qs) { + qs = qs.split("+").join(" "); + var params = {}, + tokens, + re = /[?&]?([^=]+)=([^&]*)/g; + while (tokens = re.exec(qs)) { + params[decodeURIComponent(tokens[1])] + = decodeURIComponent(tokens[2]); + } + return params; +} + +var fullwidth=false; +function toggle_fullwidth(itemId){ + if(fullwidth){ + jQuery(itemId).removeClass("fullwidth"); + jQuery("#fullscreen-btn").show() + jQuery("#exit-fullscreen-btn").hide() + fullwidth = false; + } + else{ + jQuery(itemId).addClass("fullwidth"); + jQuery("#exit-fullscreen-btn").show() + jQuery("#fullscreen-btn").hide() + fullwidth = true; + } + jQuery(window).trigger("toggleFullwidth", fullwidth); +} + +function fullscreenPageLoad(itemId){ + jQuery(document).ready(function(){ + var $_GET = getQueryParams(document.location.search); + if ($_GET['fullscreen']==1){ + toggle_fullwidth(itemId); + } + }); +} + window.isHidden = function isHidden() { return (typeof(document.hidden) != 'undefined') ? document.hidden : !document.hasFocus() }; -- libgit2 0.21.2