From 2c76e035d794d6ceac49e277c801ab2a682cbc08 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Wed, 21 Feb 2018 19:19:20 +0100 Subject: [PATCH] Fancybox generalization --- Site/Pages/v5/Financial/FileExpenseClaim.aspx | 84 +------------------ Site/Scripts/Swarmops-v5.js | 65 ++++++++++++++ Site/Style/style-v5.css | 40 +++++++++ 3 files changed, 106 insertions(+), 83 deletions(-) diff --git a/Site/Pages/v5/Financial/FileExpenseClaim.aspx b/Site/Pages/v5/Financial/FileExpenseClaim.aspx index 0e3e3c80..947d395a 100644 --- a/Site/Pages/v5/Financial/FileExpenseClaim.aspx +++ b/Site/Pages/v5/Financial/FileExpenseClaim.aspx @@ -8,37 +8,7 @@ @@ -178,59 +148,7 @@ $('#divDocumentsHidden').html(result.Documents); - $("a.FancyBox_Gallery").fancybox({ - toolbar: false, - smallBtn: true, - arrows: false, - infobar: false, - title: this.title, - - helpers: { - title: { - position: 'bottom', - type: 'float' - } - }, - - afterShow: function(instance, current) { - $('.zoomContainer').remove(); - $('.fancybox-image').elevateZoom({ - zoomType: "lens", - cursor: "crosshair", - zoomWindowFadeIn: 200, - zoomWindowFadeOut: 200, - lensShape: "round", - lensSize: 200 - }); - - if (instance.group.length > 1) { - if (instance.currIndex > 0) { - $('a.fancybox-arrow-previous').show(); - } else { - $('a.fancybox-arrow-previous').hide(); - } - - if (instance.currIndex < instance.group.length - 1) { - $('a.fancybox-arrow-next').show(); - } else { - $('a.fancybox-arrow-next').hide(); - } - } - }, - - afterLoad: function(instance, current) { - - /* TODO: MAKE A RIGHT-TO-LEFT VERSION OF THIS */ - - if ( instance.group.length > 1 && current.$content ) { - current.$content.append('→←'); - } - }, - - afterClose: function() { - $('.zoomContainer').remove(); - } - }); + SwarmopsJS.fancyBoxInit('.FancyBox_Gallery'); $(".LocalIconViewDoc").click(function () { $("a.FancyBox_Gallery[data-fancybox='" + $(this).attr("firstDocId") + "']").first().click(); diff --git a/Site/Scripts/Swarmops-v5.js b/Site/Scripts/Swarmops-v5.js index e098f04b..6fbe6456 100644 --- a/Site/Scripts/Swarmops-v5.js +++ b/Site/Scripts/Swarmops-v5.js @@ -166,6 +166,71 @@ function _master_watchHeartbeat() { } +function fancyBoxInit(selector) { + + if (typeof selector == 'undefined') { + selector = '.FancyBox_Gallery'; + } + + $(selector).fancybox({ + toolbar: false, + smallBtn: true, + arrows: false, + infobar: false, + title: $(this).title, + + helpers: { + title: { + position: 'bottom', + type: 'float' + } + }, + + beforeShow: function (instance, current) { + $('.zoomContainer').remove(); + if (instance.group.length > 1) { + if (instance.currIndex > 0) { + $('a.fancybox-arrow-previous').show(); + } else { + $('a.fancybox-arrow-previous').hide(); + } + + if (instance.currIndex < instance.group.length - 1) { + $('a.fancybox-arrow-next').show(); + } else { + $('a.fancybox-arrow-next').hide(); + } + } + }, + + afterShow: function (instance, current) { + $('.fancybox-image').elevateZoom({ + zoomType: "lens", + cursor: "crosshair", + zoomWindowFadeIn: 200, + zoomWindowFadeOut: 200, + lensShape: "round", + lensSize: 200 + }); + }, + + afterLoad: function (instance, current) { + + /* TODO: MAKE A RIGHT-TO-LEFT VERSION OF THIS */ + + if (instance.group.length > 1 && current.$content) { + current.$content.append('→←'); + } + }, + + afterClose: function () { + $('.zoomContainer').remove(); + } + }); + +} + + function getMasterSocketAddress() { if (location.host.indexOf ("localhost") >= 0) { // Assume dev environment, go for sandbox socket return 'ws://sandbox.swarmops.com/ws/Front'; diff --git a/Site/Style/style-v5.css b/Site/Style/style-v5.css index 4380c014..48908648 100644 --- a/Site/Style/style-v5.css +++ b/Site/Style/style-v5.css @@ -1364,6 +1364,46 @@ nav.alertify-buttons { } +/* FANCYBOX */ + +.fancybox-arrow-previous, +.fancybox-arrow-next { + position: absolute; + width: 44px; + height: 44px; + background: #000; + text-align: center; + line-height: 40px; + color: #fff; + text-decoration: none; + border-radius: 50%; + font-size: 36px; + top: 50%; + margin-top: -22px; + -webkit-text-stroke: 1px white; + text-stroke: 1px white; +} + +.fancybox-arrow-previous:hover, +.fancybox-arrow-next:hover { + text-decoration: none; + background: #222; + color: #FFF; +} + +.fancybox-arrow-previous { + left: -60px; +} + +.fancybox-arrow-next { + right: -60px; +} + +.zoomContainer { + overflow: hidden; +} + + /* VARIOUS ADDITIONS - SORT LATER */ span.spanGrayedOut {