Skip to content

Commit

Permalink
Import js config for prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
ulgens committed Dec 21, 2024
1 parent 3d37e7f commit 19903e4
Show file tree
Hide file tree
Showing 5 changed files with 345 additions and 284 deletions.
3 changes: 2 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ repos:
rev: "v3.4.2"
hooks:
- id: prettier
exclude_types: [html, css, javascript, json, scss]
exclude_types: [html, css, json, scss]
exclude: '(^trac-env\/htdocs\/js\/lib\/.*$)'

- repo: https://github.com/tox-dev/pyproject-fmt
rev: "v2.5.0"
Expand Down
11 changes: 11 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"overrides": [
{
"files": "*.js",
"options": {
"tabWidth": 2,
"singleQuote": true
}
}
]
}
121 changes: 64 additions & 57 deletions trac-env/htdocs/js/main.js
Original file line number Diff line number Diff line change
@@ -1,63 +1,70 @@
// Require.js Module Loader - http://requirejs.org

requirejs.config({
paths: {
"jquery": "//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min",
// "jquery": "lib/jquery", -- local version of jquery if desired.
"jquery.inview": "lib/jquery.inview"
}
paths: {
jquery: '//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min',
// "jquery": "lib/jquery", -- local version of jquery if desired.
'jquery.inview': 'lib/jquery.inview',
},
});

define(function(){

var mods = [];

//detect Class function
function hasClass( className ) {
if (!document.getElementsByClassName) { //class name function in old IE
document.getElementsByClassName = function(search) {
var d = document, elements, pattern, i, results = [];
if (d.querySelectorAll) { // IE8
return d.querySelectorAll("." + search);
}
if (d.evaluate) { // IE6, IE7
pattern = ".//*[contains(concat(' ', @class, ' '), ' " + search + " ')]";
elements = d.evaluate(pattern, d, null, 0, null);
while ((i = elements.iterateNext())) {
results.push(i);
}
} else {
elements = d.getElementsByTagName("*");
pattern = new RegExp("(^|\\s)" + search + "(\\s|$)");
for (i = 0; i < elements.length; i++) {
if ( pattern.test(elements[i].className) ) {
results.push(elements[i]);
}
}
}
return results;
};
}
return !!document.getElementsByClassName( className ).length; //return a boolean
}

//feature list
if (hasClass('list-features')) {
mods.push('mod/list-feature');
}

//collapsing list
if (hasClass('list-collapsing')) {
mods.push('mod/list-collapsing');
}

if (hasClass('version-switcher')) {
mods.push('mod/version-switcher');
}

if (hasClass('doc-floating-warning')) {
mods.push('mod/floating-warning');
}

require(mods);
define(function () {
var mods = [];

//detect Class function
function hasClass(className) {
if (!document.getElementsByClassName) {
//class name function in old IE
document.getElementsByClassName = function (search) {
var d = document,
elements,
pattern,
i,
results = [];
if (d.querySelectorAll) {
// IE8
return d.querySelectorAll('.' + search);
}
if (d.evaluate) {
// IE6, IE7
pattern =
".//*[contains(concat(' ', @class, ' '), ' " + search + " ')]";
elements = d.evaluate(pattern, d, null, 0, null);
while ((i = elements.iterateNext())) {
results.push(i);
}
} else {
elements = d.getElementsByTagName('*');
pattern = new RegExp('(^|\\s)' + search + '(\\s|$)');
for (i = 0; i < elements.length; i++) {
if (pattern.test(elements[i].className)) {
results.push(elements[i]);
}
}
}
return results;
};
}
return !!document.getElementsByClassName(className).length; //return a boolean
}

//feature list
if (hasClass('list-features')) {
mods.push('mod/list-feature');
}

//collapsing list
if (hasClass('list-collapsing')) {
mods.push('mod/list-collapsing');
}

if (hasClass('version-switcher')) {
mods.push('mod/version-switcher');
}

if (hasClass('doc-floating-warning')) {
mods.push('mod/floating-warning');
}

require(mods);
});
22 changes: 12 additions & 10 deletions trac-env/htdocs/js/mobile-menu.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
jQuery(document).ready(function($) {
var menu = $('[role="banner"] [role="navigation"]');
var button = $('<div class="menu-button"><i class="icon icon-reorder"></i><span>Menu</span></div>');
jQuery(document).ready(function ($) {
var menu = $('[role="banner"] [role="navigation"]');
var button = $(
'<div class="menu-button"><i class="icon icon-reorder"></i><span>Menu</span></div>',
);

menu.addClass('nav-menu-on');
button.insertBefore(menu);
button.on('click', function(){
menu.toggleClass('active');
button.toggleClass('active')
});
})
menu.addClass('nav-menu-on');
button.insertBefore(menu);
button.on('click', function () {
menu.toggleClass('active');
button.toggleClass('active');
});
});
Loading

0 comments on commit 19903e4

Please sign in to comment.