|
1 | 1 | (function(angular, backToTop) {
|
2 | 2 | 'use strict';
|
3 |
| - angular.module('datatablesSampleApp', ['ngResource', 'datatables', 'ui.bootstrap', 'ui.router', 'hljs']). |
4 |
| - controller('apiCtrl', function($scope, DTOptionsBuilder) { |
5 |
| - $scope.dtOptions = DTOptionsBuilder.newOptions() |
6 |
| - .withDisplayLength(10) |
7 |
| - .withColReorder() |
8 |
| - .withColVis() |
9 |
| - .withOption('bAutoWidth', false) |
10 |
| - .withTableTools('vendor/datatables-tabletools/swf/copy_csv_xls_pdf.swf'); |
11 |
| - }). |
12 |
| - config(function (hljsServiceProvider) { |
| 3 | + angular.module('datatablesSampleApp', ['ngResource', 'datatables', 'ui.bootstrap', 'ui.router', 'hljs']) |
| 4 | + .config(function (hljsServiceProvider) { |
13 | 5 | hljsServiceProvider.setOptions({
|
14 | 6 | // replace tab with 4 spaces
|
15 | 7 | tabReplace: ' '
|
16 | 8 | });
|
17 |
| - }). |
18 |
| - config(function($stateProvider, $urlRouterProvider) { |
| 9 | + }) |
| 10 | + .config(function($stateProvider, $urlRouterProvider) { |
19 | 11 | $urlRouterProvider.otherwise('/gettingStarted');
|
20 | 12 | $stateProvider
|
21 | 13 | .state('gettingStarted', {
|
22 | 14 | url: '/gettingStarted',
|
23 |
| - templateUrl: 'demo/partials/getting_started.html' |
| 15 | + templateUrl: 'demo/partials/getting_started.html', |
| 16 | + controller: function($rootScope) { |
| 17 | + $rootScope.$broadcast('event:changeView', 'gettingStarted'); |
| 18 | + } |
24 | 19 | })
|
25 | 20 | .state('zeroConfig', {
|
26 | 21 | url: '/zeroConfig',
|
27 |
| - templateUrl: 'demo/partials/zero_config.html' |
| 22 | + templateUrl: 'demo/partials/zero_config.html', |
| 23 | + controller: function($rootScope) { |
| 24 | + $rootScope.$broadcast('event:changeView', 'zeroConfig'); |
| 25 | + } |
28 | 26 | })
|
29 | 27 | .state('withOptions', {
|
30 | 28 | url: '/withOptions',
|
31 |
| - templateUrl: 'demo/partials/with_options.html' |
| 29 | + templateUrl: 'demo/partials/with_options.html', |
| 30 | + controller: function($rootScope) { |
| 31 | + $rootScope.$broadcast('event:changeView', 'withOptions'); |
| 32 | + } |
32 | 33 | })
|
33 | 34 | .state('withPromise', {
|
34 | 35 | url: '/withPromise',
|
35 |
| - templateUrl: 'demo/partials/with_promise.html' |
| 36 | + templateUrl: 'demo/partials/with_promise.html', |
| 37 | + controller: function($rootScope) { |
| 38 | + $rootScope.$broadcast('event:changeView', 'withPromise'); |
| 39 | + } |
36 | 40 | })
|
37 | 41 | .state('dataReloadWithPromise', {
|
38 | 42 | url: '/dataReloadWithPromise',
|
39 |
| - templateUrl: 'demo/partials/data_reload_with_promise.html' |
| 43 | + templateUrl: 'demo/partials/data_reload_with_promise.html', |
| 44 | + controller: function($rootScope) { |
| 45 | + $rootScope.$broadcast('event:changeView', 'dataReloadWithPromise'); |
| 46 | + } |
40 | 47 | })
|
41 | 48 | .state('withAjax', {
|
42 | 49 | url: '/withAjax',
|
43 |
| - templateUrl: 'demo/partials/with_ajax.html' |
| 50 | + templateUrl: 'demo/partials/with_ajax.html', |
| 51 | + controller: function($rootScope) { |
| 52 | + $rootScope.$broadcast('event:changeView', 'withAjax'); |
| 53 | + } |
44 | 54 | })
|
45 | 55 | .state('dataReloadWithAjax', {
|
46 | 56 | url: '/dataReloadWithAjax',
|
47 |
| - templateUrl: 'demo/partials/data_reload_with_ajax.html' |
| 57 | + templateUrl: 'demo/partials/data_reload_with_ajax.html', |
| 58 | + controller: function($rootScope) { |
| 59 | + $rootScope.$broadcast('event:changeView', 'dataReloadWithAjax'); |
| 60 | + } |
48 | 61 | })
|
49 | 62 | .state('angularWay', {
|
50 | 63 | url: '/angularWay',
|
51 |
| - templateUrl: 'demo/partials/angular_way.html' |
| 64 | + templateUrl: 'demo/partials/angular_way.html', |
| 65 | + controller: function($rootScope) { |
| 66 | + $rootScope.$broadcast('event:changeView', 'angularWay'); |
| 67 | + } |
52 | 68 | })
|
53 | 69 | .state('angularWayWithOptions', {
|
54 | 70 | url: '/angularWayWithOptions',
|
55 |
| - templateUrl: 'demo/partials/angular_way_with_options.html' |
| 71 | + templateUrl: 'demo/partials/angular_way_with_options.html', |
| 72 | + controller: function($rootScope) { |
| 73 | + $rootScope.$broadcast('event:changeView', 'angularWayWithOptions'); |
| 74 | + } |
56 | 75 | })
|
57 | 76 | .state('withColReorder', {
|
58 | 77 | url: '/withColReorder',
|
59 |
| - templateUrl: 'demo/partials/with_col_reorder.html' |
| 78 | + templateUrl: 'demo/partials/with_col_reorder.html', |
| 79 | + controller: function($rootScope) { |
| 80 | + $rootScope.$broadcast('event:changeView', 'withColReorder'); |
| 81 | + } |
60 | 82 | })
|
61 | 83 | .state('withColVis', {
|
62 | 84 | url: '/withColVis',
|
63 |
| - templateUrl: 'demo/partials/with_col_vis.html' |
| 85 | + templateUrl: 'demo/partials/with_col_vis.html', |
| 86 | + controller: function($rootScope) { |
| 87 | + $rootScope.$broadcast('event:changeView', 'withColVis'); |
| 88 | + } |
64 | 89 | })
|
65 | 90 | .state('withTableTools', {
|
66 | 91 | url: '/withTableTools',
|
67 |
| - templateUrl: 'demo/partials/with_table_tools.html' |
| 92 | + templateUrl: 'demo/partials/with_table_tools.html', |
| 93 | + controller: function($rootScope) { |
| 94 | + $rootScope.$broadcast('event:changeView', 'withTableTools'); |
| 95 | + } |
68 | 96 | })
|
69 | 97 | .state('bootstrapIntegration', {
|
70 | 98 | url: '/bootstrapIntegration',
|
71 |
| - templateUrl: 'demo/partials/bootstrap_integration.html' |
| 99 | + templateUrl: 'demo/partials/bootstrap_integration.html', |
| 100 | + controller: function($rootScope) { |
| 101 | + $rootScope.$broadcast('event:changeView', 'bootstrapIntegration'); |
| 102 | + } |
72 | 103 | })
|
73 | 104 | .state('allInOne', {
|
74 | 105 | url: '/allInOne',
|
75 |
| - templateUrl: 'demo/partials/all_in_one.html' |
| 106 | + templateUrl: 'demo/partials/all_in_one.html', |
| 107 | + controller: function($rootScope) { |
| 108 | + $rootScope.$broadcast('event:changeView', 'allInOne'); |
| 109 | + } |
76 | 110 | })
|
77 | 111 | .state('api', {
|
78 | 112 | url: '/api',
|
79 |
| - templateUrl: 'demo/partials/api.html' |
| 113 | + templateUrl: 'demo/partials/api.html', |
| 114 | + controller: function($rootScope) { |
| 115 | + $rootScope.$broadcast('event:changeView', 'api'); |
| 116 | + } |
80 | 117 | });
|
| 118 | + }) |
| 119 | + .controller('sidebarCtrl', function($scope) { |
| 120 | + $scope.currentView = 'gettingStarted'; |
| 121 | + $scope.$on('event:changeView', function (event, view) { |
| 122 | + $scope.currentView = view; |
| 123 | + $scope.isCollapsed = $scope.isUsageActive(); |
| 124 | + }); |
| 125 | + $scope.isActive = function (view) { |
| 126 | + return $scope.currentView === view; |
| 127 | + }; |
| 128 | + $scope.isUsageActive = function () { |
| 129 | + return 'gettingStarted' !== $scope.currentView && 'api' !== $scope.currentView; |
| 130 | + }; |
| 131 | + $scope.isCollapsed = !('gettingStarted' === $scope.currentView || 'api' === $scope.currentView); |
| 132 | + }) |
| 133 | + .controller('apiCtrl', function($scope, DTOptionsBuilder) { |
| 134 | + $scope.dtOptions = DTOptionsBuilder.newOptions() |
| 135 | + .withDisplayLength(10) |
| 136 | + .withColReorder() |
| 137 | + .withColVis() |
| 138 | + .withOption('bAutoWidth', false) |
| 139 | + .withTableTools('vendor/datatables-tabletools/swf/copy_csv_xls_pdf.swf'); |
81 | 140 | });
|
82 | 141 |
|
83 | 142 | backToTop.init({
|
|
0 commit comments