equal
deleted
inserted
replaced
20 ``foreach "arg" | "«@value»", |
20 ``foreach "arg" | "«@value»", |
21 ]; |
21 ]; |
22 this.menu_offset = 0; |
22 this.menu_offset = 0; |
23 this.lift = 0; |
23 this.lift = 0; |
24 this.opened = false; |
24 this.opened = false; |
25 this.bound_inhibit_click_elsewhere = this.inhibit_click_elsewhere.bind(this); |
25 this.bound_close_on_click_elsewhere = this.close_on_click_elsewhere.bind(this); |
26 }, |
26 }, |
27 on_selection_click: function(selection) { |
27 on_selection_click: function(selection) { |
28 console.log("selected "+selection); |
28 console.log("selected "+selection); |
29 this.close(); |
29 this.close(); |
30 let orig = this.indexes[0]; |
30 let orig = this.indexes[0]; |
75 } |
75 } |
76 count++; |
76 count++; |
77 } |
77 } |
78 return count; |
78 return count; |
79 }, |
79 }, |
80 inhibit_click_elsewhere: function(e) { |
80 close_on_click_elsewhere: function(e) { |
81 console.log("inhibit", e); |
81 console.log("inhibit", e); |
82 console.log(e.target.parentNode, this.text_elt); |
82 console.log(e.target.parentNode, this.text_elt); |
83 if(e.target.parentNode !== this.text_elt) |
83 if(e.target.parentNode !== this.text_elt){ |
84 e.stopPropagation(); |
84 e.stopPropagation(); |
|
85 if(e.target !== this.box_elt) |
|
86 this.close(); |
|
87 } |
85 }, |
88 }, |
86 close: function(){ |
89 close: function(){ |
87 document.removeEventListener("click", this.bound_inhibit_click_elsewhere, true); |
90 document.removeEventListener("click", this.bound_close_on_click_elsewhere, true); |
88 this.reset_text(); |
91 this.reset_text(); |
89 this.reset_box(); |
92 this.reset_box(); |
90 this.element.appendChild(this.button_elt); |
93 this.element.appendChild(this.button_elt); |
91 this.opened = false; |
94 this.opened = false; |
92 this.apply_cache(); |
95 this.apply_cache(); |
151 } |
154 } |
152 this.adjust_box_to_text(); |
155 this.adjust_box_to_text(); |
153 this.element.removeChild(this.button_elt); |
156 this.element.removeChild(this.button_elt); |
154 this.element.parentNode.appendChild(this.element.parentNode.removeChild(this.element)); |
157 this.element.parentNode.appendChild(this.element.parentNode.removeChild(this.element)); |
155 // disable interaction with background |
158 // disable interaction with background |
156 document.addEventListener("click", this.bound_inhibit_click_elsewhere, true); |
159 document.addEventListener("click", this.bound_close_on_click_elsewhere, true); |
157 this.opened = true; |
160 this.opened = true; |
158 }, |
161 }, |
159 reset_text: function(){ |
162 reset_text: function(){ |
160 let txt = this.text_elt; |
163 let txt = this.text_elt; |
161 let first = txt.firstElementChild; |
164 let first = txt.firstElementChild; |