|
9 | 9 | $rootScope.deviceHeight = window.innerHeight; |
10 | 10 | $rootScope.deviceWidth = window.innerWidth || 320; |
11 | 11 |
|
| 12 | + var _path = $location.path(); |
| 13 | + $scope.first = true; |
| 14 | + /** |
| 15 | + * @name handleBookmarkNav |
| 16 | + * @type {function} |
| 17 | + * Handles incoming bookmark navigation |
| 18 | + */ |
12 | 19 | var handleBookmarkNav = function handleBookmarkNav() { |
13 | | - buildfire.deeplink.getData(function(data){ |
14 | | - if(data && data.link){ |
15 | | - var targetGuid = data.link; |
16 | | - var itemLinks = _items.map(item => item.guid); |
17 | | - var index = itemLinks.indexOf(targetGuid); |
18 | | - if (index < 0) { |
19 | | - console.warn('bookmarked item not found.'); |
20 | | - } else { |
21 | | - WidgetHome.goToItem(index, _items[index]); |
| 20 | + if ($scope.first) { |
| 21 | + buildfire.deeplink.getData(function(data){ |
| 22 | + if(data && data.link){ |
| 23 | + var targetGuid = data.link; |
| 24 | + var itemLinks = _items.map(item => item.guid); |
| 25 | + var index = itemLinks.indexOf(targetGuid); |
| 26 | + if (index < 0) { |
| 27 | + console.warn('bookmarked item not found.'); |
| 28 | + } else { |
| 29 | + if (data.timeIndex) { |
| 30 | + _items[index].seekTo = data.timeIndex; |
| 31 | + } |
| 32 | + $rootScope.deeplinkFirstNav = true; |
| 33 | + WidgetHome.goToItem(index, _items[index]); |
| 34 | + } |
| 35 | + $scope.first = false; |
| 36 | + if (!$scope.$$phase) $scope.$apply(); |
22 | 37 | } |
23 | | - } |
24 | | - }); |
| 38 | + }); |
| 39 | + } |
25 | 40 | }; |
26 | 41 |
|
27 | 42 | /** |
28 | 43 | * Private variables |
29 | 44 | * |
30 | | - * _items used to hold RSS feed items and helps in lazy loading. |
| 45 | + * @name _items used to hold RSS feed items and helps in lazy loading. |
31 | 46 | * @type {object} |
32 | 47 | * @private |
33 | 48 | * |
34 | | - * limit used to load a number of items in list on scroll |
| 49 | + * @name limit used to load a number of items in list on scroll |
35 | 50 | * @type {number} |
36 | 51 | * @private |
37 | 52 | * |
38 | | - * chunkData used to hold chunks of _items. |
| 53 | + * @name chunkData used to hold chunks of _items. |
39 | 54 | * @type {object} |
40 | 55 | * @private |
41 | 56 | * |
42 | | - * nextChunkDataIndex used to hold index of next chunk. |
| 57 | + * @name nextChunkDataIndex used to hold index of next chunk. |
43 | 58 | * @type {number} |
44 | 59 | * @private |
45 | 60 | * |
46 | | - * nextChunk used to hold chunk based on nextChunkDataIndex token. |
| 61 | + * @name nextChunk used to hold chunk based on nextChunkDataIndex token. |
47 | 62 | * @type {object} |
48 | 63 | * @private |
49 | 64 | * |
50 | | - * totalChunks used to hold number of available chunks i.e. chunkData.length. |
| 65 | + * @name totalChunks used to hold number of available chunks i.e. chunkData.length. |
51 | 66 | * @type {number} |
52 | 67 | * @private |
53 | 68 | * |
54 | | - * currentRssUrl used to hold previously saved rss url. |
| 69 | + * @name currentRssUrl used to hold previously saved rss url. |
55 | 70 | * @type {string} |
56 | 71 | * @private |
57 | 72 | * |
|
81 | 96 | } |
82 | 97 | }; |
83 | 98 |
|
84 | | - /* |
85 | | - * WidgetHome.data is used to hold user's data object which used throughout the app. |
| 99 | + /** |
| 100 | + * @name WidgetHome.data is used to hold user's data object which used throughout the app. |
86 | 101 | * @type {object} |
87 | 102 | */ |
88 | 103 | WidgetHome.data = null; |
89 | 104 | WidgetHome.view=null; |
90 | 105 |
|
91 | | - /* |
92 | | - * WidgetHome.items is used to listing items. |
| 106 | + /** |
| 107 | + * @name WidgetHome.items is used to listing items. |
93 | 108 | * @type {object} |
94 | 109 | */ |
95 | 110 | WidgetHome.items = []; |
96 | 111 |
|
97 | | - /* |
98 | | - * WidgetHome.busy is used to disable ng-infinite scroll when more data not available to show. |
| 112 | + /** |
| 113 | + * @name WidgetHome.busy is used to disable ng-infinite scroll when more data not available to show. |
99 | 114 | * @type {boolean} |
100 | 115 | */ |
101 | 116 | WidgetHome.busy = false; |
102 | 117 |
|
103 | | - /* |
104 | | - * WidgetHome.isItems is used to show info message when _items.length == 0. |
| 118 | + /** |
| 119 | + * @name WidgetHome.isItems is used to show info message when _items.length == 0. |
105 | 120 | * @type {boolean} |
106 | 121 | */ |
107 | 122 | WidgetHome.isItems = true; |
108 | 123 |
|
109 | 124 | $rootScope.showFeed = true; |
110 | 125 |
|
111 | 126 | /** |
112 | | - * resetDefaults() private method |
| 127 | + * @name resetDefaults() |
113 | 128 | * Used to reset default values |
| 129 | + * @private |
114 | 130 | */ |
115 | 131 | var resetDefaults = function () { |
116 | 132 | chunkData = null; |
|
123 | 139 | WidgetHome.isItems = true; |
124 | 140 | ItemDetailsService.setData(null); |
125 | 141 | }; |
126 | | - |
| 142 | + |
127 | 143 | /** |
128 | | - * getImageUrl() private method |
| 144 | + * @name getImageUrl() |
129 | 145 | * Used to extract image url |
130 | 146 | * @param item |
131 | 147 | * @returns {*} |
|
161 | 177 | }; |
162 | 178 |
|
163 | 179 | /** |
164 | | - * getFeedData() private method |
| 180 | + * @name getFeedData() |
| 181 | + * @private |
165 | 182 | * used to fetch RSS feed Data object if a valid RSS feed url provided |
166 | 183 | * @param rssUrl |
167 | 184 | */ |
|
187 | 204 | handleBookmarkNav(); |
188 | 205 | Buildfire.spinner.hide(); |
189 | 206 | isInit = false; |
| 207 | + searchEngine.indexFeed(rssUrl); |
190 | 208 | } |
191 | 209 | , error = function (err) { |
192 | 210 | Buildfire.spinner.hide(); |
|
196 | 214 | }; |
197 | 215 |
|
198 | 216 | /** |
199 | | - * onUpdateCallback() private method |
| 217 | + * @name onUpdateCallback() |
| 218 | + * @private |
200 | 219 | * Will be called when DataStore.onUpdate() have been made. |
201 | 220 | * @param event |
202 | 221 | */ |
|
228 | 247 | }; |
229 | 248 |
|
230 | 249 | /** |
231 | | - * init() private function |
| 250 | + * @name init() |
| 251 | + * @private |
232 | 252 | * It is used to fetch previously saved user's data |
233 | 253 | */ |
234 | 254 | var init = function () { |
|
266 | 286 | }; |
267 | 287 |
|
268 | 288 | /** |
269 | | - * init() function invocation to fetch previously saved user's data from datastore. |
| 289 | + * @name init() function invocation to fetch previously saved user's data from datastore. |
270 | 290 | */ |
271 | 291 | init(); |
272 | 292 |
|
273 | 293 | /** |
274 | | - * DataStore.onUpdate() will invoked when there is some change in datastore |
| 294 | + * @name DataStore.onUpdate() will invoked when there is some change in datastore |
275 | 295 | */ |
276 | 296 | DataStore.onUpdate().then(null, null, onUpdateCallback); |
277 | 297 |
|
278 | 298 | /** |
279 | | - * WidgetHome.showDescription() method |
| 299 | + * @name WidgetHome.showDescription() method |
280 | 300 | * will be called to check whether the description have text to show or no. |
281 | 301 | * @param description |
282 | 302 | * @returns {boolean} |
|
291 | 311 | }; |
292 | 312 |
|
293 | 313 | /** |
294 | | - * WidgetHome.getTitle() method |
| 314 | + * @name WidgetHome.getTitle() method |
295 | 315 | * Will used to extract item title |
296 | 316 | * @param item |
297 | 317 | * @returns {item.title|*} |
|
312 | 332 | }; |
313 | 333 |
|
314 | 334 | /** |
315 | | - * WidgetHome.getItemSummary() method |
| 335 | + * @name WidgetHome.getItemSummary() method |
316 | 336 | * Will used to extract item summary |
317 | 337 | * @param item |
318 | 338 | * @returns {*} |
|
327 | 347 | }; |
328 | 348 |
|
329 | 349 | /** |
330 | | - * WidgetHome.getItemPublishDate() method |
| 350 | + * @name WidgetHome.getItemPublishDate() method |
331 | 351 | * Will used to extract item published date |
332 | 352 | * @param item |
333 | 353 | * @returns {*} |
|
344 | 364 | }; |
345 | 365 |
|
346 | 366 | /** |
347 | | - * WidgetHome.goToItem() method |
| 367 | + * @name WidgetHome.goToItem() method |
348 | 368 | * will used to redirect on details page |
349 | 369 | * @param index |
350 | 370 | */ |
351 | 371 | WidgetHome.goToItem = function (index, item) { |
352 | | - viewedItems.markViewed($scope, item.link) |
| 372 | + viewedItems.markViewed($scope, item.guid) |
353 | 373 | if (WidgetHome.items[index]) { |
354 | 374 | WidgetHome.items[index].index = index; |
355 | 375 | } |
|
362 | 382 |
|
363 | 383 | WidgetHome.bookmark = function ($event, item) { |
364 | 384 | $event.stopImmediatePropagation(); |
365 | | - const isBookmarked = item.bookmarked ? true : false; |
| 385 | + var isBookmarked = item.bookmarked ? true : false; |
366 | 386 | if (isBookmarked) { |
367 | 387 | bookmarks.delete($scope, item); |
368 | 388 | } else { |
|
373 | 393 | WidgetHome.share = function ($event, item) { |
374 | 394 | $event.stopImmediatePropagation(); |
375 | 395 |
|
376 | | - const options = { |
| 396 | + var options = { |
377 | 397 | subject: item.title, |
378 | | - text: `${item.title}, by ${item.author}`, |
| 398 | + text: item.title + ", by " + item.author, |
379 | 399 | // image: item.image.url, |
380 | 400 | link: item.link |
381 | 401 | }; |
382 | 402 |
|
383 | | - const callback = err => { |
| 403 | + var callback = function(err) { |
384 | 404 | if (err) { |
385 | 405 | console.warn(err); |
386 | 406 | } |
|
389 | 409 | buildfire.device.share(options, callback); |
390 | 410 | }; |
391 | 411 |
|
392 | | - |
393 | | - const initAuthUpdate = () => { |
394 | | - Buildfire.auth.onLogin(() => { |
| 412 | + var initAuthUpdate = function () { |
| 413 | + Buildfire.auth.onLogin(function () { |
395 | 414 | init(); |
396 | 415 | }); |
397 | | - |
398 | | - Buildfire.auth.onLogout(() => { |
| 416 | + |
| 417 | + Buildfire.auth.onLogout(function () { |
399 | 418 | init(); |
400 | 419 | }); |
401 | 420 | }; |
402 | 421 |
|
403 | 422 | /** |
404 | | - * WidgetHome.loadMore() function |
| 423 | + * @name WidgetHome.loadMore() function |
405 | 424 | * will used to load more items on scroll to implement lazy loading |
406 | 425 | */ |
407 | 426 | WidgetHome.loadMore = function () { |
|
0 commit comments