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
06fd8238
Commit
06fd8238
authored
Dec 25, 2012
by
Valera Rozuvan
Committed by
Alexander Kryklia
Jan 21, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Client side drag and drop. Work in progress. Part 3.
parent
f6592477
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
197 additions
and
10 deletions
+197
-10
common/static/images/arrow-left.png
+0
-0
common/static/images/arrow-right.png
+0
-0
common/static/js/capa/drag_and_drop/config_parser.js
+1
-1
common/static/js/capa/drag_and_drop/container.js
+10
-0
common/static/js/capa/drag_and_drop/draggables.js
+33
-2
common/static/js/capa/drag_and_drop/main.js
+12
-4
common/static/js/capa/drag_and_drop/scroller.js
+99
-0
common/static/js/capa/drag_and_drop/target.js
+41
-2
rakefile
+1
-1
No files found.
common/static/images/arrow-left.png
0 → 100644
View file @
06fd8238
2.41 KB
common/static/images/arrow-right.png
0 → 100644
View file @
06fd8238
2.4 KB
common/static/js/capa/drag_and_drop/config_parser.js
View file @
06fd8238
...
@@ -13,7 +13,7 @@ define(['logme'], function (logme) {
...
@@ -13,7 +13,7 @@ define(['logme'], function (logme) {
returnStatus
=
true
;
returnStatus
=
true
;
state
.
config
=
{
state
.
config
=
{
'imageDir'
:
'/static/'
+
imageDir
+
'/images
/
'
,
'imageDir'
:
'/static/'
+
imageDir
+
'/images'
,
'draggable'
:
[],
'draggable'
:
[],
'target'
:
''
'target'
:
''
};
};
...
...
common/static/js/capa/drag_and_drop/container.js
View file @
06fd8238
...
@@ -8,7 +8,17 @@ define(['logme'], function (logme) {
...
@@ -8,7 +8,17 @@ define(['logme'], function (logme) {
return
Container
;
return
Container
;
function
Container
(
state
)
{
function
Container
(
state
)
{
state
.
containerEl
=
$
(
'<div '
+
'style=" '
+
'border: 1px solid black; '
+
'overflow: hidden; '
+
'clear: both; '
+
'" '
+
'></div>'
);
$
(
'#inputtype_'
+
state
.
problemId
).
before
(
state
.
containerEl
);
}
}
});
});
...
...
common/static/js/capa/drag_and_drop/draggables.js
View file @
06fd8238
...
@@ -4,11 +4,42 @@
...
@@ -4,11 +4,42 @@
// See https://edx-wiki.atlassian.net/wiki/display/LMS/Integration+of+Require+JS+into+the+system
// See https://edx-wiki.atlassian.net/wiki/display/LMS/Integration+of+Require+JS+into+the+system
(
function
(
requirejs
,
require
,
define
)
{
(
function
(
requirejs
,
require
,
define
)
{
define
([
],
function
(
)
{
define
([
'logme'
],
function
(
logme
)
{
return
Draggables
;
return
Draggables
;
function
Draggables
(
state
)
{
function
Draggables
(
state
)
{
state
.
draggables
=
1
;
(
function
(
i
)
{
while
(
i
<
state
.
config
.
draggable
.
length
)
{
processDraggable
(
state
.
config
.
draggable
[
i
]);
i
+=
1
;
}
}(
0
));
function
processDraggable
(
obj
)
{
var
draggableContainerEl
;
logme
(
obj
);
draggableContainerEl
=
$
(
'<div '
+
'style=" '
+
'width: 100px; '
+
'height: 100px; '
+
'display: inline; '
+
'float: left; '
+
'" '
+
'></div>'
);
if
(
obj
.
icon
.
length
>
0
)
{
draggableContainerEl
.
append
(
$
(
'<img src="'
+
state
.
config
.
imageDir
+
'/'
+
obj
.
icon
+
'" />'
)
);
}
draggableContainerEl
.
appendTo
(
state
.
sliderEl
);
}
}
}
});
});
...
...
common/static/js/capa/drag_and_drop/main.js
View file @
06fd8238
...
@@ -5,8 +5,8 @@
...
@@ -5,8 +5,8 @@
(
function
(
requirejs
,
require
,
define
)
{
(
function
(
requirejs
,
require
,
define
)
{
define
(
define
(
[
'logme'
,
'state'
,
'config_parser'
,
'
target
'
,
'draggables'
],
[
'logme'
,
'state'
,
'config_parser'
,
'
container'
,
'target'
,
'scroller
'
,
'draggables'
],
function
(
logme
,
State
,
configParser
,
Target
,
Draggables
)
{
function
(
logme
,
State
,
configParser
,
Container
,
Target
,
Scroller
,
Draggables
)
{
return
Main
;
return
Main
;
function
Main
()
{
function
Main
()
{
...
@@ -17,6 +17,14 @@ define(
...
@@ -17,6 +17,14 @@ define(
function
processProblem
(
index
,
value
)
{
function
processProblem
(
index
,
value
)
{
var
problemId
,
imageDir
,
config
,
state
;
var
problemId
,
imageDir
,
config
,
state
;
if
(
$
(
value
).
attr
(
'data-problem-processed'
)
===
'true'
)
{
// This problem was already processed by us before, so we will
// skip it.
return
;
}
$
(
value
).
attr
(
'data-problem-processed'
,
'true'
);
problemId
=
$
(
value
).
attr
(
'data-plain-id'
);
problemId
=
$
(
value
).
attr
(
'data-plain-id'
);
if
(
typeof
problemId
!==
'string'
)
{
if
(
typeof
problemId
!==
'string'
)
{
logme
(
'ERROR: Could not find the ID of the problem DOM element.'
);
logme
(
'ERROR: Could not find the ID of the problem DOM element.'
);
...
@@ -24,7 +32,7 @@ define(
...
@@ -24,7 +32,7 @@ define(
return
;
return
;
}
}
imageDir
=
$
(
value
).
attr
(
'data-
plain-id
'
);
imageDir
=
$
(
value
).
attr
(
'data-
course-folder
'
);
if
(
typeof
imageDir
!==
'string'
)
{
if
(
typeof
imageDir
!==
'string'
)
{
logme
(
'ERROR: Could not find the name of the image directory.'
);
logme
(
'ERROR: Could not find the name of the image directory.'
);
...
@@ -50,7 +58,7 @@ define(
...
@@ -50,7 +58,7 @@ define(
Container
(
state
);
Container
(
state
);
Target
(
state
);
Target
(
state
);
//
Scroller(state);
Scroller
(
state
);
Draggables
(
state
);
Draggables
(
state
);
logme
(
state
);
logme
(
state
);
...
...
common/static/js/capa/drag_and_drop/scroller.js
0 → 100644
View file @
06fd8238
// 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
Scroller
;
function
Scroller
(
state
)
{
var
parentEl
,
moveLeftEl
,
showEl
,
moveRightEL
,
moveRightEl_leftMargin
;
parentEl
=
$
(
'<div '
+
'style=" '
+
'width: 95%; '
+
'height: 100px; '
+
'border: 1px solid black; '
+
'margin-left: auto; '
+
'margin-right: auto; '
+
'" '
+
'></div>'
);
moveLeftEl
=
$
(
'<div '
+
'style=" '
+
'width: 6%; '
+
'height: 100px; '
+
'display: inline; '
+
'float: left; '
+
'background: url(
\'
/static/images/arrow-left.png
\'
) center center no-repeat; '
+
'" '
+
'></div>'
);
moveLeftEl
.
appendTo
(
parentEl
);
moveLeftEl
.
click
(
function
()
{
state
.
showElLeftMargin
-=
100
;
state
.
sliderEl
.
animate
({
'margin-left'
:
state
.
showElLeftMargin
+
'px'
});
});
showEl
=
$
(
'<div '
+
'style=" '
+
'width: 88%; '
+
'height: 100px; '
+
'overflow: hidden; '
+
'display: inline; '
+
'float: left; '
+
'" '
+
'></div>'
);
showEl
.
appendTo
(
parentEl
);
state
.
showElLeftMargin
=
0
;
state
.
sliderEl
=
$
(
'<div '
+
'style=" '
+
'width: 800px; '
+
'height: 100px; '
+
'" '
+
'></div>'
);
state
.
sliderEl
.
appendTo
(
showEl
);
moveRightEl
=
$
(
'<div '
+
'style=" '
+
'width: 6%; '
+
'height: 100px; '
+
'display: inline; '
+
'float: left; '
+
'background: url(
\'
/static/images/arrow-right.png
\'
) center center no-repeat; '
+
'" '
+
'></div>'
);
moveRightEl
.
appendTo
(
parentEl
);
moveRightEl
.
click
(
function
()
{
state
.
showElLeftMargin
+=
100
;
state
.
sliderEl
.
animate
({
'margin-left'
:
state
.
showElLeftMargin
+
'px'
});
});
parentEl
.
appendTo
(
state
.
containerEl
);
}
});
// 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)
common/static/js/capa/drag_and_drop/target.js
View file @
06fd8238
...
@@ -4,11 +4,50 @@
...
@@ -4,11 +4,50 @@
// See https://edx-wiki.atlassian.net/wiki/display/LMS/Integration+of+Require+JS+into+the+system
// See https://edx-wiki.atlassian.net/wiki/display/LMS/Integration+of+Require+JS+into+the+system
(
function
(
requirejs
,
require
,
define
)
{
(
function
(
requirejs
,
require
,
define
)
{
define
([
],
function
(
)
{
define
([
'logme'
],
function
(
logme
)
{
return
Target
;
return
Target
;
function
Target
(
state
)
{
function
Target
(
state
)
{
state
.
target
=
1
;
var
targetImgSrc
,
targetElContainer
,
mouseMoveDiv
;
targetImgSrc
=
state
.
config
.
imageDir
+
'/'
+
state
.
config
.
target
;
targetElContainer
=
$
(
'<div '
+
'style=" '
+
'text-align: center; '
+
'" '
+
'></div>'
);
state
.
targetEl
=
$
(
'<img '
+
'src="'
+
targetImgSrc
+
'" '
+
'/>'
);
state
.
targetEl
.
appendTo
(
targetElContainer
);
state
.
targetEl
.
mousemove
(
function
(
event
)
{
mouseMoveDiv
.
html
(
'['
+
event
.
offsetX
+
', '
+
event
.
offsetY
+
']'
);
}
);
mouseMoveDiv
=
$
(
'<div '
+
'style=" '
+
'clear: both; '
+
'width: auto; '
+
'height: 25px; '
+
'text-align: center; '
+
'" '
+
'>[0, 0]</div>'
);
mouseMoveDiv
.
appendTo
(
targetElContainer
);
targetElContainer
.
appendTo
(
state
.
containerEl
);
}
}
});
});
...
...
rakefile
View file @
06fd8238
...
@@ -53,7 +53,7 @@ default_options = {
...
@@ -53,7 +53,7 @@ default_options = {
task
:predjango
do
task
:predjango
do
sh
(
"find . -type f -name *.pyc -delete"
)
sh
(
"find . -type f -name *.pyc -delete"
)
sh
(
'pip install -q --upgrade --no-deps -r local-requirements.txt'
)
#
sh('pip install -q --upgrade --no-deps -r local-requirements.txt')
end
end
task
:clean_test_files
do
task
:clean_test_files
do
...
...
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