Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/gallery.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Paroz <github@oparoz.com>2015-03-15 17:03:23 +0300
committerOlivier Paroz <github@oparoz.com>2015-03-15 17:03:23 +0300
commit0dd0bd2af15828f26abfb1ffb01fd67a70f5785c (patch)
tree4859ff5d74199ba230302f80bfcfb4792ab95d1f
parentd5c3a6d9fc67710d8e6fcbdcd0345b1db54bd2d0 (diff)
Various style fixes
-rw-r--r--.scrutinizer.yml28
-rw-r--r--controller/servicecontroller.php2
-rw-r--r--js/album.js24
-rw-r--r--js/eventsource.js5
-rw-r--r--js/gallery.js3
-rw-r--r--js/gallerybutton.js4
-rw-r--r--js/slideshow.js120
7 files changed, 104 insertions, 82 deletions
diff --git a/.scrutinizer.yml b/.scrutinizer.yml
index 19e83c8d..cfe34dfb 100644
--- a/.scrutinizer.yml
+++ b/.scrutinizer.yml
@@ -82,6 +82,34 @@ checks:
avoid_space_indentation: true
overriding_private_members: true
no_unnecessary_function_call_in_for_loop: true
+ javascript:
+ wrap_iife: true
+ no_process_exit: true
+ no_process_env: true
+ no_extra_semi: true
+ no_extra_bind: true
+ no_eval: true
+ no_else_return: true
+ dot_notation: true
+ camelcase: true
+ wrap_regex: true
+ valid_typeof: true
+ no_wrap_func: true
+ no_use_before_define: true
+ no_unreachable: true
+ no_undefined: true
+ no_trailing_spaces: true
+ no_reserved_keys: true
+ no_redeclare: true
+ no_obj_calls: true
+ no_loop_func: true
+ no_lonely_if: true
+ no_lone_blocks: true
+ no_inner_declarations: true
+ no_floating_decimal: true
+ no_extra_boolean_cast: true
+ no_empty: true
+ no_dupe_keys: true
coding_style:
php:
diff --git a/controller/servicecontroller.php b/controller/servicecontroller.php
index 3eaa6dca..302d7bdd 100644
--- a/controller/servicecontroller.php
+++ b/controller/servicecontroller.php
@@ -148,7 +148,7 @@ class ServiceController extends Controller {
* For private galleries, it returns all images, with the full path from the root folder
* For public galleries, the path starts from the folder the link gives access to
*
- * @return array|Http\JSONResponse
+ * @return array<string,string|int>|Http\JSONResponse
*/
public function getImages() {
try {
diff --git a/js/album.js b/js/album.js
index fde7dae5..d5fba873 100644
--- a/js/album.js
+++ b/js/album.js
@@ -53,9 +53,8 @@ Album.prototype = {
_getThumbnail: function () {
if (this.images.length) {
return this.images[0].getThumbnail(1);
- } else {
- return this.subAlbums[0]._getThumbnail();
}
+ return this.subAlbums[0]._getThumbnail();
},
/**
* Retrieves a thumbnail and adds it to the album representation
@@ -185,14 +184,12 @@ Album.prototype = {
if (album.images.length > 1) {
album._getFourImages(album.images, targetHeight, a);
+ } else if (album.images.length === 0 && album.subAlbums[0].images.length > 1) {
+ album._getFourImages(album.subAlbums[0].images, targetHeight, a);
} else {
- if (album.images.length === 0 && album.subAlbums[0].images.length > 1) {
- album._getFourImages(album.subAlbums[0].images, targetHeight, a);
- } else {
- a.append(img);
- img.height = (targetHeight - 2);
- img.width = (targetHeight * ratio) - 2;
- }
+ a.append(img);
+ img.height = (targetHeight - 2);
+ img.width = (targetHeight * ratio) - 2;
}
return a;
@@ -233,9 +230,8 @@ Album.prototype = {
album.viewedItems++;
if (more && album.viewedItems < images.length) {
return addRowElements(album, row, images);
- } else {
- return row;
}
+ return row;
});
};
var items = this.subAlbums.concat(this.images);
@@ -308,9 +304,8 @@ Row.prototype = {
row.append(itemDom);
if (i < items.length) {
return addImageToDom(row, items, i);
- } else {
- return row;
}
+ return row;
});
};
return addImageToDom(row, this.items, 0);
@@ -352,9 +347,8 @@ GalleryImage.prototype = {
return this.getThumbnail().then(function (img) {
if (img) {
return img.originalWidth;
- } else {
- return 0;
}
+ return 0;
});
},
diff --git a/js/eventsource.js b/js/eventsource.js
index d23e6965..ec8ba25d 100644
--- a/js/eventsource.js
+++ b/js/eventsource.js
@@ -43,8 +43,9 @@ Gallery.EventSource = function (src, data) {
var options = {};
if (EventSource.isPolyfill !== undefined) {
// 10 thumbnails * 200k per thumbnail
- options['bufferSizeLimit'] = 10 * 200 * 1024;
- options['silentTimeout'] = 1000;
+ options.bufferSizeLimit = 10 * 200 * 1024;
+ options.silentTimeout = 1000;
+ //options.loggingEnabled = true;
}
this.source = new EventSource(src + joinChar + dataStr, options);
this.source.onmessage = function (e) {
diff --git a/js/gallery.js b/js/gallery.js
index be60171d..af91f4c2 100644
--- a/js/gallery.js
+++ b/js/gallery.js
@@ -253,9 +253,8 @@ Gallery.view.loadVisibleRows = function (album, path) {
if (album.viewedItems < album.subAlbums.length + album.images.length &&
Gallery.view.element.height() < targetHeight) {
return showRows(album);
- } else {
- Gallery.view.loadVisibleRows.loading = null;
}
+ Gallery.view.loadVisibleRows.loading = null;
}, function () {
Gallery.view.loadVisibleRows.loading = null;
});
diff --git a/js/gallerybutton.js b/js/gallerybutton.js
index cf1e6f58..8d69a572 100644
--- a/js/gallerybutton.js
+++ b/js/gallerybutton.js
@@ -18,7 +18,7 @@ GalleryButton.onFileListUpdated = function () {
files = fileList.files;
GalleryButton.buildUrl(fileList.getCurrentDirectory().replace(/^\//, ''));
-
+
for (var i = 0; i < files.length; i++) {
var file = files[i];
if (file.isPreviewAvailable) {
@@ -48,7 +48,7 @@ GalleryButton.hijackShare = function () {
OC.Share.showLink = function () {
var r = target.apply(this, arguments);
if ($('#dropdown.drop.shareDropDown').data('item-type') === "folder") {
-
+
if (!$('#linkSwitchButton').length) {
var linkSwitchButton = '<a class="button" id="linkSwitchButton">' +
t(GalleryButton.appName, 'Show Gallery link') + '</a>';
diff --git a/js/slideshow.js b/js/slideshow.js
index 539cef99..2cd68225 100644
--- a/js/slideshow.js
+++ b/js/slideshow.js
@@ -38,16 +38,16 @@ SlideShow.prototype = {
this.active = true;
this.hideImage();
this.bigShotSetup();
-
+
// hide arrows and play/pause when only one pic
this.container.find('.next, .previous').toggle(this.images.length > 1);
if (this.images.length === 1) {
this.container.find('.play, .pause').hide();
}
-
+
// Hide the toggle background button until we have something to show
this.container.find('.changeBackground').hide();
-
+
var makeCallBack = function (handler) {
return function (evt) {
if (!this.active) {
@@ -57,21 +57,21 @@ SlideShow.prototype = {
handler.call(this);
}.bind(this);
}.bind(this);
-
+
this.buttonSetup(makeCallBack);
this.keyCodeSetup(makeCallBack);
-
+
$(window).resize(function () {
this.zoomDecider();
}.bind(this));
-
+
if (play) {
this.play();
} else {
this.pause();
}
},
-
+
bigShotSetup: function () {
// Detect fullscreen capability (mobile)
var e = this.container.get(0);
@@ -79,7 +79,7 @@ SlideShow.prototype = {
e.mozRequestFullScreen !== undefined ||
e.webkitRequestFullscreen !== undefined ||
e.msRequestFullscreen !== undefined;
-
+
// makes UI controls work in mobile version. Pinch only works on iOS
var browser = new bigshot.Browser();
this.container.children('input').each(function (i, e) {
@@ -88,7 +88,7 @@ SlideShow.prototype = {
browser.registerListener(e, 'touchend', browser.stopEventBubblingHandler(), false);
});
},
-
+
/**
*
* @param makeCallBack
@@ -103,7 +103,7 @@ SlideShow.prototype = {
this.container.children('.changeBackground').click(makeCallBack(this.toggleBackground));
//this.container.click(makeCallBack(this.next));
},
-
+
/**
*
* @param makeCallBack
@@ -127,29 +127,31 @@ SlideShow.prototype = {
}
}.bind(this));
},
-
+
/**
*
* @param evt
- *
+ *
* @returns {boolean}
*/
zoomOutKey: function (evt) {
// zero, o or down key
- return (evt.keyCode === 48 || evt.keyCode === 96 || evt.keyCode === 79 || evt.keyCode === 40);
+ return (evt.keyCode === 48 || evt.keyCode === 96 || evt.keyCode === 79 ||
+ evt.keyCode === 40);
},
-
+
/**
*
* @param evt
- *
+ *
* @returns {boolean}
*/
zoomInKey: function (evt) {
// 9, i or up key
- return (evt.keyCode === 57 || evt.keyCode === 105 || evt.keyCode === 73 || evt.keyCode === 38);
+ return (evt.keyCode === 57 || evt.keyCode === 105 || evt.keyCode === 73 ||
+ evt.keyCode === 38);
},
-
+
zoomDecider: function () {
if (this.fullScreen === null && this.currentImage.mimeType !== 'image/svg+xml') {
this.zoomToOriginal();
@@ -157,13 +159,13 @@ SlideShow.prototype = {
this.zoomToFit();
}
},
-
+
zoomToFit: function () {
if (this.zoomable !== null) {
this.zoomable.flyZoomToFit();
}
},
-
+
zoomToOriginal: function () {
if (this.zoomable === null) {
return;
@@ -174,7 +176,7 @@ SlideShow.prototype = {
this.zoomable.flyTo(0, 0, 0, true);
}
},
-
+
resetZoom: function () {
if (this.zoomable === null) {
return;
@@ -185,7 +187,7 @@ SlideShow.prototype = {
this.zoomable.setZoom(0, true);
}
},
-
+
fullScreenStart: function () {
if (!this.canFullScreen) {
return;
@@ -196,7 +198,7 @@ SlideShow.prototype = {
this.fullScreenExit();
}.bind(this));
},
-
+
fullScreenExit: function () {
if (this.fullScreen === null) {
return;
@@ -204,9 +206,9 @@ SlideShow.prototype = {
this.fullScreen.close();
this.fullScreen = null;
this.zoomDecider();
-
+
},
-
+
fullScreenToggle: function () {
if (this.zoomable === null) {
return;
@@ -217,11 +219,11 @@ SlideShow.prototype = {
this.fullScreenStart();
}
},
-
+
/**
*
* @param index
- *
+ *
* @returns {*}
*/
show: function (index) {
@@ -233,40 +235,40 @@ SlideShow.prototype = {
return this.loadImage(this.images[index]).then(function (image) {
this.container.css('background-position', '-10000px 0');
this.container.find('.changeBackground').show();
-
+
// check if we moved along while we were loading
if (this.current === index) {
this.errorLoadingImage = false;
this.currentImage = image;
this.currentImage.mimeType = this.images[index].mimeType;
this.container.append(image);
-
+
image.setAttribute('alt', this.images[index].name);
$(image).css('position', 'absolute');
$(image).css('background-color', '#fff');
var $border = 30 / window.devicePixelRatio;
$(image).css('outline', $border + 'px solid #fff');
-
+
this.startBigshot(image);
-
+
this.setUrl(this.images[index].path);
if (this.playing) {
this.setTimeout();
}
}
}.bind(this), function () {
- // Don't do anything if the user has moved along while we were loading as it would mess up
- // the index
+ // Don't do anything if the user has moved along while we were loading as it would mess
+ // up the index
if (this.current === index) {
this.errorLoadingImage = true;
this.showErrorNotification();
this.setUrl(this.images[index].path);
this.images.splice(index, 1);
}
-
+
}.bind(this));
},
-
+
/**
*
* @param image
@@ -294,13 +296,13 @@ SlideShow.prototype = {
if (this.fullScreen === null && this.currentImage.mimeType !== 'image/svg+xml') {
this.resetZoom();
}
-
+
// prevent zoom-on-doubleClick
this.zoomable.addEventListener('dblclick', function (ie) {
ie.preventDefault();
}.bind(this));
},
-
+
/**
*
* @param path
@@ -310,21 +312,21 @@ SlideShow.prototype = {
history.replaceState('', '', '#' + encodeURI(path));
}
},
-
+
/**
*
* @param preview
- *
+ *
* @returns {*}
*/
loadImage: function (preview) {
var url = preview.url;
var mimeType = preview.mimeType;
-
+
if (!this.imageCache[url]) {
this.imageCache[url] = new jQuery.Deferred();
var image = new Image();
-
+
image.onload = function () {
if (this.imageCache[url]) {
this.imageCache[url].resolve(image);
@@ -343,11 +345,11 @@ SlideShow.prototype = {
}
return this.imageCache[url];
},
-
+
/**
*
* @param source
- *
+ *
* @returns {*}
*/
getSVG: function (source) {
@@ -358,14 +360,12 @@ SlideShow.prototype = {
if (xmlHttp.responseXML) {
// Has to be base64 encoded for Firefox
return "data:image/svg+xml;base64," + btoa(xmlHttp.responseText);
- } else {
- return source;
}
- } else {
- return null;
+ return source;
}
+ return null;
},
-
+
setTimeout: function () {
this.clearTimeout();
this.playTimeout = setTimeout(this.next.bind(this), this.interval);
@@ -373,7 +373,7 @@ SlideShow.prototype = {
this.progressBar.css('height', '6px');
this.progressBar.animate({'height': '26px'}, this.interval, 'linear');
},
-
+
clearTimeout: function () {
if (this.playTimeout) {
clearTimeout(this.playTimeout);
@@ -382,21 +382,21 @@ SlideShow.prototype = {
this.progressBar.css('height', '6px');
this.playTimeout = 0;
},
-
+
play: function () {
this.playing = true;
this.container.find('.pause').show();
this.container.find('.play').hide();
this.setTimeout();
},
-
+
pause: function () {
this.playing = false;
this.container.find('.pause').hide();
this.container.find('.play').show();
this.clearTimeout();
},
-
+
next: function () {
if (this.zoomable !== null) {
this.zoomable.stopFlying();
@@ -413,7 +413,7 @@ SlideShow.prototype = {
this.loadImage(this.images[next]);
}.bind(this));
},
-
+
previous: function () {
if (this.zoomable !== null) {
this.zoomable.stopFlying();
@@ -427,7 +427,7 @@ SlideShow.prototype = {
this.loadImage(this.images[previous]);
}.bind(this));
},
-
+
stop: function () {
if (this.fullScreen !== null) {
this.fullScreenExit();
@@ -443,11 +443,11 @@ SlideShow.prototype = {
this.onStop();
}
},
-
+
hideImage: function () {
this.container.children('img').remove();
},
-
+
togglePlay: function () {
if (this.playing) {
this.pause();
@@ -473,7 +473,7 @@ SlideShow.prototype = {
var rgb = container.css('background-color').match(/\d+/g);
var hex = "#" + toHex(rgb[0]) + toHex(rgb[1]) + toHex(rgb[2]);
var $border = 30 / window.devicePixelRatio;
-
+
// Grey #363636
if (hex === "#000000") {
container.css('background-color', '#FFF');
@@ -499,7 +499,7 @@ SlideShow.prototype = {
* @param endPoint
* @param path
* @param params
- *
+ *
* @returns {string}
*/
SlideShow.buildUrl = function (endPoint, params) {
@@ -605,14 +605,14 @@ $(document).ready(function () {
if (!OC.Util.hasSVGSupport()) {
OC.Util.replaceSVG(this.$el);
}
-
+
if (OCA.Files) {
// Don't show the download button on the "Files" slideshow
$('#slideshow').find('.downloadImage').hide();
}
}).fail(function () {
- OC.Notification.show(t('core', 'Error loading slideshow template'));
- });
+ OC.Notification.show(t('core', 'Error loading slideshow template'));
+ });
if (OCA.Files && OCA.Files.fileActions) {
// This is still required in OC8