Last active
December 24, 2015 01:19
-
-
Save baldwicc/6723353 to your computer and use it in GitHub Desktop.
Quick script to add is-ie, is-ie-8, and not-ie classes to a given list of selectors. Requires Prototype. HTML one-liner version provided that should cope with Bb 9.1sp9's text editor.
- Leave VTBE on
- Toggle HTML mode
- Paste markup
- Press submit (don't toggle html mode back off!!)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// <script type="text/javascript"> | |
/** | |
* configurable options | |
* @type {object} | |
* @property {array} selectors array of selectors to add ie classes to | |
* @property {string} isie_prefix prefix for ie version class | |
* @property {string} isie class to add when browser is ie | |
* @property {string} not-ie class to add when browser is not ie | |
*/ | |
var opts = { | |
selectors: [ | |
'body', | |
'.show', | |
'.hide', | |
'#structureHeader', | |
'#structureInfographic', | |
'#jurisdictionHeader', | |
'#jurisdictionSubHeader1', | |
'#jurisdictionSubHeader2', | |
'#jurisdictionSubHeader3', | |
'#jurisdictionSubHeader4', | |
'#jurisdictionSubHeader5', | |
'#jurisdictionCourtIcon', | |
'#jurisdictionAustraliaIcon', | |
'#jurisdictionStopIcon', | |
'#breakoutTopSmall', | |
'#breakoutBottomSmall', | |
'#breakoutTopLarge', | |
'#breakoutBottomLarge' | |
], | |
isie_prefix: 'is-ie-', | |
isie: 'is-ie', | |
notie: 'not-ie' | |
}; | |
/** | |
* current version of ie [https://gist.github.com/527683] | |
* @type {number|undefined} | |
*/ | |
var ie = (function() { | |
var undef, | |
v = 3, | |
div = document.createElement('div'), | |
all = div.getElementsByTagName('i'); | |
while ( | |
div.innerHTML = '<!--[if gt IE ' + (++v) + ']><i></i><![endif]-->', | |
all[0] | |
); | |
return v > 4 ? v : undef; | |
}()); | |
var addClasses = function(inopts, iever) { | |
// fetch all the elems | |
var elems = $$(inopts.selectors.join(', ')); | |
for (var i = 0; i < elems.length; i++) { | |
if (iever) { | |
elems[i].toggleClassName(inopts.isie); | |
elems[i].toggleClassName(inopts.isie_prefix + iever); | |
} else { | |
elems[i].toggleClassName(inopts.notie); | |
} | |
} | |
}; | |
// FIRE | |
Event.observe(window.document, "dom:loaded", function() { | |
addClasses(opts, ie); | |
}); | |
// </script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="hidemyrow"><p>Script-block to allow targeting IE with CSS styles. Source: <a href="https://gist.github.com/6723353">gist.github.com/6723353</a></p></div><script type="text/javascript" defer> | |
var opts={selectors:["body",".show",".hide","#structureHeader","#structureInfographic","#jurisdictionHeader","#jurisdictionSubHeader1","#jurisdictionSubHeader2","#jurisdictionSubHeader3","#jurisdictionSubHeader4","#jurisdictionSubHeader5","#jurisdictionCourtIcon","#jurisdictionAustraliaIcon","#jurisdictionStopIcon","#breakoutTopSmall","#breakoutBottomSmall","#breakoutTopLarge","#breakoutBottomLarge","#procedureHeader",".ICJprocedureContainer","#procedure1","#procedure2","#procedure3","#procedure4","#procedure5","#procedure6","#judgementHeader","#judgementSubHeader1","#judgementSubHeader2","#breakoutTopLarge"],isie_prefix:"is-ie-",isie:"is-ie",notie:"not-ie"},ie=function(){for(var e,i=3,o=document.createElement("div"),t=o.getElementsByTagName("i");o.innerHTML="<!--[if gt IE "+ ++i+"]><i></i><![endif]-->",t[0];);return i>4?i:e}(),addClasses=function(e,i){var o,t=$$(e.selectors.join(", "));for(o=0;o<t.length;o++)i?(t[o].addClassName(e.isie),t[o].addClassName(e.isie_prefix+i)):t[o].addClassName(e.notie)};Event.observe(window.document,"dom:loaded",function(){addClasses(opts,ie)}); </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment