Skip to content

Commit

Permalink
added configurable data source for tip image
Browse files Browse the repository at this point in the history
Removed title as source for image, used data-attribute instead (default
data-photo, configurable by user).
  • Loading branch information
Lennart committed May 19, 2013
1 parent f50e05f commit a4c53b6
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 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,16 @@ 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 ($($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 Down

0 comments on commit a4c53b6

Please sign in to comment.