Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
30488537
Commit
30488537
authored
Dec 26, 2012
by
Valera Rozuvan
Committed by
Alexander Kryklia
Jan 21, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added ability to communicate with server via input element. Work in progress. Part 8.
parent
c34fbbe1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
80 additions
and
10 deletions
+80
-10
common/static/js/capa/drag_and_drop/config_parser.js
+6
-0
common/static/js/capa/drag_and_drop/draggables.js
+22
-2
common/static/js/capa/drag_and_drop/targets.js
+5
-8
common/static/js/capa/drag_and_drop/update_input.js
+47
-0
No files found.
common/static/js/capa/drag_and_drop/config_parser.js
View file @
30488537
...
...
@@ -90,6 +90,12 @@ define(['logme'], function (logme) {
returnStatus
=
false
;
}
if
(
state
.
config
.
targets
.
length
===
0
)
{
state
.
individualTargets
=
false
;
}
else
{
state
.
individualTargets
=
true
;
}
return
true
;
function
processDraggable
(
obj
)
{
...
...
common/static/js/capa/drag_and_drop/draggables.js
View file @
30488537
...
...
@@ -4,13 +4,14 @@
// See https://edx-wiki.atlassian.net/wiki/display/LMS/Integration+of+Require+JS+into+the+system
(
function
(
requirejs
,
require
,
define
)
{
define
([
'logme'
],
function
(
logme
)
{
define
([
'logme'
,
'update_input'
],
function
(
logme
,
updateInput
)
{
return
Draggables
;
function
Draggables
(
state
)
{
var
_draggables
;
_draggables
=
[];
state
.
draggables
=
[];
(
function
(
i
)
{
while
(
i
<
state
.
config
.
draggable
.
length
)
{
...
...
@@ -23,7 +24,7 @@ define(['logme'], function (logme) {
function
processDraggable
(
obj
,
index
)
{
var
draggableContainerEl
,
imgEl
,
inContainer
,
ousePressed
,
onTarget
;
onTarget
,
draggableObj
;
draggableContainerEl
=
$
(
'<div '
+
...
...
@@ -63,11 +64,22 @@ define(['logme'], function (logme) {
onTarget
=
null
;
draggableObj
=
{
'id'
:
obj
.
id
,
'x'
:
-
1
,
'y'
:
-
1
};
state
.
draggables
.
push
(
draggableObj
);
draggableContainerEl
.
mousedown
(
mouseDown
);
draggableContainerEl
.
mouseup
(
mouseUp
);
draggableContainerEl
.
mousemove
(
mouseMove
);
draggableContainerEl
.
mouseleave
(
mouseLeave
);
if
(
state
.
individualTargets
===
false
)
{
updateInput
(
state
);
}
return
;
function
mouseDown
(
event
)
{
...
...
@@ -126,8 +138,14 @@ define(['logme'], function (logme) {
(
offsetDE
.
top
+
100
>
offsetTE
.
top
+
state
.
targetEl
.
height
())
)
{
moveBackToSlider
();
draggableObj
.
x
=
-
1
;
draggableObj
.
y
=
-
1
;
}
else
{
correctZIndexes
();
draggableObj
.
x
=
offsetDE
.
left
+
50
-
offsetTE
.
left
;
draggableObj
.
y
=
offsetDE
.
top
+
50
-
offsetTE
.
top
;
}
}
else
if
(
state
.
individualTargets
===
true
)
{
targetFound
=
false
;
...
...
@@ -142,6 +160,8 @@ define(['logme'], function (logme) {
}
}
updateInput
(
state
);
return
;
function
removeObjIdFromTarget
()
{
...
...
common/static/js/capa/drag_and_drop/targets.js
View file @
30488537
...
...
@@ -4,17 +4,10 @@
// See https://edx-wiki.atlassian.net/wiki/display/LMS/Integration+of+Require+JS+into+the+system
(
function
(
requirejs
,
require
,
define
)
{
define
([
'logme'
],
function
(
logme
)
{
define
([
'logme'
,
'update_input'
],
function
(
logme
,
updateInput
)
{
return
Targets
;
function
Targets
(
state
)
{
if
(
state
.
config
.
targets
.
length
===
0
)
{
state
.
individualTargets
=
false
;
return
;
}
state
.
individualTargets
=
true
;
state
.
targets
=
[];
(
function
(
c1
)
{
...
...
@@ -68,6 +61,10 @@ define(['logme'], function (logme) {
'el'
:
tEl
,
'draggable'
:
[]
});
if
(
state
.
individualTargets
===
true
)
{
updateInput
(
state
);
}
}
}
});
...
...
common/static/js/capa/drag_and_drop/update_input.js
0 → 100644
View file @
30488537
// 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
([
'logme'
],
function
(
logme
)
{
return
updateInput
;
function
updateInput
(
state
)
{
var
inputEl
,
stateStr
,
targets
;
if
(
state
.
individualTargets
===
false
)
{
stateStr
=
JSON
.
stringify
({
'individualTargets'
:
false
,
'draggables'
:
state
.
draggables
});
}
else
{
targets
=
[];
(
function
(
c1
)
{
while
(
c1
<
state
.
targets
.
length
)
{
targets
.
push
({
'id'
:
state
.
targets
[
c1
].
id
,
'draggables'
:
state
.
targets
[
c1
].
draggable
});
c1
+=
1
;
}
}(
0
));
stateStr
=
JSON
.
stringify
({
'individualTargets'
:
true
,
'targets'
:
targets
});
}
inputEl
=
$
(
'#input_'
+
state
.
problemId
);
inputEl
.
val
(
stateStr
);
}
});
// 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)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment