- };
-
-
-
- PropertiesPerspective.prototype.addEditField = function(defn, value, elem) {
- let self = this;
- let $form = $("#properties-form", self.$pane);
-
- let $fg = $("<div class='form-group'>");
- $("<label/>").attr("for", "property-" + defn.name).text(defn.name).appendTo($fg);
- let $input;
- switch (defn.type) {
- case 'text':
- $input = $("<textarea>");
- break;
- case 'select':
- $input = $("<select>");
- $.each(defn.options, function(i, e) {
- $("<option>").text(e).appendTo($input);
- });
- break;
- case 'bool':
- $input = $("<input type='checkbox'>");
- break;
- default:
- $input = $("<input>");
+
+ addEditField(defn, value, elem) {
+ let self = this;
+ let $form = $("#properties-form", self.$pane);
+
+ let $fg = $("<div class='form-group'>");
+ $("<label/>").attr("for", "property-" + defn.name).text(defn.name).appendTo($fg);
+ let $input, $inputCnt;
+ switch (defn.type) {
+ case 'text':
+ $inputCnt =$input = $("<textarea>");
+ break;
+ case 'select':
+ $inputCnt = $input = $("<select>");
+ $.each(defn.options, function(i, e) {
+ $("<option>").text(e).appendTo($input);
+ });
+ break;
+ case 'bool':
+ $inputCnt = $input = $("<input type='checkbox'>");
+ break;
+ case 'media':
+ $inputCnt = $("<div class='media-input input-group'>");
+ $input = $("<input type='text'>");
+ $inputCnt.append($input);
+ $inputCnt.append($("<button type='button' class='ctrl-media-choose btn btn-primary' data-toggle='modal' data-target='#media-chooser'>…</button>"));
+ break;
+ default:
+ $inputCnt = $input = $("<input>");
+ }
+
+ $input.addClass("form-control").attr("id", "property-" + defn.name).data("property", defn.name);
+ if ($input.attr('type') == 'checkbox') {
+ $input.prop('checked', value == 'true');
+ } else {
+ $input.val(value);
+ }
+
+ if (elem) {
+ $input.data("edited", elem);
+ }
+ $inputCnt.appendTo($fg);
+
+ $fg.appendTo($form);