Commit 98172538 by Valera Rozuvan Committed by Alexander Kryklia

Fixed problem with smaller and larger base images. Refactoring. Cleaning of code.

parent ad0a7d30
...@@ -16,18 +16,26 @@ define(['logme'], function (logme) { ...@@ -16,18 +16,26 @@ define(['logme'], function (logme) {
'style=" ' + 'style=" ' +
'position: relative; ' + 'position: relative; ' +
'margin-bottom: 25px; ' + 'margin-bottom: 25px; ' +
'margin-left: auto; ' +
'margin-right: auto; ' +
'" ' + '" ' +
'></div>' '></div>'
); );
state.baseImageEl = $( state.baseImageEl = $('<img />');
'<img ' + state.baseImageEl.attr(
'src="' + state.config.imageDir + '/' + state.config.base_image + '" ' + 'src',
'/>' state.config.imageDir + '/' + state.config.base_image
); );
state.baseImageEl.appendTo(baseImageElContainer); state.baseImageEl.load(function () {
baseImageElContainer.css('width', this.width);
baseImageElContainer.css('height', this.height);
baseImageElContainer.appendTo(state.containerEl); state.baseImageEl.appendTo(baseImageElContainer);
baseImageElContainer.appendTo(state.containerEl);
state.baseImageLoaded = true;
});
} }
}); });
......
...@@ -60,13 +60,22 @@ define( ...@@ -60,13 +60,22 @@ define(
Container(state); Container(state);
BaseImage(state); BaseImage(state);
Targets(state);
Scroller(state);
Draggables(state);
// Update the input element, checking first that it is not filled with (function addContent() {
// an answer from the server. if (state.baseImageLoaded !== true) {
updateInput(state, true); setTimeout(addContent, 50);
return;
}
Targets(state);
Scroller(state);
Draggables(state);
// Update the input element, checking first that it is not filled with
// an answer from the server.
updateInput(state, true);
}());
} }
}); });
......
...@@ -11,10 +11,7 @@ define([], function () { ...@@ -11,10 +11,7 @@ define([], function () {
return { return {
'problemId': problemId, 'problemId': problemId,
// Will indicate when all targetsand draggables have been loaded, 'baseImageLoaded': false,
// processed, and postioned intially.
'targetsLoaded': false,
'draggablesLoaded': false,
'numDraggablesInSlider': 0 'numDraggablesInSlider': 0
}; };
......
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