Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
xblock-drag-and-drop-v2
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
OpenEdx
xblock-drag-and-drop-v2
Commits
7ccdeded
Commit
7ccdeded
authored
Jun 30, 2014
by
Filippo Valsorda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for image items
parent
92d83062
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
7 deletions
+29
-7
js/draggable_builder.js
+29
-7
No files found.
js/draggable_builder.js
View file @
7ccdeded
...
@@ -35,6 +35,14 @@ var dragAndDrop = (function() {
...
@@ -35,6 +35,14 @@ var dragAndDrop = (function() {
'</li>'
'</li>'
].
join
(
''
);
].
join
(
''
);
},
},
image_item
:
function
()
{
return
[
'<li class="option" data-value="<%= id %>"'
,
'style="width: <%= size.width %>; height: <%= size.height %>">'
,
'<img src="<%= backgroundImage %>" />'
,
'</li>'
].
join
(
''
);
},
zoneInput
:
function
()
{
zoneInput
:
function
()
{
return
[
return
[
'<div class="zone-row <%= name %>">'
,
'<div class="zone-row <%= name %>">'
,
...
@@ -81,6 +89,10 @@ var dragAndDrop = (function() {
...
@@ -81,6 +89,10 @@ var dragAndDrop = (function() {
'</a>'
,
'</a>'
,
'</div>'
,
'</div>'
,
'<div class="row">'
,
'<div class="row">'
,
'<label>Background image URL (alternative to the text)</label>'
,
'<textarea class="background-image"></textarea>'
,
'</div>'
,
'<div class="row">'
,
'<label>Success Feedback</label>'
,
'<label>Success Feedback</label>'
,
'<textarea class="success-feedback"></textarea>'
,
'<textarea class="success-feedback"></textarea>'
,
'</div>'
,
'</div>'
,
...
@@ -89,7 +101,7 @@ var dragAndDrop = (function() {
...
@@ -89,7 +101,7 @@ var dragAndDrop = (function() {
'<textarea class="error-feedback"></textarea>'
,
'<textarea class="error-feedback"></textarea>'
,
'</div>'
,
'</div>'
,
'<div class="row">'
,
'<div class="row">'
,
'<label>Width (px)</label>'
,
'<label>Width (px
- 0 for auto
)</label>'
,
'<input type="text" class="item-width" value="190"></input>'
,
'<input type="text" class="item-width" value="190"></input>'
,
'<label>Height (px - 0 for auto)</label>'
,
'<label>Height (px - 0 for auto)</label>'
,
'<input type="text" class="item-height" value="0"></input>'
,
'<input type="text" class="item-height" value="0"></input>'
,
...
@@ -406,15 +418,19 @@ var dragAndDrop = (function() {
...
@@ -406,15 +418,19 @@ var dragAndDrop = (function() {
$form
.
each
(
function
(
i
,
el
)
{
$form
.
each
(
function
(
i
,
el
)
{
var
$el
=
$
(
el
),
var
$el
=
$
(
el
),
name
=
$el
.
find
(
'.item-text'
).
val
();
name
=
$el
.
find
(
'.item-text'
).
val
(),
backgroundImage
=
$el
.
find
(
'.background-image'
).
val
();
if
(
name
.
length
>
0
)
{
if
(
name
.
length
>
0
||
backgroundImage
.
length
>
0
)
{
var
width
=
$el
.
find
(
'.item-width'
).
val
()
+
'px'
,
var
width
=
$el
.
find
(
'.item-width'
).
val
(),
height
=
$el
.
find
(
'.item-height'
).
val
();
height
=
$el
.
find
(
'.item-height'
).
val
();
if
(
height
===
'0'
)
height
=
'auto'
;
if
(
height
===
'0'
)
height
=
'auto'
;
else
height
=
height
+
'px'
;
else
height
=
height
+
'px'
;
if
(
width
===
'0'
)
width
=
'auto'
;
else
width
=
width
+
'px'
;
items
.
push
({
items
.
push
({
displayName
:
name
,
displayName
:
name
,
zone
:
$el
.
find
(
'.zone-select'
).
val
(),
zone
:
$el
.
find
(
'.zone-select'
).
val
(),
...
@@ -426,7 +442,8 @@ var dragAndDrop = (function() {
...
@@ -426,7 +442,8 @@ var dragAndDrop = (function() {
size
:
{
size
:
{
width
:
width
,
width
:
width
,
height
:
height
height
:
height
}
},
backgroundImage
:
backgroundImage
});
});
}
}
});
});
...
@@ -545,10 +562,15 @@ var dragAndDrop = (function() {
...
@@ -545,10 +562,15 @@ var dragAndDrop = (function() {
draw
:
function
()
{
draw
:
function
()
{
var
list
=
[],
var
list
=
[],
items
=
_fn
.
data
.
items
,
items
=
_fn
.
data
.
items
,
tpl
=
_fn
.
tpl
.
item
();
tpl
=
_fn
.
tpl
.
item
(),
img_tpl
=
_fn
.
tpl
.
image_item
();
_
.
each
(
items
,
function
(
item
)
{
_
.
each
(
items
,
function
(
item
)
{
list
.
push
(
_
.
template
(
tpl
,
item
)
);
if
(
item
.
backgroundImage
.
length
>
0
)
{
list
.
push
(
_
.
template
(
img_tpl
,
item
)
);
}
else
{
list
.
push
(
_
.
template
(
tpl
,
item
)
);
}
});
});
// Update DOM
// Update DOM
...
...
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