|
39 | 39 | */ |
40 | 40 | $currentContent: null, |
41 | 41 |
|
42 | | - /** |
43 | | - * Strategy by which the quickaccesslist is sorted |
44 | | - * |
45 | | - * Possible Strategies: |
46 | | - * customorder |
47 | | - * datemodified |
48 | | - * date |
49 | | - * alphabet |
50 | | - * |
51 | | - */ |
52 | | - $sortingStrategy: 'alphabet', |
53 | | - |
54 | 42 | /** |
55 | 43 | * Key for the quick-acces-list |
56 | 44 | */ |
|
67 | 55 | this.$currentContent = null; |
68 | 56 | this._setupEvents(); |
69 | 57 |
|
70 | | - var scope=this; |
71 | | - $.get(OC.generateUrl("/apps/files/api/v1/quickaccess/get/SortingStrategy"), function (data, status) { |
72 | | - scope.$sortingStrategy=data; |
73 | | - scope.setInitialQuickaccessSettings(); |
74 | | - }); |
75 | | - |
| 58 | + this.setInitialQuickaccessSettings(); |
76 | 59 | }, |
77 | 60 |
|
78 | 61 | /** |
|
198 | 181 | * Sort initially as setup of sidebar for QuickAccess |
199 | 182 | */ |
200 | 183 | setInitialQuickaccessSettings: function () { |
201 | | - |
202 | 184 | var quickAccesKey = this.$quickAccessListKey; |
203 | 185 | var list = document.getElementById(quickAccesKey).getElementsByTagName('li'); |
204 | | - |
205 | | - var sort = true; |
206 | | - var reverse = false; |
207 | | - if (this.$sortingStrategy === 'datemodified') { |
208 | | - sort = false; |
209 | | - reverse = false; |
210 | | - |
211 | | - var scope = this; |
212 | | - $.get(OC.generateUrl("/apps/files/api/v1/quickaccess/get/FavoriteFolders/"), function (data, status) { |
213 | | - for (var i = 0; i < data.favoriteFolders.length; i++) { |
214 | | - for (var j = 0; j < list.length; j++) { |
215 | | - if (scope.getCompareValue(list, j, 'alphabet').toLowerCase() === data.favoriteFolders[i].name.toLowerCase()) { |
216 | | - list[j].setAttribute("mtime", data.favoriteFolders[i].mtime); |
217 | | - } |
218 | | - } |
219 | | - } |
220 | | - scope.QuickSort(list, 0, list.length - 1); |
221 | | - scope.reverse(list); |
222 | | - }); |
223 | | - |
224 | | - } else if (this.$sortingStrategy === 'alphabet') { |
225 | | - sort = true; |
226 | | - } else if (this.$sortingStrategy === 'date') { |
227 | | - sort = true; |
228 | | - } else if (this.$sortingStrategy === 'customorder') { |
229 | | - var scope = this; |
230 | | - $.get(OC.generateUrl("/apps/files/api/v1/quickaccess/get/CustomSortingOrder"), function (data, status) { |
231 | | - var ordering = JSON.parse(data); |
232 | | - for (var i = 0; i < ordering.length; i++) { |
233 | | - for (var j = 0; j < list.length; j++) { |
234 | | - if (scope.getCompareValue(list, j, 'alphabet').toLowerCase() === ordering[i].name.toLowerCase()) { |
235 | | - list[j].setAttribute("folderPosition", ordering[i].id); |
236 | | - } |
237 | | - } |
238 | | - } |
239 | | - scope.QuickSort(list, 0, list.length - 1); |
240 | | - }); |
241 | | - sort = false; |
242 | | - } |
243 | | - |
244 | | - if (sort) { |
245 | | - this.QuickSort(list, 0, list.length - 1); |
246 | | - } |
247 | | - if (reverse) { |
248 | | - this.reverse(list); |
249 | | - } |
250 | | - |
| 186 | + this.QuickSort(list, 0, list.length - 1); |
251 | 187 | }, |
252 | 188 |
|
253 | 189 | /** |
|
296 | 232 | * This method allows easy access to the element which is sorted by. |
297 | 233 | */ |
298 | 234 | getCompareValue: function (nodes, int, strategy) { |
299 | | - |
300 | | - if ((typeof strategy === 'undefined')) { |
301 | | - strategy = this.$sortingStrategy; |
302 | | - } |
303 | | - |
304 | | - if (strategy === 'alphabet') { |
305 | 235 | return nodes[int].getElementsByTagName('a')[0].innerHTML.toLowerCase(); |
306 | | - } else if (strategy === 'date') { |
307 | | - return nodes[int].getAttribute('folderPosition').toLowerCase(); |
308 | | - } else if (strategy === 'datemodified') { |
309 | | - return nodes[int].getAttribute('mtime'); |
310 | | - } else if (strategy === 'customorder') { |
311 | | - return nodes[int].getAttribute('folderPosition'); |
312 | | - } |
313 | | - return nodes[int].getElementsByTagName('a')[0].innerHTML.toLowerCase(); |
314 | 236 | }, |
315 | 237 |
|
316 | 238 | /** |
|
320 | 242 | swap: function (list, j, i) { |
321 | 243 | list[i].before(list[j]); |
322 | 244 | list[j].before(list[i]); |
323 | | - }, |
324 | | - |
325 | | - /** |
326 | | - * Reverse QuickAccess-List |
327 | | - */ |
328 | | - reverse: function (list) { |
329 | | - var len = list.length - 1; |
330 | | - for (var i = 0; i < len / 2; i++) { |
331 | | - this.swap(list, i, len - i); |
332 | | - } |
333 | 245 | } |
334 | 246 |
|
335 | 247 | }; |
|
0 commit comments