Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import js config for prettier #248

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading