##// END OF EJS Templates
ui: bookmark items should use consisten space leading position number so UI is evenly displayed
marcink -
r3434:1f1d701e default
parent child Browse files
Show More
@@ -1,728 +1,728 b''
1 1 ## -*- coding: utf-8 -*-
2 2 <%inherit file="root.mako"/>
3 3
4 4 <%include file="/ejs_templates/templates.html"/>
5 5
6 6 <div class="outerwrapper">
7 7 <!-- HEADER -->
8 8 <div class="header">
9 9 <div id="header-inner" class="wrapper">
10 10 <div id="logo">
11 11 <div class="logo-wrapper">
12 12 <a href="${h.route_path('home')}"><img src="${h.asset('images/rhodecode-logo-white-216x60.png')}" alt="RhodeCode"/></a>
13 13 </div>
14 14 %if c.rhodecode_name:
15 15 <div class="branding">- ${h.branding(c.rhodecode_name)}</div>
16 16 %endif
17 17 </div>
18 18 <!-- MENU BAR NAV -->
19 19 ${self.menu_bar_nav()}
20 20 <!-- END MENU BAR NAV -->
21 21 </div>
22 22 </div>
23 23 ${self.menu_bar_subnav()}
24 24 <!-- END HEADER -->
25 25
26 26 <!-- CONTENT -->
27 27 <div id="content" class="wrapper">
28 28
29 29 <rhodecode-toast id="notifications"></rhodecode-toast>
30 30
31 31 <div class="main">
32 32 ${next.main()}
33 33 </div>
34 34 </div>
35 35 <!-- END CONTENT -->
36 36
37 37 </div>
38 38 <!-- FOOTER -->
39 39 <div id="footer">
40 40 <div id="footer-inner" class="title wrapper">
41 41 <div>
42 42 <p class="footer-link-right">
43 43 % if c.visual.show_version:
44 44 RhodeCode Enterprise ${c.rhodecode_version} ${c.rhodecode_edition}
45 45 % endif
46 46 &copy; 2010-${h.datetime.today().year}, <a href="${h.route_url('rhodecode_official')}" target="_blank">RhodeCode GmbH</a>. All rights reserved.
47 47 % if c.visual.rhodecode_support_url:
48 48 <a href="${c.visual.rhodecode_support_url}" target="_blank">${_('Support')}</a>
49 49 % endif
50 50 </p>
51 51 <% sid = 'block' if request.GET.get('showrcid') else 'none' %>
52 52 <p class="server-instance" style="display:${sid}">
53 53 ## display hidden instance ID if specially defined
54 54 % if c.rhodecode_instanceid:
55 55 ${_('RhodeCode instance id: {}').format(c.rhodecode_instanceid)}
56 56 % endif
57 57 </p>
58 58 </div>
59 59 </div>
60 60 </div>
61 61
62 62 <!-- END FOOTER -->
63 63
64 64 ### MAKO DEFS ###
65 65
66 66 <%def name="menu_bar_subnav()">
67 67 </%def>
68 68
69 69 <%def name="breadcrumbs(class_='breadcrumbs')">
70 70 <div class="${class_}">
71 71 ${self.breadcrumbs_links()}
72 72 </div>
73 73 </%def>
74 74
75 75 <%def name="admin_menu()">
76 76 <ul class="admin_menu submenu">
77 77 <li><a href="${h.route_path('admin_audit_logs')}">${_('Admin audit logs')}</a></li>
78 78 <li><a href="${h.route_path('repos')}">${_('Repositories')}</a></li>
79 79 <li><a href="${h.route_path('repo_groups')}">${_('Repository groups')}</a></li>
80 80 <li><a href="${h.route_path('users')}">${_('Users')}</a></li>
81 81 <li><a href="${h.route_path('user_groups')}">${_('User groups')}</a></li>
82 82 <li><a href="${h.route_path('admin_permissions_application')}">${_('Permissions')}</a></li>
83 83 <li><a href="${h.route_path('auth_home', traverse='')}">${_('Authentication')}</a></li>
84 84 <li><a href="${h.route_path('global_integrations_home')}">${_('Integrations')}</a></li>
85 85 <li><a href="${h.route_path('admin_defaults_repositories')}">${_('Defaults')}</a></li>
86 86 <li class="last"><a href="${h.route_path('admin_settings')}">${_('Settings')}</a></li>
87 87 </ul>
88 88 </%def>
89 89
90 90
91 91 <%def name="dt_info_panel(elements)">
92 92 <dl class="dl-horizontal">
93 93 %for dt, dd, title, show_items in elements:
94 94 <dt>${dt}:</dt>
95 95 <dd title="${h.tooltip(title)}">
96 96 %if callable(dd):
97 97 ## allow lazy evaluation of elements
98 98 ${dd()}
99 99 %else:
100 100 ${dd}
101 101 %endif
102 102 %if show_items:
103 103 <span class="btn-collapse" data-toggle="item-${h.md5_safe(dt)[:6]}-details">${_('Show More')} </span>
104 104 %endif
105 105 </dd>
106 106
107 107 %if show_items:
108 108 <div class="collapsable-content" data-toggle="item-${h.md5_safe(dt)[:6]}-details" style="display: none">
109 109 %for item in show_items:
110 110 <dt></dt>
111 111 <dd>${item}</dd>
112 112 %endfor
113 113 </div>
114 114 %endif
115 115
116 116 %endfor
117 117 </dl>
118 118 </%def>
119 119
120 120
121 121 <%def name="gravatar(email, size=16)">
122 122 <%
123 123 if (size > 16):
124 124 gravatar_class = 'gravatar gravatar-large'
125 125 else:
126 126 gravatar_class = 'gravatar'
127 127 %>
128 128 <%doc>
129 129 TODO: johbo: For now we serve double size images to make it smooth
130 130 for retina. This is how it worked until now. Should be replaced
131 131 with a better solution at some point.
132 132 </%doc>
133 133 <img class="${gravatar_class}" src="${h.gravatar_url(email, size * 2)}" height="${size}" width="${size}">
134 134 </%def>
135 135
136 136
137 137 <%def name="gravatar_with_user(contact, size=16, show_disabled=False)">
138 138 <% email = h.email_or_none(contact) %>
139 139 <div class="rc-user tooltip" title="${h.tooltip(h.author_string(email))}">
140 140 ${self.gravatar(email, size)}
141 141 <span class="${'user user-disabled' if show_disabled else 'user'}"> ${h.link_to_user(contact)}</span>
142 142 </div>
143 143 </%def>
144 144
145 145
146 146 ## admin menu used for people that have some admin resources
147 147 <%def name="admin_menu_simple(repositories=None, repository_groups=None, user_groups=None)">
148 148 <ul class="submenu">
149 149 %if repositories:
150 150 <li class="local-admin-repos"><a href="${h.route_path('repos')}">${_('Repositories')}</a></li>
151 151 %endif
152 152 %if repository_groups:
153 153 <li class="local-admin-repo-groups"><a href="${h.route_path('repo_groups')}">${_('Repository groups')}</a></li>
154 154 %endif
155 155 %if user_groups:
156 156 <li class="local-admin-user-groups"><a href="${h.route_path('user_groups')}">${_('User groups')}</a></li>
157 157 %endif
158 158 </ul>
159 159 </%def>
160 160
161 161 <%def name="repo_page_title(repo_instance)">
162 162 <div class="title-content">
163 163 <div class="title-main">
164 164 ## SVN/HG/GIT icons
165 165 %if h.is_hg(repo_instance):
166 166 <i class="icon-hg"></i>
167 167 %endif
168 168 %if h.is_git(repo_instance):
169 169 <i class="icon-git"></i>
170 170 %endif
171 171 %if h.is_svn(repo_instance):
172 172 <i class="icon-svn"></i>
173 173 %endif
174 174
175 175 ## public/private
176 176 %if repo_instance.private:
177 177 <i class="icon-repo-private"></i>
178 178 %else:
179 179 <i class="icon-repo-public"></i>
180 180 %endif
181 181
182 182 ## repo name with group name
183 183 ${h.breadcrumb_repo_link(c.rhodecode_db_repo)}
184 184
185 185 </div>
186 186
187 187 ## FORKED
188 188 %if repo_instance.fork:
189 189 <p>
190 190 <i class="icon-code-fork"></i> ${_('Fork of')}
191 191 ${h.link_to_if(c.has_origin_repo_read_perm,repo_instance.fork.repo_name, h.route_path('repo_summary', repo_name=repo_instance.fork.repo_name))}
192 192 </p>
193 193 %endif
194 194
195 195 ## IMPORTED FROM REMOTE
196 196 %if repo_instance.clone_uri:
197 197 <p>
198 198 <i class="icon-code-fork"></i> ${_('Clone from')}
199 199 <a href="${h.safe_str(h.hide_credentials(repo_instance.clone_uri))}">${h.hide_credentials(repo_instance.clone_uri)}</a>
200 200 </p>
201 201 %endif
202 202
203 203 ## LOCKING STATUS
204 204 %if repo_instance.locked[0]:
205 205 <p class="locking_locked">
206 206 <i class="icon-repo-lock"></i>
207 207 ${_('Repository locked by %(user)s') % {'user': h.person_by_id(repo_instance.locked[0])}}
208 208 </p>
209 209 %elif repo_instance.enable_locking:
210 210 <p class="locking_unlocked">
211 211 <i class="icon-repo-unlock"></i>
212 212 ${_('Repository not locked. Pull repository to lock it.')}
213 213 </p>
214 214 %endif
215 215
216 216 </div>
217 217 </%def>
218 218
219 219 <%def name="repo_menu(active=None)">
220 220 <%
221 221 def is_active(selected):
222 222 if selected == active:
223 223 return "active"
224 224 %>
225 225
226 226 <!--- CONTEXT BAR -->
227 227 <div id="context-bar">
228 228 <div class="wrapper">
229 229 <ul id="context-pages" class="navigation horizontal-list">
230 230 <li class="${is_active('summary')}"><a class="menulink" href="${h.route_path('repo_summary', repo_name=c.repo_name)}"><div class="menulabel">${_('Summary')}</div></a></li>
231 231 <li class="${is_active('changelog')}"><a class="menulink" href="${h.route_path('repo_changelog', repo_name=c.repo_name)}"><div class="menulabel">${_('Changelog')}</div></a></li>
232 232 <li class="${is_active('files')}"><a class="menulink" href="${h.route_path('repo_files', repo_name=c.repo_name, commit_id=c.rhodecode_db_repo.landing_rev[1], f_path='')}"><div class="menulabel">${_('Files')}</div></a></li>
233 233 <li class="${is_active('compare')}"><a class="menulink" href="${h.route_path('repo_compare_select',repo_name=c.repo_name)}"><div class="menulabel">${_('Compare')}</div></a></li>
234 234 ## TODO: anderson: ideally it would have a function on the scm_instance "enable_pullrequest() and enable_fork()"
235 235 %if c.rhodecode_db_repo.repo_type in ['git','hg']:
236 236 <li class="${is_active('showpullrequest')}">
237 237 <a class="menulink" href="${h.route_path('pullrequest_show_all', repo_name=c.repo_name)}" title="${h.tooltip(_('Show Pull Requests for %s') % c.repo_name)}">
238 238 %if c.repository_pull_requests:
239 239 <span class="pr_notifications">${c.repository_pull_requests}</span>
240 240 %endif
241 241 <div class="menulabel">${_('Pull Requests')}</div>
242 242 </a>
243 243 </li>
244 244 %endif
245 245 <li class="${is_active('options')}">
246 246 <a class="menulink dropdown">
247 247 <div class="menulabel">${_('Options')} <div class="show_more"></div></div>
248 248 </a>
249 249 <ul class="submenu">
250 250 %if h.HasRepoPermissionAll('repository.admin')(c.repo_name):
251 251 <li><a href="${h.route_path('edit_repo',repo_name=c.repo_name)}">${_('Settings')}</a></li>
252 252 %endif
253 253 %if c.rhodecode_db_repo.fork:
254 254 <li>
255 255 <a title="${h.tooltip(_('Compare fork with %s' % c.rhodecode_db_repo.fork.repo_name))}"
256 256 href="${h.route_path('repo_compare',
257 257 repo_name=c.rhodecode_db_repo.fork.repo_name,
258 258 source_ref_type=c.rhodecode_db_repo.landing_rev[0],
259 259 source_ref=c.rhodecode_db_repo.landing_rev[1],
260 260 target_repo=c.repo_name,target_ref_type='branch' if request.GET.get('branch') else c.rhodecode_db_repo.landing_rev[0],
261 261 target_ref=request.GET.get('branch') or c.rhodecode_db_repo.landing_rev[1],
262 262 _query=dict(merge=1))}"
263 263 >
264 264 ${_('Compare fork')}
265 265 </a>
266 266 </li>
267 267 %endif
268 268
269 269 <li><a href="${h.route_path('search_repo',repo_name=c.repo_name)}">${_('Search')}</a></li>
270 270
271 271 %if h.HasRepoPermissionAny('repository.write','repository.admin')(c.repo_name) and c.rhodecode_db_repo.enable_locking:
272 272 %if c.rhodecode_db_repo.locked[0]:
273 273 <li><a class="locking_del" href="${h.route_path('repo_edit_toggle_locking',repo_name=c.repo_name)}">${_('Unlock')}</a></li>
274 274 %else:
275 275 <li><a class="locking_add" href="${h.route_path('repo_edit_toggle_locking',repo_name=c.repo_name)}">${_('Lock')}</a></li>
276 276 %endif
277 277 %endif
278 278 %if c.rhodecode_user.username != h.DEFAULT_USER:
279 279 %if c.rhodecode_db_repo.repo_type in ['git','hg']:
280 280 <li><a href="${h.route_path('repo_fork_new',repo_name=c.repo_name)}">${_('Fork')}</a></li>
281 281 <li><a href="${h.route_path('pullrequest_new',repo_name=c.repo_name)}">${_('Create Pull Request')}</a></li>
282 282 %endif
283 283 %endif
284 284 </ul>
285 285 </li>
286 286 </ul>
287 287 </div>
288 288 <div class="clear"></div>
289 289 </div>
290 290 % if c.rhodecode_db_repo.archived:
291 291 <div class="alert alert-warning text-center">
292 292 <strong>${_('This repository has been archived. It is now read-only.')}</strong>
293 293 </div>
294 294 % endif
295 295 <!--- END CONTEXT BAR -->
296 296
297 297 </%def>
298 298
299 299 <%def name="usermenu(active=False)">
300 300 ## USER MENU
301 301 <li id="quick_login_li" class="${'active' if active else ''}">
302 302 % if c.rhodecode_user.username == h.DEFAULT_USER:
303 303 <a id="quick_login_link" class="menulink childs" href="${h.route_path('login', _query={'came_from': h.current_route_path(request)})}">
304 304 ${gravatar(c.rhodecode_user.email, 20)}
305 305 <span class="user">
306 306 <span>${_('Sign in')}</span>
307 307 </span>
308 308 </a>
309 309 % else:
310 310 ## logged in user
311 311 <a id="quick_login_link" class="menulink childs">
312 312 ${gravatar(c.rhodecode_user.email, 20)}
313 313 <span class="user">
314 314 <span class="menu_link_user">${c.rhodecode_user.username}</span>
315 315 <div class="show_more"></div>
316 316 </span>
317 317 </a>
318 318 ## subnav with menu for logged in user
319 319 <div class="user-menu submenu">
320 320 <div id="quick_login">
321 321 %if c.rhodecode_user.username != h.DEFAULT_USER:
322 322 <div class="">
323 323 <div class="big_gravatar">${gravatar(c.rhodecode_user.email, 48)}</div>
324 324 <div class="full_name">${c.rhodecode_user.full_name_or_username}</div>
325 325 <div class="email">${c.rhodecode_user.email}</div>
326 326 </div>
327 327 <div class="">
328 328 <ol class="links">
329 329 <li>${h.link_to(_(u'My account'),h.route_path('my_account_profile'))}</li>
330 330 % if c.rhodecode_user.personal_repo_group:
331 331 <li>${h.link_to(_(u'My personal group'), h.route_path('repo_group_home', repo_group_name=c.rhodecode_user.personal_repo_group.group_name))}</li>
332 332 % endif
333 333 <li>${h.link_to(_(u'Pull Requests'), h.route_path('my_account_pullrequests'))}</li>
334 334 ## bookmark-items
335 335 <li class="bookmark-items">
336 336 ${_('Bookmarks')}
337 337 <div class="pull-right">
338 338 <a href="${h.route_path('my_account_bookmarks')}">${_('Manage')}</a>
339 339 </div>
340 340 </li>
341 341 % if not c.bookmark_items:
342 342 <li>
343 343 <a href="${h.route_path('my_account_bookmarks')}">${_('No Bookmarks yet.')}</a>
344 344 </li>
345 345 % endif
346 346 % for item in c.bookmark_items:
347 347 <li>
348 348 % if item.repository:
349 349 <div>
350 350 <a class="bookmark-item" href="${h.route_path('my_account_goto_bookmark', bookmark_id=item.position)}">
351 ${item.position}
351 <code>${item.position}</code>
352 352 % if item.repository.repo_type == 'hg':
353 353 <i class="icon-hg" title="${_('Repository')}" style="font-size: 16px"></i>
354 354 % elif item.repository.repo_type == 'git':
355 355 <i class="icon-git" title="${_('Repository')}" style="font-size: 16px"></i>
356 356 % elif item.repository.repo_type == 'svn':
357 357 <i class="icon-svn" title="${_('Repository')}" style="font-size: 16px"></i>
358 358 % endif
359 359 ${(item.title or h.shorter(item.repository.repo_name, 30))}
360 360 </a>
361 361 </div>
362 362 % elif item.repository_group:
363 363 <div>
364 364 <a class="bookmark-item" href="${h.route_path('my_account_goto_bookmark', bookmark_id=item.position)}">
365 ${item.position}
365 <code>${item.position}</code>
366 366 <i class="icon-folder-close" title="${_('Repository group')}" style="font-size: 16px"></i>
367 367 ${(item.title or h.shorter(item.repository_group.group_name, 30))}
368 368 </a>
369 369 </div>
370 370 % else:
371 371 <a class="bookmark-item" href="${h.route_path('my_account_goto_bookmark', bookmark_id=item.position)}">
372 ${item.position}
372 <code>${item.position}</code>
373 373 ${item.title}
374 374 </a>
375 375 % endif
376 376 </li>
377 377 % endfor
378 378
379 379 <li class="logout">
380 380 ${h.secure_form(h.route_path('logout'), request=request)}
381 381 ${h.submit('log_out', _(u'Sign Out'),class_="btn btn-primary")}
382 382 ${h.end_form()}
383 383 </li>
384 384 </ol>
385 385 </div>
386 386 %endif
387 387 </div>
388 388 </div>
389 389 ## unread counter
390 390 <div class="pill_container">
391 391 <a class="menu_link_notifications ${'empty' if c.unread_notifications == 0 else ''}" href="${h.route_path('notifications_show_all')}">${c.unread_notifications}</a>
392 392 </div>
393 393 % endif
394 394 </li>
395 395 </%def>
396 396
397 397 <%def name="menu_items(active=None)">
398 398 <%
399 399 def is_active(selected):
400 400 if selected == active:
401 401 return "active"
402 402 return ""
403 403 %>
404 404
405 405 <ul id="quick" class="main_nav navigation horizontal-list">
406 406 ## notice box for important system messages
407 407 <li style="display: none">
408 408 <a class="notice-box" href="#openNotice" onclick="showNoticeBox(); return false">
409 409 <div class="menulabel-notice" >
410 410 0
411 411 </div>
412 412 </a>
413 413 </li>
414 414
415 415 ## Main filter
416 416 <li>
417 417 <div class="menulabel main_filter_box">
418 418 <div class="main_filter_input_box">
419 419 <input class="main_filter_input" id="main_filter" size="15" type="text" name="main_filter" placeholder="${_('search / go to...')}" value=""/>
420 420 </div>
421 421 <div class="main_filter_help_box">
422 422 <a href="#showFilterHelp" onclick="showMainFilterBox(); return false">?</a>
423 423 </div>
424 424 </div>
425 425
426 426 <div id="main_filter_help" style="display: none">
427 427 Use '/' key to quickly access this field.
428 428 Enter name of repository, or repository group for quick search.
429 429
430 430 Prefix query to allow special search:
431 431
432 432 user:admin, to search for usernames
433 433
434 434 user_group:devops, to search for user groups
435 435
436 436 commit:efced4, to search for commits
437 437
438 438 </div>
439 439 </li>
440 440
441 441 ## ROOT MENU
442 442 %if c.rhodecode_user.username != h.DEFAULT_USER:
443 443 <li class="${is_active('journal')}">
444 444 <a class="menulink" title="${_('Show activity journal')}" href="${h.route_path('journal')}">
445 445 <div class="menulabel">${_('Journal')}</div>
446 446 </a>
447 447 </li>
448 448 %else:
449 449 <li class="${is_active('journal')}">
450 450 <a class="menulink" title="${_('Show Public activity journal')}" href="${h.route_path('journal_public')}">
451 451 <div class="menulabel">${_('Public journal')}</div>
452 452 </a>
453 453 </li>
454 454 %endif
455 455 <li class="${is_active('gists')}">
456 456 <a class="menulink childs" title="${_('Show Gists')}" href="${h.route_path('gists_show')}">
457 457 <div class="menulabel">${_('Gists')}</div>
458 458 </a>
459 459 </li>
460 460 <li class="${is_active('search')}">
461 461 <a class="menulink" title="${_('Search in repositories you have access to')}" href="${h.route_path('search')}">
462 462 <div class="menulabel">${_('Search')}</div>
463 463 </a>
464 464 </li>
465 465 % if h.HasPermissionAll('hg.admin')('access admin main page'):
466 466 <li class="${is_active('admin')}">
467 467 <a class="menulink childs" title="${_('Admin settings')}" href="#" onclick="return false;">
468 468 <div class="menulabel">${_('Admin')} <div class="show_more"></div></div>
469 469 </a>
470 470 ${admin_menu()}
471 471 </li>
472 472 % elif c.rhodecode_user.repositories_admin or c.rhodecode_user.repository_groups_admin or c.rhodecode_user.user_groups_admin:
473 473 <li class="${is_active('admin')}">
474 474 <a class="menulink childs" title="${_('Delegated Admin settings')}">
475 475 <div class="menulabel">${_('Admin')} <div class="show_more"></div></div>
476 476 </a>
477 477 ${admin_menu_simple(c.rhodecode_user.repositories_admin,
478 478 c.rhodecode_user.repository_groups_admin,
479 479 c.rhodecode_user.user_groups_admin or h.HasPermissionAny('hg.usergroup.create.true')())}
480 480 </li>
481 481 % endif
482 482 ## render extra user menu
483 483 ${usermenu(active=(active=='my_account'))}
484 484
485 485 % if c.debug_style:
486 486 <li>
487 487 <a class="menulink" title="${_('Style')}" href="${h.route_path('debug_style_home')}">
488 488 <div class="menulabel">${_('[Style]')}</div>
489 489 </a>
490 490 </li>
491 491 % endif
492 492 </ul>
493 493
494 494 <script type="text/javascript">
495 495 var visualShowPublicIcon = "${c.visual.show_public_icon}" == "True";
496 496
497 497 var formatRepoResult = function(result, container, query, escapeMarkup) {
498 498 return function(data, escapeMarkup) {
499 499 if (!data.repo_id){
500 500 return data.text; // optgroup text Repositories
501 501 }
502 502
503 503 var tmpl = '';
504 504 var repoType = data['repo_type'];
505 505 var repoName = data['text'];
506 506
507 507 if(data && data.type == 'repo'){
508 508 if(repoType === 'hg'){
509 509 tmpl += '<i class="icon-hg"></i> ';
510 510 }
511 511 else if(repoType === 'git'){
512 512 tmpl += '<i class="icon-git"></i> ';
513 513 }
514 514 else if(repoType === 'svn'){
515 515 tmpl += '<i class="icon-svn"></i> ';
516 516 }
517 517 if(data['private']){
518 518 tmpl += '<i class="icon-lock" ></i> ';
519 519 }
520 520 else if(visualShowPublicIcon){
521 521 tmpl += '<i class="icon-unlock-alt"></i> ';
522 522 }
523 523 }
524 524 tmpl += escapeMarkup(repoName);
525 525 return tmpl;
526 526
527 527 }(result, escapeMarkup);
528 528 };
529 529
530 530 var formatRepoGroupResult = function(result, container, query, escapeMarkup) {
531 531 return function(data, escapeMarkup) {
532 532 if (!data.repo_group_id){
533 533 return data.text; // optgroup text Repositories
534 534 }
535 535
536 536 var tmpl = '';
537 537 var repoGroupName = data['text'];
538 538
539 539 if(data){
540 540
541 541 tmpl += '<i class="icon-folder-close"></i> ';
542 542
543 543 }
544 544 tmpl += escapeMarkup(repoGroupName);
545 545 return tmpl;
546 546
547 547 }(result, escapeMarkup);
548 548 };
549 549
550 550
551 551 var autocompleteMainFilterFormatResult = function (data, value, org_formatter) {
552 552
553 553 if (value.split(':').length === 2) {
554 554 value = value.split(':')[1]
555 555 }
556 556
557 557 var searchType = data['type'];
558 558 var valueDisplay = data['value_display'];
559 559
560 560 var escapeRegExChars = function (value) {
561 561 return value.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
562 562 };
563 563 var pattern = '(' + escapeRegExChars(value) + ')';
564 564
565 565 // highlight match
566 566 valueDisplay = Select2.util.escapeMarkup(valueDisplay);
567 567 valueDisplay = valueDisplay.replace(new RegExp(pattern, 'gi'), '<strong>$1<\/strong>');
568 568
569 569 var icon = '';
570 570
571 571 if (searchType === 'hint') {
572 572 icon += '<i class="icon-folder-close"></i> ';
573 573 }
574 574 else if (searchType === 'search') {
575 575 icon += '<i class="icon-more"></i> ';
576 576 }
577 577 else if (searchType === 'repo') {
578 578 if (data['repo_type'] === 'hg') {
579 579 icon += '<i class="icon-hg"></i> ';
580 580 }
581 581 else if (data['repo_type'] === 'git') {
582 582 icon += '<i class="icon-git"></i> ';
583 583 }
584 584 else if (data['repo_type'] === 'svn') {
585 585 icon += '<i class="icon-svn"></i> ';
586 586 }
587 587 if (data['private']) {
588 588 icon += '<i class="icon-lock" ></i> ';
589 589 }
590 590 else if (visualShowPublicIcon) {
591 591 icon += '<i class="icon-unlock-alt"></i> ';
592 592 }
593 593 }
594 594 else if (searchType === 'repo_group') {
595 595 icon += '<i class="icon-folder-close"></i> ';
596 596 }
597 597 else if (searchType === 'user_group') {
598 598 icon += '<i class="icon-group"></i> ';
599 599 }
600 600 else if (searchType === 'user') {
601 601 icon += '<img class="gravatar" src="{0}"/>'.format(data['icon_link']);
602 602 }
603 603 else if (searchType === 'commit') {
604 604 icon += '<i class="icon-tag"></i>';
605 605 }
606 606
607 607 var tmpl = '<div class="ac-container-wrap">{0}{1}</div>';
608 608 return tmpl.format(icon, valueDisplay);
609 609 };
610 610
611 611 var handleSelect = function(element, suggestion) {
612 612 if (suggestion.type === "hint") {
613 613 // we skip action
614 614 $('#main_filter').focus();
615 615 } else {
616 616 window.location = suggestion['url'];
617 617 }
618 618 };
619 619 var autocompleteMainFilterResult = function (suggestion, originalQuery, queryLowerCase) {
620 620 if (queryLowerCase.split(':').length === 2) {
621 621 queryLowerCase = queryLowerCase.split(':')[1]
622 622 }
623 623 return suggestion.value_display.toLowerCase().indexOf(queryLowerCase) !== -1;
624 624 };
625 625
626 626 $('#main_filter').autocomplete({
627 627 serviceUrl: pyroutes.url('goto_switcher_data'),
628 628 params: {"search_context": templateContext.search_context},
629 629 minChars:2,
630 630 maxHeight:400,
631 631 deferRequestBy: 300, //miliseconds
632 632 tabDisabled: true,
633 633 autoSelectFirst: true,
634 634 formatResult: autocompleteMainFilterFormatResult,
635 635 lookupFilter: autocompleteMainFilterResult,
636 636 onSelect: function (element, suggestion) {
637 637 handleSelect(element, suggestion);
638 638 return false;
639 639 },
640 640 onSearchError: function (element, query, jqXHR, textStatus, errorThrown) {
641 641 if (jqXHR !== 'abort') {
642 642 alert("Error during search.\nError code: {0}".format(textStatus));
643 643 window.location = '';
644 644 }
645 645 }
646 646 });
647 647
648 648 showMainFilterBox = function () {
649 649 $('#main_filter_help').toggle();
650 650 }
651 651
652 652 </script>
653 653 <script src="${h.asset('js/rhodecode/base/keyboard-bindings.js', ver=c.rhodecode_version_hash)}"></script>
654 654 </%def>
655 655
656 656 <div class="modal" id="help_kb" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
657 657 <div class="modal-dialog">
658 658 <div class="modal-content">
659 659 <div class="modal-header">
660 660 <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
661 661 <h4 class="modal-title" id="myModalLabel">${_('Keyboard shortcuts')}</h4>
662 662 </div>
663 663 <div class="modal-body">
664 664 <div class="block-left">
665 665 <table class="keyboard-mappings">
666 666 <tbody>
667 667 <tr>
668 668 <th></th>
669 669 <th>${_('Site-wide shortcuts')}</th>
670 670 </tr>
671 671 <%
672 672 elems = [
673 673 ('/', 'Use quick search box'),
674 674 ('g h', 'Goto home page'),
675 675 ('g g', 'Goto my private gists page'),
676 676 ('g G', 'Goto my public gists page'),
677 677 ('g 0-9', 'Goto bookmarked items from 0-9'),
678 678 ('n r', 'New repository page'),
679 679 ('n g', 'New gist page'),
680 680 ]
681 681 %>
682 682 %for key, desc in elems:
683 683 <tr>
684 684 <td class="keys">
685 685 <span class="key tag">${key}</span>
686 686 </td>
687 687 <td>${desc}</td>
688 688 </tr>
689 689 %endfor
690 690 </tbody>
691 691 </table>
692 692 </div>
693 693 <div class="block-left">
694 694 <table class="keyboard-mappings">
695 695 <tbody>
696 696 <tr>
697 697 <th></th>
698 698 <th>${_('Repositories')}</th>
699 699 </tr>
700 700 <%
701 701 elems = [
702 702 ('g s', 'Goto summary page'),
703 703 ('g c', 'Goto changelog page'),
704 704 ('g f', 'Goto files page'),
705 705 ('g F', 'Goto files page with file search activated'),
706 706 ('g p', 'Goto pull requests page'),
707 707 ('g o', 'Goto repository settings'),
708 708 ('g O', 'Goto repository permissions settings'),
709 709 ]
710 710 %>
711 711 %for key, desc in elems:
712 712 <tr>
713 713 <td class="keys">
714 714 <span class="key tag">${key}</span>
715 715 </td>
716 716 <td>${desc}</td>
717 717 </tr>
718 718 %endfor
719 719 </tbody>
720 720 </table>
721 721 </div>
722 722 </div>
723 723 <div class="modal-footer">
724 724 </div>
725 725 </div><!-- /.modal-content -->
726 726 </div><!-- /.modal-dialog -->
727 727 </div><!-- /.modal -->
728 728
General Comments 0
You need to be logged in to leave comments. Login now