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
dae644a9
Commit
dae644a9
authored
Jul 04, 2014
by
Filippo Valsorda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Kill some Studio unused code
parent
f6237815
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
191 deletions
+0
-191
drag_and_drop_v2/public/js/drag_and_drop_edit.js
+0
-191
No files found.
drag_and_drop_v2/public/js/drag_and_drop_edit.js
View file @
dae644a9
...
...
@@ -3,28 +3,7 @@ function DragAndDropEditBlock(runtime, element) {
var
_fn
=
{
// DOM Elements
$block
:
$
(
'.xblock--drag-and-drop'
,
element
),
$app
:
$
(
'.xblock--drag-and-drop .drag-container'
,
element
),
$ul
:
$
(
'.xblock--drag-and-drop .items'
,
element
),
$target
:
$
(
'.xblock--drag-and-drop .target-img'
,
element
),
$feedback
:
$
(
'.xblock--drag-and-drop .feedback .message'
,
element
),
// Cannot set until items added to DOM
$items
:
{},
// $('.xblock--drag-and-drop .items .option'),
$zones
:
{},
// $('.xblock--drag-and-drop .target .zone'),
// jQuery UI Draggable options
options
:
{
drag
:
{
containment
:
'.xblock--drag-and-drop .drag-container'
,
cursor
:
'move'
,
stack
:
'.xblock--drag-and-drop .items .option'
},
drop
:
{
accept
:
'.xblock--drag-and-drop .items .option'
,
tolerance
:
'pointer'
}
},
// item template
tpl
:
{
...
...
@@ -455,176 +434,6 @@ function DragAndDropEditBlock(runtime, element) {
}
},
finish
:
function
()
{
// Disable any decoy items
_fn
.
$items
.
draggable
(
'disable'
);
// Show final feedback
_fn
.
feedback
.
set
(
_fn
.
data
.
feedback
.
finish
);
},
clickHandlers
:
{
init
:
function
(
$drag
,
$dropzone
)
{
var
clk
=
_fn
.
clickHandlers
;
$drag
.
on
(
'dragstart'
,
clk
.
drag
.
start
);
$drag
.
on
(
'dragstop'
,
clk
.
drag
.
stop
);
$dropzone
.
on
(
'drop'
,
clk
.
drop
.
success
);
$dropzone
.
on
(
'dropover'
,
clk
.
drop
.
hover
.
in
);
$dropzone
.
on
(
'dropout'
,
clk
.
drop
.
hover
.
out
);
},
drag
:
{
start
:
function
(
event
,
ui
)
{
$
(
event
.
currentTarget
).
removeClass
(
'within-dropzone fade'
);
},
stop
:
function
(
event
,
ui
)
{
var
$el
=
$
(
event
.
currentTarget
),
val
=
$el
.
data
(
'value'
),
zone
=
$el
.
data
(
'zone'
)
||
null
;
if
(
$el
.
hasClass
(
'within-dropzone'
)
&&
_fn
.
test
.
match
(
val
,
zone
))
{
$el
.
removeClass
(
'hover'
)
.
draggable
(
'disable'
);
_fn
.
test
.
completed
++
;
_fn
.
feedback
.
popup
(
_fn
.
feedback
.
get
(
val
,
true
),
true
);
if
(
_fn
.
items
.
allSubmitted
())
{
_fn
.
finish
();
}
}
else
{
// Return to original position
_fn
.
clickHandlers
.
drag
.
reset
(
$el
);
_fn
.
feedback
.
popup
(
_fn
.
feedback
.
get
(
val
,
false
),
false
);
}
},
reset
:
function
(
$el
)
{
$el
.
removeClass
(
'within-dropzone fade hover'
)
.
css
({
top
:
''
,
left
:
''
});
}
},
drop
:
{
hover
:
{
in
:
function
(
event
,
ui
)
{
var
zone
=
$
(
event
.
currentTarget
).
data
(
'zone'
);
ui
.
draggable
.
addClass
(
'hover'
).
data
(
'zone'
,
zone
);
},
out
:
function
(
event
,
ui
)
{
ui
.
draggable
.
removeClass
(
'hover'
);
}
},
success
:
function
(
event
,
ui
)
{
ui
.
draggable
.
addClass
(
'within-dropzone'
)
}
}
},
items
:
{
count
:
0
,
init
:
function
()
{
var
items
=
_fn
.
data
.
items
,
i
,
len
=
items
.
length
,
total
=
0
;
for
(
i
=
0
;
i
<
len
;
i
++
)
{
if
(
items
[
i
].
zone
!==
'none'
)
{
total
++
;
}
}
_fn
.
items
.
count
=
total
;
},
allSubmitted
:
function
()
{
return
_fn
.
test
.
completed
===
_fn
.
items
.
count
;
},
draw
:
function
()
{
var
list
=
[],
items
=
_fn
.
data
.
items
,
tpl
=
_fn
.
tpl
.
item
(),
img_tpl
=
_fn
.
tpl
.
image_item
();
_
.
each
(
items
,
function
(
item
)
{
if
(
item
.
backgroundImage
.
length
>
0
)
{
list
.
push
(
_
.
template
(
img_tpl
,
item
));
}
else
{
list
.
push
(
_
.
template
(
tpl
,
item
));
}
});
// Update DOM
_fn
.
$ul
.
html
(
list
.
join
(
''
));
// Set variable
_fn
.
$items
=
$
(
'.xblock--drag-and-drop .items .option'
,
element
);
}
},
zones
:
{
draw
:
function
()
{
var
html
=
[],
zones
=
_fn
.
data
.
zones
,
tpl
=
_fn
.
tpl
.
zoneElement
(),
i
,
len
=
zones
.
length
;
for
(
i
=
0
;
i
<
len
;
i
++
)
{
html
.
push
(
_
.
template
(
tpl
,
zones
[
i
]));
}
// Update DOM
_fn
.
$target
.
html
(
html
.
join
(
''
));
// Set variable
_fn
.
$zones
=
_fn
.
$target
.
find
(
'.zone'
);
}
},
test
:
{
completed
:
0
,
match
:
function
(
id
,
zone
)
{
var
item
=
_
.
findWhere
(
_fn
.
data
.
items
,
{
id
:
id
});
return
item
.
zone
===
zone
;
}
},
feedback
:
{
// Returns string based on user's answer
get
:
function
(
id
,
boo
)
{
var
item
,
type
=
boo
?
'correct'
:
'incorrect'
;
// Null loses its string-ness
if
(
id
===
null
)
{
id
=
'null'
;
}
// Get object from data.items that matches val
item
=
_
.
findWhere
(
_fn
.
data
.
items
,
{
id
:
id
});
return
item
.
feedback
[
type
];
},
// Update DOM with feedback
set
:
function
(
str
)
{
return
_fn
.
$feedback
.
html
(
str
);
},
// Show a feedback popup
popup
:
function
(
str
,
boo
)
{
if
(
str
===
undefined
||
str
===
''
)
return
;
return
$
(
"<div>"
).
attr
(
'title'
,
boo
?
'Correct'
:
'Error'
).
text
(
str
).
dialog
();
}
},
data
:
null
};
...
...
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