Skip to content

Commit

Permalink
Merge pull request #3 from lpilon/master
Browse files Browse the repository at this point in the history
Small change to use data-attribute instead of title
  • Loading branch information
lorenzos committed Oct 26, 2013
2 parents f50e05f + 9eaa917 commit 024b72e
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions Source/mooimagetip.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ var MooImageTip = new Class({
className: 'imagetip',
tipId: 'mooimagetip',
follow: true,
fx: { }
fx: { },
dataSource: 'data-photo'
},

initialize: function(options) {
Expand All @@ -34,18 +35,21 @@ var MooImageTip = new Class({
$(item).addEvents({
'mouseenter': function(e) {
var title = $(item).getProperty('title');
var image = $(item).getProperty('rel');

var image = $(item).getProperty($this.options.dataSource);
if (!image) return;
if (!title) title = $(item).getProperty('title_original');

if (!title) title = $(item).getProperty('data-title_original');
$(item).setProperty('data-title_original', title);
$(item).setProperty('title', '');

if ($($this.options.tipId)) $($this.options.tipId).destroy();
var tip = new Element('p', {'id': $this.options.tipId});
new Element('img', {'src': image, 'alt': title, 'title': title}).inject(tip);
if (title && title != "") {
new Element('br').inject(tip);
new Element('span', {'text': title}).inject(tip);
}
$(item).setProperty('title_original', title);
$(item).setProperty('title', '');
tip.setStyles({ 'position': 'absolute', 'left': e.page.x + $this.options.offset.x, 'top': e.page.y + $this.options.offset.y });
tip.set('tween', $this.options.fx);
tip.fade('hide').inject($(document.body), 'bottom').fade('in');
Expand All @@ -59,6 +63,7 @@ var MooImageTip = new Class({
$this.fireEvent('hide', [$this]);
});
$this.fireEvent('hiding', [$this, tip]);

},
'mousemove': function(e) {
if (!$this.options.follow) return;
Expand Down

0 comments on commit 024b72e

Please sign in to comment.