TagSpaces is an offline, open source, document manager with tagging support
jQuery Color Picker integrated in tagspaces
uggrockb8afe3748ae2
diff --git a/data/css/tagspaces.css b/data/css/tagspaces.cssindex acb9c4c58..e6d70d7f5 100644--- a/data/css/tagspaces.css+++ b/data/css/tagspaces.css@@ -1,4 +1,4 @@-/* Copyright (c) 2012 The Tagspaces Authors.+/* Copyright (c) 2012 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. */@@ -191,6 +191,12 @@ li hr {color: white;}+.simplecolorpicker {+ width: 40px;+ border: 1px solid #999 !important;+}++.fileButton {padding: 1px;background-color: #E5E5E5;diff --git a/data/ext/viewerText/extension.js b/data/ext/viewerText/extension.jsindex 81f389ddf..ebbd6db3d 100644--- a/data/ext/viewerText/extension.js+++ b/data/ext/viewerText/extension.js@@ -36,8 +36,8 @@ define(function(require, exports, module) {exports.setContent = function(content) {$('#'+containerElID).empty();- $('#'+containerElID).append($('<pre>', {- style: "height: 100%; margin: 3px",+ $('#'+containerElID).append($('<textarea>', {+ style: "overflow: auto; height: 100%; margin: 3px; background-color: white; border-width: 0px;",}).append(content));diff --git a/data/index.html b/data/index.htmlindex f3a5109c4..58d0cc5ac 100644--- a/data/index.html+++ b/data/index.html@@ -7,6 +7,7 @@can be found in the LICENSE file.--><meta http-equiv="Content-type" content="text/html; charset=utf-8" />+ <meta name="viewport" content="width=device-width, initial-scale=1.0"><link rel="shortcut icon" type="image/x-icon" href="icons/icon16.png"><title>TagSpaces</title><script type="text/javascript" data-main="loader" src="libs/requirejs/require.js"></script>@@ -15,7 +16,7 @@<link rel="stylesheet" type="text/css" href="libs/jsoneditor/jsoneditor.css"><link rel="stylesheet" type="text/css" href="libs/jquerydropdown/jquery.dropdown.css"><link rel="stylesheet" type="text/css" href="libs/bootstrap/css/bootstrap.css">- <link rel="stylesheet" type="text/css" href="libs/pickacolor/css/pick-a-color-1.1.7.min.css">+ <link rel="stylesheet" type="text/css" href="libs/jquery-simplecolorpicker/jquery.simplecolorpicker.css"><link rel="stylesheet" type="text/css" href="css/tagspaces.css"></head><body style="background-color: lightgray;">@@ -284,13 +285,43 @@<div class="control-group"><label class="control-label" for="tagColor">Color</label><div class="controls">- <input type="text" name="tagColor" id="tagColor" value="green" placeholder="green" class="pick-a-color" />+ <select id="tagColor" >+ <option value="#ac725e">#ac725e</option>+ <option value="#d06b64">#d06b64</option>+ <option value="#f83a22">#f83a22</option>+ <option value="#fa573c">#fa573c</option>+ <option value="#ff7537">#ff7537</option>+ <option value="#ffad46">#ffad46</option>+ <option value="#42d692">#42d692</option>+ <option value="#16a765">#16a765</option>+ <option value="#7bd148">#7bd148</option>+ <option value="#7bd148">#7bd148</option>+ <option value="#7bd148">#7bd148</option>+ <option value="#fad165">#fad165</option>+ <option value="#92e1c0">#92e1c0</option>+ <option value="#9fe1e7">#9fe1e7</option>+ <option value="#9fc6e7">#9fc6e7</option>+ <option value="#4986e7">#4986e7</option>+ <option value="#9a9cff">#9a9cff</option>+ <option value="#b99aff">#b99aff</option>+ <option value="#c2c2c2">#c2c2c2</option>+ <option value="#cabdbf">#cabdbf</option>+ <option value="#cca6ac">#cca6ac</option>+ <option value="#f691b2">#f691b2</option>+ <option value="#cd74e6">#cd74e6</option>+ <option value="#a47ae2">#a47ae2</option>+ </select></div></div><div class="control-group"><label class="control-label" for="tagTextColor">Text Color</label><div class="controls">- <input type="text" name="tagTextColor" id="tagTextColor" value="white" placeholder="white" class="pick-a-color"/>+ <select id="tagTextColor">+ <option value="#ffffff">#ffffff</option>+ <option value="#cccccc">#cccccc</option>+ <option value="#333333">#333333</option>+ <option value="#000000">#000000</option>+ </select></div></div></div>@@ -407,7 +438,7 @@<li><a id="startNewInstanceBack" title="Options Dialog"><i class="icon-external-link-sign"></i> New Instance</a></li><li class="divider"></li><li><a id="openOptions" title="Options Dialog"><i class="icon-wrench"></i> Options</a></li>- <li><a target="_new" href="https://tagspaces.uservoice.com/forums/213931-general" title="Suggest or vote for a feature"><i class="icon-bullhorn"></i> Vote on feature</a></li>+ <li><a target="_new" href="https://tagspaces.uservoice.com/forums/213931-general" title="Suggest or vote for a feature"><i class="icon-bullhorn"></i> Suggest Features</a></li><li><a target="_new" href="https://github.com/uggrock/tagspaces/issues/" title="Report a issue or enhancement"><i class="icon-flag"></i> Report Issue</a></li><li><a target="_new" href="https://twitter.com/tagspaces" title="Follow on twitter"><i class="icon-twitter"></i> Follow @tagspaces</a></li><li><a href="mailto:[email protected]" title="Drop a line to the developers"><i class="icon-envelope-alt"></i> Contact Developers</a></li>diff --git a/data/js/tags.ui.js b/data/js/tags.ui.jsindex e8c9370f0..79be2be80 100644--- a/data/js/tags.ui.js+++ b/data/js/tags.ui.js@@ -328,26 +328,18 @@ define(function(require, exports, module) {function showTagEditInTreeDialog() {$( "#tagInTreeName" ).val(TSCORE.selectedTagData.title);- if(TSCORE.selectedTagData.color == undefined) {- $( "#tagColor" ).val($( "#tagColor" ).attr("placeholder"));+ $( "#tagColor" ).simplecolorpicker({picker: true});+ if(TSCORE.selectedTagData.color == undefined || TSCORE.selectedTagData.color.length < 1) {+ $( "#tagColor" ).simplecolorpicker('selectColor', '#51b749');} else {- $( "#tagColor" ).val(TSCORE.selectedTagData.color);+ $( "#tagColor" ).simplecolorpicker('selectColor', TSCORE.selectedTagData.color);}- if(TSCORE.selectedTagData.textcolor == undefined) {- $( "#tagTextColor" ).val($( "#tagTextColor" ).attr("placeholder"));+ $( "#tagTextColor" ).simplecolorpicker({picker: true});+ if(TSCORE.selectedTagData.textcolor == undefined || TSCORE.selectedTagData.textcolor.length < 1) {+ $( "#tagTextColor" ).simplecolorpicker('selectColor', '#ffffff');} else {- $( "#tagTextColor" ).val(TSCORE.selectedTagData.textcolor);+ $( "#tagTextColor" ).simplecolorpicker('selectColor', TSCORE.selectedTagData.textcolor);}- /*$( "#tagColor" ).pickAColor({- showSpectrum : true,- showSavedColors : true,- saveColorsPerElement : true,- fadeMenuToggle : true,- showAdvanced : true,- showHexInput : true,- showBasicColors : true- });- $( "#tagTextColor" ).pickAColor();*/$( '#dialogEditInTreeTag' ).modal({show: true});}diff --git a/data/libs/jquery-simplecolorpicker/LICENSE.txt b/data/libs/jquery-simplecolorpicker/LICENSE.txtnew file mode 100644index 000000000..fd8ae3d14--- /dev/null+++ b/data/libs/jquery-simplecolorpicker/LICENSE.txt@@ -0,0 +1,22 @@+Copyright (c) 2012-2013 Tanguy Krotoff++MIT License++Permission is hereby granted, free of charge, to any person obtaining+a copy of this software and associated documentation files (the+"Software"), to deal in the Software without restriction, including+without limitation the rights to use, copy, modify, merge, publish,+distribute, sublicense, and/or sell copies of the Software, and to+permit persons to whom the Software is furnished to do so, subject to+the following conditions:++The above copyright notice and this permission notice shall be+included in all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.diff --git a/data/libs/jquery-simplecolorpicker/jquery.simplecolorpicker.css b/data/libs/jquery-simplecolorpicker/jquery.simplecolorpicker.cssnew file mode 100644index 000000000..174b57710--- /dev/null+++ b/data/libs/jquery-simplecolorpicker/jquery.simplecolorpicker.css@@ -0,0 +1,98 @@+/*+ * Very simple jQuery Color Picker+ * https://github.com/tkrotoff/jquery-simplecolorpicker+ *+ * Copyright (C) 2012-2013 Tanguy Krotoff <[email protected]>+ *+ * Licensed under the MIT license+ */++/**+ * Inspired by Bootstrap Twitter.+ * See https://github.com/twitter/bootstrap/blob/master/less/dropdowns.less+ * See http://twitter.github.com/bootstrap/assets/css/bootstrap.css+ */++.simplecolorpicker.picker:before {+ position: absolute;+ top: -7px;+ left: 9px;+ display: inline-block;+ border-right: 7px solid transparent;+ border-bottom: 7px solid #ccc;+ border-left: 7px solid transparent;+ border-bottom-color: rgba(0, 0, 0, 0.2);+ content: '';+}++.simplecolorpicker.picker:after {+ position: absolute;+ top: -6px;+ left: 10px;+ display: inline-block;+ border-right: 6px solid transparent;+ border-bottom: 6px solid #ffffff;+ border-left: 6px solid transparent;+ content: '';+}++.simplecolorpicker.picker {+ position: absolute;+ top: 100%;+ left: 0;+ z-index: 1051; /* Above Bootstrap modal (z-index of 1050) */+ display: none;+ float: left;++ min-width: 160px;+ max-width: 264px;++ padding: 4px 0 0 4px;+ margin: 1px 0 0;+ list-style: none;+ background-color: #ffffff;++ border: 1px solid #ccc;+ border: 1px solid rgba(0, 0, 0, 0.2);++ *border-right-width: 2px;+ *border-bottom-width: 2px;++ -webkit-border-radius: 5px;+ -moz-border-radius: 5px;+ border-radius: 5px;++ -webkit-box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);+ -moz-box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);+ box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);++ -webkit-background-clip: padding-box;+ -moz-background-clip: padding;+ background-clip: padding-box;+}++ .simplecolorpicker.inline {+ display: inline-block;+ height: 18px;+ padding: 4px 0;+ }++ .simplecolorpicker.icon,+ .simplecolorpicker span {+ cursor: pointer;+ display: inline-block;++ -webkit-border-radius: 3px;+ -moz-border-radius: 3px;+ border-radius: 3px;++ border: 1px solid transparent;+ }+ .simplecolorpicker span {+ margin: 0 4px 4px 0;+ }++ .simplecolorpicker span:hover,+ .simplecolorpicker span.selected {+ border: 1px solid black;+ }diff --git a/data/libs/jquery-simplecolorpicker/jquery.simplecolorpicker.js b/data/libs/jquery-simplecolorpicker/jquery.simplecolorpicker.jsnew file mode 100644index 000000000..1f94f0dfc--- /dev/null+++ b/data/libs/jquery-simplecolorpicker/jquery.simplecolorpicker.js@@ -0,0 +1,216 @@+/*+ * Very simple jQuery Color Picker+ * https://github.com/tkrotoff/jquery-simplecolorpicker+ *+ * Copyright (C) 2012-2013 Tanguy Krotoff <[email protected]>+ *+ * Licensed under the MIT license+ */++(function($) {+ 'use strict';++ /**+ * Constructor.+ */+ var SimpleColorPicker = function(select, options) {+ this.init('simplecolorpicker', select, options);+ };++ /**+ * SimpleColorPicker class.+ */+ SimpleColorPicker.prototype = {+ constructor: SimpleColorPicker,++ init: function(type, select, options) {+ var self = this;++ self.type = type;++ self.$select = $(select);+ var selectValue = self.$select.val();+ self.options = $.extend({}, $.fn.simplecolorpicker.defaults, options);++ self.$select.hide();++ // Trick: fix span alignment+ // When a span does not contain any text, its alignment is not correct+ var fakeText = ' ';++ self.$colorList = null;++ if (self.options.picker) {+ var selectText = self.$select.find('option:selected').text();+ self.$icon = $('<span class="simplecolorpicker icon"'+ + ' title="' + selectText + '"'+ + ' style="background-color: ' + selectValue + ';"'+ + ' role="button" tabindex="0">'+ + fakeText+ + '</span>').insertAfter(self.$select);+ self.$icon.on('click.' + self.type, $.proxy(self.showPicker, self));++ self.$picker = $('<span class="simplecolorpicker picker"></span>').appendTo(document.body);+ self.$colorList = self.$picker;++ // Hide picker when clicking outside+ $(document).on('mousedown.' + self.type, $.proxy(self.hidePicker, self));+ self.$picker.on('mousedown.' + self.type, $.proxy(self.mousedown, self));+ } else {+ self.$inline = $('<span class="simplecolorpicker inline"></span>').insertAfter(self.$select);+ self.$colorList = self.$inline;+ }++ // Build the list of colors+ // <span class="selected" title="Green" style="background-color: #7bd148;" role="button"></span>+ var colors = '';+ $('option', self.$select).each(function() {+ var option = $(this);+ var color = option.val();+ var title = option.text();+ var selected = '';+ if (option.prop('selected') === true || selectValue === color) {+ selected = 'class="selected"';+ }+ colors += '<span ' + selected+ + ' title="' + title + '"'+ + ' style="background-color: ' + color + ';"'+ + ' data-color="' + color + '"'+ + ' role="button" tabindex="0">'+ + fakeText+ + '</span>';+ });++ self.$colorList.html(colors);+ self.$colorList.on('click.' + self.type, $.proxy(self.click, self));+ },++ /**+ * Changes the selected color.+ *+ * @param color the hexadecimal color to select, ex: '#fbd75b'+ */+ selectColor: function(color) {+ var self = this;++ var colorSpan = self.$colorList.find('span').filter(function() {+ return $(this).data('color').toLowerCase() === color.toLowerCase();+ });++ if (colorSpan.length > 0) {+ self.selectColorSpan(colorSpan);+ } else {+ console.error("The given color '" + color + "' could not be found");+ }+ },++ showPicker: function() {+ var bootstrapArrowWidth = 16; // Empirical value+ var pos = this.$icon.offset();+ this.$picker.css({+ left: pos.left + this.$icon.width() / 2 - bootstrapArrowWidth, // Middle of the icon+ top: pos.top + this.$icon.outerHeight()+ });++ this.$picker.show(this.options.delay);+ },++ hidePicker: function() {+ this.$picker.hide(this.options.delay);+ },++ /**+ * Selects the given span inside $colorList.+ *+ * The given span becomes the selected one.+ * It also changes the HTML select value, this will emit the 'change' event.+ */+ selectColorSpan: function(colorSpan) {+ var color = colorSpan.data('color');+ var title = colorSpan.prop('title');++ // Mark this span as the selected one+ colorSpan.siblings().removeClass('selected');+ colorSpan.addClass('selected');++ if (this.options.picker) {+ this.$icon.css('background-color', color);+ this.$icon.prop('title', title);+ this.hidePicker();+ }++ // Change HTML select value+ this.$select.val(color);+ },++ /**+ * The user clicked on a span inside $colorList.+ */+ click: function(e) {+ var target = $(e.target);+ if (target.length === 1) {+ if (target[0].nodeName.toLowerCase() === 'span') {+ // When you click on a color, make it the new selected one+ this.selectColorSpan(target);+ this.$select.trigger('change');+ }+ }+ },++ /**+ * Prevents the mousedown event from "eating" the click event.+ */+ mousedown: function(e) {+ e.stopPropagation();+ e.preventDefault();+ },++ destroy: function() {+ if (this.options.picker) {+ this.$icon.off('.' + this.type);+ this.$icon.remove();+ $(document).off('.' + this.type);+ }++ this.$colorList.off('.' + this.type);+ this.$colorList.remove();++ this.$select.removeData(this.type);+ this.$select.show();+ }+ };++ /**+ * Plugin definition.+ * How to use: $('#id').simplecolorpicker()+ */+ $.fn.simplecolorpicker = function(option) {+ var args = $.makeArray(arguments);+ args.shift();++ // For HTML element passed to the plugin+ return this.each(function() {+ var $this = $(this),+ data = $this.data('simplecolorpicker'),+ options = typeof option === 'object' && option;+ if (data === undefined) {+ $this.data('simplecolorpicker', (data = new SimpleColorPicker(this, options)));+ }+ if (typeof option === 'string') {+ data[option].apply(data, args);+ }+ });+ };++ /**+ * Default options.+ */+ $.fn.simplecolorpicker.defaults = {+ // Animation delay+ delay: 0,++ // Show the picker or make it inline+ picker: false+ };++})(jQuery);diff --git a/data/loader.js b/data/loader.jsindex 1e75b6f9a..55e6f1b04 100644--- a/data/loader.js+++ b/data/loader.js@@ -88,6 +88,7 @@ requirejs.config({jqueryuidatepicker: 'libs/jqueryui/jquery.ui.datepicker',bootstrap: 'libs/bootstrap/js/bootstrap',+ jquerysimplecolorpicker:'libs/jquery-simplecolorpicker/jquery.simplecolorpicker',datatables: 'libs/datatables/js/jquery.dataTables.min',datatablescss: 'libs/datatables/css/jquery.dataTables',jsoneditor: 'libs/jsoneditor/jsoneditor',@@ -112,23 +113,24 @@ requirejs.config({tsioapi: IO_JS,},shim: {- 'bootstrap': { deps: ['jquery'] },- 'jqueryui': { deps: ['jquery'] },- 'jqueryuiwidget': { deps: ['jqueryui'] },- 'jqueryuimouse': { deps: ['jqueryui','jqueryuiwidget'] },- 'jqueryuiposition': { deps: ['jqueryui'] },- 'jqueryuiselectable': { deps: ['jqueryui','jqueryuiwidget','jqueryuimouse'] },- 'jqueryuisortable': { deps: ['jqueryui','jqueryuiwidget','jqueryuimouse'] },- 'jqueryuidatepicker': { deps: ['jqueryui'] },- 'jqueryuidroppable': { deps: ['jqueryui','jqueryuiwidget','jqueryuimouse','jqueryuidraggable'] },- 'jqueryuidraggable': { deps: ['jqueryui','jqueryuiwidget','jqueryuimouse'] },- 'jqueryuiresizable': { deps: ['jqueryui','jqueryuiwidget','jqueryuimouse'] },- 'jquerylayout': { deps: ['jquery', 'jqueryuidraggable' ] },- 'jquerydropdown': { deps: ['jquery','bootstrap'] },- 'datatables': { deps: ['jquery'] },- 'jqueryeditinplace': { deps: ['jquery'] },- 'jquerynanoscroller': { deps: ['jquery'] },- 'tscore': { deps: [+ 'bootstrap': { deps: ['jquery'] },+ 'jquerysimplecolorpicker': { deps: ['jquery','bootstrap'] },+ 'jqueryui': { deps: ['jquery'] },+ 'jqueryuiwidget': { deps: ['jqueryui'] },+ 'jqueryuimouse': { deps: ['jqueryui','jqueryuiwidget'] },+ 'jqueryuiposition': { deps: ['jqueryui'] },+ 'jqueryuiselectable': { deps: ['jqueryui','jqueryuiwidget','jqueryuimouse'] },+ 'jqueryuisortable': { deps: ['jqueryui','jqueryuiwidget','jqueryuimouse'] },+ 'jqueryuidatepicker': { deps: ['jqueryui'] },+ 'jqueryuidroppable': { deps: ['jqueryui','jqueryuiwidget','jqueryuimouse','jqueryuidraggable'] },+ 'jqueryuidraggable': { deps: ['jqueryui','jqueryuiwidget','jqueryuimouse'] },+ 'jqueryuiresizable': { deps: ['jqueryui','jqueryuiwidget','jqueryuimouse'] },+ 'jquerylayout': { deps: ['jquery', 'jqueryuidraggable' ] },+ 'jquerydropdown': { deps: ['jquery','bootstrap'] },+ 'datatables': { deps: ['jquery'] },+ 'jqueryeditinplace': { deps: ['jquery'] },+ 'jquerynanoscroller': { deps: ['jquery'] },+ 'tscore': { deps: ['jquery','jqueryui','jqueryuidraggable',@@ -138,6 +140,7 @@ requirejs.config({'jqueryuiselectable','jqueryuisortable','bootstrap',+ 'jquerysimplecolorpicker','jquerylayout','jquerydropdown',] },