1/** 2 * Plani javascript module 3 * 4 * jquery 3.1.0 5 * 6 * @package Plani javascript Api Module 7 * @author kim seung beom 8 * @copyright Copyright (c) 2016, Plani, Inc. 9 * @link http://plani.co.kr 10 * @since Version 2.0 11 * @filesource 12 */ 13/* 14----------------------------------------------------------- 15jquery form 16*/ 17$.module['form'] = function( platform, options ) { 18 this.platform = platform.eq(0); 19 this.file = platform.attr('enctype')=='multipart/form-data'; 20 21 this.options = $.extend 22 ( 23 { 24 'ajax' : true, 25 'error' : null, 26 'success' : null, 27 'before' : null, 28 'message' : __('ì²ë¦¬ ëììµëë¤'), 29 'jgrow' : false, 30 'auto_focus' : true, 31 'page_exit' : false, 32 'page_exit_check' : true 33 }, 34 options 35 ); 36 37 this.__construct(); 38} 39 40$.extend 41( 42 $.module['form'].prototype, { 43 __construct : function() { 44 var $this=this; 45 46 $this.platform 47 .addClass('plani-form') 48 .prepend('<div class="alert-error"></div><div class="alert-success"></div>') 49 .end() 50 .on 51 ( 52 'submit', function() { 53 $this.options['page_exit_check'] = true; 54 // event=before 55 if( $this.options['before'] instanceof Function ) { 56 if( $this.options['before']($this) != true ) { 57 return false; 58 } 59 } 60 61 // event=ajax 62 if( $this.options['ajax'] == true ) { 63 $this.request(); 64 return false; 65 } 66 } 67 ); 68 69 $('.submit', $this.platform).on('click', function(){ 70 $this.platform.submit(); 71 return false; 72 }); 73 74 $this.platform.hook(); 75 76 if( $this.options['page_exit'] == true ) { 77 $.window.on 78 ( 79 'beforeunload', function(){ 80 if( $this.options['page_exit_check'] == false ) { 81 $this.platform.trigger('editor_update'); 82 if( $('[detect-check=false]', $this.platform).length > 0 ) { 83 return __('ë³ê²½ì¬íì´ ì ì¥ëì§ ììì ì ììµëë¤.'); 84 } 85 } 86 } 87 ); 88 89 $this.detect(); 90 } 91 }, 92 request : function() { 93 var $this = this; 94 95 $this._disposal(true); 96 $this.platform.ajaxSubmit 97 ( 98 { 99 data: { HTTP_X_REQUESTED_WITH : 'XMLHttpRequest' }, 100 beforeSubmit : function(a, f, o){ o.dataType = 'html' }, 101 success: function ( msg ) { 102 var msgSplit = msg.split('::'), 103 arg1 = 'failed', 104 arg2 = ''; 105 106 if( msgSplit[0] == 'true' ) { 107 arg1 = 'true'; 108 arg2 = msgSplit[1] ? msgSplit[1] : ''; 109 }else if( msgSplit.length > 1 ) { 110 arg1 = msgSplit[0]; 111 arg2 = msgSplit[1]; 112 }else { 113 arg2 = msgSplit[0]; 114 } 115 116 $this.response( arg1, arg2 ); 117 } 118 } 119 ); 120 }, 121 response : function( result, msg ){ 122 var $this = this 123 124 //success 125 if( result != 'failed' ) { 126 if( $this.options['jgrow'] == true ) { 127 $this._jgrow_success( result, msg ); 128 }else { 129 $this._success( result, msg ); 130 } 131 132 //failed 133 }else { 134 $this.options['page_exit_check'] = false; 135 if( $this.options['jgrow'] == true ){ 136 $this._jgrow_error( msg ); 137 }else{ 138 $this._error( msg ); 139 } 140 } 141 }, 142 detect : function() { 143 var $this = this; 144 145 $('input[type=text], input[type=radio], input[type=checkbox], select, textarea', $this.platform).each 146 ( 147 function(){ 148 var choice_mode = this.type == 'radio' || this.type == 'checkbox' 149 150 $(this) 151 .attr('detect', choice_mode == true ? this.checked : this.value) 152 .attr('detect-check', 'true') 153 .on 154 ( 155 'change', function(){ 156 var detect = $(this).attr('detect'), 157 v = choice_mode == true ? this.checked : this.value; 158 159 $this.options['page_exit_check'] = false; 160 $(this).attr('detect-check', detect == v.toString() ); 161 } 162 ); 163 } 164 ); 165 }, 166 _disposal : function( method ){ 167 var $this = this; 168 169 if( method == true ) 170 { 171 $('.alert-error', this.platform).html(''); 172 $('.alert-success', this.platform).html(''); 173 } 174 175 $(':image, :submit, .submit', $this.platform).each 176 ( 177 function(){ 178 if( this.tagName == 'BUTTON' ){ 179 if( method == true ){ 180 $(this).attr('disabled', true).find('span').hide().end().append('<span class="saveing"><i class="xi-spinner-3 xi-spin"></i>
180' +__('ì²ë¦¬ì¤')+ '...</span>'); 181 }else{ 182 $(this).attr('disabled', false).find('span').eq(0).show().end().eq(1).remove(); 183 } 184 }else{ 185 if( method == true ){ 186 $(this).hide().after('<span class="saveing"><i class="xi-spinner-3 xi-spin"></i> ' +__('ì²ë¦¬ì¤')+ '...</span>'); 187 }else{ 188 $(this).show().next().remove(); 189 } 190 } 191 } 192 ); 193 }, 194 _focus : function( msg ) { 195 var focus = msg.match(/<!--focus>(.+)<\/focus-->/g), 196 p = msg.match(/<p>(.+)<\/p>/g); 197 198 199 try { 200 for( var i=0; i < focus.length; i++ ){ 201 var item = focus[i].match(/<!--focus>(.+)<\/focus-->/), 202 obj = $('[name='+item[1]+']'); 203 204 if( obj.length > 0 ) { 205 try { 206 var text = p[i].match(/<p>(.+)<\/p>/), 207 text_message = text[1].split(' : '); 208 obj.eq(0).addClass('tooltip').helper_tooltip({ 209 message : text_message[1], 210 open : false, 211 form_element : true 212 }); 213 } 214 catch (e) { 215 } 216 217 if( i == 0 ){ 218 obj.focus(); 219 } 220 } 221 } 222 223 }catch( e ) { 224 // return null 225 } 226 }, 227 _success : function( result, msg ) { 228 var $this = this, 229 msg = msg !='' ? msg : this.options['message']; 230 231 $('.alert-success', this.platform) 232 .html('<p>' +this.options['message']+ '</p>') 233 .fadeIn() 234 .find('p') 235 .append('<i class="fa fa-times"></i>') 236 .find('i') 237 .on 238 ( 239 'click', function(){ 240 $(this).closest('p').remove(); 241 } 242 ); 243 244 setTimeout 245 ( 246 function(){ 247 $this._process(msg, true); 248 }, 249 1000 250 ); 251 }, 252 _error : function( msg ) { 253 if( msg.indexOf('</p>') < 0 ) { 254 msg='<p>' +msg+ '</p>'; 255 } 256 257 $('.alert-error', this.platform) 258 .html(msg) 259 .fadeIn('slow') 260 .find('p') 261 .append('<i class="fa fa-times"></i>') 262 .find('i') 263 .one 264 ( 265 'click', function(){ 266 $(this).closest('p').remove(); 267 } 268 ); 269 270 this._process(msg, false); 271 this._disposal(false); 272 this._focus(msg); 273 }, 274 _jgrow_success : function(result, msg) { 275 var $this=this; 276 var $this = this, 277 msg = msg !='' && result !='redirect' ? msg : this.options['message']; 278 279 $.jGrowl 280 ( 281 $this.options['message'], 282 { 283 life : 1000, 284 header : 'SUCCESS', 285 close : function(e, m) 286 { 287 $this._process(msg, true); 288 } 289 } 290 ); 291 292 }, 293 _jgrow_error : function(msg) { 294 var $this=this; 295 296 $.jGrowl 297 ( 298 msg, 299 { 300 life : 2000, 301 header : 'ERROR', 302 close : function(e, m) 303 { 304 $this._process(msg, false); 305 $this._disposal(false); 306 $this._focus(msg); 307 } 308 } 309 ); 310 }, 311 _process : function( msg, issuccess ) { 312 if( issuccess == true ) { 313 if( typeof this.options['success'] == 'function' ){ 314 this.options['success'] 315 ( 316 this, 317 msg 318 ); 319 320 }else{ 321 location.reload(); 322 } 323 }else { 324 if( typeof this.options['error'] == 'function' ){ 325 this.options['error'] 326 ( 327 this, 328 msg 329 ); 330 } 331 332 } 333 } 334 } 335); 336 337 338/* 339----------------------------------------------------------- 340jquery modal 341*/ 342$.static.modal = null; 343$.module['modal'] = function(platform, options){ 344 this.platform = platform; 345 this.layer = null; 346 this.bg = null; 347 this.selector = null; 348 this.selector_size = { 349 width : 0, 350 heigth : 0 351 }; 352 this.timer = null; 353 this.status = { 354 'open' : false, 355 'mode' : 'img', 356 'index' : 0 357 } 358 this.options = $.extend 359 ( 360 { 361 'title' : 'untitle', 362 'start' : false, 363 'close' : true, 364 'iframe' : false, 365 'width' : 'auto', 366 'destory' : false, 367 'onclose' : function(){ 368 } 369 }, 370 options 371 ); 372 373 if(typeof this.platform == 'string'){ 374 this.platform = $('<a />', { 'href' : this.platform }); 375 this.options.start = true; 376 this.options.destory = true; 377 } 378 379 this.layer = $('.plani-modal'); 380 this.bg = $('.plani-modal-bg'); 381 this.progress = $('.plani-modal-progress'); 382 383 this.__layout(); 384 this.__construct(); 385} 386 387$.extend 388( 389 $.module['modal'].prototype, { 390 __layout : function() { 391 if( this.layer.length < 1 ){
392 this.layer = $('<div />', {'class' : 'plani-modal', 'tabindex' : 0}).html('<div class="modal-title"></div><div class="modal-frame"></div><iframe src="about:blank" class="modal-iframe" title="modal-iframe" />').appendTo('body'); 393 } 394 if( this.bg.length < 1 ){ 395 this.bg = $('<div />', {'class' : 'plani-modal-bg'}).appendTo('body'); 396 } 397 if( this.progress.length < 1 ){ 398 this.progress = $('<i />', {'class' : 'xi-spinner-1 xi-spin plani-modal-progress'}).appendTo(this.bg); 399 } 400 }, 401 __construct : function() { 402 var $this=this; 403 404 $this.platform.on 405 ( 406 'click',function(){ 407 if( this.tagName == 'IMG' ){ 408 $this._imagebox(this); 409 }else{ 410 $this._pagebox(this); 411 } 412 413 return false; 414 } 415 ); 416 417 $this.bg.on 418 ( 419 'click', function(){ 420 if( $this.options.close == true ){ 421 $this.end(); 422 } 423 } 424 ); 425 426 $this.layer 427 .undelegate('.close-button', 'click') 428 .delegate 429 ( 430 '.close-button', 'click', function(){ 431 $this.end(); 432 return false; 433 } 434 ) 435 .undelegate('.prev-button', 'click') 436 .delegate 437 ( 438 '.prev-button', 'click', function(){ 439 $this.change($this.status.index-1); 440 return false; 441 } 442 ) 443 .undelegate('.next-button', 'click') 444 .delegate 445 ( 446 '.next-button', 'click', function(){ 447 $this.change($this.status.index+1); 448 return false; 449 } 450 ); 451 452 $.window 453 .on 454 ( 455 'keydown', function(e){ 456 if(e.which == 27 && $this.status.open == true){ 457 $this.end(); 458 return false; 459 } 460 } 461 ) 462 .on 463 ( 464 'resize', function(){ 465 if($this.status.open == true){ 466 var size=$this._resize($this.selector); 467 $this.layer.stop().animate 468 ( 469 {'left' : size.end.left, 'top' : size.end.top, 'min-width' : size.width, 'min-height' : size.height, 'max-width' : size.width}, 470 'normal' 471 ); 472 } 473 } 474 ) 475 .on 476 ( 477 'load', function(){ 478 if($this.status.open == true){ 479 var size=$this._resize($this.selector); 480 $this.layer.stop().animate 481 ( 482 {'left' : size.end.left, 'top' : size.end.top, 'min-width' : size.width, 'min-height' : size.height, 'max-width' : size.width}, 483 'normal' 484 ); 485 } 486 } 487 ); 488 489 if( this.options.start == true ){ 490 $this.platform.eq(0).trigger('click'); 491 } 492 }, 493 _pagebox : function(obj) { 494 var $this=this, 495 img=new Image(), 496 iframe = $('.modal-iframe', $this.layer), 497 frame = $('.modal-frame', $this.layer), 498 iframe_src = iframe.attr('src'), 499 obj_src = obj.getAttribute('href')+'/layout/modal'; 500 501 $this.bg.fadeIn('slow'); 502 $this.status.open = true; 503 $this.status.mode = 'iframe'; 504 505 frame.hide(); 506 iframe.hide(); 507 508 title = $this.options.title; 509 if( title == 'untitle' && $(obj).attr('title') != '' ) { 510 title = $(obj).attr('title'); 511 } 512 513 $('.modal-title', $this.layer).html(title + $this._panel(obj)); 514 if( $this.options.iframe == true ) { 515 iframe 516 .css({'height' : 'auto'}) 517 .attr('src', obj_src) 518 .off('load') 519 .on 520 ( 521 'load', function(){ 522 var frame = $(this), 523 framebody=$(this.contentWindow.document); 524 525 $this.layer.css({'width' : $this.options.width+20}).show(); 526 frame.show(); 527 528 img.width = $this.options.width =='auto'? framebody.width() : $this.options.width; 529 img.height = framebody.height()+50; 530 531 frame.hide(); 532 533 $('body', framebody).css('overflow', 'hidden'); 534 535 $this.open 536 ( 537 $this._resize(img, true), 538 true, 539 function(){ 540 $this.timer=setInterval 541 ( 542 function(){ 543 iframe.stop().animate({'height' : framebody.height()}, 'fast'); 544 }, 545 100 546 ); 547 } 548 ); 549 } 550 ) 551 }else{ 552 $.post 553 ( 554 obj.getAttribute('href'), 555 {}, 556 function(data) { 557 var target=$('.modal-frame', $this.layer); 558 559 target.html(data); 560 561 $this.timer=setTimeout 562 ( 563 function(){ 564 img.width=$this.options.width =='auto'? target.width() : $this.options.width; 565 img.height=target.height(); 566 567 $this.layer.css({'width' : img.width+20}).show(); 568 $this.open 569 ( 570 $this._resize(img, true) 571 ); 572 }, 573 500 574 ); 575 } 576 ); 577 } 578 }, 579 _imagebox : function(obj) { 580 var $this = this, 581 img = $('<img />', {'src' : obj.getAttribute('src'), 'alt' : obj.getAttribute('alt') || $this.options.title }), 582 frame = $('.modal-frame', $this.layer); 583 584 $this.bg.fadeIn('slow'); 585 $this.status.open=true; 586 $this.status.mode = 'img'; 587 588 frame.hide(); 589 img 590 .off('load') 591 .on 592 ( 593 'load', 594 function(){ 595 $this.open 596 ( 597 $this._resize(this, true) 598 ); 599 } 600 ); 601 602 $this.layer.focus(); 603 $('.modal-frame', $this.layer).html(img); 604 $('.modal-title', $this.layer).html(img.attr('alt') + $this._panel(obj)); 605 }, 606 _resize : function(obj, isnew){ 607 var width = isnew == true ? obj.width : this.selector_size.width, 608 height = isnew == true ? obj.height : this.selector_size.height, 609 maxWidth = $.window.width(), 610 maxHeight = $.document.height(), 611 layer = this.layer,
612 resize = {width : 0, height : 0, start : {}, end : {}}, 613 margin = 50; 614 615 if( height <= 0 ) { 616 height = 150; 617 } 618 619 resize.width = width > maxWidth-margin ? maxWidth-margin : width; 620 621 if( resize.width < 150 ){ 622 resize.width = 150; 623 } 624 625 resize.height = Math.round(height-height*0.01*Math.round((width-resize.width) / (width*0.01))); 626 627 if( resize.height > (maxHeight-margin-100) && this.status.mode == 'img' ) { 628 resize.height = (maxHeight-margin-100); 629 resize.width = Math.round(width-width*0.01*Math.round((height-resize.height) / (height*0.01))); 630 } 631 632 resize.start.width = layer.width(); 633 resize.start.height = layer.height(); 634 resize.start.left = ((maxWidth - layer.width()) / 2); 635 resize.start.top = ((maxHeight- layer.height()) / 3) + $.window.scrollTop(); 636 637 resize.end.left = ((maxWidth - resize.width) / 2); 638 resize.end.top = ((maxHeight- resize.height) / 3) + $.window.scrollTop(); 639 640 if( resize.end.top < 50 ){ 641 resize.end.top = 50; 642 } 643 644 if( isnew == true ){ 645 this.selector=obj; 646 this.selector_size.width= width; 647 this.selector_size.height= height; 648 } 649 650 return resize; 651 }, 652 _panel : function(obj) { 653 var text=[], 654 size=this.platform.length, 655 index=this.platform.index(obj)+1; 656 657 text.push('<span class="modal-panel-close"><a href="#" class="close-button"><i class="xi-close-circle bg-radius"></i></a></span>'); 658 659 if( size > 1 ){ 660 text.push('<span class="modal-panel">'); 661 if( index > 1 ){ 662 text.push('<i class="fas fa-chevron-circle-left prev-button"></i>'); 663 } 664 665 text.push(' <span style="padding:0px 4px"> file of ' + size+ ' / ' + index + '</span> '); 666 667 if( index < size ){ 668 text.push('<i class="fas fa-chevron-circle-right next-button"></i>'); 669 } 670 text.push('</span>'); 671 } 672 673 this.status.index=index-1; 674 675 return text.join(''); 676 }, 677 open : function(size, iframemode, callback) { 678 var $this=this; 679 680 //save modal 681 $.static.modal = $this; 682 683 $('.modal-title', $this.layer).hide(); 684 $this.layer.css( 685 {'left' : size.end.left, 'top' : size.end.top, 'min-width' : size.width, 'min-height' : size.height, 'max-width' : size.width} 686 ) 687 .animate 688 ( 689 {'opacity' : 'show'}, 690 'normal', 691 function() { 692 $(this).animate({'top' : size.end.top}); 693 if( iframemode == true ){ 694 $('.modal-iframe', $this.layer).height(size.height).fadeIn('fast', function(){ 695 if( typeof callback == 'function' ){ 696 callback(); 697 } 698 }) 699 }else{ 700 $('.modal-frame', $this.layer).fadeIn('fast'); 701 } 702 703 $this.layer.focus(); 704 $('.modal-title', $this.layer).show(); 705 $this.progress.hide(); 706 } 707 ); 708 709 if( $.window.width() < size.start.width ){ 710 var size = $this._resize( 711 $this.selector 712 ); 713 714 $this.layer.css 715 ( 716 {'left' : size.end.left, 'top' : size.end.top, 'min-width' : size.width, 'min-height' : size.height, 'max-width' : size.width} 717 ); 718 } 719 }, 720 end : function() { 721 this.bg.stop().fadeOut(); 722 this.layer.stop().fadeOut(); 723 this.progress.show(); 724 this.status.open=false; 725 this.platform.focus(); 726 if(typeof this.timer != 'undefined' ){ 727 clearInterval(this.timer); 728 this.timer = null; 729 } 730 731 if(typeof this.options.onclose == 'function'){ 732 this.options.onclose(); 733 734 if( this.options.destory == true ) { 735 this.options.onclose = null; 736 } 737 } 738 739 try { 740 clearInterval(this.timer); 741 } 742 catch (e) { 743 } 744 }, 745 change : function(index) { 746 this.layer.stop().hide(); 747 this.progress.show(); 748 this.status.open=false; 749 750 if(typeof this.timer != 'undefined' ){ 751 clearInterval(this.timer); 752 this.timer = null; 753 } 754 755 if( typeof index == 'string' ) { 756 $('.modal-iframe', this.layer).attr('src', index) 757 }else { 758 this.platform.eq(index).trigger('click'); 759 } 760 } 761 } 762); 763 764 765 766/* 767----------------------------------------------------------- 768jquery print 769*/ 770$.module['print'] = function(platform, options) { 771 this.platform = platform; 772 this.options = $.extend 773 ( 774 { 775 'layer' : 'body', 776 'javascript' : false, 777 'style' : true 778 }, 779 options 780 ); 781 782 this.iframe = $('.plani-print-iframe'); 783 784 this.__layout(); 785 this.__construct(); 786} 787 788$.extend 789( 790 $.module['print'].prototype, { 791 __layout : function() { 792 if( this.iframe.length < 1 ){ 793 this.iframe = $('<iframe src="about:blank" class="plani-print-iframe">').insertBefore('body'); 794 } 795 }, 796 __construct : function() { 797 var $this = this; 798 799 $this.platform.on 800 ( 801 'click', function(){ 802 $this.area_print(); 803 } 804 ); 805 }, 806 area_print : function(){ 807 var $this = this, 808 head_clone = $('head').clone(), 809 body_clone = $($this.options.layer), 810 doc = []; 811 812 if( $this.options.javascript == false ){ 813 head_clone.find('script').remove(); 814 body_clone.find('script').remove(); 815 } 816 817 if( $this.options.style == false ){ 818 head_clone.find('link, style').remove(); 819 body_clone.find('link, style').remove(); 820 } 821 822 doc.push('<!doctype html>'); 823 doc.push('<html lang="ko-KR">'); 824 doc.push('<head>'); 825 doc.push(head_clone.html()); 826 doc.push('</head>'); 827 doc.push('<body>'); 828 doc.push(body_clone.html()); 829 doc.push('</body>'); 830 doc.push('</html>'); 831 832 var framebody = $this.iframe.get(0).contentWindow.document; 833 with(framebody) { 834 designMode='on'; 835 open(); 836 writeln(doc.join(''));
837 close(); 838 } 839 840 $this.iframe.one('load', function(){ 841 framebody.body.focus(); 842 framebody.execCommand('print', 0, 0); 843 844 try { 845 $.static.modal.end(); 846 } catch (e) { 847 848 } 849 }); 850 851 } 852 } 853); 854 855/* 856----------------------------------------------------------- 857jquery nested sortable 858*/ 859$.module['nested.sortable'] = function(platform, options) { 860 this.platform = platform; 861 this.ol = $('ol:eq(0)', platform); 862 this.begin = false; 863 this.removesData = []; 864 this.not_visible_remove = true; 865 866 this.options = $.extend 867 ( 868 { 869 'title' : '', 870 'obj' : { 871 'group' : $('button:eq(0)', platform), 872 'message' : $('.message', platform) 873 }, 874 'item-level' : 3, 875 'item-name' : '그룹ë©ë´', 876 'item-sub-name' : 'ìë¸ë©ë´', 877 'item-id' : 0, 878 'isAllowed' : function(){ 879 return true; 880 }, 881 'axis' : 'xy', 882 'submit_jgrow' : true, 883 'submit_success' : null, 884 'event' : { 885 'click' : null 886 } 887 }, 888 options 889 ); 890 891 this.__construct(); 892} 893 894$.extend 895( 896 $.module['nested.sortable'].prototype, { 897 __construct : function() { 898 var $this = this; 899 900 $this.platform.addClass('plani-nested-wrap'); 901 902 if( this.options.title != '' ) 903 { 904 $this.platform.prepend('<h2 class="title">' +this.options.title+ '</h2>'); 905 } 906 907 new $.module['form'] 908 ( 909 $this.platform, 910 { 911 before : function(module){ 912 $this._serialize(); 913 return true; 914 }, 915 success : function(module, result){ 916 $this.options.obj.message.hide(); 917 module._disposal(false); 918 919 if( typeof $this.options.submit_success == 'function' ){ 920 console.log('d'); 921 $this.options.submit_success(module); 922 } 923 }, 924 jgrow : $this.options.submit_jgrow 925 } 926 ); 927 928 $this.options.obj.group 929 .on 930 ( 931 'click', function() { 932 $this._import_group(); 933 } 934 ); 935 936 $this.ol 937 .delegate 938 ( 939 'div', 940 'mouseenter', 941 function(){ 942 if($(this).hasClass('not-remove') == false) { 943 $('<i class="fa fa-times tmp-button" style="right:14px"></i>') 944 .appendTo(this) 945 .on 946 ( 947 'click', 948 function(){ 949 $this._remove(this); 950 } 951 ); 952 } 953 954 if($(this).parents('ol').length < $this.options['item-level']) { 955 $('<i class="fa fa-plus tmp-button" style="right:34px"></i>') 956 .appendTo(this) 957 .on 958 ( 959 'click', 960 function(){ 961 $this._import(this); 962 } 963 ); 964 } 965 } 966 ) 967 .delegate 968 ( 969 'div', 970 'mouseleave', 971 function(){ 972 $('.tmp-button', this).remove(); 973 } 974 ) 975 .delegate 976 ( 977 'div', 978 'click', 979 function(e){ 980 if( e.target == this || $(e.target).hasClass('tmp-button') == false ){ 981 $this._hook('click', this); 982 } 983 } 984 ) 985 .delegate 986 ( 987 'div', 988 'dblclick', 989 function(e){ 990 if(e.target.tagName.toLowerCase() == 'span'){ 991 var target=$('span', this); 992 993 $(this).find('.tmp-button').remove(); 994 target 995 .html('<input type="text" value="' +target.text().trim()+ '"/>') 996 .find('input') 997 .focus() 998 .one( 999 'focusout', 1000 function(){ 1001 var value=$(this).val().replace(/[\+]/g,'ï¼'); 1002 1003 target.text(value? value : 'Empty'); 1004 } 1005 ) 1006 .keyenter('focusout'); 1007 } 1008 } 1009 ); 1010 1011 $this.ol.nestedSortable 1012 ( 1013 { 1014 axis: $this.options['axis'], 1015 isAllowed: $this.options['isAllowed'], 1016 forcePlaceholderSize: true, 1017 handle: '.move', 1018 helper: 'clone', 1019 items: 'li', 1020 opacity: .8, 1021 placeholder: 'placeholder', 1022 revert: 250, 1023 tabSize: 25, 1024 tolerance: 'pointer', 1025 toleranceElement: '> div', 1026 maxLevels: $this.options['item-level'], 1027 isTree: true, 1028 expandOnHover: 700, 1029 startCollapsed: true, 1030 complate : function(){ 1031 $this._depth(); 1032 } 1033 } 1034 ); 1035 1036 $this._depth(); 1037 }, 1038 _depth : function(){ 1039 var $this = this, 1040 target = $('li', $this.platform); 1041 1042 setTimeout 1043 ( 1044 function(){ 1045 if( $this.not_visible_remove == true ) { 1046 $('li:not(:visible)', $this.ol).remove(); 1047 } 1048 1049 target.each 1050 ( 1051 function(){ 1052 var icon = $(this).has('li').length > 0? 'fa-folder-open' : 'fa-folder', 1053 div = $('div:eq(0)', this); 1054 1055 if($('.move', div).length < 1) 1056 { 1057 div.html('<i class="far fa-eye-slash"></i><i class="far ' +icon+ ' move"></i><span>' +div.text()+ '</span>'); 1058 }else 1059 { 1060 $('.move', div).attr('class', 'far ' +icon+ ' move'); 1061 } 1062 } 1063 ); 1064 1065 if($this.begin == true){ 1066 $this.options.obj.message.show(); 1067 } 1068 1069 if($this.begin == false){ 1070 $this.begin=true; 1071 } 1072 }, 300 1073 ) 1074 }, 1075 _import_group : function(){ 1076 var $this = this, 1077 target = $this.ol, 1078 newid = $this._latest(); 1079 1080 target.append('<li id="list_' +newid+ '"><div class="new">' +$this.options['item-name']+ '</div></li>'); 1081 1082 $this._depth(); 1083 }, 1084 _import : function( obj ){ 1085 var $this = this, 1086 target = $(obj).closest('li'), 1087 newid = $this._latest(); 1088 1089 1090 if( target.is(':has(> ol)') == false ){ 1091 target = $('<ol />').appendTo(target); 1092 }else{ 1093 target = target.find('> ol'); 1094 } 1095 1096 target.append('<li id="list_' +newid+ '"><div class="new">' +$this.options['item-sub-name']+ '</div></li>'); 1097 1098 $this._depth(); 1099 }, 1100 _latest : function(){ 1101 var no = parseInt(this.options['item-id']);
1102 $('li', this.platform).each 1103 ( 1104 function(){ 1105 var id=parseInt(this.id.replace('list_', '')); 1106 if(id > no){ 1107 no = id; 1108 } 1109 } 1110 ); 1111 1112 return no+1; 1113 }, 1114 _remove : function( obj ){ 1115 var $this=this; 1116 1117 $(obj).closest('li').slideUp 1118 ( 1119 function(){ 1120 $this.removesData.push(this.id.replace('list_', '')); 1121 1122 $(this).find('li').each 1123 ( 1124 function(){ 1125 if( typeof this.id != 'undefined' ){ 1126 $this.removesData.push(this.id.replace('list_', '')); 1127 } 1128 } 1129 ) 1130 1131 $(this).remove(); 1132 $this._depth(); 1133 } 1134 ); 1135 }, 1136 _serialize : function(){ 1137 var $this=this, 1138 //toArray= $this.ol.nestedSortable('toArray', {startDepthCount: 0}), 1139 serialized = $this.ol.nestedSortable('serialize').split('&'), 1140 hash = [] 1141 1142 $('.postdata', $this.platform).remove(); 1143 1144 postdata = $('<div />', {'class' : 'postdata'}).appendTo($this.platform); 1145 1146 for(var i=0; i< serialized.length; i++){ 1147 if( serialized[i] == '' ){ 1148 continue; 1149 } 1150 1151 var item = serialized[i].replace('list[', '').split(']='), 1152 id = item[0], 1153 pid = item[1]=='null'? 0 : item[1], 1154 text = $('#list_' + id + ' > div', $this.ol).text().trim(), 1155 sort = 1, 1156 str ='' 1157 1158 if( typeof hash[pid] == 'undefined'){ 1159 hash[pid]=1; 1160 }else{ 1161 hash[pid]+=1; 1162 } 1163 1164 sort = hash[pid]; 1165 postdata.append($('<input />', {'type' : 'hidden', 'name' : 'sitemap['+id+'][id]', 'value' : id})); 1166 postdata.append($('<input />', {'type' : 'hidden', 'name' : 'sitemap['+id+'][pid]', 'value' : pid})); 1167 postdata.append($('<input />', {'type' : 'hidden', 'name' : 'sitemap['+id+'][text]', 'value' : text})); 1168 postdata.append($('<input />', {'type' : 'hidden', 'name' : 'sitemap['+id+'][sort]', 'value' : sort})); 1169 } 1170 1171 for(var i=0; i< $this.removesData.length; i++){ 1172 postdata.append($('<input />', {'type' : 'hidden','name' : 'sitemap_remove[]', 'value' : $this.removesData[i]})); 1173 } 1174 }, 1175 _hook : function(action, target){ 1176 if( typeof this.options.event[action] == 'function' ) 1177 { 1178 this.options.event[action](target); 1179 } 1180 } 1181 } 1182); 1183 1184/* 1185----------------------------------------------------------- 1186tree nodes 1187*/ 1188$.module['nested.tree'] = function(platform, options) { 1189 this.platform = platform; 1190 this.ul = $('ul', platform); 1191 this.options = $.extend 1192 ( 1193 { 1194 'title' : 'nodes', 1195 'open' : false 1196 }, 1197 options 1198 ); 1199 1200 this.__construct(); 1201} 1202$.extend 1203( 1204 $.module['nested.tree'].prototype, { 1205 __construct : function() { 1206 var $this = this; 1207 1208 $this.platform.addClass('plani-tree-wrap'); 1209 1210 if( this.options.title != '' ) 1211 { 1212 $this.platform.prepend('<h2 class="title">' +this.options.title+ '</h2>'); 1213 } 1214 1215 $this.ul.each 1216 ( 1217 function(){ 1218 var li=$(this).find('>li'); 1219 li.each 1220 ( 1221 function(){ 1222 $(this).prepend( $(this).is(':has(ul)') == true ? '<span class="plus button"></span><span class="folder"></span>' : '<span class="page"></span>'); 1223 } 1224 ); 1225 li.eq(-1).addClass('joinend'); 1226 } 1227 ); 1228 1229 $('li:has(ul) .button', $this.ul).on 1230 ( 1231 'click' , $this._open 1232 ); 1233 1234 if( this.options.open == true ) { 1235 $('li:has(ul) .button', $this.ul).trigger('click'); 1236 } 1237 }, 1238 _open : function(e){ 1239 var target = $(this).closest('li'), 1240 ul = target.find('>ul'), 1241 span = target.find('span'), 1242 hide = ul.is(':hidden'); 1243 1244 if( hide == true ){ 1245 ul.show(); 1246 }else{ 1247 ul.hide(); 1248 } 1249 1250 span.eq(0).attr('class',hide? 'minus' : 'plus') 1251 .end() 1252 .eq(1).attr('class',hide? 'folder-open' : 'folder'); 1253 } 1254 } 1255); 1256 1257/* 1258----------------------------------------------------------- 1259animate flip 1260*/ 1261$.module['animate.flip'] = function( platform, options ) { 1262 this.platform = platform; 1263 this.btn = { 1264 'flip' : $('.flip', platform), 1265 'unflip' : $('.unflip', platform) 1266 } 1267 this.layer = { 1268 'front' : $('.front', platform), 1269 'back' : $('.back', platform) 1270 } 1271 this.queue = true; 1272 1273 this.options = $.extend 1274 ( 1275 { 1276 trigger : 'menual', 1277 reverse: true, 1278 axis: 'y' 1279 }, 1280 options 1281 ); 1282 1283 this.__construct(); 1284} 1285 1286$.extend 1287( 1288 $.module['animate.flip'].prototype, { 1289 __construct : function() { 1290 var $this = this 1291 1292 $this.platform.addClass('plani-flip').flip($this.options); 1293 1294 $this.btn.flip.on 1295 ( 1296 'click', function(){ 1297 $this._flip();
1298 } 1299 ); 1300 1301 $this.btn.unflip.on 1302 ( 1303 'click', function(){ 1304 $this._unflip(); 1305 } 1306 ); 1307 1308 setInterval 1309 ( 1310 function(){ 1311 var layer = $this.queue == true? $this.layer.front : $this.layer.back; 1312 $this.platform.height(layer.height()) 1313 }, 1314 100 1315 ); 1316 1317 $this._unflip(); 1318 }, 1319 _flip : function(){ 1320 this.queue = false; 1321 this.platform.flip(true); 1322 this.layer.back.css('opacity', '1'); 1323 this.layer.front.css('opacity', '0'); 1324 }, 1325 _unflip : function(){ 1326 this.queue = true; 1327 this.platform.flip(false); 1328 this.layer.front.css('opacity', '1'); 1329 this.layer.back.css('opacity', '0'); 1330 } 1331 } 1332); 1333 1334 1335 1336/* 1337----------------------------------------------------------- 1338animate tabs 1339*/ 1340$.module['animate.tabs'] = function( platform, options ) { 1341 this.platform = platform; 1342 this.btn = $(' > ol > li', platform); 1343 this.layer = $(' > div', platform); 1344 this.options = $.extend 1345 ( 1346 { 1347 start : '0', 1348 prefix : '<i class="fa fa-angle-right" aria-hidden="true"></i>' 1349 }, 1350 options 1351 ); 1352 1353 this.__construct(); 1354} 1355 1356$.extend 1357( 1358 $.module['animate.tabs'].prototype, { 1359 __construct : function() { 1360 var $this=this; 1361 1362 $this.btn.attr('tabindex', 0); 1363 $this.btn.prepend($this.options.prefix); 1364 1365 $this.btn.on 1366 ( 1367 'click', function( e ){ 1368 var no=$this.btn.index(this); 1369 1370 $this.btn.removeClass('on').eq(no).addClass('on'); 1371 $this.layer.hide().eq(no).fadeIn('fast'); 1372 } 1373 ) 1374 .keyenter('click') 1375 .eq($this.options.start) 1376 .trigger('click'); 1377 } 1378 } 1379); 1380 1381 1382 1383/* 1384----------------------------------------------------------- 1385animate scroll 1386*/ 1387$.module['animate.scroll'] = function( platform, options ) { 1388 var $this = this; 1389 $this.platform = platform; 1390 1391 //bug 1392 $.window.on('load', function(){ 1393 $this.fix = $this.platform.position().top; 1394 $this.__construct(); 1395 }); 1396} 1397 1398$.extend 1399( 1400 $.module['animate.scroll'].prototype, { 1401 __construct : function() { 1402 var $this=this; 1403 1404 $.window.on 1405 ( 1406 'scroll', function(){ 1407 var top = $(document).scrollTop(), 1408 move = top > $this.fix ? (top-$this.fix) : 0; 1409 1410 console.log($.window.height()); 1411 1412 if( $.window.height() > ($this.platform.height()+100) || move == 0 ) { 1413 $this.platform.stop().animate 1414 ( 1415 { 'top' : move } 1416 ); 1417 } 1418 } 1419 ).on 1420 ( 1421 'resize', function(){ 1422 $this.platform.css('top', 0); 1423 $.window.trigger('scroll'); 1424 } 1425 ); 1426 1427 setTimeout(function(){ 1428 $.window.trigger('scroll'); 1429 },100) 1430 } 1431 } 1432); 1433 1434/* 1435----------------------------------------------------------- 1436board lists 1437*/ 1438$.module['board.lists'] = function( platform, options ){ 1439 this.platform = platform; 1440 this.options = $.extend 1441 ( 1442 { 1443 'layer' : '.request', 1444 'grid' : false, 1445 'autoload' : false, 1446 'callback' : function(){} 1447 }, 1448 options 1449 ); 1450 this.grid_options = { 1451 'able' : this.options.grid, 1452 'paging' : null, 1453 'col_width' : [], 1454 'min_height' : 200 1455 } 1456 this.pos_left = 0; 1457 this.layer = $(this.options.layer, platform); 1458 1459 this.__construct(); 1460} 1461 1462$.extend 1463( 1464 $.module['board.lists'].prototype, { 1465 __construct : function() { 1466 var $this=this; 1467 1468 $this.layer.addClass('plani-board-lists'); 1469 $this.platform.delegate('.paging-area a', 'click', function(){ 1470 if( $(this).attr('href') != '#' ){ 1471 $this.request( $(this).attr('href') ); 1472 } 1473 return false; 1474 }); 1475 1476 new $.module['form']( $this.platform, { 1477 'ajax' : false, 1478 'before' : function(){ 1479 $this.request(); 1480 return false; 1481 } 1482 }); 1483 1484 if( $this.options.autoload == true ) { 1485 $this.request(); 1486 }else { 1487 $this._trigger(); 1488 } 1489 }, 1490 request : function( url ){ 1491 var $this = this; 1492 1493 if( !url ){ 1494 url = $this.platform.attr('action'); 1495 } 1496 1497 try { 1498 var $scrollerOuter = $( '.mCustomScrollbar' ); 1499 var $dragger = $scrollerOuter.find( '.mCSB_dragger' ).eq(1); 1500 var scrollWidth = $scrollerOuter.find( '.mCSB_container' ).width(); 1501 var draggerLeft = $dragger.position().left; 1502 var scrollLeft = draggerLeft / ($scrollerOuter.width() - $dragger.width()) * (scrollWidth - $scrollerOuter.width()); 1503 $this.pos_left = scrollLeft; 1504 } 1505 catch (e) { 1506 } 1507 1508 $this.layer.append('<div class="progress"><i class="xi-spinner-1 xi-spin"></i></div>'); 1509 $.request( { 'url' : url,'param' : $this.platform.serialize() }, function( html ){ 1510 var $html = $(html); 1511 1512 history.pushState({}, '', $html.find('input[name=history]').val()); 1513 if( $this.grid_options.able == true ) { 1514 $this._grid_reset(); 1515 } 1516 1517 $html.filter(':not(' +$this.options.layer+ ')').find('[update-id]').each(function(){ 1518 var obj1 = $(this), 1519 obj2 = $('[update-id=' +obj1.attr('update-id')+ ']', $this.platform); 1520 1521 if( obj2.length > 0 ){ 1522 obj2.after(obj1).remove(); 1523 } 1524 }); 1525 1526 $this.layer.html($html.find($this.options.layer).html()); 1527 $this._trigger(); 1528 }); 1529 }, 1530 _trigger : function(){ 1531 var $this=this, 1532 order_by=$('[name=search_order]', $this.platform).val(), 1533 sort=typeof order_by != 'undefined' ? order_by.split(' ') : ['', 'asc'], 1534 th=$('th[sort]', $this.platform); 1535 1536 if( typeof $this.options.callback == 'function' ){ 1537 this.options.callback($this.platform); 1538 } 1539 1540 th.each 1541 ( 1542 function(){ 1543 var target=$(this); 1544 target.append('<span class="sort"></span>').addClass('cursor-hand'); 1545
1546 if( target.attr('sort') == sort[0] ){ 1547 $('span', target).attr('class', 'sort ' + (sort.length < 2 ? 'asc' : sort[1]) ); 1548 } 1549 1550 target.on('click', function(){ 1551 var span=$('span', target), 1552 order_by=span.hasClass('asc') == true? 'desc' : 'asc', 1553 val=target.attr('sort') + ' ' + order_by; 1554 1555 $('[name=search_order]', $this.platform).val(val); 1556 $this.platform.submit(); 1557 }); 1558 } 1559 ); 1560 1561 if( $this.grid_options.able == true ) { 1562 $this._grid_set(); 1563 } 1564 }, 1565 _grid_set : function() { 1566 this.layer.addClass('plani-grid'); 1567 1568 if( this.grid_options.paging == null ){ 1569 this.grid_options.paging = $('<div />', {'class' : 'plani-grid-paging'}); 1570 this.layer.after(this.grid_options.paging); 1571 } 1572 1573 this.grid_options.paging.html(this.layer.children().not('table')); 1574 1575 this._grid(); 1576 }, 1577 _grid_reset : function() { 1578 this.layer.mCustomScrollbar("destroy"); 1579 this.layer.removeClass('plani-grid'); 1580 1581 }, 1582 _grid_scroll : function() { 1583 var top = parseInt($('.mCSB_container', this.layer).css('top'))*-1; 1584 1585 $('.col-resize', this.layer).css('top', top); 1586 try { 1587 var tfoot = $('tfoot', this.layer); 1588 1589 tfoot.css('top', (top + this.layer.height() - tfoot.height())-2); 1590 }catch (e) { 1591 } 1592 }, 1593 _grid_resize : function( cols, base, extend ) { 1594 var $this = this, 1595 table_width = $('table', $this.layer).width(), 1596 base_col_size = base.length; 1597 1598 base.each 1599 ( 1600 function( no ){ 1601 var w = $(this).width(); 1602 1603 if( extend == true ){ 1604 if( typeof $this.grid_options.col_width[no] != 'undefined' ){ 1605 w = $this.grid_options.col_width[no]; 1606 } 1607 if( w < 60 ){ 1608 w = 60; 1609 } 1610 } 1611 1612 if( base_col_size == (no+1) ) { 1613 w=table_width; 1614 }else { 1615 table_width-=w; 1616 } 1617 1618 for( var key in cols ) { 1619 var col = cols[key]; 1620 try { 1621 col.eq(no).width(w); 1622 }catch (e) { 1623 } 1624 } 1625 1626 $this.grid_options.col_width[no] = w; 1627 } 1628 ); 1629 }, 1630 _grid_resize_overap : function( overap, base ) { 1631 var $this = this; 1632 1633 for( var i=0; i < overap.length; i++ ) { 1634 var target= overap[i], 1635 w = 0, 1636 l = 0 1637 1638 for( var x=target.start; x<=target.end; x++ ) { 1639 w+=base.eq(x).outerWidth(); 1640 1641 if( x == target.start ){ 1642 l = base.eq(x).position().left; 1643 } 1644 } 1645 1646 target.obj.css({'left': l+($.info.isie == true ? -1 : 0), 'width' : w+1}); 1647 } 1648 }, 1649 _grid : function() { 1650 var $this = this, 1651 _table = $('table', $this.layer), 1652 _thead = $('thead', _table), 1653 _tbody = $('tbody', _table), 1654 _tfoot = $('tfoot', _table), 1655 _trows = $('trows name', $this.platform), 1656 _trows_cols = [], 1657 _ths = $('tr:eq(0) th', _thead), 1658 _tds = $('tr:eq(0) td', _tbody), 1659 _tfoot_tds = $('td', _tfoot), 1660 _col_size = _ths.length 1661 1662 if( _tds.length > 0 ) { 1663 _tbody.append('<tr><td colspan="' +_col_size+ '" class="end-tr"> </td></tr>'); 1664 } 1665 1666 if( _trows.length > 0 ) { 1667 var eq_no = 0; 1668 _trows.each 1669 ( 1670 function(){ 1671 var colspan = parseInt($(this).attr('colspan')), 1672 text = $(this).attr('value'), 1673 bg = $(this).attr('bg') 1674 1675 if( colspan > 1 ) { 1676 _ths.eq(eq_no).prepend('<div class="grp">'+text+'</div>'); 1677 for(var i=1; i<colspan; i++ ){ 1678 _ths.eq(eq_no+i).prepend('<div class="grp"> </div>') 1679 } 1680 1681 _trows_cols.push({'obj' : $('<div />', {'class' : 'grp-overap'}).html(text).css('background', bg) , 'start' : eq_no, 'end' : eq_no+(i-1)}); 1682 }else { 1683 _ths.eq(eq_no).prepend('<div class="grp-text"> </div>'); 1684 } 1685 eq_no+=colspan; 1686 } 1687 ); 1688 } 1689 1690 $this._grid_resize( 1691 [_ths], _ths, true 1692 ); 1693 1694 $this.layer.mCustomScrollbar({ 1695 theme : 'minimal-dark', //rounded-dark 1696 axis:"xy", 1697 scrollButtons:{ 1698 enable : true 1699 }, 1700 setLeft : ($this.pos_left+ (($this.pos_left / 500)*10)) + 'px', 1701 callbacks:{ 1702 onInit : function(){ 1703 $this._grid_scroll(); 1704 }, 1705 whileScrolling : function(){ 1706 $this._grid_resize( 1707 [_ths, _tfoot_tds], _ths, true 1708 ); 1709 $this._grid_scroll(); 1710 } 1711 } 1712 }); 1713 $this.pos_left = 0; 1714 1715 $.window.off('resize.grid').on 1716 ( 1717 'resize.grid', function() { 1718 $('.col-resize', _table).remove(); 1719 1720 var clone = _thead.clone().height(_thead.height()+1).addClass('col-resize'), 1721 clone_th = $('th', clone).height(_thead.height()+1); 1722 1723 clone_th.each 1724 ( 1725 function(no){ 1726 $(this) 1727 .on 1728 ( 1729 'click', function(){ 1730 _ths.eq(no).trigger('click'); 1731 } 1732 ); 1733 } 1734 ); 1735 1736 for( var i=0; i < _trows_cols.length; i++ ) 1737 { 1738 clone.append(_trows_cols[i].obj); 1739 } 1740 1741 _table.prepend(clone); 1742 1743 1744 var layer_height = $(this).height() - $this.layer.offset().top - $this.grid_options.min_height; 1745 if( layer_height > _table.height()+50 ) { 1746 layer_height = _table.height()+50; 1747 } 1748 1749 if( layer_height < $this.grid_options.min_height ) { 1750 layer_height = $this.grid_options.min_height; 1751 } 1752 1753 $this.layer.height(layer_height); 1754 1755 _table.removeAttr('id').colResizable({ 1756 'minWidth' : 60, 1757 'onResize' : function(e){
1758 $this._grid_resize_overap( 1759 _trows_cols, clone_th 1760 ); 1761 $this._grid_resize( 1762 [_ths, _tfoot_tds], clone_th, false 1763 ); 1764 } 1765 }); 1766 1767 $this._grid_resize( 1768 [_ths, _tfoot_tds], clone_th, false 1769 ); 1770 $this._grid_resize( 1771 [_ths, _tfoot_tds], clone_th, true 1772 ); 1773 $this._grid_resize_overap( 1774 _trows_cols, _ths 1775 ); 1776 $this._grid_scroll(); 1777 1778 } 1779 ); 1780 1781 setTimeout(function(){ 1782 $.window.trigger('resize.grid'); 1783 }, 500); 1784 } 1785 } 1786); 1787 1788/* 1789----------------------------------------------------------- 1790board masonry 1791*/ 1792$.module['board.masonry'] = function( platform, options ){ 1793 this.platform = platform; 1794 this.options = $.extend 1795 ( 1796 { 1797 'layer' : '.request', 1798 'paging' : '.paging-area', 1799 'items' : '.masonry_item', 1800 'callback' : function(){} 1801 }, 1802 options 1803 ); 1804 1805 this.params = { num : 0, width : 0, margin : 20 } 1806 this.layer = $(this.options.layer, platform); 1807 this.items = $(this.options.items, this.layer); 1808 this.pageing = $(this.options.paging, platform).hide(); 1809 this.progress = $('<div />', {'class' : 'progress' }).html('<i class="xi-spinner-1 xi-spin"></i>').appendTo(this.layer); 1810 this.empty = $('<div />', {'class' : 'empty-data' }).html(__('ê²ì ê²°ê³¼ê° ììµëë¤')).appendTo(this.layer); 1811 1812 this.__construct(); 1813} 1814 1815 1816$.extend 1817( 1818 $.module['board.masonry'].prototype, { 1819 __construct : function(){ 1820 var $this=this; 1821 1822 $this.layer.addClass('plani-board-masonry'); 1823 $this.platform.delegate 1824 ( 1825 '.paging-area a', 'click', function(){ 1826 if( $(this).attr('href') != '#' ){ 1827 $this.request( $(this).attr('href'), true ); 1828 } 1829 return false; 1830 } 1831 ); 1832 1833 new $.module['form'] 1834 ( 1835 $this.platform, { 1836 'ajax' : false, 1837 'before' : function(){ 1838 $this.request(); 1839 return false; 1840 } 1841 } 1842 ); 1843 1844 setTimeout(function(){ 1845 $this.progress.remove(); 1846 $this.pageing.show(); 1847 $this.resizer 1848 ( 1849 $this.layer.width(), 1850 'fadein' 1851 ); 1852 $(this).on 1853 ( 1854 'resize', function(){ 1855 if( typeof this.resizedFinished != 'undefined' ){ 1856 clearTimeout(this.resizedFinished); 1857 } 1858 1859 this.resizedFinished = setTimeout 1860 ( 1861 function(){ 1862 $this.resizer 1863 ( 1864 $this.layer.width(), 1865 'sort' 1866 ); 1867 }, 1868 200 1869 ); 1870 } 1871 ); 1872 }, 300); 1873 }, 1874 resizer : function( width, method ){ 1875 var $this=this, 1876 num = 6 1877 1878 if( width < 600) 1879 num = 1; 1880 else if( width <= 800) 1881 num = 2; 1882 else if( width <= 1100 ) 1883 num = 3; 1884 else if( width <= 1400 ) 1885 num = 4; 1886 else if( width <= 1700 ) 1887 num = 5; 1888 1889 $this.params.num = num; 1890 $this.params.width = width; 1891 $this.items = $($this.options.items, this.platform); 1892 1893 setTimeout 1894 ( 1895 function(){ 1896 $this.netsort(method); 1897 }, 100 1898 ) 1899 }, 1900 netsort : function(method){ 1901 var $this=this, 1902 positioning = $this._position( method ), 1903 original_method = method, 1904 myno = 0; 1905 1906 $this.items.each 1907 ( 1908 function(no){ 1909 var target = $(this), 1910 item_pos = positioning[myno]; 1911 1912 if( original_method == 'reload' ) 1913 { 1914 if(typeof target.attr('data-load') != 'undefined' ){ 1915 myno++; 1916 method = target.attr('data-load'); 1917 }else{ 1918 method = 'fadeout'; 1919 } 1920 }else{ 1921 myno++; 1922 } 1923 1924 target.stop(); 1925 1926 if( method == 'fadein'){ 1927 target.css 1928 ( 1929 {'left' : item_pos.end_left, 'top' : item_pos.end_top, 'transform' : 'scale(0.5, 0.5)', 'opacity' : 0} 1930 ); 1931 1932 target.transition 1933 ( 1934 { 1935 'opacity' : 1, 1936 'transform' : 'scale(1.0, 1.0)', 1937 'duration' : 800 1938 } 1939 ); 1940 }else if( method == 'fadeout' ) 1941 { 1942 target.transition 1943 ( 1944 { 1945 'opacity' : 0, 1946 'transform' : 'scale(0.5, 0.5)', 1947 'duration' : 800 1948 }, 1949 function(){ 1950 target.remove(); 1951 } 1952 ); 1953 1954 }else 1955 { 1956 target.animate 1957 ( 1958 { 1959 'left' : item_pos.end_left, 1960 'top' : item_pos.end_top, 1961 'opacity' : 1 1962 }, 1963 { duration : 500 + (no*50) }, 1964 'slow', 1965 'easeOutCirc' 1966 ); 1967 } 1968 } 1969 ); 1970 }, 1971 request : function( url, focus ){ 1972 var $this = this; 1973 1974 if( !url ){ 1975 url = $this.platform.attr('action'); 1976 } 1977 1978 $.request 1979 ( 1980 { 1981 'url' : url, 1982 'param' : $this.platform.serialize() 1983 }, 1984 function( html ){ 1985 if( focus == true ) { 1986 $('html, body').scrollTop($this.layer.position().top); 1987 } 1988 1989 $this._parse(html); 1990 } 1991 ); 1992 }, 1993 _parse : function( html ){ 1994 var $this=this, 1995 text_obj=$(html), 1996 new_items=$(this.options.items, text_obj).clone(), 1997 paging=$(this.options.paging, text_obj).clone(), 1998 sorts =[]; 1999 2000 $this.items = $(this.options.items, $this.layer); 2001 $this.items.removeAttr('data-load'); 2002 2003 new_items.each 2004 ( 2005 function(no){ 2006 var new_target = $(this), 2007 new_target_data = new_target.data(), 2008 old_target = $this.items.filter('[data-id=' +new_target_data.id+ ']'); 2009 2010 old_target.find('a').attr('href', new_target_data.href); 2011 2012 if( $this.items.eq(no).length == 0 ){ 2013 if( old_target.length < 1 ){ 2014 sorts[no]=new_target.attr('data-load', 'fadein'); 2015 }else{ 2016 sorts[no]=old_target.attr('data-load', 'sort'); 2017 } 2018 }else{ 2019 if( old_target.length < 1 ){ 2020 sorts[no]=new_target.attr('data-load', 'fadein'); 2021 }else{ 2022 sorts[no]=old_target.attr('data-load', 'sort'); 2023 } 2024 } 2025 } 2026 ); 2027 2028 for(var i=0; i<sorts.length; i++) { 2029 $this.layer.append(sorts[i]); 2030 } 2031 2032 if( sorts.length == 0 ){ 2033 $this.empty.show(); 2034 $this.pageing.html(''); 2035 }else{ 2036 $this.empty.hide(); 2037 $this.pageing.html(paging.html()); 2038 } 2039 $this.resizer 2040 ( 2041 $this.layer.width(), 2042 'reload' 2043 ); 2044 }, 2045 _position : function( method ){ 2046 var $this=this, 2047 $params = $this.params, 2048 $return = {}, 2049 $items = method == 'reload'? $this.items.filter('[data-load]') : $this.items, 2050 item_width = (($params.width - (($params.num+1)*$params.margin)) / $params.num) + (($params.margin / $params.num) * 2), 2051 latest_height = []; 2052 2053 2054 2055 $items.stop().width(item_width).removeAttr('data-no').each 2056 ( 2057 function( no ){ 2058 var item_sort_num = no == 0 ? 0 : no % $params.num, 2059 item_sort_top_target = $items.filter('[data-no=' +item_sort_num+ ']'), 2060 item_left = (($params.margin / 2) + (item_sort_num * $params.margin) + (item_width * item_sort_num)) - ($params.margin ) , 2061 item_top = item_sort_top_target.length < 1? 0 : $this._top_sum(item_sort_top_target, method), 2062 target = $(this); 2063 2064 2065 target.attr({ 'data-no' : item_sort_num }); 2066 $return[no] = { 2067 'end_width' : item_width, 2068 'end_height' : target.height(), 2069 'end_left' : item_left, 2070 'end_top' : item_top 2071 } 2072 2073 latest_height.push(item_top + target.height()); 2074 } 2075 ); 2076 2077 $this.layer.stop().animate({ 'height' : Math.max.apply(null, latest_height) + 50 }); 2078 2079 return $return; 2080 }, 2081 _top_sum : function(item_sort_top_target){ 2082 var h=0; 2083 2084 item_sort_top_target.each 2085 ( 2086 function(){ 2087 h+=$(this).height(); 2088 } 2089 ); 2090 2091 return h + (this.params.margin * item_sort_top_target.length); 2092 2093 } 2094 } 2095);
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.