1/*! jrx - v0.1.0 - 2015-02-24 */(function(document, window){ 2 'use strict'; 3 4 /** 5 * @constructor 6 * @class : JRX > javascript runtime extension. 7 * @type : Class 8 * @method JRX 9 * @param {} $ 10 * @param {} window 11 * @param {} document 12 * @return 13 */ 14 function JRX ($, window, document) { 15 16 /** 17 * @method : _config 18 * @params : object 19 * @depends: config [Object] 20 */ 21 var _config = { 22 'useLog': { 'editable': true, 'value': false }, 23 'isLogin': { 'editable': true, 'value': false }, 24 'root': { 'editable': true, 'value': '/' }, 25 'staticPath': { 'editable': true, 'value': '/' }, 26 'contextPath': { 'editable': true, 'value': '/' }, 27 'loginUrl': { 'editable': true, 'value': ''}, 28 'logoutUrl': { 'editable': true, 'value': ''}, 29 'loading' : { 'editable': true, 'value': './images/loading_medium.gif'}, 30 'maskColor' : { 'editable': true, 'value': '#aaaaaa'}, 31 'useAlert' : { 'editable': true, 'value': true}, 32 'language' : { 'editable': true, 'value': {}} 33 }, 34 35 /** 36 * @name : _REG_EXP 37 * @desc : reqular expression literal. 38 */ 39 _REG_EXP = { 40 "tag" : /(<([^>]+)>)/ig, 41 "trim" : /(^[\sã]+)|([\sã]+$)/g, 42 "number" : /(\d{3})(?=\d)/g, 43 "date" : /(yyyy|yy|MM|dd|E|hh|mm|ss|a\/p)/gi, 44 "rgb" : /\d+, \d+, \d+/, 45 "engnum" : /^[A-Za-z0-9+]*$/, 46 "email" : /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i, 47 "url" : /^(https?|s?ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i 48 }; 49 50 /** 51 * @depends: _config (private) 52 * @type : method 53 * @name : config 54 * @param {object or string} p 55 * @return 56 */ 57 this.config = function (p) { 58 59 if ($.type(p) === 'object') { 60 set(p); 61 } else if($.type(p) === 'string'){ 62 return get(p); 63 } else { 64 throw new Error('parameter is only json or string. current type : ' + $.type(p)); 65 } 66 67 /** 68 * Description 69 * @method set 70 * @param {} obj 71 * @return 72 */ 73 function set(obj) { 74 75 $.each(obj, function(n){ 76 77 if (_config[n] && _config[n].editable) { 78 if (typeof obj[n] === 'string' && (obj[n] === 'True' || obj[n] === 'False')) { 79 obj[n] = obj[n] == 'True'; 80 } 81 82 _config[n].value = obj[n];
83 _config[n].editable = false; 84 } 85 }); 86 } 87 88 /** 89 * Description 90 * @method get 91 * @param {} n 92 * @return MemberExpression 93 */ 94 function get(n) { 95 96 if(_config[n] === undefined && n !== 'all'){ 97 throw new Error('undefined property name : ' + n); 98 } 99 100 var returnVal; 101 102 if(n == 'all'){ 103 returnVal = {}; 104 for(var item in _config){ 105 returnVal[item] = _config[item].value; 106 } 107 } else { 108 returnVal = _config[n].value; 109 } 110 return returnVal; 111 } 112 }; 113 114 /** 115 * Description 116 * @params : object 117 * @method log 118 * @param {} obj 119 */ 120 this.log = function (obj) { 121 var useLog = this.config('useLog') == true && window.console; 122 if (useLog) { 123 if (typeof obj == "object" && console.dir) { 124 console.dir && console.dir(obj); 125 } else { 126 console.log && console.log(obj); 127 } 128 } 129 }; 130 131 /** 132 * Description 133 * @desc : define namespace. 134 * @method define 135 * @param {} ns 136 * @param {} fn 137 * @return self 138 */ 139 this.define = function (ns, fn) { 140 141 var gns = 'jrx', 142 self = this, 143 arrNS = ns.split('.'), i, len; 144 145 if(arrNS[0] === gns) arrNS = arrNS.slice(1); 146 147 for(i = 0, len = arrNS.length; i < len; i += 1){ 148 if(!self.hasOwnProperty(arrNS[i])){ 149 150 self[arrNS[i]] = {}; 151 152 if (i === (len - 1)){ 153 self[arrNS[i]] = fn; 154 } 155 } 156 self = self[arrNS[i]]; 157 } 158 159 return self; 160 }; 161 162 /** 163 * @method : regexp 164 */ 165 this.regexp = function(s){ 166 return _REG_EXP[s] || new RegExp(); 167 }; 168 169 /** 170 * @method : extend 171 * @TODO : deep option ì²ë¦¬. 172 */ 173 this.extend = function () { 174 175 var deep = false, 176 origin = {}, 177 add = {}; 178 179 if($.isBoolean(arguments[0])){ 180 deep = arguments[0]; 181 origin = arguments[1]; 182 add = arguments[2]; 183 } else { 184 origin = arguments[0]; 185 add = arguments[1]; 186 } 187 188 for(var o in origin) { 189 origin[o] = add[o] ? add[o] : origin[o]; 190 } 191 }; 192 193 /** 194 * @method : strip 195 * @desc : remove tag 196 */ 197 this.strip = function(s) { 198 199 if($.trim(s) === '') return s; 200 201 var reg_tag = this.regexp('tag'), r = ''; 202 203 s = s.replace(reg_tag, ''); 204 205 if(this.decodeEntities){ 206 s = this.decodeEntities(s); 207 } 208 r = s.replace(reg_tag, ''); 209 210 return r; 211 }; 212 /** 213 * @method : decodeEntities [function] 214 * @desc : decode html entities. 215 */ 216 this.decodeEntities = function(s){ 217 var r, t = document.createElement('textarea'); 218 t.innerHTML= s; 219 r = t.textContent || t.innerText; 220 t = null; 221 return r; 222 }; 223 224 /* 225 * @name : toHexFromRGB [Function] 226 * @desc : convert RGB to Hex. 227 */ 228 this.toHexFromRGB = function (rgb) { 229 var hex = [ 230 rgb.r.toString(16), 231 rgb.g.toString(16), 232 rgb.b.toString(16) 233 ]; 234 $.each(hex, function (nr, val) { 235 if (val.length == 1) { 236 hex[nr] = '0' + val; 237 } 238 }); 239 return hex.join(''); 240 }; 241 /* 242 * @method : toRGBFromHex [Function] 243 * @desc : convert Hex to RGB. 244 */ 245 this.toRGBFromHex = function (hex) { 246 247 var _hex = parseInt(((hex.indexOf('#') > -1) ? hex.substring(1) : hex), 16); 248 249 return { r: _hex >> 16, g: (_hex & 0x00FF00) >> 8, b: (_hex & 0x0000FF) }; 250 }; 251 /* 252 * @method : toRGBFromRGBA [Function] 253 * @desc : get rgb from background. 254 */ 255 this.toRGBFromRGBA = function (rgba) { 256 257 var rgbMatch = this.regexp('rgb'), 258 matchRGB = rgba.match(rgbMatch).length && rgba.match(rgbMatch)[0].split(','); 259 260 return { r: parseInt(matchRGB[0].trim(), 10), g: parseInt(matchRGB[1].trim(), 10), b: parseInt(matchRGB[2].trim(), 10) }; 261 }; 262 /* 263 * @method : stringify [Function]
264 * @desc : parse string 265 */ 266 this.stringify = function (obj) { 267 var t = typeof (obj); 268 if (t != "object" || obj === null) { 269 // simple data type 270 if (t == "string") obj = '"' + obj + '"'; 271 return String(obj); 272 } else { 273 // recurse array or object 274 var n, v, json = [], arr = (obj && obj.constructor == Array); 275 276 for (n in obj) { 277 v = obj[n]; 278 t = typeof(v); 279 if (obj.hasOwnProperty(n)) { 280 if (t == "string") v = '"' + v + '"'; else if (t == "object" && v !== null) v = app.stringify(v); 281 json.push((arr ? "" : '"' + n + '":') + String(v)); 282 } 283 } 284 return (arr ? "[" : "{") + String(json) + (arr ? "]" : "}"); 285 } 286 }; 287 288 /* 289 * @method : isNumberKey [Function] 290 * @desc : event ì ë ¥ ë°ìì keycode ì²ë¦¬. 291 */ 292 this.isNumberKey = function (e) { 293 294 var code = e.which || e.keyCode, 295 rtnValue = false; 296 297 // <backspace> || <tab> || Function Key || Number Key || Key Pad 298 if(code == 8 || code == 9 || (code >= 35 && code <= 40) || (code >= 46 && code <= 57) || (code >= 96 && code <= 105) ){ 299 rtnValue = true; 300 } 301 302 return rtnValue; 303 }; 304 305 /* 306 * @method : addCommas [Function] 307 * @desc : 308 */ 309 this.addCommas = function (nStr) { 310 311 nStr += ''; 312 var x = nStr.split('.'); 313 var x1 = x[0]; 314 var x2 = x.length > 1 ? '.' + x[1] : ''; 315 var rgx = /(\d+)(\d{3})/; 316 317 while (rgx.test(x1)) { 318 x1 = x1.replace(rgx, '$1' + ',' + '$2'); 319 } 320 return x1 + x2; 321 }; 322 323 /* 324 * @method : preloadImage [Function] 325 * @desc : 326 */ 327 this.preloadImage = function () { 328 329 if(arguments.length === 0 ) return; 330 331 var i = 0; 332 333 if(jrx.isArray(arguments[0])){ 334 for (i = 0; i < arguments[0].length; i++) { 335 load(arguments[0][i]); 336 } 337 } else { 338 for (i = 0; i < arguments.length; i++) { 339 load(arguments[i]); 340 } 341 } 342 function load(src) { 343 var img = new Image(); 344 img.src = src; 345 } 346 }; 347 348 349 /* 350 * @name : imageLoadResize [Function] 351 * @TODO : ì¶ê° ìì íì ì´ë¯¸ì§ë¥¼ ë¤ì ë¡ë©íì¬ ì¬ì´ì¦ë¥¼ ì½ì´ë¤ì´ë ë°©ìì´ íìí¨. 352 * íë¬ê·¸ì¸ ííë¡ ì ìëëê² ì¢ê² ë¤. 353 */ 354 // this.imageLoadResize = function (_this, maxSize) { 355 // var $this = $(_this), 356 // n_width = $this.prop('naturalWidth'), 357 // n_height = $this.prop('naturalHeight'); 358 // 359 // maxSize = maxSize ? maxSize : 192; 360 // //108*192 361 // //192*108 362 // 363 // if (n_width < n_height) { 364 // if (n_height > maxSize) { 365 // $this.css('height', maxSize); 366 // } 367 // } else { 368 // if (n_width > maxSize) { 369 // $this.css('width', maxSize); 370 // } 371 // } 372 // }; 373 374 }; 375 376 //======================== new JRX =========================== 377 378 window.jrx = new JRX($, window, document);; 379 380 //============================================================ 381 382 /* 383 * @define : cookie 384 */ 385 jrx.define('cookie', new function(){ 386 /* 387 * @method : get 388 */ 389 this.get = function (name) { 390 var prefix = name + "=", 391 startIndex = document.cookie.indexOf(prefix), 392 endIndex = document.cookie.indexOf(";", startIndex + prefix.length); 393 394 if (startIndex == -1) return null; 395 396 if (endIndex == -1) endIndex = document.cookie.length; 397 398 return (unescape(document.cookie.substring(startIndex + prefix.length, endIndex))); 399 }; 400 401 /* 402 * @method : set 403 * @param : cookie name 404 * @param : value 405 * @param : expireDays 406 */ 407 this.set = function (name, value, expireDays) { 408 if(value === undefined) throw new Error('should be add second parameter, value'); 409 if(!expireDays) { 410 document.cookie = name + "=" + escape(value) + "; path=/; "; 411 } else { 412 var today = new Date(); 413 today.setDate(today.getDate() + expireDays); 414 document.cookie = name + "=" + escape(value) + "; path=/; expires=" + today.toGMTString() + ";"; 415 } 416 }; 417 418 /* 419 * @method : remove 420 * @param name 421 */ 422 this.remove = function (name) { 423 this.set(name, "", -1); 424 }; 425 426 /* 427 * @method : clear 428 */ 429 this.clear = function () { 430 var cookies = document.cookie.split(';'); 431 for (cookie in cookies) {
432 this.remove(cookies[cookie].split('=')[0].trim()); 433 } 434 }; 435 }); 436 437 /* 438 * @define : storage 439 * @desc : local & session Storage wrapper 440 */ 441 jrx.define('storage', (new function (){ 442 var storage = _getStorage('local'); 443 444 function _getStorage(type) { 445 if (typeof(Storage) !== 'undefined') { 446 //console.log('this browser support storage'); 447 if(type === 'local') { 448 return window['localStorage']; 449 } else if (type === 'session') { 450 return window['sessionStorage']; 451 } 452 } else { 453 //console.log('this browser does not support storage'); 454 //console.log('it will be saved as windows object'); 455 // use this instance on unsupported localstorage brower 456 window[type] = { 457 _data : {}, 458 setItem : function(id, val) { return this._data[id] = String(val); }, 459 getItem : function(id) { return this._data.hasOwnProperty(id) ? this._data[id] : this._data; }, 460 removeItem : function(id) { return delete this._data[id]; }, 461 clear : function() { return this._data = {}; } 462 }; 463 return window[type]; 464 } 465 } 466 467 return { 468 /** 469 * get Storage value by name 470 * @param name 471 */ 472 get : function (name) { 473 if (name) { 474 return storage.getItem(name); 475 } else { 476 return storage; 477 } 478 }, 479 480 /** 481 * set Storage data 482 * @param name 483 * @param value 484 */ 485 set : function (name, value) { 486 storage.setItem(name, value); 487 }, 488 489 /** 490 * remove data by name 491 * @param name 492 */ 493 remove : function (name) { 494 storage.removeItem(name); 495 }, 496 497 /** 498 * clear all Storage data 499 */ 500 clear : function () { 501 storage.clear(); 502 } 503 }; 504 })); 505 506 /* 507 * @define : loading 508 * @desc : loading layer 509 * @css : .loading{position:fixed; top:0; left:0; width:100%; height:100%; z-index:5000; background:url('./images/loading_medium.gif') no-repeat 50% 50%} 510 */ 511 jrx.define('loading', new function(){ 512 var id = 'loading', 513 cls = 'loading', 514 isLoading = false, 515 isTimeout = false, 516 delay = 800, 517 css = { 518 'position' : 'fixed', 519 'top' : 0, 520 'left' : 0, 521 'width' : '100%', 522 'height' : '100%', 523 'background' : 'url(' + jrx.config('loading') + ') no-repeat 50% 50%', 524 'z-index' : 98 525 }; 526 527 /* 528 * @method : show 529 */ 530 this.show = function (cls) { 531 532 if(!isLoading){ 533 jrx.mask && jrx.mask.show(); 534 535 var msk = document.createElement('div'), 536 style = ''; 537 538 msk.setAttribute('id', id); 539 540 if(cls){ 541 msk.setAttribute('class', cls); 542 } else { 543 msk.setAttribute('class', id); 544 css.background = 'url(' + jrx.config('loading') + ') no-repeat 50% 50%'; 545 546 if(cls){ 547 css = $.extend(css, addStyle); 548 } 549 550 for(var v in css){ 551 style += v + ':' + css[v] + ';'; 552 } 553 msk.setAttribute('style', style); 554 } 555 556 if (!document.getElementById(id)) document.body.appendChild(msk); 557 isLoading= true; 558 isTimeout = false; 559 560 setTimeout(function () { 561 562 if(isTimeout) { 563 jrx.loading.hide(); 564 } else { 565 isTimeout = true; 566 } 567 }, delay); 568 } 569 }; 570 571 /* 572 * @method : hide 573 */ 574 this.hide = function () { 575 576 if(isLoading) { 577 if(isTimeout) { 578 jrx.mask && jrx.mask.hide(); 579 var loading = document.getElementById(id); 580 if(loading) document.body.removeChild(loading); 581 isLoading= false; 582 } else { 583 isTimeout = true; 584 } 585 } 586 }; 587 }); 588 589 /* 590 * @define : mask 591 * @desc : mask layer 592 * @css : .mask{ position:absolute; top:0; left:0; width:100%; height:100%; background-color:#fff; opacity: 0.4; filter:alpha(opacity=40); z-index: 4000;} 593 */ 594 jrx.define('mask', new function(){ 595 var id = 'mask', 596 cls = 'mask', 597 css = { 598 'position' : 'fixed', 599 'top' : 0, 600 'left' : 0, 601 'width' : '100%', 602 'height' : '100%', 603 'background-color' : '#aaaaaa', 604 'opacity' : 0.4, 605 'filter' : 'alpha(opacity=40)', 606 'z-index' : 98 607 }; 608 609 /* 610 * @method : show 611 */ 612 this.show = function (addStyle) { 613 614 var msk = document.createElement('div'); 615 var style = ''; 616 617 msk.setAttribute('id', id); 618 msk.setAttribute('class', cls); 619 620 css['background-color'] = jrx.config('maskColor'); 621 622 if(addStyle){ 623 css = $.extend(css, addStyle); 624 } 625 626 for(var v in css){ 627 style += v + ':' + css[v] + ';'; 628 } 629 msk.setAttribute('style', style); 630 631 if (!document.getElementById(id)) document.body.appendChild(msk); 632 633 return msk; 634 }; 635 /* 636 * @method : hide 637 */ 638 this.hide = function () { 639 var msk = document.getElementById(id); 640 if(msk) document.body.removeChild(msk); 641 }; 642 }); 643 644 /* 645 * @define : language 646 * @desc : 647 */ 648 jrx.define('language', {validate : { 649 required: "ë(ì) íì ì ë ¥ í목ì ëë¤.", 650 remote: "ì´ í목ì ìì í´ì£¼ì¸ì.", 651 email: " ì¬ë°ë¥¸ ì´ë©ì¼íìì¼ë¡ ì ë ¥í´ì£¼ì¸ì.", 652 url: "http://ì í¬í¨í ì¬ë°ë¥¸ URL ì ì ë ¥í´ì£¼ì¸ì.", 653 date: "ì¬ë°ë¥¸ ë ì§ë¥¼ ì ë ¥í´ì£¼ì¸ì.", 654 dateISO: "ISO íì¤ì ë§ë ë ì§íìì¼ë¡ ì ë ¥í´ì£¼ì¸ì.",
655 number: "ì¬ë°ë¥¸ ê°ì ì ë ¥í´ì£¼ì¸ì.", 656 digits: "ì«ìë§ ì ë ¥ì´ ê°ë¥í©ëë¤.", 657 creditcard: "ì¬ë°ë¥¸ ì¹´ëë²í¸ë¥¼ ì ë ¥í´ì£¼ì¸ì.", 658 equalTo: "ì ë ¥íì ë´ì©ì´ ì¼ì¹íì§ ììµëë¤.", 659 length: "{0} ìë¦¬ë¡ ì ë ¥í´ì£¼ì¸ì.", 660 maxlength: "{0}ì ì´íë¡ ì ë ¥í´ì£¼ì¸ì.", 661 minlength: "{0}ì ì´ì ì ë ¥í´ì£¼ì¸ì.", 662 rangelength: "{0}ì ì´ì {1}ì ì´íë¡ ì ë ¥í´ì£¼ì¸ì.", 663 range: "{0} ~ {1} ì¬ì´ì ê°ë§ ì ë ¥í´ì£¼ì¸ì.", 664 max: "{0} ì´íì ê°ì ì ë ¥í´ì£¼ì¸ì.", 665 min: "{0} ì´ìì ê°ì ì ë ¥í´ì£¼ì¸ì.", 666 engnum : "ì문 ëë ì«ìë§ ì ë ¥í´ì£¼ì¸ì..", 667 count: "{0} ê° ì´ì ë±ë¡ëì´ì¼ í©ëë¤." 668 }}); 669 670 var validate = { 671 required: "ë(ì) íì ì ë ¥ í목ì ëë¤.", 672 remote: "ì´ í목ì ìì í´ì£¼ì¸ì.", 673 email: " ì¬ë°ë¥¸ ì´ë©ì¼íìì¼ë¡ ì ë ¥í´ì£¼ì¸ì.", 674 url: "http://ì í¬í¨í ì¬ë°ë¥¸ URL ì ì ë ¥í´ì£¼ì¸ì.", 675 date: "ì¬ë°ë¥¸ ë ì§ë¥¼ ì ë ¥í´ì£¼ì¸ì.", 676 dateISO: "ISO íì¤ì ë§ë ë ì§íìì¼ë¡ ì ë ¥í´ì£¼ì¸ì.",
677 number: "ì¬ë°ë¥¸ ê°ì ì ë ¥í´ì£¼ì¸ì.", 678 digits: "ì«ìë§ ì ë ¥ì´ ê°ë¥í©ëë¤.", 679 creditcard: "ì¬ë°ë¥¸ ì¹´ëë²í¸ë¥¼ ì ë ¥í´ì£¼ì¸ì.", 680 equalTo: "ì ë ¥íì ë´ì©ì´ ì¼ì¹íì§ ììµëë¤.", 681 length: "{0} ìë¦¬ë¡ ì ë ¥í´ì£¼ì¸ì.", 682 maxlength: "{0}ì ì´íë¡ ì ë ¥í´ì£¼ì¸ì.", 683 minlength: "{0}ì ì´ì ì ë ¥í´ì£¼ì¸ì.", 684 rangelength: "{0}ì ì´ì {1}ì ì´íë¡ ì ë ¥í´ì£¼ì¸ì.", 685 range: "{0} ~ {1} ì¬ì´ì ê°ë§ ì ë ¥í´ì£¼ì¸ì.", 686 max: "{0} ì´íì ê°ì ì ë ¥í´ì£¼ì¸ì.", 687 min: "{0} ì´ìì ê°ì ì ë ¥í´ì£¼ì¸ì.", 688 engnum : "ì문 ëë ì«ìë§ ì ë ¥í´ì£¼ì¸ì..", 689 count: "{0} ê° ì´ì ë±ë¡ëì´ì¼ í©ëë¤." 690 }; 691 692})(document, window); 693//======================== polyfill ========================== 694 695/* 696* @name : trim [String] 697* @desc : 공백 ì ê±° 698* @param : 699*/ 700if (typeof String.prototype.trim != 'function') { 701 String.prototype.trim = function () { 702 return this.replace(jrx.regexp('trim'), ""); 703 }; 704};
705 706/* 707* @name : getByteLength [String] 708* @desc : 문ìì´ì Byte ê° ë°í. 709* @param : 710*/ 711if (typeof String.prototype.getByteLength != 'function') { 712 String.prototype.getByteLength = function () { 713 var _this = this, b, i, c; 714 for (b = i = 0; c = _this.charCodeAt(i++); b += c >> 11 ? 3 : c >> 7 ? c : 1); 715 return b; 716 }; 717}; 718 719/* 720* @name : filter [Array] 721* @desc : ë°°ì´ì íí°íì¬ ìë¡ì´ ë°°ì´ ë°í 722* @param : [filter condition function.] 723*/ 724if (typeof Array.prototype.filter != 'function') { 725 Array.prototype.filter = function (_function) { 726 var newArray = [], 727 _this = this; 728 729 for (var i = 0, len = _this.length; i < len; i++) { 730 if (_function(_this[i], i, _this)) { 731 newArray.push(_this[i]); 732 } 733 } 734 return newArray; 735 }; 736}; 737/* 738* @name : forEach [Array] 739* @desc : ë°°ì´ ìííë©° ì¡°ê±´ ì²ë¦¬. 740* @param : 741*/ 742if (typeof Array.prototype.forEach != 'function') { 743 Array.prototype.forEach = function (_function) { 744 var _this = this; 745 746 for (var i = 0, len = _this.length; i < len; i++) { 747 _function.call(_this, _this[i], i, _this); 748 } 749 }; 750};
751/* 752* @name : contains [Array] 753* @desc : ë°°ì´ì ì¡´ì¬íë ììì¸ì§ íì¸. 754* @param : 755*/ 756if (typeof Array.prototype.contains != 'function') { 757 Array.prototype.contains = function (compareValue) { 758 var _this = this; 759 for (var i = 0, len = _this.length; i < len; i++) { 760 if (_this[i] === compareValue) { 761 return true; 762 break; 763 } 764 } 765 return false; 766 }; 767}; 768 769// Production steps of ECMA-262, Edition 5, 15.4.4.14 770// Reference: http://es5.github.io/#x15.4.4.14 771if (!Array.prototype.indexOf) { 772 Array.prototype.indexOf = function(searchElement, fromIndex) { 773 774 var k; 775 776 // 1. Let O be the result of calling ToObject passing 777 // the this value as the argument. 778 if (this == null) { 779 throw new TypeError('"this" is null or not defined'); 780 } 781 782 var O = Object(this); 783 784 // 2. Let lenValue be the result of calling the Get 785 // internal method of O with the argument "length". 786 // 3. Let len be ToUint32(lenValue). 787 var len = O.length >>> 0; 788 789 // 4. If len is 0, return -1. 790 if (len === 0) { 791 return -1; 792 } 793 794 // 5. If argument fromIndex was passed let n be 795 // ToInteger(fromIndex); else let n be 0. 796 var n = +fromIndex || 0; 797 798 if (Math.abs(n) === Infinity) { 799 n = 0; 800 } 801 802 // 6. If n >= len, return -1. 803 if (n >= len) { 804 return -1; 805 } 806 807 // 7. If n >= 0, then Let k be n. 808 // 8. Else, n<0, Let k be len - abs(n). 809 // If k is less than 0, then let k be 0. 810 k = Math.max(n >= 0 ? n : len - Math.abs(n), 0); 811 812 // 9. Repeat, while k < len 813 while (k < len) { 814 var kValue; 815 // a. Let Pk be ToString(k). 816 // This is implicit for LHS operands of the in operator 817 // b. Let kPresent be the result of calling the 818 // HasProperty internal method of O with argument Pk. 819 // This step can be combined with c 820 // c. If kPresent is true, then 821 // i. Let elementK be the result of calling the Get 822 // internal method of O with the argument ToString(k). 823 // ii. Let same be the result of applying the 824 // Strict Equality Comparison Algorithm to 825 // searchElement and elementK. 826 // iii. If same is true, return k. 827 if (k in O && O[k] === searchElement) { 828 return k; 829 } 830 k++; 831 } 832 return -1; 833 }; 834} 835//============================================================ 836 837;(function( $, window, document){ 838 'use strict'; 839 840 841 jrx.define('g', function(fn){ 842 $(function(){ 843 if($.isFunction(fn)){ 844 fn(); 845 } 846 }); 847 }); 848 849 jrx.define('p', function(fn){ 850 $(function(){ 851 if($.isFunction(fn)){ 852 fn(); 853 } 854 }); 855 }); 856 857 jrx.define('isString', function(obj){ 858 return $.type(obj) === 'string'; 859 }); 860 861 jrx.define('isNumber', function(obj){ 862 return $.type(obj) === 'number'; 863 }); 864 865 jrx.define('isArray', function(obj){ 866 return $.type(obj) === 'array'; 867 }); 868 869 jrx.define('isBoolean', function(obj){ 870 return $.type(obj) === 'boolean'; 871 }); 872 873 jrx.define('isObject', function(obj){ 874 return $.type(obj) === 'object'; 875 }); 876 877 jrx.define('isEmail', function(obj){ 878 return $.regexp('email').test(obj); 879 }); 880 881 jrx.define('isUrl', function(obj){ 882 return $.regexp('url').test(obj); 883 }); 884 885 jrx.define('isDate', function(obj){ 886 return !/Invalid|NaN/.test(new Date(obj).toString()); 887 }); 888 889 /* 890 * @define : validate 891 * @desc : init, extend validate 892 */ 893 jrx.define('validate.init', function(){ 894 /* 895 * @name : set jquery.validate extend 896 * @depends : {plugin} jquery.validate 897 */ 898 var language = jrx.config('language') || jrx.language; 899 900 if($.type($.fn.validate) === 'function'){ 901 902 $.extend($.validator.messages, { 903 required: language.validate.required, 904 remote: language.validate.remote, 905 email: language.validate.email, 906 url: language.validate.url, 907 date: language.validate.date, 908 dateISO: language.validate.dateISO, 909 number: language.validate.number, 910 digits: language.validate.digits, 911 creditcard: language.validate.creditcard, 912 equalTo: language.validate.equalTo, 913 length: $.validator.format(language.validate.length), 914 maxlength: $.validator.format(language.validate.maxlength), 915 minlength: $.validator.format(language.validate.minlength), 916 rangelength: $.validator.format(language.validate.rangelength), 917 range: $.validator.format(language.validate.range), 918 max: $.validator.format(language.validate.max), 919 min: $.validator.format(language.validate.min), 920 engnum : $.validator.format(language.validate.engnum), 921 count: $.validator.format(language.validate.count) 922 }); 923 924 $.validator.addMethod('engnum', function(value, element, params){ 925 return this.optional(element) || jrx.regexp('engnum').test(value); 926 }); 927 928 $.validator.addMethod('length', function(value, element, params){ 929 return this.optional(element) || value.length == element.getAttribute('length'); 930 }); 931 932 // addMethod : count 933 $.validator.addMethod('count', function(value, element, params){ 934 return this.optional(element) || value >= params[0]; 935 });
936 937 $.validator.setDefaults({ 938 ignore: '', 939 ignoreTitle: true, 940 // onkeyup: false, 941 // onfocusout: false, 942 // onclick : false, 943 // focusInvalid: true, 944 showErrors: function (errorMap, errorList) { 945 946 if (errorList.length === 0) return false; 947 948 var labelWrap = $('<div />').addClass('label-lists'), 949 textMessage = ''; 950 951 $.each(errorList, function (i, v) { 952 var _$element = $(v.element); 953 954 if (i == 0) { 955 textMessage = _$element.data('message') || (getMessage(_$element) + (errorMap[v.element.name] || '')); 956 _$element.focus(); 957 } 958 }); 959 960 function getMessage(_$element) { 961 962 return _$element.data('title') 963 || _$element.attr('title') 964 || _$element.parent().find('>label').text() 965 || _$element.parent('label').text() 966 || _$element.attr('placeholder') 967 || _$element.attr('name'); 968 }; 969 970 if(!jrx.config('useAlert') && $.isfunction($.stateAlarm)){ 971 $.stateAlarm(textMessage); 972 } else { 973 alert(textMessage); 974 } 975 976 return; 977 }, 978 submitHandler: function (form) { form.submit(); } 979 }); 980 } 981 }); 982 983})( jQuery, window, document );;(function( $, window, document){ 984 985 //======================== Valiable ========================== 986 var utils = $ || {}; 987 988 //============================================================ 989 990 //======================== mix $.utils ======================= 991 992 utils.jrx = jrx; 993 994 $.each(jrx, function(v, i){ 995 996 if( utils[v] === undefined ){ 997 utils[v] = jrx[v]; 998 } else { 999 jrx.log('ooora! - ' + v); 1000 } 1001 }); 1002 //============================================================ 1003 1004 //======================== Language ========================== 1005 1006 //============================================================ 1007 1008 $(function(){ 1009 1010 //========================= variable ========================= 1011 var dateFormat = 'yy-mm-dd', 1012 timeFormat = 'HH:mm', 1013 content_type = { 1014 defaults : 'application/x-www-form-urlencoded; charset=UTF-8', 1015 json : 'application/json' 1016 }; 1017 //============================================================ 1018 1019 //===================== set jquery ajax. ===================== contentType : content_type.defaults, 1020 $.ajaxSetup({ cache: false, 1021 converters: { 1022 // Convert anything to text 1023 "* text": window.String, 1024 // Text to html (true = no transformation) 1025 "text html": true, 1026 // Evaluate text as a json expression 1027 "text json": jQuery.parseJSON, 1028 // Parse text as xml 1029 "text xml": jQuery.parseXML 1030 } 1031 }); 1032 //============================================================ 1033 1034 1035 //======================== datepicker ======================== 1036 // if($.isFunction($.fn.datepicker)){ 1037 // $.datepicker.setDefaults({ 1038 // // showOn: "button", 1039 // // buttonImage: $.config('staticPath') + "images/ico_calendar.gif", 1040 // // buttonImageOnly: true, 1041 // dateFormat: dateFormat 1042 // }); 1043 // // $('input[date]', $contents).datepicker(); 1044 // } 1045 //============================================================ 1046 1047 }); 1048})( jQuery, window, document );
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.