Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Knowledge Space WP Plugin
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
alg
Knowledge Space WP Plugin
Commits
d9087f9d
Commit
d9087f9d
authored
2 years ago
by
Matthias Konitzny
Browse files
Options
Downloads
Patches
Plain Diff
Modernized helpers
parent
bcfd4d76
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/common/helpers.ts
+17
-0
17 additions, 0 deletions
src/common/helpers.ts
src/display/display.tsx
+5
-5
5 additions, 5 deletions
src/display/display.tsx
src/display/helpers.js
+0
-58
0 additions, 58 deletions
src/display/helpers.js
with
22 additions
and
63 deletions
src/common/helpers.ts
0 → 100644
+
17
−
0
View file @
d9087f9d
export
{
getClientWidth
,
getWindowInnerHeight
};
/**
* Returns the maximum width that should be used if displaying elements inside of wordpress.
* @returns {number}
*/
function
getClientWidth
(
elementId
:
string
):
number
{
return
document
.
getElementById
(
"
knowledge-space-display
"
).
clientWidth
;
}
/**
* Returns the maximum height that should be used if displaying elements inside of wordpress.
* @returns {number}
*/
function
getWindowInnerHeight
(
offset
=
200
):
number
{
return
window
.
innerHeight
-
offset
;
}
This diff is collapsed.
Click to expand it.
src/display/display.tsx
+
5
−
5
View file @
d9087f9d
...
...
@@ -4,7 +4,7 @@ import PropTypes, { InferType } from "prop-types";
import
"
./display.css
"
;
import
{
VisualGraphNode
,
GraphRenderer
}
from
"
./renderer
"
;
import
*
as
Helpers
from
"
./helpers
"
;
import
*
as
Helpers
from
"
.
./common
/helpers
"
;
import
{
Graph
}
from
"
../common/graph/graph
"
;
import
{
loadGraphJson
}
from
"
../common/datasets
"
;
import
NodeInfoBar
from
"
./components/nodeinfo/nodeinfobar
"
;
...
...
@@ -58,8 +58,8 @@ class Display extends React.Component<
componentDidMount
()
{
this
.
setState
({
width
:
Helpers
.
get
Width
(
),
height
:
Helpers
.
getHeight
(),
width
:
Helpers
.
get
ClientWidth
(
"
knowledge-space-display
"
),
height
:
Helpers
.
get
WindowInner
Height
(
200
),
});
const
fetchGraph
=
async
()
=>
{
...
...
@@ -101,8 +101,8 @@ class Display extends React.Component<
});
}
else
{
this
.
setState
({
width
:
Helpers
.
get
Width
(
),
height
:
Helpers
.
getHeight
(),
width
:
Helpers
.
get
ClientWidth
(
"
knowledge-space-display
"
),
height
:
Helpers
.
get
WindowInner
Height
(
200
),
});
}
...
...
This diff is collapsed.
Click to expand it.
src/display/helpers.js
deleted
100644 → 0
+
0
−
58
View file @
bcfd4d76
export
{
getWidth
,
getHeight
,
getCanvasDivNode
,
createDiv
,
createHTMLElement
};
/**
* Returns the maximum width that should be used if displaying elements inside of wordpress.
* @returns {number}
*/
function
getWidth
()
{
return
document
.
getElementById
(
"
knowledge-space-display
"
).
clientWidth
;
}
/**
* Returns the maximum height that should be used if displaying elements inside of wordpress.
* @returns {number}
*/
function
getHeight
()
{
return
window
.
innerHeight
-
200
;
}
/**
* Returns the div node which encapsulates the canvas the 3d-force-graph is drawn on.
* @returns {ChildNode}
*/
function
getCanvasDivNode
()
{
const
domNode
=
document
.
getElementById
(
"
3d-graph
"
);
return
domNode
.
firstChild
.
firstChild
.
firstChild
;
}
/**
* Creates a new div element.
* @param {string} className Class name of the new div element.
* @param {HTMLElement} parent Optional parent element of the new div.
* @param opts Defines any additional values that should be set for the new div element.
* @returns {HTMLDivElement} The new div element.
*/
function
createDiv
(
className
,
parent
,
opts
=
{})
{
opts
[
"
className
"
]
=
className
;
return
createHTMLElement
(
"
div
"
,
parent
,
opts
);
}
/**
* Creates a new HTML element with specified options.
* @param {string} type Type of the new element (e.g. div or img)
* @param {HTMLElement} parent Optional parent for the new element.
* @param opts Optional parameters to attach to the new element.
* @returns {HTMLElement}
*/
function
createHTMLElement
(
type
,
parent
,
opts
=
{})
{
const
node
=
document
.
createElement
(
type
);
for
(
const
[
key
,
value
]
of
Object
.
entries
(
opts
))
{
node
[
key
]
=
value
;
}
if
(
typeof
parent
!==
"
undefined
"
)
{
parent
.
appendChild
(
node
);
}
return
node
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment