From ef6656c0f03be22af6edcde320e2cec744e23f7e Mon Sep 17 00:00:00 2001 From: Joe Levy Date: Fri, 24 Feb 2012 16:07:04 -0500 Subject: [PATCH 1/3] added confirm on delete --- src/onde.js | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/onde.js b/src/onde.js index 89da995..308b2ea 100644 --- a/src/onde.js +++ b/src/onde.js @@ -104,18 +104,22 @@ onde.Onde = function (formElement, schema, documentInst, opts) { this.panelElement.find('.field-delete').live('click', function (evt) { evt.preventDefault(); evt.stopPropagation(); //CHECK: Only if collapsible - $('#' + $(this).attr('data-id')).fadeOut('fast', function () { - // Change the item's and siblings' classes accordingly - //FIXME: This is unstable - if ($(this).hasClass('first')) { - $(this).next('li.field').addClass('first'); - } - if ($(this).hasClass('last')) { - $(this).prev('li.field').addClass('last'); - } - $(this).remove(); - }); + + if (confirm("Are you sure you want to delete?")) { + $('#' + $(this).attr('data-id')).fadeOut('fast', function () { + // Change the item's and siblings' classes accordingly + //FIXME: This is unstable + if ($(this).hasClass('first')) { + $(this).next('li.field').addClass('first'); + } + if ($(this).hasClass('last')) { + $(this).prev('li.field').addClass('last'); + } + $(this).remove(); + }); + } }); + // Type selector this.panelElement.find('.field-type-select').live('change', function (evt) { evt.preventDefault(); From cec580d3fa6e3a3aea98214345acdfb71f3ef651 Mon Sep 17 00:00:00 2001 From: Joe Levy Date: Fri, 24 Feb 2012 17:05:28 -0500 Subject: [PATCH 2/3] onde works better for schemas with additionalProperties at the top level, when starting data is defined --- samples/helloworld2.html | 156 +++++++++++++++++++++++++++++++++++++++ src/onde.js | 6 ++ 2 files changed, 162 insertions(+) create mode 100644 samples/helloworld2.html diff --git a/samples/helloworld2.html b/samples/helloworld2.html new file mode 100644 index 0000000..966d988 --- /dev/null +++ b/samples/helloworld2.html @@ -0,0 +1,156 @@ + + + + + JSON Editor + + + + + + +
+ +
+ +

+
+ + + + + + + + diff --git a/src/onde.js b/src/onde.js index 308b2ea..32236ed 100644 --- a/src/onde.js +++ b/src/onde.js @@ -163,6 +163,12 @@ onde.Onde.prototype.renderObject = function (schema, parentNode, namespace, data sortedKeys.push(propName); } } + // Check for additional properties + if(schema.additionalProperties) { + for (var propName in data) { + sortedKeys.push(propName); + } + } // Last property to be collected is the primary, if any. if (schema.primaryProperty) { sortedKeys.unshift(schema.primaryProperty); From 547b1d29ee1b68df2d8ffeb8e8b38670ceed769a Mon Sep 17 00:00:00 2001 From: Joe Levy Date: Fri, 24 Feb 2012 17:29:18 -0500 Subject: [PATCH 3/3] top level additional properties now keep there schema, and can be deleted --- src/onde.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/onde.js b/src/onde.js index 32236ed..49b9a2d 100644 --- a/src/onde.js +++ b/src/onde.js @@ -167,6 +167,8 @@ onde.Onde.prototype.renderObject = function (schema, parentNode, namespace, data if(schema.additionalProperties) { for (var propName in data) { sortedKeys.push(propName); + props[propName] = schema.additionalProperties; + props[propName]._deletable = true; } } // Last property to be collected is the primary, if any.