+
+
+ +
+
+ + + +
    + +
  • +
    + +
    + + + + Watch + + + + +
    + +
    +
    +
    +
  • + +
  • + +
    + +
    + + +
    +
    + + +
    + +
  • + +
  • +
    + +
    + +
  • +
+ +

+ + /jquery-live-preview + +

+ +
+ +
+ +
+
+ + + +Permalink + + + +
+ +
+ + + +
+ +
+ + Find file + + +
+ +
+ + +
+ Fetching contributors… +
+ +
+ + Cannot retrieve contributors at this time +
+
+ +
+
+
+ +
+ Raw + Blame + History +
+ + + + + +
+ +
+ +
+ +
+ 1 lines (1 sloc) + + 1.83 KB +
+
+ + + +
+ + + + + +
!function(t){t.fn.extend({livePreview:function(e){var i={trigger:"hover",targetWidth:1e3,targetHeight:800,viewWidth:300,viewHeight:200,position:"right",positionOffset:40},e=t.extend(i,e),a=e.viewWidth/e.targetWidth,r=e.viewHeight/e.targetHeight,o=1,n="livepreview_dialog";o="undefined"!=typeof e.scale?e.scale:a>r?a:r;var d=function(i){var a=i.data.triggerType,r=i.data.target,o=i.data.href,d=i.data.scale;"click"==a&&0==t("#"+n).length&&i.preventDefault();var h=e.position;r.attr("data-position")&&(h=r.attr("data-position"));var s=e.positionOffset;r.attr("data-positionOffset")&&(s=r.attr("data-positionOffset")),r.attr("data-scale")&&(d=r.attr("data-scale"));var g=t(this).offset(),v=t(this).width(),f=t(this).height(),l=g.top-e.viewHeight/2,p=g.left+v+s;"left"==h&&(p=g.left-e.viewWidth-s),"top"==h&&(p=g.left+v/2-e.viewWidth/2,l=g.top-e.viewHeight-s),"bottom"==h&&(p=g.left+v/2-e.viewWidth/2,l=g.top+f/2+s),t("body").append('<div id="livepreview_dialog" class="'+h+'" style="display:none; padding:0px; left: '+p+"px; top:"+l+"px; width: "+e.viewWidth+"px; height: "+e.viewHeight+'px"><div class="livepreview-container" style="overflow:hidden; width: '+e.viewWidth+"px; height: "+e.viewHeight+'px"><iframe id="livepreview_iframe" src="'+o+'" style="height:'+e.targetHeight+"px; width:"+e.targetWidth+"px;-moz-transform: scale("+d+");-moz-transform-origin: 0 0;-o-transform: scale("+d+");-o-transform-origin: 0 0;-webkit-transform: scale("+d+');-webkit-transform-origin: 0 0;"></iframe></div></div>'),t("#"+n).fadeIn(100)};return this.each(function(){var i=o,a=t(this),r=a.attr("data-preview-url")||a.attr("href"),h=e.trigger;a.attr("data-trigger")&&(h=a.attr("data-trigger")),"click"!=h&&(h="mouseenter",a.on("click",function(){t("#"+n).remove()})),a.on(h,null,{triggerType:h,target:a,href:r,scale:i},d),a.on("mouseleave",function(){t("#"+n).remove()})})}})}(jQuery);
+ +
+ +
+ + + + +
+ +
+ + +
+
+ +