changeset 5436:d2b9788d2760

follow: various minor cleanup A debug session gave no other result than this +0.1 cleanup ...
author Mads Kiilerich <madski@unity3d.com>
date Wed, 26 Aug 2015 17:28:58 +0200
parents 60e04a21bf0f
children 3f017db297c4
files kallithea/public/js/base.js kallithea/templates/base/base.html kallithea/templates/data_table/_dt_elements.html
diffstat 3 files changed, 11 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/public/js/base.js	Wed Aug 26 17:28:58 2015 +0200
+++ b/kallithea/public/js/base.js	Wed Aug 26 17:28:58 2015 +0200
@@ -439,18 +439,17 @@
 var _onSuccessFollow = function(target){
     var $target = $(target);
     var $f_cnt = $('#current_followers_count');
-    if($target.hasClass('follow')){
-        $target.attr('class', 'following');
-        $target.attr('title', _TM['Stop following this repository']);
-        if($f_cnt.html()){
+    if ($target.hasClass('follow')) {
+        $target.removeClass('follow').addClass('following');
+        $target.prop('title', _TM['Stop following this repository']);
+        if ($f_cnt.html()) {
             var cnt = Number($f_cnt.html())+1;
             $f_cnt.html(cnt);
         }
-    }
-    else{
-        $target.attr('class', 'follow');
-        $target.attr('title', _TM['Start following this repository']);
-        if($f_cnt.html()){
+    } else {
+        $target.removeClass('following').addClass('follow');
+        $target.prop('title', _TM['Start following this repository']);
+        if ($f_cnt.html()) {
             var cnt = Number($f_cnt.html())-1;
             $f_cnt.html(cnt);
         }
--- a/kallithea/templates/base/base.html	Wed Aug 26 17:28:58 2015 +0200
+++ b/kallithea/templates/base/base.html	Wed Aug 26 17:28:58 2015 +0200
@@ -97,13 +97,6 @@
 <%def name="repo_context_bar(current=None, rev=None)">
   <% rev = None if rev == 'tip' else rev %>
   <%
-      def follow_class():
-          if c.repository_following:
-              return h.literal('following')
-          else:
-              return h.literal('follow')
-  %>
-  <%
     def is_current(selected):
         if selected == current:
             return h.literal('class="current"')
@@ -176,10 +169,10 @@
               ## also it feels like a job for the controller
               %if c.authuser.username != 'default':
                   <li>
-                   <a class="${follow_class()}" onclick="javascript:toggleFollowingRepo(this,${c.db_repo.repo_id});">
+                   <a class="${'following' if c.repository_following else 'follow'}" onclick="toggleFollowingRepo(this, ${c.db_repo.repo_id});">
                     <span class="show-follow"><i class="icon-heart-empty"></i> ${_('Follow')}</span>
                     <span class="show-following"><i class="icon-heart"></i> ${_('Unfollow')}</span>
-                  </a>
+                   </a>
                   </li>
                   <li><a href="${h.url('repo_fork_home',repo_name=c.repo_name)}"><i class="icon-git-pull-request"></i> ${_('Fork')}</a></li>
                   <li><a href="${h.url('pullrequest_home',repo_name=c.repo_name)}"><i class="icon-git-pull-request"></i> ${_('Create Pull Request')}</a></li>
--- a/kallithea/templates/data_table/_dt_elements.html	Wed Aug 26 17:28:58 2015 +0200
+++ b/kallithea/templates/data_table/_dt_elements.html	Wed Aug 26 17:28:58 2015 +0200
@@ -212,6 +212,6 @@
 
 <%def name="toggle_follow(repo_id)">
   <span id="follow_toggle_${repo_id}" class="following" title="${_('Stop following this repository')}"
-        onclick="javascript:toggleFollowingRepo(this, ${repo_id})">
+        onclick="toggleFollowingRepo(this, ${repo_id})">
   </span>
 </%def>