refactor: rename RDReaderView -> RDEpubReaderView, update pod config and docs
- Rename source module from RDReaderView to RDEpubReaderView - Move all source files from Sources/RDReaderView/ to Sources/RDEpubReaderView/ - Update podspec: RDReaderView.podspec -> RDEpubReaderView.podspec - Update Podfile, demo project, and CocoaPods config for new pod name - Delete old RDReaderView pod support files from ReadViewDemo/Pods - Add new RDEpubReaderView pod support files - Update documentation (API ref, architecture, UML, conventions, etc.) - Add FixedLayoutRotationTests - Update .gitignore: exclude .DS_Store, manual unpack backups, _ssoft-output
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
(function() {
|
||||
if (window.RDInjectedCSS) { return; }
|
||||
|
||||
function applyStyle(doc, identifier, cssText) {
|
||||
if (!doc || !doc.head) { return; }
|
||||
var style = doc.getElementById(identifier);
|
||||
if (!style) {
|
||||
style = doc.createElement('style');
|
||||
style.id = identifier;
|
||||
doc.head.appendChild(style);
|
||||
}
|
||||
style.textContent = cssText || '';
|
||||
}
|
||||
|
||||
function walkDocuments(rootDoc, includeFrames, visitor) {
|
||||
if (!rootDoc) { return; }
|
||||
visitor(rootDoc);
|
||||
if (!includeFrames || !rootDoc.querySelectorAll) { return; }
|
||||
Array.prototype.forEach.call(rootDoc.querySelectorAll('iframe'), function(frame) {
|
||||
try {
|
||||
if (!frame.contentDocument) { return; }
|
||||
walkDocuments(frame.contentDocument, includeFrames, visitor);
|
||||
} catch (error) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
window.RDInjectedCSS = {
|
||||
setStyle: function(identifier, cssText, options) {
|
||||
var includeFrames = !!(options && options.includeFrames);
|
||||
walkDocuments(document, includeFrames, function(doc) {
|
||||
applyStyle(doc, identifier, cssText);
|
||||
});
|
||||
},
|
||||
removeStyle: function(identifier, options) {
|
||||
var includeFrames = !!(options && options.includeFrames);
|
||||
walkDocuments(document, includeFrames, function(doc) {
|
||||
var style = doc.getElementById(identifier);
|
||||
if (style && style.parentNode) {
|
||||
style.parentNode.removeChild(style);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
})();
|
||||
Reference in New Issue
Block a user