Add loader

This commit is contained in:
Nicolas Le Goff
2012-10-19 14:16:34 +02:00
parent ec8d577a41
commit d0ad79c318
2 changed files with 28 additions and 18 deletions

View File

@@ -114,9 +114,12 @@
</tfoot>
</table>
{% endfor %}
<div class="form-actions">
<div class="form-actions" style="background:transparent">
<button type="button" class="btn btn-primary submiter">{% trans "Apply changes" %}</button>
<button type="button" class="btn cancel">{% trans "Cancel" %}</button>
<span class="form-action-loader" style="display:none;">
<img src="../skins/icons/loader414141.gif" />
</span>
</div>
</form>
</div>
@@ -139,6 +142,7 @@
$("button.submiter", $dialogBox).bind("click", function(){
var $this = $(this);
var form = $(this).closest("form");
var loader = form.find("form-action-loader");
$.ajax({
type: form.attr("method"),
@@ -147,13 +151,14 @@
dataType: 'json',
beforeSend:function(){
$this.attr("disabled", true);
//@todo add loader
loader.show();
},
success: function(data){
$dialog.Close();
},
complete: function(){
$this.attr("disabled", false);
loader.hide();
}
});
});

View File

@@ -1,18 +1,18 @@
{% import 'common/thumbnail.html.twig' as thumbnail %}
{% import "common/thumbnail.html.twig" as thumbnail %}
{% set typesEnum = [
constant('\\Alchemy\\Phrasea\\Media\\Type\\Type::TYPE_AUDIO'),
constant('\\Alchemy\\Phrasea\\Media\\Type\\Type::TYPE_VIDEO'),
constant('\\Alchemy\\Phrasea\\Media\\Type\\Type::TYPE_DOCUMENT'),
constant('\\Alchemy\\Phrasea\\Media\\Type\\Type::TYPE_FLASH'),
constant('\\Alchemy\\Phrasea\\Media\\Type\\Type::TYPE_IMAGE')
constant("\\Alchemy\\Phrasea\\Media\\Type\\Type::TYPE_AUDIO"),
constant("\\Alchemy\\Phrasea\\Media\\Type\\Type::TYPE_VIDEO"),
constant("\\Alchemy\\Phrasea\\Media\\Type\\Type::TYPE_DOCUMENT"),
constant("\\Alchemy\\Phrasea\\Media\\Type\\Type::TYPE_FLASH"),
constant("\\Alchemy\\Phrasea\\Media\\Type\\Type::TYPE_IMAGE")
]
%}
<form style='padding:15px;' name="change-records-type" action="/prod/records/property/type/" method="POST">
<div class='well-small 'style="text-align:center;">
<select name='force_types' style="width:250px">
<option value="">{% trans 'Apply to all selected documents' %}</option>
<form style="padding:15px;" name="change-records-type" action="/prod/records/property/type/" method="POST">
<div class="well-small" style="text-align:center;">
<select name="force_types" style="width:250px">
<option value="">{% trans "Apply to all selected documents" %}</option>
{% for option in typesEnum %}
<option value="{{ option }}">{{ option }}</option>
{% endfor %}
@@ -25,12 +25,12 @@
<ul class="thumbnails" style="margin:20px auto;">
{% for record in recordsByType %}
<li class="span2">
<div class="thumbnail" style='min-height:205px'>
{{ thumbnail.format(record.get_thumbnail(), 160, 120, '', false, false) }}
<div class="thumbnail" style="min-height:205px">
{{ thumbnail.format(record.get_thumbnail(), 160, 120, "", false, false) }}
<div class="caption">
<h5>{{ record.get_title() }}</h5>
<p>
<select name="types[{{record.get_serialize_key()}}]" style='width:100%'>
<select name="types[{{record.get_serialize_key()}}]" style="width:100%">
{% for option in typesEnum %}
<option value="{{ option }}" {{ record.is_grouping() ? "disabled='disabled'": "" }} {{ option == record.get_type() ? "selected='selected'" : '' }}>{{ option }}</option>
{% endfor %}
@@ -44,9 +44,12 @@
{% endfor %}
{% endfor %}
<div class="form-actions">
<div class="form-actions" style="background-color:transparent;">
<button type="button" class="btn btn-primary submiter">{% trans "Apply changes" %}</button>
<button type="button" class="btn cancel">{% trans "Cancel" %}</button>
<span class="form-action-loader" style="display:none;">
<img src="../skins/icons/loader414141.gif" />
</span>
</div>
</form>
@@ -57,21 +60,23 @@
$("button.submiter", $dialogBox).bind("click", function(){
var $this = $(this);
var form = $(this).closest("form");
var loader = form.find("form-action-loader");
$.ajax({
type: form.attr("method"),
url: form.attr("action"),
data: form.serializeArray(),
dataType: 'json',
dataType: "json",
beforeSend:function(){
$this.attr("disabled", true);
//@todo add loader
loader.show();
},
success: function(data){
$dialog.Close();
},
complete: function(){
$this.attr("disabled", false);
loader.hide();
}
});
});