Permalink
Browse files

Adding refreshing image behaviour

  • Loading branch information...
Jake Archibald
Jake Archibald committed Aug 5, 2011
1 parent 1d3e1e4 commit a5d5a9964499f440c4e450a3d8419b4b401ea1e2
@@ -10,6 +10,7 @@ spriteCow.ImgInput = (function() {
imgInput.fileName = 'example.png';
imgInput._fileInput = $fileInput[0];
imgInput._addDropEvents($dropZone);
//imgInput._lastFile = undefined;
$fileInput.change(function(event) {
var file = this.files[0];
@@ -32,6 +33,7 @@ spriteCow.ImgInput = (function() {
var imgInput = this,
reader = new FileReader;
imgInput._lastFile = file;
imgInput.fileName = file.fileName;
reader.onload = function() {
@@ -83,6 +85,10 @@ spriteCow.ImgInput = (function() {
img.src = url;
};
ImgInputProto.reloadLastFile = function() {
this._lastFile && this._openFileAsImg( this._lastFile );
};
ImgInputProto.fileClickjackFor = function( $elm ) {
$elm.fileClickjack( this._fileInput );
};
@@ -4,7 +4,7 @@ spriteCow.Toolbar = (function() {
$container = $('' +
'<div class="toolbar">' +
'<div role="button" class="open-img"><div>Open</div></div>' +
'<div role="button" class="no-label reload-img"><div>Toggle Dark Background</div></div>' +
'<div role="button" class="no-label reload-img"><div>Reload current image</div></div>' +
'<div role="button" class="select-sprite active"><div>Select Sprite</div></div>' +
'<div role="button" class="pick-bg"><div>Pick Background</div></div>' +
'<div role="button" class="no-label invert-bg"><div>Toggle Dark Background</div></div>' +
@@ -14,6 +14,7 @@ spriteCow.Toolbar = (function() {
$children = $container.children(),
toolNames = [
'openImg',
'reloadImg',
'selectSprite',
'selectBg',
'invertBg',
@@ -69,6 +69,10 @@
toolbar.deactivate('selectBg').activate(toolName)
});
toolbar.bind('reloadImg', function() {
imgInput.reloadLastFile();
});
imgInput.fileClickjackFor( toolbar.$container.find('div.open-img') );
toolbar.bind('invertBg', function() {
@@ -478,6 +478,9 @@ body {
.toolbar .invert-bg div {
background-position: -867px -121px;
}
.toolbar .reload-img div {
background-position: -867px -164px;
}
/* Footer */
footer.main {
View
Binary file not shown.

0 comments on commit a5d5a99

Please sign in to comment.