Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
7866247f
Commit
7866247f
authored
Dec 05, 2019
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dragresize: Unregister global event handlers
parent
97b8ecbb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
41 deletions
+52
-41
src/converse-dragresize.js
src/converse-dragresize.js
+36
-26
src/headless/converse-core.js
src/headless/converse-core.js
+16
-15
No files found.
src/converse-dragresize.js
View file @
7866247f
...
@@ -331,37 +331,47 @@ converse.plugins.add('converse-dragresize', {
...
@@ -331,37 +331,47 @@ converse.plugins.add('converse-dragresize', {
};
};
function
onMouseMove
(
ev
)
{
if
(
!
_converse
.
resizing
||
!
_converse
.
allow_dragresize
)
{
return
true
;
}
ev
.
preventDefault
();
_converse
.
resizing
.
chatbox
.
resizeChatBox
(
ev
);
}
function
onMouseUp
(
ev
)
{
if
(
!
_converse
.
resizing
||
!
_converse
.
allow_dragresize
)
{
return
true
;
}
ev
.
preventDefault
();
const
height
=
u
.
applyDragResistance
(
_converse
.
resizing
.
chatbox
.
height
,
_converse
.
resizing
.
chatbox
.
model
.
get
(
'
default_height
'
)
);
const
width
=
u
.
applyDragResistance
(
_converse
.
resizing
.
chatbox
.
width
,
_converse
.
resizing
.
chatbox
.
model
.
get
(
'
default_width
'
)
);
if
(
_converse
.
api
.
connection
.
connected
())
{
_converse
.
resizing
.
chatbox
.
model
.
save
({
'
height
'
:
height
});
_converse
.
resizing
.
chatbox
.
model
.
save
({
'
width
'
:
width
});
}
else
{
_converse
.
resizing
.
chatbox
.
model
.
set
({
'
height
'
:
height
});
_converse
.
resizing
.
chatbox
.
model
.
set
({
'
width
'
:
width
});
}
_converse
.
resizing
=
null
;
}
/************************ BEGIN Event Handlers ************************/
/************************ BEGIN Event Handlers ************************/
function
registerGlobalEventHandlers
()
{
function
registerGlobalEventHandlers
()
{
document
.
addEventListener
(
'
mousemove
'
,
onMouseMove
);
document
.
addEventListener
(
'
mouseup
'
,
onMouseUp
);
}
document
.
addEventListener
(
'
mousemove
'
,
function
(
ev
)
{
function
unregisterGlobalEventHandlers
()
{
if
(
!
_converse
.
resizing
||
!
_converse
.
allow_dragresize
)
{
return
true
;
}
document
.
removeEventListener
(
'
mousemove
'
,
onMouseMove
);
ev
.
preventDefault
();
document
.
removeEventListener
(
'
mouseup
'
,
onMouseUp
);
_converse
.
resizing
.
chatbox
.
resizeChatBox
(
ev
);
});
document
.
addEventListener
(
'
mouseup
'
,
function
(
ev
)
{
if
(
!
_converse
.
resizing
||
!
_converse
.
allow_dragresize
)
{
return
true
;
}
ev
.
preventDefault
();
const
height
=
u
.
applyDragResistance
(
_converse
.
resizing
.
chatbox
.
height
,
_converse
.
resizing
.
chatbox
.
model
.
get
(
'
default_height
'
)
);
const
width
=
u
.
applyDragResistance
(
_converse
.
resizing
.
chatbox
.
width
,
_converse
.
resizing
.
chatbox
.
model
.
get
(
'
default_width
'
)
);
if
(
_converse
.
api
.
connection
.
connected
())
{
_converse
.
resizing
.
chatbox
.
model
.
save
({
'
height
'
:
height
});
_converse
.
resizing
.
chatbox
.
model
.
save
({
'
width
'
:
width
});
}
else
{
_converse
.
resizing
.
chatbox
.
model
.
set
({
'
height
'
:
height
});
_converse
.
resizing
.
chatbox
.
model
.
set
({
'
width
'
:
width
});
}
_converse
.
resizing
=
null
;
});
}
}
_converse
.
api
.
listen
.
on
(
'
registeredGlobalEventHandlers
'
,
registerGlobalEventHandlers
);
_converse
.
api
.
listen
.
on
(
'
registeredGlobalEventHandlers
'
,
registerGlobalEventHandlers
);
_converse
.
api
.
listen
.
on
(
'
unregisteredGlobalEventHandlers
'
,
unregisterGlobalEventHandlers
);
_converse
.
api
.
listen
.
on
(
'
beforeShowingChatView
'
,
view
=>
view
.
initDragResize
().
setDimensions
());
_converse
.
api
.
listen
.
on
(
'
beforeShowingChatView
'
,
view
=>
view
.
initDragResize
().
setDimensions
());
/************************ END Event Handlers ************************/
/************************ END Event Handlers ************************/
}
}
...
...
src/headless/converse-core.js
View file @
7866247f
...
@@ -836,7 +836,7 @@ async function finishInitialization () {
...
@@ -836,7 +836,7 @@ async function finishInitialization () {
await
initStorage
();
await
initStorage
();
initClientConfig
();
initClientConfig
();
initPlugins
();
initPlugins
();
_converse
.
registerGlobalEventHandlers
();
registerGlobalEventHandlers
();
if
(
!
Backbone
.
History
.
started
)
{
if
(
!
Backbone
.
History
.
started
)
{
Backbone
.
history
.
start
();
Backbone
.
history
.
start
();
...
@@ -927,6 +927,21 @@ async function getLoginCredentialsFromBrowser () {
...
@@ -927,6 +927,21 @@ async function getLoginCredentialsFromBrowser () {
}
}
function
registerGlobalEventHandlers
()
{
document
.
addEventListener
(
"
visibilitychange
"
,
_converse
.
saveWindowState
);
_converse
.
saveWindowState
({
'
type
'
:
document
.
hidden
?
"
blur
"
:
"
focus
"
});
// Set initial state
/**
* Called once Converse has registered its global event handlers
* (for events such as window resize or unload).
* Plugins can listen to this event as cue to register their own
* global event handlers.
* @event _converse#registeredGlobalEventHandlers
* @example _converse.api.listen.on('registeredGlobalEventHandlers', () => { ... });
*/
_converse
.
api
.
trigger
(
'
registeredGlobalEventHandlers
'
);
}
function
unregisterGlobalEventHandlers
()
{
function
unregisterGlobalEventHandlers
()
{
document
.
removeEventListener
(
"
visibilitychange
"
,
_converse
.
saveWindowState
);
document
.
removeEventListener
(
"
visibilitychange
"
,
_converse
.
saveWindowState
);
_converse
.
api
.
trigger
(
'
unregisteredGlobalEventHandlers
'
);
_converse
.
api
.
trigger
(
'
unregisteredGlobalEventHandlers
'
);
...
@@ -1174,20 +1189,6 @@ _converse.initialize = async function (settings, callback) {
...
@@ -1174,20 +1189,6 @@ _converse.initialize = async function (settings, callback) {
_converse
.
api
.
trigger
(
'
windowStateChanged
'
,
{
state
});
_converse
.
api
.
trigger
(
'
windowStateChanged
'
,
{
state
});
};
};
this
.
registerGlobalEventHandlers
=
function
()
{
document
.
addEventListener
(
"
visibilitychange
"
,
_converse
.
saveWindowState
);
_converse
.
saveWindowState
({
'
type
'
:
document
.
hidden
?
"
blur
"
:
"
focus
"
});
// Set initial state
/**
* Called once Converse has registered its global event handlers
* (for events such as window resize or unload).
* Plugins can listen to this event as cue to register their own
* global event handlers.
* @event _converse#registeredGlobalEventHandlers
* @example _converse.api.listen.on('registeredGlobalEventHandlers', () => { ... });
*/
_converse
.
api
.
trigger
(
'
registeredGlobalEventHandlers
'
);
};
this
.
bindResource
=
async
function
()
{
this
.
bindResource
=
async
function
()
{
/**
/**
* Synchronous event triggered before we send an IQ to bind the user's
* Synchronous event triggered before we send an IQ to bind the user's
...
...
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