74 lines
2.5 KiB
JavaScript
74 lines
2.5 KiB
JavaScript
/**
|
|
* HelpBubble helper functions, for help bubbles with lots of arguments or logic
|
|
*/
|
|
(function (context, $) {
|
|
|
|
"use strict";
|
|
|
|
context.JK = context.JK || {};
|
|
var helpBubble = {};
|
|
var rest = new context.JK.Rest();
|
|
context.JK.HelpBubbleHelper = helpBubble;
|
|
var logger = context.JK.logger;
|
|
|
|
var defaultScoreBreakDownOptions = {positions: ['right', 'top', 'bottom', 'left'], width:'600px', closeWhenOthersOpen: true };
|
|
helpBubble.scoreBreakdown = function($element, isCurrentUser, full_score, myAudioLatency, otherAudioLatency, internetScore, options) {
|
|
options = options || {};
|
|
options = $.extend({}, defaultScoreBreakDownOptions, options)
|
|
if(isCurrentUser) {
|
|
context.JK.helpBubble($element, 'musician-score-self',
|
|
{full_score: full_score ? Math.round(full_score / 2) : null, my_gear_latency: myAudioLatency, their_gear_latency: otherAudioLatency, internet_latency: internetScore},
|
|
options);
|
|
} else {
|
|
context.JK.helpBubble($element, 'musician-score-count',
|
|
{full_score: full_score ? Math.round(full_score / 2) : null, my_gear_latency: myAudioLatency, their_gear_latency: otherAudioLatency, internet_latency: internetScore},
|
|
options);
|
|
}
|
|
}
|
|
|
|
function bigHelpOptions(options) {
|
|
return {positions: options.positions, offsetParent: options.offsetParent,
|
|
spikeGirth: 15,
|
|
spikeLength: 20,
|
|
fill: 'white',
|
|
cornerRadius:8,
|
|
strokeWidth: 2,
|
|
cssStyles: {
|
|
fontWeight:'bold',
|
|
fontSize: '20px',
|
|
backgroundColor:'transparent',
|
|
color:'#ed3618'}}
|
|
}
|
|
|
|
function jamTrackGuide(callback) {
|
|
if(gon.isNativeClient) {
|
|
context.JK.app.user().done(function(user) {
|
|
if(user.show_jamtrack_guide) {
|
|
setTimeout(function() {
|
|
callback()
|
|
}, 1000)
|
|
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
helpBubble.jamtrackGuideTile = function ($element, $offsetParent) {
|
|
jamTrackGuide(function() {
|
|
context.JK.prodBubble($element, 'jamtrack-guide-tile', {}, bigHelpOptions({positions:['top'], offsetParent: $offsetParent}))
|
|
})
|
|
}
|
|
|
|
helpBubble.jamtrackGuidePrivate = function ($element, $offsetParent) {
|
|
jamTrackGuide(function() {
|
|
context.JK.prodBubble($element, 'jamtrack-guide-private', {}, bigHelpOptions({positions:['right'], offsetParent: $offsetParent}))
|
|
})
|
|
}
|
|
|
|
helpBubble.jamtrackGuideSession = function ($element, $offsetParent) {
|
|
jamTrackGuide(function() {
|
|
context.JK.prodBubble($element, 'jamtrack-guide-session', {}, bigHelpOptions({positions:['left'], offsetParent: $offsetParent}))
|
|
})
|
|
}
|
|
|
|
})(window, jQuery); |