diff options
author | Cesar G <prototech91@gmail.com> | 2013-11-27 14:48:38 -0800 |
---|---|---|
committer | Cesar G <prototech91@gmail.com> | 2014-01-17 19:20:36 -0800 |
commit | 9c1cacae42d5d993a004a311089d7ac943002dc5 (patch) | |
tree | 37d96df33f4f91810086c68db2015d673388de80 /phpBB/assets | |
parent | 708622a0bba1656f8538767ab8d0e0260075dddc (diff) | |
download | forums-9c1cacae42d5d993a004a311089d7ac943002dc5.tar forums-9c1cacae42d5d993a004a311089d7ac943002dc5.tar.gz forums-9c1cacae42d5d993a004a311089d7ac943002dc5.tar.bz2 forums-9c1cacae42d5d993a004a311089d7ac943002dc5.tar.xz forums-9c1cacae42d5d993a004a311089d7ac943002dc5.zip |
[ticket/11915] Provide the URL to the attachment when it's uploaded.
PHPBB3-11915
Diffstat (limited to 'phpBB/assets')
-rw-r--r-- | phpBB/assets/javascript/plupload.js | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/phpBB/assets/javascript/plupload.js b/phpBB/assets/javascript/plupload.js index 594b88bae5..d0bf545dbc 100644 --- a/phpBB/assets/javascript/plupload.js +++ b/phpBB/assets/javascript/plupload.js @@ -142,15 +142,17 @@ phpbb.plupload.setData = function(data) { /** * Update the attachment data in the HTML and the phpbb & phpbb.plupload objects. * - * @param array data Array containing the new data to use. - * @param string action The action that required the update. Used to update the inline attachment bbcodes. - * @param int index The index from phpbb.plupload_ids that was affected by the action. + * @param array data Array containing the new data to use. + * @param string action The action that required the update. Used to update the inline attachment bbcodes. + * @param int index The index from phpbb.plupload_ids that was affected by the action. + * @param array downloadUrl Optional array of download urls to update. * @return undefined */ -phpbb.plupload.update = function (data, action, index) { +phpbb.plupload.update = function (data, action, index, downloadUrl) { + phpbb.plupload.updateBbcode(action, index); phpbb.plupload.setData(data); - phpbb.plupload.updateRows(); + phpbb.plupload.updateRows(downloadUrl); phpbb.plupload.clearParams(); phpbb.plupload.updateMultipartParams(phpbb.plupload.getSerializedData()); }; @@ -158,11 +160,12 @@ phpbb.plupload.update = function (data, action, index) { /** * Update the relevant elements and hidden data for all attachments. * + * @param array downloadUrl Optional array of download urls to update. * @return undefined */ -phpbb.plupload.updateRows = function () { +phpbb.plupload.updateRows = function (downloadUrl) { for (var i = 0; i < phpbb.plupload.ids.length; i++) { - phpbb.plupload.updateRow(i); + phpbb.plupload.updateRow(i, downloadUrl); } }; @@ -193,11 +196,21 @@ phpbb.plupload.insertRow = function(file) { * Update the relevant elements and hidden data for an attachment. * * @param int index The index from phpbb.plupload.ids of the attachment to edit. + * @param array downloadUrl Optional array of download urls to update. * @return undefined */ -phpbb.plupload.updateRow = function (index) { - var attach = phpbb.plupload.data[index]; - var row = $('[data-attach-id="' + attach.attach_id + '"]'); +phpbb.plupload.updateRow = function (index, downloadUrl) { + var attach = phpbb.plupload.data[index], + row = $('[data-attach-id="' + attach.attach_id + '"]'); + + // Add the link to the file + if (typeof downloadUrl !== 'undefined' && typeof downloadUrl[index] !== 'undefined') { + var url = downloadUrl[index].replace('&', '&'), + link = $('<a></a>'); + + link.attr('href', url).html(attach.real_filename); + row.find('.file-name').html(link) + } row.find('textarea').attr('name', 'comment_list[' + index + ']'); row.find('.file-inline-bbcode').attr('onclick', 'attach_inline(' + index + ',\'' + attach.real_filename + '\');'); @@ -637,12 +650,12 @@ uploader.bind('FileUploaded', function(up, file, response) { if (typeof error !== 'undefined') { phpbb.plupload.fileError(file, error); } else if (file.status === plupload.DONE) { - file.attachment_data = json[0]; + file.attachment_data = json['data'][0]; row.attr('data-attach-id', file.attachment_data.attach_id); row.find('.file-inline-bbcode').show(); row.find('.file-status').addClass('file-uploaded'); - phpbb.plupload.update(json, 'addition', 0); + phpbb.plupload.update(json['data'], 'addition', 0, [json['download_url']]); } }); |