Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d9d839e
commit 1ed3a22
Showing
5 changed files
with
74 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/bin/bash | ||
ver=8 | ||
cat www/assets/$ver/script/{jquery-1.7.1,jquery.easing,jquery.transition,jquery.fileClickjack,intro,MicroEvent,Rect,ImgInput,SpriteCanvas,SpriteCanvasView,CssOutput,Toolbar,pageLayout,FeatureTest,featureTests,base}.js | node bin/uglify.js > www/assets/$ver/script/mainmin.js | ||
cat www/assets/$ver/script/{jquery-1.7.1,jquery.easing,jquery.transition,jquery.fileClickjack,intro,MicroEvent,Rect,ImgInput,SpriteCanvas,SpriteCanvasView,InlineEdit,CssOutput,Toolbar,pageLayout,FeatureTest,featureTests,base}.js | node bin/uglify.js > www/assets/$ver/script/mainmin.js | ||
~/dev/sass/bin/sass --style compressed www/assets/$ver/style/all.scss:www/assets/$ver/style/all-min.css |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
(function() { | ||
function InlineEdit( $toWatch ) { | ||
var $input = $('<input type="text"/>').appendTo( $toWatch ); | ||
var inlineEdit = this; | ||
|
||
inlineEdit._$input = $input; | ||
inlineEdit._$editing = null; | ||
inlineEdit._inputBoxOffset = { | ||
top: -parseInt( $input.css('padding-top'), 10 ) - parseInt( $input.css('border-top-width'), 10 ), | ||
left: -parseInt( $input.css('padding-left'), 10 ) - parseInt( $input.css('border-left-width'), 10 ) | ||
}; | ||
|
||
$input.hide(); | ||
$toWatch.on('click', '[data-inline-edit]', function(event) { | ||
var $target = $(event.target); | ||
var $editing = inlineEdit._$editing; | ||
|
||
if ($editing && $target[0] === $editing[0]) { | ||
return; | ||
} | ||
inlineEdit.edit( $target ); | ||
event.preventDefault(); | ||
}); | ||
|
||
$input.blur(function() { | ||
inlineEdit.finishEdit(); | ||
}).keyup(function(event) { | ||
if (event.keyCode === 13) { | ||
$input[0].blur(); | ||
event.preventDefault(); | ||
} | ||
}); | ||
} | ||
|
||
var InlineEditProto = InlineEdit.prototype = new spriteCow.MicroEvent(); | ||
|
||
InlineEditProto.edit = function( $elm ) { | ||
$elm = $($elm); | ||
|
||
var position = $elm.position(); | ||
|
||
if (this._$editing) { | ||
this.finishEdit(); | ||
} | ||
|
||
this._$editing = $elm; | ||
this._$input.show().css({ | ||
top: position.top + this._inputBoxOffset.top, | ||
left: position.left + this._inputBoxOffset.left, | ||
width: Math.max( $elm.width(), 50 ) | ||
}).val( $elm.text() ).focus(); | ||
}; | ||
|
||
InlineEditProto.finishEdit = function() { | ||
if (!this._$editing) { return; } | ||
|
||
var newVal = this._$input.hide().val(); | ||
var event = new $.Event( this._$editing.data('inlineEdit') ); | ||
|
||
event.val = newVal; | ||
this.trigger( event ); | ||
this._$editing = null; | ||
}; | ||
|
||
spriteCow.InlineEdit = InlineEdit; | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters