summaryrefslogtreecommitdiff
path: root/src/static/js/cssmanager.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/static/js/cssmanager.js')
-rw-r--r--src/static/js/cssmanager.js32
1 files changed, 25 insertions, 7 deletions
diff --git a/src/static/js/cssmanager.js b/src/static/js/cssmanager.js
index 62f17496..710cdbe5 100644
--- a/src/static/js/cssmanager.js
+++ b/src/static/js/cssmanager.js
@@ -1,5 +1,5 @@
/**
- * This code is mostly from the old Etherpad. Please help us to comment this code.
+ * This code is mostly from the old Etherpad. Please help us to comment this code.
* This helps other people to understand this code better and helps them to improve it.
* TL;DR COMMENTS ON THIS FILE ARE HIGHLY APPRECIATED
*/
@@ -20,14 +20,32 @@
* limitations under the License.
*/
-function makeCSSManager(emptyStylesheetTitle, parentCss)
+function makeCSSManager(emptyStylesheetTitle, doc)
{
+ if (doc === true)
+ {
+ doc = 'parent';
+ } else if (!doc) {
+ doc = 'inner';
+ }
function getSheetByTitle(title)
{
- if (parentCss) var allSheets = window.parent.parent.document.styleSheets;
- else var allSheets = document.styleSheets;
-
+ if (doc === 'parent')
+ {
+ win = window.parent.parent;
+ }
+ else if (doc === 'inner') {
+ win = window;
+ }
+ else if (doc === 'outer') {
+ win = window.parent;
+ }
+ else {
+ throw "Unknown dynamic style container";
+ }
+ var allSheets = win.document.styleSheets;
+
for (var i = 0; i < allSheets.length; i++)
{
var s = allSheets[i];
@@ -38,8 +56,8 @@ function makeCSSManager(emptyStylesheetTitle, parentCss)
}
return null;
}
-
- var browserSheet = getSheetByTitle(emptyStylesheetTitle, parentCss);
+
+ var browserSheet = getSheetByTitle(emptyStylesheetTitle);
function browserRules()
{