-
Notifications
You must be signed in to change notification settings - Fork 8
/
jquery.rframe.min.js
1 lines (1 loc) · 3.66 KB
/
jquery.rframe.min.js
1
(function(c,d){var b="rFrame",a="0.0.3";c.rFrame=function(f){var g=c.extend({background:"#dedede",color:"#dedede",toolbar_bg:"#333",btn_bg:"#3e8ec0",btn_color:"#fff",font:"Verdana",device:"iPhone5",device_color:"#d0d0d0",view:0,forkme:true,width:320,height:568,topmargin:100,rightsidepad:27,leftsidepad:27,toppad:125,bottompad:125,radius:50,hash:window.location.hash,forkme_code:c('<a href="https://github.com/seyDoggy/rFrame" style="position: absolute; top: 0; right: 2em; border: 0;"><img style="border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_red_aa0000.png" alt="Fork me on GitHub"></a>'),reference:null,wrapper:null,selectdevice:null,selectview:null,rFrame:null,toolbar:null,iFrame:null,rehash:function(){window.location.hash="";c.ajax({url:"",context:document.body,success:function(i,h){c(this).html(i);c.rFrame({background:g.background,color:g.color,toolbar_bg:g.toolbar_bg,btn_bg:g.btn_bg,btn_color:g.btn_color,font:g.font,device:g.device,device_color:g.device_color,view:g.view,forkme:g.forkme})}})},setSelect:function(){c('#rFrame option[value="'+g.device+'"]').attr("selected","selected")}},f);if(g.hash!="#rFrame"){window.location.hash="#rFrame";g.reference=c(location).attr("href");g.selectdevice=c('<select id="device_select"><option value="iPhone5">iPhone5</option><option value="iPhone4">iPhone4</option><option value="Android">Android</option><option value="iPad">iPad</option><option value="Kindle">Kindle</option><option value="Off">Off</option></select>').on("change",function(){if(c(this).val()!="null"&&c(this).val()!="Off"){switch(c(this).val()){case"iPhone5":g.device="iPhone5";break;case"iPhone4":g.device="iPhone4";break;case"Android":g.device="Android";break;case"iPad":g.device="iPad";break;case"Kindle":g.device="Kindle";break}g.rehash()}else{window.location.hash="rFrame";window.location.reload()}});g.selectview=c('<a href="#" title="Select the device orientation."/>').text(function(){if(g.view==0){c(this).html("Portrait")}else{c(this).html("Landscape")}}).css({"text-decoration":"none","background-color":g.btn_bg,color:g.btn_color,padding:"0.5em 1em","margin-left":"2em"}).on("click",function(h){h.preventDefault();if(g.view==0){g.view=1;g.rehash()}else{g.view=0;g.rehash()}});if(g.device!="iPhone5"){switch(g.device){case"iPhone4":g.height=480;break;case"iPad":g.width=768;g.height=1024;g.rightsidepad=100;g.leftsidepad=g.rightsidepad;g.toppad=100;g.bottompad=g.toppad;break;case"Android":g.width=380;g.height=685;g.toppad=80;g.bottompad=90;g.radius=85;break;case"Kindle":g.width=600;g.height=1024;g.rightsidepad=100;g.leftsidepad=g.rightsidepad;g.toppad=84;g.bottompad=146;g.radius=50;break}}if(g.view==1){var e=g.width;g.width=g.height;g.height=e;e=g.rightsidepad;g.rightsidepad=g.bottompad;g.bottompad=e;e=g.leftsidepad;g.leftsidepad=g.toppad;g.toppad=e}if((g.height+g.toppad+g.bottompad)<c(window).height()){g.topmargin=((c(window).height()-(g.height+g.toppad+g.bottompad))/2)+25}g.wrapper=c('<div id="rFrame"/>').css({"background-color":g.background,position:"absolute",top:0,left:0,height:c("html").height(),"min-height":"100%","min-width":"100%"});g.iFrame=c('<iframe src="'+g.reference+'"/>').css({"background-color":g.device_color,border:"none","border-radius":g.radius+"px",display:"block",height:g.height,margin:g.topmargin+"px auto 0",padding:g.toppad+"px "+g.rightsidepad+"px "+g.bottompad+"px "+g.leftsidepad+"px",width:g.width,});g.toolbar=c('<div id="rFrame-toolbar"/>').css({padding:"1em",position:"fixed",color:g.color,"font-family":g.font,"background-color":g.toolbar_bg,"z-index":"1000000",width:"100%"}).append(g.forkme==true?g.forkme_code:"",g.selectdevice,g.selectview);g.rFrame=g.wrapper.append(g.toolbar,g.iFrame);c("body").html(g.rFrame);g.setSelect()}}})(jQuery);