Mercurial > kallithea
comparison rhodecode/templates/base/root.html @ 1700:bc16d1d0869a beta
js cleanup
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Sat, 19 Nov 2011 21:23:29 +0200 |
parents | 277690a23606 |
children | c83d3d42ab92 |
comparison
equal
deleted
inserted
replaced
1699:623b228cf325 | 1700:bc16d1d0869a |
---|---|
45 <script type="text/javascript" src="${h.url('/js/rhodecode.js')}"></script> | 45 <script type="text/javascript" src="${h.url('/js/rhodecode.js')}"></script> |
46 ## EXTRA FOR JS | 46 ## EXTRA FOR JS |
47 ${self.js_extra()} | 47 ${self.js_extra()} |
48 | 48 |
49 <script type="text/javascript"> | 49 <script type="text/javascript"> |
50 var base_url = "${h.url('toggle_following')}"; | 50 var follow_base_url = "${h.url('toggle_following')}"; |
51 function onSuccess(target){ | 51 var stop_follow_text = "${_('Stop following this repository')}"; |
52 var start_follow_text = "${_('Start following this repository')}"; | |
53 | |
54 | |
55 var onSuccessFollow = function(target){ | |
52 var f = YUD.get(target.id); | 56 var f = YUD.get(target.id); |
53 var f_cnt = YUD.get('current_followers_count'); | 57 var f_cnt = YUD.get('current_followers_count'); |
54 | 58 |
55 if(f.getAttribute('class')=='follow'){ | 59 if(f.getAttribute('class')=='follow'){ |
56 f.setAttribute('class','following'); | 60 f.setAttribute('class','following'); |
57 f.setAttribute('title',"${_('Stop following this repository')}"); | 61 f.setAttribute('title',stop_follow_text); |
58 | 62 |
59 if(f_cnt){ | 63 if(f_cnt){ |
60 var cnt = Number(f_cnt.innerHTML)+1; | 64 var cnt = Number(f_cnt.innerHTML)+1; |
61 f_cnt.innerHTML = cnt; | 65 f_cnt.innerHTML = cnt; |
62 } | 66 } |
63 } | 67 } |
64 else{ | 68 else{ |
65 f.setAttribute('class','follow'); | 69 f.setAttribute('class','follow'); |
66 f.setAttribute('title',"${_('Start following this repository')}"); | 70 f.setAttribute('title',start_follow_text); |
67 if(f_cnt){ | 71 if(f_cnt){ |
68 var cnt = Number(f_cnt.innerHTML)+1; | 72 var cnt = Number(f_cnt.innerHTML)+1; |
69 f_cnt.innerHTML = cnt; | 73 f_cnt.innerHTML = cnt; |
70 } | 74 } |
71 } | 75 } |
72 } | 76 } |
73 | 77 |
74 function toggleFollowingUser(target,fallows_user_id,token,user_id){ | 78 var toggleFollowingUser = function(target,fallows_user_id,token,user_id){ |
75 args = 'follows_user_id='+fallows_user_id; | 79 args = 'follows_user_id='+fallows_user_id; |
76 args+= '&auth_token='+token; | 80 args+= '&auth_token='+token; |
77 if(user_id != undefined){ | 81 if(user_id != undefined){ |
78 args+="&user_id="+user_id; | 82 args+="&user_id="+user_id; |
79 } | 83 } |
80 YUC.asyncRequest('POST',base_url,{ | 84 YUC.asyncRequest('POST',follow_base_url,{ |
81 success:function(o){ | 85 success:function(o){ |
82 onSuccess(target); | 86 onSuccessFollow(target); |
83 } | 87 } |
84 },args); | 88 },args); |
85 return false; | 89 return false; |
86 } | 90 } |
87 | 91 |
88 function toggleFollowingRepo(target,fallows_repo_id,token,user_id){ | 92 var toggleFollowingRepo = function(target,fallows_repo_id,token,user_id){ |
89 | 93 |
90 args = 'follows_repo_id='+fallows_repo_id; | 94 args = 'follows_repo_id='+fallows_repo_id; |
91 args+= '&auth_token='+token; | 95 args+= '&auth_token='+token; |
92 if(user_id != undefined){ | 96 if(user_id != undefined){ |
93 args+="&user_id="+user_id; | 97 args+="&user_id="+user_id; |
94 } | 98 } |
95 YUC.asyncRequest('POST',base_url,{ | 99 YUC.asyncRequest('POST',follow_base_url,{ |
96 success:function(o){ | 100 success:function(o){ |
97 onSuccess(target); | 101 onSuccessFollow(target); |
98 } | 102 } |
99 },args); | 103 },args); |
100 return false; | 104 return false; |
101 } | 105 } |
102 YUE.onDOMReady(function(){ | 106 YUE.onDOMReady(function(){ |
103 | 107 tooltip_activate(); |
108 show_more_event(); | |
109 | |
104 YUE.on('quick_login_link','click',function(e){ | 110 YUE.on('quick_login_link','click',function(e){ |
111 // make sure we don't redirect | |
112 YUE.preventDefault(e); | |
105 | 113 |
106 if(YUD.hasClass('quick_login_link','enabled')){ | 114 if(YUD.hasClass('quick_login_link','enabled')){ |
107 YUD.setStyle('quick_login','display','none'); | 115 YUD.setStyle('quick_login','display','none'); |
108 YUD.removeClass('quick_login_link','enabled'); | 116 YUD.removeClass('quick_login_link','enabled'); |
109 } | 117 } |
110 else{ | 118 else{ |
111 YUD.setStyle('quick_login','display',''); | 119 YUD.setStyle('quick_login','display',''); |
112 YUD.addClass('quick_login_link','enabled'); | 120 YUD.addClass('quick_login_link','enabled'); |
113 YUD.get('username').focus(); | 121 YUD.get('username').focus(); |
114 } | 122 } |
115 //make sure we don't redirect | |
116 YUE.preventDefault(e); | |
117 }); | 123 }); |
118 | 124 |
119 tooltip_activate(); | |
120 show_more_event(); | |
121 | |
122 YUE.on(YUQ('.quick_repo_menu'),'click',function(e){ | 125 YUE.on(YUQ('.quick_repo_menu'),'click',function(e){ |
123 var menu = e.currentTarget.firstElementChild; | 126 var menu = e.currentTarget.firstElementChild; |
124 if(YUD.hasClass(menu,'hidden')){ | 127 if(YUD.hasClass(menu,'hidden')){ |
125 YUD.addClass(e.currentTarget,'active'); | 128 YUD.addClass(e.currentTarget,'active'); |
126 YUD.removeClass(menu,'hidden'); | 129 YUD.removeClass(menu,'hidden'); |
127 }else{ | 130 }else{ |
128 YUD.removeClass(e.currentTarget,'active'); | 131 YUD.removeClass(e.currentTarget,'active'); |
129 YUD.addClass(menu,'hidden'); | 132 YUD.addClass(menu,'hidden'); |
130 } | 133 } |
131 }) | 134 }) |
135 | |
132 YUE.on(window,'scroll',function(){ | 136 YUE.on(window,'scroll',function(){ |
133 if(YUD.getDocumentScrollTop() > 45){ | 137 if(YUD.getDocumentScrollTop() > 45){ |
134 YUD.addClass('header-inner','hover'); | 138 YUD.addClass('header-inner','hover'); |
135 } | 139 } |
136 else{ | 140 else{ |
138 } | 142 } |
139 }) | 143 }) |
140 }) | 144 }) |
141 </script> | 145 </script> |
142 </%def> | 146 </%def> |
143 <%def name="js_extra()"> | 147 <%def name="js_extra()"></%def> |
144 </%def> | |
145 ${self.js()} | 148 ${self.js()} |
146 </head> | 149 </head> |
147 <body id="body"> | 150 <body id="body"> |
148 ${next.body()} | 151 ${next.body()} |
149 </body> | 152 </body> |