artDialog提示框、對話方塊,artdialog對話方塊

來源:互聯網
上載者:User

artDialog提示框、對話方塊,artdialog對話方塊
/**
 * 警告
 * @param {String}訊息內容
 */
artDialog.alert = function (content, callback) {
return artDialog({
id: 'Alert',
icon: 'warning',
fixed: true,
// lock: true,
width:250,
height:50,
content: content,
ok: true,
close: callback
});
};




/**
 * 確認
 * @param {String}訊息內容
 * @param {Function}確定按鈕回呼函數
 * @param {Function}取消按鈕回呼函數
 */
artDialog.confirm = function (content, yes, no) {
return artDialog({
id: 'Confirm',
icon: 'question',
fixed: true,
// lock: true,
opacity: .1,
width:250,
height:50,
content: content,
ok: function (here) {
return yes.call(this, here);
},
cancel: function (here) {
return no && no.call(this, here);
}
});
};




/**
 * 提問
 * @param {String}提問內容
 * @param {Function}回呼函數. 接收參數:輸入值
 * @param {String}預設值
 */
artDialog.prompt = function (content, yes, value) {
value = value || '';
var input;

return artDialog({
id: 'Prompt',
icon: 'question',
fixed: true,
// lock: true,
width:250,
height:50,
opacity: .1,
content: [
'<div style="margin-bottom:5px;font-size:12px">',
content,
'</div>',
'<div>',
'<input value="',
value,
'" style="width:18em;padding:6px 4px" />',
'</div>'
].join(''),
init: function () {
input = this.DOM.content.find('input')[0];
input.select();
input.focus();
},
ok: function (here) {
return yes && yes.call(this, input.value, here);
},
cancel: true
});
};




/**
 * 短暫提示
 * @param {String}提示內容
 * @param {Number}顯示時間 (預設1.5秒)
 */
artDialog.tips = function (content, time) {
return artDialog({
id: 'Tips',
title: false,
        cancel: false,
fixed: true,
// lock: true,
width:250,
height:50
})
    .content('<div style="padding: 0 1em;">' + content + '</div>')
.time(time || 1);
};


//右下角滑動通知
artDialog.notice = function (options) {
var opt = options || {},
api, aConfig, hide, wrap, top,
duration = 800;

var config = {
id: 'Notice',
left: '100%',
top: '100%',
fixed: true,
drag: false,
width:250,
height:50,
resize: false,
follow: null,
lock: false,
init: function(here){
api = this;
aConfig = api.config;
wrap = api.DOM.wrap;
top = parseInt(wrap[0].style.top);
hide = top + wrap[0].offsetHeight;

wrap.css('top', hide + 'px')
.animate({top: top + 'px'}, duration, function () {
opt.init && opt.init.call(api, here);
});
},
close: function(here){
wrap.animate({top: hide + 'px'}, duration, function () {
opt.close && opt.close.call(this, here);
aConfig.close = $.noop;
api.close();
});

return false;
}
};

for (var i in opt) {
if (config[i] === undefined) config[i] = opt[i];
};

return artDialog(config);
};


//調用範例:
art.dialog.alert('人品越來越不那麼穩定了,請檢查!');


art.dialog.confirm('你確定要刪除這掉訊息嗎?', function () {
art.dialog.tips('執行確定操作');
}, function () {
art.dialog.tips('執行取消操作');
});


art.dialog.prompt('請輸入圖片網址', function (val) {
art.dialog.tips(val);
}, 'http://');




art.dialog.tips('資料正在提交..', 2);
//[more code..]
art.dialog.tips('成功!已經儲存在伺服器');

著作權聲明:本文為博主原創文章,未經博主允許不得轉載。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.