diff options
| author | 2014-02-22 16:53:51 -0500 | |
|---|---|---|
| committer | 2014-02-22 17:03:36 -0500 | |
| commit | 27764b36353b3066a9e92da2a96ac17b546295be (patch) | |
| tree | e95e6dada362a45ef8d920fbe954ae1dd9c5b899 /p/scripts | |
| parent | 7313f9f3a306d16fac78ab587e3055482398ceac (diff) | |
Improve sharing
Previously, the share page can handle only a limited number of shares and only one of each type.
Now the configuration has been change to be more flexible and allows an unlimited number of shares.
The share description is located in an array and the share configuration is stored along with the
user configuration.
Note: I tried to include the specific javascript code in a separate file but I did not succeded to
import it.
Diffstat (limited to 'p/scripts')
| -rw-r--r-- | p/scripts/main.js | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/p/scripts/main.js b/p/scripts/main.js index beb77a19c..ec27bd50c 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -1,6 +1,7 @@ "use strict"; var $stream = null, - isCollapsed = true; + isCollapsed = true, + shares = 0; function is_normal_mode() { return $stream.hasClass('normal'); @@ -945,7 +946,7 @@ function init_confirm_action() { } function init_print_action() { - $('.print-article').click(function () { + $('.item.share > a[href="#"]').click(function () { var content = "<html><head><style>" + "body { font-family: Serif; text-align: justify; }" + "a { color: #000; text-decoration: none; }" @@ -965,6 +966,27 @@ function init_print_action() { }); } +function init_share_observers() { + shares = $('.form-group:not(".form-actions")').length; + + $('.post').on('click', '.share.remove', function(e){ + e.preventDefault(); + $(this).parents('.form-group').remove(); + }); + + $('.share.add').on('click',function(e){ + e.preventDefault(); + var opt = $(this).siblings('select').find(':selected'); + var row = $(this).parents('form').data(opt.data('form')); + row = row.replace('##label##', opt.html(), 'g'); + row = row.replace('##type##', opt.val(), 'g'); + row = row.replace('##help##', opt.data('help'), 'g'); + row = row.replace('##key##', shares, 'g'); + $(this).parents('.form-actions').before(row); + shares++; + }); +}; + function init_all() { if (!(window.$ && window.url_freshrss && ((!full_lazyload) || $.fn.lazyload))) { if (window.console) { @@ -994,6 +1016,8 @@ function init_all() { init_shortcuts(); init_print_action(); window.setInterval(refreshUnreads, 120000); + } else { + init_share_observers(); } if (window.console) { |
