diff --git a/web/app/assets/javascripts/accounts_profile_samples.js b/web/app/assets/javascripts/accounts_profile_samples.js index 30cd85c20..4ba0afd28 100644 --- a/web/app/assets/javascripts/accounts_profile_samples.js +++ b/web/app/assets/javascripts/accounts_profile_samples.js @@ -32,9 +32,9 @@ var $twitterUsername = $screen.find('.twitter-username'); // performance samples - var $jamkazamSampleList = $screen.find('.samples.jamkazam').find('.sample-list'); - var $soundCloudSampleList = $screen.find('.samples.soundcloud').find('.sample-list'); - var $youTubeSampleList = $screen.find('.samples.youtube').find('.sample-list'); + var $jamkazamSampleList = $screen.find(".sample-list[source-type='jamkazam']") + var $soundCloudSampleList = $screen.find(".sample-list[source-type='soundcloud']") + var $youTubeSampleList = $screen.find(".sample-list[source-type='youtube']") // buttons var $btnAddJkRecording = $screen.find('.btn-add-jk-recording'); @@ -51,7 +51,7 @@ if (targetPlayer && targetPlayer.keys && targetPlayer.keys.length > 0) { renderPlayer(targetPlayer) } - }); + }) } function renderPlayer(targetPlayer) { @@ -120,7 +120,7 @@ } function loadSamples(samples, type, $sampleList, recordingSources) { - $sampleList.empty(); + $sampleList.empty(); if (type === 'jamkazam') { $.each(samples, function(index, val) { @@ -131,8 +131,7 @@ buildJamkazamEntry(val.claimed_recording.id, val.claimed_recording.name); }); - } - else { + } else { if (samples && samples.length > 0) { $.each(samples, function(index, val) { @@ -208,6 +207,9 @@ }); enableSubmits(); + + $(".sample-list .close-button", $screen).on("click", function(e) { + } } function enableSubmits() { @@ -257,9 +259,7 @@ 'service_type': type, 'claimed_recording_id': id, }); - } - - else { + } else { var url = $(this).attr('data-recording-url'); var title = $(this).attr('data-recording-title'); @@ -325,14 +325,19 @@ if(xhr.status == 422) { - } - else { + } else { app.ajaxError(xhr, textStatus, errorMessage) } } function removeRow(recordingId, type) { $('div[data-recording-id=' + recordingId + ']').remove(); + var sampleList = $('.sample-list[source-type="' + type + '"]') + var rowCnt = sampleList.find('.recording-row').length + + if (rowCnt==0) { + sampleList.find(".empty").removeClass("hidden") + } if (type === 'soundcloud') { window.soundCloudRecordingValidator.removeRecordingId(recordingId); @@ -361,10 +366,11 @@ //var $screen = $('#account-profile-samples'); var $btnAddSoundCloudRecording = $screen.find('.btn-add-soundcloud-recording'); var $btnAddYouTubeVideo = $screen.find('.btn-add-youtube-video'); - var $soundCloudSampleList = $screen.find('.samples.soundcloud'); - var $youTubeSampleList = $screen.find('.samples.youtube'); + // var $soundCloudSampleList = $screen.find('.samples.soundcloud'); + // var $youTubeSampleList = $screen.find('.samples.youtube'); + - setTimeout(function() { + setTimeout(function() { window.urlValidator = new JK.SiteValidator('url', userNameSuccessCallback, userNameFailCallback, parent); window.urlValidator.init(); @@ -390,7 +396,7 @@ window.twitterValidator.init(); window.soundCloudRecordingValidator = new JK.RecordingSourceValidator('rec_soundcloud', soundCloudSuccessCallback, siteFailCallback, parent); - logger.debug("window.soundCloudRecordingValidator", window.soundCloudRecordingValidator) + logger.debug("window.soundCloudRecordingValidator", window.soundCloudRecordingValidator, parent) window.youTubeRecordingValidator = new JK.RecordingSourceValidator('rec_youtube', youTubeSuccessCallback, siteFailCallback, parent); $document.triggerHandler('INIT_SITE_VALIDATORS'); @@ -408,7 +414,7 @@ $inputDiv.append("Invalid username").show(); } - function soundCloudSuccessCallback($inputDiv) { + function soundCloudSuccessCallback($inputDiv) { siteSuccessCallback($inputDiv, window.soundCloudRecordingValidator, $soundCloudSampleList, 'soundcloud'); } @@ -416,24 +422,24 @@ siteSuccessCallback($inputDiv, window.youTubeRecordingValidator, $youTubeSampleList, 'youtube'); } - function siteSuccessCallback($inputDiv, recordingSiteValidator, $sampleList, type) { + function siteSuccessCallback($inputDiv, recordingSiteValidator, sampleList, type) { + sampleList.find(".empty").addClass("hidden") $inputDiv.removeClass('error'); $inputDiv.find('.error-text').remove(); var recordingSources = recordingSiteValidator.recordingSources(); if (recordingSources && recordingSources.length > 0) { - var $sampleList = $sampleList.find('.sample-list'); var addedRecording = recordingSources[recordingSources.length-1]; - // TODO: this code is repeated in JS file + // TODO: this code is repeated in elsewhere in this JS file: var recordingIdAttr = ' data-recording-id="' + addedRecording.recording_id + '" '; var recordingUrlAttr = ' data-recording-url="' + addedRecording.url + '" '; var recordingTitleAttr = ' data-recording-title="' + addedRecording.recording_title + '"'; var title = formatTitle(addedRecording.recording_title); - $sampleList.append('