equal
deleted
inserted
replaced
39 }, |
39 }, |
40 on_forward_click:function(){ |
40 on_forward_click:function(){ |
41 this.move(true); |
41 this.move(true); |
42 }, |
42 }, |
43 set_selection: function(value) { |
43 set_selection: function(value) { |
44 this.text_elt.firstElementChild.textContent = |
44 let display_str; |
45 (value >= 0 && value < this.content.length) ? |
45 if(value >= 0 && value < this.content.length){ |
46 this.content[value] : "?"+String(value)+"?"; |
46 display_str = this.content[value]; |
|
47 this.last_selection = value; |
|
48 } else { |
|
49 display_str = "?"+String(value)+"?"; |
|
50 } |
|
51 this.text_elt.firstElementChild.textContent = display_str; |
47 }, |
52 }, |
48 grow_text: function(up_to) { |
53 grow_text: function(up_to) { |
49 let count = 1; |
54 let count = 1; |
50 let txt = this.text_elt; |
55 let txt = this.text_elt; |
51 let first = txt.firstElementChild; |
56 let first = txt.firstElementChild; |
148 this.reset_text(); |
153 this.reset_text(); |
149 let slots = this.grow_text(length); |
154 let slots = this.grow_text(length); |
150 if(slots == length) { |
155 if(slots == length) { |
151 this.set_complete_text(); |
156 this.set_complete_text(); |
152 } else { |
157 } else { |
|
158 // align to selection |
|
159 let offset = this.last_selection - this.lift; |
|
160 if(offset > 0) |
|
161 this.menu_offset = Math.min(offset + 1, length - slots + 1); |
|
162 else |
|
163 this.menu_offset = 0; |
153 this.set_partial_text(); |
164 this.set_partial_text(); |
154 } |
165 } |
155 this.adjust_box_to_text(); |
166 this.adjust_box_to_text(); |
156 this.element.removeChild(this.button_elt); |
167 this.element.removeChild(this.button_elt); |
157 this.element.parentNode.appendChild(this.element.parentNode.removeChild(this.element)); |
168 this.element.parentNode.appendChild(this.element.parentNode.removeChild(this.element)); |