-
Notifications
You must be signed in to change notification settings - Fork 1
/
jquery.slidereference.min.js
1 lines (1 loc) · 7.48 KB
/
jquery.slidereference.min.js
1
/*!https://github.com/fabionolasco/slidereference*/!function(e){"use strict";function i(i){e('.slidereference[data-active="yes"]').each(function(){i!==e(this)&&(e(this).html(e(this).attr("data-originaltext")),e(this).attr("data-active","no"))})}function t(t){e(t).find(".slidereference").bind("click",function(){var t,o=e(this);"yes"===e(this).attr("data-active")?(e(this).attr("data-active","no"),e(this).text(e(this).attr("data-originaltext"))):(i(o),e(this).attr("data-active","yes"),e(this).attr("data-clicktext")?e(this).text(e(this).attr("data-clicktext")):e(this).text("Deactivate"),e("#slidereference_div").remove()),e("<div/>").prop("id","slidereference_div").appendTo("body"),e(this).attr("data-url")&&(t={url:e(this).attr("data-url")}),e(this).attr("data-options")&&(t=(t=e(this).attr("data-options")).replace("}",",url:'"+e(this).attr("data-url")+"'}")),e("#slidereference_div").slidereference(t)})}function o(i,t){t.length>0&&(t=t.replace(/\'/g,'"'),t=e.parseJSON(t)),this.config=e.extend({},n,t),this.element=i,this.init()}function s(i,t,o){e(i).css(t,o)}var n={url:"http://www.fabionolasco.com/",mobile_friendly:"yes",loading_text:"Loading...",preloading_css:{display:"block",width:"200px",height:"200px",margin:"0 auto",border:"none",position:"relative"},loadingcss:{position:"fixed",height:"100%",backgroundColor:"#999",borderLeft:"1px solid #000",top:"0px",left:"100%",lineHeight:"100px",fontSize:"2em",fontWeight:"bold",color:"#fff",textAlign:"center",zIndex:"2",marginLeft:"0%"},ownsite_width:"70%",ownsite_container:".all",reference_width:"30%",iframe_border:"0",iframe_css:{width:"100%",height:"100%",padding:"20px"},resizable:"yes",resize_bar_css:{backgroundColor:"#777",height:"100%",position:"absolute",width:"3px",cursor:"col-resize",top:"0px",left:"0px"},resize_icon:"yes",resize_icon_css:{top:"50%",opacity:"0.5"},close_btn:"no",close_btn_css:{display:"block",width:"18px",lineHeight:"24px",backgroundColor:"#777",fontSize:"1.2em",fontWeight:"bold",color:"#fff",cursor:"pointer",position:"absolute",top:"0px",left:"0px",textAlign:"center"},close_bar:"yes",close_bar_text:"CLOSE",close_bar_css:{display:"block",width:"100%",lineHeight:"30px",backgroundColor:"#777",fontSize:"11px",fontWeight:"bold",color:"#fff",cursor:"pointer",position:"absolute",top:"0px",left:"0px",textAlign:"center"},css:{position:"fixed",height:"100%",backgroundColor:"#fff",borderLeft:"1px solid #000",top:"0px",zIndex:"1",left:"100%"},animation:{"-webkit-transition":"all 150ms ease","-moz-transition":"all 150ms ease","-o-transition":"all 150ms ease","-ms-transition":"all 150ms ease",transition:"all 150ms ease"}};o.prototype.init=function(){if(e("#slidereference").length)e("#slidereference").remove(),e(this.config.ownsite_container).css({width:"100%"});else{this.config.css.width=this.config.reference_width,this.config.loadingcss.width=this.config.reference_width;var t,o,n,r,a,c=e("<div/>"),d=e("<div/>"),l=e("<div/>"),f="<style>.loader,.loader:after,.loader:before{background:#FFF;-webkit-animation:load1 1s infinite ease-in-out;animation:load1 1s infinite ease-in-out;width:1em;height:4em}.loader:after,.loader:before{position:absolute;top:0;content:''}.loader:before{left:-1.5em}.loader{text-indent:-9999em;margin:2em auto;position:relative;font-size:11px;-webkit-animation-delay:-.16s;animation-delay:-.16s}.loader:after{left:1.5em;-webkit-animation-delay:-.32s;animation-delay:-.32s}@-webkit-keyframes load1{0%,100%,80%{box-shadow:0 0 #FFF;height:4em}40%{box-shadow:0 -2em #fff;height:5em}}@keyframes load1{0%,100%,80%{box-shadow:0 0 #FFF;height:4em}40%{box-shadow:0 -2em #fff;height:5em}}</style>",h=this.config.reference_width,p=!1,g=this.config.ownsite_container,m=this.config.ownsite_width;"yes"===this.config.mobile_friendly&&e(window).width()<481&&(m="100%",this.config.ownsite_width="100%",h="100%",this.config.reference_width="100%",this.config.loadingcss.width="100%",this.config.css.width="100%",this.config.close_bar_css.lineHeight="40px",this.config.close_bar_css.fontSize="1.2em",a="yes"),e(this.config.ownsite_container).css(this.config.animation),r=e("<div />").css(this.config.preloading_css).html('<div class="loader"></div>'+f),e(l).prop("id","slidereference_animatebars").append(r).css(this.config.loadingcss),e(d).prop("id","slidereference_loading").html(this.config.loading_text+e(l).html()).css(this.config.loadingcss).css(this.config.animation).appendTo(this.element),window.setTimeout(function(){s(g,"width",m)},1),window.setTimeout(function(){s("#slidereference_loading","margin-left","-"+h)},1),"yes"===this.config.resizable&&"yes"!==a&&(t=e("<div />").prop("id","slidereference_dragbar").css(this.config.resize_bar_css),"yes"===this.config.resize_icon&&e("<div />",{class:"slidereference_hamburger"}).css(this.config.resize_icon_css).html('<style>.slidereference_hamburger{position:relative;font-size:10px;width:3.3em;height:3.3em;background:#383b3e;border-radius:.3em;top: 50%;font-size:5px;height:30px}.slidereference_hamburger:before{border-top:.3em solid #efefef;content:"";position:absolute;width:1.9em;height:1em;margin:auto;border-bottom:.3em solid #efefef;top:1em;left:.7em;border-radius:.1em}.slidereference_hamburger:after{display:block;content:"";position:absolute;top:1.6em;width:1.9em;height:.3em;background:#efefef;left:.7em;border-radius:.1em}</style>').appendTo(t)),n=e("<iframe />",{id:"slidereference_iframe",src:this.config.url,frameborder:this.config.iframe_border,css:this.config.iframe_css}),e(c).prop("id","slidereference").append(n).append(t).css(this.config.css).appendTo(this.element),"yes"===this.config.close_btn&&(o=e("<div />",{id:"slidereference_close"}).html("X").css(this.config.close_btn_css),e("#slidereference").append(o),e("#slidereference_close").click(function(){i(),e("#slidereference").remove(),e("#slidereference_div").remove(),e(g).css({width:"100%"})})),"yes"===this.config.close_bar&&(o=e("<div />",{id:"slidereference_close"}).html(this.config.close_bar_text).css(this.config.close_bar_css),e("#slidereference").append(o),e("#slidereference_close").click(function(){i(),e("#slidereference").remove(),e("#slidereference_div").remove(),e(g).css({width:"100%"})}),e("#slidereference_iframe").css({"padding-top":e("#slidereference_close").css("line-height")})),e("#slidereference").on("mousewheel DOMMouseScroll touchmove scroll",function(e){var i=e.originalEvent,t=i.wheelDelta||-i.detail;this.scrollTop+=30*(t<0?1:-1),e.preventDefault()}),e("#slidereference_iframe").bind("load",function(){window.setTimeout(function(){s("#slidereference","margin-left","-"+h)},1),window.setTimeout(function(){e("#slidereference_loading").fadeOut(5e3).remove()},1)}),"yes"===this.config.resizable&&(e("#slidereference_dragbar").mousedown(function(i){i.preventDefault(),p=!0;var t=e("#slidereference"),o=e("<div />",{id:"slidereference_coverall",css:{position:"fixed",width:"100%",height:"100%",opacity:"0","z-index":"999991"}}),s=e("<div />",{id:"slidereference_ghostbar",css:{height:t.outerHeight(),top:t.offset().top,left:t.offset().left,width:"3px","background-color":"#000",opacity:"1",position:"absolute",cursor:"col-resize","z-index":"999999"}});e(s).appendTo(e("body")),e(o).appendTo(e("body")),e(document).mousemove(function(e){s.css("left",e.pageX+2)})}),e(document).mouseup(function(i){var t,o;p&&(o=i.pageX+2,t=e(window).width()-o,e(g).css({float:"left",width:o+"px"}),e("#slidereference").css({left:o+"px",width:t+"px","margin-left":"0px"}),e("#slidereference_ghostbar").remove(),e("#slidereference_coverall").remove(),e(document).unbind("mousemove"),p=!1)}))}},e.fn.slidereference=function(e){return"start"==e?void new t(this):(new o(this.first(),e),this.first())}}(jQuery,$);