comparison static/js/markitup/sets/markdown/set.js @ 971:4f265f61874b

Hotlink image form is functioning. The user can now submit a URL via a form and the URL will be downloaded and uploaded to a S3 bucket if it is an image. Tests to follow.
author Brian Neal <bgneal@gmail.com>
date Tue, 22 Sep 2015 20:23:50 -0500
parents 682b159f3763
children 8c3d52b7cbd1
comparison
equal deleted inserted replaced
970:bd594bcba5eb 971:4f265f61874b
177 error: function(xhr, textStatus, ex) { 177 error: function(xhr, textStatus, ex) {
178 alert('Oops, there was an error: ' + ex); 178 alert('Oops, there was an error: ' + ex);
179 } 179 }
180 }); 180 });
181 } 181 }
182
183 var $hotLinkForm = $('#hot-link-form');
184 if ($hotLinkForm.length) {
185 var $postBox = $('#id_body');
186 var $hotLinkFormSubmit = $('#hot-link-form-submit');
187
188 $hotLinkForm.ajaxForm({
189 beforeSubmit: function(arr, $form, options) {
190 var url = null;
191 $.each(arr, function(index, val) {
192 if (val.name == 'url') {
193 url = val.value;
194 }
195 });
196 if (!url) {
197 alert("Please enter an image URL.");
198 return false;
199 }
200 $hotLinkFormSubmit.attr('disabled', 'disabled').val('Retrieving...');
201 return true;
202 },
203 success: function(resp, statusText, xhr, $form) {
204 $postBox.val($postBox.val() + '\n![image](' + resp.url + ')');
205 alert("Success! The image code was added to your post.");
206 $hotLinkForm.clearForm();
207 },
208 complete: function(xhr) {
209 $hotLinkFormSubmit.removeAttr('disabled').val('Hot Link');
210 },
211 error: function(xhr, textStatus, ex) {
212 alert('Oops, there was an error: ' + ex);
213 }
214 });
215 }
182 }); 216 });