Created
March 21, 2011 17:02
-
-
Save benfoxall/879785 to your computer and use it in GitHub Desktop.
Outline jQuery cssHook
This file contains hidden or 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
(function($){ | |
if(document.createElement().style.outline == undefined){ | |
/* | |
This requires the following lines in the document: | |
<style>v\: * { behavior:url(#default#VML);}</style> | |
<xml:namespace ns="urn:schemas-microsoft-com:vml" prefix="v" /> | |
*/ | |
$.cssHooks['outline'] = { | |
set: function(elem, value){ | |
values = value.split(' '); | |
$(elem).find('.outline').remove(); | |
if(values.length == 3){ | |
var outline = $('<v:shape coordorigin="0 0" coordsize="1 1" class="outline" filled="False" style="position:absolute" path="m 0, 0 l 0,1, 1,1, 1,0 x e"></v:shape>'); | |
outline.height($(elem).height()).width($(elem).width()) | |
outline.attr({'strokecolor': values[0],'strokeweight':values[2]}) | |
$(elem).prepend(outline); | |
} | |
$(elem).data('outline-css', value); | |
}, | |
get: function(elem, computed, extra){ | |
return $(elem).data('outline-css') || ''; | |
} | |
} | |
} | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment