@@ -117,12 +117,6 @@ function Pane(id) {
117
117
cloneButton . innerHTML = 'o' ;
118
118
cloneButton . title = 'disconnect' ;
119
119
120
- var saveButton = document . createElement ( 'a' ) ;
121
- saveButton . innerHTML = '⤓' ;
122
- saveButton . title = 'save' ;
123
- saveButton . download = 'untitled_image.jpg' ;
124
- saveButton . href = '' ;
125
-
126
120
var title = document . createElement ( 'div' ) ;
127
121
title . className = 'title' ;
128
122
@@ -135,14 +129,12 @@ function Pane(id) {
135
129
this . grip = grip ;
136
130
this . title = title ;
137
131
this . content = content ;
138
- this . saveButton = saveButton ;
139
132
140
133
el . appendChild ( grip ) ;
141
134
el . appendChild ( bar ) ;
142
135
el . appendChild ( content ) ;
143
136
bar . appendChild ( closeButton ) ;
144
137
bar . appendChild ( cloneButton ) ;
145
- bar . appendChild ( saveButton ) ;
146
138
bar . appendChild ( title ) ;
147
139
body . appendChild ( el ) ;
148
140
@@ -196,7 +188,6 @@ function Pane(id) {
196
188
Pane . prototype = {
197
189
setTitle : function ( title ) {
198
190
this . title . innerHTML = title ;
199
- this . saveButton . download = title . replace ( / \s + / g, '_' ) + '.jpg' ;
200
191
} ,
201
192
202
193
focus : function ( ) {
@@ -343,6 +334,12 @@ function ImagePane(id) {
343
334
var self = this
344
335
, content = this . content ;
345
336
337
+ var saveButton = document . createElement ( 'a' ) ;
338
+ saveButton . innerHTML = '⬇' ;
339
+ saveButton . title = 'save' ;
340
+ saveButton . download = 'untitled_image.jpg' ;
341
+ saveButton . href = '' ;
342
+
346
343
var image = document . createElement ( 'img' ) ;
347
344
image . className = 'content-image' ;
348
345
content . appendChild ( image ) ;
@@ -351,6 +348,10 @@ function ImagePane(id) {
351
348
labels . className = 'labels' ;
352
349
content . appendChild ( labels ) ;
353
350
351
+
352
+ this . bar . appendChild ( saveButton ) ;
353
+
354
+ this . saveButton = saveButton ;
354
355
this . content = image ;
355
356
this . labels = labels ;
356
357
this . width = 0 ;
@@ -379,8 +380,6 @@ function ImagePane(id) {
379
380
380
381
on ( image , 'load' , function ( ev ) {
381
382
if ( ( image . naturalWidth != self . width ) || ( image . naturalHeight != self . height ) ) {
382
- self . width = image . naturalWidth ;
383
- self . height = image . naturalHeight ;
384
383
self . reset ( ) ;
385
384
}
386
385
} ) ;
@@ -487,10 +486,13 @@ ImagePane.prototype = extend(Object.create(Pane.prototype), {
487
486
} ,
488
487
489
488
setContent : function ( content ) {
489
+
490
+ this . saveButton . href = content . src ;
491
+ this . saveButton . download = this . title . innerHTML . replace ( / \s + / g, '_' ) + '.jpg' ;
492
+
490
493
// Hack around unexpected behavior. Setting .src resets .style (except 'position: absolute').
491
494
var oldCss = this . content . style . cssText ;
492
495
this . content . src = content . src ;
493
- this . saveButton . href = content . src ;
494
496
this . content . style . cssText = oldCss ;
495
497
if ( this . content . style . cssText != oldCss ) {
496
498
this . content . style . cssText = oldCss ;
0 commit comments