Index: branches/js2-work/phase3/js/mwEmbed/mwEmbed.js |
— | — | @@ -1643,8 +1643,7 @@ |
1644 | 1644 | * |
1645 | 1645 | * @param {Function} callback Function to run once DOM and jQuery are ready |
1646 | 1646 | */ |
1647 | | - mw.ready = function( callback ){ |
1648 | | - mw.log('addOnloadHook:: ' ); |
| 1647 | + mw.ready = function( callback ){ |
1649 | 1648 | if( mwReadyFlag === false ){ |
1650 | 1649 | |
1651 | 1650 | // Add the callbcak to the onLoad function stack |
— | — | @@ -1653,7 +1652,7 @@ |
1654 | 1653 | // Set the mwSetup flag. So that onLoad functions can |
1655 | 1654 | // be called once mwEmbed interfaces are setup. |
1656 | 1655 | if( !mwDomReadyFlag ){ |
1657 | | - mw.log( 'set config flag' ); |
| 1656 | + //mw.log( 'set config flag' ); |
1658 | 1657 | mw.setConfig( 'runSetupMwEmbed', true ); |
1659 | 1658 | }else{ |
1660 | 1659 | mw.log( 'run setup directly' ); |
— | — | @@ -2262,6 +2261,8 @@ |
2263 | 2262 | * On a page with lots of rules it can take some time |
2264 | 2263 | * so avoid calling this function where possible and |
2265 | 2264 | * cache its result |
| 2265 | + * |
| 2266 | + * Note this only works when mwEmbed is on the same domain as the style sheets |
2266 | 2267 | * |
2267 | 2268 | * @param {String} styleRule Style rule name to check |
2268 | 2269 | * @return |
— | — | @@ -2270,18 +2271,22 @@ |
2271 | 2272 | * @type {Boolean} |
2272 | 2273 | */ |
2273 | 2274 | mw.styleRuleExists = function ( styleRule ){ |
2274 | | - // Set up the skin paths configuration |
| 2275 | + // Set up the skin paths configuration |
2275 | 2276 | for( var i=0 ; i < document.styleSheets.length ; i++ ){ |
2276 | 2277 | var rules = null; |
2277 | | - if (document.styleSheets[i].cssRules) |
2278 | | - rules = document.styleSheets[i].cssRules |
2279 | | - else if (document.styleSheets[0].rules) |
2280 | | - rules = document.styleSheets[i].rules |
2281 | | - for(var j=0 ; j < rules.length ; j++ ){ |
2282 | | - var rule = rules[j].selectorText; |
2283 | | - if( rule && rule.indexOf( styleRule ) != -1 ){ |
2284 | | - return true; |
2285 | | - } |
| 2278 | + try { |
| 2279 | + if ( document.styleSheets[i].cssRules ) |
| 2280 | + rules = document.styleSheets[i].cssRules |
| 2281 | + else if (document.styleSheets[0].rules) |
| 2282 | + rules = document.styleSheets[i].rules |
| 2283 | + for(var j=0 ; j < rules.length ; j++ ){ |
| 2284 | + var rule = rules[j].selectorText; |
| 2285 | + if( rule && rule.indexOf( styleRule ) != -1 ){ |
| 2286 | + return true; |
| 2287 | + } |
| 2288 | + } |
| 2289 | + } catch ( e ){ |
| 2290 | + mw.log( 'Error: cross domain style sheet:' + document.styleSheets[i].href); |
2286 | 2291 | } |
2287 | 2292 | } |
2288 | 2293 | return false; |