From 61c68b740ce2151e5bb61419ee436e4da5822c5d Mon Sep 17 00:00:00 2001 From: Valera Rozuvan Date: Mon, 24 Dec 2012 10:41:07 +0200 Subject: [PATCH] Set up of basic RequireJS skeleton structure. --- common/static/js/capa/drag_and_drop.js | 28 ++++++++++++++++++++- common/static/js/capa/drag_and_drop/main.js | 19 ++++++++++++++ lms/envs/common.py | 2 ++ 3 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 common/static/js/capa/drag_and_drop/main.js diff --git a/common/static/js/capa/drag_and_drop.js b/common/static/js/capa/drag_and_drop.js index 73c9f606d1..a2d8b8d37b 100644 --- a/common/static/js/capa/drag_and_drop.js +++ b/common/static/js/capa/drag_and_drop.js @@ -1 +1,27 @@ -alert('drag-and-drop js is loaded') \ No newline at end of file +// Wrapper for RequireJS. It will make the standard requirejs(), require(), and +// define() functions from Require JS available inside the anonymous function. +// +// See https://edx-wiki.atlassian.net/wiki/display/LMS/Integration+of+Require+JS+into+the+system +(function (requirejs, require, define) { + +requirejs.config({ + 'baseUrl': '/static/js/capa/drag_and_drop/', + + 'paths': { + + }, + + 'shim': { + + } +}); + +requirejs(['main'], function (Main) { + Main(); +}); + +// End of wrapper for RequireJS. As you can see, we are passing +// namespaced Require JS variables to an anonymous function. Within +// it, you can use the standard requirejs(), require(), and define() +// functions as if they were in the global namespace. +}(RequireJS.requirejs, RequireJS.require, RequireJS.define)); // End-of: (function (requirejs, require, define) diff --git a/common/static/js/capa/drag_and_drop/main.js b/common/static/js/capa/drag_and_drop/main.js new file mode 100644 index 0000000000..7ea7b103ad --- /dev/null +++ b/common/static/js/capa/drag_and_drop/main.js @@ -0,0 +1,19 @@ +// Wrapper for RequireJS. It will make the standard requirejs(), require(), and +// define() functions from Require JS available inside the anonymous function. +// +// See https://edx-wiki.atlassian.net/wiki/display/LMS/Integration+of+Require+JS+into+the+system +(function (requirejs, require, define) { + +define([], function () { + return Main; + + function Main() { + alert('This is a drag-and-drop demo.'); + } +}); + +// End of wrapper for RequireJS. As you can see, we are passing +// namespaced Require JS variables to an anonymous function. Within +// it, you can use the standard requirejs(), require(), and define() +// functions as if they were in the global namespace. +}(RequireJS.requirejs, RequireJS.require, RequireJS.define)); // End-of: (function (requirejs, require, define) diff --git a/lms/envs/common.py b/lms/envs/common.py index b50fc25917..570d26ae2a 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -432,6 +432,8 @@ courseware_only_js += [ in glob2.glob(PROJECT_ROOT / 'static/coffee/src/modules/**/*.coffee') ] +# 'js/vendor/RequireJS.js' - Require JS wrapper. +# See https://edx-wiki.atlassian.net/wiki/display/LMS/Integration+of+Require+JS+into+the+system main_vendor_js = [ 'js/vendor/RequireJS.js', 'js/vendor/json2.js',