diff options
author | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-05-23 20:19:06 +0200 |
---|---|---|
committer | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-05-23 20:19:06 +0200 |
commit | 0b22611a929fc317c6ad073d2ddf5f198ee836f3 (patch) | |
tree | ca3593e76af10dc6a81ed0412c6d0e6434f73331 /js | |
parent | 94e24c1e1a53db60e6924b39ad308b6b2d2e8c2b (diff) |
more boilerplate
Diffstat (limited to 'js')
-rw-r--r-- | js/build/app.js | 91 | ||||
-rw-r--r-- | js/controller/ContentController.js | 11 | ||||
-rw-r--r-- | js/controller/NavigationController.js | 7 | ||||
-rw-r--r-- | js/directive/NewsAutoFocus.js | 17 | ||||
-rw-r--r-- | js/tests/unit/controller/NavigationControllerSpec.js | 12 |
5 files changed, 66 insertions, 72 deletions
diff --git a/js/build/app.js b/js/build/app.js index 180bde700..fe71d10fb 100644 --- a/js/build/app.js +++ b/js/build/app.js @@ -199,13 +199,23 @@ var $__build_47_app__ = function () { this.keepUnread = function (itemId) { console.log(itemId); }; + this.isContentView = function () { + console.log('tbd'); + }; + this.orderBy = function () { + console.log('tbd'); + }; + this.getRelativeDate = function (timestamp) { + console.log(timestamp); + }; } ]); app.controller('NavigationController', [ 'FeedResource', 'FolderResource', 'ItemResource', - function (FeedResource, FolderResource, ItemResource) { + 'SettingsResource', + function (FeedResource, FolderResource, ItemResource, SettingsResource) { 'use strict'; this.getFeeds = function () { return FeedResource.getAll(); @@ -234,6 +244,9 @@ var $__build_47_app__ = function () { ItemResource.markRead(); FeedResource.markRead(); }; + this.isShowAll = function () { + return SettingsResource.get('showAll'); + }; this.createFeed = function () { console.log('TBD'); }; @@ -882,22 +895,6 @@ var $__build_47_app__ = function () { } }); }(window, document, jQuery)); - (function (window, document, $) { - 'use strict'; - $(document).ready(function () { - var buttons = $(':not([data-app-slide-toggle-area=""])'); - $(document).click(function (event) { - buttons.each(function (index, button) { - console.log(button); - var area = $(button).data('app-slide-toggle-area'); - if (button === event.target) { - console.log(area); - event.stopPropagation(); - } - }); - }); - }); - }(window, document, jQuery)); var call = Function.prototype.call.bind(Function.prototype.call); var hasOwn = Object.prototype.hasOwnProperty; window.items = function (obj) { @@ -1161,6 +1158,12 @@ var $__build_47_app__ = function () { writable: true }), $__2; }; + app.directive('newsAutoFocus', function () { + 'use strict'; + return function (scope, elem, attrs) { + $(attrs.newsAutofocus).focus(); + }; + }); app.directive('newsBindHtmlUnsafe', function () { 'use strict'; return function (scope, elem, attr) { @@ -1276,60 +1279,6 @@ var $__build_47_app__ = function () { }; } ]); - app.directive('newsSlideUp', [ - '$rootScope', - '$document', - function ($rootScope, $document) { - 'use strict'; - return function (scope, elem, attr) { - var slideArea = elem; - var cssClass = false; - var options = scope.$eval(attr.newsSlideUp); - if (options) { - if (options.selector) { - slideArea = $(options.selector); - } - if (options.cssClass) { - cssClass = options.cssClass; - } - if (options.hideOnFocusLost) { - $($document[0].body).click(function () { - $rootScope.$broadcast('newsSlideUp'); - }); - $rootScope.$on('newsSlideUp', function (scope, params) { - if (params !== slideArea && slideArea.is(':visible') && !slideArea.is(':animated')) { - slideArea.slideUp(); - if (cssClass) { - elem.removeClass(cssClass); - } - } - }); - slideArea.click(function (event) { - $rootScope.$broadcast('newsSlideUp', slideArea); - event.stopPropagation(); - }); - elem.click(function (event) { - $rootScope.$broadcast('newsSlideUp', slideArea); - event.stopPropagation(); - }); - } - } - elem.click(function () { - if (slideArea.is(':visible') && !slideArea.is(':animated')) { - slideArea.slideUp(); - if (cssClass) { - elem.removeClass(cssClass); - } - } else { - slideArea.slideDown(); - if (cssClass) { - elem.addClass(cssClass); - } - } - }); - }; - } - ]); app.directive('newsTooltip', function () { 'use strict'; return function (scope, elem) { diff --git a/js/controller/ContentController.js b/js/controller/ContentController.js index 9edac534f..9258b3f11 100644 --- a/js/controller/ContentController.js +++ b/js/controller/ContentController.js @@ -37,4 +37,15 @@ function (Publisher, FeedResource, ItemResource, data) { console.log(itemId); }; + this.isContentView = () => { + console.log('tbd'); + }; + + this.orderBy = () => { + console.log('tbd'); + }; + + this.getRelativeDate = (timestamp) => { + console.log(timestamp); + }; });
\ No newline at end of file diff --git a/js/controller/NavigationController.js b/js/controller/NavigationController.js index 299d433da..08443191b 100644 --- a/js/controller/NavigationController.js +++ b/js/controller/NavigationController.js @@ -8,7 +8,7 @@ * @copyright Bernhard Posselt 2014 */ app.controller('NavigationController', -function (FeedResource, FolderResource, ItemResource) { +function (FeedResource, FolderResource, ItemResource, SettingsResource) { 'use strict'; this.getFeeds = () => { @@ -37,6 +37,10 @@ function (FeedResource, FolderResource, ItemResource) { FeedResource.markRead(); }; + this.isShowAll = () => { + return SettingsResource.get('showAll'); + }; + // TBD this.createFeed = () => { console.log('TBD'); @@ -74,4 +78,5 @@ function (FeedResource, FolderResource, ItemResource) { console.log('TBD'); }; + });
\ No newline at end of file diff --git a/js/directive/NewsAutoFocus.js b/js/directive/NewsAutoFocus.js new file mode 100644 index 000000000..a66f4453c --- /dev/null +++ b/js/directive/NewsAutoFocus.js @@ -0,0 +1,17 @@ +/** + * ownCloud - News + * + * This file is licensed under the Affero General Public License version 3 or + * later. See the COPYING file. + * + * @author Bernhard Posselt <dev@bernhard-posselt.com> + * @copyright Bernhard Posselt 2014 + */ +app.directive('newsAutoFocus', () => { + 'use strict'; + + return (scope, elem, attrs) => { + $(attrs.newsAutofocus).focus(); + }; + +});
\ No newline at end of file diff --git a/js/tests/unit/controller/NavigationControllerSpec.js b/js/tests/unit/controller/NavigationControllerSpec.js index 4d4e4bb10..653dfea26 100644 --- a/js/tests/unit/controller/NavigationControllerSpec.js +++ b/js/tests/unit/controller/NavigationControllerSpec.js @@ -100,4 +100,16 @@ describe('NavigationController', () => { expect(FeedResource.markRead).toHaveBeenCalled(); expect(ItemResource.markRead).toHaveBeenCalled(); })); + + + it('should mark all read', inject((SettingsResource, $controller) => { + let ctrl = $controller('NavigationController', { + SettingsResource: SettingsResource, + }); + + SettingsResource.set('showAll', true); + + expect(ctrl.isShowAll()).toBe(true); + + })); });
\ No newline at end of file |