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
eccffa23
Commit
eccffa23
authored
Feb 02, 2016
by
Jillian Vogel
Committed by
Jonathan Piacenti
Feb 18, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
OC-1320 Added zone.align option select to the DnDv2 edit panel
parent
9865e721
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
3 deletions
+52
-3
drag_and_drop_v2/public/css/drag_and_drop_edit.css
+1
-1
drag_and_drop_v2/public/js/drag_and_drop_edit.js
+42
-2
drag_and_drop_v2/templates/html/js_templates.html
+9
-0
No files found.
drag_and_drop_v2/public/css/drag_and_drop_edit.css
View file @
eccffa23
...
@@ -144,7 +144,7 @@
...
@@ -144,7 +144,7 @@
here we make sure that both input fields get the same value for line-height */
here we make sure that both input fields get the same value for line-height */
}
}
.xblock--drag-and-drop--editor
.zones-form
.zone-row
.
layou
t
{
.xblock--drag-and-drop--editor
.zones-form
.zone-row
.
alignmen
t
{
margin-bottom
:
15px
;
margin-bottom
:
15px
;
}
}
...
...
drag_and_drop_v2/public/js/drag_and_drop_edit.js
View file @
eccffa23
...
@@ -23,6 +23,7 @@ function DragAndDropEditBlock(runtime, element, params) {
...
@@ -23,6 +23,7 @@ function DragAndDropEditBlock(runtime, element, params) {
tpl
:
{
tpl
:
{
init
:
function
()
{
init
:
function
()
{
_fn
.
tpl
=
{
_fn
.
tpl
=
{
zoneAlignDropdown
:
Handlebars
.
compile
(
$
(
"#zone-align-dropdown-tpl"
,
element
).
html
()),
zoneInput
:
Handlebars
.
compile
(
$
(
"#zone-input-tpl"
,
element
).
html
()),
zoneInput
:
Handlebars
.
compile
(
$
(
"#zone-input-tpl"
,
element
).
html
()),
zoneElement
:
Handlebars
.
compile
(
$
(
"#zone-element-tpl"
,
element
).
html
()),
zoneElement
:
Handlebars
.
compile
(
$
(
"#zone-element-tpl"
,
element
).
html
()),
zoneDropdown
:
Handlebars
.
compile
(
$
(
"#zone-dropdown-tpl"
,
element
).
html
()),
zoneDropdown
:
Handlebars
.
compile
(
$
(
"#zone-dropdown-tpl"
,
element
).
html
()),
...
@@ -171,7 +172,7 @@ function DragAndDropEditBlock(runtime, element, params) {
...
@@ -171,7 +172,7 @@ function DragAndDropEditBlock(runtime, element, params) {
_fn
.
build
.
form
.
zone
.
add
();
_fn
.
build
.
form
.
zone
.
add
();
})
})
.
on
(
'click'
,
'.remove-zone'
,
_fn
.
build
.
form
.
zone
.
remove
)
.
on
(
'click'
,
'.remove-zone'
,
_fn
.
build
.
form
.
zone
.
remove
)
.
on
(
'input'
,
'.zone-row input'
,
_fn
.
build
.
form
.
zone
.
changedInputHandler
)
.
on
(
'input'
,
'.zone-row input
, .zone-row select
'
,
_fn
.
build
.
form
.
zone
.
changedInputHandler
)
.
on
(
'click'
,
'.target-image-form button'
,
function
(
e
)
{
.
on
(
'click'
,
'.target-image-form button'
,
function
(
e
)
{
e
.
preventDefault
();
e
.
preventDefault
();
...
@@ -240,6 +241,8 @@ function DragAndDropEditBlock(runtime, element, params) {
...
@@ -240,6 +241,8 @@ function DragAndDropEditBlock(runtime, element, params) {
height
:
oldZone
.
height
||
100
,
height
:
oldZone
.
height
||
100
,
x
:
oldZone
.
x
||
0
,
x
:
oldZone
.
x
||
0
,
y
:
oldZone
.
y
||
0
,
y
:
oldZone
.
y
||
0
,
align
:
oldZone
.
align
||
''
,
align_dropdown
:
_fn
.
build
.
form
.
createAlignDropdown
(
oldZone
),
};
};
_fn
.
build
.
form
.
zone
.
zoneObjects
.
push
(
zoneObj
);
_fn
.
build
.
form
.
zone
.
zoneObjects
.
push
(
zoneObj
);
...
@@ -252,9 +255,11 @@ function DragAndDropEditBlock(runtime, element, params) {
...
@@ -252,9 +255,11 @@ function DragAndDropEditBlock(runtime, element, params) {
_fn
.
build
.
$el
.
zones
.
form
.
append
(
$zoneNode
);
_fn
.
build
.
$el
.
zones
.
form
.
append
(
$zoneNode
);
_fn
.
build
.
form
.
zone
.
enableDelete
();
_fn
.
build
.
form
.
zone
.
enableDelete
();
// Once form is built, clean out html from zoneObj
delete
zoneObj
[
'align_dropdown'
];
// Add zone div to target
// Add zone div to target
_fn
.
build
.
form
.
zone
.
renderZonesPreview
();
_fn
.
build
.
form
.
zone
.
renderZonesPreview
();
},
},
generateUID
:
function
()
{
generateUID
:
function
()
{
// Generate a unique ID for a new zone.
// Generate a unique ID for a new zone.
...
@@ -316,10 +321,29 @@ function DragAndDropEditBlock(runtime, element, params) {
...
@@ -316,10 +321,29 @@ function DragAndDropEditBlock(runtime, element, params) {
y_percent
:
(
+
zoneObj
.
y
)
/
imgHeight
*
100
,
y_percent
:
(
+
zoneObj
.
y
)
/
imgHeight
*
100
,
width_percent
:
(
+
zoneObj
.
width
)
/
imgWidth
*
100
,
width_percent
:
(
+
zoneObj
.
width
)
/
imgWidth
*
100
,
height_percent
:
(
+
zoneObj
.
height
)
/
imgHeight
*
100
,
height_percent
:
(
+
zoneObj
.
height
)
/
imgHeight
*
100
,
align
:
zoneObj
.
align
,
})
})
);
);
});
});
},
},
getZoneNames
:
function
()
{
var
zoneNames
=
[];
var
$form
=
_fn
.
build
.
$el
.
zones
.
form
.
find
(
'.title'
);
$form
.
each
(
function
(
i
,
el
)
{
var
val
=
$
(
el
).
val
();
if
(
val
.
length
>
0
)
{
zoneNames
.
push
(
val
);
}
});
return
zoneNames
;
},
getZoneAlignNames
:
function
()
{
var
alignNames
=
[
""
,
"left"
,
"center"
,
"right"
];
return
alignNames
;
},
changedInputHandler
:
function
(
ev
)
{
changedInputHandler
:
function
(
ev
)
{
// Called when any of the inputs have changed.
// Called when any of the inputs have changed.
var
$changedInput
=
$
(
ev
.
currentTarget
);
var
$changedInput
=
$
(
ev
.
currentTarget
);
...
@@ -337,6 +361,8 @@ function DragAndDropEditBlock(runtime, element, params) {
...
@@ -337,6 +361,8 @@ function DragAndDropEditBlock(runtime, element, params) {
record
.
x
=
$changedInput
.
val
();
record
.
x
=
$changedInput
.
val
();
}
else
if
(
$changedInput
.
hasClass
(
'y'
))
{
}
else
if
(
$changedInput
.
hasClass
(
'y'
))
{
record
.
y
=
$changedInput
.
val
();
record
.
y
=
$changedInput
.
val
();
}
else
if
(
$changedInput
.
hasClass
(
'align-select'
))
{
record
.
align
=
$changedInput
.
val
();
}
}
_fn
.
build
.
form
.
zone
.
renderZonesPreview
();
_fn
.
build
.
form
.
zone
.
renderZonesPreview
();
},
},
...
@@ -367,6 +393,20 @@ function DragAndDropEditBlock(runtime, element, params) {
...
@@ -367,6 +393,20 @@ function DragAndDropEditBlock(runtime, element, params) {
var
html
=
dropdown
.
join
(
''
);
var
html
=
dropdown
.
join
(
''
);
return
new
Handlebars
.
SafeString
(
html
);
return
new
Handlebars
.
SafeString
(
html
);
},
},
createAlignDropdown
:
function
(
selected
)
{
var
tpl
=
_fn
.
tpl
.
zoneAlignDropdown
,
dropdown
=
[],
html
,
dropdown_items
=
_fn
.
build
.
form
.
zone
.
getZoneAlignNames
();
for
(
var
i
=
0
;
i
<
dropdown_items
.
length
;
i
++
)
{
var
is_sel
=
(
dropdown_items
[
i
]
==
selected
[
'align'
])
?
'selected'
:
''
;
dropdown
.
push
(
tpl
({
value
:
dropdown_items
[
i
],
selected
:
is_sel
}));
}
html
=
dropdown
.
join
(
''
);
return
new
Handlebars
.
SafeString
(
html
);
},
feedback
:
function
(
$form
)
{
feedback
:
function
(
$form
)
{
_fn
.
data
.
feedback
=
{
_fn
.
data
.
feedback
=
{
start
:
$form
.
find
(
'#intro-feedback'
).
val
(),
start
:
$form
.
find
(
'#intro-feedback'
).
val
(),
...
...
drag_and_drop_v2/templates/html/js_templates.html
View file @
eccffa23
...
@@ -9,6 +9,10 @@
...
@@ -9,6 +9,10 @@
<
/div
>
<
/div
>
</script>
</script>
<script
id=
"zone-align-dropdown-tpl"
type=
"text/html"
>
<
option
value
=
"{{ value }}"
{{
selected
}}
>
{{
value
}}
<
/option
>
</script>
<script
id=
"zone-input-tpl"
type=
"text/html"
>
<script
id=
"zone-input-tpl"
type=
"text/html"
>
<
div
class
=
"zone-row"
data
-
uid
=
"{{zone.uid}}"
>
<
div
class
=
"zone-row"
data
-
uid
=
"{{zone.uid}}"
>
<!--
uid
values
from
old
versions
of
the
block
may
contain
spaces
and
other
characters
,
so
we
use
'index'
as
an
alternate
unique
ID
here
.
-->
<!--
uid
values
from
old
versions
of
the
block
may
contain
spaces
and
other
characters
,
so
we
use
'index'
as
an
alternate
unique
ID
here
.
-->
...
@@ -51,6 +55,11 @@
...
@@ -51,6 +55,11 @@
class
=
"coord y"
class
=
"coord y"
value
=
"{{ zone.y }}"
/>
value
=
"{{ zone.y }}"
/>
<
/div
>
<
/div
>
<
div
class
=
"alignment"
>
<
label
for
=
"zone-{{index}}-align"
>
align
<
/label
>
<
select
id
=
"zone-{{index}}-align"
class
=
"align-select"
>
{{
align_dropdown
}}
<
/select
>
<
/div
>
<
/div
>
<
/div
>
</script>
</script>
...
...
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