优化菜单栏代码
This commit is contained in:
parent
fc9de8e146
commit
9e4971151c
|
|
@ -6,6 +6,7 @@ app.controller('menuCtr', ['$scope', '$stateParams', '$state', '$window', '$time
|
||||||
$scope.searchWord = ''; /**< 搜索关键字 */
|
$scope.searchWord = ''; /**< 搜索关键字 */
|
||||||
$scope.showStyle = null;
|
$scope.showStyle = null;
|
||||||
$scope.searchHistory = [];
|
$scope.searchHistory = [];
|
||||||
|
$scope.historyTypes = dataService.historyTypes;
|
||||||
|
|
||||||
// 防止在登陆的情况下,在浏览器里面直接输入url,这时候要更新菜单选项
|
// 防止在登陆的情况下,在浏览器里面直接输入url,这时候要更新菜单选项
|
||||||
pubSubService.subscribe('Common.menuActive', $scope, function(event, params) {
|
pubSubService.subscribe('Common.menuActive', $scope, function(event, params) {
|
||||||
|
|
@ -15,11 +16,8 @@ app.controller('menuCtr', ['$scope', '$stateParams', '$state', '$window', '$time
|
||||||
updateMenuActive(index);
|
updateMenuActive(index);
|
||||||
});
|
});
|
||||||
|
|
||||||
// 登陆之后显示的菜单数据。uiSerf:内部跳转链接。
|
$scope.loginMenus = dataService.loginMenus; // 登陆之后显示的菜单数据。uiSerf:内部跳转链接。
|
||||||
$scope.loginMenus = dataService.loginMenus;
|
$scope.notLoginMenus = dataService.notLoginMenus; // 未登陆显示的菜单数据
|
||||||
|
|
||||||
// 未登陆显示的菜单数据
|
|
||||||
$scope.notLoginMenus = dataService.notLoginMenus;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @func
|
* @func
|
||||||
|
|
@ -49,7 +47,7 @@ app.controller('menuCtr', ['$scope', '$stateParams', '$state', '$window', '$time
|
||||||
}, {
|
}, {
|
||||||
reload: true,
|
reload: true,
|
||||||
})
|
})
|
||||||
updateMenuActive($scope.selectLoginIndex = 6);
|
updateMenuActive($scope.selectLoginIndex = dataService.LoginIndexNote);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!searchWord) {
|
if (!searchWord) {
|
||||||
|
|
@ -82,12 +80,7 @@ app.controller('menuCtr', ['$scope', '$stateParams', '$state', '$window', '$time
|
||||||
$('.search-item').val($scope.searchWord);
|
$('.search-item').val($scope.searchWord);
|
||||||
|
|
||||||
$('.js-search-option').dropdown('set value', type);
|
$('.js-search-option').dropdown('set value', type);
|
||||||
var types = {};
|
var types = $scope.historyTypes;
|
||||||
types[0] = '书签';
|
|
||||||
types[1] = '谷歌';
|
|
||||||
types[2] = 'Github';
|
|
||||||
types[3] = '栈溢出';
|
|
||||||
types[4] = '百度';
|
|
||||||
$('.js-search-option').dropdown('set text', types[type]);
|
$('.js-search-option').dropdown('set text', types[type]);
|
||||||
$('.js-search-option').dropdown('save defaults', types[type]);
|
$('.js-search-option').dropdown('save defaults', types[type]);
|
||||||
$('.js-search-option .menu .item').removeClass('active');
|
$('.js-search-option .menu .item').removeClass('active');
|
||||||
|
|
@ -170,8 +163,17 @@ app.controller('menuCtr', ['$scope', '$stateParams', '$state', '$window', '$time
|
||||||
}
|
}
|
||||||
|
|
||||||
bookmarkService.userInfo({})
|
bookmarkService.userInfo({})
|
||||||
.then((data) => {
|
.then((user) => {
|
||||||
$scope.searchHistory = JSON.parse(data.search_history || '[]');
|
$scope.searchHistory = JSON.parse(user.search_history || '[]');
|
||||||
|
$timeout(function() {
|
||||||
|
var showStyle = (user && user.show_style) || 'navigate';
|
||||||
|
if (showStyle) {
|
||||||
|
$('.js-bookmark-dropdown' + ' .radio.checkbox').checkbox('set unchecked');
|
||||||
|
$('.js-radio-' + showStyle).checkbox('set checked');
|
||||||
|
$('.js-bookmark-dropdown' + ' .field.item').removeClass('active selected');
|
||||||
|
$('.js-field-' + showStyle).addClass('active selected');
|
||||||
|
}
|
||||||
|
}, 1000)
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
|
|
|
||||||
|
|
@ -223,19 +223,6 @@ app.directive('faviconErr', function() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
app.filter('searchType', function() {
|
|
||||||
return function(type) {
|
|
||||||
var types = {};
|
|
||||||
types[0] = '书签';
|
|
||||||
types[1] = '谷歌';
|
|
||||||
types[2] = 'Github';
|
|
||||||
types[3] = '栈溢出';
|
|
||||||
types[4] = '百度';
|
|
||||||
types[5] = '备忘录';
|
|
||||||
return types[type];
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
app.filter('characters', function() {
|
app.filter('characters', function() {
|
||||||
return function(input, chars, breakOnWord) {
|
return function(input, chars, breakOnWord) {
|
||||||
if (isNaN(chars)) return input;
|
if (isNaN(chars)) return input;
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,7 @@ app.factory('dataService', [function() {
|
||||||
var t = data[parseInt(Math.random() * 1000) % data.length];
|
var t = data[parseInt(Math.random() * 1000) % data.length];
|
||||||
return t;
|
return t;
|
||||||
},
|
},
|
||||||
|
historyTypes: ['书签', '谷歌', 'Github', '栈溢出', '百度', '备忘录'],
|
||||||
};
|
};
|
||||||
|
|
||||||
return service;
|
return service;
|
||||||
|
|
|
||||||
|
|
@ -42,12 +42,7 @@
|
||||||
<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 active" data-value="0">书签</div>
|
<div class="item" data-value="$index" ng-class="{active:$index==0}" ng-repeat="historyType in historyTypes">{{historyType}}</div>
|
||||||
<div class="item" data-value="1">谷歌</div>
|
|
||||||
<div class="item" data-value="2">Github</div>
|
|
||||||
<div class="item" data-value="3">栈溢出</div>
|
|
||||||
<div class="item" data-value="4">百度</div>
|
|
||||||
<div class="item" data-value="5">备忘录</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</label>
|
</label>
|
||||||
|
|
@ -56,7 +51,7 @@
|
||||||
<div class="ui selection list">
|
<div class="ui selection list">
|
||||||
<div class="item" ng-repeat="item in searchHistory" ng-click="searchByHistory(item.t, item.d)" style="height:30px;">
|
<div class="item" ng-repeat="item in searchHistory" ng-click="searchByHistory(item.t, item.d)" style="height:30px;">
|
||||||
<div class="right floated content">
|
<div class="right floated content">
|
||||||
<span style="margin-right:10px;">{{ item.t | searchType }}</span>
|
<span style="margin-right:10px;">{{ historyTypes[item.t] }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<span style="margin-left:10px;">{{ item.d}}</span>
|
<span style="margin-left:10px;">{{ item.d}}</span>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue