(function(angular) { 'use strict'; var app = angular.module('puzzleApp', ['slidingPuzzle', 'wordSearchPuzzle']); // puzzle types var types = [ { id: 'sliding-puzzle', title: 'Sliding puzzle' }, { id: 'word-search-puzzle', title: 'Word search puzzle' } ]; /** * Config */ app.config(function($routeProvider) { $routeProvider.when('/:type'); }); /** * Startup */ app.run(function($rootScope, $route, $filter) { $rootScope.types = types; $rootScope.type = types[0].id; // set type on route change $rootScope.$on('$routeChangeSuccess', function(event, route) { $rootScope.type = ($filter('filter')(types, { id: route.params.type }).length ? route.params.type : types[0].id); }); }); /** * Advanced sliding puzzle controller */ app.controller('slidingAdvancedCtrl', function($scope) { $scope.puzzles = [ { src: './img/misko.jpg', title: 'Misko Hevery', rows: 4, cols: 4 }, { src: './img/igor.jpg', title: 'Igor Minar', rows: 3, cols: 3 }, { src: './img/vojta.jpg', title: 'Vojta Jina', rows: 4, cols: 3 } ]; }); /** * Word search puzzle controller */ app.controller('wordSearchCtrl', function($scope) { $scope.matrix = [ ['N', 'I', 'G', 'O', 'R', 'Y', 'G', 'S', 'T', 'T', 'A', 'N'], ['O', 'G', 'G', 'U', 'L', 'C', 'O', 'E', 'P', 'E', 'A', 'S'], ['I', 'N', 'N', 'R', 'M', 'N', 'O', 'R', 'I', 'M', 'E', 'C'], ['T', 'I', 'A', 'I', 'O', 'E', 'G', 'V', 'R', 'P', 'V', 'E'], ['C', 'T', 'T', 'E', 'D', 'D', 'L', 'I', 'C', 'L', 'I', 'N'], ['E', 'S', 'J', 'P', 'U', 'N', 'E', 'C', 'S', 'A', 'T', 'A'], ['J', 'E', 'O', 'O', 'L', 'E', 'I', 'E', 'A', 'T', 'C', 'R'], ['N', 'T', 'V', 'C', 'E', 'P', 'J', 'B', 'V', 'E', 'E', 'I'], ['I', 'S', 'I', 'S', 'S', 'E', 'S', 'A', 'A', 'W', 'R', 'O'], ['O', 'K', 'S', 'I', 'M', 'D', 'E', 'S', 'J', 'O', 'I', 'M'], ['R', 'E', 'L', 'L', 'O', 'R', 'T', 'N', 'O', 'C', 'D', 'E'] ]; $scope.words = [ 'BINDING', 'CONTROLLER', 'DEPENDENCY', 'DIRECTIVE', 'GOOGLE', 'IGOR', 'INJECTION', 'JAVASCRIPT', 'MISKO', 'MODULES', 'SCENARIO', 'SCOPE', 'SERVICE', 'TEMPLATE', 'TESTING', 'VOJTA' ]; }); })(window.angular);