/** * ResponsiveTest v1.2.2 (http://github.com/nghuuphuoc/responsivetest) * * Test responsive layout * * @author Nguyen Huu Phuoc * @copyright (c) 2013 Nguyen Huu Phuoc * @license MIT */ angular.module("ResponsiveTest",[]).directive("rtDevice",["$compile",function(a){return{restrict:"EA",replace:!0,scope:{brands:"="},link:function(b,c){var d='";var j=angular.element(d);a(j)(b),c.replaceWith(j)}}}]).directive("rtFrameLoading",function(){return{restrict:"A",link:function(a,b){var c=angular.element("
").css({position:"absolute",top:0,width:0,margin:0,padding:0,width:"100%",height:"100%"}).addClass("rt-loader").prependTo(b.parent());b.on("load",function(){c.hide()}),a.$watch("frameSrc",function(){a.frameSrc&&c.show()})}}}).directive("rtResizable",function(){return{restrict:"A",link:function(a,b){var c=a.$parent;b.css("position","relative");var d=angular.element("
").css({position:"absolute",top:0,width:0,margin:0,padding:0,width:"100%",height:"100%"}).hide().prependTo(b);b.resizable({start:function(){d.show()},stop:function(){d.hide()},resize:function(b,d){a.w=d.size.width*a.pxd,a.h=d.size.height*a.pxd,c.$apply()}})}}}).directive("rtKeyup",function(){return function(a,b,c){var d=a.$eval(c.rtKeyup);b.bind("keyup",function(b){a.$apply(function(){d(b.which)})})}}).config(["$httpProvider",function(a){var b=0,c=angular.element('
').appendTo(angular.element("body")).hide();a.responseInterceptors.push(function(){return function(a){b++,c.show();var d=function(a){return--b||c.hide(),a};return a.then(d,d)}})}]).controller("IndexController",["$rootScope","$scope","$http","$sce",function(a,b,c,d){b.loading=!0,b.w=1024,b.h=768,b.pxd=1,b.url=null,b.frameSrc=null,b.init=function(){c.get("data/devices.json").success(function(a){if(b.SUPPORTED_DEVICES=a.supportedDevices,window.location.hash&&"#u="==window.location.hash.substr(0,3)){var c=window.location.hash.substring(3);if(-1==c.indexOf("|"))b.url=c;else{var e=c.split("|");b.url=e[0],b.w=e[1],b.h=e[2],b.pxd=e.length>3?e[3]:1}}else b.url=a.randomUrls[Math.floor(Math.random()*a.randomUrls.length)];b.url&&(b.frameSrc=d.trustAsResourceUrl(b.normalizeUrl(b.url))),b.loading=!1}),b.$watch("w + h + url",function(){b.updateHash()})},b.rotate=function(){if(b.w&&b.h){var a=b.w;b.w=b.h,b.h=a}},b.resizeTo=function(a,c,d){b.w=a,b.h=c,b.pxd=d},b.onKeyup=function(a){13==a&&(b.frameSrc=d.trustAsResourceUrl(b.normalizeUrl(b.url)))},b.normalizeUrl=function(a){return a&&"http://"==a.substr(0,7)||"https://"==a.substr(0,8)?a:"http://"+a},b.updateHash=function(){b.w&&b.h&&b.url&&(window.location.hash="#u="+[b.url,b.w,b.h,b.pxd].join("|"))}}]);