(main)
| 143 | } |
| 144 | |
| 145 | init(main) { |
| 146 | this.CLIP_DATA_MARKER = 'painterro-image-data'; |
| 147 | this.ctx = main.ctx; |
| 148 | this.main = main; |
| 149 | this.worklog = main.worklog; |
| 150 | this.selector = main.wrapper.querySelector('.ptro-paster-select-wrapper'); |
| 151 | this.cancelChoosing(); |
| 152 | this.img = null; |
| 153 | this.mimetype = null; // mime of pending image |
| 154 | this.getAvailableOptions().forEach((k) => { |
| 155 | const o = this.pasteOptions[k]; |
| 156 | this.main.getElemByIdSafe(o.id).onclick = () => { |
| 157 | if (this.loading) { |
| 158 | this.doLater = o.handle; |
| 159 | } else { |
| 160 | o.handle(this.img); |
| 161 | } |
| 162 | this.cancelChoosing(); |
| 163 | }; |
| 164 | }); |
| 165 | this.loading = false; |
| 166 | this.doLater = null; |
| 167 | } |
| 168 | |
| 169 | insert(x, y, w, h) { |
| 170 | this.main.ctx.drawImage(this.tmpImg, x, y, w, h); |
no test coverage detected