Skip to content

TagSpaces is an offline, open source, document manager with tagging support

jshinting, code styling, updating copyright year

uggrockd8ea15e5ba51
diff --git a/data/about.html b/data/about.html
index 11c1437a9..501f934c9 100644
--- a/data/about.html
+++ b/data/about.html
@@ -1,7 +1,7 @@
<html>
<head>
<!--
- Copyright (c) 2012-2014 The TagSpaces Authors. All rights reserved.
+ Copyright (c) 2012-2015 The TagSpaces Authors. All rights reserved.
Use of this source code is governed by a AGPL3 license that can be
found in the LICENSE file.
-->
@@ -76,13 +76,13 @@ Copyright (c) 2012-2015 The TagSpaces Authors. All rights reserved. Use of this
<li><a href="https://github.com/brandonaaron/jquery-mousewheel" target="_system">jQuery Mousewheel</a> used in viewerImage extension - <a href="ext/viewerImage/jquery.mousewheel/LICENSE.txt">License[MIT]</a></li>
<li><a href="http://fontawesome.io/" target="_system">Font Awesome</a> used in the core - <a href="http://fontawesome.io/license/">License[SIL OFL 1.1]</a></li>
<li><a href="http://font.ubuntu.com/" target="_system">Ubuntu Font Family</a> used in the core - <a href="assets/ubuntu-font-licence-1.0.txt">Ubuntu Font License</a></li>
- <li><a href="https://github.com/sara-nl/js-webdav-client" target="_system">js-webdav-client</a> used in the WebDav edition - <a href="https://raw.githubusercontent.com/sara-nl/js-webdav-client/master/COPYING.LESSER.txt">LGPL</a></li>
+ <li><a href="https://github.com/sara-nl/js-webdav-client" target="_system">js-webdav-client</a> used in the WebDav edition - <a href="web/webdavlib/lgpl.txt">LGPL</a></li>
<li><a href="https://github.com/eligrey/FileSaver.js/" target="_system">filesaver.js</a> used for the CSV export - <a href="libs/filesaver.js/LICENSE%5Bmit%5D.md">License[MIT]</a></li>
<li><a href="https://github.com/josdejong/jsoneditor/" target="_system">jsoneditor</a> used in the editorJSON extension - <a href="ext/editorJSON/jsoneditor/LICENSE%5Bapache2%5D.txt">License[MIT]</a></li>
<li><a href="https://github.com/rhiokim/markdown-css" target="_system">markdown-css</a> used in the viewerMD extension - <a href="https://github.com/rhiokim/markdown-css#license" target="_system">License[MIT]</a></li>
<li><a href="https://github.com/cure53/DOMPurify" target="_system">DOM Purify</a> used in the chrome extension - <a href="libs/dompurify/LICENSE[mozilla].txt" target="_system">License[Mozilla]</a></li>
<li><a href="https://github.com/jseidelin/exif-js" target="_system">exif.js</a> used in the viewerImage - <a href="ext/viewerImage/exif-js/LICENSE%5Bmit%5D.txt" target="_system">License[MIT]</a></li>
- <li><a href="https://github.com/andris9/mailparser" target="_system">mailparser</a> used in the viewerMHTML - <a href="ext/viewerMHTML/LICENSE%5BMIT%5D.txt" target="_system">License[MIT]</a></li>
+ <li><a href="https://github.com/andris9/mailparser" target="_system">mailparser</a> used in the viewerMHTML - <a href="ext/viewerMHTML/mailparser/LICENSE%5BMIT%5D.txt" target="_system">License[MIT]</a></li>
</ul>
</body>
</html>
diff --git a/data/chrome/chrome.api.js b/data/chrome/chrome.api.js
index 40828c335..94ba27b0d 100644
--- a/data/chrome/chrome.api.js
+++ b/data/chrome/chrome.api.js
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2014 The TagSpaces Authors. All rights reserved.
+/* Copyright (c) 2012-2015 The TagSpaces Authors. All rights reserved.
* Use of this source code is governed by a AGPL3 license that
* can be found in the LICENSE file. */
/* global define, nativeIO, isWin */
diff --git a/data/chromelight/chrome.api.js b/data/chromelight/chrome.api.js
index 4954b46b3..25fc34382 100644
--- a/data/chromelight/chrome.api.js
+++ b/data/chromelight/chrome.api.js
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2014 The TagSpaces Authors. All rights reserved.
+/* Copyright (c) 2012-2015 The TagSpaces Authors. All rights reserved.
* Use of this source code is governed by a AGPL3 license that
* can be found in the LICENSE file. */
/* global define, nativeIO, isWin */
diff --git a/data/chromelight/popup.js b/data/chromelight/popup.js
index 219bab7e8..819c8dc56 100644
--- a/data/chromelight/popup.js
+++ b/data/chromelight/popup.js
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2014 The TagSpaces Authors. All rights reserved.
+/* Copyright (c) 2012-2015 The TagSpaces Authors. All rights reserved.
* Use of this source code is governed by a AGPL3 license that
* can be found in the LICENSE file. */
/* global saveAs, DOMPurify */
diff --git a/data/cordova/cordova.api.js b/data/cordova/cordova.api.js
index 16c34dc65..cb3c057da 100644
--- a/data/cordova/cordova.api.js
+++ b/data/cordova/cordova.api.js
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2014 The TagSpaces Authors. All rights reserved.
+/* Copyright (c) 2012-2015 The TagSpaces Authors. All rights reserved.
* Use of this source code is governed by a AGPL3 license that
* can be found in the LICENSE file. */
/* global define */
diff --git a/data/ext/editorHTML/editor.js b/data/ext/editorHTML/editor.js
index af6d768bb..1759e1a9b 100644
--- a/data/ext/editorHTML/editor.js
+++ b/data/ext/editorHTML/editor.js
@@ -1,64 +1,68 @@
-var isCordova = document.URL.indexOf( 'file:///android_asset' ) === 0;
+"use strict";
+
+var isCordova = document.URL.indexOf('file:///android_asset') === 0;
+var $htmlEditor;
var toolbar = [
- ['style', ['style']],
+ ['style', ['style']],
+ ['color', ['color']],
+ ['font', ['bold', 'italic', 'underline']],
+ ['font2', ['superscript', 'subscript', 'strikethrough', 'clear']],
+ ['fontname', ['fontname']],
+ // ['fontsize', ['fontsize']],
+ ['para', ['ul', 'ol', 'paragraph']],
+ ['height', ['height']],
+ ['table', ['table']],
+ ['insert', ['link', 'picture', 'hr']], // 'video',
+ ['view', ['codeview']], // 'fullscreen',
+ ['help', ['help']]
+];
+
+if (isCordova) {
+ toolbar = [
['color', ['color']],
+ ['style', ['style']],
+ ['para', ['paragraph', 'ul', 'ol']],
['font', ['bold', 'italic', 'underline']],
['font2', ['superscript', 'subscript', 'strikethrough', 'clear']],
- ['fontname', ['fontname']],
- // ['fontsize', ['fontsize']],
- ['para', ['ul', 'ol', 'paragraph']],
+ //['fontsize', ['fontsize']],
['height', ['height']],
+ ['insert', ['picture', 'link', 'hr']],
['table', ['table']],
- ['insert', ['link', 'picture', 'hr']], // 'video',
- ['view', ['codeview']], // 'fullscreen',
- ['help', ['help']]
-];
-
-if (isCordova) {
- toolbar = [
- ['color', ['color']],
- ['style', ['style']],
- ['para', ['paragraph', 'ul', 'ol']],
- ['font', ['bold', 'italic', 'underline']],
- ['font2', ['superscript', 'subscript', 'strikethrough', 'clear']],
- //['fontsize', ['fontsize']],
- ['height', ['height']],
- ['insert', ['picture', 'link', 'hr']],
- ['table', ['table']],
- ['view', ['codeview']]
- ];
+ ['view', ['codeview']]
+ ];
}
function initEditor() {
- $htmlEditor.summernote({
- focus: true,
- height: "100%",
- toolbar: toolbar,
- onkeyup: function() {
- contentVersion++;
-// window.parent.postMessage('par1', '*');
- }
- });
+ $htmlEditor.summernote({
+ focus: true,
+ height: "100%",
+ toolbar: toolbar,
+ onkeyup: function() {
+ contentVersion++;
+ // window.parent.postMessage('par1', '*');
+ }
+ });
}
var contentVersion = 0;
+
function resetContentVersion() {
- contentVersion = 0;
+ contentVersion = 0;
}
function getContentVersion() {
- return contentVersion;
+ return contentVersion;
}
function setContent(content) {
- resetContentVersion();
- $htmlEditor = $('#htmlEditor');
- $htmlEditor.append(content);
- // Check if summernote is loaded
- if(typeof $htmlEditor.summernote === 'function') {
- initEditor();
- } else {
- // window.setTimeout(initEditor(), 1000);
- }
-}
\ No newline at end of file
+ resetContentVersion();
+ $htmlEditor = $('#htmlEditor');
+ $htmlEditor.append(content);
+ // Check if summernote is loaded
+ if (typeof $htmlEditor.summernote === 'function') {
+ initEditor();
+ } else {
+ // window.setTimeout(initEditor(), 1000);
+ }
+}
diff --git a/data/ext/editorHTML/extension.js b/data/ext/editorHTML/extension.js
index c128065d9..c1d6a5926 100644
--- a/data/ext/editorHTML/extension.js
+++ b/data/ext/editorHTML/extension.js
@@ -1,178 +1,178 @@
-/* Copyright (c) 2013 The Tagspaces Authors. All rights reserved.
- * Use of this source code is governed by a AGPL3 license that
- * can be found in the LICENSE file. */
-
-define(function(require, exports, module) {
-"use strict";
-
- console.log("Loading editorHTML");
-
- var extensionTitle = "HTML Editor";
- var extensionID = "editorHTML"; // ID should be equal to the directory name where the ext. is located
- var extensionType = "editor";
- var extensionIcon = "icon-list";
- var extensionVersion = "1.0";
- var extensionManifestVersion = 1;
- var extensionLicense = "AGPL";
- var extensionSupportedFileTypes = [ "html", "htm" ];
-
- var TSCORE = require("tscore");
-
- var extensionsPath = TSCORE.Config.getExtensionPath();
-
- var extensionDirectory = extensionsPath+"/"+extensionID;
-
- var currentContent,
- currentFilePath,
- $containerElement;
-
- exports.init = function(filePath, containerElementID) {
- console.log("Initalization HTML Editor...");
-
- $containerElement = $('#'+containerElementID);
-
- currentFilePath = filePath;
-
- //var fileExt = TSCORE.TagUtils.extractFileExtension(filePath);
-
- $containerElement.empty();
- $containerElement.css("background-color","white");
-
- var extPath = extensionDirectory+"/index.html";
- $containerElement.append($('<iframe>', {
- id: "iframeViewer",
- sandbox: "allow-same-origin allow-scripts",
- scrolling: "no",
- style: "background-color: white; overflow: hidden;",
- src: extPath+"?cp="+filePath,
- "nwdisable": "",
- "nwfaketop": ""
- }));
- TSCORE.IO.loadTextFile(filePath);
-
-// if (!window.addEventListener) {
-// window.attachEvent('onmessage', function(e) {alert(e.origin);alert(e.data);});
-// } else {
-// window.addEventListener('message', function(e) {alert(e.origin);alert(e.data);}, false);
-// }
- };
-
- exports.setFileType = function(fileType) {
- console.log("setFileType not supported on this extension");
- };
-
- exports.viewerMode = function(isViewerMode) {
- // set readonly
- console.log("viewerMode not supported on this extension");
- };
-
- exports.setContent = function(content) {
- currentContent = content;
-
- var bodyRegex = /\<body[^>]*\>([^]*)\<\/body/m;
- var bodyContent = undefined;
-
- try {
- bodyContent = content.match( bodyRegex )[1];
- } catch(e) {
- console.log("Error parsing HTML document. "+e);
- TSCORE.FileOpener.closeFile(true);
- TSCORE.showAlertDialog("Probably a body tag was not found in the document. Document will be closed.","Error parsing HTML document");
- }
-
-// var titleRegex = /\<title[^>]*\>([^]*)\<\/title/m;
-// var titleContent = content.match( titleRegex )[1];
-
- // removing all scripts from the document
- var cleanedBodyContent = bodyContent.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"");
-
- var contentWindow = document.getElementById("iframeViewer").contentWindow;
- if(typeof contentWindow.setContent === "function") {
- contentWindow.setContent(cleanedBodyContent);
- } else {
- // TODO optimize setTimeout
- window.setTimeout(function() {
- contentWindow.setContent(cleanedBodyContent);
- }, 500);
- }
- };
-
- var contentVersion = 0;
-
- function resetContentVersion() {
- contentVersion = 0;
- document.getElementById("iframeViewer").contentWindow.resetContentVersion();
- }
-
- function checkContentChanged() {
- var newContentVersion;
- try {
- newContentVersion = document.getElementById("iframeViewer").contentWindow.getContentVersion();
- } catch(e) { }
- if(newContentVersion > contentVersion) {
- contentVersion = newContentVersion;
- TSCORE.FileOpener.setFileChanged(true);
- // autosave
- //TSCORE.FileOpener.saveFile();
- }
- window.setTimeout(checkContentChanged, 1000);
- }
-
- window.setTimeout(checkContentChanged, 1000);
-
- exports.getContent = function() {
- var content = $("#iframeViewer").contents().find(".note-editable").html();
-
- // removing all scripts from the document
- var cleanedContent = content.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"");
-
- // saving all images as png in base64 format
- var match,
- urls = [],
- imgUrl = "",
- rex = /<img.*?src="([^">]*\/([^">]*?))".*?>/g;;
-
- while ( match = rex.exec( cleanedContent ) ) {
- imgUrl = match[1];
- console.log("URLs: "+imgUrl);
- urls.push([imgUrl, getBase64Image(imgUrl)]);
- }
-
- urls.forEach(function(dataURLObject) {
- if(dataURLObject[1].length > 7) {
- cleanedContent = cleanedContent.split(dataURLObject[0]).join(dataURLObject[1]);
- }
- //console.log(dataURLObject[0]+" - "+dataURLObject[1]);
- });
- // end saving all images
-
- cleanedContent = "<body>"+cleanedContent+"</body>";
-
- var htmlContent = currentContent.replace(/\<body[^>]*\>([^]*)\<\/body>/m,cleanedContent);
- //console.log("Final html "+htmlContent);
- resetContentVersion();
- return htmlContent;
- };
-
- function getBase64Image(imgURL) {
- var canvas = document.createElement("canvas");
- var img = new Image();
- img.src = imgURL;
- canvas.width = img.width;
- canvas.height = img.height;
- var ctx = canvas.getContext("2d");
- ctx.drawImage(img, 0, 0);
- return canvas.toDataURL("image/png");
- }
-
- // Extension Vars
- exports.Title = extensionTitle;
- exports.ID = extensionID;
- exports.Type = extensionType;
- exports.Icon = extensionIcon;
- exports.Version = extensionVersion;
- exports.ManifestVersion = extensionManifestVersion;
- exports.License = extensionLicense;
- exports.SupportedFileTypes = extensionSupportedFileTypes;
-
-});
+/* Copyright (c) 2013 The Tagspaces Authors. All rights reserved.
+ * Use of this source code is governed by a AGPL3 license that
+ * can be found in the LICENSE file. */
+
+define(function(require, exports, module) {
+ "use strict";
+
+ console.log("Loading editorHTML");
+
+ var extensionTitle = "HTML Editor";
+ var extensionID = "editorHTML"; // ID should be equal to the directory name where the ext. is located
+ var extensionType = "editor";
+ var extensionIcon = "icon-list";
+ var extensionVersion = "1.0";
+ var extensionManifestVersion = 1;
+ var extensionLicense = "AGPL";
+ var extensionSupportedFileTypes = ["html", "htm"];
+
+ var TSCORE = require("tscore");
+
+ var extensionsPath = TSCORE.Config.getExtensionPath();
+
+ var extensionDirectory = extensionsPath + "/" + extensionID;
+
+ var currentContent,
+ currentFilePath,
+ $containerElement;
+
+ exports.init = function(filePath, containerElementID) {
+ console.log("Initalization HTML Editor...");
+
+ $containerElement = $('#' + containerElementID);
+
+ currentFilePath = filePath;
+
+ //var fileExt = TSCORE.TagUtils.extractFileExtension(filePath);
+
+ $containerElement.empty();
+ $containerElement.css("background-color", "white");
+
+ var extPath = extensionDirectory + "/index.html";
+ $containerElement.append($('<iframe>', {
+ id: "iframeViewer",
+ sandbox: "allow-same-origin allow-scripts",
+ scrolling: "no",
+ style: "background-color: white; overflow: hidden;",
+ src: extPath + "?cp=" + filePath,
+ "nwdisable": "",
+ "nwfaketop": ""
+ }));
+ TSCORE.IO.loadTextFile(filePath);
+
+ // if (!window.addEventListener) {
+ // window.attachEvent('onmessage', function(e) {alert(e.origin);alert(e.data);});
+ // } else {
+ // window.addEventListener('message', function(e) {alert(e.origin);alert(e.data);}, false);
+ // }
+ };
+
+ exports.setFileType = function(fileType) {
+ console.log("setFileType not supported on this extension");
+ };
+
+ exports.viewerMode = function(isViewerMode) {
+ // set readonly
+ console.log("viewerMode not supported on this extension");
+ };
+
+ exports.setContent = function(content) {
+ currentContent = content;
+
+ var bodyRegex = /\<body[^>]*\>([^]*)\<\/body/m; // jshint ignore:line
+ var bodyContent;
+
+ try {
+ bodyContent = content.match(bodyRegex)[1];
+ } catch (e) {
+ console.log("Error parsing HTML document. " + e);
+ TSCORE.FileOpener.closeFile(true);
+ TSCORE.showAlertDialog("Probably a body tag was not found in the document. Document will be closed.", "Error parsing HTML document");
+ }
+
+ // var titleRegex = /\<title[^>]*\>([^]*)\<\/title/m;
+ // var titleContent = content.match( titleRegex )[1];
+
+ // removing all scripts from the document
+ var cleanedBodyContent = bodyContent.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, "");
+
+ var contentWindow = document.getElementById("iframeViewer").contentWindow;
+ if (typeof contentWindow.setContent === "function") {
+ contentWindow.setContent(cleanedBodyContent);
+ } else {
+ // TODO optimize setTimeout
+ window.setTimeout(function() {
+ contentWindow.setContent(cleanedBodyContent);
+ }, 500);
+ }
+ };
+
+ var contentVersion = 0;
+
+ function resetContentVersion() {
+ contentVersion = 0;
+ document.getElementById("iframeViewer").contentWindow.resetContentVersion();
+ }
+
+ function checkContentChanged() {
+ var newContentVersion;
+ try {
+ newContentVersion = document.getElementById("iframeViewer").contentWindow.getContentVersion();
+ } catch (e) {}
+ if (newContentVersion > contentVersion) {
+ contentVersion = newContentVersion;
+ TSCORE.FileOpener.setFileChanged(true);
+ // autosave
+ //TSCORE.FileOpener.saveFile();
+ }
+ window.setTimeout(checkContentChanged, 1000);
+ }
+
+ window.setTimeout(checkContentChanged, 1000);
+
+ exports.getContent = function() {
+ var content = $("#iframeViewer").contents().find(".note-editable").html();
+
+ // removing all scripts from the document
+ var cleanedContent = content.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, "");
+
+ // saving all images as png in base64 format
+ var match,
+ urls = [],
+ imgUrl = "",
+ rex = /<img.*?src="([^">]*\/([^">]*?))".*?>/g;
+
+ while (match = rex.exec(cleanedContent)) {
+ imgUrl = match[1];
+ console.log("URLs: " + imgUrl);
+ urls.push([imgUrl, getBase64Image(imgUrl)]);
+ }
+
+ urls.forEach(function(dataURLObject) {
+ if (dataURLObject[1].length > 7) {
+ cleanedContent = cleanedContent.split(dataURLObject[0]).join(dataURLObject[1]);
+ }
+ //console.log(dataURLObject[0]+" - "+dataURLObject[1]);
+ });
+ // end saving all images
+
+ cleanedContent = "<body>" + cleanedContent + "</body>";
+
+ var htmlContent = currentContent.replace(/\<body[^>]*\>([^]*)\<\/body>/m, cleanedContent); // jshint ignore:line
+ //console.log("Final html "+htmlContent);
+ resetContentVersion();
+ return htmlContent;
+ };
+
+ function getBase64Image(imgURL) {
+ var canvas = document.createElement("canvas");
+ var img = new Image();
+ img.src = imgURL;
+ canvas.width = img.width;
+ canvas.height = img.height;
+ var ctx = canvas.getContext("2d");
+ ctx.drawImage(img, 0, 0);
+ return canvas.toDataURL("image/png");
+ }
+
+ // Extension Vars
+ exports.Title = extensionTitle;
+ exports.ID = extensionID;
+ exports.Type = extensionType;
+ exports.Icon = extensionIcon;
+ exports.Version = extensionVersion;
+ exports.ManifestVersion = extensionManifestVersion;
+ exports.License = extensionLicense;
+ exports.SupportedFileTypes = extensionSupportedFileTypes;
+
+});
diff --git a/data/ext/editorJSON/extension.js b/data/ext/editorJSON/extension.js
index daf2fc0d1..098e4d853 100644
--- a/data/ext/editorJSON/extension.js
+++ b/data/ext/editorJSON/extension.js
@@ -1,83 +1,86 @@
-/* Copyright (c) 2014 The Tagspaces Authors. All rights reserved.
- * Use of this source code is governed by a AGPL3 license that
+/* Copyright (c) 2012-2015 The TagSpaces Authors. All rights reserved.
+ * Use of this source code is governed by a AGPL3 license that
* can be found in the LICENSE file. */
define(function(require, exports, module) {
-"use strict";
-
- console.log("Loading editorJSON");
- exports.id = "editorJSON"; // ID should be equal to the directory name where the ext. is located
- exports.title = "JSON Editor";
- exports.type = "editor";
- exports.supportedFileTypes = [ "json" ];
-
- var TSCORE = require("tscore");
-
- var jsonEditor;
-
- var extensionsPath = TSCORE.Config.getExtensionPath();
-
- var extensionDirectory = extensionsPath+"/"+exports.id;
-
- var currentContent;
- var currentFilePath;
-
- exports.init = function(filePath, containerElementID, isViewer) {
- console.log("Initalization JSON Editor...");
- currentFilePath = filePath;
- require([
- extensionDirectory+'/jsoneditor/jsoneditor.js',
- 'css!'+extensionDirectory+'/jsoneditor/jsoneditor.css',
- 'css!'+extensionDirectory+'/extension.css'
- ], function(JSONEditor) {
- $("#"+containerElementID)
- .css("background-color","white")
- .append('<div id="jsonEditor"></div>');
- var options = {mode: isViewer?'view':'tree', change: contentChanged};
- jsonEditor = new JSONEditor(document.getElementById("jsonEditor"), options);
- TSCORE.IO.loadTextFile(filePath);
- });
- };
-
- function contentChanged() {
- TSCORE.FileOpener.setFileChanged(true);
+ "use strict";
+
+ console.log("Loading editorJSON");
+ exports.id = "editorJSON"; // ID should be equal to the directory name where the ext. is located
+ exports.title = "JSON Editor";
+ exports.type = "editor";
+ exports.supportedFileTypes = ["json"];
+
+ var TSCORE = require("tscore");
+
+ var jsonEditor;
+
+ var extensionsPath = TSCORE.Config.getExtensionPath();
+
+ var extensionDirectory = extensionsPath + "/" + exports.id;
+
+ var currentContent;
+ var currentFilePath;
+
+ exports.init = function(filePath, containerElementID, isViewer) {
+ console.log("Initalization JSON Editor...");
+ currentFilePath = filePath;
+ require([
+ extensionDirectory + '/jsoneditor/jsoneditor.js',
+ 'css!' + extensionDirectory + '/jsoneditor/jsoneditor.css',
+ 'css!' + extensionDirectory + '/extension.css'
+ ], function(JSONEditor) {
+ $("#" + containerElementID)
+ .css("background-color", "white")
+ .append('<div id="jsonEditor"></div>');
+ var options = {
+ mode: isViewer ? 'view' : 'tree',
+ change: contentChanged
+ };
+ jsonEditor = new JSONEditor(document.getElementById("jsonEditor"), options);
+ TSCORE.IO.loadTextFile(filePath);
+ });
+ };
+
+ function contentChanged() {
+ TSCORE.FileOpener.setFileChanged(true);
+ }
+
+ exports.setFileType = function(fileType) {
+ console.log("setFileType not supported on this extension");
+ };
+
+ exports.viewerMode = function(isViewerMode) {
+ if (isViewerMode) {
+ jsonEditor.setMode('view');
+ } else {
+ jsonEditor.setMode('tree');
}
+ };
- exports.setFileType = function(fileType) {
- console.log("setFileType not supported on this extension");
- };
-
- exports.viewerMode = function(isViewerMode) {
- if(isViewerMode) {
- jsonEditor.setMode('view');
- } else {
- jsonEditor.setMode('tree');
- }
- };
-
- exports.setContent = function(content) {
- var jsonContent;
-
- var UTF8_BOM = "\ufeff";
- if(content.indexOf(UTF8_BOM) === 0) {
- content = content.substring(1,content.length);
- }
-
- try {
- jsonContent = JSON.parse(content);
- } catch(e) {
- console.log("Error parsing JSON document. "+e);
- TSCORE.FileOpener.closeFile(true);
- TSCORE.showAlertDialog("Error parsing JSON document");
- return false;
- }
- //console.log("Content: "+JSON.stringify(jsonConten));
- jsonEditor.set(jsonContent);
- //jsonEditor.expandAll();
- };
-
- exports.getContent = function() {
- return JSON.stringify(jsonEditor.get());
- };
+ exports.setContent = function(content) {
+ var jsonContent;
+
+ var UTF8_BOM = "\ufeff";
+ if (content.indexOf(UTF8_BOM) === 0) {
+ content = content.substring(1, content.length);
+ }
+
+ try {
+ jsonContent = JSON.parse(content);
+ } catch (e) {
+ console.log("Error parsing JSON document. " + e);
+ TSCORE.FileOpener.closeFile(true);
+ TSCORE.showAlertDialog("Error parsing JSON document");
+ return false;
+ }
+ //console.log("Content: "+JSON.stringify(jsonConten));
+ jsonEditor.set(jsonContent);
+ //jsonEditor.expandAll();
+ };
+
+ exports.getContent = function() {
+ return JSON.stringify(jsonEditor.get());
+ };
});
diff --git a/data/ext/editorODF/extension.js b/data/ext/editorODF/extension.js
index 6f7dd3449..a66e03327 100644
--- a/data/ext/editorODF/extension.js
+++ b/data/ext/editorODF/extension.js
@@ -1,51 +1,52 @@
-/* Copyright (c) 2013 The Tagspaces Authors. All rights reserved.
- * Use of this source code is governed by a AGPL3 license that
- * can be found in the LICENSE file. */
-
-define(function(require, exports, module) {
-"use strict";
-
- console.log("Loading editorODF");
-
- exports.id = "editorODF"; // ID should be equal to the directory name where the ext. is located
- exports.title = "ODF Viewer/Editor";
- exports.type = "editor";
- exports.supportedFileTypes = [ "odt", "ods" ];
-
- var TSCORE = require("tscore");
-
- var extensionDirectory = TSCORE.Config.getExtensionPath()+"/"+exports.id;
-
- exports.init = function(filePath, elementID) {
- console.log("Initalization ODF Viewer/Editor...");
- //filePath = "file:///"+filePath;
- //filePath = "http://www.webodf.org/demos/presentation/ohm2013.odp";
- var extPath = extensionDirectory+"/index.html";
- $('#'+elementID).append($('<iframe>', {
- id: "iframeViewer",
- sandbox: "allow-same-origin allow-scripts",
- style: "background-color: white",
- src: extPath+"?cp="+filePath,
- "nwdisable": "",
- "nwfaketop": ""
- }));
-
- /*require([extensionDirectory+'/webodf/webodf.js'], function() {
- var odfelement = document.getElementById(elementID),
- odfcanvas = new odf.OdfCanvas(odfelement);
- odfcanvas.load(filePath);
- });*/
- };
-
- exports.viewerMode = function() {
- console.log("viewerMode not supported on this extension");
- };
-
- exports.setContent = function() {
- console.log("setContent not supported on this extension");
- };
-
- exports.getContent = function() {
- console.log("getContent not supported on this extension"); };
-
-});
\ No newline at end of file
+/* Copyright (c) 2013 The Tagspaces Authors. All rights reserved.
+ * Use of this source code is governed by a AGPL3 license that
+ * can be found in the LICENSE file. */
+
+define(function(require, exports, module) {
+ "use strict";
+
+ console.log("Loading editorODF");
+
+ exports.id = "editorODF"; // ID should be equal to the directory name where the ext. is located
+ exports.title = "ODF Viewer/Editor";
+ exports.type = "editor";
+ exports.supportedFileTypes = ["odt", "ods"];
+
+ var TSCORE = require("tscore");
+
+ var extensionDirectory = TSCORE.Config.getExtensionPath() + "/" + exports.id;
+
+ exports.init = function(filePath, elementID) {
+ console.log("Initalization ODF Viewer/Editor...");
+ //filePath = "file:///"+filePath;
+ //filePath = "http://www.webodf.org/demos/presentation/ohm2013.odp";
+ var extPath = extensionDirectory + "/index.html";
+ $('#' + elementID).append($('<iframe>', {
+ id: "iframeViewer",
+ sandbox: "allow-same-origin allow-scripts",
+ style: "background-color: white",
+ src: extPath + "?cp=" + filePath,
+ "nwdisable": "",
+ "nwfaketop": ""
+ }));
+
+ /*require([extensionDirectory+'/webodf/webodf.js'], function() {
+ var odfelement = document.getElementById(elementID),
+ odfcanvas = new odf.OdfCanvas(odfelement);
+ odfcanvas.load(filePath);
+ });*/
+ };
+
+ exports.viewerMode = function() {
+ console.log("viewerMode not supported on this extension");
+ };
+
+ exports.setContent = function() {
+ console.log("setContent not supported on this extension");
+ };
+
+ exports.getContent = function() {
+ console.log("getContent not supported on this extension");
+ };
+
+});
diff --git a/data/ext/editorText/extension.js b/data/ext/editorText/extension.js
index 6ac66e72c..f9cb1380e 100644
--- a/data/ext/editorText/extension.js
+++ b/data/ext/editorText/extension.js
@@ -1,154 +1,156 @@
-/* Copyright (c) 2013 The Tagspaces Authors. All rights reserved.
- * Use of this source code is governed by a AGPL3 license that
- * can be found in the LICENSE file. */
-
-define(function(require, exports, module) {
-"use strict";
-
- console.log("Loading editorText extension");
-
- exports.id = "editorText"; // ID should be equal to the directory name where the ext. is located
- exports.title = "Text Editor based on codemirror";
- exports.type = "editor";
- exports.supportedFileTypes = [
- "h", "c", "clj", "coffee", "coldfusion", "cpp",
- "cs", "css", "groovy", "haxe", "htm", "html",
- "java", "js", "jsm", "json", "latex", "less",
- "ly", "ily", "lua", "markdown", "md", "mdown",
- "mdwn", "mkd", "ml", "mli", "pl", "php",
- "powershell", "py", "rb", "scad", "scala",
- "scss", "sh", "sql", "svg", "textile", "txt", "xml"
- ] ;
-
- var TSCORE = require("tscore");
-
- var cmEditor = undefined;
- var extensionDirectory = TSCORE.Config.getExtensionPath() + "/" + exports.id;
-
- var contentLoaded = false;
-
- exports.init = function (filePath, containerElementID, isViewerMode) {
- console.log("Initalization Text Editor...");
- contentLoaded = false;
-
- var fileExt = filePath.substring(filePath.lastIndexOf(".") + 1, filePath.length).toLowerCase();
-
- $("#" + containerElementID).append('<div id="code" style="width: 100%; height: 100%">');
- var mode = filetype[fileExt];
- if (mode == null) {
- mode = "properties";
- }
- require([
- extensionDirectory + '/codemirror/codemirror.js',
- 'css!' + extensionDirectory + '/codemirror/codemirror.css',
- 'css!' + extensionDirectory + '/extension.css'
- ], function () {
- require([
- extensionDirectory + "/codemirror/mode/" + mode + "/" + mode + ".js"
- ], function () {
- var cursorBlinkRate = isViewerMode ? -1 : 530; // disabling the blinking cursor in readonly mode
-
- //var saveKB = convertMouseTrapToCodeMirrorKeyBindings(TSCORE.Config.getSaveDocumentKeyBinding());
-
- var keys = {};
-
- keys[convertMouseTrapToCodeMirrorKeyBindings(TSCORE.Config.getSaveDocumentKeyBinding())] = function () {
- TSCORE.FileOpener.saveFile();
- };
-
- keys[convertMouseTrapToCodeMirrorKeyBindings(TSCORE.Config.getCloseViewerKeyBinding())] = function () {
- TSCORE.FileOpener.closeFile();
- };
-
- cmEditor = CodeMirror(document.getElementById("code"), {
- fixedGutter: false,
- mode: mode,
- lineNumbers: true,
- lineWrapping: true,
- tabSize: 2,
- collapseRange: true,
- matchBrackets: true,
- cursorBlinkRate: cursorBlinkRate,
- readOnly: isViewerMode,
- autofocus: true,
- //theme: "lesser-dark",
- //extraKeys: keys // workarrounded with bindGlobal plugin for mousetrap
- });
-
- cmEditor.on("change", function() {
- if(contentLoaded) {
- TSCORE.FileOpener.setFileChanged(true);
- }
- });
-
- cmEditor.setSize("100%", "100%");
- TSCORE.IO.loadTextFile(filePath);
- });
- });
- };
-
- // Converts mod+s to Ctrl+S
- function convertMouseTrapToCodeMirrorKeyBindings(keyBinding) {
- if(keyBinding.indexOf("+") < 0) return;
- var key = keyBinding.split("+");
- if(key[0] === "mod") {
- isOSX?key[0]="cmd":key[0]="ctrl";
- }
- key[0] = key[0].charAt(0).toUpperCase() + key[0].slice(1);
- return key[0] + "-" + key[1].toUpperCase();
- }
-
- exports.viewerMode = function (isViewerMode) {
- cmEditor.readOnly = isViewerMode;
- };
-
- exports.setContent = function (content) {
- //console.log("Content: "+content);
- var UTF8_BOM = "\ufeff";
- if (content.indexOf(UTF8_BOM) === 0) {
- content = content.substring(1, content.length);
- }
- cmEditor.setValue(content);
- cmEditor.clearHistory();
- contentLoaded = true;
- };
-
- exports.getContent = function () {
- return cmEditor.getValue();
- };
-
- var filetype = [];
- filetype["h"] = "clike";
- filetype["c"] = "clike";
- filetype["clj"] = "clojure";
- filetype["coffee"] = "coffeescript";
- filetype["cpp"] = "clike";
- filetype["cs"] = "clike";
- filetype["css"] = "css";
- filetype["groovy"] = "groovy";
- filetype["haxe"] = "haxe";
- filetype["htm"] = "xml";
- filetype["html"] = "xml";
- filetype["java"] = "clike";
- filetype["js"] = "javascript";
- filetype["jsm"] = "javascript";
- filetype["json"] = "javascript";
- filetype["less"] = "less";
- filetype["lua"] = "lua";
- filetype["markdown"] = "markdown";
- filetype["md"] = "markdown";
- filetype["mdown"] = "markdown";
- filetype["mdwn"] = "markdown";
- filetype["mkd"] = "markdown";
- filetype["ml"] = "ocaml";
- filetype["mli"] = "ocaml";
- filetype["pl"] = "perl";
- filetype["php"] = "php";
- filetype["py"] = "python";
- filetype["rb"] = "ruby";
- filetype["sh"] = "shell";
- filetype["sql"] = "sql";
- filetype["svg"] = "xml";
- filetype["xml"] = "xml";
-
-});
\ No newline at end of file
+/* Copyright (c) 2013 The Tagspaces Authors. All rights reserved.
+ * Use of this source code is governed by a AGPL3 license that
+ * can be found in the LICENSE file. */
+
+define(function(require, exports, module) {
+ "use strict";
+
+ console.log("Loading editorText extension");
+
+ exports.id = "editorText"; // ID should be equal to the directory name where the ext. is located
+ exports.title = "Text Editor based on codemirror";
+ exports.type = "editor";
+ exports.supportedFileTypes = [
+ "h", "c", "clj", "coffee", "coldfusion", "cpp",
+ "cs", "css", "groovy", "haxe", "htm", "html",
+ "java", "js", "jsm", "json", "latex", "less",
+ "ly", "ily", "lua", "markdown", "md", "mdown",
+ "mdwn", "mkd", "ml", "mli", "pl", "php",
+ "powershell", "py", "rb", "scad", "scala",
+ "scss", "sh", "sql", "svg", "textile", "txt", "xml"
+ ];
+
+ var TSCORE = require("tscore");
+
+ var cmEditor;
+ var extensionDirectory = TSCORE.Config.getExtensionPath() + "/" + exports.id;
+
+ var contentLoaded = false;
+
+ exports.init = function(filePath, containerElementID, isViewerMode) {
+ console.log("Initalization Text Editor...");
+ contentLoaded = false;
+
+ var fileExt = filePath.substring(filePath.lastIndexOf(".") + 1, filePath.length).toLowerCase();
+
+ $("#" + containerElementID).append('<div id="code" style="width: 100%; height: 100%">');
+ var mode = filetype[fileExt];
+ if (mode === null) {
+ mode = "properties";
+ }
+ require([
+ extensionDirectory + '/codemirror/codemirror.js',
+ 'css!' + extensionDirectory + '/codemirror/codemirror.css',
+ 'css!' + extensionDirectory + '/extension.css'
+ ], function() {
+ require([
+ extensionDirectory + "/codemirror/mode/" + mode + "/" + mode + ".js"
+ ], function() {
+ var cursorBlinkRate = isViewerMode ? -1 : 530; // disabling the blinking cursor in readonly mode
+
+ //var saveKB = convertMouseTrapToCodeMirrorKeyBindings(TSCORE.Config.getSaveDocumentKeyBinding());
+
+ var keys = {};
+
+ keys[convertMouseTrapToCodeMirrorKeyBindings(TSCORE.Config.getSaveDocumentKeyBinding())] = function() {
+ TSCORE.FileOpener.saveFile();
+ };
+
+ keys[convertMouseTrapToCodeMirrorKeyBindings(TSCORE.Config.getCloseViewerKeyBinding())] = function() {
+ TSCORE.FileOpener.closeFile();
+ };
+
+ cmEditor = new CodeMirror(document.getElementById("code"), {
+ fixedGutter: false,
+ mode: mode,
+ lineNumbers: true,
+ lineWrapping: true,
+ tabSize: 2,
+ collapseRange: true,
+ matchBrackets: true,
+ cursorBlinkRate: cursorBlinkRate,
+ readOnly: isViewerMode,
+ autofocus: true,
+ //theme: "lesser-dark",
+ //extraKeys: keys // workarrounded with bindGlobal plugin for mousetrap
+ });
+
+ cmEditor.on("change", function() {
+ if (contentLoaded) {
+ TSCORE.FileOpener.setFileChanged(true);
+ }
+ });
+
+ cmEditor.setSize("100%", "100%");
+ TSCORE.IO.loadTextFile(filePath);
+ });
+ });
+ };
+
+ // Converts mod+s to Ctrl+S
+ function convertMouseTrapToCodeMirrorKeyBindings(keyBinding) {
+ if (keyBinding.indexOf("+") < 0) {
+ return;
+ }
+ var key = keyBinding.split("+");
+ if (key[0] === "mod") {
+ isOSX ? key[0] = "cmd" : key[0] = "ctrl";
+ }
+ key[0] = key[0].charAt(0).toUpperCase() + key[0].slice(1);
+ return key[0] + "-" + key[1].toUpperCase();
+ }
+
+ exports.viewerMode = function(isViewerMode) {
+ cmEditor.readOnly = isViewerMode;
+ };
+
+ exports.setContent = function(content) {
+ //console.log("Content: "+content);
+ var UTF8_BOM = "\ufeff";
+ if (content.indexOf(UTF8_BOM) === 0) {
+ content = content.substring(1, content.length);
+ }
+ cmEditor.setValue(content);
+ cmEditor.clearHistory();
+ contentLoaded = true;
+ };
+
+ exports.getContent = function() {
+ return cmEditor.getValue();
+ };
+
+ var filetype = [];
+ filetype.h = "clike";
+ filetype.c = "clike";
+ filetype.clj = "clojure";
+ filetype.coffee = "coffeescript";
+ filetype.cpp = "clike";
+ filetype.cs = "clike";
+ filetype.css = "css";
+ filetype.groovy = "groovy";
+ filetype.haxe = "haxe";
+ filetype.htm = "xml";
+ filetype.html = "xml";
+ filetype.java = "clike";
+ filetype.js = "javascript";
+ filetype.jsm = "javascript";
+ filetype.json = "javascript";
+ filetype.less = "less";
+ filetype.lua = "lua";
+ filetype.markdown = "markdown";
+ filetype.md = "markdown";
+ filetype.mdown = "markdown";
+ filetype.mdwn = "markdown";
+ filetype.mkd = "markdown";
+ filetype.ml = "ocaml";
+ filetype.mli = "ocaml";
+ filetype.pl = "perl";
+ filetype.php = "php";
+ filetype.py = "python";
+ filetype.rb = "ruby";
+ filetype.sh = "shell";
+ filetype.sql = "sql";
+ filetype.svg = "xml";
+ filetype.xml = "xml";
+
+});
diff --git a/data/ext/perspectiveGrid/extension.js b/data/ext/perspectiveGrid/extension.js
index 186ec9be9..9af6d4827 100644
--- a/data/ext/perspectiveGrid/extension.js
+++ b/data/ext/perspectiveGrid/extension.js
@@ -1,98 +1,99 @@
-/* Copyright (c) 2013-2014 The Tagspaces Authors. All rights reserved.
- * Use of this source code is governed by a AGPL3 license that
- * can be found in the LICENSE file. */
-/* global define, Handlebars, isCordova */
-define(function(require, exports, module) {
-"use strict";
-
- var extensionTitle = "Grid";
- var extensionID = "perspectiveGrid"; // ID should be equal to the directory name where the ext. is located
- var extensionType = "perspective";
- var extensionIcon = "fa fa-th";
- var extensionVersion = "1.0";
- var extensionManifestVersion = 1;
- var extensionLicense = "AGPL";
-
- console.log("Loading "+extensionID);
-
- var TSCORE = require("tscore");
-
- var extensionDirectory = TSCORE.Config.getExtensionPath()+"/"+extensionID;
- var UI;
-
- var init = function () {
- console.log("Initializing perspective "+extensionID);
- require([
- extensionDirectory+'/perspectiveUI.js',
- "text!"+extensionDirectory+'/toolbar.html'
- ], function(extUI, toolbarTPL) {
- var toolbarTemplate = Handlebars.compile( toolbarTPL );
- UI = new extUI.ExtUI(extensionID);
- UI.buildUI(toolbarTemplate);
- platformTuning();
- $('#'+extensionID+'Toolbar [data-i18n]').i18n();
- }
- );
- };
-
- var platformTuning = function() {
- if(isCordova) {
- $("#"+extensionID+"IncludeSubDirsButton").hide();
- } else if(isChrome) {
- $('#'+extensionID+'AddFileButton').hide();
- } else if(isFirefox) {
- $('#'+extensionID+'AddFileButton').hide(); // Current impl has 0.5mb limit
- }
- };
-
- var load = function () {
- console.log("Loading perspective "+extensionID);
- if(UI === undefined) {
- window.setTimeout(function() { UI.reInit(); }, 1000);
- } else {
- UI.reInit();
- }
- };
-
- var clearSelectedFiles = function() {
- if(UI !== undefined) {
- UI.clearSelectedFiles();
- UI.handleElementActivation();
- }
- };
-
- var removeFileUI = function(filePath) {
- UI.removeFileUI(filePath);
- };
-
- var updateFileUI = function(oldFilePath, newFilePath) {
- UI.updateFileUI(oldFilePath, newFilePath);
- };
-
- var getNextFile = function (filePath) {
- return UI.getNextFile(filePath);
- };
-
- var getPrevFile = function (filePath) {
- return UI.getPrevFile(filePath);
- };
-
- // Vars
- exports.Title = extensionTitle;
- exports.ID = extensionID;
- exports.Type = extensionType;
- exports.Icon = extensionIcon;
- exports.Version = extensionVersion;
- exports.ManifestVersion = extensionManifestVersion;
- exports.License = extensionLicense;
-
- // Methods
- exports.init = init;
- exports.load = load;
- exports.clearSelectedFiles = clearSelectedFiles;
- exports.getNextFile = getNextFile;
- exports.getPrevFile = getPrevFile;
- exports.removeFileUI = removeFileUI;
- exports.updateFileUI = updateFileUI;
-
-});
\ No newline at end of file
+/* Copyright (c) 2013-2015 The Tagspaces Authors. All rights reserved.
+ * Use of this source code is governed by a AGPL3 license that
+ * can be found in the LICENSE file. */
+/* global define, Handlebars, isCordova */
+define(function(require, exports, module) {
+ "use strict";
+
+ var extensionTitle = "Grid";
+ var extensionID = "perspectiveGrid"; // ID should be equal to the directory name where the ext. is located
+ var extensionType = "perspective";
+ var extensionIcon = "fa fa-th";
+ var extensionVersion = "1.0";
+ var extensionManifestVersion = 1;
+ var extensionLicense = "AGPL";
+
+ console.log("Loading " + extensionID);
+
+ var TSCORE = require("tscore");
+
+ var extensionDirectory = TSCORE.Config.getExtensionPath() + "/" + extensionID;
+ var UI;
+
+ var init = function() {
+ console.log("Initializing perspective " + extensionID);
+ require([
+ extensionDirectory + '/perspectiveUI.js',
+ "text!" + extensionDirectory + '/toolbar.html'
+ ], function(extUI, toolbarTPL) {
+ var toolbarTemplate = Handlebars.compile(toolbarTPL);
+ UI = new extUI.ExtUI(extensionID);
+ UI.buildUI(toolbarTemplate);
+ platformTuning();
+ $('#' + extensionID + 'Toolbar [data-i18n]').i18n();
+ });
+ };
+
+ var platformTuning = function() {
+ if (isCordova) {
+ $("#" + extensionID + "IncludeSubDirsButton").hide();
+ } else if (isChrome) {
+ $('#' + extensionID + 'AddFileButton').hide();
+ } else if (isFirefox) {
+ $('#' + extensionID + 'AddFileButton').hide(); // Current impl has 0.5mb limit
+ }
+ };
+
+ var load = function() {
+ console.log("Loading perspective " + extensionID);
+ if (UI === undefined) {
+ window.setTimeout(function() {
+ UI.reInit();
+ }, 1000);
+ } else {
+ UI.reInit();
+ }
+ };
+
+ var clearSelectedFiles = function() {
+ if (UI !== undefined) {
+ UI.clearSelectedFiles();
+ UI.handleElementActivation();
+ }
+ };
+
+ var removeFileUI = function(filePath) {
+ UI.removeFileUI(filePath);
+ };
+
+ var updateFileUI = function(oldFilePath, newFilePath) {
+ UI.updateFileUI(oldFilePath, newFilePath);
+ };
+
+ var getNextFile = function(filePath) {
+ return UI.getNextFile(filePath);
+ };
+
+ var getPrevFile = function(filePath) {
+ return UI.getPrevFile(filePath);
+ };
+
+ // Vars
+ exports.Title = extensionTitle;
+ exports.ID = extensionID;
+ exports.Type = extensionType;
+ exports.Icon = extensionIcon;
+ exports.Version = extensionVersion;
+ exports.ManifestVersion = extensionManifestVersion;
+ exports.License = extensionLicense;
+
+ // Methods
+ exports.init = init;
+ exports.load = load;
+ exports.clearSelectedFiles = clearSelectedFiles;
+ exports.getNextFile = getNextFile;
+ exports.getPrevFile = getPrevFile;
+ exports.removeFileUI = removeFileUI;
+ exports.updateFileUI = updateFileUI;
+
+});
diff --git a/data/ext/perspectiveGrid/perspectiveUI.js b/data/ext/perspectiveGrid/perspectiveUI.js
index f9f93ecd5..0b173ec05 100644
--- a/data/ext/perspectiveGrid/perspectiveUI.js
+++ b/data/ext/perspectiveGrid/perspectiveUI.js
@@ -1,59 +1,68 @@
-/* Copyright (c) 2012-2014 The TagSpaces Authors. All rights reserved.
- * Use of this source code is governed by a AGPL3 license that
+/* Copyright (c) 2012-2015 The TagSpaces Authors. All rights reserved.
+ * Use of this source code is governed by a AGPL3 license that
* can be found in the LICENSE file. */
/* global define, Handlebars, isWin, _ */
define(function(require, exports, module) {
-"use strict";
-
-console.log("Loading UI for perspectiveDefault");
-
- var TSCORE = require("tscore");
-
- var TMB_SIZES = [ "200px", "300px", "100px" ];
-
- var MONTH = [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ];
-
- var PREVIEW_TAGS_CNT = 5;
-
- var supportedFileTypeThumnailing = ['jpg','jpeg','png','gif'];
-
- function ExtUI(extID) {
- this.extensionID = extID;
- this.viewContainer = $("#"+this.extensionID+"Container").empty();
- this.viewToolbar = $("#"+this.extensionID+"Toolbar").empty();
- this.viewFooter = $("#"+this.extensionID+"Footer").empty();
-
- this.currentGrouping = ""; // tagchain, day, month, year
- this.thumbEnabled = false;
- this.currentTmbSize = 0;
- this.searchResults = undefined;
- this.supportedGroupings = [];
-
- this.supportedGroupings.push({"title":"Day","key":"day"});
- this.supportedGroupings.push({"title":"Month","key":"month"});
- this.supportedGroupings.push({"title":"Year","key":"year"});
-
- for(var i=0; i < TSCORE.Config.Settings.tagGroups.length; i++) {
- // Exclude smart tags and calculated tags
- if( TSCORE.Config.Settings.tagGroups[i].key !== "SMR" &&
- TSCORE.Config.Settings.tagGroups[i].key !== "CTG" ) {
- this.supportedGroupings.push({
- "title": TSCORE.Config.Settings.tagGroups[i].title,
- "key": TSCORE.Config.Settings.tagGroups[i].key
- });
- }
- }
+ "use strict";
+
+ console.log("Loading UI for perspectiveDefault");
+
+ var TSCORE = require("tscore");
+
+ var TMB_SIZES = ["200px", "300px", "100px"];
+
+ var MONTH = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
+
+ var PREVIEW_TAGS_CNT = 5;
+
+ var supportedFileTypeThumnailing = ['jpg', 'jpeg', 'png', 'gif'];
+
+ function ExtUI(extID) {
+ this.extensionID = extID;
+ this.viewContainer = $("#" + this.extensionID + "Container").empty();
+ this.viewToolbar = $("#" + this.extensionID + "Toolbar").empty();
+ this.viewFooter = $("#" + this.extensionID + "Footer").empty();
+
+ this.currentGrouping = ""; // tagchain, day, month, year
+ this.thumbEnabled = false;
+ this.currentTmbSize = 0;
+ this.searchResults = undefined;
+ this.supportedGroupings = [];
+
+ this.supportedGroupings.push({
+ "title": "Day",
+ "key": "day"
+ });
+ this.supportedGroupings.push({
+ "title": "Month",
+ "key": "month"
+ });
+ this.supportedGroupings.push({
+ "title": "Year",
+ "key": "year"
+ });
+
+ for (var i = 0; i < TSCORE.Config.Settings.tagGroups.length; i++) {
+ // Exclude smart tags and calculated tags
+ if (TSCORE.Config.Settings.tagGroups[i].key !== "SMR" &&
+ TSCORE.Config.Settings.tagGroups[i].key !== "CTG") {
+ this.supportedGroupings.push({
+ "title": TSCORE.Config.Settings.tagGroups[i].title,
+ "key": TSCORE.Config.Settings.tagGroups[i].key
+ });
+ }
}
-
- var fileTileTmpl = Handlebars.compile('<li title="{{filepath}}" filepath="{{filepath}}" class="fileTile">\
+ }
+
+ var fileTileTmpl = Handlebars.compile('<li title="{{filepath}}" filepath="{{filepath}}" class="fileTile">\
<p class="titleInFileTile">{{title}}</p><span class="tagsInFileTile">\
{{#each tags}}\
<button class="btn btn-sm tagButton fileTagsTile" tag="{{tag}}" filepath="{{filepath}}" style="{{style}}">{{tag}} <span class="caret"></span></button>\
{{/each}}\
</span><span class="fileExtTile">{{fileext}}</span>\
<button class="btn btn-link fileTileSelector" filepath="{{filepath}}"><i class="fa {{selected}} fa-lg"></i></button></p></li>');
-
- var fileTileTmbTmpl = Handlebars.compile('<li title="{{filepath}}" filepath="{{filepath}}" class="fileTile">\
+
+ var fileTileTmbTmpl = Handlebars.compile('<li title="{{filepath}}" filepath="{{filepath}}" class="fileTile">\
<span><img class="thumbImgTile" filepath="{{tmbpath}}" style="max-width: 200px; max-height: 200px;" src=""></span>\
<p class="titleInFileTile">{{title}}</p><span class="tagsInFileTile">\
{{#each tags}}\
@@ -61,683 +70,683 @@ console.log("Loading UI for perspectiveDefault");
{{/each}}\
</span><span class="fileExtTile">{{fileext}}</span>\
<button class="btn btn-link fileTileSelector" filepath="{{filepath}}"><i class="fa {{selected}} fa-lg"></i></button></p></li>');
-
- ExtUI.prototype.createFileTile = function(title, filePath, fileExt, fileTags, isSelected) {
- //TODO minimize platform specific calls
- var tmbPath = undefined;
- if(isCordova || isWeb) {
- tmbPath = filePath;
- } else {
- tmbPath = "file:///"+filePath;
- }
-
- var context = {
- filepath: filePath,
- tmbpath: tmbPath,
- fileext: fileExt,
- title: title,
- tags : [],
- selected: isSelected?"fa-check-square-o":"fa-square-o"
- };
-
- if(fileTags.length > 0) {
- var tagString = ""+fileTags ;
- var tags = tagString.split(",");
-
- var tagCounter = 0;
- if (tags.length > PREVIEW_TAGS_CNT) {
- tagCounter = PREVIEW_TAGS_CNT+1;
- tags[PREVIEW_TAGS_CNT] = "...";
- } else {
- tagCounter = tags.length;
- }
- for (var i=0; i < tagCounter; i++) {
- context.tags.push({tag: tags[i], filepath: filePath, style: TSCORE.generateTagStyle(TSCORE.Config.findTag(tags[i]))});
- }
- }
-
- if(supportedFileTypeThumnailing.indexOf(fileExt) >= 0) {
- return fileTileTmbTmpl(context);
- } else {
- return fileTileTmpl(context);
- }
- };
-
- ExtUI.prototype.initFileGroupingMenu = function () {
- var self = this;
-
- var suggMenu = $("#"+self.extensionID+"GroupingMenu");
-
- suggMenu.append($('<li>').append($('<a>', {
- title: "Ungroup all elementes",
- text: " Ungroup"
- })
- .prepend("<i class='fa fa-times-circle'></i>")
- .click(function() {
- $("#"+self.extensionID+"GroupingButton")
- .text(" Group ")
- .prepend( "<i class='fa fa-group' />" )
- .append( "<span class='caret'></span>" );
- self.switchGrouping("");
- })
- ));
- suggMenu.append('<li class="divider"></li>');
-
- // Adding context menu entries according to the taggroups
- for (var i=0; i < self.supportedGroupings.length; i++) {
- suggMenu.append($('<li>').append($('<a>', {
- text: " Group by "+self.supportedGroupings[i].title,
- key: self.supportedGroupings[i].key,
- group: self.supportedGroupings[i].title
- })
- .prepend( "<i class='fa fa-group fa-fw' />" )
- .click(function() {
- $("#"+self.extensionID+"GroupingButton")
- .attr("title"," Grouped by "+$(this).attr("group")+" ")
- .text(" "+$(this).attr("group")+" ")
- .prepend( "<i class='fa fa-group fa-fw' />" )
- .append( "<span class='caret'></span>" );
- self.switchGrouping($(this).attr("key"));
- })
- ));
- }
- };
-
- ExtUI.prototype.buildUI = function(toolbarTemplate) {
- console.log("Init UI module");
-
- var self = this;
-
- var context = {
- id: this.extensionID
- };
- this.viewToolbar.append(toolbarTemplate(context));
-
- $("#"+this.extensionID+"ToogleSelectAll")
- .click(function() {
- var checkIcon = $(this).find("i");
- if(checkIcon.hasClass("fa-square-o")) {
- TSCORE.selectedFiles = [];
- $(self.viewContainer).find('.fileTileSelector').each(function(){
- $(this).parent().parent().addClass("ui-selected");
- $(this).find("i").addClass("fa-check-square").removeClass("fa-square-o");
- TSCORE.selectedFiles.push($(this).attr("filepath"));
- });
- } else {
- TSCORE.PerspectiveManager.clearSelectedFiles();
- }
- self.handleElementActivation();
- checkIcon.toggleClass("fa-check-square");
- checkIcon.toggleClass("fa-square-o");
- });
-
- $("#"+this.extensionID+"CreateFileButton").on("click", function () {
- TSCORE.showFileCreateDialog();
- });
- $("#"+this.extensionID+"CreateDirectoryButton").on("click", function () {
- TSCORE.showCreateDirectoryDialog(TSCORE.currentPath)
- });
+ ExtUI.prototype.createFileTile = function(title, filePath, fileExt, fileTags, isSelected) {
+ //TODO minimize platform specific calls
+ var tmbPath;
+ if (isCordova || isWeb) {
+ tmbPath = filePath;
+ } else {
+ tmbPath = "file:///" + filePath;
+ }
- $("#"+this.extensionID+"CreateHTMLFileButton").on("click", function () {
- TSCORE.createHTMLFile();
- });
+ var context = {
+ filepath: filePath,
+ tmbpath: tmbPath,
+ fileext: fileExt,
+ title: title,
+ tags: [],
+ selected: isSelected ? "fa-check-square-o" : "fa-square-o"
+ };
- $("#"+this.extensionID+"CreateMDFileButton").on("click", function () {
- TSCORE.createMDFile();
+ if (fileTags.length > 0) {
+ var tagString = "" + fileTags;
+ var tags = tagString.split(",");
+
+ var tagCounter = 0;
+ if (tags.length > PREVIEW_TAGS_CNT) {
+ tagCounter = PREVIEW_TAGS_CNT + 1;
+ tags[PREVIEW_TAGS_CNT] = "...";
+ } else {
+ tagCounter = tags.length;
+ }
+ for (var i = 0; i < tagCounter; i++) {
+ context.tags.push({
+ tag: tags[i],
+ filepath: filePath,
+ style: TSCORE.generateTagStyle(TSCORE.Config.findTag(tags[i]))
});
+ }
+ }
- $("#"+this.extensionID+"CreateTXTFileButton").on("click", function () {
- TSCORE.createTXTFile();
- });
-
- $("#"+this.extensionID+"IncludeSubDirsButton")
- .click(function() {
- TSCORE.IO.createDirectoryIndex(TSCORE.currentPath);
- });
-
- $("#"+this.extensionID+"TagButton")
- .click(function() {
- TSCORE.showAddTagsDialog();
- });
-
- $("#"+this.extensionID+"ShowTmbButton")
- .click(function() {
- self.toggleThumbnails();
- });
+ if (supportedFileTypeThumnailing.indexOf(fileExt) >= 0) {
+ return fileTileTmbTmpl(context);
+ } else {
+ return fileTileTmpl(context);
+ }
+ };
+
+ ExtUI.prototype.initFileGroupingMenu = function() {
+ var self = this;
+
+ var suggMenu = $("#" + self.extensionID + "GroupingMenu");
+
+ suggMenu.append($('<li>').append($('<a>', {
+ title: "Ungroup all elementes",
+ text: " Ungroup"
+ })
+ .prepend("<i class='fa fa-times-circle'></i>")
+ .click(function() {
+ $("#" + self.extensionID + "GroupingButton")
+ .text(" Group ")
+ .prepend("<i class='fa fa-group' />")
+ .append("<span class='caret'></span>");
+ self.switchGrouping("");
+ })
+ ));
+ suggMenu.append('<li class="divider"></li>');
+
+ // Adding context menu entries according to the taggroups
+ for (var i = 0; i < self.supportedGroupings.length; i++) {
+ suggMenu.append($('<li>').append($('<a>', {
+ text: " Group by " + self.supportedGroupings[i].title,
+ key: self.supportedGroupings[i].key,
+ group: self.supportedGroupings[i].title
+ })
+ .prepend("<i class='fa fa-group fa-fw' />")
+ .click(function() {
+ $("#" + self.extensionID + "GroupingButton")
+ .attr("title", " Grouped by " + $(this).attr("group") + " ")
+ .text(" " + $(this).attr("group") + " ")
+ .prepend("<i class='fa fa-group fa-fw' />")
+ .append("<span class='caret'></span>");
+ self.switchGrouping($(this).attr("key"));
+ }) // jshint ignore:line
+ ));
+ }
+ };
- $("#"+this.extensionID+"IncreaseThumbsButton")
- .click(function() {
- self.switchThumbnailSize();
- })
- .prop('disabled', true);
+ ExtUI.prototype.buildUI = function(toolbarTemplate) {
+ console.log("Init UI module");
- $("#"+this.extensionID+"AddFileButton").on("click", function () {
- $("#addFileInput").click();
- });
-
- // Init Tag Context Menus
- this.viewContainer.on("contextmenu click", ".tagButton", function () {
- TSCORE.hideAllDropDownMenus();
- self.selectFile($(this).attr("filepath"));
- TSCORE.openTagMenu(this, $(this).attr("tag"), $(this).attr("filepath"));
- TSCORE.showContextMenu("#tagMenu", $(this));
- return false;
- });
-
- this.initFileGroupingMenu();
-
- // Disable all buttons
- this.viewToolbar.find(".btn").prop('disabled', true);
- };
+ var self = this;
- ExtUI.prototype.switchThumbnailSize = function() {
- this.currentTmbSize = this.currentTmbSize + 1;
-
- if(this.currentTmbSize >= TMB_SIZES.length) { this.currentTmbSize = 0; }
-
- $('.thumbImgTile').css({"max-width":TMB_SIZES[this.currentTmbSize], "max-height":TMB_SIZES[this.currentTmbSize] });
- };
-
- ExtUI.prototype.enableThumbnails = function() {
- $("#"+this.extensionID+"IncreaseThumbsButton" ).prop('disabled', false);
- $("#"+this.extensionID+"Container .thumbImgTile").each(function() {
- generateThumbnail($(this).attr('filepath'), $(this));
- $(this).attr('style', "");
- });
- $('.thumbImgTile').css({"max-width":TMB_SIZES[this.currentTmbSize], "max-height":TMB_SIZES[this.currentTmbSize] });
+ var context = {
+ id: this.extensionID
};
-
- function generateThumbnail(imgURL, imgElement) {
- var maxSize = 200;
- var canvas = document.createElement("canvas");
- var ctx = canvas.getContext("2d");
- var img = new Image();
- img.onload = function(){
- if(img.width >= img.height) {
- canvas.width = maxSize;
- canvas.height = (maxSize*img.height)/img.width;
- } else {
- canvas.height = maxSize;
- canvas.width = (maxSize*img.width)/img.height;
- }
- ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
- var dataURL = canvas.toDataURL("image/png");
- imgElement.attr('src',dataURL);
- //console.log("<-->"+dataURL);
- img = null;
- canvas = null;
- //canvas.parentNode.removeChild(canvas)
- };
- img.src = imgURL;
- }
-
- ExtUI.prototype.disableThumbnails = function() {
- //this.currentTmbSize = 0;
- $("#"+this.extensionID+"IncreaseThumbsButton" ).prop('disabled', true);
- $("#"+this.extensionID+"Container .thumbImgTile").each(function() {
- $(this).attr('style', "width: 0px; height: 0px; border: 0px");
- $(this).attr('src',"");
- });
- };
-
- ExtUI.prototype.refreshThumbnails = function() {
- if(this.thumbEnabled) {
- this.enableThumbnails();
+ this.viewToolbar.append(toolbarTemplate(context));
+
+ $("#" + this.extensionID + "ToogleSelectAll")
+ .click(function() {
+ var checkIcon = $(this).find("i");
+ if (checkIcon.hasClass("fa-square-o")) {
+ TSCORE.selectedFiles = [];
+ $(self.viewContainer).find('.fileTileSelector').each(function() {
+ $(this).parent().parent().addClass("ui-selected");
+ $(this).find("i").addClass("fa-check-square").removeClass("fa-square-o");
+ TSCORE.selectedFiles.push($(this).attr("filepath"));
+ });
} else {
- this.disableThumbnails();
+ TSCORE.PerspectiveManager.clearSelectedFiles();
}
- };
-
- ExtUI.prototype.toggleThumbnails = function() {
- this.thumbEnabled = !this.thumbEnabled;
- this.refreshThumbnails();
- };
-
- ExtUI.prototype.switchGrouping = function(grouping) {
- this.currentGrouping = grouping;
- //TSCORE.startTime = new Date().getTime();
- this.reInit();
- };
+ self.handleElementActivation();
+ checkIcon.toggleClass("fa-check-square");
+ checkIcon.toggleClass("fa-square-o");
+ });
+
+ $("#" + this.extensionID + "CreateFileButton").on("click", function() {
+ TSCORE.showFileCreateDialog();
+ });
+
+ $("#" + this.extensionID + "CreateDirectoryButton").on("click", function() {
+ TSCORE.showCreateDirectoryDialog(TSCORE.currentPath);
+ });
+
+ $("#" + this.extensionID + "CreateHTMLFileButton").on("click", function() {
+ TSCORE.createHTMLFile();
+ });
+
+ $("#" + this.extensionID + "CreateMDFileButton").on("click", function() {
+ TSCORE.createMDFile();
+ });
+
+ $("#" + this.extensionID + "CreateTXTFileButton").on("click", function() {
+ TSCORE.createTXTFile();
+ });
+
+ $("#" + this.extensionID + "IncludeSubDirsButton")
+ .click(function() {
+ TSCORE.IO.createDirectoryIndex(TSCORE.currentPath);
+ });
+
+ $("#" + this.extensionID + "TagButton")
+ .click(function() {
+ TSCORE.showAddTagsDialog();
+ });
+
+ $("#" + this.extensionID + "ShowTmbButton")
+ .click(function() {
+ self.toggleThumbnails();
+ });
+
+ $("#" + this.extensionID + "IncreaseThumbsButton")
+ .click(function() {
+ self.switchThumbnailSize();
+ })
+ .prop('disabled', true);
+
+ $("#" + this.extensionID + "AddFileButton").on("click", function() {
+ $("#addFileInput").click();
+ });
+
+ // Init Tag Context Menus
+ this.viewContainer.on("contextmenu click", ".tagButton", function() {
+ TSCORE.hideAllDropDownMenus();
+ self.selectFile($(this).attr("filepath"));
+ TSCORE.openTagMenu(this, $(this).attr("tag"), $(this).attr("filepath"));
+ TSCORE.showContextMenu("#tagMenu", $(this));
+ return false;
+ });
+
+ this.initFileGroupingMenu();
+
+ // Disable all buttons
+ this.viewToolbar.find(".btn").prop('disabled', true);
+ };
+
+ ExtUI.prototype.switchThumbnailSize = function() {
+ this.currentTmbSize = this.currentTmbSize + 1;
+
+ if (this.currentTmbSize >= TMB_SIZES.length) {
+ this.currentTmbSize = 0;
+ }
- ExtUI.prototype.calculateGroupTitle = function(rawSource) {
- var groupingTitle = "No Grouping";
- var self = this;
- var tmpDate;
- switch (this.currentGrouping){
- case "day": {
- tmpDate = new Date(rawSource[TSCORE.fileListFILELMDT]);
- tmpDate.setHours(0,0,0,0);
- groupingTitle = TSCORE.TagUtils.formatDateTime(tmpDate, false);
- break;
- }
- case "month": {
- tmpDate = new Date(rawSource[TSCORE.fileListFILELMDT]);
- tmpDate.setHours(0,0,0,0);
- tmpDate.setDate(1);
- groupingTitle = MONTH[tmpDate.getMonth()] +", "+tmpDate.getFullYear();
- break;
- }
- case "year": {
- tmpDate = new Date(rawSource[TSCORE.fileListFILELMDT]);
- tmpDate.setHours(0,0,0,0);
- tmpDate.setDate(1);
- tmpDate.setMonth(1);
- groupingTitle = tmpDate.getFullYear();
- break;
- }
- default : {
- for (var i=0; i < TSCORE.Config.Settings.tagGroups.length; i++) {
- if(TSCORE.Config.Settings.tagGroups[i].key === self.currentGrouping) {
- var tagsInGroup = _.pluck(TSCORE.Config.Settings.tagGroups[i].children, "title");
- var matchedTags = _.intersection(
- rawSource[TSCORE.fileListTAGS],
- tagsInGroup
- );
- groupingTitle = "not grouped";
- if(matchedTags.length > 0) {
- groupingTitle = TSCORE.Config.Settings.tagGroups[i].title+" - "+matchedTags[0];
- }
- break;
- }
- }
- }
- }
- return groupingTitle;
+ $('.thumbImgTile').css({
+ "max-width": TMB_SIZES[this.currentTmbSize],
+ "max-height": TMB_SIZES[this.currentTmbSize]
+ });
+ };
+
+ ExtUI.prototype.enableThumbnails = function() {
+ $("#" + this.extensionID + "IncreaseThumbsButton").prop('disabled', false);
+ $("#" + this.extensionID + "Container .thumbImgTile").each(function() {
+ generateThumbnail($(this).attr('filepath'), $(this));
+ $(this).attr('style', "");
+ });
+ $('.thumbImgTile').css({
+ "max-width": TMB_SIZES[this.currentTmbSize],
+ "max-height": TMB_SIZES[this.currentTmbSize]
+ });
+ };
+
+ function generateThumbnail(imgURL, imgElement) {
+ var maxSize = 200;
+ var canvas = document.createElement("canvas");
+ var ctx = canvas.getContext("2d");
+ var img = new Image();
+ img.onload = function() {
+ if (img.width >= img.height) {
+ canvas.width = maxSize;
+ canvas.height = (maxSize * img.height) / img.width;
+ } else {
+ canvas.height = maxSize;
+ canvas.width = (maxSize * img.width) / img.height;
+ }
+ ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
+ var dataURL = canvas.toDataURL("image/png");
+ imgElement.attr('src', dataURL);
+ //console.log("<-->"+dataURL);
+ img = null;
+ canvas = null;
+ //canvas.parentNode.removeChild(canvas)
};
-
- // Helper function for organizing the files in data buckets
- ExtUI.prototype.calculateGrouping = function(data) {
- var self = this;
- switch (this.currentGrouping){
- case "day": {
- data = _.groupBy( data, function(value){
- var tmpDate = new Date(value[TSCORE.fileListFILELMDT]);
- tmpDate.setHours(0,0,0,0);
- return tmpDate.getTime();
- });
- break;
- }
- case "month": {
- data = _.groupBy( data, function(value){
- var tmpDate = new Date(value[TSCORE.fileListFILELMDT]);
- tmpDate.setHours(0,0,0,0);
- tmpDate.setDate(1);
- return tmpDate.getTime();
- });
- break;
+ img.src = imgURL;
+ }
+
+ ExtUI.prototype.disableThumbnails = function() {
+ //this.currentTmbSize = 0;
+ $("#" + this.extensionID + "IncreaseThumbsButton").prop('disabled', true);
+ $("#" + this.extensionID + "Container .thumbImgTile").each(function() {
+ $(this).attr('style', "width: 0px; height: 0px; border: 0px");
+ $(this).attr('src', "");
+ });
+ };
+
+ ExtUI.prototype.refreshThumbnails = function() {
+ if (this.thumbEnabled) {
+ this.enableThumbnails();
+ } else {
+ this.disableThumbnails();
+ }
+ };
+
+ ExtUI.prototype.toggleThumbnails = function() {
+ this.thumbEnabled = !this.thumbEnabled;
+ this.refreshThumbnails();
+ };
+
+ ExtUI.prototype.switchGrouping = function(grouping) {
+ this.currentGrouping = grouping;
+ //TSCORE.startTime = new Date().getTime();
+ this.reInit();
+ };
+
+ ExtUI.prototype.calculateGroupTitle = function(rawSource) {
+ var groupingTitle = "No Grouping";
+ var self = this;
+ var tmpDate;
+ switch (this.currentGrouping) {
+ case "day":
+ tmpDate = new Date(rawSource[TSCORE.fileListFILELMDT]);
+ tmpDate.setHours(0, 0, 0, 0);
+ groupingTitle = TSCORE.TagUtils.formatDateTime(tmpDate, false);
+ break;
+ case "month":
+ tmpDate = new Date(rawSource[TSCORE.fileListFILELMDT]);
+ tmpDate.setHours(0, 0, 0, 0);
+ tmpDate.setDate(1);
+ groupingTitle = MONTH[tmpDate.getMonth()] + ", " + tmpDate.getFullYear();
+ break;
+ case "year":
+ tmpDate = new Date(rawSource[TSCORE.fileListFILELMDT]);
+ tmpDate.setHours(0, 0, 0, 0);
+ tmpDate.setDate(1);
+ tmpDate.setMonth(1);
+ groupingTitle = tmpDate.getFullYear();
+ break;
+ default:
+ for (var i = 0; i < TSCORE.Config.Settings.tagGroups.length; i++) {
+ if (TSCORE.Config.Settings.tagGroups[i].key === self.currentGrouping) {
+ var tagsInGroup = _.pluck(TSCORE.Config.Settings.tagGroups[i].children, "title");
+ var matchedTags = _.intersection(
+ rawSource[TSCORE.fileListTAGS],
+ tagsInGroup
+ );
+ groupingTitle = "not grouped";
+ if (matchedTags.length > 0) {
+ groupingTitle = TSCORE.Config.Settings.tagGroups[i].title + " - " + matchedTags[0];
}
- case "year": {
- data = _.groupBy( data, function(value){
- var tmpDate = new Date(value[TSCORE.fileListFILELMDT]);
- tmpDate.setHours(0,0,0,0);
- tmpDate.setDate(1);
- tmpDate.setMonth(1);
- return tmpDate.getTime();
- });
- break;
- }
- default : {
- var grouped = false;
- this.supportedGroupings.forEach(function(grouping) {
- if(grouping.key === self.currentGrouping) {
- data = _.groupBy( data, function(value) {
- var tagGroup = TSCORE.Config.getTagGroupData(grouping.key);
- for (var i=0; i < tagGroup.children.length; i++) {
- for (var j=0; j < value[TSCORE.fileListTAGS].length; j++) {
- if (tagGroup.children[i].title === value[TSCORE.fileListTAGS][j]) {
- return tagGroup.children[i].title;
- }
- }
- }
- });
- grouped = true;
- }
- });
- if(!grouped) {
- data = _.groupBy( data, function(){
- return true;
- });
+ break;
+ }
+ }
+ }
+ return groupingTitle;
+ };
+
+ // Helper function for organizing the files in data buckets
+ ExtUI.prototype.calculateGrouping = function(data) {
+ var self = this;
+ switch (this.currentGrouping) {
+ case "day":
+ data = _.groupBy(data, function(value) {
+ var tmpDate = new Date(value[TSCORE.fileListFILELMDT]);
+ tmpDate.setHours(0, 0, 0, 0);
+ return tmpDate.getTime();
+ });
+ break;
+ case "month":
+ data = _.groupBy(data, function(value) {
+ var tmpDate = new Date(value[TSCORE.fileListFILELMDT]);
+ tmpDate.setHours(0, 0, 0, 0);
+ tmpDate.setDate(1);
+ return tmpDate.getTime();
+ });
+ break;
+ case "year":
+ data = _.groupBy(data, function(value) {
+ var tmpDate = new Date(value[TSCORE.fileListFILELMDT]);
+ tmpDate.setHours(0, 0, 0, 0);
+ tmpDate.setDate(1);
+ tmpDate.setMonth(1);
+ return tmpDate.getTime();
+ });
+ break;
+ default:
+ var grouped = false;
+ this.supportedGroupings.forEach(function(grouping) {
+ if (grouping.key === self.currentGrouping) {
+ data = _.groupBy(data, function(value) {
+ var tagGroup = TSCORE.Config.getTagGroupData(grouping.key);
+ for (var i = 0; i < tagGroup.children.length; i++) {
+ for (var j = 0; j < value[TSCORE.fileListTAGS].length; j++) {
+ if (tagGroup.children[i].title === value[TSCORE.fileListTAGS][j]) {
+ return tagGroup.children[i].title;
+ }
}
- break;
- }
+ }
+ });
+ grouped = true;
+ }
+ });
+ if (!grouped) {
+ data = _.groupBy(data, function() {
+ return true;
+ });
}
-
- // Sort groups by date
- data = _.sortBy(data, function(value) {
- var tmpDate = new Date(value[0][TSCORE.fileListFILELMDT]);
- return -tmpDate.getTime();
- });
-
- return data;
- };
+ break;
+ }
- ExtUI.prototype.reInit = function() {
-
- // Clear old data
- this.viewContainer.children().remove();
- this.viewFooter.children().remove();
-
- this.viewContainer.addClass("accordion");
- $( this.extensionID+"IncludeSubDirsButton" ).prop('disabled', false);
-
- var self = this;
-
- // Load new filtered data
- this.searchResults = TSCORE.Search.searchData(TSCORE.fileList, TSCORE.Search.nextQuery);
-
- var i=0;
- _.each(self.calculateGrouping(this.searchResults), function (value) {
- i++;
-
- var groupingTitle = self.calculateGroupTitle(value[0]);
-
- self.viewContainer.append($("<div>", {
- "class": "accordion-group disableTextSelection",
- "style": "width: 100%; border: 0px #aaa solid;"
- })
- .append($("<div>", {
- "class": "accordion-heading btn-group",
- "style": "width:100%; margin: 0px; border-bottom: solid 1px #eee; background-color: #ddd;"
+ // Sort groups by date
+ data = _.sortBy(data, function(value) {
+ var tmpDate = new Date(value[0][TSCORE.fileListFILELMDT]);
+ return -tmpDate.getTime();
+ });
+
+ return data;
+ };
+
+ ExtUI.prototype.reInit = function() {
+
+ // Clear old data
+ this.viewContainer.children().remove();
+ this.viewFooter.children().remove();
+
+ this.viewContainer.addClass("accordion");
+ $(this.extensionID + "IncludeSubDirsButton").prop('disabled', false);
+
+ var self = this;
+
+ // Load new filtered data
+ this.searchResults = TSCORE.Search.searchData(TSCORE.fileList, TSCORE.Search.nextQuery);
+
+ var i = 0;
+ _.each(self.calculateGrouping(this.searchResults), function(value) {
+ i++;
+
+ var groupingTitle = self.calculateGroupTitle(value[0]);
+
+ self.viewContainer.append($("<div>", {
+ "class": "accordion-group disableTextSelection",
+ "style": "width: 100%; border: 0px #aaa solid;"
+ })
+ .append($("<div>", {
+ "class": "accordion-heading btn-group",
+ "style": "width:100%; margin: 0px; border-bottom: solid 1px #eee; background-color: #ddd;"
+ })
+
+ .append($("<button>", { // Grouped content toggle button
+ "class": "btn btn-link groupTitle",
+ "data-toggle": "collapse",
+ "data-target": "#" + self.extensionID + "sortingButtons" + i,
+ "title": "Toggle Group"
})
-
- .append($("<button>", { // Grouped content toggle button
- "class": "btn btn-link groupTitle",
- "data-toggle": "collapse",
- "data-target": "#"+self.extensionID+"sortingButtons"+i,
- "title": "Toggle Group"
- }
- )
- .html("<i class='fa fa-minus-square' /i>&nbsp;")
- .click(function() {
- $(this).find('i').toggleClass("fa-minus-square").toggleClass("fa-plus-square");
- })
- )// End date toggle button
-
- .append($("<span>", {
- "class": "btn btn-link groupTitle",
- // "data-toggle": "collapse",
- // "data-target": "#"+self.extensionID+"sortingButtons"+i,
- "style": "margin-left: 0px; padding-left: 0px;",
- "text": groupingTitle
- })
- )
-
- ) // end heading
-
- .append($("<div>", {
- "class": "accordion-body collapse in",
- "id": self.extensionID+"sortingButtons"+i,
- "style": "margin: 0px 0px 0px 3px; border: 0px;"
- })
- .append($("<div>", {
- "class": "accordion-inner",
- "id": self.extensionID+"sortingButtonsContent"+i,
- "style": "padding: 2px; border: 0px;"
+ .html("<i class='fa fa-minus-square' /i>&nbsp;")
+ .click(function() {
+ $(this).find('i').toggleClass("fa-minus-square").toggleClass("fa-plus-square");
})
- ) // end accordion-inner
- ) // end accordion button
-
- ); // end group
-
- var groupedContent = $("<ol>", {
- style: "overflow: visible;",
- class: "selectableFiles"
- }).appendTo( "#"+self.extensionID+"sortingButtonsContent"+i );
-
- // Sort the files in group by name
- value = _.sortBy(value, function(entry) {
- return entry[TSCORE.fileListFILENAME];
- });
-
- // Iterating over the files in group
- for(var j=0; j < value.length; j++) {
- groupedContent.append(self.createFileTile(
- value[j][TSCORE.fileListTITLE],
- value[j][TSCORE.fileListFILEPATH],
- value[j][TSCORE.fileListFILEEXT],
- value[j][TSCORE.fileListTAGS]
- ));
- }
-
- // Adding event listeners
- groupedContent.find(".fileTile").each(function() {
- self.assingFileTileHandlers($(this));
- });
-
- // Disabling the file tile selection
- /* $( "#"+self.extensionID+"sortingButtonsContent"+i ).selectable({
- start: function() {
- TSCORE.PerspectiveManager.clearSelectedFiles();
- },
- stop: function() {
- TSCORE.selectedFiles = [];
- $( ".ui-selected", this ).each(function() {
- TSCORE.selectedFiles.push($(this).attr("filepath"));
- });
- console.log("Selected files: "+TSCORE.selectedFiles);
- self.handleElementActivation();
- }
- }); */
- });
-
- // Enable all buttons
- this.viewToolbar.find(".btn").prop('disabled', false);
- // Disable certain buttons again
- $("#"+this.extensionID+"IncreaseThumbsButton" ).prop('disabled', true);
- $("#"+this.extensionID+"TagButton" ).prop('disabled', true);
-
- this.refreshThumbnails();
-
- if(this.searchResults.length !== undefined) {
- if(TSCORE.Search.nextQuery.length > 0) {
- $("#statusBar").text(this.searchResults.length+" files found for '"+TSCORE.Search.nextQuery+"'");
- } else {
- $("#statusBar").text(this.searchResults.length+" files found");
- }
- }
-
- TSCORE.hideLoadingAnimation();
- };
+ ) // End date toggle button
+
+ .append($("<span>", {
+ "class": "btn btn-link groupTitle",
+ // "data-toggle": "collapse",
+ // "data-target": "#"+self.extensionID+"sortingButtons"+i,
+ "style": "margin-left: 0px; padding-left: 0px;",
+ "text": groupingTitle
+ }))
+
+ ) // end heading
+
+ .append($("<div>", {
+ "class": "accordion-body collapse in",
+ "id": self.extensionID + "sortingButtons" + i,
+ "style": "margin: 0px 0px 0px 3px; border: 0px;"
+ })
+ .append($("<div>", {
+ "class": "accordion-inner",
+ "id": self.extensionID + "sortingButtonsContent" + i,
+ "style": "padding: 2px; border: 0px;"
+ })) // end accordion-inner
+ ) // end accordion button
+
+ ); // end group
+
+ var groupedContent = $("<ol>", {
+ style: "overflow: visible;",
+ class: "selectableFiles"
+ }).appendTo("#" + self.extensionID + "sortingButtonsContent" + i);
+
+ // Sort the files in group by name
+ value = _.sortBy(value, function(entry) {
+ return entry[TSCORE.fileListFILENAME];
+ });
+
+ // Iterating over the files in group
+ for (var j = 0; j < value.length; j++) {
+ groupedContent.append(self.createFileTile(
+ value[j][TSCORE.fileListTITLE],
+ value[j][TSCORE.fileListFILEPATH],
+ value[j][TSCORE.fileListFILEEXT],
+ value[j][TSCORE.fileListTAGS]
+ ));
+ }
+
+ // Adding event listeners
+ groupedContent.find(".fileTile").each(function() {
+ self.assingFileTileHandlers($(this));
+ });
+
+ // Disabling the file tile selection
+ /* $( "#"+self.extensionID+"sortingButtonsContent"+i ).selectable({
+ start: function() {
+ TSCORE.PerspectiveManager.clearSelectedFiles();
+ },
+ stop: function() {
+ TSCORE.selectedFiles = [];
+ $( ".ui-selected", this ).each(function() {
+ TSCORE.selectedFiles.push($(this).attr("filepath"));
+ });
+ console.log("Selected files: "+TSCORE.selectedFiles);
+ self.handleElementActivation();
+ }
+ }); */
+ });
+
+ // Enable all buttons
+ this.viewToolbar.find(".btn").prop('disabled', false);
+ // Disable certain buttons again
+ $("#" + this.extensionID + "IncreaseThumbsButton").prop('disabled', true);
+ $("#" + this.extensionID + "TagButton").prop('disabled', true);
+
+ this.refreshThumbnails();
+
+ if (this.searchResults.length !== undefined) {
+ if (TSCORE.Search.nextQuery.length > 0) {
+ $("#statusBar").text(this.searchResults.length + " files found for '" + TSCORE.Search.nextQuery + "'");
+ } else {
+ $("#statusBar").text(this.searchResults.length + " files found");
+ }
+ }
- ExtUI.prototype.assingFileTileHandlers = function($fileTile) {
- var filePath = $fileTile.attr("filepath");
- var self = this;
-
- $fileTile
- //.dblclick(function() {
- // TSCORE.FileOpener.openFile(filePath);
- // self.selectFile(filePath);
- //})
- .hammer().on("doubletap", function() {
- TSCORE.FileOpener.openFile(filePath);
- self.selectFile(filePath);
- })
- .click(function() {
- self.selectFile(filePath);
- })
- .draggable({
- "cancel": false,
- "appendTo": "body",
- "helper": "clone",
- "opacity": "0.5",
- "revert": true,
- "start": function() {
- self.selectFile(filePath);
- }
- })
- .droppable({
- accept: ".tagButton",
- hoverClass: "activeRow",
- drop: function( event, ui ) {
- var tagName = TSCORE.selectedTag; //ui.draggable.attr("tag");
- var targetFilePath = filePath;// $(this).attr("filepath");;
-
- // preventing self drag of tags
- var targetTags = TSCORE.TagUtils.extractTags(targetFilePath);
- for (var i = 0; i < targetTags.length; i++) {
- if (targetTags[i] === tagName) {
- return true;
- }
- }
-
- console.log("Tagging file: "+tagName+" to "+targetFilePath);
- $(this).toggleClass("ui-selected");
- TSCORE.PerspectiveManager.clearSelectedFiles();
- TSCORE.selectedFiles.push(targetFilePath);
- TSCORE.TagUtils.addTag(TSCORE.selectedFiles, [tagName]);
- self.handleElementActivation();
-
- //$(ui.helper).remove();
- }
- })
- .find(".fileTileSelector").click( function(e) {
- e.preventDefault();
- var $stateTag = $(this).find("i");
- if($stateTag.hasClass("fa-square-o")) {
- $stateTag.removeClass("fa-square-o").addClass("fa fa-check-square");
- $(this).parent().parent().addClass("ui-selected");
- TSCORE.selectedFiles.push(filePath);
- } else {
- $stateTag.removeClass("fa-check-square").addClass("fa-square-o");
- $(this).parent().parent().removeClass("ui-selected");
- TSCORE.selectedFiles.splice(TSCORE.selectedFiles.indexOf(filePath), 1);
- }
- self.handleElementActivation();
- return false;
- })
- .find(".fileTagsTile").click( function() {
- self.selectFile($(this).attr("filepath"));
- TSCORE.openTagMenu(this, $(this).attr("tag"), $(this).attr("filepath"));
- })
- };
-
-
- ExtUI.prototype.clearSelectedFiles = function() {
- TSCORE.selectedFiles = [];
- $("#"+this.extensionID+"Container").find(".ui-selected")
- .removeClass("ui-selected");
- $("#"+this.extensionID+"Container").find(".fileTileSelector").find("i")
- .removeClass("fa-check-square")
- .addClass("fa-square-o");
-
- // Reseting select all button
- //$("#"+this.extensionID+"ToogleSelectAll").find("i").removeClass("fa-check-square").addClass("fa-square-o");
- };
-
- ExtUI.prototype.selectFile = function(filePath) {
- TSCORE.PerspectiveManager.clearSelectedFiles();
- $(this.viewContainer).find('.fileTileSelector').each(function(){
- if($(this).attr("filepath") === filePath) {
- $(this).parent().parent().toggleClass("ui-selected");
- $(this).find("i").toggleClass("fa-check-square").toggleClass("fa-square-o");
- TSCORE.selectedFiles.push($(this).attr("filepath"));
+ TSCORE.hideLoadingAnimation();
+ };
+
+ ExtUI.prototype.assingFileTileHandlers = function($fileTile) {
+ var filePath = $fileTile.attr("filepath");
+ var self = this;
+
+ $fileTile
+ //.dblclick(function() {
+ // TSCORE.FileOpener.openFile(filePath);
+ // self.selectFile(filePath);
+ //})
+ .hammer().on("doubletap", function() {
+ TSCORE.FileOpener.openFile(filePath);
+ self.selectFile(filePath);
+ })
+ .click(function() {
+ self.selectFile(filePath);
+ })
+ .draggable({
+ "cancel": false,
+ "appendTo": "body",
+ "helper": "clone",
+ "opacity": "0.5",
+ "revert": true,
+ "start": function() {
+ self.selectFile(filePath);
+ }
+ })
+ .droppable({
+ accept: ".tagButton",
+ hoverClass: "activeRow",
+ drop: function(event, ui) {
+ var tagName = TSCORE.selectedTag; //ui.draggable.attr("tag");
+ var targetFilePath = filePath; // $(this).attr("filepath");;
+
+ // preventing self drag of tags
+ var targetTags = TSCORE.TagUtils.extractTags(targetFilePath);
+ for (var i = 0; i < targetTags.length; i++) {
+ if (targetTags[i] === tagName) {
+ return true;
}
- });
-
- TSCORE.selectedFiles.push(filePath);
- this.handleElementActivation();
- };
-
- ExtUI.prototype.handleElementActivation = function() {
- console.log("Entering element activation handler...");
-
- var tagButton = $( "#"+this.extensionID+"TagButton" );
-
- if (TSCORE.selectedFiles.length > 1) {
- tagButton.prop('disabled', false);
- } else if (TSCORE.selectedFiles.length === 1) {
- tagButton.prop('disabled', false);
+ }
+
+ console.log("Tagging file: " + tagName + " to " + targetFilePath);
+ $(this).toggleClass("ui-selected");
+ TSCORE.PerspectiveManager.clearSelectedFiles();
+ TSCORE.selectedFiles.push(targetFilePath);
+ TSCORE.TagUtils.addTag(TSCORE.selectedFiles, [tagName]);
+ self.handleElementActivation();
+
+ //$(ui.helper).remove();
+ }
+ })
+ .find(".fileTileSelector").click(function(e) {
+ e.preventDefault();
+ var $stateTag = $(this).find("i");
+ if ($stateTag.hasClass("fa-square-o")) {
+ $stateTag.removeClass("fa-square-o").addClass("fa fa-check-square");
+ $(this).parent().parent().addClass("ui-selected");
+ TSCORE.selectedFiles.push(filePath);
} else {
- tagButton.prop('disabled', true);
- }
- };
+ $stateTag.removeClass("fa-check-square").addClass("fa-square-o");
+ $(this).parent().parent().removeClass("ui-selected");
+ TSCORE.selectedFiles.splice(TSCORE.selectedFiles.indexOf(filePath), 1);
+ }
+ self.handleElementActivation();
+ return false;
+ })
+ .find(".fileTagsTile").click(function() {
+ self.selectFile($(this).attr("filepath"));
+ TSCORE.openTagMenu(this, $(this).attr("tag"), $(this).attr("filepath"));
+ });
+ };
+
+ ExtUI.prototype.clearSelectedFiles = function() {
+ TSCORE.selectedFiles = [];
+ $("#" + this.extensionID + "Container").find(".ui-selected")
+ .removeClass("ui-selected");
+ $("#" + this.extensionID + "Container").find(".fileTileSelector").find("i")
+ .removeClass("fa-check-square")
+ .addClass("fa-square-o");
+
+ // Reseting select all button
+ //$("#"+this.extensionID+"ToogleSelectAll").find("i").removeClass("fa-check-square").addClass("fa-square-o");
+ };
+
+ ExtUI.prototype.selectFile = function(filePath) {
+ TSCORE.PerspectiveManager.clearSelectedFiles();
+ $(this.viewContainer).find('.fileTileSelector').each(function() {
+ if ($(this).attr("filepath") === filePath) {
+ $(this).parent().parent().toggleClass("ui-selected");
+ $(this).find("i").toggleClass("fa-check-square").toggleClass("fa-square-o");
+ TSCORE.selectedFiles.push($(this).attr("filepath"));
+ }
+ });
+
+ TSCORE.selectedFiles.push(filePath);
+ this.handleElementActivation();
+ };
+
+ ExtUI.prototype.handleElementActivation = function() {
+ console.log("Entering element activation handler...");
+
+ var tagButton = $("#" + this.extensionID + "TagButton");
+
+ if (TSCORE.selectedFiles.length > 1) {
+ tagButton.prop('disabled', false);
+ } else if (TSCORE.selectedFiles.length === 1) {
+ tagButton.prop('disabled', false);
+ } else {
+ tagButton.prop('disabled', true);
+ }
+ };
- ExtUI.prototype.removeFileUI = function(filePath) {
- console.log("Removing "+filePath+" from UI");
+ ExtUI.prototype.removeFileUI = function(filePath) {
+ console.log("Removing " + filePath + " from UI");
- // Updating the file selection
- TSCORE.selectedFiles.splice(TSCORE.selectedFiles.indexOf(filePath), 1);
+ // Updating the file selection
+ TSCORE.selectedFiles.splice(TSCORE.selectedFiles.indexOf(filePath), 1);
- if(isWin && !isWeb) {
- filePath = filePath.replace("\\","");
- $("#"+this.extensionID+"Container li[filepath]").each(function() {
- if( $( this ).attr("filepath").replace("\\","") === filePath ) {
- $( this ).remove();
- }
- });
+ if (isWin && !isWeb) {
+ filePath = filePath.replace("\\", "");
+ $("#" + this.extensionID + "Container li[filepath]").each(function() {
+ if ($(this).attr("filepath").replace("\\", "") === filePath) {
+ $(this).remove();
+ }
+ });
+ } else {
+ $("#" + this.extensionID + "Container li[filepath='" + filePath + "']").remove();
+ }
+ };
+
+ ExtUI.prototype.updateFileUI = function(oldFilePath, newFilePath) {
+ console.log("Updating file in UI");
+
+ // Updating the file selection
+ TSCORE.selectedFiles.splice(TSCORE.selectedFiles.indexOf(oldFilePath), 1);
+ TSCORE.selectedFiles.push(newFilePath);
+
+ var title = TSCORE.TagUtils.extractTitle(newFilePath),
+ fileExt = TSCORE.TagUtils.extractFileExtension(newFilePath),
+ fileTags = TSCORE.TagUtils.extractTags(newFilePath);
+
+ var $fileTile;
+
+ if (isWin && !isWeb) {
+ oldFilePath = oldFilePath.replace("\\", "");
+ $("#" + this.extensionID + "Container li[filepath]").each(function() {
+ if ($(this).attr("filepath").replace("\\", "") === oldFilePath) {
+ $fileTile = $(this);
+ }
+ });
+ } else {
+ $fileTile = $("#" + this.extensionID + "Container li[filepath='" + oldFilePath + "']");
+ }
+
+ $fileTile.replaceWith(this.createFileTile(title, newFilePath, fileExt, fileTags, true));
+ this.refreshThumbnails();
+ this.assingFileTileHandlers($fileTile);
+ };
+
+ ExtUI.prototype.getNextFile = function(filePath) {
+ var nextFilePath;
+ var self = this;
+ this.searchResults.forEach(function(entry, index) {
+ if (entry[TSCORE.fileListFILEPATH] === filePath) {
+ var nextIndex = index + 1;
+ if (nextIndex < self.searchResults.length) {
+ nextFilePath = self.searchResults[nextIndex][TSCORE.fileListFILEPATH];
} else {
- $("#"+this.extensionID+"Container li[filepath='"+filePath+"']").remove();
- }
- };
-
- ExtUI.prototype.updateFileUI = function(oldFilePath, newFilePath) {
- console.log("Updating file in UI");
-
- // Updating the file selection
- TSCORE.selectedFiles.splice(TSCORE.selectedFiles.indexOf(oldFilePath), 1);
- TSCORE.selectedFiles.push(newFilePath);
-
- var title = TSCORE.TagUtils.extractTitle(newFilePath),
- fileExt = TSCORE.TagUtils.extractFileExtension(newFilePath),
- fileTags = TSCORE.TagUtils.extractTags(newFilePath);
-
- var $fileTile;
-
- if(isWin && !isWeb) {
- oldFilePath = oldFilePath.replace("\\","");
- $("#"+this.extensionID+"Container li[filepath]").each(function() {
- if( $( this ).attr("filepath").replace("\\","") === oldFilePath ) {
- $fileTile = $( this );
- }
- });
+ nextFilePath = self.searchResults[0][TSCORE.fileListFILEPATH];
+ }
+ }
+ //console.log("Path: "+entry[TSCORE.fileListFILEPATH]);
+ });
+ TSCORE.PerspectiveManager.clearSelectedFiles();
+ console.log("Next file: " + nextFilePath);
+ return nextFilePath;
+ };
+
+ ExtUI.prototype.getPrevFile = function(filePath) {
+ var prevFilePath;
+ var self = this;
+ this.searchResults.forEach(function(entry, index) {
+ if (entry[TSCORE.fileListFILEPATH] === filePath) {
+ var prevIndex = index - 1;
+ if (prevIndex >= 0) {
+ prevFilePath = self.searchResults[prevIndex][TSCORE.fileListFILEPATH];
} else {
- $fileTile = $("#"+this.extensionID+"Container li[filepath='"+oldFilePath+"']");
- }
-
- $fileTile.replaceWith(this.createFileTile(title, newFilePath, fileExt, fileTags, true));
- this.refreshThumbnails();
- this.assingFileTileHandlers($fileTile);
- };
-
- ExtUI.prototype.getNextFile = function(filePath) {
- var nextFilePath;
- var self = this;
- this.searchResults.forEach(function(entry, index) {
- if(entry[TSCORE.fileListFILEPATH] === filePath) {
- var nextIndex = index+1;
- if(nextIndex < self.searchResults.length) {
- nextFilePath = self.searchResults[nextIndex][TSCORE.fileListFILEPATH];
- } else {
- nextFilePath = self.searchResults[0][TSCORE.fileListFILEPATH];
- }
- }
- //console.log("Path: "+entry[TSCORE.fileListFILEPATH]);
- });
- TSCORE.PerspectiveManager.clearSelectedFiles();
- console.log("Next file: "+nextFilePath);
- return nextFilePath;
- };
-
- ExtUI.prototype.getPrevFile = function(filePath) {
- var prevFilePath;
- var self = this;
- this.searchResults.forEach(function(entry, index) {
- if(entry[TSCORE.fileListFILEPATH] === filePath) {
- var prevIndex = index-1;
- if(prevIndex >= 0) {
- prevFilePath = self.searchResults[prevIndex][TSCORE.fileListFILEPATH];
- } else {
- prevFilePath = self.searchResults[self.searchResults.length-1][TSCORE.fileListFILEPATH];
- }
- }
- //console.log("Path: "+entry[TSCORE.fileListFILEPATH]);
- });
- TSCORE.PerspectiveManager.clearSelectedFiles();
- console.log("Prev file: "+prevFilePath);
- return prevFilePath;
- };
-
- exports.ExtUI = ExtUI;
-
-});
\ No newline at end of file
+ prevFilePath = self.searchResults[self.searchResults.length - 1][TSCORE.fileListFILEPATH];
+ }
+ }
+ //console.log("Path: "+entry[TSCORE.fileListFILEPATH]);
+ });
+ TSCORE.PerspectiveManager.clearSelectedFiles();
+ console.log("Prev file: " + prevFilePath);
+ return prevFilePath;
+ };
+
+ exports.ExtUI = ExtUI;
+
+});
diff --git a/data/ext/perspectiveImageSwiper/dist/default-skin/default-skin.css b/data/ext/perspectiveImageSwiper/dist/default-skin/default-skin.css
new file mode 100644
index 000000000..21185a237
--- /dev/null
+++ b/data/ext/perspectiveImageSwiper/dist/default-skin/default-skin.css
@@ -0,0 +1,393 @@
+/*! PhotoSwipe Default UI CSS by Dmitry Semenov | photoswipe.com | MIT license */
+.pswp__button {
+ width: 44px;
+ height: 44px;
+ position: relative;
+ background: none;
+ cursor: pointer;
+ overflow: visible;
+ -webkit-appearance: none;
+ display: block;
+ border: 0;
+ padding: 0;
+ margin: 0;
+ float: right;
+ opacity: 0.75;
+ -webkit-transition: opacity 0.2s;
+ transition: opacity 0.2s;
+ -webkit-box-shadow: none;
+ box-shadow: none; }
+ .pswp__button:focus, .pswp__button:hover {
+ opacity: 1; }
+ .pswp__button:active {
+ outline: none;
+ opacity: 0.9; }
+ .pswp__button::-moz-focus-inner {
+ padding: 0;
+ border: 0; }
+
+.pswp__ui--over-close .pswp__button--close {
+ opacity: 1; }
+
+.pswp__button, .pswp__button--arrow--left:before, .pswp__button--arrow--right:before {
+ background: url(default-skin.png) 0 0 no-repeat;
+ background-size: 264px 88px;
+ width: 44px;
+ height: 44px; }
+
+@media (-webkit-min-device-pixel-ratio: 1.1), (min-resolution: 105dpi), (min-resolution: 1.1dppx) {
+ .pswp--svg .pswp__button, .pswp--svg .pswp__button--arrow--left:before, .pswp--svg .pswp__button--arrow--right:before {
+ background-image: url(default-skin.svg); }
+
+ .pswp--svg .pswp__button--arrow--left, .pswp--svg .pswp__button--arrow--right {
+ background: none; }
+ }
+
+.pswp__button--close {
+ background-position: 0 -44px; }
+
+.pswp__button--share {
+ background-position: -44px -44px; }
+
+.pswp__button--fs {
+ display: none; }
+
+.pswp--supports-fs .pswp__button--fs {
+ display: block; }
+
+.pswp--fs .pswp__button--fs {
+ background-position: -44px 0; }
+
+.pswp__button--zoom {
+ display: none;
+ background-position: -88px 0; }
+
+.pswp--zoom-allowed .pswp__button--zoom {
+ display: block; }
+
+.pswp--zoomed-in .pswp__button--zoom {
+ background-position: -132px 0; }
+
+.pswp--touch .pswp__button--arrow--left, .pswp--touch .pswp__button--arrow--right {
+ visibility: hidden; }
+
+.pswp__button--arrow--left, .pswp__button--arrow--right {
+ background: none;
+ top: 50%;
+ margin-top: -50px;
+ width: 70px;
+ height: 100px;
+ position: absolute; }
+
+.pswp__button--arrow--left {
+ left: 0; }
+
+.pswp__button--arrow--right {
+ right: 0; }
+
+.pswp__button--arrow--left:before, .pswp__button--arrow--right:before {
+ content: '';
+ top: 35px;
+ background-color: rgba(0, 0, 0, 0.3);
+ height: 30px;
+ width: 32px;
+ position: absolute; }
+
+.pswp__button--arrow--left:before {
+ left: 6px;
+ background-position: -138px -44px; }
+
+.pswp__button--arrow--right:before {
+ right: 6px;
+ background-position: -94px -44px; }
+
+.pswp__counter, .pswp__share-modal {
+ -webkit-user-select: none;
+ -moz-user-select: none;
+ -ms-user-select: none;
+ user-select: none; }
+
+.pswp__share-modal {
+ display: block;
+ background: rgba(0, 0, 0, 0.5);
+ width: 100%;
+ height: 100%;
+ top: 0;
+ left: 0;
+ padding: 10px;
+ position: absolute;
+ z-index: 1600;
+ opacity: 0;
+ -webkit-transition: opacity 0.25s ease-out;
+ transition: opacity 0.25s ease-out;
+ -webkit-backface-visibility: hidden;
+ will-change: opacity; }
+
+.pswp__share-modal--hidden {
+ display: none; }
+
+.pswp__share-tooltip {
+ z-index: 1620;
+ position: absolute;
+ background: #FFF;
+ top: 56px;
+ border-radius: 2px;
+ display: block;
+ width: auto;
+ right: 44px;
+ -webkit-box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25);
+ box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25);
+ -webkit-transform: translateY(6px);
+ -ms-transform: translateY(6px);
+ transform: translateY(6px);
+ -webkit-transition: -webkit-transform 0.25s;
+ transition: transform 0.25s;
+ -webkit-backface-visibility: hidden;
+ will-change: transform; }
+ .pswp__share-tooltip a {
+ display: block;
+ padding: 8px 12px;
+ color: #000;
+ text-decoration: none;
+ font-size: 14px;
+ line-height: 18px; }
+ .pswp__share-tooltip a:hover {
+ text-decoration: none;
+ color: #000; }
+ .pswp__share-tooltip a:first-child {
+ border-radius: 2px 2px 0 0; }
+ .pswp__share-tooltip a:last-child {
+ border-radius: 0 0 2px 2px; }
+
+.pswp__share-modal--fade-in {
+ opacity: 1; }
+ .pswp__share-modal--fade-in .pswp__share-tooltip {
+ -webkit-transform: translateY(0);
+ -ms-transform: translateY(0);
+ transform: translateY(0); }
+
+.pswp--touch .pswp__share-tooltip a {
+ padding: 16px 12px; }
+
+a.pswp__share--facebook:before {
+ content: '';
+ display: block;
+ width: 0;
+ height: 0;
+ position: absolute;
+ top: -12px;
+ right: 15px;
+ border: 6px solid rgba(0, 0, 0, 0);
+ border-bottom-color: #FFF;
+ -webkit-pointer-events: none;
+ -moz-pointer-events: none;
+ pointer-events: none; }
+a.pswp__share--facebook:hover {
+ background: #3E5C9A;
+ color: #FFF; }
+ a.pswp__share--facebook:hover:before {
+ border-bottom-color: #3E5C9A; }
+
+a.pswp__share--twitter:hover {
+ background: #55ACEE;
+ color: #FFF; }
+
+a.pswp__share--pinterest:hover {
+ background: #CCC;
+ color: #CE272D; }
+
+a.pswp__share--download:hover {
+ background: #DDD; }
+
+.pswp__counter {
+ position: absolute;
+ left: 0;
+ top: 0;
+ height: 44px;
+ font-size: 13px;
+ line-height: 44px;
+ color: #FFF;
+ opacity: 0.75;
+ padding: 0 10px; }
+
+.pswp__caption {
+ position: absolute;
+ left: 0;
+ bottom: 0;
+ width: 100%;
+ min-height: 44px; }
+ .pswp__caption small {
+ font-size: 11px;
+ color: #BBB; }
+
+.pswp__caption__center {
+ text-align: left;
+ max-width: 420px;
+ margin: 0 auto;
+ font-size: 13px;
+ padding: 10px;
+ line-height: 20px;
+ color: #CCC; }
+
+.pswp__caption--empty {
+ display: none; }
+
+.pswp__caption--fake {
+ visibility: hidden; }
+
+.pswp__preloader {
+ width: 44px;
+ height: 44px;
+ position: absolute;
+ top: 0;
+ left: 50%;
+ margin-left: -22px;
+ opacity: 0;
+ -webkit-transition: opacity 0.25s ease-out;
+ transition: opacity 0.25s ease-out;
+ will-change: opacity; }
+
+.pswp__preloader__icn {
+ width: 20px;
+ height: 20px;
+ margin: 12px; }
+
+.pswp__preloader--active {
+ opacity: 1; }
+ .pswp__preloader--active .pswp__preloader__icn {
+ background: url(preloader.gif) 0 0 no-repeat; }
+
+.pswp--css_animation .pswp__preloader--active {
+ opacity: 1; }
+ .pswp--css_animation .pswp__preloader--active .pswp__preloader__icn {
+ -webkit-animation: clockwise 500ms linear infinite;
+ animation: clockwise 500ms linear infinite; }
+ .pswp--css_animation .pswp__preloader--active .pswp__preloader__donut {
+ -webkit-animation: donut-rotate 1000ms cubic-bezier(0.4, 0, 0.22, 1) infinite;
+ animation: donut-rotate 1000ms cubic-bezier(0.4, 0, 0.22, 1) infinite; }
+.pswp--css_animation .pswp__preloader__icn {
+ background: none;
+ opacity: 0.75;
+ width: 14px;
+ height: 14px;
+ position: absolute;
+ left: 15px;
+ top: 15px;
+ margin: 0; }
+.pswp--css_animation .pswp__preloader__cut {
+ position: relative;
+ width: 7px;
+ height: 14px;
+ overflow: hidden; }
+.pswp--css_animation .pswp__preloader__donut {
+ -webkit-box-sizing: border-box;
+ box-sizing: border-box;
+ width: 14px;
+ height: 14px;
+ border: 2px solid #FFF;
+ border-radius: 50%;
+ border-left-color: transparent;
+ border-bottom-color: transparent;
+ position: absolute;
+ top: 0;
+ left: 0;
+ background: none;
+ margin: 0; }
+
+@media screen and (max-width: 1024px) {
+ .pswp__preloader {
+ position: relative;
+ left: auto;
+ top: auto;
+ margin: 0;
+ float: right; }
+ }
+
+@-webkit-keyframes clockwise {
+ 0% {
+ -webkit-transform: rotate(0deg);
+ transform: rotate(0deg); }
+
+ 100% {
+ -webkit-transform: rotate(360deg);
+ transform: rotate(360deg); } }
+
+@keyframes clockwise {
+ 0% {
+ -webkit-transform: rotate(0deg);
+ transform: rotate(0deg); }
+
+ 100% {
+ -webkit-transform: rotate(360deg);
+ transform: rotate(360deg); } }
+
+@-webkit-keyframes donut-rotate {
+ 0% {
+ -webkit-transform: rotate(0);
+ transform: rotate(0); }
+
+ 50% {
+ -webkit-transform: rotate(-140deg);
+ transform: rotate(-140deg); }
+
+ 100% {
+ -webkit-transform: rotate(0);
+ transform: rotate(0); } }
+
+@keyframes donut-rotate {
+ 0% {
+ -webkit-transform: rotate(0);
+ transform: rotate(0); }
+
+ 50% {
+ -webkit-transform: rotate(-140deg);
+ transform: rotate(-140deg); }
+
+ 100% {
+ -webkit-transform: rotate(0);
+ transform: rotate(0); } }
+
+.pswp__ui {
+ -webkit-font-smoothing: auto;
+ visibility: visible;
+ opacity: 1;
+ z-index: 1550; }
+
+.pswp__top-bar {
+ position: absolute;
+ left: 0;
+ top: 0;
+ height: 44px;
+ width: 100%; }
+
+.pswp__caption, .pswp__top-bar, .pswp--has_mouse .pswp__button--arrow--left, .pswp--has_mouse .pswp__button--arrow--right {
+ -webkit-backface-visibility: hidden;
+ will-change: opacity;
+ -webkit-transition: opacity 333ms cubic-bezier(0.4, 0, 0.22, 1);
+ transition: opacity 333ms cubic-bezier(0.4, 0, 0.22, 1); }
+
+.pswp--has_mouse .pswp__button--arrow--left, .pswp--has_mouse .pswp__button--arrow--right {
+ visibility: visible; }
+
+.pswp__top-bar, .pswp__caption {
+ background-color: rgba(0, 0, 0, 0.5); }
+
+.pswp__ui--fit .pswp__top-bar, .pswp__ui--fit .pswp__caption {
+ background-color: rgba(0, 0, 0, 0.3); }
+
+.pswp__ui--idle .pswp__top-bar {
+ opacity: 0; }
+.pswp__ui--idle .pswp__button--arrow--left, .pswp__ui--idle .pswp__button--arrow--right {
+ opacity: 0; }
+
+.pswp__ui--hidden .pswp__top-bar, .pswp__ui--hidden .pswp__caption, .pswp__ui--hidden .pswp__button--arrow--left, .pswp__ui--hidden .pswp__button--arrow--right {
+ opacity: 0.001; }
+
+.pswp__ui--one-slide .pswp__button--arrow--left, .pswp__ui--one-slide .pswp__button--arrow--right, .pswp__ui--one-slide .pswp__counter {
+ display: none; }
+
+.pswp__element--disabled {
+ display: none !important; }
+
+.pswp--minimal--dark .pswp__top-bar {
+ background: none; }
diff --git a/data/ext/perspectiveImageSwiper/dist/default-skin/default-skin.png b/data/ext/perspectiveImageSwiper/dist/default-skin/default-skin.png
new file mode 100644
index 000000000..441c502c9
Binary files /dev/null and b/data/ext/perspectiveImageSwiper/dist/default-skin/default-skin.png differ
diff --git a/data/ext/perspectiveImageSwiper/dist/default-skin/default-skin.svg b/data/ext/perspectiveImageSwiper/dist/default-skin/default-skin.svg
new file mode 100644
index 000000000..9d5f0c6a1
--- /dev/null
+++ b/data/ext/perspectiveImageSwiper/dist/default-skin/default-skin.svg
@@ -0,0 +1 @@
+<svg width="264" height="88" viewBox="0 0 264 88" xmlns="http://www.w3.org/2000/svg"><title>default-skin 2</title><g fill="none" fill-rule="evenodd"><g><path d="M67.002 59.5v3.768c-6.307.84-9.184 5.75-10.002 9.732 2.22-2.83 5.564-5.098 10.002-5.098V71.5L73 65.585 67.002 59.5z" id="Shape" fill="#fff"/><g fill="#fff"><path d="M13 29v-5h2v3h3v2h-5zM13 15h5v2h-3v3h-2v-5zM31 15v5h-2v-3h-3v-2h5zM31 29h-5v-2h3v-3h2v5z" id="Shape"/></g><g fill="#fff"><path d="M62 24v5h-2v-3h-3v-2h5zM62 20h-5v-2h3v-3h2v5zM70 20v-5h2v3h3v2h-5zM70 24h5v2h-3v3h-2v-5z"/></g><path d="M20.586 66l-5.656-5.656 1.414-1.414L22 64.586l5.656-5.656 1.414 1.414L23.414 66l5.656 5.656-1.414 1.414L22 67.414l-5.656 5.656-1.414-1.414L20.586 66z" fill="#fff"/><path d="M111.785 65.03L110 63.5l3-3.5h-10v-2h10l-3-3.5 1.785-1.468L117 59l-5.215 6.03z" fill="#fff"/><path d="M152.215 65.03L154 63.5l-3-3.5h10v-2h-10l3-3.5-1.785-1.468L147 59l5.215 6.03z" fill="#fff"/><g><path id="Rectangle-11" fill="#fff" d="M160.957 28.543l-3.25-3.25-1.413 1.414 3.25 3.25z"/><path d="M152.5 27c3.038 0 5.5-2.462 5.5-5.5s-2.462-5.5-5.5-5.5-5.5 2.462-5.5 5.5 2.462 5.5 5.5 5.5z" id="Oval-1" stroke="#fff" stroke-width="1.5"/><path fill="#fff" d="M150 21h5v1h-5z"/></g><g><path d="M116.957 28.543l-1.414 1.414-3.25-3.25 1.414-1.414 3.25 3.25z" fill="#fff"/><path d="M108.5 27c3.038 0 5.5-2.462 5.5-5.5s-2.462-5.5-5.5-5.5-5.5 2.462-5.5 5.5 2.462 5.5 5.5 5.5z" stroke="#fff" stroke-width="1.5"/><path fill="#fff" d="M106 21h5v1h-5z"/><path fill="#fff" d="M109.043 19.008l-.085 5-1-.017.085-5z"/></g></g></g></svg>
\ No newline at end of file
diff --git a/data/ext/perspectiveImageSwiper/dist/default-skin/preloader.gif b/data/ext/perspectiveImageSwiper/dist/default-skin/preloader.gif
new file mode 100644
index 000000000..b8faa697c
Binary files /dev/null and b/data/ext/perspectiveImageSwiper/dist/default-skin/preloader.gif differ
diff --git a/data/ext/perspectiveImageSwiper/dist/photoswipe-ui-default.js b/data/ext/perspectiveImageSwiper/dist/photoswipe-ui-default.js
new file mode 100644
index 000000000..a13182a40
--- /dev/null
+++ b/data/ext/perspectiveImageSwiper/dist/photoswipe-ui-default.js
@@ -0,0 +1,836 @@
+/*! PhotoSwipe Default UI - 4.0.3 - 2015-01-09
+* http://photoswipe.com
+* Copyright (c) 2015 Dmitry Semenov; */
+/**
+*
+* UI on top of main sliding area (caption, arrows, close button, etc.).
+* Built just using public methods/properties of PhotoSwipe.
+*
+*/
+(function (root, factory) {
+ if (typeof define === 'function' && define.amd) {
+ define(factory);
+ } else if (typeof exports === 'object') {
+ module.exports = factory();
+ } else {
+ root.PhotoSwipeUI_Default = factory();
+ }
+})(this, function () {
+
+ 'use strict';
+
+
+
+var PhotoSwipeUI_Default =
+ function(pswp, framework) {
+
+ var ui = this;
+ var _overlayUIUpdated = false,
+ _controlsVisible = true,
+ _fullscrenAPI,
+ _controls,
+ _captionContainer,
+ _fakeCaptionContainer,
+ _indexIndicator,
+ _shareButton,
+ _shareModal,
+ _shareModalHidden = true,
+ _initalCloseOnScrollValue,
+ _isIdle,
+ _listen,
+
+ _loadingIndicator,
+ _loadingIndicatorHidden,
+ _loadingIndicatorTimeout,
+
+ _galleryHasOneSlide,
+
+ _options,
+ _defaultUIOptions = {
+ barsSize: {top:44, bottom:'auto'},
+ closeElClasses: ['item', 'caption', 'zoom-wrap', 'ui', 'top-bar'],
+ timeToIdle: 4000,
+ timeToIdleOutside: 1000,
+ loadingIndicatorDelay: 1000, // 2s
+
+ addCaptionHTMLFn: function(item, captionEl /*, isFake */) {
+ if(!item.title) {
+ captionEl.children[0].innerHTML = '';
+ return false;
+ }
+ captionEl.children[0].innerHTML = item.title;
+ return true;
+ },
+
+ closeEl:true,
+ captionEl: true,
+ fullscreenEl: true,
+ zoomEl: true,
+ shareEl: true,
+ counterEl: true,
+ arrowEl: true,
+ preloaderEl: true,
+
+ tapToClose: false,
+ tapToToggleControls: true,
+
+ shareButtons: [
+ {id:'facebook', label:'Share on Facebook', url:'https://www.facebook.com/sharer/sharer.php?u={{url}}'},
+ {id:'twitter', label:'Tweet', url:'https://twitter.com/intent/tweet?text={{text}}&url={{url}}'},
+ {id:'pinterest', label:'Pin it', url:'http://www.pinterest.com/pin/create/button/'+
+ '?url={{url}}&media={{image_url}}&description={{text}}'},
+ {id:'download', label:'Download image', url:'{{raw_image_url}}', download:true}
+ ],
+ getImageURLForShare: function( /* shareButtonData */ ) {
+ return pswp.currItem.src || '';
+ },
+ getPageURLForShare: function( /* shareButtonData */ ) {
+ return window.location.href;
+ },
+ getTextForShare: function( /* shareButtonData */ ) {
+ return pswp.currItem.title || '';
+ },
+
+ indexIndicatorSep: ' / '
+
+ },
+ _blockControlsTap,
+ _blockControlsTapTimeout;
+
+
+
+ var _onControlsTap = function(e) {
+ if(_blockControlsTap) {
+ return true;
+ }
+
+
+ e = e || window.event;
+
+
+ var target = e.target || e.srcElement,
+ uiElement,
+ clickedClass = target.className,
+ found;
+
+ for(var i = 0; i < _uiElements.length; i++) {
+ uiElement = _uiElements[i];
+ if(uiElement.onTap && clickedClass.indexOf('pswp__' + uiElement.name ) > -1 ) {
+ uiElement.onTap();
+ found = true;
+
+ }
+ }
+
+ if(found) {
+ if(e.stopPropagation) {
+ e.stopPropagation();
+ }
+ _blockControlsTap = true;
+
+ // Some versions of Android don't prevent ghost click event
+ // when preventDefault() was called on touchstart and/or touchend.
+ //
+ // This happens on v4.3, 4.2, 4.1,
+ // older versions strangely work correctly,
+ // but just in case we add delay on all of them)
+ var tapDelay = framework.features.isOldAndroid ? 600 : 30;
+ _blockControlsTapTimeout = setTimeout(function() {
+ _blockControlsTap = false;
+ }, tapDelay);
+ }
+
+ },
+ _fitControlsInViewport = function() {
+ return !pswp.likelyTouchDevice || _options.mouseUsed || screen.width > 1200;
+ },
+ _togglePswpClass = function(el, cName, add) {
+ framework[ (add ? 'add' : 'remove') + 'Class' ](el, 'pswp__' + cName);
+ },
+
+ // add class when there is just one item in the gallery
+ // (by default it hides left/right arrows and 1ofX counter)
+ _countNumItems = function() {
+ var hasOneSlide = (_options.getNumItemsFn() === 1);
+
+ if(hasOneSlide !== _galleryHasOneSlide) {
+ _togglePswpClass(_controls, 'ui--one-slide', hasOneSlide);
+ _galleryHasOneSlide = hasOneSlide;
+ }
+ },
+ _toggleShareModalClass = function() {
+ _togglePswpClass(_shareModal, 'share-modal--hidden', _shareModalHidden);
+ },
+ _toggleShareModal = function() {
+
+ _shareModalHidden = !_shareModalHidden;
+
+
+ if(!_shareModalHidden) {
+ _toggleShareModalClass();
+ setTimeout(function() {
+ if(!_shareModalHidden) {
+ framework.addClass(_shareModal, 'pswp__share-modal--fade-in');
+ }
+ }, 30);
+ } else {
+ framework.removeClass(_shareModal, 'pswp__share-modal--fade-in');
+ setTimeout(function() {
+ if(_shareModalHidden) {
+ _toggleShareModalClass();
+ }
+ }, 300);
+ }
+
+ if(!_shareModalHidden) {
+ _updateShareURLs();
+ }
+ return false;
+ },
+
+ _openWindowPopup = function(e) {
+ e = e || window.event;
+ var target = e.target || e.srcElement;
+
+ pswp.shout('shareLinkClick', e, target);
+
+ if(!target.href) {
+ return false;
+ }
+
+ if( target.hasAttribute('download') ) {
+ return true;
+ }
+
+ window.open(target.href, 'pswp_share', 'scrollbars=yes,resizable=yes,toolbar=no,'+
+ 'location=yes,width=550,height=420,top=100,left=' +
+ (window.screen ? Math.round(screen.width / 2 - 275) : 100) );
+
+ if(!_shareModalHidden) {
+ _toggleShareModal();
+ }
+
+ return false;
+ },
+ _updateShareURLs = function() {
+ var shareButtonOut = '',
+ shareButtonData,
+ shareURL,
+ image_url,
+ page_url,
+ share_text;
+
+ for(var i = 0; i < _options.shareButtons.length; i++) {
+ shareButtonData = _options.shareButtons[i];
+
+ image_url = _options.getImageURLForShare(shareButtonData);
+ page_url = _options.getPageURLForShare(shareButtonData);
+ share_text = _options.getTextForShare(shareButtonData);
+
+ shareURL = shareButtonData.url.replace('{{url}}', encodeURIComponent(page_url) )
+ .replace('{{image_url}}', encodeURIComponent(image_url) )
+ .replace('{{raw_image_url}}', image_url )
+ .replace('{{text}}', encodeURIComponent(share_text) );
+
+ shareButtonOut += '<a href="' + shareURL + '" target="_blank" '+
+ 'class="pswp__share--' + shareButtonData.id + '"' +
+ (shareButtonData.download ? 'download' : '') + '>' +
+ shareButtonData.label + '</a>';
+
+ if(_options.parseShareButtonOut) {
+ shareButtonOut = _options.parseShareButtonOut(shareButtonData, shareButtonOut);
+ }
+ }
+ _shareModal.children[0].innerHTML = shareButtonOut;
+ _shareModal.children[0].onclick = _openWindowPopup;
+
+ },
+ _hasCloseClass = function(target) {
+ for(var i = 0; i < _options.closeElClasses.length; i++) {
+ if( framework.hasClass(target, 'pswp__' + _options.closeElClasses[i]) ) {
+ return true;
+ }
+ }
+ },
+ _idleInterval,
+ _idleTimer,
+ _idleIncrement = 0,
+ _onIdleMouseMove = function() {
+ clearTimeout(_idleTimer);
+ _idleIncrement = 0;
+ if(_isIdle) {
+ ui.setIdle(false);
+ }
+ },
+ _onMouseLeaveWindow = function(e) {
+ e = e ? e : window.event;
+ var from = e.relatedTarget || e.toElement;
+ if (!from || from.nodeName === 'HTML') {
+ clearTimeout(_idleTimer);
+ _idleTimer = setTimeout(function() {
+ ui.setIdle(true);
+ }, _options.timeToIdleOutside);
+ }
+ },
+ _setupFullscreenAPI = function() {
+ if(_options.fullscreenEl) {
+ if(!_fullscrenAPI) {
+ _fullscrenAPI = ui.getFullscreenAPI();
+ }
+ if(_fullscrenAPI) {
+ framework.bind(document, _fullscrenAPI.eventK, ui.updateFullscreen);
+ ui.updateFullscreen();
+ framework.addClass(pswp.template, 'pswp--supports-fs');
+ } else {
+ framework.removeClass(pswp.template, 'pswp--supports-fs');
+ }
+ }
+ },
+ _setupLoadingIndicator = function() {
+ // Setup loading indicator
+ if(_options.preloaderEl) {
+
+ _toggleLoadingIndicator(true);
+
+ _listen('beforeChange', function() {
+
+ clearTimeout(_loadingIndicatorTimeout);
+
+ // display loading indicator with delay
+ _loadingIndicatorTimeout = setTimeout(function() {
+
+ if(pswp.currItem && pswp.currItem.loading) {
+
+ if( !pswp.allowProgressiveImg() || (pswp.currItem.img && !pswp.currItem.img.naturalWidth) ) {
+ // show preloader if progressive loading is not enabled,
+ // or image width is not defined yet (because of slow connection)
+ _toggleLoadingIndicator(false);
+ // items-controller.js function allowProgressiveImg
+ }
+
+ } else {
+ _toggleLoadingIndicator(true); // hide preloader
+ }
+
+ }, _options.loadingIndicatorDelay);
+
+ });
+ _listen('imageLoadComplete', function(index, item) {
+ if(pswp.currItem === item) {
+ _toggleLoadingIndicator(true);
+ }
+ });
+
+ }
+ },
+ _toggleLoadingIndicator = function(hide) {
+ if( _loadingIndicatorHidden !== hide ) {
+ _togglePswpClass(_loadingIndicator, 'preloader--active', !hide);
+ _loadingIndicatorHidden = hide;
+ }
+ },
+ _applyNavBarGaps = function(item) {
+ var gap = item.vGap;
+
+ if( _fitControlsInViewport() ) {
+
+ var bars = _options.barsSize;
+ if(_options.captionEl && bars.bottom === 'auto') {
+ if(!_fakeCaptionContainer) {
+ _fakeCaptionContainer = framework.createEl('pswp__caption pswp__caption--fake');
+ _fakeCaptionContainer.appendChild( framework.createEl('pswp__caption__center') );
+ _controls.insertBefore(_fakeCaptionContainer, _captionContainer);
+ framework.addClass(_controls, 'pswp__ui--fit');
+ }
+ if( _options.addCaptionHTMLFn(item, _fakeCaptionContainer, true) ) {
+
+ var captionSize = _fakeCaptionContainer.clientHeight;
+ gap.bottom = parseInt(captionSize,10) || 44;
+ } else {
+ gap.bottom = bars.top; // if no caption, set size of bottom gap to size of top
+ }
+ } else {
+ gap.bottom = bars.bottom;
+ }
+
+ // height of top bar is static, no need to calculate it
+ gap.top = bars.top;
+ } else {
+ gap.top = gap.bottom = 0;
+ }
+ },
+ _setupIdle = function() {
+ // Hide controls when mouse is used
+ if(_options.timeToIdle) {
+ _listen('mouseUsed', function() {
+
+ framework.bind(document, 'mousemove', _onIdleMouseMove);
+ framework.bind(document, 'mouseout', _onMouseLeaveWindow);
+
+ _idleInterval = setInterval(function() {
+ _idleIncrement++;
+ if(_idleIncrement === 2) {
+ ui.setIdle(true);
+ }
+ }, _options.timeToIdle / 2);
+ });
+ }
+ },
+ _setupHidingControlsDuringGestures = function() {
+
+ // Hide controls on vertical drag
+ _listen('onVerticalDrag', function(now) {
+ if(_controlsVisible && now < 0.95) {
+ ui.hideControls();
+ } else if(!_controlsVisible && now >= 0.95) {
+ ui.showControls();
+ }
+ });
+
+ // Hide controls when pinching to close
+ var pinchControlsHidden;
+ _listen('onPinchClose' , function(now) {
+ if(_controlsVisible && now < 0.9) {
+ ui.hideControls();
+ pinchControlsHidden = true;
+ } else if(pinchControlsHidden && !_controlsVisible && now > 0.9) {
+ ui.showControls();
+ }
+ });
+
+ _listen('zoomGestureEnded', function() {
+ pinchControlsHidden = false;
+ if(pinchControlsHidden && !_controlsVisible) {
+ ui.showControls();
+ }
+ });
+
+ };
+
+
+
+ var _uiElements = [
+ {
+ name: 'caption',
+ option: 'captionEl',
+ onInit: function(el) {
+ _captionContainer = el;
+ }
+ },
+ {
+ name: 'share-modal',
+ option: 'shareEl',
+ onInit: function(el) {
+ _shareModal = el;
+ },
+ onTap: function() {
+ _toggleShareModal();
+ }
+ },
+ {
+ name: 'button--share',
+ option: 'shareEl',
+ onInit: function(el) {
+ _shareButton = el;
+ },
+ onTap: function() {
+ _toggleShareModal();
+ }
+ },
+ {
+ name: 'button--zoom',
+ option: 'zoomEl',
+ onTap: pswp.toggleDesktopZoom
+ },
+ {
+ name: 'counter',
+ option: 'counterEl',
+ onInit: function(el) {
+ _indexIndicator = el;
+ }
+ },
+ {
+ name: 'button--close',
+ option: 'closeEl',
+ onTap: pswp.close
+ },
+ {
+ name: 'button--arrow--left',
+ option: 'arrowEl',
+ onTap: pswp.prev
+ },
+ {
+ name: 'button--arrow--right',
+ option: 'arrowEl',
+ onTap: pswp.next
+ },
+ {
+ name: 'button--fs',
+ option: 'fullscreenEl',
+ onTap: function() {
+ if(_fullscrenAPI.isFullscreen()) {
+ _fullscrenAPI.exit();
+ } else {
+ _fullscrenAPI.enter();
+ }
+ }
+ },
+ {
+ name: 'preloader',
+ option: 'preloaderEl',
+ onInit: function(el) {
+ _loadingIndicator = el;
+ }
+ }
+
+ ];
+
+ var _setupUIElements = function() {
+ var item,
+ classAttr,
+ uiElement;
+
+ var loopThroughChildElements = function(sChildren) {
+ if(!sChildren) {
+ return;
+ }
+
+ var l = sChildren.length;
+ for(var i = 0; i < l; i++) {
+ item = sChildren[i];
+ classAttr = item.className;
+
+ for(var a = 0; a < _uiElements.length; a++) {
+ uiElement = _uiElements[a];
+
+ if(classAttr.indexOf('pswp__' + uiElement.name) > -1 ) {
+
+ if( _options[uiElement.option] ) { // if element is not disabled from options
+
+ framework.removeClass(item, 'pswp__element--disabled');
+ if(uiElement.onInit) {
+ uiElement.onInit(item);
+ }
+
+ //item.style.display = 'block';
+ } else {
+ framework.addClass(item, 'pswp__element--disabled');
+ //item.style.display = 'none';
+ }
+ }
+ }
+ }
+ };
+ loopThroughChildElements(_controls.children);
+
+ var topBar = framework.getChildByClass(_controls, 'pswp__top-bar');
+ if(topBar) {
+ loopThroughChildElements( topBar.children );
+ }
+ };
+
+
+
+
+ ui.init = function() {
+
+ // extend options
+ framework.extend(pswp.options, _defaultUIOptions, true);
+
+ // create local link for fast access
+ _options = pswp.options;
+
+ // find pswp__ui element
+ _controls = framework.getChildByClass(pswp.scrollWrap, 'pswp__ui');
+
+ // create local link
+ _listen = pswp.listen;
+
+
+ _setupHidingControlsDuringGestures();
+
+ // update controls when slides change
+ _listen('beforeChange', ui.update);
+
+ // toggle zoom on double-tap
+ _listen('doubleTap', function(point) {
+ var initialZoomLevel = pswp.currItem.initialZoomLevel;
+ if(pswp.getZoomLevel() !== initialZoomLevel) {
+ pswp.zoomTo(initialZoomLevel, point, 333);
+ } else {
+ pswp.zoomTo(_options.getDoubleTapZoom(false, pswp.currItem), point, 333);
+ }
+ });
+
+ // Allow text selection in caption
+ _listen('preventDragEvent', function(e, isDown, preventObj) {
+ var t = e.target || e.srcElement;
+ if(
+ t &&
+ t.className && e.type.indexOf('mouse') > -1 &&
+ ( t.className.indexOf('__caption') > 0 || (/(SMALL|STRONG|EM)/i).test(t.tagName) )
+ ) {
+ preventObj.prevent = false;
+ }
+ });
+
+ // bind events for UI
+ _listen('bindEvents', function() {
+ framework.bind(_controls, 'pswpTap click', _onControlsTap);
+ framework.bind(pswp.scrollWrap, 'pswpTap', ui.onGlobalTap);
+
+ if(!pswp.likelyTouchDevice) {
+ framework.bind(pswp.scrollWrap, 'mouseover', ui.onMouseOver);
+ }
+ });
+
+ // unbind events for UI
+ _listen('unbindEvents', function() {
+ if(!_shareModalHidden) {
+ _toggleShareModal();
+ }
+
+ if(_idleInterval) {
+ clearInterval(_idleInterval);
+ }
+ framework.unbind(document, 'mouseout', _onMouseLeaveWindow);
+ framework.unbind(document, 'mousemove', _onIdleMouseMove);
+ framework.unbind(_controls, 'pswpTap click', _onControlsTap);
+ framework.unbind(pswp.scrollWrap, 'pswpTap', ui.onGlobalTap);
+ framework.unbind(pswp.scrollWrap, 'mouseover', ui.onMouseOver);
+
+ if(_fullscrenAPI) {
+ framework.unbind(document, _fullscrenAPI.eventK, ui.updateFullscreen);
+ if(_fullscrenAPI.isFullscreen()) {
+ _options.hideAnimationDuration = 0;
+ _fullscrenAPI.exit();
+ }
+ _fullscrenAPI = null;
+ }
+ });
+
+
+ // clean up things when gallery is destroyed
+ _listen('destroy', function() {
+ if(_options.captionEl) {
+ if(_fakeCaptionContainer) {
+ _controls.removeChild(_fakeCaptionContainer);
+ }
+ framework.removeClass(_captionContainer, 'pswp__caption--empty');
+ }
+
+ if(_shareModal) {
+ _shareModal.children[0].onclick = null;
+ }
+ framework.removeClass(_controls, 'pswp__ui--over-close');
+ framework.addClass( _controls, 'pswp__ui--hidden');
+ ui.setIdle(false);
+ });
+
+
+ if(!_options.showAnimationDuration) {
+ framework.removeClass( _controls, 'pswp__ui--hidden');
+ }
+ _listen('initialZoomIn', function() {
+ if(_options.showAnimationDuration) {
+ framework.removeClass( _controls, 'pswp__ui--hidden');
+ }
+ });
+ _listen('initialZoomOut', function() {
+ framework.addClass( _controls, 'pswp__ui--hidden');
+ });
+
+ _listen('parseVerticalMargin', _applyNavBarGaps);
+
+ _setupUIElements();
+
+ if(_options.shareEl && _shareButton && _shareModal) {
+ _shareModalHidden = true;
+ }
+
+ _countNumItems();
+
+ _setupIdle();
+
+ _setupFullscreenAPI();
+
+ _setupLoadingIndicator();
+ };
+
+ ui.setIdle = function(isIdle) {
+ _isIdle = isIdle;
+ _togglePswpClass(_controls, 'ui--idle', isIdle);
+ };
+
+ ui.update = function() {
+ // Don't update UI if it's hidden
+ if(_controlsVisible && pswp.currItem) {
+
+ ui.updateIndexIndicator();
+
+ if(_options.captionEl) {
+ _options.addCaptionHTMLFn(pswp.currItem, _captionContainer);
+
+ _togglePswpClass(_captionContainer, 'caption--empty', !pswp.currItem.title);
+ }
+
+ _overlayUIUpdated = true;
+
+ } else {
+ _overlayUIUpdated = false;
+ }
+
+ _countNumItems();
+ };
+
+ ui.updateFullscreen = function() {
+ _togglePswpClass(pswp.template, 'fs', _fullscrenAPI.isFullscreen());
+ };
+
+ ui.updateIndexIndicator = function() {
+ if(_options.counterEl) {
+ _indexIndicator.innerHTML = (pswp.getCurrentIndex()+1) +
+ _options.indexIndicatorSep +
+ _options.getNumItemsFn();
+ }
+ };
+
+ ui.onGlobalTap = function(e) {
+ e = e || window.event;
+ var target = e.target || e.srcElement;
+
+ if(_blockControlsTap) {
+ return;
+ }
+
+ if(e.detail && e.detail.pointerType === 'mouse') {
+
+ // close gallery if clicked outside of the image
+ if(_hasCloseClass(target)) {
+ pswp.close();
+ }
+
+ if(framework.hasClass(target, 'pswp__img')) {
+ if(pswp.getZoomLevel() === 1 && pswp.getZoomLevel() <= pswp.currItem.fitRatio) {
+ pswp.close();
+ } else {
+ pswp.toggleDesktopZoom(e.detail.releasePoint);
+ }
+ }
+
+ } else {
+
+ // tap anywhere (except buttons) to toggle visibility of controls
+ if(_options.tapToToggleControls) {
+ if(_controlsVisible) {
+ ui.hideControls();
+ } else {
+ ui.showControls();
+ }
+ }
+
+ // tap to close gallery
+ if(_options.tapToClose && (framework.hasClass(target, 'pswp__img') || _hasCloseClass(target)) ) {
+ pswp.close();
+ return;
+ }
+
+ }
+ };
+ ui.onMouseOver = function(e) {
+ e = e || window.event;
+ var target = e.target || e.srcElement;
+
+ // add class when mouse is over an element that should close the gallery
+ _togglePswpClass(_controls, 'ui--over-close', _hasCloseClass(target));
+ };
+
+ ui.hideControls = function() {
+ framework.addClass(_controls,'pswp__ui--hidden');
+ _controlsVisible = false;
+ };
+
+ ui.showControls = function() {
+ _controlsVisible = true;
+ if(!_overlayUIUpdated) {
+ ui.update();
+ }
+ framework.removeClass(_controls,'pswp__ui--hidden');
+ };
+
+ ui.supportsFullscreen = function() {
+ var d = document;
+ return !!(d.exitFullscreen || d.mozCancelFullScreen || d.webkitExitFullscreen || d.msExitFullscreen);
+ };
+
+ ui.getFullscreenAPI = function() {
+ var dE = document.documentElement,
+ api,
+ tF = 'fullscreenchange';
+
+ if (dE.requestFullscreen) {
+ api = {
+ enterK: 'requestFullscreen',
+ exitK: 'exitFullscreen',
+ elementK: 'fullscreenElement',
+ eventK: tF
+ };
+
+ } else if(dE.mozRequestFullScreen ) {
+ api = {
+ enterK: 'mozRequestFullScreen',
+ exitK: 'mozCancelFullScreen',
+ elementK: 'mozFullScreenElement',
+ eventK: 'moz' + tF
+ };
+
+
+
+ } else if(dE.webkitRequestFullscreen) {
+ api = {
+ enterK: 'webkitRequestFullscreen',
+ exitK: 'webkitExitFullscreen',
+ elementK: 'webkitFullscreenElement',
+ eventK: 'webkit' + tF
+ };
+
+ } else if(dE.msRequestFullscreen) {
+ api = {
+ enterK: 'msRequestFullscreen',
+ exitK: 'msExitFullscreen',
+ elementK: 'msFullscreenElement',
+ eventK: 'MSFullscreenChange'
+ };
+ }
+
+ if(api) {
+ api.enter = function() {
+ // disable close-on-scroll in fullscreen
+ _initalCloseOnScrollValue = _options.closeOnScroll;
+ _options.closeOnScroll = false;
+
+ if(this.enterK === 'webkitRequestFullscreen') {
+ pswp.template[this.enterK]( Element.ALLOW_KEYBOARD_INPUT );
+ } else {
+ return pswp.template[this.enterK]();
+ }
+ };
+ api.exit = function() {
+ _options.closeOnScroll = _initalCloseOnScrollValue;
+
+ return document[this.exitK]();
+
+ };
+ api.isFullscreen = function() { return document[this.elementK]; };
+ }
+
+ return api;
+ };
+
+
+
+};
+return PhotoSwipeUI_Default;
+
+
+});
\ No newline at end of file
diff --git a/data/ext/perspectiveImageSwiper/dist/photoswipe-ui-default.min.js b/data/ext/perspectiveImageSwiper/dist/photoswipe-ui-default.min.js
new file mode 100644
index 000000000..f1ca5ba69
--- /dev/null
+++ b/data/ext/perspectiveImageSwiper/dist/photoswipe-ui-default.min.js
@@ -0,0 +1,4 @@
+/*! PhotoSwipe Default UI - 4.0.3 - 2015-01-09
+* http://photoswipe.com
+* Copyright (c) 2015 Dmitry Semenov; */
+!function(a,b){"function"==typeof define&&define.amd?define(b):"object"==typeof exports?module.exports=b():a.PhotoSwipeUI_Default=b()}(this,function(){"use strict";var a=function(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v=this,w=!1,x=!0,y=!0,z={barsSize:{top:44,bottom:"auto"},closeElClasses:["item","caption","zoom-wrap","ui","top-bar"],timeToIdle:4e3,timeToIdleOutside:1e3,loadingIndicatorDelay:1e3,addCaptionHTMLFn:function(a,b){return a.title?(b.children[0].innerHTML=a.title,!0):(b.children[0].innerHTML="",!1)},closeEl:!0,captionEl:!0,fullscreenEl:!0,zoomEl:!0,shareEl:!0,counterEl:!0,arrowEl:!0,preloaderEl:!0,tapToClose:!1,tapToToggleControls:!0,shareButtons:[{id:"facebook",label:"Share on Facebook",url:"https://www.facebook.com/sharer/sharer.php?u={{url}}"},{id:"twitter",label:"Tweet",url:"https://twitter.com/intent/tweet?text={{text}}&url={{url}}"},{id:"pinterest",label:"Pin it",url:"http://www.pinterest.com/pin/create/button/?url={{url}}&media={{image_url}}&description={{text}}"},{id:"download",label:"Download image",url:"{{raw_image_url}}",download:!0}],getImageURLForShare:function(){return a.currItem.src||""},getPageURLForShare:function(){return window.location.href},getTextForShare:function(){return a.currItem.title||""},indexIndicatorSep:" / "},A=function(a){if(r)return!0;a=a||window.event;for(var c,d,e=a.target||a.srcElement,f=e.className,g=0;g<S.length;g++)c=S[g],c.onTap&&f.indexOf("pswp__"+c.name)>-1&&(c.onTap(),d=!0);if(d){a.stopPropagation&&a.stopPropagation(),r=!0;var h=b.features.isOldAndroid?600:30;s=setTimeout(function(){r=!1},h)}},B=function(){return!a.likelyTouchDevice||q.mouseUsed||screen.width>1200},C=function(a,c,d){b[(d?"add":"remove")+"Class"](a,"pswp__"+c)},D=function(){var a=1===q.getNumItemsFn();a!==p&&(C(d,"ui--one-slide",a),p=a)},E=function(){C(i,"share-modal--hidden",y)},F=function(){return y=!y,y?(b.removeClass(i,"pswp__share-modal--fade-in"),setTimeout(function(){y&&E()},300)):(E(),setTimeout(function(){y||b.addClass(i,"pswp__share-modal--fade-in")},30)),y||H(),!1},G=function(b){b=b||window.event;var c=b.target||b.srcElement;return a.shout("shareLinkClick",b,c),c.href?c.hasAttribute("download")?!0:(window.open(c.href,"pswp_share","scrollbars=yes,resizable=yes,toolbar=no,location=yes,width=550,height=420,top=100,left="+(window.screen?Math.round(screen.width/2-275):100)),y||F(),!1):!1},H=function(){for(var a,b,c,d,e,f="",g=0;g<q.shareButtons.length;g++)a=q.shareButtons[g],c=q.getImageURLForShare(a),d=q.getPageURLForShare(a),e=q.getTextForShare(a),b=a.url.replace("{{url}}",encodeURIComponent(d)).replace("{{image_url}}",encodeURIComponent(c)).replace("{{raw_image_url}}",c).replace("{{text}}",encodeURIComponent(e)),f+='<a href="'+b+'" target="_blank" class="pswp__share--'+a.id+'"'+(a.download?"download":"")+">"+a.label+"</a>",q.parseShareButtonOut&&(f=q.parseShareButtonOut(a,f));i.children[0].innerHTML=f,i.children[0].onclick=G},I=function(a){for(var c=0;c<q.closeElClasses.length;c++)if(b.hasClass(a,"pswp__"+q.closeElClasses[c]))return!0},J=0,K=function(){clearTimeout(u),J=0,k&&v.setIdle(!1)},L=function(a){a=a?a:window.event;var b=a.relatedTarget||a.toElement;b&&"HTML"!==b.nodeName||(clearTimeout(u),u=setTimeout(function(){v.setIdle(!0)},q.timeToIdleOutside))},M=function(){q.fullscreenEl&&(c||(c=v.getFullscreenAPI()),c?(b.bind(document,c.eventK,v.updateFullscreen),v.updateFullscreen(),b.addClass(a.template,"pswp--supports-fs")):b.removeClass(a.template,"pswp--supports-fs"))},N=function(){q.preloaderEl&&(O(!0),l("beforeChange",function(){clearTimeout(o),o=setTimeout(function(){a.currItem&&a.currItem.loading?(!a.allowProgressiveImg()||a.currItem.img&&!a.currItem.img.naturalWidth)&&O(!1):O(!0)},q.loadingIndicatorDelay)}),l("imageLoadComplete",function(b,c){a.currItem===c&&O(!0)}))},O=function(a){n!==a&&(C(m,"preloader--active",!a),n=a)},P=function(a){var c=a.vGap;if(B()){var g=q.barsSize;if(q.captionEl&&"auto"===g.bottom)if(f||(f=b.createEl("pswp__caption pswp__caption--fake"),f.appendChild(b.createEl("pswp__caption__center")),d.insertBefore(f,e),b.addClass(d,"pswp__ui--fit")),q.addCaptionHTMLFn(a,f,!0)){var h=f.clientHeight;c.bottom=parseInt(h,10)||44}else c.bottom=g.top;else c.bottom=g.bottom;c.top=g.top}else c.top=c.bottom=0},Q=function(){q.timeToIdle&&l("mouseUsed",function(){b.bind(document,"mousemove",K),b.bind(document,"mouseout",L),t=setInterval(function(){J++,2===J&&v.setIdle(!0)},q.timeToIdle/2)})},R=function(){l("onVerticalDrag",function(a){x&&.95>a?v.hideControls():!x&&a>=.95&&v.showControls()});var a;l("onPinchClose",function(b){x&&.9>b?(v.hideControls(),a=!0):a&&!x&&b>.9&&v.showControls()}),l("zoomGestureEnded",function(){a=!1,a&&!x&&v.showControls()})},S=[{name:"caption",option:"captionEl",onInit:function(a){e=a}},{name:"share-modal",option:"shareEl",onInit:function(a){i=a},onTap:function(){F()}},{name:"button--share",option:"shareEl",onInit:function(a){h=a},onTap:function(){F()}},{name:"button--zoom",option:"zoomEl",onTap:a.toggleDesktopZoom},{name:"counter",option:"counterEl",onInit:function(a){g=a}},{name:"button--close",option:"closeEl",onTap:a.close},{name:"button--arrow--left",option:"arrowEl",onTap:a.prev},{name:"button--arrow--right",option:"arrowEl",onTap:a.next},{name:"button--fs",option:"fullscreenEl",onTap:function(){c.isFullscreen()?c.exit():c.enter()}},{name:"preloader",option:"preloaderEl",onInit:function(a){m=a}}],T=function(){var a,c,e,f=function(d){if(d)for(var f=d.length,g=0;f>g;g++){a=d[g],c=a.className;for(var h=0;h<S.length;h++)e=S[h],c.indexOf("pswp__"+e.name)>-1&&(q[e.option]?(b.removeClass(a,"pswp__element--disabled"),e.onInit&&e.onInit(a)):b.addClass(a,"pswp__element--disabled"))}};f(d.children);var g=b.getChildByClass(d,"pswp__top-bar");g&&f(g.children)};v.init=function(){b.extend(a.options,z,!0),q=a.options,d=b.getChildByClass(a.scrollWrap,"pswp__ui"),l=a.listen,R(),l("beforeChange",v.update),l("doubleTap",function(b){var c=a.currItem.initialZoomLevel;a.getZoomLevel()!==c?a.zoomTo(c,b,333):a.zoomTo(q.getDoubleTapZoom(!1,a.currItem),b,333)}),l("preventDragEvent",function(a,b,c){var d=a.target||a.srcElement;d&&d.className&&a.type.indexOf("mouse")>-1&&(d.className.indexOf("__caption")>0||/(SMALL|STRONG|EM)/i.test(d.tagName))&&(c.prevent=!1)}),l("bindEvents",function(){b.bind(d,"pswpTap click",A),b.bind(a.scrollWrap,"pswpTap",v.onGlobalTap),a.likelyTouchDevice||b.bind(a.scrollWrap,"mouseover",v.onMouseOver)}),l("unbindEvents",function(){y||F(),t&&clearInterval(t),b.unbind(document,"mouseout",L),b.unbind(document,"mousemove",K),b.unbind(d,"pswpTap click",A),b.unbind(a.scrollWrap,"pswpTap",v.onGlobalTap),b.unbind(a.scrollWrap,"mouseover",v.onMouseOver),c&&(b.unbind(document,c.eventK,v.updateFullscreen),c.isFullscreen()&&(q.hideAnimationDuration=0,c.exit()),c=null)}),l("destroy",function(){q.captionEl&&(f&&d.removeChild(f),b.removeClass(e,"pswp__caption--empty")),i&&(i.children[0].onclick=null),b.removeClass(d,"pswp__ui--over-close"),b.addClass(d,"pswp__ui--hidden"),v.setIdle(!1)}),q.showAnimationDuration||b.removeClass(d,"pswp__ui--hidden"),l("initialZoomIn",function(){q.showAnimationDuration&&b.removeClass(d,"pswp__ui--hidden")}),l("initialZoomOut",function(){b.addClass(d,"pswp__ui--hidden")}),l("parseVerticalMargin",P),T(),q.shareEl&&h&&i&&(y=!0),D(),Q(),M(),N()},v.setIdle=function(a){k=a,C(d,"ui--idle",a)},v.update=function(){x&&a.currItem?(v.updateIndexIndicator(),q.captionEl&&(q.addCaptionHTMLFn(a.currItem,e),C(e,"caption--empty",!a.currItem.title)),w=!0):w=!1,D()},v.updateFullscreen=function(){C(a.template,"fs",c.isFullscreen())},v.updateIndexIndicator=function(){q.counterEl&&(g.innerHTML=a.getCurrentIndex()+1+q.indexIndicatorSep+q.getNumItemsFn())},v.onGlobalTap=function(c){c=c||window.event;var d=c.target||c.srcElement;if(!r)if(c.detail&&"mouse"===c.detail.pointerType)I(d)&&a.close(),b.hasClass(d,"pswp__img")&&(1===a.getZoomLevel()&&a.getZoomLevel()<=a.currItem.fitRatio?a.close():a.toggleDesktopZoom(c.detail.releasePoint));else if(q.tapToToggleControls&&(x?v.hideControls():v.showControls()),q.tapToClose&&(b.hasClass(d,"pswp__img")||I(d)))return void a.close()},v.onMouseOver=function(a){a=a||window.event;var b=a.target||a.srcElement;C(d,"ui--over-close",I(b))},v.hideControls=function(){b.addClass(d,"pswp__ui--hidden"),x=!1},v.showControls=function(){x=!0,w||v.update(),b.removeClass(d,"pswp__ui--hidden")},v.supportsFullscreen=function(){var a=document;return!!(a.exitFullscreen||a.mozCancelFullScreen||a.webkitExitFullscreen||a.msExitFullscreen)},v.getFullscreenAPI=function(){var b,c=document.documentElement,d="fullscreenchange";return c.requestFullscreen?b={enterK:"requestFullscreen",exitK:"exitFullscreen",elementK:"fullscreenElement",eventK:d}:c.mozRequestFullScreen?b={enterK:"mozRequestFullScreen",exitK:"mozCancelFullScreen",elementK:"mozFullScreenElement",eventK:"moz"+d}:c.webkitRequestFullscreen?b={enterK:"webkitRequestFullscreen",exitK:"webkitExitFullscreen",elementK:"webkitFullscreenElement",eventK:"webkit"+d}:c.msRequestFullscreen&&(b={enterK:"msRequestFullscreen",exitK:"msExitFullscreen",elementK:"msFullscreenElement",eventK:"MSFullscreenChange"}),b&&(b.enter=function(){return j=q.closeOnScroll,q.closeOnScroll=!1,"webkitRequestFullscreen"!==this.enterK?a.template[this.enterK]():void a.template[this.enterK](Element.ALLOW_KEYBOARD_INPUT)},b.exit=function(){return q.closeOnScroll=j,document[this.exitK]()},b.isFullscreen=function(){return document[this.elementK]}),b}};return a});
\ No newline at end of file
diff --git a/data/ext/perspectiveImageSwiper/dist/photoswipe.css b/data/ext/perspectiveImageSwiper/dist/photoswipe.css
new file mode 100644
index 000000000..e4950eb2b
--- /dev/null
+++ b/data/ext/perspectiveImageSwiper/dist/photoswipe.css
@@ -0,0 +1,148 @@
+/*! PhotoSwipe main CSS by Dmitry Semenov | photoswipe.com | MIT license */
+.pswp {
+ display: none;
+ position: absolute;
+ width: 100%;
+ height: 100%;
+ left: 0;
+ top: 0;
+ overflow: hidden;
+ -ms-touch-action: none;
+ touch-action: none;
+ z-index: 1500;
+ -webkit-text-size-adjust: 100%;
+ -webkit-backface-visibility: hidden;
+ outline: none; }
+ .pswp * {
+ -webkit-box-sizing: border-box;
+ box-sizing: border-box; }
+ .pswp img {
+ max-width: none; }
+
+.pswp--animate_opacity {
+ opacity: 0.001;
+ will-change: opacity;
+ -webkit-transition: opacity 333ms cubic-bezier(0.4, 0, 0.22, 1);
+ transition: opacity 333ms cubic-bezier(0.4, 0, 0.22, 1); }
+
+.pswp--open {
+ display: block; }
+
+.pswp--zoom-allowed .pswp__img {
+ /* autoprefixer: off */
+ cursor: -webkit-zoom-in;
+ cursor: -moz-zoom-in;
+ cursor: zoom-in; }
+
+.pswp--zoomed-in .pswp__img {
+ /* autoprefixer: off */
+ cursor: -webkit-grab;
+ cursor: -moz-grab;
+ cursor: grab; }
+
+.pswp--dragging .pswp__img {
+ /* autoprefixer: off */
+ cursor: -webkit-grabbing;
+ cursor: -moz-grabbing;
+ cursor: grabbing; }
+
+.pswp__bg {
+ position: absolute;
+ left: 0;
+ top: 0;
+ width: 100%;
+ height: 100%;
+ background: #000;
+ opacity: 0;
+ -webkit-backface-visibility: hidden;
+ will-change: opacity; }
+
+.pswp__scroll-wrap {
+ position: absolute;
+ left: 0;
+ top: 0;
+ width: 100%;
+ height: 100%;
+ -webkit-backface-visibility: hidden;
+ will-change: transform; }
+
+.pswp__container, .pswp__zoom-wrap {
+ -ms-touch-action: none;
+ touch-action: none;
+ position: absolute;
+ left: 0;
+ right: 0;
+ top: 0;
+ bottom: 0; }
+
+.pswp__container, .pswp__img {
+ -webkit-user-select: none;
+ -moz-user-select: none;
+ -ms-user-select: none;
+ user-select: none;
+ -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
+ -webkit-touch-callout: none; }
+
+.pswp__zoom-wrap {
+ position: absolute;
+ width: 100%;
+ -webkit-transform-origin: left top;
+ -ms-transform-origin: left top;
+ transform-origin: left top;
+ -webkit-transition: -webkit-transform 333ms cubic-bezier(0.4, 0, 0.22, 1);
+ transition: transform 333ms cubic-bezier(0.4, 0, 0.22, 1); }
+
+.pswp__bg {
+ will-change: opacity;
+ -webkit-transition: opacity 333ms cubic-bezier(0.4, 0, 0.22, 1);
+ transition: opacity 333ms cubic-bezier(0.4, 0, 0.22, 1); }
+
+.pswp--animated-in .pswp__bg, .pswp--animated-in .pswp__zoom-wrap {
+ -webkit-transition: none;
+ transition: none; }
+
+.pswp__container, .pswp__zoom-wrap {
+ -webkit-backface-visibility: hidden;
+ will-change: transform; }
+
+.pswp__item {
+ position: absolute;
+ left: 0;
+ right: 0;
+ top: 0;
+ bottom: 0;
+ overflow: hidden; }
+
+.pswp__img {
+ position: absolute;
+ width: auto;
+ height: auto;
+ -webkit-transition: opacity 0.15s;
+ transition: opacity 0.15s; }
+
+.pswp__img--placeholder {
+ -webkit-backface-visibility: hidden; }
+
+.pswp__img--placeholder--blank {
+ background: #222; }
+
+.pswp--ie .pswp__img {
+ width: 100%;
+ height: 100%;
+ left: 0;
+ top: 0; }
+
+.pswp__error-msg {
+ position: absolute;
+ left: 0;
+ top: 50%;
+ width: 100%;
+ text-align: center;
+ font-size: 14px;
+ line-height: 16px;
+ margin-top: -8px;
+ color: #CCC; }
+
+.pswp__error-msg a {
+ color: #CCC;
+ text-decoration: underline; }
diff --git a/data/ext/perspectiveImageSwiper/dist/photoswipe.js b/data/ext/perspectiveImageSwiper/dist/photoswipe.js
new file mode 100644
index 000000000..b5547683d
--- /dev/null
+++ b/data/ext/perspectiveImageSwiper/dist/photoswipe.js
@@ -0,0 +1,3641 @@
+/*! PhotoSwipe - v4.0.3 - 2015-01-09
+* http://photoswipe.com
+* Copyright (c) 2015 Dmitry Semenov; */
+(function (root, factory) {
+ if (typeof define === 'function' && define.amd) {
+ define(factory);
+ } else if (typeof exports === 'object') {
+ module.exports = factory();
+ } else {
+ root.PhotoSwipe = factory();
+ }
+})(this, function () {
+
+ 'use strict';
+ var PhotoSwipe = function(template, UiClass, items, options){
+
+/*>>framework-bridge*/
+/**
+ *
+ * Set of generic functions used by gallery.
+ *
+ * You're free to modify anything here as long as functionality is kept.
+ *
+ */
+var framework = {
+ features: null,
+ bind: function(target, type, listener, unbind) {
+ var methodName = (unbind ? 'remove' : 'add') + 'EventListener';
+ type = type.split(' ');
+ for(var i = 0; i < type.length; i++) {
+ if(type[i]) {
+ target[methodName]( type[i], listener, false);
+ }
+ }
+ },
+ isArray: function(obj) {
+ return (obj instanceof Array);
+ },
+ createEl: function(classes, tag) {
+ var el = document.createElement(tag || 'div');
+ if(classes) {
+ el.className = classes;
+ }
+ return el;
+ },
+ getScrollY: function() {
+ var yOffset = window.pageYOffset;
+ return yOffset !== undefined ? yOffset : document.documentElement.scrollTop;
+ },
+ unbind: function(target, type, listener) {
+ framework.bind(target,type,listener,true);
+ },
+ removeClass: function(el, className) {
+ var reg = new RegExp('(\\s|^)' + className + '(\\s|$)');
+ el.className = el.className.replace(reg, ' ').replace(/^\s\s*/, '').replace(/\s\s*$/, '');
+ },
+ addClass: function(el, className) {
+ if( !framework.hasClass(el,className) ) {
+ el.className += (el.className ? ' ' : '') + className;
+ }
+ },
+ hasClass: function(el, className) {
+ return el.className && new RegExp('(^|\\s)' + className + '(\\s|$)').test(el.className);
+ },
+ getChildByClass: function(parentEl, childClassName) {
+ var node = parentEl.firstChild;
+ while(node) {
+ if( framework.hasClass(node, childClassName) ) {
+ return node;
+ }
+ node = node.nextSibling;
+ }
+ },
+ arraySearch: function(array, value, key) {
+ var i = array.length;
+ while(i--) {
+ if(array[i][key] === value) {
+ return i;
+ }
+ }
+ return -1;
+ },
+ extend: function(o1, o2, preventOverwrite) {
+ for (var prop in o2) {
+ if (o2.hasOwnProperty(prop)) {
+ if(preventOverwrite && o1.hasOwnProperty(prop)) {
+ continue;
+ }
+ o1[prop] = o2[prop];
+ }
+ }
+ },
+ easing: {
+ sine: {
+ out: function(k) {
+ return Math.sin(k * (Math.PI / 2));
+ },
+ inOut: function(k) {
+ return - (Math.cos(Math.PI * k) - 1) / 2;
+ }
+ },
+ cubic: {
+ out: function(k) {
+ return --k * k * k + 1;
+ }
+ }
+ /*
+ elastic: {
+ out: function ( k ) {
+
+ var s, a = 0.1, p = 0.4;
+ if ( k === 0 ) return 0;
+ if ( k === 1 ) return 1;
+ if ( !a || a < 1 ) { a = 1; s = p / 4; }
+ else s = p * Math.asin( 1 / a ) / ( 2 * Math.PI );
+ return ( a * Math.pow( 2, - 10 * k) * Math.sin( ( k - s ) * ( 2 * Math.PI ) / p ) + 1 );
+
+ },
+ },
+ back: {
+ out: function ( k ) {
+ var s = 1.70158;
+ return --k * k * ( ( s + 1 ) * k + s ) + 1;
+ }
+ }
+ */
+ },
+
+ /**
+ *
+ * @return {object}
+ *
+ * {
+ * raf : request animation frame function
+ * caf : cancel animation frame function
+ * transfrom : transform property key (with vendor), or null if not supported
+ * oldIE : IE8 or below
+ * }
+ *
+ */
+ detectFeatures: function() {
+ if(framework.features) {
+ return framework.features;
+ }
+ var helperEl = framework.createEl(),
+ helperStyle = helperEl.style,
+ vendor = '',
+ features = {};
+
+ // IE8 and below
+ features.oldIE = document.all && !document.addEventListener;
+
+ features.touch = 'ontouchstart' in window;
+
+ if(window.requestAnimationFrame) {
+ features.raf = window.requestAnimationFrame;
+ features.caf = window.cancelAnimationFrame;
+ }
+
+ features.pointerEvent = navigator.pointerEnabled || navigator.msPointerEnabled;
+
+ // fix false-positive detection of old Android in new IE
+ // (IE11 ua string contains "Android 4.0")
+
+ if(!features.pointerEvent) {
+
+ var ua = navigator.userAgent;
+
+ // Detect if device is iPhone or iPod and if it's older than iOS 8
+ // http://stackoverflow.com/a/14223920
+ //
+ // This detection is made because of buggy top/bottom toolbars
+ // that don't trigger window.resize event.
+ // For more info refer to _isFixedPosition variable in core.js
+
+ if (/iP(hone|od)/.test(navigator.platform)) {
+ var v = (navigator.appVersion).match(/OS (\d+)_(\d+)_?(\d+)?/);
+ if(v && v.length > 0) {
+ v = parseInt(v[1], 10);
+ if(v >= 1 && v < 8 ) {
+ features.isOldIOSPhone = true;
+ }
+ }
+ }
+
+ // Detect old Android (before KitKat)
+ // due to bugs related to position:fixed
+ // http://stackoverflow.com/questions/7184573/pick-up-the-android-version-in-the-browser-by-javascript
+
+ var match = ua.match(/Android\s([0-9\.]*)/);
+ var androidversion = match ? match[1] : 0;
+ androidversion = parseFloat(androidversion);
+ if(androidversion >= 1 ) {
+ if(androidversion < 4.4) {
+ features.isOldAndroid = true; // for fixed position bug & performance
+ }
+ features.androidVersion = androidversion; // for touchend bug
+ }
+ features.isMobileOpera = /opera mini|opera mobi/i.test(ua);
+
+ // p.s. yes, yes, UA sniffing is bad, propose your solution for above bugs.
+ }
+
+ var styleChecks = ['transform', 'perspective', 'animationName'],
+ vendors = ['', 'webkit','Moz','ms','O'],
+ styleCheckItem,
+ styleName;
+
+ for(var i = 0; i < 4; i++) {
+ vendor = vendors[i];
+
+ for(var a = 0; a < 3; a++) {
+ styleCheckItem = styleChecks[a];
+
+ // uppercase first letter of property name, if vendor is present
+ styleName = vendor + (vendor ?
+ styleCheckItem.charAt(0).toUpperCase() + styleCheckItem.slice(1) :
+ styleCheckItem);
+
+ if(!features[styleCheckItem] && styleName in helperStyle ) {
+ features[styleCheckItem] = styleName;
+ }
+ }
+
+ if(vendor && !features.raf) {
+ vendor = vendor.toLowerCase();
+ features.raf = window[vendor+'RequestAnimationFrame'];
+ if(features.raf) {
+ features.caf = window[vendor+'CancelAnimationFrame'] ||
+ window[vendor+'CancelRequestAnimationFrame'];
+ }
+ }
+ }
+
+ if(!features.raf) {
+ var lastTime = 0;
+ features.raf = function(fn) {
+ var currTime = new Date().getTime();
+ var timeToCall = Math.max(0, 16 - (currTime - lastTime));
+ var id = window.setTimeout(function() { fn(currTime + timeToCall); }, timeToCall);
+ lastTime = currTime + timeToCall;
+ return id;
+ };
+ features.caf = function(id) { clearTimeout(id); };
+ }
+
+ // Detect SVG support
+ features.svg = !!document.createElementNS &&
+ !!document.createElementNS('http://www.w3.org/2000/svg', 'svg').createSVGRect;
+
+ framework.features = features;
+
+ return features;
+ }
+};
+
+framework.detectFeatures();
+
+// Override addEventListener for old versions of IE
+if(framework.features.oldIE) {
+
+ framework.bind = function(target, type, listener, unbind) {
+
+ type = type.split(' ');
+
+ var methodName = (unbind ? 'detach' : 'attach') + 'Event',
+ evName,
+ _handleEv = function() {
+ listener.handleEvent.call(listener);
+ };
+
+ for(var i = 0; i < type.length; i++) {
+ evName = type[i];
+ if(evName) {
+
+ if(typeof listener === 'object' && listener.handleEvent) {
+ if(!unbind) {
+ listener['oldIE' + evName] = _handleEv;
+ } else {
+ if(!listener['oldIE' + evName]) {
+ return false;
+ }
+ }
+
+ target[methodName]( 'on' + evName, listener['oldIE' + evName]);
+ } else {
+ target[methodName]( 'on' + evName, listener);
+ }
+
+ }
+ }
+ };
+
+}
+
+/*>>framework-bridge*/
+
+/*>>core*/
+//function(template, UiClass, items, options)
+
+var self = this;
+
+/**
+ * Static vars, don't change unless you know what you're doing.
+ */
+var DOUBLE_TAP_RADIUS = 25,
+ NUM_HOLDERS = 3;
+
+/**
+ * Options
+ */
+var _options = {
+ allowPanToNext:true,
+ spacing: 0.12,
+ bgOpacity: 1,
+ mouseUsed: false,
+ loop: true,
+ pinchToClose: true,
+ closeOnScroll: true,
+ closeOnVerticalDrag: true,
+ hideAnimationDuration: 333,
+ showAnimationDuration: 333,
+ showHideOpacity: false,
+ focus: true,
+ escKey: true,
+ arrowKeys: true,
+ mainScrollEndFriction: 0.35,
+ panEndFriction: 0.35,
+ isClickableElement: function(el) {
+ return el.tagName === 'A';
+ },
+ getDoubleTapZoom: function(isMouseClick, item) {
+ if(isMouseClick) {
+ return 1;
+ } else {
+ return item.initialZoomLevel < 0.7 ? 1 : 1.5;
+ }
+ },
+ maxSpreadZoom: 2,
+
+ // not fully implemented yet
+ scaleMode: 'fit', // TODO
+ modal: true, // TODO
+ alwaysFadeIn: false // TODO
+};
+framework.extend(_options, options);
+
+
+/**
+ * Private helper variables & functions
+ */
+
+var _getEmptyPoint = function() {
+ return {x:0,y:0};
+ };
+
+var _isOpen,
+ _isDestroying,
+ _closedByScroll,
+ _currentItemIndex,
+ _containerStyle,
+ _containerShiftIndex,
+ _currPanDist = _getEmptyPoint(),
+ _startPanOffset = _getEmptyPoint(),
+ _panOffset = _getEmptyPoint(),
+ _upMoveEvents, // drag move, drag end & drag cancel events array
+ _downEvents, // drag start events array
+ _globalEventHandlers,
+ _viewportSize = {},
+ _currZoomLevel,
+ _startZoomLevel,
+ _translatePrefix,
+ _translateSufix,
+ _updateSizeInterval,
+ _itemsNeedUpdate,
+ _currPositionIndex = 0,
+ _offset,
+ _slideSize = _getEmptyPoint(), // size of slide area, including spacing
+ _scrollChanged,
+ _itemHolders,
+ _prevItemIndex,
+ _indexDiff = 0, // difference of indexes since last content update
+ _dragStartEvent,
+ _dragMoveEvent,
+ _dragEndEvent,
+ _dragCancelEvent,
+ _transformKey,
+ _pointerEventEnabled,
+ _isFixedPosition = true,
+ _likelyTouchDevice,
+ _modules = [],
+ _requestAF,
+ _cancelAF,
+ _initalClassName,
+ _initalWindowScrollY,
+ _oldIE,
+ _currentWindowScrollY,
+ _features,
+ _windowVisibleSize = {},
+
+ // Registers PhotoSWipe module (History, Controller ...)
+ _registerModule = function(name, module) {
+ framework.extend(self, module.publicMethods);
+ _modules.push(name);
+ },
+
+ _getLoopedId = function(index) {
+ var numSlides = _getNumItems();
+ if(index > numSlides - 1) {
+ return index - numSlides;
+ } else if(index < 0) {
+ return numSlides + index;
+ }
+ return index;
+ },
+
+ // Micro bind/trigger
+ _listeners = {},
+ _listen = function(name, fn) {
+ if(!_listeners[name]) {
+ _listeners[name] = [];
+ }
+ return _listeners[name].push(fn);
+ },
+ _shout = function(name) {
+ var listeners = _listeners[name];
+
+ if(listeners) {
+ var args = Array.prototype.slice.call(arguments);
+ args.shift();
+
+ for(var i = 0; i < listeners.length; i++) {
+ listeners[i].apply(self, args);
+ }
+ }
+ },
+
+ _getCurrentTime = function() {
+ return new Date().getTime();
+ },
+ _applyBgOpacity = function(opacity) {
+ _bgOpacity = opacity;
+ self.bg.style.opacity = opacity * _options.bgOpacity;
+ },
+
+ _applyZoomTransform = function(styleObj,x,y,zoom) {
+ styleObj[_transformKey] = _translatePrefix + x + 'px, ' + y + 'px' + _translateSufix + ' scale(' + zoom + ')';
+ },
+ _applyCurrentZoomPan = function() {
+ if(_currZoomElementStyle) {
+ _applyZoomTransform(_currZoomElementStyle, _panOffset.x, _panOffset.y, _currZoomLevel);
+ }
+ },
+ _applyZoomPanToItem = function(item) {
+ if(item.container) {
+ _applyZoomTransform(item.container.style,
+ item.initialPosition.x,
+ item.initialPosition.y,
+ item.initialZoomLevel);
+ }
+ },
+ _setTranslateX = function(x, elStyle) {
+ elStyle[_transformKey] = _translatePrefix + x + 'px, 0px' + _translateSufix;
+ },
+ _moveMainScroll = function(x, dragging) {
+
+ if(!_options.loop && dragging) {
+ // if of current item during scroll (float)
+ var newSlideIndexOffset = _currentItemIndex + (_slideSize.x * _currPositionIndex - x)/_slideSize.x;
+ var delta = Math.round(x - _mainScrollPos.x);
+
+ if( (newSlideIndexOffset < 0 && delta > 0) ||
+ (newSlideIndexOffset >= _getNumItems()-1 && delta < 0) ) {
+ x = _mainScrollPos.x + delta * _options.mainScrollEndFriction;
+ }
+ }
+
+ _mainScrollPos.x = x;
+ _setTranslateX(x, _containerStyle);
+ },
+ _calculatePanOffset = function(axis, zoomLevel) {
+ var m = _midZoomPoint[axis] - _offset[axis];
+ return _startPanOffset[axis] + _currPanDist[axis] + m - m * ( zoomLevel / _startZoomLevel );
+ },
+
+ _equalizePoints = function(p1, p2) {
+ p1.x = p2.x;
+ p1.y = p2.y;
+ if(p2.id) {
+ p1.id = p2.id;
+ }
+ },
+ _roundPoint = function(p) {
+ p.x = Math.round(p.x);
+ p.y = Math.round(p.y);
+ },
+
+ _mouseMoveTimeout = null,
+ _onFirstMouseMove = function() {
+ // Wait until mouse move event is fired at least twice during 100ms
+ // We do this, because some mobile browsers trigger it on touchstart
+ if(_mouseMoveTimeout ) {
+ framework.unbind(document, 'mousemove', _onFirstMouseMove);
+ framework.addClass(template, 'pswp--has_mouse');
+ _options.mouseUsed = true;
+ _shout('mouseUsed');
+ }
+ _mouseMoveTimeout = setTimeout(function() {
+ _mouseMoveTimeout = null;
+ }, 100);
+ },
+
+ _bindEvents = function() {
+ framework.bind(document, 'keydown', self);
+
+ if(_features.transform) {
+ // don't bind click event in browsers that don't support transform (mostly IE8)
+ framework.bind(self.scrollWrap, 'click', self);
+ }
+
+
+ if(!_options.mouseUsed) {
+ framework.bind(document, 'mousemove', _onFirstMouseMove);
+ }
+
+ framework.bind(window, 'resize scroll', self);
+
+ _shout('bindEvents');
+ },
+
+ _unbindEvents = function() {
+ framework.unbind(window, 'resize', self);
+ framework.unbind(window, 'scroll', _globalEventHandlers.scroll);
+ framework.unbind(document, 'keydown', self);
+ framework.unbind(document, 'mousemove', _onFirstMouseMove);
+
+ if(_features.transform) {
+ framework.unbind(self.scrollWrap, 'click', self);
+ }
+
+ if(_isDragging) {
+ framework.unbind(window, _upMoveEvents, self);
+ }
+
+ _shout('unbindEvents');
+ },
+
+ _calculatePanBounds = function(zoomLevel, update) {
+ var bounds = _calculateItemSize( self.currItem, _viewportSize, zoomLevel );
+ if(update) {
+ _currPanBounds = bounds;
+ }
+ return bounds;
+ },
+
+ _getMinZoomLevel = function(item) {
+ if(!item) {
+ item = self.currItem;
+ }
+ return item.initialZoomLevel;
+ },
+ _getMaxZoomLevel = function(item) {
+ if(!item) {
+ item = self.currItem;
+ }
+ return item.w > 0 ? _options.maxSpreadZoom : 1;
+ },
+
+ // Return true if offset is out of the bounds
+ _modifyDestPanOffset = function(axis, destPanBounds, destPanOffset, destZoomLevel) {
+ if(destZoomLevel === self.currItem.initialZoomLevel) {
+ destPanOffset[axis] = self.currItem.initialPosition[axis];
+ return true;
+ } else {
+ destPanOffset[axis] = _calculatePanOffset(axis, destZoomLevel);
+
+ if(destPanOffset[axis] > destPanBounds.min[axis]) {
+ destPanOffset[axis] = destPanBounds.min[axis];
+ return true;
+ } else if(destPanOffset[axis] < destPanBounds.max[axis] ) {
+ destPanOffset[axis] = destPanBounds.max[axis];
+ return true;
+ }
+ }
+ return false;
+ },
+
+ _setupTransforms = function() {
+
+ if(_transformKey) {
+ // setup 3d transforms
+ var allow3dTransform = _features.perspective && !_likelyTouchDevice;
+ _translatePrefix = 'translate' + (allow3dTransform ? '3d(' : '(');
+ _translateSufix = _features.perspective ? ', 0px)' : ')';
+ return;
+ }
+
+ // Override zoom/pan/move functions in case old browser is used (most likely IE)
+ // (so they use left/top/width/height, instead of CSS transform)
+
+ _transformKey = 'left';
+ framework.addClass(template, 'pswp--ie');
+
+ _setTranslateX = function(x, elStyle) {
+ elStyle.left = x + 'px';
+ };
+ _applyZoomPanToItem = function(item) {
+
+ var s = item.container.style,
+ w = item.fitRatio * item.w,
+ h = item.fitRatio * item.h;
+
+ s.width = w + 'px';
+ s.height = h + 'px';
+ s.left = item.initialPosition.x + 'px';
+ s.top = item.initialPosition.y + 'px';
+
+ };
+ _applyCurrentZoomPan = function() {
+ if(_currZoomElementStyle) {
+ var s = _currZoomElementStyle;
+ var item = self.currItem;
+
+ var w = item.fitRatio * item.w;
+ var h = item.fitRatio * item.h;
+
+ s.width = w + 'px';
+ s.height = h + 'px';
+
+
+ s.left = _panOffset.x + 'px';
+ s.top = _panOffset.y + 'px';
+ }
+
+ };
+ },
+
+ _onKeyDown = function(e) {
+ var keydownAction = '';
+ if(_options.escKey && e.keyCode === 27) {
+ keydownAction = 'close';
+ } else if(_options.arrowKeys) {
+ if(e.keyCode === 37) {
+ keydownAction = 'prev';
+ } else if(e.keyCode === 39) {
+ keydownAction = 'next';
+ }
+ }
+
+ if(keydownAction) {
+ // don't do anything if special key pressed to prevent from overriding default browser actions
+ // e.g. in Chrome on Mac cmd+arrow-left returns to previous page
+ if( !e.ctrlKey && !e.altKey && !e.shiftKey && !e.metaKey ) {
+ if(e.preventDefault) {
+ e.preventDefault();
+ } else {
+ e.returnValue = false;
+ }
+ self[keydownAction]();
+ }
+ }
+ },
+
+ _onGlobalClick = function(e) {
+ if(!e) {
+ return;
+ }
+
+ // don't allow click event to pass through when triggering after drag or some other gesture
+ if(_moved || _zoomStarted || _mainScrollAnimating || _verticalDragInitiated) {
+ e.preventDefault();
+ e.stopPropagation();
+ }
+ },
+
+ _onPageScroll = function() {
+ _scrollChanged = true;
+ // "close" on scroll works only on desktop devices, or when mouse is used
+ if(_options.closeOnScroll && _isOpen && (!self.likelyTouchDevice || _options.mouseUsed) ) {
+ // if scrolled for more than 2px
+ if(Math.abs(framework.getScrollY() - _initalWindowScrollY) > 2) {
+ _closedByScroll = true;
+ self.close();
+ }
+ }
+ };
+
+
+
+
+
+
+
+// Micro animation engine
+var _animations = {},
+ _numAnimations = 0,
+ _stopAnimation = function(name) {
+ if(_animations[name]) {
+ if(_animations[name].raf) {
+ _cancelAF( _animations[name].raf );
+ }
+ _numAnimations--;
+ delete _animations[name];
+ }
+ },
+ _registerStartAnimation = function(name) {
+ if(_animations[name]) {
+ _stopAnimation(name);
+ }
+ if(!_animations[name]) {
+ _numAnimations++;
+ _animations[name] = {};
+ }
+ },
+ _stopAllAnimations = function() {
+ for (var prop in _animations) {
+
+ if( _animations.hasOwnProperty( prop ) ) {
+ _stopAnimation(prop);
+ }
+
+ }
+ },
+ _animateProp = function(name, b, endProp, d, easingFn, onUpdate, onComplete) {
+ var startAnimTime = _getCurrentTime(), t;
+ _registerStartAnimation(name);
+
+ var animloop = function(){
+ if ( _animations[name] ) {
+
+ t = _getCurrentTime() - startAnimTime; // time diff
+ //b - beginning (start prop)
+ //d - anim duration
+
+ if ( t >= d ) {
+ _stopAnimation(name);
+ onUpdate(endProp);
+ if(onComplete) {
+ onComplete();
+ }
+ return;
+ }
+ onUpdate( (endProp - b) * easingFn(t/d) + b );
+
+ _animations[name].raf = _requestAF(animloop);
+ }
+ };
+ animloop();
+ };
+
+
+
+var publicMethods = {
+
+ // make a few local variables and functions public
+ shout: _shout,
+ listen: _listen,
+ viewportSize: _viewportSize,
+ options: _options,
+
+ isMainScrollAnimating: function() {
+ return _mainScrollAnimating;
+ },
+ getZoomLevel: function() {
+ return _currZoomLevel;
+ },
+ getCurrentIndex: function() {
+ return _currentItemIndex;
+ },
+ isDragging: function() {
+ return _isDragging;
+ },
+ isZooming: function() {
+ return _isZooming;
+ },
+ applyZoomPan: function(zoomLevel,panX,panY) {
+ _panOffset.x = panX;
+ _panOffset.y = panY;
+ _currZoomLevel = zoomLevel;
+ _applyCurrentZoomPan();
+ },
+
+ init: function() {
+
+ if(_isOpen || _isDestroying) {
+ return;
+ }
+
+ var i;
+
+ self.framework = framework; // basic function
+ self.template = template; // root DOM element of PhotoSwipe
+ self.bg = framework.getChildByClass(template, 'pswp__bg');
+
+ _initalClassName = template.className;
+ _isOpen = true;
+
+ _features = framework.detectFeatures();
+ _requestAF = _features.raf;
+ _cancelAF = _features.caf;
+ _transformKey = _features.transform;
+ _oldIE = _features.oldIE;
+
+ self.scrollWrap = framework.getChildByClass(template, 'pswp__scroll-wrap');
+ self.container = framework.getChildByClass(self.scrollWrap, 'pswp__container');
+
+ _containerStyle = self.container.style; // for fast access
+
+ // Objects that hold slides (there are only 3 in DOM)
+ self.itemHolders = _itemHolders = [
+ {el:self.container.children[0] , wrap:0, index: -1},
+ {el:self.container.children[1] , wrap:0, index: -1},
+ {el:self.container.children[2] , wrap:0, index: -1}
+ ];
+
+ // hide nearby item holders until initial zoom animation finishes (to avoid extra Paints)
+ _itemHolders[0].el.style.display = _itemHolders[2].el.style.display = 'none';
+
+ _setupTransforms();
+
+ // Setup global events
+ _globalEventHandlers = {
+ resize: self.updateSize,
+ scroll: _onPageScroll,
+ keydown: _onKeyDown,
+ click: _onGlobalClick
+ };
+
+ // disable show/hide effects on old browsers that don't support CSS animations or transforms,
+ // old IOS, Android and Opera mobile. Blackberry seems to work fine, even older models.
+ var oldPhone = _features.isOldIOSPhone || _features.isOldAndroid || _features.isMobileOpera;
+ if(!_features.animationName || !_features.transform || oldPhone) {
+ _options.showAnimationDuration = _options.hideAnimationDuration = 0;
+ }
+
+ // init modules
+ for(i = 0; i < _modules.length; i++) {
+ self['init' + _modules[i]]();
+ }
+
+ // init
+ if(UiClass) {
+ var ui = self.ui = new UiClass(self, framework);
+ ui.init();
+ }
+
+ _shout('firstUpdate');
+ _currentItemIndex = _currentItemIndex || _options.index || 0;
+ // validate index
+ if( isNaN(_currentItemIndex) || _currentItemIndex < 0 || _currentItemIndex >= _getNumItems() ) {
+ _currentItemIndex = 0;
+ }
+ self.currItem = _getItemAt( _currentItemIndex );
+
+
+ if(_features.isOldIOSPhone || _features.isOldAndroid) {
+ _isFixedPosition = false;
+ }
+
+ if(_options.modal) {
+ template.setAttribute('aria-hidden', 'false');
+ if(!_isFixedPosition) {
+ template.style.position = 'absolute';
+ template.style.top = framework.getScrollY() + 'px';
+ } else {
+ template.style.position = 'fixed';
+ }
+ }
+
+ if(_currentWindowScrollY === undefined) {
+ _shout('initialLayout');
+ _currentWindowScrollY = _initalWindowScrollY = framework.getScrollY();
+ }
+
+ // add classes to root element of PhotoSwipe
+ var rootClasses = 'pswp--open ';
+ if(_options.mainClass) {
+ rootClasses += _options.mainClass + ' ';
+ }
+ if(_options.showHideOpacity) {
+ rootClasses += 'pswp--animate_opacity ';
+ }
+ rootClasses += _likelyTouchDevice ? 'pswp--touch' : 'pswp--notouch';
+ rootClasses += _features.animationName ? ' pswp--css_animation' : '';
+ rootClasses += _features.svg ? ' pswp--svg' : '';
+ framework.addClass(template, rootClasses);
+
+ self.updateSize();
+
+ // initial update
+ _containerShiftIndex = -1;
+ _indexDiff = null;
+ for(i = 0; i < NUM_HOLDERS; i++) {
+ _setTranslateX( (i+_containerShiftIndex) * _slideSize.x, _itemHolders[i].el.style);
+ }
+
+ if(!_oldIE) {
+ framework.bind(self.scrollWrap, _downEvents, self); // no dragging for old IE
+ }
+
+ _listen('initialZoomInEnd', function() {
+ self.setContent(_itemHolders[0], _currentItemIndex-1);
+ self.setContent(_itemHolders[2], _currentItemIndex+1);
+
+ _itemHolders[0].el.style.display = _itemHolders[2].el.style.display = 'block';
+
+ if(_options.focus) {
+ // focus causes layout,
+ // which causes lag during the animation,
+ // that's why we delay it untill the initial zoom transition ends
+ template.focus();
+ }
+
+
+ _bindEvents();
+ });
+
+ // set content for center slide (first time)
+ self.setContent(_itemHolders[1], _currentItemIndex);
+
+ self.updateCurrItem();
+
+ _shout('afterInit');
+
+ if(!_isFixedPosition) {
+
+ // On all versions of iOS lower than 8.0, we check size of viewport every second.
+ //
+ // This is done to detect when Safari top & bottom bars appear,
+ // as this action doesn't trigger any events (like resize).
+ //
+ // On iOS8 they fixed this.
+ //
+ // 10 Nov 2014: iOS 7 usage ~40%. iOS 8 usage 56%.
+
+ _updateSizeInterval = setInterval(function() {
+ if(!_numAnimations && !_isDragging && !_isZooming && (_currZoomLevel === self.currItem.initialZoomLevel) ) {
+ self.updateSize();
+ }
+ }, 1000);
+ }
+
+ framework.addClass(template, 'pswp--visible');
+ },
+
+ // Closes the gallery, then destroy it
+ close: function() {
+ if(!_isOpen) {
+ return;
+ }
+
+ _isOpen = false;
+ _isDestroying = true;
+ _shout('close');
+ _unbindEvents();
+
+ _showOrHide( self.currItem, null, true, self.destroy);
+ },
+
+ // destroys gallery (unbinds events, cleans up intervals and timeouts to avoid memory leaks)
+ destroy: function() {
+ _shout('destroy');
+
+ if(_showOrHideTimeout) {
+ clearTimeout(_showOrHideTimeout);
+ }
+
+ if(_options.modal) {
+ template.setAttribute('aria-hidden', 'true');
+ template.className = _initalClassName;
+ }
+
+ if(_updateSizeInterval) {
+ clearInterval(_updateSizeInterval);
+ }
+
+ framework.unbind(self.scrollWrap, _downEvents, self);
+
+ // we unbind lost event at the end, as closing animation may depend on it
+ framework.unbind(window, 'scroll', self);
+
+ _stopDragUpdateLoop();
+
+ _stopAllAnimations();
+
+ _listeners = null;
+ },
+
+ /**
+ * Pan image to position
+ * @param {Number} x
+ * @param {Number} y
+ * @param {Boolean} force Will ignore bounds if set to true.
+ */
+ panTo: function(x,y,force) {
+ if(!force) {
+ if(x > _currPanBounds.min.x) {
+ x = _currPanBounds.min.x;
+ } else if(x < _currPanBounds.max.x) {
+ x = _currPanBounds.max.x;
+ }
+
+ if(y > _currPanBounds.min.y) {
+ y = _currPanBounds.min.y;
+ } else if(y < _currPanBounds.max.y) {
+ y = _currPanBounds.max.y;
+ }
+ }
+
+ _panOffset.x = x;
+ _panOffset.y = y;
+ _applyCurrentZoomPan();
+ },
+
+ handleEvent: function (e) {
+ e = e || window.event;
+ if(_globalEventHandlers[e.type]) {
+ _globalEventHandlers[e.type](e);
+ }
+ },
+
+
+ goTo: function(index) {
+
+ index = _getLoopedId(index);
+
+ var diff = index - _currentItemIndex;
+ _indexDiff = diff;
+
+ _currentItemIndex = index;
+ self.currItem = _getItemAt( _currentItemIndex );
+ _currPositionIndex -= diff;
+
+ _moveMainScroll(_slideSize.x * _currPositionIndex);
+
+
+ _stopAllAnimations();
+ _mainScrollAnimating = false;
+
+ self.updateCurrItem();
+ },
+ next: function() {
+ self.goTo( _currentItemIndex + 1);
+ },
+ prev: function() {
+ self.goTo( _currentItemIndex - 1);
+ },
+
+ // update current zoom/pan objects
+ updateCurrZoomItem: function(emulateSetContent) {
+ if(emulateSetContent) {
+ _shout('beforeChange', 0);
+ }
+
+ // itemHolder[1] is middle (current) item
+ if(_itemHolders[1].el.children.length) {
+ var zoomElement = _itemHolders[1].el.children[0];
+ if( framework.hasClass(zoomElement, 'pswp__zoom-wrap') ) {
+ _currZoomElementStyle = zoomElement.style;
+ } else {
+ _currZoomElementStyle = null;
+ }
+ } else {
+ _currZoomElementStyle = null;
+ }
+
+ _currPanBounds = self.currItem.bounds;
+ _startZoomLevel = _currZoomLevel = self.currItem.initialZoomLevel;
+
+ _panOffset.x = _currPanBounds.center.x;
+ _panOffset.y = _currPanBounds.center.y;
+
+ if(emulateSetContent) {
+ _shout('afterChange');
+ }
+ },
+
+
+ invalidateCurrItems: function() {
+ _itemsNeedUpdate = true;
+ for(var i = 0; i < NUM_HOLDERS; i++) {
+ if( _itemHolders[i].item ) {
+ _itemHolders[i].item.needsUpdate = true;
+ }
+ }
+ },
+
+ updateCurrItem: function(beforeAnimation) {
+
+ if(_indexDiff === 0) {
+ return;
+ }
+
+ var diffAbs = Math.abs(_indexDiff),
+ tempHolder;
+
+ if(beforeAnimation && diffAbs < 2) {
+ return;
+ }
+
+
+ self.currItem = _getItemAt( _currentItemIndex );
+
+ _shout('beforeChange', _indexDiff);
+
+ if(diffAbs >= NUM_HOLDERS) {
+ _containerShiftIndex += _indexDiff + (_indexDiff > 0 ? -NUM_HOLDERS : NUM_HOLDERS);
+ diffAbs = NUM_HOLDERS;
+ }
+ for(var i = 0; i < diffAbs; i++) {
+ if(_indexDiff > 0) {
+ tempHolder = _itemHolders.shift();
+ _itemHolders[NUM_HOLDERS-1] = tempHolder; // move first to last
+
+ _containerShiftIndex++;
+ _setTranslateX( (_containerShiftIndex+2) * _slideSize.x, tempHolder.el.style);
+ self.setContent(tempHolder, _currentItemIndex - diffAbs + i + 1 + 1);
+ } else {
+ tempHolder = _itemHolders.pop();
+ _itemHolders.unshift( tempHolder ); // move last to first
+
+ _containerShiftIndex--;
+ _setTranslateX( _containerShiftIndex * _slideSize.x, tempHolder.el.style);
+ self.setContent(tempHolder, _currentItemIndex + diffAbs - i - 1 - 1);
+ }
+
+ }
+
+ // reset zoom/pan on previous item
+ if(_currZoomElementStyle && Math.abs(_indexDiff) === 1) {
+
+ var prevItem = _getItemAt(_prevItemIndex);
+ if(prevItem.initialZoomLevel !== _currZoomLevel) {
+ _calculateItemSize(prevItem , _viewportSize );
+ _applyZoomPanToItem( prevItem );
+ }
+
+ }
+
+ // reset diff after update
+ _indexDiff = 0;
+
+ self.updateCurrZoomItem();
+
+ _prevItemIndex = _currentItemIndex;
+
+ _shout('afterChange');
+
+ },
+
+
+
+ updateSize: function(force) {
+
+ if(!_isFixedPosition) {
+ var windowScrollY = framework.getScrollY();
+ if(_currentWindowScrollY !== windowScrollY) {
+ template.style.top = windowScrollY + 'px';
+ _currentWindowScrollY = windowScrollY;
+ }
+ if(!force && _windowVisibleSize.x === window.innerWidth && _windowVisibleSize.y === window.innerHeight) {
+ return;
+ }
+ _windowVisibleSize.x = window.innerWidth;
+ _windowVisibleSize.y = window.innerHeight;
+
+ //template.style.width = _windowVisibleSize.x + 'px';
+ template.style.height = _windowVisibleSize.y + 'px';
+ }
+
+
+
+ _viewportSize.x = self.scrollWrap.clientWidth;
+ _viewportSize.y = self.scrollWrap.clientHeight;
+
+
+ _offset = {x:0,y:_currentWindowScrollY};//framework.getOffset(template);
+
+ _slideSize.x = _viewportSize.x + Math.round(_viewportSize.x * _options.spacing);
+ _slideSize.y = _viewportSize.y;
+
+ _moveMainScroll(_slideSize.x * _currPositionIndex);
+
+ _shout('beforeResize'); // even may be used for example to switch image sources
+
+ // don't re-calculate size on inital size update
+ if(_containerShiftIndex !== undefined) {
+
+ var holder,
+ item,
+ hIndex;
+
+ for(var i = 0; i < NUM_HOLDERS; i++) {
+ holder = _itemHolders[i];
+ _setTranslateX( (i+_containerShiftIndex) * _slideSize.x, holder.el.style);
+
+ hIndex = _getLoopedId(_currentItemIndex+i-1);
+
+ // update zoom level on items and refresh source (if needsUpdate)
+ item = _getItemAt( hIndex );
+
+ // re-render gallery item if `needsUpdate`,
+ // or doesn't have `bounds` (entirely new slide object)
+ if(_itemsNeedUpdate || item.needsUpdate || !item.bounds) {
+
+ if(item) {
+ self.cleanSlide( item );
+ }
+
+ self.setContent( holder, hIndex );
+
+ // if "center" slide
+ if(i === 1) {
+ self.currItem = item;
+ self.updateCurrZoomItem(true);
+ }
+
+ item.needsUpdate = false;
+ } else if(holder.index === -1 && hIndex >= 0) {
+ // add content first time
+ self.setContent( holder, hIndex );
+ }
+ if(item && item.container) {
+ _calculateItemSize(item, _viewportSize);
+ _applyZoomPanToItem( item );
+ }
+
+ }
+ _itemsNeedUpdate = false;
+ }
+
+ _startZoomLevel = _currZoomLevel = self.currItem.initialZoomLevel;
+ _currPanBounds = self.currItem.bounds;
+
+ if(_currPanBounds) {
+ _panOffset.x = _currPanBounds.center.x;
+ _panOffset.y = _currPanBounds.center.y;
+ _applyCurrentZoomPan();
+ }
+
+ _shout('resize');
+ },
+
+ //Zoom current item to
+ zoomTo: function(destZoomLevel, centerPoint, speed, easingFn, updateFn) {
+
+ /*
+ if(destZoomLevel === 'fit') {
+ destZoomLevel = self.currItem.fitRatio;
+ } else if(destZoomLevel === 'fill') {
+ destZoomLevel = self.currItem.fillRatio;
+ }
+ */
+
+ if(centerPoint) {
+ _startZoomLevel = _currZoomLevel;
+ _midZoomPoint.x = Math.abs(centerPoint.x) - _panOffset.x ;
+ _midZoomPoint.y = Math.abs(centerPoint.y) - _panOffset.y ;
+ _equalizePoints(_startPanOffset, _panOffset);
+ }
+
+ var destPanBounds = _calculatePanBounds(destZoomLevel, false),
+ destPanOffset = {};
+
+ _modifyDestPanOffset('x', destPanBounds, destPanOffset, destZoomLevel);
+ _modifyDestPanOffset('y', destPanBounds, destPanOffset, destZoomLevel);
+
+ var initialZoomLevel = _currZoomLevel;
+ var initialPanOffset = {
+ x: _panOffset.x,
+ y: _panOffset.y
+ };
+
+ _roundPoint(destPanOffset);
+
+ //_startZoomLevel = destZoomLevel;
+ var onUpdate = function(now) {
+ if(now === 1) {
+ _currZoomLevel = destZoomLevel;
+ _panOffset.x = destPanOffset.x;
+ _panOffset.y = destPanOffset.y;
+ } else {
+ _currZoomLevel = (destZoomLevel - initialZoomLevel) * now + initialZoomLevel;
+ _panOffset.x = (destPanOffset.x - initialPanOffset.x) * now + initialPanOffset.x;
+ _panOffset.y = (destPanOffset.y - initialPanOffset.y) * now + initialPanOffset.y;
+ }
+
+ if(updateFn) {
+ updateFn(now);
+ }
+
+ _applyCurrentZoomPan();
+ };
+
+ if(speed) {
+ _animateProp('customZoomTo', 0, 1, speed, easingFn || framework.easing.sine.inOut, onUpdate);
+ } else {
+ onUpdate(1);
+ }
+ }
+
+
+};
+
+/*>>core*/
+
+/*>>gestures*/
+/**
+ * Mouse/touch/pointer event handlers.
+ *
+ * separated from @core.js for readability
+ */
+
+var MIN_SWIPE_DISTANCE = 30,
+ DIRECTION_CHECK_OFFSET = 10; // amount of pixels to drag to determine direction of swipe
+
+var _gestureStartTime,
+ _gestureCheckSpeedTime,
+
+ // pool of objects that are used during dragging of zooming
+ p = {}, // first point
+ p2 = {}, // second point (for zoom gesture)
+ delta = {},
+ _currPoint = {},
+ _startPoint = {},
+ _currPointers = [],
+ _startMainScrollPos = {},
+ _releaseAnimData,
+ _posPoints = [], // array of points during dragging, used to determine type of gesture
+ _tempPoint = {},
+
+ _isZoomingIn,
+ _verticalDragInitiated,
+ _oldAndroidTouchEndTimeout,
+ _currZoomedItemIndex = 0,
+ _centerPoint = _getEmptyPoint(),
+ _lastReleaseTime = 0,
+ _isDragging, // at least one pointer is down
+ _isMultitouch, // at least two _pointers are down
+ _zoomStarted, // zoom level changed during zoom gesture
+ _moved,
+ _dragAnimFrame,
+ _mainScrollShifted,
+ _currentPoints, // array of current touch points
+ _isZooming,
+ _currPointsDistance,
+ _startPointsDistance,
+ _currPanBounds,
+ _mainScrollPos = _getEmptyPoint(),
+ _currZoomElementStyle,
+ _mainScrollAnimating, // true, if animation after swipe gesture is running
+ _midZoomPoint = _getEmptyPoint(),
+ _currCenterPoint = _getEmptyPoint(),
+ _direction,
+ _isFirstMove,
+ _opacityChanged,
+ _bgOpacity,
+ _wasOverInitialZoom,
+
+ _isEqualPoints = function(p1, p2) {
+ return p1.x === p2.x && p1.y === p2.y;
+ },
+ _isNearbyPoints = function(touch0, touch1) {
+ return Math.abs(touch0.x - touch1.x) < DOUBLE_TAP_RADIUS && Math.abs(touch0.y - touch1.y) < DOUBLE_TAP_RADIUS;
+ },
+ _calculatePointsDistance = function(p1, p2) {
+ _tempPoint.x = Math.abs( p1.x - p2.x );
+ _tempPoint.y = Math.abs( p1.y - p2.y );
+ return Math.sqrt(_tempPoint.x * _tempPoint.x + _tempPoint.y * _tempPoint.y);
+ },
+ _stopDragUpdateLoop = function() {
+ if(_dragAnimFrame) {
+ _cancelAF(_dragAnimFrame);
+ _dragAnimFrame = null;
+ }
+ },
+ _dragUpdateLoop = function() {
+ if(_isDragging) {
+ _dragAnimFrame = _requestAF(_dragUpdateLoop);
+ _renderMovement();
+ }
+ },
+ _canPan = function() {
+ return !(_options.scaleMode === 'fit' && _currZoomLevel === self.currItem.initialZoomLevel);
+ },
+
+ // find the closest parent DOM element
+ _closestElement = function(el, fn) {
+ if(!el) {
+ return false;
+ }
+
+ // don't search elements above pswp__scroll-wrap
+ if(el.className && el.className.indexOf('pswp__scroll-wrap') > -1 ) {
+ return false;
+ }
+
+ if( fn(el) ) {
+ return el;
+ }
+
+ return _closestElement(el.parentNode, fn);
+ },
+
+ _preventObj = {},
+ _preventDefaultEventBehaviour = function(e, isDown) {
+ _preventObj.prevent = !_closestElement(e.target, _options.isClickableElement);
+
+ _shout('preventDragEvent', e, isDown, _preventObj);
+ return _preventObj.prevent;
+
+ },
+ _convertTouchToPoint = function(touch, p) {
+ p.x = touch.pageX;
+ p.y = touch.pageY;
+ p.id = touch.identifier;
+ return p;
+ },
+ _findCenterOfPoints = function(p1, p2, pCenter) {
+ pCenter.x = (p1.x + p2.x) * 0.5;
+ pCenter.y = (p1.y + p2.y) * 0.5;
+ },
+ _pushPosPoint = function(time, x, y) {
+ if(time - _gestureCheckSpeedTime > 50) {
+ var o = _posPoints.length > 2 ? _posPoints.shift() : {};
+ o.x = x;
+ o.y = y;
+ _posPoints.push(o);
+ _gestureCheckSpeedTime = time;
+ }
+ },
+
+ _calculateVerticalDragOpacityRatio = function() {
+ var yOffset = _panOffset.y - self.currItem.initialPosition.y; // difference between initial and current position
+ return 1 - Math.abs( yOffset / (_viewportSize.y / 2) );
+ },
+
+
+ // points pool, reused during touch events
+ _ePoint1 = {},
+ _ePoint2 = {},
+ _tempPointsArr = [],
+ _tempCounter,
+ _getTouchPoints = function(e) {
+ // clean up previous points, without recreating array
+ while(_tempPointsArr.length > 0) {
+ _tempPointsArr.pop();
+ }
+
+ if(!_pointerEventEnabled) {
+ if(e.type.indexOf('touch') > -1) {
+
+ if(e.touches && e.touches.length > 0) {
+ _tempPointsArr[0] = _convertTouchToPoint(e.touches[0], _ePoint1);
+ if(e.touches.length > 1) {
+ _tempPointsArr[1] = _convertTouchToPoint(e.touches[1], _ePoint2);
+ }
+ }
+
+ } else {
+ _ePoint1.x = e.pageX;
+ _ePoint1.y = e.pageY;
+ _ePoint1.id = '';
+ _tempPointsArr[0] = _ePoint1;//_ePoint1;
+ }
+ } else {
+ _tempCounter = 0;
+ // we can use forEach, as pointer events are supported only in modern browsers
+ _currPointers.forEach(function(p) {
+ if(_tempCounter === 0) {
+ _tempPointsArr[0] = p;
+ } else if(_tempCounter === 1) {
+ _tempPointsArr[1] = p;
+ }
+ _tempCounter++;
+
+ });
+ }
+ return _tempPointsArr;
+ },
+
+ _panOrMoveMainScroll = function(axis, delta) {
+
+ var panFriction,
+ overDiff = 0,
+ newOffset = _panOffset[axis] + delta[axis],
+ startOverDiff,
+ dir = delta[axis] > 0,
+ newMainScrollPosition = _mainScrollPos.x + delta.x,
+ mainScrollDiff = _mainScrollPos.x - _startMainScrollPos.x,
+ newPanPos,
+ newMainScrollPos;
+
+ // calculate fdistance over the bounds and friction
+ if(newOffset > _currPanBounds.min[axis] || newOffset < _currPanBounds.max[axis]) {
+ panFriction = _options.panEndFriction;
+ // Linear increasing of friction, so at 1/4 of viewport it's at max value.
+ // Looks not as nice as was expected. Left for history.
+ // panFriction = (1 - (_panOffset[axis] + delta[axis] + panBounds.min[axis]) / (_viewportSize[axis] / 4) );
+ } else {
+ panFriction = 1;
+ }
+
+ newOffset = _panOffset[axis] + delta[axis] * panFriction;
+
+ // move main scroll or start panning
+ if(_options.allowPanToNext || _currZoomLevel === self.currItem.initialZoomLevel) {
+
+
+ if(!_currZoomElementStyle) {
+
+ newMainScrollPos = newMainScrollPosition;
+
+ } else if(_direction === 'h' && axis === 'x' && !_zoomStarted ) {
+
+ if(dir) {
+ if(newOffset > _currPanBounds.min[axis]) {
+ panFriction = _options.panEndFriction;
+ overDiff = _currPanBounds.min[axis] - newOffset;
+ startOverDiff = _currPanBounds.min[axis] - _startPanOffset[axis];
+ }
+
+ // drag right
+ if( (startOverDiff <= 0 || mainScrollDiff < 0) && _getNumItems() > 1 ) {
+ newMainScrollPos = newMainScrollPosition;
+ if(mainScrollDiff < 0 && newMainScrollPosition > _startMainScrollPos.x) {
+ newMainScrollPos = _startMainScrollPos.x;
+ }
+ } else {
+ if(_currPanBounds.min.x !== _currPanBounds.max.x) {
+ newPanPos = newOffset;
+ }
+
+ }
+
+ } else {
+
+ if(newOffset < _currPanBounds.max[axis] ) {
+ panFriction =_options.panEndFriction;
+ overDiff = newOffset - _currPanBounds.max[axis];
+ startOverDiff = _startPanOffset[axis] - _currPanBounds.max[axis];
+ }
+
+ if( (startOverDiff <= 0 || mainScrollDiff > 0) && _getNumItems() > 1 ) {
+ newMainScrollPos = newMainScrollPosition;
+
+ if(mainScrollDiff > 0 && newMainScrollPosition < _startMainScrollPos.x) {
+ newMainScrollPos = _startMainScrollPos.x;
+ }
+
+ } else {
+ if(_currPanBounds.min.x !== _currPanBounds.max.x) {
+ newPanPos = newOffset;
+ }
+ }
+
+ }
+
+
+ //
+ }
+
+ if(axis === 'x') {
+
+ if(newMainScrollPos !== undefined) {
+ _moveMainScroll(newMainScrollPos, true);
+ if(newMainScrollPos === _startMainScrollPos.x) {
+ _mainScrollShifted = false;
+ } else {
+ _mainScrollShifted = true;
+ }
+ }
+
+ if(_currPanBounds.min.x !== _currPanBounds.max.x) {
+ if(newPanPos !== undefined) {
+ _panOffset.x = newPanPos;
+ } else if(!_mainScrollShifted) {
+ _panOffset.x += delta.x * panFriction;
+ }
+ }
+
+ return newMainScrollPos !== undefined;
+ }
+
+ }
+
+ if(!_mainScrollAnimating) {
+
+ if(!_mainScrollShifted) {
+ if(_currZoomLevel > self.currItem.fitRatio) {
+ _panOffset[axis] += delta[axis] * panFriction;
+
+ }
+ }
+
+
+ }
+
+ },
+
+ // Pointerdown/touchstart/mousedown handler
+ _onDragStart = function(e) {
+
+ // Allow dragging only via left mouse button.
+ // As this handler is not added in IE8 - we ignore e.which
+ //
+ // http://www.quirksmode.org/js/events_properties.html
+ // https://developer.mozilla.org/en-US/docs/Web/API/event.button
+ if(e.type === 'mousedown' && e.button > 0 ) {
+ return;
+ }
+
+ if(_initialZoomRunning) {
+ e.preventDefault();
+ return;
+ }
+
+ if(_oldAndroidTouchEndTimeout && e.type === 'mousedown') {
+ return;
+ }
+
+ if(_preventDefaultEventBehaviour(e, true)) {
+ e.preventDefault();
+ }
+
+
+
+ _shout('pointerDown');
+
+ if(_pointerEventEnabled) {
+ var pointerIndex = framework.arraySearch(_currPointers, e.pointerId, 'id');
+ if(pointerIndex < 0) {
+ pointerIndex = _currPointers.length;
+ }
+ _currPointers[pointerIndex] = {x:e.pageX, y:e.pageY, id: e.pointerId};
+ }
+
+
+
+ var startPointsList = _getTouchPoints(e),
+ numPoints = startPointsList.length;
+
+ _currentPoints = null;
+
+ _stopAllAnimations();
+
+ // init drag
+ if(!_isDragging || numPoints === 1) {
+
+
+
+ _isDragging = _isFirstMove = true;
+ framework.bind(window, _upMoveEvents, self);
+
+ _isZoomingIn =
+ _wasOverInitialZoom =
+ _opacityChanged =
+ _verticalDragInitiated =
+ _mainScrollShifted =
+ _moved =
+ _isMultitouch =
+ _zoomStarted = false;
+
+ _direction = null;
+
+ _shout('firstTouchStart', startPointsList);
+
+ _equalizePoints(_startPanOffset, _panOffset);
+
+ _currPanDist.x = _currPanDist.y = 0;
+ _equalizePoints(_currPoint, startPointsList[0]);
+ _equalizePoints(_startPoint, _currPoint);
+
+ //_equalizePoints(_startMainScrollPos, _mainScrollPos);
+ _startMainScrollPos.x = _slideSize.x * _currPositionIndex;
+
+ _posPoints = [{
+ x: _currPoint.x,
+ y: _currPoint.y
+ }];
+
+ _gestureCheckSpeedTime = _gestureStartTime = _getCurrentTime();
+
+ //_mainScrollAnimationEnd(true);
+ _calculatePanBounds( _currZoomLevel, true );
+
+ // Start rendering
+ _stopDragUpdateLoop();
+ _dragUpdateLoop();
+
+ }
+
+ // init zoom
+ if(!_isZooming && numPoints > 1 && !_mainScrollAnimating && !_mainScrollShifted) {
+ _startZoomLevel = _currZoomLevel;
+ _zoomStarted = false; // true if zoom changed at least once
+
+ _isZooming = _isMultitouch = true;
+ _currPanDist.y = _currPanDist.x = 0;
+
+ _equalizePoints(_startPanOffset, _panOffset);
+
+ _equalizePoints(p, startPointsList[0]);
+ _equalizePoints(p2, startPointsList[1]);
+
+ _findCenterOfPoints(p, p2, _currCenterPoint);
+
+ _midZoomPoint.x = Math.abs(_currCenterPoint.x) - _panOffset.x;
+ _midZoomPoint.y = Math.abs(_currCenterPoint.y) - _panOffset.y;
+ _currPointsDistance = _startPointsDistance = _calculatePointsDistance(p, p2);
+ }
+
+
+ },
+
+ // Pointermove/touchmove/mousemove handler
+ _onDragMove = function(e) {
+
+ e.preventDefault();
+
+ if(_pointerEventEnabled) {
+ var pointerIndex = framework.arraySearch(_currPointers, e.pointerId, 'id');
+ if(pointerIndex > -1) {
+ var p = _currPointers[pointerIndex];
+ p.x = e.pageX;
+ p.y = e.pageY;
+ }
+ }
+
+ if(_isDragging) {
+ var touchesList = _getTouchPoints(e);
+ if(!_direction && !_moved && !_isZooming) {
+ var diff = Math.abs(touchesList[0].x - _currPoint.x) - Math.abs(touchesList[0].y - _currPoint.y);
+ // check the direction of movement
+ if(Math.abs(diff) >= DIRECTION_CHECK_OFFSET) {
+ _direction = diff > 0 ? 'h' : 'v';
+ _currentPoints = touchesList;
+ }
+ } else {
+ _currentPoints = touchesList;
+ }
+ }
+ },
+ //
+ _renderMovement = function() {
+
+ if(!_currentPoints) {
+ return;
+ }
+
+ var numPoints = _currentPoints.length;
+
+ if(numPoints === 0) {
+ return;
+ }
+
+ _equalizePoints(p, _currentPoints[0]);
+
+ delta.x = p.x - _currPoint.x;
+ delta.y = p.y - _currPoint.y;
+
+ if(_isZooming && numPoints > 1) {
+ // Handle behaviour for more than 1 point
+
+ _currPoint.x = p.x;
+ _currPoint.y = p.y;
+
+ // check if one of two points changed
+ if( !delta.x && !delta.y && _isEqualPoints(_currentPoints[1], p2) ) {
+ return;
+ }
+
+ _equalizePoints(p2, _currentPoints[1]);
+
+
+ if(!_zoomStarted) {
+ _zoomStarted = true;
+ _shout('zoomGestureStarted');
+ }
+
+ // Distance between two points
+ var pointsDistance = _calculatePointsDistance(p,p2);
+
+ var zoomLevel = _calculateZoomLevel(pointsDistance);
+
+ // slightly over the of initial zoom level
+ if(zoomLevel > self.currItem.initialZoomLevel + self.currItem.initialZoomLevel / 15) {
+ _wasOverInitialZoom = true;
+ }
+
+ // Apply the friction if zoom level is out of the bounds
+ var zoomFriction = 1,
+ minZoomLevel = _getMinZoomLevel(),
+ maxZoomLevel = _getMaxZoomLevel();
+
+ if ( zoomLevel < minZoomLevel ) {
+
+ if(_options.pinchToClose && !_wasOverInitialZoom && _startZoomLevel <= self.currItem.initialZoomLevel) {
+ // fade out background if zooming out
+ var minusDiff = minZoomLevel - zoomLevel;
+ var percent = 1 - minusDiff / (minZoomLevel / 1.2);
+
+ _applyBgOpacity(percent);
+ _shout('onPinchClose', percent);
+ _opacityChanged = true;
+ } else {
+ zoomFriction = (minZoomLevel - zoomLevel) / minZoomLevel;
+ if(zoomFriction > 1) {
+ zoomFriction = 1;
+ }
+ zoomLevel = minZoomLevel - zoomFriction * (minZoomLevel / 3);
+ }
+
+ } else if ( zoomLevel > maxZoomLevel ) {
+ // 1.5 - extra zoom level above the max. E.g. if max is x6, real max 6 + 1.5 = 7.5
+ zoomFriction = (zoomLevel - maxZoomLevel) / ( minZoomLevel * 6 );
+ if(zoomFriction > 1) {
+ zoomFriction = 1;
+ }
+ zoomLevel = maxZoomLevel + zoomFriction * minZoomLevel;
+ }
+
+ if(zoomFriction < 0) {
+ zoomFriction = 0;
+ }
+
+ // distance between touch points after friction is applied
+ _currPointsDistance = pointsDistance;
+
+ // _centerPoint - The point in the middle of two pointers
+ _findCenterOfPoints(p, p2, _centerPoint);
+
+ // paning with two pointers pressed
+ _currPanDist.x += _centerPoint.x - _currCenterPoint.x;
+ _currPanDist.y += _centerPoint.y - _currCenterPoint.y;
+ _equalizePoints(_currCenterPoint, _centerPoint);
+
+ _panOffset.x = _calculatePanOffset('x', zoomLevel);
+ _panOffset.y = _calculatePanOffset('y', zoomLevel);
+
+ _isZoomingIn = zoomLevel > _currZoomLevel;
+ _currZoomLevel = zoomLevel;
+ _applyCurrentZoomPan();
+
+ } else {
+
+ // handle behaviour for one point (dragging or panning)
+
+ if(!_direction) {
+ return;
+ }
+
+ if(_isFirstMove) {
+ _isFirstMove = false;
+
+ // subtract drag distance that was used during the detection direction
+
+ if( Math.abs(delta.x) >= DIRECTION_CHECK_OFFSET) {
+ delta.x -= _currentPoints[0].x - _startPoint.x;
+ }
+
+ if( Math.abs(delta.y) >= DIRECTION_CHECK_OFFSET) {
+ delta.y -= _currentPoints[0].y - _startPoint.y;
+ }
+ }
+
+ _currPoint.x = p.x;
+ _currPoint.y = p.y;
+
+ // do nothing if pointers position hasn't changed
+ if(delta.x === 0 && delta.y === 0) {
+ return;
+ }
+
+ if(_direction === 'v' && _options.closeOnVerticalDrag) {
+ if(!_canPan()) {
+
+ _currPanDist.y += delta.y;
+ _panOffset.y += delta.y;
+
+ var opacityRatio = _calculateVerticalDragOpacityRatio();
+
+ _verticalDragInitiated = true;
+ _shout('onVerticalDrag', opacityRatio);
+
+ _applyBgOpacity(opacityRatio);
+ _applyCurrentZoomPan();
+ return ;
+ }
+ }
+
+ _pushPosPoint(_getCurrentTime(), p.x, p.y);
+
+ _moved = true;
+ _currPanBounds = self.currItem.bounds;
+
+ var mainScrollChanged = _panOrMoveMainScroll('x', delta);
+ if(!mainScrollChanged) {
+ _panOrMoveMainScroll('y', delta);
+
+ _roundPoint(_panOffset);
+ _applyCurrentZoomPan();
+ }
+
+ }
+
+ },
+
+ // Pointerup/pointercancel/touchend/touchcancel/mouseup event handler
+ _onDragRelease = function(e) {
+
+ if(_features.isOldAndroid ) {
+
+ if(_oldAndroidTouchEndTimeout && e.type === 'mouseup') {
+ return;
+ }
+
+ // on Android (v4.1, 4.2, 4.3 & possibly older)
+ // ghost mousedown/up event isn't preventable via e.preventDefault,
+ // which causes fake mousedown event
+ // so we block mousedown/up for 600ms
+ if( e.type.indexOf('touch') > -1 ) {
+ clearTimeout(_oldAndroidTouchEndTimeout);
+ _oldAndroidTouchEndTimeout = setTimeout(function() {
+ _oldAndroidTouchEndTimeout = 0;
+ }, 600);
+ }
+
+ }
+
+ _shout('pointerUp');
+
+ if(_preventDefaultEventBehaviour(e, false)) {
+ e.preventDefault();
+ }
+
+ var releasePoint;
+
+ if(_pointerEventEnabled) {
+ var pointerIndex = framework.arraySearch(_currPointers, e.pointerId, 'id');
+
+ if(pointerIndex > -1) {
+ releasePoint = _currPointers.splice(pointerIndex, 1)[0];
+
+ if(navigator.pointerEnabled) {
+ releasePoint.type = e.pointerType || 'mouse';
+ } else {
+ var MSPOINTER_TYPES = {
+ 4: 'mouse', // event.MSPOINTER_TYPE_MOUSE
+ 2: 'touch', // event.MSPOINTER_TYPE_TOUCH
+ 3: 'pen' // event.MSPOINTER_TYPE_PEN
+ };
+ releasePoint.type = MSPOINTER_TYPES[e.pointerType];
+
+ if(!releasePoint.type) {
+ releasePoint.type = e.pointerType || 'mouse';
+ }
+ }
+
+ }
+ }
+
+ var touchList = _getTouchPoints(e),
+ gestureType,
+ numPoints = touchList.length;
+
+ if(e.type === 'mouseup') {
+ numPoints = 0;
+ }
+
+ // Do nothing if there were 3 touch points or more
+ if(numPoints === 2) {
+ _currentPoints = null;
+ return true;
+ }
+
+ // if second pointer released
+ if(numPoints === 1) {
+ _equalizePoints(_startPoint, touchList[0]);
+ }
+
+
+ // pointer hasn't moved, send "tap release" point
+ if(numPoints === 0 && !_direction && !_mainScrollAnimating) {
+ if(!releasePoint) {
+ if(e.type === 'mouseup') {
+ releasePoint = {x: e.pageX, y: e.pageY, type:'mouse'};
+ } else if(e.changedTouches && e.changedTouches[0]) {
+ releasePoint = {x: e.changedTouches[0].pageX, y: e.changedTouches[0].pageY, type:'touch'};
+ }
+ }
+
+ _shout('touchRelease', e, releasePoint);
+ }
+
+ // Difference in time between releasing of two last touch points (zoom gesture)
+ var releaseTimeDiff = -1;
+
+ // Gesture completed, no pointers left
+ if(numPoints === 0) {
+ _isDragging = false;
+ framework.unbind(window, _upMoveEvents, self);
+
+ _stopDragUpdateLoop();
+
+ if(_isZooming) {
+ // Two points released at the same time
+ releaseTimeDiff = 0;
+ } else if(_lastReleaseTime !== -1) {
+ releaseTimeDiff = _getCurrentTime() - _lastReleaseTime;
+ }
+ }
+ _lastReleaseTime = numPoints === 1 ? _getCurrentTime() : -1;
+
+ if(releaseTimeDiff !== -1 && releaseTimeDiff < 150) {
+ gestureType = 'zoom';
+ } else {
+ gestureType = 'swipe';
+ }
+
+ if(_isZooming && numPoints < 2) {
+ _isZooming = false;
+
+ // Only second point released
+ if(numPoints === 1) {
+ gestureType = 'zoomPointerUp';
+ }
+ _shout('zoomGestureEnded');
+ }
+
+ _currentPoints = null;
+ if(!_moved && !_zoomStarted && !_mainScrollAnimating && !_verticalDragInitiated) {
+ // nothing to animate
+ return;
+ }
+
+ _stopAllAnimations();
+
+
+ if(!_releaseAnimData) {
+ _releaseAnimData = _initDragReleaseAnimationData();
+ }
+
+ _releaseAnimData.calculateSwipeSpeed('x');
+
+
+ if(_verticalDragInitiated) {
+
+ var opacityRatio = _calculateVerticalDragOpacityRatio();
+
+ if(opacityRatio < 0.6) {
+ self.close();
+ } else {
+ var initalPanY = _panOffset.y,
+ initialBgOpacity = _bgOpacity;
+
+ _animateProp('verticalDrag', 0, 1, 300, framework.easing.cubic.out, function(now) {
+
+ _panOffset.y = (self.currItem.initialPosition.y - initalPanY) * now + initalPanY;
+
+ _applyBgOpacity( (1 - initialBgOpacity) * now + initialBgOpacity );
+ _applyCurrentZoomPan();
+ });
+
+ _shout('onVerticalDrag', 1);
+ }
+
+ return;
+ }
+
+
+ // main scroll
+ if( (_mainScrollShifted || _mainScrollAnimating) && numPoints === 0) {
+ var itemChanged = _finishSwipeMainScrollGesture(gestureType, _releaseAnimData);
+ if(itemChanged) {
+ return;
+ }
+ gestureType = 'zoomPointerUp';
+ }
+
+ // prevent zoom/pan animation when main scroll animation runs
+ if(_mainScrollAnimating) {
+ return;
+ }
+
+ // Complete simple zoom gesture (reset zoom level if it's out of the bounds)
+ if(gestureType !== 'swipe') {
+ _completeZoomGesture();
+ return;
+ }
+
+ // Complete pan gesture if main scroll is not shifted, and it's possible to pan current image
+ if(!_mainScrollShifted && _currZoomLevel > self.currItem.fitRatio) {
+ _completePanGesture(_releaseAnimData);
+ }
+ },
+
+
+ // Returns object with data about gesture
+ // It's created only once and then reused
+ _initDragReleaseAnimationData = function() {
+ // temp local vars
+ var lastFlickDuration,
+ tempReleasePos;
+
+ // s = this
+ var s = {
+ lastFlickOffset: {},
+ lastFlickDist: {},
+ lastFlickSpeed: {},
+ slowDownRatio: {},
+ slowDownRatioReverse: {},
+ speedDecelerationRatio: {},
+ speedDecelerationRatioAbs: {},
+ distanceOffset: {},
+ backAnimDestination: {},
+ backAnimStarted: {},
+ calculateSwipeSpeed: function(axis) {
+
+
+ if( _posPoints.length > 1) {
+ lastFlickDuration = _getCurrentTime() - _gestureCheckSpeedTime + 50;
+ tempReleasePos = _posPoints[_posPoints.length-2][axis];
+ } else {
+ lastFlickDuration = _getCurrentTime() - _gestureStartTime; // total gesture duration
+ tempReleasePos = _startPoint[axis];
+ }
+ s.lastFlickOffset[axis] = _currPoint[axis] - tempReleasePos;
+ s.lastFlickDist[axis] = Math.abs(s.lastFlickOffset[axis]);
+ if(s.lastFlickDist[axis] > 20) {
+ s.lastFlickSpeed[axis] = s.lastFlickOffset[axis] / lastFlickDuration;
+ } else {
+ s.lastFlickSpeed[axis] = 0;
+ }
+ if( Math.abs(s.lastFlickSpeed[axis]) < 0.1 ) {
+ s.lastFlickSpeed[axis] = 0;
+ }
+
+ s.slowDownRatio[axis] = 0.95;
+ s.slowDownRatioReverse[axis] = 1 - s.slowDownRatio[axis];
+ s.speedDecelerationRatio[axis] = 1;
+ },
+
+ calculateOverBoundsAnimOffset: function(axis, speed) {
+ if(!s.backAnimStarted[axis]) {
+
+ if(_panOffset[axis] > _currPanBounds.min[axis]) {
+ s.backAnimDestination[axis] = _currPanBounds.min[axis];
+
+ } else if(_panOffset[axis] < _currPanBounds.max[axis]) {
+ s.backAnimDestination[axis] = _currPanBounds.max[axis];
+ }
+
+ if(s.backAnimDestination[axis] !== undefined) {
+ s.slowDownRatio[axis] = 0.7;
+ s.slowDownRatioReverse[axis] = 1 - s.slowDownRatio[axis];
+ if(s.speedDecelerationRatioAbs[axis] < 0.05) {
+
+ s.lastFlickSpeed[axis] = 0;
+ s.backAnimStarted[axis] = true;
+
+ _animateProp('bounceZoomPan'+axis,_panOffset[axis],
+ s.backAnimDestination[axis],
+ speed || 300,
+ framework.easing.sine.out,
+ function(pos) {
+ _panOffset[axis] = pos;
+ _applyCurrentZoomPan();
+ }
+ );
+
+ }
+ }
+ }
+ },
+
+ // Reduces the speed by slowDownRatio (per 10ms)
+ calculateAnimOffset: function(axis) {
+ if(!s.backAnimStarted[axis]) {
+ s.speedDecelerationRatio[axis] = s.speedDecelerationRatio[axis] * (s.slowDownRatio[axis] +
+ s.slowDownRatioReverse[axis] -
+ s.slowDownRatioReverse[axis] * s.timeDiff / 10);
+
+ s.speedDecelerationRatioAbs[axis] = Math.abs(s.lastFlickSpeed[axis] * s.speedDecelerationRatio[axis]);
+ s.distanceOffset[axis] = s.lastFlickSpeed[axis] * s.speedDecelerationRatio[axis] * s.timeDiff;
+ _panOffset[axis] += s.distanceOffset[axis];
+
+ }
+ },
+
+ panAnimLoop: function() {
+ if ( _animations.zoomPan ) {
+ _animations.zoomPan.raf = _requestAF(s.panAnimLoop);
+
+ s.now = _getCurrentTime();
+ s.timeDiff = s.now - s.lastNow;
+ s.lastNow = s.now;
+
+ s.calculateAnimOffset('x');
+ s.calculateAnimOffset('y');
+
+ _applyCurrentZoomPan();
+
+ s.calculateOverBoundsAnimOffset('x');
+ s.calculateOverBoundsAnimOffset('y');
+
+
+ if (s.speedDecelerationRatioAbs.x < 0.05 && s.speedDecelerationRatioAbs.y < 0.05) {
+
+ // round pan position
+ _panOffset.x = Math.round(_panOffset.x);
+ _panOffset.y = Math.round(_panOffset.y);
+ _applyCurrentZoomPan();
+
+ _stopAnimation('zoomPan');
+ return;
+ }
+ }
+
+ }
+ };
+ return s;
+ },
+
+ _completePanGesture = function(animData) {
+ // calculate swipe speed for Y axis (paanning)
+ animData.calculateSwipeSpeed('y');
+
+ _currPanBounds = self.currItem.bounds;
+
+ animData.backAnimDestination = {};
+ animData.backAnimStarted = {};
+
+ // Avoid acceleration animation if speed is too low
+ if(Math.abs(animData.lastFlickSpeed.x) <= 0.05 && Math.abs(animData.lastFlickSpeed.y) <= 0.05 ) {
+ animData.speedDecelerationRatioAbs.x = animData.speedDecelerationRatioAbs.y = 0;
+
+ // Run pan drag release animation. E.g. if you drag image and release finger without momentum.
+ animData.calculateOverBoundsAnimOffset('x');
+ animData.calculateOverBoundsAnimOffset('y');
+ return true;
+ }
+
+ // Animation loop that controls the acceleration after pan gesture ends
+ _registerStartAnimation('zoomPan');
+ animData.lastNow = _getCurrentTime();
+ animData.panAnimLoop();
+ },
+
+
+ _finishSwipeMainScrollGesture = function(gestureType, _releaseAnimData) {
+ var itemChanged;
+ if(!_mainScrollAnimating) {
+ _currZoomedItemIndex = _currentItemIndex;
+ }
+
+
+
+ var itemsDiff;
+
+ if(gestureType === 'swipe') {
+ var totalShiftDist = _currPoint.x - _startPoint.x,
+ isFastLastFlick = _releaseAnimData.lastFlickDist.x < 10;
+
+ // if container is shifted for more than MIN_SWIPE_DISTANCE,
+ // and last flick gesture was in right direction
+ if(totalShiftDist > MIN_SWIPE_DISTANCE &&
+ (isFastLastFlick || _releaseAnimData.lastFlickOffset.x > 20) ) {
+ // go to prev item
+ itemsDiff = -1;
+ } else if(totalShiftDist < -MIN_SWIPE_DISTANCE &&
+ (isFastLastFlick || _releaseAnimData.lastFlickOffset.x < -20) ) {
+ // go to next item
+ itemsDiff = 1;
+ }
+ }
+
+ var nextCircle;
+
+ if(itemsDiff) {
+
+ _currentItemIndex += itemsDiff;
+
+ if(_currentItemIndex < 0) {
+ _currentItemIndex = _options.loop ? _getNumItems()-1 : 0;
+ nextCircle = true;
+ } else if(_currentItemIndex >= _getNumItems()) {
+ _currentItemIndex = _options.loop ? 0 : _getNumItems()-1;
+ nextCircle = true;
+ }
+
+ if(!nextCircle || _options.loop) {
+ _indexDiff += itemsDiff;
+ _currPositionIndex -= itemsDiff;
+ itemChanged = true;
+ }
+
+
+
+ }
+
+ var animateToX = _slideSize.x * _currPositionIndex;
+ var animateToDist = Math.abs( animateToX - _mainScrollPos.x );
+ var finishAnimDuration;
+
+
+ if(!itemChanged && animateToX > _mainScrollPos.x !== _releaseAnimData.lastFlickSpeed.x > 0) {
+ // "return to current" duration, e.g. when dragging from slide 0 to -1
+ finishAnimDuration = 333;
+ } else {
+ finishAnimDuration = Math.abs(_releaseAnimData.lastFlickSpeed.x) > 0 ?
+ animateToDist / Math.abs(_releaseAnimData.lastFlickSpeed.x) :
+ 333;
+
+ finishAnimDuration = Math.min(finishAnimDuration, 400);
+ finishAnimDuration = Math.max(finishAnimDuration, 250);
+ }
+
+ if(_currZoomedItemIndex === _currentItemIndex) {
+ itemChanged = false;
+ }
+
+ _mainScrollAnimating = true;
+
+ _animateProp('mainScroll', _mainScrollPos.x, animateToX, finishAnimDuration, framework.easing.cubic.out,
+ _moveMainScroll,
+ function() {
+ _stopAllAnimations();
+ _mainScrollAnimating = false;
+ _currZoomedItemIndex = -1;
+
+ if(itemChanged || _currZoomedItemIndex !== _currentItemIndex) {
+ self.updateCurrItem();
+ }
+
+ _shout('mainScrollAnimComplete');
+ }
+ );
+
+ if(itemChanged) {
+ self.updateCurrItem(true);
+ }
+
+ return itemChanged;
+ },
+
+ _calculateZoomLevel = function(touchesDistance) {
+ return 1 / _startPointsDistance * touchesDistance * _startZoomLevel;
+ },
+
+ // Resets zoom if it's out of bounds
+ _completeZoomGesture = function() {
+ var destZoomLevel = _currZoomLevel,
+ minZoomLevel = _getMinZoomLevel(),
+ maxZoomLevel = _getMaxZoomLevel();
+
+ if ( _currZoomLevel < minZoomLevel ) {
+ destZoomLevel = minZoomLevel;
+ } else if ( _currZoomLevel > maxZoomLevel ) {
+ destZoomLevel = maxZoomLevel;
+ }
+
+ var destOpacity = 1,
+ onUpdate,
+ initialOpacity = _bgOpacity;
+
+ if(_opacityChanged && !_isZoomingIn && !_wasOverInitialZoom && _currZoomLevel < minZoomLevel) {
+ //_closedByScroll = true;
+ self.close();
+ return true;
+ }
+
+ if(_opacityChanged) {
+ onUpdate = function(now) {
+
+ _applyBgOpacity( (destOpacity - initialOpacity) * now + initialOpacity );
+
+ };
+ }
+
+ self.zoomTo(destZoomLevel, 0, 300, framework.easing.cubic.out, onUpdate);
+ return true;
+ };
+
+
+_registerModule('Gestures', {
+ publicMethods: {
+
+ initGestures: function() {
+
+ // helper function that builds touch/pointer/mouse events
+ var addEventNames = function(pref, down, move, up, cancel) {
+ _dragStartEvent = pref + down;
+ _dragMoveEvent = pref + move;
+ _dragEndEvent = pref + up;
+ if(cancel) {
+ _dragCancelEvent = pref + cancel;
+ } else {
+ _dragCancelEvent = '';
+ }
+ };
+
+ _pointerEventEnabled = _features.pointerEvent;
+ if(_pointerEventEnabled && _features.touch) {
+ // we don't need touch events, if browser supports pointer events
+ _features.touch = false;
+ }
+
+ if(_pointerEventEnabled) {
+ if(navigator.pointerEnabled) {
+ addEventNames('pointer', 'down', 'move', 'up', 'cancel');
+ } else {
+ // IE10 pointer events are case-sensitive
+ addEventNames('MSPointer', 'Down', 'Move', 'Up', 'Cancel');
+ }
+ } else if(_features.touch) {
+ addEventNames('touch', 'start', 'move', 'end', 'cancel');
+ _likelyTouchDevice = true;
+ } else {
+ addEventNames('mouse', 'down', 'move', 'up');
+ }
+
+ _upMoveEvents = _dragMoveEvent + ' ' + _dragEndEvent + ' ' + _dragCancelEvent;
+ _downEvents = _dragStartEvent;
+
+ if(_pointerEventEnabled && !_likelyTouchDevice) {
+ _likelyTouchDevice = (navigator.maxTouchPoints > 1) || (navigator.msMaxTouchPoints > 1);
+ }
+ // make variable public
+ self.likelyTouchDevice = _likelyTouchDevice;
+
+ _globalEventHandlers[_dragStartEvent] = _onDragStart;
+ _globalEventHandlers[_dragMoveEvent] = _onDragMove;
+ _globalEventHandlers[_dragEndEvent] = _onDragRelease; // the Kraken
+
+ if(_dragCancelEvent) {
+ _globalEventHandlers[_dragCancelEvent] = _globalEventHandlers[_dragEndEvent];
+ }
+
+ // Bind mouse events on device with detected hardware touch support, in case it supports multiple types of input.
+ if(_features.touch) {
+ _downEvents += ' mousedown';
+ _upMoveEvents += ' mousemove mouseup';
+ _globalEventHandlers.mousedown = _globalEventHandlers[_dragStartEvent];
+ _globalEventHandlers.mousemove = _globalEventHandlers[_dragMoveEvent];
+ _globalEventHandlers.mouseup = _globalEventHandlers[_dragEndEvent];
+ }
+
+ if(!_likelyTouchDevice) {
+ // don't allow pan to next slide from zoomed state on Desktop
+ _options.allowPanToNext = false;
+ }
+ }
+
+ }
+});
+
+/*>>gestures*/
+
+/*>>show-hide-transition*/
+/**
+ * show-hide-transition.js:
+ *
+ * Manages initial opening or closing transition.
+ *
+ * If you're not planning to use transition for gallery at all,
+ * you may set options hideAnimationDuration and showAnimationDuration to 0,
+ * and just delete startAnimation function.
+ *
+ */
+
+
+var _showOrHideTimeout,
+ _showOrHide = function(item, img, out, completeFn) {
+
+ if(_showOrHideTimeout) {
+ clearTimeout(_showOrHideTimeout);
+ }
+
+ _initialZoomRunning = true;
+ _initialContentSet = true;
+
+ // dimensions of small thumbnail {x:,y:,w:}.
+ // Height is optional, as calculated based on large image.
+ var thumbBounds;
+ if(item.initialLayout) {
+ thumbBounds = item.initialLayout;
+ item.initialLayout = null;
+ } else {
+ thumbBounds = _options.getThumbBoundsFn && _options.getThumbBoundsFn(_currentItemIndex);
+ }
+
+ var duration = out ? _options.hideAnimationDuration : _options.showAnimationDuration;
+
+ var onComplete = function() {
+ _stopAnimation('initialZoom');
+ if(!out) {
+ _applyBgOpacity(1);
+ if(img) {
+ img.style.display = 'block';
+ }
+ framework.addClass(template, 'pswp--animated-in');
+ _shout('initialZoom' + (out ? 'OutEnd' : 'InEnd'));
+ } else {
+ self.template.removeAttribute('style');
+ self.bg.removeAttribute('style');
+ }
+
+ if(completeFn) {
+ completeFn();
+ }
+ _initialZoomRunning = false;
+ };
+
+ // if bounds aren't provided, just open gallery without animation
+ if(!duration || !thumbBounds || thumbBounds.x === undefined) {
+
+ var finishWithoutAnimation = function() {
+ _shout('initialZoom' + (out ? 'Out' : 'In') );
+
+ _currZoomLevel = item.initialZoomLevel;
+ _equalizePoints(_panOffset, item.initialPosition );
+ _applyCurrentZoomPan();
+
+ // no transition
+ template.style.opacity = out ? 0 : 1;
+ _applyBgOpacity(1);
+
+ onComplete();
+ };
+ finishWithoutAnimation();
+
+ return;
+ }
+
+ var startAnimation = function() {
+ var closeWithRaf = _closedByScroll,
+ fadeEverything = !self.currItem.src || self.currItem.loadError || _options.showHideOpacity;
+
+ // apply hw-acceleration to image
+ if(item.miniImg) {
+ item.miniImg.style.webkitBackfaceVisibility = 'hidden';
+ }
+
+ if(!out) {
+ _currZoomLevel = thumbBounds.w / item.w;
+ _panOffset.x = thumbBounds.x;
+ _panOffset.y = thumbBounds.y - _initalWindowScrollY;
+
+ self[fadeEverything ? 'template' : 'bg'].style.opacity = 0.001;
+ _applyCurrentZoomPan();
+ }
+
+ _registerStartAnimation('initialZoom');
+
+ if(out && !closeWithRaf) {
+ framework.removeClass(template, 'pswp--animated-in');
+ }
+
+ if(fadeEverything) {
+ if(out) {
+ framework[ (closeWithRaf ? 'remove' : 'add') + 'Class' ](template, 'pswp--animate_opacity');
+ } else {
+ setTimeout(function() {
+ framework.addClass(template, 'pswp--animate_opacity');
+ }, 30);
+ }
+ }
+
+ _showOrHideTimeout = setTimeout(function() {
+
+ _shout('initialZoom' + (out ? 'Out' : 'In') );
+
+
+ if(!out) {
+
+ // "in" animation always uses CSS transitions (instead of rAF).
+ // CSS transition work faster here,
+ // as developer may also want to animate other things,
+ // like ui on top of sliding area, which can be animated just via CSS
+
+ _currZoomLevel = item.initialZoomLevel;
+ _equalizePoints(_panOffset, item.initialPosition );
+ _applyCurrentZoomPan();
+ _applyBgOpacity(1);
+
+ if(fadeEverything) {
+ template.style.opacity = 1;
+ } else {
+ _applyBgOpacity(1);
+ }
+
+ _showOrHideTimeout = setTimeout(onComplete, duration + 20);
+ } else {
+
+ // "out" animation uses rAF only when PhotoSwipe is closed by browser scroll, to recalculate position
+ var destZoomLevel = thumbBounds.w / item.w,
+ initialPanOffset = {
+ x: _panOffset.x,
+ y: _panOffset.y
+ },
+ initialZoomLevel = _currZoomLevel,
+ scrollY = _initalWindowScrollY,
+ initalBgOpacity = _bgOpacity,
+ onUpdate = function(now) {
+ if(_scrollChanged) {
+ scrollY = framework.getScrollY();
+ _scrollChanged = false;
+ }
+
+ if(now === 1) {
+ _currZoomLevel = destZoomLevel;
+ _panOffset.x = thumbBounds.x;
+ _panOffset.y = thumbBounds.y - scrollY;
+ } else {
+ _currZoomLevel = (destZoomLevel - initialZoomLevel) * now + initialZoomLevel;
+ _panOffset.x = (thumbBounds.x - initialPanOffset.x) * now + initialPanOffset.x;
+ _panOffset.y = (thumbBounds.y - scrollY - initialPanOffset.y) * now + initialPanOffset.y;
+ }
+
+ _applyCurrentZoomPan();
+ if(fadeEverything) {
+ template.style.opacity = 1 - now;
+ } else {
+ _applyBgOpacity( initalBgOpacity - now * initalBgOpacity );
+ }
+ };
+
+ if(closeWithRaf) {
+ _animateProp('initialZoom', 0, 1, duration, framework.easing.cubic.out, onUpdate, onComplete);
+ } else {
+ onUpdate(1);
+ _showOrHideTimeout = setTimeout(onComplete, duration + 20);
+ }
+ }
+
+ }, out ? 25 : 90); // Main purpose of this delay is to give browser time to paint and
+ // create composite layers of PhotoSwipe UI parts (background, controls, caption, arrows).
+ // Which avoids lag at the beginning of scale transition.
+ };
+ startAnimation();
+
+
+ };
+
+/*>>show-hide-transition*/
+
+/*>>items-controller*/
+/**
+*
+* Controller manages gallery items, their dimensions, and their content.
+*
+*/
+
+var _items,
+ _tempPanAreaSize = {},
+ _imagesToAppendPool = [],
+ _initialContentSet,
+ _initialZoomRunning,
+ _controllerDefaultOptions = {
+ index: 0,
+ errorMsg: '<div class="pswp__error-msg"><a href="%url%" target="_blank">The image</a> could not be loaded.</div>',
+ forceProgressiveLoading: false, // TODO
+ preload: [1,1],
+ getNumItemsFn: function() {
+ return _items.length;
+ }
+ };
+
+
+var _getItemAt,
+ _getNumItems,
+ _initialIsLoop,
+ _getZeroBounds = function() {
+ return {
+ center:{x:0,y:0},
+ max:{x:0,y:0},
+ min:{x:0,y:0}
+ };
+ },
+ _calculateSingleItemPanBounds = function(item, realPanElementW, realPanElementH ) {
+ var bounds = item.bounds;
+
+ // position of element when it's centered
+ bounds.center.x = Math.round((_tempPanAreaSize.x - realPanElementW) / 2);
+ bounds.center.y = Math.round((_tempPanAreaSize.y - realPanElementH) / 2) + item.vGap.top;
+
+ // maximum pan position
+ bounds.max.x = (realPanElementW > _tempPanAreaSize.x) ?
+ Math.round(_tempPanAreaSize.x - realPanElementW) :
+ bounds.center.x;
+
+ bounds.max.y = (realPanElementH > _tempPanAreaSize.y) ?
+ Math.round(_tempPanAreaSize.y - realPanElementH) + item.vGap.top :
+ bounds.center.y;
+
+ // minimum pan position
+ bounds.min.x = (realPanElementW > _tempPanAreaSize.x) ? 0 : bounds.center.x;
+ bounds.min.y = (realPanElementH > _tempPanAreaSize.y) ? item.vGap.top : bounds.center.y;
+ },
+ _calculateItemSize = function(item, viewportSize, zoomLevel) {
+
+ if (item.src && !item.loadError) {
+ var isInitial = !zoomLevel;
+
+ if(isInitial) {
+ if(!item.vGap) {
+ item.vGap = {top:0,bottom:0};
+ }
+ // allows overriding vertical margin for individual items
+ _shout('parseVerticalMargin', item);
+ }
+
+
+ _tempPanAreaSize.x = viewportSize.x;
+ _tempPanAreaSize.y = viewportSize.y - item.vGap.top - item.vGap.bottom;
+
+ if (isInitial) {
+ var hRatio = _tempPanAreaSize.x / item.w;
+ var vRatio = _tempPanAreaSize.y / item.h;
+
+ item.fitRatio = hRatio < vRatio ? hRatio : vRatio;
+ //item.fillRatio = hRatio > vRatio ? hRatio : vRatio;
+
+ var scaleMode = _options.scaleMode;
+
+ if (scaleMode === 'orig') {
+ zoomLevel = 1;
+ } else if (scaleMode === 'fit') {
+ zoomLevel = item.fitRatio;
+ }
+
+ if (zoomLevel > 1) {
+ zoomLevel = 1;
+ }
+
+ item.initialZoomLevel = zoomLevel;
+
+ if(!item.bounds) {
+ // reuse bounds object
+ item.bounds = _getZeroBounds();
+ }
+ }
+
+ if(!zoomLevel) {
+ return;
+ }
+
+ _calculateSingleItemPanBounds(item, item.w * zoomLevel, item.h * zoomLevel);
+
+ if (isInitial && zoomLevel === item.initialZoomLevel) {
+ item.initialPosition = item.bounds.center;
+ }
+
+ return item.bounds;
+ } else {
+ item.w = item.h = 0;
+ item.initialZoomLevel = item.fitRatio = 1;
+ item.bounds = _getZeroBounds();
+ item.initialPosition = item.bounds.center;
+
+ // if it's not image, we return zero bounds (content is not zoomable)
+ return item.bounds;
+ }
+ return false;
+ },
+
+
+
+
+ _appendImage = function(index, item, baseDiv, img, preventAnimation, keepPlaceholder) {
+
+
+ if(item.loadError) {
+ return;
+ }
+
+ var animate,
+ isSwiping = self.isDragging() && !self.isZooming(),
+ slideMightBeVisible = index === _currentItemIndex || self.isMainScrollAnimating() || isSwiping;
+
+ // fade in loaded image only when current holder is active, or might be visible
+ if(!preventAnimation && (_likelyTouchDevice || _options.alwaysFadeIn) && slideMightBeVisible) {
+ animate = true;
+ }
+
+ if(img) {
+ if(animate) {
+ img.style.opacity = 0;
+ }
+
+ item.imageAppended = true;
+
+ baseDiv.appendChild(img);
+
+ if(animate) {
+ setTimeout(function() {
+ img.style.opacity = 1;
+ if(keepPlaceholder) {
+ setTimeout(function() {
+ // hide image placeholder "behind"
+ if(item && item.loaded && item.placeholder) {
+ item.placeholder.style.display = 'none';
+ item.placeholder = null;
+ }
+ }, 500);
+ }
+ }, 50);
+ }
+ }
+ },
+
+
+
+ _preloadImage = function(item) {
+ item.loading = true;
+ item.loaded = false;
+ var img = item.img = framework.createEl('pswp__img', 'img');
+ var onComplete = function() {
+ item.loading = false;
+ item.loaded = true;
+
+ if(item.loadComplete) {
+ item.loadComplete(item);
+ } else {
+ item.img = null; // no need to store image object
+ }
+ img.onload = img.onerror = null;
+ img = null;
+ };
+ img.onload = onComplete;
+ img.onerror = function() {
+ item.loadError = true;
+ onComplete();
+ };
+
+ img.src = item.src;// + '?a=' + Math.random();
+
+ return img;
+ },
+ _checkForError = function(item, cleanUp) {
+ if(item.src && item.loadError && item.container) {
+
+ if(cleanUp) {
+ item.container.innerHTML = '';
+ }
+
+ item.container.innerHTML = _options.errorMsg.replace('%url%', item.src );
+ return true;
+
+ }
+ },
+ _appendImagesPool = function() {
+
+ if(_imagesToAppendPool.length) {
+ var poolItem;
+
+ for(var i = 0; i < _imagesToAppendPool.length; i++) {
+ poolItem = _imagesToAppendPool[i];
+ if( poolItem.holder.index === poolItem.index ) {
+ _appendImage(poolItem.index, poolItem.item, poolItem.baseDiv, poolItem.img);
+ }
+ }
+ _imagesToAppendPool = [];
+ }
+ };
+
+
+
+_registerModule('Controller', {
+
+ publicMethods: {
+
+ lazyLoadItem: function(index) {
+ index = _getLoopedId(index);
+ var item = _getItemAt(index);
+
+ if(!item || !item.src || item.loaded || item.loading) {
+ return;
+ }
+
+ _shout('gettingData', index, item);
+ _preloadImage(item);
+ },
+ initController: function() {
+ framework.extend(_options, _controllerDefaultOptions, true);
+ self.items = _items = items;
+ _getItemAt = self.getItemAt;
+ _getNumItems = _options.getNumItemsFn; //self.getNumItems;
+
+
+
+ _initialIsLoop = _options.loop;
+ if(_getNumItems() < 3) {
+ _options.loop = false; // disable loop if less then 3 items
+ }
+
+ _listen('beforeChange', function(diff) {
+
+ var p = _options.preload,
+ isNext = diff === null ? true : (diff > 0),
+ preloadBefore = Math.min(p[0], _getNumItems() ),
+ preloadAfter = Math.min(p[1], _getNumItems() ),
+ i;
+
+
+ for(i = 1; i <= (isNext ? preloadAfter : preloadBefore); i++) {
+ self.lazyLoadItem(_currentItemIndex+i);
+ }
+ for(i = 1; i <= (isNext ? preloadBefore : preloadAfter); i++) {
+ self.lazyLoadItem(_currentItemIndex-i);
+ }
+ });
+
+ _listen('initialLayout', function() {
+ self.currItem.initialLayout = _options.getThumbBoundsFn && _options.getThumbBoundsFn(_currentItemIndex);
+ });
+
+ _listen('mainScrollAnimComplete', _appendImagesPool);
+ _listen('initialZoomInEnd', _appendImagesPool);
+
+
+
+ _listen('destroy', function() {
+ var item;
+ for(var i = 0; i < _items.length; i++) {
+ item = _items[i];
+ // remove reference to DOM elements, for GC
+ if(item.container) {
+ item.container = null;
+ }
+ if(item.placeholder) {
+ item.placeholder = null;
+ }
+ if(item.img) {
+ item.img = null;
+ }
+ if(item.preloader) {
+ item.preloader = null;
+ }
+ if(item.loadError) {
+ item.loaded = item.loadError = false;
+ }
+ }
+ _imagesToAppendPool = null;
+ });
+ },
+
+
+ getItemAt: function(index) {
+ if (index >= 0) {
+ return _items[index] !== undefined ? _items[index] : false;
+ }
+ return false;
+ },
+
+ allowProgressiveImg: function() {
+ // 1. Progressive image loading isn't working on webkit/blink
+ // when hw-acceleration (e.g. translateZ) is applied to IMG element.
+ // That's why in PhotoSwipe parent element gets zoom transform, not image itself.
+ //
+ // 2. Progressive image loading sometimes blinks in webkit/blink when applying animation to parent element.
+ // That's why it's disabled on touch devices (mainly because of swipe transition)
+ //
+ // 3. Progressive image loading sometimes doesn't work in IE (up to 11).
+
+ // Don't allow progressive loading on non-large touch devices
+ return _options.forceProgressiveLoading || !_likelyTouchDevice || _options.mouseUsed || screen.width > 1200;
+ // 1200 - to eliminate touch devices with large screen (like Chromebook Pixel)
+ },
+
+ setContent: function(holder, index) {
+
+ if(_options.loop) {
+ index = _getLoopedId(index);
+ }
+
+ var prevItem = self.getItemAt(holder.index);
+ if(prevItem) {
+ prevItem.container = null;
+ }
+
+ var item = self.getItemAt(index),
+ img;
+
+ if(!item) {
+ holder.el.innerHTML = '';
+ return;
+ }
+
+ // allow to override data
+ _shout('gettingData', index, item);
+
+ holder.index = index;
+ holder.item = item;
+
+ // base container DIV is created only once for each of 3 holders
+ var baseDiv = item.container = framework.createEl('pswp__zoom-wrap');
+
+
+
+ if(!item.src && item.html) {
+ if(item.html.tagName) {
+ baseDiv.appendChild(item.html);
+ } else {
+ baseDiv.innerHTML = item.html;
+ }
+ }
+
+ _checkForError(item);
+
+ if(item.src && !item.loadError && !item.loaded) {
+
+ item.loadComplete = function(item) {
+
+ // gallery closed before image finished loading
+ if(!_isOpen) {
+ return;
+ }
+
+ // Apply hw-acceleration only after image is loaded.
+ // This is webkit progressive image loading bugfix.
+ // https://bugs.webkit.org/show_bug.cgi?id=108630
+ // https://code.google.com/p/chromium/issues/detail?id=404547
+ item.img.style.webkitBackfaceVisibility = 'hidden';
+
+ // check if holder hasn't changed while image was loading
+ if(holder && holder.index === index ) {
+ if( _checkForError(item, true) ) {
+ item.loadComplete = item.img = null;
+ _calculateItemSize(item, _viewportSize);
+ _applyZoomPanToItem(item);
+
+ if(holder.index === _currentItemIndex) {
+ // recalculate dimensions
+ self.updateCurrZoomItem();
+ }
+ return;
+ }
+ if( !item.imageAppended ) {
+ if(_features.transform && (_mainScrollAnimating || _initialZoomRunning) ) {
+ _imagesToAppendPool.push({
+ item:item,
+ baseDiv:baseDiv,
+ img:item.img,
+ index:index,
+ holder:holder
+ });
+ } else {
+ _appendImage(index, item, baseDiv, item.img, _mainScrollAnimating || _initialZoomRunning);
+ }
+ } else {
+ // remove preloader & mini-img
+ if(!_initialZoomRunning && item.placeholder) {
+ item.placeholder.style.display = 'none';
+ item.placeholder = null;
+ }
+ }
+ }
+
+ item.loadComplete = null;
+ item.img = null; // no need to store image element after it's added
+
+ _shout('imageLoadComplete', index, item);
+ };
+
+ if(framework.features.transform) {
+
+ var placeholderClassName = 'pswp__img pswp__img--placeholder';
+ placeholderClassName += (item.msrc ? '' : ' pswp__img--placeholder--blank');
+
+ var placeholder = framework.createEl(placeholderClassName, item.msrc ? 'img' : '');
+ if(item.msrc) {
+ placeholder.src = item.msrc;
+ }
+
+ placeholder.style.width = item.w + 'px';
+ placeholder.style.height = item.h + 'px';
+
+ baseDiv.appendChild(placeholder);
+ item.placeholder = placeholder;
+
+ }
+
+
+
+
+ if(!item.loading) {
+ _preloadImage(item);
+ }
+
+
+ if( self.allowProgressiveImg() ) {
+ // just append image
+ if(!_initialContentSet && _features.transform) {
+ _imagesToAppendPool.push({
+ item:item,
+ baseDiv:baseDiv,
+ img:item.img,
+ index:index,
+ holder:holder
+ });
+ } else {
+ _appendImage(index, item, baseDiv, item.img, true, true);
+ }
+ }
+
+ } else if(item.src && !item.loadError) {
+ // image object is created every time, due to bugs of image loading & delay when switching images
+ img = framework.createEl('pswp__img', 'img');
+ img.style.webkitBackfaceVisibility = 'hidden';
+ img.style.opacity = 1;
+ img.src = item.src;
+ _appendImage(index, item, baseDiv, img, true);
+ }
+
+ _calculateItemSize(item, _viewportSize);
+
+ if(!_initialContentSet && index === _currentItemIndex) {
+ _currZoomElementStyle = baseDiv.style;
+ _showOrHide(item, (img ||item.img) );
+ } else {
+ _applyZoomPanToItem(item);
+ }
+
+ holder.el.innerHTML = '';
+ holder.el.appendChild(baseDiv);
+ },
+
+ cleanSlide: function( item ) {
+ if(item.img ) {
+ item.img.onload = item.img.onerror = null;
+ }
+ item.loaded = item.loading = item.img = item.imageAppended = false;
+ }
+
+ }
+});
+
+/*>>items-controller*/
+
+/*>>tap*/
+/**
+ * tap.js:
+ *
+ * Displatches tap and double-tap events.
+ *
+ */
+
+var tapTimer,
+ tapReleasePoint = {},
+ _dispatchTapEvent = function(origEvent, releasePoint, pointerType) {
+ var e = document.createEvent( 'CustomEvent' ),
+ eDetail = {
+ origEvent:origEvent,
+ target:origEvent.target,
+ releasePoint: releasePoint,
+ pointerType:pointerType || 'touch'
+ };
+
+ e.initCustomEvent( 'pswpTap', true, true, eDetail );
+ origEvent.target.dispatchEvent(e);
+ };
+
+_registerModule('Tap', {
+ publicMethods: {
+ initTap: function() {
+ _listen('firstTouchStart', self.onTapStart);
+ _listen('touchRelease', self.onTapRelease);
+ _listen('destroy', function() {
+ tapReleasePoint = {};
+ tapTimer = null;
+ });
+ },
+ onTapStart: function(touchList) {
+ if(touchList.length > 1) {
+ clearTimeout(tapTimer);
+ tapTimer = null;
+ }
+ },
+ onTapRelease: function(e, releasePoint) {
+ if(!releasePoint) {
+ return;
+ }
+
+ if(!_moved && !_isMultitouch && !_numAnimations) {
+ var p0 = releasePoint;
+ if(tapTimer) {
+ clearTimeout(tapTimer);
+ tapTimer = null;
+
+ // Check if taped on the same place
+ if ( _isNearbyPoints(p0, tapReleasePoint) ) {
+ _shout('doubleTap', p0);
+ return;
+ }
+ }
+
+ if(releasePoint.type === 'mouse') {
+ _dispatchTapEvent(e, releasePoint, 'mouse');
+ return;
+ }
+
+ var clickedTagName = e.target.tagName.toUpperCase();
+ // avoid double tap delay on buttons and elements that have class pswp__single-tap
+ if(clickedTagName === 'BUTTON' || framework.hasClass(e.target, 'pswp__single-tap') ) {
+ _dispatchTapEvent(e, releasePoint);
+ return;
+ }
+
+ _equalizePoints(tapReleasePoint, p0);
+
+ tapTimer = setTimeout(function() {
+ _dispatchTapEvent(e, releasePoint);
+ tapTimer = null;
+ }, 300);
+ }
+ }
+ }
+});
+
+/*>>tap*/
+
+/*>>desktop-zoom*/
+/**
+ *
+ * desktop-zoom.js:
+ *
+ * - Binds mousewheel event for paning zoomed image.
+ * - Manages "dragging", "zoomed-in", "zoom-out" classes.
+ * (which are used for cursors and zoom icon)
+ * - Adds toggleDesktopZoom function.
+ *
+ */
+
+var _wheelDelta;
+
+_registerModule('DesktopZoom', {
+
+ publicMethods: {
+
+ initDesktopZoom: function() {
+
+ if(_oldIE) {
+ // no zoom for old IE (<=8)
+ return;
+ }
+
+ if(_likelyTouchDevice) {
+ // if detected hardware touch support, we wait until mouse is used,
+ // and only then apply desktop-zoom features
+ _listen('mouseUsed', function() {
+ self.setupDesktopZoom();
+ });
+ } else {
+ self.setupDesktopZoom(true);
+ }
+
+ },
+
+ setupDesktopZoom: function(onInit) {
+
+ _wheelDelta = {};
+
+ var events = 'wheel mousewheel DOMMouseScroll';
+
+ _listen('bindEvents', function() {
+ framework.bind(template, events, self.handleMouseWheel);
+ });
+
+ _listen('unbindEvents', function() {
+ if(_wheelDelta) {
+ framework.unbind(template, events, self.handleMouseWheel);
+ }
+ });
+
+ self.mouseZoomedIn = false;
+
+ var hasDraggingClass,
+ updateZoomable = function() {
+ if(self.mouseZoomedIn) {
+ framework.removeClass(template, 'pswp--zoomed-in');
+ self.mouseZoomedIn = false;
+ }
+ if(_currZoomLevel < 1) {
+ framework.addClass(template, 'pswp--zoom-allowed');
+ } else {
+ framework.removeClass(template, 'pswp--zoom-allowed');
+ }
+ removeDraggingClass();
+ },
+ removeDraggingClass = function() {
+ if(hasDraggingClass) {
+ framework.removeClass(template, 'pswp--dragging');
+ hasDraggingClass = false;
+ }
+ };
+
+ _listen('resize' , updateZoomable);
+ _listen('afterChange' , updateZoomable);
+ _listen('pointerDown', function() {
+ if(self.mouseZoomedIn) {
+ hasDraggingClass = true;
+ framework.addClass(template, 'pswp--dragging');
+ }
+ });
+ _listen('pointerUp', removeDraggingClass);
+
+ if(!onInit) {
+ updateZoomable();
+ }
+
+ },
+
+ handleMouseWheel: function(e) {
+
+ if(_currZoomLevel <= self.currItem.fitRatio) {
+ if(!_options.closeOnScroll) {
+ e.preventDefault();
+ }
+ return true;
+ }
+
+ e.preventDefault();
+ // allow just one event to fire
+ e.stopPropagation();
+
+ // https://developer.mozilla.org/en-US/docs/Web/Events/wheel
+ _wheelDelta.x = 0;
+
+ if('deltaX' in e) {
+ _wheelDelta.x = e.deltaX;
+ _wheelDelta.y = e.deltaY;
+ } else if('wheelDelta' in e) {
+ if(e.wheelDeltaX) {
+ _wheelDelta.x = -0.16 * e.wheelDeltaX;
+ }
+ if(e.wheelDeltaY) {
+ _wheelDelta.y = -0.16 * e.wheelDeltaY;
+ } else {
+ _wheelDelta.y = -0.16 * e.wheelDelta;
+ }
+ } else if('detail' in e) {
+ _wheelDelta.y = e.detail;
+ } else {
+ return;
+ }
+
+ // TODO: use rAF instead of mousewheel?
+ _calculatePanBounds(_currZoomLevel, true);
+ self.panTo(_panOffset.x - _wheelDelta.x, _panOffset.y - _wheelDelta.y);
+ },
+
+ toggleDesktopZoom: function(centerPoint) {
+ centerPoint = centerPoint || {x:_viewportSize.x/2, y:_viewportSize.y/2 + _initalWindowScrollY };
+
+ var doubleTapZoomLevel = _options.getDoubleTapZoom(true, self.currItem);
+ var zoomOut = _currZoomLevel === doubleTapZoomLevel;
+
+ self.mouseZoomedIn = !zoomOut;
+
+ self.zoomTo(zoomOut ? self.currItem.initialZoomLevel : doubleTapZoomLevel, centerPoint, 333);
+ framework[ (!zoomOut ? 'add' : 'remove') + 'Class'](template, 'pswp--zoomed-in');
+ }
+
+ }
+});
+
+/*>>desktop-zoom*/
+
+/*>>history*/
+/**
+ *
+ * history.js:
+ *
+ * - Back button to close gallery.
+ *
+ * - Unique URL for each slide: example.com/&pid=1&gid=3
+ * (where PID is picture index, and GID and gallery index)
+ *
+ * - Switch URL when slides change.
+ *
+ */
+
+
+var _historyDefaultOptions = {
+ history: true,
+ galleryUID: 1
+};
+
+var _historyUpdateTimeout,
+ _hashChangeTimeout,
+ _hashAnimCheckTimeout,
+ _hashChangedByScript,
+ _hashChangedByHistory,
+ _hashReseted,
+ _initialHash,
+ _historyChanged,
+ _closedFromURL,
+ _urlChangedOnce,
+ _windowLoc,
+
+ _supportsPushState,
+
+ _getHash = function() {
+ return _windowLoc.hash.substring(1);
+ },
+ _cleanHistoryTimeouts = function() {
+
+ if(_historyUpdateTimeout) {
+ clearTimeout(_historyUpdateTimeout);
+ }
+
+ if(_hashAnimCheckTimeout) {
+ clearTimeout(_hashAnimCheckTimeout);
+ }
+ },
+
+ // pid - Picture index
+ // gid - Gallery index
+ _parseItemIndexFromURL = function() {
+ var hash = _getHash(),
+ params = {};
+
+ if(hash.length < 5) { // pid=1
+ return params;
+ }
+
+ var vars = hash.split('&');
+ for (var i = 0; i < vars.length; i++) {
+ if(!vars[i]) {
+ continue;
+ }
+ var pair = vars[i].split('=');
+ if(pair.length < 2) {
+ continue;
+ }
+ params[pair[0]] = pair[1];
+ }
+ params.pid = parseInt(params.pid,10)-1;
+ if( params.pid < 0 ) {
+ params.pid = 0;
+ }
+ return params;
+ },
+ _updateHash = function() {
+
+ if(_hashAnimCheckTimeout) {
+ clearTimeout(_hashAnimCheckTimeout);
+ }
+
+
+ if(_numAnimations || _isDragging) {
+ // changing browser URL forces layout/paint in some browsers, which causes noticable lag during animation
+ // that's why we update hash only when no animations running
+ _hashAnimCheckTimeout = setTimeout(_updateHash, 500);
+ return;
+ }
+
+ if(_hashChangedByScript) {
+ clearTimeout(_hashChangeTimeout);
+ } else {
+ _hashChangedByScript = true;
+ }
+
+
+ var newHash = _initialHash + '&' + 'gid=' + _options.galleryUID + '&' + 'pid=' + (_currentItemIndex + 1);
+
+ if(!_historyChanged) {
+ if(_windowLoc.hash.indexOf(newHash) === -1) {
+ _urlChangedOnce = true;
+ }
+ // first time - add new hisory record, then just replace
+ }
+
+ var newURL = _windowLoc.href.split('#')[0] + '#' + newHash;
+
+ if( _supportsPushState ) {
+
+ if('#' + newHash !== window.location.hash) {
+ history[_historyChanged ? 'replaceState' : 'pushState']('', document.title, newURL);
+ }
+
+ } else {
+ if(_historyChanged) {
+ _windowLoc.replace( newURL );
+ } else {
+ _windowLoc.hash = newHash;
+ }
+ }
+
+
+
+ _historyChanged = true;
+ _hashChangeTimeout = setTimeout(function() {
+ _hashChangedByScript = false;
+ }, 60);
+ };
+
+
+
+
+
+_registerModule('History', {
+
+
+
+ publicMethods: {
+ initHistory: function() {
+
+ framework.extend(_options, _historyDefaultOptions, true);
+
+ if( !_options.history ) {
+ return;
+ }
+
+
+ _windowLoc = window.location;
+ _urlChangedOnce = false;
+ _closedFromURL = false;
+ _historyChanged = false;
+ _initialHash = _getHash();
+ _supportsPushState = ('pushState' in history);
+
+
+ if(_initialHash.indexOf('gid=') > -1) {
+ _initialHash = _initialHash.split('&gid=')[0];
+ _initialHash = _initialHash.split('?gid=')[0];
+ }
+
+
+ _listen('afterChange', self.updateURL);
+ _listen('unbindEvents', function() {
+ framework.unbind(window, 'hashchange', self.onHashChange);
+ });
+
+
+ var returnToOriginal = function() {
+ _hashReseted = true;
+ if(!_closedFromURL) {
+
+ if(_urlChangedOnce) {
+ history.back();
+ } else {
+
+ if(_initialHash) {
+ _windowLoc.hash = _initialHash;
+ } else {
+ if (_supportsPushState) {
+
+ // remove hash from url without refreshing it or scrolling to top
+ history.pushState('', document.title, _windowLoc.pathname + _windowLoc.search );
+ } else {
+ _windowLoc.hash = '';
+ }
+ }
+ }
+
+ }
+
+ _cleanHistoryTimeouts();
+ };
+
+
+ _listen('unbindEvents', function() {
+ if(_closedByScroll) {
+ // if PhotoSwipe is closed by scroll, we go "back" before the closing animation starts
+ // this is done to keep the scroll position
+ returnToOriginal();
+ }
+ });
+ _listen('destroy', function() {
+ if(!_hashReseted) {
+ returnToOriginal();
+ }
+ });
+ _listen('firstUpdate', function() {
+ _currentItemIndex = _parseItemIndexFromURL().pid;
+ });
+
+
+
+
+ var index = _initialHash.indexOf('pid=');
+ if(index > -1) {
+ _initialHash = _initialHash.substring(0, index);
+ if(_initialHash.slice(-1) === '&') {
+ _initialHash = _initialHash.slice(0, -1);
+ }
+ }
+
+
+ setTimeout(function() {
+ if(_isOpen) { // hasn't destroyed yet
+ framework.bind(window, 'hashchange', self.onHashChange);
+ }
+ }, 40);
+
+ },
+ onHashChange: function() {
+
+ if(_getHash() === _initialHash) {
+
+ _closedFromURL = true;
+ self.close();
+ return;
+ }
+ if(!_hashChangedByScript) {
+
+ _hashChangedByHistory = true;
+ self.goTo( _parseItemIndexFromURL().pid );
+ _hashChangedByHistory = false;
+ }
+
+ },
+ updateURL: function() {
+
+ // Delay the update of URL, to avoid lag during transition,
+ // and to not to trigger actions like "refresh page sound" or "blinking favicon" to often
+
+ _cleanHistoryTimeouts();
+
+
+ if(_hashChangedByHistory) {
+ return;
+ }
+
+ if(!_historyChanged) {
+ _updateHash(); // first time
+ } else {
+ _historyUpdateTimeout = setTimeout(_updateHash, 800);
+ }
+ }
+
+ }
+});
+
+/*>>history*/
+ framework.extend(self, publicMethods); };
+ return PhotoSwipe;
+});
\ No newline at end of file
diff --git a/data/ext/perspectiveImageSwiper/dist/photoswipe.min.js b/data/ext/perspectiveImageSwiper/dist/photoswipe.min.js
new file mode 100644
index 000000000..d657ff2f1
--- /dev/null
+++ b/data/ext/perspectiveImageSwiper/dist/photoswipe.min.js
@@ -0,0 +1,4 @@
+/*! PhotoSwipe - v4.0.3 - 2015-01-09
+* http://photoswipe.com
+* Copyright (c) 2015 Dmitry Semenov; */
+!function(a,b){"function"==typeof define&&define.amd?define(b):"object"==typeof exports?module.exports=b():a.PhotoSwipe=b()}(this,function(){"use strict";var a=function(a,b,c,d){var e={features:null,bind:function(a,b,c,d){var e=(d?"remove":"add")+"EventListener";b=b.split(" ");for(var f=0;f<b.length;f++)b[f]&&a[e](b[f],c,!1)},isArray:function(a){return a instanceof Array},createEl:function(a,b){var c=document.createElement(b||"div");return a&&(c.className=a),c},getScrollY:function(){var a=window.pageYOffset;return void 0!==a?a:document.documentElement.scrollTop},unbind:function(a,b,c){e.bind(a,b,c,!0)},removeClass:function(a,b){var c=new RegExp("(\\s|^)"+b+"(\\s|$)");a.className=a.className.replace(c," ").replace(/^\s\s*/,"").replace(/\s\s*$/,"")},addClass:function(a,b){e.hasClass(a,b)||(a.className+=(a.className?" ":"")+b)},hasClass:function(a,b){return a.className&&new RegExp("(^|\\s)"+b+"(\\s|$)").test(a.className)},getChildByClass:function(a,b){for(var c=a.firstChild;c;){if(e.hasClass(c,b))return c;c=c.nextSibling}},arraySearch:function(a,b,c){for(var d=a.length;d--;)if(a[d][c]===b)return d;return-1},extend:function(a,b,c){for(var d in b)if(b.hasOwnProperty(d)){if(c&&a.hasOwnProperty(d))continue;a[d]=b[d]}},easing:{sine:{out:function(a){return Math.sin(a*(Math.PI/2))},inOut:function(a){return-(Math.cos(Math.PI*a)-1)/2}},cubic:{out:function(a){return--a*a*a+1}}},detectFeatures:function(){if(e.features)return e.features;var a=e.createEl(),b=a.style,c="",d={};if(d.oldIE=document.all&&!document.addEventListener,d.touch="ontouchstart"in window,window.requestAnimationFrame&&(d.raf=window.requestAnimationFrame,d.caf=window.cancelAnimationFrame),d.pointerEvent=navigator.pointerEnabled||navigator.msPointerEnabled,!d.pointerEvent){var f=navigator.userAgent;if(/iP(hone|od)/.test(navigator.platform)){var g=navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);g&&g.length>0&&(g=parseInt(g[1],10),g>=1&&8>g&&(d.isOldIOSPhone=!0))}var h=f.match(/Android\s([0-9\.]*)/),i=h?h[1]:0;i=parseFloat(i),i>=1&&(4.4>i&&(d.isOldAndroid=!0),d.androidVersion=i),d.isMobileOpera=/opera mini|opera mobi/i.test(f)}for(var j,k,l=["transform","perspective","animationName"],m=["","webkit","Moz","ms","O"],n=0;4>n;n++){c=m[n];for(var o=0;3>o;o++)j=l[o],k=c+(c?j.charAt(0).toUpperCase()+j.slice(1):j),!d[j]&&k in b&&(d[j]=k);c&&!d.raf&&(c=c.toLowerCase(),d.raf=window[c+"RequestAnimationFrame"],d.raf&&(d.caf=window[c+"CancelAnimationFrame"]||window[c+"CancelRequestAnimationFrame"]))}if(!d.raf){var p=0;d.raf=function(a){var b=(new Date).getTime(),c=Math.max(0,16-(b-p)),d=window.setTimeout(function(){a(b+c)},c);return p=b+c,d},d.caf=function(a){clearTimeout(a)}}return d.svg=!!document.createElementNS&&!!document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGRect,e.features=d,d}};e.detectFeatures(),e.features.oldIE&&(e.bind=function(a,b,c,d){b=b.split(" ");for(var e,f=(d?"detach":"attach")+"Event",g=function(){c.handleEvent.call(c)},h=0;h<b.length;h++)if(e=b[h])if("object"==typeof c&&c.handleEvent){if(d){if(!c["oldIE"+e])return!1}else c["oldIE"+e]=g;a[f]("on"+e,c["oldIE"+e])}else a[f]("on"+e,c)});var f=this,g=25,h=3,i={allowPanToNext:!0,spacing:.12,bgOpacity:1,mouseUsed:!1,loop:!0,pinchToClose:!0,closeOnScroll:!0,closeOnVerticalDrag:!0,hideAnimationDuration:333,showAnimationDuration:333,showHideOpacity:!1,focus:!0,escKey:!0,arrowKeys:!0,mainScrollEndFriction:.35,panEndFriction:.35,isClickableElement:function(a){return"A"===a.tagName},getDoubleTapZoom:function(a,b){return a?1:b.initialZoomLevel<.7?1:1.5},maxSpreadZoom:2,scaleMode:"fit",modal:!0,alwaysFadeIn:!1};e.extend(i,d);var j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,$,_,ab,bb,cb,db,eb,fb,gb,hb,ib,jb,kb,lb,mb,nb=function(){return{x:0,y:0}},ob=nb(),pb=nb(),qb=nb(),rb={},sb=0,tb=nb(),ub=0,vb=!0,wb=[],xb={},yb=function(a,b){e.extend(f,b.publicMethods),wb.push(a)},zb=function(a){var b=_c();return a>b-1?a-b:0>a?b+a:a},Ab={},Bb=function(a,b){return Ab[a]||(Ab[a]=[]),Ab[a].push(b)},Cb=function(a){var b=Ab[a];if(b){var c=Array.prototype.slice.call(arguments);c.shift();for(var d=0;d<b.length;d++)b[d].apply(f,c)}},Db=function(){return(new Date).getTime()},Eb=function(a){kb=a,f.bg.style.opacity=a*i.bgOpacity},Fb=function(a,b,c,d){a[G]=u+b+"px, "+c+"px"+v+" scale("+d+")"},Gb=function(){fb&&Fb(fb,qb.x,qb.y,s)},Hb=function(a){a.container&&Fb(a.container.style,a.initialPosition.x,a.initialPosition.y,a.initialZoomLevel)},Ib=function(a,b){b[G]=u+a+"px, 0px"+v},Jb=function(a,b){if(!i.loop&&b){var c=m+(tb.x*sb-a)/tb.x,d=Math.round(a-sc.x);(0>c&&d>0||c>=_c()-1&&0>d)&&(a=sc.x+d*i.mainScrollEndFriction)}sc.x=a,Ib(a,n)},Kb=function(a,b){var c=tc[a]-y[a];return pb[a]+ob[a]+c-c*(b/t)},Lb=function(a,b){a.x=b.x,a.y=b.y,b.id&&(a.id=b.id)},Mb=function(a){a.x=Math.round(a.x),a.y=Math.round(a.y)},Nb=null,Ob=function(){Nb&&(e.unbind(document,"mousemove",Ob),e.addClass(a,"pswp--has_mouse"),i.mouseUsed=!0,Cb("mouseUsed")),Nb=setTimeout(function(){Nb=null},100)},Pb=function(){e.bind(document,"keydown",f),P.transform&&e.bind(f.scrollWrap,"click",f),i.mouseUsed||e.bind(document,"mousemove",Ob),e.bind(window,"resize scroll",f),Cb("bindEvents")},Qb=function(){e.unbind(window,"resize",f),e.unbind(window,"scroll",r.scroll),e.unbind(document,"keydown",f),e.unbind(document,"mousemove",Ob),P.transform&&e.unbind(f.scrollWrap,"click",f),W&&e.unbind(window,p,f),Cb("unbindEvents")},Rb=function(a,b){var c=hd(f.currItem,rb,a);return b&&(eb=c),c},Sb=function(a){return a||(a=f.currItem),a.initialZoomLevel},Tb=function(a){return a||(a=f.currItem),a.w>0?i.maxSpreadZoom:1},Ub=function(a,b,c,d){return d===f.currItem.initialZoomLevel?(c[a]=f.currItem.initialPosition[a],!0):(c[a]=Kb(a,d),c[a]>b.min[a]?(c[a]=b.min[a],!0):c[a]<b.max[a]?(c[a]=b.max[a],!0):!1)},Vb=function(){if(G){var b=P.perspective&&!I;return u="translate"+(b?"3d(":"("),void(v=P.perspective?", 0px)":")")}G="left",e.addClass(a,"pswp--ie"),Ib=function(a,b){b.left=a+"px"},Hb=function(a){var b=a.container.style,c=a.fitRatio*a.w,d=a.fitRatio*a.h;b.width=c+"px",b.height=d+"px",b.left=a.initialPosition.x+"px",b.top=a.initialPosition.y+"px"},Gb=function(){if(fb){var a=fb,b=f.currItem,c=b.fitRatio*b.w,d=b.fitRatio*b.h;a.width=c+"px",a.height=d+"px",a.left=qb.x+"px",a.top=qb.y+"px"}}},Wb=function(a){var b="";i.escKey&&27===a.keyCode?b="close":i.arrowKeys&&(37===a.keyCode?b="prev":39===a.keyCode&&(b="next")),b&&(a.ctrlKey||a.altKey||a.shiftKey||a.metaKey||(a.preventDefault?a.preventDefault():a.returnValue=!1,f[b]()))},Xb=function(a){a&&(Z||Y||gb||U)&&(a.preventDefault(),a.stopPropagation())},Yb=function(){z=!0,i.closeOnScroll&&j&&(!f.likelyTouchDevice||i.mouseUsed)&&Math.abs(e.getScrollY()-M)>2&&(l=!0,f.close())},Zb={},$b=0,_b=function(a){Zb[a]&&(Zb[a].raf&&K(Zb[a].raf),$b--,delete Zb[a])},ac=function(a){Zb[a]&&_b(a),Zb[a]||($b++,Zb[a]={})},bc=function(){for(var a in Zb)Zb.hasOwnProperty(a)&&_b(a)},cc=function(a,b,c,d,e,f,g){var h,i=Db();ac(a);var j=function(){if(Zb[a]){if(h=Db()-i,h>=d)return _b(a),f(c),void(g&&g());f((c-b)*e(h/d)+b),Zb[a].raf=J(j)}};j()},dc={shout:Cb,listen:Bb,viewportSize:rb,options:i,isMainScrollAnimating:function(){return gb},getZoomLevel:function(){return s},getCurrentIndex:function(){return m},isDragging:function(){return W},isZooming:function(){return bb},applyZoomPan:function(a,b,c){qb.x=b,qb.y=c,s=a,Gb()},init:function(){if(!j&&!k){var c;f.framework=e,f.template=a,f.bg=e.getChildByClass(a,"pswp__bg"),L=a.className,j=!0,P=e.detectFeatures(),J=P.raf,K=P.caf,G=P.transform,N=P.oldIE,f.scrollWrap=e.getChildByClass(a,"pswp__scroll-wrap"),f.container=e.getChildByClass(f.scrollWrap,"pswp__container"),n=f.container.style,f.itemHolders=A=[{el:f.container.children[0],wrap:0,index:-1},{el:f.container.children[1],wrap:0,index:-1},{el:f.container.children[2],wrap:0,index:-1}],A[0].el.style.display=A[2].el.style.display="none",Vb(),r={resize:f.updateSize,scroll:Yb,keydown:Wb,click:Xb};var d=P.isOldIOSPhone||P.isOldAndroid||P.isMobileOpera;for(P.animationName&&P.transform&&!d||(i.showAnimationDuration=i.hideAnimationDuration=0),c=0;c<wb.length;c++)f["init"+wb[c]]();if(b){var g=f.ui=new b(f,e);g.init()}Cb("firstUpdate"),m=m||i.index||0,(isNaN(m)||0>m||m>=_c())&&(m=0),f.currItem=$c(m),(P.isOldIOSPhone||P.isOldAndroid)&&(vb=!1),i.modal&&(a.setAttribute("aria-hidden","false"),vb?a.style.position="fixed":(a.style.position="absolute",a.style.top=e.getScrollY()+"px")),void 0===O&&(Cb("initialLayout"),O=M=e.getScrollY());var l="pswp--open ";for(i.mainClass&&(l+=i.mainClass+" "),i.showHideOpacity&&(l+="pswp--animate_opacity "),l+=I?"pswp--touch":"pswp--notouch",l+=P.animationName?" pswp--css_animation":"",l+=P.svg?" pswp--svg":"",e.addClass(a,l),f.updateSize(),o=-1,ub=null,c=0;h>c;c++)Ib((c+o)*tb.x,A[c].el.style);N||e.bind(f.scrollWrap,q,f),Bb("initialZoomInEnd",function(){f.setContent(A[0],m-1),f.setContent(A[2],m+1),A[0].el.style.display=A[2].el.style.display="block",i.focus&&a.focus(),Pb()}),f.setContent(A[1],m),f.updateCurrItem(),Cb("afterInit"),vb||(w=setInterval(function(){$b||W||bb||s!==f.currItem.initialZoomLevel||f.updateSize()},1e3)),e.addClass(a,"pswp--visible")}},close:function(){j&&(j=!1,k=!0,Cb("close"),Qb(),bd(f.currItem,null,!0,f.destroy))},destroy:function(){Cb("destroy"),Wc&&clearTimeout(Wc),i.modal&&(a.setAttribute("aria-hidden","true"),a.className=L),w&&clearInterval(w),e.unbind(f.scrollWrap,q,f),e.unbind(window,"scroll",f),yc(),bc(),Ab=null},panTo:function(a,b,c){c||(a>eb.min.x?a=eb.min.x:a<eb.max.x&&(a=eb.max.x),b>eb.min.y?b=eb.min.y:b<eb.max.y&&(b=eb.max.y)),qb.x=a,qb.y=b,Gb()},handleEvent:function(a){a=a||window.event,r[a.type]&&r[a.type](a)},goTo:function(a){a=zb(a);var b=a-m;ub=b,m=a,f.currItem=$c(m),sb-=b,Jb(tb.x*sb),bc(),gb=!1,f.updateCurrItem()},next:function(){f.goTo(m+1)},prev:function(){f.goTo(m-1)},updateCurrZoomItem:function(a){if(a&&Cb("beforeChange",0),A[1].el.children.length){var b=A[1].el.children[0];fb=e.hasClass(b,"pswp__zoom-wrap")?b.style:null}else fb=null;eb=f.currItem.bounds,t=s=f.currItem.initialZoomLevel,qb.x=eb.center.x,qb.y=eb.center.y,a&&Cb("afterChange")},invalidateCurrItems:function(){x=!0;for(var a=0;h>a;a++)A[a].item&&(A[a].item.needsUpdate=!0)},updateCurrItem:function(a){if(0!==ub){var b,c=Math.abs(ub);if(!(a&&2>c)){f.currItem=$c(m),Cb("beforeChange",ub),c>=h&&(o+=ub+(ub>0?-h:h),c=h);for(var d=0;c>d;d++)ub>0?(b=A.shift(),A[h-1]=b,o++,Ib((o+2)*tb.x,b.el.style),f.setContent(b,m-c+d+1+1)):(b=A.pop(),A.unshift(b),o--,Ib(o*tb.x,b.el.style),f.setContent(b,m+c-d-1-1));if(fb&&1===Math.abs(ub)){var e=$c(B);e.initialZoomLevel!==s&&(hd(e,rb),Hb(e))}ub=0,f.updateCurrZoomItem(),B=m,Cb("afterChange")}}},updateSize:function(b){if(!vb){var c=e.getScrollY();if(O!==c&&(a.style.top=c+"px",O=c),!b&&xb.x===window.innerWidth&&xb.y===window.innerHeight)return;xb.x=window.innerWidth,xb.y=window.innerHeight,a.style.height=xb.y+"px"}if(rb.x=f.scrollWrap.clientWidth,rb.y=f.scrollWrap.clientHeight,y={x:0,y:O},tb.x=rb.x+Math.round(rb.x*i.spacing),tb.y=rb.y,Jb(tb.x*sb),Cb("beforeResize"),void 0!==o){for(var d,g,j,k=0;h>k;k++)d=A[k],Ib((k+o)*tb.x,d.el.style),j=zb(m+k-1),g=$c(j),x||g.needsUpdate||!g.bounds?(g&&f.cleanSlide(g),f.setContent(d,j),1===k&&(f.currItem=g,f.updateCurrZoomItem(!0)),g.needsUpdate=!1):-1===d.index&&j>=0&&f.setContent(d,j),g&&g.container&&(hd(g,rb),Hb(g));x=!1}t=s=f.currItem.initialZoomLevel,eb=f.currItem.bounds,eb&&(qb.x=eb.center.x,qb.y=eb.center.y,Gb()),Cb("resize")},zoomTo:function(a,b,c,d,f){b&&(t=s,tc.x=Math.abs(b.x)-qb.x,tc.y=Math.abs(b.y)-qb.y,Lb(pb,qb));var g=Rb(a,!1),h={};Ub("x",g,h,a),Ub("y",g,h,a);var i=s,j={x:qb.x,y:qb.y};Mb(h);var k=function(b){1===b?(s=a,qb.x=h.x,qb.y=h.y):(s=(a-i)*b+i,qb.x=(h.x-j.x)*b+j.x,qb.y=(h.y-j.y)*b+j.y),f&&f(b),Gb()};c?cc("customZoomTo",0,1,c,d||e.easing.sine.inOut,k):k(1)}},ec=30,fc=10,gc={},hc={},ic={},jc={},kc={},lc=[],mc={},nc=[],oc={},pc=0,qc=nb(),rc=0,sc=nb(),tc=nb(),uc=nb(),vc=function(a,b){return a.x===b.x&&a.y===b.y},wc=function(a,b){return Math.abs(a.x-b.x)<g&&Math.abs(a.y-b.y)<g},xc=function(a,b){return oc.x=Math.abs(a.x-b.x),oc.y=Math.abs(a.y-b.y),Math.sqrt(oc.x*oc.x+oc.y*oc.y)},yc=function(){$&&(K($),$=null)},zc=function(){W&&($=J(zc),Pc())},Ac=function(){return!("fit"===i.scaleMode&&s===f.currItem.initialZoomLevel)},Bc=function(a,b){return a?a.className&&a.className.indexOf("pswp__scroll-wrap")>-1?!1:b(a)?a:Bc(a.parentNode,b):!1},Cc={},Dc=function(a,b){return Cc.prevent=!Bc(a.target,i.isClickableElement),Cb("preventDragEvent",a,b,Cc),Cc.prevent},Ec=function(a,b){return b.x=a.pageX,b.y=a.pageY,b.id=a.identifier,b},Fc=function(a,b,c){c.x=.5*(a.x+b.x),c.y=.5*(a.y+b.y)},Gc=function(a,b,c){if(a-R>50){var d=nc.length>2?nc.shift():{};d.x=b,d.y=c,nc.push(d),R=a}},Hc=function(){var a=qb.y-f.currItem.initialPosition.y;return 1-Math.abs(a/(rb.y/2))},Ic={},Jc={},Kc=[],Lc=function(a){for(;Kc.length>0;)Kc.pop();return H?(mb=0,lc.forEach(function(a){0===mb?Kc[0]=a:1===mb&&(Kc[1]=a),mb++})):a.type.indexOf("touch")>-1?a.touches&&a.touches.length>0&&(Kc[0]=Ec(a.touches[0],Ic),a.touches.length>1&&(Kc[1]=Ec(a.touches[1],Jc))):(Ic.x=a.pageX,Ic.y=a.pageY,Ic.id="",Kc[0]=Ic),Kc},Mc=function(a,b){var c,d,e,g,h=0,j=qb[a]+b[a],k=b[a]>0,l=sc.x+b.x,m=sc.x-mc.x;return c=j>eb.min[a]||j<eb.max[a]?i.panEndFriction:1,j=qb[a]+b[a]*c,!i.allowPanToNext&&s!==f.currItem.initialZoomLevel||(fb?"h"!==hb||"x"!==a||Y||(k?(j>eb.min[a]&&(c=i.panEndFriction,h=eb.min[a]-j,d=eb.min[a]-pb[a]),(0>=d||0>m)&&_c()>1?(g=l,0>m&&l>mc.x&&(g=mc.x)):eb.min.x!==eb.max.x&&(e=j)):(j<eb.max[a]&&(c=i.panEndFriction,h=j-eb.max[a],d=pb[a]-eb.max[a]),(0>=d||m>0)&&_c()>1?(g=l,m>0&&l<mc.x&&(g=mc.x)):eb.min.x!==eb.max.x&&(e=j))):g=l,"x"!==a)?void(gb||_||s>f.currItem.fitRatio&&(qb[a]+=b[a]*c)):(void 0!==g&&(Jb(g,!0),_=g===mc.x?!1:!0),eb.min.x!==eb.max.x&&(void 0!==e?qb.x=e:_||(qb.x+=b.x*c)),void 0!==g)},Nc=function(a){if(!("mousedown"===a.type&&a.button>0)){if(Zc)return void a.preventDefault();if(!V||"mousedown"!==a.type){if(Dc(a,!0)&&a.preventDefault(),Cb("pointerDown"),H){var b=e.arraySearch(lc,a.pointerId,"id");0>b&&(b=lc.length),lc[b]={x:a.pageX,y:a.pageY,id:a.pointerId}}var c=Lc(a),d=c.length;ab=null,bc(),W&&1!==d||(W=ib=!0,e.bind(window,p,f),T=lb=jb=U=_=Z=X=Y=!1,hb=null,Cb("firstTouchStart",c),Lb(pb,qb),ob.x=ob.y=0,Lb(jc,c[0]),Lb(kc,jc),mc.x=tb.x*sb,nc=[{x:jc.x,y:jc.y}],R=Q=Db(),Rb(s,!0),yc(),zc()),!bb&&d>1&&!gb&&!_&&(t=s,Y=!1,bb=X=!0,ob.y=ob.x=0,Lb(pb,qb),Lb(gc,c[0]),Lb(hc,c[1]),Fc(gc,hc,uc),tc.x=Math.abs(uc.x)-qb.x,tc.y=Math.abs(uc.y)-qb.y,cb=db=xc(gc,hc))}}},Oc=function(a){if(a.preventDefault(),H){var b=e.arraySearch(lc,a.pointerId,"id");if(b>-1){var c=lc[b];c.x=a.pageX,c.y=a.pageY}}if(W){var d=Lc(a);if(hb||Z||bb)ab=d;else{var f=Math.abs(d[0].x-jc.x)-Math.abs(d[0].y-jc.y);Math.abs(f)>=fc&&(hb=f>0?"h":"v",ab=d)}}},Pc=function(){if(ab){var a=ab.length;if(0!==a)if(Lb(gc,ab[0]),ic.x=gc.x-jc.x,ic.y=gc.y-jc.y,bb&&a>1){if(jc.x=gc.x,jc.y=gc.y,!ic.x&&!ic.y&&vc(ab[1],hc))return;Lb(hc,ab[1]),Y||(Y=!0,Cb("zoomGestureStarted"));var b=xc(gc,hc),c=Uc(b);c>f.currItem.initialZoomLevel+f.currItem.initialZoomLevel/15&&(lb=!0);var d=1,e=Sb(),g=Tb();if(e>c)if(i.pinchToClose&&!lb&&t<=f.currItem.initialZoomLevel){var h=e-c,j=1-h/(e/1.2);Eb(j),Cb("onPinchClose",j),jb=!0}else d=(e-c)/e,d>1&&(d=1),c=e-d*(e/3);else c>g&&(d=(c-g)/(6*e),d>1&&(d=1),c=g+d*e);0>d&&(d=0),cb=b,Fc(gc,hc,qc),ob.x+=qc.x-uc.x,ob.y+=qc.y-uc.y,Lb(uc,qc),qb.x=Kb("x",c),qb.y=Kb("y",c),T=c>s,s=c,Gb()}else{if(!hb)return;if(ib&&(ib=!1,Math.abs(ic.x)>=fc&&(ic.x-=ab[0].x-kc.x),Math.abs(ic.y)>=fc&&(ic.y-=ab[0].y-kc.y)),jc.x=gc.x,jc.y=gc.y,0===ic.x&&0===ic.y)return;if("v"===hb&&i.closeOnVerticalDrag&&!Ac()){ob.y+=ic.y,qb.y+=ic.y;var k=Hc();return U=!0,Cb("onVerticalDrag",k),Eb(k),void Gb()}Gc(Db(),gc.x,gc.y),Z=!0,eb=f.currItem.bounds;var l=Mc("x",ic);l||(Mc("y",ic),Mb(qb),Gb())}}},Qc=function(a){if(P.isOldAndroid){if(V&&"mouseup"===a.type)return;a.type.indexOf("touch")>-1&&(clearTimeout(V),V=setTimeout(function(){V=0},600))}Cb("pointerUp"),Dc(a,!1)&&a.preventDefault();var b;if(H){var c=e.arraySearch(lc,a.pointerId,"id");if(c>-1)if(b=lc.splice(c,1)[0],navigator.pointerEnabled)b.type=a.pointerType||"mouse";else{var d={4:"mouse",2:"touch",3:"pen"};b.type=d[a.pointerType],b.type||(b.type=a.pointerType||"mouse")}}var g,h=Lc(a),i=h.length;if("mouseup"===a.type&&(i=0),2===i)return ab=null,!0;1===i&&Lb(kc,h[0]),0!==i||hb||gb||(b||("mouseup"===a.type?b={x:a.pageX,y:a.pageY,type:"mouse"}:a.changedTouches&&a.changedTouches[0]&&(b={x:a.changedTouches[0].pageX,y:a.changedTouches[0].pageY,type:"touch"})),Cb("touchRelease",a,b));var j=-1;if(0===i&&(W=!1,e.unbind(window,p,f),yc(),bb?j=0:-1!==rc&&(j=Db()-rc)),rc=1===i?Db():-1,g=-1!==j&&150>j?"zoom":"swipe",bb&&2>i&&(bb=!1,1===i&&(g="zoomPointerUp"),Cb("zoomGestureEnded")),ab=null,Z||Y||gb||U)if(bc(),S||(S=Rc()),S.calculateSwipeSpeed("x"),U){var k=Hc();if(.6>k)f.close();else{var l=qb.y,m=kb;cc("verticalDrag",0,1,300,e.easing.cubic.out,function(a){qb.y=(f.currItem.initialPosition.y-l)*a+l,Eb((1-m)*a+m),Gb()}),Cb("onVerticalDrag",1)}}else{if((_||gb)&&0===i){var n=Tc(g,S);if(n)return;g="zoomPointerUp"}if(!gb)return"swipe"!==g?void Vc():void(!_&&s>f.currItem.fitRatio&&Sc(S))}},Rc=function(){var a,b,c={lastFlickOffset:{},lastFlickDist:{},lastFlickSpeed:{},slowDownRatio:{},slowDownRatioReverse:{},speedDecelerationRatio:{},speedDecelerationRatioAbs:{},distanceOffset:{},backAnimDestination:{},backAnimStarted:{},calculateSwipeSpeed:function(d){nc.length>1?(a=Db()-R+50,b=nc[nc.length-2][d]):(a=Db()-Q,b=kc[d]),c.lastFlickOffset[d]=jc[d]-b,c.lastFlickDist[d]=Math.abs(c.lastFlickOffset[d]),c.lastFlickSpeed[d]=c.lastFlickDist[d]>20?c.lastFlickOffset[d]/a:0,Math.abs(c.lastFlickSpeed[d])<.1&&(c.lastFlickSpeed[d]=0),c.slowDownRatio[d]=.95,c.slowDownRatioReverse[d]=1-c.slowDownRatio[d],c.speedDecelerationRatio[d]=1},calculateOverBoundsAnimOffset:function(a,b){c.backAnimStarted[a]||(qb[a]>eb.min[a]?c.backAnimDestination[a]=eb.min[a]:qb[a]<eb.max[a]&&(c.backAnimDestination[a]=eb.max[a]),void 0!==c.backAnimDestination[a]&&(c.slowDownRatio[a]=.7,c.slowDownRatioReverse[a]=1-c.slowDownRatio[a],c.speedDecelerationRatioAbs[a]<.05&&(c.lastFlickSpeed[a]=0,c.backAnimStarted[a]=!0,cc("bounceZoomPan"+a,qb[a],c.backAnimDestination[a],b||300,e.easing.sine.out,function(b){qb[a]=b,Gb()}))))},calculateAnimOffset:function(a){c.backAnimStarted[a]||(c.speedDecelerationRatio[a]=c.speedDecelerationRatio[a]*(c.slowDownRatio[a]+c.slowDownRatioReverse[a]-c.slowDownRatioReverse[a]*c.timeDiff/10),c.speedDecelerationRatioAbs[a]=Math.abs(c.lastFlickSpeed[a]*c.speedDecelerationRatio[a]),c.distanceOffset[a]=c.lastFlickSpeed[a]*c.speedDecelerationRatio[a]*c.timeDiff,qb[a]+=c.distanceOffset[a])},panAnimLoop:function(){return Zb.zoomPan&&(Zb.zoomPan.raf=J(c.panAnimLoop),c.now=Db(),c.timeDiff=c.now-c.lastNow,c.lastNow=c.now,c.calculateAnimOffset("x"),c.calculateAnimOffset("y"),Gb(),c.calculateOverBoundsAnimOffset("x"),c.calculateOverBoundsAnimOffset("y"),c.speedDecelerationRatioAbs.x<.05&&c.speedDecelerationRatioAbs.y<.05)?(qb.x=Math.round(qb.x),qb.y=Math.round(qb.y),Gb(),void _b("zoomPan")):void 0}};return c},Sc=function(a){return a.calculateSwipeSpeed("y"),eb=f.currItem.bounds,a.backAnimDestination={},a.backAnimStarted={},Math.abs(a.lastFlickSpeed.x)<=.05&&Math.abs(a.lastFlickSpeed.y)<=.05?(a.speedDecelerationRatioAbs.x=a.speedDecelerationRatioAbs.y=0,a.calculateOverBoundsAnimOffset("x"),a.calculateOverBoundsAnimOffset("y"),!0):(ac("zoomPan"),a.lastNow=Db(),void a.panAnimLoop())},Tc=function(a,b){var c;gb||(pc=m);var d;if("swipe"===a){var g=jc.x-kc.x,h=b.lastFlickDist.x<10;g>ec&&(h||b.lastFlickOffset.x>20)?d=-1:-ec>g&&(h||b.lastFlickOffset.x<-20)&&(d=1)}var j;d&&(m+=d,0>m?(m=i.loop?_c()-1:0,j=!0):m>=_c()&&(m=i.loop?0:_c()-1,j=!0),(!j||i.loop)&&(ub+=d,sb-=d,c=!0));var k,l=tb.x*sb,n=Math.abs(l-sc.x);return c||l>sc.x==b.lastFlickSpeed.x>0?(k=Math.abs(b.lastFlickSpeed.x)>0?n/Math.abs(b.lastFlickSpeed.x):333,k=Math.min(k,400),k=Math.max(k,250)):k=333,pc===m&&(c=!1),gb=!0,cc("mainScroll",sc.x,l,k,e.easing.cubic.out,Jb,function(){bc(),gb=!1,pc=-1,(c||pc!==m)&&f.updateCurrItem(),Cb("mainScrollAnimComplete")}),c&&f.updateCurrItem(!0),c},Uc=function(a){return 1/db*a*t},Vc=function(){var a=s,b=Sb(),c=Tb();b>s?a=b:s>c&&(a=c);var d,g=1,h=kb;return jb&&!T&&!lb&&b>s?(f.close(),!0):(jb&&(d=function(a){Eb((g-h)*a+h)}),f.zoomTo(a,0,300,e.easing.cubic.out,d),!0)};yb("Gestures",{publicMethods:{initGestures:function(){var a=function(a,b,c,d,e){C=a+b,D=a+c,E=a+d,F=e?a+e:""};H=P.pointerEvent,H&&P.touch&&(P.touch=!1),H?navigator.pointerEnabled?a("pointer","down","move","up","cancel"):a("MSPointer","Down","Move","Up","Cancel"):P.touch?(a("touch","start","move","end","cancel"),I=!0):a("mouse","down","move","up"),p=D+" "+E+" "+F,q=C,H&&!I&&(I=navigator.maxTouchPoints>1||navigator.msMaxTouchPoints>1),f.likelyTouchDevice=I,r[C]=Nc,r[D]=Oc,r[E]=Qc,F&&(r[F]=r[E]),P.touch&&(q+=" mousedown",p+=" mousemove mouseup",r.mousedown=r[C],r.mousemove=r[D],r.mouseup=r[E]),I||(i.allowPanToNext=!1)}}});var Wc,Xc,Yc,Zc,$c,_c,ad,bd=function(b,c,d,g){Wc&&clearTimeout(Wc),Zc=!0,Yc=!0;var h;b.initialLayout?(h=b.initialLayout,b.initialLayout=null):h=i.getThumbBoundsFn&&i.getThumbBoundsFn(m);var j=d?i.hideAnimationDuration:i.showAnimationDuration,k=function(){_b("initialZoom"),d?(f.template.removeAttribute("style"),f.bg.removeAttribute("style")):(Eb(1),c&&(c.style.display="block"),e.addClass(a,"pswp--animated-in"),Cb("initialZoom"+(d?"OutEnd":"InEnd"))),g&&g(),Zc=!1};if(!j||!h||void 0===h.x){var n=function(){Cb("initialZoom"+(d?"Out":"In")),s=b.initialZoomLevel,Lb(qb,b.initialPosition),Gb(),a.style.opacity=d?0:1,Eb(1),k()};return void n()}var o=function(){var c=l,g=!f.currItem.src||f.currItem.loadError||i.showHideOpacity;b.miniImg&&(b.miniImg.style.webkitBackfaceVisibility="hidden"),d||(s=h.w/b.w,qb.x=h.x,qb.y=h.y-M,f[g?"template":"bg"].style.opacity=.001,Gb()),ac("initialZoom"),d&&!c&&e.removeClass(a,"pswp--animated-in"),g&&(d?e[(c?"remove":"add")+"Class"](a,"pswp--animate_opacity"):setTimeout(function(){e.addClass(a,"pswp--animate_opacity")},30)),Wc=setTimeout(function(){if(Cb("initialZoom"+(d?"Out":"In")),d){var f=h.w/b.w,i={x:qb.x,y:qb.y},l=s,m=M,n=kb,o=function(b){z&&(m=e.getScrollY(),z=!1),1===b?(s=f,qb.x=h.x,qb.y=h.y-m):(s=(f-l)*b+l,qb.x=(h.x-i.x)*b+i.x,qb.y=(h.y-m-i.y)*b+i.y),Gb(),g?a.style.opacity=1-b:Eb(n-b*n)};c?cc("initialZoom",0,1,j,e.easing.cubic.out,o,k):(o(1),Wc=setTimeout(k,j+20))}else s=b.initialZoomLevel,Lb(qb,b.initialPosition),Gb(),Eb(1),g?a.style.opacity=1:Eb(1),Wc=setTimeout(k,j+20)},d?25:90)};o()},cd={},dd=[],ed={index:0,errorMsg:'<div class="pswp__error-msg"><a href="%url%" target="_blank">The image</a> could not be loaded.</div>',forceProgressiveLoading:!1,preload:[1,1],getNumItemsFn:function(){return Xc.length}},fd=function(){return{center:{x:0,y:0},max:{x:0,y:0},min:{x:0,y:0}}},gd=function(a,b,c){var d=a.bounds;d.center.x=Math.round((cd.x-b)/2),d.center.y=Math.round((cd.y-c)/2)+a.vGap.top,d.max.x=b>cd.x?Math.round(cd.x-b):d.center.x,d.max.y=c>cd.y?Math.round(cd.y-c)+a.vGap.top:d.center.y,d.min.x=b>cd.x?0:d.center.x,d.min.y=c>cd.y?a.vGap.top:d.center.y},hd=function(a,b,c){if(a.src&&!a.loadError){var d=!c;if(d&&(a.vGap||(a.vGap={top:0,bottom:0}),Cb("parseVerticalMargin",a)),cd.x=b.x,cd.y=b.y-a.vGap.top-a.vGap.bottom,d){var e=cd.x/a.w,f=cd.y/a.h;a.fitRatio=f>e?e:f;var g=i.scaleMode;"orig"===g?c=1:"fit"===g&&(c=a.fitRatio),c>1&&(c=1),a.initialZoomLevel=c,a.bounds||(a.bounds=fd())}if(!c)return;return gd(a,a.w*c,a.h*c),d&&c===a.initialZoomLevel&&(a.initialPosition=a.bounds.center),a.bounds}return a.w=a.h=0,a.initialZoomLevel=a.fitRatio=1,a.bounds=fd(),a.initialPosition=a.bounds.center,a.bounds},id=function(a,b,c,d,e,g){if(!b.loadError){var h,j=f.isDragging()&&!f.isZooming(),k=a===m||f.isMainScrollAnimating()||j;!e&&(I||i.alwaysFadeIn)&&k&&(h=!0),d&&(h&&(d.style.opacity=0),b.imageAppended=!0,c.appendChild(d),h&&setTimeout(function(){d.style.opacity=1,g&&setTimeout(function(){b&&b.loaded&&b.placeholder&&(b.placeholder.style.display="none",b.placeholder=null)},500)},50))}},jd=function(a){a.loading=!0,a.loaded=!1;var b=a.img=e.createEl("pswp__img","img"),c=function(){a.loading=!1,a.loaded=!0,a.loadComplete?a.loadComplete(a):a.img=null,b.onload=b.onerror=null,b=null};return b.onload=c,b.onerror=function(){a.loadError=!0,c()},b.src=a.src,b},kd=function(a,b){return a.src&&a.loadError&&a.container?(b&&(a.container.innerHTML=""),a.container.innerHTML=i.errorMsg.replace("%url%",a.src),!0):void 0},ld=function(){if(dd.length){for(var a,b=0;b<dd.length;b++)a=dd[b],a.holder.index===a.index&&id(a.index,a.item,a.baseDiv,a.img);dd=[]}};yb("Controller",{publicMethods:{lazyLoadItem:function(a){a=zb(a);var b=$c(a);b&&b.src&&!b.loaded&&!b.loading&&(Cb("gettingData",a,b),jd(b))},initController:function(){e.extend(i,ed,!0),f.items=Xc=c,$c=f.getItemAt,_c=i.getNumItemsFn,ad=i.loop,_c()<3&&(i.loop=!1),Bb("beforeChange",function(a){var b,c=i.preload,d=null===a?!0:a>0,e=Math.min(c[0],_c()),g=Math.min(c[1],_c());for(b=1;(d?g:e)>=b;b++)f.lazyLoadItem(m+b);for(b=1;(d?e:g)>=b;b++)f.lazyLoadItem(m-b)}),Bb("initialLayout",function(){f.currItem.initialLayout=i.getThumbBoundsFn&&i.getThumbBoundsFn(m)}),Bb("mainScrollAnimComplete",ld),Bb("initialZoomInEnd",ld),Bb("destroy",function(){for(var a,b=0;b<Xc.length;b++)a=Xc[b],a.container&&(a.container=null),a.placeholder&&(a.placeholder=null),a.img&&(a.img=null),a.preloader&&(a.preloader=null),a.loadError&&(a.loaded=a.loadError=!1);dd=null})},getItemAt:function(a){return a>=0&&void 0!==Xc[a]?Xc[a]:!1},allowProgressiveImg:function(){return i.forceProgressiveLoading||!I||i.mouseUsed||screen.width>1200},setContent:function(a,b){i.loop&&(b=zb(b));var c=f.getItemAt(a.index);c&&(c.container=null);var d,g=f.getItemAt(b);if(!g)return void(a.el.innerHTML="");Cb("gettingData",b,g),a.index=b,a.item=g;var h=g.container=e.createEl("pswp__zoom-wrap");if(!g.src&&g.html&&(g.html.tagName?h.appendChild(g.html):h.innerHTML=g.html),kd(g),!g.src||g.loadError||g.loaded)g.src&&!g.loadError&&(d=e.createEl("pswp__img","img"),d.style.webkitBackfaceVisibility="hidden",d.style.opacity=1,d.src=g.src,id(b,g,h,d,!0));else{if(g.loadComplete=function(c){if(j){if(c.img.style.webkitBackfaceVisibility="hidden",a&&a.index===b){if(kd(c,!0))return c.loadComplete=c.img=null,hd(c,rb),Hb(c),void(a.index===m&&f.updateCurrZoomItem());c.imageAppended?!Zc&&c.placeholder&&(c.placeholder.style.display="none",c.placeholder=null):P.transform&&(gb||Zc)?dd.push({item:c,baseDiv:h,img:c.img,index:b,holder:a}):id(b,c,h,c.img,gb||Zc)}c.loadComplete=null,c.img=null,Cb("imageLoadComplete",b,c)}},e.features.transform){var k="pswp__img pswp__img--placeholder";k+=g.msrc?"":" pswp__img--placeholder--blank";var l=e.createEl(k,g.msrc?"img":"");g.msrc&&(l.src=g.msrc),l.style.width=g.w+"px",l.style.height=g.h+"px",h.appendChild(l),g.placeholder=l}g.loading||jd(g),f.allowProgressiveImg()&&(!Yc&&P.transform?dd.push({item:g,baseDiv:h,img:g.img,index:b,holder:a}):id(b,g,h,g.img,!0,!0))}hd(g,rb),Yc||b!==m?Hb(g):(fb=h.style,bd(g,d||g.img)),a.el.innerHTML="",a.el.appendChild(h)},cleanSlide:function(a){a.img&&(a.img.onload=a.img.onerror=null),a.loaded=a.loading=a.img=a.imageAppended=!1}}});var md,nd={},od=function(a,b,c){var d=document.createEvent("CustomEvent"),e={origEvent:a,target:a.target,releasePoint:b,pointerType:c||"touch"};d.initCustomEvent("pswpTap",!0,!0,e),a.target.dispatchEvent(d)};yb("Tap",{publicMethods:{initTap:function(){Bb("firstTouchStart",f.onTapStart),Bb("touchRelease",f.onTapRelease),Bb("destroy",function(){nd={},md=null})},onTapStart:function(a){a.length>1&&(clearTimeout(md),md=null)},onTapRelease:function(a,b){if(b&&!Z&&!X&&!$b){var c=b;if(md&&(clearTimeout(md),md=null,wc(c,nd)))return void Cb("doubleTap",c);if("mouse"===b.type)return void od(a,b,"mouse");var d=a.target.tagName.toUpperCase();if("BUTTON"===d||e.hasClass(a.target,"pswp__single-tap"))return void od(a,b);Lb(nd,c),md=setTimeout(function(){od(a,b),md=null},300)}}}});var pd;yb("DesktopZoom",{publicMethods:{initDesktopZoom:function(){N||(I?Bb("mouseUsed",function(){f.setupDesktopZoom()}):f.setupDesktopZoom(!0))},setupDesktopZoom:function(b){pd={};var c="wheel mousewheel DOMMouseScroll";Bb("bindEvents",function(){e.bind(a,c,f.handleMouseWheel)}),Bb("unbindEvents",function(){pd&&e.unbind(a,c,f.handleMouseWheel)}),f.mouseZoomedIn=!1;var d,g=function(){f.mouseZoomedIn&&(e.removeClass(a,"pswp--zoomed-in"),f.mouseZoomedIn=!1),1>s?e.addClass(a,"pswp--zoom-allowed"):e.removeClass(a,"pswp--zoom-allowed"),h()},h=function(){d&&(e.removeClass(a,"pswp--dragging"),d=!1)};Bb("resize",g),Bb("afterChange",g),Bb("pointerDown",function(){f.mouseZoomedIn&&(d=!0,e.addClass(a,"pswp--dragging"))}),Bb("pointerUp",h),b||g()},handleMouseWheel:function(a){if(s<=f.currItem.fitRatio)return i.closeOnScroll||a.preventDefault(),!0;if(a.preventDefault(),a.stopPropagation(),pd.x=0,"deltaX"in a)pd.x=a.deltaX,pd.y=a.deltaY;else if("wheelDelta"in a)a.wheelDeltaX&&(pd.x=-.16*a.wheelDeltaX),pd.y=a.wheelDeltaY?-.16*a.wheelDeltaY:-.16*a.wheelDelta;else{if(!("detail"in a))return;pd.y=a.detail}Rb(s,!0),f.panTo(qb.x-pd.x,qb.y-pd.y)},toggleDesktopZoom:function(b){b=b||{x:rb.x/2,y:rb.y/2+M};var c=i.getDoubleTapZoom(!0,f.currItem),d=s===c;f.mouseZoomedIn=!d,f.zoomTo(d?f.currItem.initialZoomLevel:c,b,333),e[(d?"remove":"add")+"Class"](a,"pswp--zoomed-in")}}});var qd,rd,sd,td,ud,vd,wd,xd,yd,zd,Ad,Bd,Cd={history:!0,galleryUID:1},Dd=function(){return Ad.hash.substring(1)},Ed=function(){qd&&clearTimeout(qd),sd&&clearTimeout(sd)},Fd=function(){var a=Dd(),b={};if(a.length<5)return b;for(var c=a.split("&"),d=0;d<c.length;d++)if(c[d]){var e=c[d].split("=");e.length<2||(b[e[0]]=e[1])}return b.pid=parseInt(b.pid,10)-1,b.pid<0&&(b.pid=0),b},Gd=function(){if(sd&&clearTimeout(sd),$b||W)return void(sd=setTimeout(Gd,500));td?clearTimeout(rd):td=!0;var a=wd+"&gid="+i.galleryUID+"&pid="+(m+1);xd||-1===Ad.hash.indexOf(a)&&(zd=!0);var b=Ad.href.split("#")[0]+"#"+a;Bd?"#"+a!==window.location.hash&&history[xd?"replaceState":"pushState"]("",document.title,b):xd?Ad.replace(b):Ad.hash=a,xd=!0,rd=setTimeout(function(){td=!1},60)};yb("History",{publicMethods:{initHistory:function(){if(e.extend(i,Cd,!0),i.history){Ad=window.location,zd=!1,yd=!1,xd=!1,wd=Dd(),Bd="pushState"in history,wd.indexOf("gid=")>-1&&(wd=wd.split("&gid=")[0],wd=wd.split("?gid=")[0]),Bb("afterChange",f.updateURL),Bb("unbindEvents",function(){e.unbind(window,"hashchange",f.onHashChange)});var a=function(){vd=!0,yd||(zd?history.back():wd?Ad.hash=wd:Bd?history.pushState("",document.title,Ad.pathname+Ad.search):Ad.hash=""),Ed()};Bb("unbindEvents",function(){l&&a()}),Bb("destroy",function(){vd||a()}),Bb("firstUpdate",function(){m=Fd().pid});var b=wd.indexOf("pid=");b>-1&&(wd=wd.substring(0,b),"&"===wd.slice(-1)&&(wd=wd.slice(0,-1))),setTimeout(function(){j&&e.bind(window,"hashchange",f.onHashChange)},40)}},onHashChange:function(){return Dd()===wd?(yd=!0,void f.close()):void(td||(ud=!0,f.goTo(Fd().pid),ud=!1))},updateURL:function(){Ed(),ud||(xd?qd=setTimeout(Gd,800):Gd())}}}),e.extend(f,dc)};return a});
\ No newline at end of file
diff --git a/data/ext/perspectiveImageSwiper/index.html b/data/ext/perspectiveImageSwiper/index.html
new file mode 100644
index 000000000..a52953e68
--- /dev/null
+++ b/data/ext/perspectiveImageSwiper/index.html
@@ -0,0 +1,366 @@
+<!DOCTYPE html>
+<html lang="en" debug="true">
+ <head>
+<link href="site.css" rel="stylesheet" />
+<link href="dist/photoswipe.css?v=4.0.3-1.0.4" rel="stylesheet" />
+<link href="dist/default-skin/default-skin.css?v=4.0.3-1.0.4" rel="stylesheet" />
+<script>
+document.write('<script src=dist/photoswipe.js?r='+Math.random()+'><\/script>');
+document.write('<script src=dist/photoswipe-ui-default.js?r='+Math.random()+'><\/script>');
+</script>
+</head>
+ <body>
+ <div class="section section--head">
+ <div class="row">
+ <div id="demo-test-gallery" class="demo-gallery">
+ <a href="file:///home/na/Pictures/30.jpg" data-size="2048x1365" >
+ <img src="file:///home/na/Pictures/30.jpg" alt="" />
+ <figure>This is dummy caption.</figure>
+ </a>
+ <a href="file:///home/na/Pictures/31.jpg" data-size="2048x1227">
+ <img src="file:///home/na/Pictures/31.jpg" alt="" />
+ <figure>typeset text.</figure>
+ </a>
+ </div>
+ <div class="style-select">
+ <p style="margin:24px 0 12px;color:#444;">Demo gallery style</p>
+ <div class="radio">
+ <input type="radio" name="gallery-style" value="all" id="radio-all-controls" checked />
+ <label for="radio-all-controls">
+ All controls<br/>
+ <span>caption, share and fullscreen buttons, tap to toggle controls</span>
+ </label>
+ </div>
+ <div class="radio">
+ <input type="radio" name="gallery-style" value="minimal" id="radio-minimal-black" />
+ <label for="radio-minimal-black">
+ Minimal<br/>
+ <span>no caption, transparent background, tap to close</span>
+ </label>
+ </div>
+ </div>
+ </div>
+ </div>
+
+ <div id="gallery" class="pswp" tabindex="-1" role="dialog" aria-hidden="true">
+ <div class="pswp__bg"></div>
+ <div class="pswp__scroll-wrap">
+ <div class="pswp__container">
+ <div class="pswp__item"></div>
+ <div class="pswp__item"></div>
+ <div class="pswp__item"></div>
+ </div>
+ <div class="pswp__ui pswp__ui--hidden">
+ <div class="pswp__top-bar">
+ <div class="pswp__counter"></div>
+ <button class="pswp__button pswp__button--close" title="Close (Esc)"></button>
+ <button class="pswp__button pswp__button--share" title="Share"></button>
+ <button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button>
+ <button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>
+ <div class="pswp__preloader">
+ <div class="pswp__preloader__icn">
+ <div class="pswp__preloader__cut">
+ <div class="pswp__preloader__donut"></div>
+ </div>
+ </div>
+ </div>
+ </div>
+
+ <!-- <div class="pswp__loading-indicator"><div class="pswp__loading-indicator__line"></div></div> -->
+
+ <div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
+ <div class="pswp__share-tooltip">
+ <!-- <a href="#" class="pswp__share--facebook"></a>
+ <a href="#" class="pswp__share--twitter"></a>
+ <a href="#" class="pswp__share--pinterest"></a>
+ <a href="#" download class="pswp__share--download"></a> -->
+ </div>
+ </div>
+
+ <button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)"></button>
+ <button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)"></button>
+ <div class="pswp__caption">
+ <div class="pswp__caption__center">
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+
+ <script type="text/javascript">
+ (function() {
+
+ var initPhotoSwipeFromDOM = function(gallerySelector) {
+
+ var parseThumbnailElements = function(el) {
+ var thumbElements = el.childNodes,
+ numNodes = thumbElements.length,
+ items = [],
+ el,
+ childElements,
+ thumbnailEl,
+ size,
+ item;
+
+ for(var i = 0; i < numNodes; i++) {
+ el = thumbElements[i];
+
+ // include only element nodes
+ if(el.nodeType !== 1) {
+ continue;
+ }
+
+ childElements = el.children;
+
+ size = el.getAttribute('data-size').split('x');
+
+ // create slide object
+ item = {
+ src: el.getAttribute('href'),
+ w: parseInt(size[0], 10),
+ h: parseInt(size[1], 10),
+ author: el.getAttribute('data-author')
+ };
+
+ item.el = el; // save link to element for getThumbBoundsFn
+
+ if(childElements.length > 0) {
+ item.msrc = childElements[0].getAttribute('src'); // thumbnail url
+ if(childElements.length > 1) {
+ item.title = childElements[1].innerHTML; // caption (contents of figure)
+ }
+ }
+
+
+ var mediumSrc = el.getAttribute('data-med');
+ if(mediumSrc) {
+ size = el.getAttribute('data-med-size').split('x');
+ // "medium-sized" image
+ item.m = {
+ src: mediumSrc,
+ w: parseInt(size[0], 10),
+ h: parseInt(size[1], 10)
+ };
+ }
+ // original image
+ item.o = {
+ src: item.src,
+ w: item.w,
+ h: item.h
+ };
+
+ items.push(item);
+ }
+
+ return items;
+ };
+
+ // find nearest parent element
+ var closest = function closest(el, fn) {
+ return el && ( fn(el) ? el : closest(el.parentNode, fn) );
+ };
+
+ var onThumbnailsClick = function(e) {
+ e = e || window.event;
+ e.preventDefault ? e.preventDefault() : e.returnValue = false;
+
+ var eTarget = e.target || e.srcElement;
+
+ var clickedListItem = closest(eTarget, function(el) {
+ return el.tagName === 'A';
+ });
+
+ if(!clickedListItem) {
+ return;
+ }
+
+ var clickedGallery = clickedListItem.parentNode;
+
+ var childNodes = clickedListItem.parentNode.childNodes,
+ numChildNodes = childNodes.length,
+ nodeIndex = 0,
+ index;
+
+ for (var i = 0; i < numChildNodes; i++) {
+ if(childNodes[i].nodeType !== 1) {
+ continue;
+ }
+
+ if(childNodes[i] === clickedListItem) {
+ index = nodeIndex;
+ break;
+ }
+ nodeIndex++;
+ }
+
+ if(index >= 0) {
+ openPhotoSwipe( index, clickedGallery );
+ }
+ return false;
+ };
+
+ var photoswipeParseHash = function() {
+ var hash = window.location.hash.substring(1),
+ params = {};
+
+ if(hash.length < 5) { // pid=1
+ return params;
+ }
+
+ var vars = hash.split('&');
+ for (var i = 0; i < vars.length; i++) {
+ if(!vars[i]) {
+ continue;
+ }
+ var pair = vars[i].split('=');
+ if(pair.length < 2) {
+ continue;
+ }
+ params[pair[0]] = pair[1];
+ }
+
+ if(params.gid) {
+ params.gid = parseInt(params.gid, 10);
+ }
+
+ if(!params.hasOwnProperty('pid')) {
+ return params;
+ }
+ params.pid = parseInt(params.pid, 10);
+ return params;
+ };
+
+ var openPhotoSwipe = function(index, galleryElement, disableAnimation) {
+ var pswpElement = document.querySelectorAll('.pswp')[0],
+ gallery,
+ options,
+ items;
+
+ items = parseThumbnailElements(galleryElement);
+
+ // define options (if needed)
+ options = {
+ index: index,
+
+ galleryUID: galleryElement.getAttribute('data-pswp-uid'),
+
+ getThumbBoundsFn: function(index) {
+ // See Options->getThumbBoundsFn section of docs for more info
+ var thumbnail = items[index].el.children[0],
+ pageYScroll = window.pageYOffset || document.documentElement.scrollTop,
+ rect = thumbnail.getBoundingClientRect();
+
+ return {x:rect.left, y:rect.top + pageYScroll, w:rect.width};
+ },
+
+ addCaptionHTMLFn: function(item, captionEl, isFake) {
+ if(!item.title) {
+ captionEl.children[0].innerText = '';
+ return false;
+ }
+ captionEl.children[0].innerHTML = item.title + '<br/><small>Photo: ' + item.author + '</small>';
+ return true;
+ }
+
+ };
+
+ var radios = document.getElementsByName('gallery-style');
+ for (var i = 0, length = radios.length; i < length; i++) {
+ if (radios[i].checked) {
+ if(radios[i].id == 'radio-all-controls') {
+
+ } else if(radios[i].id == 'radio-minimal-black') {
+ options.mainClass = 'pswp--minimal--dark';
+ options.barsSize = {top:0,bottom:0};
+ options.captionEl = false;
+ options.fullscreenEl = false;
+ options.shareEl = false;
+ options.bgOpacity = 0.85;
+ options.tapToClose = true;
+ options.tapToToggleControls = false;
+ }
+ break;
+ }
+ }
+
+ if(disableAnimation) {
+ options.showAnimationDuration = 0;
+ }
+
+ // Pass data to PhotoSwipe and initialize it
+ gallery = new PhotoSwipe( pswpElement, PhotoSwipeUI_Default, items, options);
+
+ // see: http://photoswipe.com/documentation/responsive-images.html
+ var realViewportWidth,
+ useLargeImages = false,
+ firstResize = true,
+ imageSrcWillChange;
+
+ gallery.listen('beforeResize', function() {
+
+ var dpiRatio = window.devicePixelRatio ? window.devicePixelRatio : 1;
+ dpiRatio = Math.min(dpiRatio, 2.5);
+ realViewportWidth = gallery.viewportSize.x * dpiRatio;
+
+
+ if(realViewportWidth >= 1200 || (!gallery.likelyTouchDevice && realViewportWidth > 800) || screen.width > 1200 ) {
+ if(!useLargeImages) {
+ useLargeImages = true;
+ imageSrcWillChange = true;
+ }
+
+ } else {
+ if(useLargeImages) {
+ useLargeImages = false;
+ imageSrcWillChange = true;
+ }
+ }
+
+ if(imageSrcWillChange && !firstResize) {
+ gallery.invalidateCurrItems();
+ }
+
+ if(firstResize) {
+ firstResize = false;
+ }
+
+ imageSrcWillChange = false;
+
+ });
+
+ gallery.listen('gettingData', function(index, item) {
+ if( useLargeImages ) {
+ item.src = item.o.src;
+ item.w = item.o.w;
+ item.h = item.o.h;
+ } else {
+ item.src = item.m.src;
+ item.w = item.m.w;
+ item.h = item.m.h;
+ }
+ });
+
+ gallery.init();
+ };
+
+ // select all gallery elements
+ var galleryElements = document.querySelectorAll( gallerySelector );
+ for(var i = 0, l = galleryElements.length; i < l; i++) {
+ galleryElements[i].setAttribute('data-pswp-uid', i+1);
+ galleryElements[i].onclick = onThumbnailsClick;
+ }
+
+ // Parse URL and open gallery if it contains #&pid=3&gid=1
+ var hashData = photoswipeParseHash();
+ if(hashData.pid > 0 && hashData.gid > 0) {
+ openPhotoSwipe( hashData.pid - 1 , galleryElements[ hashData.gid - 1 ], true );
+ }
+ };
+
+ initPhotoSwipeFromDOM('.demo-gallery');
+
+ })();
+
+ </script>
+ </body>
+</html>
\ No newline at end of file
diff --git a/data/ext/perspectiveImageSwiper/site.css b/data/ext/perspectiveImageSwiper/site.css
new file mode 100644
index 000000000..f41b03bb0
--- /dev/null
+++ b/data/ext/perspectiveImageSwiper/site.css
@@ -0,0 +1,916 @@
+/* Demo site CSS. Not mobile first, not semantic, not optimized, made for 20 minutes, mess */
+html, body, div, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, ol, ul, li, form, fieldset, legend, label, table, header, footer, nav, section, figure {
+ margin: 0;
+ padding: 0;
+}
+figure {
+ display: block;
+}
+html {
+ /*overflow-y: scroll;*/
+}
+
+a {
+ color: #3169B3;
+}
+a:hover {
+ color: #C00;
+}
+
+* {
+ -moz-box-sizing: border-box;
+ -webkit-box-sizing: border-box;
+ box-sizing: border-box;
+}
+body {
+ font-family: "myriad-pro","Myriad Pro","Helvetica Neue",Helvetica,Arial,sans-serif;
+ font-size: 18px;
+ line-height: 26px;
+ color: #282B30;
+
+ text-rendering: optimizeLegibility;
+ -webkit-font-smoothing: antialiased;
+ -moz-osx-font-smoothing: grayscale;
+ -moz-font-feature-settings: "liga", "kern";
+
+}
+
+
+
+/*code {
+ background: #F8F8F8;
+ padding: .1em .4em;
+ color: #c82829;
+ font-size: 14px;
+}*/
+code, pre {
+ font-family: Menlo, Monaco, monospace;
+ font-size: 12px;
+ line-height: 1.45;
+ color: #333;
+ tab-size: 4;
+}
+pre {
+ padding: 0;
+ margin: 0;
+ overflow: auto;
+
+ word-wrap: normal;
+
+ text-rendering: auto;
+ -webkit-font-smoothing: auto;
+}
+code {
+ padding: 0;
+ padding: 3px 5px;
+ margin: 0;
+ background: #f2f2f2;
+ border-radius: 2px;
+}
+pre code {
+ background: none;
+ padding: 0;
+ border-radius: 0;
+
+
+}
+h3 code {
+ font-size: 22px;
+ font-weight: normal;
+ padding: 6px 10px;
+}
+h3 code.default {
+ font-size: 12px;
+ padding: 0;
+ background: none;
+ opacity: 0.7;
+}
+
+.docs p {
+ margin: 0;
+ padding-bottom: 12px;
+ padding-top: 12px;
+}
+.docs h1 {
+ margin-bottom: 32px;
+}
+.docs h1 a {
+ text-decoration: none;
+}
+.docs h1 a:hover {
+ text-decoration: underline;
+}
+.docs h2 {
+ margin: 0;
+ margin: 36px 0 12px;
+}
+.docs h3 {
+ margin: 0;
+ margin: 24px 0 8px 0;
+ font-size: 22px;
+ line-height: 28px;
+}
+.docs ul,
+.docs ol {
+ margin-top: 8px;
+ margin-bottom: 8px;
+}
+.docs li {
+ margin: 0;
+ padding: 4px 0;
+}
+
+.docs-menu {
+ position: absolute;
+ width: 160px;
+ left: 0;
+ top: 106px;
+ border-top: 1px solid #CCC;
+ padding-top: 25px;
+ border-bottom: 1px solid #CCC;
+ padding-bottom: 25px;
+}
+.docs-menu a {
+ text-decoration: none;
+ width: 100%;
+}
+a.docs-logo {
+ font-weight: 600;
+ font-size: 20px;
+ margin-bottom: 0;
+ text-decoration: none;
+}
+.docs-menu ul {
+ list-style: none;
+ margin: 0;
+ padding:0;
+}
+.docs-menu li {
+ list-style: none;
+ margin: 0;
+ padding:0;
+}
+a.docs-menu__item--active {
+ color: #222;
+ font-weight: normal;
+}
+
+.codepen-embed {
+ margin-left: -30px;
+ padding: 16px 30px;
+ width: 100%;
+ -webkit-box-sizing: content-box;
+ -moz-box-sizing: content-box;
+ box-sizing: content-box;
+ background-color: #f8f8f8;
+ height: 600px;
+
+}
+.codepen-embed--disabled {
+ height: auto;
+}
+.codepen-embed p {
+ margin-bottom: 0;
+}
+
+.docs .highlight {
+ border-radius: 2px;
+ margin-left: -30px;
+padding: 16px 30px;
+width: 100%;
+-webkit-box-sizing: content-box;
+-moz-box-sizing: content-box;
+box-sizing: content-box;
+margin-bottom: 26px;
+}
+
+
+
+
+/* Syntax highlighter styles (for docs) */
+.highlight { background-color: #f8f8f8 }
+.c { color: #888; } /* Comment */
+.err { color: #a61717; background-color: #e3d2d2 } /* Error */
+.k { color: #a71d5d; } /* Keyword */
+.o { color: #000000; } /* Operator */
+.cm { color: #888; } /* Comment.Multiline */
+.cp { color: #888; font-weight: bold;} /* Comment.Preproc */
+.c1 { color: #888; } /* Comment.Single */
+.cs { color: #888; font-weight: bold; } /* Comment.Special */
+.gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
+.ge { color: #000000; } /* Generic.Emph */
+.gr { color: #aa0000 } /* Generic.Error */
+.gh { color: #888 } /* Generic.Heading */
+.gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
+.go { color: #888888 } /* Generic.Output */
+.gp { color: #555555 } /* Generic.Prompt */
+.gs { font-weight: bold } /* Generic.Strong */
+.gu { color: #aaaaaa } /* Generic.Subheading */
+.gt { color: #aa0000 } /* Generic.Traceback */
+.kc { color: #0086b3; } /* Keyword.Constant */
+.kd { color: #a71d5d; } /* Keyword.Declaration */
+.kn { color: #000000; font-weight: bold } /* Keyword.Namespace */
+.kp { color: #000000; font-weight: bold } /* Keyword.Pseudo */
+.kr { color: #000000; font-weight: bold } /* Keyword.Reserved */
+.kt { color: #795da3; } /* Keyword.Type */
+.m { color: #009999 } /* Literal.Number */
+.s { color: #df5000 } /* Literal.String */
+.na { color: #a71d5d } /* Name.Attribute */
+.nb { color: #0086B3 } /* Name.Builtin */
+.nc { color: #795da3; } /* Name.Class */
+.no { color: #a71d5d } /* Name.Constant */
+.nd { color: #3c5d5d; font-weight: bold } /* Name.Decorator */
+.ni { color: #800080 } /* Name.Entity */
+.ne { color: #990000; font-weight: bold } /* Name.Exception */
+.nf { color: #990000; font-weight: bold } /* Name.Function */
+.nl { color: #990000; font-weight: bold } /* Name.Label */
+.nn { color: #555555 } /* Name.Namespace */
+.nt { color: #0086b3 } /* Name.Tag */
+.nv { color: #a71d5d } /* Name.Variable */
+.ow { color: #000000; font-weight: bold } /* Operator.Word */
+.w { color: #bbbbbb } /* Text.Whitespace */
+.mf { color: #009999 } /* Literal.Number.Float */
+.mh { color: #009999 } /* Literal.Number.Hex */
+.mi { color: #009999 } /* Literal.Number.Integer */
+.mo { color: #009999 } /* Literal.Number.Oct */
+.sb { color: #df5000 } /* Literal.String.Backtick */
+.sc { color: #df5000 } /* Literal.String.Char */
+.sd { color: #df5000 } /* Literal.String.Doc */
+.s2 { color: #df5000 } /* Literal.String.Double */
+.se { color: #df5000 } /* Literal.String.Escape */
+.sh { color: #df5000 } /* Literal.String.Heredoc */
+.si { color: #df5000 } /* Literal.String.Interpol */
+.sx { color: #df5000 } /* Literal.String.Other */
+.sr { color: #009926 } /* Literal.String.Regex */
+.s1 { color: #df5000 } /* Literal.String.Single */
+.ss { color: #990073 } /* Literal.String.Symbol */
+.bp { color: #888 } /* Name.Builtin.Pseudo */
+.vc { color: #a71d5d } /* Name.Variable.Class */
+.vg { color: #a71d5d } /* Name.Variable.Global */
+.vi { color: #a71d5d } /* Name.Variable.Instance */
+.il { color: #009999 } /* Literal.Number.Integer.Long */
+
+
+.language-css .k {
+ color: #0086b3;
+}
+.language-css .nt {
+ color: #63a35c;
+}
+
+
+
+
+/*body.open-sans {
+ font-family: "open-sans";
+}
+.futura-pt {
+
+}
+.futura-pt p {
+ font-family: "adelle";
+}
+.futura-pt h1, .futura-pt h2 {
+ font-family: "futura-pt";
+ text-transform: uppercase;
+}
+.futura-pt h3 {
+ font-weight: bold;
+}
+*/
+
+
+img {
+ width: auto;
+ max-width: 100%;
+ height: auto;
+ border: 0;
+}
+
+
+.video {
+ width: 100%%;
+ margin: 0 0 24px 0;
+}
+.video__container {
+ position: relative;
+ width: 100%;
+ padding-bottom: 56.25%;
+ padding-top: 35px;
+ height: 0;
+ overflow: hidden;
+}
+.video__container iframe {
+ position: absolute;
+ top:0;
+ left: 0;
+ width: 100%;
+ height: 100%;
+}
+.video-desc {
+ width: 100%;
+ max-width: 740px;
+ margin: 12px auto;
+}
+
+
+p {
+ margin: 0 0 12px;
+}
+ul {
+ list-style: disc;
+}
+ul, ol {
+ padding: 0;
+ margin: 0 0 12px 25px;
+}
+li {
+ margin: 0 0 12px 0;
+}
+h1, h2, h3, h4, h5, h6 {
+ margin: 0;
+ font-weight: normal;
+}
+
+
+h1 {
+ font-size: 48px;
+ line-height: 1;
+ margin: 0;
+ font-weight: 600;
+ margin-bottom: 6px;
+}
+
+.row--heading {
+ position: relative;
+}
+.section--head p {
+ text-align: left;
+ font-size: 26px;
+ line-height: 32px;
+ margin-bottom: 24px;
+
+ font-size: 19px;
+ line-height: 29px;
+
+}
+
+
+.section--head .github-button {
+ position: absolute;
+ right:0;
+ top:0;
+}
+.row--nav {
+ text-align: center;
+ font-size: 32px;
+ line-height: 1.1;
+}
+.navigation {
+ width: 100%;
+ background: #F7F7F7;
+ position: relative;
+ padding: 30px 0;
+}
+
+
+
+
+
+h2 {
+ font-size: 32px;
+ line-height: 1.1;
+ margin-bottom: 12px;
+ font-weight: 600;
+}
+
+h3 {
+ font-size: 22px;
+ line-height: 28px;
+ margin: 0 0 8px 0;
+
+ font-size: 18px;
+ line-height: 24px;
+ font-weight: 600;
+}
+strong {
+ font-weight: 600;
+}
+span.highlight {
+ background:rgb(246, 243, 226);
+}
+.title-block p {
+ font-size: 22px;
+ line-height: 28px;
+ max-width: 600px;
+ margin-bottom: 24px;
+
+}
+
+p, ul.text-list {
+ color: #444;
+}
+.section--head p,
+.title-block p {
+ color: #666;
+}
+
+
+
+
+.title-block p {
+ font-size: 19px;
+ line-height: 29px;
+}
+
+
+
+
+
+.section {
+ width: 100%;
+ margin-top: 176px;
+}
+.docs {
+ margin-top: 60px;
+}
+.section--head {
+ margin: 0;
+ background: #EEE;
+ /*background: linear-gradient(180deg, #eee 0%,#fff 100%);*/
+ padding: 132px 0;
+}
+
+
+.row {
+ max-width: 800px;
+ margin: 24px auto;
+ padding: 0 30px;
+ position: relative;
+}
+
+.row--docs {
+ max-width: 960px;
+ padding-left: 210px;
+}
+.row--heading {
+ margin-top: 0;
+ margin-bottom: 0;
+}
+.row--footer {
+ text-align: center;
+ padding: 132px 0;
+}
+.row--wide {
+ max-width: 1000px;
+}
+.row--video {
+ max-width: 1160px;
+}
+
+.row--wide img {
+ float: left;
+ margin: 0 12px 12px 0;
+ width: 200px;
+}
+img.img--with_border {
+ border: 1px solid #DDD;
+ border-radius: 2px;
+}
+.img-desc {
+ margin-left: 212px;
+}
+
+
+
+
+/*.main-wrapper {
+ background: none;
+ width: 100%;
+ padding-top: 0;
+
+}
+.content-wrap {
+
+
+
+}*/
+
+
+/* clearfix */
+.row:after{
+ content: " ";
+ visibility: hidden;
+ display: block;
+ height: 0;
+ clear: both;
+}
+.row--large {
+ margin-bottom: 48px;
+}
+
+
+.section--head h1 span {
+ vertical-align: super;
+ opacity: 0.6;
+ font-size: 14px;
+}
+
+/*p.intro {
+ margin-top: 24px;
+ font-size: 18px;
+ line-height: 24px;
+}*/
+
+
+
+
+
+
+
+.col-50 {
+ width: 48%;
+ float: left;
+}
+.col-50:nth-child(1) {
+ margin-right: 4%;
+}
+.col-img {
+ width: auto;
+ max-width: 100%;
+ height: auto;
+}
+
+.style-select {
+ width: 100%;
+ float: left;
+}
+.style-select .radio {
+ position: relative;
+ margin-bottom: 12px;
+ display: block;
+ float: left;
+ width: 100%;
+}
+.style-select label {
+ padding-left: 24px;
+ position: relative;
+ display: block;
+ cursor: pointer;
+}
+.style-select input {
+ position: absolute;
+ left:0;
+ top:0;
+ width:24px;
+ height:24px;
+ overflow:hidden;
+ margin:0;
+ padding:0;
+ border:0;
+ outline:0;
+ opacity:0;
+ cursor: pointer;
+
+}
+.style-select input + label:before {
+ content: '';
+ position: absolute;
+ left:0;
+ top:4px;
+ background: none;
+ border-radius: 50%;
+ width:16px;
+ height:16px;
+ box-sizing: border-box;
+ border: 2px solid rgba(0,0,0,0.6);
+}
+.radio:hover label:before {
+ border-color: #3169B3;
+}
+.style-select input:checked + label:before {
+ border-color: #3169B3;
+}
+.style-select input:checked + label:after {
+ content: '';
+ position: absolute;
+ left: 5px;
+ top: 9px;
+ width:6px;
+ height: 6px;
+ background: #3169B3;
+ border-radius: 50%;
+}
+
+/*.section--developers {
+ color: #FFF;
+ background: #222;
+ background: #1f1f1f;
+ padding: 80px 0;
+}
+.section--developers a {
+ color:#FFFFFF;
+}
+.section--developers p,
+.section--developers ul.text-list {
+ color: #ddd;
+}
+.section--developers .section--head p,
+.section--developers .title-block p {
+ color: #ddd;
+}*/
+
+.row--modules ul {
+ list-style: none;
+ margin-left: 0;
+ /*color: rgba(255, 255, 255, 0.8);*/
+}
+.row--modules span {
+ font-wight:600;
+ border-left:5px solid #FFF;
+ padding-left:5px;
+ margin-left:-10px;
+}
+
+.size-chart {
+ width: 100%;
+ display: inline-block;
+}
+
+.size-chart div {
+ height: 21px;
+ float: left;
+ font-size: 13px;
+ padding: 4px;
+ line-height: 1;
+}
+
+.block__ui-separated {
+ position: relative;
+}
+.block__ui-separated .col-50 {
+ position: absolute;
+ left: 0;
+ top:12px;
+}
+.block__ui-separated img {
+ float: right;
+ max-width: 450px;
+}
+
+
+.demo-gallery {
+ width: 100%;
+ height: auto;
+ float: left;
+}
+.demo-gallery a {
+ -webkit-tap-highlight-color: rgba(0,0,0,0);
+ -webkit-touch-callout: none;
+ display: block;
+ float: left;
+ margin: 0 12px 12px 0;
+ width: 171px;
+ line-height: 0;
+}
+
+
+
+a.demo-gallery__img--main {
+ width: auto;
+ height: auto;
+}
+
+.ukraine-flag {
+ width: 21px;
+ height: 14px;
+ position: relative;
+ background: #ffcc00;
+ top: 1px;
+ display: inline-block;
+}
+.ukraine-flag:before {
+ content:'';
+ position: absolute;
+ width: 21px;
+ height: 7px;
+ left:0;
+ top:0;
+ background: #0066cc;
+}
+
+.demo-gallery figure {
+ display: none;
+}
+.demo-gallery__title {
+ line-height: 14px;
+ font-size: 14px;
+ opacity: 0.8;
+ margin-top: 5px;
+ width: 100%;
+ float: left;
+}
+
+.share-buttons h2 {
+ text-align: center;
+ border: 0;
+
+}
+.share-buttons {
+ text-align: center;
+ position: relative;
+ margin: 0 0 24px;
+}
+.share-buttons a {
+ -moz-border-radius: 2px;
+ border-radius: 2px;
+ display: inline-block;
+ padding: 10px 20px;
+ margin: 10px;
+ color: #FFF;
+ text-decoration: none;
+ background: #5AAF63;
+ font-size: 16px;
+ line-height: 22px;
+ cursor: pointer;
+}
+.share-buttons a:hover {
+ opacity: 0.7;
+}
+#tweet {
+ background: #0096c4;
+}
+#like {
+ background: #3b5998;
+}
+#gplus {
+ background: #d34836;
+}
+
+
+
+@media screen and (max-width: 1000px) {
+
+
+
+ .row--wide {
+ max-width: 800px;
+ }
+ .row--wide img {
+ float: none;
+ }
+ .img-desc {
+ margin-left: 0;
+ }
+ .section {
+ margin-top: 132px;
+ }
+
+ .row--docs {
+ max-width: 800px;
+ padding-left: 30px;
+
+ }
+
+ .section--head {
+ margin-top:0;
+ padding: 30px 0;
+ }
+
+ .docs {
+ margin-top: 48px;
+ }
+
+ .docs-menu {
+ position: relative;
+ left: 0;
+ top: 0;
+ border-top: 1px solid #CCC;
+ padding-top: 25px;
+ border-bottom: 1px solid #CCC;
+ padding-bottom: 25px;
+ margin: 15px 0;
+ }
+
+ .row--nav {
+ font-size: 24px;
+ line-height: 1.1;
+ }
+
+}
+
+@media screen and (max-width: 650px) {
+ h1 {
+ font-size: 40px;
+ }
+ .block__ui-separated .col-50 {
+ position: relative;
+ top: 0;
+ }
+ .block__ui-separated img {
+ max-width: 100%;
+ width: 100%;
+ float: left;
+ }
+}
+
+@media screen and (max-width: 450px) {
+
+
+ .col-50:nth-child(1) {
+ margin-right: 0;
+ }
+ .row--wide img {
+ margin-bottom: 6px;
+ }
+ .col-50 {
+ width: 100%;
+ margin-bottom: 12px;
+ }
+ .row {
+ padding: 0 18px;
+ }
+ .docs .highlight,
+ .codepen-embed {
+ padding-left: 18px;
+ padding-right: 18px;
+ margin-left: -18px;
+ }
+ .section {
+ margin-top: 88px;
+ }
+ .docs {
+ margin-top: 32px;
+ }
+ .section--head {
+ margin-top:0;
+ padding: 24px 0;
+ }
+ .row--nav {
+ font-size: 18px;
+ line-height: 26px;
+ }
+
+
+}
+
+@media screen and (max-width: 700px) {
+
+ .row--nav {
+ font-size: 18px;
+ line-height: 26px;
+ }
+
+ .demo-gallery {
+ max-width: 500px;
+ }
+ .demo-gallery a {
+ width: 120px;
+ margin: 0 4px 4px 0;
+ }
+ a.demo-gallery__img--main {
+ width: 164px;
+ }
+ .section--head p {
+ font-size: 18px;
+ line-height: 24px;
+ }
+}
+
+/*@media screen and (max-width: 490px) {
+ .demo-gallery a {
+ width: 100px;
+ margin: 0 4px 4px 0;
+ }
+ a.demo-gallery__img--main {
+ width: 137px;
+ }
+}
+*/
+
+
+@media screen and (max-width: 450px) {
+ .demo-gallery a {
+ width: 95px;
+ margin: 0 1px 1px 0;
+ }
+ a.demo-gallery__img--main {
+ width: 127px;
+ }
+}
+
+
+@media screen and (max-width: 350px) {
+ .demo-gallery a {
+ width: 81px;
+margin: 0 1px 1px 0;
+ }
+ a.demo-gallery__img--main {
+ width: 109px;
+ }
+}
+
+
+
+
+
diff --git a/data/ext/perspectiveList/extension.js b/data/ext/perspectiveList/extension.js
index 4091b5664..923eae52b 100644
--- a/data/ext/perspectiveList/extension.js
+++ b/data/ext/perspectiveList/extension.js
@@ -1,142 +1,142 @@
-/* Copyright (c) 2012-2013 The TagSpaces Authors. All rights reserved.
- * Use of this source code is governed by a AGPL3 license that
- * can be found in the LICENSE file. */
-/* global define, Handlebars */
-define(function(require, exports, module) {
-"use strict";
-
- var extensionTitle = "List";
- var extensionID = "perspectiveList"; // ID should be equal to the directory name where the ext. is located
- var extensionType = "perspective";
- var extensionIcon = "fa fa-list-ul";
- var extensionVersion = "1.0";
- var extensionManifestVersion = 1;
- var extensionLicense = "AGPL";
-
- console.log("Loading "+extensionID);
-
- var TSCORE = require("tscore");
-
- var extensionDirectory = TSCORE.Config.getExtensionPath()+"/"+extensionID;
- var UI;
-
- function init() {
- console.log("Initializing perspective "+extensionID);
- require([
- "css!"+extensionDirectory+'/extension.css',
- extensionDirectory+'/datatables/jquery.dataTables.min.js',
- 'libs/filesaver.js/FileSaver.js'
- ], function() {
- require([
- extensionDirectory+'/perspectiveUI.js',
- "text!"+extensionDirectory+'/toolbar.html',
- extensionDirectory+'/datatables/natural.js',
- ], function(extUI, toolbarTPL) {
-
- var toolbarTemplate = Handlebars.compile( toolbarTPL );
- UI = new extUI.ExtUI(extensionID);
- UI.buildUI(toolbarTemplate);
-
- // TODO refactor translations
- var translation = $.i18n.t("ns.perspectiveList:fileExtension");
- if(translation.length > 0) {
- $('#'+extensionID+'Container').find("th:contains('File Ext.')").text(translation);
- }
- translation = $.i18n.t("ns.perspectiveList:fileTitle");
- if(translation.length > 0) {
- $('#'+extensionID+'Container').find("th:contains('Title')").text(translation);
- }
- translation = $.i18n.t("ns.perspectiveList:fileTags");
- if(translation.length > 0) {
- $('#'+extensionID+'Container').find("th:contains('Tags')").text(translation);
- }
- translation = $.i18n.t("ns.perspectiveList:fileSize");
- if(translation.length > 0) {
- $('#'+extensionID+'Container').find("th:contains('Size')").text(translation);
- }
- translation = $.i18n.t("ns.perspectiveList:fileLDTM");
- if(translation.length > 0) {
- $('#'+extensionID+'Container').find("th:contains('Last Modified')").text(translation);
- }
- translation = $.i18n.t("ns.perspectiveList:filePath");
- if(translation.length > 0) {
- $('#'+extensionID+'Container').find("th:contains('File Path')").text(translation);
- }
- translation = $.i18n.t("ns.perspectiveList:fileName");
- if(translation.length > 0) {
- $('#' + extensionID + 'Container').find("th:contains('File Name')").text(translation);
- }
-
- $('#'+extensionID+'Toolbar [data-i18n]').i18n();
-
- platformTuning();
- }
- );
- }
- );
- }
-
- var platformTuning = function() {
- if(isCordova) {
- $('#'+extensionID+'Export2CSVButton').hide();
- } else if(isChrome) {
- $('#'+extensionID+'AddFileButton').hide();
- $('#'+extensionID+'TagButton').hide();
- $('#'+extensionID+'CopyMoveButton').hide();
- $('#'+extensionID+'CreateDirectoryButton').hide();
- } else if(isFirefox) {
- $('#'+extensionID+'AddFileButton').hide(); // Current impl has 0.5mb limit
- }
- };
-
- var load = function () {
- console.log("Loading perspective "+extensionID);
- if(UI === undefined) {
- window.setTimeout(function() { UI.reInit(); }, 1000);
- } else {
- UI.reInit();
- }
- };
-
- var clearSelectedFiles = function() {
- if(UI !== undefined) {
- UI.clearSelectedFiles();
- UI.handleElementActivation();
- }
- };
-
- var removeFileUI = function(filePath) {
- UI.removeFileUI(filePath);
- };
-
- var updateFileUI = function(oldFilePath, newFilePath) {
- UI.updateFileUI(oldFilePath, newFilePath);
- };
-
- var getNextFile = function (filePath) {
- return UI.getNextFile(filePath);
- };
-
- var getPrevFile = function (filePath) {
- return UI.getPrevFile(filePath);
- };
-
- // Vars
- exports.Title = extensionTitle;
- exports.ID = extensionID;
- exports.Type = extensionType;
- exports.Icon = extensionIcon;
- exports.Version = extensionVersion;
- exports.ManifestVersion = extensionManifestVersion;
- exports.License = extensionLicense;
-
- // Methods
- exports.init = init;
- exports.load = load;
- exports.clearSelectedFiles = clearSelectedFiles;
- exports.getNextFile = getNextFile;
- exports.getPrevFile = getPrevFile;
- exports.removeFileUI = removeFileUI;
- exports.updateFileUI = updateFileUI;
-
-});
\ No newline at end of file
+/* Copyright (c) 2012-2013 The TagSpaces Authors. All rights reserved.
+ * Use of this source code is governed by a AGPL3 license that
+ * can be found in the LICENSE file. */
+/* global define, Handlebars */
+define(function(require, exports, module) {
+ "use strict";
+
+ var extensionTitle = "List";
+ var extensionID = "perspectiveList"; // ID should be equal to the directory name where the ext. is located
+ var extensionType = "perspective";
+ var extensionIcon = "fa fa-list-ul";
+ var extensionVersion = "1.0";
+ var extensionManifestVersion = 1;
+ var extensionLicense = "AGPL";
+
+ console.log("Loading " + extensionID);
+
+ var TSCORE = require("tscore");
+
+ var extensionDirectory = TSCORE.Config.getExtensionPath() + "/" + extensionID;
+ var UI;
+
+ function init() {
+ console.log("Initializing perspective " + extensionID);
+ require([
+ "css!" + extensionDirectory + '/extension.css',
+ extensionDirectory + '/datatables/jquery.dataTables.min.js',
+ 'libs/filesaver.js/FileSaver.js'
+ ], function() {
+ require([
+ extensionDirectory + '/perspectiveUI.js',
+ "text!" + extensionDirectory + '/toolbar.html',
+ extensionDirectory + '/datatables/natural.js',
+ ], function(extUI, toolbarTPL) {
+
+ var toolbarTemplate = Handlebars.compile(toolbarTPL);
+ UI = new extUI.ExtUI(extensionID);
+ UI.buildUI(toolbarTemplate);
+
+ // TODO refactor translations
+ var translation = $.i18n.t("ns.perspectiveList:fileExtension");
+ if (translation.length > 0) {
+ $('#' + extensionID + 'Container').find("th:contains('File Ext.')").text(translation);
+ }
+ translation = $.i18n.t("ns.perspectiveList:fileTitle");
+ if (translation.length > 0) {
+ $('#' + extensionID + 'Container').find("th:contains('Title')").text(translation);
+ }
+ translation = $.i18n.t("ns.perspectiveList:fileTags");
+ if (translation.length > 0) {
+ $('#' + extensionID + 'Container').find("th:contains('Tags')").text(translation);
+ }
+ translation = $.i18n.t("ns.perspectiveList:fileSize");
+ if (translation.length > 0) {
+ $('#' + extensionID + 'Container').find("th:contains('Size')").text(translation);
+ }
+ translation = $.i18n.t("ns.perspectiveList:fileLDTM");
+ if (translation.length > 0) {
+ $('#' + extensionID + 'Container').find("th:contains('Last Modified')").text(translation);
+ }
+ translation = $.i18n.t("ns.perspectiveList:filePath");
+ if (translation.length > 0) {
+ $('#' + extensionID + 'Container').find("th:contains('File Path')").text(translation);
+ }
+ translation = $.i18n.t("ns.perspectiveList:fileName");
+ if (translation.length > 0) {
+ $('#' + extensionID + 'Container').find("th:contains('File Name')").text(translation);
+ }
+
+ $('#' + extensionID + 'Toolbar [data-i18n]').i18n();
+
+ platformTuning();
+ });
+ });
+ }
+
+ var platformTuning = function() {
+ if (isCordova) {
+ $('#' + extensionID + 'Export2CSVButton').hide();
+ } else if (isChrome) {
+ $('#' + extensionID + 'AddFileButton').hide();
+ $('#' + extensionID + 'TagButton').hide();
+ $('#' + extensionID + 'CopyMoveButton').hide();
+ $('#' + extensionID + 'CreateDirectoryButton').hide();
+ } else if (isFirefox) {
+ $('#' + extensionID + 'AddFileButton').hide(); // Current impl has 0.5mb limit
+ }
+ };
+
+ var load = function() {
+ console.log("Loading perspective " + extensionID);
+ if (UI === undefined) {
+ window.setTimeout(function() {
+ UI.reInit();
+ }, 1000);
+ } else {
+ UI.reInit();
+ }
+ };
+
+ var clearSelectedFiles = function() {
+ if (UI !== undefined) {
+ UI.clearSelectedFiles();
+ UI.handleElementActivation();
+ }
+ };
+
+ var removeFileUI = function(filePath) {
+ UI.removeFileUI(filePath);
+ };
+
+ var updateFileUI = function(oldFilePath, newFilePath) {
+ UI.updateFileUI(oldFilePath, newFilePath);
+ };
+
+ var getNextFile = function(filePath) {
+ return UI.getNextFile(filePath);
+ };
+
+ var getPrevFile = function(filePath) {
+ return UI.getPrevFile(filePath);
+ };
+
+ // Vars
+ exports.Title = extensionTitle;
+ exports.ID = extensionID;
+ exports.Type = extensionType;
+ exports.Icon = extensionIcon;
+ exports.Version = extensionVersion;
+ exports.ManifestVersion = extensionManifestVersion;
+ exports.License = extensionLicense;
+
+ // Methods
+ exports.init = init;
+ exports.load = load;
+ exports.clearSelectedFiles = clearSelectedFiles;
+ exports.getNextFile = getNextFile;
+ exports.getPrevFile = getPrevFile;
+ exports.removeFileUI = removeFileUI;
+ exports.updateFileUI = updateFileUI;
+
+});
diff --git a/data/ext/perspectiveList/perspectiveUI.js b/data/ext/perspectiveList/perspectiveUI.js
index 74bec9407..a0692e3d1 100644
--- a/data/ext/perspectiveList/perspectiveUI.js
+++ b/data/ext/perspectiveList/perspectiveUI.js
@@ -1,702 +1,726 @@
-/* Copyright (c) 2012-2014 The TagSpaces Authors. All rights reserved.
- * Use of this source code is governed by a AGPL3 license that
- * can be found in the LICENSE file. */
-/* global define, Handlebars, isWin */
-define(function(require, exports, module) {
-"use strict";
-
-console.log("Loading UI for perspectiveList");
-
- var TSCORE = require("tscore");
-
- var TMB_SIZES = [ "100px", "200px", "300px", "400px", "500px" ];
-
- var supportedFileTypeThumnailing = ['jpg','jpeg','png','gif'];
-
- var extensionDirectory;
-
- function ExtUI(extID) {
- this.extensionID = extID;
- this.viewContainer = $("#"+this.extensionID+"Container").empty();
- this.viewToolbar = $("#"+this.extensionID+"Toolbar").empty();
- this.viewFooter = $("#"+this.extensionID+"Footer").empty();
-
- this.thumbEnabled = false;
- this.showFileDetails = false;
- this.showTags = true;
- this.currentTmbSize = 0;
-
- extensionDirectory = TSCORE.Config.getExtensionPath()+"/"+this.extensionID;
- }
-
- ExtUI.prototype.buildUI = function(toolbarTemplate) {
- console.log("Init UI module");
-
- var self = this;
-
- var context = {
- id: this.extensionID
- };
- // Init Toolbar
-
- this.viewToolbar.append(toolbarTemplate(context));
-
- $("#"+this.extensionID+"ToogleSelectAll")
- .click(function() {
- if($(this).find("i").hasClass("fa-square-o")) {
- TSCORE.selectedFiles = [];
- $('#'+self.extensionID+'FileTable tbody tr').each(function(){
- $(this).addClass('ui-selected');
- $(this).find(".fileSelection").find("i").addClass("fa-check-square-o").removeClass("fa-square-o");
- TSCORE.selectedFiles.push($(this).find(".fileTitleButton").attr("filepath"));
- self.handleElementActivation();
- });
- $(this).find("i")
- .removeClass("fa-square-o")
- .addClass("fa-check-square-o");
- } else {
- TSCORE.PerspectiveManager.clearSelectedFiles();
- $(this).find("i")
- .removeClass("fa fa-check-square-o")
- .addClass("fa fa-square-o");
- }
- });
-
- $("#"+this.extensionID+"IncludeSubDirsButton")
- .click(function() {
- if(TSCORE.Config.getShowWarningRecursiveScan()) {
- TSCORE.showConfirmDialog(
- $.i18n.t("ns.perspectiveList:includeSubdirsTitleConfirm"),
- $.i18n.t("ns.perspectiveList:includeSubdirsContentConfirm"),
- function () {
- TSCORE.Config.setShowWarningRecursiveScan($("#confirmDialog").find("#showThisDialogAgain").prop('checked'));
- //console.log("Shownextime : "+$("#confirmDialog").find("#showThisDialogAgain").prop('checked'));
- $("#" + self.extensionID + "IncludeSubDirsButton").prop('disabled', true);
- TSCORE.IO.createDirectoryIndex(TSCORE.currentPath);
- },
- function () {},
- TSCORE.Config.getShowWarningRecursiveScan()
- );
- } else {
- $("#" + self.extensionID + "IncludeSubDirsButton").prop('disabled', true);
- TSCORE.IO.createDirectoryIndex(TSCORE.currentPath);
- }
- });
-
- $("#"+this.extensionID+"TagButton")
- .click(function() {
- TSCORE.showAddTagsDialog();
- });
-
- $("#"+this.extensionID+"CopyMoveButton")
- .click(function() {
- TSCORE.showMoveCopyFilesDialog();
- });
-
- $("#"+this.extensionID+"ShowTmbButton")
- .click(function() {
- self.toggleThumbnails();
- });
-
- $("#"+this.extensionID+"IncreaseThumbsButton")
- .click(function() {
- self.switchThumbnailSize();
- })
- .prop('disabled', true);
-
- $("#"+this.extensionID+"ShowFileDetailsButton")
- .click(function() {
- self.toggleFileDetails();
- });
-
- $("#"+this.extensionID+"ShowTagsButton")
- .click(function() {
- self.toggleTags();
- });
-
-
- $("#"+this.extensionID+"Export2CSVButton")
- .click(function() {
- var blob = new Blob([TSCORE.exportFileListCSV(TSCORE.fileList)], {type: "text/csv;charset=utf-8"});
- saveAs(blob, "Export.csv");
- //console.log("Export data: "+TSCORE.exportFileListCSV(TSCORE.fileList));
- });
-
- $("#"+this.extensionID+"ReloadFolderButton")
- .click(function() {
- TSCORE.navigateToDirectory(TSCORE.currentPath);
- });
-
- $("#"+this.extensionID+"CreateFileButton").on("click", function () {
- TSCORE.showFileCreateDialog();
- });
-
- $("#"+this.extensionID+"CreateDirectoryButton").on("click", function () {
- TSCORE.showCreateDirectoryDialog(TSCORE.currentPath)
- });
-
- $("#"+this.extensionID+"CreateHTMLFileButton").on("click", function () {
- TSCORE.createHTMLFile();
- });
-
- $("#"+this.extensionID+"CreateMDFileButton").on("click", function () {
- TSCORE.createMDFile();
- });
-
- $("#"+this.extensionID+"CreateTXTFileButton").on("click", function () {
- TSCORE.createTXTFile();
- });
-
- $("#"+this.extensionID+"AddFileButton").on("click", function () {
- $("#addFileInput").click();
- });
-
- // Disabling all buttons by no data
- this.viewToolbar.find(".btn").prop('disabled', true);
-
- // Init Toolbar END
-
- // Init Container
-
- // Init File Context Menu
- this.viewContainer.on("contextmenu click", ".fileTitleButton", function (e) {
- e.preventDefault();
- TSCORE.hideAllDropDownMenus();
- self.selectFile(this, $(this).attr("filepath"));
- TSCORE.showContextMenu("#fileMenu", $(this));
- return false;
- });
-
- // Init Tag Context Menu
- this.viewContainer.on("contextmenu click", ".tagButton", function (e) {
- e.preventDefault();
- TSCORE.hideAllDropDownMenus();
- self.selectFile(this, $(this).attr("filepath"));
- TSCORE.openTagMenu(this, $(this).attr("tag"), $(this).attr("filepath"));
- TSCORE.showContextMenu("#tagMenu", $(this));
- return false;
- });
-
- this.viewContainer.append($("<table>", {
- cellpadding: "0", cellspacing: "0", border: "0", style: "width: 100%",
- class: "table content disableTextSelection",
- id: this.extensionID+"FileTable"
- }));
-
- this.fileTable = $('#'+this.extensionID+"FileTable").dataTable( {
- "bStateSave": true,
- "iCookieDuration": 60*60*24*365,
- "bJQueryUI": false,
- "bPaginate": false,
- "bLengthChange": false,
- "bFilter": true,
- "bSort": true,
- "bInfo": false,
- "bAutoWidth": false,
- "oLanguage": {
- "sEmptyTable": " " // No files found
- },
- "aoColumns": [
- { "sTitle": "File Ext.", "sClass": "fileTitle noWrap" },
- { "sTitle": "Title", "sClass": "fileTitle forceWrap" },
- { "sTitle": "Tags", "sClass": "fileTitle" },
- { "sTitle": "Size", "sClass": "fileTitle" },
- { "sTitle": "Last Modified", "sClass": "fileTitle" },
- { "sTitle": "File Path", "sClass": "fileTitle" },
- { "sTitle": "File Name", "sClass": "fileTitle forceWrap" }
- ],
- "aaSorting": [[ 1, "asc" ]], // default sorting by filename
- "aoColumnDefs": [
- { // File title
- sType: 'natural',
- aTargets: [ TSCORE.fileListTITLE ]
- },
- { // File extension column
- "mRender": function ( data, type, row ) {
- return self.buttonizeTitle(row[TSCORE.fileListTITLE],row[TSCORE.fileListFILEPATH],row[TSCORE.fileListFILEEXT]);
- },
- "aTargets": [ TSCORE.fileListFILEEXT ]
- },
- { // Tags column
- "mRender": function ( data, type, row ) {
- return TSCORE.generateTagButtons(data,row[TSCORE.fileListFILEPATH]);
- },
- "aTargets": [ TSCORE.fileListTAGS ]
- },
- { // Filesize column
- "sType": 'numeric',
- "aTargets": [ TSCORE.fileListFILESIZE ],
- "mRender": function ( data, type, row ) {
- return TSCORE.TagUtils.formatFileSize(data, true);
- }
- },
- { // Last changed date column
- "mRender": function ( data ) {
- return TSCORE.TagUtils.formatDateTime(data, true); // moment(data).fromNow();
- },
- "aTargets": [ TSCORE.fileListFILELMDT ]
- },
- { // Filename column
- "mRender": function ( data ) {
- return data;
- },
- "aTargets": [ TSCORE.fileListFILENAME ]
- },
- { "bVisible": false, "aTargets": [
- //TSCORE.fileListFILESIZE,
- //TSCORE.fileListFILELMDT,
- TSCORE.fileListFILEPATH,
- TSCORE.fileListFILENAME
- ]
- },
- { "bSearchable": false, "aTargets": [
- TSCORE.fileListTITLE,
- TSCORE.fileListFILEEXT,
- TSCORE.fileListTAGS,
- TSCORE.fileListFILESIZE,
- TSCORE.fileListFILELMDT,
- TSCORE.fileListFILEPATH
- ]
- }
- ]
- } );
-
- /*
- var dropTarget = this.viewToolbar;
- //dropTarget.on("dragover", function () { dropTarget.css("border","2px red solid"); return false; });
- //dropTarget.on("dragend", function () { dropTarget.css("border","0px solid"); return false; });
- dropTarget.on("drop", function (e) {
- e.preventDefault();
- var droppedFilePath = e.originalEvent.dataTransfer.files[0].path;
- if( droppedFilePath != undefined){
- var targetFilePath = TSCORE.currentPath+TSCORE.dirSeparator+TSCORE.TagUtils.extractFileName(droppedFilePath);
- TSCORE.showConfirmDialog(
- "Confirm File Move",
- "Do you want to move '"+droppedFilePath+"' to '"+targetFilePath+"'?",
- function() { TSCORE.IO.renameFile(droppedFilePath,targetFilePath); }
- );
- }
- //for (var i = 0; i < e.originalEvent.dataTransfer.files.length; ++i) {
- // console.log(e.originalEvent.dataTransfer.files[i].path);
- //}
- return false;
- }); */
-
- // Disable alerts in datatable
- this.fileTable.dataTableExt.sErrMode = 'throw';
- };
-
- ExtUI.prototype.reInit = function() {
- // Clearing old data
- this.fileTable.fnClearTable();
-
- // Load new filtered data
- this.searchResults = TSCORE.Search.searchData(TSCORE.fileList, TSCORE.Search.nextQuery);
-
- this.fileTable.fnAddData( this.searchResults );
-
- var self = this;
-
- this.fileTable.$('tr')
- .droppable({
- accept: ".tagButton",
- hoverClass: "activeRow",
- drop: function( event, ui ) {
-
- var tagName = TSCORE.selectedTag;
- var targetFilePath = $(this).find(".fileTitleButton").attr("filepath");
-
- // preventing self drag of tags
- var targetTags = TSCORE.TagUtils.extractTags(targetFilePath);
- for (var i = 0; i < targetTags.length; i++) {
- if (targetTags[i] === tagName) {
- return true;
- }
- }
-
- console.log("Tagging file: "+tagName+" to "+targetFilePath);
- $(this).toggleClass("ui-selected");
- TSCORE.PerspectiveManager.clearSelectedFiles();
- TSCORE.selectedFiles.push(targetFilePath);
- TSCORE.TagUtils.addTag(TSCORE.selectedFiles, [tagName]);
- self.handleElementActivation();
-
- //$(ui.helper).remove();
- }
- })
- .click( function() {
- console.log("Selecting file...");
- var titleBut = $(this).find(".fileTitleButton");
- self.selectFile(titleBut, $(titleBut).attr("filepath"));
- } );
-
- if(isCordova) {
- this.fileTable.$('tr')
- .hammer().on("doubletap", function () {
- console.log("Doubletap & Opening file...");
- var titleBut = $(this).find(".fileTitleButton");
- TSCORE.FileOpener.openFile($(titleBut).attr("filepath"));
- self.selectFile(titleBut, $(titleBut).attr("filepath"));
- })
- } else {
- this.fileTable.$('tr')
- .on("dblclick", function () {
- console.log("Doubletap -> Opening file...");
- var titleBut = $(this).find(".fileTitleButton");
- TSCORE.FileOpener.openFile($(titleBut).attr("filepath"));
- self.selectFile(titleBut, $(titleBut).attr("filepath"));
- })
- }
-
- this.fileTable.$('.fileTitleButton')
- //.on('click', function(e) { e.preventDefault(); return false; })
- .draggable({
- "cancel": false,
- "appendTo": "body",
- "helper": "clone",
- "revert": true,
- "start": function() {
- console.log("Start dragging -----");
- self.selectFile(this, $(this).attr("filepath"));
- }
- });
-
- this.fileTable.$('.fileSelection')
- .on('click', function(e) {
- e.preventDefault();
- var fpath = $(this).parent().find(".fileTitleButton").attr("filepath");
- var stateTag = $(this).find("i");
- if(stateTag.hasClass("fa-square-o")) {
- stateTag.removeClass("fa-square-o").addClass("fa fa-check-square-o");
- $(this).parent().parent().addClass("ui-selected");
- TSCORE.selectedFiles.push(fpath);
- } else {
- stateTag.removeClass("fa-check-square-o").addClass("fa-square-o");
- $(this).parent().parent().removeClass("ui-selected");
- TSCORE.selectedFiles.splice(TSCORE.selectedFiles.indexOf(fpath), 1);
- }
- self.handleElementActivation();
- return false;
- } );
-
- this.fileTable.$('.tagButton')
- //.on('click', function(e) { e.preventDefault(); return false; })
- .draggable({
- "cancel": false,
- "appendTo": "body",
- "helper": "clone",
- "revert": true,
- "start": function() {
- TSCORE.selectedTag = $(this).attr("tag");
- self.selectFile(this, $(this).attr("filepath"));
- }
- });
-
- // Enable all buttons
- this.viewToolbar.find(".btn").prop('disabled', false);
- // Disable certain buttons again
- $("#"+this.extensionID+"IncreaseThumbsButton" ).prop('disabled', true);
- $("#"+this.extensionID+"TagButton" ).prop('disabled', true);
- $("#"+this.extensionID+"CopyMoveButton" ).prop('disabled', true);
-
- //Update statusbar
- if(this.searchResults.length !== undefined) {
- if(TSCORE.Search.nextQuery.length > 0) {
- $("#statusBar").text(this.searchResults.length+" "+$.i18n.t("ns.perspectiveList:filesFoundFor")+" '"+TSCORE.Search.nextQuery+"'");
- } else {
- $("#statusBar").text(this.searchResults.length+" "+$.i18n.t("ns.perspectiveList:filesFound"));
- }
- }
-
- this.refreshThumbnails();
- };
-
- var buttonCompTmpl = Handlebars.compile('<button filepath="{{filepath}}" class="btn btn-link fileSelection"><i class="fa {{selected}} fa-fw fa-lg"></i></button>' +
- '<button filepath="{{filepath}}" title="{{filepath}}" class="btn btn-link fileTitleButton"><span class="fileExt"><span>{{fileext}}</span>&nbsp;<span class="caret white-caret"></span></span></button>');
-
- var buttonCompTmbTmpl = Handlebars.compile('<button filepath="{{filepath}}" class="btn btn-link fileSelection"><i class="fa {{selected}} fa-fw fa-lg"></i></button>' +
- '<button filepath="{{filepath}}" title="{{filepath}}" class="btn btn-link fileTitleButton"><span class="fileExt"><span>{{fileext}}</span>&nbsp;<span class="caret white-caret"></span></span></button>' +
- '<br><img class="thumbImg" filepath="{{tmbpath}}" style="width: 0; height: 0; border: 0" src="">');
-
- // Helper function user by basic and search views
- ExtUI.prototype.buttonizeTitle = function(title, filePath, fileExt, isSelected) {
- if(title.length < 1) {
- title = filePath;
- }
-
- //TODO minimize platform specific calls
- var tmbPath = undefined;
- if(isCordova || isWeb) {
- tmbPath = filePath;
- } else {
- tmbPath = "file:///"+filePath;
- }
-
- var context = {
- filepath: filePath,
- tmbpath: tmbPath,
- fileext: fileExt,
- selected: isSelected?"fa-check-square-o":"fa-square-o"
- };
-
- if(supportedFileTypeThumnailing.indexOf(fileExt) >= 0) {
- return buttonCompTmbTmpl(context);
- } else {
- return buttonCompTmpl(context);
- }
- };
-
- ExtUI.prototype.clearSelectedFiles = function() {
- TSCORE.selectedFiles = [];
- $("#"+this.extensionID+"Container").find(".fileSelection").find("i")
- .removeClass("fa-check-square-o")
- .addClass("fa-square-o");
- $("#"+this.extensionID+"Container").find("tr")
- .removeClass('ui-selected');
-
- // Reseting select all button
- //$("#"+this.extensionID+"ToogleSelectAll").find("i").removeClass("fa-check-square-o").addClass("fa-square-o");
- };
-
- ExtUI.prototype.selectFile = function(uiElement, filePath) {
- TSCORE.PerspectiveManager.clearSelectedFiles();
-
- $(uiElement).parent().parent().toggleClass("ui-selected");
- $(uiElement).parent().parent().find(".fileSelection").find("i")
- .toggleClass("fa-check-square-o")
- .toggleClass("fa-square-o");
-
- TSCORE.selectedFiles.push(filePath);
- this.handleElementActivation();
- };
-
- ExtUI.prototype.switchThumbnailSize = function() {
- this.currentTmbSize = this.currentTmbSize + 1;
-
- if(this.currentTmbSize >= TMB_SIZES.length) { this.currentTmbSize = 0; }
-
- $('.thumbImg').css({"max-width":TMB_SIZES[this.currentTmbSize], "max-height":TMB_SIZES[this.currentTmbSize] });
- };
-
- ExtUI.prototype.toggleFileDetails = function() {
- if(this.showFileDetails) {
- this.fileTable.fnSetColumnVis( TSCORE.fileListFILESIZE, false );
- this.fileTable.fnSetColumnVis( TSCORE.fileListFILELMDT, false );
- this.fileTable.fnSetColumnVis( TSCORE.fileListFILEPATH, false );
- } else {
- this.fileTable.fnSetColumnVis( TSCORE.fileListFILESIZE, true );
- this.fileTable.fnSetColumnVis( TSCORE.fileListFILELMDT, true );
- this.fileTable.fnSetColumnVis( TSCORE.fileListFILEPATH, true );
- }
-
- var translation = $.i18n.t("ns.perspectiveList:fileSize");
- if(translation.length > 0) {
- $("#"+this.extensionID+"Container").find("th:contains('Size')").text(translation);
- }
- translation = $.i18n.t("ns.perspectiveList:fileLDTM");
- if(translation.length > 0) {
- $("#"+this.extensionID+"Container").find("th:contains('Last Modified')").text(translation);
- }
- translation = $.i18n.t("ns.perspectiveList:filePath");
- if(translation.length > 0) {
- $("#"+this.extensionID+"Container").find("th:contains('File Path')").text(translation);
- }
- translation = $.i18n.t("ns.perspectiveList:fileName");
- if(translation.length > 0) {
- $("#"+this.extensionID+"Container").find("th:contains('File Name')").text();
- }
-
- this.showFileDetails = !this.showFileDetails;
- };
-
- ExtUI.prototype.enableThumbnails = function() {
- $( "#"+this.extensionID+"IncreaseThumbsButton" ).prop('disabled', false);
- $.each(this.fileTable.$('.thumbImg'), function() {
- $(this).attr('style', "");
- $(this).attr('src',$(this).attr('filepath'));
- });
- $('.thumbImg').css({"max-width":TMB_SIZES[this.currentTmbSize], "max-height":TMB_SIZES[this.currentTmbSize] });
- };
-
- ExtUI.prototype.disableThumbnails = function() {
- $( "#"+this.extensionID+"IncreaseThumbsButton" ).prop('disabled', true);
- $.each(this.fileTable.$('.thumbImg'), function() {
- $(this).attr('style', "width: 0px; height: 0px; border: 0px");
- $(this).attr('src',"");
- });
- };
-
- ExtUI.prototype.refreshThumbnails = function() {
- if(this.thumbEnabled) {
- this.enableThumbnails();
- } else {
- this.disableThumbnails();
- }
- };
-
- ExtUI.prototype.toggleThumbnails = function() {
- this.thumbEnabled = !this.thumbEnabled;
- this.refreshThumbnails();
- };
-
- ExtUI.prototype.toggleTags = function() {
- if(this.showTags) {
- this.fileTable.fnSetColumnVis( TSCORE.fileListTAGS, false );
- } else {
- this.fileTable.fnSetColumnVis( TSCORE.fileListTAGS, true );
- }
- this.showTags = !this.showTags;
- };
-
- ExtUI.prototype.handleElementActivation = function() {
- console.log("Entering element activation handler...");
-
- var tagButton = $( "#"+this.extensionID+"TagButton" );
- var copyMoveButton = $( "#"+this.extensionID+"CopyMoveButton" );
-
- if (TSCORE.selectedFiles.length > 1) {
- tagButton.prop('disabled', false);
- copyMoveButton.prop('disabled', false);
- } else if (TSCORE.selectedFiles.length === 1) {
- tagButton.prop('disabled', false);
- copyMoveButton.prop('disabled', false);
- } else {
- tagButton.prop('disabled', true);
- copyMoveButton.prop('disabled', true);
- }
- };
-
- ExtUI.prototype.removeFileUI = function(filePath) {
- console.log("Removing from UI"+filePath+" from UI");
-
- // Updating the file selection
- TSCORE.selectedFiles.splice(TSCORE.selectedFiles.indexOf(filePath), 1);
-
- var row4remove;
- if(isWin && !isWeb) {
- filePath = filePath.replace("\\","");
- $("#"+this.extensionID+"Container button[filepath]").each(function() {
- if( $( this ).attr("filepath").replace("\\","") === filePath ) {
- row4remove = $( this ).parent().parent();
- }
- });
- } else {
- row4remove = $("#"+this.extensionID+"Container button[filepath='"+filePath+"']").parent().parent();
- }
- if(row4remove !== undefined) {
- row4remove.remove();
- }
- };
-
- ExtUI.prototype.updateFileUI = function(oldFilePath, newFilePath) {
- console.log("Updating UI for oldfile "+oldFilePath+" newfile "+newFilePath);
-
- // Updating the file selection
- TSCORE.selectedFiles.splice(TSCORE.selectedFiles.indexOf(oldFilePath), 1);
- TSCORE.selectedFiles.push(newFilePath);
-
- var title = TSCORE.TagUtils.extractTitle(newFilePath),
- fileExt = TSCORE.TagUtils.extractFileExtension(newFilePath),
- fileTags = TSCORE.TagUtils.extractTags(newFilePath);
-
- var $fileRow = undefined;
-
- if(isWin && !isWeb) {
- oldFilePath = oldFilePath.replace("\\","");
- $("#"+this.extensionID+"Container button[filepath]").each(function() {
- if( $( this ).attr("filepath").replace("\\","") === oldFilePath ) {
- $fileRow = $( this ).parent().parent();
- }
- });
- } else {
- $fileRow = $("#"+this.extensionID+"Container button[filepath='"+oldFilePath+"']").parent().parent();
- }
-
- $($fileRow.find("td")[0]).empty().append(this.buttonizeTitle(title,newFilePath,fileExt,true));
- $($fileRow.find("td")[1]).text(title);
- $($fileRow.find("td")[2]).empty().append(TSCORE.generateTagButtons(fileTags,newFilePath));
-
- this.refreshThumbnails();
-
- var self = this;
- $fileRow.find('.fileTitleButton')
- .draggable({
- "cancel": false,
- "appendTo": "body",
- "helper": "clone",
- "revert": true,
- "start": function() { self.selectFile(this, $(this).attr("filepath")); }
- });
-
- $fileRow.find('.fileSelection')
- .click( function(e) {
- e.preventDefault();
- var fpath = $(this).parent().find(".fileTitleButton").attr("filepath");
- var stateTag = $(this).find("i");
- if(stateTag.hasClass("fa-square-o")) {
- stateTag.removeClass("fa-square-o").addClass("fa fa-check-square-o");
- $(this).parent().parent().addClass("ui-selected");
- TSCORE.selectedFiles.push(fpath);
- } else {
- stateTag.removeClass("fa-check-square-o").addClass("fa-square-o");
- $(this).parent().parent().removeClass("ui-selected");
- TSCORE.selectedFiles.splice(TSCORE.selectedFiles.indexOf(fpath), 1);
- }
- self.handleElementActivation();
- return false;
- } );
-
- $fileRow.find('.tagButton')
- .draggable({
- "cancel": false,
- "appendTo": "body",
- "helper": "clone",
- "revert": true,
- "start": function() {
- TSCORE.selectedTag = $(this).attr("tag");
- self.selectFile(this, $(this).attr("filepath"));
- }
- });
-
- };
-
- ExtUI.prototype.getNextFile = function(filePath) {
- var nextFilePath;
- var self = this;
- this.searchResults.forEach(function(entry, index) {
- if(entry[TSCORE.fileListFILEPATH] === filePath) {
- var nextIndex = index+1;
- if(nextIndex < self.searchResults.length) {
- nextFilePath = self.searchResults[nextIndex][TSCORE.fileListFILEPATH];
- } else {
- nextFilePath = self.searchResults[0][TSCORE.fileListFILEPATH];
- }
- }
- console.log("Path: "+entry[TSCORE.fileListFILEPATH]);
- });
- TSCORE.PerspectiveManager.clearSelectedFiles();
- console.log("Next file: "+nextFilePath);
- return nextFilePath;
- };
-
- ExtUI.prototype.getPrevFile = function(filePath) {
- var prevFilePath;
- var self = this;
- this.searchResults.forEach(function(entry, index) {
- if(entry[TSCORE.fileListFILEPATH] === filePath) {
- var prevIndex = index-1;
- if(prevIndex >= 0) {
- prevFilePath = self.searchResults[prevIndex][TSCORE.fileListFILEPATH];
- } else {
- prevFilePath = self.searchResults[self.searchResults.length-1][TSCORE.fileListFILEPATH];
- }
- }
- console.log("Path: "+entry[TSCORE.fileListFILEPATH]);
- });
- TSCORE.PerspectiveManager.clearSelectedFiles();
- console.log("Prev file: "+prevFilePath);
- return prevFilePath;
- };
-
- exports.ExtUI = ExtUI;
-});
+/* Copyright (c) 2012-2015 The TagSpaces Authors. All rights reserved.
+ * Use of this source code is governed by a AGPL3 license that
+ * can be found in the LICENSE file. */
+/* global define, Handlebars, isWin */
+define(function(require, exports, module) {
+ "use strict";
+
+ console.log("Loading UI for perspectiveList");
+
+ var TSCORE = require("tscore");
+
+ var TMB_SIZES = ["100px", "200px", "300px", "400px", "500px"];
+
+ var supportedFileTypeThumnailing = ['jpg', 'jpeg', 'png', 'gif'];
+
+ var extensionDirectory;
+
+ function ExtUI(extID) {
+ this.extensionID = extID;
+ this.viewContainer = $("#" + this.extensionID + "Container").empty();
+ this.viewToolbar = $("#" + this.extensionID + "Toolbar").empty();
+ this.viewFooter = $("#" + this.extensionID + "Footer").empty();
+
+ this.thumbEnabled = false;
+ this.showFileDetails = false;
+ this.showTags = true;
+ this.currentTmbSize = 0;
+
+ extensionDirectory = TSCORE.Config.getExtensionPath() + "/" + this.extensionID;
+ }
+
+ ExtUI.prototype.buildUI = function(toolbarTemplate) {
+ console.log("Init UI module");
+
+ var self = this;
+
+ var context = {
+ id: this.extensionID
+ };
+ // Init Toolbar
+
+ this.viewToolbar.append(toolbarTemplate(context));
+
+ $("#" + this.extensionID + "ToogleSelectAll")
+ .click(function() {
+ if ($(this).find("i").hasClass("fa-square-o")) {
+ TSCORE.selectedFiles = [];
+ $('#' + self.extensionID + 'FileTable tbody tr').each(function() {
+ $(this).addClass('ui-selected');
+ $(this).find(".fileSelection").find("i").addClass("fa-check-square-o").removeClass("fa-square-o");
+ TSCORE.selectedFiles.push($(this).find(".fileTitleButton").attr("filepath"));
+ self.handleElementActivation();
+ });
+ $(this).find("i")
+ .removeClass("fa-square-o")
+ .addClass("fa-check-square-o");
+ } else {
+ TSCORE.PerspectiveManager.clearSelectedFiles();
+ $(this).find("i")
+ .removeClass("fa fa-check-square-o")
+ .addClass("fa fa-square-o");
+ }
+ });
+
+ $("#" + this.extensionID + "IncludeSubDirsButton")
+ .click(function() {
+ if (TSCORE.Config.getShowWarningRecursiveScan()) {
+ TSCORE.showConfirmDialog(
+ $.i18n.t("ns.perspectiveList:includeSubdirsTitleConfirm"),
+ $.i18n.t("ns.perspectiveList:includeSubdirsContentConfirm"),
+ function() {
+ TSCORE.Config.setShowWarningRecursiveScan($("#confirmDialog").find("#showThisDialogAgain").prop('checked'));
+ //console.log("Shownextime : "+$("#confirmDialog").find("#showThisDialogAgain").prop('checked'));
+ $("#" + self.extensionID + "IncludeSubDirsButton").prop('disabled', true);
+ TSCORE.IO.createDirectoryIndex(TSCORE.currentPath);
+ },
+ function() {},
+ TSCORE.Config.getShowWarningRecursiveScan()
+ );
+ } else {
+ $("#" + self.extensionID + "IncludeSubDirsButton").prop('disabled', true);
+ TSCORE.IO.createDirectoryIndex(TSCORE.currentPath);
+ }
+ });
+
+ $("#" + this.extensionID + "TagButton")
+ .click(function() {
+ TSCORE.showAddTagsDialog();
+ });
+
+ $("#" + this.extensionID + "CopyMoveButton")
+ .click(function() {
+ TSCORE.showMoveCopyFilesDialog();
+ });
+
+ $("#" + this.extensionID + "ShowTmbButton")
+ .click(function() {
+ self.toggleThumbnails();
+ });
+
+ $("#" + this.extensionID + "IncreaseThumbsButton")
+ .click(function() {
+ self.switchThumbnailSize();
+ })
+ .prop('disabled', true);
+
+ $("#" + this.extensionID + "ShowFileDetailsButton")
+ .click(function() {
+ self.toggleFileDetails();
+ });
+
+ $("#" + this.extensionID + "ShowTagsButton")
+ .click(function() {
+ self.toggleTags();
+ });
+
+ $("#" + this.extensionID + "Export2CSVButton")
+ .click(function() {
+ var blob = new Blob([TSCORE.exportFileListCSV(TSCORE.fileList)], {
+ type: "text/csv;charset=utf-8"
+ });
+ saveAs(blob, "Export.csv");
+ //console.log("Export data: "+TSCORE.exportFileListCSV(TSCORE.fileList));
+ });
+
+ $("#" + this.extensionID + "ReloadFolderButton")
+ .click(function() {
+ TSCORE.navigateToDirectory(TSCORE.currentPath);
+ });
+
+ $("#" + this.extensionID + "CreateFileButton").on("click", function() {
+ TSCORE.showFileCreateDialog();
+ });
+
+ $("#" + this.extensionID + "CreateDirectoryButton").on("click", function() {
+ TSCORE.showCreateDirectoryDialog(TSCORE.currentPath);
+ });
+
+ $("#" + this.extensionID + "CreateHTMLFileButton").on("click", function() {
+ TSCORE.createHTMLFile();
+ });
+
+ $("#" + this.extensionID + "CreateMDFileButton").on("click", function() {
+ TSCORE.createMDFile();
+ });
+
+ $("#" + this.extensionID + "CreateTXTFileButton").on("click", function() {
+ TSCORE.createTXTFile();
+ });
+
+ $("#" + this.extensionID + "AddFileButton").on("click", function() {
+ $("#addFileInput").click();
+ });
+
+ // Disabling all buttons by no data
+ this.viewToolbar.find(".btn").prop('disabled', true);
+
+ // Init Toolbar END
+
+ // Init Container
+
+ // Init File Context Menu
+ this.viewContainer.on("contextmenu click", ".fileTitleButton", function(e) {
+ e.preventDefault();
+ TSCORE.hideAllDropDownMenus();
+ self.selectFile(this, $(this).attr("filepath"));
+ TSCORE.showContextMenu("#fileMenu", $(this));
+ return false;
+ });
+
+ // Init Tag Context Menu
+ this.viewContainer.on("contextmenu click", ".tagButton", function(e) {
+ e.preventDefault();
+ TSCORE.hideAllDropDownMenus();
+ self.selectFile(this, $(this).attr("filepath"));
+ TSCORE.openTagMenu(this, $(this).attr("tag"), $(this).attr("filepath"));
+ TSCORE.showContextMenu("#tagMenu", $(this));
+ return false;
+ });
+
+ this.viewContainer.append($("<table>", {
+ cellpadding: "0",
+ cellspacing: "0",
+ border: "0",
+ style: "width: 100%",
+ class: "table content disableTextSelection",
+ id: this.extensionID + "FileTable"
+ }));
+
+ this.fileTable = $('#' + this.extensionID + "FileTable").dataTable({
+ "bStateSave": true,
+ "iCookieDuration": 60 * 60 * 24 * 365,
+ "bJQueryUI": false,
+ "bPaginate": false,
+ "bLengthChange": false,
+ "bFilter": true,
+ "bSort": true,
+ "bInfo": false,
+ "bAutoWidth": false,
+ "oLanguage": {
+ "sEmptyTable": " " // No files found
+ },
+ "aoColumns": [{
+ "sTitle": "File Ext.",
+ "sClass": "fileTitle noWrap"
+ }, {
+ "sTitle": "Title",
+ "sClass": "fileTitle forceWrap"
+ }, {
+ "sTitle": "Tags",
+ "sClass": "fileTitle"
+ }, {
+ "sTitle": "Size",
+ "sClass": "fileTitle"
+ }, {
+ "sTitle": "Last Modified",
+ "sClass": "fileTitle"
+ }, {
+ "sTitle": "File Path",
+ "sClass": "fileTitle"
+ }, {
+ "sTitle": "File Name",
+ "sClass": "fileTitle forceWrap"
+ }],
+ "aaSorting": [
+ [1, "asc"]
+ ], // default sorting by filename
+ "aoColumnDefs": [{ // File title
+ sType: 'natural',
+ aTargets: [TSCORE.fileListTITLE]
+ }, { // File extension column
+ "mRender": function(data, type, row) {
+ return self.buttonizeTitle(row[TSCORE.fileListTITLE], row[TSCORE.fileListFILEPATH], row[TSCORE.fileListFILEEXT]);
+ },
+ "aTargets": [TSCORE.fileListFILEEXT]
+ }, { // Tags column
+ "mRender": function(data, type, row) {
+ return TSCORE.generateTagButtons(data, row[TSCORE.fileListFILEPATH]);
+ },
+ "aTargets": [TSCORE.fileListTAGS]
+ }, { // Filesize column
+ "sType": 'numeric',
+ "aTargets": [TSCORE.fileListFILESIZE],
+ "mRender": function(data, type, row) {
+ return TSCORE.TagUtils.formatFileSize(data, true);
+ }
+ }, { // Last changed date column
+ "mRender": function(data) {
+ return TSCORE.TagUtils.formatDateTime(data, true); // moment(data).fromNow();
+ },
+ "aTargets": [TSCORE.fileListFILELMDT]
+ }, { // Filename column
+ "mRender": function(data) {
+ return data;
+ },
+ "aTargets": [TSCORE.fileListFILENAME]
+ }, {
+ "bVisible": false,
+ "aTargets": [
+ //TSCORE.fileListFILESIZE,
+ //TSCORE.fileListFILELMDT,
+ TSCORE.fileListFILEPATH,
+ TSCORE.fileListFILENAME
+ ]
+ }, {
+ "bSearchable": false,
+ "aTargets": [
+ TSCORE.fileListTITLE,
+ TSCORE.fileListFILEEXT,
+ TSCORE.fileListTAGS,
+ TSCORE.fileListFILESIZE,
+ TSCORE.fileListFILELMDT,
+ TSCORE.fileListFILEPATH
+ ]
+ }]
+ });
+
+ /*
+ var dropTarget = this.viewToolbar;
+ //dropTarget.on("dragover", function () { dropTarget.css("border","2px red solid"); return false; });
+ //dropTarget.on("dragend", function () { dropTarget.css("border","0px solid"); return false; });
+ dropTarget.on("drop", function (e) {
+ e.preventDefault();
+ var droppedFilePath = e.originalEvent.dataTransfer.files[0].path;
+ if( droppedFilePath != undefined){
+ var targetFilePath = TSCORE.currentPath+TSCORE.dirSeparator+TSCORE.TagUtils.extractFileName(droppedFilePath);
+ TSCORE.showConfirmDialog(
+ "Confirm File Move",
+ "Do you want to move '"+droppedFilePath+"' to '"+targetFilePath+"'?",
+ function() { TSCORE.IO.renameFile(droppedFilePath,targetFilePath); }
+ );
+ }
+ //for (var i = 0; i < e.originalEvent.dataTransfer.files.length; ++i) {
+ // console.log(e.originalEvent.dataTransfer.files[i].path);
+ //}
+ return false;
+ }); */
+
+ // Disable alerts in datatable
+ this.fileTable.dataTableExt.sErrMode = 'throw';
+ };
+
+ ExtUI.prototype.reInit = function() {
+ // Clearing old data
+ this.fileTable.fnClearTable();
+
+ // Load new filtered data
+ this.searchResults = TSCORE.Search.searchData(TSCORE.fileList, TSCORE.Search.nextQuery);
+
+ this.fileTable.fnAddData(this.searchResults);
+
+ var self = this;
+
+ this.fileTable.$('tr')
+ .droppable({
+ accept: ".tagButton",
+ hoverClass: "activeRow",
+ drop: function(event, ui) {
+
+ var tagName = TSCORE.selectedTag;
+ var targetFilePath = $(this).find(".fileTitleButton").attr("filepath");
+
+ // preventing self drag of tags
+ var targetTags = TSCORE.TagUtils.extractTags(targetFilePath);
+ for (var i = 0; i < targetTags.length; i++) {
+ if (targetTags[i] === tagName) {
+ return true;
+ }
+ }
+
+ console.log("Tagging file: " + tagName + " to " + targetFilePath);
+ $(this).toggleClass("ui-selected");
+ TSCORE.PerspectiveManager.clearSelectedFiles();
+ TSCORE.selectedFiles.push(targetFilePath);
+ TSCORE.TagUtils.addTag(TSCORE.selectedFiles, [tagName]);
+ self.handleElementActivation();
+
+ //$(ui.helper).remove();
+ }
+ })
+ .click(function() {
+ console.log("Selecting file...");
+ var titleBut = $(this).find(".fileTitleButton");
+ self.selectFile(titleBut, $(titleBut).attr("filepath"));
+ });
+
+ if (isCordova) {
+ this.fileTable.$('tr')
+ .hammer().on("doubletap", function() {
+ console.log("Doubletap & Opening file...");
+ var titleBut = $(this).find(".fileTitleButton");
+ TSCORE.FileOpener.openFile($(titleBut).attr("filepath"));
+ self.selectFile(titleBut, $(titleBut).attr("filepath"));
+ });
+ } else {
+ this.fileTable.$('tr')
+ .on("dblclick", function() {
+ console.log("Doubletap -> Opening file...");
+ var titleBut = $(this).find(".fileTitleButton");
+ TSCORE.FileOpener.openFile($(titleBut).attr("filepath"));
+ self.selectFile(titleBut, $(titleBut).attr("filepath"));
+ });
+ }
+
+ this.fileTable.$('.fileTitleButton')
+ //.on('click', function(e) { e.preventDefault(); return false; })
+ .draggable({
+ "cancel": false,
+ "appendTo": "body",
+ "helper": "clone",
+ "revert": true,
+ "start": function() {
+ console.log("Start dragging -----");
+ self.selectFile(this, $(this).attr("filepath"));
+ }
+ });
+
+ this.fileTable.$('.fileSelection')
+ .on('click', function(e) {
+ e.preventDefault();
+ var fpath = $(this).parent().find(".fileTitleButton").attr("filepath");
+ var stateTag = $(this).find("i");
+ if (stateTag.hasClass("fa-square-o")) {
+ stateTag.removeClass("fa-square-o").addClass("fa fa-check-square-o");
+ $(this).parent().parent().addClass("ui-selected");
+ TSCORE.selectedFiles.push(fpath);
+ } else {
+ stateTag.removeClass("fa-check-square-o").addClass("fa-square-o");
+ $(this).parent().parent().removeClass("ui-selected");
+ TSCORE.selectedFiles.splice(TSCORE.selectedFiles.indexOf(fpath), 1);
+ }
+ self.handleElementActivation();
+ return false;
+ });
+
+ this.fileTable.$('.tagButton')
+ //.on('click', function(e) { e.preventDefault(); return false; })
+ .draggable({
+ "cancel": false,
+ "appendTo": "body",
+ "helper": "clone",
+ "revert": true,
+ "start": function() {
+ TSCORE.selectedTag = $(this).attr("tag");
+ self.selectFile(this, $(this).attr("filepath"));
+ }
+ });
+
+ // Enable all buttons
+ this.viewToolbar.find(".btn").prop('disabled', false);
+ // Disable certain buttons again
+ $("#" + this.extensionID + "IncreaseThumbsButton").prop('disabled', true);
+ $("#" + this.extensionID + "TagButton").prop('disabled', true);
+ $("#" + this.extensionID + "CopyMoveButton").prop('disabled', true);
+
+ //Update statusbar
+ if (this.searchResults.length !== undefined) {
+ if (TSCORE.Search.nextQuery.length > 0) {
+ $("#statusBar").text(this.searchResults.length + " " + $.i18n.t("ns.perspectiveList:filesFoundFor") + " '" + TSCORE.Search.nextQuery + "'");
+ } else {
+ $("#statusBar").text(this.searchResults.length + " " + $.i18n.t("ns.perspectiveList:filesFound"));
+ }
+ }
+
+ this.refreshThumbnails();
+ };
+
+ var buttonCompTmpl = Handlebars.compile('<button filepath="{{filepath}}" class="btn btn-link fileSelection"><i class="fa {{selected}} fa-fw fa-lg"></i></button>' +
+ '<button filepath="{{filepath}}" title="{{filepath}}" class="btn btn-link fileTitleButton"><span class="fileExt"><span>{{fileext}}</span>&nbsp;<span class="caret white-caret"></span></span></button>');
+
+ var buttonCompTmbTmpl = Handlebars.compile('<button filepath="{{filepath}}" class="btn btn-link fileSelection"><i class="fa {{selected}} fa-fw fa-lg"></i></button>' +
+ '<button filepath="{{filepath}}" title="{{filepath}}" class="btn btn-link fileTitleButton"><span class="fileExt"><span>{{fileext}}</span>&nbsp;<span class="caret white-caret"></span></span></button>' +
+ '<br><img class="thumbImg" filepath="{{tmbpath}}" style="width: 0; height: 0; border: 0" src="">');
+
+ // Helper function user by basic and search views
+ ExtUI.prototype.buttonizeTitle = function(title, filePath, fileExt, isSelected) {
+ if (title.length < 1) {
+ title = filePath;
+ }
+
+ //TODO minimize platform specific calls
+ var tmbPath;
+ if (isCordova || isWeb) {
+ tmbPath = filePath;
+ } else {
+ tmbPath = "file:///" + filePath;
+ }
+
+ var context = {
+ filepath: filePath,
+ tmbpath: tmbPath,
+ fileext: fileExt,
+ selected: isSelected ? "fa-check-square-o" : "fa-square-o"
+ };
+
+ if (supportedFileTypeThumnailing.indexOf(fileExt) >= 0) {
+ return buttonCompTmbTmpl(context);
+ } else {
+ return buttonCompTmpl(context);
+ }
+ };
+
+ ExtUI.prototype.clearSelectedFiles = function() {
+ TSCORE.selectedFiles = [];
+ $("#" + this.extensionID + "Container").find(".fileSelection").find("i")
+ .removeClass("fa-check-square-o")
+ .addClass("fa-square-o");
+ $("#" + this.extensionID + "Container").find("tr")
+ .removeClass('ui-selected');
+
+ // Reseting select all button
+ //$("#"+this.extensionID+"ToogleSelectAll").find("i").removeClass("fa-check-square-o").addClass("fa-square-o");
+ };
+
+ ExtUI.prototype.selectFile = function(uiElement, filePath) {
+ TSCORE.PerspectiveManager.clearSelectedFiles();
+
+ $(uiElement).parent().parent().toggleClass("ui-selected");
+ $(uiElement).parent().parent().find(".fileSelection").find("i")
+ .toggleClass("fa-check-square-o")
+ .toggleClass("fa-square-o");
+
+ TSCORE.selectedFiles.push(filePath);
+ this.handleElementActivation();
+ };
+
+ ExtUI.prototype.switchThumbnailSize = function() {
+ this.currentTmbSize = this.currentTmbSize + 1;
+
+ if (this.currentTmbSize >= TMB_SIZES.length) {
+ this.currentTmbSize = 0;
+ }
+
+ $('.thumbImg').css({
+ "max-width": TMB_SIZES[this.currentTmbSize],
+ "max-height": TMB_SIZES[this.currentTmbSize]
+ });
+ };
+
+ ExtUI.prototype.toggleFileDetails = function() {
+ if (this.showFileDetails) {
+ this.fileTable.fnSetColumnVis(TSCORE.fileListFILESIZE, false);
+ this.fileTable.fnSetColumnVis(TSCORE.fileListFILELMDT, false);
+ this.fileTable.fnSetColumnVis(TSCORE.fileListFILEPATH, false);
+ } else {
+ this.fileTable.fnSetColumnVis(TSCORE.fileListFILESIZE, true);
+ this.fileTable.fnSetColumnVis(TSCORE.fileListFILELMDT, true);
+ this.fileTable.fnSetColumnVis(TSCORE.fileListFILEPATH, true);
+ }
+
+ var translation = $.i18n.t("ns.perspectiveList:fileSize");
+ if (translation.length > 0) {
+ $("#" + this.extensionID + "Container").find("th:contains('Size')").text(translation);
+ }
+ translation = $.i18n.t("ns.perspectiveList:fileLDTM");
+ if (translation.length > 0) {
+ $("#" + this.extensionID + "Container").find("th:contains('Last Modified')").text(translation);
+ }
+ translation = $.i18n.t("ns.perspectiveList:filePath");
+ if (translation.length > 0) {
+ $("#" + this.extensionID + "Container").find("th:contains('File Path')").text(translation);
+ }
+ translation = $.i18n.t("ns.perspectiveList:fileName");
+ if (translation.length > 0) {
+ $("#" + this.extensionID + "Container").find("th:contains('File Name')").text();
+ }
+
+ this.showFileDetails = !this.showFileDetails;
+ };
+
+ ExtUI.prototype.enableThumbnails = function() {
+ $("#" + this.extensionID + "IncreaseThumbsButton").prop('disabled', false);
+ $.each(this.fileTable.$('.thumbImg'), function() {
+ $(this).attr('style', "");
+ $(this).attr('src', $(this).attr('filepath'));
+ });
+ $('.thumbImg').css({
+ "max-width": TMB_SIZES[this.currentTmbSize],
+ "max-height": TMB_SIZES[this.currentTmbSize]
+ });
+ };
+
+ ExtUI.prototype.disableThumbnails = function() {
+ $("#" + this.extensionID + "IncreaseThumbsButton").prop('disabled', true);
+ $.each(this.fileTable.$('.thumbImg'), function() {
+ $(this).attr('style', "width: 0px; height: 0px; border: 0px");
+ $(this).attr('src', "");
+ });
+ };
+
+ ExtUI.prototype.refreshThumbnails = function() {
+ if (this.thumbEnabled) {
+ this.enableThumbnails();
+ } else {
+ this.disableThumbnails();
+ }
+ };
+
+ ExtUI.prototype.toggleThumbnails = function() {
+ this.thumbEnabled = !this.thumbEnabled;
+ this.refreshThumbnails();
+ };
+
+ ExtUI.prototype.toggleTags = function() {
+ if (this.showTags) {
+ this.fileTable.fnSetColumnVis(TSCORE.fileListTAGS, false);
+ } else {
+ this.fileTable.fnSetColumnVis(TSCORE.fileListTAGS, true);
+ }
+ this.showTags = !this.showTags;
+ };
+
+ ExtUI.prototype.handleElementActivation = function() {
+ console.log("Entering element activation handler...");
+
+ var tagButton = $("#" + this.extensionID + "TagButton");
+ var copyMoveButton = $("#" + this.extensionID + "CopyMoveButton");
+
+ if (TSCORE.selectedFiles.length > 1) {
+ tagButton.prop('disabled', false);
+ copyMoveButton.prop('disabled', false);
+ } else if (TSCORE.selectedFiles.length === 1) {
+ tagButton.prop('disabled', false);
+ copyMoveButton.prop('disabled', false);
+ } else {
+ tagButton.prop('disabled', true);
+ copyMoveButton.prop('disabled', true);
+ }
+ };
+
+ ExtUI.prototype.removeFileUI = function(filePath) {
+ console.log("Removing from UI" + filePath + " from UI");
+
+ // Updating the file selection
+ TSCORE.selectedFiles.splice(TSCORE.selectedFiles.indexOf(filePath), 1);
+
+ var row4remove;
+ if (isWin && !isWeb) {
+ filePath = filePath.replace("\\", "");
+ $("#" + this.extensionID + "Container button[filepath]").each(function() {
+ if ($(this).attr("filepath").replace("\\", "") === filePath) {
+ row4remove = $(this).parent().parent();
+ }
+ });
+ } else {
+ row4remove = $("#" + this.extensionID + "Container button[filepath='" + filePath + "']").parent().parent();
+ }
+ if (row4remove !== undefined) {
+ row4remove.remove();
+ }
+ };
+
+ ExtUI.prototype.updateFileUI = function(oldFilePath, newFilePath) {
+ console.log("Updating UI for oldfile " + oldFilePath + " newfile " + newFilePath);
+
+ // Updating the file selection
+ TSCORE.selectedFiles.splice(TSCORE.selectedFiles.indexOf(oldFilePath), 1);
+ TSCORE.selectedFiles.push(newFilePath);
+
+ var title = TSCORE.TagUtils.extractTitle(newFilePath),
+ fileExt = TSCORE.TagUtils.extractFileExtension(newFilePath),
+ fileTags = TSCORE.TagUtils.extractTags(newFilePath);
+
+ var $fileRow;
+
+ if (isWin && !isWeb) {
+ oldFilePath = oldFilePath.replace("\\", "");
+ $("#" + this.extensionID + "Container button[filepath]").each(function() {
+ if ($(this).attr("filepath").replace("\\", "") === oldFilePath) {
+ $fileRow = $(this).parent().parent();
+ }
+ });
+ } else {
+ $fileRow = $("#" + this.extensionID + "Container button[filepath='" + oldFilePath + "']").parent().parent();
+ }
+
+ $($fileRow.find("td")[0]).empty().append(this.buttonizeTitle(title, newFilePath, fileExt, true));
+ $($fileRow.find("td")[1]).text(title);
+ $($fileRow.find("td")[2]).empty().append(TSCORE.generateTagButtons(fileTags, newFilePath));
+
+ this.refreshThumbnails();
+
+ var self = this;
+ $fileRow.find('.fileTitleButton')
+ .draggable({
+ "cancel": false,
+ "appendTo": "body",
+ "helper": "clone",
+ "revert": true,
+ "start": function() {
+ self.selectFile(this, $(this).attr("filepath"));
+ }
+ });
+
+ $fileRow.find('.fileSelection')
+ .click(function(e) {
+ e.preventDefault();
+ var fpath = $(this).parent().find(".fileTitleButton").attr("filepath");
+ var stateTag = $(this).find("i");
+ if (stateTag.hasClass("fa-square-o")) {
+ stateTag.removeClass("fa-square-o").addClass("fa fa-check-square-o");
+ $(this).parent().parent().addClass("ui-selected");
+ TSCORE.selectedFiles.push(fpath);
+ } else {
+ stateTag.removeClass("fa-check-square-o").addClass("fa-square-o");
+ $(this).parent().parent().removeClass("ui-selected");
+ TSCORE.selectedFiles.splice(TSCORE.selectedFiles.indexOf(fpath), 1);
+ }
+ self.handleElementActivation();
+ return false;
+ });
+
+ $fileRow.find('.tagButton')
+ .draggable({
+ "cancel": false,
+ "appendTo": "body",
+ "helper": "clone",
+ "revert": true,
+ "start": function() {
+ TSCORE.selectedTag = $(this).attr("tag");
+ self.selectFile(this, $(this).attr("filepath"));
+ }
+ });
+
+ };
+
+ ExtUI.prototype.getNextFile = function(filePath) {
+ var nextFilePath;
+ var self = this;
+ this.searchResults.forEach(function(entry, index) {
+ if (entry[TSCORE.fileListFILEPATH] === filePath) {
+ var nextIndex = index + 1;
+ if (nextIndex < self.searchResults.length) {
+ nextFilePath = self.searchResults[nextIndex][TSCORE.fileListFILEPATH];
+ } else {
+ nextFilePath = self.searchResults[0][TSCORE.fileListFILEPATH];
+ }
+ }
+ console.log("Path: " + entry[TSCORE.fileListFILEPATH]);
+ });
+ TSCORE.PerspectiveManager.clearSelectedFiles();
+ console.log("Next file: " + nextFilePath);
+ return nextFilePath;
+ };
+
+ ExtUI.prototype.getPrevFile = function(filePath) {
+ var prevFilePath;
+ var self = this;
+ this.searchResults.forEach(function(entry, index) {
+ if (entry[TSCORE.fileListFILEPATH] === filePath) {
+ var prevIndex = index - 1;
+ if (prevIndex >= 0) {
+ prevFilePath = self.searchResults[prevIndex][TSCORE.fileListFILEPATH];
+ } else {
+ prevFilePath = self.searchResults[self.searchResults.length - 1][TSCORE.fileListFILEPATH];
+ }
+ }
+ console.log("Path: " + entry[TSCORE.fileListFILEPATH]);
+ });
+ TSCORE.PerspectiveManager.clearSelectedFiles();
+ console.log("Prev file: " + prevFilePath);
+ return prevFilePath;
+ };
+
+ exports.ExtUI = ExtUI;
+});
diff --git a/data/ext/perspectiveOCRO/controller.js b/data/ext/perspectiveOCRO/controller.js
index 6b5c2c789..347a9c8f5 100644
--- a/data/ext/perspectiveOCRO/controller.js
+++ b/data/ext/perspectiveOCRO/controller.js
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2014 The TagSpaces Authors. All rights reserved.
+/* Copyright (c) 2014-2015 The TagSpaces Authors. All rights reserved.
* Use of this source code is governed by a AGPL3 license that
* can be found in the LICENSE file. */
/* global define, Handlebars */
diff --git a/data/ext/perspectiveOCRO/extension.js b/data/ext/perspectiveOCRO/extension.js
index 72615dd9a..d8d2f829b 100644
--- a/data/ext/perspectiveOCRO/extension.js
+++ b/data/ext/perspectiveOCRO/extension.js
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2014 The TagSpaces Authors. All rights reserved.
+/* Copyright (c) 2014-2015 The TagSpaces Authors. All rights reserved.
* Use of this source code is governed by a AGPL3 license that
* can be found in the LICENSE file. */
/* global define, Handlebars */
diff --git a/data/ext/perspectiveOCRO/templates.js b/data/ext/perspectiveOCRO/templates.js
index 6ed19cdd4..f9df6bfeb 100644
--- a/data/ext/perspectiveOCRO/templates.js
+++ b/data/ext/perspectiveOCRO/templates.js
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2014 The TagSpaces Authors. All rights reserved.
+/* Copyright (c) 2014-2015 The TagSpaces Authors. All rights reserved.
* Use of this source code is governed by a AGPL3 license that
* can be found in the LICENSE file. */
/* global define, Handlebars */
diff --git a/data/ext/viewerBrowser/extension.js b/data/ext/viewerBrowser/extension.js
index 8e9fc5766..e61fbf6e0 100644
--- a/data/ext/viewerBrowser/extension.js
+++ b/data/ext/viewerBrowser/extension.js
@@ -1,134 +1,130 @@
-/* Copyright (c) 2012-2014 The TagSpaces Authors. All rights reserved.
- * Use of this source code is governed by a AGPL3 license that
- * can be found in the LICENSE file. */
-
-define(function(require, exports, module) {
-"use strict";
-
- console.log("Loading viewerText");
-
- var extensionTitle = "IFrame Viewer";
- var extensionID = "viewerBrowser"; // ID should be equal to the directory name where the ext. is located
- var extensionType = "viewer";
- var extensionIcon = "icon-list";
- var extensionVersion = "1.0";
- var extensionManifestVersion = 1;
- var extensionLicense = "AGPL";
- var extensionSupportedFileTypes = [ "*" ];
-
- var TSCORE = require("tscore");
-
- var containerElID,
- $containerElement,
- currentFilePath;
-
- var extensionDirectory = TSCORE.Config.getExtensionPath()+"/"+extensionID;
-
- exports.init = function(filePath, containerElementID) {
- console.log("Initalization Text Viewer...");
- containerElID = containerElementID;
- $containerElement = $('#'+containerElID);
-
- currentFilePath = filePath;
-
- var filePathURI = undefined;
- if(isCordova || isWeb) {
- filePathURI = filePath;
- } else {
- filePathURI = "file:///"+filePath;
- }
-
- var fileExt = TSCORE.TagUtils.extractFileExtension(filePath);
-
- $containerElement.empty();
- $containerElement.css("background-color","white");
-
- if((fileExt.indexOf("htm") == 0 || fileExt.indexOf("xhtm") == 0 || fileExt.indexOf("txt") == 0) && !isFirefox) {
- $containerElement.append($('<iframe>', {
- sandbox: "allow-same-origin allow-scripts",
- id: "iframeViewer",
- "nwdisable": "",
- "nwfaketop": ""
- })
- );
- TSCORE.IO.loadTextFile(filePath);
- } else if(fileExt.indexOf("mht") == 0 && (isChrome || isNode)) {
- $containerElement.append($('<button>', {
- class: "btn btn-primary",
- style: "margin: 5px;",
- text: "Open in new window"
- }).click(function() {
- // if(isNode) {
- window.open(filePathURI,'_blank');
- // }
- })
- );
- $containerElement.append($('<div>', {
- class: "alert alert-info",
- style: "margin: 5px; font-size: 14px;",
- text: "For security reasons, opening of MHT files in iframes has been disabled in Chrome, so to open this MHT file, press the button above. This issue will be solved soon, with a custom MHT viewer."
- })
- );
- } else {
- $containerElement.append($('<iframe>', {
- // sandbox: "allow-same-origin allow-scripts", // comment out due not loading pdfs in chrome ext
- id: "iframeViewer",
- src: filePathURI,
- "nwdisable": "",
- "nwfaketop": ""
- })
- );
- }
- };
-
- exports.setFileType = function(fileType) {
- console.log("setFileType not supported on this extension");
- };
-
- exports.viewerMode = function(isViewerMode) {
- // set readonly
- };
-
- exports.setContent = function(content) {
- // removing the script tags from the content
- var cleanedContent = content.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"");
- var viewerIframe = $("#iframeViewer").get(0);
-
- var fileDirectory = TSCORE.TagUtils.extractContainingDirectoryPath(currentFilePath);
-
- if(viewerIframe != undefined) {
- viewerIframe.contentWindow.document.write(cleanedContent);
-
- // making all links open in the user default browser
- $(viewerIframe.contentWindow.document).find( "a" ).bind('click', function(e){
- e.preventDefault();
- TSCORE.openLinkExternally($(this).attr("href"));
- });
-
- // fixing embedding of local images
- $(viewerIframe.contentWindow.document).find( "img[src]").each(function(){
- var currentSrc = $( this ).attr("src");
- if(currentSrc.indexOf("http://") == 0 || currentSrc.indexOf("https://") == 0 || currentSrc.indexOf("data:") == 0) {
- // do nothing if src begins with http(s):// or data:
- } else {
- $( this ).attr("src","file://"+fileDirectory+TSCORE.dirSeparator+currentSrc);
- }
- });
- }
- };
-
- exports.getContent = function() {
- console.log("Not implemented");
- };
-
- // Extension Vars
- exports.Title = extensionTitle;
- exports.ID = extensionID;
- exports.Type = extensionType;
- exports.Icon = extensionIcon;
- exports.Version = extensionVersion;
- exports.ManifestVersion = extensionManifestVersion;
- exports.License = extensionLicense;
- exports.SupportedFileTypes = extensionSupportedFileTypes;
-
-});
\ No newline at end of file
+/* Copyright (c) 2013-2015 The TagSpaces Authors. All rights reserved.
+ * Use of this source code is governed by a AGPL3 license that
+ * can be found in the LICENSE file. */
+
+define(function(require, exports, module) {
+ "use strict";
+
+ console.log("Loading viewerText");
+
+ var extensionTitle = "IFrame Viewer";
+ var extensionID = "viewerBrowser"; // ID should be equal to the directory name where the ext. is located
+ var extensionType = "viewer";
+ var extensionIcon = "icon-list";
+ var extensionVersion = "1.0";
+ var extensionManifestVersion = 1;
+ var extensionLicense = "AGPL";
+ var extensionSupportedFileTypes = ["*"];
+
+ var TSCORE = require("tscore");
+
+ var containerElID,
+ $containerElement,
+ currentFilePath;
+
+ var extensionDirectory = TSCORE.Config.getExtensionPath() + "/" + extensionID;
+
+ exports.init = function(filePath, containerElementID) {
+ console.log("Initalization Text Viewer...");
+ containerElID = containerElementID;
+ $containerElement = $('#' + containerElID);
+
+ currentFilePath = filePath;
+
+ var filePathURI;
+ if (isCordova || isWeb) {
+ filePathURI = filePath;
+ } else {
+ filePathURI = "file:///" + filePath;
+ }
+
+ var fileExt = TSCORE.TagUtils.extractFileExtension(filePath);
+
+ $containerElement.empty();
+ $containerElement.css("background-color", "white");
+
+ if ((fileExt.indexOf("htm") === 0 || fileExt.indexOf("xhtm") === 0 || fileExt.indexOf("txt") === 0) && !isFirefox) {
+ $containerElement.append($('<iframe>', {
+ sandbox: "allow-same-origin allow-scripts",
+ id: "iframeViewer",
+ "nwdisable": "",
+ "nwfaketop": ""
+ }));
+ TSCORE.IO.loadTextFile(filePath);
+ } else if (fileExt.indexOf("mht") === 0 && (isChrome || isNode)) {
+ $containerElement.append($('<button>', {
+ class: "btn btn-primary",
+ style: "margin: 5px;",
+ text: "Open in new window"
+ }).click(function() {
+ // if(isNode) {
+ window.open(filePathURI, '_blank');
+ // }
+ }));
+ $containerElement.append($('<div>', {
+ class: "alert alert-info",
+ style: "margin: 5px; font-size: 14px;",
+ text: "For security reasons, opening of MHT files in iframes has been disabled in Chrome, so to open this MHT file, press the button above. This issue will be solved soon, with a custom MHT viewer."
+ }));
+ } else {
+ $containerElement.append($('<iframe>', {
+ // sandbox: "allow-same-origin allow-scripts", // comment out due not loading pdfs in chrome ext
+ id: "iframeViewer",
+ src: filePathURI,
+ "nwdisable": "",
+ "nwfaketop": ""
+ }));
+ }
+ };
+
+ exports.setFileType = function(fileType) {
+ console.log("setFileType not supported on this extension");
+ };
+
+ exports.viewerMode = function(isViewerMode) {
+ // set readonly
+ };
+
+ exports.setContent = function(content) {
+ // removing the script tags from the content
+ var cleanedContent = content.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, "");
+ var viewerIframe = $("#iframeViewer").get(0);
+
+ var fileDirectory = TSCORE.TagUtils.extractContainingDirectoryPath(currentFilePath);
+
+ if (viewerIframe !== undefined) {
+ viewerIframe.contentWindow.document.write(cleanedContent);
+
+ // making all links open in the user default browser
+ $(viewerIframe.contentWindow.document).find("a").bind('click', function(e) {
+ e.preventDefault();
+ TSCORE.openLinkExternally($(this).attr("href"));
+ });
+
+ // fixing embedding of local images
+ $(viewerIframe.contentWindow.document).find("img[src]").each(function() {
+ var currentSrc = $(this).attr("src");
+ if (currentSrc.indexOf("http://") === 0 || currentSrc.indexOf("https://") === 0 || currentSrc.indexOf("data:") === 0) {
+ // do nothing if src begins with http(s):// or data:
+ } else {
+ $(this).attr("src", "file://" + fileDirectory + TSCORE.dirSeparator + currentSrc);
+ }
+ });
+ }
+ };
+
+ exports.getContent = function() {
+ console.log("Not implemented");
+ };
+
+ // Extension Vars
+ exports.Title = extensionTitle;
+ exports.ID = extensionID;
+ exports.Type = extensionType;
+ exports.Icon = extensionIcon;
+ exports.Version = extensionVersion;
+ exports.ManifestVersion = extensionManifestVersion;
+ exports.License = extensionLicense;
+ exports.SupportedFileTypes = extensionSupportedFileTypes;
+
+});
diff --git a/data/ext/viewerHTML/extension.js b/data/ext/viewerHTML/extension.js
index 8b8388f56..89841a29d 100644
--- a/data/ext/viewerHTML/extension.js
+++ b/data/ext/viewerHTML/extension.js
@@ -1,173 +1,202 @@
-/* Copyright (c) 2012-2014 The TagSpaces Authors. All rights reserved.
- * Use of this source code is governed by a AGPL3 license that
+/* Copyright (c) 2012-2015 The TagSpaces Authors. All rights reserved.
+ * Use of this source code is governed by a AGPL3 license that
* can be found in the LICENSE file. */
define(function(require, exports, module) {
- "use strict";
-
- console.log("Loading viewerHTML");
-
- var extensionTitle = "HTML Viewer";
- var extensionID = "viewerHTML"; // ID should be equal to the directory name where the ext. is located
- var extensionType = "viewer";
- var extensionIcon = "icon-list";
- var extensionVersion = "1.0";
- var extensionManifestVersion = 1;
- var extensionLicense = "AGPL";
- var extensionSupportedFileTypes = [ "html", "htm" ];
-
- var TSCORE = require("tscore");
-
- var containerElID,
- $containerElement,
- currentFilePath,
- viewerToolbar,
- $iframeViewer;
-
- var extensionDirectory = TSCORE.Config.getExtensionPath()+"/"+extensionID;
-
- exports.init = function(filePath, containerElementID) {
- console.log("Initalization HTML Viewer...");
- containerElID = containerElementID;
- $containerElement = $('#'+containerElID);
-
- currentFilePath = filePath;
-
- //var fileExt = TSCORE.TagUtils.extractFileExtension(filePath);
-
- $containerElement.empty();
- $containerElement.css("background-color","white");
-
- $containerElement.append($('<iframe>', {
- sandbox: "allow-same-origin allow-scripts",
- id: "iframeViewer",
- "nwdisable": "",
- "nwfaketop": ""
- })
- );
-
- require([
- "text!"+extensionDirectory+'/mainUI.html'
- ], function(uiTPL) {
- var uiTemplate = Handlebars.compile( uiTPL );
- viewerToolbar = uiTemplate({ id: extensionID });
-
- TSCORE.IO.loadTextFile(filePath);
- });
- };
-
- // set readonly
- exports.setFileType = function(fileType) {
- console.log("setFileType not supported on this extension");
- };
-
- exports.viewerMode = function(isViewerMode) {
- };
-
- exports.setContent = function(content) {
- var cleanedContent = content.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"");
- $iframeViewer = $("#iframeViewer");
-
- var fileDirectory = TSCORE.TagUtils.extractContainingDirectoryPath(currentFilePath);
-
- if($iframeViewer != undefined) {
- var $iframeViewerHead = $iframeViewer.contents().find('head');
- $iframeViewerHead.append($('<link/>', { rel: 'stylesheet', href: extensionDirectory+'/extension.css' }));
- $iframeViewerHead.append($('<link/>', { rel: 'stylesheet', href: extensionDirectory+'/../../libs/bootstrap/css/bootstrap.css' }));
- $iframeViewerHead.append($('<link/>', { rel: 'stylesheet', href: extensionDirectory+'/../../libs/font-awesome/css/font-awesome.css' }));
- $iframeViewerHead.append($('<link/>', { rel: 'stylesheet', href: extensionDirectory+'/css/markdown.css' }));
- $iframeViewerHead.append($('<link/>', { rel: 'stylesheet', href: extensionDirectory+'/css/github.css' }));
- //$iframeViewerHead.append($('<link/>', { rel: 'stylesheet', href: extensionDirectory+'/css/haroopad.css' }));
- $iframeViewerHead.append($('<link/>', { rel: 'stylesheet', href: extensionDirectory+'/css/metro-vibes.css' }));
- $iframeViewerHead.append($('<link/>', { rel: 'stylesheet', href: extensionDirectory+'/css/solarized-dark.css' }));
- $iframeViewerHead.append($('<link/>', { rel: 'stylesheet', href: extensionDirectory+'/css/clearness.css' }));
- $iframeViewerHead.append($('<link/>', { rel: 'stylesheet', href: extensionDirectory+'/css/clearness-dark.css' }));
- //$iframeViewerHead.append($('<link/>', { rel: 'stylesheet', href: extensionDirectory+'/readability/readability.css' }));
- //$iframeViewerHead.append($('<script>', { type: 'text/javascript', src: extensionDirectory+'/readability/readability.js' }));
+ "use strict";
+
+ console.log("Loading viewerHTML");
+
+ var extensionTitle = "HTML Viewer";
+ var extensionID = "viewerHTML"; // ID should be equal to the directory name where the ext. is located
+ var extensionType = "viewer";
+ var extensionIcon = "icon-list";
+ var extensionVersion = "1.0";
+ var extensionManifestVersion = 1;
+ var extensionLicense = "AGPL";
+ var extensionSupportedFileTypes = ["html", "htm"];
+
+ var TSCORE = require("tscore");
+
+ var containerElID,
+ $containerElement,
+ currentFilePath,
+ viewerToolbar,
+ $iframeViewer;
+
+ var extensionDirectory = TSCORE.Config.getExtensionPath() + "/" + extensionID;
+
+ exports.init = function(filePath, containerElementID) {
+ console.log("Initalization HTML Viewer...");
+ containerElID = containerElementID;
+ $containerElement = $('#' + containerElID);
+
+ currentFilePath = filePath;
+
+ //var fileExt = TSCORE.TagUtils.extractFileExtension(filePath);
+
+ $containerElement.empty();
+ $containerElement.css("background-color", "white");
+
+ $containerElement.append($('<iframe>', {
+ sandbox: "allow-same-origin allow-scripts",
+ id: "iframeViewer",
+ "nwdisable": "",
+ "nwfaketop": ""
+ }));
+
+ require([
+ "text!" + extensionDirectory + '/mainUI.html'
+ ], function(uiTPL) {
+ var uiTemplate = Handlebars.compile(uiTPL);
+ viewerToolbar = uiTemplate({
+ id: extensionID
+ });
+
+ TSCORE.IO.loadTextFile(filePath);
+ });
+ };
+
+ // set readonly
+ exports.setFileType = function(fileType) {
+ console.log("setFileType not supported on this extension");
+ };
+
+ exports.viewerMode = function(isViewerMode) {};
+
+ exports.setContent = function(content) {
+ var cleanedContent = content.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, "");
+ $iframeViewer = $("#iframeViewer");
+
+ var fileDirectory = TSCORE.TagUtils.extractContainingDirectoryPath(currentFilePath);
+
+ if ($iframeViewer !== undefined) {
+ var $iframeViewerHead = $iframeViewer.contents().find('head');
+ $iframeViewerHead.append($('<link/>', {
+ rel: 'stylesheet',
+ href: extensionDirectory + '/extension.css'
+ }));
+ $iframeViewerHead.append($('<link/>', {
+ rel: 'stylesheet',
+ href: extensionDirectory + '/../../libs/bootstrap/css/bootstrap.css'
+ }));
+ $iframeViewerHead.append($('<link/>', {
+ rel: 'stylesheet',
+ href: extensionDirectory + '/../../libs/font-awesome/css/font-awesome.css'
+ }));
+ $iframeViewerHead.append($('<link/>', {
+ rel: 'stylesheet',
+ href: extensionDirectory + '/css/markdown.css'
+ }));
+ $iframeViewerHead.append($('<link/>', {
+ rel: 'stylesheet',
+ href: extensionDirectory + '/css/github.css'
+ }));
+ //$iframeViewerHead.append($('<link/>', { rel: 'stylesheet', href: extensionDirectory+'/css/haroopad.css' }));
+ $iframeViewerHead.append($('<link/>', {
+ rel: 'stylesheet',
+ href: extensionDirectory + '/css/metro-vibes.css'
+ }));
+ $iframeViewerHead.append($('<link/>', {
+ rel: 'stylesheet',
+ href: extensionDirectory + '/css/solarized-dark.css'
+ }));
+ $iframeViewerHead.append($('<link/>', {
+ rel: 'stylesheet',
+ href: extensionDirectory + '/css/clearness.css'
+ }));
+ $iframeViewerHead.append($('<link/>', {
+ rel: 'stylesheet',
+ href: extensionDirectory + '/css/clearness-dark.css'
+ }));
+ //$iframeViewerHead.append($('<link/>', { rel: 'stylesheet', href: extensionDirectory+'/readability/readability.css' }));
+ //$iframeViewerHead.append($('<script>', { type: 'text/javascript', src: extensionDirectory+'/readability/readability.js' }));
+ }
+
+ var styles = ['', 'solarized-dark', 'github', 'metro-vibes', 'clearness', 'clearness-dark'];
+ var currentStyleIndex = 0;
+
+ var zoomSteps = ['zoomSmallest', 'zoomSmaller', 'zoomSmall', 'zoomDefault', 'zoomLarge', 'zoomLarger', 'zoomLargest'];
+ var currentZoomState = 3;
+
+ if ($iframeViewer !== undefined) {
+ var $iframeViewerBody = $iframeViewer.contents().find('body');
+ $iframeViewerBody.children().remove();
+ $iframeViewerBody.append($('<div/>', {
+ id: 'htmlContent'
+ }).append(cleanedContent));
+ $iframeViewerBody.append(viewerToolbar);
+
+ if (isCordova) {
+ $iframeViewerBody.find("#printButton").hide();
+ }
+
+ var $iframeHTMLContent = $iframeViewer.contents().find('#htmlContent');
+
+ $iframeViewerBody.find("#changeStyleButton").bind('click', function() {
+ currentStyleIndex = currentStyleIndex + 1;
+ if (currentStyleIndex >= styles.length) {
+ currentStyleIndex = 0;
}
-
- var styles = ['','solarized-dark','github','metro-vibes','clearness','clearness-dark'];
- var currentStyleIndex = 0;
-
- var zoomSteps = ['zoomSmallest','zoomSmaller','zoomSmall','zoomDefault','zoomLarge','zoomLarger','zoomLargest'];
- var currentZoomState = 3;
-
- if($iframeViewer != undefined) {
- var $iframeViewerBody = $iframeViewer.contents().find('body');
- $iframeViewerBody.children().remove();
- $iframeViewerBody.append($('<div/>', { id: 'htmlContent' }).append(cleanedContent));
- $iframeViewerBody.append(viewerToolbar);
-
- if(isCordova) {
- $iframeViewerBody.find( "#printButton").hide();
- }
-
- var $iframeHTMLContent = $iframeViewer.contents().find('#htmlContent');
-
- $iframeViewerBody.find( "#changeStyleButton" ).bind('click', function(){
- currentStyleIndex = currentStyleIndex + 1;
- if(currentStyleIndex >= styles.length) {
- currentStyleIndex = 0;
- }
- $iframeViewerBody.css("padding","0");
- $iframeViewerBody.css("margin","0");
- $iframeHTMLContent.removeClass();
- $iframeHTMLContent.addClass('markdown');
- $iframeHTMLContent.addClass(styles[currentStyleIndex]);
- });
-
- $iframeViewerBody.find( "#zoomInButton" ).bind('click', function(){
- currentZoomState++;
- if(currentZoomState >= zoomSteps.length) {
- currentZoomState = 6;
- }
- $iframeHTMLContent.removeClass();
- $iframeHTMLContent.addClass('markdown '+styles[currentStyleIndex]+" "+zoomSteps[currentZoomState]);
- });
-
- $iframeViewerBody.find( "#zoomOutButton" ).bind('click', function(){
- currentZoomState--;
- if(currentZoomState < 0) {
- currentZoomState = 0;
- }
- $iframeHTMLContent.removeClass();
- $iframeHTMLContent.addClass('markdown '+styles[currentStyleIndex]+" "+zoomSteps[currentZoomState]);
- });
-
- $iframeViewerBody.find( "#printButton" ).bind('click', function(){
- document.getElementById("iframeViewer").contentWindow.print();
- });
-
- // making all links open in the user default browser
- $iframeViewerBody.find( "a" ).bind('click', function(e){
- e.preventDefault();
- TSCORE.openLinkExternally($(this).attr("href"));
- });
-
- // fixing embedding of local images
- $iframeViewerBody.find( "img[src]").each(function(){
- var currentSrc = $( this ).attr("src");
- if(currentSrc.indexOf("http://") == 0 || currentSrc.indexOf("https://") == 0 || currentSrc.indexOf("data:") == 0) {
- // do nothing if src begins with http(s):// or data:
- } else {
- $( this ).attr("src","file://"+fileDirectory+TSCORE.dirSeparator+currentSrc);
- }
- });
+ $iframeViewerBody.css("padding", "0");
+ $iframeViewerBody.css("margin", "0");
+ $iframeHTMLContent.removeClass();
+ $iframeHTMLContent.addClass('markdown');
+ $iframeHTMLContent.addClass(styles[currentStyleIndex]);
+ });
+
+ $iframeViewerBody.find("#zoomInButton").bind('click', function() {
+ currentZoomState++;
+ if (currentZoomState >= zoomSteps.length) {
+ currentZoomState = 6;
+ }
+ $iframeHTMLContent.removeClass();
+ $iframeHTMLContent.addClass('markdown ' + styles[currentStyleIndex] + " " + zoomSteps[currentZoomState]);
+ });
+
+ $iframeViewerBody.find("#zoomOutButton").bind('click', function() {
+ currentZoomState--;
+ if (currentZoomState < 0) {
+ currentZoomState = 0;
+ }
+ $iframeHTMLContent.removeClass();
+ $iframeHTMLContent.addClass('markdown ' + styles[currentStyleIndex] + " " + zoomSteps[currentZoomState]);
+ });
+
+ $iframeViewerBody.find("#printButton").bind('click', function() {
+ document.getElementById("iframeViewer").contentWindow.print();
+ });
+
+ // making all links open in the user default browser
+ $iframeViewerBody.find("a").bind('click', function(e) {
+ e.preventDefault();
+ TSCORE.openLinkExternally($(this).attr("href"));
+ });
+
+ // fixing embedding of local images
+ $iframeViewerBody.find("img[src]").each(function() {
+ var currentSrc = $(this).attr("src");
+ if (currentSrc.indexOf("http://") === 0 || currentSrc.indexOf("https://") === 0 || currentSrc.indexOf("data:") === 0) {
+ // do nothing if src begins with http(s):// or data:
+ } else {
+ $(this).attr("src", "file://" + fileDirectory + TSCORE.dirSeparator + currentSrc);
}
- };
-
- exports.getContent = function() {
- console.log("Not implemented");
- };
-
- // Extension Vars
- exports.Title = extensionTitle;
- exports.ID = extensionID;
- exports.Type = extensionType;
- exports.Icon = extensionIcon;
- exports.Version = extensionVersion;
- exports.ManifestVersion = extensionManifestVersion;
- exports.License = extensionLicense;
- exports.SupportedFileTypes = extensionSupportedFileTypes;
-
-});
\ No newline at end of file
+ });
+ }
+ };
+
+ exports.getContent = function() {
+ console.log("Not implemented");
+ };
+
+ // Extension Vars
+ exports.Title = extensionTitle;
+ exports.ID = extensionID;
+ exports.Type = extensionType;
+ exports.Icon = extensionIcon;
+ exports.Version = extensionVersion;
+ exports.ManifestVersion = extensionManifestVersion;
+ exports.License = extensionLicense;
+ exports.SupportedFileTypes = extensionSupportedFileTypes;
+
+});
diff --git a/data/ext/viewerImage/extension.js b/data/ext/viewerImage/extension.js
index 910caf82a..078869ff1 100644
--- a/data/ext/viewerImage/extension.js
+++ b/data/ext/viewerImage/extension.js
@@ -1,110 +1,73 @@
-/* Copyright (c) 2013 The Tagspaces Authors. All rights reserved.
- * Use of this source code is governed by a AGPL3 license that
- * can be found in the LICENSE file. */
-
-define(function(require, exports, module) {
-"use strict";
-
- console.log("Loading viewerImage");
-
- var extensionTitle = "Image Viewer";
- var extensionID = "viewerImage"; // ID should be equal to the directory name where the ext. is located
- var extensionType = "viewer";
- var extensionIcon = "icon-list";
- var extensionVersion = "1.0";
- var extensionManifestVersion = 1;
- var extensionLicense = "AGPL";
- var extensionSupportedFileTypes = [ "jpeg", "jpg", "png", "gif", "bmp", "ico", "webp" ];
-
- var TSCORE = require("tscore");
-
- var extensionDirectory = TSCORE.Config.getExtensionPath()+"/"+extensionID;
- var UI;
-
- var currentFilePath,
- $containerElement;
-
- exports.init = function(filePath, elementID) {
- console.log("Initalization Browser Image Viewer...");
-
- $containerElement = $('#'+elementID);
- currentFilePath = filePath;
-
- $containerElement.append($('<iframe>', {
- id: "iframeViewer",
- sandbox: "allow-same-origin allow-scripts",
- scrolling: "no",
- src: extensionDirectory+"/index.html?cp="+filePath,
- "nwdisable": "",
- "nwfaketop": ""
- }));
-
- /* $("#iframeViewer")
- .hammer().on("swipeleft", function() {
- TSCORE.FileOpener.openFile(TSCORE.PerspectiveManager.getNextFile(internPath));
- })
- .hammer().on("swiperight", function() {
- TSCORE.FileOpener.openFile(TSCORE.PerspectiveManager.getPrevFile(internPath));
- }); */
-
- /*require([
- extensionDirectory+'/viewerUI.js',
- "text!"+extensionDirectory+'/mainUI.html',
- 'css!'+extensionDirectory+'/extension.css',
- //extensionDirectory+'/loadimage/canvas-to-blob.js',
- extensionDirectory+'/jquery.panzoom/jquery.panzoom.min.js',
- extensionDirectory+'/jquery.mousewheel/jquery.mousewheel.js'
- ], function(extUI, uiTPL) {
- //extensionDirectory+'/pixastic/pixastic.custom.js',
- var uiTemplate = Handlebars.compile( uiTPL );
- UI = new extUI.ExtUI(extensionID, elementID, filePath, uiTemplate);
-
- // TODO remove tmp solution for memory leak prevention
- UI = null;
- /*
- loadImage(
- filePath,
- function (img) {
- img.toBlob(
- function (blob) {
- loadImage.parseMetaData(blob, function (data) {
- console.log("EXIF: "+data.exif);
- if (data.exif) {
- options.orientation = data.exif.get('Orientation');
- displayExifData(data.exif);
- }
- });
- },
- 'image/jpeg'
- );
- },
- {
- maxWidth: 600,maxHeight: 300,minWidth: 100,minHeight: 50,canvas: true
- }
- ); */
- //});
- };
-
- exports.viewerMode = function(isViewerMode) {
- console.log("viewerMode not supported on this extension");
- };
-
- exports.setContent = function(content) {
- console.log("setContent not supported on this extension");
- };
-
- exports.getContent = function() {
- console.log("getContent not supported on this extension");
- };
-
- // Extension Vars
- exports.Title = extensionTitle;
- exports.ID = extensionID;
- exports.Type = extensionType;
- exports.Icon = extensionIcon;
- exports.Version = extensionVersion;
- exports.ManifestVersion = extensionManifestVersion;
- exports.License = extensionLicense;
- exports.SupportedFileTypes = extensionSupportedFileTypes;
-
-});
\ No newline at end of file
+/* Copyright (c) 2013 The Tagspaces Authors. All rights reserved.
+ * Use of this source code is governed by a AGPL3 license that
+ * can be found in the LICENSE file. */
+
+define(function(require, exports, module) {
+ "use strict";
+
+ console.log("Loading viewerImage");
+
+ var extensionTitle = "Image Viewer";
+ var extensionID = "viewerImage"; // ID should be equal to the directory name where the ext. is located
+ var extensionType = "viewer";
+ var extensionIcon = "icon-list";
+ var extensionVersion = "1.0";
+ var extensionManifestVersion = 1;
+ var extensionLicense = "AGPL";
+ var extensionSupportedFileTypes = ["jpeg", "jpg", "png", "gif", "bmp", "ico", "webp"];
+
+ var TSCORE = require("tscore");
+
+ var extensionDirectory = TSCORE.Config.getExtensionPath() + "/" + extensionID;
+ var UI;
+
+ var currentFilePath,
+ $containerElement;
+
+ exports.init = function(filePath, elementID) {
+ console.log("Initalization Browser Image Viewer...");
+
+ $containerElement = $('#' + elementID);
+ currentFilePath = filePath;
+
+ $containerElement.append($('<iframe>', {
+ id: "iframeViewer",
+ sandbox: "allow-same-origin allow-scripts",
+ scrolling: "no",
+ src: extensionDirectory + "/index.html?cp=" + filePath,
+ "nwdisable": "",
+ "nwfaketop": ""
+ }));
+
+ /* $("#iframeViewer")
+ .hammer().on("swipeleft", function() {
+ TSCORE.FileOpener.openFile(TSCORE.PerspectiveManager.getNextFile(internPath));
+ })
+ .hammer().on("swiperight", function() {
+ TSCORE.FileOpener.openFile(TSCORE.PerspectiveManager.getPrevFile(internPath));
+ }); */
+ };
+
+ exports.viewerMode = function(isViewerMode) {
+ console.log("viewerMode not supported on this extension");
+ };
+
+ exports.setContent = function(content) {
+ console.log("setContent not supported on this extension");
+ };
+
+ exports.getContent = function() {
+ console.log("getContent not supported on this extension");
+ };
+
+ // Extension Vars
+ exports.Title = extensionTitle;
+ exports.ID = extensionID;
+ exports.Type = extensionType;
+ exports.Icon = extensionIcon;
+ exports.Version = extensionVersion;
+ exports.ManifestVersion = extensionManifestVersion;
+ exports.License = extensionLicense;
+ exports.SupportedFileTypes = extensionSupportedFileTypes;
+
+});
diff --git a/data/ext/viewerImage/viewer.js b/data/ext/viewerImage/viewer.js
index b1fb5f953..f26aad754 100644
--- a/data/ext/viewerImage/viewer.js
+++ b/data/ext/viewerImage/viewer.js
@@ -1,153 +1,154 @@
-/* Copyright (c) 2012-2014 The TagSpaces Authors. All rights reserved.
- * Use of this source code is governed by a AGPL3 license that
+/* Copyright (c) 2012-2015 The TagSpaces Authors. All rights reserved.
+ * Use of this source code is governed by a AGPL3 license that
* can be found in the LICENSE file. */
-/* global define, isCordova */
+/* global define, EXIF */
+"use strict";
$(document).ready(function() {
- function getParameterByName(name) {
- name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
- var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
- results = regex.exec(location.search);
- return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
- }
+ function getParameterByName(name) {
+ name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
+ var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
+ results = regex.exec(location.search);
+ return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
+ }
- var filePath = getParameterByName("cp");
- /*$.ajax({
- url: fileURL,//"file://"+filePath,
- type: 'POST'
- })
- .done(function(data) {
- cleanContent(data);
- })
- .fail(function(data) {
- console.log("AJAX failed "+data);
- }); */
+ var filePath = getParameterByName("cp");
+ /*$.ajax({
+ url: fileURL,//"file://"+filePath,
+ type: 'POST'
+ })
+ .done(function(data) {
+ cleanContent(data);
+ })
+ .fail(function(data) {
+ console.log("AJAX failed "+data);
+ }); */
- var imageRotationClass = "";
- var isCordova = document.URL.indexOf( 'file:///android_asset' ) === 0;
- var isWeb = document.URL.indexOf( 'http' ) === 0;
+ var imageRotationClass = "";
+ var isCordova = document.URL.indexOf('file:///android_asset') === 0;
+ var isWeb = document.URL.indexOf('http') === 0;
- if(isCordova || isWeb) {
+ if (isCordova || isWeb) {
- } else {
- filePath = "file://"+filePath;
- }
+ } else {
+ filePath = "file://" + filePath;
+ }
- var $imgViewer = $("#imgViewer");
+ var $imgViewer = $("#imgViewer");
- $("#imageContent")
- .attr("src",filePath)
- .bind("load",function() {
- $(this).addClass("transparentImageBackground");
- $imgViewer.addClass("imgViewer");
- if(filePath.toLowerCase().indexOf("jpg") === (filePath.length-3) ||
- filePath.toLowerCase().indexOf("jpeg") === (filePath.length-4)) {
- EXIF.getData(this, function() {
- var orientation = EXIF.getTag(this, "Orientation");
- correctOrientation(orientation);
- //console.log(EXIF.pretty(this));
- });
- }
+ $("#imageContent")
+ .attr("src", filePath)
+ .bind("load", function() {
+ $(this).addClass("transparentImageBackground");
+ $imgViewer.addClass("imgViewer");
+ if (filePath.toLowerCase().indexOf("jpg") === (filePath.length - 3) ||
+ filePath.toLowerCase().indexOf("jpeg") === (filePath.length - 4)) {
+ EXIF.getData(this, function() {
+ var orientation = EXIF.getTag(this, "Orientation");
+ correctOrientation(orientation);
+ //console.log(EXIF.pretty(this));
});
+ }
+ });
- $imgViewer
- .panzoom({
- $zoomIn: $("#zoomInButton"),
- $zoomOut: $("#zoomOutButton"),
- $reset: $("#zoomResetButton"),
- minScale: 0.1,
- maxScale: 10,
- increment: 0.2,
- easing: "ease-in-out",
- contain: 'invert'
- })
- .parent().on('mousewheel.focal', function(e){
- e.preventDefault();
- var delta = e.delta || e.originalEvent.wheelDelta;
- var zoomOut = delta ? delta < 0 : e.originalEvent.deltaY > 0;
- $imgViewer.panzoom('zoom', zoomOut, {
- increment: 0.1,
- focal: e,
- animate: false
- });
- });
+ $imgViewer
+ .panzoom({
+ $zoomIn: $("#zoomInButton"),
+ $zoomOut: $("#zoomOutButton"),
+ $reset: $("#zoomResetButton"),
+ minScale: 0.1,
+ maxScale: 10,
+ increment: 0.2,
+ easing: "ease-in-out",
+ contain: 'invert'
+ })
+ .parent().on('mousewheel.focal', function(e) {
+ e.preventDefault();
+ var delta = e.delta || e.originalEvent.wheelDelta;
+ var zoomOut = delta ? delta < 0 : e.originalEvent.deltaY > 0;
+ $imgViewer.panzoom('zoom', zoomOut, {
+ increment: 0.1,
+ focal: e,
+ animate: false
+ });
+ });
- function correctOrientation(orientation) {
- var $image = $("#imageContent");
- $image.removeClass(imageRotationClass);
- console.log("ORIENTATION: "+orientation);
- switch (orientation) {
- case 8:
- imageRotationClass = "rotate270";
- break;
- case 3:
- imageRotationClass = "rotate180";
- break;
- case 6:
- imageRotationClass = "rotate90";
- break;
- case 1:
- imageRotationClass = "";
- break;
- default:
- imageRotationClass = "";
- }
- $image.addClass(imageRotationClass);
+ function correctOrientation(orientation) {
+ var $image = $("#imageContent");
+ $image.removeClass(imageRotationClass);
+ console.log("ORIENTATION: " + orientation);
+ switch (orientation) {
+ case 8:
+ imageRotationClass = "rotate270";
+ break;
+ case 3:
+ imageRotationClass = "rotate180";
+ break;
+ case 6:
+ imageRotationClass = "rotate90";
+ break;
+ case 1:
+ imageRotationClass = "";
+ break;
+ default:
+ imageRotationClass = "";
}
+ $image.addClass(imageRotationClass);
+ }
- $("#rotateLeftButton").on("click",function() {
- //console.log("Rotate Left");
- var $image = $("#imageContent");
- $image.removeClass(imageRotationClass);
- switch (imageRotationClass) {
- case "":
- imageRotationClass = "rotate270";
- break;
- case "rotate270":
- imageRotationClass = "rotate180";
- break;
- case "rotate180":
- imageRotationClass = "rotate90";
- break;
- case "rotate90":
- imageRotationClass = "";
- break;
- default:
- imageRotationClass = "";
- }
- $image.addClass(imageRotationClass);
- });
+ $("#rotateLeftButton").on("click", function() {
+ //console.log("Rotate Left");
+ var $image = $("#imageContent");
+ $image.removeClass(imageRotationClass);
+ switch (imageRotationClass) {
+ case "":
+ imageRotationClass = "rotate270";
+ break;
+ case "rotate270":
+ imageRotationClass = "rotate180";
+ break;
+ case "rotate180":
+ imageRotationClass = "rotate90";
+ break;
+ case "rotate90":
+ imageRotationClass = "";
+ break;
+ default:
+ imageRotationClass = "";
+ }
+ $image.addClass(imageRotationClass);
+ });
- $("#rotateRightButton").on("click",function() {
- //console.log("Rotate Right");
- var $image = $("#imageContent");
- $image.removeClass(imageRotationClass);
- switch (imageRotationClass) {
- case "":
- imageRotationClass = "rotate90";
- break;
- case "rotate90":
- imageRotationClass = "rotate180";
- break;
- case "rotate180":
- imageRotationClass = "rotate270";
- break;
- case "rotate270":
- imageRotationClass = "";
- break;
- default:
- imageRotationClass = "";
- }
- $image.addClass(imageRotationClass);
- });
+ $("#rotateRightButton").on("click", function() {
+ //console.log("Rotate Right");
+ var $image = $("#imageContent");
+ $image.removeClass(imageRotationClass);
+ switch (imageRotationClass) {
+ case "":
+ imageRotationClass = "rotate90";
+ break;
+ case "rotate90":
+ imageRotationClass = "rotate180";
+ break;
+ case "rotate180":
+ imageRotationClass = "rotate270";
+ break;
+ case "rotate270":
+ imageRotationClass = "";
+ break;
+ default:
+ imageRotationClass = "";
+ }
+ $image.addClass(imageRotationClass);
+ });
- $("#printButton").on("click",function() {
- window.print();
- });
+ $("#printButton").on("click", function() {
+ window.print();
+ });
- if(isCordova) {
- $("#zoomInButton").hide();
- $("#zoomOutButton").hide();
- $("#printButton").hide();
- }
-});
\ No newline at end of file
+ if (isCordova) {
+ $("#zoomInButton").hide();
+ $("#zoomOutButton").hide();
+ $("#printButton").hide();
+ }
+});
diff --git a/data/ext/viewerMD/extension.js b/data/ext/viewerMD/extension.js
index f4b723a0f..e68908468 100644
--- a/data/ext/viewerMD/extension.js
+++ b/data/ext/viewerMD/extension.js
@@ -1,202 +1,233 @@
-/* Copyright (c) 2012-2013 The TagSpaces Authors. All rights reserved.
- * Use of this source code is governed by a AGPL3 license that
- * can be found in the LICENSE file. */
-
-define(function(require, exports, module) {
-"use strict";
-
- console.log("Loading viewerMD");
-
- var extensionTitle = "MardDown Viewer";
- var extensionID = "viewerMD"; // ID should be equal to the directory name where the ext. is located
- var extensionType = "viewer";
- var extensionIcon = "icon-list";
- var extensionVersion = "1.0";
- var extensionManifestVersion = 1;
- var extensionLicense = "AGPL";
- var extensionSupportedFileTypes = [ "md", "markdown", "mdown" ];
-
- var TSCORE = require("tscore");
-
- var md2htmlConverter,
- containerElID,
- currentFilePath,
- $iframeViewer,
- $iframeViewerBody,
- $containerElement,
- viewerToolbar;
-
- var extensionDirectory = TSCORE.Config.getExtensionPath()+"/"+extensionID;
-
- // GFM https://help.github.com/articles/github-flavored-markdown
-
- exports.init = function(filePath, containerElementID) {
- console.log("Initalization MD Viewer...");
- containerElID = containerElementID;
-
- $containerElement = $('#'+containerElID);
-
- currentFilePath = filePath;
-
- //var fileExt = TSCORE.TagUtils.extractFileExtension(filePath);
-
- $containerElement.empty();
- $containerElement.css("background-color","white");
-
- $containerElement.append($('<iframe>', {
- sandbox: "allow-same-origin allow-scripts",
- id: "iframeViewer",
- "nwdisable": "",
- "nwfaketop": ""
- })
- );
-
- require([
- extensionDirectory+'/marked/marked.js',
- "text!"+extensionDirectory+'/mainUI.html'
- ], function(marked, uiTPL) {
- md2htmlConverter = marked;
- md2htmlConverter.setOptions({
- renderer: new marked.Renderer(),
- //highlight: function (code) {
- // //return require([extensionDirectory+'/highlightjs/highlight.js']).highlightAuto(code).value;
- //},
- gfm: true,
- tables: true,
- breaks: false,
- pedantic: false,
- smartLists: true,
- smartypants: false
- });
-
- var uiTemplate = Handlebars.compile( uiTPL );
- viewerToolbar = uiTemplate({ id: extensionID });
-
- $iframeViewer = $("#iframeViewer");
- $iframeViewerBody = $iframeViewer.contents().find('body');
-
- TSCORE.IO.loadTextFile(filePath);
- });
- };
-
- exports.setFileType = function() {
- console.log("setFileType not supported on this extension");
- };
-
- exports.viewerMode = function(isViewerMode) {
- // set readonly
- };
-
- exports.setContent = function(content) {
- var UTF8_BOM = "\ufeff";
-
- // removing the UTF8 bom because it brakes thing like #header1 in the beginning of the document
- if(content.indexOf(UTF8_BOM) === 0) {
- content = content.substring(1,content.length);
- }
-
- var fileDirectory = TSCORE.TagUtils.extractContainingDirectoryPath(currentFilePath);
-
- var cleanedContent = content.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"");
- var mdContent = md2htmlConverter(cleanedContent);
-
- var styles = ['','solarized-dark','github','metro-vibes','clearness','clearness-dark'];
- var currentStyleIndex = 0;
-
- var zoomSteps = ['zoomSmallest','zoomSmaller','zoomSmall','zoomDefault','zoomLarge','zoomLarger','zoomLargest'];
- var currentZoomState = 3;
-
- if($iframeViewer != undefined) {
- var $iframeViewerHead = $iframeViewer.contents().find('head');
- $iframeViewerHead.append($('<link/>', { rel: 'stylesheet', href: extensionDirectory+'/extension.css' }));
- $iframeViewerHead.append($('<link/>', { rel: 'stylesheet', href: extensionDirectory+'/../../libs/bootstrap/css/bootstrap.css' }));
- $iframeViewerHead.append($('<link/>', { rel: 'stylesheet', href: extensionDirectory+'/../../libs/font-awesome/css/font-awesome.css' }));
- $iframeViewerHead.append($('<link/>', { rel: 'stylesheet', href: extensionDirectory+'/css/markdown.css' }));
- $iframeViewerHead.append($('<link/>', { rel: 'stylesheet', href: extensionDirectory+'/css/github.css' }));
- //$iframeViewerHead.append($('<link/>', { rel: 'stylesheet', href: extensionDirectory+'/css/haroopad.css' }));
- $iframeViewerHead.append($('<link/>', { rel: 'stylesheet', href: extensionDirectory+'/css/metro-vibes.css' }));
- $iframeViewerHead.append($('<link/>', { rel: 'stylesheet', href: extensionDirectory+'/css/solarized-dark.css' }));
- $iframeViewerHead.append($('<link/>', { rel: 'stylesheet', href: extensionDirectory+'/css/clearness.css' }));
- $iframeViewerHead.append($('<link/>', { rel: 'stylesheet', href: extensionDirectory+'/css/clearness-dark.css' }));
-
- $iframeViewerBody.children().remove();
- $iframeViewerBody.append($('<div/>', { id: 'viewerContent', class: "markdown" }).append(mdContent));
- $iframeViewerBody.append(viewerToolbar);
-
- if(isCordova) {
- $iframeViewerBody.find( "#printButton").hide();
- }
-
- var $viewerContent = $iframeViewer.contents().find('#viewerContent');
-
- $iframeViewerBody.find( "#changeStyleButton" ).bind('click', function(){
- currentStyleIndex = currentStyleIndex + 1;
- if(currentStyleIndex >= styles.length) {
- currentStyleIndex = 0;
- }
- $viewerContent.removeClass();
- $viewerContent.addClass('markdown '+styles[currentStyleIndex]+" "+zoomSteps[currentZoomState]);
- });
-
- $iframeViewerBody.find( "#zoomInButton" ).bind('click', function(e){
- currentZoomState++;
- if(currentZoomState >= zoomSteps.length) {
- currentZoomState = 6;
- }
- $viewerContent.removeClass();
- $viewerContent.addClass('markdown '+styles[currentStyleIndex]+" "+zoomSteps[currentZoomState]);
- });
-
- $iframeViewerBody.find( "#zoomOutButton" ).bind('click', function(e){
- currentZoomState--;
- if(currentZoomState < 0) {
- currentZoomState = 0;
- }
- $viewerContent.removeClass();
- $viewerContent.addClass('markdown '+styles[currentStyleIndex]+" "+zoomSteps[currentZoomState]);
- });
-
- $iframeViewerBody.find( "#zoomResetButton" ).bind('click', function(e){
- currentZoomState = 3;
- $viewerContent.removeClass();
- $viewerContent.addClass('markdown '+styles[currentStyleIndex]+" "+zoomSteps[currentZoomState]);
- });
-
- $iframeViewerBody.find( "#printButton" ).bind('click', function(e){
- //document.getElementById("iframeViewer").contentWindow.print();
- $iframeViewer.get(0).contentWindow.print();
- });
-
- // making all links open in the user default browser
- $iframeViewerBody.find( "a" ).bind('click', function(e){
- e.preventDefault();
- TSCORE.openLinkExternally($(this).attr("href"));
- });
-
- // fixing embedding of local images
- $iframeViewerBody.find( "img[src]").each(function(){
- var currentSrc = $( this ).attr("src");
- if(currentSrc.indexOf("http://") == 0 || currentSrc.indexOf("https://") == 0 || currentSrc.indexOf("data:") == 0) {
- // do nothing if src begins with http(s):// or data:
- } else {
- $( this ).attr("src","file://"+fileDirectory+TSCORE.dirSeparator+currentSrc);
- }
- });
- }
- };
-
- exports.getContent = function() {
- //$('#'+containerElID).html();
- };
-
- // Extension Vars
- exports.Title = extensionTitle;
- exports.ID = extensionID;
- exports.Type = extensionType;
- exports.Icon = extensionIcon;
- exports.Version = extensionVersion;
- exports.ManifestVersion = extensionManifestVersion;
- exports.License = extensionLicense;
- exports.SupportedFileTypes = extensionSupportedFileTypes;
-
-});
\ No newline at end of file
+/* Copyright (c) 2012-2015 The TagSpaces Authors. All rights reserved.
+ * Use of this source code is governed by a AGPL3 license that
+ * can be found in the LICENSE file. */
+
+define(function(require, exports, module) {
+ "use strict";
+
+ console.log("Loading viewerMD");
+
+ var extensionTitle = "MardDown Viewer";
+ var extensionID = "viewerMD"; // ID should be equal to the directory name where the ext. is located
+ var extensionType = "viewer";
+ var extensionIcon = "icon-list";
+ var extensionVersion = "1.0";
+ var extensionManifestVersion = 1;
+ var extensionLicense = "AGPL";
+ var extensionSupportedFileTypes = ["md", "markdown", "mdown"];
+
+ var TSCORE = require("tscore");
+
+ var md2htmlConverter,
+ containerElID,
+ currentFilePath,
+ $iframeViewer,
+ $iframeViewerBody,
+ $containerElement,
+ viewerToolbar;
+
+ var extensionDirectory = TSCORE.Config.getExtensionPath() + "/" + extensionID;
+
+ // GFM https://help.github.com/articles/github-flavored-markdown
+
+ exports.init = function(filePath, containerElementID) {
+ console.log("Initalization MD Viewer...");
+ containerElID = containerElementID;
+
+ $containerElement = $('#' + containerElID);
+
+ currentFilePath = filePath;
+
+ //var fileExt = TSCORE.TagUtils.extractFileExtension(filePath);
+
+ $containerElement.empty();
+ $containerElement.css("background-color", "white");
+
+ $containerElement.append($('<iframe>', {
+ sandbox: "allow-same-origin allow-scripts",
+ id: "iframeViewer",
+ "nwdisable": "",
+ "nwfaketop": ""
+ }));
+
+ require([
+ extensionDirectory + '/marked/marked.js',
+ "text!" + extensionDirectory + '/mainUI.html'
+ ], function(marked, uiTPL) {
+ md2htmlConverter = marked;
+ md2htmlConverter.setOptions({
+ renderer: new marked.Renderer(),
+ //highlight: function (code) {
+ // //return require([extensionDirectory+'/highlightjs/highlight.js']).highlightAuto(code).value;
+ //},
+ gfm: true,
+ tables: true,
+ breaks: false,
+ pedantic: false,
+ smartLists: true,
+ smartypants: false
+ });
+
+ var uiTemplate = Handlebars.compile(uiTPL);
+ viewerToolbar = uiTemplate({
+ id: extensionID
+ });
+
+ $iframeViewer = $("#iframeViewer");
+ $iframeViewerBody = $iframeViewer.contents().find('body');
+
+ TSCORE.IO.loadTextFile(filePath);
+ });
+ };
+
+ exports.setFileType = function() {
+ console.log("setFileType not supported on this extension");
+ };
+
+ exports.viewerMode = function(isViewerMode) {
+ // set readonly
+ };
+
+ exports.setContent = function(content) {
+ var UTF8_BOM = "\ufeff";
+
+ // removing the UTF8 bom because it brakes thing like #header1 in the beginning of the document
+ if (content.indexOf(UTF8_BOM) === 0) {
+ content = content.substring(1, content.length);
+ }
+
+ var fileDirectory = TSCORE.TagUtils.extractContainingDirectoryPath(currentFilePath);
+
+ var cleanedContent = content.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, "");
+ var mdContent = md2htmlConverter(cleanedContent);
+
+ var styles = ['', 'solarized-dark', 'github', 'metro-vibes', 'clearness', 'clearness-dark'];
+ var currentStyleIndex = 0;
+
+ var zoomSteps = ['zoomSmallest', 'zoomSmaller', 'zoomSmall', 'zoomDefault', 'zoomLarge', 'zoomLarger', 'zoomLargest'];
+ var currentZoomState = 3;
+
+ if ($iframeViewer !== undefined) {
+ var $iframeViewerHead = $iframeViewer.contents().find('head');
+ $iframeViewerHead.append($('<link/>', {
+ rel: 'stylesheet',
+ href: extensionDirectory + '/extension.css'
+ }));
+ $iframeViewerHead.append($('<link/>', {
+ rel: 'stylesheet',
+ href: extensionDirectory + '/../../libs/bootstrap/css/bootstrap.css'
+ }));
+ $iframeViewerHead.append($('<link/>', {
+ rel: 'stylesheet',
+ href: extensionDirectory + '/../../libs/font-awesome/css/font-awesome.css'
+ }));
+ $iframeViewerHead.append($('<link/>', {
+ rel: 'stylesheet',
+ href: extensionDirectory + '/css/markdown.css'
+ }));
+ $iframeViewerHead.append($('<link/>', {
+ rel: 'stylesheet',
+ href: extensionDirectory + '/css/github.css'
+ }));
+ //$iframeViewerHead.append($('<link/>', { rel: 'stylesheet', href: extensionDirectory+'/css/haroopad.css' }));
+ $iframeViewerHead.append($('<link/>', {
+ rel: 'stylesheet',
+ href: extensionDirectory + '/css/metro-vibes.css'
+ }));
+ $iframeViewerHead.append($('<link/>', {
+ rel: 'stylesheet',
+ href: extensionDirectory + '/css/solarized-dark.css'
+ }));
+ $iframeViewerHead.append($('<link/>', {
+ rel: 'stylesheet',
+ href: extensionDirectory + '/css/clearness.css'
+ }));
+ $iframeViewerHead.append($('<link/>', {
+ rel: 'stylesheet',
+ href: extensionDirectory + '/css/clearness-dark.css'
+ }));
+
+ $iframeViewerBody.children().remove();
+ $iframeViewerBody.append($('<div/>', {
+ id: 'viewerContent',
+ class: "markdown"
+ }).append(mdContent));
+ $iframeViewerBody.append(viewerToolbar);
+
+ if (isCordova) {
+ $iframeViewerBody.find("#printButton").hide();
+ }
+
+ var $viewerContent = $iframeViewer.contents().find('#viewerContent');
+
+ $iframeViewerBody.find("#changeStyleButton").bind('click', function() {
+ currentStyleIndex = currentStyleIndex + 1;
+ if (currentStyleIndex >= styles.length) {
+ currentStyleIndex = 0;
+ }
+ $viewerContent.removeClass();
+ $viewerContent.addClass('markdown ' + styles[currentStyleIndex] + " " + zoomSteps[currentZoomState]);
+ });
+
+ $iframeViewerBody.find("#zoomInButton").bind('click', function(e) {
+ currentZoomState++;
+ if (currentZoomState >= zoomSteps.length) {
+ currentZoomState = 6;
+ }
+ $viewerContent.removeClass();
+ $viewerContent.addClass('markdown ' + styles[currentStyleIndex] + " " + zoomSteps[currentZoomState]);
+ });
+
+ $iframeViewerBody.find("#zoomOutButton").bind('click', function(e) {
+ currentZoomState--;
+ if (currentZoomState < 0) {
+ currentZoomState = 0;
+ }
+ $viewerContent.removeClass();
+ $viewerContent.addClass('markdown ' + styles[currentStyleIndex] + " " + zoomSteps[currentZoomState]);
+ });
+
+ $iframeViewerBody.find("#zoomResetButton").bind('click', function(e) {
+ currentZoomState = 3;
+ $viewerContent.removeClass();
+ $viewerContent.addClass('markdown ' + styles[currentStyleIndex] + " " + zoomSteps[currentZoomState]);
+ });
+
+ $iframeViewerBody.find("#printButton").bind('click', function(e) {
+ //document.getElementById("iframeViewer").contentWindow.print();
+ $iframeViewer.get(0).contentWindow.print();
+ });
+
+ // making all links open in the user default browser
+ $iframeViewerBody.find("a").bind('click', function(e) {
+ e.preventDefault();
+ TSCORE.openLinkExternally($(this).attr("href"));
+ });
+
+ // fixing embedding of local images
+ $iframeViewerBody.find("img[src]").each(function() {
+ var currentSrc = $(this).attr("src");
+ if (currentSrc.indexOf("http://") === 0 || currentSrc.indexOf("https://") === 0 || currentSrc.indexOf("data:") === 0) {
+ // do nothing if src begins with http(s):// or data:
+ } else {
+ $(this).attr("src", "file://" + fileDirectory + TSCORE.dirSeparator + currentSrc);
+ }
+ });
+ }
+ };
+
+ exports.getContent = function() {
+ //$('#'+containerElID).html();
+ };
+
+ // Extension Vars
+ exports.Title = extensionTitle;
+ exports.ID = extensionID;
+ exports.Type = extensionType;
+ exports.Icon = extensionIcon;
+ exports.Version = extensionVersion;
+ exports.ManifestVersion = extensionManifestVersion;
+ exports.License = extensionLicense;
+ exports.SupportedFileTypes = extensionSupportedFileTypes;
+
+});
diff --git a/data/ext/viewerPDF/extension.js b/data/ext/viewerPDF/extension.js
index bd0b3ce60..62871fe9b 100644
--- a/data/ext/viewerPDF/extension.js
+++ b/data/ext/viewerPDF/extension.js
@@ -1,40 +1,40 @@
-/* Copyright (c) 2013 The Tagspaces Authors. All rights reserved.
- * Use of this source code is governed by a AGPL3 license that
- * can be found in the LICENSE file. */
-
-define(function(require, exports, module) {
-"use strict";
-
- console.log("Loading viewerPDF");
-
- exports.id = "viewerPDF"; // ID should be equal to the directory name where the ext. is located
- exports.title = "PDF Viewer";
- exports.type = "viewer";
- exports.supportedFileTypes = [ "pdf" ];
-
- var TSCORE = require("tscore");
-
- var extensionDirectory = TSCORE.Config.getExtensionPath()+"/"+exports.id;
-
- exports.init = function(filePath, elementID) {
- console.log("Initalization Browser PDF Viewer...");
- $('#'+elementID).append($('<iframe>', {
- id: "iframeViewer",
- src: extensionDirectory+"/web/viewer.html?file="+filePath,
- "nwdisable": "",
- "nwfaketop": ""
- }));
- };
-
- exports.viewerMode = function() {
- console.log("viewerMode not supported on this extension");
- };
-
- exports.setContent = function() {
- console.log("setContent not supported on this extension");
- };
-
- exports.getContent = function() {
- console.log("getContent not supported on this extension");
- };
-});
+/* Copyright (c) 2013 The Tagspaces Authors. All rights reserved.
+ * Use of this source code is governed by a AGPL3 license that
+ * can be found in the LICENSE file. */
+
+define(function(require, exports, module) {
+ "use strict";
+
+ console.log("Loading viewerPDF");
+
+ exports.id = "viewerPDF"; // ID should be equal to the directory name where the ext. is located
+ exports.title = "PDF Viewer";
+ exports.type = "viewer";
+ exports.supportedFileTypes = ["pdf"];
+
+ var TSCORE = require("tscore");
+
+ var extensionDirectory = TSCORE.Config.getExtensionPath() + "/" + exports.id;
+
+ exports.init = function(filePath, elementID) {
+ console.log("Initalization Browser PDF Viewer...");
+ $('#' + elementID).append($('<iframe>', {
+ id: "iframeViewer",
+ src: extensionDirectory + "/web/viewer.html?file=" + filePath,
+ "nwdisable": "",
+ "nwfaketop": ""
+ }));
+ };
+
+ exports.viewerMode = function() {
+ console.log("viewerMode not supported on this extension");
+ };
+
+ exports.setContent = function() {
+ console.log("setContent not supported on this extension");
+ };
+
+ exports.getContent = function() {
+ console.log("getContent not supported on this extension");
+ };
+});
diff --git a/data/ext/viewerText/extension.js b/data/ext/viewerText/extension.js
index 95fa8d7bc..dc02a88b6 100644
--- a/data/ext/viewerText/extension.js
+++ b/data/ext/viewerText/extension.js
@@ -1,90 +1,89 @@
-/* Copyright (c) 2012-2013 The TagSpaces Authors. All rights reserved.
- * Use of this source code is governed by a AGPL3 license that
- * can be found in the LICENSE file. */
-
-define(function(require, exports, module) {
-"use strict";
-
- console.log("Loading viewerText");
-
- var extensionTitle = "Universal Viewer";
- var extensionID = "viewerText"; // ID should be equal to the directory name where the ext. is located
- var extensionType = "viewer";
- var extensionIcon = "icon-list";
- var extensionVersion = "1.0";
- var extensionManifestVersion = 1;
- var extensionLicense = "AGPL";
- var extensionSupportedFileTypes = [ "*" ];
-
- var TSCORE = require("tscore");
-
- var containerElID,
- $containerElement,
- filePath;
-
- var extensionDirectory = TSCORE.Config.getExtensionPath()+"/"+extensionID;
-
-
- exports.init = function(fPath, containerElementID) {
- console.log("Initalization Text Viewer...");
- containerElID = containerElementID;
- $containerElement = $('#'+containerElID);
- filePath = fPath;
- TSCORE.IO.loadTextFile(filePath, true);
- };
-
- exports.setFileType = function(fileType) {
- console.log("setFileType not supported on this extension");
- };
-
- exports.viewerMode = function(isViewerMode) {
- // set readonly
- };
-
- exports.setContent = function(content) {
- // Cutting preview content 8kb
- var previewSize = 1024*10;
- console.log("Content size: "+content.length);
- if(content.length > previewSize) {
- content = content.substring(0,previewSize);
- }
- //console.log("Content size: "+content);
-
- // removing the script tags from the content
- var cleanedContent = content.toString().replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"");
-
- $containerElement.empty();
- $containerElement.css("background-color","darkgray");
- if(isNode) {
- $containerElement.append($('<button/>', {
- class: 'btn btn-primary',
- style: 'margin: 5px;',
- text: 'Open Natively'
- }).on("click", function(){
- TSCORE.IO.openFile(filePath)
- }));
- }
- $containerElement.append('<span style="font-size: 14px; color: white;">&nbsp;Preview of the document begin: </span>');
- $containerElement.append($('<textarea>', {
- readonly: "true",
- style: "overflow: auto; height: 100%; width: 100%; font-size: 13px; margin: 0px; background-color: white; border-width: 0px;",
- })
- .append(cleanedContent)
- );
- };
-
- exports.getContent = function() {
- console.log("Not implemented");
- };
-
- // Extension Vars
- exports.Title = extensionTitle;
- exports.ID = extensionID;
- exports.Type = extensionType;
- exports.Icon = extensionIcon;
- exports.Version = extensionVersion;
- exports.ManifestVersion = extensionManifestVersion;
- exports.License = extensionLicense;
- exports.SupportedFileTypes = extensionSupportedFileTypes;
-
-});
\ No newline at end of file
+/* Copyright (c) 2012-2013 The TagSpaces Authors. All rights reserved.
+ * Use of this source code is governed by a AGPL3 license that
+ * can be found in the LICENSE file. */
+
+define(function(require, exports, module) {
+ "use strict";
+
+ console.log("Loading viewerText");
+
+ var extensionTitle = "Universal Viewer";
+ var extensionID = "viewerText"; // ID should be equal to the directory name where the ext. is located
+ var extensionType = "viewer";
+ var extensionIcon = "icon-list";
+ var extensionVersion = "1.0";
+ var extensionManifestVersion = 1;
+ var extensionLicense = "AGPL";
+ var extensionSupportedFileTypes = ["*"];
+
+ var TSCORE = require("tscore");
+
+ var containerElID,
+ $containerElement,
+ filePath;
+
+ var extensionDirectory = TSCORE.Config.getExtensionPath() + "/" + extensionID;
+
+ exports.init = function(fPath, containerElementID) {
+ console.log("Initalization Text Viewer...");
+ containerElID = containerElementID;
+ $containerElement = $('#' + containerElID);
+ filePath = fPath;
+ TSCORE.IO.loadTextFile(filePath, true);
+ };
+
+ exports.setFileType = function(fileType) {
+ console.log("setFileType not supported on this extension");
+ };
+
+ exports.viewerMode = function(isViewerMode) {
+ // set readonly
+ };
+
+ exports.setContent = function(content) {
+ // Cutting preview content 8kb
+ var previewSize = 1024 * 10;
+ console.log("Content size: " + content.length);
+ if (content.length > previewSize) {
+ content = content.substring(0, previewSize);
+ }
+ //console.log("Content size: "+content);
+
+ // removing the script tags from the content
+ var cleanedContent = content.toString().replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, "");
+
+ $containerElement.empty();
+ $containerElement.css("background-color", "darkgray");
+ if (isNode) {
+ $containerElement.append($('<button/>', {
+ class: 'btn btn-primary',
+ style: 'margin: 5px;',
+ text: 'Open Natively'
+ }).on("click", function() {
+ TSCORE.IO.openFile(filePath);
+ }));
+ }
+ $containerElement.append('<span style="font-size: 14px; color: white;">&nbsp;Preview of the document begin: </span>');
+ $containerElement.append($('<textarea>', {
+ readonly: "true",
+ style: "overflow: auto; height: 100%; width: 100%; font-size: 13px; margin: 0px; background-color: white; border-width: 0px;",
+ })
+ .append(cleanedContent)
+ );
+ };
+
+ exports.getContent = function() {
+ console.log("Not implemented");
+ };
+
+ // Extension Vars
+ exports.Title = extensionTitle;
+ exports.ID = extensionID;
+ exports.Type = extensionType;
+ exports.Icon = extensionIcon;
+ exports.Version = extensionVersion;
+ exports.ManifestVersion = extensionManifestVersion;
+ exports.License = extensionLicense;
+ exports.SupportedFileTypes = extensionSupportedFileTypes;
+
+});
diff --git a/data/ext/viewerURL/extension.js b/data/ext/viewerURL/extension.js
index 03329c901..ff6d8410e 100644
--- a/data/ext/viewerURL/extension.js
+++ b/data/ext/viewerURL/extension.js
@@ -1,75 +1,74 @@
-/* Copyright (c) 2012-2014 The TagSpaces Authors. All rights reserved.
- * Use of this source code is governed by a AGPL3 license that
+/* Copyright (c) 2012-2015 The TagSpaces Authors. All rights reserved.
+ * Use of this source code is governed by a AGPL3 license that
* can be found in the LICENSE file. */
define(function(require, exports, module) {
-"use strict";
+ "use strict";
- console.log("Loading viewerURL");
+ console.log("Loading viewerURL");
- exports.id = "viewerURL"; // ID should be equal to the directory name where the ext. is located
- exports.title = "URL Viewer";
- exports.type = "editor";
- exports.supportedFileTypes = [ "url", "website", "desktop" ];
+ exports.id = "viewerURL"; // ID should be equal to the directory name where the ext. is located
+ exports.title = "URL Viewer";
+ exports.type = "editor";
+ exports.supportedFileTypes = ["url", "website", "desktop"];
- var TSCORE = require("tscore");
+ var TSCORE = require("tscore");
- var containerElID;
- var currentFilePath;
+ var containerElID;
+ var currentFilePath;
- var extensionDirectory = TSCORE.Config.getExtensionPath()+"/"+exports.id;
+ var extensionDirectory = TSCORE.Config.getExtensionPath() + "/" + exports.id;
- exports.init = function(filePath, containerElementID) {
- console.log("Initalization MD Viewer...");
- containerElID = containerElementID;
- $('#'+containerElID).attr("style","background-color: white;");
- currentFilePath = filePath;
- require(['css!'+extensionDirectory+'/extension.css'], function() {
- TSCORE.IO.loadTextFile(filePath);
- });
- };
+ exports.init = function(filePath, containerElementID) {
+ console.log("Initalization MD Viewer...");
+ containerElID = containerElementID;
+ $('#' + containerElID).attr("style", "background-color: white;");
+ currentFilePath = filePath;
+ require(['css!' + extensionDirectory + '/extension.css'], function() {
+ TSCORE.IO.loadTextFile(filePath);
+ });
+ };
- exports.setFileType = function() {
- console.log("setFileType not supported on this extension");
- };
+ exports.setFileType = function() {
+ console.log("setFileType not supported on this extension");
+ };
- exports.viewerMode = function(isViewerMode) {
- // set readonly
- };
+ exports.viewerMode = function(isViewerMode) {
+ // set readonly
+ };
- exports.setContent = function(content) {
- var urlBegin = "URL=";
+ exports.setContent = function(content) {
+ var urlBegin = "URL=";
- var url = content.substring(content.indexOf(urlBegin)+urlBegin.length, content.length);
+ var url = content.substring(content.indexOf(urlBegin) + urlBegin.length, content.length);
- // preventing the case the url is at the end of the file
- url = url+"\n";
+ // preventing the case the url is at the end of the file
+ url = url + "\n";
- url = url.substring(0,url.indexOf("\n"));
+ url = url.substring(0, url.indexOf("\n"));
- var urlRegExp = /https?:\/\/([-\w\.]+)+(:\d+)?(\/([\w/_\.]*(\?\S+)?)?)?/;
+ var urlRegExp = /https?:\/\/([-\w\.]+)+(:\d+)?(\/([\w/_\.]*(\?\S+)?)?)?/;
- console.log("URL: "+url);
+ console.log("URL: " + url);
- if(urlRegExp.test(url)) {
- $('#'+containerElID).append($("<button>", {
- "class": "viewerURLButton btn btn-primary",
- "data-url": url,
- "text": url
- })
- .prepend("<i class='fa fa-external-link'></i>&nbsp;")
- .click(function(e){
- e.preventDefault();
- TSCORE.openLinkExternally($(this).attr("data-url"));
- })
- );
- } else {
- TSCORE.showAlertDialog("No URL found in this file.");
- console.log("No URL found!");
- }
- };
+ if (urlRegExp.test(url)) {
+ $('#' + containerElID).append($("<button>", {
+ "class": "viewerURLButton btn btn-primary",
+ "data-url": url,
+ "text": url
+ })
+ .prepend("<i class='fa fa-external-link'></i>&nbsp;")
+ .click(function(e) {
+ e.preventDefault();
+ TSCORE.openLinkExternally($(this).attr("data-url"));
+ })
+ );
+ } else {
+ TSCORE.showAlertDialog("No URL found in this file.");
+ console.log("No URL found!");
+ }
+ };
- exports.getContent = function() {
- };
+ exports.getContent = function() {};
-});
\ No newline at end of file
+});
diff --git a/data/loader.js b/data/loader.js
index 98706e99b..68c0696a0 100644
--- a/data/loader.js
+++ b/data/loader.js
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2014 The TagSpaces Authors. All rights reserved.
+/* Copyright (c) 2012-2015 The TagSpaces Authors. All rights reserved.
* Use of this source code is governed by a AGPL3 license that
* can be found in the LICENSE file. */
/* global define, requirejs, _ */
diff --git a/data/mozilla/firefoxos.api.js b/data/mozilla/firefoxos.api.js
index 26aa830e8..52d4569e1 100644
--- a/data/mozilla/firefoxos.api.js
+++ b/data/mozilla/firefoxos.api.js
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2014 The TagSpaces Authors. All rights reserved.
+/* Copyright (c) 2012-2015 The TagSpaces Authors. All rights reserved.
* Use of this source code is governed by a AGPL3 license that
* can be found in the LICENSE file. */
define(function(require, exports, module) {
diff --git a/data/mozilla/ioutils.js b/data/mozilla/ioutils.js
index 5c01c93df..167459f7d 100644
--- a/data/mozilla/ioutils.js
+++ b/data/mozilla/ioutils.js
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2014 The TagSpaces Authors. All rights reserved.
+/* Copyright (c) 2012-2015 The TagSpaces Authors. All rights reserved.
* Use of this source code is governed by a AGPL3 license that
* can be found in the LICENSE file. */
/* jshint moz: true, strict: false */
diff --git a/data/mozilla/mozilla.api.js b/data/mozilla/mozilla.api.js
index 6f9e1755a..4413794b4 100644
--- a/data/mozilla/mozilla.api.js
+++ b/data/mozilla/mozilla.api.js
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2014 The TagSpaces Authors. All rights reserved.
+/* Copyright (c) 2012-2015 The TagSpaces Authors. All rights reserved.
* Use of this source code is governed by a AGPL3 license that
* can be found in the LICENSE file. */
/* global define */
diff --git a/data/mozilla/settings.js b/data/mozilla/settings.js
index eb104838c..02099b888 100644
--- a/data/mozilla/settings.js
+++ b/data/mozilla/settings.js
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2014 The TagSpaces Authors. All rights reserved.
+/* Copyright (c) 2012-2015 The TagSpaces Authors. All rights reserved.
* Use of this source code is governed by a AGPL3 license that
* can be found in the LICENSE file. */
/* jshint moz: true, strict: false */
diff --git a/data/node-webkit/node-webkit.api.js b/data/node-webkit/node-webkit.api.js
index d9bc9736d..156ffb265 100644
--- a/data/node-webkit/node-webkit.api.js
+++ b/data/node-webkit/node-webkit.api.js
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2014 The TagSpaces Authors. All rights reserved.
+/* Copyright (c) 2012-2015 The TagSpaces Authors. All rights reserved.
* Use of this source code is governed by a AGPL3 license that
* can be found in the LICENSE file. */
@@ -286,7 +286,7 @@ define(function(require, exports, module) {
TSCORE.showAlertDialog("Copying of '" + sourceFilePath + "' failed.");
});
wr.on("close", function(ex) {
- TSPOSTIO.copyFile(sourceFilePath, targetFilePath)
+ TSPOSTIO.copyFile(sourceFilePath, targetFilePath);
});
rd.pipe(wr);
};
diff --git a/data/web/dropbox.api.js b/data/web/dropbox.api.js
index 6314d55c3..ba7985b0a 100644
--- a/data/web/dropbox.api.js
+++ b/data/web/dropbox.api.js
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2014 The TagSpaces Authors. All rights reserved.
+/* Copyright (c) 2013-2015 The TagSpaces Authors. All rights reserved.
* Use of this source code is governed by a AGPL3 license that
* can be found in the LICENSE file. */
define(function(require, exports, module) {
@@ -62,7 +62,7 @@ define(function(require, exports, module) {
var checkNewVersion = function() {
console.log("Checking for new version...");
- var cVer = TSCORE.Config.DefaultSettings["appVersion"] + "." + TSCORE.Config.DefaultSettings["appBuild"];
+ var cVer = TSCORE.Config.DefaultSettings.appVersion + "." + TSCORE.Config.DefaultSettings.appBuild;
$.ajax({
url: 'http://tagspaces.org/releases/version.json?pVer=' + cVer,
type: 'GET'
diff --git a/data/web/web.api.js b/data/web/web.api.js
index 7bb09cbdc..e1e6cd513 100644
--- a/data/web/web.api.js
+++ b/data/web/web.api.js
@@ -10,7 +10,7 @@ define(function(require, exports, module) {
var TSCORE = require("tscore");
var TSPOSTIO = require("tspostioapi");
- require("webdavlib");
+ require("webdavlib/webdavlib");
var davClient;
diff --git a/data/web/lgpl.txt b/data/web/webdavlib/lgpl.txt
similarity index 100%
rename from data/web/lgpl.txt
rename to data/web/webdavlib/lgpl.txt
diff --git a/data/web/webdavlib.js b/data/web/webdavlib/webdavlib.js
similarity index 100%
rename from data/web/webdavlib.js
rename to data/web/webdavlib/webdavlib.js