|
1 | 1 | /* ======================================================================== |
2 | 2 | * Bootstrap-Airview: airview.js v1.0.0 |
3 | | - * https://github.com/deviprsd21/Bootstrap-Airview |
| 3 | + * http://deviprsd21.github.io/Airview/ |
4 | 4 | * ======================================================================== |
5 | 5 | * This Plugin is inspired by Tooltip.js by Jacob Thornton |
6 | 6 | * Copyright 2014 Devi Prasad |
|
46 | 46 | } |
47 | 47 |
|
48 | 48 | Airview.prototype.setContent = function () { |
| 49 | + var $e = this.$element |
49 | 50 | var $tip = this.tip() |
50 | 51 | var title = this.getTitle() |
51 | 52 | var imgalt = title.substr(title.lastIndexOf('/') + 1) |
|
68 | 69 |
|
69 | 70 | // IE8 doesn't accept hiding via the `:empty` pseudo selector, we have to do |
70 | 71 | // this manually by checking the contents. |
71 | | - if (!title) $tip.find('.airview-inner').empty().html('<h4>' + this.options.error + '</h4>') |
| 72 | + if (!title || $e.attr('data-lost')) $tip.find('.airview-inner').empty().addClass('error').html('<span>' + this.options.error + '</span>') |
| 73 | + else if(title && isNaN(dimension.height) && $e.attr('data-broken')) $tip.find('.airview-inner').empty().addClass('error').html('<span>Broken Link</span>') |
72 | 74 | } |
73 | 75 |
|
74 | 76 | Airview.prototype.getHeight = function (width) { |
|
78 | 80 |
|
79 | 81 | Airview.prototype.fixTitle = function () { |
80 | 82 | var $e = this.$element |
81 | | - var loaded = false |
| 83 | + var error = false |
82 | 84 | var wait = false |
83 | 85 | var img = new Image() |
84 | 86 | var that = this |
|
99 | 101 | else title = content ? this.options.url ? this.options.url + content : content : title |
100 | 102 | } |
101 | 103 |
|
102 | | - img.addEventListener('load', function () { }, true) |
| 104 | + $(img).error(function(e){ |
| 105 | + if(title) $e.attr('data-broken', true) |
| 106 | + else $e.attr('data-lost', true) |
| 107 | + error = true |
| 108 | + }) |
103 | 109 | img.src = title |
104 | 110 |
|
105 | 111 | wait = setInterval(function () { |
106 | | - if(img.width != 0 && img.height != 0) { |
| 112 | + if(img.width != 0 && img.height != 0 || error) { |
107 | 113 | $e.attr('data-aratio', img.width / img.height) |
108 | 114 | img.removeAttribute("src") |
109 | | - img = null |
110 | | - clearInterval(wait) |
| 115 | + img = null |
| 116 | + clearInterval(wait) |
111 | 117 | } |
112 | 118 | },0) |
113 | 119 | } |
|
0 commit comments