Newer
Older
gitbucket_jkp / src / main / twirl / account / edit.scala.html
@takezoe takezoe on 10 Jul 2013 3 KB (refs #28)Fix information message.
@(account: Option[model.Account], info: Option[Any])(implicit context: app.Context)
@import context._
@import view.helpers._
@html.main((if(account.isDefined) "Edit your profile" else "Create your account")){
  @if(account.isDefined){
    <h3>Edit your profile</h3>
  } else {
    <h3>Create your account</h3>
  }
  @helper.html.information(info)
  <form action="@if(account.isDefined){@url(account.get.userName)/_edit}else{@path/register}" method="POST" validate="true">
    <div class="row-fluid">
      <div class="span6">
        @if(account.isEmpty){
          <fieldset>
            <label for="userName"><strong>User name</strong></label>
            <input type="text" name="userName" id="userName" value=""/>
            <span id="error-userName" class="error"></span>
          </fieldset>
        }
        <fieldset>
          <label for="password"><strong>Password</strong>
            @if(account.nonEmpty){
              (Input to change password)
            }
          </label>
          <input type="password" name="password" id="password" value=""/>
          <span id="error-password" class="error"></span>
        </fieldset>
        <fieldset>
          <label for="mailAddress"><strong>Mail Address</strong></label>
          <input type="text" name="mailAddress" id="mailAddress" value="@account.map(_.mailAddress)"/>
          <span id="error-mailAddress" class="error"></span>
        </fieldset>
        <fieldset>
          <label for="url"><strong>URL (Optional)</strong></label>
          <input type="text" name="url" id="url" style="width: 400px;" value="@account.map(_.url)"/>
          <span id="error-url" class="error"></span>
        </fieldset>
      </div>
      <div class="span6">
        <fieldset>
          <label for="avatar"><strong>Image (Optional)</strong></label>
          <div id="avatar" class="muted">
            @if(account.nonEmpty && account.get.image.nonEmpty){
              <img src="@path/@account.get.userName/_avatar" style="with: 120px; height: 120px;"/>
            } else {
              <div id="clickable">No Image</div>
            }
          </div>
          @if(account.nonEmpty && account.get.image.nonEmpty){
            <label>
              <input type="checkbox" name="clearImage"/> Clear image
            </label>
          }
          <input type="hidden" name="fileId" value=""/>
        </fieldset>
      </div>
    </div>
    <fieldset class="margin">
      @if(account.isDefined){
        <input type="submit" class="btn btn-success" value="Save"/>
        <a href="@url(account.get.userName)" class="btn">Cancel</a>
      } else {
        <input type="submit" class="btn btn-success" value="Create account"/>
      }
    </fieldset>
  </form>
}
<script>
$(function(){
  var dropzone = new Dropzone('div#clickable', {
    url: '@path/upload/image',
    previewsContainer: 'div#avatar',
    paramName: 'file',
    parallelUploads: 1,
    thumbnailWidth: 120,
    thumbnailHeight: 120
  });

  dropzone.on("success", function(file, id){
    $('div#clickable').remove();
    $('input[name=fileId]').val(id);
  });
});
</script>
<style type="text/css">
div.dz-filename, div.dz-size, div.dz-progress, div.dz-success-mark, div.dz-error-mark, div.dz-error-message {
  display: none;
}

div#clickable {
  width: 100%;
  text-align: center;
  line-height: 120px;
}

div#avatar {
  background-color: #f8f8f8;
  border: 1px dashed silver;
  width: 120px;
  height: 120px;
}
</style>