added site files

This commit is contained in:
gribse 2025-05-16 18:49:08 +02:00
parent a6f70a6c78
commit 329148c253
253 changed files with 30486 additions and 0 deletions

View file

@ -0,0 +1,90 @@
/*
---
name: Helper
description: Helper to initialize multiple Enlighter instances on your page as well as code-groups
license: MIT-style X11 License
authors:
- Andi Dittrich
requires:
- Core/1.4.5
provides: [EnlighterJS.Util.Helper]
...
*/
EJS.Util.Helper = (function(elements, options){
// break if no elements are selected/found
if (elements == null || (elements.length && elements.length == 0)){
return;
}
// defaults
options = options || {};
// element grouping disabled?
if (options.grouping && options.grouping===false){
// highlight all elements
elements.enlight(options);
// use grouping
}else{
// get separated groups and single elements
var groups = {};
var ungrouped = [];
// group elements
Array.each(elements, function(el){
// extract group name
var groupName = el.get('data-enlighter-group');
// build element tree
if (groupName){
if (groups[groupName]){
groups[groupName].push(el);
}else{
groups[groupName] = [el];
}
}else{
ungrouped.push(el);
}
});
// highlight single elements (non grouped)
ungrouped.each(function(el){
el.enlight(options);
});
// create & highlight groups
Object.each(groups, function(obj){
// copy options
var localoptions = Object.clone(options);
// force theme defined within options (all group members should have the same theme as group-leader)
localoptions.forceTheme = true;
// get group-leader theme
localoptions.theme = obj[0].get('data-enlighter-theme') || options.theme || 'Enlighter';
// create new tab pane
var tabpane = new EJS.UI.TabPane(localoptions.theme);
// put enlighted objects into the tabpane
Array.each(obj, function(el, index){
// create new tab - set title with fallback
var container = tabpane.addTab(el.get('data-enlighter-title') || el.get('data-enlighter-language') || localoptions.language);
// run enlighter
(new EJS(el, localoptions, container)).enlight(true);
}.bind(this));
// select first tab (group-leader)
tabpane.getContainer().inject(obj[0], 'before');
tabpane.selectTab(0);
}.bind(this));
}
});

View file

@ -0,0 +1,32 @@
/*
---
description: Simple global-initialization of inline+block codeblocks
license: MIT-style X11 License
authors:
- Andi Dittrich
requires:
- Core/1.4.5
provides: [EnlighterJS.Util.Init]
...
*/
EJS.Util.Init = (function(blockSelector, inlineSelector, options){
// defaults
options = options || {};
// highlight all matching block tags
if (blockSelector){
options.renderer = 'Block';
EJS.Util.Helper(EJS.Dom.getElements(blockSelector), options);
}
// highlight all matching inline tags
if (inlineSelector){
options.renderer = 'Inline';
options.grouping = false;
EJS.Util.Helper(EJS.Dom.getElements(inlineSelector), options);
}
});

View file

@ -0,0 +1,55 @@
/*
---
description: Automatical element highlighting using meta tag options
license: MIT-style X11 License
authors:
- Andi Dittrich
requires:
- Core/1.4.5
provides: [EnlighterJS]
...
*/
window.addEvent('domready', function(){
// metadata config available ? -> autoinit
var m = EJS.Dom.getElement('meta[name="EnlighterJS"]');
// check instance
if (!m){
return;
}
// create new options object
var options = {
language: m.get('data-language') || 'generic',
theme: m.get('data-theme') || 'Enlighter',
indent: m.get('data-indent').toInt() || -1,
hover: m.get('data-hover') || 'hoverEnabled',
rawButton: (m.get('data-rawcodebutton')==='true'),
windowButton: (m.get('data-windowbutton')==='true'),
infoButton: (m.get('data-infobutton')==='true'),
showLinenumbers: (m.get('data-linenumbers')!=='false')
};
// selector available ? if not, match all pre-tags
var blockSelector = m.get('data-selector-block') || 'pre';
// selector available ? if not, match all pre-tags
var inlineSelector = m.get('data-selector-inline') || 'code';
// highlight all matching block tags
if (blockSelector != 'NULL'){
options.renderer = 'Block';
EJS.Util.Helper(EJS.Dom.getElements(blockSelector), options);
}
// highlight all matching inline tags
if (inlineSelector != 'NULL'){
options.renderer = 'Inline';
options.grouping = false;
EJS.Util.Helper(EJS.Dom.getElements(inlineSelector), options);
}
});