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
48fa4b4a
Commit
48fa4b4a
authored
Jan 22, 2013
by
Don Mitchell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cache in order to try updated sortable lib
parent
edda80d4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
0 deletions
+51
-0
cms/static/js/hesitate.js
+51
-0
No files found.
cms/static/js/hesitate.js
0 → 100644
View file @
48fa4b4a
/*
* Create a HesitateEvent and assign it as the event to execute:
* $(el).on('mouseEnter', CMS.HesitateEvent( expand, 'mouseLeave').trigger);
* It calls the executeOnTimeOut function with the event.currentTarget after the configurable timeout IFF the cancelSelector event
* did not occur on the event.currentTarget.
*
* More specifically, when trigger is called (triggered by the event you bound it to), it starts a timer
* which the cancelSelector event will cancel or if the timer finished, it executes the executeOnTimeOut function
* passing it the original event (whose currentTarget s/b the specific ele). It never accumulates events; however, it doesn't hurt for your
* code to minimize invocations of trigger by binding to mouseEnter v mouseOver and such.
*
* NOTE: if something outside of this wants to cancel the event, invoke cachedhesitation.untrigger(null | anything);
*/
CMS
.
HesitateEvent
=
function
(
executeOnTimeOut
,
cancelSelector
,
onlyOnce
=
false
)
{
this
.
executeOnTimeOut
=
executeOnTimeOut
;
this
.
cancelSelector
=
cancelSelector
;
this
.
timeoutEventId
=
null
;
this
.
originalEvent
=
null
;
this
.
onlyOnce
=
onlyOnce
;
}
CMS
.
HesitateEvent
.
DURATION
=
400
;
CMS
.
HesitateEvent
.
prototype
.
trigger
=
function
(
event
)
{
console
.
log
(
'trigger'
);
if
(
this
.
timeoutEventId
===
null
)
{
this
.
timeoutEventId
=
window
.
setTimeout
(
this
.
fireEvent
,
CMS
.
HesitateEvent
.
DURATION
);
this
.
originalEvent
=
event
;
// is it wrong to bind to the below v $(event.currentTarget)?
$
(
this
.
originalEvent
.
delegateTarget
).
on
(
this
.
cancelSelector
,
this
.
untrigger
);
}
}
CMS
.
HesitateEvent
.
prototype
.
fireEvent
=
function
(
event
)
{
console
.
log
(
'fire'
);
this
.
timeoutEventId
=
null
;
$
(
this
.
originalEvent
.
delegateTarget
).
off
(
this
.
cancelSelector
,
this
.
untrigger
);
if
(
this
.
onlyOnce
)
$
(
this
.
originalEvent
.
delegateTarget
).
off
(
this
.
originalEvent
.
type
,
this
.
trigger
);
this
.
executeOnTimeOut
(
this
.
originalEvent
);
}
CMS
.
HesitateEvent
.
prototype
.
untrigger
=
function
(
event
)
{
console
.
log
(
'untrigger'
);
if
(
this
.
timeoutEventId
)
{
window
.
clearTimeout
(
this
.
timeoutEventId
);
$
(
this
.
originalEvent
.
delegateTarget
).
off
(
this
.
cancelSelector
,
this
.
untrigger
);
}
this
.
timeoutEventId
=
null
;
}
\ No newline at end of file
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