Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 3rd, 2012  |  syntax: None  |  size: 2.45 KB  |  hits: 17  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. /**
  2.   * A quick and dirty function to apply a className to a custom html snippet
  3.   * in the Wibiya toolbar in browsers that do not support media queries, w/out
  4.   * bothering to learn the Wibiya API. Include before the closing </body> tag.
  5.   *
  6.   * Was written specifically to provide IE support for the following snippet
  7.   * of html and css:
  8.   */
  9. // <style type="text/css">
  10. // @media screen and (max-width: 740px) {#wibiyaToolbar_support_key span { display:none; padding-left:60px;padding-right:0}}
  11. // #wibiyaToolbar_support_key {color:#e1e1e1;font-weight:bold;line-height:1;display:block;width:auto;height:18px;padding:6px 10px 0 65px;background:#675388 url(http://example.com/images/keyicon.png) no-repeat 5px top}
  12. // #wibiyaToolbar_support_key:hover,
  13. // #wibiyaToolbar_support_key:focus {color:#FFF}
  14. // #wibiyaToolbar_support_key > .n {display:none!important}
  15. // </style>
  16.  
  17. // <a title="your support is the key" id="wibiyaToolbar_support_key" href="http://example.com/"><span>This is a label</span></a>
  18.  
  19.  
  20. (function() {
  21.     var ct = 0, id = 'wibiyaToolbar_support_key';
  22.     function w() {
  23.         if (typeof wibiyaToolbar == 'object') {
  24.             if ((function () {
  25.                 var style = document.createElement('style'),
  26.                 div = document.createElement('div'),
  27.                 uid = '__nsf_rand-' + (+new Date()),
  28.                 ret;
  29.                 div.id = uid;
  30.                 style = ['&shy;', '<style>', '@media screen and (max-width: 9999px) { #' + uid + ' { display:none !important } }', '</style>'].join('');
  31.                 div.innerHTML += style;
  32.                 document.documentElement.appendChild(div);
  33.                 ret = (window.getComputedStyle ? getComputedStyle(div,null).getPropertyValue('display') : div.currentStyle['display']) != 'none';
  34.                 div.parentNode.removeChild(div);
  35.                 return ret}()))
  36.             (function() {
  37.                 var label = document.getElementById(id).firstChild;
  38.                 function resize() {
  39.                     return label.className = ((document.documentElement.offsetWidth || window.innerWidth) < 710) ? 'n' : '';
  40.                 };
  41.  
  42.                 if (window.attachEvent)
  43.                     window.attachEvent('onresize', resize);
  44.                 else if (window.addEventListener)
  45.                     window.addEventListener('resize', resize, false);
  46.             }())
  47.         } else if (ct++ < 4) {
  48.             setTimeout(w, 200 * ct);
  49.         } else
  50.             return;
  51.     }
  52.    return w();
  53. }());