mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-09 15:27:55 -04:00
+ imp. version
This commit is contained in:
parent
40acdfc252
commit
c451e14479
@ -1,72 +1,5 @@
|
|||||||
var Toggled;
|
var Toggled;
|
||||||
|
|
||||||
function initCss() {
|
|
||||||
var colorProperties = ['color', 'background-color', 'background'];
|
|
||||||
|
|
||||||
$('*').each(function () {
|
|
||||||
|
|
||||||
for (var prop in colorProperties) {
|
|
||||||
prop = colorProperties[prop];
|
|
||||||
if (($(this).css(prop) === 'rgba(0, 0, 0, 0)') || ($(this).css(prop) === 'transparent')) {
|
|
||||||
if ($(this).is('body')) {
|
|
||||||
$(this).css('background', 'rgb(255, 255, 255)');
|
|
||||||
$(this).css('color', 'rgb(0, 0, 0)');
|
|
||||||
} else
|
|
||||||
if (!$(this).is('a'))
|
|
||||||
$(this).css('color', 'rgb(0, 0, 0)');
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function invertColors() {
|
|
||||||
|
|
||||||
//First init for other elements
|
|
||||||
if (typeof Toggled === 'undefined') {
|
|
||||||
initCss();
|
|
||||||
Toggled = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
var colorProperties = ['color', 'background-color', 'background'];
|
|
||||||
|
|
||||||
$('*').each(function () {
|
|
||||||
var color = null;
|
|
||||||
for (var prop in colorProperties) {
|
|
||||||
prop = colorProperties[prop];
|
|
||||||
if (!$(this).css(prop)) continue;
|
|
||||||
color = new RGBColor($(this).css(prop));
|
|
||||||
if (color.ok) {
|
|
||||||
$(this).css(prop, 'rgb(' + (255 - color.r) + ',' + (255 - color.g) + ',' + (255 - color.b) + ')');
|
|
||||||
}
|
|
||||||
color = null;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A class to parse color values
|
|
||||||
* @author Stoyan Stefanov <sstoo@gmail.com>
|
|
||||||
* @link http://www.phpied.com/rgb-color-parser-in-javascript/
|
|
||||||
* @license Use it if you like it
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
function RGBColor(color_string) {
|
|
||||||
this.ok = false;
|
|
||||||
|
|
||||||
// strip any leading #
|
|
||||||
if (color_string.charAt(0) == '#') { // remove # if any
|
|
||||||
color_string = color_string.substr(1, 6);
|
|
||||||
}
|
|
||||||
|
|
||||||
color_string = color_string.replace(/ /g, '');
|
|
||||||
color_string = color_string.toLowerCase();
|
|
||||||
|
|
||||||
// before getting into regexps, try simple matches
|
// before getting into regexps, try simple matches
|
||||||
// and overwrite the input
|
// and overwrite the input
|
||||||
var simple_colors = {
|
var simple_colors = {
|
||||||
@ -215,12 +148,9 @@ function RGBColor(color_string) {
|
|||||||
yellow: 'ffff00',
|
yellow: 'ffff00',
|
||||||
yellowgreen: '9acd32'
|
yellowgreen: '9acd32'
|
||||||
};
|
};
|
||||||
for (var key in simple_colors) {
|
|
||||||
if (color_string == key) {
|
var colorCache = new Object();
|
||||||
color_string = simple_colors[key];
|
var rgbCache = new Object();
|
||||||
}
|
|
||||||
}
|
|
||||||
// emd of simple type-in colors
|
|
||||||
|
|
||||||
// array of color definition objects
|
// array of color definition objects
|
||||||
var color_defs = [{
|
var color_defs = [{
|
||||||
@ -255,6 +185,82 @@ function RGBColor(color_string) {
|
|||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
|
|
||||||
|
var colorProperties = ['color', 'background-color', 'background'];
|
||||||
|
|
||||||
|
function initCss() {
|
||||||
|
$('*').each(function () {
|
||||||
|
for (var prop in colorProperties) {
|
||||||
|
prop = colorProperties[prop];
|
||||||
|
if (($(this).css(prop) === 'rgba(0, 0, 0, 0)') || ($(this).css(prop) === 'transparent')) {
|
||||||
|
if ($(this).is('body')) {
|
||||||
|
$(this).css('background', 'rgb(255, 255, 255)');
|
||||||
|
$(this).css('color', 'rgb(0, 0, 0)');
|
||||||
|
} else
|
||||||
|
if (!$(this).is('a'))
|
||||||
|
$(this).css('color', 'rgb(0, 0, 0)');
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function invertColors() {
|
||||||
|
//First init for other elements
|
||||||
|
if (typeof Toggled === 'undefined') {
|
||||||
|
initCss();
|
||||||
|
Toggled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
var color;
|
||||||
|
var prop;
|
||||||
|
var cssProp;
|
||||||
|
|
||||||
|
$('*').each(function () {
|
||||||
|
for (prop in colorProperties) {
|
||||||
|
prop = colorProperties[prop];
|
||||||
|
if ($(this).css(prop)) {
|
||||||
|
cssProp = $(this).css(prop);
|
||||||
|
if (colorCache[cssProp] != undefined) {
|
||||||
|
$(this).css(prop, colorCache[cssProp]);
|
||||||
|
} else {
|
||||||
|
color = new RGBColor(cssProp);
|
||||||
|
if (color.ok) {
|
||||||
|
$(this).css(prop, 'rgb(' + (255 - color.r) + ',' + (255 - color.g) + ',' + (255 - color.b) + ')');
|
||||||
|
}
|
||||||
|
colorCache[cssProp] = $(this).css(prop);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A class to parse color values
|
||||||
|
* @author Stoyan Stefanov <sstoo@gmail.com>
|
||||||
|
* @link http://www.phpied.com/rgb-color-parser-in-javascript/
|
||||||
|
* @license Use it if you like it
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
function RGBColor(color_string) {
|
||||||
|
this.ok = false;
|
||||||
|
|
||||||
|
// strip any leading #
|
||||||
|
if (color_string.charAt(0) == '#') { // remove # if any
|
||||||
|
color_string = color_string.substr(1, 6);
|
||||||
|
}
|
||||||
|
|
||||||
|
color_string = color_string.replace(/ /g, '');
|
||||||
|
color_string = color_string.toLowerCase();
|
||||||
|
|
||||||
|
for (var key in simple_colors) {
|
||||||
|
if (color_string == key) {
|
||||||
|
color_string = simple_colors[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// emd of simple type-in colors
|
||||||
|
|
||||||
// search through the definitions to find a match
|
// search through the definitions to find a match
|
||||||
for (var i = 0; i < color_defs.length; i++) {
|
for (var i = 0; i < color_defs.length; i++) {
|
||||||
var re = color_defs[i].re;
|
var re = color_defs[i].re;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user