summaryrefslogtreecommitdiffstats
path: root/js/plugin/ArticleActionPlugin.js
blob: 3602471e519edd0baf32da179d24b4e771f44f40 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
window.News = window.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, window.News);