Created
August 25, 2014 00:09
-
-
Save recidive/23277cdc2e15488e9e71 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/applications/default/public/js/app.js b/applications/default/public/js/app.js | |
index 2e7ae9e..2c7f0c0 100644 | |
--- a/applications/default/public/js/app.js | |
+++ b/applications/default/public/js/app.js | |
@@ -1,7 +1,7 @@ | |
'use strict'; | |
// Declare app level module which depends on services, directives and filters. | |
-angular.module('choko', ['ngRoute', 'ngResource', 'ngSanitize', 'summernote', 'angularFileUpload', 'choko.services', 'choko.directives', 'choko.filters']) | |
+angular.module('choko', ['ngRoute', 'ngResource', 'ngSanitize', 'summernote', 'angularFileUpload', 'choko.services', 'choko.directives', 'choko.filters', 'choko.controllers']) | |
.config(['$locationProvider', function($locationProvider) { | |
//$locationProvider.html5Mode(true); | |
}]); | |
diff --git a/applications/default/public/js/controllers.js b/applications/default/public/js/controllers.js | |
index 8ac995e..7651bf0 100644 | |
--- a/applications/default/public/js/controllers.js | |
+++ b/applications/default/public/js/controllers.js | |
@@ -1,6 +1,9 @@ | |
'use strict'; | |
-function ApplicationController($scope, $location, $http, applicationState, Choko) { | |
+angular.module('choko.controllers', []) | |
+ | |
+ .controller('ApplicationController', ['$scope', '$location', '$http', 'applicationState', | |
+ function ($scope, $location, $http, applicationState) { | |
$scope.state = {}; | |
$scope.changeState = function() { | |
@@ -46,14 +49,18 @@ function ApplicationController($scope, $location, $http, applicationState, Choko | |
}, function(){ | |
$scope.changeState(); | |
}); | |
-} | |
-//ApplicationController.$inject = ['$scope', '$location', '$http', 'applicationState', 'Choko']; | |
+ }]) | |
-function PanelController($scope, $location, $http, applicationState, Choko) { | |
+ .controller('PanelController', ['$scope', '$controller', | |
+ function ($scope, $controller) { | |
if ($scope.panel.type && $scope.panel.type !== 'default') { | |
// Set view to the panel itself and call ViewController. | |
$scope.view = $scope.panel; | |
- ViewController($scope, $location, $http, applicationState, Choko); | |
+ | |
+ // Inherit controller. | |
+ $controller('ViewController', { | |
+ $scope: $scope | |
+ }); | |
} | |
if ($scope.panel.bare) { | |
@@ -62,10 +69,10 @@ function PanelController($scope, $location, $http, applicationState, Choko) { | |
else { | |
$scope.template = 'templates/panel.html'; | |
} | |
-} | |
-//PanelController.$inject = ['$scope', '$location', '$http', 'applicationState', 'Choko']; | |
+ }]) | |
-function PageController($scope, $location, $http, applicationState, Choko) { | |
+ .controller('PageController', ['$scope', '$controller', | |
+ function ($scope, $controller) { | |
if (!$scope.page.type || $scope.page.type === 'default') { | |
$scope.items = $scope.page.items || {}; | |
$scope.title = $scope.page.title; | |
@@ -73,34 +80,43 @@ function PageController($scope, $location, $http, applicationState, Choko) { | |
else { | |
// Set view to the panel itself and call ViewController. | |
$scope.view = $scope.page; | |
- ViewController($scope, $location, $http, applicationState, Choko); | |
- } | |
+ | |
+ // Inherit controller. | |
+ $controller('ViewController', { | |
+ $scope: $scope | |
+ }); | |
} | |
-//PageController.$inject = ['$scope', '$location', '$http', 'applicationState', 'Choko']; | |
+ }]) | |
-function RowController($scope, $location, applicationState, Choko) { | |
+ .controller('RowController', ['$scope', | |
+ function ($scope) { | |
$scope.name = $scope.row.name; | |
$scope.getTemplate = function() { | |
return $scope.template || 'templates/row.html'; | |
} | |
-} | |
-//RowController.$inject = ['$scope', '$location', 'applicationState', 'Choko']; | |
+ }]) | |
-function ColumnController($scope, $location, applicationState, Choko) { | |
+ .controller('ColumnController', ['$scope', | |
+ function ($scope) { | |
$scope.name = $scope.column.name; | |
$scope.getTemplate = function() { | |
return $scope.template || 'templates/column.html'; | |
}; | |
-} | |
-//ColumnController.$inject = ['$scope', '$location', 'applicationState', 'Choko']; | |
+ }]) | |
-function RegionController($scope, $location, applicationState, Choko) { | |
-} | |
-//RegionController.$inject = ['$scope', '$location', 'applicationState', 'Choko']; | |
+ .controller('RegionController', ['$scope', | |
+ function ($scope) { | |
+ | |
+ }]) | |
+ | |
+ .controller('NavigationController', ['$scope', '$location', | |
+ function ($scope, $location) { | |
+ | |
+ // Avoid undefined. | |
+ $scope.panel.classes = $scope.panel.classes || []; | |
-function NavigationController($scope, $location, $window, applicationState, Choko) { | |
$scope.panel.classes.unshift('nav'); | |
$scope.isAbsolute = function(url) { | |
@@ -118,23 +134,25 @@ function NavigationController($scope, $location, $window, applicationState, Chok | |
//var regexp = new RegExp('^' + pattern + '.*$', ["i"]); | |
return route === $location.path(); | |
}; | |
-} | |
-//NavigationController.$inject = ['$scope', '$location', 'applicationState', 'Choko']; | |
+ }]) | |
-function ItemController($scope, $location, applicationState, Choko) { | |
-} | |
-//ItemController.$inject = ['$scope', '$location', 'applicationState', 'Choko']; | |
+ .controller('ItemController', ['$scope', | |
+ function ($scope) { | |
-function DisplayRegionController($scope, $location, applicationState, Choko) { | |
-} | |
-//DisplayRegionController.$inject = ['$scope', '$location', 'applicationState', 'Choko']; | |
+ }]) | |
+ | |
+ .controller('DisplayRegionController', ['$scope', | |
+ function ($scope) { | |
+ | |
+ }]) | |
-function DisplayFieldController($scope, $location, applicationState, Choko) { | |
+ .controller('DisplayFieldController', ['$scope', | |
+ function ($scope) { | |
$scope.field.template = $scope.field.template || '/templates/' + $scope.field.format + '.html'; | |
-} | |
-//DisplayFieldController.$inject = ['$scope', '$location', 'applicationState', 'Choko']; | |
+ }]) | |
-function ReferenceElementController($scope, $location, applicationState, Choko) { | |
+ .controller('ReferenceElementController', ['$scope', | |
+ function ($scope) { | |
var query = { | |
type: $scope.element.reference.type | |
}; | |
@@ -166,10 +184,10 @@ function ReferenceElementController($scope, $location, applicationState, Choko) | |
$scope.data[$scope.element.name].push(option); | |
} | |
}; | |
-} | |
-//ReferenceElementController.$inject = ['$scope', '$location', 'applicationState', 'Choko']; | |
+ }]) | |
-function InlineReferenceElementController($scope, $location, applicationState, Choko) { | |
+ .controller('InlineReferenceElementController', ['$scope', 'Choko', | |
+ function ($scope, Choko) { | |
var multiple = $scope.element.reference.multiple; | |
// Subform errors are handled separately. | |
@@ -276,11 +294,10 @@ function InlineReferenceElementController($scope, $location, applicationState, C | |
else { | |
$scope.setSubForm($scope.element.reference.type); | |
} | |
+ }]) | |
-} | |
-//InlineReferenceElementController.$inject = ['$scope', '$location', 'applicationState', 'Choko']; | |
- | |
-function InlineReferenceElementItemController($scope, $filter, applicationState, Choko) { | |
+ .controller('InlineReferenceElementItemController', ['$scope', | |
+ function ($scope) { | |
$scope.editItem = function() { | |
$scope.setSubForm($scope.typeName(), !!$scope.element.reference.subtypes, $scope.item, $scope.key); | |
@@ -301,11 +318,11 @@ function InlineReferenceElementItemController($scope, $filter, applicationState, | |
return typeName; | |
}; | |
+ }]) | |
-} | |
-//InlineReferenceElementItemController.$inject = ['$scope', '$location', 'applicationState', 'Choko']; | |
+ .controller('ViewController', ['$scope', '$location', '$http', 'Choko', | |
+ function ($scope, $location, $http, Choko) { | |
-function ViewController($scope, $location, $http, applicationState, Choko) { | |
// Handle 'list' type views. | |
if ($scope.view.type === 'list' && $scope.view.itemType) { | |
var query = { | |
@@ -402,15 +419,15 @@ function ViewController($scope, $location, $http, applicationState, Choko) { | |
$scope.view.template = $scope.view.template || 'templates/form.html'; | |
}); | |
} | |
-} | |
-//ViewController.$inject = ['$scope', '$location', '$http', 'applicationState', 'Choko']; | |
+ }]) | |
-function ElementController($scope, $location, applicationState, Choko) { | |
+ .controller('ElementController', ['$scope', | |
+ function ($scope) { | |
$scope.element.template = $scope.element.template || 'templates/' + $scope.element.type + '.html'; | |
-} | |
-//ElementController.$inject = ['$scope', '$location', 'applicationState', 'Choko']; | |
+ }]) | |
-function FileElementController($scope, $location, $upload, applicationState, Choko) { | |
+ .controller('FileElementController', ['$scope', '$upload', | |
+ function ($scope, $upload) { | |
$scope.element.template = $scope.element.template || 'templates/' + $scope.element.type + '.html'; | |
$scope.progress = 0; | |
@@ -433,22 +450,22 @@ function FileElementController($scope, $location, $upload, applicationState, Cho | |
}); | |
} | |
}; | |
-} | |
-//FileElementController.$inject = ['$scope', '$location', '$upload', 'applicationState', 'Choko']; | |
+ }]) | |
-function SubElementController($scope, $location, applicationState, Choko) { | |
+ .controller('SubElementController', ['$scope', | |
+ function ($scope) { | |
$scope.subElement.template = $scope.subElement.template || 'templates/' + $scope.subElement.type + '.html'; | |
-} | |
-//SubElementController.$inject = ['$scope', '$location', 'applicationState', 'Choko']; | |
+ }]) | |
-function ButtonController($scope, $location, applicationState, Choko) { | |
+ .controller('ButtonController', ['$scope', | |
+ function ($scope) { | |
$scope.call = function(func, args) { | |
$scope[func].apply(this, args); | |
}; | |
-} | |
-//ButtonController.$inject = ['$scope', '$location', 'applicationState', 'Choko']; | |
+ }]) | |
-function WYSIWYGController($scope, $location, applicationState, Choko) { | |
+ .controller('WYSIWYGController', ['$scope', | |
+ function ($scope) { | |
$scope.options = { | |
height: $scope.element.height || 300, | |
toolbar: [ | |
@@ -459,5 +476,4 @@ function WYSIWYGController($scope, $location, applicationState, Choko) { | |
['table', ['table']] | |
] | |
}; | |
-} | |
-//WYSIWYGController.$inject = ['$scope', '$location', 'applicationState', 'Choko']; | |
+ }]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment