@@ -117,6 +117,12 @@ 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
+
120
126
var title = document . createElement ( 'div' ) ;
121
127
title . className = 'title' ;
122
128
@@ -129,12 +135,14 @@ function Pane(id) {
129
135
this . grip = grip ;
130
136
this . title = title ;
131
137
this . content = content ;
138
+ this . saveButton = saveButton ;
132
139
133
140
el . appendChild ( grip ) ;
134
141
el . appendChild ( bar ) ;
135
142
el . appendChild ( content ) ;
136
143
bar . appendChild ( closeButton ) ;
137
144
bar . appendChild ( cloneButton ) ;
145
+ bar . appendChild ( saveButton ) ;
138
146
bar . appendChild ( title ) ;
139
147
body . appendChild ( el ) ;
140
148
@@ -188,6 +196,7 @@ function Pane(id) {
188
196
Pane . prototype = {
189
197
setTitle : function ( title ) {
190
198
this . title . innerHTML = title ;
199
+ this . saveButton . download = title . replace ( / \s + / g, '_' ) + '.jpg' ;
191
200
} ,
192
201
193
202
focus : function ( ) {
@@ -481,6 +490,7 @@ ImagePane.prototype = extend(Object.create(Pane.prototype), {
481
490
// Hack around unexpected behavior. Setting .src resets .style (except 'position: absolute').
482
491
var oldCss = this . content . style . cssText ;
483
492
this . content . src = content . src ;
493
+ this . saveButton . href = content . src ;
484
494
this . content . style . cssText = oldCss ;
485
495
if ( this . content . style . cssText != oldCss ) {
486
496
this . content . style . cssText = oldCss ;
0 commit comments