Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/studio/static/js/jquery.plugin.svgimg.js
blob: 4e2f9bea9aaefea1cfc7468229e8a4c4b983f351 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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();
      }
    });
  };
})();