Fancybox generalization

This commit is contained in:
Rick Falkvinge
2018-02-21 19:19:20 +01:00
parent 18dd453ca4
commit 2c76e035d7
3 changed files with 106 additions and 83 deletions
+1 -83
View File
@@ -8,37 +8,7 @@
<style type="text/css">
.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: #444;
}
.fancybox-arrow-previous {
left: -60px;
}
.fancybox-arrow-next {
right: -60px;
}
</style>
@@ -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('<a data-fancybox-next class="fancybox-arrow-next button-next" href="javascript:;">→</a><a data-fancybox-prev class="fancybox-arrow-previous button-previous" href="javascript:;">←</a>');
}
},
afterClose: function() {
$('.zoomContainer').remove();
}
});
SwarmopsJS.fancyBoxInit('.FancyBox_Gallery');
$(".LocalIconViewDoc").click(function () {
$("a.FancyBox_Gallery[data-fancybox='" + $(this).attr("firstDocId") + "']").first().click();
+65
View File
@@ -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('<a data-fancybox-next class="fancybox-arrow-next button-next" href="javascript:;">→</a><a data-fancybox-prev class="fancybox-arrow-previous button-previous" href="javascript:;">←</a>');
}
},
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';
+40
View File
@@ -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 {