diff --git a/src/main/twirl/repo/blob.scala.html b/src/main/twirl/repo/blob.scala.html
index b13846b..06d8234 100644
--- a/src/main/twirl/repo/blob.scala.html
+++ b/src/main/twirl/repo/blob.scala.html
@@ -31,12 +31,12 @@
diff --git a/src/main/twirl/repo/editor.scala.html b/src/main/twirl/repo/editor.scala.html
index 77d1026..f78b9be 100644
--- a/src/main/twirl/repo/editor.scala.html
+++ b/src/main/twirl/repo/editor.scala.html
@@ -20,31 +20,22 @@
-
- @*
-
-
+
+
+
|
- *@
-
+
|
@@ -74,17 +65,24 @@
$('#editor').text($('#initial').val());
var editor = ace.edit("editor");
editor.setTheme("ace/theme/monokai");
- editor.getSession().setUseWrapMode(false);
+ //editor.getSession().setUseWrapMode(false);
@if(fileName.isDefined){
editor.getSession().setMode("ace/mode/@editorType(fileName.get)");
}
editor.on('change', function(){
- $('#commit').attr('disabled', editor.getValue() == $('#initial').val());
+ updateCommitButtonStatus();
});
- @*
+ function updateCommitButtonStatus(){
+ if(editor.getValue() == $('#initial').val() && $('#newFileName').val() == $('#oldFileName').val()){
+ $('#commit').attr('disabled', true);
+ } else {
+ $('#commit').attr('disabled', false);
+ }
+ }
+
$('#wrap').change(function(){
console.log($('#wrap option:selected').val());
if($('#wrap option:selected').val() == 'true'){
@@ -94,14 +92,12 @@
}
});
- $('#indent').change(function(){
- console.log($('#indent option:selected').val());
- editor.getSession().setUseWrapMode(parseInt($('#indent option:selected').val()));
+ $('#newFileName').watch(function(){
+ updateCommitButtonStatus();
});
- *@
$('#commit').click(function(){
$('#content').val(editor.getValue());
});
-})
+});
diff --git a/src/main/webapp/assets/common/js/gitbucket.js b/src/main/webapp/assets/common/js/gitbucket.js
index 26df149..02529ad 100644
--- a/src/main/webapp/assets/common/js/gitbucket.js
+++ b/src/main/webapp/assets/common/js/gitbucket.js
@@ -44,4 +44,26 @@
}
i++;
});
-}
\ No newline at end of file
+}
+
+(function($){
+ $.fn.watch = function(callback){
+ var timer = null;
+ var prevValue = this.val();
+
+ this.on('focus', function(e){
+ window.clearInterval(timer);
+ timer = window.setInterval(function(){
+ var newValue = $(e.target).val();
+ if(prevValue != newValue){
+ callback();
+ }
+ prevValue = newValue;
+ }, 10);
+ });
+
+ this.on('blur', function(){
+ window.clearInterval(timer);
+ });
+ };
+})(jQuery);
\ No newline at end of file