瀏覽代碼

'editableOption's are now full width. 'editableOptionShort' type added to replace the old style.

n1474335 6 年之前
父節點
當前提交
5acee80463
共有 3 個文件被更改,包括 32 次插入2 次删除
  1. 1 0
      src/core/Ingredient.mjs
  2. 2 2
      src/core/operations/Split.mjs
  3. 29 0
      src/web/HTMLIngredient.mjs

+ 1 - 0
src/core/Ingredient.mjs

@@ -95,6 +95,7 @@ class Ingredient {
             case "binaryString":
             case "binaryShortString":
             case "editableOption":
+            case "editableOptionShort":
                 return Utils.parseEscapedChars(data);
             case "byteArray":
                 if (typeof data == "string") {

+ 2 - 2
src/core/operations/Split.mjs

@@ -26,12 +26,12 @@ class Split extends Operation {
         this.args = [
             {
                 "name": "Split delimiter",
-                "type": "editableOption",
+                "type": "editableOptionShort",
                 "value": SPLIT_DELIM_OPTIONS
             },
             {
                 "name": "Join delimiter",
-                "type": "editableOption",
+                "type": "editableOptionShort",
                 "value": JOIN_DELIM_OPTIONS
             }
         ];

+ 29 - 0
src/web/HTMLIngredient.mjs

@@ -165,6 +165,35 @@ class HTMLIngredient {
                 this.manager.addDynamicListener("#" + this.id, "change", this.populateOptionChange, this);
                 break;
             case "editableOption":
+                html += `<div class="form-group input-group">
+                    <label for="${this.id}" class="bmd-label-floating">${this.name}</label>
+                    <input type="text"
+                        class="form-control arg"
+                        id="${this.id}"
+                        arg-name="${this.name}"
+                        value="${this.value[this.defaultIndex].value}"
+                        ${this.disabled ? "disabled" : ""}>
+                    ${this.hint ? "<span class='bmd-help'>" + this.hint + "</span>" : ""}
+                    <div class="input-group-append">
+                        <button type="button"
+                            class="btn btn-secondary dropdown-toggle dropdown-toggle-split"
+                            data-toggle="dropdown"
+                            data-boundary="scrollParent"
+                            aria-haspopup="true"
+                            aria-expanded="false">
+                            <span class="sr-only">Toggle Dropdown</span>
+                        </button>
+                        <div class="dropdown-menu editable-option-menu">`;
+                for (i = 0; i < this.value.length; i++) {
+                    html += `<a class="dropdown-item" href="#" value="${this.value[i].value}">${this.value[i].name}</a>`;
+                }
+                html += `</div>
+                    </div>
+                </div>`;
+
+                this.manager.addDynamicListener(".editable-option-menu a", "click", this.editableOptionClick, this);
+                break;
+            case "editableOptionShort":
                 html += `<div class="form-group input-group inline">
                     <label for="${this.id}" class="bmd-label-floating inline">${this.name}</label>
                     <input type="text"