1/************************************************ 2 * @author :leon.z 3 * @date :2014-9-3 4 * @description :èªå·±åçalertåconfirmå¼¹åºæ¡ 5 ***********************************************/ 6/** 7 èªå·±åçalertåconfirmå¼¹åºæ¡ãç¨æ³å¾ç®åï¼ç´æ¥è°ç¨æä»¶å¯¹è±¡ä¼ äººåæ°ok, 8 注æçæ¯èªå·±æ èå°æä»¶åçº§ä¸ºç¨æ·èªå®ä¹ï¼å®å ¨æ ¹æ®ç¨æ·å®¡ç¾èªå®ä¹é¢è²ï¼åå°±æ¯æä¸ä¸ªå ¨å±é¢è²éæºæºå¶ï¼å¦ææ¨ä¸æ¯éå£å³ï¼å»ºè®®æ¨ä¸è¦å¼å¯, 9 èªå¨æºå¶ä¹å¯ä»¥ç¨äºè°è¯èªå·±å欢é¢è²ï¼ç¶ååå°é è²æ¹æ¡åå ³éå ¨å±èªå¨ï¼éä¸èªå·±æ¾å°é è²å¹¶èµå¼ 10 eg:$.MsgBox({type:"confirm",speed:200,title:"",msg:"",opacity:'',callback:function(){}.....}) 11**/ 12; (function ($) { 13 $.MsgBox = function (options) { 14 $.MsgBox.defaults = { 15 is_changeBg: true, //é»è®¤æ¾ç¤ºé®ç½©å± 16 title: 'æç¤ºä¿¡æ¯', //å¤´é¨ 17 msg: 'è³å°æ¥ç¹å 容å§ï¼', //å 容 18 okBtnText: 'ç¡®å®', 19 noBtnText: 'åæ¶', 20 opacity: .5, //é®ç½©å±éæåº¦ 21 filter: "alpha(opacity=50)", 22 bgColor: '#000', //é®ç½©å±é¢è² 23 type: '', //è°ç¨ç±»åï¼å¿ 须填åï¼ 24 userDesign: false, //ç¨æ·èªå®ä¹ï¼é»è®¤falseï¼ 25 borderColor: "#009bfe", //titleä¸è¾¹æ¡é¢è²(åªé对èªå®ä¹ä¸ææ) 26 titleBg: "#ddd", //titleèæ¯é¢è²(åªé对èªå®ä¹ä¸ææ) 27 contentBg: "#fff", //å å®¹èæ¯(åªé对èªå®ä¹ä¸ææ) 28 dashColor: "#ddd", //è线é¢è²(åªé对èªå®ä¹ä¸ææ) 29 btnBg: "#168bbb", //æé®é¢è²(åªé对èªå®ä¹ä¸ææ) 30 iconHoverBg: "red", //å ³éæé®æ¾ä¸å»é¢è²(åªé对èªå®ä¹ä¸ææ) 31 AllColorAuto: false, //æ¯å¦å¯ç¨å ¨å±é¢è²éæºäº§çï¼å¯ç¨åèªå®ä¹çé¢è²å°å®æ(åªé对èªå®ä¹ä¸ææ) 32 callback: function () { }, //声æåè°å½æ° 33 nocallback: function () { } 34 }; 35 var opts = $.extend(true, $.MsgBox.defaults, options); 36 if (!!opts.userDesign && opts.userDesign == !0) { 37 if (!!opts.AllColorAuto && opts.AllColorAuto == !0) { 38 var btnBg = '#' + (Math.random() * 0xffffff << 0).toString(16); 39 var borderColor = '#' + (Math.random() * 0xffffff << 0).toString(16); 40 var titleBg = '#ddd' //䏿¢éæºï¼å½±å飿¬² 41 var contentBg = '#fff'; //䏿¢éæºï¼å½±å飿¬² 42 var dashColor = '#' + (Math.random() * 0xffffff << 0).toString(16); 43 var iconHoverBg = '#' + (Math.random() * 0xffffff << 0).toString(16); 44 } else { 45 var btnBg = opts.btnBg; 46 var borderColor = opts.borderColor; 47 var titleBg = opts.titleBg; 48 var contentBg = opts.contentBg; 49 var dashColor = opts.dashColor; 50 var iconHoverBg = opts.iconHoverBg; 51 } 52 } else { 53 var borderColor = "#009bfe"; 54 var titleBg = "#ddd"; 55 var contentBg = "#fff"; 56 var dashColor = "#ddd"; 57 var btnBg = "#168bbb"; 58 var iconHoverBg = "red"; 59 } 60 (function (opts) { 61 switch (opts.type) { //æ£æ¥ç¨æ·ä¼ è¿æ¥çç±»åï¼ç®ååªå¼åå°alert,confirmä¸¤ç§ 62 case "alert": 63 pageRender("alert", opts.title, opts.msg); 64 btnOk(opts.callback); 65 btnNo(); 66 break; 67 case "confirm": 68 pageRender("confirm", opts.title, opts.msg); 69 btnOk(opts.callback); 70 btnNo(opts.nocallback); 71 break; 72 default: 73 pageRender("alert", 'æ¶æ¯', "ææ¶æªå¼åå ¶ä»åè½ï¼è¯·æç»å ³æ³¨leon.zæä»¶åº"); 74 btnOk(); 75 btnNo(); 76 break; 77 } 78 })(opts); 79 function pageRender(type, title, msg) { /** 渲æé¡µé¢**/ 80 var html = ""; 81 html += '<div id="msg_box"></div><div id="msg_con"><span id="msg_tit">' + title + '</span>'; 82 html += '<a id="msg_ico">x</a><div id="msg_msg">' + msg + '</div><div id="msg_btnbox">'; 83 if (type == "alert") { 84 html += '<input id="msg_btn_ok" type="button" value="' + opts.okBtnText + '" />'; 85 } 86 if (type == "confirm") { 87 html += '<input id="msg_btn_ok" type="button" value="' + opts.okBtnText + '" />'; 88 html += '<input id="msg_btn_no" type="button" value="' + opts.noBtnText + '" />'; 89 } 90 html += '</div></div>';
91 //å¿ é¡»å å°htmlæ·»å å°bodyï¼å设置Cssæ ·å¼ 92 $("body").append(html); 93 renderCss(); //æ¸²ææ ·å¼ 94 }; 95 function renderCss() { 96 var msgBox = document.body.clientWidth > 400 ? 400 : document.body.clientWidth - 10; 97 if (opts.is_changeBg == !0) { 98 $("#msg_box").css({ 99 width: '100%', 100 height: '100%', 101 zIndex: '99999', 102 position: 'fixed', 103 backgroundColor: opts.bgColor, 104 top: '0', 105 left: '0', 106 opacity: opts.opacity, 107 filter: opts.filter 108 }); 109 } else { 110 $("#msg_con").css({ 111 border: "1px solid " + borderColor, 112 boxShadow: "0px 2px 0px " + borderColor 113 }); 114 } 115 $("#msg_con").css({ 116 zIndex: '999999', 117 width: msgBox + 'px', 118 position: 'fixed', 119 backgroundColor: contentBg, 120 borderRadius: '15px', 121 cursor: 'pointer' 122 }); 123 124 $("#msg_tit").css({ 125 display: 'block', 126 fontSize: '14px', 127 color: '#444', 128 padding: '10px 15px', 129 backgroundColor: titleBg, 130 borderRadius: '15px 15px 0 0', 131 borderBottom: '3px solid ' + borderColor, 132 fontWeight: 'bold' 133 }); 134 135 $("#msg_msg").css({ 136 padding: '20px', 137 lineHeight: '20px', 138 borderBottom: '1px dashed ' + dashColor, 139 fontSize: '13px' 140 }); 141 142 $("#msg_ico").css({ 143 display: 'block', 144 position: 'absolute', 145 right: '10px', 146 top: '9px', 147 border: '1px solid Gray', 148 width: '18px', 149 height: '18px', 150 textAlign: 'center', 151 lineHeight: '15px', 152 cursor: 'pointer', 153 borderRadius: '12px', 154 fontFamily: '微软é é»' 155 }); 156 $("#msg_btnbox").css({ 157 margin: '15px 0 10px 0', 158 textAlign: 'center' 159 }); 160 $("#msg_btn_ok,#msg_btn_no").css({ 161 width: '85px', 162 height: '30px', 163 color: 'white', 164 border: 'none', 165 cursor: 'pointer' 166 }); 167 $("#msg_btn_ok").css({ 168 backgroundColor: btnBg 169 }); 170 $("#msg_btn_no").css({ 171 backgroundColor: 'gray', 172 marginLeft: '20px' 173 }); 174 //å³ä¸è§å ³éæé®hoveræ ·å¼ 175 $("#msg_ico").hover(function () { 176 var hoverClass = { 177 "transition-property": "all", 178 "transition-duration": "0.3s", 179 "transition-timing-function": "ease-in", 180 "transition-delay": "0.05s", 181 "backgroundColor": iconHoverBg, 182 "color": "white" 183 } 184 if (window.applicationCache) { //æ¯å¦æ¯æhtml5 transition屿§ 185 $(this).css(hoverClass || {}); 186 } else { 187 $(this).css({ 188 backgroundColor: iconHoverBg, 189 color: 'white' 190 }); 191 } 192 }, function () { 193 $(this).css({ 194 backgroundColor: titleBg, 195 color: 'black' 196 }); 197 }); 198 var _widht = window.screen.clientWidth || document.documentElement.clientWidth; //å±å¹å®½ 199 var _height = window.screen.clientHeight || document.documentElement.clientHeight; //å±å¹é« 200 var msgBoxidth = $("#msg_con").width(); 201 var boxHeight = $("#msg_con").height() + 100; 202 //让æç¤ºæ¡å± ä¸ 203 $("#msg_con").css({ 204 top: (_height - boxHeight) / 2 + "px", 205 left: (_widht - msgBoxidth) / 2 + "px" 206 }); 207 } 208 //ç¡®å®æé®äºä»¶ 209 function btnOk(callback) { 210 $("#msg_btn_ok").click(function () { 211 $("#msg_box,#msg_con").remove(); 212 if (typeof (callback) == 'function') { 213 callback(); 214 } 215 }); 216 } 217 //åæ¶æé®äºä»¶ 218 function btnNo(nocallback) { 219 $("#msg_btn_no,#msg_ico").click(function () { 220 $("#msg_box,#msg_con").remove(); 221 if (typeof (nocallback) == 'function') { 222 nocallback(); 223 } 224 }); 225 } 226 } 227})(jQuery); 228 229//function checkData($form) { 230// var data = {}; 231// var ispass = true; 232// $form.find('input').each(function () { 233// var $this = $(this); 234// var name = $this.attr('name'), value = $this.val(), 235// type = $this.attr('datatype'), nullmsg = $this.attr('nullmsg'), 236// errormsg = $this.attr('errormsg'); 237// if (name == undefined || name == '') return true; 238// if (value == '') { 239// alertMsg(nullmsg); 240// $this.focus(); 241// ispass = false; 242// return false; 243// } else if (type == 'e' && !(/^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/.test(value))) { 244// alertMsg(errormsg); 245// $this.focus(); 246// ispass = false; 247// return false; 248// } else { 249// data[name] = $this.val(); 250// } 251// });
252// function alertMsg(msg) { 253// $.MsgBox({ type: "alert", speed: 200, userDesign: true, borderColor: "red", btnBg: "#e84200", msg: msg }); 254// } 255// if (ispass) { 256// data["token"] = $('#token').val(); 257// submitData(); 258// } 259//}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.