Add main chat window on nav bar chat click
This commit is contained in:
@ -49,14 +49,6 @@ var common = (function() {
|
||||
});
|
||||
};
|
||||
|
||||
// this will overwrite if gitter object is already present
|
||||
common.createGitterOptions = function createGitterOptions(room) {
|
||||
((window.gitter = {}).chat = {}).options = {
|
||||
room: room,
|
||||
activationElement: document.createElement('div')
|
||||
};
|
||||
};
|
||||
|
||||
return common;
|
||||
})();
|
||||
|
||||
|
@ -4,6 +4,50 @@ main.mapShareKey = 'map-shares';
|
||||
|
||||
main.ga = window.ga || function() {};
|
||||
|
||||
main = (function(main) {
|
||||
|
||||
((window.gitter = {}).chat = {}).options = {
|
||||
disableDefaultChat: true
|
||||
};
|
||||
// wait for sidecar to load
|
||||
|
||||
main.chat = {};
|
||||
main.chat.isOpen = false;
|
||||
main.chat.createHelpChat = function createHelpChat() {
|
||||
throw new Error('Sidecar chat has not initialized');
|
||||
};
|
||||
|
||||
document.addEventListener('gitter-sidecar-ready', function(e) {
|
||||
main.chat.GitterChat = e.detail.Chat;
|
||||
|
||||
main.chat.createHelpChat = function(room, helpChatBtnClass) {
|
||||
main.chat.helpChat = new main.chat.GitterChat({
|
||||
room: room,
|
||||
activationElement: document.createElement('div')
|
||||
});
|
||||
|
||||
$(helpChatBtnClass).on('click', function() {
|
||||
main.chat.helpChat.toggleChat(true);
|
||||
});
|
||||
};
|
||||
|
||||
main.chat.mainChat = new main.chat.GitterChat({
|
||||
room: 'freecodecamp/freecodecamp',
|
||||
activationElement: document.createElement('div')
|
||||
});
|
||||
|
||||
$('#nav-chat-btn').on('click', function() {
|
||||
console.log('Create');
|
||||
if (!main.chat.isOpen) {
|
||||
|
||||
main.chat.mainChat.toggleChat(true);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
return main;
|
||||
}(main));
|
||||
|
||||
var lastCompleted = typeof lastCompleted !== 'undefined' ?
|
||||
lastCompleted :
|
||||
'';
|
||||
@ -38,9 +82,10 @@ function setMapShare(id) {
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
|
||||
var challengeName = typeof challengeName !== 'undefined' ?
|
||||
challengeName :
|
||||
'Untitled';
|
||||
'';
|
||||
|
||||
if (challengeName) {
|
||||
ga('send', 'event', 'Challenge', 'load', challengeName);
|
||||
|
@ -52,7 +52,7 @@ block content
|
||||
label.btn.btn-success#trigger-reset-modal
|
||||
i.fa.fa-refresh
|
||||
| Reset
|
||||
label.btn.btn-success.js-gitter-toggle-chat-button
|
||||
label.btn.btn-success#challenge-help-btn
|
||||
i.fa.fa-medkit
|
||||
| Help
|
||||
label.btn.btn-success#trigger-issue-modal
|
||||
@ -122,13 +122,14 @@ block content
|
||||
a.btn.btn-lg.btn-primary.btn-block(href='#', data-dismiss='modal', aria-hidden='true') Cancel
|
||||
include ../partials/challenge-modals
|
||||
script.
|
||||
// requires common framework
|
||||
if (window.common) {
|
||||
window.common.createGitterOptions('freecodecamp/helpbonfires', 'challenge-help-chat-btn');
|
||||
|
||||
document.addEventListener('gitter-sidecar-ready', function(e) {
|
||||
if (window.main) {
|
||||
window.main.chat.createHelpChat('freecodecamp/helpbonfires', '#challenge-help-btn');
|
||||
}
|
||||
});
|
||||
|
||||
var MDNlinks = !{JSON.stringify(MDNlinks)};
|
||||
if (!MDNlinks.length) {
|
||||
$('#MDN-links').addClass('collapse');
|
||||
}
|
||||
script(src="https://sidecar.gitter.im/dist/sidecar.v1.js" async defer)
|
||||
|
@ -38,7 +38,7 @@ block content
|
||||
label.btn.btn-success#trigger-reset-modal
|
||||
i.fa.fa-refresh
|
||||
| Reset
|
||||
label.btn.btn-success.js-gitter-toggle-chat-button
|
||||
label.btn.btn-success#challenge-help-btn
|
||||
i.fa.fa-medkit
|
||||
| Help
|
||||
label.btn.btn-success#trigger-issue-modal
|
||||
@ -96,8 +96,8 @@ block content
|
||||
a.btn.btn-lg.btn-primary.btn-block(href='/challenges/next-challenge?id=' + challengeId) Go to my next challenge
|
||||
include ../partials/challenge-modals
|
||||
script.
|
||||
// requires common framework
|
||||
if (window.common) {
|
||||
window.common.createGitterOptions('freecodecamp/help');
|
||||
document.addEventListener('gitter-sidecar-ready', function(e) {
|
||||
if (window.main) {
|
||||
window.main.chat.createHelpChat('freecodecamp/help', '#challenge-help-btn');
|
||||
}
|
||||
script(src="https://sidecar.gitter.im/dist/sidecar.v1.js" async defer)
|
||||
});
|
||||
|
@ -43,7 +43,7 @@ block content
|
||||
label.btn.btn-success#trigger-reset-modal
|
||||
i.fa.fa-refresh
|
||||
| Reset
|
||||
label.btn.btn-success.js-gitter-toggle-chat-button
|
||||
label.btn.btn-success#challenge-help-btn
|
||||
i.fa.fa-medkit
|
||||
| Help
|
||||
label.btn.btn-success#trigger-issue-modal
|
||||
@ -98,12 +98,12 @@ block content
|
||||
a.animated.fadeIn.btn.btn-lg.btn-primary.btn-block(href='/challenges/next-challenge?id=' + challengeId) Go to my next challenge
|
||||
include ../partials/challenge-modals
|
||||
script.
|
||||
// requires common framework
|
||||
if (window.common) {
|
||||
window.common.createGitterOptions('freecodecamp/help');
|
||||
}
|
||||
var MDNlinks = !{JSON.stringify(MDNlinks)};
|
||||
if (!MDNlinks.length) {
|
||||
$('#MDN-links').addClass('collapse');
|
||||
}
|
||||
script(src="https://sidecar.gitter.im/dist/sidecar.v1.js" async defer)
|
||||
document.addEventListener('gitter-sidecar-ready', function(e) {
|
||||
if (window.main) {
|
||||
window.main.chat.createHelpChat('freecodecamp/help', '#challenge-help-btn');
|
||||
}
|
||||
});
|
||||
|
@ -32,7 +32,6 @@ block content
|
||||
script(src=rev('/js', 'commonFramework.js'))
|
||||
script.
|
||||
var common = window.common || { init: [] };
|
||||
common.createGitterOptions('freecodecamp/help');
|
||||
common.challengeId = !{JSON.stringify(challengeId)};
|
||||
common.challengeName = !{JSON.stringify(name)};
|
||||
common.challengeType = 7;
|
||||
@ -41,4 +40,3 @@ block content
|
||||
common.isFrontEndCert = !{JSON.stringify(isFrontEndCert || false)};
|
||||
common.isFullStackCert = !{JSON.stringify(isFullStackCert || false)};
|
||||
common.challengeSeed = !{JSON.stringify(challengeSeed || [])};
|
||||
script(src="https://sidecar.gitter.im/dist/sidecar.v1.js" async defer)
|
||||
|
@ -24,7 +24,7 @@ block content
|
||||
var userLoggedIn = true;
|
||||
.button-spacer
|
||||
.btn-group.input-group.btn-group-justified
|
||||
.btn.btn-success.btn-big.js-gitter-toggle-chat-button
|
||||
.btn.btn-success.btn-big#challenge-help-btn
|
||||
i.fa.fa-medkit
|
||||
| Get help
|
||||
.btn.btn-success.btn-big#trigger-issue-modal
|
||||
@ -78,8 +78,10 @@ block content
|
||||
var challenge_Name = !{JSON.stringify(name)};
|
||||
var challengeType = !{JSON.stringify(challengeType)};
|
||||
var dashedName = !{JSON.stringify(dashedName)};
|
||||
if (window.common) {
|
||||
window.common.createGitterOptions('freecodecamp/help');
|
||||
document.addEventListener('gitter-sidecar-ready', function(e) {
|
||||
if (window.main) {
|
||||
window.main.chat.createHelpChat('freecodecamp/help', '#challenge-help-btn');
|
||||
}
|
||||
});
|
||||
include ../partials/challenge-modals
|
||||
script(src="https://sidecar.gitter.im/dist/sidecar.v1.js" async defer)
|
||||
|
||||
|
@ -24,7 +24,7 @@ block content
|
||||
a.btn.btn-big.btn-primary.btn-block(href='/challenges/next-challenge?id=' + challengeId) Go to my next challenge (ctrl + enter)
|
||||
.button-spacer
|
||||
.btn-group.input-group.btn-group-justified
|
||||
.btn.btn-success.btn-big.js-gitter-toggle-chat-button
|
||||
.btn.btn-success.btn-big#challenge-help-btn
|
||||
i.fa.fa-medkit
|
||||
| Help
|
||||
.btn.btn-success.btn-big#trigger-issue-modal
|
||||
@ -97,11 +97,13 @@ block content
|
||||
$('body').on('keypress', controlEnterHandler);
|
||||
include ../partials/challenge-modals
|
||||
script.
|
||||
if (window.common) {
|
||||
window.common.createGitterOptions(
|
||||
document.addEventListener('gitter-sidecar-ready', function(e) {
|
||||
if (window.main) {
|
||||
window.main.chat.createHelpChat(
|
||||
!{JSON.stringify(challengeType)} === 3 ?
|
||||
'freecodecamp/helpZiplines' :
|
||||
'freecodecamp/helpBonfires'
|
||||
'freecodecamp/helpBonfires',
|
||||
'#challenge-help-btn'
|
||||
);
|
||||
}
|
||||
script(src="https://sidecar.gitter.im/dist/sidecar.v1.js" async defer)
|
||||
});
|
||||
|
@ -22,3 +22,6 @@
|
||||
span.sr-only Free Code Camp on Twitter
|
||||
a.ion-locked(href="//github.com/FreeCodeCamp/freecodecamp/wiki/Free-Code-Camp's-Privacy-Policy")
|
||||
span.sr-only Free Code Camp's Privacy Policy
|
||||
|
||||
// scripts should be moved here
|
||||
script(src="https://sidecar.gitter.im/dist/sidecar.v1.js" async defer)
|
||||
|
@ -12,7 +12,7 @@ nav.navbar.navbar-default.navbar-fixed-top.nav-height
|
||||
li
|
||||
a(href='/map') Map
|
||||
li
|
||||
a(href='//gitter.im/FreeCodeCamp/FreeCodeCamp', target='_blank') Chat
|
||||
a#nav-chat-btn(href='#' onclick="return false") Chat
|
||||
li
|
||||
a(href='/news', target='_blank') News
|
||||
li
|
||||
|
Reference in New Issue
Block a user