From 03f94480e76c8ac90bd403ee25b0e0b2aedafcfa Mon Sep 17 00:00:00 2001 From: Brian Smith Date: Tue, 31 Mar 2015 22:32:41 -0400 Subject: [PATCH] VRFS-2701 wip adding recording sources --- .../javascripts/accounts_profile_samples.js | 28 ++++----- .../javascripts/site_validator.js.coffee | 3 + .../client/accountProfileSamples.css.scss | 6 +- .../clients/_account_profile_samples.html.erb | 58 +++++++++++-------- 4 files changed, 53 insertions(+), 42 deletions(-) diff --git a/web/app/assets/javascripts/accounts_profile_samples.js b/web/app/assets/javascripts/accounts_profile_samples.js index 97a83ed51..e884d3549 100644 --- a/web/app/assets/javascripts/accounts_profile_samples.js +++ b/web/app/assets/javascripts/accounts_profile_samples.js @@ -25,18 +25,12 @@ var $twitterUsername = $screen.find('#twitter-username'); // performance samples - var $soundCloudRecordingUrl = $screen.find('#soundcloud-recording'); - var $youTubeVideoUrl = $screen.find('#youtube-video'); - var $jamkazamSampleList = $screen.find('.samples.jamkazam'); var $soundCloudSampleList = $screen.find('.samples.soundcloud'); var $youTubeSampleList = $screen.find('.samples.youtube'); // buttons var $btnAddJkRecording = $screen.find('#btn-add-jk-recording'); - var $btnAddSoundCloudRecording = $screen.find('#btn-add-soundcloud-recording'); - var $btnAddYouTubeVideo = $screen.find('#btn-add-youtube-video'); - var $btnCancel = $screen.find('#account-edit-profile-cancel'); var $btnBack = $screen.find('#account-edit-profile-back'); var $btnSubmit = $screen.find('#account-edit-profile-submit'); @@ -102,7 +96,7 @@ // JamKazam recordings var samples = profileUtils.jamkazamSamples(user.performance_samples); - if (samples) { + if (samples && samples.length > 0) { $.each(samples, function(index, val) { }); @@ -110,7 +104,7 @@ // SoundCloud recordings samples = profileUtils.soundCloudSamples(user.performance_samples); - if (samples) { + if (samples && samples.length > 0) { $.each(samples, function(index, val) { }); @@ -118,9 +112,9 @@ // YouTube videos samples = profileUtils.youTubeSamples(user.performance_samples); - if (samples) { + if (samples && samples.length > 0) { $.each(samples, function(index, val) { - + }); } } @@ -200,13 +194,13 @@ addPerformanceSamples(ps, $soundCloudSampleList, performanceSampleTypes.SOUNDCLOUD.description); addPerformanceSamples(ps, $youTubeSampleList, performanceSampleTypes.YOUTUBE.description); - // api.updateUser({ - // website: $website.val(), - // online_presences: op, - // performance_samples: ps - // }) - // .done(postUpdateProfileSuccess) - // .fail(postUpdateProfileFailure); + api.updateUser({ + website: $website.val(), + online_presences: op, + performance_samples: ps + }) + .done(postUpdateProfileSuccess) + .fail(postUpdateProfileFailure); } function postUpdateProfileSuccess(response) { diff --git a/web/app/assets/javascripts/site_validator.js.coffee b/web/app/assets/javascripts/site_validator.js.coffee index fc54465dd..a17bbd565 100644 --- a/web/app/assets/javascripts/site_validator.js.coffee +++ b/web/app/assets/javascripts/site_validator.js.coffee @@ -174,3 +174,6 @@ context.JK.RecordingSourceValidator = class RecordingSourceValidator extends Sit src_data['url'] == url 0 < vals.length + recordingSources: () => + @recording_sources + diff --git a/web/app/assets/stylesheets/client/accountProfileSamples.css.scss b/web/app/assets/stylesheets/client/accountProfileSamples.css.scss index dfe7bc128..11b3bb704 100644 --- a/web/app/assets/stylesheets/client/accountProfileSamples.css.scss +++ b/web/app/assets/stylesheets/client/accountProfileSamples.css.scss @@ -31,8 +31,10 @@ } } - .sample-list { - height: inherit; + div.sample-list { + height: 250px; + width: 250px; + border: 2px solid #ccc; overflow: auto; } } diff --git a/web/app/views/clients/_account_profile_samples.html.erb b/web/app/views/clients/_account_profile_samples.html.erb index 79e63f5ae..35c61d4ee 100644 --- a/web/app/views/clients/_account_profile_samples.html.erb +++ b/web/app/views/clients/_account_profile_samples.html.erb @@ -74,21 +74,18 @@
+
-
+

- - - - - -
Test RecordingX
+  
+
@@ -98,14 +95,10 @@
- - - - - -
Test RecordingX
+  
+
@@ -115,22 +108,18 @@
- - - - - -
Test RecordingX
+  
+


- CANCEL   - BACK   + CANCEL  + BACK  SAVE & FINISH
@@ -152,6 +141,12 @@ } initialized = true; + 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'); + setTimeout(function() { window.urlValidator = new JK.SiteValidator('url', userNameSuccessCallback, userNameFailCallback); urlValidator.init(); @@ -177,13 +172,30 @@ window.twitterValidator = new JK.SiteValidator('twitter', userNameSuccessCallback, userNameFailCallback); twitterValidator.init(); - window.soundCloudRecordingValidator = new JK.SiteValidator('rec_soundcloud', userNameSuccessCallback, userNameFailCallback); + window.soundCloudRecordingValidator = new JK.SiteValidator('rec_soundcloud', siteSuccessCallback, siteFailCallback); soundCloudRecordingValidator.init(); - window.youTubeRecordingValidator = new JK.SiteValidator('rec_youtube', userNameSuccessCallback, userNameFailCallback); + window.youTubeRecordingValidator = new JK.SiteValidator('rec_youtube', siteSuccessCallback, siteFailCallback); youTubeRecordingValidator.init(); }, 1); + $btnAddSoundCloudRecording.click(function(evt) { + evt.preventDefault(); + console.log("IN ADD"); + if (!$('#rec_soundcloud_validator').hasClass('error')) { + console.log("NO ERROR"); + var recordingSources = [];//window.soundCloudRecordingValidator.recordingSources(); + console.log("recordingSources=%o", recordingSources); + if (recordingSources && recordingSources.length > 0) { + var $sampleList = $soundCloudSampleList.find('.sample-list'); + var addedRecording = recordingSources[recordingSources.length-1]; + $sampleList.append('
'); + $sampleList.append(addedRecording.url); + $sampleList.append('
'); + } + } + }); + function userNameSuccessCallback($inputDiv) { $inputDiv.removeClass('error'); $inputDiv.find('.error-text').remove();