allow cssmanager to manage outer_ace

This commit is contained in:
Chia-liang Kao 2013-06-15 01:37:41 +08:00
parent 548f31a46a
commit f31db205da
3 changed files with 110 additions and 89 deletions

View file

@ -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()
{