56 } |
56 } |
57 } |
57 } |
58 this.offset = 0; |
58 this.offset = 0; |
59 } |
59 } |
60 |
60 |
61 foreach_widgets_do(new_offset, todo){ |
61 foreach_widgets_do(todo){ |
62 this.offset = new_offset; |
|
63 for(let i = 0; i < this.items.length; i++) { |
62 for(let i = 0; i < this.items.length; i++) { |
64 let item = this.items[i]; |
63 let item = this.items[i]; |
65 let orig_item_index = this.index_pool[i]; |
64 let orig_item_index = this.index_pool[i]; |
66 let item_index = this.index_pool[i+this.item_offset]; |
65 let item_index = this.index_pool[i+this.item_offset]; |
67 let item_index_offset = item_index - orig_item_index; |
66 let item_index_offset = item_index - orig_item_index; |
68 for(let widget of item) { |
67 for(let widget of item) { |
69 todo(widget).call(widget, new_offset + item_index_offset); |
68 todo(widget).call(widget, this.offset + item_index_offset); |
70 } |
69 } |
71 } |
70 } |
72 } |
71 } |
73 |
72 |
74 sub(new_offset=0){ |
73 sub(new_offset=0){ |
75 this.foreach_widgets_do(new_offset, w=>w.sub); |
74 this.offset = new_offset; |
|
75 this.foreach_widgets_do(w=>w.sub); |
76 } |
76 } |
77 |
77 |
78 apply_cache() { |
78 apply_cache() { |
79 this.foreach_widgets_do(this.offset, w=>w.apply_cache); |
79 this.foreach_widgets_do(w=>w.apply_cache); |
80 } |
80 } |
81 |
81 |
82 on_click(opstr, evt) { |
82 on_click(opstr, evt) { |
83 let new_item_offset = eval(String(this.item_offset)+opstr); |
83 let new_item_offset = eval(String(this.item_offset)+opstr); |
84 if(new_item_offset + this.items.length > this.index_pool.length) { |
84 if(new_item_offset + this.items.length > this.index_pool.length) { |