TagSpaces is an offline, open source, document manager with tagging support
croppr added to the viewerImage extension
uggrockb20a48a5eb70
diff --git a/data/ext/viewerImage/croppr.css b/data/ext/viewerImage/croppr.cssnew file mode 100644index 000000000..6a89d4f00--- /dev/null+++ b/data/ext/viewerImage/croppr.css@@ -0,0 +1,51 @@+@charset "utf-8";+body {+ font-size: 67%;+ font-family: Sans-Serif;+ min-height: 416px;+ -webkit-text-size-adjust: 100%;+ -ms-text-size-adjust: 100%;+}++#cropprMenu{+ color:#fff;+ font-size:11px;+ position:fixed;+ top:11px;+ left:11px;+ z-index:1;+ font-family:Verdana,Arial,Tahoma,sans-serif;+ border:1px solid #000;+ border-radius:5px;+ opacity:0.4;+ background:rgba(30,30,30,0.55);+ -webkit-box-shadow:0 0 5px rgba(0,0,0,0.5);+ cursor:default;+ white-space:nowrap;+ padding:2px 3px;+ text-shadow: 1px 1px 0 #000;+}+#cropprMenu:hover { opacity: 1; }++#cropprMenu div {+ display: block;+ text-align: center;+ color: black;+ background-color: rgba(30,30,30,0.75);+ cursor: pointer;+ padding: 2px;+ border: 1px solid #000;+ height: 20px;+ width: 20px;+ margin: 0px;+ background-repeat: no-repeat;+ background-position: center center;+ /* -webkit-border-radius: 3px;+ -moz-border-radius: 3px;+ border-radius: 3px; */+}++/* Color schemes */+.croppr-white {background:#fbfbfb;color:#080000;}+.croppr-black {background:#080000;color:#fbfbfb;}+.croppr-blue {background:#0D3349;color:#C6FFC6;}diff --git a/data/ext/viewerImage/croppr.js b/data/ext/viewerImage/croppr.jsnew file mode 100644index 000000000..2480c2c85--- /dev/null+++ b/data/ext/viewerImage/croppr.js@@ -0,0 +1,290 @@+/**+ * Croppr is a Structmedia Experiment.+ *+ * Version: 1.12+ *+ * MaWeRe - Makes the Web Readable !+ *+ *+ * Most of the icons used in this extension are from:+ * http://gentleface.com/free_icon_set.html+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++var Croppr = (typeof Croppr == 'object' && Croppr != null) ? Croppr : {};++Croppr.cropprColors = ['croppr-white', 'croppr-black', 'croppr-blue'];+Croppr.cropprColor = (Croppr.cropprColor==null)?Croppr.cropprColors[1]:Croppr.cropprColor;++Croppr.logger = {+ isEnabled : function() {+ return true;+ },+ debug : function(msg) {+ if (Croppr.logger.isEnabled() && typeof console == 'object' && console != null && typeof console["log"] == 'function') {+ console.log(msg);+ }+ }+};++Croppr.rotateXYStep = 180;+Croppr.currentRotationXAngle = 0;+Croppr.currentRotationYAngle = 0;++Croppr.rotateStep = 90;+Croppr.currentRotationAngle = 0;++Croppr.zoomStep = 0.3;+Croppr.currentZoomLevel = 1;++Croppr.updateTransformations = function() {+ $('#cropprBody').attr('style', '-webkit-transform: rotate('+Croppr.currentRotationAngle+'deg) scale('+Croppr.currentZoomLevel+') rotateX('+Croppr.currentRotationXAngle+'deg) rotateY('+Croppr.currentRotationYAngle+'deg)');+};++Croppr.rotateRight = function() {+ Croppr.currentRotationAngle = Croppr.currentRotationAngle + Croppr.rotateStep;+ Croppr.updateTransformations();+};++Croppr.rotateLeft = function() {+ Croppr.currentRotationAngle = Croppr.currentRotationAngle - Croppr.rotateStep;+ Croppr.updateTransformations();+};++Croppr.flipVertically = function() {+ Croppr.currentRotationYAngle = Croppr.currentRotationYAngle + Croppr.rotateXYStep;+ Croppr.updateTransformations();+};++Croppr.flipHorizontally = function() {+ Croppr.currentRotationXAngle = Croppr.currentRotationXAngle + Croppr.rotateXYStep;+ Croppr.updateTransformations();+};++Croppr.zoomIn = function() {+ Croppr.currentZoomLevel = Croppr.currentZoomLevel + Croppr.zoomStep;+ Croppr.updateTransformations();+};++Croppr.zoomOut = function() {+ Croppr.currentZoomLevel = Croppr.currentZoomLevel - Croppr.zoomStep;+ Croppr.updateTransformations();+};++// Resize the content image to fit in the viewport+Croppr.fitViewport = function() {+ var newWidth = null;+ var newHeight = null;++ if($('#imageContent').width() > window.innerWidth) {+ newWidth = window.innerWidth;+ newHeight = Math.round(newWidth * $('#imageContent').height() / $('#imageContent').width());+ }+ $('#imageContent').attr('style', 'width: '+newWidth+'px; height: '+newHeight+'px;');++ if($('#imageContent').height() > window.innerHeight) {+ newHeight = window.innerHeight;+ newWidth = Math.round(newHeight * $('#imageContent').width() / $('#imageContent').height());+ }+ $('#imageContent').attr('style', 'width: '+newWidth+'px; height: '+newHeight+'px;');+// Croppr.logger.debug("W: "+newWidth+" H: "+newHeight+" Viewport: "+window.innerWidth);+};++Croppr.reset = function() {+ Croppr.currentRotationXAngle = 0;+ Croppr.currentRotationYAngle = 0;+ Croppr.currentRotationAngle = 0;+ Croppr.currentZoomLevel = 1;+ $('#cropprBody').attr('style', '-webkit-transform: rotate(0deg) scale(1) rotateX(0deg) rotateY(0deg)');+ Croppr.fitViewport();+};++Croppr.toggleColor = function() {+ $('body').removeClass(Croppr.cropprColor);+ var currentIndex = Croppr.cropprColors.indexOf(Croppr.cropprColor);+ var nextIndex = currentIndex+1;+ if (nextIndex >= Croppr.cropprColors.length) { nextIndex = 0; }+ Croppr.cropprColor = Croppr.cropprColors[nextIndex];+ $('body').addClass(Croppr.cropprColor);+};++Croppr.enableEventHandling = function() {+ $(document).ready(function(){++ // Fit the content to viewport+ Croppr.fitViewport();++ // Shows the cropper toolbox+ $("#cropprMenu").show();++ $(window).resize(function() {+ Croppr.fitViewport();+ });++ $("#cropprClose").click( function() {+ $("#cropprMenu").hide();+ });++ $("#cropprColors").click( function() {+ Croppr.toggleColor();+ });++ $("#cropprRotateRight").click( function() {+ Croppr.rotateRight();+ });++ $("#cropprRotateLeft").click( function() {+ Croppr.rotateLeft();+ });++ $("#cropprFlipVertically").click( function() {+ Croppr.flipVertically();+ });++ $("#cropprFlipHorizontally").click( function() {+ Croppr.flipHorizontally();+ });++ $("#cropprZoomIn").click( function() {+ Croppr.zoomIn();+ });++ $("#cropprZoomOut").click( function() {+ Croppr.zoomOut();+ });++ $("#cropprEvernote").click( function() {+ Evernote.doClip({contentId:'cropprBody',code:'Ilia8863'});+ });++ $("#cropprFacebook").click( function() {+ window.location.href="http://www.facebook.com/sharer.php?u="+encodeURIComponent(Croppr.biggestImageUrl)+"&t="+encodeURIComponent('Shared through croppr chrome extension!');+ });++ $("#cropprTwitter").click( function() {+ window.location.href="http://twitter.com/share?url="+encodeURIComponent(Croppr.biggestImageUrl)+"&r=cr";+ });++ $("#cropprReset").click( function() {+ Croppr.reset();+ });++ $("#cropprReload").click( function() {+ window.location.reload();+ });++ $("#cropprAbout").click( function() {+ window.location.href="http://mawere.com";+ });++ $("#cropprPrint").click( function() {+ $("#cropprMenu").hide();+ window.print();+ });++ });+};++Croppr.findLinksToImages = function() {+ $("a").each(function(index) {+ Croppr.logger.debug("index: " + index + " href: " + $(this).attr('href'));+ });+};++Croppr.findBiggestImage = function() {+ var indexBiggestImage = 0;+ var areaBiggestImage = 0;+ $("img").each(function(index) {+ var area = $(this).width()*$(this).height();+ if(area > areaBiggestImage) {+ indexBiggestImage = index;+ areaBiggestImage = area;+ }+ Croppr.logger.debug("index: " + index + " w: " + $(this).width() + " h: "+$(this).height() + " m2: " + area + " src: " +$("img")[index].src + " - " +indexBiggestImage);+ });++ Croppr.logger.debug(indexBiggestImage + " - " + $("img")[indexBiggestImage].src);++ return $("img")[indexBiggestImage].src;+};++Croppr.biggestImageUrl = "";++Croppr.initCroppr = function() {+ Croppr.biggestImageUrl = Croppr.findBiggestImage();++ // ToDo+ Croppr.findLinksToImages();++ // Generating croppr toolbox+ var cropprToolboxDiv = document.createElement("DIV");+ cropprToolboxDiv.id = "cropprMenu";+ cropprToolboxDiv.innerHTML = '' ++'<div id="cropprColors" style="background-image: url(\''+chrome.extension.getURL('imgs/color.png')+'\');" title="Change the background color"> </div>'++'<div id="cropprRotateLeft" style="background-image: url(\''+chrome.extension.getURL('imgs/rotateleft.png')+'\');" title="Rotate to the left"> </div>'++'<div id="cropprRotateRight" style="background-image: url(\''+chrome.extension.getURL('imgs/rotateright.png')+'\');" title="Rotate to the right"> </div>'++'<div id="cropprFlipHorizontally" style="background-image: url(\''+chrome.extension.getURL('imgs/fliph.png')+'\');" title="Flip horizontally"> </div>'++'<div id="cropprFlipVertically" style="background-image: url(\''+chrome.extension.getURL('imgs/flipv.png')+'\');" title="Flip vertically"> </div>'++'<div id="cropprZoomIn" style="background-image: url(\''+chrome.extension.getURL('imgs/zoomin.png')+'\');" title="Zoom in"> </div>'++'<div id="cropprZoomOut" style="background-image: url(\''+chrome.extension.getURL('imgs/zoomout.png')+'\');" title="Zoom out"> </div>'++'<div id="cropprReset" style="background-image: url(\''+chrome.extension.getURL('imgs/reset.png')+'\');" title="Reset the image"> </div>'++'<div id="cropprTwitter" style="background-image: url(\''+chrome.extension.getURL('imgs/twitter.png')+'\');" title="Send to Twitter"> </div>'++'<div id="cropprFacebook" style="background-image: url(\''+chrome.extension.getURL('imgs/facebook.png')+'\');" title="Send to Facebook"> </div>'++'<div id="cropprPrint" style="background-image: url(\''+chrome.extension.getURL('imgs/print.png')+'\');" title="Print"> </div>'++'<div id="cropprReload" style="background-image: url(\''+chrome.extension.getURL('imgs/reload.png')+'\');" title="Reload the original page"> </div>'++'<div id="cropprAbout" style="background-image: url(\''+chrome.extension.getURL('imgs/about.png')+'\');" title="About Croppr"> </div>'++'<div id="cropprClose" style="background-image: url(\''+chrome.extension.getURL('imgs/close.png\');" title="Closes this toolbox"> </div>'++ '';++ var contentDiv = document.createElement("DIV");+ contentDiv.id = "cropprBody";+ contentDiv.style = "";+ contentDiv.innerHTML = '' ++ // '<a href="'+biggestImageUrl+'" target="_blank" style="border: 0px;"><img id="imageContent" src="'+biggestImageUrl+'"></a>'++ '<img id="imageContent" src="'+Croppr.biggestImageUrl+'">'++ '';++ // Clears the document content+ document.body.innerHTML = "";++ // Inserts the content on the page+ document.body.insertBefore(contentDiv, document.body.firstChild);++ // Remove all stylesheets+ document.body.removeAttribute('style');+ for (var i=0; i < document.styleSheets.length; i++) {+ if (document.styleSheets[i].href !== null && document.styleSheets[i].href.lastIndexOf("croppr") == -1) {+ document.styleSheets[i].disabled = true;+ }+ }++ // Sets the background color of the page to the default color(black)+ $('body').attr('class', '');+ $('body').addClass(Croppr.cropprColor);++ // Centers the content on the page+ document.documentElement.style.display = 'table';+ document.documentElement.style.width = '100%';+ document.documentElement.style.height = '100%';+ document.documentElement.style.background = '#000';+ document.body.style.display = 'table-cell';+ document.body.style.verticalAlign = 'middle';+ document.body.style.textAlign = 'center';++ // Inserts the croppr's toolbox on the page+ document.body.insertBefore(cropprToolboxDiv, document.body.firstChild);++ Croppr.enableEventHandling();+};+Croppr.initCroppr();diff --git a/data/ext/viewerImage/imgs/about.png b/data/ext/viewerImage/imgs/about.pngnew file mode 100644index 000000000..81c0f33fcBinary files /dev/null and b/data/ext/viewerImage/imgs/about.png differdiff --git a/data/ext/viewerImage/imgs/close.png b/data/ext/viewerImage/imgs/close.pngnew file mode 100644index 000000000..63ffbe167Binary files /dev/null and b/data/ext/viewerImage/imgs/close.png differdiff --git a/data/ext/viewerImage/imgs/color.png b/data/ext/viewerImage/imgs/color.pngnew file mode 100644index 000000000..a70017c49Binary files /dev/null and b/data/ext/viewerImage/imgs/color.png differdiff --git a/data/ext/viewerImage/imgs/cursor_H_split.png b/data/ext/viewerImage/imgs/cursor_H_split.pngnew file mode 100644index 000000000..b531aff8eBinary files /dev/null and b/data/ext/viewerImage/imgs/cursor_H_split.png differdiff --git a/data/ext/viewerImage/imgs/cursor_V_split.png b/data/ext/viewerImage/imgs/cursor_V_split.pngnew file mode 100644index 000000000..a2483cccfBinary files /dev/null and b/data/ext/viewerImage/imgs/cursor_V_split.png differdiff --git a/data/ext/viewerImage/imgs/facebook.png b/data/ext/viewerImage/imgs/facebook.pngnew file mode 100644index 000000000..404fec4f2Binary files /dev/null and b/data/ext/viewerImage/imgs/facebook.png differdiff --git a/data/ext/viewerImage/imgs/fliph.png b/data/ext/viewerImage/imgs/fliph.pngnew file mode 100644index 000000000..28b1d46d4Binary files /dev/null and b/data/ext/viewerImage/imgs/fliph.png differdiff --git a/data/ext/viewerImage/imgs/flipv.png b/data/ext/viewerImage/imgs/flipv.pngnew file mode 100644index 000000000..fa4c80bf0Binary files /dev/null and b/data/ext/viewerImage/imgs/flipv.png differdiff --git a/data/ext/viewerImage/imgs/next.png b/data/ext/viewerImage/imgs/next.pngnew file mode 100644index 000000000..22ce09f32Binary files /dev/null and b/data/ext/viewerImage/imgs/next.png differdiff --git a/data/ext/viewerImage/imgs/prev.png b/data/ext/viewerImage/imgs/prev.pngnew file mode 100644index 000000000..e9ed46303Binary files /dev/null and b/data/ext/viewerImage/imgs/prev.png differdiff --git a/data/ext/viewerImage/imgs/print.png b/data/ext/viewerImage/imgs/print.pngnew file mode 100644index 000000000..c24b3f603Binary files /dev/null and b/data/ext/viewerImage/imgs/print.png differdiff --git a/data/ext/viewerImage/imgs/reload.png b/data/ext/viewerImage/imgs/reload.pngnew file mode 100644index 000000000..6ee1ef889Binary files /dev/null and b/data/ext/viewerImage/imgs/reload.png differdiff --git a/data/ext/viewerImage/imgs/reset.png b/data/ext/viewerImage/imgs/reset.pngnew file mode 100644index 000000000..81113c5eaBinary files /dev/null and b/data/ext/viewerImage/imgs/reset.png differdiff --git a/data/ext/viewerImage/imgs/rotateleft.png b/data/ext/viewerImage/imgs/rotateleft.pngnew file mode 100644index 000000000..1cd093b53Binary files /dev/null and b/data/ext/viewerImage/imgs/rotateleft.png differdiff --git a/data/ext/viewerImage/imgs/rotateright.png b/data/ext/viewerImage/imgs/rotateright.pngnew file mode 100644index 000000000..0e552f558Binary files /dev/null and b/data/ext/viewerImage/imgs/rotateright.png differdiff --git a/data/ext/viewerImage/imgs/twitter.png b/data/ext/viewerImage/imgs/twitter.pngnew file mode 100644index 000000000..ae7da0ba1Binary files /dev/null and b/data/ext/viewerImage/imgs/twitter.png differdiff --git a/data/ext/viewerImage/imgs/video.png b/data/ext/viewerImage/imgs/video.pngnew file mode 100644index 000000000..fda487f4dBinary files /dev/null and b/data/ext/viewerImage/imgs/video.png differdiff --git a/data/ext/viewerImage/imgs/zoomin.png b/data/ext/viewerImage/imgs/zoomin.pngnew file mode 100644index 000000000..c1a96f080Binary files /dev/null and b/data/ext/viewerImage/imgs/zoomin.png differdiff --git a/data/ext/viewerImage/imgs/zoomout.png b/data/ext/viewerImage/imgs/zoomout.pngnew file mode 100644index 000000000..e870b76b5Binary files /dev/null and b/data/ext/viewerImage/imgs/zoomout.png differ