From e048b3251d6340147af6718bb26d2e32f582c838 Mon Sep 17 00:00:00 2001 From: Matthew Mongeau Date: Thu, 14 Jun 2012 14:19:47 -0400 Subject: [PATCH] Get dropdown working --- lms/djangoapps/student/views.py | 1 - lms/static/coffee/src/main.coffee | 2 +- lms/static/js/vendor/jquery.cookie.js | 47 +++++++++++++++++++++++++++ lms/templates/main.html | 1 + lms/templates/navigation.html | 9 ++++- 5 files changed, 57 insertions(+), 3 deletions(-) create mode 100644 lms/static/js/vendor/jquery.cookie.js diff --git a/lms/djangoapps/student/views.py b/lms/djangoapps/student/views.py index 9214bc4223..fa321963f5 100644 --- a/lms/djangoapps/student/views.py +++ b/lms/djangoapps/student/views.py @@ -46,7 +46,6 @@ def index(request): @ensure_csrf_cookie def dashboard(request): - user = request.user csrf_token = csrf(request)['csrf_token'] return render_to_response('dashboard.html', {'csrf': csrf_token}) diff --git a/lms/static/coffee/src/main.coffee b/lms/static/coffee/src/main.coffee index 9f3c759a9a..ccccb540c9 100644 --- a/lms/static/coffee/src/main.coffee +++ b/lms/static/coffee/src/main.coffee @@ -14,7 +14,7 @@ $ -> $('body').addClass 'touch-based-device' if onTouchBasedDevice() - $("a[rel*=leanModal]").leanModal() + # $("a[rel*=leanModal]").leanModal() $('#csrfmiddlewaretoken').attr 'value', $.cookie('csrftoken') if $('body').hasClass('courseware') diff --git a/lms/static/js/vendor/jquery.cookie.js b/lms/static/js/vendor/jquery.cookie.js new file mode 100644 index 0000000000..6d5974a2c5 --- /dev/null +++ b/lms/static/js/vendor/jquery.cookie.js @@ -0,0 +1,47 @@ +/*! + * jQuery Cookie Plugin + * https://github.com/carhartl/jquery-cookie + * + * Copyright 2011, Klaus Hartl + * Dual licensed under the MIT or GPL Version 2 licenses. + * http://www.opensource.org/licenses/mit-license.php + * http://www.opensource.org/licenses/GPL-2.0 + */ +(function($) { + $.cookie = function(key, value, options) { + + // key and at least value given, set cookie... + if (arguments.length > 1 && (!/Object/.test(Object.prototype.toString.call(value)) || value === null || value === undefined)) { + options = $.extend({}, options); + + if (value === null || value === undefined) { + options.expires = -1; + } + + if (typeof options.expires === 'number') { + var days = options.expires, t = options.expires = new Date(); + t.setDate(t.getDate() + days); + } + + value = String(value); + + return (document.cookie = [ + encodeURIComponent(key), '=', options.raw ? value : encodeURIComponent(value), + options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE + options.path ? '; path=' + options.path : '', + options.domain ? '; domain=' + options.domain : '', + options.secure ? '; secure' : '' + ].join('')); + } + + // key and possibly options given, get cookie... + options = value || {}; + var decode = options.raw ? function(s) { return s; } : decodeURIComponent; + + var pairs = document.cookie.split('; '); + for (var i = 0, pair; pair = pairs[i] && pairs[i].split('='); i++) { + if (decode(pair[0]) === key) return decode(pair[1] || ''); // IE saves cookies with empty string as "c; ", e.g. without "=" as opposed to EOMB, thus pair[1] may be undefined + } + return null; + }; +})(jQuery); diff --git a/lms/templates/main.html b/lms/templates/main.html index 8c075b5c4b..4a4c25f518 100644 --- a/lms/templates/main.html +++ b/lms/templates/main.html @@ -16,6 +16,7 @@ + % if settings.MITX_FEATURES['USE_DJANGO_PIPELINE']: diff --git a/lms/templates/navigation.html b/lms/templates/navigation.html index 04852aa055..63f9eaa28d 100644 --- a/lms/templates/navigation.html +++ b/lms/templates/navigation.html @@ -1,4 +1,9 @@ <%page args="active_page" /> + +<%namespace name='static' file='static_content.html'/> +<%block name="js_extra"> + +