var elem = document.documentElement; function openFullscreen() { if (elem.requestFullscreen) { elem.requestFullscreen(); } else if (elem.mozRequestFullScreen) { /* Firefox */ elem.mozRequestFullScreen(); } else if (elem.webkitRequestFullscreen) { /* Chrome, Safari & Opera */ elem.webkitRequestFullscreen(); } else if (elem.msRequestFullscreen) { /* IE/Edge */ elem.msRequestFullscreen(); } } function closeFullscreen() { if (document.exitFullscreen) { document.exitFullscreen(); } else if (document.mozCancelFullScreen) { document.mozCancelFullScreen(); } else if (document.webkitExitFullscreen) { document.webkitExitFullscreen(); } else if (document.msExitFullscreen) { document.msExitFullscreen(); } } // Loop all cards and insert their hashes to settings-links $(document).ready(function () { $(document).ajaxComplete(function () { $(".widget-card").each(function(){ var thisId = $(this).attr("id"); var thisHash = $(this).attr("data-widget-hash"); // console.log("id: " + thisId); // console.log("hash: " + thisHash); // console.log("------------------"); // TODO: Change this to long-tap // var settingsLink = "/settings/?widget-hash="+thisHash; // $("#"+thisId+" .settings-link").attr("href",settingsLink); }); }); }); // We need to create dynamic keyframes to show the animation from full-screen to normal. So we create a stylesheet in which we can insert CSS keyframe rules $("body").append(""); // Zooming a Card function zoomCard(thisId) { var thisHash = $("#"+thisId).attr("data-widget-hash"); var thisWidgetFolderName = $("#"+thisId).attr("data-widget-folder-name"); if (thisId != 'widget-content-advertising') { // Remove Card Zoom (if there is one) TODO: add again if user wants zoom $("#"+thisId).find(".card").removeClass("card-zoom"); // The position of the container will be set to fixed, so set the top & left properties of the container var bounding_box = $("#"+thisId).get(0).getBoundingClientRect(); $("#"+thisId).css({ top: bounding_box.top + "px", left: bounding_box.left + "px" }); // Set container to fixed position. Add animation $("#"+thisId).addClass("in-animation"); $(".widget-card-zoom").hide(); var windowHeight = $(window).height(); var newHeight = (windowHeight-65); $(".in-animation .card").css("max-height", newHeight+"px"); // Test with a backdrop $(".overlay").css("opacity", "1"); $(".overlay").css("display", "block"); $(".overlay").css("visibility", "visible"); $(".overlay").css("z-index", "11000"); $(".overlay").css("background-color", "#f2f4f7"); $("#buttons-all").show(); // Change settings-link var settingsLink = "/settings/?widget-hash="+thisHash; $("#settings-all").attr("href",settingsLink); var timestamp = new Date().getTime(); var settingsLinkModal = "/?widget-settings="+thisWidgetFolderName+"&hash="+thisHash+"×tamp="+timestamp; $("#settings-all-modal").attr("data-url",settingsLinkModal); $("#settings-all-modal .material-icons").attr("data-url",settingsLinkModal); // An empty container has to be added in place of the lightbox container so that the elements below don"t come up // ensions of this empty container is the same as the original container $("
").insertAfter(this); // Added variables for smoother animation var thisHeight = $("#"+thisId).height(); var colWidth = $(".dashboard-col").width(); // Setting correct height for #empty-container $("#empty-container").height(thisHeight); // To animate the container from full-screen to normal, we need dynamic keyframes var styles = ""; styles = "@keyframes outlightbox {"; styles += "0% {"; styles += "height: 80%;"; styles += "width: 80%;"; styles += "top: 10%;"; styles += "left: 10%;"; styles += "}"; styles += "50% {"; styles += "height: "+thisHeight+"px;"; styles += "top: " + bounding_box.y + "px;"; styles += "}"; styles += "100% {"; styles += "height: "+thisHeight+"px;"; /*styles += "width: "+colWidth+"px;";*/ styles += "top: " + bounding_box.y + "px;"; styles += "left: " + bounding_box.x + "px;"; styles += "}"; styles += "}"; // Add keyframe to CSS $("#lightbox-animations").get(0).sheet.insertRule(styles, 0); // Hide the window scrollbar $("body").css("overflow", "hidden"); } } // Click on the container // $(".widget-card").on("click", function() { $(".widget-card-zoom").on("click", function() { // $(document).on('click', '.widget-card-zoom', function(event) { // alert("here"); var thisId = $(this).attr("id"); var thisHash = $(this).attr("data-widget-hash"); var thisWidgetFolderName = $(this).attr("data-widget-folder-name"); if (thisId != 'widget-content-advertising') { // Remove Card Zoom (if there is one) TODO: add again if user wants zoom $(this).find(".card").removeClass("card-zoom"); // The position of the container will be set to fixed, so set the top & left properties of the container var bounding_box = $(this).get(0).getBoundingClientRect(); $(this).css({ top: bounding_box.top + "px", left: bounding_box.left + "px" }); // Set container to fixed position. Add animation $(this).addClass("in-animation"); var windowHeight = $(window).height(); var newHeight = (windowHeight-65); $(".in-animation .card").css("max-height", newHeight+"px"); // Test with a backdrop $(".overlay").css("opacity", "1"); $(".overlay").css("display", "block"); $(".overlay").css("visibility", "visible"); $(".overlay").css("z-index", "11000"); $(".overlay").css("background-color", "#f2f4f7"); $("#buttons-all").show(); // Change settings-link var settingsLink = "/settings/?widget-hash="+thisHash; $("#settings-all").attr("href",settingsLink); var timestamp = new Date().getTime(); var settingsLinkModal = "/?widget-settings="+thisWidgetFolderName+"&hash="+thisHash+"×tamp="+timestamp; $("#settings-all-modal").attr("data-url",settingsLinkModal); $("#settings-all-modal .material-icons").attr("data-url",settingsLinkModal); // An empty container has to be added in place of the lightbox container so that the elements below don"t come up // ensions of this empty container is the same as the original container $("").insertAfter(this); // Added variables for smoother animation var thisHeight = $(this).height(); var colWidth = $(".dashboard-col").width(); // Setting correct height for #empty-container $("#empty-container").height(thisHeight); // To animate the container from full-screen to normal, we need dynamic keyframes var styles = ""; styles = "@keyframes outlightbox {"; styles += "0% {"; styles += "height: 80%;"; styles += "width: 80%;"; styles += "top: 10%;"; styles += "left: 10%;"; styles += "}"; styles += "50% {"; styles += "height: "+thisHeight+"px;"; styles += "top: " + bounding_box.y + "px;"; styles += "}"; styles += "100% {"; styles += "height: "+thisHeight+"px;"; /*styles += "width: "+colWidth+"px;";*/ styles += "top: " + bounding_box.y + "px;"; styles += "left: " + bounding_box.x + "px;"; styles += "}"; styles += "}"; // Add keyframe to CSS $("#lightbox-animations").get(0).sheet.insertRule(styles, 0); // Hide the window scrollbar $("body").css("overflow", "hidden"); } }); // On animationend : from normal to full screen & full screen to normal $(".widget-card").on("animationend", function(e) { // On animation end from normal to full-screen if(e.originalEvent.animationName == "inlightbox") { $(this).find(".close").show(); } // On animation end from full-screen to normal else if(e.originalEvent.animationName == "outlightbox") { var newHeight = $(this).find(".card-inner").height(); // alert(newHeight); $(".in-animation .card").css("max-height", newHeight+"px"); // Remove fixed positioning, remove animation rules $(this).removeClass("in-animation").removeClass("out-animation"); // Remove Card Zoom (if there is one) TODO: add again if user wants zoom $(this).find(".card").addClass("card-zoom"); // Backdrop $(".overlay").css("opacity", "0"); $(".overlay").css("display", "none"); $(".overlay").css("visibility", "invisible"); // Remove the empty container that was earlier added $("#empty-container").remove(); // Delete the dynamic keyframe rule that was earlier created $("#lightbox-animations").get(0).sheet.deleteRule(0); } }); // Set widget width (smooth zoom-in animation) var colWidth = $(".dashboard-col").width(); // Enable Tooltips Everywhere $('[data-toggle="tooltip"]').tooltip() // Settings - Portfolio, Delete Asset $(document).on("click", ".delete-content", function(event) { // Need to send var getAction = "delete-widget-content"; var getWidgetId = $(this).attr("data-widget-id"); var getHash = $(this).attr("data-hash"); var getType = $(this).attr("data-type"); var getRemoveCategory = $(this).attr("data-remove-category"); var getRemoveValue = $(this).attr("data-remove-value"); var timestamp = new Date().getTime(); $.ajax({ type:"GET", dataType:"JSON", url:"/", data:"action="+getAction+"&widget-hash="+getHash+"&widget-id="+getWidgetId+"&type="+getType+"&remove-category="+getRemoveCategory+"&remove-value="+getRemoveValue+"×tamp="+timestamp, success:function(data) { var data=eval(data); message=data.message; success=data.success; $("#heading").html(success); $("#body").html(message); // Get user information var ua = data; var role = Cookies.get("user-role"); var hash = Cookies.get("user-hash"); // Update Cookies Cookies.set("user-updated-at", data); // Update Reload With Timestamp link $(".downupPopup-kapat").attr("onclick", "location.reload();"); $("#modal-close-reload").attr("onclick", "location.reload();"); $("#dark-back").attr("onclick", "location.reload();"); // Remove localStorage localStorage.removeItem("content-portfolio-new2"); localStorage.removeItem("widget-content-portfolio"); // Preload (and use localStorage for caching) var localStorageKey = "content-portfolio-new2"; var getUrl = "/content-portfolio"; preloadLocalStorage(localStorageKey, getUrl, hash, ua); } }); }); // START - Long Press on Widget // ------------------------------------------------------------------------------------------------------------------ $(document).on("mousedown touchstart", ".widget .no-scrollbars", function(event) { setTimeout(function() { $("#presstimer").val(0); }, 200); }); $(document).on("mousedown touchstart", ".no-long-tap", function(event) { setTimeout(function() { $("#presstimer").val(0); }, 200); }); $(document).on("mousedown mouseup touchstart touchend", ".widget", function(event) { // console.log(event.type); var thisId = $(this).attr("id"); var thisName = thisId.replace('widget-', ''); // var thisHash = $(this).attr("data-hash"); var thisUpdatedAt = $(this).attr("data-updated-at"); var parentWidgetId = thisId.replace('widget-', 'widget-content-'); var thisHash = $("#"+parentWidgetId).attr("data-widget-hash"); $("#debug").val(""); var thisScrollTop0 = $("#"+thisId).offset().top; //get the offset top of the element var scrollTop0 = (thisScrollTop0 - $(window).scrollTop()); var thisScrollLeft0 = $("#"+thisId).offset().left; //get the offset top of the element var scrollLeft0 = (thisScrollLeft0 - $(window).scrollLeft()); if (event.type == 'mousedown') { var t0 = new Date().getTime(); $("#presstimer").val(t0); $("#presstimer_top").val(scrollTop0); $("#presstimer_left").val(scrollLeft0); } if (event.type == 'touchstart') { var t0 = new Date().getTime(); $("#presstimer").val(t0); $("#presstimer_top").val(scrollTop0); $("#presstimer_left").val(scrollLeft0); } if (event.type == 'mouseup') { var t0 = new Date().getTime(); $("#presstimer").val(0); $("#presstimer_top").val(0); $("#presstimer_left").val(0); } if (event.type == 'touchend') { var t0 = new Date().getTime(); $("#presstimer").val(0); $("#presstimer_top").val(0); $("#presstimer_left").val(0); } if (event.type == 'mousedown' || event.type == 'touchstart') { $("#debug").val("touchstart"); setTimeout(function() { var scrolled = 'scrolled'; var gett0 = $("#presstimer").val(); var getpt0 = $("#presstimer_top").val(); var getpl0 = $("#presstimer_left").val(); getpt0 = parseInt(getpt0, 10); getpl0 = parseInt(getpl0, 10); // Set time to 0 if page has been scrolled var thisScrollTop1 = $("#"+thisId).offset().top; //get the offset top of the element var scrollTop1 = (thisScrollTop1 - $(window).scrollTop()); // Scroll Top Check if (getpt0 > 0) { // console.log(getpt0); //position of the ele w.r.t window // console.log(scrollTop1); //position of the ele w.r.t window if (getpt0 == scrollTop1) { // console.log("NOT Scrolled"); scrolled = 'not scrolled'; } else { // console.log("Scrolled Up/Down"); gett0 = 0; } } // Set time to 0 if page has been scrolled var thisScrollLeft1 = $("#"+thisId).offset().left; //get the offset top of the element var scrollLeft1 = (thisScrollLeft1 - $(window).scrollLeft()); // Scroll Left Check if (getpl0 > 0) { // console.log(getpl0); //position of the ele w.r.t window // console.log(scrollLeft1); //position of the ele w.r.t window if (getpl0 == scrollLeft1) { // console.log("NOT Scrolled"); scrolled = 'not scrolled'; } else { // console.log("Scrolled Left/Right"); gett0 = 0; } } var t1 = new Date().getTime(); // console.log("gett0: "+gett0); // console.log("t1: "+t1); if (gett0 > 0) { var diff = (t1-gett0); } else { var diff = 0; } // console.log("diff: "+diff); if (diff > 300 && scrolled == 'not scrolled') { $("#"+thisId).css("transform", "scale(0.97)"); setTimeout(function() { // Restore widget's scale $("#"+thisId).css("transform", "scale(1)"); var headline = 'Widget'; var url = '/long-tap/1.0.0/long-tap.php?widget-settings='+thisName+'&hash='+thisHash+'&ua='+thisUpdatedAt; var type = 'all'; $("#debug").val("open modal"); dashboardModal(type, headline, url); }, 100); } }, 300); return false; } }); // ------------------------------------------------------------------------------------------------------------------ // END - Long Press on Widget // Making register button to spinner on click for mobile registration carousel $("#app-register-button").on("click", function() { $(this).html(''); }); $("#login-page-login-button").on("click", function() { var thisWidth = $("#login-page-login-button").width(); $("#login-page-login-button").width(thisWidth); $("#login-page-login-button").html(''); }); function reloadWithTimestamp(timestamp) { Cookies.remove("user-updated-at"); // Remove localStorage // localStorage.removeItem("content-portfolio-new2"); localStorage.removeItem("widget-content-portfolio"); localStorage.removeItem("widget-content-portfolio-fullscreen"); var full_url = window.location.href; full_url = full_url.split('#')[0]; if (timestamp == 0) { } else { // Set Timestamp & Preload var ua = timestamp; var hash = Cookies.get("user-hash"); // Update Cookies Cookies.set("user-updated-at", ua); // Preload content-portfolio & portfolio-widget setTimeout(function() { // Use GET and save to localStorage $.get("/content-portfolio?hash="+hash+"&ua="+ua, function(data) { // localStorage.setItem("content-portfolio-new2", data); }); $.get("/widget_portfolio_2.0.1/?hash="+hash+"&ua="+ua+"×tamp="+timestamp, function(data) { // localStorage.setItem("widget-content-portfolio-fullscreen", data); }); }, 100); } if (full_url.includes("?")) { if (full_url.includes("timestamp")) { var new_url = full_url; } else { var new_url = full_url + "×tamp=" + timestamp; } } else { var new_url = full_url + "?timestamp=" + timestamp; } // Test var new_url = full_url; $('#dashboard-modal .modal-dialog').fadeOut(); window.location.replace(new_url); } $('.menu, .overlay').click(function () { $('.menu').toggleClass('clicked'); $('#nav-menu-left').toggleClass('show'); }); $(".btn-cta").click(function() { // Get width var ctaWidth = $(this).width(); // Set width $(this).width(ctaWidth); // $(this).html("