(sel, decl, media, newStyle)
| 573 | - Based on Bobby van der Sluis' solution: http://www.bobbyvandersluis.com/articles/dynamicCSS.php |
| 574 | */ |
| 575 | function createCSS(sel, decl, media, newStyle) { |
| 576 | if (ua.ie && ua.mac) { return; } |
| 577 | var h = doc.getElementsByTagName("head")[0]; |
| 578 | if (!h) { return; } // to also support badly authored HTML pages that lack a head element |
| 579 | var m = (media && typeof media == "string") ? media : "screen"; |
| 580 | if (newStyle) { |
| 581 | dynamicStylesheet = null; |
| 582 | dynamicStylesheetMedia = null; |
| 583 | } |
| 584 | if (!dynamicStylesheet || dynamicStylesheetMedia != m) { |
| 585 | // create dynamic stylesheet + get a global reference to it |
| 586 | var s = createElement("style"); |
| 587 | s.setAttribute("type", "text/css"); |
| 588 | s.setAttribute("media", m); |
| 589 | dynamicStylesheet = h.appendChild(s); |
| 590 | if (ua.ie && ua.win && typeof doc.styleSheets != UNDEF && doc.styleSheets.length > 0) { |
| 591 | dynamicStylesheet = doc.styleSheets[doc.styleSheets.length - 1]; |
| 592 | } |
| 593 | dynamicStylesheetMedia = m; |
| 594 | } |
| 595 | // add style rule |
| 596 | if (ua.ie && ua.win) { |
| 597 | if (dynamicStylesheet && typeof dynamicStylesheet.addRule == OBJECT) { |
| 598 | dynamicStylesheet.addRule(sel, decl); |
| 599 | } |
| 600 | } |
| 601 | else { |
| 602 | if (dynamicStylesheet && typeof doc.createTextNode != UNDEF) { |
| 603 | dynamicStylesheet.appendChild(doc.createTextNode(sel + " {" + decl + "}")); |
| 604 | } |
| 605 | } |
| 606 | } |
| 607 | |
| 608 | function setVisibility(id, isVisible) { |
| 609 | if (!autoHideShow) { return; } |
no test coverage detected