|
|
|
@ -16,7 +16,7 @@ class SelectBox { |
|
|
|
let main = ` |
|
|
|
let main = ` |
|
|
|
<div class="row"> |
|
|
|
<div class="row"> |
|
|
|
<div class="col-lg-3 test"> |
|
|
|
<div class="col-lg-3 test"> |
|
|
|
<input class="select-box-search" type="text"> |
|
|
|
<input class="select-box-search" type="text" placeholder="Выберите/Поиск"> |
|
|
|
<button class="button-add options">добавить</button> |
|
|
|
<button class="button-add options">добавить</button> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class="col-lg-9"> |
|
|
|
<div class="col-lg-9"> |
|
|
|
@ -25,12 +25,12 @@ class SelectBox { |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
`;
|
|
|
|
`;
|
|
|
|
let child = ` |
|
|
|
let child = ` |
|
|
|
<input class="select-box-search" type="text"> |
|
|
|
<input class="select-box-search" type="text" placeholder="Выберите/Поиск"> |
|
|
|
<span style="clear:both; display:block"></span> |
|
|
|
<span style="clear:both; display:block"></span> |
|
|
|
<button class="button-add options">добавить</button> |
|
|
|
<button class="button-add options">добавить</button> |
|
|
|
`;
|
|
|
|
`;
|
|
|
|
let insert_template = editable_container ? main : child; |
|
|
|
let insert_template = editable_container ? main : child; |
|
|
|
vertical_child = vertical_child ? 'vertical-child': ''; |
|
|
|
vertical_child = vertical_child ? 'vertical-child' : ''; |
|
|
|
let htmlTemplate = |
|
|
|
let htmlTemplate = |
|
|
|
` |
|
|
|
` |
|
|
|
<span class="select-box-container ${vertical_child}" id="${id}"> |
|
|
|
<span class="select-box-container ${vertical_child}" id="${id}"> |
|
|
|
@ -106,16 +106,17 @@ class SelectBox { |
|
|
|
this.$search_input.val(""); |
|
|
|
this.$search_input.val(""); |
|
|
|
this.$options_box.hide(); |
|
|
|
this.$options_box.hide(); |
|
|
|
this.$results_box.hide(); |
|
|
|
this.$results_box.hide(); |
|
|
|
// this.$button_add.hide();
|
|
|
|
|
|
|
|
this.$button_add_options.hide(); |
|
|
|
this.$button_add_options.hide(); |
|
|
|
this.element_id = undefined; |
|
|
|
this.element_id = undefined; |
|
|
|
this.parent_id = undefined; |
|
|
|
this.parent_id = undefined; |
|
|
|
this.$editable_container.html(""); |
|
|
|
this.$editable_container.html(""); |
|
|
|
if (this.prev_select_box) this.hide(); |
|
|
|
if (this.prev_select_box) this.hide(); |
|
|
|
|
|
|
|
this.selected_id = undefined; |
|
|
|
|
|
|
|
this.selected_val = ""; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
clearAll(only_next) { |
|
|
|
clearAll(only_next) { |
|
|
|
console.log("only_next = ", only_next); |
|
|
|
// console.log("only_next = ", only_next);
|
|
|
|
if (this.next_select_box) { |
|
|
|
if (this.next_select_box) { |
|
|
|
this.next_select_box.clear() |
|
|
|
this.next_select_box.clear() |
|
|
|
} |
|
|
|
} |
|
|
|
@ -174,9 +175,10 @@ class SelectBox { |
|
|
|
this.clearAll(true); |
|
|
|
this.clearAll(true); |
|
|
|
let el_id = $(e.target).data("id"); |
|
|
|
let el_id = $(e.target).data("id"); |
|
|
|
this.selected_id = el_id; |
|
|
|
this.selected_id = el_id; |
|
|
|
|
|
|
|
this.selected_val = $(e.target).html(); |
|
|
|
this.updateEditableContainer(el_id); |
|
|
|
this.updateEditableContainer(el_id); |
|
|
|
this.$search_input.val($(e.target).html()); |
|
|
|
this.$search_input.val($(e.target).html()); |
|
|
|
this.element_id = el_id; |
|
|
|
// this.element_id = el_id;
|
|
|
|
if (this.next_select_box) { |
|
|
|
if (this.next_select_box) { |
|
|
|
this.next_select_box.setParent(el_id); |
|
|
|
this.next_select_box.setParent(el_id); |
|
|
|
this.next_select_box.setHeader($(e.target).html()); |
|
|
|
this.next_select_box.setHeader($(e.target).html()); |
|
|
|
@ -259,7 +261,11 @@ class SelectBox { |
|
|
|
_looseFocus() { |
|
|
|
_looseFocus() { |
|
|
|
this.$results_box.hide(); |
|
|
|
this.$results_box.hide(); |
|
|
|
this.$options_box.hide(); |
|
|
|
this.$options_box.hide(); |
|
|
|
if (!this.selected_id) this.$search_input.val(""); |
|
|
|
if (!this.selected_id) { |
|
|
|
|
|
|
|
this.$search_input.val(""); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
this.$search_input.val(this.selected_val); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
_bindEvents() { |
|
|
|
_bindEvents() { |
|
|
|
|