Created
March 6, 2014 15:35
-
-
Save ewebdev/9392320 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
define([ | |
'jquery', | |
'underscore' | |
], function ($, _) { | |
$.fn.loadImg = function (options) { | |
// var opts = $.extend({}, $.fn.loadImg.defaults, options); | |
return this.each(function () { | |
var $ph = $(this); | |
var $img = $('<img/>', {src: $ph.data('src'), class: $ph.data('img-class') || '', style: $ph.data('img-style') || {}}).load(function () { | |
var tagName = $ph.data('tag') || 'img', | |
$el = tagName === 'img' ? $img : $('<' + tagName + '/>', {class: $ph.data('img-class') || '', style: $ph.data('img-style') || {}}); | |
$ph.append($el).addClass($ph.data('loaded-class') || ''); | |
}); | |
}); | |
}; | |
/* $.fn.loadImg.defaults = { | |
};*/ | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment