From 6fd3cea87ec366ee66d96d359ab8cbaeabd9223d Mon Sep 17 00:00:00 2001 From: Antonio Terceiro Date: Thu, 12 Jul 2012 10:57:54 -0300 Subject: [PATCH] Adding images to the text from the zoom dialog --- public/javascripts/article.js | 44 +++++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/public/javascripts/article.js b/public/javascripts/article.js index 206d98f..cc7727f 100644 --- a/public/javascripts/article.js +++ b/public/javascripts/article.js @@ -27,12 +27,16 @@ jQuery(function($) { var button_add = $('.text-editor-sidebar meta[name=button.add]').attr('value'); var button_zoom = $('.text-editor-sidebar meta[name=button.zoom]').attr('value'); - function add_to_text_button(item) { - return '' + button_add + ''; + function add_to_text_button() { + return '' + button_add + ''; } - function zoom_button(item) { - return '' + button_zoom + '/span>'; + function add_to_text_link() { + return '' + button_add + ''; + } + + function zoom_button() { + return '' + button_zoom + ''; } function list_items(items, selector) { @@ -55,11 +59,11 @@ jQuery(function($) { }); $.each(images, function(i, item) { - html_for_items += '
' + add_to_text_button(item) + zoom_button(item) + '
'; + html_for_items += '
' + add_to_text_button() + zoom_button() + '
'; }); $.each(files, function(i, item) { - html_for_items += '
' + item.title + '
' + add_to_text_button(item) + '
'; + html_for_items += '
' + item.title + '
' + add_to_text_button() + '
'; }); $.each(errors, function(i, item) { @@ -67,21 +71,23 @@ jQuery(function($) { }); $(selector).html(html_for_items); - $(selector).find('.controls a.icon-add').click(function() { - var $item = $(this).closest('.item'); - var html_selector = $item.attr('data-item'); - insert_item_in_text($item.find(html_selector)); - return false; - }); - $(selector).find('.controls a.icon-zoom').click(function() { - var $item = $(this).closest('.item'); - var html_selector = $item.attr('data-item'); - var img = $item.find(html_selector).find('img').attr('src'); - $.colorbox({ html: '', maxWidth: '640px', maxHeight: '640px', scrolling: false }); - return false; - }); } + $('.controls a.add-to-text').live('click', function() { + var $item = $(this).closest('.item'); + var html_selector = $item.attr('data-item'); + insert_item_in_text($item.find(html_selector)); + $.colorbox.close(); + return false; + }); + $('.controls a.zoom').live('click', function() { + var $item = $(this).closest('.item'); + var html_selector = $item.attr('data-item'); + var img = $item.find(html_selector).find('img').attr('src'); + $.colorbox({ html: '
' + '
' + add_to_text_link() + '
', maxWidth: '640px', maxHeight: '670px', scrolling: false }); + return false; + }); + // FIXME the user may also want to add the item to the abstract textarea! var text_field = 'article_body'; -- libgit2 0.21.2