Show More
@@ -120,191 +120,6 | |||
|
120 | 120 | </div> |
|
121 | 121 | </div> |
|
122 | 122 | ${h.end_form()} |
|
123 | <script type="text/javascript"> | |
|
124 | YAHOO.util.Event.onDOMReady(function(){ | |
|
125 | var D = YAHOO.util.Dom; | |
|
126 | if(!D.hasClass('perm_new_member_name','error')){ | |
|
127 | D.setStyle('add_perm_input','display','none'); | |
|
128 | } | |
|
129 | YAHOO.util.Event.addListener('add_perm','click',function(){ | |
|
130 | D.setStyle('add_perm_input','display',''); | |
|
131 | D.setStyle('add_perm','opacity','0.6'); | |
|
132 | D.setStyle('add_perm','cursor','default'); | |
|
133 | }); | |
|
134 | }); | |
|
135 | </script> | |
|
136 | <script type="text/javascript"> | |
|
137 | YAHOO.example.FnMultipleFields = function(){ | |
|
138 | var myUsers = ${c.users_array|n}; | |
|
139 | var myGroups = ${c.users_groups_array|n}; | |
|
140 | ||
|
141 | // Define a custom search function for the DataSource of users | |
|
142 | var matchUsers = function(sQuery) { | |
|
143 | // Case insensitive matching | |
|
144 | var query = sQuery.toLowerCase(); | |
|
145 | var i=0; | |
|
146 | var l=myUsers.length; | |
|
147 | var matches = []; | |
|
148 | ||
|
149 | // Match against each name of each contact | |
|
150 | for(; i<l; i++) { | |
|
151 | contact = myUsers[i]; | |
|
152 | if((contact.fname.toLowerCase().indexOf(query) > -1) || | |
|
153 | (contact.lname.toLowerCase().indexOf(query) > -1) || | |
|
154 | (contact.nname && (contact.nname.toLowerCase().indexOf(query) > -1))) { | |
|
155 | matches[matches.length] = contact; | |
|
156 | } | |
|
157 | } | |
|
158 | return matches; | |
|
159 | }; | |
|
160 | ||
|
161 | // Define a custom search function for the DataSource of usersGroups | |
|
162 | var matchGroups = function(sQuery) { | |
|
163 | // Case insensitive matching | |
|
164 | var query = sQuery.toLowerCase(); | |
|
165 | var i=0; | |
|
166 | var l=myGroups.length; | |
|
167 | var matches = []; | |
|
168 | ||
|
169 | // Match against each name of each contact | |
|
170 | for(; i<l; i++) { | |
|
171 | matched_group = myGroups[i]; | |
|
172 | if(matched_group.grname.toLowerCase().indexOf(query) > -1) { | |
|
173 | matches[matches.length] = matched_group; | |
|
174 | } | |
|
175 | } | |
|
176 | return matches; | |
|
177 | }; | |
|
178 | ||
|
179 | //match all | |
|
180 | var matchAll = function(sQuery){ | |
|
181 | u = matchUsers(sQuery); | |
|
182 | g = matchGroups(sQuery); | |
|
183 | return u.concat(g); | |
|
184 | }; | |
|
185 | ||
|
186 | // DataScheme for members | |
|
187 | var memberDS = new YAHOO.util.FunctionDataSource(matchAll); | |
|
188 | memberDS.responseSchema = { | |
|
189 | fields: ["id", "fname", "lname", "nname", "grname", "grmembers"] | |
|
190 | }; | |
|
191 | ||
|
192 | // DataScheme for owner | |
|
193 | var ownerDS = new YAHOO.util.FunctionDataSource(matchUsers); | |
|
194 | ownerDS.responseSchema = { | |
|
195 | fields: ["id", "fname", "lname", "nname"] | |
|
196 | }; | |
|
197 | ||
|
198 | // Instantiate AutoComplete for perms | |
|
199 | var membersAC = new YAHOO.widget.AutoComplete("perm_new_member_name", "perm_container", memberDS); | |
|
200 | membersAC.useShadow = false; | |
|
201 | membersAC.resultTypeList = false; | |
|
202 | ||
|
203 | // Instantiate AutoComplete for owner | |
|
204 | var ownerAC = new YAHOO.widget.AutoComplete("user", "owner_container", ownerDS); | |
|
205 | ownerAC.useShadow = false; | |
|
206 | ownerAC.resultTypeList = false; | |
|
207 | ||
|
208 | ||
|
209 | // Helper highlight function for the formatter | |
|
210 | var highlightMatch = function(full, snippet, matchindex) { | |
|
211 | return full.substring(0, matchindex) + | |
|
212 | "<span class='match'>" + | |
|
213 | full.substr(matchindex, snippet.length) + | |
|
214 | "</span>" + | |
|
215 | full.substring(matchindex + snippet.length); | |
|
216 | }; | |
|
217 | ||
|
218 | // Custom formatter to highlight the matching letters | |
|
219 | var custom_formatter = function(oResultData, sQuery, sResultMatch) { | |
|
220 | var query = sQuery.toLowerCase(); | |
|
221 | ||
|
222 | if (oResultData.grname != undefined){ | |
|
223 | var grname = oResultData.grname; | |
|
224 | var grmembers = oResultData.grmembers; | |
|
225 | var grnameMatchIndex = grname.toLowerCase().indexOf(query); | |
|
226 | var grprefix = "${_('Group')}: "; | |
|
227 | var grsuffix = " ("+grmembers+" ${_('members')})"; | |
|
228 | ||
|
229 | if (grnameMatchIndex > -1){ | |
|
230 | return grprefix+highlightMatch(grname,query,grnameMatchIndex)+grsuffix; | |
|
231 | } | |
|
232 | ||
|
233 | return grprefix+oResultData.grname+grsuffix; | |
|
234 | } | |
|
235 | else if(oResultData.fname != undefined){ | |
|
236 | ||
|
237 | var fname = oResultData.fname, | |
|
238 | lname = oResultData.lname, | |
|
239 | nname = oResultData.nname || "", // Guard against null value | |
|
240 | fnameMatchIndex = fname.toLowerCase().indexOf(query), | |
|
241 | lnameMatchIndex = lname.toLowerCase().indexOf(query), | |
|
242 | nnameMatchIndex = nname.toLowerCase().indexOf(query), | |
|
243 | displayfname, displaylname, displaynname; | |
|
244 | ||
|
245 | if(fnameMatchIndex > -1) { | |
|
246 | displayfname = highlightMatch(fname, query, fnameMatchIndex); | |
|
247 | } | |
|
248 | else { | |
|
249 | displayfname = fname; | |
|
250 | } | |
|
251 | ||
|
252 | if(lnameMatchIndex > -1) { | |
|
253 | displaylname = highlightMatch(lname, query, lnameMatchIndex); | |
|
254 | } | |
|
255 | else { | |
|
256 | displaylname = lname; | |
|
257 | } | |
|
258 | ||
|
259 | if(nnameMatchIndex > -1) { | |
|
260 | displaynname = "(" + highlightMatch(nname, query, nnameMatchIndex) + ")"; | |
|
261 | } | |
|
262 | else { | |
|
263 | displaynname = nname ? "(" + nname + ")" : ""; | |
|
264 | } | |
|
265 | ||
|
266 | return displayfname + " " + displaylname + " " + displaynname; | |
|
267 | } | |
|
268 | else{ | |
|
269 | return ''; | |
|
270 | } | |
|
271 | }; | |
|
272 | membersAC.formatResult = custom_formatter; | |
|
273 | ownerAC.formatResult = custom_formatter; | |
|
274 | ||
|
275 | var myHandler = function(sType, aArgs) { | |
|
276 | ||
|
277 | var myAC = aArgs[0]; // reference back to the AC instance | |
|
278 | var elLI = aArgs[1]; // reference to the selected LI element | |
|
279 | var oData = aArgs[2]; // object literal of selected item's result data | |
|
280 | ||
|
281 | //fill the autocomplete with value | |
|
282 | if(oData.nname != undefined){ | |
|
283 | //users | |
|
284 | myAC.getInputEl().value = oData.nname; | |
|
285 | YUD.get('perm_new_member_type').value = 'user'; | |
|
286 | } | |
|
287 | else{ | |
|
288 | //groups | |
|
289 | myAC.getInputEl().value = oData.grname; | |
|
290 | YUD.get('perm_new_member_type').value = 'users_group'; | |
|
291 | } | |
|
292 | ||
|
293 | }; | |
|
294 | ||
|
295 | membersAC.itemSelectEvent.subscribe(myHandler); | |
|
296 | ownerAC.itemSelectEvent.subscribe(myHandler); | |
|
297 | ||
|
298 | return { | |
|
299 | memberDS: memberDS, | |
|
300 | ownerDS: ownerDS, | |
|
301 | membersAC: membersAC, | |
|
302 | ownerAC: ownerAC, | |
|
303 | }; | |
|
304 | }(); | |
|
305 | ||
|
306 | </script> | |
|
307 | ||
|
308 | 123 | </div> |
|
309 | 124 | |
|
310 | 125 | <div class="box box-right"> |
@@ -7,18 +7,7 | |||
|
7 | 7 | <td>${_('member')}</td> |
|
8 | 8 | <td></td> |
|
9 | 9 | </tr> |
|
10 | ## USERS | |
|
11 | <script type="text/javascript"> | |
|
12 | function ajaxActionUser(user_id,field_id){ | |
|
13 | var sUrl = "${h.url('delete_repo_user',repo_name=c.repo_name)}"; | |
|
14 | var callback = { success:function(o){ | |
|
15 | var tr = YUD.get(String(field_id)); | |
|
16 | tr.parentNode.removeChild(tr);}, | |
|
17 | failure:function(o){ | |
|
18 | alert("${_('Failed to remove user')}");},}; | |
|
19 | var postData = '_method=delete&user_id='+user_id; | |
|
20 | var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, callback, postData);}; | |
|
21 | </script> | |
|
10 | ## USERS | |
|
22 | 11 | %for r2p in c.repo_info.repo_to_perm: |
|
23 | 12 | %if r2p.user.username =='default' and c.repo_info.private: |
|
24 | 13 | <tr> |
@@ -35,7 +24,9 | |||
|
35 | 24 | <td>${h.radio('u_perm_%s' % r2p.user.username,'repository.read')}</td> |
|
36 | 25 | <td>${h.radio('u_perm_%s' % r2p.user.username,'repository.write')}</td> |
|
37 | 26 | <td>${h.radio('u_perm_%s' % r2p.user.username,'repository.admin')}</td> |
|
38 | <td style="white-space: nowrap;"><img style="vertical-align:bottom" src="${h.url("/images/icons/user.png")}"/>${r2p.user.username}</td> | |
|
27 | <td style="white-space: nowrap;"> | |
|
28 | <img style="vertical-align:bottom" src="${h.url('/images/icons/user.png')}"/>${r2p.user.username} | |
|
29 | </td> | |
|
39 | 30 | <td> |
|
40 | 31 | %if r2p.user.username !='default': |
|
41 | 32 | <span class="delete_icon action_button" onclick="ajaxActionUser(${r2p.user.user_id},'${'id%s'%id(r2p.user.username)}')"> |
@@ -47,25 +38,16 | |||
|
47 | 38 | %endif |
|
48 | 39 | %endfor |
|
49 | 40 | |
|
50 | ## USERS GROUPS | |
|
51 | <script type="text/javascript"> | |
|
52 | function ajaxActionUsersGroup(users_group_id,field_id){ | |
|
53 | var sUrl = "${h.url('delete_repo_users_group',repo_name=c.repo_name)}"; | |
|
54 | var callback = { success:function(o){ | |
|
55 | var tr = YUD.get(String(field_id)); | |
|
56 | tr.parentNode.removeChild(tr);}, | |
|
57 | failure:function(o){ | |
|
58 | alert("${_('Failed to remove users group')}");},}; | |
|
59 | var postData = '_method=delete&users_group_id='+users_group_id; | |
|
60 | var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, callback, postData);}; | |
|
61 | </script> | |
|
41 | ## USERS GROUPS | |
|
62 | 42 | %for g2p in c.repo_info.users_group_to_perm: |
|
63 | 43 | <tr id="id${id(g2p.users_group.users_group_name)}"> |
|
64 | 44 | <td>${h.radio('g_perm_%s' % g2p.users_group.users_group_name,'repository.none')}</td> |
|
65 | 45 | <td>${h.radio('g_perm_%s' % g2p.users_group.users_group_name,'repository.read')}</td> |
|
66 | 46 | <td>${h.radio('g_perm_%s' % g2p.users_group.users_group_name,'repository.write')}</td> |
|
67 | 47 | <td>${h.radio('g_perm_%s' % g2p.users_group.users_group_name,'repository.admin')}</td> |
|
68 | <td><img style="vertical-align:bottom" src="${h.url("/images/icons/group.png")}"/>${g2p.users_group.users_group_name}</td> | |
|
48 | <td style="white-space: nowrap;"> | |
|
49 | <img style="vertical-align:bottom" src="${h.url('/images/icons/group.png')}"/>${g2p.users_group.users_group_name} | |
|
50 | </td> | |
|
69 | 51 | <td> |
|
70 | 52 | <span class="delete_icon action_button" onclick="ajaxActionUsersGroup(${g2p.users_group.users_group_id},'${'id%s'%id(g2p.users_group.users_group_name)}')"> |
|
71 | 53 | ${_('revoke')} |
@@ -94,4 +76,206 | |||
|
94 | 76 | </span> |
|
95 | 77 | </td> |
|
96 | 78 | </tr> |
|
97 | </table> No newline at end of file | |
|
79 | </table> | |
|
80 | <script type="text/javascript"> | |
|
81 | function ajaxActionUser(user_id, field_id) { | |
|
82 | var sUrl = "${h.url('delete_repo_user',repo_name=c.repo_name)}"; | |
|
83 | var callback = { | |
|
84 | success: function (o) { | |
|
85 | var tr = YUD.get(String(field_id)); | |
|
86 | tr.parentNode.removeChild(tr); | |
|
87 | }, | |
|
88 | failure: function (o) { | |
|
89 | alert("${_('Failed to remove user')}"); | |
|
90 | }, | |
|
91 | }; | |
|
92 | var postData = '_method=delete&user_id=' + user_id; | |
|
93 | var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, callback, postData); | |
|
94 | }; | |
|
95 | ||
|
96 | function ajaxActionUsersGroup(users_group_id,field_id){ | |
|
97 | var sUrl = "${h.url('delete_repo_users_group',repo_name=c.repo_name)}"; | |
|
98 | var callback = { | |
|
99 | success:function(o){ | |
|
100 | var tr = YUD.get(String(field_id)); | |
|
101 | tr.parentNode.removeChild(tr); | |
|
102 | }, | |
|
103 | failure:function(o){ | |
|
104 | alert("${_('Failed to remove users group')}"); | |
|
105 | }, | |
|
106 | }; | |
|
107 | var postData = '_method=delete&users_group_id='+users_group_id; | |
|
108 | var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, callback, postData); | |
|
109 | }; | |
|
110 | ||
|
111 | YUE.onDOMReady(function () { | |
|
112 | if (!YUD.hasClass('perm_new_member_name', 'error')) { | |
|
113 | YUD.setStyle('add_perm_input', 'display', 'none'); | |
|
114 | } | |
|
115 | YAHOO.util.Event.addListener('add_perm', 'click', function () { | |
|
116 | YUD.setStyle('add_perm_input', 'display', ''); | |
|
117 | YUD.setStyle('add_perm', 'opacity', '0.6'); | |
|
118 | YUD.setStyle('add_perm', 'cursor', 'default'); | |
|
119 | }); | |
|
120 | }); | |
|
121 | ||
|
122 | YAHOO.example.FnMultipleFields = function () { | |
|
123 | var myUsers = ${c.users_array|n}; | |
|
124 | var myGroups = ${c.users_groups_array|n}; | |
|
125 | ||
|
126 | // Define a custom search function for the DataSource of users | |
|
127 | var matchUsers = function (sQuery) { | |
|
128 | // Case insensitive matching | |
|
129 | var query = sQuery.toLowerCase(); | |
|
130 | var i = 0; | |
|
131 | var l = myUsers.length; | |
|
132 | var matches = []; | |
|
133 | ||
|
134 | // Match against each name of each contact | |
|
135 | for (; i < l; i++) { | |
|
136 | contact = myUsers[i]; | |
|
137 | if ((contact.fname.toLowerCase().indexOf(query) > -1) || (contact.lname.toLowerCase().indexOf(query) > -1) || (contact.nname && (contact.nname.toLowerCase().indexOf(query) > -1))) { | |
|
138 | matches[matches.length] = contact; | |
|
139 | } | |
|
140 | } | |
|
141 | return matches; | |
|
142 | }; | |
|
143 | ||
|
144 | // Define a custom search function for the DataSource of usersGroups | |
|
145 | var matchGroups = function (sQuery) { | |
|
146 | // Case insensitive matching | |
|
147 | var query = sQuery.toLowerCase(); | |
|
148 | var i = 0; | |
|
149 | var l = myGroups.length; | |
|
150 | var matches = []; | |
|
151 | ||
|
152 | // Match against each name of each contact | |
|
153 | for (; i < l; i++) { | |
|
154 | matched_group = myGroups[i]; | |
|
155 | if (matched_group.grname.toLowerCase().indexOf(query) > -1) { | |
|
156 | matches[matches.length] = matched_group; | |
|
157 | } | |
|
158 | } | |
|
159 | return matches; | |
|
160 | }; | |
|
161 | ||
|
162 | //match all | |
|
163 | var matchAll = function (sQuery) { | |
|
164 | u = matchUsers(sQuery); | |
|
165 | g = matchGroups(sQuery); | |
|
166 | return u.concat(g); | |
|
167 | }; | |
|
168 | ||
|
169 | // DataScheme for members | |
|
170 | var memberDS = new YAHOO.util.FunctionDataSource(matchAll); | |
|
171 | memberDS.responseSchema = { | |
|
172 | fields: ["id", "fname", "lname", "nname", "grname", "grmembers"] | |
|
173 | }; | |
|
174 | ||
|
175 | // DataScheme for owner | |
|
176 | var ownerDS = new YAHOO.util.FunctionDataSource(matchUsers); | |
|
177 | ownerDS.responseSchema = { | |
|
178 | fields: ["id", "fname", "lname", "nname"] | |
|
179 | }; | |
|
180 | ||
|
181 | // Instantiate AutoComplete for perms | |
|
182 | var membersAC = new YAHOO.widget.AutoComplete("perm_new_member_name", "perm_container", memberDS); | |
|
183 | membersAC.useShadow = false; | |
|
184 | membersAC.resultTypeList = false; | |
|
185 | ||
|
186 | // Instantiate AutoComplete for owner | |
|
187 | var ownerAC = new YAHOO.widget.AutoComplete("user", "owner_container", ownerDS); | |
|
188 | ownerAC.useShadow = false; | |
|
189 | ownerAC.resultTypeList = false; | |
|
190 | ||
|
191 | ||
|
192 | // Helper highlight function for the formatter | |
|
193 | var highlightMatch = function (full, snippet, matchindex) { | |
|
194 | return full.substring(0, matchindex) + "<span class='match'>" + full.substr(matchindex, snippet.length) + "</span>" + full.substring(matchindex + snippet.length); | |
|
195 | }; | |
|
196 | ||
|
197 | // Custom formatter to highlight the matching letters | |
|
198 | var custom_formatter = function (oResultData, sQuery, sResultMatch) { | |
|
199 | var query = sQuery.toLowerCase(); | |
|
200 | ||
|
201 | if (oResultData.grname != undefined) { | |
|
202 | var grname = oResultData.grname; | |
|
203 | var grmembers = oResultData.grmembers; | |
|
204 | var grnameMatchIndex = grname.toLowerCase().indexOf(query); | |
|
205 | var grprefix = "${_('Group')}: "; | |
|
206 | var grsuffix = " (" + grmembers + " ${_('members')})"; | |
|
207 | ||
|
208 | if (grnameMatchIndex > -1) { | |
|
209 | return grprefix + highlightMatch(grname, query, grnameMatchIndex) + grsuffix; | |
|
210 | } | |
|
211 | ||
|
212 | return grprefix + oResultData.grname + grsuffix; | |
|
213 | } else if (oResultData.fname != undefined) { | |
|
214 | ||
|
215 | var fname = oResultData.fname, | |
|
216 | lname = oResultData.lname, | |
|
217 | nname = oResultData.nname || "", | |
|
218 | // Guard against null value | |
|
219 | fnameMatchIndex = fname.toLowerCase().indexOf(query), | |
|
220 | lnameMatchIndex = lname.toLowerCase().indexOf(query), | |
|
221 | nnameMatchIndex = nname.toLowerCase().indexOf(query), | |
|
222 | displayfname, displaylname, displaynname; | |
|
223 | ||
|
224 | if (fnameMatchIndex > -1) { | |
|
225 | displayfname = highlightMatch(fname, query, fnameMatchIndex); | |
|
226 | } else { | |
|
227 | displayfname = fname; | |
|
228 | } | |
|
229 | ||
|
230 | if (lnameMatchIndex > -1) { | |
|
231 | displaylname = highlightMatch(lname, query, lnameMatchIndex); | |
|
232 | } else { | |
|
233 | displaylname = lname; | |
|
234 | } | |
|
235 | ||
|
236 | if (nnameMatchIndex > -1) { | |
|
237 | displaynname = "(" + highlightMatch(nname, query, nnameMatchIndex) + ")"; | |
|
238 | } else { | |
|
239 | displaynname = nname ? "(" + nname + ")" : ""; | |
|
240 | } | |
|
241 | ||
|
242 | return displayfname + " " + displaylname + " " + displaynname; | |
|
243 | } else { | |
|
244 | return ''; | |
|
245 | } | |
|
246 | }; | |
|
247 | membersAC.formatResult = custom_formatter; | |
|
248 | ownerAC.formatResult = custom_formatter; | |
|
249 | ||
|
250 | var myHandler = function (sType, aArgs) { | |
|
251 | ||
|
252 | var myAC = aArgs[0]; // reference back to the AC instance | |
|
253 | var elLI = aArgs[1]; // reference to the selected LI element | |
|
254 | var oData = aArgs[2]; // object literal of selected item's result data | |
|
255 | //fill the autocomplete with value | |
|
256 | if (oData.nname != undefined) { | |
|
257 | //users | |
|
258 | myAC.getInputEl().value = oData.nname; | |
|
259 | YUD.get('perm_new_member_type').value = 'user'; | |
|
260 | } else { | |
|
261 | //groups | |
|
262 | myAC.getInputEl().value = oData.grname; | |
|
263 | YUD.get('perm_new_member_type').value = 'users_group'; | |
|
264 | } | |
|
265 | ||
|
266 | }; | |
|
267 | ||
|
268 | membersAC.itemSelectEvent.subscribe(myHandler); | |
|
269 | if(ownerAC.itemSelectEvent){ | |
|
270 | ownerAC.itemSelectEvent.subscribe(myHandler); | |
|
271 | } | |
|
272 | ||
|
273 | return { | |
|
274 | memberDS: memberDS, | |
|
275 | ownerDS: ownerDS, | |
|
276 | membersAC: membersAC, | |
|
277 | ownerAC: ownerAC, | |
|
278 | }; | |
|
279 | }(); | |
|
280 | ||
|
281 | </script> No newline at end of file |
@@ -39,18 +39,18 | |||
|
39 | 39 | <td> |
|
40 | 40 | ## TYPE OF REPO |
|
41 | 41 | %if repo['dbrepo']['repo_type'] =='hg': |
|
42 |
<img class="icon" title="${_('Mercurial repository')}" alt="${_('Mercurial repository')}" src="${h.url( |
|
|
42 | <img class="icon" title="${_('Mercurial repository')}" alt="${_('Mercurial repository')}" src="${h.url('/images/icons/hgicon.png')}"/> | |
|
43 | 43 | %elif repo['dbrepo']['repo_type'] =='git': |
|
44 |
<img class="icon" title="${_('Git repository')}" alt="${_('Git repository')}" src="${h.url( |
|
|
44 | <img class="icon" title="${_('Git repository')}" alt="${_('Git repository')}" src="${h.url('/images/icons/giticon.png')}"/> | |
|
45 | 45 | %else: |
|
46 | 46 | |
|
47 | 47 | %endif |
|
48 | 48 | |
|
49 | 49 | ## PRIVATE/PUBLIC REPO |
|
50 | 50 | %if repo['dbrepo']['private']: |
|
51 |
<img alt="${_('private')}" src="${h.url( |
|
|
51 | <img alt="${_('private')}" src="${h.url('/images/icons/lock.png')}"/> | |
|
52 | 52 | %else: |
|
53 |
<img alt="${_('public')}" src="${h.url( |
|
|
53 | <img alt="${_('public')}" src="${h.url('/images/icons/lock_open.png')}"/> | |
|
54 | 54 | %endif |
|
55 | 55 | ${h.link_to(repo['name'],h.url('edit_repo',repo_name=repo['name']))} |
|
56 | 56 |
@@ -62,134 +62,12 | |||
|
62 | 62 | </div> |
|
63 | 63 | |
|
64 | 64 | <div class="buttons"> |
|
65 |
${h.submit(' |
|
|
65 | ${h.submit('save','Save',class_="ui-button")} | |
|
66 | 66 | ${h.reset('reset','Reset',class_="ui-button")} |
|
67 | 67 | </div> |
|
68 | 68 | </div> |
|
69 | 69 | </div> |
|
70 | 70 | ${h.end_form()} |
|
71 | <script type="text/javascript"> | |
|
72 | YAHOO.util.Event.onDOMReady(function(){ | |
|
73 | var D = YAHOO.util.Dom; | |
|
74 | if(!D.hasClass('perm_new_member_name','error')){ | |
|
75 | D.setStyle('add_perm_input','display','none'); | |
|
76 | } | |
|
77 | YAHOO.util.Event.addListener('add_perm','click',function(){ | |
|
78 | D.setStyle('add_perm_input','display',''); | |
|
79 | D.setStyle('add_perm','opacity','0.6'); | |
|
80 | D.setStyle('add_perm','cursor','default'); | |
|
81 | }); | |
|
82 | }); | |
|
83 | </script> | |
|
84 | <script type="text/javascript"> | |
|
85 | YAHOO.example.FnMultipleFields = function(){ | |
|
86 | var myContacts = ${c.users_array|n} | |
|
87 | ||
|
88 | // Define a custom search function for the DataSource | |
|
89 | var matchNames = function(sQuery) { | |
|
90 | // Case insensitive matching | |
|
91 | var query = sQuery.toLowerCase(), | |
|
92 | contact, | |
|
93 | i=0, | |
|
94 | l=myContacts.length, | |
|
95 | matches = []; | |
|
96 | ||
|
97 | // Match against each name of each contact | |
|
98 | for(; i<l; i++) { | |
|
99 | contact = myContacts[i]; | |
|
100 | if((contact.fname.toLowerCase().indexOf(query) > -1) || | |
|
101 | (contact.lname.toLowerCase().indexOf(query) > -1) || | |
|
102 | (contact.nname && (contact.nname.toLowerCase().indexOf(query) > -1))) { | |
|
103 | matches[matches.length] = contact; | |
|
104 | } | |
|
105 | } | |
|
106 | ||
|
107 | return matches; | |
|
108 | }; | |
|
109 | ||
|
110 | // Use a FunctionDataSource | |
|
111 | var oDS = new YAHOO.util.FunctionDataSource(matchNames); | |
|
112 | oDS.responseSchema = { | |
|
113 | fields: ["id", "fname", "lname", "nname"] | |
|
114 | } | |
|
115 | ||
|
116 | // Instantiate AutoComplete for perms | |
|
117 | var oAC_perms = new YAHOO.widget.AutoComplete("perm_new_member_name", "perm_container", oDS); | |
|
118 | oAC_perms.useShadow = false; | |
|
119 | oAC_perms.resultTypeList = false; | |
|
120 | ||
|
121 | // Instantiate AutoComplete for owner | |
|
122 | var oAC_owner = new YAHOO.widget.AutoComplete("user", "owner_container", oDS); | |
|
123 | oAC_owner.useShadow = false; | |
|
124 | oAC_owner.resultTypeList = false; | |
|
125 | ||
|
126 | ||
|
127 | // Custom formatter to highlight the matching letters | |
|
128 | var custom_formatter = function(oResultData, sQuery, sResultMatch) { | |
|
129 | var query = sQuery.toLowerCase(), | |
|
130 | fname = oResultData.fname, | |
|
131 | lname = oResultData.lname, | |
|
132 | nname = oResultData.nname || "", // Guard against null value | |
|
133 | query = sQuery.toLowerCase(), | |
|
134 | fnameMatchIndex = fname.toLowerCase().indexOf(query), | |
|
135 | lnameMatchIndex = lname.toLowerCase().indexOf(query), | |
|
136 | nnameMatchIndex = nname.toLowerCase().indexOf(query), | |
|
137 | displayfname, displaylname, displaynname; | |
|
138 | ||
|
139 | if(fnameMatchIndex > -1) { | |
|
140 | displayfname = highlightMatch(fname, query, fnameMatchIndex); | |
|
141 | } | |
|
142 | else { | |
|
143 | displayfname = fname; | |
|
144 | } | |
|
145 | ||
|
146 | if(lnameMatchIndex > -1) { | |
|
147 | displaylname = highlightMatch(lname, query, lnameMatchIndex); | |
|
148 | } | |
|
149 | else { | |
|
150 | displaylname = lname; | |
|
151 | } | |
|
152 | ||
|
153 | if(nnameMatchIndex > -1) { | |
|
154 | displaynname = "(" + highlightMatch(nname, query, nnameMatchIndex) + ")"; | |
|
155 | } | |
|
156 | else { | |
|
157 | displaynname = nname ? "(" + nname + ")" : ""; | |
|
158 | } | |
|
159 | ||
|
160 | return displayfname + " " + displaylname + " " + displaynname; | |
|
161 | ||
|
162 | }; | |
|
163 | oAC_perms.formatResult = custom_formatter; | |
|
164 | oAC_owner.formatResult = custom_formatter; | |
|
165 | ||
|
166 | // Helper function for the formatter | |
|
167 | var highlightMatch = function(full, snippet, matchindex) { | |
|
168 | return full.substring(0, matchindex) + | |
|
169 | "<span class='match'>" + | |
|
170 | full.substr(matchindex, snippet.length) + | |
|
171 | "</span>" + | |
|
172 | full.substring(matchindex + snippet.length); | |
|
173 | }; | |
|
174 | ||
|
175 | var myHandler = function(sType, aArgs) { | |
|
176 | var myAC = aArgs[0]; // reference back to the AC instance | |
|
177 | var elLI = aArgs[1]; // reference to the selected LI element | |
|
178 | var oData = aArgs[2]; // object literal of selected item's result data | |
|
179 | myAC.getInputEl().value = oData.nname; | |
|
180 | }; | |
|
181 | ||
|
182 | oAC_perms.itemSelectEvent.subscribe(myHandler); | |
|
183 | //oAC_owner.itemSelectEvent.subscribe(myHandler); | |
|
184 | ||
|
185 | return { | |
|
186 | oDS: oDS, | |
|
187 | oAC_perms: oAC_perms, | |
|
188 | oAC_owner: oAC_owner, | |
|
189 | }; | |
|
190 | }(); | |
|
191 | ||
|
192 | </script> | |
|
193 | 71 | </div> |
|
194 | 72 | </div> |
|
195 | 73 | </%def> |
General Comments 0
You need to be logged in to leave comments.
Login now