1
0
Fork 0
mirror of https://github.com/Yetangitu/owncloud-apps.git synced 2025-10-02 14:49:17 +02:00

Initial commit

This commit is contained in:
frankdelange 2014-12-09 22:40:49 +01:00
parent 26dd81b2df
commit 993289d86b
51 changed files with 16863 additions and 0 deletions

171
files_reader/js/ready.js Normal file
View file

@ -0,0 +1,171 @@
function disableStyles(doc, disable) {
for ( var i=0; i<doc.styleSheets.length; i++) {
void(doc.styleSheets.item(i).disabled=disable);
}
}
function addStyleSheet() {
var style = document.createElement("style");
// WebKit hack :(
style.appendChild(document.createTextNode(""));
document.head.appendChild(style);
return style.sheet;
}
function getCSSRule(sheet, selector, del) {
lcSelector = selector.toLowerCase();
for ( var i=0; i<sheet.cssRules.length; i++) {
if (sheet.cssRules.item(i).selectorText.toLowerCase() == lcSelector) {
if (del) {
sheet.deleteRule(i);
return null;
} else {
return sheet.cssRules.item(i);
}
}
}
return null;
}
function addCSSRule(sheet, selector, rules, index) {
if("insertRule" in sheet) {
sheet.insertRule(selector + "{" + rules + "}", index);
}
else if("addRule" in sheet) {
sheet.addRule(selector, rules, index);
}
}
function delCSSRule(sheet, selector) {
getCSSRule(sheet, selector, true);
}
document.onreadystatechange = function () {
if (document.readyState == "complete") {
// enable (large-screen) or hide (mobile/small-screen) close button
if (parent.READER == undefined) {
$('#close').hide();
} else {
$('#close').on('click', function() { reader.book.destroy(); parent.READER.hideReader(); });
parent.READER.hideControls();
}
// some parameters...
EPUBJS.filePath = "js/libs/";
EPUBJS.cssPath = "css/";
// device-specific rules
//
// webworkers...
if(!window.Worker) {
// use zip.js without webworkers, include inflate.js
zip.useWebWorkers = false;
$.getScript('js/libs/inflate.js');
} else {
zip.workerScriptsPath = document.getElementsByTagName('base')[0].href + 'js/libs/';
}
// touch-enabled devices...
$('#touch_nav').prop('checked', !('ontouchstart' in document.documentElement));
if (!($('#touch_nav').prop('checked'))) {
$("#next").addClass("touch_nav");
$("#prev").addClass("touch_nav");
}
// idevices...
if (navigator.userAgent.match(/(iPad|iPhone|iPod)/g)) {
$('head').append($('<link rel="stylesheet" type="text/css" />').attr('href', document.getElementsByTagName("base").item(0).href + 'css/idevice.css'));
}
function nightModeConfig() {
delCSSRule(EPUBJS.nightSheet, EPUBJS.nightSelector);
addCSSRule(EPUBJS.nightSheet, EPUBJS.nightSelector, 'color: ' + EPUBJS.nightModeColor + ' !important; background: ' + EPUBJS.nightModeBackground + ' !important;');
}
// nightMode
EPUBJS.nightMode = false;
EPUBJS.nightSheet = addStyleSheet();
EPUBJS.nightSelector = '.night *';
EPUBJS.nightModeBackground = $('#nightModeBackground').val();
EPUBJS.nightModeColor = $('#nightModeColor').val();
addCSSRule(EPUBJS.nightSheet, '.nonight', 'background: initial !important;');
nightModeConfig();
$('#nightModeBackground').on('change', function() {
EPUBJS.nightModeBackground = $('#nightModeBackground').val();
nightModeConfig();
});
$('#nightModeColor').on('change', function() {
EPUBJS.nightModeColor = $('#nightModeColor').val();
nightModeConfig();
});
var reader = ePubReader(document.getElementById("dllink").value, { contained: true });
// enable night/day mode switch by clicking on the book title/author
// just switching in the "night" class works on some browsers but not on others, hence the trickery with
// setStyle/removeStyle...
$('#metainfo').on('click', function() {
if(EPUBJS.nightMode) {
reader.book.removeStyle("background");
reader.book.removeStyle("color");
$("#outerContainer").removeClass("night");
EPUBJS.nightMode = false;
} else {
reader.book.setStyle("background", EPUBJS.nightModeBackground);
reader.book.setStyle("color", EPUBJS.nightModeColor);
$("#outerContainer").addClass("night");
EPUBJS.nightMode = true;
}
});
// extra-wide page turn area?
$('#touch_nav').on('click', function() {
if ($('#touch_nav').prop('checked')) {
$("#prev").removeClass("touch_nav");
$("#next").removeClass("touch_nav");
} else {
$("#prev").addClass("touch_nav");
$("#next").addClass("touch_nav");
}
});
// user-defined font
EPUBJS.ignore_css = false;
EPUBJS.bookFrame = null;
EPUBJS.user_fontFamily = $('#fontFamily').val();
EPUBJS.user_fontSize = $('#fontSize').val() + '%';
$('#ignore_css').on('click', function() {
EPUBJS.bookFrame = document.getElementsByTagName('iframe')[0].contentDocument;
if ($('#ignore_css').prop('checked')) {
$('#fontFamily').prop('disabled',false);
$('#fontSize').prop('disabled',false);
EPUBJS.ignore_css = true;
reader.book.setStyle('font-size', EPUBJS.user_fontSize);
reader.book.setStyle('font-family', EPUBJS.user_fontFamily);
} else {
$('#fontFamily').prop('disabled',true);
$('#fontSize').prop('disabled',true);
EPUBJS.ignore_css = false;
reader.book.removeStyle('font-size');
reader.book.removeStyle('font-family');
}
disableStyles(EPUBJS.bookFrame, EPUBJS.ignore_css);
;
});
$('#fontSize').on('change', function() {
EPUBJS.user_fontSize = $('#fontSize').val() + '%';
$('#font_example').css('font-size', EPUBJS.user_fontSize);
reader.book.setStyle('font-size', EPUBJS.user_fontSize);
});
$('#fontFamily').on('change', function() {
EPUBJS.user_fontFamily = $('#fontFamily').val();
$('#font_example').css('font-family', EPUBJS.user_fontFamily);
reader.book.setStyle('font-family', EPUBJS.user_fontFamily);
});
}
};