Skip to content

Commit

Permalink
Prevent the #media_url from being overridden
Browse files Browse the repository at this point in the history
There is a race between the upload js and the js to set the `#media_url` from the add media form (`#url`).  We should only ever set the value of `#media_url` with `#url` IFF it is NOT an upload.  Otherwise, we could upload the video, set the `#media_url` with the uploaded url and then the rest of the script would execute and set the `#media_url` to null, because a `#url` was never provided.
  • Loading branch information
mfairchild365 committed Nov 18, 2013
1 parent 90a0fe1 commit cb58e61
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions www/templates/html/scripts/mediaDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ WDN.jQuery(document).ready(function() {
});

WDN.jQuery("#mediaSubmit").click(function (event) { //called when a user adds video

var isUpload = false;

if (document.getElementById("file_upload").value == '') {
if (!mediaDetails.validURL(document.getElementById("url").value)) {
return false;
Expand All @@ -141,6 +142,7 @@ WDN.jQuery(document).ready(function() {
event.preventDefault();

} else {
isUpload = true;
// Hide the url field, user is uploading a file
WDN.jQuery('#media_url').closest('li').hide();
}
Expand All @@ -151,7 +153,12 @@ WDN.jQuery(document).ready(function() {
WDN.jQuery("#headline_main").slideDown(400, function () {
WDN.jQuery("#media_form").show().css({"width": "930px"}).parent("#formDetails").removeClass("two_col right");
WDN.jQuery("#existing_media, #enhanced_header, #feedSelect, #maincontent form.zenform #continue3").slideDown(400);
//WDN.jQuery("#media_url").attr("value", WDN.jQuery("#url").val());

//set the url if this is not an upload.
if (!isUpload) {
WDN.jQuery("#media_url").attr("value", WDN.jQuery("#url").val());
}

WDN.jQuery(this).css('display', 'inline-block');
});
});
Expand Down

0 comments on commit cb58e61

Please sign in to comment.