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
6c6b8534
Commit
6c6b8534
authored
Aug 23, 2017
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move functions out to make containing function smaller
parent
b31cdd77
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
20 deletions
+29
-20
src/utils.js
src/utils.js
+29
-20
No files found.
src/utils.js
View file @
6c6b8534
...
@@ -88,6 +88,25 @@
...
@@ -88,6 +88,25 @@
}
}
}
}
function
calculateElementHeight
(
el
)
{
/* Return the height of the passed in DOM element,
* based on the heights of its children.
*/
return
_
.
reduce
(
el
.
children
,
(
result
,
child
)
=>
result
+
child
.
offsetHeight
,
0
);
}
function
slideOutWrapup
(
el
)
{
/* Wrapup function for slideOut. */
el
.
removeAttribute
(
'
data-slider-marker
'
);
el
.
classList
.
remove
(
'
collapsed
'
);
el
.
style
.
overflow
=
""
;
el
.
style
.
height
=
""
;
}
var
u
=
{};
var
u
=
{};
// Translation machinery
// Translation machinery
...
@@ -186,22 +205,12 @@
...
@@ -186,22 +205,12 @@
};
};
u
.
slideOut
=
function
(
el
,
duration
=
900
)
{
u
.
slideOut
=
function
(
el
,
duration
=
900
)
{
/* Shows/expands an element by sliding it out of itself. */
/* Shows/expands an element by sliding it out of itself
*
function
calculateEndHeight
(
el
)
{
* Parameters:
return
_
.
reduce
(
* (HTMLElement) el - The HTML string
el
.
children
,
* (Number) duration - The duration amount in milliseconds
(
result
,
child
)
=>
result
+
child
.
offsetHeight
,
0
*/
);
}
function
wrapup
(
el
)
{
el
.
removeAttribute
(
'
data-slider-marker
'
);
el
.
classList
.
remove
(
'
collapsed
'
);
el
.
style
.
overflow
=
""
;
el
.
style
.
height
=
""
;
}
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
if
(
_
.
isNil
(
el
))
{
if
(
_
.
isNil
(
el
))
{
const
err
=
"
Undefined or null element passed into slideOut
"
const
err
=
"
Undefined or null element passed into slideOut
"
...
@@ -214,10 +223,10 @@
...
@@ -214,10 +223,10 @@
el
.
removeAttribute
(
'
data-slider-marker
'
);
el
.
removeAttribute
(
'
data-slider-marker
'
);
window
.
clearInterval
(
interval_marker
);
window
.
clearInterval
(
interval_marker
);
}
}
const
end_height
=
calculateE
nd
Height
(
el
);
const
end_height
=
calculateE
lement
Height
(
el
);
if
(
window
.
converse_disable_effects
)
{
// Effects are disabled (for tests)
if
(
window
.
converse_disable_effects
)
{
// Effects are disabled (for tests)
el
.
style
.
height
=
end_height
+
'
px
'
;
el
.
style
.
height
=
end_height
+
'
px
'
;
w
rapup
(
el
);
slideOutW
rapup
(
el
);
resolve
();
resolve
();
return
;
return
;
}
}
...
@@ -234,9 +243,9 @@
...
@@ -234,9 +243,9 @@
// We recalculate the height to work around an apparent
// We recalculate the height to work around an apparent
// browser bug where browsers don't know the correct
// browser bug where browsers don't know the correct
// offsetHeight beforehand.
// offsetHeight beforehand.
el
.
style
.
height
=
calculateE
nd
Height
(
el
)
+
'
px
'
;
el
.
style
.
height
=
calculateE
lement
Height
(
el
)
+
'
px
'
;
window
.
clearInterval
(
interval_marker
);
window
.
clearInterval
(
interval_marker
);
w
rapup
(
el
);
slideOutW
rapup
(
el
);
resolve
();
resolve
();
}
}
},
interval
);
},
interval
);
...
...
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