VRFS-3325 : Re-enable change to allow multiple of the widget for online presence and performance samples.
This commit is contained in:
parent
9980aef982
commit
fe9e604d70
|
|
@ -4,9 +4,9 @@
|
|||
|
||||
context.JK = context.JK || {};
|
||||
|
||||
// TODO: Add a target type, which can be band or user -- call the
|
||||
// appropriate API methods.
|
||||
context.JK.AccountProfileSamples = function(app) {
|
||||
// Using loadFn & updateFn, this can be used to render online
|
||||
// presences and performance samples for both users and bands:
|
||||
context.JK.AccountProfileSamples = function(app, parent, loadFn, updateFn) {
|
||||
var $document = $(document)
|
||||
|
||||
// used to initialize RecordingSourceValidator in site_validator.js.coffee
|
||||
|
|
@ -20,8 +20,6 @@
|
|||
var ui = new context.JK.UIHelper(JK.app);
|
||||
var target = {};
|
||||
var profileUtils = context.JK.ProfileUtils;
|
||||
var parent = $(".account-profile-samples")
|
||||
|
||||
var $screen = $('.profile-online-sample-controls', parent);
|
||||
// online presences
|
||||
var $website = $screen.find('.website');
|
||||
|
|
@ -60,8 +58,11 @@
|
|||
}
|
||||
|
||||
function afterShow(data) {
|
||||
api.getUserProfile().done(function(targetPlayer) {
|
||||
$.when(loadFn())
|
||||
.done(function(targetPlayer) {
|
||||
if (targetPlayer && targetPlayer.keys && targetPlayer.keys.length > 0) {
|
||||
renderPlayer(targetPlayer)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -146,29 +147,24 @@
|
|||
if (samples && samples.length > 0) {
|
||||
$.each(samples, function(index, val) {
|
||||
|
||||
var source = {
|
||||
recordingSources.push({
|
||||
'url': val.url,
|
||||
'recording_id': val.service_id,
|
||||
'recording_title': val.description
|
||||
}
|
||||
recordingSources.push(source);
|
||||
buildNonJamKazamEntry($sampleList, type, source);
|
||||
});
|
||||
|
||||
// TODO: this code is repeated in HTML file
|
||||
var recordingIdAttr = ' data-recording-id="' + val.service_id + '" ';
|
||||
var recordingUrlAttr = ' data-recording-url="' + val.url + '" ';
|
||||
var recordingTitleAttr = ' data-recording-title="' + val.description + '"';
|
||||
var title = formatTitle(val.description);
|
||||
$sampleList.append('<div class="clearall recording-row left entry"' + recordingIdAttr + recordingUrlAttr + recordingTitleAttr + '>' + title + '</div>');
|
||||
$sampleList.append('<div class="right close-button" data-recording-type="' + type + '"' + recordingIdAttr + '>X</div>');
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function buildNonJamKazamEntry($sampleList, type, source) {
|
||||
// TODO: this code is repeated in HTML file
|
||||
var recordingIdAttr = ' data-recording-id="' + source.recording_id + '" ';
|
||||
var recordingUrlAttr = ' data-recording-url="' + source.url + '" ';
|
||||
var recordingTitleAttr = ' data-recording-title="' + source.recording_title + '"';
|
||||
var title = formatTitle(source.recording_title);
|
||||
$sampleList.find(".empty").addClass("hidden")
|
||||
$sampleList.append('<div class="clearall recording-row left entry"' + recordingIdAttr + recordingUrlAttr + recordingTitleAttr + '>' + title + '</div>');
|
||||
$sampleList.append('<div class="right close-button" data-recording-type="' + type + '"' + recordingIdAttr + '>X</div>');
|
||||
}
|
||||
|
||||
function buildJamkazamEntry(recordingId, recordingName) {
|
||||
var title = formatTitle(recordingName);
|
||||
|
||||
|
|
@ -183,7 +179,10 @@
|
|||
$btnAddJkRecording.click(function(evt) {
|
||||
evt.preventDefault();
|
||||
|
||||
ui.launchRecordingSelectorDialog(jamkazamRecordingSources, function(selectedRecordings) {
|
||||
// retrieve recordings and pass to modal dialog
|
||||
api.getClaimedRecordings()
|
||||
.done(function(response) {
|
||||
ui.launchRecordingSelectorDialog(response, jamkazamRecordingSources, function(selectedRecordings) {
|
||||
$jamkazamSampleList.empty();
|
||||
|
||||
jamkazamRecordingSources = [];
|
||||
|
|
@ -198,7 +197,7 @@
|
|||
buildJamkazamEntry(val.id, val.name);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
|
|
@ -288,7 +287,7 @@
|
|||
disableSubmits()
|
||||
|
||||
var player = buildPlayer()
|
||||
api.updateUser({
|
||||
updateFn({
|
||||
website: player.website,
|
||||
online_presences: player.online_presences,
|
||||
performance_samples: player.performance_samples
|
||||
|
|
@ -317,13 +316,8 @@
|
|||
addPerformanceSamples(ps, $soundCloudSampleList, performanceSampleTypes.SOUNDCLOUD.description);
|
||||
addPerformanceSamples(ps, $youTubeSampleList, performanceSampleTypes.YOUTUBE.description);
|
||||
|
||||
var website = $website.val()
|
||||
if (website == '') {
|
||||
website = null;
|
||||
}
|
||||
|
||||
return {
|
||||
website: website,
|
||||
website: $website.val(),
|
||||
online_presences: op,
|
||||
performance_samples: ps
|
||||
}
|
||||
|
|
@ -369,7 +363,7 @@
|
|||
// refactor:
|
||||
function initializeValidators() {
|
||||
var initialized = false;
|
||||
//$document.on('JAMKAZAM_READY', function(e, data) {
|
||||
$document.on('JAMKAZAM_READY', function(e, data) {
|
||||
JK.JamServer.get$Server().on(JK.EVENTS.CONNECTION_UP, function() {
|
||||
if(initialized) {
|
||||
return;
|
||||
|
|
@ -434,8 +428,8 @@
|
|||
siteSuccessCallback($inputDiv, youTubeRecordingValidator, $youTubeSampleList, 'youtube');
|
||||
}
|
||||
|
||||
function siteSuccessCallback($inputDiv, recordingSiteValidator, $sampleList, type) {
|
||||
$sampleList.find(".empty").addClass("hidden")
|
||||
function siteSuccessCallback($inputDiv, recordingSiteValidator, sampleList, type) {
|
||||
sampleList.find(".empty").addClass("hidden")
|
||||
$inputDiv.removeClass('error');
|
||||
$inputDiv.find('.error-text').remove();
|
||||
|
||||
|
|
@ -443,7 +437,13 @@
|
|||
if (recordingSources && recordingSources.length > 0) {
|
||||
var addedRecording = recordingSources[recordingSources.length-1];
|
||||
|
||||
buildNonJamKazamEntry($sampleList, type, addedRecording);
|
||||
// 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('<div class="clearall recording-row left entry"' + recordingIdAttr + recordingUrlAttr + recordingTitleAttr + '>' + title + '</div>');
|
||||
sampleList.append('<div class="right close-button" data-recording-type="' + type + '"' + recordingIdAttr + '>X</div>');
|
||||
}
|
||||
|
||||
$inputDiv.find('input').val('');
|
||||
|
|
@ -455,7 +455,7 @@
|
|||
$inputDiv.append("<span class='error-text'>Invalid URL</span>").show();
|
||||
}
|
||||
});
|
||||
//});
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -240,8 +240,8 @@
|
|||
var accountProfileInterests = new JK.AccountProfileInterests(JK.app);
|
||||
accountProfileInterests.initialize();
|
||||
|
||||
var accountProfileSamples = new JK.AccountProfileSamples(JK.app)
|
||||
accountProfileSamples.initialize();
|
||||
var accountProfileSamples = new JK.AccountProfileSamples(JK.app, $(".account-profile-samples"), api.getUserProfile, api.updateUser)
|
||||
accountProfileSamples.initialize()
|
||||
|
||||
var accountAudioProfile = new JK.AccountAudioProfile(JK.app);
|
||||
accountAudioProfile.initialize();
|
||||
|
|
|
|||
Loading…
Reference in New Issue