Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nikola Balog
erp5
Commits
2efe40c3
Commit
2efe40c3
authored
Feb 12, 2021
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_core/graph_editor: add compatibility with renderJS.loopEventListener
parent
d76f81f4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
99 deletions
+9
-99
bt5/erp5_graph_editor/SkinTemplateItem/portal_skins/erp5_graph_editor/dream_graph_editor/dream/mixin_promise.js.js
...graph_editor/dream_graph_editor/dream/mixin_promise.js.js
+4
-40
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/gadget_global.js.js
...inTemplateItem/portal_skins/erp5_core/gadget_global.js.js
+5
-59
No files found.
bt5/erp5_graph_editor/SkinTemplateItem/portal_skins/erp5_graph_editor/dream_graph_editor/dream/mixin_promise.js.js
View file @
2efe40c3
/// FIXME: merge into the gadget using these utilities and remove this file
/// FIXME: merge into the gadget using these utilities and remove this file
/*global RSVP, FileReader */
/*global RSVP, FileReader
, renderJS
*/
/*jslint unparam: true */
/*jslint unparam: true */
(
function
(
window
,
RSVP
,
FileReader
)
{
(
function
(
window
,
RSVP
,
FileReader
,
renderJS
)
{
"
use strict
"
;
"
use strict
"
;
window
.
loopEventListener
=
function
(
target
,
type
,
useCapture
,
callback
,
allowDefault
)
{
window
.
loopEventListener
=
renderJS
.
loopEventListener
;
//////////////////////////
// Infinite event listener (promise is never resolved)
// eventListener is removed when promise is cancelled/rejected
//////////////////////////
var
handle_event_callback
,
callback_promise
;
function
cancelResolver
()
{
if
(
callback_promise
!==
undefined
&&
typeof
callback_promise
.
cancel
===
"
function
"
)
{
callback_promise
.
cancel
();
}
}
function
canceller
()
{
if
(
handle_event_callback
!==
undefined
)
{
target
.
removeEventListener
(
type
,
handle_event_callback
,
useCapture
);
}
cancelResolver
();
}
function
itsANonResolvableTrap
(
resolve
,
reject
)
{
handle_event_callback
=
function
(
evt
)
{
evt
.
stopPropagation
();
if
(
allowDefault
!==
true
)
{
evt
.
preventDefault
();
}
cancelResolver
();
callback_promise
=
new
RSVP
.
Queue
().
push
(
function
()
{
return
callback
(
evt
);
}).
push
(
undefined
,
function
(
error
)
{
if
(
!
(
error
instanceof
RSVP
.
CancellationError
))
{
canceller
();
reject
(
error
);
}
});
};
target
.
addEventListener
(
type
,
handle_event_callback
,
useCapture
);
}
return
new
RSVP
.
Promise
(
itsANonResolvableTrap
,
canceller
);
};
window
.
promiseEventListener
=
function
(
target
,
type
,
useCapture
)
{
window
.
promiseEventListener
=
function
(
target
,
type
,
useCapture
)
{
//////////////////////////
//////////////////////////
// Resolve the promise as soon as the event is triggered
// Resolve the promise as soon as the event is triggered
...
@@ -74,4 +38,4 @@
...
@@ -74,4 +38,4 @@
reader
.
readAsText
(
file
);
reader
.
readAsText
(
file
);
});
});
};
};
})(
window
,
RSVP
,
FileReader
);
})(
window
,
RSVP
,
FileReader
,
renderJS
);
\ No newline at end of file
\ No newline at end of file
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/gadget_global.js.js
View file @
2efe40c3
/*global window, RSVP, FileReader */
/*global window, RSVP, FileReader
, renderJS
*/
/*jslint indent: 2, maxerr: 3, unparam: true */
/*jslint indent: 2, maxerr: 3, unparam: true */
(
function
(
window
,
RSVP
,
FileReader
)
{
(
function
(
window
,
RSVP
,
FileReader
,
renderJS
)
{
"
use strict
"
;
"
use strict
"
;
...
@@ -62,62 +62,8 @@
...
@@ -62,62 +62,8 @@
}
}
window
.
asBoolean
=
asBoolean
;
window
.
asBoolean
=
asBoolean
;
window
.
loopEventListener
=
function
(
target
,
type
,
useCapture
,
callback
,
// Compatibility with gadgets not accessing this function from renderJS
prevent_default
)
{
window
.
loopEventListener
=
renderJS
.
loopEventListener
;
//////////////////////////
// Infinite event listener (promise is never resolved)
// eventListener is removed when promise is cancelled/rejected
//////////////////////////
var
handle_event_callback
,
callback_promise
;
if
(
prevent_default
===
undefined
)
{
prevent_default
=
true
;
}
function
cancelResolver
()
{
if
((
callback_promise
!==
undefined
)
&&
(
typeof
callback_promise
.
cancel
===
"
function
"
))
{
callback_promise
.
cancel
();
}
}
function
canceller
()
{
if
(
handle_event_callback
!==
undefined
)
{
target
.
removeEventListener
(
type
,
handle_event_callback
,
useCapture
);
}
cancelResolver
();
}
function
itsANonResolvableTrap
(
resolve
,
reject
)
{
var
result
;
handle_event_callback
=
function
(
evt
)
{
if
(
prevent_default
)
{
evt
.
stopPropagation
();
evt
.
preventDefault
();
}
cancelResolver
();
try
{
result
=
callback
(
evt
);
}
catch
(
e
)
{
result
=
reject
(
e
);
}
callback_promise
=
new
RSVP
.
Queue
(
result
)
.
push
(
undefined
,
function
handleEventCallbackError
(
error
)
{
// Prevent rejecting the loop, if the result cancelled itself
if
(
!
(
error
instanceof
RSVP
.
CancellationError
))
{
canceller
();
reject
(
error
);
}
});
};
target
.
addEventListener
(
type
,
handle_event_callback
,
useCapture
);
}
return
new
RSVP
.
Promise
(
itsANonResolvableTrap
,
canceller
);
};
window
.
promiseEventListener
=
function
(
target
,
type
,
useCapture
)
{
window
.
promiseEventListener
=
function
(
target
,
type
,
useCapture
)
{
//////////////////////////
//////////////////////////
...
@@ -182,4 +128,4 @@
...
@@ -182,4 +128,4 @@
});
});
};
};
}(
window
,
RSVP
,
FileReader
));
}(
window
,
RSVP
,
FileReader
,
renderJS
));
\ No newline at end of file
\ 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