|
57 | 57 | if(splash){
|
58 | 58 | splash.remove();
|
59 | 59 | }
|
60 |
| - document.removeEventListener('dragover', FileDragHover, false); |
61 |
| - document.removeEventListener('dragleave', FileDragHover, false); |
62 |
| - document.removeEventListener('drop', FileDrop, false); |
63 | 60 | svgnest.setAttribute('style','display: block');
|
64 | 61 | }
|
65 | 62 |
|
|
146 | 143 | };
|
147 | 144 |
|
148 | 145 | function startnest(){
|
| 146 | + // Once started, don't allow this anymore |
| 147 | + document.removeEventListener('dragover', FileDragHover, false); |
| 148 | + document.removeEventListener('dragleave', FileDragHover, false); |
| 149 | + document.removeEventListener('drop', FileDrop, false); |
| 150 | + |
149 | 151 | SvgNest.start(progress, renderSvg);
|
150 | 152 | startlabel.innerHTML = 'Stop Nest';
|
151 | 153 | start.className = 'button spinner';
|
|
334 | 336 | if(reader.result){
|
335 | 337 | try{
|
336 | 338 | var svg = window.SvgNest.parsesvg(reader.result);
|
| 339 | + { |
| 340 | + var wholeSVG = document.createElementNS("http://www.w3.org/2000/svg", "svg"); |
| 341 | + // Copy relevant scaling info |
| 342 | + wholeSVG.setAttribute('width',svg.getAttribute('width')); |
| 343 | + wholeSVG.setAttribute('height',svg.getAttribute('height')); |
| 344 | + wholeSVG.setAttribute('viewBox',svg.getAttribute('viewBox')); |
| 345 | + var rect = document.createElementNS(wholeSVG.namespaceURI,'rect'); |
| 346 | + rect.setAttribute('x', wholeSVG.viewBox.baseVal.x); |
| 347 | + rect.setAttribute('y', wholeSVG.viewBox.baseVal.x); |
| 348 | + rect.setAttribute('width', wholeSVG.viewBox.baseVal.width); |
| 349 | + rect.setAttribute('height', wholeSVG.viewBox.baseVal.height); |
| 350 | + rect.setAttribute('class', 'fullRect'); |
| 351 | + wholeSVG.appendChild(rect); |
| 352 | + } |
337 | 353 | display.innerHTML = '';
|
| 354 | + display.appendChild(wholeSVG); // As a default bin in background |
338 | 355 | display.appendChild(svg);
|
339 | 356 | }
|
340 | 357 | catch(e){
|
|
349 | 366 | start.className = 'button start disabled';
|
350 | 367 |
|
351 | 368 | attachSvgListeners(svg);
|
| 369 | + attachSvgListeners(wholeSVG); |
352 | 370 | }
|
353 | 371 | }
|
354 | 372 |
|
|
366 | 384 | }
|
367 | 385 | var currentbin = document.querySelector('#select .active');
|
368 | 386 | if(currentbin){
|
369 |
| - currentbin.removeAttribute('class'); |
| 387 | + var className = currentbin.getAttribute('class').replace('active', '').trim(); |
| 388 | + if(!className) |
| 389 | + currentbin.removeAttribute('class'); |
| 390 | + else |
| 391 | + currentbin.setAttribute('class', className); |
370 | 392 | }
|
371 | 393 |
|
372 | 394 | window.SvgNest.setbin(this);
|
373 |
| - this.setAttribute('class','active'); |
| 395 | + this.setAttribute('class',(this.getAttribute('class') ? this.getAttribute('class')+' ' : '') + 'active'); |
374 | 396 |
|
375 | 397 | start.className = 'button start animated bounce';
|
376 | 398 | message.className = '';
|
|
0 commit comments