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;
|
return common;
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
@ -4,6 +4,50 @@ main.mapShareKey = 'map-shares';
|
|||||||
|
|
||||||
main.ga = window.ga || function() {};
|
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' ?
|
var lastCompleted = typeof lastCompleted !== 'undefined' ?
|
||||||
lastCompleted :
|
lastCompleted :
|
||||||
'';
|
'';
|
||||||
@ -38,9 +82,10 @@ function setMapShare(id) {
|
|||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
|
||||||
|
|
||||||
var challengeName = typeof challengeName !== 'undefined' ?
|
var challengeName = typeof challengeName !== 'undefined' ?
|
||||||
challengeName :
|
challengeName :
|
||||||
'Untitled';
|
'';
|
||||||
|
|
||||||
if (challengeName) {
|
if (challengeName) {
|
||||||
ga('send', 'event', 'Challenge', 'load', challengeName);
|
ga('send', 'event', 'Challenge', 'load', challengeName);
|
||||||
|
@ -52,7 +52,7 @@ block content
|
|||||||
label.btn.btn-success#trigger-reset-modal
|
label.btn.btn-success#trigger-reset-modal
|
||||||
i.fa.fa-refresh
|
i.fa.fa-refresh
|
||||||
| Reset
|
| Reset
|
||||||
label.btn.btn-success.js-gitter-toggle-chat-button
|
label.btn.btn-success#challenge-help-btn
|
||||||
i.fa.fa-medkit
|
i.fa.fa-medkit
|
||||||
| Help
|
| Help
|
||||||
label.btn.btn-success#trigger-issue-modal
|
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
|
a.btn.btn-lg.btn-primary.btn-block(href='#', data-dismiss='modal', aria-hidden='true') Cancel
|
||||||
include ../partials/challenge-modals
|
include ../partials/challenge-modals
|
||||||
script.
|
script.
|
||||||
// requires common framework
|
|
||||||
if (window.common) {
|
document.addEventListener('gitter-sidecar-ready', function(e) {
|
||||||
window.common.createGitterOptions('freecodecamp/helpbonfires', 'challenge-help-chat-btn');
|
if (window.main) {
|
||||||
}
|
window.main.chat.createHelpChat('freecodecamp/helpbonfires', '#challenge-help-btn');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
var MDNlinks = !{JSON.stringify(MDNlinks)};
|
var MDNlinks = !{JSON.stringify(MDNlinks)};
|
||||||
if (!MDNlinks.length) {
|
if (!MDNlinks.length) {
|
||||||
$('#MDN-links').addClass('collapse');
|
$('#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
|
label.btn.btn-success#trigger-reset-modal
|
||||||
i.fa.fa-refresh
|
i.fa.fa-refresh
|
||||||
| Reset
|
| Reset
|
||||||
label.btn.btn-success.js-gitter-toggle-chat-button
|
label.btn.btn-success#challenge-help-btn
|
||||||
i.fa.fa-medkit
|
i.fa.fa-medkit
|
||||||
| Help
|
| Help
|
||||||
label.btn.btn-success#trigger-issue-modal
|
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
|
a.btn.btn-lg.btn-primary.btn-block(href='/challenges/next-challenge?id=' + challengeId) Go to my next challenge
|
||||||
include ../partials/challenge-modals
|
include ../partials/challenge-modals
|
||||||
script.
|
script.
|
||||||
// requires common framework
|
document.addEventListener('gitter-sidecar-ready', function(e) {
|
||||||
if (window.common) {
|
if (window.main) {
|
||||||
window.common.createGitterOptions('freecodecamp/help');
|
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
|
label.btn.btn-success#trigger-reset-modal
|
||||||
i.fa.fa-refresh
|
i.fa.fa-refresh
|
||||||
| Reset
|
| Reset
|
||||||
label.btn.btn-success.js-gitter-toggle-chat-button
|
label.btn.btn-success#challenge-help-btn
|
||||||
i.fa.fa-medkit
|
i.fa.fa-medkit
|
||||||
| Help
|
| Help
|
||||||
label.btn.btn-success#trigger-issue-modal
|
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
|
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
|
include ../partials/challenge-modals
|
||||||
script.
|
script.
|
||||||
// requires common framework
|
|
||||||
if (window.common) {
|
|
||||||
window.common.createGitterOptions('freecodecamp/help');
|
|
||||||
}
|
|
||||||
var MDNlinks = !{JSON.stringify(MDNlinks)};
|
var MDNlinks = !{JSON.stringify(MDNlinks)};
|
||||||
if (!MDNlinks.length) {
|
if (!MDNlinks.length) {
|
||||||
$('#MDN-links').addClass('collapse');
|
$('#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(src=rev('/js', 'commonFramework.js'))
|
||||||
script.
|
script.
|
||||||
var common = window.common || { init: [] };
|
var common = window.common || { init: [] };
|
||||||
common.createGitterOptions('freecodecamp/help');
|
|
||||||
common.challengeId = !{JSON.stringify(challengeId)};
|
common.challengeId = !{JSON.stringify(challengeId)};
|
||||||
common.challengeName = !{JSON.stringify(name)};
|
common.challengeName = !{JSON.stringify(name)};
|
||||||
common.challengeType = 7;
|
common.challengeType = 7;
|
||||||
@ -41,4 +40,3 @@ block content
|
|||||||
common.isFrontEndCert = !{JSON.stringify(isFrontEndCert || false)};
|
common.isFrontEndCert = !{JSON.stringify(isFrontEndCert || false)};
|
||||||
common.isFullStackCert = !{JSON.stringify(isFullStackCert || false)};
|
common.isFullStackCert = !{JSON.stringify(isFullStackCert || false)};
|
||||||
common.challengeSeed = !{JSON.stringify(challengeSeed || [])};
|
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;
|
var userLoggedIn = true;
|
||||||
.button-spacer
|
.button-spacer
|
||||||
.btn-group.input-group.btn-group-justified
|
.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
|
i.fa.fa-medkit
|
||||||
| Get help
|
| Get help
|
||||||
.btn.btn-success.btn-big#trigger-issue-modal
|
.btn.btn-success.btn-big#trigger-issue-modal
|
||||||
@ -78,8 +78,10 @@ block content
|
|||||||
var challenge_Name = !{JSON.stringify(name)};
|
var challenge_Name = !{JSON.stringify(name)};
|
||||||
var challengeType = !{JSON.stringify(challengeType)};
|
var challengeType = !{JSON.stringify(challengeType)};
|
||||||
var dashedName = !{JSON.stringify(dashedName)};
|
var dashedName = !{JSON.stringify(dashedName)};
|
||||||
if (window.common) {
|
document.addEventListener('gitter-sidecar-ready', function(e) {
|
||||||
window.common.createGitterOptions('freecodecamp/help');
|
if (window.main) {
|
||||||
}
|
window.main.chat.createHelpChat('freecodecamp/help', '#challenge-help-btn');
|
||||||
|
}
|
||||||
|
});
|
||||||
include ../partials/challenge-modals
|
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)
|
a.btn.btn-big.btn-primary.btn-block(href='/challenges/next-challenge?id=' + challengeId) Go to my next challenge (ctrl + enter)
|
||||||
.button-spacer
|
.button-spacer
|
||||||
.btn-group.input-group.btn-group-justified
|
.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
|
i.fa.fa-medkit
|
||||||
| Help
|
| Help
|
||||||
.btn.btn-success.btn-big#trigger-issue-modal
|
.btn.btn-success.btn-big#trigger-issue-modal
|
||||||
@ -97,11 +97,13 @@ block content
|
|||||||
$('body').on('keypress', controlEnterHandler);
|
$('body').on('keypress', controlEnterHandler);
|
||||||
include ../partials/challenge-modals
|
include ../partials/challenge-modals
|
||||||
script.
|
script.
|
||||||
if (window.common) {
|
document.addEventListener('gitter-sidecar-ready', function(e) {
|
||||||
window.common.createGitterOptions(
|
if (window.main) {
|
||||||
!{JSON.stringify(challengeType)} === 3 ?
|
window.main.chat.createHelpChat(
|
||||||
'freecodecamp/helpZiplines' :
|
!{JSON.stringify(challengeType)} === 3 ?
|
||||||
'freecodecamp/helpBonfires'
|
'freecodecamp/helpZiplines' :
|
||||||
);
|
'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
|
span.sr-only Free Code Camp on Twitter
|
||||||
a.ion-locked(href="//github.com/FreeCodeCamp/freecodecamp/wiki/Free-Code-Camp's-Privacy-Policy")
|
a.ion-locked(href="//github.com/FreeCodeCamp/freecodecamp/wiki/Free-Code-Camp's-Privacy-Policy")
|
||||||
span.sr-only 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
|
li
|
||||||
a(href='/map') Map
|
a(href='/map') Map
|
||||||
li
|
li
|
||||||
a(href='//gitter.im/FreeCodeCamp/FreeCodeCamp', target='_blank') Chat
|
a#nav-chat-btn(href='#' onclick="return false") Chat
|
||||||
li
|
li
|
||||||
a(href='/news', target='_blank') News
|
a(href='/news', target='_blank') News
|
||||||
li
|
li
|
||||||
|
Reference in New Issue
Block a user