Commit c1862e35771103c5c9b6f7b85712a9a105e2e4f8

Authored by Antonio Terceiro
1 parent 6fd3cea8

When uploading, add images directly to the text

Showing 1 changed file with 7 additions and 3 deletions   Show diff stats
public/javascripts/article.js
@@ -39,7 +39,7 @@ jQuery(function($) { @@ -39,7 +39,7 @@ jQuery(function($) {
39 return '<a class="button icon-zoom zoom" href="#" title="' + button_zoom + '"><span>' + button_zoom + '</span></a>'; 39 return '<a class="button icon-zoom zoom" href="#" title="' + button_zoom + '"><span>' + button_zoom + '</span></a>';
40 } 40 }
41 41
42 - function list_items(items, selector) { 42 + function list_items(items, selector, auto_add) {
43 var html_for_items = ''; 43 var html_for_items = '';
44 44
45 var images = []; 45 var images = [];
@@ -71,6 +71,10 @@ jQuery(function($) { @@ -71,6 +71,10 @@ jQuery(function($) {
71 }); 71 });
72 72
73 $(selector).html(html_for_items); 73 $(selector).html(html_for_items);
  74 +
  75 + if (auto_add) {
  76 + $(selector).find('a.add-to-text').click();
  77 + }
74 } 78 }
75 79
76 $('.controls a.add-to-text').live('click', function() { 80 $('.controls a.add-to-text').live('click', function() {
@@ -118,7 +122,7 @@ jQuery(function($) { @@ -118,7 +122,7 @@ jQuery(function($) {
118 var $button = $(this); 122 var $button = $(this);
119 $('#media-search-box .header').toggleClass('icon-loading'); 123 $('#media-search-box .header').toggleClass('icon-loading');
120 $.get($(this).parent().attr('action'), { 'q': query }, function(data) { 124 $.get($(this).parent().attr('action'), { 'q': query }, function(data) {
121 - list_items(data, '#media-search-results .items'); 125 + list_items(data, '#media-search-results .items', false);
122 if (data.length && data.length > 0) { 126 if (data.length && data.length > 0) {
123 $('#media-search-results').slideDown(); 127 $('#media-search-results').slideDown();
124 } 128 }
@@ -137,7 +141,7 @@ jQuery(function($) { @@ -137,7 +141,7 @@ jQuery(function($) {
137 }, 141 },
138 success: 142 success:
139 function(data) { 143 function(data) {
140 - list_items(data, '#media-upload-results .items'); 144 + list_items(data, '#media-upload-results .items', true);
141 if (data.length && data.length > 0) { 145 if (data.length && data.length > 0) {
142 $('#media-upload-results').slideDown(); 146 $('#media-upload-results').slideDown();
143 } 147 }