From 802ac33714e1b93d064cd7a854ab0442fffdba64 Mon Sep 17 00:00:00 2001 From: Ignacio del Valle Alles Date: Tue, 15 Mar 2016 15:06:40 +0100 Subject: [PATCH] add text area support (#17) --- dist/css/brutusin-json-forms.css | 218 ++++++++++++++--------------- dist/js/brutusin-json-forms.js | 2 + dist/js/brutusin-json-forms.min.js | 2 +- src/js/brutusin-json-forms.js | 2 + 4 files changed, 114 insertions(+), 110 deletions(-) diff --git a/dist/css/brutusin-json-forms.css b/dist/css/brutusin-json-forms.css index 517c181..92b5a38 100644 --- a/dist/css/brutusin-json-forms.css +++ b/dist/css/brutusin-json-forms.css @@ -1,109 +1,109 @@ -/* - * Copyright 2015 brutusin.org - * - * 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. - * - * @author Ignacio del Valle Alles idelvall@brutusin.org - */ -.loading-layer{ - position: absolute; - top:0px; - left:0px; - z-index : 10; - width: 100%; - height: 100%; - opacity: 0.7; - background-color: white; -} -.loading-icon{ - position: absolute; - top:14px; - left:50%; - z-index : 11; -} -.loading-icon-select{ - position: absolute; - top:14px; - left:50%; - z-index : 11; -} -.loading-icon-checkbox{ - position: absolute; - top:7px; - left:3px; - z-index : 11; -} -.glyphicon-refresh-animate { - animation: spin .7s infinite linear; - -webkit-animation: spin2 .7s infinite linear; -} - -@-webkit-keyframes spin2 { - from { -webkit-transform: rotate(0deg);} - to { -webkit-transform: rotate(360deg);} -} - -@keyframes spin { - from { transform: scale(1) rotate(0deg);} - to { transform: scale(1) rotate(360deg);} -} -form.brutusin-form table, form.brutusin-form input, form.brutusin-form select, form.brutusin-form textarea{ - width: 100% !important; - min-width: 80px; -} -form.brutusin-form input[type=checkbox]{ - width: auto !important; - min-width: auto !important; -} -form.brutusin-form textarea{ - height: 8em; -} -form.brutusin-form table table{ - border-left: solid 1px; - border-color: lightgray; - margin: 4px; -} -form.brutusin-form td { - vertical-align: top; - padding: 4px; - white-space: nowrap; -} -form.brutusin-form td.prop-name { - text-align: right; -} -form.brutusin-form td.add-prop-name table { - text-align: right; - border: none; -} -form.brutusin-form td.add-prop-name table td { - vertical-align: middle; -} -form.brutusin-form td.prop-value { - width: 100%; - text-align: left; -} -form.brutusin-form td.item-index{ - font-size: 0.8em; - color: lightgray; - width: 25px; - text-align: right; -} -form.brutusin-form td.item-action{ - width: 30px; -} -form.brutusin-form .error { - border-color: red; -} -form.brutusin-form .error-message { - color: red; -} +/* + * Copyright 2015 brutusin.org + * + * 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. + * + * @author Ignacio del Valle Alles idelvall@brutusin.org + */ +.loading-layer{ + position: absolute; + top:0px; + left:0px; + z-index : 10; + width: 100%; + height: 100%; + opacity: 0.7; + background-color: white; +} +.loading-icon{ + position: absolute; + top:14px; + left:50%; + z-index : 11; +} +.loading-icon-select{ + position: absolute; + top:14px; + left:50%; + z-index : 11; +} +.loading-icon-checkbox{ + position: absolute; + top:7px; + left:3px; + z-index : 11; +} +.glyphicon-refresh-animate { + animation: spin .7s infinite linear; + -webkit-animation: spin2 .7s infinite linear; +} + +@-webkit-keyframes spin2 { + from { -webkit-transform: rotate(0deg);} + to { -webkit-transform: rotate(360deg);} +} + +@keyframes spin { + from { transform: scale(1) rotate(0deg);} + to { transform: scale(1) rotate(360deg);} +} +form.brutusin-form table, form.brutusin-form input, form.brutusin-form select, form.brutusin-form textarea{ + width: 100% !important; + min-width: 80px; +} +form.brutusin-form input[type=checkbox]{ + width: auto !important; + min-width: auto !important; +} +form.brutusin-form textarea{ + height: 8em; +} +form.brutusin-form table table{ + border-left: solid 1px; + border-color: lightgray; + margin: 4px; +} +form.brutusin-form td { + vertical-align: top; + padding: 4px; + white-space: nowrap; +} +form.brutusin-form td.prop-name { + text-align: right; +} +form.brutusin-form td.add-prop-name table { + text-align: right; + border: none; +} +form.brutusin-form td.add-prop-name table td { + vertical-align: middle; +} +form.brutusin-form td.prop-value { + width: 100%; + text-align: left; +} +form.brutusin-form td.item-index{ + font-size: 0.8em; + color: lightgray; + width: 25px; + text-align: right; +} +form.brutusin-form td.item-action{ + width: 30px; +} +form.brutusin-form .error { + border-color: red; +} +form.brutusin-form .error-message { + color: red; +} diff --git a/dist/js/brutusin-json-forms.js b/dist/js/brutusin-json-forms.js index b3d9153..d988e29 100644 --- a/dist/js/brutusin-json-forms.js +++ b/dist/js/brutusin-json-forms.js @@ -196,6 +196,8 @@ if (typeof brutusin === "undefined") { } } else if (s.format === "email") { input.type = "email"; + } else if (s.format === "text") { + input = document.createElement("textarea"); } else { input.type = "text"; } diff --git a/dist/js/brutusin-json-forms.min.js b/dist/js/brutusin-json-forms.min.js index 92d6209..9aef13e 100644 --- a/dist/js/brutusin-json-forms.min.js +++ b/dist/js/brutusin-json-forms.min.js @@ -1 +1 @@ -if("undefined"==typeof brutusin)window.brutusin=new Object;else if("object"!=typeof brutusin)throw"brutusin global variable already exists";!function(){String.prototype.startsWith||(String.prototype.startsWith=function(e,t){return t=t||0,this.indexOf(e,t)===t}),String.prototype.endsWith||(String.prototype.endsWith=function(e,t){var n=this.toString();(void 0===t||t>n.length)&&(t=n.length),t-=e.length;var r=n.indexOf(e,t);return-1!==r&&r===t}),String.prototype.includes||(String.prototype.includes=function(){"use strict";return-1!==String.prototype.indexOf.apply(this,arguments)}),String.prototype.format||(String.prototype.format=function(){for(var e=this,t=0;t0)throw"Error parsing expression '"+e+"': Multiple tokens found inside a bracket";o+=s,i++}else n[n.length]=s;if(u===r.length-1&&a)throw"Error parsing expression '"+e+"': Unbalanced [ found"}this.exp=e,this.queue=n,this.visit=function(e,t){function n(e,r,a,i,o){if(null!=a){var u=r.shift();if("$"===u){e="$";var u=r.shift()}if(u)if(Array.isArray(a)){if(!u.startsWith("["))throw"Node '"+e+"' is of type array";var s=u.substring(1,u.length-1);if(s.equals("#"))for(var l=0;lc)throw"Element '"+s+"' of node '"+e+"' is lower than zero";var d=a[c];n(e+u,r.slice(0),d,a,c)}}else{if("object"!=typeof a)throw"boolean"==typeof a||"number"==typeof a||"string"==typeof a?"Node is leaf but still are tokens remaining: "+u:"Node type '"+typeof a+"' not supported for index field '"+e+"'";if("[*]"===u)for(var p in a){var d=a[p];n(e+u,r.slice(0),d,a,p),n(e+'["'+p+'"]',r.slice(0),d,a,p)}else{var d;if(u.startsWith("[")){var s=u.substring(1,u.length-1);if(!s.startsWith('"')&&!s.startsWith("'"))throw"Element '"+s+"' of node '"+e+"' must be a string expression or wilcard '*'";s=s.substring(1,s.length()-1),e+=u,d=a[s]}else e=e.length>0?e+"."+u:u,d=a[u];n(e,r,d,a,u)}}else t(a,i,o)}}n(this.exp,this.queue,e)}}var SCHEMA_ANY={type:"any"},obj=new Object,schemaMap=new Object,dependencyMap=new Object,renderInfoMap=new Object,container,data,error,initialValue,inputCounter=0,formId="BrutusinForms#"+BrutusinForms.instances.length;populateSchemaMap("$",schema),validateDepencyMapIsAcyclic();var renderers=new Object;return renderers.integer=function(e,t,n,r,a){renderers.string(e,t,n,r,a)},renderers.number=function(e,t,n,r,a){renderers.string(e,t,n,r,a)},renderers.any=function(e,t,n,r,a){renderers.string(e,t,n,r,a)},renderers.string=function(e,t,n,r,a){var i,o=getSchemaId(t),u=getSchema(o);if("any"===u.type)i=document.createElement("textarea"),a&&(i.value=JSON.stringify(a,null,4));else if(u["enum"]){if(i=document.createElement("select"),!u.required){var s=document.createElement("option"),l=document.createTextNode("");s.value="",appendChild(s,l,u),appendChild(i,s,u)}for(var d=0,c=0;ce.length))return BrutusinForms.messages.minLength.format(u.minLength);if(u.maxLength&&e&&u.maxLength=u.maximum)return BrutusinForms.messages.exclusiveMaximum.format(u.maximum);if(!u.exclusiveMaximum&&e>u.maximum)return BrutusinForms.messages.maximum.format(u.maximum)}if(u.hasOwnProperty("minimum")){if(u.exclusiveMinimum&&e<=u.minimum)return BrutusinForms.messages.exclusiveMinimum.format(u.minimum);if(!u.exclusiveMinimum&&es.maxProperties?BrutusinForms.messages.maxProperties.format(s.maxProperties):void 0}),x.description&&(C.title=x.description),appendChild(C,document.createTextNode("Add"),s),appendChild(w,C,s),a)for(var O in a)s.properties.hasOwnProperty(O)||o(l,d,t+'["'+m+'"]',O,a[O]);appendChild(e,w,s)}else appendChild(e,d,s)},renderers.array=function(e,t,n,r,a){function i(e,t,n,r){var a=getSchemaId(n),i=getSchema(a),o=document.createElement("tbody"),u=document.createElement("tr");u.className="item";var s=document.createElement("td");s.className="item-index";var l=document.createElement("td");l.className="item-action";var d=document.createElement("td");d.className="item-value";var c=document.createElement("button");c.setAttribute("type","button"),c.className="remove",appendChild(c,document.createTextNode("x"),i);var p=function(){for(var e=0;ec.rows.length?BrutusinForms.messages.minItems.format(u.minItems):u.maxItems&&u.maxItemsn.length)&&(t=n.length),t-=e.length;var r=n.indexOf(e,t);return-1!==r&&r===t}),String.prototype.includes||(String.prototype.includes=function(){"use strict";return-1!==String.prototype.indexOf.apply(this,arguments)}),String.prototype.format||(String.prototype.format=function(){for(var e=this,t=0;t0)throw"Error parsing expression '"+e+"': Multiple tokens found inside a bracket";o+=s,i++}else n[n.length]=s;if(u===r.length-1&&a)throw"Error parsing expression '"+e+"': Unbalanced [ found"}this.exp=e,this.queue=n,this.visit=function(e,t){function n(e,r,a,i,o){if(null!=a){var u=r.shift();if("$"===u){e="$";var u=r.shift()}if(u)if(Array.isArray(a)){if(!u.startsWith("["))throw"Node '"+e+"' is of type array";var s=u.substring(1,u.length-1);if(s.equals("#"))for(var l=0;lc)throw"Element '"+s+"' of node '"+e+"' is lower than zero";var d=a[c];n(e+u,r.slice(0),d,a,c)}}else{if("object"!=typeof a)throw"boolean"==typeof a||"number"==typeof a||"string"==typeof a?"Node is leaf but still are tokens remaining: "+u:"Node type '"+typeof a+"' not supported for index field '"+e+"'";if("[*]"===u)for(var m in a){var d=a[m];n(e+u,r.slice(0),d,a,m),n(e+'["'+m+'"]',r.slice(0),d,a,m)}else{var d;if(u.startsWith("[")){var s=u.substring(1,u.length-1);if(!s.startsWith('"')&&!s.startsWith("'"))throw"Element '"+s+"' of node '"+e+"' must be a string expression or wilcard '*'";s=s.substring(1,s.length()-1),e+=u,d=a[s]}else e=e.length>0?e+"."+u:u,d=a[u];n(e,r,d,a,u)}}else t(a,i,o)}}n(this.exp,this.queue,e)}}var SCHEMA_ANY={type:"any"},obj=new Object,schemaMap=new Object,dependencyMap=new Object,renderInfoMap=new Object,container,data,error,initialValue,inputCounter=0,formId="BrutusinForms#"+BrutusinForms.instances.length;populateSchemaMap("$",schema),validateDepencyMapIsAcyclic();var renderers=new Object;return renderers.integer=function(e,t,n,r,a){renderers.string(e,t,n,r,a)},renderers.number=function(e,t,n,r,a){renderers.string(e,t,n,r,a)},renderers.any=function(e,t,n,r,a){renderers.string(e,t,n,r,a)},renderers.string=function(e,t,n,r,a){var i,o=getSchemaId(t),u=getSchema(o);if("any"===u.type)i=document.createElement("textarea"),a&&(i.value=JSON.stringify(a,null,4));else if(u["enum"]){if(i=document.createElement("select"),!u.required){var s=document.createElement("option"),l=document.createTextNode("");s.value="",appendChild(s,l,u),appendChild(i,s,u)}for(var d=0,c=0;ce.length))return BrutusinForms.messages.minLength.format(u.minLength);if(u.maxLength&&e&&u.maxLength=u.maximum)return BrutusinForms.messages.exclusiveMaximum.format(u.maximum);if(!u.exclusiveMaximum&&e>u.maximum)return BrutusinForms.messages.maximum.format(u.maximum)}if(u.hasOwnProperty("minimum")){if(u.exclusiveMinimum&&e<=u.minimum)return BrutusinForms.messages.exclusiveMinimum.format(u.minimum);if(!u.exclusiveMinimum&&es.maxProperties?BrutusinForms.messages.maxProperties.format(s.maxProperties):void 0}),x.description&&(C.title=x.description),appendChild(C,document.createTextNode("Add"),s),appendChild(w,C,s),a)for(var O in a)s.properties.hasOwnProperty(O)||o(l,d,t+'["'+p+'"]',O,a[O]);appendChild(e,w,s)}else appendChild(e,d,s)},renderers.array=function(e,t,n,r,a){function i(e,t,n,r){var a=getSchemaId(n),i=getSchema(a),o=document.createElement("tbody"),u=document.createElement("tr");u.className="item";var s=document.createElement("td");s.className="item-index";var l=document.createElement("td");l.className="item-action";var d=document.createElement("td");d.className="item-value";var c=document.createElement("button");c.setAttribute("type","button"),c.className="remove",appendChild(c,document.createTextNode("x"),i);var m=function(){for(var e=0;ec.rows.length?BrutusinForms.messages.minItems.format(u.minItems):u.maxItems&&u.maxItems