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
f1588738
Commit
f1588738
authored
Jan 16, 2013
by
Valera Rozuvan
Committed by
Alexander Kryklia
Jan 21, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactoring.
parent
35174dd3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
59 additions
and
10 deletions
+59
-10
common/static/js/capa/drag_and_drop/config_parser.js
+44
-1
common/static/js/capa/drag_and_drop/draggables.js
+11
-9
common/static/js/capa/drag_and_drop/main.js
+4
-0
No files found.
common/static/js/capa/drag_and_drop/config_parser.js
View file @
f1588738
...
@@ -163,10 +163,15 @@ define(['logme'], function (logme) {
...
@@ -163,10 +163,15 @@ define(['logme'], function (logme) {
if
(
!
attrIsString
(
obj
,
'icon'
))
{
if
(
!
attrIsString
(
obj
,
'icon'
))
{
return
false
;
return
false
;
}
}
if
(
!
attrIsString
(
obj
,
'label'
))
{
if
(
!
attrIsString
(
obj
,
'label'
))
{
return
false
;
return
false
;
}
}
if
(
!
attrIsBoolean
(
obj
,
'can_reuse'
,
false
))
{
return
false
;
}
state
.
config
.
draggables
.
push
(
obj
);
state
.
config
.
draggables
.
push
(
obj
);
return
true
;
return
true
;
...
@@ -197,7 +202,11 @@ define(['logme'], function (logme) {
...
@@ -197,7 +202,11 @@ define(['logme'], function (logme) {
}
}
function
attrIsString
(
obj
,
attr
)
{
function
attrIsString
(
obj
,
attr
)
{
if
(
typeof
obj
[
attr
]
!==
'string'
)
{
if
(
obj
.
hasOwnProperty
(
attr
)
===
false
)
{
logme
(
'ERROR: Attribute "obj.'
+
attr
+
'" is not present.'
);
return
false
;
}
else
if
(
typeof
obj
[
attr
]
!==
'string'
)
{
logme
(
'ERROR: Attribute "obj.'
+
attr
+
'" is not a string.'
);
logme
(
'ERROR: Attribute "obj.'
+
attr
+
'" is not a string.'
);
return
false
;
return
false
;
...
@@ -209,6 +218,12 @@ define(['logme'], function (logme) {
...
@@ -209,6 +218,12 @@ define(['logme'], function (logme) {
function
attrIsInteger
(
obj
,
attr
)
{
function
attrIsInteger
(
obj
,
attr
)
{
var
tempInt
;
var
tempInt
;
if
(
obj
.
hasOwnProperty
(
attr
)
===
false
)
{
logme
(
'ERROR: Attribute "obj.'
+
attr
+
'" is not present.'
);
return
false
;
}
tempInt
=
parseInt
(
obj
[
attr
],
10
);
tempInt
=
parseInt
(
obj
[
attr
],
10
);
if
(
isFinite
(
tempInt
)
===
false
)
{
if
(
isFinite
(
tempInt
)
===
false
)
{
...
@@ -221,6 +236,34 @@ define(['logme'], function (logme) {
...
@@ -221,6 +236,34 @@ define(['logme'], function (logme) {
return
true
;
return
true
;
}
}
function
attrIsBoolean
(
obj
,
attr
,
defaultVal
)
{
if
(
obj
.
hasOwnProperty
(
attr
)
===
false
)
{
if
(
defaultVal
===
undefined
)
{
logme
(
'ERROR: Attribute "obj.'
+
attr
+
'" is not present.'
);
return
false
;
}
else
{
obj
[
attr
]
=
defaultVal
;
return
true
;
}
}
if
(
obj
[
attr
]
===
''
)
{
obj
[
attr
]
=
defaultVal
;
}
else
if
((
obj
[
attr
]
===
'false'
)
||
(
obj
[
attr
]
===
false
))
{
obj
[
attr
]
=
false
;
}
else
if
((
obj
[
attr
]
===
'true'
)
||
(
obj
[
attr
]
===
true
))
{
obj
[
attr
]
=
true
;
}
else
{
logme
(
'ERROR: Attribute "obj.'
+
attr
+
'" is not a boolean.'
);
return
false
;
}
return
true
;
}
});
});
// End of wrapper for RequireJS. As you can see, we are passing
// End of wrapper for RequireJS. As you can see, we are passing
...
...
common/static/js/capa/drag_and_drop/draggables.js
View file @
f1588738
...
@@ -195,6 +195,13 @@ define(['logme', 'update_input'], function (logme, updateInput) {
...
@@ -195,6 +195,13 @@ define(['logme', 'update_input'], function (logme, updateInput) {
var
draggableObj
;
var
draggableObj
;
draggableObj
=
{
draggableObj
=
{
'id'
:
obj
.
id
,
'isReusable'
:
obj
.
can_reuse
,
'x'
:
-
1
,
'y'
:
-
1
,
'zIndex'
:
objIndex
,
'zIndex'
:
objIndex
,
'oldZIndex'
:
objIndex
,
'oldZIndex'
:
objIndex
,
'labelEl'
:
null
,
'labelEl'
:
null
,
...
@@ -373,12 +380,15 @@ define(['logme', 'update_input'], function (logme, updateInput) {
...
@@ -373,12 +380,15 @@ define(['logme', 'update_input'], function (logme, updateInput) {
'top'
,
'top'
,
50
-
draggableObj
.
iconHeightSmall
*
0.5
50
-
draggableObj
.
iconHeightSmall
*
0.5
);
);
draggableObj
.
hasLoaded
=
true
;
}
else
{
}
else
{
// If no icon and no label, don't create a draggable.
// If no icon and no label, don't create a draggable.
return
;
return
;
}
}
}
}
// Attach events to "iconEl".
draggableObj
.
iconEl
.
mousedown
(
function
(
event
)
{
draggableObj
.
iconEl
.
mousedown
(
function
(
event
)
{
draggableObj
.
mouseDown
.
call
(
draggableObj
,
event
);
draggableObj
.
mouseDown
.
call
(
draggableObj
,
event
);
});
});
...
@@ -389,6 +399,7 @@ define(['logme', 'update_input'], function (logme, updateInput) {
...
@@ -389,6 +399,7 @@ define(['logme', 'update_input'], function (logme, updateInput) {
draggableObj
.
mouseMove
.
call
(
draggableObj
,
event
);
draggableObj
.
mouseMove
.
call
(
draggableObj
,
event
);
});
});
// Attach events to "containerEl".
draggableObj
.
containerEl
.
mousedown
(
function
(
event
)
{
draggableObj
.
containerEl
.
mousedown
(
function
(
event
)
{
draggableObj
.
mouseDown
.
call
(
draggableObj
,
event
);
draggableObj
.
mouseDown
.
call
(
draggableObj
,
event
);
});
});
...
@@ -399,16 +410,7 @@ define(['logme', 'update_input'], function (logme, updateInput) {
...
@@ -399,16 +410,7 @@ define(['logme', 'update_input'], function (logme, updateInput) {
draggableObj
.
mouseMove
.
call
(
draggableObj
,
event
);
draggableObj
.
mouseMove
.
call
(
draggableObj
,
event
);
});
});
draggableObj
.
id
=
obj
.
id
;
draggableObj
.
x
=
-
1
;
draggableObj
.
y
=
-
1
;
state
.
numDraggablesInSlider
+=
1
;
state
.
numDraggablesInSlider
+=
1
;
if
(
obj
.
icon
.
length
===
0
)
{
draggableObj
.
hasLoaded
=
true
;
}
state
.
draggables
.
push
(
draggableObj
);
state
.
draggables
.
push
(
draggableObj
);
}
}
...
...
common/static/js/capa/drag_and_drop/main.js
View file @
f1588738
...
@@ -70,6 +70,10 @@ define(
...
@@ -70,6 +70,10 @@ define(
if
(
updateInput
.
check
(
state
)
===
false
)
{
if
(
updateInput
.
check
(
state
)
===
false
)
{
updateInput
.
update
(
state
);
updateInput
.
update
(
state
);
}
}
setTimeout
(
function
()
{
logme
(
'state.draggables'
,
state
.
draggables
);
},
500
);
}());
}());
}
}
});
});
...
...
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