Commit b08b25b9 by Valera Rozuvan Committed by Alexander Kryklia

GST work in progress.

parent 3e9d325a
...@@ -139,8 +139,8 @@ class GraphicalSliderToolModule(XModule): ...@@ -139,8 +139,8 @@ class GraphicalSliderToolModule(XModule):
sliders = [sliders] sliders = [sliders]
vars = [x['@var'] for x in sliders] vars = [x['@var'] for x in sliders]
slider_div = '<div class="{element_class}_slider" id="{element_id}_slider_{var}" \ slider_div = '<span class="{element_class}_slider" id="{element_id}_slider_{var}" \
data-var="{var}"></div>' data-var="{var}"></span>'
for var in vars: for var in vars:
html_string = re.sub(r'\$slider\s+' + var + r'\$', html_string = re.sub(r'\$slider\s+' + var + r'\$',
......
...@@ -27,9 +27,9 @@ define('Inputs', ['logme'], function (logme) { ...@@ -27,9 +27,9 @@ define('Inputs', ['logme'], function (logme) {
} }
function createInput(obj) { function createInput(obj) {
var constName, constValue, inputDiv, textInputDiv; var constName, constValue, spanEl, inputEl;
if (typeof obj['@var'] === 'undefined') { if (typeof obj['@var'] !== 'string') {
return; return;
} }
...@@ -40,19 +40,28 @@ define('Inputs', ['logme'], function (logme) { ...@@ -40,19 +40,28 @@ define('Inputs', ['logme'], function (logme) {
constValue = 0; constValue = 0;
} }
inputDiv = $('#' + gstId + '_input_' + constName); spanEl = $('#' + gstId + '_input_' + constName);
if (inputDiv.length === 0) { if (spanEl.length === 0) {
return; return;
} }
textInputDiv = $('<input type"text" />'); inputEl = $('<input type"text" />');
textInputDiv.width(50);
// inputEl.width(50);
textInputDiv.appendTo(inputDiv); inputEl.val(constValue);
textInputDiv.val(constValue); inputEl.bind('change', inputOnChange);
inputEl.button().css({
textInputDiv.bind('change', inputOnChange); 'font': 'inherit',
'color': 'inherit',
'text-align': 'left',
'outline': 'none',
'cursor': 'text',
'height': '15px',
'width': '50px'
});
inputEl.appendTo(spanEl);
return; return;
......
...@@ -25,7 +25,7 @@ define('Sliders', [], function () { ...@@ -25,7 +25,7 @@ define('Sliders', [], function () {
function createSlider(obj) { function createSlider(obj) {
var constName, constValue, rangeBlobs, valueMin, valueMax, var constName, constValue, rangeBlobs, valueMin, valueMax,
sliderDiv, sliderWidth; spanEl, sliderEl, sliderWidth;
// The name of the constant is obj['@var']. Multiple sliders and/or // The name of the constant is obj['@var']. Multiple sliders and/or
// inputs can represent the same constant - therefore we will get // inputs can represent the same constant - therefore we will get
...@@ -34,7 +34,7 @@ define('Sliders', [], function () { ...@@ -34,7 +34,7 @@ define('Sliders', [], function () {
// blob is the min value for the slider, the third blob is the max // blob is the min value for the slider, the third blob is the max
// value for the slider. // value for the slider.
if (typeof obj['@var'] === 'undefined') { if (typeof obj['@var'] !== 'string') {
return; return;
} }
...@@ -85,14 +85,16 @@ define('Sliders', [], function () { ...@@ -85,14 +85,16 @@ define('Sliders', [], function () {
} }
} }
sliderDiv = $('#' + gstId + '_slider_' + constName); spanEl = $('#' + gstId + '_slider_' + constName);
// If a corresponding slider DIV for this constant does not exist, // If a corresponding slider DIV for this constant does not exist,
// do not do anything. // do not do anything.
if (sliderDiv.length === 0) { if (spanEl.length === 0) {
return; return;
} }
sliderEl = $('<div>');
// The default slider width. // The default slider width.
sliderWidth = 400; sliderWidth = 400;
...@@ -103,21 +105,23 @@ define('Sliders', [], function () { ...@@ -103,21 +105,23 @@ define('Sliders', [], function () {
} }
// Set the new width to the slider. // Set the new width to the slider.
sliderDiv.width(sliderWidth); sliderEl.width(sliderWidth);
sliderDiv.css('display', 'inline-block'); sliderEl.css('display', 'inline-block');
// Create a jQuery UI slider from the current DIV. We will set // Create a jQuery UI slider from the current DIV. We will set
// starting parameters, and will also attach a handler to update // starting parameters, and will also attach a handler to update
// the state on the change event. // the state on the change event.
sliderDiv.slider({ sliderEl.slider({
'min': valueMin, 'min': valueMin,
'max': valueMax, 'max': valueMax,
'value': constValue, 'value': constValue,
'step': 0.01, 'step': (valueMax - valueMin) / 50.0,
'change': sliderOnChange 'change': sliderOnChange
}); });
sliderEl.appendTo(spanEl);
return; return;
function sliderOnChange(event, ui) { function sliderOnChange(event, ui) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment