diff --git a/public/scripts/controllers/edit-controller.js b/public/scripts/controllers/edit-controller.js index f6291dd..d05b8b1 100644 --- a/public/scripts/controllers/edit-controller.js +++ b/public/scripts/controllers/edit-controller.js @@ -160,6 +160,7 @@ app.controller('editCtr', ['$scope', '$state', '$timeout', 'bookmarkService', 'p $('.ui.dropdown').dropdown({ forceSelection: false, maxSelections: maxSelections, + action: 'hide', onChange: function(value, text, $choice) { var selectedTags = $('.ui.modal.js-add-bookmark .ui.dropdown').dropdown('get value'); $timeout(function() { diff --git a/public/scripts/controllers/search-controller.js b/public/scripts/controllers/search-controller.js index 0805060..6ee8596 100644 --- a/public/scripts/controllers/search-controller.js +++ b/public/scripts/controllers/search-controller.js @@ -1,14 +1,18 @@ app.controller('searchCtr', ['$scope', '$state', '$stateParams', '$filter', '$window', '$timeout', 'bookmarkService', 'pubSubService', function($scope, $state, $stateParams, $filter, $window, $timeout, bookmarkService, pubSubService) { console.log("Hello searchCtr...", $stateParams); $scope.bookmarks = []; // 书签数据 - $scope.showSearch = false; // 搜索对话框 + $scope.showSearch = false; // + $scope.showTags = false; // $scope.searchWord = ($stateParams && $stateParams.searchWord) || '' - $scope.dateBegin = ''; - $scope.dateEnd = ''; + $scope.dateCreateBegin = ''; + $scope.dateCreateEnd = ''; + $scope.dateClickBegin = ''; + $scope.dateClickEnd = ''; $scope.clickCount = ''; $scope.username = ''; $scope.userRange = ''; - $scope.bookmarkCount = 0 + $scope.bookmarkCount = 0; + var searchParams = { searchWord: $scope.searchWord, } @@ -42,6 +46,23 @@ app.controller('searchCtr', ['$scope', '$state', '$stateParams', '$filter', '$wi searchBookmarks(params) console.log('search..', $scope.searchWord, $scope.dateBegin, $scope.clickCount, $scope.username, $scope.userRange) } + $scope.updateCreateDate = function() { + console.log($scope.dateCreateBegin, $scope.dateCreateEnd); + if ($scope.dateCreateBegin && $scope.dateCreateEnd) { + $('.js-create-date').dropdown('hide'); + $('.js-create-date').dropdown('clear'); + $('.js-create-date .text').text($scope.dateCreateBegin + " 至 " + $scope.dateCreateEnd).removeClass('default'); + } + } + + $scope.updateClickDate = function() { + console.log($scope.dateClickBegin, $scope.dateClickEnd); + if ($scope.dateClickBegin && $scope.dateClickEnd) { + $('.js-click-date').dropdown('hide'); + $('.js-click-date').dropdown('clear'); + $('.js-click-date .text').text($scope.dateClickBegin + " 至 " + $scope.dateClickEnd).removeClass('default'); + } + } function searchBookmarks(params) { bookmarkService.searchBookmarks(params) @@ -55,34 +76,4 @@ app.controller('searchCtr', ['$scope', '$state', '$stateParams', '$filter', '$wi }) .catch((err) => console.log('getBookmarks err', err)); } - - $scope.$on('viewContentLoaded', function(elementRenderFinishedEvent) { - $('.ui.dropdown').dropdown(); - $('.ui.calendar.js-date-begin').calendar({ - type: 'date', - formatter: { - date: function(date, settings) { - if (!date) return ''; - var day = date.getDate(); - var month = date.getMonth() + 1; - var year = date.getFullYear(); - return year + '/' + month + '/' + day; - } - }, - endCalendar: $('.ui.calendar.js-date-end') - }); - $('.ui.calendar.js-date-end').calendar({ - type: 'date', - formatter: { - date: function(date, settings) { - if (!date) return ''; - var day = date.getDate(); - var month = date.getMonth() + 1; - var year = date.getFullYear(); - return year + '/' + month + '/' + day; - } - }, - startCalendar: $('.ui.calendar.js-date-begin') - }); - }); }]); diff --git a/public/scripts/directives/js-init-directive.js b/public/scripts/directives/js-init-directive.js index f76b5f4..8481acb 100644 --- a/public/scripts/directives/js-init-directive.js +++ b/public/scripts/directives/js-init-directive.js @@ -1,84 +1,82 @@ -app.directive('jsDataCreateBeginInit', function($compile) { +function date(date, settings) { + if (!date) return ''; + var day = date.getDate(); + var month = date.getMonth() + 1; + var year = date.getFullYear(); + return year + '/' + month + '/' + day; +}; + +app.directive('jsDataCreateInit', function($compile) { return { restrict: 'A', link: function($scope, $element, $attrs) { $('.ui.calendar.js-date-create-begin').calendar({ type: 'date', formatter: { - date: function(date, settings) { - if (!date) return ''; - var day = date.getDate(); - var month = date.getMonth() + 1; - var year = date.getFullYear(); - return year + '/' + month + '/' + day; - } + date: date + }, + onChange: function(date, text) { + console.log($scope.username); + $('.ui.calendar.js-date-create-begin :input').val(text).trigger("change"); }, endCalendar: $('.ui.calendar.js-date-create-end') }); - }, - }; -}); - -app.directive('jsDataCreateEndInit', function($compile) { - return { - restrict: 'A', - link: function($scope, $element, $attrs) { $('.ui.calendar.js-date-create-end').calendar({ type: 'date', formatter: { - date: function(date, settings) { - if (!date) return ''; - var day = date.getDate(); - var month = date.getMonth() + 1; - var year = date.getFullYear(); - return year + '/' + month + '/' + day; - } + date: date + }, + onChange: function(date, text) { + $('.ui.calendar.js-date-create-end :input').val(text).trigger("change"); }, startCalendar: $('.ui.calendar.js-date-create-begin') }); + + $('.js-create-date').dropdown('set value', 0); }, }; }); -app.directive('jsDataClickBeginInit', function($compile) { +app.directive('jsDataClickInit', function($compile) { return { restrict: 'A', link: function($scope, $element, $attrs) { $('.ui.calendar.js-date-click-begin').calendar({ type: 'date', formatter: { - date: function(date, settings) { - if (!date) return ''; - var day = date.getDate(); - var month = date.getMonth() + 1; - var year = date.getFullYear(); - return year + '/' + month + '/' + day; - } + date: date + }, + onChange: function(date, text) { + $('.ui.calendar.js-date-click-begin :input').val(text).trigger("change"); }, endCalendar: $('.ui.calendar.js-date-click-end') }); + $('.ui.calendar.js-date-click-end').calendar({ + type: 'date', + formatter: { + date: date + }, + onChange: function(date, text) { + $('.ui.calendar.js-date-click-end :input').val(text).trigger("change"); + }, + startCalendar: $('.ui.calendar.js-date-click-begin') + }); + $('.js-click-date').dropdown('set value', 0); }, }; }); - -app.directive('jsDataClickEndInit', function($compile) { +app.directive('jsDropdownUserRangeInit', function($compile) { return { restrict: 'A', link: function($scope, $element, $attrs) { - $('.ui.calendar.js-date-click-end').calendar({ - type: 'date', - formatter: { - date: function(date, settings) { - if (!date) return ''; - var day = date.getDate(); - var month = date.getMonth() + 1; - var year = date.getFullYear(); - return year + '/' + month + '/' + day; - } + $('.ui.dropdown.js-user-range').dropdown({ + onChange: function(value, text, $choice) { + $scope.showTags = (value === '1'); + console.log(value, text, $choice, $scope.showTags, $scope.username); + $scope.$apply(); }, - startCalendar: $('.ui.calendar.js-date-click-begin') }); }, }; diff --git a/public/scripts/services/data-service.js b/public/scripts/services/data-service.js index def88b5..dffa907 100644 --- a/public/scripts/services/data-service.js +++ b/public/scripts/services/data-service.js @@ -1,12 +1,16 @@ app.factory('dataService', [function() { - var service = { + const service = { + Enum: { + UserSelf: 1, + }, loginParams: function() { return { - username:'', - password:'', - autoLogin:true, + username: '', + password: '', + autoLogin: true, }; }, + }; return service; diff --git a/public/views/search.html b/public/views/search.html index 29da5c9..4b5a1e8 100644 --- a/public/views/search.html +++ b/public/views/search.html @@ -3,34 +3,32 @@ 共为您找到相关书签约{{bookmarkCount}}个