The iPhone Wiki is no longer updated. Visit this article on The Apple Wiki for current information. |
Difference between revisions of "MediaWiki:Jony.js"
Line 2: | Line 2: | ||
* The iPhone Wiki MediaWiki:jony.js |
* The iPhone Wiki MediaWiki:jony.js |
||
* - JavaScript to fix issues regarding the iOS 7 theme |
* - JavaScript to fix issues regarding the iOS 7 theme |
||
− | * Copyright (c) 2013- |
+ | * Copyright (c) 2013-2018 Cole Johnson <coleharrisjohnson@gmail.com> |
* Licensed under CC BY-SA 4.0 <http://creativecommons.org/licenses/by-sa/4.0/> |
* Licensed under CC BY-SA 4.0 <http://creativecommons.org/licenses/by-sa/4.0/> |
||
**/ |
**/ |
||
Line 23: | Line 23: | ||
var cell = row[colIdx]; |
var cell = row[colIdx]; |
||
if (cell.rowSpan != 1 && cell.rowSpan == dist) { |
if (cell.rowSpan != 1 && cell.rowSpan == dist) { |
||
− | // this is the last cell in a column, and it has a rowspan |
+ | // this is the last cell in a column, and it has a rowspan reaching the bottom of the table |
if (cell.className == undefined || cell.className == "") { |
if (cell.className == undefined || cell.className == "") { |
||
cell.className = "nobborderplz"; |
cell.className = "nobborderplz"; |
||
Line 39: | Line 39: | ||
for (var tableIdx = 0; tableIdx < tables.length; tableIdx++) { |
for (var tableIdx = 0; tableIdx < tables.length; tableIdx++) { |
||
+ | var fixedCorner = false; |
||
var children = tables[tableIdx].children; |
var children = tables[tableIdx].children; |
||
if (children.length > 0 && children[0].localName == "tbody") { |
if (children.length > 0 && children[0].localName == "tbody") { |
||
Line 51: | Line 52: | ||
var cell = row[colIdx]; |
var cell = row[colIdx]; |
||
if (cell.rowSpan != 1 && cell.rowSpan == dist) { |
if (cell.rowSpan != 1 && cell.rowSpan == dist) { |
||
− | // this is the last cell in a column, and it has a rowspan |
+ | // this is the last cell in a column, and it has a rowspan reaching the bottom of the table |
+ | fixedCorner = true; |
||
if (cell.style == undefined || cell.style == "") { |
if (cell.style == undefined || cell.style == "") { |
||
cell.style = "border-bottom-right-radius: 6px"; |
cell.style = "border-bottom-right-radius: 6px"; |
||
Line 58: | Line 60: | ||
} |
} |
||
} |
} |
||
+ | } |
||
+ | } |
||
+ | |||
+ | if (fixedCorner) { |
||
+ | // unround the last row's last column's corner |
||
+ | var lastRow = children[height - 1].children; |
||
+ | var lastColumnCell = lastRow[lastRow.length - 1]; |
||
+ | if (lastColumnCell.style == undefined || lastColumnCell.style == "") { |
||
+ | lastColumnCell.style = "border-bottom-right-radius: 0px"; |
||
+ | } else { |
||
+ | lastColumnCell.style = lastColumnCell.style + ";border-bottom-right-radius: 0px"; |
||
} |
} |
||
} |
} |
Revision as of 22:25, 10 October 2018
/**
* The iPhone Wiki MediaWiki:jony.js
* - JavaScript to fix issues regarding the iOS 7 theme
* Copyright (c) 2013-2018 Cole Johnson <coleharrisjohnson@gmail.com>
* Licensed under CC BY-SA 4.0 <http://creativecommons.org/licenses/by-sa/4.0/>
**/
// Automatically adds the "nobborderplz" class to applicable table cells
function autoAddNoBBorderPlzClass() {
var tables = $("table[class=wikitable]");
for (var tableIdx = 0; tableIdx < tables.length; tableIdx++) {
var children = tables[tableIdx].children;
if (children.length > 0 && children[0].localName == "tbody") {
children = children[0].children; // skip the tbody tag
}
var height = children.length;
for (var rowIdx = 0; rowIdx < height; rowIdx++) {
var row = children[rowIdx].children;
var width = row.length; // not true number of columns if there's a rowspan spanning through
var dist = height - rowIdx;
for (var colIdx = 0; colIdx < width; colIdx++) {
var cell = row[colIdx];
if (cell.rowSpan != 1 && cell.rowSpan == dist) {
// this is the last cell in a column, and it has a rowspan reaching the bottom of the table
if (cell.className == undefined || cell.className == "") {
cell.className = "nobborderplz";
} else {
cell.className = cell.className + " nobborderplz";
}
}
}
}
}
}
function fixRoundedTableCorners() {
var tables = $("table[class=wikitable]");
for (var tableIdx = 0; tableIdx < tables.length; tableIdx++) {
var fixedCorner = false;
var children = tables[tableIdx].children;
if (children.length > 0 && children[0].localName == "tbody") {
children = children[0].children; // skip the tbody tag
}
var height = children.length;
for (var rowIdx = 0; rowIdx < height; rowIdx++) {
var row = children[rowIdx].children;
var width = row.length; // not true number of columns if there's a rowspan spanning through
var dist = height - rowIdx;
for (var colIdx = 0; colIdx < width; colIdx++) {
var cell = row[colIdx];
if (cell.rowSpan != 1 && cell.rowSpan == dist) {
// this is the last cell in a column, and it has a rowspan reaching the bottom of the table
fixedCorner = true;
if (cell.style == undefined || cell.style == "") {
cell.style = "border-bottom-right-radius: 6px";
} else {
cell.style = cell.style + ";border-bottom-right-radius: 6px";
}
}
}
}
if (fixedCorner) {
// unround the last row's last column's corner
var lastRow = children[height - 1].children;
var lastColumnCell = lastRow[lastRow.length - 1];
if (lastColumnCell.style == undefined || lastColumnCell.style == "") {
lastColumnCell.style = "border-bottom-right-radius: 0px";
} else {
lastColumnCell.style = lastColumnCell.style + ";border-bottom-right-radius: 0px";
}
}
}
}
autoAddNoBBorderPlzClass();
fixRoundedTableCorners();