Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Javascript minor fixes to enable backward compatibility to iPad2 #208

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions gallery.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@
<script type="text/javascript" src="resources/lang/<?php echo $config['language']; ?>.js"></script>
<script>
$(function() {
let reloadElement = $('<a>');
var reloadElement = $('<a>');
reloadElement.append('<i class="fa fa-refresh"></i>');
reloadElement.attr('href', '#');
reloadElement.on('click', () => photoBooth.reloadPage());
reloadElement.on('click', function() { photoBooth.reloadPage(); } );
reloadElement.appendTo('.gallery__header');

$('.gallery__close').hide();
Expand Down
4 changes: 2 additions & 2 deletions resources/js/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ $(function() {
$.ajax({
url: '../api/checkVersion.php',
method: 'GET',
success: (data) => {
let message = 'Error';
success: function(data) {
var message = 'Error';
$('#checkVersion').empty();
console.log('data', data)
if (!data.updateAvailable) {
Expand Down
2 changes: 1 addition & 1 deletion resources/js/adminshortcut.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* exported adminsettings */
let admincount = 0;
var admincount = 0;

function countreset() {
admincount = 0;
Expand Down
26 changes: 13 additions & 13 deletions resources/js/chromakeying.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/* globals MarvinColorModelConverter AlphaBoundary MarvinImage */
/* exported setBackgroundImage */
let mainImage;
let mainImageWidth;
let mainImageHeight;
let backgroundImage;
var mainImage;
var mainImageWidth;
var mainImageHeight;
var backgroundImage;

function greenToTransparency(imageIn, imageOut) {
for (let y = 0; y < imageIn.getHeight(); y++) {
for (let x = 0; x < imageIn.getWidth(); x++) {
for (var y = 0; y < imageIn.getHeight(); y++) {
for (var x = 0; x < imageIn.getWidth(); x++) {

const color = imageIn.getIntColor(x, y);
const hsv = MarvinColorModelConverter.rgbToHsv([color]);
Expand All @@ -22,8 +22,8 @@ function greenToTransparency(imageIn, imageOut) {
}

function reduceGreen(image) {
for (let y = 0; y < image.getHeight(); y++) {
for (let x = 0; x < image.getWidth(); x++) {
for (var y = 0; y < image.getHeight(); y++) {
for (var x = 0; x < image.getWidth(); x++) {
const r = image.getIntComponent0(x, y);
const g = image.getIntComponent1(x, y);
const b = image.getIntComponent2(x, y);
Expand All @@ -43,8 +43,8 @@ function reduceGreen(image) {

function alphaBoundary(imageOut, radius) {
const ab = new AlphaBoundary();
for (let y = 0; y < imageOut.getHeight(); y++) {
for (let x = 0; x < imageOut.getWidth(); x++) {
for (var y = 0; y < imageOut.getHeight(); y++) {
for (var x = 0; x < imageOut.getWidth(); x++) {
ab.alphaRadius(imageOut, x, y, radius);
}
}
Expand Down Expand Up @@ -164,12 +164,12 @@ function printImageHandler(ev) {
$('#print_mesg').addClass('modal--show');

setTimeout(function () {
saveImage((data) => {
saveImage(function(data) {
if (!data.success) {
return;
}

printImage(data.filename, () => {
printImage(data.filename, function() {
setTimeout(function () {
$('#print_mesg').removeClass('modal--show');

Expand All @@ -186,7 +186,7 @@ function saveImageHandler(ev) {
$('#save_mesg').addClass('modal--show');

setTimeout(function () {
saveImage(() => {
saveImage(function() {
setTimeout(function () {
$('#save_mesg').removeClass('modal--show');
}, 2000);
Expand Down
40 changes: 20 additions & 20 deletions resources/js/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const photoBooth = (function () {
}
};

let timeOut,
var timeOut,
nextCollageNumber = 0,
currentCollageFile = '',
imgFilter = config.default_imagefilter;
Expand Down Expand Up @@ -137,7 +137,7 @@ const photoBooth = (function () {
}

loader.addClass('open');
public.startCountdown(nextCollageNumber ? config.collage_cntdwn_time : config.cntdwn_time, $('#counter'), () => {
public.startCountdown(nextCollageNumber ? config.collage_cntdwn_time : config.cntdwn_time, $('#counter'), function() {
public.cheese(photoStyle);
});
}
Expand All @@ -156,7 +156,7 @@ const photoBooth = (function () {
$('.loading').text(L10N.cheeseCollage);
}

setTimeout(() => {
setTimeout(function() {
public.takePic(photoStyle);
}, config.cheese_time);
}
Expand Down Expand Up @@ -195,11 +195,11 @@ const photoBooth = (function () {
$('<p>').text(`${result.current + 1} / ${result.limit}`).appendTo('.loading');

if (config.continuous_collage) {
setTimeout(() => {
setTimeout(function() {
public.thrill('collage');
}, 1000);
} else {
$('<a class="btn" href="#">' + L10N.nextPhoto + '</a>').appendTo('.loading').click((ev) => {
$('<a class="btn" href="#">' + L10N.nextPhoto + '</a>').appendTo('.loading').click(function(ev) {
ev.preventDefault();

public.thrill('collage');
Expand Down Expand Up @@ -239,7 +239,7 @@ const photoBooth = (function () {

if (photoStyle === 'photo') {
const preloadImage = new Image();
preloadImage.onload = () => {
preloadImage.onload = function() {
$('#loader').css('background-image', `url(${tempImageUrl})`);
$('#loader').addClass('showBackgroundImage');
}
Expand All @@ -254,7 +254,7 @@ const photoBooth = (function () {
filter: imgFilter,
isCollage: photoStyle === 'collage',
},
success: (data) => {
success: function(data) {
console.log('picture processed', data);

if (data.error) {
Expand All @@ -263,7 +263,7 @@ const photoBooth = (function () {
public.renderPic(data.file);
}
},
error: (jqXHR, textStatus) => {
error: function(jqXHR, textStatus) {
console.log('An error occurred', textStatus);

public.errorPic({
Expand Down Expand Up @@ -291,15 +291,15 @@ const photoBooth = (function () {
e.preventDefault();
e.stopPropagation();

public.printImage(filename, () => {
public.printImage(filename, function() {
public.reloadPage();
});
});

resultPage.find('.deletebtn').off('click').on('click', (ev) => {
resultPage.find('.deletebtn').off('click').on('click', function(ev) {
ev.preventDefault();

public.deleteImage(filename, (data) => {
public.deleteImage(filename, function(data) {
if (data.success) {
public.reloadPage();
} else {
Expand All @@ -314,7 +314,7 @@ const photoBooth = (function () {
const imageUrl = config.folders.images + '/' + filename;

const preloadImage = new Image();
preloadImage.onload = () => {
preloadImage.onload = function() {
resultPage.css({
'background-image': `url(${imageUrl})`,
});
Expand All @@ -340,10 +340,10 @@ const photoBooth = (function () {
public.addImage = function (imageName) {
const thumbImg = new Image();
const bigImg = new Image();
let thumbSize = '';
let bigSize = '';
var thumbSize = '';
var bigSize = '';

let imgtoLoad = 2;
var imgtoLoad = 2;

thumbImg.onload = function () {
thumbSize = this.width + 'x' + this.height;
Expand Down Expand Up @@ -384,7 +384,7 @@ const photoBooth = (function () {

gallery.addClass('gallery--open');

setTimeout(() => gallery.find('.gallery__inner').show(), 300);
setTimeout(function() { gallery.find('.gallery__inner').show();}, 300);
}

public.resetMailForm = function () {
Expand All @@ -394,8 +394,8 @@ const photoBooth = (function () {

// Countdown Function
public.startCountdown = function (start, element, cb) {
let count = 0;
let current = start;
var count = 0;
var current = start;

function timerFunction() {
element.text(current);
Expand All @@ -404,7 +404,7 @@ const photoBooth = (function () {
element.removeClass('tick');

if (count < start) {
window.setTimeout(() => element.addClass('tick'), 50);
window.setTimeout(function() { element.addClass('tick'); }, 50);
window.setTimeout(timerFunction, 1000);
} else {
cb();
Expand Down Expand Up @@ -440,7 +440,7 @@ const photoBooth = (function () {
data: {
file: imageName,
},
success: (data) => {
success: function(data) {
cb(data);
}
});
Expand Down
11 changes: 6 additions & 5 deletions resources/js/photoinit.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/* global photoBooth */
function initPhotoSwipeFromDOM (gallerySelector) {

let gallery;
var gallery;

const parseThumbnailElements = function (container) {
return $(container).find('>a').map(function () {
Expand Down Expand Up @@ -67,20 +67,21 @@ function initPhotoSwipeFromDOM (gallerySelector) {
shareEl: false,
zoomEl: false,
fullscreenEl: false,
tapToToggleControls: false
andi34 marked this conversation as resolved.
Show resolved Hide resolved
};

// Pass data to PhotoSwipe and initialize it
gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, options);

// see: http://photoswipe.com/documentation/responsive-images.html
let realViewportWidth,
var realViewportWidth,
useLargeImages = false,
firstResize = true,
imageSrcWillChange;

gallery.listen('beforeResize', function () {

let dpiRatio = window.devicePixelRatio ? window.devicePixelRatio : 1;
var dpiRatio = window.devicePixelRatio ? window.devicePixelRatio : 1;
dpiRatio = Math.min(dpiRatio, 2.5);
realViewportWidth = gallery.viewportSize.x * dpiRatio;

Expand Down Expand Up @@ -154,7 +155,7 @@ function initPhotoSwipeFromDOM (gallerySelector) {
pswpQR.removeClass('qr-active').fadeOut('fast');
} else {
pswpQR.empty();
let img = gallery.currItem.src;
var img = gallery.currItem.src;
img = img.split('/').pop();

$('<img>').attr('src', 'api/qrcode.php?filename=' + img).appendTo(pswpQR);
Expand All @@ -170,7 +171,7 @@ function initPhotoSwipeFromDOM (gallerySelector) {

const img = gallery.currItem.src.split('/').pop();

photoBooth.printImage(img, () => {
photoBooth.printImage(img, function() {
gallery.close();
});
});
Expand Down