Project

General

Profile

1
var module = angular.module('lightUI', ['ngRoute', 'lightUiControllers']);
2

    
3
module.config([
4
	'$routeProvider',
5
	function ($routeProvider) {
6
		$routeProvider
7
			.when('/form', {templateUrl: '../resources/html/lightui/lightUiForm.html', controller: 'lightUiFormCtrl'})
8
			.when('/results/:page/:query', {templateUrl: '../resources/html/lightui/lightUiResults.html', controller: 'lightUiResultsCtrl'})
9
			.when('/doc/:field/:id', {templateUrl: '../resources/html/lightui/lightUiDoc.html', controller: 'lightUiDocCtrl'})
10
			.otherwise({redirectTo: '/form'});
11
	}
12
]);
13

    
14
module.directive('compileTemplate', function ($compile, $parse) {
15
	return {
16
		link: function (scope, element, attr) {
17
			var parsed = $parse(attr.ngBindHtml);
18

    
19
			function getStringValue() {
20
				return (parsed(scope) || '').toString();
21
			}
22

    
23
			//Recompile if the template changes
24
			scope.$watch(getStringValue, function () {
25
				$compile(element, null, -9999)(scope);  //The -9999 makes it skip directives so that we do not recompile ourselves
26
			});
27
		}
28
	}
29
});
30

    
31
module.service('sharedProperties', function () {
32
	var browseHtml = "";
33
	var totalPages = 0;
34
	var total = 0;
35
	var query = "";
36

    
37
	return {
38
		getBrowseHtml: function () {
39
			return browseHtml;
40
		},
41
		setBrowseHtml: function (html) {
42
			browseHtml = html;
43
		},
44
		getQuery: function () {
45
			return query;
46
		},
47
		setQuery: function (q) {
48
			query = q;
49
		},
50
		getTotalPages: function () {
51
			return totalPages;
52
		},
53
		setTotalPages: function (n) {
54
			totalPages = n;
55
		},
56
		getTotal: function () {
57
			return total;
58
		},
59
		setTotal: function (n) {
60
			total = n;
61
		}
62
	};
63
});
(1-1/2)