From 3e40fe1ba93d254538b445f08a97c114e2c7f4fa Mon Sep 17 00:00:00 2001 From: luchenqun Date: Wed, 29 Mar 2017 12:31:43 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=90=9C=E7=B4=A2=E9=80=89?= =?UTF-8?q?=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../scripts/controllers/menus-controller.js | 27 +++++++++++++------ .../scripts/directives/js-init-directive.js | 12 +++++++++ public/views/menus.html | 22 +++++++++++---- 3 files changed, 48 insertions(+), 13 deletions(-) diff --git a/public/scripts/controllers/menus-controller.js b/public/scripts/controllers/menus-controller.js index 012dbb9..a949bdb 100644 --- a/public/scripts/controllers/menus-controller.js +++ b/public/scripts/controllers/menus-controller.js @@ -1,4 +1,4 @@ -app.controller('menuCtr', ['$scope', '$stateParams', '$state', 'pubSubService', 'bookmarkService', function($scope, $stateParams, $state, pubSubService, bookmarkService) { +app.controller('menuCtr', ['$scope', '$stateParams', '$state', '$window', 'pubSubService', 'bookmarkService', function($scope, $stateParams, $state, $window, pubSubService, bookmarkService) { console.log("Hello menuCtr") $scope.login = false; /**< 是否登陆 */ $scope.selectLoginIndex = 0; /**< 默认登陆之后的选择的菜单索引,下表从 0 开始 */ @@ -47,14 +47,25 @@ app.controller('menuCtr', ['$scope', '$stateParams', '$state', 'pubSubService', * @func * @desc 点击搜索按钮搜索书签 */ - $scope.searchBookmarks = function(searchWord) { - $state.go('search', { - searchWord: searchWord, - }, { - reload: true, - }) + $scope.search = function(searchWord) { $scope.login = true; - updateMenuActive($scope.selectLoginIndex = 0); + var searchOption = $('.js-search-option').dropdown('get value') || 0; + if (searchOption == 0) { + $window.open('http://www.baidu.com/s?tn=mybookmark.cn&ch=3&ie=utf-8&wd=' + encodeURIComponent(searchWord), '_blank'); + } else if(searchOption == 1){ + $window.open('https://www.google.com.hk/#newwindow=1&safe=strict&q=' + encodeURIComponent(searchWord), '_blank'); + } else if(searchOption == 2){ + $window.open('https://github.com/search?utf8=%E2%9C%93&q='+ encodeURIComponent(searchWord) +'&type=', '_blank'); + } else if(searchOption == 3){ + $window.open('https://stackoverflow.com/search?q='+ encodeURIComponent(searchWord), '_blank'); + } else { + $state.go('search', { + searchWord: searchWord, + }, { + reload: true, + }) + updateMenuActive($scope.selectLoginIndex = 0); + } } $scope.updateShowStyle = function(showStyle) { diff --git a/public/scripts/directives/js-init-directive.js b/public/scripts/directives/js-init-directive.js index ccd06de..aeb814d 100644 --- a/public/scripts/directives/js-init-directive.js +++ b/public/scripts/directives/js-init-directive.js @@ -182,6 +182,18 @@ app.directive('jsMenuInit', function($compile) { }; }); +app.directive('jsSearchOptionInit', function($compile) { + return { + restrict: 'A', + link: function($scope, $element, $attrs) { + console.log('jsSearchOptionInit......') + $('.js-search-option').dropdown({ + // on: 'hover', + }); + }, + }; +}); + app.directive('errSrc', function() { return { link: function(scope, element, attrs) { diff --git a/public/views/menus.html b/public/views/menus.html index 9e6fafd..c1f8df2 100644 --- a/public/views/menus.html +++ b/public/views/menus.html @@ -1,6 +1,6 @@