-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add "save image" button #29
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -117,6 +117,12 @@ function Pane(id) { | |
cloneButton.innerHTML = 'o'; | ||
cloneButton.title = 'disconnect'; | ||
|
||
var saveButton = document.createElement('a'); | ||
saveButton.innerHTML = '⤓'; | ||
saveButton.title = 'save'; | ||
saveButton.download = 'untitled_image.jpg'; | ||
saveButton.href = ''; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should make it show up only if the content is savable. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, I wasn't aware that the content can be unsavable. When can this happen? I thought the panes only show up for images and charts. |
||
|
||
var title = document.createElement('div'); | ||
title.className = 'title'; | ||
|
||
|
@@ -129,12 +135,14 @@ function Pane(id) { | |
this.grip = grip; | ||
this.title = title; | ||
this.content = content; | ||
this.saveButton = saveButton; | ||
|
||
el.appendChild(grip); | ||
el.appendChild(bar); | ||
el.appendChild(content); | ||
bar.appendChild(closeButton); | ||
bar.appendChild(cloneButton); | ||
bar.appendChild(saveButton); | ||
bar.appendChild(title); | ||
body.appendChild(el); | ||
|
||
|
@@ -188,6 +196,7 @@ function Pane(id) { | |
Pane.prototype = { | ||
setTitle: function(title) { | ||
this.title.innerHTML = title; | ||
this.saveButton.download = title.replace(/\s+/g, '_') + '.jpg'; | ||
}, | ||
|
||
focus: function() { | ||
|
@@ -481,6 +490,7 @@ ImagePane.prototype = extend(Object.create(Pane.prototype), { | |
// Hack around unexpected behavior. Setting .src resets .style (except 'position: absolute'). | ||
var oldCss = this.content.style.cssText; | ||
this.content.src = content.src; | ||
this.saveButton.href = content.src; | ||
this.content.style.cssText = oldCss; | ||
if (this.content.style.cssText != oldCss) { | ||
this.content.style.cssText = oldCss; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'd be nice to have something easier to read. The arrow is rather thin and hard to tell apart.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about http://www.fileformat.info/info/unicode/char/2b07/index.htm?