+function ($){
"use strict";
var _css='';
$(document.head).append(_css);
}($);
+function ($) {
"use strict";
var defaults;
$.modal = function (params) {
params = $.extend({}, defaults, params);
//检测当前系统是移动端还是pc端
var _useragent = navigator.useragent;
var _iphone = /iphone/i;
var _ipad = /ipad/i;
var _android = /android/i;
var _winphone = /windows phone/i;
var _symbianos = /symbianos/i;
var _blackberry = /blackberry/i;
if (_iphone.test(_useragent) || _ipad.test(_useragent) || _android.test(_useragent) || _winphone.test(_useragent) || _symbianos.test(_useragent) || _blackberry.test(_useragent)) {
params.os = 'mobi';
} else {
params.os = 'pc';
}
var buttons = params.buttons;
var btnlen = buttons.length;
var buttonshtml = buttons.map(function (d, i) {
return '' + d.text + '';
}).join("");
var tpl = '
' +
'
' + params.title + '
' +
(params.text ? '
' + params.text + '
' : '') +
'
' + buttonshtml + '
' +
'
';
var dialog = $.openmodal(tpl);
dialog.find(".wandou-btn").each(function (i, e) {
var el = $(e);
el.click(function () {
//先关闭对话框,再调用回调函数
if (params.autoclose) {
if ($('#wandou-dialog-' + params.os).find('.wandou-prompt-input').length > 0) {
if (buttons[i].onclick) {
buttons[i].onclick();
}
$.closemodal(params);
} else {
$.closemodal(params);
if (buttons[i].onclick) {
buttons[i].onclick();
}
}
}
});
});
};
$.openmodal = function (tpl) {
var mask = $("").appendto(document.body);
mask.show();
var dialog = $(tpl).appendto(document.body);
dialog.show();
return dialog;
}
$.closemodal = function (obj) {
console.log(obj);
$('#wandou-mask').remove();
$('#wandou-dialog-' + obj.os).remove();
// $(".weui_mask_visible").removeclass("weui_mask_visible").transitionend(function() {
// console.log($(this));
// $(this).remove();
// });
// $(".weui_dialog_visible").removeclass("weui_dialog_visible").transitionend(function() {
// console.log($(this));
// $(this).remove();
// });
};
$.alert = function (text, title, callback) {
if (typeof title === 'function') {
callback = arguments[1];
title = undefined;
}
return $.modal({
text: text,
title: title,
buttons: [{
text: defaults.buttonok,
classname: "primary",
onclick: callback
}]
});
}
$.confirm = function (text, title, callbackok, callbackcancel) {
if (typeof title === 'function') {
callbackcancel = arguments[2];
callbackok = arguments[1];
title = undefined;
}
return $.modal({
text: text,
title: title,
buttons: [
{
text: defaults.buttoncancel,
classname: "default",
onclick: callbackcancel
},
{
text: defaults.buttonok,
classname: "primary",
onclick: callbackok
}]
});
};
$.prompt = function (text, title, callbackok, callbackcancel) {
if (typeof title === 'function') {
callbackcancel = arguments[2];
callbackok = arguments[1];
title = undefined;
}
return $.modal({
text: "" + (text || "") + "
",
title: title,
buttons: [
{
text: defaults.buttoncancel,
classname: "default",
onclick: callbackcancel
},
{
text: defaults.buttonok,
classname: "primary",
onclick: function () {
callbackok && callbackok($("#wandouval").val());
}
}]
});
};
defaults = $.modal.prototype.defaults = {
title: "提示",
text: undefined,
buttonok: "确定",
buttoncancel: "取消",
buttons: [{
text: "确定",
classname: "primary"
}],
autoclose: true //点击按钮自动关闭对话框,如果你不希望点击按钮就关闭对话框,可以把这个设置为false
};
}($);
+function ($) {
"use strict";
var defaults;
var _os;
//检测当前系统是移动端还是pc端
var _useragent = navigator.useragent;
var _iphone = /iphone/i;
var _ipad = /ipad/i;
var _android = /android/i;
var _winphone = /windows phone/i;
var _symbianos = /symbianos/i;
var _blackberry = /blackberry/i;
if (_iphone.test(_useragent) || _ipad.test(_useragent) || _android.test(_useragent) || _winphone.test(_useragent) || _symbianos.test(_useragent) || _blackberry.test(_useragent)) {
_os = 'mobi';
} else {
_os = 'pc';
}
var show = function (html, classname) {
classname = classname || "";
var mask = $("").appendto(document.body);
var tpl = '' + html + '
';
var dialog = $(tpl).appendto(document.body);
dialog.show();
//dialog.addclass("weui_toast_visible");
};
var hide = function (callback) {
$("#wandou-mask").remove();
var $this = $('#wandou-toast-'+_os).remove();
callback && callback($this);
// $(".weui_toast_visible").removeclass("weui_toast_visible").transitionend(function () {
// var $this = $(this);
// $this.remove();
// callback && callback($this);
// });
}
$.toast = function (text, style, callback) {
if (typeof style === "function") {
callback = style;
style = 'undefined';
}
var classname;
var html;
if (style == "cancel") {
html = ''
} else if (style == "none") {
html = ''
} else{
html = '';
}
html+='' + (text || "已经完成") + '
';
show(html, classname);
settimeout(function () {
hide(callback);
}, toastdefaults.duration);
}
$.showloading = function (text) {
var html = '';
html += '' + (text || "数据加载中") + '
';
show(html);
}
$.hideloading = function () {
hide();
}
var toastdefaults = $.toast.prototype.defaults = {
duration: 2000
}
}($);