var app=angular.module('edlpro',['restangular','ngDragDrop','ngAnimate','ngCookies','ngSanitize','countdownTimer','angularUtils.directives.dirPagination','gameFilters','videoFilters','UIresize','ngRoute','elasticsearch','ElasticService','ElasticServiceUtil','GameService','ScheduleService','EventService','VideoService','VideoplayerService','MainCtrl','VideosearchCtrl','VideoArchiveCtrl','VideoplayerCtrl','VideofeaturedCtrl','VideosetCtrl','VideoDirective',]).config(function($sceDelegateProvider){$sceDelegateProvider.resourceUrlWhitelist(['self','http://dev.pro.eslgaming.com/**','http://pro.eslgaming.com/**','http://event.eslgaming.com/**','http://dev.event.eslgaming.com/**','http://api.esl.tv/**','http://cdn2.esl.tv/**','https://publish.twitter.com/**','http://dev.api.esl.tv/**','http://cdn1.api.esl.tv/**','https://cdn1.api.esl.tv/**','http://*.esl.tv/**','http://localhost/**','https://cdn1.api.esl.tv/**']);}).config(function($sceDelegateProvider){$sceDelegateProvider.resourceUrlWhitelist(['self','http://www.youtube.com/**','http://www.twitch.tv/**','https://twitter.com/**','https://publish.twitter.com/**','http://www.hitbox.tv/**','http://www.azubu.tv/**','http://embed.azubu.tv/**','http://play.viagame.com/**',]);}).config(function(RestangularProvider){var isDev=window.location.host.indexOf("dev")>=0;if(window.location.href.indexOf("calendar")>=0){};if(window.location.href.indexOf("localhost")>=0){isDev=1;};if(isDev){RestangularProvider.setBaseUrl('http://dev.api.esl.tv/v1/');}else{RestangularProvider.setBaseUrl('https://cdn1.api.esl.tv/v1/');} RestangularProvider.addResponseInterceptor(function(data,operation,what,url,response,deferred){var extractedData;if(operation==="getList"){extractedData=data.items;extractedData.meta=data._meta;extractedData.links=data._links;}else{extractedData=data;} return extractedData;});}).run(function($rootScope,Restangular){Restangular.addRequestInterceptor(function(element){return element;});Restangular.addResponseInterceptor(function(data){return data;});Restangular.setResponseExtractor(function(response){var newResponse=response;if(angular.isArray(response)){angular.forEach(newResponse,function(value,key){newResponse[key].originalElement=angular.copy(value);});}else{newResponse.originalElement=angular.copy(response);} return newResponse;});});;app.controller('PageCtrl',function($scope,Restangular){});;(function(angular){'use strict';angular.module('countdownTimer',[]).directive('countdown',function($interval,dateFilter){return{restrict:'A',transclude:true,link:function(scope,element,attrs){var countDownInterval;function displayString(){attrs.units=angular.isArray(attrs.units)?attrs.units:attrs.units.split('|');var lastUnit=attrs.units[attrs.units.length-1],unitConstantForMillisecs={weeks:(1000*60*60*24*7),days:(1000*60*60*24),hours:(1000*60*60),minutes:(1000*60),seconds:1000,milliseconds:1},unitsLeft={},returnString='',totalMillisecsLeft=new Date(attrs.endDate)-new Date(),i,unit;for(i in attrs.units){if(attrs.units.hasOwnProperty(i)){unit=attrs.units[i].trim();if(unitConstantForMillisecs[unit.toLowerCase()]===false){$interval.cancel(countDownInterval);throw new Error('Cannot repeat unit: '+unit);} if(unitConstantForMillisecs.hasOwnProperty(unit.toLowerCase())===false){$interval.cancel(countDownInterval);throw new Error('Unit: '+unit+' is not supported. Please use following units: weeks, days, hours, minutes, seconds, milliseconds');} unitsLeft[unit]=totalMillisecsLeft/unitConstantForMillisecs[unit.toLowerCase()];if(lastUnit===unit){unitsLeft[unit]=Math.floor(unitsLeft[unit]);}else{unitsLeft[unit]=Math.floor(unitsLeft[unit]);} totalMillisecsLeft-=unitsLeft[unit]*unitConstantForMillisecs[unit.toLowerCase()];unitConstantForMillisecs[unit.toLowerCase()]=false;returnString+=' '+unitsLeft[unit]+' '+unit;}} return returnString;} function updateCountDown(){element.text(displayString());} element.on('$destroy',function(){$interval.cancel(countDownInterval);});countDownInterval=$interval(function(){updateCountDown();},1);}};});}(angular));;app.controller('CmsParamsCtrl',function($scope,$attrs){$scope.cmsparams=[];for(var key in $attrs){if(typeof $attrs[key]==='string'){$scope.cmsparams[key]=$attrs[key];}}});;app.controller('ScheduleCtrl',function($scope,Restangular,$attrs){$scope.eventid=$attrs.eventid;$scope.languages=$attrs.languages;$scope.removetitle=$attrs.removetitle;$scope.getparams=$attrs.getparams;if($attrs.fetchdata){getdata();} $scope.$watch('fetchdata',function(newValue,oldValue){if(newValue){getdata();}});function getdata(){var x=new Date();var currentTimeZoneOffsetInHours=x.getTimezoneOffset()/60;var restSchedule=new Restangular.all('schedule/byday?event='+$scope.eventid+'&languages='+$scope.languages+'&offset='+currentTimeZoneOffsetInHours+'&'+$scope.getparams);restSchedule.getList().then(function(fetchedItems){$scope.scheduleperday=fetchedItems;});};});;app.controller('TeamsCtrl',function($scope,Restangular,$attrs,$cookies){$scope.pids='';$scope.categories='';$scope.lang=$attrs.lang;$scope.allteams=[];$attrs.$observe('pids',function(value){var restTeams=new Restangular.all('team/listgrouped?pids='+value+'&lang='+$scope.lang);restTeams.getList().then(function(fetchedItems){$scope.teams=fetchedItems;angular.forEach($scope.teams,function(group,groupkey){angular.forEach(group.teams,function(team,teamskey){$scope.allteams.push(team);});});$scope.doneloading=true;$scope.updateSelectedDivision();});});$scope.selecteddivision=function(viewLocation){return $cookies.get('selecteddivision');};$scope.selectedsubgroup=function(viewLocation){var selecteddivision=this.selecteddivision();var pieces=selecteddivision.split("__");return pieces[0];};$scope.$watch('fetchdata',function(newValue,oldValue){if(newValue){var restTeams=new Restangular.all('team/list?pids='+$scope.pids+'&lang='+$scope.lang+'&categories='+$scope.categories);restTeams.getList().then(function(fetchedItems){$scope.teams=fetchedItems;});}});$scope.updateSelectedDivision=function($show) {var isfirst=true;var cookievar;var firstshow;var selectectedDivExists=false;var now=new Date(),exp=new Date(now.getFullYear()+1,now.getMonth(),now.getDate());angular.forEach($scope.teams,function(group,groupkey){angular.forEach(group.teams,function(team,teamskey){if(isfirst){firstshow=group.groupname;isfirst=false;} if($cookies.get('selecteddivision')==group.groupname){selectectedDivExists=true;cookievar=group.groupname;}});});if($show==undefined){if(selectectedDivExists){console.log("setting 1: "+cookievar);$cookies.put("selecteddivision",cookievar,{path:'/',expires:exp});}else{console.log("setting 2: "+firstshow);$cookies.put("selecteddivision",firstshow,{path:'/',expires:exp});}}else{console.log("setting 3: "+$show);$cookies.put("selecteddivision",$show,{path:'/',expires:exp});}}});;app.controller('PlayersCtrl',function($scope,Restangular,$attrs,$cookies){$scope.pids='';$scope.categories='';$scope.lang=$attrs.lang;$scope.allplayers=[];$attrs.$observe('pids',function(value){var restPlayers=new Restangular.all('player/listgrouped?pids='+value+'&lang='+$scope.lang);restPlayers.getList().then(function(fetchedItems){$scope.players=fetchedItems;angular.forEach($scope.players,function(group,groupkey){angular.forEach(group.players,function(player,playerskey){$scope.allplayers.push(player);});});$scope.doneloading=true;$scope.updateSelectedDivision();});});$scope.selecteddivision=function(viewLocation){return $cookies.get('selecteddivision');};$scope.$watch('fetchdata',function(newValue,oldValue){if(newValue){var restPlayers=new Restangular.all('player/list?pids='+$scope.pids+'&lang='+$scope.lang+'&categories='+$scope.categories);restPlayers.getList().then(function(fetchedItems){$scope.players=fetchedItems;});}});$scope.updateSelectedDivision=function($show) {var isfirst=true;var first='';var now=new Date(),exp=new Date(now.getFullYear()+1,now.getMonth(),now.getDate());var selectedByCookie=!$cookies.get('selecteddivision');var selectedExist=false;if($show==undefined){angular.forEach($scope.players,function(player,playerskey){if(isfirst){first=player.groupname;isfirst=false;} if(player.groupname==selectedByCookie){selectedExist=true;}});if(!selectedExist||!selectedByCookie){$show=first;}} if($show){$cookies.put("selecteddivision",$show,{path:'/',expires:exp});}}});;app.controller('TweetsCtrl',function($scope,Restangular,$attrs,$cookies){$scope.numTweets=0;$scope.screenname='';$scope.mediatype='';$scope.toggleshow=false;$scope.showtweet={};$scope.viewStart=1;if($attrs.limit){$scope.limit=$attrs.limit/1;}else{$scope.limit=2;} $scope.numtofetch=$scope.limit*4;$attrs.$observe('screenname',function(value){var restTweets=new Restangular.all('tweet/list?screen_name='+value+'&media_type='+$attrs.mediatype+'&keyword='+$attrs.keyword+'&limit='+$scope.numtofetch);restTweets.getList().then(function(fetchedItems){$scope.tweets=fetchedItems;var num=1;angular.forEach($scope.tweets,function(tweet,tweetkey){$scope.tweets[tweetkey]['num']=num;num++;});$scope.numTweets=num;});});$scope.isView=function(item){var end=$scope.viewStart+$scope.limit;if(item.num>=$scope.viewStart&&item.num<($scope.viewStart+$scope.limit)){return item;}};$scope.more=function(){$scope.viewStart=$scope.viewStart+$scope.limit;if($scope.viewStart>$scope.numtofetch){$scope.viewStart=1;} var end=$scope.viewStart+$scope.limit;};$scope.next=function($tweet) {var currentIndex=$scope.showtweet.num;var nextIndex=currentIndex+1;if(nextIndex>=$scope.numTweets){nextIndex=1;} angular.forEach($scope.tweets,function(tweet,tweetkey){if(tweet.num==nextIndex){$scope.showtweet=tweet;}});} $scope.show=function($tweet) {$scope.toggleshow=true;$scope.showtweet={};$scope.showtweet=$tweet;console.log($scope.showtweet.media_url);} $scope.close=function() {$scope.toggleshow=false;$scope.showtweet='';}});;app.controller('TeamCtrl',function($scope,Restangular,$attrs,$interval,$location,$cookies){$scope.getparams=$attrs.getparams;$scope.parentpid=$attrs.parentpid;$scope.lang=$attrs.lang;$scope.pids=$attrs.pids;$scope.uid=$attrs.uid;$scope.anyphotos=0;$scope.anyplayerstats=0;$scope.nophotosclass='nophoto';$attrs.$observe('uid',function(value){if(value){var restTeam=new Restangular.all('team/detail?uid='+value+'&pids='+$scope.pids+'&lang='+$scope.lang+'&'+$scope.getparams);var restStandings=new Restangular.all('teamranking/list?pid='+$scope.pids+'&'+$scope.getparams);restTeam.getList().then(function(fetchedItems){$scope.team=fetchedItems[0];$scope.uid=$scope.team.uid;angular.forEach($scope.team.players,function(player,playerkey){if(player.photo){$scope.anyphotos=1;$scope.nophotosclass='';}});var restMatches=new Restangular.all('match/list?team='+$scope.team.uid+'&parentpid='+$scope.parentpid+'&'+$scope.getparams);restMatches.getList().then(function(fetchedItems){$scope.matches=fetchedItems;$scope.streak=0;var currentstreak=0;angular.forEach($scope.matches,function(match,matchkey){if(match.team1.uid==$scope.uid){if(match.winner==1){currentstreak++;} if(currentstreak>$scope.streak){$scope.streak=currentstreak;} if(match.winner==2){currentstreak=0;}} if(match.team2.uid==$scope.uid){if(match.winner==2){currentstreak++;} if(currentstreak>$scope.streak){$scope.streak=currentstreak;} if(match.winner==1){currentstreak=0;}}});});var restStats=new Restangular.all('teammatchstats/playerstats?team_uid='+$scope.team.uid+'&parentpid='+$scope.parentpid+'&'+$scope.getparams);restStats.getList().then(function(fetchedItems){$scope.playerstats=[];$scope.teamstats={};$scope.teamstats.sum_kills=0;$scope.teamstats.sum_deaths=0;var topkd_player=0;var topkd=0;angular.forEach(fetchedItems,function(item,itemkey){$scope.teamstats.sum_kills+=item.sum_kills;$scope.teamstats.sum_deaths+=item.sum_deaths;if($scope.teamstats.sum_deaths){$scope.teamstats.kd=$scope.teamstats.sum_kills/$scope.teamstats.sum_deaths;}else{$scope.teamstats.kd=$scope.teamstats.sum_kills/1;} $scope.playerstats[item.player_key]=item;$scope.playerstats[item.player_key].istopkd='';$scope.anyplayerstats=1;if(item.kd>topkd){topkd=item.kd;topkd_player=item.player_key;}});$scope.playerstats[topkd_player].istopkd='topkd';});restStandings.getList().then(function(fetchedItems){angular.forEach(fetchedItems,function(matches,matcheskey){angular.forEach(matches.groups,function(group,groupkey){angular.forEach(group.teams,function(team,teamkey){if(team.team.uid==$scope.uid){$scope.seasonstats=team;}});});});});});$scope.doneloading=true;}});$scope.playerfirst=function(player){return player.position!=='Player';} $scope.substitutefirst=function(player){return player.position!=='Substitute';}});;app.controller('GooglesheetCtrl',function($scope,Restangular,$attrs,$interval,$location,$cookies,$http){$scope.url=$attrs.url;$scope.getData=function(url){$http.get(url).success(function(response){var entries=response['feed']['entry'];$scope.sheetdata=[];for(key in entries){var content=entries[key];$scope.sheetdata.push(parse(content));}});};$attrs.$observe('url',function(value){if(value){$scope.getData(value);}});var parse=function(entry){var name=entry['gsx$name']['$t'];var logo=entry['gsx$logo']['$t'];var twitter=entry['gsx$twitter']['$t'];var website=entry['gsx$website']['$t'];var youtube=entry['gsx$youtube']['$t'];var facebook=entry['gsx$facebook']['$t'];var twitch=entry['gsx$twitch']['$t'];var description=entry['gsx$description']['$t'];return{name:name,logo:logo,twitter:twitter,website:website,youtube:youtube,facebook:facebook,twitch:twitch,description:description,};};});;app.controller('MatchesCtrl',function($scope,Restangular,$attrs,$interval,$location,$anchorScroll,$cookies){$scope.matchesqueue=[];$scope.resultsbuffering=0;$scope.matchesqueuesize=0;$scope.reloadeveryseconds=20;$scope.pids=$attrs.pids;$scope.parentpid=$attrs.parentpid;$scope.maxdays=$attrs.maxdays;$scope.delay=$attrs.delay;$scope.status=$attrs.status;$scope.division=$attrs.division;$scope.getparams=$attrs.getparams;$scope.lang=$attrs.lang;$scope.rematches=$attrs.rematches;$scope.dontreload=$attrs.dontreload;$scope.nourlchange=$attrs.nourlchange;$scope.noselect=$attrs.noselect;$scope.contestanttype=$attrs.contestanttype;$scope.totalmatches=0;$scope.selectedmatchday='';$scope.matchstats=[];$scope.groups={};$scope.allmatches=[];$scope.numWeeks=0;$scope.offset=0;$scope.showmaps=false;if(!$scope.lang){$scope.lang='en';} var date=new Date();$scope.timezoneoffset=-(date.getTimezoneOffset()/60);if($scope.timezoneoffset>0){$scope.timezoneoffset='+'+$scope.timezoneoffset;} if($attrs.fetchdata){getdata();} $scope.$watch('fetchdata',function(newValue,oldValue){if(newValue){if($scope.delay){$scope.matchesqueuesize=$scope.delay/$scope.reloadeveryseconds;} getdata();}});$scope.selecteddivision=function(viewLocation){if($scope.division!==undefined&&$scope.division!=""){return $scope.division}else{return $cookies.get('selecteddivision');}};$scope.selectedsubgroup=function(viewLocation){var selecteddivision=this.selecteddivision();var pieces=selecteddivision.split("__");return pieces[0];};$scope.hidespoiler=function(match){var hidespoilercookie=$cookies.get('hidespoiler');if(hidespoilercookie){return true;} if(match.winner>0||(match.winner==0&&(match.result_team1+match.result_team2==0))){return true;}} $scope.toggleSpoiler=function(){$cookies.put("hidespoiler",1,{path:'/'});} $scope.updateSelectedDivision=function($show) {var isfirst=true;var now=new Date(),exp=new Date(now.getFullYear()+1,now.getMonth(),now.getDate());if($show==undefined&&!$cookies.get('selecteddivision')){angular.forEach($scope.matches,function(matches,matcheskey){angular.forEach(rankings.groups,function(group,groupkey){if(isfirst){$show=group.groupname;isfirst=false;}});});} if($show){$cookies.put("selecteddivision",$show,{path:'/',expires:exp});}} function getdata(){var x=new Date();var currentTimeZoneOffsetInHours=x.getTimezoneOffset()/60;var restMatches=new Restangular.all('match/perday?parentpid='+$scope.parentpid +'&pids='+$scope.pids +'&lang='+$scope.lang +'&status='+$scope.status +'&type='+$scope.contestanttype +'&offset='+currentTimeZoneOffsetInHours +'&rematches='+$scope.rematches +'&maxdays='+$scope.maxdays +'&'+$scope.getparams);var firstopen=false;var numclosedmatches=0;var subgroup_is_first=[];restMatches.getList().then(function(fetchedItems){$scope.matches=queuematches(fetchedItems);scrollToFirstOpen();if(!$scope.dontreload){$interval(reload,1000*$scope.reloadeveryseconds);} angular.forEach($scope.matches,function(matchday,matchdaykey){$scope.matches[matchdaykey].nummatches={};var last_subgroup_title='';angular.forEach(matchday.matches,function(match,matchkey){if(match.winner==0&&firstopen==false){firstopen=true;if(numclosedmatches>0){$scope.offset=numclosedmatches-1;}}else{numclosedmatches++;} $scope.allmatches.push($scope.matches[matchdaykey].matches[matchkey]);var groupname=$scope.matches[matchdaykey].matches[matchkey].groupname;if($scope.matches[matchdaykey].matches[matchkey].subgroup_title!=undefined){} if($scope.groups[groupname]==undefined){$scope.groups[groupname]={};$scope.groups[groupname].first_in_subgroup=0;} $scope.groups[groupname].groupname=groupname;$scope.groups[groupname].groupname_short=$scope.matches[matchdaykey].matches[matchkey].groupname_short;$scope.groups[groupname].subgroupname=$scope.matches[matchdaykey].matches[matchkey].subgroupname;$scope.groups[groupname].subgroup_title=$scope.matches[matchdaykey].matches[matchkey].subgroup_title;if(last_subgroup_title!=$scope.matches[matchdaykey].matches[matchkey].subgroup_title&&$scope.matches[matchdaykey].matches[matchkey].subgroup_title!==undefined&&$scope.matches[matchdaykey].matches[matchkey].subgroup_title!==''&&$scope.groups[groupname].first_in_subgroup==0&&subgroup_is_first[$scope.matches[matchdaykey].matches[matchkey].subgroup_title]==undefined){$scope.groups[groupname].first_in_subgroup=1;last_subgroup_title=$scope.matches[matchdaykey].matches[matchkey].subgroup_title;subgroup_is_first[last_subgroup_title]=1;console.log("first: for groupname("+groupname+") "+last_subgroup_title);}else{} if($scope.matches[matchdaykey].nummatches[groupname]==undefined){$scope.matches[matchdaykey].nummatches[groupname]=0;}else{$scope.matches[matchdaykey].nummatches[groupname]++;}});$scope.setmatchday($location.search().matchday);});});};$scope.isMatchday=function(match){if(match.matchday==$scope.selectedmatchday){return true;} return false;};$scope.setmatchday=function(newmatchday) {$scope.selectedmatchday=newmatchday;$location.search('matchday',newmatchday);} $scope.changeOffset=function(diff) {$scope.offset+=diff;if($scope.offset<0){$scope.offset=0;} if($scope.offset>$scope.allmatches.length){$scope.offset=$scope.allmatches.length;}} function queuematches(matches) {if(!$scope.delay){return matches;} $scope.matchesqueue.push(matches);if($scope.matchesqueue.length>=$scope.matchesqueuesize){$scope.matchesqueue.splice(0,1);$scope.resultsbuffering=0;}else{$scope.resultsbuffering=1;} return $scope.matchesqueue[0];} function scrollToFirstOpen() {var isFirst=0;$scope.totalmatches=0;angular.forEach($scope.matches,function(day,daykey){if(day.nextday==true&&$scope.selectedmatchday==''&&$location.search().matchday==undefined&&!$scope.noselect){$scope.selectedmatchday=day.matchday;if($scope.nourlchange==1){}else{$location.search('matchday',day.matchday);}} angular.forEach(day.matches,function(value,key){$scope.totalmatches++;if(value.map1_ingamestats!=''){var json=JSON.parse(value.map1_ingamestats);$scope.matches[daykey]['matches'][key]['map1_ingamestats']=json;$scope.matchstats[value.uid]=[];$scope.matchstats[value.uid]['map1']=json;$scope.matches[daykey].matches[key]['map1_stats']=json;} if(value.map2_ingamestats!=''){var json=JSON.parse(value.map2_ingamestats);$scope.matches[daykey]['matches'][key]['map2_ingamestats']=json;$scope.matchstats[value.uid]=[];$scope.matchstats[value.uid]['map2']=json;$scope.matches[daykey].matches[key]['map2_stats']=json;} if(value.map3_ingamestats!=''){var json=JSON.parse(value.map3_ingamestats);$scope.matches[daykey]['matches'][key]['map3_ingamestats']=json;$scope.matchstats[value.uid]=[];$scope.matchstats[value.uid]['map3']=json;$scope.matches[daykey].matches[key]['map3_stats']=json;} if(value.map4_ingamestats!=''){var json=JSON.parse(value.map4_ingamestats);$scope.matches[daykey]['matches'][key]['map4_ingamestats']=json;$scope.matchstats[value.uid]=[];$scope.matchstats[value.uid]['map4']=json;$scope.matches[daykey].matches[key]['map4_stats']=json;} if(value.map5_ingamestats!=''){var json=JSON.parse(value.map5_ingamestats);$scope.matches[daykey]['matches'][key]['map5_ingamestats']=json;$scope.matchstats[value.uid]=[];$scope.matchstats[value.uid]['map5']=json;$scope.matches[daykey].matches[key]['map5_stats']=json;} if(!isFirst&&value.winner==0){isFirst=1;$anchorScroll();}});});} function reload() {var x=new Date();var currentTimeZoneOffsetInHours=x.getTimezoneOffset()/60;var restMatches=new Restangular.all('match/perday?parentpid='+$scope.parentpid +'&pids='+$scope.pids +'&lang='+$scope.lang +'&status='+$scope.status +'&type='+$scope.contestanttype +'&offset='+currentTimeZoneOffsetInHours +'&rematches='+$scope.rematches +'&maxdays='+$scope.maxdays +'&'+$scope.getparams);restMatches.getList().then(function(fetchedItems){$scope.matches=queuematches(fetchedItems);scrollToFirstOpen();angular.forEach($scope.matches,function(matchday,matchdaykey){$scope.matches[matchdaykey].nummatches={};angular.forEach(matchday.matches,function(match,matchkey){var groupname=$scope.matches[matchdaykey].matches[matchkey].team1.category;$scope.groups[groupname]={};$scope.groups[groupname].groupname=groupname;$scope.groups[groupname].groupname_short=$scope.matches[matchdaykey].matches[matchkey].groupname_short;if($scope.matches[matchdaykey].nummatches[groupname]==undefined){$scope.matches[matchdaykey].nummatches[groupname]=0;}else{$scope.matches[matchdaykey].nummatches[groupname]++;}});});});}});;app.controller('NextmatchCtrl',function($scope,Restangular,$attrs,$interval,$location,$anchorScroll,$cookies){$scope.pids=$attrs.pids;$scope.parentpid=$attrs.parentpid;$scope.getparams=$attrs.getparams;$scope.lang=$attrs.lang;$scope.totalmatches=0;$scope.selectedmatchday='';$scope.matchstats=[];$scope.groups={};var date=new Date();$scope.timezoneoffset=-(date.getTimezoneOffset()/60);if($scope.timezoneoffset>0){$scope.timezoneoffset='+'+$scope.timezoneoffset;} if($attrs.fetchdata){getdata();} $scope.$watch('fetchdata',function(newValue,oldValue){if(newValue){getdata();}});$scope.selecteddivision=function(viewLocation){return $cookies.get('selecteddivision');};$scope.hidespoiler=function(match){var hidespoilercookie=$cookies.get('hidespoiler');if(hidespoilercookie){return true;} if(hidespoilercookie){return true;} if(match.winner>0||(match.winner==0&&(match.result_team1+match.result_team2==0))){return true;}} $scope.toggleSpoiler=function(){$cookies.put("hidespoiler",1,{path:'/'});} $scope.updateSelectedDivision=function($show) {var isfirst=true;var now=new Date(),exp=new Date(now.getFullYear()+1,now.getMonth(),now.getDate());if($show==undefined&&!$cookies.get('selecteddivision')){angular.forEach($scope.matches,function(matches,matcheskey){angular.forEach(rankings.groups,function(group,groupkey){if(isfirst){$show=group.groupname;isfirst=false;}});});} if($show){$cookies.put("selecteddivision",$show,{path:'/',expires:exp});}} function getdata(){var x=new Date();var currentTimeZoneOffsetInHours=x.getTimezoneOffset()/60;var restMatches=new Restangular.all('match/nextbroadcast?parentpid='+$scope.parentpid+'&limit=1&pids='+$scope.pids+'&lang='+$scope.lang+'&offset='+currentTimeZoneOffsetInHours+'&'+$scope.getparams);restMatches.getList().then(function(fetchedItems){$scope.matches=fetchedItems;angular.forEach($scope.matches,function(match,matchkey){var groupname=$scope.matches[matchkey].groupname;var numphotos=0;angular.forEach(match.team1withplayers.players,function(player,playerkey){if(player.position=='Player'&&player.photo!=''){numphotos++;}});angular.forEach(match.team2withplayers.players,function(player,playerkey){if(player.position=='Player'&&player.photo!=''){numphotos++;}});if(numphotos>8){$scope.showplayers=true;}});});};$scope.isMatchday=function(match){if(match.matchday==$scope.selectedmatchday){return true;} return false;};function scrollToFirstOpen() {var isFirst=0;$scope.totalmatches=0;angular.forEach($scope.matches,function(day,daykey){if(day.nextday==true&&$scope.selectedmatchday==''&&$location.search().matchday==undefined){$scope.selectedmatchday=day.matchday;$location.search('matchday',day.matchday);} angular.forEach(day.matches,function(value,key){$scope.totalmatches++;if(value.map1_ingamestats!=''){var json=JSON.parse(value.map1_ingamestats);$scope.matches[daykey]['matches'][key]['map1_ingamestats']=json;$scope.matchstats[value.uid]=[];$scope.matchstats[value.uid]['map1']=json;$scope.matches[daykey].matches[key]['map1_stats']=json;} if(value.map2_ingamestats!=''){var json=JSON.parse(value.map2_ingamestats);$scope.matches[daykey]['matches'][key]['map2_ingamestats']=json;$scope.matchstats[value.uid]=[];$scope.matchstats[value.uid]['map2']=json;$scope.matches[daykey].matches[key]['map2_stats']=json;} if(value.map3_ingamestats!=''){var json=JSON.parse(value.map3_ingamestats);$scope.matches[daykey]['matches'][key]['map3_ingamestats']=json;$scope.matchstats[value.uid]=[];$scope.matchstats[value.uid]['map3']=json;$scope.matches[daykey].matches[key]['map3_stats']=json;} if(value.map4_ingamestats!=''){var json=JSON.parse(value.map4_ingamestats);$scope.matches[daykey]['matches'][key]['map4_ingamestats']=json;$scope.matchstats[value.uid]=[];$scope.matchstats[value.uid]['map4']=json;$scope.matches[daykey].matches[key]['map4_stats']=json;} if(value.map5_ingamestats!=''){var json=JSON.parse(value.map5_ingamestats);$scope.matches[daykey]['matches'][key]['map5_ingamestats']=json;$scope.matchstats[value.uid]=[];$scope.matchstats[value.uid]['map5']=json;$scope.matches[daykey].matches[key]['map5_stats']=json;} if(!isFirst&&value.winner==0){isFirst=1;$anchorScroll();}});});}});;app.controller('DemosCtrl',function($scope,Restangular,$attrs,$interval,$location,$anchorScroll){$scope.pids=$attrs.pids;$scope.parentpid=$attrs.parentpid;$scope.status=$attrs.status;$scope.getparams=$attrs.getparams;$scope.roundfilter='';$scope.totaldemos=0;if($attrs.fetchdata){getdata();} $scope.$watch('fetchdata',function(newValue,oldValue){if(newValue){getdata();}});function getdata(){var x=new Date();var currentTimeZoneOffsetInHours=x.getTimezoneOffset()/60;var restMatches=new Restangular.all('match/demos?parentpid='+$scope.parentpid+'&pids='+$scope.pids+'&status='+$scope.status+'&offset='+currentTimeZoneOffsetInHours+'&'+$scope.getparams);restMatches.getList().then(function(fetchedItems){$scope.matches=fetchedItems;$scope.rounds=[];var dummydemo=[];dummydemo.title='notplayed';dummydemo.url='';angular.forEach($scope.matches,function(match,matchkey){if(match['demos']!=undefined){if(match['demos'].length>1){var times=3-match['demos'].length;for(var i=0;i0||(match.winner==0&&(match.result_team1+match.result_team2==0))){return true;}} $scope.toggleSpoiler=function(){$cookies.put("hidespoiler",1,{path:'/'});} $scope.selecteddivision=function(viewLocation){return $cookies.get('selecteddivision');};$scope.hasmatches=function(day){var division=$scope.selecteddivision();if(day.nummatches[division]){return 1;}else{return 0;}};function scrollToFirstOpen() {$scope.totalmatches=0;var num=0;var firstopen=false;var currentday=0;var lastday=0;var firstopenmatchnum=0;var numday=0;angular.forEach($scope.allmatches,function(day,daykey){angular.forEach(day.matches,function(value,key){$scope.totalmatches++;num++;$scope.allmatches[daykey].matches[key]['url']=$scope.urlSchedule;if(value.winner==0&&firstopen==false){$scope.allmatches[daykey].matches[key]['nextmatch']='isnextmatch';firstopen=true;currentday=daykey;} lastday=daykey;});});if(firstopen==false){currentday=lastday;} if(Object.prototype.toString.call($scope.allmatches[currentday-2])==='[object Object]'){$scope.matches.push($scope.allmatches[currentday-2]);} if(Object.prototype.toString.call($scope.allmatches[currentday-1])==='[object Object]'){$scope.matches.push($scope.allmatches[currentday-1]);} if(Object.prototype.toString.call($scope.allmatches[currentday])==='[object Object]'){$scope.matches.push($scope.allmatches[currentday]);} if(Object.prototype.toString.call($scope.allmatches[currentday+1])==='[object Object]'){$scope.matches.push($scope.allmatches[currentday+1]);} if(Object.prototype.toString.call($scope.allmatches[currentday+2])==='[object Object]'){$scope.matches.push($scope.allmatches[currentday+2]);} if(Object.prototype.toString.call($scope.allmatches[currentday+3])==='[object Object]'){$scope.matches.push($scope.allmatches[currentday+3]);} num=0;numday=0;angular.forEach($scope.matches,function(day,daykey){numday++;angular.forEach(day.matches,function(value,key){num++;$scope.displayedmatches++;if($scope.matches[daykey]['nummatches']==undefined){$scope.matches[daykey]['nummatches']=[];} if($scope.matches[daykey]['nummatches'][value.groupname]==undefined){$scope.matches[daykey]['nummatches'][value.groupname]=0;}else{$scope.matches[daykey]['nummatches'][value.groupname]++;} if(value.nextmatch){firstopenmatchnum=num;$scope.numdaystocurrent=numday;$scope.nummatchestocurrent=num;}});});} function reload() {var restMatches=new Restangular.all('match/perday?pids='+$scope.pids+'&parentpid='+$scope.parentpid+'&status='+$scope.status+'&offset='+currentTimeZoneOffsetInHours);restMatches.getList().then(function(fetchedItems){$scope.allmatches=fetchedItems;scrollToFirstOpen();});}});;app.controller('RankingsbarCtrl',function($scope,Restangular,$attrs,$interval,$location,$cookies){$scope.pid=$attrs.pid;$scope.urlRankings=$attrs.urlRankings;$scope.urlTeamsheet=$attrs.urlTeamsheet;$scope.lang=$attrs.lang;$scope.selecteddivision=function(viewLocation){return $cookies.get('selecteddivision');};if($attrs.fetchdata){var restRankings=new Restangular.all('teamranking/list?pid='+$scope.pid+'&lang='+$scope.lang);restRankings.getList().then(function(fetchedItems){$scope.rankings=fetchedItems;$scope.updateSelectedDivision();});} $scope.updateSelectedDivision=function($show) {var isfirst=true;var now=new Date(),exp=new Date(now.getFullYear()+1,now.getMonth(),now.getDate());angular.forEach($scope.rankings,function(rankings,rankingskey){angular.forEach(rankings.groups,function(group,groupkey){angular.forEach(group.teams,function(team,teamkey){$scope.rankings[rankingskey].groups[groupkey].teams[teamkey]['url']=$scope.urlTeamsheet+team.team.url+'/';});});});if($show==undefined&&!$cookies.get('selecteddivision')){angular.forEach($scope.rankings,function(rankings,rankingskey){angular.forEach(rankings.groups,function(group,groupkey){if(isfirst){$show=group.groupname;isfirst=false;}});});} if($show){$cookies.put("selecteddivision",$show,{path:'/',expires:exp});}}});;app.controller('TeamsbarCtrl',function($scope,Restangular,$attrs,$interval,$location,$cookies){$scope.pid=$attrs.pid;$scope.urlTeams=$attrs.urlTeams;$scope.urlTeamsheet=$attrs.urlTeamsheet;$scope.lang=$attrs.lang;$scope.selecteddivision=function(viewLocation){return $cookies.get('selecteddivision');};if($attrs.fetchdata){var restTeams=new Restangular.all('team/list?pids='+$scope.pid+'&lang='+$scope.lang);restTeams.getList().then(function(fetchedItems){$scope.teams=fetchedItems;});}});;app.controller('RegionswitcherCtrl',function($scope,Restangular,$attrs,$interval,$location,$cookies,$element){$scope.pid='';$scope.urlRankings='';$scope.selecteddivision=function(viewLocation){return $cookies.get('selecteddivision');};$scope.updateSelectedDivision=function($show) {var isfirst=true;var now=new Date(),exp=new Date(now.getFullYear()+1,now.getMonth(),now.getDate());if($show==undefined&&!$cookies.get('selecteddivision')){angular.forEach($scope.rankings,function(rankings,rankingskey){angular.forEach(rankings.groups,function(group,groupkey){if(isfirst){$show=group.groupname;isfirst=false;}});});} if($show){$cookies.put("selecteddivision",$show,{path:'/',expires:exp});}} $scope.updateSelectedDivision();});;;app.controller('YoutubeplaylistCtrl',function($scope,Restangular,$attrs,$location,$http){$scope.getparams='';$scope.limit='';$scope.sortPublishedAt=function(video){var date=new Date(video.publishedAt);return date;};$scope.$watch('fetchdata',function(newValue,oldValue){if(newValue){var $maxResults='';if($scope.limit!=''){$maxResults='&maxResults=50';}else{$maxResults='&maxResults=50';} $http.get('https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&key=AIzaSyAGJ2p4DTzK9BrB4eJi1-dg-IAaE5HbNx0&'+$scope.getparams+$maxResults).success(function(data,status,headers,config){$scope.videos=[];angular.forEach(data.items,function(items,itemskey){data.items[itemskey].snippet $scope.videos[itemskey]=data.items[itemskey].snippet;});}).error(function(data,status,headers,config){});}});});;app.controller('EventsCtrl',function($scope,Restangular,$attrs){$scope.pids='';$scope.categories='';$scope.highlight={};var restEvents=new Restangular.all('event/list?series=ESL One,ESL One powered by Intel');restEvents.getList().then(function(fetchedItems){$scope.events=fetchedItems;for(index=0;index<$scope.events.length;++index){if($scope.events[index].status!='past'){$scope.highlight=$scope.events[index];}}});$scope.sethighlight=function(event){$scope.highlight=event;};});;app.controller('EsportstvscheduleCtrl',function($scope,Restangular,$attrs){$scope.pids='';$scope.currentweek='';$scope.currentyear='';$scope.existnextweek=true $scope.existprevweek=true var restWeeks=new Restangular.all('esportstvschedule/allweeks');restWeeks.getList().then(function(fetchedItems){$scope.allweeks=fetchedItems;angular.forEach($scope.allweeks,function(week,weekkey){if(week.current==true){$scope.currentweek=week.week $scope.currentyear=week.year $scope.currentindex=weekkey}}) existNextPrev() getdata()});$scope.setweek=function(nextprev) {newindex=$scope.currentindex+(nextprev/1) if($scope.allweeks[newindex]){$scope.msg='';$scope.currentweek=$scope.allweeks[newindex].week $scope.currentyear=$scope.allweeks[newindex].year $scope.currentindex=newindex}else{$scope.msg='no schedule';} existNextPrev() getdata()} function existNextPrev(){if($scope.allweeks[$scope.currentindex+1]){$scope.existnextweek=''}else{$scope.existnextweek='passive'} if($scope.allweeks[$scope.currentindex-1]){$scope.existprevweek=''}else{$scope.existprevweek='passive'}} function getdata(){var restEvents=new Restangular.all('esportstvschedule/list?week='+$scope.currentweek+'&year='+$scope.currentyear);restEvents.getList().then(function(fetchedItems){$scope.days=fetchedItems;angular.forEach($scope.days,function(days,dayskey){angular.forEach($scope.days[dayskey]['items'],function(item,itemkey){if($scope.currentweek==''){$scope.currentyear=$scope.days[dayskey]['items'][itemkey]['year']/1;$scope.currentweek=$scope.days[dayskey]['items'][itemkey]['week']/1;}});});});}});;app.controller('CalendarCtrl',function($scope,Restangular,$attrs){$scope.highlight={};$scope.hello='hello';var restEvents=new Restangular.all('event/permonth?status=upcoming');restEvents.getList().then(function(fetchedItems){$scope.eventmonths=fetchedItems;});$scope.sethighlight=function(event){$scope.highlight=event;};});;;app.directive('scheduleperday',function(){return{restrict:"EA",templateUrl:'/fileadmin/templates/js/lib/edlpro/partials/schedule_per_day.html',link:function(scope,element,attrs){scope.eventid=attrs.eventid;scope.languages=attrs.languages;scope.removetitle=attrs.removetitle;scope.getparams=attrs.getparams;scope.fetchdata=true;}};});app.directive('animateOnChange',function($timeout){return function(scope,element,attr){scope.$watch(attr.animateOnChange,function(nv,ov){if(nv!=ov){element.addClass('changed');$timeout(function(){element.removeClass('changed');},200);}});};});app.directive('escKey',function(){return function(scope,element,attrs){element.bind('keydown keypress',function(event){if(event.which===27){scope.$apply(function(){scope.$eval(attrs.escKey);});event.preventDefault();}});};});app.directive('teams',function(){return{restrict:"EA",templateUrl:'/fileadmin/templates/js/lib/edlpro/partials/teams.html',link:function(scope,element,attrs){scope.pids=attrs.pids;scope.categories=attrs.categories;scope.fetchdata=true;}};});app.directive('events',function(){return{restrict:"EA",templateUrl:'/fileadmin/templates/js/lib/edlpro/partials/events.html',link:function(scope,element,attrs){scope.status=attrs.status;scope.getparams=attrs.getparams;scope.fetchdata=true;}};});app.directive('rankingsbar',function(){return{restrict:"EA",templateUrl:'/fileadmin/templates/js/lib/edlpro/partials/rankingsbar.html',link:function(scope,element,attrs){scope.pid=attrs.pid;scope.urlRankings=attrs.urlRankings;scope.getparams=attrs.getparams;scope.urlTeamsheet=attrs.urlTeamsheet;scope.fetchdatarankings=true;}};});function pagesUrl(){var url=(window.browserInfo.isIE?CLIENT_URL+"/assets":STATIC_URL);return url;} app.directive('timeline',function($sce){return{restrict:"EA",templateUrl:$sce.trustAsResourceUrl('http://dev.pro.eslgaming.com/fileadmin/templates/js/lib/edlpro/partials/timeline.html'),link:function(scope,element,attrs){scope.status=attrs.status;scope.getparams=attrs.getparams;scope.fetchdataevents=true;}};});app.directive('matchesbar',function(){return{restrict:"EA",templateUrl:'/fileadmin/templates/js/lib/edlpro/partials/matchesbar.html',link:function(scope,element,attrs){scope.pids=attrs.pids;scope.parentpid=attrs.parentpid;scope.status=attrs.status;scope.spoilerprotection=attrs.spoilerprotection;scope.urlSchedule=attrs.urlSchedule;scope.getparams=attrs.getparams;scope.fetchdatamatches=true;}};});app.directive('matches',function(){return{restrict:"EA",templateUrl:'/fileadmin/templates/js/lib/edlpro/partials/matches.html',link:function(scope,element,attrs){scope.pids=attrs.pids;scope.parentpid=attrs.parentpid;scope.delay=attrs.delay;scope.maxdays=attrs.maxdays;scope.status=attrs.status;scope.getparams=attrs.getparams;scope.fetchdata=true;}};});app.directive('videos',function(){return{restrict:"EA",templateUrl:'/fileadmin/templates/js/lib/edlpro/partials/videos.html',link:function(scope,element,attrs){scope.getparams=attrs.getparams;scope.fetchdata=true;}};});app.directive('youtubeplaylist',function(){return{restrict:"EA",templateUrl:'/fileadmin/templates/js/lib/edlpro/partials/youtubeplaylist.html',link:function(scope,element,attrs){scope.getparams=attrs.getparams;scope.limit=attrs.limit;scope.fetchdata=true;}};});app.directive('dragscroll',function(){return{restrict:'AE',link:function(scope,element){var currentoffset=0;var isDragging=false;var mouseStartPos=0;element.mousedown(function(event){isDragging=true;mouseStartPos=event.pageX;});element.mouseup(function(){isDragging=false;});element.mousemove(function(event){if(isDragging){currentoffset=element.offset().left+((event.pageX-mouseStartPos)/10);element.offset({left:currentoffset});}});}};});app.directive('scrolltoopen',function(){return{restrict:'AE',link:function(scope,element,attr){var look=$('.isnextmatch');attr.$observe('nummatchestocurrent',function(value){if(value>0){var xpos=attr.numdaystocurrent*110+(attr.nummatchestocurrent-1)*200;var xposscreen=xpos-620;element.offset({left:-xposscreen});}});}};});app.directive('regionswitch',function(){return{restrict:'AE',link:function(scope,element,attr,rootScope){console.log("wut");var region={};region.name=attr.title;region.bla='test';rootScope.regions.push(region);}};});;app.filter('removepart',function(){return function(str,remove){return(!str)?'':str.replace(remove,"");};});app.filter('lowerchars',function(){return function(str){return(!str)?'':str.toLowerCase().replace(/[^\w]/gi,'');};});app.filter('translate',function(){return function(str,lang){var texts=[];texts['ru']=[];texts['ru']['cliff']='Утёс';texts['ru']['ghosttown']='Затерянный город';texts['ru']['himmelsdorf']='Химмельсдорф';texts['ru']['mines']='Рудники';texts['ru']['murovanka']='Мурованка';texts['ru']['prokhorovka']='Прохоровка';texts['ru']['ruinberg']='Руинберг';texts['ru']['steppes']='Степи';texts['ru']['Attack Win %']='Побед в атаке';texts['ru']['Defense win %']='Побед в защите';texts['ru']['Map Win%']='Процент побед на картах';texts['ru']['Group A']='Группа A';texts['ru']['Group B']='Группа B';texts['ru']['Group C']='Группа C';texts['ru']['Group D']='Группа D';if(texts[lang]!==undefined&&texts[lang][str]!==undefined){return texts[lang][str];}else{return str;}};});app.filter('dayHasMatchesForDivision',function(){return function(items,selecteddivision){var filtered=[];if(items!=undefined){for(var i=0;i<=items.length;i++){var item=items[i];if(item.nummatches[selecteddivision]){filtered.push(item);}}} return filtered;};});app.filter('orderObjectBy',function(){return function(items,$field,reverse){var filtered=[];angular.forEach(items,function(item){if(item[$field]){filtered.push(item);}});filtered.sort(function(a,b){return(a[$field]>b[$field]?1:-1);});if(reverse)filtered.reverse();return filtered;};});app.filter('slice',function(){return function(arr,start,end){return(arr||[]).slice(start,end);};});app.filter('numberFixedLen',function(){return function(n,len){var num=parseInt(n,10);len=parseInt(len,10);if(isNaN(num)||isNaN(len)){return n;} num=''+num;while(num.length - amitgharat.wordpress.com */ !function(e,a,t,n){"use strict";var i=a.module("ngDragDrop",[]).service("ngDragDropService",["$timeout","$parse","$q",function(r,l,o){this.draggableScope=null,this.droppableScope=null,t("head").prepend(''),this.callEventCallback=function(e,a,n,i){function r(a){var n=-1!==a.indexOf("(")?a.indexOf("("):a.length,i=-1!==a.lastIndexOf(")")?a.lastIndexOf(")"):a.length,r=a.substring(n+1,i),o=-1!==a.indexOf(".")?a.substr(0,a.indexOf(".")):null;return o=e[o]&&"function"==typeof e[o].constructor?o:null,{callback:a.substring(o&&o.length+1||0,n),args:t.map(r&&r.split(",")||[],function(a){return[l(a)(e)]}),constructor:o}}if(a){var o=r(a),d=o.callback,s=o.constructor,p=[n,i].concat(o.args);return(e[d]||e[s][d]).apply(e[d]?e:e[s],p)}},this.invokeDrop=function(e,l,d,s){var p,c,u,g="",f="",b={},h={},v=null,y={},x={},m=null,D=this.droppableScope,q=this.draggableScope,j=null,k=[];g=e.ngattr("ng-model"),f=l.ngattr("ng-model"),p=q.$eval(g),c=D.$eval(f),m=l.find("[jqyoui-draggable]:last,[data-jqyoui-draggable]:last"),h=D.$eval(l.attr("jqyoui-droppable")||l.attr("data-jqyoui-droppable"))||[],b=q.$eval(e.attr("jqyoui-draggable")||e.attr("data-jqyoui-draggable"))||[],b.index=this.fixIndex(q,b,p),h.index=this.fixIndex(D,h,c),v=a.isArray(p)?b.index:null,y=a.isArray(p)?p[v]:p,b.deepCopy&&(y=a.copy(y)),x=a.isArray(c)&&h&&h.index!==n?c[h.index]:a.isArray(c)?{}:c,h.deepCopy&&(x=a.copy(x)),b.beforeDrop&&k.push(this.callEventCallback(q,b.beforeDrop,d,s)),o.all(k).then(a.bind(this,function(){if(b.insertInline&&g===f){if(b.index>h.index){u=p[b.index];for(var n=b.index;n>h.index;n--)c[n]=a.copy(c[n-1]),c[n-1]={},c[n][b.direction]="left";c[h.index]=u}else{u=p[b.index];for(var n=b.index;n0?m:l,null,"fast",h,function(){j.remove()}),this.move(m.length>0&&!h.multiple?m:[],e.parent("[jqyoui-droppable],[data-jqyoui-droppable]"),i.startXY,"fast",h,a.bind(this,function(){r(a.bind(this,function(){e.css({position:"relative",left:"",top:""}).removeClass("angular-dragdrop-hide"),m.css({position:"relative",left:"",top:"",display:"none"===m.css("display")?"":m.css("display")}),this.mutateDraggable(q,h,b,g,f,x,e),this.mutateDroppable(D,h,b,f,y,v),this.callEventCallback(D,h.onDrop,d,s)}))}))):r(a.bind(this,function(){this.mutateDraggable(q,h,b,g,f,x,e),this.mutateDroppable(D,h,b,f,y,v),this.callEventCallback(D,h.onDrop,d,s)}))}))["finally"](a.bind(this,function(){this.restore(e)}))},this.move=function(a,t,i,r,l,o){if(0===a.length)return o&&e.setTimeout(function(){o()},300),!1;var d=a.css("z-index"),s=a[l.containment||"offset"](),p=t.css("display"),c=t.hasClass("ng-hide"),u=t.hasClass("angular-dragdrop-hide");null===i&&t.length>0&&((t.attr("jqyoui-draggable")||t.attr("data-jqyoui-draggable"))!==n&&t.ngattr("ng-model")!==n&&t.is(":visible")&&l&&l.multiple?(i=t[l.containment||"offset"](),l.stack===!1?i.left+=t.outerWidth(!0):i.top+=t.outerHeight(!0)):(c&&t.removeClass("ng-hide"),u&&t.removeClass("angular-dragdrop-hide"),i=t.css({visibility:"hidden",display:"block"})[l.containment||"offset"](),t.css({visibility:"",display:p}))),a.css({position:"absolute","z-index":9999}).css(s).animate(i,r,function(){c&&t.addClass("ng-hide"),u&&t.addClass("angular-dragdrop-hide"),a.css("z-index",d),o&&o()})},this.mutateDroppable=function(e,t,n,i,r,o){var d=e.$eval(i);e.dndDragItem=r,a.isArray(d)?(t&&t.index>=0?d[t.index]=r:d.push(r),n&&n.placeholder===!0&&(d[d.length-1].jqyoui_pos=o)):(l(i+" = dndDragItem")(e),n&&n.placeholder===!0&&(d.jqyoui_pos=o))},this.mutateDraggable=function(e,t,i,r,o,d,s){var p=a.equals(d,{})||!d,c=e.$eval(r);e.dndDropItem=d,i&&i.placeholder?"keep"!=i.placeholder&&(a.isArray(c)&&i.index!==n?c[i.index]=d:l(r+" = dndDropItem")(e)):a.isArray(c)?p?i&&i.placeholder!==!0&&"keep"!==i.placeholder&&c.splice(i.index,1):c[i.index]=d:(l(r+" = dndDropItem")(e),e.$parent&&l(r+" = dndDropItem")(e.$parent)),this.restore(s)},this.restore=function(e){e.css({"z-index":"",left:"",top:""})},this.fixIndex=function(e,t,i){if(t.applyFilter&&a.isArray(i)&&i.length>0){var r=e[t.applyFilter](),l=r[t.index],o=n;return i.forEach(function(e,t){a.equals(e,l)&&(o=t)}),o}return t.index}}]).directive("jqyouiDraggable",["ngDragDropService",function(e){return{require:"?jqyouiDroppable",restrict:"A",link:function(n,r,l){var o,d,s,p,c=t(r),u=function(r,u){r?(o=n.$eval(c.attr("jqyoui-draggable")||c.attr("data-jqyoui-draggable"))||{},d=n.$eval(l.jqyouiOptions)||{},c.draggable({disabled:!1}).draggable(d).draggable({start:function(a,r){e.draggableScope=n,s=t(d.helper?r.helper:this).css("z-index"),t(d.helper?r.helper:this).css("z-index",9999),i.startXY=t(this)[o.containment||"offset"](),e.callEventCallback(n,o.onStart,a,r)},stop:function(a,i){t(d.helper?i.helper:this).css("z-index",s),e.callEventCallback(n,o.onStop,a,i)},drag:function(a,t){e.callEventCallback(n,o.onDrag,a,t)}})):c.draggable({disabled:!0}),p&&a.isDefined(r)&&(a.equals(l.drag,"true")||a.equals(l.drag,"false"))&&(p(),p=null)};p=n.$watch(function(){return n.$eval(l.drag)},u),u(),c.on("$destroy",function(){c.draggable({disabled:!0}).draggable("destroy")})}}}]).directive("jqyouiDroppable",["ngDragDropService","$q",function(e,n){return{restrict:"A",priority:1,link:function(i,r,l){var o,d,s,p=t(r),c=function(r,c){r?(o=i.$eval(t(p).attr("jqyoui-droppable")||t(p).attr("data-jqyoui-droppable"))||{},d=i.$eval(l.jqyouiOptions)||{},p.droppable({disabled:!1}).droppable(d).droppable({over:function(a,t){e.callEventCallback(i,o.onOver,a,t)},out:function(a,t){e.callEventCallback(i,o.onOut,a,t)},drop:function(r,s){var p=null;p=o.beforeDrop?e.callEventCallback(i,o.beforeDrop,r,s):function(){var e=n.defer();return e.resolve(),e.promise}(),p.then(a.bind(this,function(){t(s.draggable).ngattr("ng-model")&&l.ngModel?(e.droppableScope=i,e.invokeDrop(t(s.draggable),t(this),r,s)):e.callEventCallback(i,o.onDrop,r,s)}),function(){s.draggable.animate({left:"",top:""},d.revertDuration||0)})}})):p.droppable({disabled:!0}),s&&a.isDefined(r)&&(a.equals(l.drop,"true")||a.equals(l.drop,"false"))&&(s(),s=null)};s=i.$watch(function(){return i.$eval(l.drop)},c),c(),p.on("$destroy",function(){p.droppable({disabled:!0}).droppable("destroy")})}}}]);t.fn.ngattr=function(e,a){var t=this[0];return t.getAttribute(e)||t.getAttribute("data-"+e)}}(window,window.angular,window.jQuery); ;/*! * jQuery UI Touch Punch 0.2.3 * * Copyright 2011–2014, Dave Furfero * Dual licensed under the MIT or GPL Version 2 licenses. * * Depends: * jquery.ui.widget.js * jquery.ui.mouse.js */ !function(a){function f(a,b){if(!(a.originalEvent.touches.length>1)){a.preventDefault();var c=a.originalEvent.changedTouches[0],d=document.createEvent("MouseEvents");d.initMouseEvent(b,!0,!0,window,1,c.screenX,c.screenY,c.clientX,c.clientY,!1,!1,!1,!1,0,null),a.target.dispatchEvent(d)}}if(a.support.touch="ontouchend"in document,a.support.touch){var e,b=a.ui.mouse.prototype,c=b._mouseInit,d=b._mouseDestroy;b._touchStart=function(a){var b=this;!e&&b._mouseCapture(a.originalEvent.changedTouches[0])&&(e=!0,b._touchMoved=!1,f(a,"mouseover"),f(a,"mousemove"),f(a,"mousedown"))},b._touchMove=function(a){e&&(this._touchMoved=!0,f(a,"mousemove"))},b._touchEnd=function(a){e&&(f(a,"mouseup"),f(a,"mouseout"),this._touchMoved||f(a,"click"),e=!1)},b._mouseInit=function(){var b=this;b.element.bind({touchstart:a.proxy(b,"_touchStart"),touchmove:a.proxy(b,"_touchMove"),touchend:a.proxy(b,"_touchEnd")}),c.call(b)},b._mouseDestroy=function(){var b=this;b.element.unbind({touchstart:a.proxy(b,"_touchStart"),touchmove:a.proxy(b,"_touchMove"),touchend:a.proxy(b,"_touchEnd")}),d.call(b)}}}(jQuery); ;(function(){var moduleName='angularUtils.directives.dirPagination';var DEFAULT_ID='__default';angular.module(moduleName,[]).directive('dirPaginate',['$compile','$parse','paginationService',dirPaginateDirective]).directive('dirPaginateNoCompile',noCompileDirective).directive('dirPaginationControls',['paginationService','paginationTemplate',dirPaginationControlsDirective]).filter('itemsPerPage',['paginationService',itemsPerPageFilter]).service('paginationService',paginationService).provider('paginationTemplate',paginationTemplateProvider).run(['$templateCache',dirPaginationControlsTemplateInstaller]);function dirPaginateDirective($compile,$parse,paginationService){return{terminal:true,multiElement:true,priority:100,compile:dirPaginationCompileFn};function dirPaginationCompileFn(tElement,tAttrs){var expression=tAttrs.dirPaginate;var match=expression.match(/^\s*([\s\S]+?)\s+in\s+([\s\S]+?)(?:\s+as\s+([\s\S]+?))?(?:\s+track\s+by\s+([\s\S]+?))?\s*$/);var filterPattern=/\|\s*itemsPerPage\s*:\s*(.*\(\s*\w*\)|([^\)]*?(?=\s+as\s+))|[^\)]*)/;if(match[2].match(filterPattern)===null){throw'pagination directive: the \'itemsPerPage\' filter must be set.';} var itemsPerPageFilterRemoved=match[2].replace(filterPattern,'');var collectionGetter=$parse(itemsPerPageFilterRemoved);addNoCompileAttributes(tElement);var rawId=tAttrs.paginationId||DEFAULT_ID;paginationService.registerInstance(rawId);return function dirPaginationLinkFn(scope,element,attrs){var paginationId=$parse(attrs.paginationId)(scope)||attrs.paginationId||DEFAULT_ID;paginationService.registerInstance(paginationId);var repeatExpression=getRepeatExpression(expression,paginationId);addNgRepeatToElement(element,attrs,repeatExpression);removeTemporaryAttributes(element);var compiled=$compile(element);var currentPageGetter=makeCurrentPageGetterFn(scope,attrs,paginationId);paginationService.setCurrentPageParser(paginationId,currentPageGetter,scope);if(typeof attrs.totalItems!=='undefined'){paginationService.setAsyncModeTrue(paginationId);scope.$watch(function(){return $parse(attrs.totalItems)(scope);},function(result){if(0<=result){paginationService.setCollectionLength(paginationId,result);}});}else{paginationService.setAsyncModeFalse(paginationId);scope.$watchCollection(function(){return collectionGetter(scope);},function(collection){if(collection){var collectionLength=(collection instanceof Array)?collection.length:Object.keys(collection).length;paginationService.setCollectionLength(paginationId,collectionLength);}});} compiled(scope);};} function getRepeatExpression(expression,paginationId){var repeatExpression,idDefinedInFilter=!!expression.match(/(\|\s*itemsPerPage\s*:[^|]*:[^|]*)/);if(paginationId!==DEFAULT_ID&&!idDefinedInFilter){repeatExpression=expression.replace(/(\|\s*itemsPerPage\s*:\s*[^|\s]*)/,"$1 : '"+paginationId+"'");}else{repeatExpression=expression;} return repeatExpression;} function addNgRepeatToElement(element,attrs,repeatExpression){if(element[0].hasAttribute('dir-paginate-start')||element[0].hasAttribute('data-dir-paginate-start')){attrs.$set('ngRepeatStart',repeatExpression);element.eq(element.length-1).attr('ng-repeat-end',true);}else{attrs.$set('ngRepeat',repeatExpression);}} function addNoCompileAttributes(tElement){angular.forEach(tElement,function(el){if(el.nodeType===1){angular.element(el).attr('dir-paginate-no-compile',true);}});} function removeTemporaryAttributes(element){angular.forEach(element,function(el){if(el.nodeType===1){angular.element(el).removeAttr('dir-paginate-no-compile');}});element.eq(0).removeAttr('dir-paginate-start').removeAttr('dir-paginate').removeAttr('data-dir-paginate-start').removeAttr('data-dir-paginate');element.eq(element.length-1).removeAttr('dir-paginate-end').removeAttr('data-dir-paginate-end');} function makeCurrentPageGetterFn(scope,attrs,paginationId){var currentPageGetter;if(attrs.currentPage){currentPageGetter=$parse(attrs.currentPage);}else{var defaultCurrentPage=(paginationId+'__currentPage').replace(/\W/g,'_');scope[defaultCurrentPage]=1;currentPageGetter=$parse(defaultCurrentPage);} return currentPageGetter;}} function noCompileDirective(){return{priority:5000,terminal:true};} function dirPaginationControlsTemplateInstaller($templateCache){$templateCache.put('angularUtils.directives.dirPagination.template','');} function dirPaginationControlsDirective(paginationService,paginationTemplate){var numberRegex=/^\d+$/;var DDO={restrict:'AE',scope:{maxSize:'=?',onPageChange:'&?',paginationId:'=?',autoHide:'=?'},link:dirPaginationControlsLinkFn};var templateString=paginationTemplate.getString();if(templateString!==undefined){DDO.template=templateString;}else{DDO.templateUrl=function(elem,attrs){return attrs.templateUrl||paginationTemplate.getPath();};} return DDO;function dirPaginationControlsLinkFn(scope,element,attrs){var rawId=attrs.paginationId||DEFAULT_ID;var paginationId=scope.paginationId||attrs.paginationId||DEFAULT_ID;if(!paginationService.isRegistered(paginationId)&&!paginationService.isRegistered(rawId)){var idMessage=(paginationId!==DEFAULT_ID)?' (id: '+paginationId+') ':' ';if(window.console){console.warn('Pagination directive: the pagination controls'+idMessage+'cannot be used without the corresponding pagination directive, which was not found at link time.');}} if(!scope.maxSize){scope.maxSize=9;} scope.autoHide=scope.autoHide===undefined?true:scope.autoHide;scope.directionLinks=angular.isDefined(attrs.directionLinks)?scope.$parent.$eval(attrs.directionLinks):true;scope.boundaryLinks=angular.isDefined(attrs.boundaryLinks)?scope.$parent.$eval(attrs.boundaryLinks):false;var paginationRange=Math.max(scope.maxSize,5);scope.pages=[];scope.pagination={last:1,current:1};scope.range={lower:1,upper:1,total:1};scope.$watch('maxSize',function(val){if(val){paginationRange=Math.max(scope.maxSize,5);generatePagination();}});scope.$watch(function(){if(paginationService.isRegistered(paginationId)){return(paginationService.getCollectionLength(paginationId)+1)*paginationService.getItemsPerPage(paginationId);}},function(length){if(0