From 6a7b88df4d8820318324779dd89637f833e1c4f2 Mon Sep 17 00:00:00 2001 From: cahrens Date: Fri, 11 Oct 2013 14:01:30 -0400 Subject: [PATCH] Move sock JS code into its own file. --- cms/static/js/base.js | 28 ---------------------------- cms/static/js/sock.js | 32 ++++++++++++++++++++++++++++++++ cms/templates/base.html | 3 +++ 3 files changed, 35 insertions(+), 28 deletions(-) create mode 100644 cms/static/js/sock.js diff --git a/cms/static/js/base.js b/cms/static/js/base.js index 0ac9932599..f32a3856a4 100644 --- a/cms/static/js/base.js +++ b/cms/static/js/base.js @@ -94,9 +94,6 @@ domReady(function() { // tender feedback window scrolling $('a.show-tender').bind('click', smoothScrollTop); - // toggling footer additional support - $('.cta-show-sock').bind('click', toggleSock); - // toggling overview section details $(function() { if ($('.courseware-section').length > 0) { @@ -423,31 +420,6 @@ function hideModal(e) { } } -function toggleSock(e) { - e.preventDefault(); - - var $btnLabel = $(this).find('.copy'); - var $sock = $('.wrapper-sock'); - var $sockContent = $sock.find('.wrapper-inner'); - - $sock.toggleClass('is-shown'); - $sockContent.toggle('fast'); - - $.smoothScroll({ - offset: -200, - easing: 'swing', - speed: 1000, - scrollElement: null, - scrollTarget: $sock - }); - - if ($sock.hasClass('is-shown')) { - $btnLabel.text(gettext('Hide Studio Help')); - } else { - $btnLabel.text(gettext('Looking for Help with Studio?')); - } -} - function toggleSubmodules(e) { e.preventDefault(); $(this).toggleClass('expand').toggleClass('collapse'); diff --git a/cms/static/js/sock.js b/cms/static/js/sock.js new file mode 100644 index 0000000000..0d8af7c0d0 --- /dev/null +++ b/cms/static/js/sock.js @@ -0,0 +1,32 @@ +require(["domReady", "jquery", "jquery.smoothScroll"], + function (domReady, $) { + var toggleSock = function (e) { + e.preventDefault(); + + var $btnLabel = $(this).find('.copy'); + var $sock = $('.wrapper-sock'); + var $sockContent = $sock.find('.wrapper-inner'); + + $sock.toggleClass('is-shown'); + $sockContent.toggle('fast'); + + $.smoothScroll({ + offset: -200, + easing: 'swing', + speed: 1000, + scrollElement: null, + scrollTarget: $sock + }); + + if ($sock.hasClass('is-shown')) { + $btnLabel.text(gettext('Hide Studio Help')); + } else { + $btnLabel.text(gettext('Looking for Help with Studio?')); + } + }; + + domReady(function () { + // toggling footer additional support + $('.cta-show-sock').bind('click', toggleSock); + }); + }); diff --git a/cms/templates/base.html b/cms/templates/base.html index 116883b3f3..260059f274 100644 --- a/cms/templates/base.html +++ b/cms/templates/base.html @@ -200,6 +200,9 @@ require(['js/models/course'], function(Course) { <%block name="content"> % if user.is_authenticated(): + <%include file="widgets/sock.html" /> % endif