<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>app/views/times/_listed.html.erb</filename>
    </added>
    <added>
      <filename>app/views/times/create.js.rjs</filename>
    </added>
    <added>
      <filename>app/views/times/stop.js.rjs</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -96,6 +96,8 @@ class TimesController &lt; ApplicationController
     
     respond_to do |format|
       if @time.save
+        add_running_time(@time)
+        
         format.html {
           error_status(false, :success_added_time)
           redirect_back_or_default(@time)
@@ -159,6 +161,8 @@ class TimesController &lt; ApplicationController
     @time.updated_by = @logged_user
     @time.save
     
+    remove_running_time(@time)
+    
     respond_to do |format|
       format.html {
         error_status(false, :success_stopped_time)
@@ -172,7 +176,9 @@ class TimesController &lt; ApplicationController
 
   def destroy
     return error_status(true, :insufficient_permissions) unless (@time.can_be_deleted_by(@logged_user))
-
+    
+    remove_running_time(@time)
+    
     @time.updated_by = @logged_user
     @time.destroy
 
@@ -209,4 +215,13 @@ private
     @sort_type = 'created_on' unless ['done_date', 'hours'].include?(params[:orderBy])
     @sort_order = 'DESC'
   end
+  
+  def add_running_time(time)
+    @running_times.each { |chk| return if chk.id == time.id }
+    @running_times &lt;&lt; time
+  end
+  
+  def remove_running_time(time)
+    @running_times.reject! { |chk| chk.id == time.id ? true : false }
+  end
 end</diff>
      <filename>app/controllers/times_controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -63,8 +63,8 @@ class ProjectTime &lt; ActiveRecord::Base
     end
     
     # set name to task name
-    if self.name.empty? and !self.project_task.nil?
-      self.name = self.project_task.text
+    if (self.name.nil? or self.name.blank?) and !self.project_task.nil?
+      self.name = self.project_task.text[0, ProjectTime.columns_hash['name'].limit]
     end
   end
   
@@ -108,7 +108,7 @@ class ProjectTime &lt; ActiveRecord::Base
   end
   
   def open_task_id=(val)
-        # Set open_task accordingly
+    # Set open_task accordingly
     if (val.nil? || val == '0')
       self.open_task = nil
       return</diff>
      <filename>app/models/project_time.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,12 +1,12 @@
 &lt;div id=&quot;userbox&quot;&gt;
-&lt;% if user.is_anonymous? -%&gt;
+&lt;% if user.is_anonymous? %&gt;
   &lt;%= :welcome_anonymous.l %&gt; (&lt;%= link_to(:login.l, logout_path) %&gt;),
-&lt;% else -%&gt;
-  &lt;%= :welcome_back.l_with_args(:user =&gt; h(user.display_name)) %&gt; (&lt;%= link_to :logout.l, logout_path, :confirm =&gt; :are_you_sure_logout.l %&gt;),
-&lt;% end -%&gt;
-&lt;% unless running_times.blank? -%&gt;
-  &lt;%= :running_times.l_with_args(:count =&gt; running_times.size) %&gt; &lt;%= render_icon 'bullet_drop_down', '', :id =&gt; 'running_times', :class =&gt; 'PopupMenuWidgetAttachTo', :title =&gt; 'Enable javascript' %&gt;
-&lt;% end -%&gt;
+&lt;% else %&gt;
+  &lt;%= :welcome_back.l_with_args(:user =&gt; h(user.display_name)) %&gt; (&lt;%= link_to :logout.l, logout_path, :confirm =&gt; :are_you_sure_logout.l %&gt;)
+&lt;% end %&gt;
+  &lt;div id=&quot;running_times_count&quot; style=&quot;display:&lt;%= @running_times.empty? ? 'none' : 'block' %&gt;;&quot;&gt;
+  &lt;span&gt;&lt;%= :running_times.l_with_args(:count =&gt; @running_times.size) %&gt;&lt;/span&gt; &lt;%= render_icon 'bullet_drop_down', '', :id =&gt; 'running_times', :class =&gt; 'PopupMenuWidgetAttachTo', :title =&gt; 'Enable javascript' %&gt;
+  &lt;/div&gt;
   &lt;ul&gt;
     &lt;% unless user.is_anonymous? %&gt;
     &lt;li&gt;&lt;%= link_to :account.l, @logged_user %&gt; &lt;%= render_icon 'bullet_drop_down', '', :id =&gt; 'account_more', :class =&gt; 'PopupMenuWidgetAttachTo', :title =&gt; 'Enable javascript' %&gt;&lt;/li&gt;
@@ -58,18 +58,9 @@
   &lt;/div&gt;
 &lt;% end %&gt;
 
-&lt;% unless running_times.blank? %&gt;
-  &lt;div class=&quot;PopupMenuWidgetDiv&quot; id=&quot;running_times_menu&quot;  style=&quot;display:none&quot;&gt;
+  &lt;div class=&quot;PopupMenuWidgetDiv&quot; id=&quot;running_times_menu&quot; style=&quot;display:none&quot;&gt;
     &lt;ul&gt;
-&lt;% running_times.each do |time| -%&gt;
-      &lt;li&gt;
-        &lt;%= link_to h(time.name), time.object_url %&gt;
-        &lt;% form_tag stop_time_path(:active_project =&gt; time.project_id, :id =&gt; time.id), :method =&gt; :put do %&gt;
-          &lt;div&gt;&lt;%= image_submit_tag 'icons/stop.gif', :alt =&gt; :stop_time.l, :class =&gt; 'image' %&gt;&lt;/div&gt;
-        &lt;% end %&gt;
-      &lt;/li&gt;
-&lt;% end %&gt;
+	  &lt;%= render :partial =&gt; 'times/listed', :collection =&gt; @running_times %&gt;
     &lt;/ul&gt;
   &lt;/div&gt;
-&lt;% end %&gt;
 &lt;/div&gt;</diff>
      <filename>app/views/layouts/_user_box.rhtml</filename>
    </modified>
    <modified>
      <diff>@@ -18,7 +18,7 @@
     &lt;%= javascript_include_tag 'application.js' %&gt;
 
     &lt;%= javascript_tag &quot;var AUTH_TOKEN = #{form_authenticity_token.inspect};&quot; if protect_against_forgery? %&gt;
-    &lt;%= javascript_tag &quot;var PROJECT_ID = #{@active_project.id};&quot; %&gt;
+    &lt;%= javascript_tag &quot;var PROJECT_ID = #{@active_project.id}; var LOGGED_USER_ID=#{@logged_user.id};&quot; %&gt;
 &lt;!-- head needs to go here? --&gt;
   &lt;/head&gt;
   &lt;body id=&quot;body&quot;&gt;</diff>
      <filename>app/views/layouts/project_website.rhtml</filename>
    </modified>
    <modified>
      <diff>@@ -36,20 +36,9 @@
 &lt;% if !task_item.is_completed? &amp;&amp; ProjectTime.can_be_created_by(@logged_user, task_item.project) %&gt;
 &lt;% running_time = running_time_for_task(task_item) 
 unless running_time.nil? %&gt;
-
-&lt;% form_tag stop_time_path(:active_project =&gt; running_time.project_id, :id =&gt; running_time.id), :method =&gt; :put do %&gt;
-  &lt;div&gt;&lt;%= image_submit_tag 'icons/stop.gif', :alt =&gt; :stop_time.l, :class =&gt; 'image' %&gt;&lt;/div&gt;
-&lt;% end %&gt;
-
+&lt;%= link_to render_icon('stop', :stop_time.l), stop_time_path(:active_project =&gt; running_time.project_id, :id =&gt; running_time.id), :class =&gt; 'blank stopTime' %&gt;
 &lt;% else %&gt;
-    &lt;% form_tag times_path, :method =&gt; :post do %&gt;
-      &lt;div&gt;
-        &lt;%= hidden_field_tag 'time[name]', task_item.text[0, ProjectTime.columns_hash['name'].limit], :id =&gt; nil %&gt;
-        &lt;%= hidden_field_tag 'time[open_task_id]', task_item.id, :id =&gt; nil %&gt;
-        &lt;%= hidden_field_tag 'time[assigned_to_id]', @logged_user.id, :id =&gt; nil %&gt;
-        &lt;%= image_submit_tag 'icons/start.gif', :alt =&gt; :start_time.l, :class =&gt; 'image' %&gt;
-      &lt;/div&gt;
-    &lt;% end %&gt;
+&lt;%= link_to render_icon('start', :start_time.l), times_path, :class =&gt; 'blank startTime', :task_id =&gt; task_item.id %&gt;
 &lt;% end %&gt;
 &lt;% end %&gt;
   &lt;/div&gt;</diff>
      <filename>app/views/tasks/_show.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -124,7 +124,7 @@
   welcome_back: &quot;Willkommen zur&#252;ck &lt;strong&gt;{{user}}&lt;/strong&gt;&quot;
   logout: Abmelden
   are_you_sure_logout: Sind sie sicher, da&#223; Sie sich ausloggen wollen?
-  running_times: &quot;you have {{count}} running times&quot;
+  running_times: &quot;You have {{count}} running times&quot;
   
   # Permission names
   can_manage_messages: Manage messages</diff>
      <filename>config/locales/de.yml</filename>
    </modified>
    <modified>
      <diff>@@ -130,7 +130,7 @@ en-US:
   welcome_back: &quot;Welcome back &lt;strong&gt;{{user}}&lt;/strong&gt;&quot;
   logout: Logout
   are_you_sure_logout: Are you sure you want to log out?
-  running_times: &quot;you have {{count}} running times&quot;
+  running_times: &quot;You have {{count}} running times&quot;
   
   # Permission names
   can_manage_messages: Manage messages</diff>
      <filename>config/locales/en-US.yml</filename>
    </modified>
    <modified>
      <diff>@@ -129,7 +129,7 @@ en:
   welcome_back: &quot;Welcome back &lt;strong&gt;{{user}}&lt;/strong&gt;&quot;
   logout: Logout
   are_you_sure_logout: Are you sure you want to log out?
-  running_times: &quot;you have {{count}} running times&quot;
+  running_times: &quot;You have {{count}} running times&quot;
   
   # Permission names
   can_manage_messages: Manage messages</diff>
      <filename>config/locales/en.yml</filename>
    </modified>
    <modified>
      <diff>@@ -130,8 +130,8 @@ es:
   logout: Cerrar sesi&#243;n
   are_you_sure_logout: &#191;Est&#225;s seguro de que quieres cerrar sesi&#243;n?
   running_times:
-    one: &quot;tienes {{count}} tiempo en progreso&quot;
-    other: &quot;tienes {{count}} tiempos en progreso&quot;
+    one: &quot;Tienes {{count}} tiempo en progreso&quot;
+    other: &quot;Tienes {{count}} tiempos en progreso&quot;
   
   # Permission names
   can_manage_messages: Gestionar mensajes</diff>
      <filename>config/locales/es.yml</filename>
    </modified>
    <modified>
      <diff>@@ -124,7 +124,7 @@ zh-CN:
   welcome_back: &quot;&#27426;&#36814;&#20320;&#22238;&#26469;  &lt;strong&gt;{{user}}&lt;/strong&gt;&quot;
   logout: &#36864;&#20986;
   are_you_sure_logout: &#20320;&#30830;&#23450;&#35201;&#36864;&#20986;?
-  running_times: &quot;you have {{count}} running times&quot;
+  running_times: &quot;You have {{count}} running times&quot;
   
   # Permission names
   can_manage_messages: &#31649;&#29702;&#28040;&#24687;</diff>
      <filename>config/locales/zh-CN.yml</filename>
    </modified>
    <modified>
      <diff>@@ -294,6 +294,28 @@ function bindDynamic() {
 
         return false;
       });
+
+      // Start &amp; stop time
+
+      $('.startTime').click(function(evt) {
+        var el = $(this);
+        $.post(Project.buildUrl('/times'), {
+            'time[open_task_id]': el.attr('task_id'),
+            'time[assigned_to_id]': LOGGED_USER_ID,
+        }, JustRebind, 'script');
+        
+        return false;
+      });
+
+      $('.stopTime').click(function(evt) {
+        var el = $(this);
+        $.put(el.attr('href'), {
+            'time[open_task_id]': el.attr('task_id'),
+            'time[assigned_to_id]': LOGGED_USER_ID,
+        }, JustRebind, 'script');
+
+        return false;
+      });
 }
 
 function JustReload(data) {
@@ -326,13 +348,27 @@ function rebindDynamic() {
   $('#action_dialog a.cancel').unbind();
 
   $('a.oaction').unbind();
+
+  $('.startTime').unbind();
+  $('.stopTime').unbind();
   
   bindDynamic();
 }
 
 var Project = {
   buildUrl: function(resource) {
-    return ('/project' + PROJECT_ID + resource);
+    return ('/projects/' + PROJECT_ID + resource);
+  },
+
+  updateRunningTimes: function(size, locale) {
+    $('#running_times_count span').html(locale);
+    
+    if (size &gt; 0)
+      $('#running_times_count').show();
+    else {
+      $('#running_times_count').hide();
+      $('#running_times_menu').hide();
+    }
   }
 };
 </diff>
      <filename>public/javascripts/application.js</filename>
    </modified>
    <modified>
      <diff>@@ -109,10 +109,6 @@ body {
   list-style: square;
 }
 
-#userbox #running_times_menu form, #userbox #running_times_menu form div {
-  display: inline;
-}
-
 /** Tabs **/
 
 #tabsWrapper {</diff>
      <filename>public/themes/default/stylesheets/general/construction.css</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>898bd06df57afe2eeddd25552a4475390549470d</id>
    </parent>
  </parents>
  <author>
    <name>jamesu</name>
    <email>jamesu@gmail.com</email>
  </author>
  <url>http://github.com/jamesu/railscollab/commit/eadf052075498bee22a26310c4bd46b19c466e9d</url>
  <id>eadf052075498bee22a26310c4bd46b19c466e9d</id>
  <committed-date>2009-11-04T12:26:32-08:00</committed-date>
  <authored-date>2009-11-04T12:26:32-08:00</authored-date>
  <message>Ajaxified the time stop &amp; start. No more reloads!</message>
  <tree>142432018a2c8d3e57203c2a279637a5cfdb8356</tree>
  <committer>
    <name>jamesu</name>
    <email>jamesu@gmail.com</email>
  </committer>
</commit>
