简单整理了几个artDialog的经常使用方法,便于开发中使用。话很少说,直接贴上代码:javascript
git连接: http://git.oschina.net/sunss/6nvw59x7ie1acgfpro4ub87.code.gitjava
/** * 跳转到页面 * * @author sunss * @date 2015年11月23日 上午9:07:17 * @param url */ function goToPage(url) { window.location.href = url; } /** * 打开页面 * * @param url */ function openPage(url) { window.open(url); } /** * 弹出层 确认 取消 * * @author sunss * @date 2015年12月23日 上午9:43:46 * @param title * @param content * @param okFunction * @param cencelFunction * @param options * @returns */ function atrConfirm(title, content, okFunction, cencelFunction, options) { var d = dialog({ title : title, content : content, opacity : 0.05, // 透明度 button : [ { value : '肯定', callback : function() { okFunction(options); } }, { value : '取消', callback : function() { if (cencelFunction) { cencelFunction; } d.close().remove(); }, autofocus : true } ] }); d.showModal(); return d; } /** * 加载一个div里面的内容为弹出层 * * @param title * @param divid * @returns */ function atrConfirm(title, divid) { var d = dialog({ title : title, content : $("#" + divid), opacity : 0.05 // 透明度 }); d.showModal(); return d; } /** * 执行post方法 * * @param url * @param data * @param functions */ function optionAjaxPost(url, data, functions) { $.ajax({ type : "post", traditional : true, url : url, data : data, dataType : "json", success : function(data) { functions(data); },// success error : function() { alert("操做失败!"); } });// AJAX } /** * 弹出层 提示 多少秒后关闭的那种 * * @author sunss * @date 2015年12月23日 上午9:27:39 * @param content * @param time * @returns */ function atrTip(content, time) { var d = dialog({ content : content, opacity : 0.05 // 透明度 }); d.showModal(); setTimeout(function() { d.close().remove(); }, time); return d; } /** * 1.5秒后关闭 * * @param content * @returns */ function atrTip(content) { var d = dialog({ content : content, opacity : 0.05 // 透明度 }); d.showModal(); setTimeout(function() { d.close().remove(); }, 1500); return d; } /** * 加载一个页面 * * @author sunss * @date 2015年12月23日 上午10:44:45 * @param title * @param url * @returns */ function atrUrl(title, url) { return atrUrl(title, url, 800); } /** * 带宽度的 加载一个页面 * * @param title * @param url * @param width * @returns */ function atrUrl(title, url, width) { var d = dialog({ "url" : url, title : title, background : '#EEE', // 背景色 opacity : 0.05,// 透明度 width : width }); d.showModal(); return d; } /** * 带宽度的高度的 加载一个页面 * * @param title * @param url * @param width * @returns */ function atrUrl2(title, url, width, height) { var d = dialog({ "url" : url, title : title, background : '#EEE', // 背景色 opacity : 0.05,// 透明度 width : width, height : height }); d.showModal(); return d; } /** * 跟随一个元素显示弹出层 * * @param elem * @param contents * @param type */ function showMore(elem, contents, type) { var align = "bottom"; if (!type) { align = type; } var d = dialog({ align : type, quickClose : true, content : contents }); d.show(elem); }
QQ群:530456619 git
My_QQ:707012377 ajax