From 28f4921924c1e47c7a68a754292a63dcdea6c35e Mon Sep 17 00:00:00 2001 From: Valera Rozuvan Date: Tue, 11 Dec 2012 06:56:43 +0200 Subject: [PATCH] GST work in progress. --- .../js/src/graphical_slider_tool/graph.js | 44 ++++++++++++++++--- 1 file changed, 39 insertions(+), 5 deletions(-) diff --git a/common/lib/xmodule/xmodule/js/src/graphical_slider_tool/graph.js b/common/lib/xmodule/xmodule/js/src/graphical_slider_tool/graph.js index 61228413f5..dba0483674 100644 --- a/common/lib/xmodule/xmodule/js/src/graphical_slider_tool/graph.js +++ b/common/lib/xmodule/xmodule/js/src/graphical_slider_tool/graph.js @@ -2,13 +2,15 @@ // define() functions from Require JS available inside the anonymous function. (function (requirejs, require, define) { -define('Graph', [], function () { +define('Graph', ['logme'], function (logme) { return Graph; function Graph(gstId, config, state) { var plotDiv, dataSets, functions; + logme(config); + plotDiv = $('#' + gstId + '_plot'); if (plotDiv.length === 0) { @@ -39,11 +41,29 @@ define('Graph', [], function () { if (typeof config.plot['function'] === 'string') { addFunction(config.plot['function']); } else if ($.isPlainObject(config.plot['function']) === true) { - + addFunction( + config.plot['function']['#text'], + config.plot['function']['@color'], + config.plot['function']['@dot'], + config.plot['function']['@label'], + config.plot['function']['@line'], + config.plot['function']['@point_size'], + config.plot['function']['@style'] + ); } else if ($.isArray(config.plot['function'])) { for (c1 = 0; c1 < config.plot['function'].length; c1++) { if (typeof config.plot['function'][c1] === 'string') { addFunction(config.plot['function'][c1]); + } else if ($.isPlainObject(config.plot['function'][c1])) { + addFunction( + config.plot['function'][c1]['#text'], + config.plot['function'][c1]['@color'], + config.plot['function'][c1]['@dot'], + config.plot['function'][c1]['@label'], + config.plot['function'][c1]['@line'], + config.plot['function'][c1]['@point_size'], + config.plot['function'][c1]['@style'] + ); } } } @@ -76,17 +96,31 @@ define('Graph', [], function () { } if (typeof line === 'boolean') { - newFunctionObject['line'] = line; + if ((line === 'true') || (line === true)) { + newFunctionObject['line'] = true; + } else { + newFunctionObject['line'] = false; + } } - if (typeof dot === 'boolean') { - newFunctionObject['dot'] = dot; + if ((typeof dot === 'boolean') || (typeof dot === 'string')) { + if ((dot === 'true') || (dot === true)) { + newFunctionObject['dot'] = true; + } else { + newFunctionObject['dot'] = false; + } + } + + if ((newFunctionObject['dot'] === false) && (newFunctionObject['line'] === false)) { + newFunctionObject['line'] = true; } if (typeof label === 'string') { newFunctionObject['label'] = label; } + logme(newFunctionObject); + functions.push(newFunctionObject); } }