diff --git a/docs-web/src/main/webapp/src/app/docs/app.js b/docs-web/src/main/webapp/src/app/docs/app.js index 4d08b550..707bef6a 100644 --- a/docs-web/src/main/webapp/src/app/docs/app.js +++ b/docs-web/src/main/webapp/src/app/docs/app.js @@ -422,6 +422,26 @@ angular.module('docs', Restangular.one('theme').get().then(function(data) { $rootScope.appName = data.name; }); + + // Languages + $rootScope.acceptedLanguages = [ + { key: 'eng', label: 'English' }, + { key: 'fra', label: 'Français' }, + { key: 'ita', label: 'Italiano' }, + { key: 'deu', label: 'Deutsch' }, + { key: 'spa', label: 'Español' }, + { key: 'por', label: 'Português' }, + { key: 'pol', label: 'Polski' }, + { key: 'rus', label: 'русский' }, + { key: 'ukr', label: 'українська' }, + { key: 'ara', label: 'العربية' }, + { key: 'hin', label: 'हिन्दी' }, + { key: 'chi_sim', label: '简体中文' }, + { key: 'chi_tra', label: '繁体中文' }, + { key: 'jpn', label: '日本語' }, + { key: 'tha', label: 'ภาษาไทย' }, + { key: 'kor', label: '한국어' } + ]; }) /** * Initialize ngProgress. diff --git a/docs-web/src/main/webapp/src/app/docs/controller/document/Document.js b/docs-web/src/main/webapp/src/app/docs/controller/document/Document.js index 3e40cad2..88decb32 100644 --- a/docs-web/src/main/webapp/src/app/docs/controller/document/Document.js +++ b/docs-web/src/main/webapp/src/app/docs/controller/document/Document.js @@ -3,7 +3,7 @@ /** * Document controller. */ -angular.module('docs').controller('Document', function ($scope, $rootScope, $timeout, $state, Restangular) { +angular.module('docs').controller('Document', function ($scope, $rootScope, $timeout, $state, Restangular, $q) { /** * Documents table sort status. */ @@ -13,6 +13,7 @@ angular.module('docs').controller('Document', function ($scope, $rootScope, $tim $scope.currentPage = 1; $scope.limit = _.isUndefined(localStorage.documentsPageSize) ? 10 : localStorage.documentsPageSize; $scope.search = $state.params.search ? $state.params.search : ''; + $scope.searchOpened = false; $scope.setSearch = function (search) { $scope.search = search }; // A timeout promise is used to slow down search requests to the server @@ -115,9 +116,9 @@ angular.module('docs').controller('Document', function ($scope, $rootScope, $tim }; // Load tags - var tags = []; + $scope.tags = []; Restangular.one('tag/list').get().then(function (data) { - tags = data.tags; + $scope.tags = data.tags; }); /** @@ -125,11 +126,29 @@ angular.module('docs').controller('Document', function ($scope, $rootScope, $tim * @param parent */ $scope.getChildrenTags = function(parent) { - return _.filter(tags, function(tag) { + return _.filter($scope.tags, function(tag) { return tag.parent === parent; }); }; + /** + * Returns a promise for typeahead user. + */ + $scope.getUserTypeahead = function($viewValue) { + var deferred = $q.defer(); + Restangular.one('user/list') + .get({ + search: $viewValue, + sort_column: 1, + asc: true + }).then(function(data) { + deferred.resolve(_.pluck(_.filter(data.users, function(user) { + return user.username.indexOf($viewValue) !== -1; + }), 'username')); + }); + return deferred.promise; + }; + // Hack to reload the pagination directive after language change $scope.paginationShown = true; $rootScope.$on('$translateChangeSuccess', function () { @@ -138,4 +157,13 @@ angular.module('docs').controller('Document', function ($scope, $rootScope, $tim $scope.paginationShown = true; }); }) + + // Advanced search + $scope.searchDropdownAnchor = angular.element(document.querySelector('.search-dropdown-anchor')); + $scope.openSearch = function () { + var opened = $scope.searchOpened; + $timeout(function () { + $scope.searchOpened = !opened; + }); + } }); \ No newline at end of file diff --git a/docs-web/src/main/webapp/src/partial/docs/document.edit.html b/docs-web/src/main/webapp/src/partial/docs/document.edit.html index bc2f4ea9..9a50cb83 100644 --- a/docs-web/src/main/webapp/src/partial/docs/document.edit.html +++ b/docs-web/src/main/webapp/src/partial/docs/document.edit.html @@ -51,22 +51,7 @@