Show More
@@ -1,549 +1,551 b'' | |||||
1 | ## -*- coding: utf-8 -*- |
|
1 | ## -*- coding: utf-8 -*- | |
2 | <%inherit file="root.html"/> |
|
2 | <%inherit file="root.html"/> | |
3 |
|
3 | |||
4 | <!-- CONTENT --> |
|
4 | <!-- CONTENT --> | |
5 | <div id="content"> |
|
5 | <div id="content"> | |
6 | ${self.flash_msg()} |
|
6 | ${self.flash_msg()} | |
7 | <div id="main"> |
|
7 | <div id="main"> | |
8 | ${next.main()} |
|
8 | ${next.main()} | |
9 | </div> |
|
9 | </div> | |
10 | </div> |
|
10 | </div> | |
11 | <!-- END CONTENT --> |
|
11 | <!-- END CONTENT --> | |
12 |
|
12 | |||
13 | <!-- FOOTER --> |
|
13 | <!-- FOOTER --> | |
14 | <div id="footer"> |
|
14 | <div id="footer"> | |
15 | <div id="footer-inner" class="title"> |
|
15 | <div id="footer-inner" class="title"> | |
16 | <div> |
|
16 | <div> | |
17 | <p class="footer-link"> |
|
17 | <p class="footer-link"> | |
18 | ${_('Server instance: %s') % c.instance_id if c.instance_id else ''} |
|
18 | ${_('Server instance: %s') % c.instance_id if c.instance_id else ''} | |
19 | </p> |
|
19 | </p> | |
20 | <p class="footer-link-right"> |
|
20 | <p class="footer-link-right"> | |
21 | This site is powered by |
|
21 | This site is powered by | |
22 | %if c.visual.show_version: |
|
22 | %if c.visual.show_version: | |
23 | <a href="${h.url('kallithea_project_url')}" target="_blank">Kallithea</a> ${c.kallithea_version}, |
|
23 | <a href="${h.url('kallithea_project_url')}" target="_blank">Kallithea</a> ${c.kallithea_version}, | |
24 | %else: |
|
24 | %else: | |
25 | <a href="${h.url('kallithea_project_url')}" target="_blank">Kallithea</a>, |
|
25 | <a href="${h.url('kallithea_project_url')}" target="_blank">Kallithea</a>, | |
26 | %endif |
|
26 | %endif | |
27 | which is |
|
27 | which is | |
28 | <a href="${h.canonical_url('about')}#copyright">© 2010–2016 by various authors & licensed under GPLv3</a>. |
|
28 | <a href="${h.canonical_url('about')}#copyright">© 2010–2016 by various authors & licensed under GPLv3</a>. | |
29 | %if c.issues_url: |
|
29 | %if c.issues_url: | |
30 | – <a href="${c.issues_url}" target="_blank">${_('Support')}</a> |
|
30 | – <a href="${c.issues_url}" target="_blank">${_('Support')}</a> | |
31 | %endif |
|
31 | %endif | |
32 | </p> |
|
32 | </p> | |
33 | </div> |
|
33 | </div> | |
34 | </div> |
|
34 | </div> | |
35 | </div> |
|
35 | </div> | |
36 |
|
36 | |||
37 | <!-- END FOOTER --> |
|
37 | <!-- END FOOTER --> | |
38 |
|
38 | |||
39 | ### MAKO DEFS ### |
|
39 | ### MAKO DEFS ### | |
40 |
|
40 | |||
41 | <%block name="branding_title"> |
|
41 | <%block name="branding_title"> | |
42 | %if c.site_name: |
|
42 | %if c.site_name: | |
43 | · ${c.site_name} |
|
43 | · ${c.site_name} | |
44 | %endif |
|
44 | %endif | |
45 | </%block> |
|
45 | </%block> | |
46 |
|
46 | |||
47 | <%def name="flash_msg()"> |
|
47 | <%def name="flash_msg()"> | |
48 | <%include file="/base/flash_msg.html"/> |
|
48 | <%include file="/base/flash_msg.html"/> | |
49 | </%def> |
|
49 | </%def> | |
50 |
|
50 | |||
51 | <%def name="breadcrumbs()"> |
|
51 | <%def name="breadcrumbs()"> | |
52 | <div class="breadcrumbs"> |
|
52 | <div class="breadcrumbs"> | |
53 | ${self.breadcrumbs_links()} |
|
53 | ${self.breadcrumbs_links()} | |
54 | </div> |
|
54 | </div> | |
55 | </%def> |
|
55 | </%def> | |
56 |
|
56 | |||
57 | <%def name="admin_menu()"> |
|
57 | <%def name="admin_menu()"> | |
58 | <ul class="dropdown-menu" role="menu"> |
|
58 | <ul class="dropdown-menu" role="menu"> | |
59 | <li><a href="${h.url('admin_home')}"><i class="icon-book"></i> ${_('Admin Journal')}</a></li> |
|
59 | <li><a href="${h.url('admin_home')}"><i class="icon-book"></i> ${_('Admin Journal')}</a></li> | |
60 | <li><a href="${h.url('repos')}"><i class="icon-database"></i> ${_('Repositories')}</a></li> |
|
60 | <li><a href="${h.url('repos')}"><i class="icon-database"></i> ${_('Repositories')}</a></li> | |
61 | <li><a href="${h.url('repos_groups')}"><i class="icon-folder"></i> ${_('Repository Groups')}</a></li> |
|
61 | <li><a href="${h.url('repos_groups')}"><i class="icon-folder"></i> ${_('Repository Groups')}</a></li> | |
62 | <li><a href="${h.url('users')}"><i class="icon-user"></i> ${_('Users')}</a></li> |
|
62 | <li><a href="${h.url('users')}"><i class="icon-user"></i> ${_('Users')}</a></li> | |
63 | <li><a href="${h.url('users_groups')}"><i class="icon-users"></i> ${_('User Groups')}</a></li> |
|
63 | <li><a href="${h.url('users_groups')}"><i class="icon-users"></i> ${_('User Groups')}</a></li> | |
64 | <li><a href="${h.url('admin_permissions')}"><i class="icon-block"></i> ${_('Default Permissions')}</a></li> |
|
64 | <li><a href="${h.url('admin_permissions')}"><i class="icon-block"></i> ${_('Default Permissions')}</a></li> | |
65 | <li><a href="${h.url('auth_home')}"><i class="icon-key"></i> ${_('Authentication')}</a></li> |
|
65 | <li><a href="${h.url('auth_home')}"><i class="icon-key"></i> ${_('Authentication')}</a></li> | |
66 | <li><a href="${h.url('defaults')}"><i class="icon-wrench"></i> ${_('Repository Defaults')}</a></li> |
|
66 | <li><a href="${h.url('defaults')}"><i class="icon-wrench"></i> ${_('Repository Defaults')}</a></li> | |
67 | <li class="last"><a href="${h.url('admin_settings')}"><i class="icon-gear"></i> ${_('Settings')}</a></li> |
|
67 | <li class="last"><a href="${h.url('admin_settings')}"><i class="icon-gear"></i> ${_('Settings')}</a></li> | |
68 | </ul> |
|
68 | </ul> | |
69 |
|
69 | |||
70 | </%def> |
|
70 | </%def> | |
71 |
|
71 | |||
72 |
|
72 | |||
73 | ## admin menu used for people that have some admin resources |
|
73 | ## admin menu used for people that have some admin resources | |
74 | <%def name="admin_menu_simple(repositories=None, repository_groups=None, user_groups=None)"> |
|
74 | <%def name="admin_menu_simple(repositories=None, repository_groups=None, user_groups=None)"> | |
75 | <ul class="dropdown-menu" role="menu"> |
|
75 | <ul class="dropdown-menu" role="menu"> | |
76 | %if repositories: |
|
76 | %if repositories: | |
77 | <li><a href="${h.url('repos')}"><i class="icon-database"></i> ${_('Repositories')}</a></li> |
|
77 | <li><a href="${h.url('repos')}"><i class="icon-database"></i> ${_('Repositories')}</a></li> | |
78 | %endif |
|
78 | %endif | |
79 | %if repository_groups: |
|
79 | %if repository_groups: | |
80 | <li><a href="${h.url('repos_groups')}"><i class="icon-folder"></i> ${_('Repository Groups')}</a></li> |
|
80 | <li><a href="${h.url('repos_groups')}"><i class="icon-folder"></i> ${_('Repository Groups')}</a></li> | |
81 | %endif |
|
81 | %endif | |
82 | %if user_groups: |
|
82 | %if user_groups: | |
83 | <li><a href="${h.url('users_groups')}"><i class="icon-users"></i> ${_('User Groups')}</a></li> |
|
83 | <li><a href="${h.url('users_groups')}"><i class="icon-users"></i> ${_('User Groups')}</a></li> | |
84 | %endif |
|
84 | %endif | |
85 | </ul> |
|
85 | </ul> | |
86 | </%def> |
|
86 | </%def> | |
87 |
|
87 | |||
88 | <%def name="repotag(repo)"> |
|
88 | <%def name="repotag(repo)"> | |
89 | %if h.is_hg(repo): |
|
89 | %if h.is_hg(repo): | |
90 | <span class="repotag" title="${_('Mercurial repository')}">hg</span> |
|
90 | <span class="repotag" title="${_('Mercurial repository')}">hg</span> | |
91 | %endif |
|
91 | %endif | |
92 | %if h.is_git(repo): |
|
92 | %if h.is_git(repo): | |
93 | <span class="repotag" title="${_('Git repository')}">git</span> |
|
93 | <span class="repotag" title="${_('Git repository')}">git</span> | |
94 | %endif |
|
94 | %endif | |
95 | </%def> |
|
95 | </%def> | |
96 |
|
96 | |||
97 | <%def name="repo_context_bar(current=None, rev=None)"> |
|
97 | <%def name="repo_context_bar(current=None, rev=None)"> | |
98 | <% rev = None if rev == 'tip' else rev %> |
|
98 | <% rev = None if rev == 'tip' else rev %> | |
99 | <% |
|
99 | <% | |
100 | def is_current(selected): |
|
100 | def is_current(selected): | |
101 | if selected == current: |
|
101 | if selected == current: | |
102 | return h.literal('class="current"') |
|
102 | return h.literal('class="current"') | |
103 | %> |
|
103 | %> | |
104 |
|
104 | |||
105 | <!--- CONTEXT BAR --> |
|
105 | <!--- CONTEXT BAR --> | |
106 | <div id="context-bar" class="box"> |
|
106 | <div id="context-bar" class="box"> | |
107 | <h2> |
|
107 | <h2> | |
108 | ${repotag(c.db_repo)} |
|
108 | ${repotag(c.db_repo)} | |
109 |
|
109 | |||
110 | ## public/private |
|
110 | ## public/private | |
111 | %if c.db_repo.private: |
|
111 | %if c.db_repo.private: | |
112 | <i class="icon-keyhole-circled"></i> |
|
112 | <i class="icon-keyhole-circled"></i> | |
113 | %else: |
|
113 | %else: | |
114 | <i class="icon-globe"></i> |
|
114 | <i class="icon-globe"></i> | |
115 | %endif |
|
115 | %endif | |
116 | ${h.repo_breadcrumbs(c.db_repo.groups_and_repo)} |
|
116 | ${h.repo_breadcrumbs(c.db_repo.groups_and_repo)} | |
117 |
|
117 | |||
118 | %if current == 'createfork': |
|
118 | %if current == 'createfork': | |
119 | - ${_('Create Fork')} |
|
119 | - ${_('Create Fork')} | |
120 | %endif |
|
120 | %endif | |
121 | </h2> |
|
121 | </h2> | |
122 | <!-- |
|
122 | <!-- | |
123 | <div id="breadcrumbs"> |
|
123 | <div id="breadcrumbs"> | |
124 | ${h.link_to(_('Repositories'),h.url('home'))} |
|
124 | ${h.link_to(_('Repositories'),h.url('home'))} | |
125 | » |
|
125 | » | |
126 | ${h.repo_breadcrumbs(c.db_repo.groups_and_repo)} |
|
126 | ${h.repo_breadcrumbs(c.db_repo.groups_and_repo)} | |
127 | </div> |
|
127 | </div> | |
128 | --> |
|
128 | --> | |
129 | <ul id="context-pages" class="horizontal-list"> |
|
129 | <ul id="context-pages" class="horizontal-list"> | |
130 | <li ${is_current('summary')} data-context="summary"><a href="${h.url('summary_home', repo_name=c.repo_name)}"><i class="icon-doc-text"></i> ${_('Summary')}</a></li> |
|
130 | <li ${is_current('summary')} data-context="summary"><a href="${h.url('summary_home', repo_name=c.repo_name)}"><i class="icon-doc-text"></i> ${_('Summary')}</a></li> | |
131 | %if rev: |
|
131 | %if rev: | |
132 | <li ${is_current('changelog')} data-context="changelog"><a href="${h.url('changelog_file_home', repo_name=c.repo_name, revision=rev, f_path='')}"><i class="icon-clock"></i> ${_('Changelog')}</a></li> |
|
132 | <li ${is_current('changelog')} data-context="changelog"><a href="${h.url('changelog_file_home', repo_name=c.repo_name, revision=rev, f_path='')}"><i class="icon-clock"></i> ${_('Changelog')}</a></li> | |
133 | %else: |
|
133 | %else: | |
134 | <li ${is_current('changelog')} data-context="changelog"><a href="${h.url('changelog_home', repo_name=c.repo_name)}"><i class="icon-clock"></i> ${_('Changelog')}</a></li> |
|
134 | <li ${is_current('changelog')} data-context="changelog"><a href="${h.url('changelog_home', repo_name=c.repo_name)}"><i class="icon-clock"></i> ${_('Changelog')}</a></li> | |
135 | %endif |
|
135 | %endif | |
136 | <li ${is_current('files')} data-context="files"><a href="${h.url('files_home', repo_name=c.repo_name, revision=rev or 'tip')}"><i class="icon-doc-inv"></i> ${_('Files')}</a></li> |
|
136 | <li ${is_current('files')} data-context="files"><a href="${h.url('files_home', repo_name=c.repo_name, revision=rev or 'tip')}"><i class="icon-doc-inv"></i> ${_('Files')}</a></li> | |
137 | <li ${is_current('switch-to')} data-context="switch-to"> |
|
137 | <li ${is_current('switch-to')} data-context="switch-to"> | |
138 | <input id="branch_switcher" name="branch_switcher" type="hidden"> |
|
138 | <input id="branch_switcher" name="branch_switcher" type="hidden"> | |
139 | </li> |
|
139 | </li> | |
140 | <li ${is_current('options')} data-context="options" class="dropdown"> |
|
140 | <li ${is_current('options')} data-context="options" class="dropdown"> | |
141 | %if h.HasRepoPermissionAny('repository.admin')(c.repo_name): |
|
141 | %if h.HasRepoPermissionAny('repository.admin')(c.repo_name): | |
142 | <a href="${h.url('edit_repo',repo_name=c.repo_name)}" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false" aria-haspopup="true"><i class="icon-wrench"></i> ${_('Options')} <i class="caret"></i></a> |
|
142 | <a href="${h.url('edit_repo',repo_name=c.repo_name)}" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false" aria-haspopup="true"><i class="icon-wrench"></i> ${_('Options')} <i class="caret"></i></a> | |
143 | %else: |
|
143 | %else: | |
144 | <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false" aria-haspopup="true"><i class="icon-wrench"></i> ${_('Options')} <i class="caret"></i></a> |
|
144 | <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false" aria-haspopup="true"><i class="icon-wrench"></i> ${_('Options')} <i class="caret"></i></a> | |
145 | %endif |
|
145 | %endif | |
146 | <ul class="dropdown-menu" role="menu" aria-hidden="yes"> |
|
146 | <ul class="dropdown-menu" role="menu" aria-hidden="yes"> | |
147 | %if h.HasRepoPermissionAny('repository.admin')(c.repo_name): |
|
147 | %if h.HasRepoPermissionAny('repository.admin')(c.repo_name): | |
148 | <li><a href="${h.url('edit_repo',repo_name=c.repo_name)}"><i class="icon-gear"></i> ${_('Settings')}</a></li> |
|
148 | <li><a href="${h.url('edit_repo',repo_name=c.repo_name)}"><i class="icon-gear"></i> ${_('Settings')}</a></li> | |
149 | %endif |
|
149 | %endif | |
150 | %if c.db_repo.fork: |
|
150 | %if c.db_repo.fork: | |
151 | <li><a href="${h.url('compare_url',repo_name=c.db_repo.fork.repo_name,org_ref_type=c.db_repo.landing_rev[0],org_ref_name=c.db_repo.landing_rev[1], other_repo=c.repo_name,other_ref_type='branch' if request.GET.get('branch') else c.db_repo.landing_rev[0],other_ref_name=request.GET.get('branch') or c.db_repo.landing_rev[1], merge=1)}"> |
|
151 | <li><a href="${h.url('compare_url',repo_name=c.db_repo.fork.repo_name,org_ref_type=c.db_repo.landing_rev[0],org_ref_name=c.db_repo.landing_rev[1], other_repo=c.repo_name,other_ref_type='branch' if request.GET.get('branch') else c.db_repo.landing_rev[0],other_ref_name=request.GET.get('branch') or c.db_repo.landing_rev[1], merge=1)}"> | |
152 | <i class="icon-git-compare"></i> ${_('Compare Fork')}</a></li> |
|
152 | <i class="icon-git-compare"></i> ${_('Compare Fork')}</a></li> | |
153 | %endif |
|
153 | %endif | |
154 | <li><a href="${h.url('compare_home',repo_name=c.repo_name)}"><i class="icon-git-compare"></i> ${_('Compare')}</a></li> |
|
154 | <li><a href="${h.url('compare_home',repo_name=c.repo_name)}"><i class="icon-git-compare"></i> ${_('Compare')}</a></li> | |
155 |
|
155 | |||
156 | <li><a href="${h.url('search_repo',repo_name=c.repo_name)}"><i class="icon-search"></i> ${_('Search')}</a></li> |
|
156 | <li><a href="${h.url('search_repo',repo_name=c.repo_name)}"><i class="icon-search"></i> ${_('Search')}</a></li> | |
157 |
|
157 | |||
158 | %if h.HasRepoPermissionAny('repository.write','repository.admin')(c.repo_name) and c.db_repo.enable_locking: |
|
158 | %if h.HasRepoPermissionAny('repository.write','repository.admin')(c.repo_name) and c.db_repo.enable_locking: | |
159 | %if c.db_repo.locked[0]: |
|
159 | %if c.db_repo.locked[0]: | |
160 | <li><a href="${h.url('toggle_locking', repo_name=c.repo_name)}"><i class="icon-lock"></i> ${_('Unlock')}</a></li> |
|
160 | <li><a href="${h.url('toggle_locking', repo_name=c.repo_name)}"><i class="icon-lock"></i> ${_('Unlock')}</a></li> | |
161 | %else: |
|
161 | %else: | |
162 | <li><a href="${h.url('toggle_locking', repo_name=c.repo_name)}"><i class="icon-lock-open-alt"></i> ${_('Lock')}</li> |
|
162 | <li><a href="${h.url('toggle_locking', repo_name=c.repo_name)}"><i class="icon-lock-open-alt"></i> ${_('Lock')}</li> | |
163 | %endif |
|
163 | %endif | |
164 | %endif |
|
164 | %endif | |
165 | ## TODO: this check feels wrong, it would be better to have a check for permissions |
|
165 | ## TODO: this check feels wrong, it would be better to have a check for permissions | |
166 | ## also it feels like a job for the controller |
|
166 | ## also it feels like a job for the controller | |
167 | %if c.authuser.username != 'default': |
|
167 | %if c.authuser.username != 'default': | |
168 | <li> |
|
168 | <li> | |
169 | <a class="${'following' if c.repository_following else 'follow'}" onclick="toggleFollowingRepo(this, ${c.db_repo.repo_id});"> |
|
169 | <a class="${'following' if c.repository_following else 'follow'}" onclick="toggleFollowingRepo(this, ${c.db_repo.repo_id});"> | |
170 | <span class="show-follow"><i class="icon-heart-empty"></i> ${_('Follow')}</span> |
|
170 | <span class="show-follow"><i class="icon-heart-empty"></i> ${_('Follow')}</span> | |
171 | <span class="show-following"><i class="icon-heart"></i> ${_('Unfollow')}</span> |
|
171 | <span class="show-following"><i class="icon-heart"></i> ${_('Unfollow')}</span> | |
172 | </a> |
|
172 | </a> | |
173 | </li> |
|
173 | </li> | |
174 | <li><a href="${h.url('repo_fork_home',repo_name=c.repo_name)}"><i class="icon-git-pull-request"></i> ${_('Fork')}</a></li> |
|
174 | <li><a href="${h.url('repo_fork_home',repo_name=c.repo_name)}"><i class="icon-git-pull-request"></i> ${_('Fork')}</a></li> | |
175 | <li><a href="${h.url('pullrequest_home',repo_name=c.repo_name)}"><i class="icon-git-pull-request"></i> ${_('Create Pull Request')}</a></li> |
|
175 | <li><a href="${h.url('pullrequest_home',repo_name=c.repo_name)}"><i class="icon-git-pull-request"></i> ${_('Create Pull Request')}</a></li> | |
176 | %endif |
|
176 | %endif | |
177 | </ul> |
|
177 | </ul> | |
178 | </li> |
|
178 | </li> | |
179 | <li ${is_current('showpullrequest')} data-context="showpullrequest"> |
|
179 | <li ${is_current('showpullrequest')} data-context="showpullrequest"> | |
180 | <a href="${h.url('pullrequest_show_all',repo_name=c.repo_name)}" title="${_('Show Pull Requests for %s') % c.repo_name}"> <i class="icon-git-pull-request"></i> ${_('Pull Requests')} |
|
180 | <a href="${h.url('pullrequest_show_all',repo_name=c.repo_name)}" title="${_('Show Pull Requests for %s') % c.repo_name}"> <i class="icon-git-pull-request"></i> ${_('Pull Requests')} | |
181 | %if c.repository_pull_requests: |
|
181 | %if c.repository_pull_requests: | |
182 | <span class="badge">${c.repository_pull_requests}</span> |
|
182 | <span class="badge">${c.repository_pull_requests}</span> | |
183 | %endif |
|
183 | %endif | |
184 | </a> |
|
184 | </a> | |
185 | </li> |
|
185 | </li> | |
186 | </ul> |
|
186 | </ul> | |
187 | </div> |
|
187 | </div> | |
188 | <script type="text/javascript"> |
|
188 | <script type="text/javascript"> | |
189 | $(document).ready(function() { |
|
189 | $(document).ready(function() { | |
190 | var bcache = {}; |
|
190 | var bcache = {}; | |
191 |
|
191 | |||
192 | $("#branch_switcher").select2({ |
|
192 | $("#branch_switcher").select2({ | |
193 | placeholder: '<i class="icon-exchange"></i> ${_('Switch To')} <span class="caret"></span>', |
|
193 | placeholder: '<i class="icon-exchange"></i> ${_('Switch To')} <span class="caret"></span>', | |
194 | dropdownAutoWidth: true, |
|
194 | dropdownAutoWidth: true, | |
195 | sortResults: prefixFirstSort, |
|
195 | sortResults: prefixFirstSort, | |
196 | formatResult: function(obj) { |
|
196 | formatResult: function(obj) { | |
197 | return obj.text; |
|
197 | return obj.text; | |
198 | }, |
|
198 | }, | |
199 | formatSelection: function(obj) { |
|
199 | formatSelection: function(obj) { | |
200 | return obj.text; |
|
200 | return obj.text; | |
201 | }, |
|
201 | }, | |
202 | formatNoMatches: function(term) { |
|
202 | formatNoMatches: function(term) { | |
203 | return "${_('No matches found')}"; |
|
203 | return "${_('No matches found')}"; | |
204 | }, |
|
204 | }, | |
205 | escapeMarkup: function(m) { |
|
205 | escapeMarkup: function(m) { | |
206 | // don't escape our custom placeholder |
|
206 | // don't escape our custom placeholder | |
207 | if (m.substr(0, 29) == '<i class="icon-exchange"></i>') { |
|
207 | if (m.substr(0, 29) == '<i class="icon-exchange"></i>') { | |
208 | return m; |
|
208 | return m; | |
209 | } |
|
209 | } | |
210 |
|
210 | |||
211 | return Select2.util.escapeMarkup(m); |
|
211 | return Select2.util.escapeMarkup(m); | |
212 | }, |
|
212 | }, | |
213 | containerCssClass: "repo-switcher", |
|
213 | containerCssClass: "repo-switcher", | |
214 | dropdownCssClass: "repo-switcher-dropdown", |
|
214 | dropdownCssClass: "repo-switcher-dropdown", | |
215 | query: function(query) { |
|
215 | query: function(query) { | |
216 | var key = 'cache'; |
|
216 | var key = 'cache'; | |
217 | var cached = bcache[key]; |
|
217 | var cached = bcache[key]; | |
218 | if (cached) { |
|
218 | if (cached) { | |
219 | var data = { |
|
219 | var data = { | |
220 | results: [] |
|
220 | results: [] | |
221 | }; |
|
221 | }; | |
222 | // filter results |
|
222 | // filter results | |
223 | $.each(cached.results, function() { |
|
223 | $.each(cached.results, function() { | |
224 | var section = this.text; |
|
224 | var section = this.text; | |
225 | var children = []; |
|
225 | var children = []; | |
226 | $.each(this.children, function() { |
|
226 | $.each(this.children, function() { | |
227 | if (query.term.length === 0 || this.text.toUpperCase().indexOf(query.term.toUpperCase()) >= 0) { |
|
227 | if (query.term.length === 0 || this.text.toUpperCase().indexOf(query.term.toUpperCase()) >= 0) { | |
228 | children.push({ |
|
228 | children.push({ | |
229 | 'id': this.id, |
|
229 | 'id': this.id, | |
230 | 'text': this.text, |
|
230 | 'text': this.text, | |
231 | 'type': this.type, |
|
231 | 'type': this.type, | |
232 | 'obj': this.obj |
|
232 | 'obj': this.obj | |
233 | }); |
|
233 | }); | |
234 | } |
|
234 | } | |
235 | }); |
|
235 | }); | |
236 | if (children.length !== 0) { |
|
236 | if (children.length !== 0) { | |
237 | data.results.push({ |
|
237 | data.results.push({ | |
238 | 'text': section, |
|
238 | 'text': section, | |
239 | 'children': children |
|
239 | 'children': children | |
240 | }); |
|
240 | }); | |
241 | } |
|
241 | } | |
242 |
|
242 | |||
243 | }); |
|
243 | }); | |
244 | query.callback(data); |
|
244 | query.callback(data); | |
245 | } else { |
|
245 | } else { | |
246 | $.ajax({ |
|
246 | $.ajax({ | |
247 | url: pyroutes.url('repo_refs_data', { |
|
247 | url: pyroutes.url('repo_refs_data', { | |
248 | 'repo_name': '${c.repo_name}' |
|
248 | 'repo_name': '${c.repo_name}' | |
249 | }), |
|
249 | }), | |
250 | data: {}, |
|
250 | data: {}, | |
251 | dataType: 'json', |
|
251 | dataType: 'json', | |
252 | type: 'GET', |
|
252 | type: 'GET', | |
253 | success: function(data) { |
|
253 | success: function(data) { | |
254 | bcache[key] = data; |
|
254 | bcache[key] = data; | |
255 | query.callback(data); |
|
255 | query.callback(data); | |
256 | } |
|
256 | } | |
257 | }); |
|
257 | }); | |
258 | } |
|
258 | } | |
259 | } |
|
259 | } | |
260 | }); |
|
260 | }); | |
261 |
|
261 | |||
262 | $("#branch_switcher").on('select2-selecting', function(e) { |
|
262 | $("#branch_switcher").on('select2-selecting', function(e) { | |
263 | e.preventDefault(); |
|
263 | e.preventDefault(); | |
264 | var context = $('#context-bar .current').data('context'); |
|
264 | var context = $('#context-bar .current').data('context'); | |
265 | if (context == 'files') { |
|
265 | if (context == 'files') { | |
266 | window.location = pyroutes.url('files_home', { |
|
266 | window.location = pyroutes.url('files_home', { | |
267 | 'repo_name': REPO_NAME, |
|
267 | 'repo_name': REPO_NAME, | |
268 | 'revision': e.choice.id, |
|
268 | 'revision': e.choice.id, | |
269 | 'f_path': '', |
|
269 | 'f_path': '', | |
270 | 'at': e.choice.text |
|
270 | 'at': e.choice.text | |
271 | }); |
|
271 | }); | |
272 | } else if (context == 'changelog') { |
|
272 | } else if (context == 'changelog') { | |
273 | if (e.choice.type == 'tag' || e.choice.type == 'book') { |
|
273 | if (e.choice.type == 'tag' || e.choice.type == 'book') { | |
274 | $("#branch_filter").append($('<'+'option/>').val(e.choice.text)); |
|
274 | $("#branch_filter").append($('<'+'option/>').val(e.choice.text)); | |
275 | } |
|
275 | } | |
276 | $("#branch_filter").val(e.choice.text).change(); |
|
276 | $("#branch_filter").val(e.choice.text).change(); | |
277 | } else { |
|
277 | } else { | |
278 | window.location = pyroutes.url('changelog_home', { |
|
278 | window.location = pyroutes.url('changelog_home', { | |
279 | 'repo_name': '${c.repo_name}', |
|
279 | 'repo_name': '${c.repo_name}', | |
280 | 'branch': e.choice.text |
|
280 | 'branch': e.choice.text | |
281 | }); |
|
281 | }); | |
282 | } |
|
282 | } | |
283 | }); |
|
283 | }); | |
284 | }); |
|
284 | }); | |
285 | </script> |
|
285 | </script> | |
286 | <!--- END CONTEXT BAR --> |
|
286 | <!--- END CONTEXT BAR --> | |
287 | </%def> |
|
287 | </%def> | |
288 |
|
288 | |||
289 | <%def name="menu(current=None)"> |
|
289 | <%def name="menu(current=None)"> | |
290 | <% |
|
290 | <% | |
291 | def is_current(selected): |
|
291 | def is_current(selected): | |
292 | if selected == current: |
|
292 | if selected == current: | |
293 | return h.literal('class="current"') |
|
293 | return h.literal('class="current"') | |
294 | %> |
|
294 | %> | |
295 |
|
295 | |||
296 | <ul id="quick" class="horizontal-list"> |
|
296 | <ul id="quick" class="horizontal-list"> | |
297 | <!-- repo switcher --> |
|
297 | <!-- repo switcher --> | |
298 | <li ${is_current('repositories')}> |
|
298 | <li ${is_current('repositories')}> | |
299 | <input id="repo_switcher" name="repo_switcher" type="hidden"> |
|
299 | <input id="repo_switcher" name="repo_switcher" type="hidden"> | |
300 | </li> |
|
300 | </li> | |
301 |
|
301 | |||
302 | ##ROOT MENU |
|
302 | ##ROOT MENU | |
303 | %if c.authuser.username != 'default': |
|
303 | %if c.authuser.username != 'default': | |
304 | <li ${is_current('journal')}> |
|
304 | <li ${is_current('journal')}> | |
305 | <a class="menu_link" title="${_('Show recent activity')}" href="${h.url('journal')}"> |
|
305 | <a class="menu_link" title="${_('Show recent activity')}" href="${h.url('journal')}"> | |
306 | <i class="icon-book"></i> ${_('Journal')} |
|
306 | <i class="icon-book"></i> ${_('Journal')} | |
307 | </a> |
|
307 | </a> | |
308 | </li> |
|
308 | </li> | |
309 | %else: |
|
309 | %else: | |
310 | <li ${is_current('journal')}> |
|
310 | <li ${is_current('journal')}> | |
311 | <a class="menu_link" title="${_('Public journal')}" href="${h.url('public_journal')}"> |
|
311 | <a class="menu_link" title="${_('Public journal')}" href="${h.url('public_journal')}"> | |
312 | <i class="icon-book"></i> ${_('Public journal')} |
|
312 | <i class="icon-book"></i> ${_('Public journal')} | |
313 | </a> |
|
313 | </a> | |
314 | </li> |
|
314 | </li> | |
315 | %endif |
|
315 | %endif | |
316 | <li ${is_current('gists')} class="dropdown"> |
|
316 | <li ${is_current('gists')} class="dropdown"> | |
317 | <a class="menu_link dropdown-toggle" data-toggle="dropdown" role="button" title="${_('Show public gists')}" href="${h.url('gists')}"> |
|
317 | <a class="menu_link dropdown-toggle" data-toggle="dropdown" role="button" title="${_('Show public gists')}" href="${h.url('gists')}"> | |
318 | <i class="icon-clippy"></i> ${_('Gists')} <span class="caret"></span> |
|
318 | <i class="icon-clippy"></i> ${_('Gists')} <span class="caret"></span> | |
319 | </a> |
|
319 | </a> | |
320 | <ul class="dropdown-menu" role="menu"> |
|
320 | <ul class="dropdown-menu" role="menu"> | |
321 | <li><a href="${h.url('new_gist', public=1)}"><i class="icon-paste"></i> ${_('Create New Gist')}</a></li> |
|
321 | <li><a href="${h.url('new_gist', public=1)}"><i class="icon-paste"></i> ${_('Create New Gist')}</a></li> | |
322 | <li><a href="${h.url('gists')}"><i class="icon-globe"></i> ${_('All Public Gists')}</a></li> |
|
322 | <li><a href="${h.url('gists')}"><i class="icon-globe"></i> ${_('All Public Gists')}</a></li> | |
323 | %if c.authuser.username != 'default': |
|
323 | %if c.authuser.username != 'default': | |
324 | <li><a href="${h.url('gists', public=1)}"><i class="icon-user"></i> ${_('My Public Gists')}</a></li> |
|
324 | <li><a href="${h.url('gists', public=1)}"><i class="icon-user"></i> ${_('My Public Gists')}</a></li> | |
325 | <li><a href="${h.url('gists', private=1)}"><i class="icon-keyhole-circled"></i> ${_('My Private Gists')}</a></li> |
|
325 | <li><a href="${h.url('gists', private=1)}"><i class="icon-keyhole-circled"></i> ${_('My Private Gists')}</a></li> | |
326 | %endif |
|
326 | %endif | |
327 | </ul> |
|
327 | </ul> | |
328 | </li> |
|
328 | </li> | |
329 | <li ${is_current('search')}> |
|
329 | <li ${is_current('search')}> | |
330 | <a class="menu_link" title="${_('Search in repositories')}" href="${h.url('search')}"> |
|
330 | <a class="menu_link" title="${_('Search in repositories')}" href="${h.url('search')}"> | |
331 | <i class="icon-search"></i> ${_('Search')} |
|
331 | <i class="icon-search"></i> ${_('Search')} | |
332 | </a> |
|
332 | </a> | |
333 | </li> |
|
333 | </li> | |
334 | % if h.HasPermissionAny('hg.admin')('access admin main page'): |
|
334 | % if h.HasPermissionAny('hg.admin')('access admin main page'): | |
335 | <li ${is_current('admin')} class="dropdown"> |
|
335 | <li ${is_current('admin')} class="dropdown"> | |
336 | <a class="menu_link dropdown-toggle" data-toggle="dropdown" role="button" title="${_('Admin')}" href="${h.url('admin_home')}"> |
|
336 | <a class="menu_link dropdown-toggle" data-toggle="dropdown" role="button" title="${_('Admin')}" href="${h.url('admin_home')}"> | |
337 | <i class="icon-gear"></i> ${_('Admin')} <span class="caret"></span> |
|
337 | <i class="icon-gear"></i> ${_('Admin')} <span class="caret"></span> | |
338 | </a> |
|
338 | </a> | |
339 | ${admin_menu()} |
|
339 | ${admin_menu()} | |
340 | </li> |
|
340 | </li> | |
341 | % elif c.authuser.repositories_admin or c.authuser.repository_groups_admin or c.authuser.user_groups_admin: |
|
341 | % elif c.authuser.repositories_admin or c.authuser.repository_groups_admin or c.authuser.user_groups_admin: | |
342 | <li ${is_current('admin')} class="dropdown"> |
|
342 | <li ${is_current('admin')} class="dropdown"> | |
343 | <a class="menu_link dropdown-toggle" data-toggle="dropdown" role="button" title="${_('Admin')}"> |
|
343 | <a class="menu_link dropdown-toggle" data-toggle="dropdown" role="button" title="${_('Admin')}"> | |
344 | <i class="icon-gear"></i> ${_('Admin')} |
|
344 | <i class="icon-gear"></i> ${_('Admin')} | |
345 | </a> |
|
345 | </a> | |
346 | ${admin_menu_simple(c.authuser.repositories_admin, |
|
346 | ${admin_menu_simple(c.authuser.repositories_admin, | |
347 | c.authuser.repository_groups_admin, |
|
347 | c.authuser.repository_groups_admin, | |
348 | c.authuser.user_groups_admin or h.HasPermissionAny('hg.usergroup.create.true')())} |
|
348 | c.authuser.user_groups_admin or h.HasPermissionAny('hg.usergroup.create.true')())} | |
349 | </li> |
|
349 | </li> | |
350 | % endif |
|
350 | % endif | |
351 |
|
351 | |||
352 | <li ${is_current('my_pullrequests')}> |
|
352 | <li ${is_current('my_pullrequests')}> | |
353 | <a class="menu_link" title="${_('My Pull Requests')}" href="${h.url('my_pullrequests')}"> |
|
353 | <a class="menu_link" title="${_('My Pull Requests')}" href="${h.url('my_pullrequests')}"> | |
354 | <i class="icon-git-pull-request"></i> ${_('My Pull Requests')} |
|
354 | <i class="icon-git-pull-request"></i> ${_('My Pull Requests')} | |
355 | %if c.my_pr_count != 0: |
|
355 | %if c.my_pr_count != 0: | |
356 | <span class="badge">${c.my_pr_count}</span> |
|
356 | <span class="badge">${c.my_pr_count}</span> | |
357 | %endif |
|
357 | %endif | |
358 | </a> |
|
358 | </a> | |
359 | </li> |
|
359 | </li> | |
360 |
|
360 | |||
361 | ## USER MENU |
|
361 | ## USER MENU | |
362 | <li class="dropdown"> |
|
362 | <li class="dropdown"> | |
363 | <a class="menu_link dropdown-toggle" data-toggle="dropdown" role="button" id="quick_login_link" |
|
363 | <a class="menu_link dropdown-toggle" data-toggle="dropdown" role="button" id="quick_login_link" | |
364 | aria-expanded="false" aria-controls="quick_login" |
|
364 | aria-expanded="false" aria-controls="quick_login" | |
365 | %if c.authuser.username != 'default': |
|
365 | %if c.authuser.username != 'default': | |
366 | href="${h.url('notifications')}" |
|
366 | href="${h.url('notifications')}" | |
|
367 | %else: | |||
|
368 | href="#" | |||
367 | %endif |
|
369 | %endif | |
368 | > |
|
370 | > | |
369 | ${h.gravatar_div(c.authuser.email, size=20, div_class="icon", div_style="display:inline", div_aria_hidden="true")} |
|
371 | ${h.gravatar_div(c.authuser.email, size=20, div_class="icon", div_style="display:inline", div_aria_hidden="true")} | |
370 | %if c.authuser.username != 'default': |
|
372 | %if c.authuser.username != 'default': | |
371 | <span class="menu_link_user">${c.authuser.username}</span> |
|
373 | <span class="menu_link_user">${c.authuser.username}</span> | |
372 | %if c.unread_notifications != 0: |
|
374 | %if c.unread_notifications != 0: | |
373 | <span class="badge">${c.unread_notifications}</span> |
|
375 | <span class="badge">${c.unread_notifications}</span> | |
374 | %endif |
|
376 | %endif | |
375 | %else: |
|
377 | %else: | |
376 | <span>${_('Not Logged In')}</span> |
|
378 | <span>${_('Not Logged In')}</span> | |
377 | %endif |
|
379 | %endif | |
378 | </a> |
|
380 | </a> | |
379 |
|
381 | |||
380 | <div class="user-menu" role="menu"> |
|
382 | <div class="user-menu" role="menu"> | |
381 | <div id="quick_login" role="form" aria-describedby="quick_login_h" aria-hidden="true" class="dropdown-menu"> |
|
383 | <div id="quick_login" role="form" aria-describedby="quick_login_h" aria-hidden="true" class="dropdown-menu"> | |
382 | %if c.authuser.username == 'default' or c.authuser.user_id is None: |
|
384 | %if c.authuser.username == 'default' or c.authuser.user_id is None: | |
383 | <h4 id="quick_login_h">${_('Login to Your Account')}</h4> |
|
385 | <h4 id="quick_login_h">${_('Login to Your Account')}</h4> | |
384 | ${h.form(h.url('login_home', came_from=request.path_qs))} |
|
386 | ${h.form(h.url('login_home', came_from=request.path_qs))} | |
385 | <div class="form"> |
|
387 | <div class="form"> | |
386 | <div class="fields"> |
|
388 | <div class="fields"> | |
387 | <div class="field"> |
|
389 | <div class="field"> | |
388 | <div class="label"> |
|
390 | <div class="label"> | |
389 | <label for="username">${_('Username')}:</label> |
|
391 | <label for="username">${_('Username')}:</label> | |
390 | </div> |
|
392 | </div> | |
391 | <div class="input"> |
|
393 | <div class="input"> | |
392 | ${h.text('username',class_='focus')} |
|
394 | ${h.text('username',class_='focus')} | |
393 | </div> |
|
395 | </div> | |
394 |
|
396 | |||
395 | </div> |
|
397 | </div> | |
396 | <div class="field"> |
|
398 | <div class="field"> | |
397 | <div class="label"> |
|
399 | <div class="label"> | |
398 | <label for="password">${_('Password')}:</label> |
|
400 | <label for="password">${_('Password')}:</label> | |
399 | </div> |
|
401 | </div> | |
400 | <div class="input"> |
|
402 | <div class="input"> | |
401 | ${h.password('password',class_='focus')} |
|
403 | ${h.password('password',class_='focus')} | |
402 | </div> |
|
404 | </div> | |
403 |
|
405 | |||
404 | </div> |
|
406 | </div> | |
405 | <div class="buttons"> |
|
407 | <div class="buttons"> | |
406 | <div class="password_forgoten">${h.link_to(_('Forgot password ?'),h.url('reset_password'))}</div> |
|
408 | <div class="password_forgoten">${h.link_to(_('Forgot password ?'),h.url('reset_password'))}</div> | |
407 | <div class="register"> |
|
409 | <div class="register"> | |
408 | %if h.HasPermissionAny('hg.admin', 'hg.register.auto_activate', 'hg.register.manual_activate')(): |
|
410 | %if h.HasPermissionAny('hg.admin', 'hg.register.auto_activate', 'hg.register.manual_activate')(): | |
409 | ${h.link_to(_("Don't have an account ?"),h.url('register'))} |
|
411 | ${h.link_to(_("Don't have an account ?"),h.url('register'))} | |
410 | %endif |
|
412 | %endif | |
411 | </div> |
|
413 | </div> | |
412 | <div class="submit"> |
|
414 | <div class="submit"> | |
413 | ${h.submit('sign_in',_('Log In'),class_="btn btn-mini")} |
|
415 | ${h.submit('sign_in',_('Log In'),class_="btn btn-mini")} | |
414 | </div> |
|
416 | </div> | |
415 | </div> |
|
417 | </div> | |
416 | </div> |
|
418 | </div> | |
417 | </div> |
|
419 | </div> | |
418 | ${h.end_form()} |
|
420 | ${h.end_form()} | |
419 | %else: |
|
421 | %else: | |
420 | <div class="links_left"> |
|
422 | <div class="links_left"> | |
421 | ${h.gravatar_div(c.authuser.email, size=48, div_class="big_gravatar")} |
|
423 | ${h.gravatar_div(c.authuser.email, size=48, div_class="big_gravatar")} | |
422 | <div class="full_name">${c.authuser.full_name_or_username}</div> |
|
424 | <div class="full_name">${c.authuser.full_name_or_username}</div> | |
423 | <div class="email">${c.authuser.email}</div> |
|
425 | <div class="email">${c.authuser.email}</div> | |
424 | </div> |
|
426 | </div> | |
425 | <div class="links_right"> |
|
427 | <div class="links_right"> | |
426 | <ol class="links"> |
|
428 | <ol class="links"> | |
427 | <li><a href="${h.url('notifications')}">${_('Notifications')}: ${c.unread_notifications}</a></li> |
|
429 | <li><a href="${h.url('notifications')}">${_('Notifications')}: ${c.unread_notifications}</a></li> | |
428 | <li>${h.link_to(_('My Account'),h.url('my_account'))}</li> |
|
430 | <li>${h.link_to(_('My Account'),h.url('my_account'))}</li> | |
429 | %if not c.authuser.is_external_auth: |
|
431 | %if not c.authuser.is_external_auth: | |
430 | ## Cannot log out if using external (container) authentication. |
|
432 | ## Cannot log out if using external (container) authentication. | |
431 | <li class="logout">${h.link_to(_('Log Out'), h.url('logout_home'))}</li> |
|
433 | <li class="logout">${h.link_to(_('Log Out'), h.url('logout_home'))}</li> | |
432 | %endif |
|
434 | %endif | |
433 | </ol> |
|
435 | </ol> | |
434 | </div> |
|
436 | </div> | |
435 | %endif |
|
437 | %endif | |
436 | </div> |
|
438 | </div> | |
437 | </div> |
|
439 | </div> | |
438 | </li> |
|
440 | </li> | |
439 |
|
441 | |||
440 | <script type="text/javascript"> |
|
442 | <script type="text/javascript"> | |
441 | $(document).ready(function(){ |
|
443 | $(document).ready(function(){ | |
442 | var visual_show_public_icon = "${c.visual.show_public_icon}" == "True"; |
|
444 | var visual_show_public_icon = "${c.visual.show_public_icon}" == "True"; | |
443 | var cache = {} |
|
445 | var cache = {} | |
444 | /*format the look of items in the list*/ |
|
446 | /*format the look of items in the list*/ | |
445 | var format = function(state){ |
|
447 | var format = function(state){ | |
446 | if (!state.id){ |
|
448 | if (!state.id){ | |
447 | return state.text; // optgroup |
|
449 | return state.text; // optgroup | |
448 | } |
|
450 | } | |
449 | var obj_dict = state.obj; |
|
451 | var obj_dict = state.obj; | |
450 | var tmpl = ''; |
|
452 | var tmpl = ''; | |
451 |
|
453 | |||
452 | if(obj_dict && state.type == 'repo'){ |
|
454 | if(obj_dict && state.type == 'repo'){ | |
453 | tmpl += '<span class="repo-icons">'; |
|
455 | tmpl += '<span class="repo-icons">'; | |
454 | if(obj_dict['repo_type'] === 'hg'){ |
|
456 | if(obj_dict['repo_type'] === 'hg'){ | |
455 | tmpl += '<span class="repotag">hg</span> '; |
|
457 | tmpl += '<span class="repotag">hg</span> '; | |
456 | } |
|
458 | } | |
457 | else if(obj_dict['repo_type'] === 'git'){ |
|
459 | else if(obj_dict['repo_type'] === 'git'){ | |
458 | tmpl += '<span class="repotag">git</span> '; |
|
460 | tmpl += '<span class="repotag">git</span> '; | |
459 | } |
|
461 | } | |
460 | if(obj_dict['private']){ |
|
462 | if(obj_dict['private']){ | |
461 | tmpl += '<i class="icon-keyhole-circled"></i> '; |
|
463 | tmpl += '<i class="icon-keyhole-circled"></i> '; | |
462 | } |
|
464 | } | |
463 | else if(visual_show_public_icon){ |
|
465 | else if(visual_show_public_icon){ | |
464 | tmpl += '<i class="icon-globe"></i> '; |
|
466 | tmpl += '<i class="icon-globe"></i> '; | |
465 | } |
|
467 | } | |
466 | tmpl += '</span>'; |
|
468 | tmpl += '</span>'; | |
467 | } |
|
469 | } | |
468 | if(obj_dict && state.type == 'group'){ |
|
470 | if(obj_dict && state.type == 'group'){ | |
469 | tmpl += '<i class="icon-folder"></i> '; |
|
471 | tmpl += '<i class="icon-folder"></i> '; | |
470 | } |
|
472 | } | |
471 | tmpl += state.text; |
|
473 | tmpl += state.text; | |
472 | return tmpl; |
|
474 | return tmpl; | |
473 | } |
|
475 | } | |
474 |
|
476 | |||
475 | $("#repo_switcher").select2({ |
|
477 | $("#repo_switcher").select2({ | |
476 | placeholder: '<i class="icon-database"></i> ${_('Repositories')} <span class="caret"></span>', |
|
478 | placeholder: '<i class="icon-database"></i> ${_('Repositories')} <span class="caret"></span>', | |
477 | dropdownAutoWidth: true, |
|
479 | dropdownAutoWidth: true, | |
478 | sortResults: prefixFirstSort, |
|
480 | sortResults: prefixFirstSort, | |
479 | formatResult: format, |
|
481 | formatResult: format, | |
480 | formatSelection: format, |
|
482 | formatSelection: format, | |
481 | formatNoMatches: function(term){ |
|
483 | formatNoMatches: function(term){ | |
482 | return "${_('No matches found')}"; |
|
484 | return "${_('No matches found')}"; | |
483 | }, |
|
485 | }, | |
484 | containerCssClass: "repo-switcher", |
|
486 | containerCssClass: "repo-switcher", | |
485 | dropdownCssClass: "repo-switcher-dropdown", |
|
487 | dropdownCssClass: "repo-switcher-dropdown", | |
486 | escapeMarkup: function(m){ |
|
488 | escapeMarkup: function(m){ | |
487 | // don't escape our custom placeholder |
|
489 | // don't escape our custom placeholder | |
488 | if(m.substr(0,29) == '<i class="icon-database"></i>'){ |
|
490 | if(m.substr(0,29) == '<i class="icon-database"></i>'){ | |
489 | return m; |
|
491 | return m; | |
490 | } |
|
492 | } | |
491 |
|
493 | |||
492 | return Select2.util.escapeMarkup(m); |
|
494 | return Select2.util.escapeMarkup(m); | |
493 | }, |
|
495 | }, | |
494 | query: function(query){ |
|
496 | query: function(query){ | |
495 | var key = 'cache'; |
|
497 | var key = 'cache'; | |
496 | var cached = cache[key] ; |
|
498 | var cached = cache[key] ; | |
497 | if(cached) { |
|
499 | if(cached) { | |
498 | var data = {results: []}; |
|
500 | var data = {results: []}; | |
499 | //filter results |
|
501 | //filter results | |
500 | $.each(cached.results, function(){ |
|
502 | $.each(cached.results, function(){ | |
501 | var section = this.text; |
|
503 | var section = this.text; | |
502 | var children = []; |
|
504 | var children = []; | |
503 | $.each(this.children, function(){ |
|
505 | $.each(this.children, function(){ | |
504 | if(query.term.length == 0 || this.text.toUpperCase().indexOf(query.term.toUpperCase()) >= 0 ){ |
|
506 | if(query.term.length == 0 || this.text.toUpperCase().indexOf(query.term.toUpperCase()) >= 0 ){ | |
505 | children.push({'id': this.id, 'text': this.text, 'type': this.type, 'obj': this.obj}); |
|
507 | children.push({'id': this.id, 'text': this.text, 'type': this.type, 'obj': this.obj}); | |
506 | } |
|
508 | } | |
507 | }); |
|
509 | }); | |
508 | if(children.length !== 0){ |
|
510 | if(children.length !== 0){ | |
509 | data.results.push({'text': section, 'children': children}); |
|
511 | data.results.push({'text': section, 'children': children}); | |
510 | } |
|
512 | } | |
511 |
|
513 | |||
512 | }); |
|
514 | }); | |
513 | query.callback(data); |
|
515 | query.callback(data); | |
514 | }else{ |
|
516 | }else{ | |
515 | $.ajax({ |
|
517 | $.ajax({ | |
516 | url: "${h.url('repo_switcher_data')}", |
|
518 | url: "${h.url('repo_switcher_data')}", | |
517 | data: {}, |
|
519 | data: {}, | |
518 | dataType: 'json', |
|
520 | dataType: 'json', | |
519 | type: 'GET', |
|
521 | type: 'GET', | |
520 | success: function(data) { |
|
522 | success: function(data) { | |
521 | cache[key] = data; |
|
523 | cache[key] = data; | |
522 | query.callback({results: data.results}); |
|
524 | query.callback({results: data.results}); | |
523 | } |
|
525 | } | |
524 | }); |
|
526 | }); | |
525 | } |
|
527 | } | |
526 | } |
|
528 | } | |
527 | }); |
|
529 | }); | |
528 |
|
530 | |||
529 | $("#repo_switcher").on('select2-selecting', function(e){ |
|
531 | $("#repo_switcher").on('select2-selecting', function(e){ | |
530 | e.preventDefault(); |
|
532 | e.preventDefault(); | |
531 | window.location = pyroutes.url('summary_home', {'repo_name': e.val}); |
|
533 | window.location = pyroutes.url('summary_home', {'repo_name': e.val}); | |
532 | }); |
|
534 | }); | |
533 |
|
535 | |||
534 | $(document).on('shown.bs.dropdown', function(event) { |
|
536 | $(document).on('shown.bs.dropdown', function(event) { | |
535 | var dropdown = $(event.target); |
|
537 | var dropdown = $(event.target); | |
536 |
|
538 | |||
537 | dropdown.attr('aria-expanded', true); |
|
539 | dropdown.attr('aria-expanded', true); | |
538 | dropdown.find('.dropdown-menu').attr('aria-hidden', false); |
|
540 | dropdown.find('.dropdown-menu').attr('aria-hidden', false); | |
539 | }); |
|
541 | }); | |
540 |
|
542 | |||
541 | $(document).on('hidden.bs.dropdown', function(event) { |
|
543 | $(document).on('hidden.bs.dropdown', function(event) { | |
542 | var dropdown = $(event.target); |
|
544 | var dropdown = $(event.target); | |
543 |
|
545 | |||
544 | dropdown.attr('aria-expanded', false); |
|
546 | dropdown.attr('aria-expanded', false); | |
545 | dropdown.find('.dropdown-menu').attr('aria-hidden', true); |
|
547 | dropdown.find('.dropdown-menu').attr('aria-hidden', true); | |
546 | }); |
|
548 | }); | |
547 | }); |
|
549 | }); | |
548 | </script> |
|
550 | </script> | |
549 | </%def> |
|
551 | </%def> |
General Comments 0
You need to be logged in to leave comments.
Login now