Update search

This commit is contained in:
luchenqun 2019-08-02 18:33:59 +08:00
parent 4e55f7f6e7
commit 94be84c33d
4 changed files with 171 additions and 136 deletions

View File

@ -1,110 +1,110 @@
var app = angular.module('bookmarkApp', ['ui.router', 'ngCookies', 'infinite-scroll', 'angular-sortable-view', 'ngDialog']); var app = angular.module('bookmarkApp', ['ui.router', 'ngCookies', 'infinite-scroll', 'angular-sortable-view', 'ngDialog']);
app.config(function($stateProvider, $urlRouterProvider, $httpProvider) { app.config(function($stateProvider, $urlRouterProvider, $httpProvider) {
$urlRouterProvider.otherwise("/"); $urlRouterProvider.otherwise("/");
$stateProvider $stateProvider
.state('bookmarks', { .state('bookmarks', {
url: '/bookmarks', url: '/bookmarks',
templateUrl: '/views/bookmarks.html', templateUrl: '/views/bookmarks.html',
params: { params: {
showStyle: null, showStyle: null,
}, },
controller: 'bookmarksCtr' controller: 'bookmarksCtr'
}) })
.state('hot', { .state('hot', {
url: '/hot', url: '/hot',
templateUrl: '/views/hot.html', templateUrl: '/views/hot.html',
controller: 'hotCtr' controller: 'hotCtr'
}) })
.state('praise', { .state('praise', {
url: '/praise', url: '/praise',
templateUrl: '/views/praise.html', templateUrl: '/views/praise.html',
controller: 'praiseCtr' controller: 'praiseCtr'
}) })
.state('note', { .state('note', {
url: '/note', url: '/note',
templateUrl: '/views/note.html', templateUrl: '/views/note.html',
params: { params: {
searchWord: null, searchWord: null,
key:null, key:null,
}, },
controller: 'noteCtr' controller: 'noteCtr'
}) })
.state('search', { .state('search', {
url: '/search', url: '/search',
templateUrl: '/views/search.html', templateUrl: '/views/search.html',
params: { params: {
searchWord: null, searchWord: null,
}, },
controller: 'searchCtr' controller: 'searchCtr'
}) })
.state('tags', { .state('tags', {
url: '/tags', url: '/tags',
templateUrl: '/views/tags.html', templateUrl: '/views/tags.html',
params: { params: {
tagId: null, tagId: null,
orderIndex: null, orderIndex: null,
}, },
controller: 'tagsCtr' controller: 'tagsCtr'
}) })
.state('advice', { .state('advice', {
url: '/advice', url: '/advice',
templateUrl: '/views/advice.html', templateUrl: '/views/advice.html',
controller: 'adviceCtr' controller: 'adviceCtr'
}) })
.state('settings', { .state('settings', {
url: '/settings', url: '/settings',
templateUrl: '/views/settings.html', templateUrl: '/views/settings.html',
params: { params: {
formIndex: null, formIndex: null,
}, },
controller: 'settingsCtr' controller: 'settingsCtr'
}) })
.state('login', { .state('login', {
url: '/login', url: '/login',
templateUrl: '/views/login.html', templateUrl: '/views/login.html',
params: { params: {
showStyle: 'table', showStyle: 'table',
}, },
controller: 'loginCtr' controller: 'loginCtr'
}) })
.state('/', { .state('/', {
url: '/', url: '/',
templateUrl: '/views/home.html', templateUrl: '/views/home.html',
controller: 'homeCtr' controller: 'homeCtr'
}); });
}); });
console.log([ console.log([
" _ooOoo_", " _ooOoo_",
" o8888888o", " o8888888o",
" 88\" . \"88", " 88\" . \"88",
" (| -_- |)", " (| -_- |)",
" O\\ = /O", " O\\ = /O",
" ____/`---'\\____", " ____/`---'\\____",
" .' \\\\| |// `.", " .' \\\\| |// `.",
" / \\\\||| : |||// \\", " / \\\\||| : |||// \\",
" / _||||| -:- |||||- \\", " / _||||| -:- |||||- \\",
" | | \\\\\\ - /// | |", " | | \\\\\\ - /// | |",
" | \\_| ''\\---/'' | |", " | \\_| ''\\---/'' | |",
" \\ .-\\__ `-` ___/-. /", " \\ .-\\__ `-` ___/-. /",
" ___`. .' /--.--\\ `. . __", " ___`. .' /--.--\\ `. . __",
" .\"\" '< `.___\\_<|>_/___.' >'\"\".", " .\"\" '< `.___\\_<|>_/___.' >'\"\".",
" | | : `- \\`.;`\\ _ /`;.`/ - ` : | |", " | | : `- \\`.;`\\ _ /`;.`/ - ` : | |",
" \\ \\ `-. \\_ __\\ /__ _/ .-` / /", " \\ \\ `-. \\_ __\\ /__ _/ .-` / /",
"======`-.____`-.___\\_____/___.-`____.-'======", "======`-.____`-.___\\_____/___.-`____.-'======",
" `=---='", " `=---='",
"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^", "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^",
" 佛祖保佑 永无BUG", " 佛祖保佑 永无BUG",
" 写字楼里写字间,写字间里程序员;", " 写字楼里写字间,写字间里程序员;",
" 程序人员写程序,又拿程序换酒钱。", " 程序人员写程序,又拿程序换酒钱。",
" 酒醒只在网上坐,酒醉还来网下眠;", " 酒醒只在网上坐,酒醉还来网下眠;",
" 酒醉酒醒日复日,网上网下年复年。", " 酒醉酒醒日复日,网上网下年复年。",
" 但愿老死电脑间,不愿鞠躬老板前;", " 但愿老死电脑间,不愿鞠躬老板前;",
" 奔驰宝马贵者趣,公交自行程序员。", " 奔驰宝马贵者趣,公交自行程序员。",
" 别人笑我忒疯癫,我笑自己命太贱;", " 别人笑我忒疯癫,我笑自己命太贱;",
" 不见满街漂亮妹,哪个归得程序员?", " 不见满街漂亮妹,哪个归得程序员?",
].join('\n')); ].join('\n'));
console.log = function(){} // console.log = function(){}

View File

@ -10,6 +10,7 @@ app.controller('menuCtr', ['$scope', '$stateParams', '$state', '$window', '$time
$scope.quickUrl = {}; $scope.quickUrl = {};
$scope.longPress = false; $scope.longPress = false;
$scope.user = {}; $scope.user = {};
$scope.searching = true;
// 防止在登陆的情况下在浏览器里面直接输入url这时候要更新菜单选项 // 防止在登陆的情况下在浏览器里面直接输入url这时候要更新菜单选项
pubSubService.subscribe('Common.menuActive', $scope, function (event, params) { pubSubService.subscribe('Common.menuActive', $scope, function (event, params) {
@ -42,11 +43,11 @@ app.controller('menuCtr', ['$scope', '$stateParams', '$state', '$window', '$time
* @func * @func
* @desc 点击搜索按钮搜索书签 * @desc 点击搜索按钮搜索书签
*/ */
$scope.search = function (searchWord) { $scope.search = function (searchWord, searchOption) {
console.log('search......', searchWord); console.log('search......', searchWord);
$scope.login = true; $scope.login = true;
var searchOption = $('.js-search-option').dropdown('get value') || 0; // var searchOption = $('.js-search-option').dropdown('get value') || 0;
if (searchOption == 0) { if (searchOption == 0) {
$state.go('search', { $state.go('search', {
searchWord: searchWord, searchWord: searchWord,
@ -97,6 +98,16 @@ app.controller('menuCtr', ['$scope', '$stateParams', '$state', '$window', '$time
} }
} }
$scope.readySearch = function () {
$scope.searching = true;
}
$scope.exitSearch = function () {
$scope.searching = false;
$scope.searchWord = "";
$(".search-item").val("");
}
$scope.searchByHistory = function (type, data) { $scope.searchByHistory = function (type, data) {
$scope.searchWord = data; $scope.searchWord = data;
$('.search-item').val($scope.searchWord); $('.search-item').val($scope.searchWord);
@ -260,6 +271,21 @@ app.controller('menuCtr', ['$scope', '$stateParams', '$state', '$window', '$time
updateMenuActive($scope.selectLoginIndex = dataService.LoginIndexNote); updateMenuActive($scope.selectLoginIndex = dataService.LoginIndexNote);
$state.go('note', { key: key }, { reload: true }) $state.go('note', { key: key }, { reload: true })
} }
return;
}
if (key == 'S') {
$scope.searching = true;
$(".search-item").focus();
var count = 1;
var sId = setInterval(function() {
$(".search-item").val("");
count++;
if(count>=5) {
clearInterval(sId);
}
}, 3)
return;
} }
if (key == ',' || key == '.' || key == '/') { if (key == ',' || key == '.' || key == '/') {
@ -321,5 +347,4 @@ app.controller('menuCtr', ['$scope', '$stateParams', '$state', '$window', '$time
} }
}) })
}); });
}]); }]);

View File

@ -89,6 +89,7 @@ app.factory('dataService', [function() {
'D': '在有关书签页面,用作删除书签', 'D': '在有关书签页面,用作删除书签',
'I': '在有关书签页面,用作查看书签详情', 'I': '在有关书签页面,用作查看书签详情',
'R': '在热门收藏界面,已用作随机查看热门收藏', 'R': '在热门收藏界面,已用作随机查看热门收藏',
'S': '在任意界面,已用做快速进入搜索页面',
'INSERT': '全局页面,已用做添加书签', 'INSERT': '全局页面,已用做添加书签',
'ESC': '全局页面,已用做退出弹窗', 'ESC': '全局页面,已用做退出弹窗',
',': '跳转到分类定制点击次数', ',': '跳转到分类定制点击次数',

View File

@ -1,6 +1,6 @@
<div class="js-menu" ng-controller="menuCtr"> <div class="js-menu" ng-controller="menuCtr">
<div class="ui huge menu js-login-in" ng-if="login"> <div class="ui huge menu js-login-in" ng-if="login">
<a class="item" ng-class="{selected:$index===selectLoginIndex}" style="cursor:default;" ui-sref-opts="{reload: true}" ng-repeat="menu in loginMenus" ui-sref="{{ menu.uiSref }}({searchWord:null})" ng-show="menu.show !== false" js-menu-init> <a class="item js-single-menu" ng-class="{selected:$index===selectLoginIndex}" style="cursor:default;" ui-sref-opts="{reload: true}" ng-repeat="menu in loginMenus" ui-sref="{{ menu.uiSref }}({searchWord:null})" ng-show="menu.show !== false" js-menu-init>
<div>{{ menu.title }}</div> <div>{{ menu.title }}</div>
<div class="ui floating simple dropdown icon js-bookmark-dropdown" ng-if="$index==0" ng-click="$event.stopPropagation();"> <div class="ui floating simple dropdown icon js-bookmark-dropdown" ng-if="$index==0" ng-click="$event.stopPropagation();">
<i class="dropdown icon"></i> <i class="dropdown icon"></i>
@ -29,34 +29,43 @@
</div> </div>
</div> </div>
</a> </a>
<div class="right menu"> <div id="js-search" style="width: 1500px;">
<div class="item"> <div class="ui transparent fluid icon input" style="height: 100%;margin-left: 10px;">
<div class="ui transparent icon input"> <label for="lcq">
<label for="lcq"> <div class="ui inline dropdown js-search-option" style="margin-top:3px;height: 100%;" js-search-option-init>
<div class="ui inline dropdown js-search-option" style="margin-top:3px;" js-search-option-init> <!-- <div class="text " style="color:#C9C9C9;font-weight:normal;">书签</div> -->
<div class="text " style="color:#C9C9C9;font-weight:normal;">书签</div> <!-- <i class="angle down icon"></i> -->
<i class="angle down icon"></i> <div class="menu">
<div class="menu"> <div class="item" data-value="{{$index}}" ng-class="{active:$index==0}" ng-repeat="historyType in historyTypes">{{historyType}}</div>
<div class="item" data-value="{{$index}}" ng-class="{active:$index==0}" ng-repeat="historyType in historyTypes">{{historyType}}</div>
</div>
</div> </div>
</label> </div>
<input class="prompt search-item" type="text" ng-model="searchWord" placeholder="" ng-keypress="($event.which === 13)?search(searchWord):0" data-position="bottom left" data-variation="large" id="lcq"> </label>
<div class="ui fluid popup top left transition hidden" style="padding-left: 0px; padding-right: 0px;"> <input style="padding-left: 0px;" class="prompt search-item js-search-input" type="text" ng-focus="readySearch()" ng-model="searchWord" placeholder="search..." ng-keypress="($event.which === 13)?search(searchWord, 0):0" data-position="bottom left" data-variation="large" id="lcq">
<div class="ui selection list"> <div class="ui fluid popup top left transition hidden" style="padding-left: 0px; padding-right: -10px;">
<div class="item" ng-repeat="item in searchHistory" ng-click="searchByHistory(item.t, item.d)" style="height:30px;"> <div class="ui selection list">
<div class="right floated content"> <div class="item" ng-repeat="item in searchHistory" ng-click="searchByHistory(item.t, item.d)" style="height:30px;">
<span style="margin-right:10px;">{{ historyTypes[item.t] }}</span> <div class="right floated content">
</div> <span style="margin-right:10px;">{{ historyTypes[item.t] }}</span>
<div class="content"> </div>
<span style="margin-left:10px;">{{ item.d}}</span> <div class="content">
</div> <span style="margin-left:10px;">{{ item.d}}</span>
</div> </div>
</div> </div>
</div> </div>
<i class="search link icon" ng-click="search(searchWord)" style="cursor:default;"></i> </div>
<div ng-if="searching">
<span style="margin-left: -25px;"><i class="bookmark outline link icon" title="书签搜索" ng-click="search(searchWord, 0)" style="cursor:default;margin-top:16px;margin-right: 8px;"></i></span>
<span><i class="google link icon" title="谷歌搜索" ng-click="search(searchWord, 1)" style="cursor:default;margin-top:16px;margin-right: 8px;"></i></span>
<span><i class="bimobject link icon" title="百度搜索" ng-click="search(searchWord, 4)" style="cursor:default;margin-top:16px;margin-right: 8px;"></i></span>
<span><i class="github link icon" title="Github 搜索" ng-click="search(searchWord, 2)" style="cursor:default;margin-top:16px;margin-right: 8px;"></i></span>
<span><i class="stack overflow link icon" title="栈溢出搜索" ng-click="search(searchWord, 3)" style="cursor:default;margin-top:16px;margin-right: 8px;"></i></span>
<span>|</span>
<span><i class="add square link icon" title="添加书签" ng-click="showAddBookmarkMoadl()" style="cursor:default;margin-top:16px;margin-right: 8px;margin-left: 8px;"></i></span>
<span><i class="arrow right link icon" title="退出搜索" ng-click="exitSearch()" style="cursor:default;margin-top:16px;"></i></span>
</div> </div>
</div> </div>
</div>
<div class="right menu" ng-if="!searching">
<div class="item" style="padding:0 8px 0 13px;" title="添加书签" ng-click="showAddBookmarkMoadl()"> <div class="item" style="padding:0 8px 0 13px;" title="添加书签" ng-click="showAddBookmarkMoadl()">
<span data-tooltip="添加书签可按Insert快速打开添加页面"> <span data-tooltip="添加书签可按Insert快速打开添加页面">
<i class="add square icon"></i> <i class="add square icon"></i>