Added an ajax indicator for all ajax calls. Also removed highlight effects on my page layout edition.

git-svn-id: http://redmine.rubyforge.org/svn/trunk@485 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2007-04-27 19:32:57 +00:00
parent c1a18a2889
commit 5db3396c07
14 changed files with 68 additions and 31 deletions

View File

@ -115,12 +115,16 @@
</ul> </ul>
<% end %> <% end %>
</div> </div>
<div id="content"> <div id="content">
<% if flash[:notice] %><p style="color: green"><%= flash[:notice] %></p><% end %> <% if flash[:notice] %><p style="color: green"><%= flash[:notice] %></p><% end %>
<%= yield %> <%= yield %>
</div> </div>
<div id="ajax-indicator" style="display:none;">
<span><%= l(:label_loading) %></span>
</div>
<div id="footer"> <div id="footer">
<p><a href="http://redmine.rubyforge.org/">redMine</a> <small><%= Redmine::VERSION %> &copy 2006-2007 Jean-Philippe Lang</small></p> <p><a href="http://redmine.rubyforge.org/">redMine</a> <small><%= Redmine::VERSION %> &copy 2006-2007 Jean-Philippe Lang</small></p>
</div> </div>

View File

@ -3,9 +3,7 @@
<div style="float:right;margin-right:16px;z-index:500;"> <div style="float:right;margin-right:16px;z-index:500;">
<%= link_to_remote "", { <%= link_to_remote "", {
:url => { :action => "remove_block", :block => block_name }, :url => { :action => "remove_block", :block => block_name },
:complete => "removeBlock('block_#{block_name}')", :complete => "removeBlock('block_#{block_name}')" },
:loading => "Element.show('indicator')",
:loaded => "Element.hide('indicator')" },
:class => "close-icon" :class => "close-icon"
%> %>
</div> </div>

View File

@ -5,9 +5,9 @@ function recreateSortables() {
Sortable.destroy('list-left'); Sortable.destroy('list-left');
Sortable.destroy('list-right'); Sortable.destroy('list-right');
Sortable.create("list-top", {constraint:false, containment:['list-top','list-left','list-right'], dropOnEmpty:true, handle:'handle', onUpdate:function(){new Ajax.Request('/my/order_blocks?group=top', {asynchronous:true, evalScripts:true, onComplete:function(request){new Effect.Highlight("list-top",{});}, onLoaded:function(request){Element.hide('indicator')}, onLoading:function(request){Element.show('indicator')}, parameters:Sortable.serialize("list-top")})}, only:'mypage-box', tag:'div'}) Sortable.create("list-top", {constraint:false, containment:['list-top','list-left','list-right'], dropOnEmpty:true, handle:'handle', onUpdate:function(){new Ajax.Request('/my/order_blocks?group=top', {asynchronous:true, evalScripts:true, parameters:Sortable.serialize("list-top")})}, only:'mypage-box', tag:'div'})
Sortable.create("list-left", {constraint:false, containment:['list-top','list-left','list-right'], dropOnEmpty:true, handle:'handle', onUpdate:function(){new Ajax.Request('/my/order_blocks?group=left', {asynchronous:true, evalScripts:true, onComplete:function(request){new Effect.Highlight("list-left",{});}, onLoaded:function(request){Element.hide('indicator')}, onLoading:function(request){Element.show('indicator')}, parameters:Sortable.serialize("list-left")})}, only:'mypage-box', tag:'div'}) Sortable.create("list-left", {constraint:false, containment:['list-top','list-left','list-right'], dropOnEmpty:true, handle:'handle', onUpdate:function(){new Ajax.Request('/my/order_blocks?group=left', {asynchronous:true, evalScripts:true, parameters:Sortable.serialize("list-left")})}, only:'mypage-box', tag:'div'})
Sortable.create("list-right", {constraint:false, containment:['list-top','list-left','list-right'], dropOnEmpty:true, handle:'handle', onUpdate:function(){new Ajax.Request('/my/order_blocks?group=right', {asynchronous:true, evalScripts:true, onComplete:function(request){new Effect.Highlight("list-right",{});}, onLoaded:function(request){Element.hide('indicator')}, onLoading:function(request){Element.show('indicator')}, parameters:Sortable.serialize("list-right")})}, only:'mypage-box', tag:'div'}) Sortable.create("list-right", {constraint:false, containment:['list-top','list-left','list-right'], dropOnEmpty:true, handle:'handle', onUpdate:function(){new Ajax.Request('/my/order_blocks?group=right', {asynchronous:true, evalScripts:true, parameters:Sortable.serialize("list-right")})}, only:'mypage-box', tag:'div'})
} }
function updateSelect() { function updateSelect() {
@ -35,7 +35,6 @@ function removeBlock(block) {
</script> </script>
<div class="contextual"> <div class="contextual">
<span id="indicator" style="display:none"><%= image_tag "loading.gif", :align => "absmiddle" %></span>
<% form_tag({:action => "add_block"}, :id => "block-form") do %> <% form_tag({:action => "add_block"}, :id => "block-form") do %>
<%= select_tag 'block', "<option></option>" + options_for_select(@block_options), :id => "block-select" %> <%= select_tag 'block', "<option></option>" + options_for_select(@block_options), :id => "block-select" %>
<%= link_to_remote l(:button_add), <%= link_to_remote l(:button_add),
@ -43,9 +42,7 @@ function removeBlock(block) {
:with => "Form.serialize('block-form')", :with => "Form.serialize('block-form')",
:update => "list-top", :update => "list-top",
:position => :top, :position => :top,
:complete => "afterAddBlock();", :complete => "afterAddBlock();"
:loading => "Element.show('indicator')",
:loaded => "Element.hide('indicator')"
}, :class => 'icon icon-add' }, :class => 'icon icon-add'
%> %>
<% end %> <% end %>
@ -83,10 +80,7 @@ function removeBlock(block) {
:dropOnEmpty => true, :dropOnEmpty => true,
:containment => ['list-top', 'list-left', 'list-right'], :containment => ['list-top', 'list-left', 'list-right'],
:constraint => false, :constraint => false,
:complete => visual_effect(:highlight, 'list-top'), :url => { :action => "order_blocks", :group => "top" }
:url => { :action => "order_blocks", :group => "top" },
:loading => "Element.show('indicator')",
:loaded => "Element.hide('indicator')"
%> %>
@ -97,10 +91,8 @@ function removeBlock(block) {
:dropOnEmpty => true, :dropOnEmpty => true,
:containment => ['list-top', 'list-left', 'list-right'], :containment => ['list-top', 'list-left', 'list-right'],
:constraint => false, :constraint => false,
:complete => visual_effect(:highlight, 'list-left'), :url => { :action => "order_blocks", :group => "left" }
:url => { :action => "order_blocks", :group => "left" }, %>
:loading => "Element.show('indicator')",
:loaded => "Element.hide('indicator')" %>
<%= sortable_element 'list-right', <%= sortable_element 'list-right',
:tag => 'div', :tag => 'div',
@ -109,9 +101,7 @@ function removeBlock(block) {
:dropOnEmpty => true, :dropOnEmpty => true,
:containment => ['list-top', 'list-left', 'list-right'], :containment => ['list-top', 'list-left', 'list-right'],
:constraint => false, :constraint => false,
:complete => visual_effect(:highlight, 'list-right'), :url => { :action => "order_blocks", :group => "right" }
:url => { :action => "order_blocks", :group => "right" }, %>
:loading => "Element.show('indicator')",
:loaded => "Element.hide('indicator')" %>
<%= javascript_tag "updateSelect()" %> <%= javascript_tag "updateSelect()" %>

View File

@ -18,12 +18,8 @@
{ :url => { :controller => 'wiki', :action => 'preview', :id => @project, :page => @page.title }, { :url => { :controller => 'wiki', :action => 'preview', :id => @project, :page => @page.title },
:method => 'get', :method => 'get',
:update => 'preview', :update => 'preview',
:with => "Form.serialize('wiki_form')", :with => "Form.serialize('wiki_form')"
:loading => "Element.show('indicator')", } %></p>
:loaded => "Element.hide('indicator')"
} %>
<span id="indicator" style="display:none"><%= image_tag "loading.gif", :align => "absmiddle" %></span>
</p>
<% end %> <% end %>

View File

@ -362,6 +362,7 @@ label_permissions_report: Permissions report
label_watched_issues: Watched issues label_watched_issues: Watched issues
label_related_issues: Related issues label_related_issues: Related issues
label_applied_status: Applied status label_applied_status: Applied status
label_loading: Loading...
button_login: Einloggen button_login: Einloggen
button_submit: OK button_submit: OK

View File

@ -362,6 +362,7 @@ label_permissions_report: Permissions report
label_watched_issues: Watched issues label_watched_issues: Watched issues
label_related_issues: Related issues label_related_issues: Related issues
label_applied_status: Applied status label_applied_status: Applied status
label_loading: Loading...
button_login: Login button_login: Login
button_submit: Submit button_submit: Submit

View File

@ -362,6 +362,7 @@ label_permissions_report: Permissions report
label_watched_issues: Watched issues label_watched_issues: Watched issues
label_related_issues: Related issues label_related_issues: Related issues
label_applied_status: Applied status label_applied_status: Applied status
label_loading: Loading...
button_login: Conexión button_login: Conexión
button_submit: Someter button_submit: Someter

View File

@ -362,6 +362,7 @@ label_permissions_report: Synthèse des permissions
label_watched_issues: Demandes surveillées label_watched_issues: Demandes surveillées
label_related_issues: Demandes liées label_related_issues: Demandes liées
label_applied_status: Statut appliqué label_applied_status: Statut appliqué
label_loading: Chargement...
button_login: Connexion button_login: Connexion
button_submit: Soumettre button_submit: Soumettre

View File

@ -362,6 +362,7 @@ label_permissions_report: Report permessi
label_watched_issues: Watched issues label_watched_issues: Watched issues
label_related_issues: Related issues label_related_issues: Related issues
label_applied_status: Applied status label_applied_status: Applied status
label_loading: Loading...
button_login: Login button_login: Login
button_submit: Invia button_submit: Invia

View File

@ -363,6 +363,7 @@ label_permissions_report: 権限レポート
label_watched_issues: Watched issues label_watched_issues: Watched issues
label_related_issues: Related issues label_related_issues: Related issues
label_applied_status: Applied status label_applied_status: Applied status
label_loading: Loading...
button_login: ログイン button_login: ログイン
button_submit: 変更 button_submit: 変更

View File

@ -362,6 +362,7 @@ label_permissions_report: Relatorio de permissoes
label_watched_issues: Watched issues label_watched_issues: Watched issues
label_related_issues: Related issues label_related_issues: Related issues
label_applied_status: Applied status label_applied_status: Applied status
label_loading: Loading...
button_login: Login button_login: Login
button_submit: Enviar button_submit: Enviar

View File

@ -365,6 +365,7 @@ label_permissions_report: Permissions report
label_watched_issues: Watched issues label_watched_issues: Watched issues
label_related_issues: Related issues label_related_issues: Related issues
label_applied_status: Applied status label_applied_status: Applied status
label_loading: Loading...
button_login: 登录 button_login: 登录
button_submit: 提交 button_submit: 提交

View File

@ -30,4 +30,18 @@ function showTab(name) {
Element.show('tab-content-' + name); Element.show('tab-content-' + name);
Element.addClassName('tab-' + name, "selected"); Element.addClassName('tab-' + name, "selected");
return false; return false;
} }
/* shows and hides ajax indicator */
Ajax.Responders.register({
onCreate: function(){
if ($('ajax-indicator') && Ajax.activeRequestCount > 0) {
Element.show('ajax-indicator');
}
},
onComplete: function(){
if ($('ajax-indicator') && Ajax.activeRequestCount == 0) {
Element.hide('ajax-indicator');
}
}
});

View File

@ -636,3 +636,30 @@ div.wiki code {
} }
#preview .preview { background: #fafbfc url(../images/draft.png); } #preview .preview { background: #fafbfc url(../images/draft.png); }
#ajax-indicator {
position: absolute; /* fixed not supported by IE */
background-color:#eee;
border: 1px solid #bbb;
top:35%;
left:40%;
width:20%;
font-weight:bold;
text-align:center;
padding:0.6em;
z-index:100;
filter:alpha(opacity=50);
-moz-opacity:0.5;
opacity: 0.5;
-khtml-opacity: 0.5;
}
html>body #ajax-indicator { position: fixed; }
#ajax-indicator span {
background-position: 0% 40%;
background-repeat: no-repeat;
background-image: url(../images/loading.gif);
padding-left: 26px;
vertical-align: bottom;
}