diff options
author | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-12-17 10:43:14 +0100 |
---|---|---|
committer | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-12-17 10:43:14 +0100 |
commit | af95556560f2474ca504218c0a18eef267e7cd16 (patch) | |
tree | 62d91326c8a4542b4588a630802a55cd58fd8c0e /js/build/app.js | |
parent | 86b27436e7845f29a3673cdf8992301e8f865493 (diff) |
add article action plugins
Diffstat (limited to 'js/build/app.js')
-rw-r--r-- | js/build/app.js | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/js/build/app.js b/js/build/app.js index 7b4bc2aa0..7fbe629ea 100644 --- a/js/build/app.js +++ b/js/build/app.js @@ -2300,6 +2300,41 @@ app.service('SettingsResource', ["$http", "BASE_URL", function ($http, BASE_URL) }); }(window, document, $)); +var News = News || {}; + +(function (window, document, $, exports, undefined) { + 'use strict'; + + var articleActionPlugins = []; + var articleActionPluginsById = {}; + + + /** + * @param function action An article action plugin should look like this: + * function (article, baseUrl) { + * this.title = 'A title that is displayed on hover'; + * this.iconUrl = 'An url for the icon'; + * this.onClick = function (event, element) { + * + * }; + * } + */ + exports.addArticleAction = function (action) { + articleActionPlugins.push(action); + articleActionPluginsById[action.id] = action; + }; + + exports.getArticleActionPlugins = function () { + return articleActionPlugins; + }; + + exports.getArticleActionPluginById = function (id) { + return articleActionPluginsById[id]; + }; + +})(window, document, jQuery, News); + + app.run(["$document", "$rootScope", function ($document, $rootScope) { 'use strict'; $document.click(function (event) { @@ -2351,6 +2386,24 @@ app.directive('newsAddFeed', ["$rootScope", "$timeout", function ($rootScope, $t } }; }]); +app.directive('newsArticleActions', function () { + 'use strict'; + return { + restrict: 'E', + templateUrl: 'articleaction.html', + scope: { + 'article': '=' + }, + replace: true, + link: function (scope) { + scope.plugins = News.getArticleActionPlugins(); + scope.pluginClick = function (pluginId, event, article) { + News.getArticleActionPluginById(pluginId) + .onClick(event, article); + }; + } + }; +}); app.directive('newsAutoFocus', ["$timeout", function ($timeout) { 'use strict'; return function (scope, elem, attrs) { |