Refactoring and cleaning of code.
This commit is contained in:
committed by
Alexander Kryklia
parent
3cc4a663ff
commit
47d1173394
@@ -16,47 +16,6 @@ define(['logme', 'update_input'], function (logme, updateInput) {
|
|||||||
c1 += 1
|
c1 += 1
|
||||||
}
|
}
|
||||||
}(0));
|
}(0));
|
||||||
|
|
||||||
state.updateArrowOpacity();
|
|
||||||
|
|
||||||
$(document).mousemove(function (event) {
|
|
||||||
documentMouseMove(state, event);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function documentMouseMove(state, event) {
|
|
||||||
if (state.currentMovingDraggable !== null) {
|
|
||||||
state.currentMovingDraggable.iconEl.css(
|
|
||||||
'left',
|
|
||||||
event.pageX -
|
|
||||||
state.baseImageEl.offset().left -
|
|
||||||
state.currentMovingDraggable.iconWidth * 0.5
|
|
||||||
- state.currentMovingDraggable.iconElLeftOffset
|
|
||||||
);
|
|
||||||
state.currentMovingDraggable.iconEl.css(
|
|
||||||
'top',
|
|
||||||
event.pageY -
|
|
||||||
state.baseImageEl.offset().top -
|
|
||||||
state.currentMovingDraggable.iconHeight * 0.5
|
|
||||||
);
|
|
||||||
|
|
||||||
if (state.currentMovingDraggable.labelEl !== null) {
|
|
||||||
state.currentMovingDraggable.labelEl.css(
|
|
||||||
'left',
|
|
||||||
event.pageX -
|
|
||||||
state.baseImageEl.offset().left -
|
|
||||||
state.currentMovingDraggable.labelWidth * 0.5
|
|
||||||
- 9 // Account for padding, border.
|
|
||||||
);
|
|
||||||
state.currentMovingDraggable.labelEl.css(
|
|
||||||
'top',
|
|
||||||
event.pageY -
|
|
||||||
state.baseImageEl.offset().top +
|
|
||||||
state.currentMovingDraggable.iconHeight * 0.5 +
|
|
||||||
5
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function makeDraggableCopy(callbackFunc) {
|
function makeDraggableCopy(callbackFunc) {
|
||||||
|
|||||||
@@ -63,6 +63,8 @@ define(
|
|||||||
Scroller(state);
|
Scroller(state);
|
||||||
Draggables.init(state);
|
Draggables.init(state);
|
||||||
|
|
||||||
|
state.updateArrowOpacity();
|
||||||
|
|
||||||
// Update the input element, checking first that it is not filled with
|
// Update the input element, checking first that it is not filled with
|
||||||
// an answer from the server.
|
// an answer from the server.
|
||||||
if (updateInput.check(state) === false) {
|
if (updateInput.check(state) === false) {
|
||||||
|
|||||||
@@ -8,7 +8,9 @@ define([], function () {
|
|||||||
return State;
|
return State;
|
||||||
|
|
||||||
function State(problemId) {
|
function State(problemId) {
|
||||||
return {
|
var state;
|
||||||
|
|
||||||
|
state = {
|
||||||
'config': null,
|
'config': null,
|
||||||
|
|
||||||
'baseImageEl': null,
|
'baseImageEl': null,
|
||||||
@@ -33,6 +35,12 @@ define([], function () {
|
|||||||
|
|
||||||
'getUniqueId': getUniqueId
|
'getUniqueId': getUniqueId
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$(document).mousemove(function (event) {
|
||||||
|
documentMouseMove(state, event);
|
||||||
|
});
|
||||||
|
|
||||||
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getUniqueId() {
|
function getUniqueId() {
|
||||||
@@ -53,6 +61,41 @@ define([], function () {
|
|||||||
|
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function documentMouseMove(state, event) {
|
||||||
|
if (state.currentMovingDraggable !== null) {
|
||||||
|
state.currentMovingDraggable.iconEl.css(
|
||||||
|
'left',
|
||||||
|
event.pageX -
|
||||||
|
state.baseImageEl.offset().left -
|
||||||
|
state.currentMovingDraggable.iconWidth * 0.5
|
||||||
|
- state.currentMovingDraggable.iconElLeftOffset
|
||||||
|
);
|
||||||
|
state.currentMovingDraggable.iconEl.css(
|
||||||
|
'top',
|
||||||
|
event.pageY -
|
||||||
|
state.baseImageEl.offset().top -
|
||||||
|
state.currentMovingDraggable.iconHeight * 0.5
|
||||||
|
);
|
||||||
|
|
||||||
|
if (state.currentMovingDraggable.labelEl !== null) {
|
||||||
|
state.currentMovingDraggable.labelEl.css(
|
||||||
|
'left',
|
||||||
|
event.pageX -
|
||||||
|
state.baseImageEl.offset().left -
|
||||||
|
state.currentMovingDraggable.labelWidth * 0.5
|
||||||
|
- 9 // Account for padding, border.
|
||||||
|
);
|
||||||
|
state.currentMovingDraggable.labelEl.css(
|
||||||
|
'top',
|
||||||
|
event.pageY -
|
||||||
|
state.baseImageEl.offset().top +
|
||||||
|
state.currentMovingDraggable.iconHeight * 0.5 +
|
||||||
|
5
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// End of wrapper for RequireJS. As you can see, we are passing
|
// End of wrapper for RequireJS. As you can see, we are passing
|
||||||
|
|||||||
Reference in New Issue
Block a user