Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
simple_klaro
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
simple_klaro
Commits
34e6054e
Commit
34e6054e
authored
2 years ago
by
Erik Seifert
Committed by
Norman Kämper-Leymann
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3336104
by Erik Seifert, leymannx: Fix js coding standards
parent
dca4841c
No related branches found
No related tags found
1 merge request
!14
Issue #3336104: Fix js coding standards
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
.eslintrc.json
+36
-0
36 additions, 0 deletions
.eslintrc.json
js/editor.js
+30
-29
30 additions, 29 deletions
js/editor.js
js/klaro.drupal.js
+28
-23
28 additions, 23 deletions
js/klaro.drupal.js
simple_klaro.libraries.yml
+1
-0
1 addition, 0 deletions
simple_klaro.libraries.yml
with
95 additions
and
52 deletions
.eslintrc.json
0 → 100644
+
36
−
0
View file @
34e6054e
{
"globals"
:
{
"ace"
:
true
,
"klaro"
:
true
},
"rules"
:
{
"prettier/prettier"
:
[
"error"
,
{
"printWidth"
:
80
,
"semi"
:
true
,
"singleQuote"
:
true
,
"trailingComma"
:
"all"
}
],
"consistent-return"
:
[
"off"
],
"no-underscore-dangle"
:
[
"off"
],
"max-nested-callbacks"
:
[
"warn"
,
3
],
"import/no-mutable-exports"
:
[
"warn"
],
"no-plusplus"
:
[
"warn"
,
{
"allowForLoopAfterthoughts"
:
true
}],
"no-param-reassign"
:
[
"off"
],
"no-prototype-builtins"
:
[
"off"
],
"valid-jsdoc"
:
[
"warn"
,
{
"prefer"
:
{
"returns"
:
"return"
,
"property"
:
"prop"
},
"requireReturn"
:
false
}],
"no-unused-vars"
:
[
"warn"
],
"operator-linebreak"
:
[
"error"
,
"after"
,
{
"overrides"
:
{
"?"
:
"ignore"
,
":"
:
"ignore"
}
}],
"yml/indent"
:
[
"error"
,
2
]
}
}
This diff is collapsed.
Click to expand it.
js/editor.js
+
30
−
29
View file @
34e6054e
(
function
(
Drupal
,
once
)
{
"
use strict
"
;
((
Drupal
,
once
)
=>
{
Drupal
.
behaviors
.
klaroEditor
=
{
attach
:
function
(
context
)
{
var
initEditor
=
function
()
{
once
(
'
textarea
'
,
'
[data-klaro-editor]
'
,
context
).
forEach
(
function
(
textarea
)
{
var
editDiv
=
document
.
createElement
(
'
div
'
);
textarea
.
classList
.
add
(
'
visually-hidden
'
);
textarea
.
parentNode
.
insertBefore
(
editDiv
,
textarea
);
editDiv
.
style
.
fontSize
=
18
;
attach
(
context
)
{
const
initEditor
=
()
=>
{
once
(
'
klaro-editor
'
,
'
[data-klaro-editor]
'
,
context
).
forEach
(
(
textarea
)
=>
{
const
editDiv
=
document
.
createElement
(
'
div
'
);
textarea
.
classList
.
add
(
'
visually-hidden
'
);
textarea
.
parentNode
.
insertBefore
(
editDiv
,
textarea
);
editDiv
.
style
.
fontSize
=
18
;
// Init ace editor.
ace
.
config
.
set
(
'
basePath
'
,
'
https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.11/
'
);
var
editor
=
ace
.
edit
(
editDiv
);
editor
.
session
.
setValue
(
textarea
.
value
);
editor
.
session
.
setMode
(
"
ace/mode/json
"
);
editor
.
session
.
setTabSize
(
2
);
editor
.
setTheme
(
'
ace/theme/chrome
'
);
editor
.
setOptions
({
minLines
:
3
,
maxLines
:
20
});
// Init ace editor.
ace
.
config
.
set
(
'
basePath
'
,
'
https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.11/
'
,
);
const
editor
=
ace
.
edit
(
editDiv
);
editor
.
session
.
setValue
(
textarea
.
value
);
editor
.
session
.
setMode
(
'
ace/mode/json
'
);
editor
.
session
.
setTabSize
(
2
);
editor
.
setTheme
(
'
ace/theme/chrome
'
);
editor
.
setOptions
({
minLines
:
3
,
maxLines
:
20
,
});
// Update Drupal textarea value.
editor
.
getSession
().
on
(
'
change
'
,
function
()
{
textarea
.
value
=
editor
.
getSession
().
getValue
();
});
});
// Update Drupal textarea value.
editor
.
getSession
().
on
(
'
change
'
,
()
=>
{
textarea
.
value
=
editor
.
getSession
().
getValue
();
});
},
);
};
// Initialize editor.
if
(
typeof
ace
!==
'
undefined
'
)
{
initEditor
();
}
}
}
,
};
})(
Drupal
,
once
);
This diff is collapsed.
Click to expand it.
js/klaro.drupal.js
+
28
−
23
View file @
34e6054e
(
function
(
Drupal
,
drupalSettings
)
{
'
use strict
'
;
((
Drupal
,
drupalSettings
,
once
)
=>
{
Drupal
.
behaviors
.
klaro
=
{
attach
:
function
attach
(
context
)
{
if
(
drupalSettings
.
klaroConfig
!==
undefined
&&
context
===
document
)
{
if
(
drupalSettings
.
klaroConfig
)
{
// Open preferences
let
preferences
=
document
.
querySelectorAll
(
"
#klaro-preferences, .klaro-preferences
"
);
if
(
drupalSettings
.
klaroConfig
.
services
!==
undefined
)
{
drupalSettings
.
klaroConfig
.
services
.
forEach
(
function
(
value
,
index
)
{
if
(
drupalSettings
.
klaroConfig
.
services
[
index
].
callback
!==
undefined
)
{
drupalSettings
.
klaroConfig
.
services
[
index
].
callback
=
new
Function
(
"
return
"
+
drupalSettings
.
klaroConfig
.
services
[
index
].
callback
)();
}
});
}
once
(
'
klaro-init
'
,
'
body
'
,
context
).
forEach
(()
=>
{
const
preferences
=
context
.
querySelectorAll
(
'
#klaro-preferences, .klaro-preferences
'
,
);
if
(
drupalSettings
.
klaroConfig
.
services
!==
undefined
)
{
drupalSettings
.
klaroConfig
.
services
.
forEach
((
value
,
index
)
=>
{
if
(
drupalSettings
.
klaroConfig
.
services
[
index
].
callback
!==
undefined
)
{
drupalSettings
.
klaroConfig
.
services
[
index
].
callback
=
()
=>
drupalSettings
.
klaroConfig
.
services
[
index
].
callback
;
}
});
}
if
(
preferences
!==
null
)
{
preferences
.
forEach
(
function
(
button
)
{
button
.
addEventListener
(
"
click
"
,
function
(
e
)
{
e
.
preventDefault
();
klaro
.
show
(
drupalSettings
.
klaroConfig
);
if
(
preferences
!==
null
)
{
preferences
.
forEach
((
button
)
=>
{
button
.
addEventListener
(
'
click
'
,
(
e
)
=>
{
e
.
preventDefault
();
klaro
.
show
(
drupalSettings
.
klaroConfig
);
});
});
}
)
}
// Render klaro
klaro
.
render
(
drupalSettings
.
klaroConfig
);
}
// Render klaro
klaro
.
render
(
drupalSettings
.
klaroConfig
);
}
);
}
},
};
})(
Drupal
,
drupalSettings
);
})(
Drupal
,
drupalSettings
,
once
);
This diff is collapsed.
Click to expand it.
simple_klaro.libraries.yml
+
1
−
0
View file @
34e6054e
...
...
@@ -11,6 +11,7 @@ klaro: &klaro
dependencies
:
-
core/drupal
-
core/drupalSettings
-
core/once
klaro_cdn
:
<<
:
*klaro
...
...
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