From 062990851a23484ee41a12b3137a4dcda5558752 Mon Sep 17 00:00:00 2001 From: Matt Lott Date: Wed, 21 Sep 2016 10:19:52 -0700 Subject: [PATCH] Contact button opens Intercom for teachers --- app/templates/base-flat.jade | 2 +- app/templates/base.jade | 2 +- app/templates/core/loading-error.jade | 2 +- app/templates/editor/level/edit.jade | 2 +- app/templates/editor/thang/thang-type-edit-view.jade | 2 +- app/templates/i18n/i18n-edit-model-view.jade | 2 +- app/templates/play/play-level-view.jade | 2 +- app/views/core/CocoView.coffee | 11 +++++++++++ 8 files changed, 18 insertions(+), 7 deletions(-) diff --git a/app/templates/base-flat.jade b/app/templates/base-flat.jade index eb299de47..12658123f 100644 --- a/app/templates/base-flat.jade +++ b/app/templates/base-flat.jade @@ -130,7 +130,7 @@ mixin accountLinks li strong(data-i18n="nav.support") li - a(tabindex=-1, data-toggle="coco-modal", data-target="core/ContactModal", data-i18n="nav.contact") + a.contact-modal(tabindex=-1, data-i18n="nav.contact") li a(href="https://www.facebook.com/codecombat", data-i18n="nav.facebook") li diff --git a/app/templates/base.jade b/app/templates/base.jade index 49aa5d9cc..25688964d 100644 --- a/app/templates/base.jade +++ b/app/templates/base.jade @@ -63,7 +63,7 @@ block footer #footer-links a(href="/about", data-i18n="nav.about") - a(tabindex=-1, data-toggle="coco-modal", data-target="core/ContactModal", data-i18n="nav.contact") + a.contact-modal(tabindex=-1, data-i18n="nav.contact") a(href='http://blog.codecombat.com/', data-i18n="nav.blog") a(href='https://jobs.lever.co/codecombat', tabindex=-1, data-i18n="nav.careers") a(href='/legal', tabindex=-1, data-i18n="nav.legal") diff --git a/app/templates/core/loading-error.jade b/app/templates/core/loading-error.jade index b48549fd2..95673d1d1 100644 --- a/app/templates/core/loading-error.jade +++ b/app/templates/core/loading-error.jade @@ -60,7 +60,7 @@ li a(href=view.forumLink(), data-i18n="nav.forum") li - a(tabindex=-1, data-toggle="coco-modal", data-target="core/ContactModal", data-i18n="nav.contact") + a.contact-modal(tabindex=-1, data-i18n="nav.contact") li a(href='/community', data-i18n="nav.community") diff --git a/app/templates/editor/level/edit.jade b/app/templates/editor/level/edit.jade index f21cb121a..9fb608788 100644 --- a/app/templates/editor/level/edit.jade +++ b/app/templates/editor/level/edit.jade @@ -120,7 +120,7 @@ block header li a(href='http://discourse.codecombat.com/category/artisan', data-i18n="nav.forum", target="_blank") Forum li - a(data-toggle="coco-modal", data-target="core/ContactModal", data-i18n="nav.contact") Email + a.contact-modal(data-i18n="nav.contact") block outer_content .outer-content diff --git a/app/templates/editor/thang/thang-type-edit-view.jade b/app/templates/editor/thang/thang-type-edit-view.jade index 4cc153580..309218447 100644 --- a/app/templates/editor/thang/thang-type-edit-view.jade +++ b/app/templates/editor/thang/thang-type-edit-view.jade @@ -71,7 +71,7 @@ block header li a(href='http://discourse.codecombat.com/category/artisan', data-i18n="nav.forum", target="_blank") Forum li - a(data-toggle="coco-modal", data-target="core/ContactModal", data-i18n="nav.contact") Email + a.contact-modal(data-i18n="nav.contact") block outer_content .outer-content diff --git a/app/templates/i18n/i18n-edit-model-view.jade b/app/templates/i18n/i18n-edit-model-view.jade index 96d294e8f..cedc26039 100644 --- a/app/templates/i18n/i18n-edit-model-view.jade +++ b/app/templates/i18n/i18n-edit-model-view.jade @@ -37,7 +37,7 @@ block header li a(href='http://discourse.codecombat.com/category/diplomat', data-i18n="nav.forum", target="_blank") Forum li - a(data-toggle="coco-modal", data-target="core/ContactModal", data-i18n="nav.contact") Email + a.contact-modal(data-i18n="nav.contact") block outer_content .outer-content.container-fluid diff --git a/app/templates/play/play-level-view.jade b/app/templates/play/play-level-view.jade index c481bf911..4b88bc24e 100644 --- a/app/templates/play/play-level-view.jade +++ b/app/templates/play/play-level-view.jade @@ -70,5 +70,5 @@ if view.showAds() if !me.get('anonymous') #play-footer(class=me.isPremium() ? "premium" : "") p(class='footer-link-text').picoctf-hide - a.contact-link(title='Send CodeCombat a message', tabindex=-1, data-i18n="nav.contact") Contact + a.contact-link(title='Send CodeCombat a message', tabindex=-1, data-i18n="nav.contact") diff --git a/app/views/core/CocoView.coffee b/app/views/core/CocoView.coffee index ddf793df0..46b6bc6ab 100644 --- a/app/views/core/CocoView.coffee +++ b/app/views/core/CocoView.coffee @@ -21,6 +21,7 @@ module.exports = class CocoView extends Backbone.View 'click #loading-error .login-btn': 'onClickLoadingErrorLoginButton' 'click #loading-error #create-account-btn': 'onClickLoadingErrorCreateAccountButton' 'click #loading-error #logout-btn': 'onClickLoadingErrorLogoutButton' + 'click .contact-modal': 'onClickContactModal' subscriptions: {} shortcuts: {} @@ -176,6 +177,16 @@ module.exports = class CocoView extends Backbone.View msg = $.i18n.t 'loading_error.connection_failure', defaultValue: 'Connection failed.' noty text: msg, layout: 'center', type: 'error', killer: true, timeout: 3000 + onClickContactModal: (e) -> + if me.isTeacher() + if application.isProduction() + window.Intercom?('show') + else + alert('Teachers, Intercom widget only available in production.') + else + ContactModal = require 'views/core/ContactModal' + @openModalView(new ContactModal()) + onClickLoadingErrorLoginButton: (e) -> e.stopPropagation() # Backbone subviews and superviews will handle this call repeatedly otherwise AuthModal = require 'views/core/AuthModal'