1/** 2 @Name : jeBox v1.0 å¼¹å±ç»ä»¶ 3 @Author: chen guojun 4 @Date: 2016-4-2 5 @QQ群ï¼516754269 6 @å®ç½ï¼http://www.jayui.com/jebox/ æ https://github.com/singod/jeBox 7 */ 8(function(window, undefined) { 9 var document = window.document, toString = {}.toString; 10 //åºç¡åº 11 function selFind(selector, node) { 12 var fors = function(arr, fun){ 13 for (var i = 0;i < arr.length; i++) { 14 if (fun(i, arr[i]) === false) break; 15 } 16 }, 17 getId = function(id) { 18 return document.getElementById(id); 19 }, //è·åCLASSèç¹æ°ç» 20 getClass = function(cls, isNode) { 21 var node = isNode != undefined ? isNode :document, temps = []; 22 var clsall = node.getElementsByTagName("*"); 23 fors(clsall,function(i,cell){ 24 //éåææèç¹ï¼å¤ææ¯å¦æå å«className 25 if (new RegExp("(\\s|^)" + cls + "(\\s|$)").test(cell.className)) temps.push(cell); 26 }) 27 return temps; 28 }, //è·åTAGèç¹æ°ç» 29 getTagName = function(tag, isNode) { 30 var node = isNode != undefined ? isNode :document, temps = [], regCls = /\./.test(tag), regTag = /\=/.test(tag), 31 tagCls = regTag ? tag.match(/\w+\[([\w\-_][^=]+)=([\'\[\]\w\-_]+)\]/) :tag.split("."); 32 var tags = node.getElementsByTagName(regCls ? tagCls[0] : tagCls[0].split("[")[0]); 33 if ((regCls && tagCls[1] != undefined) || regTag) { 34 var clsn = regCls ? tagCls[1] : tagCls, 35 clas = /MSIE (6|7)/i.test(navigator.userAgent) ? "className" :"class", 36 atts = regCls ? clas :clsn[1], clsof = regCls ? clsn :clsn[2]; 37 fors(tags,function(i,cell){ 38 if (new RegExp(clsof).test(cell.getAttribute(atts))) temps.push(cell); 39 }) 40 } else { 41 fors(tags,function(i,cell){ temps.push(cell); }) 42 } 43 return temps; 44 }; 45 //å建ä¸ä¸ªæ°ç»ï¼ç¨æ¥ä¿åè·åçèç¹æèç¹æ°ç» 46 var thatElem = this.elements = []; 47 //å½åæ°æ¯ä¸ä¸ªå符串ï¼è¯´ææ¯å¸¸è§csséæ©å¨ï¼ä¸æ¯this,æè function 48 if (typeof selector == "string") { 49 selector = selector.replace(/(^\s*)|(\s*$)/g, ""); 50 //css模æï¼å°±æ¯è·CSSå代鿩å¨ä¸æ · 51 var sj = /\s+/g, args = /\>/.test(selector) ? selector.replace(/([ \t\r\n\v\f])*>([ \t\r\n\v\f])*/g, ">").replace(/\>/g, " ").replace(sj, " ") :selector.replace(sj, " "), 52 expId = /^\#/, expCls = /^\./; 53 if (/\,/.test(args)) { 54 var argspl = args.split(/,/g), len = argspl.length; 55 for (var idx = 0; idx < len; ++idx) thatElem = thatElem.concat(selFind(argspl[idx])); 56 }else if (/\s*/.test(args)) { 57 //æèç¹æåå¼å¹¶ä¿å卿°ç»é 58 var elements = args.split(" "); 59 //忾䏴æ¶èç¹å¯¹è±¡çæ°ç»ï¼è§£å³è¢«è¦çé®é¢ 60 var tempNode = [], node = []; 61 //ç¨æ¥åæ¾ç¶èç¹ç¨ç 62 fors(elements,function(i,elems){ 63 //妿é»è®¤æ²¡æç¶èç¹ï¼å°±æå®document 64 if (node.length == 0) node.push(document); 65 var elmSub = elems.substring(1) 66 tempNode = []; 67 if(expId.test(elems)){ //id 68 tempNode.push(getId(elmSub)); 69 }else if(expCls.test(elems)){ //class 70 fors(node,function(j,nd){ 71 fors(getClass(elmSub, nd),function(k,tp){ tempNode.push(tp); }) 72 }) 73 }else{ //tag 74 fors(node,function(j,nd){ 75 fors(getTagName(elems, nd),function(k,tp){tempNode.push(tp); }) 76 }) 77 } 78 node = tempNode; 79 }) 80 thatElem = tempNode; 81 } else { 82 //find模æ,å°±æ¯è¯´åªæ¯åä¸çéæ©å¨ 83 var argSub = args.substring(1); 84 if(expId.test(args)){ //id 85 thatElem.push(getId(argSub)); 86 }else if(expCls.test(args)){ //class 87 thatElem = getClass(argSub); 88 }else{ //tag 89 thatElem = getTagName(args); 90 } 91 } 92 } else if (typeof args == "Object") { 93 if (args != undefined) { 94 thatElem[0] = args; 95 } 96 } 97 return thatElem; 98 } 99 var JED = function(args, node) { 100 var newJED = new JED.fn.init(args, node); 101 return newJED; 102 }; 103 JED.extend = function() { 104 var _extend = function me(dest, source) { 105 for (var name in dest) { 106 if (dest.hasOwnProperty(name)) { 107 //å½å屿§æ¯å¦ä¸ºå¯¹è±¡,å¦æä¸ºå¯¹è±¡ï¼åè¿è¡éå½ 108 if (dest[name] instanceof Object && source[name] instanceof Object) { 109 me(dest[name], source[name]); 110 } 111 //æ£æµè¯¥å±æ§æ¯å¦åå¨ 112 if (source.hasOwnProperty(name)) { 113 continue; 114 } else { 115 source[name] = dest[name]; 116 } 117 } 118 } 119 }; 120 var _result = {}, arr = arguments; 121 //éå屿§ï¼è³ååå 122 if (!arr.length) return {}; 123 for (var i = arr.length - 1; i >= 0; i--) { 124 _extend(arr[i], _result); 125 } 126 arr[0] = _result; 127 return _result; 128 }; 129 JED.each = function(arr, fun) { 130 var i = 0, len = arr.length; 131 for (;i < len; i++) { 132 if (fun(i, arr[i]) === false) break; 133 } 134 }; 135 JED.isType = function(obj, type) { 136 var types = type.replace(/\b(\w)|\s(\w)/g, function(m) { 137 return m.toUpperCase(); 138 }); 139 return Object.prototype.toString.call(obj) === "[object " + types + "]"; 140 }; 141 JED.inArray = function(elem, arr, i) { 142 var core_indexOf = Array.prototype.indexOf; 143 if (arr) { 144 if (core_indexOf) return core_indexOf.call(arr, elem, i); 145 var len = arr.length; 146 i = i ? i < 0 ? Math.max(0, len + i) :i :0; 147 for (;i < len; i++) { 148 if (i in arr && arr[i] === elem) return i; 149 } 150 } 151 return -1; 152 }; 153 // æ¸ é¤æ°ç»ä¸éå¤çæ°æ® 154 JED.unique = function(arr) { 155 var rets = [], i = 0, len = arr.length; 156 if (JED.isType(arr, "array")) { 157 for (;i < len; i++) { 158 if (JED.inArray(arr[i], rets) === -1) rets.push(arr[i]); 159 } 160 } 161 return rets; 162 }; 163 JED.merge = function(first, second) { 164 var sl = second.length, i = first.length, j = 0; 165 if (JED.isType(sl, "number")) { 166 for (;j < sl; j++) { 167 first[i++] = second[j]; 168 } 169 } else { 170 while (second[j] !== undefined) { 171 first[i++] = second[j++]; 172 } 173 } 174 first.length = i; 175 return first; 176 }; 177 JED.trim = function(str) { 178 return str.replace(/(^\s*)|(\s*$)/g, ""); 179 }; 180 JED.fn = JED.prototype = { 181 init:function(selector, node) { 182 if (!selector) return this; 183 if (selector.nodeType) { 184 this.node = this[0] = selector; 185 this.length=1; 186 return this; 187 } 188 if(selector != null && selector == selector.window){ 189 this.context = this[0] = window; 190 this.length=1; 191 return this; 192 } 193 if (selector === "body" && document.body) { 194 this.node = document; 195 this[0] = document.body; 196 this.selector = selector; 197 this.length=1; 198 return this; 199 } 200 if (typeof selector === "string") { 201 node = node || document; 202 var selSize = selFind(selector, node), rets = []; 203 for (var i = 0; i < selSize.length; i++) { 204 rets.push(selSize[i]); 205 } 206 return JED(this).pushStack(rets); 207 } 208 return this; 209 }, 210 find:function(selector) { 211 return JED(selector, this); 212 }, 213 size:function() { 214 return this.length; 215 }, 216 each:function(callback) { 217 JED.each(this, callback); 218 return this; 219 }, 220 pushStack:function(elems) { 221 var obj = JED(), i = 0, len = elems.length; 222 for (;i < len; i++) { 223 obj[i] = elems[i]; 224 } 225 obj.length = len; 226 return obj;
227 }, 228 css:function(name, value) { 229 var that = this, obj = arguments[0]; 230 if (typeof name == "string" && typeof value == "string") { 231 return that.each(function(i, elem) { elem.style[name] = value; }); 232 } else if (typeof name == "string" && typeof value === "undefined") { 233 if (that.size() == 0) return null; 234 var ele = this[0], JeS = function() { 235 var def = document.defaultView; 236 return new Function("el", "style", [ "style.indexOf('-')>-1 && (style=style.replace(/-(\\w)/g,function(m,a){return a.toUpperCase()}));", "style=='float' && (style='", def ? "cssFloat" :"styleFloat", "');return el.style[style] || ", def ? "window.getComputedStyle(el, null)[style]" :"el.currentStyle[style]", " || null;" ].join("")); 237 }(); 238 return JeS(ele, name); 239 } else { 240 return that.each(function(i, elem) { 241 for (var k in obj) elem.style[k] = obj[k]; 242 }); 243 } 244 }, 245 hasClass:function(selector) { 246 var className = " " + selector + " ", i = 0, len = this.length; 247 for ( ; i < len; i++ ) { 248 if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(/[\n\t\r]/g, " ").indexOf( className ) > -1 ) return true; 249 } 250 return false; 251 }, 252 // æ·»å æ ·å¼ç±» 253 addClass:function(name) { 254 if (!this.hasClass(name)) this[0].className = JED.trim(this[0].className + " " + name + " "); 255 return this; 256 }, 257 // ç§»é¤æ ·å¼ç±» 258 removeClass:function(name) { 259 var elem = this[0]; 260 if (!name) { 261 elem.className = ""; 262 } else if (this.hasClass(name)) { 263 elem.className = JED.trim((" " + elem.className + " ").replace(" " + name + " ", " ")); 264 } 265 return this; 266 }, 267 // è·åææåèç¹ 268 contents:function() { 269 var elems, i = 0, len = this.length, rets = []; 270 for (;i < len; i++) { 271 rets = JED.merge(rets, this[i].childNodes); 272 } 273 // æé 274 rets = JED.unique(rets); 275 return this.pushStack(rets); 276 }, 277 //è·åå½åå ç´ çåæ 278 position:function() { 279 if (this.size() == 0) return null; 280 var elem = this[0]; 281 return { left:elem.offsetLeft, top:elem.offsetTop }; 282 }, 283 // å ç´ å宽度 284 width:function(value) { 285 if (value == undefined) { 286 return getWidthOrHeight(this, "width"); 287 } else { 288 this.css("width", typeof value === "number" ? value + "px" :value); 289 } 290 return this; 291 }, 292 // å ç´ åé«åº¦ 293 height:function(value) { 294 if (value == undefined) { 295 return getWidthOrHeight(this, "height"); 296 } else { 297 this.css("height", typeof value === "number" ? value + "px" :value); 298 } 299 return this; 300 }, 301 //è·åä¸è®¾ç½®ï¼èªå®ä¹å±æ§ 302 attr:function(name, value) { 303 var that = this[0], ret; 304 if (typeof value === "undefined") { 305 if (that && that.nodeType === 1) { 306 ret = that.getAttribute(name); 307 } 308 // 屿§ä¸åå¨ï¼è¿åundefined 309 return ret == null ? undefined :ret; 310 } 311 return this.each(function(i, elem) { 312 if (elem.nodeType === 1) elem.setAttribute(name, value); 313 }); 314 }, 315 // 读å设置èç¹å 容 316 html:function(value) { 317 var that = this[0]; 318 return typeof value === "undefined" ? that && that.nodeType === 1 ? that.innerHTML :undefined :typeof value !== "undefined" && value == true ? that && that.nodeType === 1 ? that.outerHTML :undefined :this.each(function(i, elem) { 319 elem.innerHTML = value; 320 }); 321 }, 322 // 读å设置èç¹ææ¬å 容 323 text:function(value) { 324 var that = this[0]; 325 var innText = document.all ? "innerText" :"textContent"; 326 return typeof value === "undefined" ? that && that.nodeType === 1 ? that[innText] :undefined :this.each(function(i, elem) { 327 elem[innText] = value; 328 }); 329 }, 330 // 读å设置表åå ç´ çå¼ 331 val:function(value) { 332 var that = this[0]; 333 if (typeof value === "undefined") { 334 return that && that.nodeType === 1 && typeof that.value !== "undefined" ? that.value :undefined; 335 } 336 // å°value转å为string 337 value = value == null ? "" :value + ""; 338 return this.each(function(i, elem) { 339 if (typeof elem.value !== "undefined") { 340 elem.value = value; 341 } 342 }); 343 },
344 bind:function(type, fn) { 345 return this.each(function(i, elem) { 346 elem.attachEvent ? elem.attachEvent("on" + type, function() { 347 fn.call(elem, window.type); 348 }) :elem.addEventListener(type, fn, false); 349 }); 350 } 351 }; 352 // 宽é«å±æ§åä½auto转å 353 function getWidthOrHeight(elem, name) { 354 // å°æ ·å¼å±æ§è½¬ä¸ºé©¼å³°å¼ 355 function camelCase(name) { 356 return name.replace(/\-(\w)/g, function(all, letter) { 357 return letter.toUpperCase(); 358 }); 359 } 360 var padding = name === "width" ? [ "left", "right" ] :[ "top", "bottom" ], ret = elem[0][camelCase("offset-" + name)]; 361 if (ret <= 0 || ret == null) { 362 ret = parseFloat(elem[0][camelCase("client-" + name)]) - parseFloat(elem.css("padding-" + padding[0]) || 0) - parseFloat(elem.css("padding-" + padding[1]) || 0); 363 } 364 return ret; 365 } 366 JED.fn.init.prototype = JED.fn; 367 window.JED = $D = JED; 368})(window); 369 370//æ ¸å¿å¼¹å±ä»£ç 371(function($D, win, undefined) { 372 var doc = document, docBody = document.body, docEle = document.documentElement, jeBox = {}, jeyer = {}, 373 regPxe = /\px|em/g, isIE = !-[ 1 ], isIE6 = /msie 6/.test(navigator.userAgent.toLowerCase()); 374 jeBox.index = Math.floor(Math.random() * 9e3); 375 //ç¼å常ç¨å符 376 var doms = ["jeBox",".jeBox-wrap",".jeBox-header",".jeBox-content",".jeBox-footer",".jeBox-close",".jeBox-maxbtn"]; 377 jeyer.endfun = {}; 378 var config = { 379 cell:"", // ç¬ç«ID,ç¨äºæ§å¶å¼¹å±å¯ä¸æ è¯ 380 title:"æç¤ºä¿¡æ¯", // æ é¢,åæ°ä¸ï¼æç¤ºæåï¼åæ°äºï¼æç¤ºæ¡æ ·å¼ ["æç¤ºä¿¡æ¯",{color:"#ff0000"}] 381 content:"ææ å 容ï¼", // å 容 382 boxStyle:{}, //设置弹å±çæ ·å¼ 383 closeBtn:true, // æ é¢ä¸çå ³éæé® 384 maxBtn:false, //æ¯å¦å¼å¯æå¤§åæé® 385 area:"auto", // åæ°ä¸ï¼å¼¹å±å®½åº¦ï¼åæ°äºï¼ å¼¹å±é«åº¦ 386 padding:"5px", // èªå®ä¹è¾¹è· 387 offset:[ "auto", "auto" ], //åæ è½´ 388 type:1, // æ¾ç¤ºåºæ¬å±ç±»å 389 icon:0, // 徿 ,ä¿¡æ¯æ¡åå è½½å±çç§æåæ° 390 button:[], // åæé® 391 yesfun:null, // ç¡®å®æé®åè°æ¹æ³ 392 nofun:null, // åæ¶åå ³éæé®è§¦åçåè° 393 time:0, // èªå¨å ³éæ¶é´(ç§),0表示ä¸èªå¨å ³é 394 masklock:true, // æ¯å¦å¼å¯é®ç½©å± 395 maskClose:false, // ç¹å»é®ç½©å±æ¯å¦å¯ä»¥å ³é 396 maskColor:[ "#000", .5 ], // åæ°ä¸ï¼é®ç½©å±é¢è²ï¼åæ°äºï¼é®ç½©å±éæåº¦ 397 isDrag:true, // æ¯å¦å¯ä»¥ææ½ 398 fixed:true, // æ¯å¦éæ¢å®ä½ 399 zIndex:9999, // å¼¹å±å±çº§å ³ç³» 400 scrollbar:true, // æ¯å¦å 许æµè§å¨åºç°æ»å¨æ¡ 401 shadow:true, //ææ½é£æ ¼ 402 success:null, // å±å¼¹åºåçæååè°æ¹æ³ 403 endfun:null 404 }; 405 //æ ¸å¿æ¹æ³ 406 var jeConCell, Dialog = function(options) { 407 var that = this; 408 that.config = $D.extend(config, options || {}); 409 that.index = that.config.cell != "" ? that.config.cell :++jeBox.index; 410 jeConCell = that.config.content; 411 that.initView(); 412 }; 413 Dialog.prototype = { 414 //åå§åå¼¹å± 415 initView:function() { 416 var that = this, opts = that.config; jeyer.scrollbar = opts.scrollbar; 417 //夿IDæ¯å¦å·²ç»åå¨ 418 if (opts.cell != "" && $D("#"+ doms[0] + that.index)[0]) return; 419 //å建æé®æ¨¡æ¿ 420 var btnHtml = function() { 421 var btnStrA = opts.button ? function() { 422 var butArr = []; 423 typeof opts.button === "array" && (opts.button = [ opts.button ]); 424 for (var i = 0; i < opts.button.length; i++) { 425 var isDisabled = opts.button[i].hasOwnProperty("disabled") && opts.button[i].disabled == true ? "disabled" :""; 426 butArr.push('<button type="button" class="jeBox-btn' + i + '" jebtn="' + i + '" ' + isDisabled + ">" + opts.button[i].name + "</button>"); 427 } 428 return butArr.reverse().join(""); 429 }() :""; 430 return '<div class="jeBox-footer">' + btnStrA + "</div>"; 431 }(); 432 //å建é»è®¤çå¼¹åºå±å å®¹æ¨¡æ¿ 433 var templates = '<span class="jeBox-headbtn"><a href="javascript:;" class="jeBox-maxbtn"></a><a href="javascript:;" class="jeBox-close" title="关闭">×</a></span>' + '<div class="jeBox-header"></div>' + '<div class="jeBox-content" style="padding:' + (opts.padding != "" ? opts.padding :0) + ';"></div>' + btnHtml; 434 //å建弹çªå¤é¨DIV 435 var getZindex = function(elem) { 436 var maxZindex = 0; 437 for (z = 0; z < elem.length; z++) { 438 maxZindex = Math.max(maxZindex, elem[z].style.zIndex); 439 } 440 return maxZindex; 441 }, WarpCls = $D(doms[1]); 442 //计ç®å±çº§å¹¶ç½®é¡¶ 443 var Zwarp = WarpCls[0] ? getZindex(WarpCls) + 5 :opts.zIndex + 5, Zmask = WarpCls[0] ? getZindex(WarpCls) + 2 :opts.zIndex, 444 divBox = document.createElement("div"), maskBox = document.createElement("div"); 445 that.id = divBox.id = doms[0] + that.index; 446 divBox.className = doms[1].replace(/\./g,""); 447 divBox.style.position = opts.fixed ? "fixed" :"absolute"; 448 divBox.style.zIndex = Zwarp; 449 divBox.innerHTML = templates; 450 divBox.setAttribute("jeb", that.index); 451 $D("body")[0].appendChild(divBox); 452 //æ¯å¦å¼å¯é®ç½©å± 453 if (opts.masklock) { 454 that.mask = maskBox.id = "jemask" + that.index; 455 maskBox.className = "jeBox-mask"; 456 maskBox.style.cssText = "left:0;top:0;background-color:" + opts.maskColor[0] + ";z-index:" + Zmask + ";opacity:" + opts.maskColor[1] + ";filter:alpha(opacity=" + opts.maskColor[1] * 100 + ");"; 457 $D("body")[0].appendChild(maskBox); 458 } 459 var thatID = "#" + that.id, isTitle = opts.title == false || opts.title == "false", 460 titType = typeof opts.title === "object", msgTitle = titType ? opts.title :[ opts.title, {} ], 461 isBtn = opts.btn == "" && opts.btn == null; 462 $D(thatID + " "+ doms[2]).html(isTitle ? "" :msgTitle[0]).css({ display:isTitle ? "none" :"", height:isTitle ? "0px" :"" }).css(msgTitle[1]); 463 $D(thatID + " "+ doms[4]).css({ display:isBtn ? "none" :"", height:isBtn ? "0px" :"" }); 464 $D(thatID + " "+ doms[5]).css("display", opts.closeBtn ? "" :"none"); 465 $D(thatID + " "+ doms[6]).css("display", opts.maxBtn ? "" :"none"); 466 !opts.scrollbar && $D("body").css("overflow", "hidden"); 467 that.content(opts).layerSize(opts).position(opts).btnCallback(opts); 468 if (opts.isDrag) { 469 var wrapCell = $D(thatID), titCell = $D(thatID + " "+ doms[2]); 470 that.dragLayer(wrapCell, titCell, .4, opts.shadow); 471 } 472 setTimeout(function() { 473 opts.success && opts.success($D(thatID),that.index); 474 }, 1); 475 }, 476 //设置å 容 477 content:function(opts) {
478 var that = this, conCell = $D("#" + that.id + " "+ doms[3]), msg = opts.content, conType = typeof msg === "object"; 479 iconMsg = '<div class="jeBox-iconbox jeicon' + opts.icon + '">' + msg + "</div>"; 480 switch (opts.type) { 481 case 1: 482 if (typeof msg === "string") { 483 conCell.html(opts.icon !== 0 ? iconMsg :msg); 484 } else if (msg && msg.nodeType === 1) { 485 //æ¥è¯¢ä¼ å ¥çä½ç½® 486 jeyer.Dispy = msg.style.display; 487 jeyer.Prev = msg.previousSibling; 488 jeyer.Next = msg.nextSibling; 489 jeyer.Parent = msg.parentNode; 490 var tempWrap = document.createElement("div"); 491 if (msg.style.display == "none") msg.style.display = "block"; 492 //æå·²ç¥çhtmlçæ®µå 裹并æå ¥å°å¼¹å±ä¸ 493 conCell[0].appendChild(tempWrap.appendChild(msg)); 494 } 495 break; 496 497 case 2: 498 var conMsg = conType ? msg :[ msg || "http://www.jayui.com/", "auto" ]; 499 conCell.html('<iframe scrolling="' + (conMsg[1] || "auto") + '" allowtransparency="true" id="jeboxiframe' + that.index + '" name="' + that.index + '" onload="this.className=\'\';" frameborder="0" width="100%" height="100%" src="' + conMsg[0] + '"></iframe>'); 500 break; 501 502 case 3: 503 conCell.html('<div class="jeBox-loadbox jeload' + opts.icon + '">' + msg + "</div>"); 504 break; 505 } 506 return that; 507 }, 508 //设置弹å±å°ºå¯¸ 509 layerSize:function(opts) { 510 var that = this, fixW = "", fixH = "", WarpID = "#" + that.id, wrapWidth, wrapHeight, conWidth, conHeight, conCell = $D(WarpID + " "+ doms[3]), 511 docW = docEle.clientWidth, docH = docEle.clientHeight, conhead = jeyer.conhead = $D(WarpID + " "+ doms[2]).height(), confoot = jeyer.confoot = $D(WarpID + " "+ doms[4]).height(), 512 Padtb = jeyer.getPads(conCell, "padding-top") + jeyer.getPads(conCell, "padding-bottom"), Padlr = jeyer.getPads(conCell, "padding-left") + jeyer.getPads(conCell, "padding-right"); 513 opts.area.length == 1 ? (fixW = opts.area, fixH = opts.area) : (fixW = opts.area[0], fixH = opts.area[1]); 514 //设置å±ç宽度 515 if ($D.isType(opts.area, "array")) { 516 if ($D.isType(fixW, "number")) { 517 wrapWidth = fixW; 518 } else if (fixW == "auto") { 519 wrapWidth = conWidth = "auto"; 520 } else { 521 var bfW = /^\d+%$/.test(fixW.toString()) ? parseInt(docW * (fixW.replace("%", "") / 100)) :parseInt(fixW.replace(regPxe, "")), nPerW = bfW >= docW ? docW :bfW; 522 wrapWidth = nPerW + "px"; 523 conWidth = nPerW - Padlr + "px"; 524 } 525 } 526 //设置å±çé«åº¦ 527 if ($D.isType(opts.area, "array")) { 528 if ($D.isType(fixH, "number")) { 529 wrapHeight = fixH; 530 } else if (fixH == "auto") { 531 wrapHeight = conHeight = "auto"; 532 } else { 533 var bfH = /^\d+%$/.test(fixH.toString()) ? parseInt(docH * (fixH.replace("%", "") / 100)) :parseInt(fixH.replace(regPxe, "")), nPerH = bfH >= docH ? docH :bfH; 534 wrapHeight = nPerH + "px"; 535 conHeight = nPerH - Padtb - conhead - confoot + "px"; 536 } 537 } 538 opts.maxBtn && $D(WarpID).attr("area", [ wrapWidth, wrapHeight, conWidth, conHeight ].toString().replace(regPxe, "")); 539 $D(WarpID).css({ width:wrapWidth, height:wrapHeight }).css(opts.boxStyle); 540 $D(WarpID + " "+ doms[3]).css({ width:conWidth, height:conHeight }); 541 return that; 542 }, 543 //å®ä½å±æ¾ç¤ºçä½ç½® 544 position:function(opts) { 545 var that = this, PosID = $D("#" + that.id), elemtr, elembl, isOffsetArr = $D.isType(opts.offset, "array"), 546 Postr = opts.offset[0], Posbl = opts.offset[1], dcWidth = docEle.clientWidth, dcHeight = docEle.clientHeight, 547 eleW = PosID.width(), eleH = PosID.height(); 548 elemtr = (isOffsetArr && /^\@/.test(Postr)) ? 549 Postr.replace(/\@/g, "") : ((Postr == "auto") ? (dcHeight - eleH) / 2 + "px" : /^\d+%$/.test(Postr) ? Postr :Postr.replace(regPxe, "") + "px"); 550 elembl = (isOffsetArr && /^\@/.test(Posbl)) ? 551 Posbl.replace(/\@/g, "") : ((Posbl == "auto") ? (dcWidth - eleW) / 2 + "px" : /^\d+%$/.test(Posbl) ? Posbl :Posbl.replace(regPxe, "") + "px"); 552 553 isOffsetArr && (/^\@/.test(Postr) || /^\@/.test(Posbl)) ? PosID.css({ right:elemtr, bottom:elembl }) : PosID.css({ top:elemtr, left:elembl }); 554 opts.maxBtn && PosID.attr("offset", [ PosID.position().top, PosID.position().left ]);
555 return that; 556 }, 557 //åå ³éæé®çäºä»¶ 558 btnCallback:function(opts) { 559 var that = this, CallID = "#" + that.id, maxBtn = $D(CallID + " "+ doms[6]); 560 //èªå¨å ³é 561 opts.time <= 0 || setTimeout(function() { 562 jeBox.close(that.index); 563 }, opts.time * 1e3); 564 function cancel() { 565 var close = opts.nofun && opts.nofun(that.index); 566 close === false || jeBox.close(that.index); 567 } 568 //å ³éæé®äºä»¶ 569 opts.closeBtn && $D(CallID + " "+ doms[5]).bind("click", cancel); 570 //æå¤§åæé® 571 opts.maxBtn && maxBtn.bind("click", function() { 572 if (maxBtn.hasClass("revert")) { 573 maxBtn.removeClass("revert"); 574 jeBox.restore(that.index); 575 } else { 576 maxBtn.addClass("revert"); 577 jeBox.full(that.index); 578 } 579 }); 580 //æ´å¤æé® 581 opts.button && $D(CallID + " "+ doms[4]).find("button").bind("click", function() { 582 var index = parseInt($D(this).attr("jebtn")); 583 if (index === 0) { 584 opts.yesfun ? opts.yesfun(that.index, $D(CallID)) :jeBox.close(that.index); 585 } 586 if (opts.button.length > 1) { 587 if (index === 1) { 588 cancel(); 589 } else { 590 opts.button[index]["callback"] && opts.button[index]["callback"](that.index, $D(CallID)); 591 opts.button[index]["callback"] || jeBox.close(that.index); 592 } 593 } 594 }); 595 //ç¹é®ç½©å ³é 596 opts.maskClose && $D("#jemask" + that.index).bind("click", function() { 597 jeBox.close(that.index); 598 }); 599 //èªéåº 600 $D(window).bind("resize",function() { 601 if ($D.isType(opts.offset, "array") && (/^\@/.test(opts.offset[0]) || /^\@/.test(opts.offset[1]))) { 602 $D(CallID).css({ top:"", left:"" }); 603 } 604 that.layerSize(opts).position(opts); 605 }); 606 opts.endfun && (jeyer.endfun[that.index] = opts.endfun); 607 return that; 608 }, 609 //ææ½äºä»¶ 610 dragLayer:function(warpCell, titCell, opacityVal, isShadow) { 611 var that = this, isIES = !-[ 1 ]; 612 titCell = titCell || warpCell; 613 that.tmpX = that.tmpY = 0; 614 that.isMoveable = false; 615 titCell[0].style.cursor = "move"; 616 if (isShadow) { 617 that.isShadow = isShadow ? isShadow == true || isShadow == false ? isShadow :false :false; 618 if (that.isShadow) that.opacity = opacityVal; 619 } else { 620 that.opacity = 100, that.isShadow = false; 621 } 622 that.tempLayer = document.createElement("div"); 623 titCell[0].onmousedown = function(event) { 624 var event = event || window.event; 625 //åªå 许éè¿é¼ æ å·¦é®è¿è¡ææ½,IEé¼ æ å·¦é®ä¸º1 FireFox为0 626 if (isIES && event.button != 1 || isIES && event.button == 0) return false; 627 //åå»ºä¸´æ¶æå¨å± 628 if (that.isShadow) { 629 that.tempLayer.style.cssText = "width : " + (warpCell[0].offsetWidth - 4) + "px;height : " + (warpCell[0].offsetHeight - 4) + "px;left : " + warpCell[0].offsetLeft + "px;top : " + warpCell[0].offsetTop + "px;opacity:" + that.opacity + ";filter:alpha(opacity=" + that.opacity * 100 + ");z-Index : 29860813;"; 630 that.tempLayer.className = "jeBox-moves"; 631 warpCell[0].parentNode.appendChild(that.tempLayer); 632 } 633 that.isMoveable = true; 634 that.tmpX = event.clientX - warpCell[0].offsetLeft; 635 that.tmpY = event.clientY - warpCell[0].offsetTop; 636 //FireFox å»é¤å®¹å¨å ææ½å¾çé®é¢ 637 if (event.preventDefault) { 638 event.preventDefault(); 639 event.stopPropagation(); 640 } 641 document.onmousemove = function(event) { 642 if (!that.isMoveable) return; 643 window.getSelection ? window.getSelection().removeAllRanges() :document.selection.empty(); 644 //æ§å¶å ç´ ä¸è¢«æåºçªå£å¤ 645 var event = event || window.event, elemCopy = that.isShadow ? that.tempLayer :warpCell, 646 DmpX = event.clientX - that.tmpX, DmpY = event.clientY - that.tmpY, 647 maxW = docEle.clientWidth - warpCell[0].offsetWidth, maxH = docEle.clientHeight - warpCell[0].offsetHeight; 648 DmpX <= 0 && (DmpX = 0); 649 DmpY <= 0 && (DmpY = 0); 650 DmpX >= maxW && (DmpX = maxW); 651 DmpY >= maxH && (DmpY = maxH); 652 elemCopy.style.top = DmpY + "px"; 653 elemCopy.style.left = DmpX + "px"; 654 }; 655 document.onmouseup = function() { 656 if (that.isMoveable) { 657 that.isMoveable = false; 658 that.tmpX = that.tmpY = 0; 659 warpCell.css({ right:"", bottom:"" }); 660 if (that.isShadow) { 661 //夿并æèæ¡çä½ç½®ä¿¡æ¯ä¼ ç»å¼¹å± 662 warpCell.css({ 663 top:that.tempLayer.offsetTop + "px", 664 left:that.tempLayer.offsetLeft + "px" 665 }); 666 //夿并å 餿°å建çèæ¡ 667 docBody.removeChild(that.tempLayer); 668 } 669 if (docEle.clientWidth != warpCell[0].offsetWidth) { 670 warpCell.attr("offset", [ warpCell[0].offsetTop, warpCell[0].offsetLeft ]); 671 } 672 } 673 }; 674 }; 675 return that; 676 } 677 }; 678 //è·åå è¾¹è· 679 jeyer.getPads = function(cell, name) { 680 return parseInt(cell.css(name).replace(regPxe, "")); 681 } 682 //è·åçªå£å¤§å° 683 jeyer.docSize = function(name) {
684 var dowSize, inner = [ "inner" + name ], client = [ "client" + name ]; 685 if (window[inner]) { 686 dowSize = window[inner]; 687 } else if (docBody && docBody[client]) { 688 dowSize = docBody[client]; 689 } 690 // éè¿æ·±å ¥ Document å é¨å¯¹ body è¿è¡æ£æµï¼è·åçªå£å¤§å° 691 if (docEle && docEle[client]) { 692 dowSize = docEle[client]; 693 } 694 return dowSize; 695 } 696 //弹屿 ¸å¿ 697 jeBox.open = function(opts) { 698 var jedia = new Dialog(opts || {}) 699 return jedia.index; 700 }; 701 //å ³éæå®å± 702 jeBox.close = function(idx) { 703 var boxCell = $D("#"+ doms[0] + idx)[0], maskCell = $D("#jemask" + idx)[0]; 704 if (!boxCell) return; 705 if (jeConCell && jeConCell.nodeType === 1) backSitu(jeConCell, jeyer.Prev, jeyer.Next, jeyer.Parent, jeyer.Dispy); 706 docBody.removeChild(boxCell); 707 maskCell && docBody.removeChild(maskCell); 708 $D("body").css("overflow") == "hidden" && $D("body").css("overflow", ""); 709 typeof jeyer.endfun[idx] === 'function' && jeyer.endfun[idx](); 710 delete jeyer.endfun[idx]; 711 }; 712 //å ³éææå± 713 jeBox.closeAll = function() { 714 $D(doms[1]).each(function(i, elem) { 715 jeBox.close(elem.getAttribute("jeb")); 716 }); 717 }; 718 //çæ¬ 719 jeBox.version = "1.0"; 720 //æ¹åå½åå¼¹å±title 721 jeBox.title = function(name, idx) { 722 $D("#"+ doms[0] + idx + " "+ doms[2]).html(name); 723 }; 724 //æ¹åå½åå¼¹å±å 容 725 jeBox.content = function(content, idx) { 726 $D("#"+ doms[0] + idx + " "+ doms[3]).html(content); 727 }; 728 //æå¸¸ç¨æç¤ºå± 729 jeBox.msg = function(content, options, end) { 730 var type = typeof options === "function"; 731 if (type) end = options; 732 return jeBox.open($D.extend({ 733 title:false, 734 content:content, 735 padding:"10px", 736 boxStyle:{ background:"#fff", border:"1px solid #e3e3e3", "border-radius":"4px", color:"#333", opacity:"0.93", filter:"alpha(opacity=90)" }, 737 time:3, 738 masklock:false, 739 closeBtn:false, 740 end:end 741 }, !type && function() { 742 options = options || {}; 743 return options; 744 }())); 745 }; 746 jeBox.alert = function(content, options, yes) { 747 var type = typeof options === "function"; 748 if (type) yes = options; 749 return jeBox.open($D.extend({ 750 content:content, 751 yesfun:yes, 752 button:[ { name:"ç¡®å®" } ] 753 }, type ? {} :options)); 754 }; 755 jeBox.loading = function(icon, content, options) { 756 return jeBox.open($D.extend({ 757 title:false, 758 closeBtn:false, 759 type:3,
760 masklock:false, 761 content:content == undefined ? "" : content, 762 icon:icon || 1, 763 boxStyle:{ background:"#fff", border:"1px solid #fff", "border-radius":"4px", color:"#111", opacity:"0.93", filter:"alpha(opacity=90)" } 764 }, options)); 765 }; 766 //è¿å 767 jeBox.restore = function(index){ 768 var CallID = $D("#"+ doms[0] + index), callCon = $D("#"+ doms[0] + index + " "+ doms[3]), 769 revArea = CallID.attr("area").split(/,/g), revOffset = CallID.attr("offset").split(/,/g); 770 $D("body").css('overflow',jeyer.scrollbar == false ? 'hidden' : ''); 771 CallID.css({ 772 width:revArea[0] + "px", height:revArea[1] + "px", 773 top:revOffset[0] + "px", left:revOffset[1] + "px", 774 right:"", bottom:"" 775 }); 776 callCon.css({ width:revArea[2] + "px", height:revArea[3] + "px" }); 777 } 778 //å ¨å± 779 jeBox.full = function(index){ 780 var timer, CallID = $D("#"+ doms[0] + index), callCon = $D("#"+ doms[0] + index + " "+ doms[3]), 781 warpMagtb = jeyer.getPads(CallID, "borderTopWidth") + jeyer.getPads(CallID, "borderBottomWidth"), 782 warpMaglr = jeyer.getPads(CallID, "borderLeftWidth") + jeyer.getPads(CallID, "borderRightWidth"), 783 conPadtb = jeyer.getPads(callCon, "padding-top") + jeyer.getPads(callCon, "padding-bottom"), 784 conPadlr = jeyer.getPads(callCon, "padding-left") + jeyer.getPads(callCon, "padding-right"); 785 $D("body").css('overflow','hidden'); 786 clearTimeout(timer); 787 timer = setTimeout(function(){ 788 $D(CallID + " "+ doms[6]).addClass("revert"); 789 var isfix = CallID.css('position') === 'fixed', offset = CallID.attr("offset").split(/,/g), 790 docWidth = jeyer.docSize("Width"), docHeight = jeyer.docSize("Height"); 791 CallID.css({ 792 width:docWidth - warpMagtb + "px", 793 height:docHeight - warpMaglr + "px", 794 top:isfix ? 0 : offset[0] + "px", left:isfix ? 0 : offset[1] + "px", right:"", bottom:"" 795 }); 796 callCon.css({ 797 width:docWidth - (conPadlr + warpMagtb) + "px", 798 height:docHeight - (conPadtb + jeyer.conhead + jeyer.confoot + warpMaglr) + "px" 799 }); 800 }, 1); 801 } 802 //è·ååiframeçDOM 803 jeBox.getChildFrame = function(selector, index) { 804 index = index || $(".jeboxiframe").attr("jeb"); 805 return $D("#"+ doms[0] + index).find("iframe").contents().find(selector); 806 }; 807 //å¾å°å½åiframeå±çç´¢å¼ï¼åiframeæ¶ä½¿ç¨ 808 jeBox.getFrameIndex = function(name) { 809 return $D("#"+ doms[0] + name).attr("jeb"); 810 }; 811 //éç½®iframe url 812 jeBox.iframeUrl = function(idx, url) { 813 $D("#"+ doms[0] + idx).find("iframe").attr("src", url); 814 }; 815 // è®©ä¼ å ¥çå ç´ å¨å¯¹è¯æ¡å ³éåå¯ä»¥è¿åå°åæ¥çå°æ¹ 816 function backSitu(elem, jePrev, jeNext, jeParent, jeDispy) { 817 if (jePrev && jePrev.parentNode) { 818 jePrev.parentNode.insertBefore(elem, jePrev.nextSibling); 819 } else if (jeNext && jeNext.parentNode) { 820 jeNext.parentNode.insertBefore(elem, jeNext); 821 } else if (jeParent) { 822 jeParent.appendChild(elem); 823 } 824 elem.style.display = jeDispy; 825 this.backSitu = null; 826 } 827 // å¤ç¯å¢æ¯æ 828 "function" === typeof define ? define(function() { 829 return jeBox; 830 }) :"object" === typeof module && "object" === typeof module.exports ? module.exports = jeBox :window.jeBox = jeDialog = jeBox; 831})(window.$D, window);
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.