-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
121 lines (118 loc) · 3.99 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
'use strict';
var yookApp = angular.module('mainApp').controller("mainCtr",function($http,$scope,$rootScope,$filter){
$scope.menu_code = menu_code; // HTML的菜单配置 来自menu_code.js
$scope.xxx = "200";
// function systermAlert(data) {
// BootstrapDialog.alert({
// title: '系统提示',
// message: data,
// cssClass: 'login-dialog',
// });
// }
});
/**
* 自定义指令 ng-enter
* */
yookApp.directive('ngEnter', function() {
return {
restrict: 'A',
require: 'ngModel',
link: function ($scope, element, attrs, controller) {
element.bind("keydown keypress", function (event) {
if(event.which === 13) {
$scope.$apply(function (){
$scope.$eval(attrs.ngEnter);
});
event.preventDefault();
}
});
}
}
});
/**
* dialog弹窗 分装
* */
// var types = [BootstrapDialog.TYPE_DEFAULT,
// BootstrapDialog.TYPE_INFO,
// BootstrapDialog.TYPE_PRIMARY,
// BootstrapDialog.TYPE_SUCCESS,
// BootstrapDialog.TYPE_WARNING,
// BootstrapDialog.TYPE_DANGER];
yookApp.service('$Bd', function() {
// 系统提示框
this.systemRemind = function (str) {
BootstrapDialog.alert({
title: '系统提示',
message: str,
cssClass: 'login-dialog',
closable : false, // <-- Default value is false,点击对话框以外的页面内容可关闭
draggable : true, // <-- Default value is false,可拖拽
});
}
// confirm确认选择框
this.showConfirm = function (str,fn){
BootstrapDialog.confirm({
title : '确认',
message : str,
type : BootstrapDialog.TYPE_WARNING, // <-- Default value is
// BootstrapDialog.TYPE_PRIMARY
closable : false, // <-- Default value is false,点击对话框以外的页面内容可关闭
draggable : true, // <-- Default value is false,可拖拽
btnCancelLabel : '取消', // <-- Default value is 'Cancel',
btnOKLabel : '确定', // <-- Default value is 'OK',
btnOKClass : 'btn-warning', // <-- If you didn't specify it, dialog type
// 对话框关闭的时候执行方法
callback : function(result) {
// 点击确定按钮时,result为true
if (result) {
// 执行方法
if(fn){
fn();
}
}
}
});
}
this.showSuccess = function(str, time) {
BootstrapDialog.show({
type : BootstrapDialog.TYPE_SUCCESS,
title : '系统提示 ',
message : str,
size : BootstrapDialog.SIZE_SMALL,
buttons : [ {
label : '确定',
action : function(dialogItself) {
dialogItself.close();
}
} ],
// 指定时间内可自动关闭
onshown : function(dialogRef) {
setTimeout(function() {
dialogRef.close();
}, time); // 时间毫秒计算
},
});
}
//弹出错误提示
this.showErr = function (str) {
// 调用show方法
BootstrapDialog.show({
type : BootstrapDialog.TYPE_DANGER,
title : '系统提示 ',
message : str,
closable : false, // <-- Default value is false,点击对话框以外的页面内容可关闭
draggable : true, // <-- Default value is false,可拖拽
size : BootstrapDialog.SIZE_SMALL,//size为小,默认的对话框比较宽
buttons : [ {// 设置关闭按钮
label : '关闭',
action : function(dialogItself) {
dialogItself.close();
}
} ],
// 对话框关闭时带入callback方法
// onhide : func
});
}
this.showModel = function () {
}
});