1/** //** ----= mwShow =----------------------------------------------\**//** \ 2* 3* Displays given element using animation setting. 4* 5* @param jQuery el - jQuery element to show. 6* @param funtion callback - Callback to call on finish. 7* 8* @return jQuery - Given element, for chain calls. 9* 10\**//** ------------------------------------= by Mr.V!T @ Morad Media Inc. =----/** //**/ 11function mwShow (el, callback) { 12 13 el = _jq(el); 14 15 var animate = getCookie('G_Animate', 1); 16 17 if ( animate != 0 && el.is(':visible') ) { 18 19 // ToDo: stop or not to stop 20 el.stop(true).fadeIn(200); 21 22 // Calling callback via promise to avoid multiple callbacks. 23 jQuery.when(el).done(function () { 24 25 // Clearing opacity (fix for partial animation stop on show) 26 _jq(this).css('opacity', ''); 27 28 if ( callback ) callback(); 29 30 }); //jQuery.done.callback; 31 32 } else { //IF animation 33 34 el.show(); 35 if ( callback ) callback(); 36 37 } //IF static 38 39 return el; 40} //FUNC mwShow 41 42/** //** ----= mwHide =----------------------------------------------\**//** \ 43* 44* Hides given element using animation setting. 45* 46* @param jQuery el - jQuery element to hide. 47* @param funtion callback - Callback to call on finish. 48* 49* @return jQuery - Given element, for chain calls. 50* 51\**//** ------------------------------------= by Mr.V!T @ Morad Media Inc. =----/** //**/ 52function mwHide (el, callback) { 53 54 el = _jq(el); 55 56 var animate = getCookie('G_Animate', 1); 57 58 if ( animate != 0 && el.is(':visible') ) { 59 60 // ToDo: stop or not to stop 61 el.stop().fadeOut(200); 62 63 // Calling callback via promise to avoid multiple callbacks. 64 jQuery.when(el).done(function () { 65 66 // Clearing opacity (fix for partial animation stop on show) 67 _jq(this).css('opacity', ''); 68 69 if ( callback ) callback(); 70 71 }); //jQuery.done.callback 72 73 } else { //IF animation 74 75 el.hide(); 76 77 if ( callback ) callback(); 78 79 } //IF static 80 81 return el; 82} //FUNC mwHide 83 84function mwError (msg) { 85 return '<div class="status Error">' + msg + '</div>'; 86} //FUNC mwError 87 88function mwSuccess (msg) { 89 return '<div class="status Success">' + msg + '</div>'; 90} //FUNC mwSuccess 91 92function mwHint (msg) { 93 return '<div class="status Hint">' + msg + '</div>'; 94} //FUNC mwHint 95 96function mwFormToggle ($form, $target, $state) { 97 98 // Makikng sure it's jQuery 99 $form = _jq($form); 100 101 // One of form elements can be provided instead of form itself 102 // Checking if that's the case. 103 if ( !$form.is('form') ) 104 $form = $form.closest('form'); 105 106 // Searching target on form 107 var $tEl = $form.find($target); 108 109 // Toggling 110 if ( !isEmpty($state) ) 111 $tEl.show(); 112 else 113 $tEl.hide(); 114 115} //FUNC mwFormToggle 116 117/** //** ----= mwState =----------------------------------------------\**//** \ 118* 119* Sets system to processing/idle state. 120* 121* @param MIXED state 122* bool - TRUE for loading indication, FALSE - idle. 123* string - Status message for idle state (usually operation result) 124* 125* @param MIXED [dialog] 126* bool - FALSE for background (hintbar only). TRUE for common 127* system loading. 128* string - Dialog name, to use for indications. 129* 130* @return bool - Always FALSE. 131* 132\**//** ------------------------------------= by Mr.V!T @ Morad Media Inc. =----/** //**/ 133function mwState (state, dialog) { 134 135 // Omited dialog is TRUE 136 if ( !isSet(dialog) ) 137 dialog = true; 138 139 // Flush hint bar test. 140 HINT_SAVE = false; 141 142 // Updating system indicator 143 if ( state !== true ) { 144 145 // ---- Setting IDLE state ---- 146 147 jQuery('#hint_bar_status_ready').show(); 148 jQuery('#hint_bar_status_working').hide(); 149 150 // Loader should be hided on this step anyway 151 // In some cases when window was created during loading, loader may miss this 152 // So it does not heart to forcehide 153 mwWindow('LoaderWindow').hide(); 154 155 // Updating modal loaders 156 if ( typeof(dialog) == 'string' ) { 157 158 // ---- Custom dialog ---- 159 160 mwWindow(dialog).State(state); 161 162 } else { 163 164 // ---- Common loader and background ---- 165 166 if ( state !== false ) 167 jQuery('#HintPlaceholder').html(state); 168 169 } //IF no dialog 170 171 } else { //IF working 172 173 // ---- Setting WORKING state ---- 174 175 jQuery('#hint_bar_status_ready').hide(); 176 jQuery('#hint_bar_status_working').show(); 177 178 // Updating modal loaders 179 if ( typeof(dialog) == 'string' && mwWindow(dialog).Visible ) { 180 181 // ---- Custom dialog ---- 182 183 mwWindow(dialog).State(state); 184 185 } else if ( dialog ) { //IF dialog set 186 187 // ---- Common loader ---- 188 189 mwWindow('LoaderWindow').show(); 190 191 } //IF common loader
192 193 } //IF idle 194 195 return false; 196} //FUNC mwState 197 198/** //** ----= mwExHandle =--------------------------------------------------------------------------------------\**//** \ 199* 200* Morweb global exceptions handler. Basic handlinng for now. This way user can say at least smth. 201* 202* @see window.onerror handler doc for parameters list. 203* 204\**//** ---------------------------------------------------------------------------= by Mr.V!T @ Morad Media Inc. =----/** //**/ 205function mwExHandle (msg, url, lineNo) { 206 207 // ToDo: test compatability 208 // ToDo: Implement class based exceptions logic, 209 // and filter errors to separate debug (not shown to user) and user friendly messages 210 211 // If nothing to show - showing nothing 212 if ( !msg ) 213 return; 214 215 // Forcing message to be string (in case object given - relying on native toString() ) 216 var msg = msg + ''; 217 218 // Removing trash 219 msg = msg.replace('uncaught exception:', ''); 220 221 mwState( mwError(msg) ); 222 223} //FUNC mwExHandle 224 225var mwHintShow = false; 226 227function mwWatchHints ($context, $dialog) { 228 229 var $target = ( $dialog ) ? '#' + $dialog + ' .winStatus' : '#HintPlaceholder'; 230 231 $context = _jq($context); 232 233 $context 234 .off('mouseenter.mwHints') 235 .off('mouseleave.mwHints') 236 .on('mouseenter.mwHints', '[title], [hint], [error]', function() { 237 238 if ( mwHintShow ) 239 return; 240 241 mwHintShow = true; 242 243 // Saving hintbar content 244 this.HINT_SAVE = jQuery($target).html(); 245 246 // Temporary allowing 'title' attribute to act as hint. 247 // Later only 'hint' will be used to avoid title tricks 248 249 // First trying if there is error 250 var hint = jQuery(this).attr('error'); 251 var cls = 'Error'; 252 253 // If no error, trying hint 254 if ( !hint ) { 255 hint = jQuery(this).attr('hint') || jQuery(this).attr('title'); 256 cls = 'Hint'; 257 } //IF no error 258 259 // Placing hint 260 if ( hint ) 261 jQuery($target).html('<div class="status ' + cls + '">' + hint + '</div>'); 262 263 // Removing title ( unnecessary later ) 264 this.TITLE_SAVE = this.title; 265 this.title = ''; 266 267 }) //FUNC mouseenter 268 .on('mouseleave.mwHints', '[title], [hint], [error]', function() { 269 270 this.title = this.TITLE_SAVE; 271 jQuery($target).html(this.HINT_SAVE); 272 273 mwHintShow = false; 274 }) //FUNC mouseleave 275 ; //jQuery(context) 276 277} //FUNC mwWatchHints 278 279/*--------------------------------------------------------------------------------*\ 280| setHintElements 281|---------------------------------------------------------------------------------- 282| Set's elements for dynamic hints. 283| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 284| Params: 285| selector string - Target elements jQuery selector. 286| Return: 287| bool - Always FALSE. 288\*--------------------------------------------------------------= by Mr.V!T =-----*/ 289function setHintElements (selector, dialog) { 290 291 var target = ( dialog ) ? '#' + dialog + ' .winStatus' : '#HintPlaceholder'; 292 293 selector = _jq(selector); 294 295 selector 296 .unbind('mouseenter') 297 .unbind('mouseleave') 298 .hover( function() { 299 // Saving hintbar content 300 HINT_SAVE = jQuery(target).html(); 301 302 // Temporary allowing 'title' attribute to act as hint. 303 // Later only 'hint' will be used to avoid title tricks 304 305 // First trying if there is error 306 var hint = jQuery(this).attr('error'); 307 var cls = 'Error'; 308 309 // If no error, trying hint 310 if ( !hint ) { 311 hint = jQuery(this).attr('hint') || jQuery(this).attr('title'); 312 cls = 'Hint'; 313 } //IF no error 314 315 // Placing hint 316 if ( hint ) 317 jQuery(target).html('<div class="status ' + cls + '">' + hint + '</div>'); 318 319 // Removing title ( unnecessary later ) 320 TITLE_SAVE = this.title; 321 this.title = ''; 322 323 }, //FUNC over 324 function() { 325 326 this.title = TITLE_SAVE; 327 328 if ( HINT_SAVE !== false ) 329 jQuery(target).html(HINT_SAVE); 330 } //FUNC out 331 ); //jQuery onclick 332 333} //FUNC setHintElements 334 335/** //** ----= mwUpdateScrolls =--------------------------------------------------------------------------------------\**//** \ 336* 337* Updates scollable contents. 338* 339* @param jQuery [$context] - Context to search scrolls within. 340* 341* @return jQuery - Scrollable elements found. 342* 343\**//** ---------------------------------------------------------------------------= by Mr.V!T @ Morad Media Inc. =----/** //**/ 344function mwUpdateScrolls ($context) { 345 346 if ( !isFunction(jQuery.fn.mCustomScrollbar) ) 347 return false; 348 349 $context = $context ? _jq($context) : jQuery(document); 350 351 var $scrolls = $context.find('.mwScroll'); 352 353 $scrolls.mCustomScrollbar('destroy') 354 $scrolls.mCustomScrollbar({ 355 theme : 'dark', 356 autoHideScrollbar : true, 357 // scrollInertia : false, 358 contentTouchScroll : true, 359 advanced : { 360 // autoScrollOnFocus : true 361 } 362 }); //mCustomScrollbar 363 364 return $scrolls; 365} //FUNC mwUpdateScrolls 366 367/** //** ----= OBJECT mwAjax =--------------------------------------------------------------------------------------\**//** \ 368* 369* Morweb system Ajax procesing object. 370* 371* @package Morweb 372* @subpackage System 373* @category helper 374*
375* @param string url - Path to controller to request from. 376* 377* @param MIXED [post] - Data to post on request. Can be DOM form, jQuery selector 378* or object which points to form, or object with parameters. 379* 380* @param MIXED [dialog]- Any valid mwState() dialog value. 381* 382\**//** ---------------------------------------------------------------------------= by Mr.V!T @ Morad Media Inc. =----/** //**/ 383function mwAjax (url, data, dialog) { 384 385 // Creating morweb extension object 386 var exObj = { 387 388 'dialog' : dialog, // Dialog related to call. Will be used to display status. 389 390// ==== CONTENTS =============================================================================================================== 391 392 /** //** ----= parseContents =------------------------------------------------------------------------------\**//** \ 393 * 394 * Parses AraxResult for different content types. 395 * 396 * @param object(AjaxResult) data - Result in vAjax object format. 397 * 398 \**//** -------------------------------------------------------------------= by Mr.V!T @ Morad Media Inc. =----/** //**/ 399 parseContents : function (data) { 400 401 var self = this; 402 403 // If smth wrong come - nothing to do 404 if ( !data ) return; 405 406 // ---- Processing debug (unexpected output) ---- 407 408 if ( data._debug && typeof(mwRawDump) != 'undefined' ) 409 mwRawDump('#wDebugCurrent', data._debug); 410 411 delete data._debug; 412 413 // ---- Processing validations ---- 414 415 if ( data._validations ) { 416 417 // To be sure that smth correct come 418 if ( typeof(data._validations) == 'object' ) { 419 420 //Processig each given validations form 421 for ( var form in data._validations ) { 422 423 // Skipping not forms ( numeric indexies are allowed ) 424 if ( isInt(form) ) continue; 425 426 // Normally forms are specified by ids, if not found, then it's for custom processing 427 // Trying to define context first to speedup and avoid cross windows applying 428 var context = ( typeof(this.dialog) == 'string ' ) ? mwWindow(this.dialog).Body : jQuery('#' + form); 429 430 // Setting validations 431 setValidations(context, data._validations[form]); 432 433 } //FOR each form 434 435 } //IF object comed 436 437 } //IF validations given 438 439 // ---- Processing cahces ----- 440 441 if ( !data._cache ) return; 442 443 var cache = data._cache; 444 delete data._cache; 445 446 // HTML comed can contain errors, 447 // though jQuery may still insert it, exception is happen right AFTER insert. 448 // To prevent script stop (content was inserted anyway) - catching exceptions 449 // for each insert individually (to process others which are succeed) and relogging them in console. 450 451 // ---- Setting up data cache ---- 452 453 // Making sure mwData exists at all 454 if ( typeof(mwData) == 'undefined' ) 455 mwData = {}; 456 457 if ( cache.Data ) { 458 459 /*/ 460 if (mwData.Users); 461 __(mwData.Users); 462 463 /**/ 464 // ToDo: Seems that jQuery.extend() does not merge arrays propertly 465 // And empty objects/assoc arrays (which meant to be data objects) 466 // come as list arrays, which are not merged 467 jQuery.extend(true, mwData, cache.Data); 468 /*/ 469 470 if (mwData.Users); 471 __(mwData.Users); 472 /**/ 473 } //IF Data set 474 475 // ---- Setting up windows ---- 476 477 // Using mwWinManager to get windows system container 478 var $winContainer = mwWinManager.init().Container; 479 480 if ( cache.Windows ) { 481 482 for ( var i in cache.Windows ) { 483 484 // Checking for html within regular results 485 if ( !data['_wc_'+i] ) continue; 486 487 var wnd = mwWindow(i); 488 var $old = wnd.Window; 489 490 // Disablingg old window, but keeping it's element 491 // This allows updated window to init in background, with smooth transition 492 // In addition - increasing z-index, to make sure it stays on top, covering new version 493 if ( $old && $old.length ) { 494 495 // Removing IDs and names from old elements, to allow proper init 496 $old.removeAttr('id') 497 $old.find('[id], [name]').removeAttr('id name'); 498 499 // Increasing z-index, just setting it notably higher 500 $old.css('z-index', $old.css('z-index')*1+100 ); 501 502 } //IF old window present 503 504 try { 505 var el = jQuery('<div id="' + i + '" class="winEl">' + data['_wc_'+i] + '</div>') 506 .appendTo($winContainer); 507 508 } catch (e) { 509 510 // Researching window, cuz it still may be inserted 511 var el = $winContainer.find('#' + i); 512 513 console.error(e); 514 } //TRY 515 516 // Initiating window 517 wnd.Element(el).align(); 518 519 // Removing old window element if there was one 520 if ( $old && $old.length ) 521 $old.remove(); 522 523 // Initiating title 524 if ( cache.Windows[i] ) 525 wnd.Title(cache.Windows[i]); 526 527 delete data['_wc_'+i]; 528 529 } //FOR each window in system 530 531 } //IF windows set 532 533 // ---- Setting up contents ---- 534 535 if ( cache.Contents ) { 536 537 for ( var i in cache.Contents ) { 538 // Checking for html within regular results 539 if ( !data['_cc_'+i] ) continue; 540 541 try { 542 jQuery('#' + i).html(data['_cc_'+i]); 543 } catch (e) { 544 console.error(e); 545 } //TRY 546 547 delete data['_cc_'+i]; 548 } //FOR each contents 549 550 } //IF contents set 551 552 // ---- Setting up subcontents ---- 553 554 // Making sure mwSubContents exists at all 555 if ( typeof(mwSubContents) == 'undefined' ) 556 mwSubContents = {}; 557 558 if ( cache.SubContents ) { 559 560 for ( var i in cache.SubContents ) { 561 562 // Checking for html within regular results 563 if ( !data['_sc_'+i] ) continue; 564 565 mwSubContents[i] = data['_sc_'+i]; 566 567 delete data['_sc_'+i]; 568 } //FOR each subcontents 569 570 } //IF subcontents set 571 572 // ---- Running java init ---- 573 574 if ( cache.Java ) { 575 576 // Executing each given java init 577 for ( var i in cache.Java ) { 578 jQuery.globalEval(cache.Java[i]); 579 } //FOR each java init 580 581 } //IF subcontents set 582 583 }, //FUNC parseResult 584 585// ==== GENERAL ================================================================================================================ 586 587 /** //** ----= init =--------------------------------------------------------------------------------------\**//** \ 588 * 589 * Sets up basic events. Used before constructor return, to make sure that processing triggers before custom events. 590 * 591 * @return SELF 592 * 593 \**//** -------------------------------------------------------------------= by Mr.V!T @ Morad Media Inc. =----/** //**/ 594 init : function () { 595 596 // ---- START ---- 597 598 this.start( function (data) { 599 600 // Setting loading state 601 mwState(true, this.dialog); 602 603 }); //FUNC vAjax.stop.callback 604 605 // ---- STOP ---- 606 607 this.stop( function (data) { 608 609 // Parsing contentns 610 this.parseContents(data); 611 612 }); //FUNC vAjax.stop.callback 613 614 // ---- SUCCESS ---- 615 616 this.success( function (data) { 617 618 // If some of contents come defined updater - calling it. 619 // DEPRECATED: Not used anymore, left from old code for compatability 620 if ( typeof(updateDesktop) == 'function' ) 621 updateDesktop(); 622 623 }); //FUNC vAjax.success.callback 624
625 // ---- ERROR ---- 626 627 this.error( function (data) { 628 629 // Simple results are threated as debug/errors 630 if ( data.status.minor == 'simple' ) { 631 632 mwRawDump('#wDebugCurrent', data.res); 633 634 // Updating status 635 mwState(false, this.dialog); 636 637 return; 638 } //IF simple 639 640 }); //FUNC vAjax.error.callback 641 642 // ---- DONE ---- 643 644 this.done( function (data) { 645 646 // Updating status 647 mwState(data.status.text, this.dialog); 648 649 }); //FUNC vAjax.stop.callback 650 651 return this; 652 }, //FUNC init 653 654 /** //** ----= go =--------------------------------------------------------------------------------------\**//** \ 655 * 656 * Basic posting method. Proceeds ajax requests, parses contents, calls callbacks and updates system status. 657 * 658 * @param object(AjaxResult) data - Result in vAjax object format. 659 * 660 \**//** -------------------------------------------------------------------= by Mr.V!T @ Morad Media Inc. =----/** //**/ 661 go : function () { 662 663 // Before posting attempting to reset current validations on dialog (if one specified) 664 if ( typeof(this.dialog) == 'string' ) 665 setValidations( mwWindow(this.dialog).Body, {}); 666 667 this.post(); 668 669 return this; 670 }, //FUNC go 671 672// ==== CONTENT TYPES ========================================================================================================== 673 674 /** //** ----= content =--------------------------------------------------------------------------------------\**//** \ 675 * 676 * Loads content from contoller specified. And applies to specified element if supplied. 677 * 678 * @param MIXED target - Target to insert content to. Can be jQuery selector, 679 * jQuery object, DOM element, or callback function. Function 680 * passed as target will act as onSuccess callback. 681 * 682 * @return SELF 683 * 684 \**//** -------------------------------------------------------------------= by Mr.V!T @ Morad Media Inc. =----/** //**/ 685 content : function (target) { 686 687 this.go(); 688 689 if ( isFunction(target) ) 690 this.success(target); 691 else 692 this.success( function (data) { 693 694 if ( !target ) return; 695 696 // If common content come - inserting it into target 697 if ( data.content !== undefined ) { 698 699 target = _jq(target); 700 701 target.html(data.content); 702 703 } //IF content set. 704 705 }); //FUNC onSuccess 706 707 return this; 708 }, //FUNC content 709 710 /** //** ----= index =--------------------------------------------------------------------------------------\**//** \ 711 * 712 * This was designed with idea of index reload. Can take optional callback parameter. 713 * On success action it reloads index from controller specified, closes related dialogs, calls given callback and 714 * triggers status. Callback will be called after success reload, all elements positioning and status updates. 715 * 716 * @param function 717 * [callback] - Callback to call upon success. 718 * If callback returns FALSE, dialog will be not 719 * canceled and status will be not updated. 720 * 721 * @return SELF 722 * 723 \**//** -------------------------------------------------------------------= by Mr.V!T @ Morad Media Inc. =----/** //**/ 724 index : function (callback) { 725 726 return this 727 .go() 728 .success( function (data) { 729 730 var res = true; 731 732 if ( typeof(callback) == 'function' ) 733 res = callback(data); 734 735 if ( res !== false && typeof(this.dialog) == 'string' ) { 736 737 mwWindow(this.dialog).hide(); 738 739 // Status was updated in window, but if it's closed - text status should go in hintbar 740 if ( data.status.text ) 741 mwState(data.status.text); 742 743 } //IF all ok 744 745 return res; 746 747 }) //FUNC onSuccess 748 ; //this 749 750 }, //FUNC index 751 752 /** //** ----= window =--------------------------------------------------------------------------------------\**//** \ 753 * 754 * Based on content loading it targets one specified window and shows it on success. 755 * Can take optional callback parameter, which will be called on success, but before show window. 756 * 757 * @param string name - Name of dialog to show upon loading. 758 * 759 * @param function 760 * [callback] - Callback to call upon success. 761 * If callback returns FALSE, dialog will be not 762 * opened and status will be not updated. 763 * 764 * @return SELF 765 * 766 \**//** -------------------------------------------------------------------= by Mr.V!T @ Morad Media Inc. =----/** //**/ 767 window : function (name, callback) { 768 769 return this 770 .go() 771 .success( function (data) { 772 773 var res = true; 774 775 if ( typeof(callback) == 'function' ) 776 res = callback(data); 777 778 if ( res !== false ) 779 mwWindow(name).show(); 780 781 return res; 782 }); //FUNC 783 784 } //FUNC window 785 786 }; //OBJECT mwAjax 787 788 // Getting basic vAjax object, and extending it with morweb behavior 789 var vAjaxObj = vAjax(url, data); 790 791 jQuery.extend(vAjaxObj, exObj); 792 793 // Initiating basic events 794 vAjaxObj.init(); 795 796 // Returning it to user 797 return vAjaxObj; 798} //CONSTRUCTOR mwAjax 799 800/** //** ----= OBJECT mwSubContent =--------------------------------------------\**//** \ 801* 802* System SubContents processing tools. 803* 804* @param jQuery container - Container element to setup with subcontents. 805* @param jQuery [animation] - Element to use for animations. Possible values: 806* jQuery compatable pointer to element to animate, 807* TRUE to animate container element (default behavior), 808* FALSE to cancel animations (for manual animating). 809* 810\**//** ------------------------------------= by Mr.V!T @ Morad Media Inc. =----/** //**/ 811function mwSubContent (_container, _animation) { 812 813 // Validating environment 814 _container = _jq(_container); 815 816 if ( _animation === undefined ) 817 _animation = true; 818 819 return { 820 821 storage : jQuery('#sysSubContents'), // System subContents storage. 822 container : _container, // Container element to operatie with. 823 animation : _animation, // Element to animate on operations. For internal use. To setup use animate() method. 824 825 /** //** ----= animate =----------------------------------------------\**//** \ 826 * 827 * Applies animation to set element and calls callback on final. For internal use. 828 *
829 * @param string type - Animation type: 'show' or 'hide'. 830 * @param function [callback] - Callback to call on final. 831 * 832 * @return SELF 833 * 834 \**//** ------------------------------------= by Mr.V!T @ Morad Media Inc. =----/** //**/ 835 animate : function ( type, callback ) { 836 837 // Calculating animation target 838 var a; 839 840 if ( this.animation === true ) 841 a = this.container; 842 else if ( this.animation === false ) 843 a = false; 844 else 845 a = _jq(this.animation); 846 847 // Ensuring callback is a function 848 callback = callback || function(){}; 849 850 // ---- Applying animation if set ---- 851 852 if ( a ) { 853 854 // If animation target set - calling proper animation and returning. 855 // If no valid animation - doing nothing, it will proceed to default no animation flow. 856 switch ( type ) { 857 case 'show' : 858 mwShow(a, callback); 859 return this; 860 case 'hide' : 861 mwHide(a, callback); 862 return this; 863 } //SWITCH type 864 865 } //IF animation 866 867 // ---- No animation ---- 868 869 if ( typeof(callback) == 'function' ) 870 callback(); 871 872 return this; 873 }, //FUNC animate 874 875 /** //** ----= setup =----------------------------------------------\**//** \ 876 * 877 * Replaces container subContents with subContent specified, cleaning container. 878 * Applies animations if set. Calls callback after subContent inserted and before show. 879 * New subContent will be passed to callbacks. 880 * 881 * @param string id - SubContainer system ID. 882 * 883 * @param function [callback] - Callback to call after hide and setup. 884 * @param function [onfinal] - Callback to call after final show. 885 * 886 * @return SELF 887 * 888 \**//** ------------------------------------= by Mr.V!T @ Morad Media Inc. =----/** //**/ 889 setup : function (id, callback, onfinal) { 890 891 var self = this; // Shortcut to use in callback 892 893 // Calling cleaner, this will also hide container 894 this.unset( function () { 895 896 // Attaching content 897 // var el = jQuery('#' + id); 898 var el = jQuery(mwSubContents[id]); 899 el.appendTo(self.container); 900 901 // Showing container 902 self.animate('show', function () { 903 // Calling final callback 904 if ( typeof(onfinal) == 'function' ) 905 onfinal(el); 906 907 }); //FUNC onShow 908 909 // Small delay to allow to update contents dimensions 910 setTimeout( function () { 911 // Calling callback, it will start before animated, 912 // but after animaiton start - contents become real 913 if ( typeof(callback) == 'function' ) 914 callback(el); 915 }, 1); 916 917 }); //FUNC onHide 918 919 return this; 920 }, //FUNC setup 921 922 /** //** ----= unset =----------------------------------------------\**//** \ 923 * 924 * Clears container from subContents, moving them to system storage. 925 * Calls callback after clean. 926 * 927 * @param function [callback] - Callback to call on done. 928 * 929 * @return SELF 930 * 931 \**//** ------------------------------------= by Mr.V!T @ Morad Media Inc. =----/** //**/ 932 unset : function ( callback ) { 933 934 var self = this; // Shortcut to use in callback 935 936 this.animate('hide', function () { 937 938 // Removing all childs in container. Container means only subcontents 939 // self.container.find('.subContent').appendTo('#sysSubContents'); 940 self.container.empty(); 941 942 if ( typeof(callback) == 'function' ) 943 callback(); 944 945 }); //FUNC onHide 946 947 return this; 948 } //FUNC unset 949 950 }; //OBJECT mwSubContent 951 952} //CONSTRUCTOR mwSubContent
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.