Commit 6fd3cea87ec366ee66d96d359ab8cbaeabd9223d
1 parent
431ec85f
Exists in
master
and in
29 other branches
Adding images to the text from the zoom dialog
Showing
1 changed file
with
25 additions
and
19 deletions
Show diff stats
public/javascripts/article.js
... | ... | @@ -27,12 +27,16 @@ jQuery(function($) { |
27 | 27 | var button_add = $('.text-editor-sidebar meta[name=button.add]').attr('value'); |
28 | 28 | var button_zoom = $('.text-editor-sidebar meta[name=button.zoom]').attr('value'); |
29 | 29 | |
30 | - function add_to_text_button(item) { | |
31 | - return '<a class="button icon-add" data-item-url="' + item.url + '" href="#"><span>' + button_add + '</span></span>'; | |
30 | + function add_to_text_button() { | |
31 | + return '<a class="button icon-add add-to-text" href="#"><span>' + button_add + '</span></a>'; | |
32 | 32 | } |
33 | 33 | |
34 | - function zoom_button(item) { | |
35 | - return '<a class="button icon-zoom" href="#" title="' + button_zoom + '"><span>' + button_zoom + '/span></a>'; | |
34 | + function add_to_text_link() { | |
35 | + return '<a class="add-to-text" href="#">' + button_add + '</a>'; | |
36 | + } | |
37 | + | |
38 | + function zoom_button() { | |
39 | + return '<a class="button icon-zoom zoom" href="#" title="' + button_zoom + '"><span>' + button_zoom + '</span></a>'; | |
36 | 40 | } |
37 | 41 | |
38 | 42 | function list_items(items, selector) { |
... | ... | @@ -55,11 +59,11 @@ jQuery(function($) { |
55 | 59 | }); |
56 | 60 | |
57 | 61 | $.each(images, function(i, item) { |
58 | - html_for_items += '<div class="item image" data-item="span"><span><img src="' + item.url + '"/></span><div class="controls image-controls">' + add_to_text_button(item) + zoom_button(item) + '</div></div>'; | |
62 | + html_for_items += '<div class="item image" data-item="span"><span><img src="' + item.url + '"/></span><div class="controls image-controls">' + add_to_text_button() + zoom_button() + '</div></div>'; | |
59 | 63 | }); |
60 | 64 | |
61 | 65 | $.each(files, function(i, item) { |
62 | - html_for_items += '<div class="item file ' + item.icon + '" data-item="div"><div><a href="' + item.url + '">' + item.title + '</a></div> <div class="controls file-controls">' + add_to_text_button(item) + '</div></div>'; | |
66 | + html_for_items += '<div class="item file ' + item.icon + '" data-item="div"><div><a href="' + item.url + '">' + item.title + '</a></div> <div class="controls file-controls">' + add_to_text_button() + '</div></div>'; | |
63 | 67 | }); |
64 | 68 | |
65 | 69 | $.each(errors, function(i, item) { |
... | ... | @@ -67,21 +71,23 @@ jQuery(function($) { |
67 | 71 | }); |
68 | 72 | |
69 | 73 | $(selector).html(html_for_items); |
70 | - $(selector).find('.controls a.icon-add').click(function() { | |
71 | - var $item = $(this).closest('.item'); | |
72 | - var html_selector = $item.attr('data-item'); | |
73 | - insert_item_in_text($item.find(html_selector)); | |
74 | - return false; | |
75 | - }); | |
76 | - $(selector).find('.controls a.icon-zoom').click(function() { | |
77 | - var $item = $(this).closest('.item'); | |
78 | - var html_selector = $item.attr('data-item'); | |
79 | - var img = $item.find(html_selector).find('img').attr('src'); | |
80 | - $.colorbox({ html: '<img src="' + img + '" style="max-width: 580px; max-height: 580px"/>', maxWidth: '640px', maxHeight: '640px', scrolling: false }); | |
81 | - return false; | |
82 | - }); | |
83 | 74 | } |
84 | 75 | |
76 | + $('.controls a.add-to-text').live('click', function() { | |
77 | + var $item = $(this).closest('.item'); | |
78 | + var html_selector = $item.attr('data-item'); | |
79 | + insert_item_in_text($item.find(html_selector)); | |
80 | + $.colorbox.close(); | |
81 | + return false; | |
82 | + }); | |
83 | + $('.controls a.zoom').live('click', function() { | |
84 | + var $item = $(this).closest('.item'); | |
85 | + var html_selector = $item.attr('data-item'); | |
86 | + var img = $item.find(html_selector).find('img').attr('src'); | |
87 | + $.colorbox({ html: '<div class="item" data-item="div"><div><img src="' + img + '" style="max-width: 580px; max-height: 580px"/></div>' + '<div class="controls" style="padding-top: 5px;">' + add_to_text_link() + '</div></div>', maxWidth: '640px', maxHeight: '670px', scrolling: false }); | |
88 | + return false; | |
89 | + }); | |
90 | + | |
85 | 91 | // FIXME the user may also want to add the item to the abstract textarea! |
86 | 92 | var text_field = 'article_body'; |
87 | 93 | ... | ... |