|
@@ -36,6 +36,7 @@
|
|
|
|
|
|
<script>
|
|
|
const hintBox = {
|
|
|
+ test: false,
|
|
|
value: null,
|
|
|
btnType: {yes: 1, yesNo: 2, yesNoCancel: 3},
|
|
|
init: function (){
|
|
@@ -44,7 +45,8 @@
|
|
|
$("#hintBox_btn_yes").unbind();
|
|
|
$('#hintBox_btn_no').unbind();
|
|
|
$('#hintBox_btn_cancel').unbind();
|
|
|
- $("#hintBox_value").keypress(
|
|
|
+
|
|
|
+ $("#hintBox_value").keyup(
|
|
|
function (event) {
|
|
|
hintBox.value = $('#hintBox_value').val();
|
|
|
if (event.keyCode === 13) {
|
|
@@ -55,7 +57,8 @@
|
|
|
);
|
|
|
$('#hintBox_btn_cancel').click(
|
|
|
function () {
|
|
|
- $.bootstrapLoading.end();
|
|
|
+ if (!hintBox.test)
|
|
|
+ $.bootstrapLoading.end();
|
|
|
return;
|
|
|
}
|
|
|
);
|
|
@@ -70,73 +73,71 @@
|
|
|
},
|
|
|
font: function(str){
|
|
|
return `<span style='color:red;font-weight:bold;font-size:15px'> ${str} </span>`;
|
|
|
- }
|
|
|
- };
|
|
|
-
|
|
|
- function hintBoxInfo(title, caption, btnType, doYes, doNo) {
|
|
|
- hintBox.init();
|
|
|
- $('#hintBox_title').text(title);
|
|
|
- $('#hintBox_caption').html(caption);
|
|
|
- $('#hintBox_caption').show();
|
|
|
-
|
|
|
- switch (btnType) {
|
|
|
- case hintBox.btnType.yes:
|
|
|
- $('#hintBox_btn_yes').text('确定');
|
|
|
- $('#hintBox_btn_yes').show();
|
|
|
- break;
|
|
|
- case hintBox.btnType.yesNo:
|
|
|
- $('#hintBox_btn_yes').text('是');
|
|
|
- $('#hintBox_btn_no').text('否');
|
|
|
- $('#hintBox_btn_yes').show();
|
|
|
- $('#hintBox_btn_no').show();
|
|
|
- break;
|
|
|
- case hintBox.btnType.yesNoCancel:
|
|
|
- $('#hintBox_btn_yes').text('是');
|
|
|
- $('#hintBox_btn_no').text('否');
|
|
|
- $('#hintBox_btn_cancel').text('取消');
|
|
|
- $('#hintBox_btn_yes').show();
|
|
|
- $('#hintBox_btn_no').show();
|
|
|
- $('#hintBox_btn_cancel').show();
|
|
|
- break;
|
|
|
- }
|
|
|
+ },
|
|
|
+ error: function (err) { // 注意:该方法只能用在valueBox()的doOK回调函数中。
|
|
|
+ $('#hintBox_error').text(err);
|
|
|
+ $('#hintBox_error').show(200);
|
|
|
+ $("#hintBox_value").focus();
|
|
|
+ $("#hintBox_value").select();
|
|
|
+ },
|
|
|
+ infoBox: function (title, caption, btnType, doYes, doNo) {
|
|
|
+ this.init();
|
|
|
+ $('#hintBox_title').text(title);
|
|
|
+ $('#hintBox_caption').html(caption);
|
|
|
+ $('#hintBox_caption').show();
|
|
|
|
|
|
- if (doYes){
|
|
|
- $('#hintBox_btn_yes').click(doYes);
|
|
|
- }
|
|
|
+ switch (btnType) {
|
|
|
+ case this.btnType.yes:
|
|
|
+ $('#hintBox_btn_yes').text('确定');
|
|
|
+ $('#hintBox_btn_yes').show();
|
|
|
+ break;
|
|
|
+ case this.btnType.yesNo:
|
|
|
+ $('#hintBox_btn_yes').text('是');
|
|
|
+ $('#hintBox_btn_no').text('否');
|
|
|
+ $('#hintBox_btn_yes').show();
|
|
|
+ $('#hintBox_btn_no').show();
|
|
|
+ break;
|
|
|
+ case this.btnType.yesNoCancel:
|
|
|
+ $('#hintBox_btn_yes').text('是');
|
|
|
+ $('#hintBox_btn_no').text('否');
|
|
|
+ $('#hintBox_btn_cancel').text('取消');
|
|
|
+ $('#hintBox_btn_yes').show();
|
|
|
+ $('#hintBox_btn_no').show();
|
|
|
+ $('#hintBox_btn_cancel').show();
|
|
|
+ break;
|
|
|
+ }
|
|
|
|
|
|
- if (doNo){
|
|
|
- $('#hintBox_btn_no').click(doNo);
|
|
|
- }
|
|
|
+ if (doYes){
|
|
|
+ $('#hintBox_btn_yes').click(doYes);
|
|
|
+ }
|
|
|
|
|
|
- $("#hintBox_form").modal('show');
|
|
|
- };
|
|
|
+ if (doNo){
|
|
|
+ $('#hintBox_btn_no').click(doNo);
|
|
|
+ }
|
|
|
|
|
|
- function hintBoxValue(title, value, doOK) {
|
|
|
- hintBox.init();
|
|
|
- $('#hintBox_title').text(title);
|
|
|
- hintBox.value = value;
|
|
|
- $('#hintBox_value').show();
|
|
|
- $('#hintBox_value').val(value);
|
|
|
- $("#hintBox_value").focus();
|
|
|
- $("#hintBox_value").select();
|
|
|
+ $("#hintBox_form").modal('show');
|
|
|
|
|
|
- $('#hintBox_btn_yes').text('确定');
|
|
|
- $('#hintBox_btn_yes').show();
|
|
|
- $('#hintBox_btn_yes').click(doOK); // doOK不能给参数
|
|
|
+ },
|
|
|
+ valueBox: function (title, value, doOK) {
|
|
|
+ this.init();
|
|
|
+ $('#hintBox_title').text(title);
|
|
|
+ this.value = value;
|
|
|
+ $('#hintBox_value').show();
|
|
|
+ $('#hintBox_value').val(value);
|
|
|
+ $("#hintBox_value").focus();
|
|
|
+ $("#hintBox_value").select();
|
|
|
|
|
|
- $("#hintBox_form").modal('show');
|
|
|
- };
|
|
|
+ $('#hintBox_btn_yes').text('确定');
|
|
|
+ $('#hintBox_btn_yes').show();
|
|
|
+ $('#hintBox_btn_yes').click(doOK); // doOK不能给参数
|
|
|
|
|
|
- // 注意:该方法只能用在hintBoxValue()的doOK回调函数中。
|
|
|
- function hintBoxError (error) {
|
|
|
- $('#hintBox_error').text(error);
|
|
|
- $('#hintBox_error').show(200);
|
|
|
- $("#hintBox_value").focus();
|
|
|
- $("#hintBox_value").select();
|
|
|
+ $("#hintBox_form").modal('show');
|
|
|
+ }
|
|
|
};
|
|
|
|
|
|
$('#hintBox_form').on('hide.bs.modal', function() {
|
|
|
- $.bootstrapLoading.end();
|
|
|
+ if (!hintBox.test)
|
|
|
+ $.bootstrapLoading.end();
|
|
|
return;
|
|
|
});
|
|
|
</script>
|