##// END OF EJS Templates
base: show my account as active when we're showing this view....
marcink -
r1318:dcb9c65b default
parent child Browse files
Show More
@@ -1,52 +1,52 b''
1 1 ## -*- coding: utf-8 -*-
2 2 <%inherit file="/base/base.mako"/>
3 3
4 4 <%def name="title()">
5 5 ${_('My account')} ${c.rhodecode_user.username}
6 6 %if c.rhodecode_name:
7 7 &middot; ${h.branding(c.rhodecode_name)}
8 8 %endif
9 9 </%def>
10 10
11 11 <%def name="breadcrumbs_links()">
12 12 ${_('My Account')}
13 13 </%def>
14 14
15 15 <%def name="menu_bar_nav()">
16 ${self.menu_items(active='admin')}
16 ${self.menu_items(active='my_account')}
17 17 </%def>
18 18
19 19 <%def name="main()">
20 20 <div class="box">
21 21 <div class="title">
22 22 ${self.breadcrumbs()}
23 23 </div>
24 24
25 25 <div class="sidebar-col-wrapper scw-small">
26 26 ##main
27 27 <div class="sidebar">
28 28 <ul class="nav nav-pills nav-stacked">
29 29 <li class="${'active' if c.active=='profile' or c.active=='profile_edit' else ''}"><a href="${h.url('my_account')}">${_('My Profile')}</a></li>
30 30 <li class="${'active' if c.active=='password' else ''}"><a href="${h.url('my_account_password')}">${_('Password')}</a></li>
31 31 <li class="${'active' if c.active=='auth_tokens' else ''}"><a href="${h.url('my_account_auth_tokens')}">${_('Auth Tokens')}</a></li>
32 32 ## TODO: Find a better integration of oauth views into navigation.
33 33 <% my_account_oauth_url = h.route_path_or_none('my_account_oauth') %>
34 34 % if my_account_oauth_url:
35 35 <li class="${'active' if c.active=='oauth' else ''}"><a href="${my_account_oauth_url}">${_('OAuth Identities')}</a></li>
36 36 % endif
37 37 <li class="${'active' if c.active=='emails' else ''}"><a href="${h.url('my_account_emails')}">${_('My Emails')}</a></li>
38 38 <li class="${'active' if c.active=='repos' else ''}"><a href="${h.url('my_account_repos')}">${_('My Repositories')}</a></li>
39 39 <li class="${'active' if c.active=='watched' else ''}"><a href="${h.url('my_account_watched')}">${_('Watched')}</a></li>
40 40 <li class="${'active' if c.active=='pullrequests' else ''}"><a href="${h.url('my_account_pullrequests')}">${_('Pull Requests')}</a></li>
41 41 <li class="${'active' if c.active=='perms' else ''}"><a href="${h.url('my_account_perms')}">${_('My Permissions')}</a></li>
42 42 <li class="${'active' if c.active=='my_notifications' else ''}"><a href="${h.url('my_account_notifications')}">${_('My Live Notifications')}</a></li>
43 43 </ul>
44 44 </div>
45 45
46 46 <div class="main-content-full-width">
47 47 <%include file="/admin/my_account/my_account_${c.active}.mako"/>
48 48 </div>
49 49 </div>
50 50 </div>
51 51
52 52 </%def>
@@ -1,598 +1,598 b''
1 1 ## -*- coding: utf-8 -*-
2 2 <%inherit file="root.mako"/>
3 3
4 4 <div class="outerwrapper">
5 5 <!-- HEADER -->
6 6 <div class="header">
7 7 <div id="header-inner" class="wrapper">
8 8 <div id="logo">
9 9 <div class="logo-wrapper">
10 10 <a href="${h.url('home')}"><img src="${h.asset('images/rhodecode-logo-white-216x60.png')}" alt="RhodeCode"/></a>
11 11 </div>
12 12 %if c.rhodecode_name:
13 13 <div class="branding">- ${h.branding(c.rhodecode_name)}</div>
14 14 %endif
15 15 </div>
16 16 <!-- MENU BAR NAV -->
17 17 ${self.menu_bar_nav()}
18 18 <!-- END MENU BAR NAV -->
19 19 </div>
20 20 </div>
21 21 ${self.menu_bar_subnav()}
22 22 <!-- END HEADER -->
23 23
24 24 <!-- CONTENT -->
25 25 <div id="content" class="wrapper">
26 26 <div class="main">
27 27 ${next.main()}
28 28 </div>
29 29 </div>
30 30 <!-- END CONTENT -->
31 31
32 32 </div>
33 33 <!-- FOOTER -->
34 34 <div id="footer">
35 35 <div id="footer-inner" class="title wrapper">
36 36 <div>
37 37 <p class="footer-link-right">
38 38 % if c.visual.show_version:
39 39 RhodeCode Enterprise ${c.rhodecode_version} ${c.rhodecode_edition}
40 40 % endif
41 41 &copy; 2010-${h.datetime.today().year}, <a href="${h.url('rhodecode_official')}" target="_blank">RhodeCode GmbH</a>. All rights reserved.
42 42 % if c.visual.rhodecode_support_url:
43 43 <a href="${c.visual.rhodecode_support_url}" target="_blank">${_('Support')}</a>
44 44 % endif
45 45 </p>
46 46 <% sid = 'block' if request.GET.get('showrcid') else 'none' %>
47 47 <p class="server-instance" style="display:${sid}">
48 48 ## display hidden instance ID if specially defined
49 49 % if c.rhodecode_instanceid:
50 50 ${_('RhodeCode instance id: %s') % c.rhodecode_instanceid}
51 51 % endif
52 52 </p>
53 53 </div>
54 54 </div>
55 55 </div>
56 56
57 57 <!-- END FOOTER -->
58 58
59 59 ### MAKO DEFS ###
60 60
61 61 <%def name="menu_bar_subnav()">
62 62 </%def>
63 63
64 64 <%def name="breadcrumbs(class_='breadcrumbs')">
65 65 <div class="${class_}">
66 66 ${self.breadcrumbs_links()}
67 67 </div>
68 68 </%def>
69 69
70 70 <%def name="admin_menu()">
71 71 <ul class="admin_menu submenu">
72 72 <li><a href="${h.url('admin_home')}">${_('Admin journal')}</a></li>
73 73 <li><a href="${h.url('repos')}">${_('Repositories')}</a></li>
74 74 <li><a href="${h.url('repo_groups')}">${_('Repository groups')}</a></li>
75 75 <li><a href="${h.url('users')}">${_('Users')}</a></li>
76 76 <li><a href="${h.url('users_groups')}">${_('User groups')}</a></li>
77 77 <li><a href="${h.url('admin_permissions_application')}">${_('Permissions')}</a></li>
78 78 <li><a href="${h.route_path('auth_home', traverse='')}">${_('Authentication')}</a></li>
79 79 <li><a href="${h.route_path('global_integrations_home')}">${_('Integrations')}</a></li>
80 80 <li><a href="${h.url('admin_defaults_repositories')}">${_('Defaults')}</a></li>
81 81 <li class="last"><a href="${h.url('admin_settings')}">${_('Settings')}</a></li>
82 82 </ul>
83 83 </%def>
84 84
85 85
86 86 <%def name="dt_info_panel(elements)">
87 87 <dl class="dl-horizontal">
88 88 %for dt, dd, title, show_items in elements:
89 89 <dt>${dt}:</dt>
90 90 <dd title="${title}">
91 91 %if callable(dd):
92 92 ## allow lazy evaluation of elements
93 93 ${dd()}
94 94 %else:
95 95 ${dd}
96 96 %endif
97 97 %if show_items:
98 98 <span class="btn-collapse" data-toggle="item-${h.md5_safe(dt)[:6]}-details">${_('Show More')} </span>
99 99 %endif
100 100 </dd>
101 101
102 102 %if show_items:
103 103 <div class="collapsable-content" data-toggle="item-${h.md5_safe(dt)[:6]}-details" style="display: none">
104 104 %for item in show_items:
105 105 <dt></dt>
106 106 <dd>${item}</dd>
107 107 %endfor
108 108 </div>
109 109 %endif
110 110
111 111 %endfor
112 112 </dl>
113 113 </%def>
114 114
115 115
116 116 <%def name="gravatar(email, size=16)">
117 117 <%
118 118 if (size > 16):
119 119 gravatar_class = 'gravatar gravatar-large'
120 120 else:
121 121 gravatar_class = 'gravatar'
122 122 %>
123 123 <%doc>
124 124 TODO: johbo: For now we serve double size images to make it smooth
125 125 for retina. This is how it worked until now. Should be replaced
126 126 with a better solution at some point.
127 127 </%doc>
128 128 <img class="${gravatar_class}" src="${h.gravatar_url(email, size * 2)}" height="${size}" width="${size}">
129 129 </%def>
130 130
131 131
132 132 <%def name="gravatar_with_user(contact, size=16, show_disabled=False)">
133 133 <% email = h.email_or_none(contact) %>
134 134 <div class="rc-user tooltip" title="${h.author_string(email)}">
135 135 ${self.gravatar(email, size)}
136 136 <span class="${'user user-disabled' if show_disabled else 'user'}"> ${h.link_to_user(contact)}</span>
137 137 </div>
138 138 </%def>
139 139
140 140
141 141 ## admin menu used for people that have some admin resources
142 142 <%def name="admin_menu_simple(repositories=None, repository_groups=None, user_groups=None)">
143 143 <ul class="submenu">
144 144 %if repositories:
145 145 <li><a href="${h.url('repos')}">${_('Repositories')}</a></li>
146 146 %endif
147 147 %if repository_groups:
148 148 <li><a href="${h.url('repo_groups')}">${_('Repository groups')}</a></li>
149 149 %endif
150 150 %if user_groups:
151 151 <li><a href="${h.url('users_groups')}">${_('User groups')}</a></li>
152 152 %endif
153 153 </ul>
154 154 </%def>
155 155
156 156 <%def name="repo_page_title(repo_instance)">
157 157 <div class="title-content">
158 158 <div class="title-main">
159 159 ## SVN/HG/GIT icons
160 160 %if h.is_hg(repo_instance):
161 161 <i class="icon-hg"></i>
162 162 %endif
163 163 %if h.is_git(repo_instance):
164 164 <i class="icon-git"></i>
165 165 %endif
166 166 %if h.is_svn(repo_instance):
167 167 <i class="icon-svn"></i>
168 168 %endif
169 169
170 170 ## public/private
171 171 %if repo_instance.private:
172 172 <i class="icon-repo-private"></i>
173 173 %else:
174 174 <i class="icon-repo-public"></i>
175 175 %endif
176 176
177 177 ## repo name with group name
178 178 ${h.breadcrumb_repo_link(c.rhodecode_db_repo)}
179 179
180 180 </div>
181 181
182 182 ## FORKED
183 183 %if repo_instance.fork:
184 184 <p>
185 185 <i class="icon-code-fork"></i> ${_('Fork of')}
186 186 <a href="${h.url('summary_home',repo_name=repo_instance.fork.repo_name)}">${repo_instance.fork.repo_name}</a>
187 187 </p>
188 188 %endif
189 189
190 190 ## IMPORTED FROM REMOTE
191 191 %if repo_instance.clone_uri:
192 192 <p>
193 193 <i class="icon-code-fork"></i> ${_('Clone from')}
194 194 <a href="${h.url(h.safe_str(h.hide_credentials(repo_instance.clone_uri)))}">${h.hide_credentials(repo_instance.clone_uri)}</a>
195 195 </p>
196 196 %endif
197 197
198 198 ## LOCKING STATUS
199 199 %if repo_instance.locked[0]:
200 200 <p class="locking_locked">
201 201 <i class="icon-repo-lock"></i>
202 202 ${_('Repository locked by %(user)s') % {'user': h.person_by_id(repo_instance.locked[0])}}
203 203 </p>
204 204 %elif repo_instance.enable_locking:
205 205 <p class="locking_unlocked">
206 206 <i class="icon-repo-unlock"></i>
207 207 ${_('Repository not locked. Pull repository to lock it.')}
208 208 </p>
209 209 %endif
210 210
211 211 </div>
212 212 </%def>
213 213
214 214 <%def name="repo_menu(active=None)">
215 215 <%
216 216 def is_active(selected):
217 217 if selected == active:
218 218 return "active"
219 219 %>
220 220
221 221 <!--- CONTEXT BAR -->
222 222 <div id="context-bar">
223 223 <div class="wrapper">
224 224 <ul id="context-pages" class="horizontal-list navigation">
225 225 <li class="${is_active('summary')}"><a class="menulink" href="${h.url('summary_home', repo_name=c.repo_name)}"><div class="menulabel">${_('Summary')}</div></a></li>
226 226 <li class="${is_active('changelog')}"><a class="menulink" href="${h.url('changelog_home', repo_name=c.repo_name)}"><div class="menulabel">${_('Changelog')}</div></a></li>
227 227 <li class="${is_active('files')}"><a class="menulink" href="${h.url('files_home', repo_name=c.repo_name, revision=c.rhodecode_db_repo.landing_rev[1])}"><div class="menulabel">${_('Files')}</div></a></li>
228 228 <li class="${is_active('compare')}">
229 229 <a class="menulink" href="${h.url('compare_home',repo_name=c.repo_name)}"><div class="menulabel">${_('Compare')}</div></a>
230 230 </li>
231 231 ## TODO: anderson: ideally it would have a function on the scm_instance "enable_pullrequest() and enable_fork()"
232 232 %if c.rhodecode_db_repo.repo_type in ['git','hg']:
233 233 <li class="${is_active('showpullrequest')}">
234 234 <a class="menulink" href="${h.url('pullrequest_show_all',repo_name=c.repo_name)}" title="${_('Show Pull Requests for %s') % c.repo_name}">
235 235 %if c.repository_pull_requests:
236 236 <span class="pr_notifications">${c.repository_pull_requests}</span>
237 237 %endif
238 238 <div class="menulabel">${_('Pull Requests')}</div>
239 239 </a>
240 240 </li>
241 241 %endif
242 242 <li class="${is_active('options')}">
243 243 <a class="menulink" href="#" class="dropdown"><div class="menulabel">${_('Options')} <div class="show_more"></div></div></a>
244 244 <ul class="submenu">
245 245 %if h.HasRepoPermissionAll('repository.admin')(c.repo_name):
246 246 <li><a href="${h.url('edit_repo',repo_name=c.repo_name)}">${_('Settings')}</a></li>
247 247 %endif
248 248 %if c.rhodecode_db_repo.fork:
249 249 <li><a href="${h.url('compare_url',repo_name=c.rhodecode_db_repo.fork.repo_name,source_ref_type=c.rhodecode_db_repo.landing_rev[0],source_ref=c.rhodecode_db_repo.landing_rev[1], target_repo=c.repo_name,target_ref_type='branch' if request.GET.get('branch') else c.rhodecode_db_repo.landing_rev[0],target_ref=request.GET.get('branch') or c.rhodecode_db_repo.landing_rev[1], merge=1)}">
250 250 ${_('Compare fork')}</a></li>
251 251 %endif
252 252
253 253 <li><a href="${h.url('search_repo_home',repo_name=c.repo_name)}">${_('Search')}</a></li>
254 254
255 255 %if h.HasRepoPermissionAny('repository.write','repository.admin')(c.repo_name) and c.rhodecode_db_repo.enable_locking:
256 256 %if c.rhodecode_db_repo.locked[0]:
257 257 <li><a class="locking_del" href="${h.url('toggle_locking',repo_name=c.repo_name)}">${_('Unlock')}</a></li>
258 258 %else:
259 259 <li><a class="locking_add" href="${h.url('toggle_locking',repo_name=c.repo_name)}">${_('Lock')}</a></li>
260 260 %endif
261 261 %endif
262 262 %if c.rhodecode_user.username != h.DEFAULT_USER:
263 263 %if c.rhodecode_db_repo.repo_type in ['git','hg']:
264 264 <li><a href="${h.url('repo_fork_home',repo_name=c.repo_name)}">${_('Fork')}</a></li>
265 265 <li><a href="${h.url('pullrequest_home',repo_name=c.repo_name)}">${_('Create Pull Request')}</a></li>
266 266 %endif
267 267 %endif
268 268 </ul>
269 269 </li>
270 270 </ul>
271 271 </div>
272 272 <div class="clear"></div>
273 273 </div>
274 274 <!--- END CONTEXT BAR -->
275 275
276 276 </%def>
277 277
278 <%def name="usermenu()">
278 <%def name="usermenu(active=False)">
279 279 ## USER MENU
280 <li id="quick_login_li">
280 <li id="quick_login_li" class="${'active' if active else ''}">
281 281 <a id="quick_login_link" class="menulink childs">
282 282 ${gravatar(c.rhodecode_user.email, 20)}
283 283 <span class="user">
284 284 %if c.rhodecode_user.username != h.DEFAULT_USER:
285 285 <span class="menu_link_user">${c.rhodecode_user.username}</span><div class="show_more"></div>
286 286 %else:
287 287 <span>${_('Sign in')}</span>
288 288 %endif
289 289 </span>
290 290 </a>
291 291
292 292 <div class="user-menu submenu">
293 293 <div id="quick_login">
294 294 %if c.rhodecode_user.username == h.DEFAULT_USER:
295 295 <h4>${_('Sign in to your account')}</h4>
296 296 ${h.form(h.route_path('login', _query={'came_from': h.url.current()}), needs_csrf_token=False)}
297 297 <div class="form form-vertical">
298 298 <div class="fields">
299 299 <div class="field">
300 300 <div class="label">
301 301 <label for="username">${_('Username')}:</label>
302 302 </div>
303 303 <div class="input">
304 304 ${h.text('username',class_='focus',tabindex=1)}
305 305 </div>
306 306
307 307 </div>
308 308 <div class="field">
309 309 <div class="label">
310 310 <label for="password">${_('Password')}:</label>
311 311 %if h.HasPermissionAny('hg.password_reset.enabled')():
312 312 <span class="forgot_password">${h.link_to(_('(Forgot password?)'),h.route_path('reset_password'), class_='pwd_reset')}</span>
313 313 %endif
314 314 </div>
315 315 <div class="input">
316 316 ${h.password('password',class_='focus',tabindex=2)}
317 317 </div>
318 318 </div>
319 319 <div class="buttons">
320 320 <div class="register">
321 321 %if h.HasPermissionAny('hg.admin', 'hg.register.auto_activate', 'hg.register.manual_activate')():
322 322 ${h.link_to(_("Don't have an account ?"),h.route_path('register'))}
323 323 %endif
324 324 </div>
325 325 <div class="submit">
326 326 ${h.submit('sign_in',_('Sign In'),class_="btn btn-small",tabindex=3)}
327 327 </div>
328 328 </div>
329 329 </div>
330 330 </div>
331 331 ${h.end_form()}
332 332 %else:
333 333 <div class="">
334 334 <div class="big_gravatar">${gravatar(c.rhodecode_user.email, 48)}</div>
335 335 <div class="full_name">${c.rhodecode_user.full_name_or_username}</div>
336 336 <div class="email">${c.rhodecode_user.email}</div>
337 337 </div>
338 338 <div class="">
339 339 <ol class="links">
340 340 <li>${h.link_to(_(u'My account'),h.url('my_account'))}</li>
341 341 % if c.rhodecode_user.personal_repo_group:
342 342 <li>${h.link_to(_(u'My personal group'), h.url('repo_group_home', group_name=c.rhodecode_user.personal_repo_group.group_name))}</li>
343 343 % endif
344 344 <li class="logout">
345 345 ${h.secure_form(h.route_path('logout'))}
346 346 ${h.submit('log_out', _(u'Sign Out'),class_="btn btn-primary")}
347 347 ${h.end_form()}
348 348 </li>
349 349 </ol>
350 350 </div>
351 351 %endif
352 352 </div>
353 353 </div>
354 354 %if c.rhodecode_user.username != h.DEFAULT_USER:
355 355 <div class="pill_container">
356 356 % if c.unread_notifications == 0:
357 357 <a class="menu_link_notifications empty" href="${h.url('notifications')}">${c.unread_notifications}</a>
358 358 % else:
359 359 <a class="menu_link_notifications" href="${h.url('notifications')}">${c.unread_notifications}</a>
360 360 % endif
361 361 </div>
362 362 % endif
363 363 </li>
364 364 </%def>
365 365
366 366 <%def name="menu_items(active=None)">
367 367 <%
368 368 def is_active(selected):
369 369 if selected == active:
370 370 return "active"
371 371 return ""
372 372 %>
373 373 <ul id="quick" class="main_nav navigation horizontal-list">
374 374 <!-- repo switcher -->
375 375 <li class="${is_active('repositories')} repo_switcher_li has_select2">
376 376 <input id="repo_switcher" name="repo_switcher" type="hidden">
377 377 </li>
378 378
379 379 ## ROOT MENU
380 380 %if c.rhodecode_user.username != h.DEFAULT_USER:
381 381 <li class="${is_active('journal')}">
382 382 <a class="menulink" title="${_('Show activity journal')}" href="${h.url('journal')}">
383 383 <div class="menulabel">${_('Journal')}</div>
384 384 </a>
385 385 </li>
386 386 %else:
387 387 <li class="${is_active('journal')}">
388 388 <a class="menulink" title="${_('Show Public activity journal')}" href="${h.url('public_journal')}">
389 389 <div class="menulabel">${_('Public journal')}</div>
390 390 </a>
391 391 </li>
392 392 %endif
393 393 <li class="${is_active('gists')}">
394 394 <a class="menulink childs" title="${_('Show Gists')}" href="${h.url('gists')}">
395 395 <div class="menulabel">${_('Gists')}</div>
396 396 </a>
397 397 </li>
398 398 <li class="${is_active('search')}">
399 399 <a class="menulink" title="${_('Search in repositories you have access to')}" href="${h.url('search')}">
400 400 <div class="menulabel">${_('Search')}</div>
401 401 </a>
402 402 </li>
403 403 % if h.HasPermissionAll('hg.admin')('access admin main page'):
404 404 <li class="${is_active('admin')}">
405 405 <a class="menulink childs" title="${_('Admin settings')}" href="#" onclick="return false;">
406 406 <div class="menulabel">${_('Admin')} <div class="show_more"></div></div>
407 407 </a>
408 408 ${admin_menu()}
409 409 </li>
410 410 % elif c.rhodecode_user.repositories_admin or c.rhodecode_user.repository_groups_admin or c.rhodecode_user.user_groups_admin:
411 411 <li class="${is_active('admin')}">
412 412 <a class="menulink childs" title="${_('Delegated Admin settings')}">
413 413 <div class="menulabel">${_('Admin')} <div class="show_more"></div></div>
414 414 </a>
415 415 ${admin_menu_simple(c.rhodecode_user.repositories_admin,
416 416 c.rhodecode_user.repository_groups_admin,
417 417 c.rhodecode_user.user_groups_admin or h.HasPermissionAny('hg.usergroup.create.true')())}
418 418 </li>
419 419 % endif
420 420 % if c.debug_style:
421 421 <li class="${is_active('debug_style')}">
422 422 <a class="menulink" title="${_('Style')}" href="${h.url('debug_style_home')}">
423 423 <div class="menulabel">${_('Style')}</div>
424 424 </a>
425 425 </li>
426 426 % endif
427 427 ## render extra user menu
428 ${usermenu()}
428 ${usermenu(active=(active=='my_account'))}
429 429 </ul>
430 430
431 431 <script type="text/javascript">
432 432 var visual_show_public_icon = "${c.visual.show_public_icon}" == "True";
433 433
434 434 /*format the look of items in the list*/
435 435 var format = function(state, escapeMarkup){
436 436 if (!state.id){
437 437 return state.text; // optgroup
438 438 }
439 439 var obj_dict = state.obj;
440 440 var tmpl = '';
441 441
442 442 if(obj_dict && state.type == 'repo'){
443 443 if(obj_dict['repo_type'] === 'hg'){
444 444 tmpl += '<i class="icon-hg"></i> ';
445 445 }
446 446 else if(obj_dict['repo_type'] === 'git'){
447 447 tmpl += '<i class="icon-git"></i> ';
448 448 }
449 449 else if(obj_dict['repo_type'] === 'svn'){
450 450 tmpl += '<i class="icon-svn"></i> ';
451 451 }
452 452 if(obj_dict['private']){
453 453 tmpl += '<i class="icon-lock" ></i> ';
454 454 }
455 455 else if(visual_show_public_icon){
456 456 tmpl += '<i class="icon-unlock-alt"></i> ';
457 457 }
458 458 }
459 459 if(obj_dict && state.type == 'commit') {
460 460 tmpl += '<i class="icon-tag"></i>';
461 461 }
462 462 if(obj_dict && state.type == 'group'){
463 463 tmpl += '<i class="icon-folder-close"></i> ';
464 464 }
465 465 tmpl += escapeMarkup(state.text);
466 466 return tmpl;
467 467 };
468 468
469 469 var formatResult = function(result, container, query, escapeMarkup) {
470 470 return format(result, escapeMarkup);
471 471 };
472 472
473 473 var formatSelection = function(data, container, escapeMarkup) {
474 474 return format(data, escapeMarkup);
475 475 };
476 476
477 477 $("#repo_switcher").select2({
478 478 cachedDataSource: {},
479 479 minimumInputLength: 2,
480 480 placeholder: '<div class="menulabel">${_('Go to')} <div class="show_more"></div></div>',
481 481 dropdownAutoWidth: true,
482 482 formatResult: formatResult,
483 483 formatSelection: formatSelection,
484 484 containerCssClass: "repo-switcher",
485 485 dropdownCssClass: "repo-switcher-dropdown",
486 486 escapeMarkup: function(m){
487 487 // don't escape our custom placeholder
488 488 if(m.substr(0,23) == '<div class="menulabel">'){
489 489 return m;
490 490 }
491 491
492 492 return Select2.util.escapeMarkup(m);
493 493 },
494 494 query: $.debounce(250, function(query){
495 495 self = this;
496 496 var cacheKey = query.term;
497 497 var cachedData = self.cachedDataSource[cacheKey];
498 498
499 499 if (cachedData) {
500 500 query.callback({results: cachedData.results});
501 501 } else {
502 502 $.ajax({
503 503 url: "${h.url('goto_switcher_data')}",
504 504 data: {'query': query.term},
505 505 dataType: 'json',
506 506 type: 'GET',
507 507 success: function(data) {
508 508 self.cachedDataSource[cacheKey] = data;
509 509 query.callback({results: data.results});
510 510 },
511 511 error: function(data, textStatus, errorThrown) {
512 512 alert("Error while fetching entries.\nError code {0} ({1}).".format(data.status, data.statusText));
513 513 }
514 514 })
515 515 }
516 516 })
517 517 });
518 518
519 519 $("#repo_switcher").on('select2-selecting', function(e){
520 520 e.preventDefault();
521 521 window.location = e.choice.url;
522 522 });
523 523
524 524 </script>
525 525 <script src="${h.asset('js/rhodecode/base/keyboard-bindings.js', ver=c.rhodecode_version_hash)}"></script>
526 526 </%def>
527 527
528 528 <div class="modal" id="help_kb" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
529 529 <div class="modal-dialog">
530 530 <div class="modal-content">
531 531 <div class="modal-header">
532 532 <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
533 533 <h4 class="modal-title" id="myModalLabel">${_('Keyboard shortcuts')}</h4>
534 534 </div>
535 535 <div class="modal-body">
536 536 <div class="block-left">
537 537 <table class="keyboard-mappings">
538 538 <tbody>
539 539 <tr>
540 540 <th></th>
541 541 <th>${_('Site-wide shortcuts')}</th>
542 542 </tr>
543 543 <%
544 544 elems = [
545 545 ('/', 'Open quick search box'),
546 546 ('g h', 'Goto home page'),
547 547 ('g g', 'Goto my private gists page'),
548 548 ('g G', 'Goto my public gists page'),
549 549 ('n r', 'New repository page'),
550 550 ('n g', 'New gist page'),
551 551 ]
552 552 %>
553 553 %for key, desc in elems:
554 554 <tr>
555 555 <td class="keys">
556 556 <span class="key tag">${key}</span>
557 557 </td>
558 558 <td>${desc}</td>
559 559 </tr>
560 560 %endfor
561 561 </tbody>
562 562 </table>
563 563 </div>
564 564 <div class="block-left">
565 565 <table class="keyboard-mappings">
566 566 <tbody>
567 567 <tr>
568 568 <th></th>
569 569 <th>${_('Repositories')}</th>
570 570 </tr>
571 571 <%
572 572 elems = [
573 573 ('g s', 'Goto summary page'),
574 574 ('g c', 'Goto changelog page'),
575 575 ('g f', 'Goto files page'),
576 576 ('g F', 'Goto files page with file search activated'),
577 577 ('g p', 'Goto pull requests page'),
578 578 ('g o', 'Goto repository settings'),
579 579 ('g O', 'Goto repository permissions settings'),
580 580 ]
581 581 %>
582 582 %for key, desc in elems:
583 583 <tr>
584 584 <td class="keys">
585 585 <span class="key tag">${key}</span>
586 586 </td>
587 587 <td>${desc}</td>
588 588 </tr>
589 589 %endfor
590 590 </tbody>
591 591 </table>
592 592 </div>
593 593 </div>
594 594 <div class="modal-footer">
595 595 </div>
596 596 </div><!-- /.modal-content -->
597 597 </div><!-- /.modal-dialog -->
598 598 </div><!-- /.modal -->
General Comments 0
You need to be logged in to leave comments. Login now