Quellcode durchsuchen

Added new color picker

causefx vor 8 Jahren
Ursprung
Commit
500e9ecaff
7 geänderte Dateien mit 521 neuen und 19 gelöschten Zeilen
  1. 18 18
      api/functions/organizr-functions.php
  2. 2 0
      index.php
  3. 19 1
      js/custom.js
  4. 8 0
      js/functions.js
  5. 236 0
      js/jqColorPicker.min.js
  6. 236 0
      js/jsColor.js
  7. 2 0
      js/jsColorPicker.min.js

+ 18 - 18
api/functions/organizr-functions.php

@@ -561,71 +561,71 @@ function getCustomizeAppearance()
                     'name' => 'headerColor',
                     'label' => 'Nav Bar Color',
                     'value' => $GLOBALS['headerColor'],
-                    'class' => 'colorpicker',
-                    'disabled' => true
+                    'class' => 'pick-a-color',
+                    'attr' => 'data-original="'.$GLOBALS['headerColor'].'"'
                 ),
                 array(
                     'type' => 'input',
                     'name' => 'headerTextColor',
                     'label' => 'Nav Bar Text Color',
                     'value' => $GLOBALS['headerTextColor'],
-                    'class' => 'colorpicker',
-                    'disabled' => true
+                    'class' => 'pick-a-color',
+                    'attr' => 'data-original="'.$GLOBALS['headerTextColor'].'"'
                 ),
                 array(
                     'type' => 'input',
                     'name' => 'sidebarColor',
                     'label' => 'Side Bar Color',
                     'value' => $GLOBALS['sidebarColor'],
-                    'class' => 'colorpicker',
-                    'disabled' => true
+                    'class' => 'pick-a-color',
+                    'attr' => 'data-original="'.$GLOBALS['sidebarColor'].'"'
                 ),
                 array(
                     'type' => 'input',
                     'name' => 'sidebarTextColor',
                     'label' => 'Side Bar Text Color',
                     'value' => $GLOBALS['sidebarTextColor'],
-                    'class' => 'colorpicker',
-                    'disabled' => true
+                    'class' => 'pick-a-color',
+                    'attr' => 'data-original="'.$GLOBALS['sidebarTextColor'].'"'
                 ),
                 array(
                     'type' => 'input',
                     'name' => 'accentColor',
                     'label' => 'Accent Color',
                     'value' => $GLOBALS['accentColor'],
-                    'class' => 'colorpicker',
-                    'disabled' => true
+                    'class' => 'pick-a-color',
+                    'attr' => 'data-original="'.$GLOBALS['accentColor'].'"'
                 ),
                 array(
                     'type' => 'input',
                     'name' => 'accentTextColor',
                     'label' => 'Accent Text Color',
                     'value' => $GLOBALS['accentTextColor'],
-                    'class' => 'colorpicker',
-                    'disabled' => true
+                    'class' => 'pick-a-color',
+                    'attr' => 'data-original="'.$GLOBALS['accentTextColor'].'"'
                 ),
                 array(
                     'type' => 'input',
                     'name' => 'buttonColor',
                     'label' => 'Button Color',
                     'value' => $GLOBALS['buttonColor'],
-                    'class' => 'colorpicker',
-                    'disabled' => true
+                    'class' => 'pick-a-color',
+                    'attr' => 'data-original="'.$GLOBALS['buttonColor'].'"'
                 ),
                 array(
                     'type' => 'input',
                     'name' => 'buttonTextColor',
                     'label' => 'Button Text Color',
                     'value' => $GLOBALS['buttonTextColor'],
-                    'class' => 'colorpicker',
-                    'disabled' => true
+                    'class' => 'pick-a-color',
+                    'attr' => 'data-original="'.$GLOBALS['buttonTextColor'].'"'
                 ),/*
                 array(
                     'type' => 'input',
                     'name' => 'buttonHoverColor',
                     'label' => 'Button Hover Color',
                     'value' => $GLOBALS['buttonHoverColor'],
-                    'class' => 'colorpicker',
+                    'class' => 'pick-a-color',
                     'disabled' => true
                 ),
                 array(
@@ -633,7 +633,7 @@ function getCustomizeAppearance()
                     'name' => 'buttonTextHoverColor',
                     'label' => 'Button Hover Text Color',
                     'value' => $GLOBALS['buttonTextHoverColor'],
-                    'class' => 'colorpicker',
+                    'class' => 'pick-a-color',
                     'disabled' => true
                 ),*/
                 array(

+ 2 - 0
index.php

@@ -137,6 +137,8 @@
 	<script src="js/jquery.serializeToJSON.js"></script>
 	<script src="js/lazyload.min2.js"></script>
 	<script src="js/clipboard.js"></script>
+	<script src="js/jsColorPicker.min.js"></script>
+	<script src="js/jsColor.js"></script>
 	<script src="js/emulatetab.joelpurra.js"></script>
 	<script src="plugins/bower_components/ace/ace.js"></script>
 	<script src="plugins/bower_components/ace/mode-css.js"></script>

+ 19 - 1
js/custom.js

@@ -953,7 +953,16 @@ $(document).on("click", ".savecustomHTMLoneTextarea", function () {
 $(document).on("click", ".savecustomHTMLtwoTextarea", function () {
     $('.customHTMLtwoTextarea').val(customHTMLtwoEditor.getValue()).trigger('change');
 });
-$(document).on('change asColorPicker::close', '#customize-appearance-form :input', function(e) {
+
+$(document).on('focusout', 'input.pick-a-color', function(e) {
+    var original = $(this).attr('data-original');
+    var newValue = $(this).val();
+    if((original !== newValue) && (newValue !== '#987654') && newValue !== ''){
+        $(this).change();
+        $(this).attr('data-original', newValue);
+    }
+});
+$(document).on('change colorPicker::close', '#customize-appearance-form :input', function(e) {
     $(this).attr('data-changed', true);
     switch ($(this).attr('type')) {
         case 'switch':
@@ -982,6 +991,15 @@ $(document).on('change asColorPicker::close', '#customize-appearance-form :input
     if($(this).hasClass('styleChanger')){
         changeStyle(value);
     }
+    //disable button then renable
+    $('#customize-appearance-form:input').prop('disabled', 'true');
+    setTimeout(
+        function(){
+            $('#customize-appearance-form :input').prop('disabled', null);
+            //input.emulateTab();
+        },
+        2000
+    );
 
 });
 //DELETE IMAGE

+ 8 - 0
js/functions.js

@@ -890,6 +890,14 @@ function buildCustomizeAppearance(){
 				$('.saveCss').removeClass('hidden');
 			}
 		});
+		var colors = jsColorPicker('input.pick-a-color', {
+			customBG: '#222',
+			readOnly: false,
+			init: function(elm, colors) { // colors is a different instance (not connected to colorPicker)
+				elm.style.backgroundColor = elm.value;
+				elm.style.color = colors.rgbaMixCustom.luminance > 0.22 ? '#222' : '#ddd';
+			}
+		});
 	}).fail(function(xhr) {
 		console.error("Organizr Function: API Connection Failed");
 	});

+ 236 - 0
js/jqColorPicker.min.js

@@ -0,0 +1,236 @@
+(function (window) {
+	window.jsColorPicker = function(selectors, config) {
+		var renderCallback = function(colors, mode) {
+				var options = this,
+					input = options.input,
+					patch = options.patch,
+					RGB = colors.RND.rgb,
+					HSL = colors.RND.hsl,
+					AHEX = options.isIE8 ? (colors.alpha < 0.16 ? '0' : '') +
+						(Math.round(colors.alpha * 100)).toString(16).toUpperCase() + colors.HEX : '',
+					RGBInnerText = RGB.r + ', ' + RGB.g + ', ' + RGB.b,
+					RGBAText = 'rgba(' + RGBInnerText + ', ' + colors.alpha + ')',
+					isAlpha = colors.alpha !== 1 && !options.isIE8,
+					colorMode = input.getAttribute('data-colorMode');
+
+				patch.style.cssText =
+					'color:' + (colors.rgbaMixCustom.luminance > 0.22 ? '#222' : '#ddd') + ';' + // Black...???
+					'background-color:' + RGBAText + ';' +
+					'filter:' + (options.isIE8 ? 'progid:DXImageTransform.Microsoft.gradient(' + // IE<9
+						'startColorstr=#' + AHEX + ',' + 'endColorstr=#' + AHEX + ')' : '');
+
+				input.value = (colorMode === 'HEX' && !isAlpha ? '#' + (options.isIE8 ? AHEX : colors.HEX) :
+					colorMode === 'rgb' || (colorMode === 'HEX' && isAlpha) ?
+					(!isAlpha ? 'rgb(' + RGBInnerText + ')' : RGBAText) :
+					('hsl' + (isAlpha ? 'a(' : '(') + HSL.h + ', ' + HSL.s + '%, ' + HSL.l + '%' +
+						(isAlpha ? ', ' + colors.alpha : '') + ')')
+				);
+
+				if (options.displayCallback) {
+					options.displayCallback(colors, mode, options);
+				}
+			},
+			extractValue = function(elm) {
+				return elm.value || elm.getAttribute('value') || elm.style.backgroundColor || '#FFFFFF';
+			},
+			actionCallback = function(event, action) {
+				var options = this,
+					colorPicker = colorPickers.current;
+
+				if (action === 'toMemory') {
+					var memos = colorPicker.nodes.memos,
+						backgroundColor = '',
+						opacity = 0,
+						cookieTXT = [];
+
+					for (var n = 0, m = memos.length; n < m; n++) {
+						backgroundColor = memos[n].style.backgroundColor;
+						opacity = memos[n].style.opacity;
+						opacity = Math.round((opacity === '' ? 1 : opacity) * 100) / 100;
+						cookieTXT.push(backgroundColor.
+							replace(/, /g, ',').
+							replace('rgb(', 'rgba(').
+							replace(')', ',' + opacity + ')')
+						);
+					}
+					cookieTXT = '\'' + cookieTXT.join('\',\'') + '\'';
+					ColorPicker.docCookies('colorPickerMemos' + (options.noAlpha ? 'NoAlpha' : ''), cookieTXT);
+				} else if (action === 'resizeApp') {
+					ColorPicker.docCookies('colorPickerSize', colorPicker.color.options.currentSize);
+				} else if (action === 'modeChange') {
+					var mode = colorPicker.color.options.mode;
+
+					ColorPicker.docCookies('colorPickerMode', mode.type + '-' + mode.z);
+				}
+			},
+			createInstance = function(elm, config) {
+				var initConfig = {
+						klass: window.ColorPicker,
+						input: elm,
+						patch: elm,
+						isIE8: !!document.all && !document.addEventListener, // Opera???
+						// *** animationSpeed: 200,
+						// *** draggable: true,
+						margin: {left: -1, top: 2},
+						customBG: '#FFFFFF',
+						// displayCallback: displayCallback,
+						/* --- regular colorPicker options from this point --- */
+						color: extractValue(elm),
+						initStyle: 'display: none',
+						mode: ColorPicker.docCookies('colorPickerMode') || 'hsv-h',
+						// memoryColors: (function(colors, config) {
+						// 	return config.noAlpha ?
+						// 		colors.replace(/\,\d*\.*\d*\)/g, ',1)') : colors;
+						// })($.docCookies('colorPickerMemos'), config || {}),
+						memoryColors: ColorPicker.docCookies('colorPickerMemos' +
+							((config || {}).noAlpha ? 'NoAlpha' : '')),
+						size: ColorPicker.docCookies('colorPickerSize') || 1,
+						renderCallback: renderCallback,
+						actionCallback: actionCallback
+					};
+
+				for (var n in config) {
+					initConfig[n] = config[n]; 
+				}
+				return new initConfig.klass(initConfig);
+			},
+			doEventListeners = function(elm, multiple, off) {
+				var onOff = off ? 'removeEventListener' : 'addEventListener',
+					focusListener = function(e) {
+						var input = this,
+							position = window.ColorPicker.getOrigin(input),
+							index = multiple ? Array.prototype.indexOf.call(elms, this) : 0,
+							colorPicker = colorPickers[index] ||
+								(colorPickers[index] = createInstance(this, config)),
+							options = colorPicker.color.options,
+							colorPickerUI = colorPicker.nodes.colorPicker,
+							appendTo = (options.appendTo || document.body),
+							isStatic = /static/.test(window.getComputedStyle(appendTo).position),
+							atrect = isStatic ? {left: 0, top: 0} : appendTo.getBoundingClientRect(),
+							waitTimer = 0;
+
+						options.color = extractValue(elm); // brings color to default on reset
+						colorPickerUI.style.cssText = 
+							'position: absolute;' + (!colorPickers[index].cssIsReady ? 'display: none;' : '') +
+							'left:' + (position.left + options.margin.left - atrect.left) + 'px;' +
+							'top:' + (position.top + +input.offsetHeight + options.margin.top - atrect.top) + 'px;';
+
+						if (!multiple) {
+							options.input = elm;
+							options.patch = elm; // check again???
+							colorPicker.setColor(extractValue(elm), undefined, undefined, true);
+							colorPicker.saveAsBackground();
+						}
+						colorPickers.current = colorPickers[index];
+						appendTo.appendChild(colorPickerUI);
+						waitTimer = setInterval(function() { // compensating late style on onload in colorPicker
+							if (colorPickers.current.cssIsReady) {
+								waitTimer = clearInterval(waitTimer);
+								colorPickerUI.style.display = 'block';
+							}
+						}, 10);
+					},
+					mousDownListener = function(e) {
+						var colorPicker = colorPickers.current,
+							colorPickerUI = (colorPicker ? colorPicker.nodes.colorPicker : undefined),
+							animationSpeed = colorPicker ? colorPicker.color.options.animationSpeed : 0,
+							isColorPicker = colorPicker && (function(elm) {
+								while (elm) {
+									if ((elm.className || '').indexOf('cp-app') !== -1) return elm;
+									elm = elm.parentNode;
+								}
+								return false;
+							})(e.target),
+							inputIndex = Array.prototype.indexOf.call(elms, e.target);
+
+						if (isColorPicker && Array.prototype.indexOf.call(colorPickers, isColorPicker)) {
+							if (e.target === colorPicker.nodes.exit) {
+								colorPickerUI.style.display = 'none';
+								document.activeElement.blur();
+							} else {
+								// ...
+							}
+						} else if (inputIndex !== -1) {
+							// ...
+						} else if (colorPickerUI) {
+							colorPickerUI.style.display = 'none';
+						}
+					};
+
+				elm[onOff]('focus', focusListener);
+
+				if (!colorPickers.evt || off) {
+					colorPickers.evt = true; // prevent new eventListener for window
+
+					window[onOff]('mousedown', mousDownListener);
+				}
+			},
+			// this is a way to prevent data binding on HTMLElements
+			colorPickers = window.jsColorPicker.colorPickers || [],
+			elms = document.querySelectorAll(selectors),
+			testColors = new window.Colors({customBG: config.customBG, allMixDetails: true});
+
+		window.jsColorPicker.colorPickers = colorPickers;
+
+		for (var n = 0, m = elms.length; n < m; n++) {
+			var elm = elms[n];
+
+			if (config === 'destroy') {
+				doEventListeners(elm, (config && config.multipleInstances), true);
+				if (colorPickers[n]) {
+					colorPickers[n].destroyAll();
+				}
+			} else {
+				var color = extractValue(elm);
+				var value = color.split('(');
+
+				testColors.setColor(color);
+				if (config && config.init) {
+					config.init(elm, testColors.colors);
+				}
+				elm.setAttribute('data-colorMode', value[1] ? value[0].substr(0, 3) : 'HEX');
+				doEventListeners(elm, (config && config.multipleInstances), false);
+				if (config && config.readOnly) {
+					elm.readOnly = true;
+				}
+			}
+		};
+
+		return window.jsColorPicker.colorPickers;
+	};
+
+	window.ColorPicker.docCookies = function(key, val, options) {
+		var encode = encodeURIComponent, decode = decodeURIComponent,
+			cookies, n, tmp, cache = {},
+			days;
+
+		if (val === undefined) { // all about reading cookies
+			cookies = document.cookie.split(/;\s*/) || [];
+			for (n = cookies.length; n--; ) {
+				tmp = cookies[n].split('=');
+				if (tmp[0]) cache[decode(tmp.shift())] = decode(tmp.join('=')); // there might be '='s in the value...
+			}
+
+			if (!key) return cache; // return Json for easy access to all cookies
+			else return cache[key]; // easy access to cookies from here
+		} else { // write/delete cookie
+			options = options || {};
+
+			if (val === '' || options.expires < 0) { // prepare deleteing the cookie
+				options.expires = -1;
+				// options.path = options.domain = options.secure = undefined; // to make shure the cookie gets deleted...
+			}
+
+			if (options.expires !== undefined) { // prepare date if any
+				days = new Date();
+				days.setDate(days.getDate() + options.expires);
+			}
+
+			document.cookie = encode(key) + '=' + encode(val) +
+				(days            ? '; expires=' + days.toUTCString() : '') +
+				(options.path    ? '; path='    + options.path       : '') +
+				(options.domain  ? '; domain='  + options.domain     : '') +
+				(options.secure  ? '; secure'                        : '');
+		}
+	};
+})(this);

+ 236 - 0
js/jsColor.js

@@ -0,0 +1,236 @@
+(function (window) {
+	window.jsColorPicker = function(selectors, config) {
+		var renderCallback = function(colors, mode) {
+				var options = this,
+					input = options.input,
+					patch = options.patch,
+					RGB = colors.RND.rgb,
+					HSL = colors.RND.hsl,
+					AHEX = options.isIE8 ? (colors.alpha < 0.16 ? '0' : '') +
+						(Math.round(colors.alpha * 100)).toString(16).toUpperCase() + colors.HEX : '',
+					RGBInnerText = RGB.r + ', ' + RGB.g + ', ' + RGB.b,
+					RGBAText = 'rgba(' + RGBInnerText + ', ' + colors.alpha + ')',
+					isAlpha = colors.alpha !== 1 && !options.isIE8,
+					colorMode = input.getAttribute('data-colorMode');
+
+				patch.style.cssText =
+					'color:' + (colors.rgbaMixCustom.luminance > 0.22 ? '#222' : '#ddd') + ';' + // Black...???
+					'background-color:' + RGBAText + ';' +
+					'filter:' + (options.isIE8 ? 'progid:DXImageTransform.Microsoft.gradient(' + // IE<9
+						'startColorstr=#' + AHEX + ',' + 'endColorstr=#' + AHEX + ')' : '');
+
+				input.value = (colorMode === 'HEX' && !isAlpha ? '#' + (options.isIE8 ? AHEX : colors.HEX) :
+					colorMode === 'rgb' || (colorMode === 'HEX' && isAlpha) ?
+					(!isAlpha ? 'rgb(' + RGBInnerText + ')' : RGBAText) :
+					('hsl' + (isAlpha ? 'a(' : '(') + HSL.h + ', ' + HSL.s + '%, ' + HSL.l + '%' +
+						(isAlpha ? ', ' + colors.alpha : '') + ')')
+				);
+
+				if (options.displayCallback) {
+					options.displayCallback(colors, mode, options);
+				}
+			},
+			extractValue = function(elm) {
+				return elm.value || elm.getAttribute('value') || elm.style.backgroundColor || '#987654';
+			},
+			actionCallback = function(event, action) {
+				var options = this,
+					colorPicker = colorPickers.current;
+
+				if (action === 'toMemory') {
+					var memos = colorPicker.nodes.memos,
+						backgroundColor = '',
+						opacity = 0,
+						cookieTXT = [];
+
+					for (var n = 0, m = memos.length; n < m; n++) {
+						backgroundColor = memos[n].style.backgroundColor;
+						opacity = memos[n].style.opacity;
+						opacity = Math.round((opacity === '' ? 1 : opacity) * 100) / 100;
+						cookieTXT.push(backgroundColor.
+							replace(/, /g, ',').
+							replace('rgb(', 'rgba(').
+							replace(')', ',' + opacity + ')')
+						);
+					}
+					cookieTXT = '\'' + cookieTXT.join('\',\'') + '\'';
+					ColorPicker.docCookies('colorPickerMemos' + (options.noAlpha ? 'NoAlpha' : ''), cookieTXT);
+				} else if (action === 'resizeApp') {
+					ColorPicker.docCookies('colorPickerSize', colorPicker.color.options.currentSize);
+				} else if (action === 'modeChange') {
+					var mode = colorPicker.color.options.mode;
+
+					ColorPicker.docCookies('colorPickerMode', mode.type + '-' + mode.z);
+				}
+			},
+			createInstance = function(elm, config) {
+				var initConfig = {
+						klass: window.ColorPicker,
+						input: elm,
+						patch: elm,
+						isIE8: !!document.all && !document.addEventListener, // Opera???
+						// *** animationSpeed: 200,
+						// *** draggable: true,
+						margin: {left: -1, top: 2},
+						customBG: '#FFFFFF',
+						// displayCallback: displayCallback,
+						/* --- regular colorPicker options from this point --- */
+						color: extractValue(elm),
+						initStyle: 'display: none',
+						mode: ColorPicker.docCookies('colorPickerMode') || 'hsv-h',
+						// memoryColors: (function(colors, config) {
+						// 	return config.noAlpha ?
+						// 		colors.replace(/\,\d*\.*\d*\)/g, ',1)') : colors;
+						// })($.docCookies('colorPickerMemos'), config || {}),
+						memoryColors: ColorPicker.docCookies('colorPickerMemos' +
+							((config || {}).noAlpha ? 'NoAlpha' : '')),
+						size: ColorPicker.docCookies('colorPickerSize') || 1,
+						renderCallback: renderCallback,
+						actionCallback: actionCallback
+					};
+
+				for (var n in config) {
+					initConfig[n] = config[n];
+				}
+				return new initConfig.klass(initConfig);
+			},
+			doEventListeners = function(elm, multiple, off) {
+				var onOff = off ? 'removeEventListener' : 'addEventListener',
+					focusListener = function(e) {
+						var input = this,
+							position = window.ColorPicker.getOrigin(input),
+							index = multiple ? Array.prototype.indexOf.call(elms, this) : 0,
+							colorPicker = colorPickers[index] ||
+								(colorPickers[index] = createInstance(this, config)),
+							options = colorPicker.color.options,
+							colorPickerUI = colorPicker.nodes.colorPicker,
+							appendTo = (options.appendTo || document.body),
+							isStatic = /static/.test(window.getComputedStyle(appendTo).position),
+							atrect = isStatic ? {left: 0, top: 0} : appendTo.getBoundingClientRect(),
+							waitTimer = 0;
+
+						options.color = extractValue(elm); // brings color to default on reset
+						colorPickerUI.style.cssText =
+							'position: absolute;' + (!colorPickers[index].cssIsReady ? 'display: none;' : '') +
+							'left:' + (position.left + options.margin.left - atrect.left) + 'px;' +
+							'top:' + (position.top + +input.offsetHeight + options.margin.top - atrect.top) + 'px;';
+
+						if (!multiple) {
+							options.input = elm;
+							options.patch = elm; // check again???
+							colorPicker.setColor(extractValue(elm), undefined, undefined, true);
+							colorPicker.saveAsBackground();
+						}
+						colorPickers.current = colorPickers[index];
+						appendTo.appendChild(colorPickerUI);
+						waitTimer = setInterval(function() { // compensating late style on onload in colorPicker
+							if (colorPickers.current.cssIsReady) {
+								waitTimer = clearInterval(waitTimer);
+								colorPickerUI.style.display = 'block';
+							}
+						}, 10);
+					},
+					mousDownListener = function(e) {
+						var colorPicker = colorPickers.current,
+							colorPickerUI = (colorPicker ? colorPicker.nodes.colorPicker : undefined),
+							animationSpeed = colorPicker ? colorPicker.color.options.animationSpeed : 0,
+							isColorPicker = colorPicker && (function(elm) {
+								while (elm) {
+									if ((elm.className || '').indexOf('cp-app') !== -1) return elm;
+									elm = elm.parentNode;
+								}
+								return false;
+							})(e.target),
+							inputIndex = Array.prototype.indexOf.call(elms, e.target);
+
+						if (isColorPicker && Array.prototype.indexOf.call(colorPickers, isColorPicker)) {
+							if (e.target === colorPicker.nodes.exit) {
+								colorPickerUI.style.display = 'none';
+								document.activeElement.blur();
+							} else {
+								// ...
+							}
+						} else if (inputIndex !== -1) {
+							// ...
+						} else if (colorPickerUI) {
+							colorPickerUI.style.display = 'none';
+						}
+					};
+
+				elm[onOff]('focus', focusListener);
+
+				if (!colorPickers.evt || off) {
+					colorPickers.evt = true; // prevent new eventListener for window
+
+					window[onOff]('mousedown', mousDownListener);
+				}
+			},
+			// this is a way to prevent data binding on HTMLElements
+			colorPickers = window.jsColorPicker.colorPickers || [],
+			elms = document.querySelectorAll(selectors),
+			testColors = new window.Colors({customBG: config.customBG, allMixDetails: true});
+
+		window.jsColorPicker.colorPickers = colorPickers;
+
+		for (var n = 0, m = elms.length; n < m; n++) {
+			var elm = elms[n];
+
+			if (config === 'destroy') {
+				doEventListeners(elm, (config && config.multipleInstances), true);
+				if (colorPickers[n]) {
+					colorPickers[n].destroyAll();
+				}
+			} else {
+				var color = extractValue(elm);
+				var value = color.split('(');
+
+				testColors.setColor(color);
+				if (config && config.init) {
+					config.init(elm, testColors.colors);
+				}
+				elm.setAttribute('data-colorMode', value[1] ? value[0].substr(0, 3) : 'HEX');
+				doEventListeners(elm, (config && config.multipleInstances), false);
+				if (config && config.readOnly) {
+					elm.readOnly = true;
+				}
+			}
+		};
+
+		return window.jsColorPicker.colorPickers;
+	};
+
+	window.ColorPicker.docCookies = function(key, val, options) {
+		var encode = encodeURIComponent, decode = decodeURIComponent,
+			cookies, n, tmp, cache = {},
+			days;
+
+		if (val === undefined) { // all about reading cookies
+			cookies = document.cookie.split(/;\s*/) || [];
+			for (n = cookies.length; n--; ) {
+				tmp = cookies[n].split('=');
+				if (tmp[0]) cache[decode(tmp.shift())] = decode(tmp.join('=')); // there might be '='s in the value...
+			}
+
+			if (!key) return cache; // return Json for easy access to all cookies
+			else return cache[key]; // easy access to cookies from here
+		} else { // write/delete cookie
+			options = options || {};
+
+			if (val === '' || options.expires < 0) { // prepare deleteing the cookie
+				options.expires = -1;
+				// options.path = options.domain = options.secure = undefined; // to make shure the cookie gets deleted...
+			}
+
+			if (options.expires !== undefined) { // prepare date if any
+				days = new Date();
+				days.setDate(days.getDate() + options.expires);
+			}
+
+			document.cookie = encode(key) + '=' + encode(val) +
+				(days            ? '; expires=' + days.toUTCString() : '') +
+				(options.path    ? '; path='    + options.path       : '') +
+				(options.domain  ? '; domain='  + options.domain     : '') +
+				(options.secure  ? '; secure'                        : '');
+		}
+	};
+})(this);

Datei-Diff unterdrückt, da er zu groß ist
+ 2 - 0
js/jsColorPicker.min.js


Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden.