mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-07 14:05:52 +01:00
Upgrade to scalatra-forms 0.0.6.
This commit is contained in:
@@ -32,7 +32,7 @@ object MyBuild extends Build {
|
|||||||
"org.scalatra" %% "scalatra-specs2" % ScalatraVersion % "test",
|
"org.scalatra" %% "scalatra-specs2" % ScalatraVersion % "test",
|
||||||
"org.scalatra" %% "scalatra-json" % ScalatraVersion,
|
"org.scalatra" %% "scalatra-json" % ScalatraVersion,
|
||||||
"org.json4s" %% "json4s-jackson" % "3.2.5",
|
"org.json4s" %% "json4s-jackson" % "3.2.5",
|
||||||
"jp.sf.amateras" %% "scalatra-forms" % "0.0.4",
|
"jp.sf.amateras" %% "scalatra-forms" % "0.0.6",
|
||||||
"commons-io" % "commons-io" % "2.4",
|
"commons-io" % "commons-io" % "2.4",
|
||||||
"org.pegdown" % "pegdown" % "1.4.1",
|
"org.pegdown" % "pegdown" % "1.4.1",
|
||||||
"org.apache.commons" % "commons-compress" % "1.5",
|
"org.apache.commons" % "commons-compress" % "1.5",
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import app._
|
import app._
|
||||||
|
import jp.sf.amateras.scalatra.forms.ValidationJavaScriptProvider
|
||||||
import org.scalatra._
|
import org.scalatra._
|
||||||
import javax.servlet._
|
import javax.servlet._
|
||||||
|
|
||||||
@@ -20,6 +21,7 @@ class ScalatraBootstrap extends LifeCycle {
|
|||||||
context.mount(new IssuesController, "/*")
|
context.mount(new IssuesController, "/*")
|
||||||
context.mount(new PullRequestsController, "/*")
|
context.mount(new PullRequestsController, "/*")
|
||||||
context.mount(new RepositorySettingsController, "/*")
|
context.mount(new RepositorySettingsController, "/*")
|
||||||
|
context.mount(new ValidationJavaScriptProvider, "/assets/common/js/*")
|
||||||
|
|
||||||
val dir = new java.io.File(_root_.util.Directory.GitBucketHome)
|
val dir = new java.io.File(_root_.util.Directory.GitBucketHome)
|
||||||
if(!dir.exists){
|
if(!dir.exists){
|
||||||
|
|||||||
@@ -1,39 +0,0 @@
|
|||||||
$(function(){
|
|
||||||
$.each($('form[validate=true]'), function(i, form){
|
|
||||||
$(form).submit(validate);
|
|
||||||
});
|
|
||||||
$.each($('input[formaction]'), function(i, input){
|
|
||||||
$(input).click(function(){
|
|
||||||
var form = $(input).parents('form')
|
|
||||||
$(form).attr('action', $(input).attr('formaction'))
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
function validate(e){
|
|
||||||
var form = $(e.target);
|
|
||||||
|
|
||||||
if(form.data('validated') == true){
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
$.post(form.attr('action') + '/validate', $(e.target).serialize(), function(data){
|
|
||||||
// clear all error messages
|
|
||||||
$('.error').text('');
|
|
||||||
|
|
||||||
if($.isEmptyObject(data)){
|
|
||||||
form.data('validated', true);
|
|
||||||
form.submit();
|
|
||||||
} else {
|
|
||||||
form.data('validated', false);
|
|
||||||
displayErrors(data);
|
|
||||||
}
|
|
||||||
}, 'json');
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
function displayErrors(data){
|
|
||||||
$.each(data, function(key, value){
|
|
||||||
$('#error-' + key.split('.').join('_')).text(value);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user