text: /*! tilePuzzle 07-10-2015 12:10:11 */
  !function(a){"use strict";a.fn.tilePuzzle=function(b){var c=a(this),d=null,e={keyAccess:!1,tileContainerClass:"tiles",level:4,maxWidth:600},f={container:null,imageDimensions:{},tileDimensions:{},spareTile:null,init:function(){var b=this;return b.container=a("<ul/>").addClass(d.tileContainerClass),c.append(b.container),d.level<3&&(d.level=3),b.loadRemoteImage(),b.container.on("click","li",function(){b.moveTile(this,this.style.top,this.style.left)}),b},loadRemoteImage:function(){var a=this,b=new Image;return b.onload=function(){if(a.imageDimensions={width:this.width,height:this.height},a.imageDimensions.width>a.maxWidth){var b=a.maxWidth/a.imageDimensions.width*this.height;a.imageDimensions.width=a.maxWidth,a.imageDimensions.height=b}a.createTiles()},b.src=d.imageUrl,a},createTiles:function(){var b,e,f=this,g=null;for(f.tileDimensions={width:Math.abs(f.imageDimensions.width/d.level),height:Math.abs(f.imageDimensions.height/d.level)},b=0,e=0,g=0;g<d.level*d.level;g++)f.container.append(a("<li/>").css({width:f.tileDimensions.width,height:f.tileDimensions.height,"background-image":"url("+d.imageUrl+")","background-position":"-"+g*this.tileDimensions.width+"px -"+b*f.tileDimensions.height+"px","background-size":f.imageDimensions.width+"px "+f.imageDimensions.height+"px",top:b*f.tileDimensions.height+"px",left:e*f.tileDimensions.width+"px"})),e++,(g+1)%d.level===0&&(b++,e=0);return f.spareTile=f.container.children(":last-child").addClass("spare")[0],c.css({width:f.imageDimensions.width,height:f.imageDimensions.height}).fadeIn(),f.scrambleTiles(d.level),f},scrambleTiles:function(a){var b,c,e,f,g,h;b=this,a*=a,c=0,setTimeout(function(){h=setInterval(function(){e=b.container.children().eq(Math.floor(Math.random()*(d.level*d.level)+1)),f=b.container.children().eq(Math.floor(Math.random()*(d.level*d.level)+1)),g={top:e.css("top"),left:e.css("left")},e.css({top:f.css("top"),left:f.css("left")}),f.css({top:g.top,left:g.left}),c++,c>a&&(clearInterval(h),setTimeout(function(){b.container.addClass("in-play")},250))},25)},1e3)},moveTile:function(a,b,c){var d,e,f;d=this,e=Math.abs(parseInt(b,10)-parseInt(d.spareTile.style.top,10)),f=Math.abs(parseInt(c,10)-parseInt(d.spareTile.style.left,10)),(f+e<=Math.round(d.tileDimensions.width)||f+e<=Math.round(d.tileDimensions.height))&&(a.style.top=d.spareTile.style.top,a.style.left=d.spareTile.style.left,d.spareTile.style.top=b,d.spareTile.style.left=c)}};return d=a.extend(f,e,b),d.init(),c}}(jQuery);