Files
dev.ttsby.com/plugins/captionjs/1.0.2/jquery.caption.min.js
2023-04-17 11:06:08 +09:00

12 lines
2.3 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*!
* caption.js | easily and semantically add captions to your images
* https://captionjs.com
*
* Copyright 20132017, Eric Magnuson
* Released under the MIT license
* https://github.com/jquery/jquery/blob/master/MIT-LICENSE.txt
*
* v1.0.2
* Date: 2017-02-03
*/
!function(t,e,o){t.fn.captionjs=function(o){var i={class_name:"captionjs",schema:!0,mode:"default",debug_mode:!1,force_dimensions:!0,is_responsive:!1,inherit_styles:!1},s=t.extend(i,o||{}),n=function(t,e,o,i){o.jquery&&i.jquery&&(o.css(t,i.css(t)),i.css(t,e))};return this.each(function(){s.debug_mode&&console.debug("caption.js | Starting.");var o,i,a=t(this),c=a.data("caption")?a.data("caption"):a.attr("alt"),d=a.wrap('<figure class="'+s.class_name+" "+s.class_name+"-"+s.mode+'"/>').after("<figcaption/>").parent(),r=a.next("figcaption").html(c);a.data("link")?r.wrapInner('<a href="'+a.data("link")+'"/>').children("a").css("padding","0").css("margin","0"):null;if("hide"===s.mode&&(s.mode="hidden"),""===c&&r.remove(),s.debug_mode&&console.debug("caption.js | Caption: "+c),s.force_dimensions){s.debug_mode&&console.debug("caption.js | Forcing dimensions with a clone.");var m=d.clone().css({position:"absolute",left:"-9999px"}).appendTo("body");o=t("img",m).outerWidth(),i=t("figcaption",m).css("width",o).css("clear","both").outerHeight(),m.remove()}else o=a.outerWidth(),i=r.outerHeight();s.is_responsive&&(o="100%",a.width(o)),s.inherit_styles&&("inline"==a.css("display")?d.css("display","inline-block"):n("display","block",d,a),"static"==a.css("position")?d.css("position","relative"):n("position","relative",d,a),n("clear","both",d,a),n("float","none",d,a),n("margin","0",d,a),a.css("padding","0"),n("left","auto",d,a),n("right","auto",d,a),n("top","auto",d,a),n("bottom","auto",d,a),n("z-index",a.css("z-index"),d,a)),d.width(o),s.schema&&(d.attr({itemscope:"itemscope",itemtype:"http://schema.org/Photograph"}),r.attr("itemprop","name"),a.attr("itemprop","image")),"stacked"===s.mode&&r.css({"margin-bottom":"0",bottom:"0"}),"animated"===s.mode&&r.css({"margin-bottom":"0",bottom:-i}),"hidden"===s.mode&&r.css({"margin-bottom":i,bottom:-i}),s.is_responsive&&t(e).resize(function(t){i=r.outerHeight(),"animated"===s.mode&&r.css({bottom:-i}),"hidden"===s.mode&&r.css({"margin-bottom":i,bottom:-i})})})}}(jQuery,window);