Skip to content

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

cleaning up the source code

uggrockd3def86e57d8
diff --git a/data/ext/viewerImage/extension.css b/data/ext/viewerImage/extension.css
index 739411afb..11a6de3c6 100644
--- a/data/ext/viewerImage/extension.css
+++ b/data/ext/viewerImage/extension.css
@@ -7,32 +7,20 @@
body, html {
width: 100% !important;
height: 100% !important;
-}
-
-#viewerImage {
- width: 100% !important;
- height: 100% !important;
overflow: hidden;
- position: relative;
- background-color: white;
+ background-color: black !important;
}
-#imageContainer {
- width: 100%;
- height: 100%;
- position: relative;
+.imgViewer {
+ display: block;
+ margin: auto auto;
}
-#viewerImage #Image {
+#imageContent {
max-width: 100%;
max-height: 100%;
- display: block;
- margin:auto;
-}
-
-#imgViewer {
- /*width: 100%;
- height: 100%;*/
+ display: none;
+ margin: auto auto;
}
.iconBackground {
@@ -43,6 +31,11 @@ body, html {
color: #f2f2f2;
}
+.transparentImageBackground {
+ display: block !important;
+ background: repeating-linear-gradient(45deg, #d5d5d5, #d5d5d5 10px, #a7a7a7 10px, #a7a7a7 20px);
+}
+
#Toolbar {
padding: 2px;
background-color: transparent;
diff --git a/data/ext/viewerImage/extension.js b/data/ext/viewerImage/extension.js
index 0abc798ee..78a735a61 100644
--- a/data/ext/viewerImage/extension.js
+++ b/data/ext/viewerImage/extension.js
@@ -34,11 +34,19 @@ define(function(require, exports, module) {
id: "iframeViewer",
sandbox: "allow-same-origin allow-scripts",
scrolling: "no",
- style: "background-color: white; overflow: hidden; width: 100%; height: 100%;",
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',
diff --git a/data/ext/viewerImage/index.html b/data/ext/viewerImage/index.html
index 21f2a8f12..bea1efc2e 100644
--- a/data/ext/viewerImage/index.html
+++ b/data/ext/viewerImage/index.html
@@ -12,7 +12,7 @@
<link rel="stylesheet" href="../../libs/bootstrap/css/bootstrap.css" />
<link rel="stylesheet" href="../../libs/font-awesome/css/font-awesome.css" />
</head>
-<body id="viewerImage">
+<body>
<div class="btn-toolbar" id="Toolbar">
<div class="btn-group">
<button class="btn btn-link btn-lg" id="zoomOutButton"><span class="fa-stack">
@@ -29,8 +29,8 @@
<i class="fa fa-circle fa-stack-base fa-stack-2x iconBackground"></i><i class="fa fa-print fa-stack-1x iconForeground"></i></span></button>
</div>
</div>
- <div id="imageContainer">
- <div id="imgViewer"></div>
+ <div id="imgViewer">
+ <img id="imageContent" src="">
</div>
</body>
</html>
\ No newline at end of file
diff --git a/data/ext/viewerImage/viewer.js b/data/ext/viewerImage/viewer.js
index 62e11d1cf..5e8d7e18b 100644
--- a/data/ext/viewerImage/viewer.js
+++ b/data/ext/viewerImage/viewer.js
@@ -4,6 +4,13 @@
/* global define, isCordova */
$(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, " "));
+ }
+
var filePath = getParameterByName("cp");
/*$.ajax({
url: fileURL,//"file://"+filePath,
@@ -26,47 +33,40 @@ $(document).ready(function() {
filePath = "file://"+filePath;
}
- if(isCordova) {
- $("#zoomInButton").hide();
- $("#zoomOutButton").hide();
- $("#printButton").hide();
- }
-
var $imgViewer = $("#imgViewer");
- $imgViewer.append($('<img>', {
- src: filePath,
- //style: "background: repeating-linear-gradient(45deg, #d5d5d5, #d5d5d5 10px, #a7a7a7 10px, #a7a7a7 20px)",
- id: "Image"
- }).bind("load",function() {
- $(this).css("background","repeating-linear-gradient(45deg, #d5d5d5, #d5d5d5 10px, #a7a7a7 10px, #a7a7a7 20px");
- })
- );
-
- console.log("inner html: "+$("#Image").attr("src"));
+ $("#imageContent")
+ .attr("src",filePath)
+ .bind("load",function() {
+ $(this).addClass("transparentImageBackground");
+ $imgViewer.addClass("imgViewer");
+ });
$imgViewer
.panzoom({
$zoomIn: $("#zoomInButton"),
$zoomOut: $("#zoomOutButton"),
$reset: $("#zoomResetButton"),
- //contain: true,
+ minScale: 0.1,
+ maxScale: 10,
+ increment: 0.2,
easing: "ease-in-out",
contain: 'invert'
-// $zoomRange: $section.find(".zoom-range"),
-// $reset: $section.find(".reset")
})
- //.hammer().on("swipeleft", function() {
- // TSCORE.FileOpener.openFile(TSCORE.PerspectiveManager.getNextFile(internPath));
- //})
- //.hammer().on("swiperight", function() {
- // TSCORE.FileOpener.openFile(TSCORE.PerspectiveManager.getPrevFile(internPath));
- //})
- .parent().on('mousewheel.focal', handleMouseWheel );
+ .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
+ });
+ });
$("#rotateLeftButton").on("click",function() {
//console.log("Rotate Left");
- var $image = $("#Image");
+ var $image = $("#imageContent");
$image.removeClass(imageRotationClass);
switch (imageRotationClass) {
case "":
@@ -89,7 +89,7 @@ $(document).ready(function() {
$("#rotateRightButton").on("click",function() {
//console.log("Rotate Right");
- var $image = $("#Image");
+ var $image = $("#imageContent");
$image.removeClass(imageRotationClass);
switch (imageRotationClass) {
case "":
@@ -113,22 +113,10 @@ $(document).ready(function() {
$("#printButton").on("click",function() {
window.print();
});
-});
-
-function handleMouseWheel(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 getParameterByName(name) {
- name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
- var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
- results = regex.exec(location.search);
- return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
-}
\ No newline at end of file
+ if(isCordova) {
+ $("#zoomInButton").hide();
+ $("#zoomOutButton").hide();
+ $("#printButton").hide();
+ }
+});
\ No newline at end of file