diff options
author | Sebastian Silva <sebastian@sugarlabs.org> | 2011-09-28 00:19:33 (GMT) |
---|---|---|
committer | Sebastian Silva <sebastian@sugarlabs.org> | 2011-09-28 06:54:34 (GMT) |
commit | 5861585e94a32b3032ac473804bf90c6e1363940 (patch) | |
tree | fb3a5bab0d75bf8eb780e749737fea87369754db /websdk/static/js/jquery.plugin.svgimg.js | |
parent | be7aa93d7ba3682d5189e1a7d72169c0b02a1ec1 (diff) |
Migrated to Flask, added JQuery sugar theme, fixed race condition
Diffstat (limited to 'websdk/static/js/jquery.plugin.svgimg.js')
-rw-r--r-- | websdk/static/js/jquery.plugin.svgimg.js | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/websdk/static/js/jquery.plugin.svgimg.js b/websdk/static/js/jquery.plugin.svgimg.js new file mode 100644 index 0000000..4e2f9be --- /dev/null +++ b/websdk/static/js/jquery.plugin.svgimg.js @@ -0,0 +1,33 @@ +(function(){ + jQuery.fn.svgimg = function(options) { + return $(this).each(function() { + var _a, _b, _c, attribute, img, object; + img = $(this); + img.attr('style', 'display: inline-block'); + if (img.height() > 0) { + if (img.width() > 0) { + $('body').addClass('has_svg_images'); + } + } else { + if (img.height() > 0) { + $('body').addClass('has_svg_images'); + } + } + if ($('body').hasClass('has_svg_images')) { + return img.removeAttr('style'); + } else { + object = $('<object>'); + _b = ['height', 'width', 'id', 'class']; + for (_a = 0, _c = _b.length; _a < _c; _a++) { + attribute = _b[_a]; + if (img.attr(attribute)) { + object.attr(attribute, img.attr(attribute)); + } + } + object.attr('data', img.attr('src')); + img.after(object); + return img.remove(); + } + }); + }; +})(); |