Show More
@@ -1,534 +1,549 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-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-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"> |
|
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 | %if c.authuser.username != 'default': |
|
365 | %if c.authuser.username != 'default': | |
365 | href="${h.url('notifications')}" |
|
366 | href="${h.url('notifications')}" | |
366 | %endif |
|
367 | %endif | |
367 | > |
|
368 | > | |
368 | ${h.gravatar_div(c.authuser.email, size=20, div_class="icon", div_style="display:inline")} |
|
369 | ${h.gravatar_div(c.authuser.email, size=20, div_class="icon", div_style="display:inline", div_aria_hidden="true")} | |
369 | %if c.authuser.username != 'default': |
|
370 | %if c.authuser.username != 'default': | |
370 | <span class="menu_link_user">${c.authuser.username}</span> |
|
371 | <span class="menu_link_user">${c.authuser.username}</span> | |
371 | %if c.unread_notifications != 0: |
|
372 | %if c.unread_notifications != 0: | |
372 | <span class="badge">${c.unread_notifications}</span> |
|
373 | <span class="badge">${c.unread_notifications}</span> | |
373 | %endif |
|
374 | %endif | |
374 | %else: |
|
375 | %else: | |
375 | <span>${_('Not Logged In')}</span> |
|
376 | <span>${_('Not Logged In')}</span> | |
376 | %endif |
|
377 | %endif | |
377 | </a> |
|
378 | </a> | |
378 |
|
379 | |||
379 | <div class="user-menu"> |
|
380 | <div class="user-menu" role="menu"> | |
380 | <div id="quick_login" class="dropdown-menu"> |
|
381 | <div id="quick_login" role="form" aria-describedby="quick_login_h" aria-hidden="true" class="dropdown-menu"> | |
381 | %if c.authuser.username == 'default' or c.authuser.user_id is None: |
|
382 | %if c.authuser.username == 'default' or c.authuser.user_id is None: | |
382 | <h4>${_('Login to Your Account')}</h4> |
|
383 | <h4 id="quick_login_h">${_('Login to Your Account')}</h4> | |
383 | ${h.form(h.url('login_home', came_from=request.path_qs))} |
|
384 | ${h.form(h.url('login_home', came_from=request.path_qs))} | |
384 | <div class="form"> |
|
385 | <div class="form"> | |
385 | <div class="fields"> |
|
386 | <div class="fields"> | |
386 | <div class="field"> |
|
387 | <div class="field"> | |
387 | <div class="label"> |
|
388 | <div class="label"> | |
388 | <label for="username">${_('Username')}:</label> |
|
389 | <label for="username">${_('Username')}:</label> | |
389 | </div> |
|
390 | </div> | |
390 | <div class="input"> |
|
391 | <div class="input"> | |
391 | ${h.text('username',class_='focus')} |
|
392 | ${h.text('username',class_='focus')} | |
392 | </div> |
|
393 | </div> | |
393 |
|
394 | |||
394 | </div> |
|
395 | </div> | |
395 | <div class="field"> |
|
396 | <div class="field"> | |
396 | <div class="label"> |
|
397 | <div class="label"> | |
397 | <label for="password">${_('Password')}:</label> |
|
398 | <label for="password">${_('Password')}:</label> | |
398 | </div> |
|
399 | </div> | |
399 | <div class="input"> |
|
400 | <div class="input"> | |
400 | ${h.password('password',class_='focus')} |
|
401 | ${h.password('password',class_='focus')} | |
401 | </div> |
|
402 | </div> | |
402 |
|
403 | |||
403 | </div> |
|
404 | </div> | |
404 | <div class="buttons"> |
|
405 | <div class="buttons"> | |
405 | <div class="password_forgoten">${h.link_to(_('Forgot password ?'),h.url('reset_password'))}</div> |
|
406 | <div class="password_forgoten">${h.link_to(_('Forgot password ?'),h.url('reset_password'))}</div> | |
406 | <div class="register"> |
|
407 | <div class="register"> | |
407 | %if h.HasPermissionAny('hg.admin', 'hg.register.auto_activate', 'hg.register.manual_activate')(): |
|
408 | %if h.HasPermissionAny('hg.admin', 'hg.register.auto_activate', 'hg.register.manual_activate')(): | |
408 | ${h.link_to(_("Don't have an account ?"),h.url('register'))} |
|
409 | ${h.link_to(_("Don't have an account ?"),h.url('register'))} | |
409 | %endif |
|
410 | %endif | |
410 | </div> |
|
411 | </div> | |
411 | <div class="submit"> |
|
412 | <div class="submit"> | |
412 | ${h.submit('sign_in',_('Log In'),class_="btn btn-mini")} |
|
413 | ${h.submit('sign_in',_('Log In'),class_="btn btn-mini")} | |
413 | </div> |
|
414 | </div> | |
414 | </div> |
|
415 | </div> | |
415 | </div> |
|
416 | </div> | |
416 | </div> |
|
417 | </div> | |
417 | ${h.end_form()} |
|
418 | ${h.end_form()} | |
418 | %else: |
|
419 | %else: | |
419 | <div class="links_left"> |
|
420 | <div class="links_left"> | |
420 | ${h.gravatar_div(c.authuser.email, size=48, div_class="big_gravatar")} |
|
421 | ${h.gravatar_div(c.authuser.email, size=48, div_class="big_gravatar")} | |
421 | <div class="full_name">${c.authuser.full_name_or_username}</div> |
|
422 | <div class="full_name">${c.authuser.full_name_or_username}</div> | |
422 | <div class="email">${c.authuser.email}</div> |
|
423 | <div class="email">${c.authuser.email}</div> | |
423 | </div> |
|
424 | </div> | |
424 | <div class="links_right"> |
|
425 | <div class="links_right"> | |
425 | <ol class="links"> |
|
426 | <ol class="links"> | |
426 | <li><a href="${h.url('notifications')}">${_('Notifications')}: ${c.unread_notifications}</a></li> |
|
427 | <li><a href="${h.url('notifications')}">${_('Notifications')}: ${c.unread_notifications}</a></li> | |
427 | <li>${h.link_to(_('My Account'),h.url('my_account'))}</li> |
|
428 | <li>${h.link_to(_('My Account'),h.url('my_account'))}</li> | |
428 | %if not c.authuser.is_external_auth: |
|
429 | %if not c.authuser.is_external_auth: | |
429 | ## Cannot log out if using external (container) authentication. |
|
430 | ## Cannot log out if using external (container) authentication. | |
430 | <li class="logout">${h.link_to(_('Log Out'), h.url('logout_home'))}</li> |
|
431 | <li class="logout">${h.link_to(_('Log Out'), h.url('logout_home'))}</li> | |
431 | %endif |
|
432 | %endif | |
432 | </ol> |
|
433 | </ol> | |
433 | </div> |
|
434 | </div> | |
434 | %endif |
|
435 | %endif | |
435 | </div> |
|
436 | </div> | |
436 | </div> |
|
437 | </div> | |
437 | </li> |
|
438 | </li> | |
438 |
|
439 | |||
439 | <script type="text/javascript"> |
|
440 | <script type="text/javascript"> | |
440 | $(document).ready(function(){ |
|
441 | $(document).ready(function(){ | |
441 | var visual_show_public_icon = "${c.visual.show_public_icon}" == "True"; |
|
442 | var visual_show_public_icon = "${c.visual.show_public_icon}" == "True"; | |
442 | var cache = {} |
|
443 | var cache = {} | |
443 | /*format the look of items in the list*/ |
|
444 | /*format the look of items in the list*/ | |
444 | var format = function(state){ |
|
445 | var format = function(state){ | |
445 | if (!state.id){ |
|
446 | if (!state.id){ | |
446 | return state.text; // optgroup |
|
447 | return state.text; // optgroup | |
447 | } |
|
448 | } | |
448 | var obj_dict = state.obj; |
|
449 | var obj_dict = state.obj; | |
449 | var tmpl = ''; |
|
450 | var tmpl = ''; | |
450 |
|
451 | |||
451 | if(obj_dict && state.type == 'repo'){ |
|
452 | if(obj_dict && state.type == 'repo'){ | |
452 | tmpl += '<span class="repo-icons">'; |
|
453 | tmpl += '<span class="repo-icons">'; | |
453 | if(obj_dict['repo_type'] === 'hg'){ |
|
454 | if(obj_dict['repo_type'] === 'hg'){ | |
454 | tmpl += '<span class="repotag">hg</span> '; |
|
455 | tmpl += '<span class="repotag">hg</span> '; | |
455 | } |
|
456 | } | |
456 | else if(obj_dict['repo_type'] === 'git'){ |
|
457 | else if(obj_dict['repo_type'] === 'git'){ | |
457 | tmpl += '<span class="repotag">git</span> '; |
|
458 | tmpl += '<span class="repotag">git</span> '; | |
458 | } |
|
459 | } | |
459 | if(obj_dict['private']){ |
|
460 | if(obj_dict['private']){ | |
460 | tmpl += '<i class="icon-keyhole-circled"></i> '; |
|
461 | tmpl += '<i class="icon-keyhole-circled"></i> '; | |
461 | } |
|
462 | } | |
462 | else if(visual_show_public_icon){ |
|
463 | else if(visual_show_public_icon){ | |
463 | tmpl += '<i class="icon-globe"></i> '; |
|
464 | tmpl += '<i class="icon-globe"></i> '; | |
464 | } |
|
465 | } | |
465 | tmpl += '</span>'; |
|
466 | tmpl += '</span>'; | |
466 | } |
|
467 | } | |
467 | if(obj_dict && state.type == 'group'){ |
|
468 | if(obj_dict && state.type == 'group'){ | |
468 | tmpl += '<i class="icon-folder"></i> '; |
|
469 | tmpl += '<i class="icon-folder"></i> '; | |
469 | } |
|
470 | } | |
470 | tmpl += state.text; |
|
471 | tmpl += state.text; | |
471 | return tmpl; |
|
472 | return tmpl; | |
472 | } |
|
473 | } | |
473 |
|
474 | |||
474 | $("#repo_switcher").select2({ |
|
475 | $("#repo_switcher").select2({ | |
475 | placeholder: '<i class="icon-database"></i> ${_('Repositories')} <span class="caret"></span>', |
|
476 | placeholder: '<i class="icon-database"></i> ${_('Repositories')} <span class="caret"></span>', | |
476 | dropdownAutoWidth: true, |
|
477 | dropdownAutoWidth: true, | |
477 | sortResults: prefixFirstSort, |
|
478 | sortResults: prefixFirstSort, | |
478 | formatResult: format, |
|
479 | formatResult: format, | |
479 | formatSelection: format, |
|
480 | formatSelection: format, | |
480 | formatNoMatches: function(term){ |
|
481 | formatNoMatches: function(term){ | |
481 | return "${_('No matches found')}"; |
|
482 | return "${_('No matches found')}"; | |
482 | }, |
|
483 | }, | |
483 | containerCssClass: "repo-switcher", |
|
484 | containerCssClass: "repo-switcher", | |
484 | dropdownCssClass: "repo-switcher-dropdown", |
|
485 | dropdownCssClass: "repo-switcher-dropdown", | |
485 | escapeMarkup: function(m){ |
|
486 | escapeMarkup: function(m){ | |
486 | // don't escape our custom placeholder |
|
487 | // don't escape our custom placeholder | |
487 | if(m.substr(0,29) == '<i class="icon-database"></i>'){ |
|
488 | if(m.substr(0,29) == '<i class="icon-database"></i>'){ | |
488 | return m; |
|
489 | return m; | |
489 | } |
|
490 | } | |
490 |
|
491 | |||
491 | return Select2.util.escapeMarkup(m); |
|
492 | return Select2.util.escapeMarkup(m); | |
492 | }, |
|
493 | }, | |
493 | query: function(query){ |
|
494 | query: function(query){ | |
494 | var key = 'cache'; |
|
495 | var key = 'cache'; | |
495 | var cached = cache[key] ; |
|
496 | var cached = cache[key] ; | |
496 | if(cached) { |
|
497 | if(cached) { | |
497 | var data = {results: []}; |
|
498 | var data = {results: []}; | |
498 | //filter results |
|
499 | //filter results | |
499 | $.each(cached.results, function(){ |
|
500 | $.each(cached.results, function(){ | |
500 | var section = this.text; |
|
501 | var section = this.text; | |
501 | var children = []; |
|
502 | var children = []; | |
502 | $.each(this.children, function(){ |
|
503 | $.each(this.children, function(){ | |
503 | if(query.term.length == 0 || this.text.toUpperCase().indexOf(query.term.toUpperCase()) >= 0 ){ |
|
504 | if(query.term.length == 0 || this.text.toUpperCase().indexOf(query.term.toUpperCase()) >= 0 ){ | |
504 | children.push({'id': this.id, 'text': this.text, 'type': this.type, 'obj': this.obj}); |
|
505 | children.push({'id': this.id, 'text': this.text, 'type': this.type, 'obj': this.obj}); | |
505 | } |
|
506 | } | |
506 | }); |
|
507 | }); | |
507 | if(children.length !== 0){ |
|
508 | if(children.length !== 0){ | |
508 | data.results.push({'text': section, 'children': children}); |
|
509 | data.results.push({'text': section, 'children': children}); | |
509 | } |
|
510 | } | |
510 |
|
511 | |||
511 | }); |
|
512 | }); | |
512 | query.callback(data); |
|
513 | query.callback(data); | |
513 | }else{ |
|
514 | }else{ | |
514 | $.ajax({ |
|
515 | $.ajax({ | |
515 | url: "${h.url('repo_switcher_data')}", |
|
516 | url: "${h.url('repo_switcher_data')}", | |
516 | data: {}, |
|
517 | data: {}, | |
517 | dataType: 'json', |
|
518 | dataType: 'json', | |
518 | type: 'GET', |
|
519 | type: 'GET', | |
519 | success: function(data) { |
|
520 | success: function(data) { | |
520 | cache[key] = data; |
|
521 | cache[key] = data; | |
521 | query.callback({results: data.results}); |
|
522 | query.callback({results: data.results}); | |
522 | } |
|
523 | } | |
523 | }); |
|
524 | }); | |
524 | } |
|
525 | } | |
525 | } |
|
526 | } | |
526 | }); |
|
527 | }); | |
527 |
|
528 | |||
528 | $("#repo_switcher").on('select2-selecting', function(e){ |
|
529 | $("#repo_switcher").on('select2-selecting', function(e){ | |
529 | e.preventDefault(); |
|
530 | e.preventDefault(); | |
530 | window.location = pyroutes.url('summary_home', {'repo_name': e.val}); |
|
531 | window.location = pyroutes.url('summary_home', {'repo_name': e.val}); | |
531 | }); |
|
532 | }); | |
|
533 | ||||
|
534 | $(document).on('shown.bs.dropdown', function(event) { | |||
|
535 | var dropdown = $(event.target); | |||
|
536 | ||||
|
537 | dropdown.attr('aria-expanded', true); | |||
|
538 | dropdown.find('.dropdown-menu').attr('aria-hidden', false); | |||
|
539 | }); | |||
|
540 | ||||
|
541 | $(document).on('hidden.bs.dropdown', function(event) { | |||
|
542 | var dropdown = $(event.target); | |||
|
543 | ||||
|
544 | dropdown.attr('aria-expanded', false); | |||
|
545 | dropdown.find('.dropdown-menu').attr('aria-hidden', true); | |||
|
546 | }); | |||
532 | }); |
|
547 | }); | |
533 | </script> |
|
548 | </script> | |
534 | </%def> |
|
549 | </%def> |
General Comments 0
You need to be logged in to leave comments.
Login now