public static string ToScript([CanBeNull] this ICustomStyleProvider provider, [CanBeNull] string url, bool transparentBackgroundSupported)
        {
            if (provider == null || url == null)
            {
                return(null);
            }

            var style = provider.GetStyle(url, transparentBackgroundSupported);

            if (style == null)
            {
                return(null);
            }

            return($@"
var s = document.getElementById('__cm_style');
if (s && s.parentNode) s.parentNode.removeChild(s);
s = document.createElement('style');
s.id = '__cm_style';
s.innerHTML = {JsonConvert.SerializeObject(style)};
if (document.body){{
    document.body.appendChild(s);
}} else if (document.head){{
    var p = document.createElement('style');
    p.innerHTML = 'body{{display:none!important}}html{{background:black!important}}'
    document.head.appendChild(p);

    function onload(){{
        if (s.parentNode == document.head){{
            document.head.removeChild(p);
            document.head.removeChild(s);
            document.body.appendChild(s);
        }}
    }}

    document.head.appendChild(s);
    document.addEventListener('DOMContentLoaded', onload, false);
    window.addEventListener('load', onload, false);
}}");
        }
Esempio n. 2
0
 public void SetStyleProvider(ICustomStyleProvider provider)
 {
     _styleProvider = provider;
 }
Esempio n. 3
0
 public void SetStyleProvider(ICustomStyleProvider provider)
 {
     _requestHandler.StyleProvider = provider;
 }
Esempio n. 4
0
 private void OnStyleProviderChanged(ICustomStyleProvider newValue) {
     _something.SetStyleProvider(newValue);
 }
Esempio n. 5
0
 public void SetStyleProvider(ICustomStyleProvider provider) {
     _styleProvider = provider;
 }
Esempio n. 6
0
 public void SetStyleProvider(ICustomStyleProvider provider) {
     _requestHandler.StyleProvider = provider;
 }
Esempio n. 7
0
 private void OnStyleProviderChanged(ICustomStyleProvider newValue)
 {
     _something.SetStyleProvider(newValue);
 }