From 1659000cbbbdaf8b1f73e3eeaeb00183a838c40e Mon Sep 17 00:00:00 2001 From: brindosch Date: Thu, 29 Dec 2016 17:12:06 +0100 Subject: [PATCH] move eff_cp to global edt, update schema --- .../js/content_effectsconfigurator.js | 63 ------------------- assets/webconfig/js/lib/jsoneditor.js | 63 +++++++++++++++++++ .../hyperion/schemas/hyperion.schema-2.json | 32 +++++++--- 3 files changed, 87 insertions(+), 71 deletions(-) diff --git a/assets/webconfig/js/content_effectsconfigurator.js b/assets/webconfig/js/content_effectsconfigurator.js index 47d4e673..012a1b37 100644 --- a/assets/webconfig/js/content_effectsconfigurator.js +++ b/assets/webconfig/js/content_effectsconfigurator.js @@ -1,66 +1,3 @@ -JSONEditor.defaults.editors.colorPicker = JSONEditor.defaults.editors.string.extend({ - - getValue: function() { - if ($(this.input).data("colorpicker") !== undefined) { - var color = $(this.input).data('colorpicker').color.toRGB(); - return [color.r,color.g, color.b]; - } - else { - return [0,0,0]; - } - }, - - setValue: function(val) { - function rgb2hex(rgb) - { - return "#" + - ("0" + parseInt(rgb[0],10).toString(16)).slice(-2) + - ("0" + parseInt(rgb[1],10).toString(16)).slice(-2) + - ("0" + parseInt(rgb[2],10).toString(16)).slice(-2); - } - - $(this.input).colorpicker('updateInput', 'rgb('+val+')'); - $(this.input).colorpicker('updateData', val); - $(this.input).colorpicker('updatePicker', rgb2hex(val)); - $(this.input).colorpicker('updateComponent', 'rgb('+val+')'); - }, - - - - build: function() { - this._super(); - var myinput = this; - $(myinput.input).parent().attr("class", $(myinput.input).parent().attr('class') + " colorpicker-element input-group"); - $(myinput.input).append(""); - $(myinput.input).colorpicker({ - format: 'rgb', - customClass: 'colorpicker-2x', - sliders: { - saturation: { - maxLeft: 200, - maxTop: 200 - }, - hue: { - maxTop: 200 - }, - }, - }) - - $("#event_catcher").detach().insertAfter(myinput.input); - $("#event_catcher").attr("id", "selector"); - - $(this.input).colorpicker().on('changeColor', function(e) { - $(myinput).val(e.color.toRGB()).change(); - }); - } -}); - -JSONEditor.defaults.resolvers.unshift(function(schema) { - if(schema.type === "array" && schema.format === "colorpicker") { - return "colorPicker"; - } - -}); var oldDelList = []; diff --git a/assets/webconfig/js/lib/jsoneditor.js b/assets/webconfig/js/lib/jsoneditor.js index 4b144c53..e24b41e3 100755 --- a/assets/webconfig/js/lib/jsoneditor.js +++ b/assets/webconfig/js/lib/jsoneditor.js @@ -6162,6 +6162,63 @@ JSONEditor.defaults.editors.arraySelectize = JSONEditor.AbstractEditor.extend({ } }); +// colorpicker creation and handling, build on top of strings editor +JSONEditor.defaults.editors.colorPicker = JSONEditor.defaults.editors.string.extend({ + getValue: function() { + if ($(this.input).data("colorpicker") !== undefined) { + var color = $(this.input).data('colorpicker').color.toRGB(); + return [color.r,color.g, color.b]; + } + else { + return [0,0,0]; + } + }, + + setValue: function(val) { + function rgb2hex(rgb) + { + return "#" + + ("0" + parseInt(rgb[0],10).toString(16)).slice(-2) + + ("0" + parseInt(rgb[1],10).toString(16)).slice(-2) + + ("0" + parseInt(rgb[2],10).toString(16)).slice(-2); + } + + $(this.input).colorpicker('updateInput', 'rgb('+val+')'); + $(this.input).colorpicker('updateData', val); + $(this.input).colorpicker('updatePicker', rgb2hex(val)); + $(this.input).colorpicker('updateComponent', 'rgb('+val+')'); + }, + + + + build: function() { + this._super(); + var myinput = this; + $(myinput.input).parent().attr("class", $(myinput.input).parent().attr('class') + " colorpicker-element input-group"); + $(myinput.input).append(""); + $(myinput.input).colorpicker({ + format: 'rgb', + customClass: 'colorpicker-2x', + sliders: { + saturation: { + maxLeft: 200, + maxTop: 200 + }, + hue: { + maxTop: 200 + }, + }, + }) + + $("#event_catcher").detach().insertAfter(myinput.input); + $("#event_catcher").attr("id", "selector"); + + $(this.input).colorpicker().on('changeColor', function(e) { + $(myinput).val(e.color.toRGB()).change(); + }); + } +}); + var matchKey = (function () { var elem = document.documentElement; @@ -7017,6 +7074,12 @@ JSONEditor.defaults.resolvers.unshift(function(schema) { // If this schema uses `oneOf` or `anyOf` if(schema.oneOf || schema.anyOf) return "multiple"; }); +// colorpicker extend for strings +JSONEditor.defaults.resolvers.unshift(function(schema) { + if(schema.type === "array" && schema.format === "colorpicker") { + return "colorPicker"; + } +}); /** * This is a small wrapper for using JSON Editor like a typical jQuery plugin. diff --git a/libsrc/hyperion/schemas/hyperion.schema-2.json b/libsrc/hyperion/schemas/hyperion.schema-2.json index 7ea1ea41..13769cd9 100644 --- a/libsrc/hyperion/schemas/hyperion.schema-2.json +++ b/libsrc/hyperion/schemas/hyperion.schema-2.json @@ -134,6 +134,7 @@ "black" : { "type" : "array", + "format" : "colorpicker", "required" : true, "default": [0,0,0], "items" : { @@ -142,11 +143,13 @@ "maximum" : 255 }, "minItems" : 3, - "maxItems" : 3 + "maxItems" : 3, + "propertOrder" : 8 }, "white" : { "type" : "array", + "format" : "colorpicker", "required" : true, "default": [255,255,255], "items" : { @@ -155,11 +158,13 @@ "maximum" : 255 }, "minItems" : 3, - "maxItems" : 3 + "maxItems" : 3, + "propertOrder" : 1 }, "red" : { "type" : "array", + "format" : "colorpicker", "required" : true, "default": [255,0,0], "items" : { @@ -168,11 +173,13 @@ "maximum" : 255 }, "minItems" : 3, - "maxItems" : 3 + "maxItems" : 3, + "propertOrder" : 2 }, "green" : { "type" : "array", + "format" : "colorpicker", "required" : true, "default": [0,255,0], "items" : { @@ -181,11 +188,13 @@ "maximum" : 255 }, "minItems" : 3, - "maxItems" : 3 + "maxItems" : 3, + "propertOrder" : 3 }, "blue" : { "type" : "array", + "format" : "colorpicker", "required" : true, "default": [0,0,255], "items" : { @@ -194,11 +203,13 @@ "maximum" : 255 }, "minItems" : 3, - "maxItems" : 3 + "maxItems" : 3, + "propertOrder" : 4 }, "cyan" : { "type" : "array", + "format" : "colorpicker", "required" : true, "default": [0,255,255], "items" : { @@ -207,11 +218,13 @@ "maximum" : 255 }, "minItems" : 3, - "maxItems" : 3 + "maxItems" : 3, + "propertOrder" : 5 }, "magenta" : { "type" : "array", + "format" : "colorpicker", "required" : true, "default": [255,0,255], "items" : { @@ -220,11 +233,13 @@ "maximum" : 255 }, "minItems" : 3, - "maxItems" : 3 + "maxItems" : 3, + "propertOrder" : 6 }, "yellow" : { "type" : "array", + "format" : "colorpicker", "required" : true, "default": [255,255,0], "items" : { @@ -233,7 +248,8 @@ "maximum" : 255 }, "minItems" : 3, - "maxItems" : 3 + "maxItems" : 3, + "propertOrder" : 7 } }, "additionalProperties" : false