1; /* /bitrix/js/main/core/core_timer.js?16337965126316*/ 2; /* /bitrix/js/main/dd.js?168616490514809*/ 3; /* /bitrix/js/main/session.js?16453469013701*/ 4; /* /bitrix/js/main/pageobject/pageobject.js?1633796512864*/ 5; /* /bitrix/js/main/core/core_window.js?164793062398768*/ 6; /* /bitrix/js/main/date/main.date.js?168616490647122*/ 7; /* /bitrix/js/main/core/core_date.js?163379651236080*/ 8; /* /bitrix/js/main/utils.js?163379651229279*/ 9; /* /bitrix/js/main/core/core_fx.js?163379651216888*/ 10 11; /* Start:"a:4:{s:4:"full";s:47:"/bitrix/js/main/core/core_fx.js?163379651216888";s:6:"source";s:31:"/bitrix/js/main/core/core_fx.js";s:3:"min";s:0:"";s:3:"map";s:0:"";}"*/ 12;(function(window){ 13 14var defaultOptions = { 15 time: 1.0, 16 step: 0.05, 17 type: 'linear', 18 19 allowFloat: false 20} 21 22/* 23options: { 24 start: start value or {param: value, param: value} 25 finish: finish value or {param: value, param: value} 26 time: time to transform in seconds 27 type: linear|accelerated|decelerated|custom func name 28 callback, 29 callback_start, 30 callback_complete, 31 32 step: time between steps in seconds 33 allowFloat: false|true 34} 35*/ 36BX.fx = function(options) 37{ 38 this.options = options; 39 40 if (null != this.options.time) 41 this.options.originalTime = this.options.time; 42 if (null != this.options.step) 43 this.options.originalStep = this.options.step; 44 45 if (!this.__checkOptions()) 46 return false; 47 48 this.__go = BX.delegate(this.go, this); 49 50 this.PARAMS = {}; 51} 52 53BX.fx.prototype.__checkOptions = function() 54{ 55 if (typeof this.options.start != typeof this.options.finish) 56 return false; 57 58 if (null == this.options.time) this.options.time = defaultOptions.time; 59 if (null == this.options.step) this.options.step = defaultOptions.step; 60 if (null == this.options.type) this.options.type = defaultOptions.type; 61 if (null == this.options.allowFloat) this.options.allowFloat = defaultOptions.allowFloat; 62 63 this.options.time *= 1000; 64 this.options.step *= 1000; 65 66 if (typeof this.options.start != 'object') 67 { 68 this.options.start = {_param: this.options.start}; 69 this.options.finish = {_param: this.options.finish}; 70 } 71 72 var i; 73 for (i in this.options.start) 74 { 75 if (null == this.options.finish[i]) 76 { 77 this.options.start[i] = null; 78 delete this.options.start[i]; 79 } 80 } 81 82 if (!BX.type.isFunction(this.options.type)) 83 { 84 if (BX.type.isFunction(window[this.options.type])) 85 this.options.type = window[this.options.type]; 86 else if (BX.type.isFunction(BX.fx.RULES[this.options.type])) 87 this.options.type = BX.fx.RULES[this.options.type]; 88 else 89 this.options.type = BX.fx.RULES[defaultOptions.type]; 90 } 91 92 return true; 93} 94 95BX.fx.prototype.go = function() 96{ 97 var timeCurrent = new Date().valueOf(); 98 if (timeCurrent < this.PARAMS.timeFinish) 99 { 100 for (var i in this.PARAMS.current) 101 { 102 this.PARAMS.current[i][0] = this.options.type.apply(this, [{ 103 start_value: this.PARAMS.start[i][0], 104 finish_value: this.PARAMS.finish[i][0], 105 current_value: this.PARAMS.current[i][0], 106 current_time: timeCurrent - this.PARAMS.timeStart, 107 total_time: this.options.time 108 }]); 109 } 110 111 this._callback(this.options.callback); 112 113 if (!this.paused) 114 this.PARAMS.timer = setTimeout(this.__go, this.options.step); 115 } 116 else 117 { 118 this.stop(); 119 } 120} 121 122BX.fx.prototype._callback = function(cb) 123{ 124 var tmp = {}; 125 126 cb = cb || this.options.callback; 127 128 for (var i in this.PARAMS.current) 129 { 130 tmp[i] = (this.options.allowFloat ? this.PARAMS.current[i][0] : Math.round(this.PARAMS.current[i][0])) + this.PARAMS.current[i][1]; 131 } 132 133 return cb.apply(this, [null != tmp['_param'] ? tmp._param : tmp]); 134} 135 136BX.fx.prototype.start = function() 137{ 138 var i,value, unit; 139 140 this.PARAMS.start = {}; 141 this.PARAMS.current = {}; 142 this.PARAMS.finish = {}; 143 144 for (i in this.options.start) 145 { 146 value = +this.options.start[i]; 147 unit = (this.options.start[i]+'').substring((value+'').length); 148 this.PARAMS.start[i] = [value, unit]; 149 this.PARAMS.current[i] = [value, unit]; 150 this.PARAMS.finish[i] = [+this.options.finish[i], unit]; 151 } 152 153 this._callback(this.options.callback_start); 154 this._callback(this.options.callback); 155 156 this.PARAMS.timeStart = new Date().valueOf(); 157 this.PARAMS.timeFinish = this.PARAMS.timeStart + this.options.time; 158 this.PARAMS.timer = setTimeout(BX.delegate(this.go, this), this.options.step); 159 160 return this; 161} 162 163BX.fx.prototype.pause = function() 164{ 165 if (this.paused) 166 { 167 this.PARAMS.timer = setTimeout(this.__go, this.options.step); 168 this.paused = false;
169 } 170 else 171 { 172 clearTimeout(this.PARAMS.timer); 173 this.paused = true; 174 } 175} 176 177BX.fx.prototype.stop = function(silent) 178{ 179 silent = !!silent; 180 if (this.PARAMS.timer) 181 clearTimeout(this.PARAMS.timer); 182 183 if (null != this.options.originalTime) 184 this.options.time = this.options.originalTime; 185 if (null != this.options.originalStep) 186 this.options.step = this.options.originalStep; 187 188 this.PARAMS.current = this.PARAMS.finish; 189 if (!silent) { 190 this._callback(this.options.callback); 191 this._callback(this.options.callback_complete); 192 } 193} 194 195/* 196type rules of animation 197 - linear - simple linear animation 198 - accelerated 199 - decelerated 200*/ 201 202/* 203 params: { 204 start_value, finish_value, current_time, total_time 205 } 206*/ 207BX.fx.RULES = 208{ 209 linear: function(params) 210 { 211 return params.start_value + (params.current_time/params.total_time) * (params.finish_value - params.start_value); 212 }, 213 214 decelerated: function(params) 215 { 216 return params.start_value + Math.sqrt(params.current_time/params.total_time) * (params.finish_value - params.start_value); 217 }, 218 219 accelerated: function(params) 220 { 221 var q = params.current_time/params.total_time; 222 return params.start_value + q * q * (params.finish_value - params.start_value); 223 } 224} 225 226/****************** effects realizaion ************************/ 227 228/* 229 type = 'fade' || 'scroll' || 'scale' || 'fold' 230*/ 231 232BX.fx.hide = function(el, type, opts) 233{ 234 el = BX(el); 235 236 if (typeof type == 'object' && null == opts) 237 { 238 opts = type; 239 type = opts.type 240 } 241 242 if (!opts) opts = {}; 243 244 if (!BX.type.isNotEmptyString(type)) 245 { 246 el.style.display = 'none'; 247 return; 248 } 249 250 var fxOptions = BX.fx.EFFECTS[type](el, opts, 0); 251 fxOptions.callback_complete = function () { 252 if (opts.hide !== false) 253 el.style.display = 'none'; 254 255 if (opts.callback_complete) 256 opts.callback_complete.apply(this, arguments); 257 } 258 259 return (new BX.fx(fxOptions)).start(); 260} 261 262BX.fx.show = function(el, type, opts) 263{ 264 el = BX(el); 265 266 if (typeof type == 'object' && null == opts) 267 { 268 opts = type; 269 type = opts.type 270 } 271 272 if (!opts) opts = {}; 273 274 if (!BX.type.isNotEmptyString(type)) 275 { 276 el.style.display = 'block'; 277 return; 278 } 279 280 var fxOptions = BX.fx.EFFECTS[type](el, opts, 1); 281 282 fxOptions.callback_complete = function () { 283 if (opts.show !== false) 284 el.style.display = 'block'; 285 286 if (opts.callback_complete) 287 opts.callback_complete.apply(this, arguments); 288 } 289 290 return (new BX.fx(fxOptions)).start(); 291} 292 293BX.fx.EFFECTS = { 294 scroll: function(el, opts, action) 295 { 296 if (!opts.direction) opts.direction = 'vertical'; 297 298 var param = opts.direction == 'horizontal' ? 'width' : 'height'; 299 300 var val = parseInt(BX.style(el, param)); 301 if (isNaN(val)) 302 { 303 val = BX.pos(el)[param]; 304 } 305 306 if (action == 0) 307 var start = val, finish = opts.min_height ? parseInt(opts.min_height) : 0; 308 else 309 var finish = val, start = opts.min_height ? parseInt(opts.min_height) : 0; 310 311 return { 312 'start': start, 313 'finish': finish, 314 'time': opts.time || defaultOptions.time, 315 'type': 'linear', 316 callback_start: function () { 317 if (BX.style(el, 'position') == 'static') 318 el.style.position = 'relative'; 319 320 el.style.overflow = 'hidden'; 321 el.style[param] = start + 'px'; 322 el.style.display = 'block'; 323 }, 324 callback: function (val) {el.style[param] = val + 'px';} 325 } 326 }, 327 328 fade: function(el, opts, action) 329 { 330 var fadeOpts = { 331 'time': opts.time || defaultOptions.time, 332 'type': action == 0 ? 'decelerated' : 'linear', 333 'start': action == 0 ? 1 : 0, 334 'finish': action == 0 ? 0 : 1, 335 'allowFloat': true 336 }; 337 338 if (BX.browser.IsIE() && !BX.browser.IsIE9()) 339 { 340 fadeOpts.start *= 100; fadeOpts.finish *= 100; fadeOpts.allowFloat = false; 341 342 fadeOpts.callback_start = function() { 343 el.style.display = 'block'; 344 el.style.filter += "progid:DXImageTransform.Microsoft.Alpha(opacity=" + fadeOpts.start + ")"; 345 }; 346 347 fadeOpts.callback = function (val) { 348 (el.filters['DXImageTransform.Microsoft.alpha']||el.filters.alpha).opacity = val; 349 } 350 } 351 else 352 { 353 fadeOpts.callback_start = function () { 354 el.style.display = 'block'; 355 } 356 357 fadeOpts.callback = function (val) { 358 el.style.opacity = el.style.KhtmlOpacity = el.style.MozOpacity = val; 359 }; 360 } 361 362 return fadeOpts; 363 }, 364 365 fold: function (el, opts, action) // 'fold' is a combination of two consequential 'scroll' hidings. 366 { 367 if (action != 0) return; 368 369 var pos = BX.pos(el); 370 var coef = pos.height / (pos.width + pos.height); 371 var old_opts = {time: opts.time || defaultOptions.time, callback_complete: opts.callback_complete, hide: opts.hide}; 372 373 opts.type = 'scroll'; 374 opts.direction = 'vertical'; 375 opts.min_height = opts.min_height || 10; 376 opts.hide = false;
377 opts.time = coef * old_opts.time; 378 opts.callback_complete = function() 379 { 380 el.style.whiteSpace = 'nowrap'; 381 382 opts.direction = 'horizontal'; 383 opts.min_height = null; 384 385 opts.time = old_opts.time - opts.time; 386 opts.hide = old_opts.hide; 387 opts.callback_complete = old_opts.callback_complete; 388 389 BX.fx.hide(el, opts); 390 } 391 392 return BX.fx.EFFECTS.scroll(el, opts, action); 393 }, 394 395 scale: function (el, opts, action) 396 { 397 var val = {width: parseInt(BX.style(el, 'width')), height: parseInt(BX.style(el, 'height'))}; 398 if (isNaN(val.width) || isNaN(val.height)) 399 { 400 var pos = BX.pos(el) 401 val = {width: pos.width, height: pos.height}; 402 } 403 404 if (action == 0) 405 var start = val, finish = {width: 0, height: 0}; 406 else 407 var finish = val, start = {width: 0, height: 0}; 408 409 return { 410 'start': start, 411 'finish': finish, 412 'time': opts.time || defaultOptions.time, 413 'type': 'linear', 414 callback_start: function () { 415 el.style.position = 'relative'; 416 el.style.overflow = 'hidden'; 417 el.style.display = 'block'; 418 el.style.height = start.height + 'px'; 419 el.style.width = start.width + 'px'; 420 }, 421 callback: function (val) { 422 el.style.height = val.height + 'px'; 423 el.style.width = val.width + 'px'; 424 } 425 } 426 } 427} 428 429// Color animation 430// 431// Set animation rule 432// BX.fx.colorAnimate.addRule('animationRule1',"#FFF","#faeeb4", "background-color", 100, 1, true); 433// BX.fx.colorAnimate.addRule('animationRule2',"#fc8282","#ff0000", "color", 100, 1, true); 434// Params: 1 - animation name, 2 - start color, 3 - end color, 4 - count step, 5 - delay each step, 6 - return color on end animation 435// 436// Animate color for element 437// BX.fx.colorAnimate(BX('element'), 'animationRule1,animationRule2'); 438 439var defaultOptionsColorAnimation = { 440 arStack: {}, 441 arRules: {}, 442 globalAnimationId: 0 443} 444 445BX.fx.colorAnimate = function(element, rule, back) 446{ 447 if (element == null) 448 return; 449 450 animationId = element.getAttribute('data-animation-id'); 451 if (animationId == null) 452 { 453 animationId = defaultOptionsColorAnimation.globalAnimationId; 454 element.setAttribute('data-animation-id', defaultOptionsColorAnimation.globalAnimationId++); 455 } 456 var aRuleList = rule.split(/\s*,\s*/); 457 458 for (var j = 0; j < aRuleList.length; j++) 459 { 460 rule = aRuleList[j]; 461 462 if (!defaultOptionsColorAnimation.arRules[rule]) continue; 463 464 var i=0; 465 466 if (!defaultOptionsColorAnimation.arStack[animationId]) 467 { 468 defaultOptionsColorAnimation.arStack[animationId] = {}; 469 } 470 else if (defaultOptionsColorAnimation.arStack[animationId][rule]) 471 { 472 i = defaultOptionsColorAnimation.arStack[animationId][rule].i; 473 clearInterval(defaultOptionsColorAnimation.arStack[animationId][rule].tId); 474 } 475 476 if ((i==0 && back) || (i==defaultOptionsColorAnimation.arRules[rule][3] && !back)) continue; 477 478 defaultOptionsColorAnimation.arStack[animationId][rule] = {'i':i, 'element': element, 'tId':setInterval('BX.fx.colorAnimate.run("'+animationId+'","'+rule+'")', defaultOptionsColorAnimation.arRules[rule][4]),'back':Boolean(back)}; 479 } 480} 481 482BX.fx.colorAnimate.addRule = function (rule, startColor, finishColor, cssProp, step, delay, back) 483{ 484 defaultOptionsColorAnimation.arRules[rule] = [ 485 BX.util.hex2rgb(startColor), 486 BX.util.hex2rgb(finishColor), 487 cssProp.replace(/\-(.)/g,function(){return arguments[1].toUpperCase();}), 488 step, 489 delay || 1, 490 back || false 491 ]; 492}; 493 494BX.fx.colorAnimate.run = function(animationId, rule) 495{ 496 element = defaultOptionsColorAnimation.arStack[animationId][rule].element; 497 498 defaultOptionsColorAnimation.arStack[animationId][rule].i += defaultOptionsColorAnimation.arStack[animationId][rule].back?-1:1; 499 var finishPercent = defaultOptionsColorAnimation.arStack[animationId][rule].i/defaultOptionsColorAnimation.arRules[rule][3]; 500 var startPercent = 1 - finishPercent; 501 502 var aRGBStart = defaultOptionsColorAnimation.arRules[rule][0]; 503 var aRGBFinish = defaultOptionsColorAnimation.arRules[rule][1]; 504 505 element.style[defaultOptionsColorAnimation.arRules[rule][2]] = 'rgb('+ 506 Math.floor( aRGBStart['r'] * startPercent + aRGBFinish['r'] * finishPercent ) + ','+ 507 Math.floor( aRGBStart['g'] * startPercent + aRGBFinish['g'] * finishPercent ) + ','+ 508 Math.floor( aRGBStart['b'] * startPercent + aRGBFinish['b'] * finishPercent ) +')'; 509 510 if ( defaultOptionsColorAnimation.arStack[animationId][rule].i == defaultOptionsColorAnimation.arRules[rule][3] || defaultOptionsColorAnimation.arStack[animationId][rule].i ==0) 511 { 512 clearInterval(defaultOptionsColorAnimation.arStack[animationId][rule].tId); 513 if (defaultOptionsColorAnimation.arRules[rule][5]) 514 BX.fx.colorAnimate(defaultOptionsColorAnimation.arStack[animationId][rule].element, rule, true); 515 } 516} 517 518 519/* 520options = { 521 delay: 100, 522 duration : 3000, 523 start : { scroll : document.body.scrollTop, left : 0, opacity : 100 }, 524 finish : { scroll : document.body.scrollHeight, left : 500, opacity : 10 },
525 transition : BitrixAnimation.makeEaseOut(BitrixAnimation.transitions.quart), 526 527 step : function(state) 528 { 529 document.body.scrollTop = state.scroll; 530 button.style.left = state.left + "px"; 531 button.style.opacity = state.opacity / 100; 532 }, 533 complete : function() 534 { 535 button.style.background = "green"; 536 } 537} 538 539options = 540{ 541 delay : 20, 542 duration : 4000, 543 transition : BXAnimation.makeEaseOut(BXAnimation.transitions.quart), 544 progress : function(progress) 545 { 546 document.body.scrollTop = Math.round(topMax * progress); 547 button.style.left = Math.round(leftMax * progress) + "px"; 548 button.style.opacity = (100 + Math.round((opacityMin - 100) * progress)) / 100; 549 550 }, 551 complete : function() 552 { 553 button.style.background = "green"; 554 } 555} 556*/ 557 558BX.easing = function(options) 559{ 560 this.options = options; 561 this.timer = null; 562}; 563 564BX.easing.prototype.animate = function() 565{ 566 if (!this.options || !this.options.start || !this.options.finish || 567 typeof(this.options.start) != "object" || typeof(this.options.finish) != "object" 568 ) 569 return null; 570 571 for (var propName in this.options.start) 572 { 573 if (typeof(this.options.finish[propName]) == "undefined") 574 { 575 delete this.options.start[propName]; 576 } 577 } 578 579 this.options.progress = function(progress) { 580 var state = {}; 581 for (var propName in this.start) 582 state[propName] = Math.round(this.start[propName] + (this.finish[propName] - this.start[propName]) * progress); 583 584 if (this.step) 585 { 586 this.step(state); 587 } 588 }; 589 590 this.animateProgress(); 591}; 592 593BX.easing.prototype.stop = function(completed) 594{ 595 if (this.timer) 596 { 597 cancelAnimationFrame(this.timer); 598 this.timer = null; 599 if (completed) 600 { 601 this.options.complete && this.options.complete(); 602 } 603 } 604}; 605 606BX.easing.prototype.animateProgress = function() 607{ 608 if (!window.requestAnimationFrame) 609 { 610 //For old browsers we skip animation 611 this.options.progress(1); 612 this.options.complete && this.options.complete(); 613 return; 614 } 615 616 var start = null; 617 var delta = this.options.transition || BX.easing.transitions.linear; 618 var duration = this.options.duration || 1000; 619 var animation = BX.proxy(function(time) { 620 621 if (start === null) 622 { 623 start = time; 624 } 625 626 var progress = (time - start) / duration; 627 if (progress > 1) 628 { 629 progress = 1; 630 } 631 632 this.options.progress(delta(progress)); 633 634 if (progress == 1) 635 { 636 this.stop(true); 637 } 638 else 639 { 640 this.timer = requestAnimationFrame(animation); 641 } 642 643 }, this); 644 645 this.timer = requestAnimationFrame(animation); 646}; 647 648BX.easing.makeEaseInOut = function(delta) 649{ 650 return function(progress) { 651 if (progress < 0.5) 652 return delta( 2 * progress ) / 2; 653 else 654 return (2 - delta( 2 * (1-progress) ) ) / 2; 655 } 656}; 657 658BX.easing.makeEaseOut = function(delta) 659{ 660 return function(progress) { 661 return 1 - delta(1 - progress); 662 }; 663}; 664 665BX.easing.transitions = { 666 667 linear : function(progress) 668 { 669 return progress; 670 }, 671 672 quad : function(progress) 673 { 674 return Math.pow(progress, 2); 675 }, 676 677 cubic : function(progress) { 678 return Math.pow(progress, 3); 679 }, 680 681 quart : function(progress) 682 { 683 return Math.pow(progress, 4); 684 }, 685 686 quint : function(progress) 687 { 688 return Math.pow(progress, 5); 689 }, 690 691 circ : function(progress) 692 { 693 return 1 - Math.sin(Math.acos(progress)); 694 }, 695 696 back : function(progress) 697 { 698 return Math.pow(progress, 2) * ((1.5 + 1) * progress - 1.5); 699 }, 700 701 elastic: function(progress) 702 { 703 return Math.pow(2, 10 * (progress-1)) * Math.cos(20 * Math.PI * 1.5/3 * progress); 704 }, 705 706 bounce : function(progress) 707 { 708 for(var a = 0, b = 1; 1; a += b, b /= 2) { 709 if (progress >= (7 - 4 * a) / 11) { 710 return -Math.pow((11 - 6 * a - 11 * progress) / 4, 2) + Math.pow(b, 2); 711 } 712 } 713 }}; 714 715 716})(window); 717 718 719/* End */ 720; 721; /* Start:"a:4:{s:4:"full";s:41:"/bitrix/js/main/session.js?16453469013701";s:6:"source";s:26:"/bitrix/js/main/session.js";s:3:"min";s:0:"";s:3:"map";s:0:"";}"*/ 722function CBXSession() 723{ 724 var _this = this; 725 this.dateInput = new Date(); 726 this.dateCheck = new Date(); 727 this.dateHit = new Date(); 728 this.notifier = null; 729 this.checkInterval = 60; 730 this.checkImmediately = false; 731 732 this.Expand = function(key) 733 { 734 this.key = key; 735 736 BX.ready(function(){ 737 BX.bind(document, "keypress", _this.OnUserInput); 738 BX.bind(document.body, "mousemove", _this.OnUserInput); 739 BX.bind(document.body, "click", _this.OnUserInput); 740 741 //check the state once in a minute 742 setInterval(_this.CheckSession, _this.checkInterval*1000); 743 }) 744 }; 745 746 this.OnUserInput = function() 747 { 748 var currentDate = new Date(); 749 _this.dateInput.setTime(currentDate.valueOf()); 750 751 if ((currentDate - _this.dateHit)/1000 > (_this.checkInterval + 5) && _this.checkImmediately === false) 752 { 753 // last hit was long time ago, need to recheck immediately 754 _this.checkImmediately = true; 755 _this.CheckSession(); 756 } 757 }; 758 759 this.CheckSession = function() 760 { 761 var currentDate = new Date(); 762 763 if((currentDate - _this.dateCheck)/1000 < (_this.checkInterval - 1) && _this.checkImmediately === false) 764 { 765 //storm protection, e.g. after PC wake-up 766 return; 767 } 768 769 _this.dateCheck.setTime(currentDate.valueOf()); 770 771 if(_this.dateInput > _this.dateHit) 772 { 773 //there was input after the last hit, expand/check the session 774 var config = { 775 'method': 'GET', 776 'headers': [ 777 {'name': 'X-Bitrix-Csrf-Token', 'value': BX.bitrix_sessid()} 778 ], 779 'dataType': 'html', 780 'url': '/bitrix/tools/public_session.php?k='+_this.key, 781 'data': '', 782 'onsuccess': function(data){_this.CheckResult(data)}, 783 'lsId': 'sess_expand', //caching the result in the local storage for multiple tabs 784 'lsTimeout': _this.checkInterval - 5 //some delta for response time 785 }; 786 BX.ajax(config); 787 } 788 }; 789 790 this.CheckResult = function(data) 791 { 792 var currentDate = new Date(); 793 _this.dateHit.setTime(currentDate.valueOf()); 794 _this.checkImmediately = false;
795 796 if(data == 'SESSION_EXPIRED') 797 { 798 if(BX.message("SessExpired")) 799 { 800 if(!_this.notifier) 801 { 802 _this.notifier = document.body.appendChild(BX.create('DIV', { 803 props: {className: 'bx-session-message'}, 804 style: { 805 top: '0', 806 backgroundColor: '#FFEB41', 807 border: '1px solid #EDDA3C', 808 width: '630px', 809 fontFamily: 'Arial,Helvetica,sans-serif', 810 fontSize: '13px', 811 fontWeight: 'bold', 812 textAlign: 'center', 813 color: 'black', 814 position: 'absolute', 815 zIndex: '10000', 816 padding: '10px' 817 }, 818 html: '<a class="bx-session-message-close" ' + 819 'style="display:block; width:12px; height:12px; background:url(/bitrix/js/main/core/images/close.gif) center no-repeat; float:right;" ' + 820 'href="javascript:bxSession.Close()"></a>' + 821 BX.message("SessExpired") 822 })); 823 824 BX.ZIndexManager.register(_this.notifier); 825 BX.ZIndexManager.bringToFront(_this.notifier); 826 827 var windowScroll = BX.GetWindowScrollPos(); 828 var windowSize = BX.GetWindowInnerSize(); 829 830 _this.notifier.style.left = parseInt(windowScroll.scrollLeft + (windowSize.innerWidth / 2) - (parseInt(_this.notifier.clientWidth) / 2)) + 'px'; 831 832 if(BX.browser.IsIE()) 833 { 834 _this.notifier.style.top = windowScroll.scrollTop + 'px'; 835 836 BX.bind(window, 'scroll', function() 837 { 838 var windowScroll = BX.GetWindowScrollPos(); 839 _this.notifier.style.top = windowScroll.scrollTop + 'px'; 840 }); 841 } 842 else 843 { 844 _this.notifier.style.position='fixed'; 845 } 846 } 847 848 _this.notifier.style.display = ''; 849 } 850 } 851 }; 852 853 this.Close = function() 854 { 855 this.notifier.style.display = 'none'; 856 } 857} 858 859var bxSession = new CBXSession(); 860 861/* End */ 862; 863; /* Start:"a:4:{s:4:"full";s:54:"/bitrix/js/main/pageobject/pageobject.js?1633796512864";s:6:"source";s:40:"/bitrix/js/main/pageobject/pageobject.js";s:3:"min";s:0:"";s:3:"map";s:0:"";}"*/ 864window.BX = BX || {}; 865 866BX.PageObject = { 867 getRootWindow: function() 868 { 869 return BX.PageObject.getTopWindowOfCurrentHost(window); 870 }, 871 872 isCrossOriginObject: function(currentWindow) 873 { 874 try 875 { 876 void currentWindow.location.host; 877 } 878 catch (e) 879 { 880 // cross-origin object 881 return true; 882 } 883 884 return false; 885 }, 886 887 getTopWindowOfCurrentHost: function(currentWindow) 888 { 889 if ( 890 !BX.PageObject.isCrossOriginObject(currentWindow.parent) 891 && currentWindow.parent !== currentWindow 892 && currentWindow.parent.location.host === currentWindow.location.host 893 ) 894 { 895 return BX.PageObject.getTopWindowOfCurrentHost(currentWindow.parent); 896 } 897 898 return currentWindow; 899 }, 900 901 getParentWindowOfCurrentHost: function(currentWindow) 902 { 903 if (BX.PageObject.isCrossOriginObject(currentWindow.parent)) 904 { 905 return currentWindow; 906 } 907 908 return currentWindow.parent; 909 } 910}; 911/* End */ 912; 913; /* Start:"a:4:{s:4:"full";s:51:"/bitrix/js/main/core/core_window.js?164793062398768";s:6:"source";s:35:"/bitrix/js/main/core/core_window.js";s:3:"min";s:0:"";s:3:"map";s:0:"";}"*/ 914;(function(window) { 915if (BX.WindowManager) return; 916 917/* windows manager */ 918BX.WindowManager = { 919 _stack: [], 920 _runtime_resize: {}, 921 _delta: 2, 922 _delta_start: 1000, 923 currently_loaded: null, 924 925 settings_category: 'BX.WindowManager.9.5', 926 927 register: function (w) 928 { 929 this.currently_loaded = null; 930 931 w.WM_REG_INDEX = this._stack.length; 932 this._stack.push(w); 933 934 if (this._stack.length < 2) 935 { 936 BX.bind(document, 'keyup', BX.proxy(this.__checkKeyPress, this)); 937 } 938 }, 939 940 unregister: function (w) 941 { 942 if (null == w.WM_REG_INDEX) 943 return null; 944 945 var _current; 946 if (this._stack.length > 0) 947 { 948 while ((_current = this.__pop_stack()) != w) 949 { 950 if (!_current) 951 { 952 _current = null; 953 break; 954 } 955 } 956 957 if (this._stack.length <= 0) 958 { 959 this.enableKeyCheck(); 960 } 961 962 return _current; 963 } 964 else 965 { 966 return null; 967 } 968 }, 969 970 __pop_stack: function(clean) 971 { 972 if (this._stack.length > 0) 973 { 974 var _current = this._stack.pop(); 975 _current.WM_REG_INDEX = null; 976 BX.onCustomEvent(_current, 'onWindowUnRegister', [clean === true]); 977 978 return _current; 979 } 980 else 981 return null; 982 }, 983 984 clean: function() 985 { 986 while (this.__pop_stack(true)){} 987 this._stack = null; 988 this.disableKeyCheck(); 989 }, 990 991 Get: function() 992 { 993 if (this.currently_loaded) 994 return this.currently_loaded; 995 else if (this._stack.length > 0) 996 return this._stack[this._stack.length-1]; 997 else 998 return null; 999 }, 1000 1001 setStartZIndex: function(value) 1002 { 1003 this._delta_start = value; 1004 }, 1005 1006 restoreStartZIndex: function() 1007 { 1008 this._delta_start = 1000; 1009 }, 1010 1011 GetZIndex: function() 1012 { 1013 var _current; 1014 return (null != (_current = this._stack[this._stack.length-1]) 1015 ? parseInt(_current.Get().style.zIndex) + this._delta 1016 : this._delta_start 1017 ); 1018 }, 1019 1020 __get_check_url: function(url) 1021 { 1022 var pos = url.indexOf('?'); 1023 return pos == -1 ? url : url.substring(0, pos); 1024 }, 1025 1026 saveWindowSize: function(url, params) 1027 { 1028 var check_url = this.__get_check_url(url); 1029 if (BX.userOptions) 1030 { 1031 BX.userOptions.save(this.settings_category, 'size_' + check_url, 'width', params.width); 1032 BX.userOptions.save(this.settings_category, 'size_' + check_url, 'height', params.height); 1033 } 1034 1035 this._runtime_resize[check_url] = params; 1036 }, 1037 1038 saveWindowOptions: function(wnd_id, opts) 1039 { 1040 if (BX.userOptions) 1041 { 1042 for (var i in opts) 1043 { 1044 if(opts.hasOwnProperty(i)) 1045 { 1046 BX.userOptions.save(this.settings_category, 'options_' + wnd_id, i, opts[i]); 1047 } 1048 } 1049 } 1050 }, 1051 1052 getRuntimeWindowSize: function(url) 1053 { 1054 return this._runtime_resize[this.__get_check_url(url)]; 1055 }, 1056 1057 disableKeyCheck: function() 1058 { 1059 BX.unbind(document, 'keyup', BX.proxy(this.__checkKeyPress, this)); 1060 }, 1061 1062 enableKeyCheck: function() 1063 { 1064 BX.bind(document, 'keyup', BX.proxy(this.__checkKeyPress, this)); 1065 }, 1066 1067 __checkKeyPress: function(e) 1068 { 1069 if (null == e) 1070 e = window.event; 1071 1072 if (e.keyCode == 27) 1073 { 1074 var wnd = BX.WindowManager.Get(); 1075 if (wnd && !wnd.unclosable) wnd.Close(); 1076 } 1077 } 1078}; 1079 1080BX.garbage(BX.WindowManager.clean, BX.WindowManager); 1081 1082/* base button class */ 1083BX.CWindowButton = function(params) 1084{ 1085 if (params.btn) 1086 { 1087 this.btn = params.btn; 1088 this.parentWindow = params.parentWindow; 1089 1090 if (/save|apply/i.test(this.btn.name)) 1091 { 1092 BX.bind(this.btn, 'click', BX.delegate(this.disableUntilError, this)); 1093 } 1094 } 1095 else 1096 { 1097 this.title = params.title; // html value attr 1098 this.hint = params.hint; // html title attr 1099 this.id = params.id; // html name and id attrs 1100 this.name = params.name; // html name or value attrs when id and title 're absent 1101 this.className = params.className; // className for button input 1102 1103 this.action = params.action; 1104 this.onclick = params.onclick; 1105 1106 // you can override button creation method 1107 if (params.Button && BX.type.isFunction(params.Button)) 1108 this.Button = params.Button; 1109 1110 this.btn = null; 1111 } 1112}; 1113 1114BX.CWindowButton.prototype.disable = function() 1115{ 1116 if (this.btn) 1117 this.parentWindow.showWait(this.btn); 1118}; 1119BX.CWindowButton.prototype.enable = function(){ 1120 if (this.btn) 1121 this.parentWindow.closeWait(this.btn); 1122}; 1123 1124BX.CWindowButton.prototype.emulate = function() 1125{ 1126 if (this.btn && this.btn.disabled) 1127 return; 1128 1129 var act = 1130 this.action 1131 ? BX.delegate(this.action, this) 1132 : ( 1133 this.onclick 1134 ? this.onclick 1135 : ( 1136 this.btn 1137 ? this.btn.getAttribute('onclick') 1138 : '' 1139 ) 1140 ); 1141 1142 if (act) 1143 { 1144 setTimeout(act, 50); 1145 if (this.btn && /save|apply/i.test(this.btn.name) && !this.action) 1146 { 1147 this.disableUntilError(); 1148 } 1149 } 1150}; 1151 1152BX.CWindowButton.prototype.Button = function(parentWindow) 1153{ 1154 this.parentWindow = parentWindow; 1155 1156 var btn = { 1157 props: { 1158 'type': 'button', 1159 'name': this.id ? this.id : this.name, 1160 'value': this.title ? this.title : this.name, 1161 'id': this.id 1162 } 1163 }; 1164 1165 if (this.hint) 1166 btn.props.title = this.hint; 1167 if (!!this.className) 1168 btn.props.className = this.className; 1169 1170 if (this.action) 1171 { 1172 btn.events = { 1173 'click': BX.delegate(this.action, this) 1174 }; 1175 } 1176 else if (this.onclick) 1177 { 1178 if (BX.browser.IsIE()) 1179 { 1180 btn.events = { 1181 'click': BX.delegate(function() {eval(this.onclick)}, this) 1182 }; 1183 } 1184 else 1185 { 1186 btn.attrs = { 1187 'onclick': this.onclick 1188 }; 1189 } 1190 } 1191 1192 this.btn = BX.create('INPUT', btn); 1193 1194 return this.btn; 1195}; 1196 1197BX.CWindowButton.prototype.disableUntilError = function() { 1198 this.disable(); 1199 if (!this.__window_error_handler_set) 1200 { 1201 BX.addCustomEvent(this.parentWindow, 'onWindowError', BX.delegate(this.enable, this)); 1202 this.__window_error_handler_set = true; 1203 } 1204}; 1205 1206/* base window class */ 1207BX.CWindow = function(div, type) 1208{ 1209 this.DIV = div || document.createElement('DIV'); 1210 1211 this.SETTINGS = { 1212 resizable: false, 1213 min_height: 0, 1214 min_width: 0, 1215 top: 0, 1216 left: 0, 1217 draggable: false, 1218 drag_restrict: true, 1219 resize_restrict: true 1220 }; 1221 1222 this.ELEMENTS = { 1223 draggable: [], 1224 resizer: [], 1225 close: [] 1226 }; 1227 1228 this.type = type == 'float' ? 'float' : 'dialog'; 1229 1230 BX.adjust(this.DIV, { 1231 props: { 1232 className: 'bx-core-window' 1233 }, 1234 style: { 1235 'zIndex': 0, 1236 'position': 'absolute', 1237 'display': 'none', 1238 'top': this.SETTINGS.top + 'px', 1239 'left': this.SETTINGS.left + 'px', 1240 'height': '100px', 1241 'width': '100px' 1242 } 1243 }); 1244 1245 this.isOpen = false;
1246 1247 BX.addCustomEvent(this, 'onWindowRegister', BX.delegate(this.onRegister, this)); 1248 BX.addCustomEvent(this, 'onWindowUnRegister', BX.delegate(this.onUnRegister, this)); 1249 1250 this.MOUSEOVER = null; 1251 BX.bind(this.DIV, 'mouseover', BX.delegate(this.__set_msover, this)); 1252 BX.bind(this.DIV, 'mouseout', BX.delegate(this.__unset_msover, this)); 1253 1254 BX.ready(BX.delegate(function() { 1255 document.body.appendChild(this.DIV); 1256 BX.ZIndexManager.register(this.DIV); 1257 }, this)); 1258}; 1259 1260BX.CWindow.prototype.Get = function () {return this.DIV}; 1261BX.CWindow.prototype.visible = function() {return this.isOpen;}; 1262 1263BX.CWindow.prototype.Show = function(bNotRegister) 1264{ 1265 this.DIV.style.display = 'block'; 1266 1267 if (!bNotRegister) 1268 { 1269 BX.WindowManager.register(this); 1270 BX.onCustomEvent(this, 'onWindowRegister'); 1271 } 1272 1273 BX.ZIndexManager.bringToFront(this.DIV); 1274}; 1275 1276BX.CWindow.prototype.Hide = function() 1277{ 1278 BX.WindowManager.unregister(this); 1279 this.DIV.style.display = 'none'; 1280}; 1281 1282BX.CWindow.prototype.onRegister = function() 1283{ 1284 this.isOpen = true; 1285}; 1286 1287BX.CWindow.prototype.onUnRegister = function(clean) 1288{ 1289 this.isOpen = false; 1290 1291 if (clean || (this.PARAMS && this.PARAMS.content_url)) 1292 { 1293 if (clean) {BX.onCustomEvent(this, 'onWindowClose', [this, true]);} 1294 1295 if (this.DIV.parentNode) 1296 this.DIV.parentNode.removeChild(this.DIV); 1297 } 1298 else 1299 { 1300 this.DIV.style.display = 'none'; 1301 } 1302}; 1303 1304BX.CWindow.prototype.CloseDialog = // compatibility 1305BX.CWindow.prototype.Close = function(bImmediately) 1306{ 1307 BX.onCustomEvent(this, 'onBeforeWindowClose', [this]); 1308 if (bImmediately !== true) 1309 { 1310 if (this.denyClose) 1311 return false; 1312 } 1313 1314 BX.onCustomEvent(this, 'onWindowClose', [this]); 1315 1316 //this crashes vis editor in ie via onWindowResizeExt event handler 1317 //if (this.bExpanded) this.__expand(); 1318 // alternative version: 1319 if (this.bExpanded) 1320 { 1321 var pDocElement = BX.GetDocElement(); 1322 BX.unbind(window, 'resize', BX.proxy(this.__expand_onresize, this)); 1323 pDocElement.style.overflow = this.__expand_settings.overflow; 1324 } 1325 1326 BX.WindowManager.unregister(this); 1327 1328 return true; 1329}; 1330 1331BX.CWindow.prototype.SetResize = function(elem) 1332{ 1333 elem.style.cursor = 'se-resize'; 1334 BX.bind(elem, 'mousedown', BX.proxy(this.__startResize, this)); 1335 1336 this.ELEMENTS.resizer.push(elem); 1337 this.SETTINGS.resizable = true; 1338}; 1339 1340BX.CWindow.prototype.SetExpand = function(elem, event_name) 1341{ 1342 event_name = event_name || 'click'; 1343 BX.bind(elem, event_name, BX.proxy(this.__expand, this)); 1344}; 1345 1346BX.CWindow.prototype.__expand_onresize = function() 1347{ 1348 var windowSize = BX.GetWindowInnerSize(); 1349 this.DIV.style.width = windowSize.innerWidth + "px"; 1350 this.DIV.style.height = windowSize.innerHeight + "px"; 1351 1352 BX.onCustomEvent(this, 'onWindowResize'); 1353}; 1354 1355BX.CWindow.prototype.__expand = function() 1356{ 1357 var pDocElement = BX.GetDocElement(); 1358 1359 if (!this.bExpanded) 1360 { 1361 var wndScroll = BX.GetWindowScrollPos(), 1362 wndSize = BX.GetWindowInnerSize(); 1363 1364 this.__expand_settings = { 1365 resizable: this.SETTINGS.resizable, 1366 draggable: this.SETTINGS.draggable, 1367 width: this.DIV.style.width, 1368 height: this.DIV.style.height, 1369 left: this.DIV.style.left, 1370 top: this.DIV.style.top, 1371 scrollTop: wndScroll.scrollTop, 1372 scrollLeft: wndScroll.scrollLeft, 1373 overflow: BX.style(pDocElement, 'overflow') 1374 }; 1375 1376 this.SETTINGS.resizable = false; 1377 this.SETTINGS.draggable = false; 1378 1379 window.scrollTo(0,0); 1380 pDocElement.style.overflow = 'hidden'; 1381 1382 this.DIV.style.top = '0px'; 1383 this.DIV.style.left = '0px'; 1384 1385 this.DIV.style.width = wndSize.innerWidth + 'px'; 1386 this.DIV.style.height = wndSize.innerHeight + 'px'; 1387 1388 this.bExpanded = true; 1389 1390 BX.onCustomEvent(this, 'onWindowExpand'); 1391 BX.onCustomEvent(this, 'onWindowResize'); 1392 1393 BX.bind(window, 'resize', BX.proxy(this.__expand_onresize, this)); 1394 } 1395 else 1396 { 1397 BX.unbind(window, 'resize', BX.proxy(this.__expand_onresize, this)); 1398 1399 this.SETTINGS.resizable = this.__expand_settings.resizable; 1400 this.SETTINGS.draggable = this.__expand_settings.draggable; 1401 1402 pDocElement.style.overflow = this.__expand_settings.overflow; 1403 1404 this.DIV.style.top = this.__expand_settings.top; 1405 this.DIV.style.left = this.__expand_settings.left; 1406 this.DIV.style.width = this.__expand_settings.width; 1407 this.DIV.style.height = this.__expand_settings.height; 1408 1409 window.scrollTo(this.__expand_settings.scrollLeft, this.__expand_settings.scrollTop); 1410 1411 this.bExpanded = false;
1412 1413 BX.onCustomEvent(this, 'onWindowNarrow'); 1414 BX.onCustomEvent(this, 'onWindowResize'); 1415 1416 } 1417}; 1418 1419BX.CWindow.prototype.Resize = function(x, y) 1420{ 1421 var new_width = Math.max(x - this.pos.left + this.dx, this.SETTINGS.min_width); 1422 var new_height = Math.max(y - this.pos.top + this.dy, this.SETTINGS.min_height); 1423 1424 if (this.SETTINGS.resize_restrict) 1425 { 1426 var scrollSize = BX.GetWindowScrollSize(); 1427 1428 if (this.pos.left + new_width > scrollSize.scrollWidth - this.dw) 1429 new_width = scrollSize.scrollWidth - this.pos.left - this.dw; 1430 } 1431 1432 this.DIV.style.width = new_width + 'px'; 1433 this.DIV.style.height = new_height + 'px'; 1434 1435 BX.onCustomEvent(this, 'onWindowResize'); 1436}; 1437 1438BX.CWindow.prototype.__startResize = function(e) 1439{ 1440 if (!this.SETTINGS.resizable) 1441 return false; 1442 1443 if(!e) e = window.event; 1444 1445 this.wndSize = BX.GetWindowScrollPos(); 1446 this.wndSize.innerWidth = BX.GetWindowInnerSize().innerWidth; 1447 1448 this.pos = BX.pos(this.DIV); 1449 1450 this.x = e.clientX + this.wndSize.scrollLeft; 1451 this.y = e.clientY + this.wndSize.scrollTop; 1452 1453 this.dx = this.pos.left + this.pos.width - this.x; 1454 this.dy = this.pos.top + this.pos.height - this.y; 1455 this.dw = this.pos.width - parseInt(this.DIV.style.width); 1456 1457 BX.bind(document, "mousemove", BX.proxy(this.__moveResize, this)); 1458 BX.bind(document, "mouseup", BX.proxy(this.__stopResize, this)); 1459 1460 if(document.body.setCapture) 1461 document.body.setCapture(); 1462 1463 document.onmousedown = BX.False; 1464 1465 var b = document.body; 1466 b.ondrag = b.onselectstart = BX.False; 1467 b.style.MozUserSelect = this.DIV.style.MozUserSelect = 'none'; 1468 b.style.cursor = 'se-resize'; 1469 1470 BX.onCustomEvent(this, 'onWindowResizeStart'); 1471 1472 return true; 1473}; 1474 1475BX.CWindow.prototype.__moveResize = function(e) 1476{ 1477 if(!e) e = window.event; 1478 1479 var windowScroll = BX.GetWindowScrollPos(); 1480 1481 var x = e.clientX + windowScroll.scrollLeft; 1482 var y = e.clientY + windowScroll.scrollTop; 1483 1484 if(this.x == x && this.y == y) 1485 return; 1486 1487 this.Resize(x, y); 1488 1489 this.x = x; 1490 this.y = y; 1491}; 1492 1493BX.CWindow.prototype.__stopResize = function() 1494{ 1495 if(document.body.releaseCapture) 1496 document.body.releaseCapture(); 1497 1498 BX.unbind(document, "mousemove", BX.proxy(this.__moveResize, this)); 1499 BX.unbind(document, "mouseup", BX.proxy(this.__stopResize, this)); 1500 1501 document.onmousedown = null; 1502 1503 var b = document.body; 1504 b.ondrag = b.onselectstart = null; 1505 b.style.MozUserSelect = this.DIV.style.MozUserSelect = ''; 1506 b.style.cursor = ''; 1507 1508 BX.onCustomEvent(this, 'onWindowResizeFinished') 1509}; 1510 1511BX.CWindow.prototype.SetClose = function(elem) 1512{ 1513 BX.bind(elem, 'click', BX.proxy(this.Close, this)); 1514 this.ELEMENTS.close.push(elem); 1515}; 1516 1517BX.CWindow.prototype.SetDraggable = function(elem) 1518{ 1519 BX.bind(elem, 'mousedown', BX.proxy(this.__startDrag, this)); 1520 1521 elem.style.cursor = 'move'; 1522 1523 this.ELEMENTS.draggable.push(elem); 1524 this.SETTINGS.draggable = true; 1525}; 1526 1527BX.CWindow.prototype.Move = function(x, y) 1528{ 1529 var dxShadow = 1; // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 1530 1531 var left = parseInt(this.DIV.style.left)+x; 1532 var top = parseInt(this.DIV.style.top)+y; 1533 1534 if (this.SETTINGS.drag_restrict) 1535 { 1536 //Left side 1537 if (left < 0) 1538 left = 0; 1539 1540 //Right side 1541 var scrollSize = BX.GetWindowScrollSize(); 1542 var floatWidth = this.DIV.offsetWidth; 1543 var floatHeight = this.DIV.offsetHeight; 1544 1545 if (left > (scrollSize.scrollWidth - floatWidth - dxShadow)) 1546 left = scrollSize.scrollWidth - floatWidth - dxShadow; 1547 1548 var scrollHeight = Math.max( 1549 document.body.scrollHeight, document.documentElement.scrollHeight, 1550 document.body.offsetHeight, document.documentElement.offsetHeight, 1551 document.body.clientHeight, document.documentElement.clientHeight, 1552 scrollSize.scrollHeight 1553 ); 1554 1555 if (top > (scrollHeight - floatHeight - dxShadow)) 1556 top = scrollHeight - floatHeight - dxShadow; 1557 1558 //Top side 1559 if (top < 0) 1560 top = 0; 1561 } 1562 1563 this.DIV.style.left = left+'px'; 1564 this.DIV.style.top = top+'px'; 1565 1566 //this.AdjustShadow(div); 1567}; 1568 1569BX.CWindow.prototype.__startDrag = function(e) 1570{ 1571 if (!this.SETTINGS.draggable) 1572 return false; 1573 1574 if(!e) e = window.event; 1575 1576 this.x = e.clientX + document.body.scrollLeft; 1577 this.y = e.clientY + document.body.scrollTop; 1578 1579 this.__bWasDragged = false;
1580 BX.bind(document, "mousemove", BX.proxy(this.__moveDrag, this)); 1581 BX.bind(document, "mouseup", BX.proxy(this.__stopDrag, this)); 1582 1583 if(document.body.setCapture) 1584 document.body.setCapture(); 1585 1586 document.onmousedown = BX.False; 1587 1588 var b = document.body; 1589 b.ondrag = b.onselectstart = BX.False; 1590 b.style.MozUserSelect = this.DIV.style.MozUserSelect = 'none'; 1591 b.style.cursor = 'move'; 1592 return BX.PreventDefault(e); 1593}; 1594 1595BX.CWindow.prototype.__moveDrag = function(e) 1596{ 1597 if(!e) e = window.event; 1598 1599 var x = e.clientX + document.body.scrollLeft; 1600 var y = e.clientY + document.body.scrollTop; 1601 1602 if(this.x == x && this.y == y) 1603 return; 1604 1605 this.Move((x - this.x), (y - this.y)); 1606 this.x = x; 1607 this.y = y; 1608 1609 if (!this.__bWasDragged) 1610 { 1611 BX.onCustomEvent(this, 'onWindowDragStart'); 1612 this.__bWasDragged = true; 1613 BX.bind(BX.proxy_context, "click", BX.PreventDefault); 1614 } 1615 1616 BX.onCustomEvent(this, 'onWindowDrag'); 1617}; 1618 1619BX.CWindow.prototype.__stopDrag = function(e) 1620{ 1621 if(document.body.releaseCapture) 1622 document.body.releaseCapture(); 1623 1624 BX.unbind(document, "mousemove", BX.proxy(this.__moveDrag, this)); 1625 BX.unbind(document, "mouseup", BX.proxy(this.__stopDrag, this)); 1626 1627 document.onmousedown = null; 1628 1629 var b = document.body; 1630 b.ondrag = b.onselectstart = null; 1631 b.style.MozUserSelect = this.DIV.style.MozUserSelect = ''; 1632 b.style.cursor = ''; 1633 1634 if (this.__bWasDragged) 1635 { 1636 BX.onCustomEvent(this, 'onWindowDragFinished'); 1637 var _proxy_context = BX.proxy_context; 1638 setTimeout(function(){BX.unbind(_proxy_context, "click", BX.PreventDefault)}, 100); 1639 this.__bWasDragged = false; 1640 } 1641 return BX.PreventDefault(e); 1642}; 1643 1644BX.CWindow.prototype.DenyClose = function() 1645{ 1646 this.denyClose = true; 1647}; 1648 1649BX.CWindow.prototype.AllowClose = function() 1650{ 1651 this.denyClose = false; 1652}; 1653 1654BX.CWindow.prototype.ShowError = function(str) 1655{ 1656 BX.onCustomEvent(this, 'onWindowError', [str]); 1657 1658 if (this._wait) 1659 BX.closeWait(this._wait); 1660 1661 window.alert(str); 1662}; 1663 1664BX.CWindow.prototype.__set_msover = function() {this.MOUSEOVER = true;}; 1665BX.CWindow.prototype.__unset_msover = function() {this.MOUSEOVER = false;}; 1666 1667/* dialog window class extends window class */ 1668BX.CWindowDialog = function() { 1669 var a = arguments; 1670 a[1] = 'dialog'; 1671 BX.CWindowDialog.superclass.constructor.apply(this, a); 1672 1673 this.DIV.style.top = '10px'; 1674 this.OVERLAY = null; 1675}; 1676BX.extend(BX.CWindowDialog, BX.CWindow); 1677 1678BX.CWindowDialog.prototype.__resizeOverlay = function() 1679{ 1680 var windowSize = BX.GetWindowScrollSize(); 1681 this.OVERLAY.style.width = windowSize.scrollWidth + "px"; 1682}; 1683 1684BX.CWindowDialog.prototype.CreateOverlay = function(zIndex) 1685{ 1686 if (null == this.OVERLAY) 1687 { 1688 var windowSize = BX.GetWindowScrollSize(); 1689 1690 // scrollHeight in BX.GetWindowScrollSize may be incorrect 1691 var scrollHeight = Math.max( 1692 document.body.scrollHeight, document.documentElement.scrollHeight, 1693 document.body.offsetHeight, document.documentElement.offsetHeight, 1694 document.body.clientHeight, document.documentElement.clientHeight, 1695 windowSize.scrollHeight 1696 ); 1697 1698 this.OVERLAY = document.body.appendChild(BX.create("DIV", { 1699 style: { 1700 position: 'absolute', 1701 top: '0px', 1702 left: '0px', 1703 zIndex: zIndex || (parseInt(this.DIV.style.zIndex)-2), 1704 width: windowSize.scrollWidth + "px", 1705 height: scrollHeight + "px" 1706 } 1707 })); 1708 1709 var component = BX.ZIndexManager.getComponent(this.DIV); 1710 if (component) 1711 { 1712 component.setOverlay(this.OVERLAY); 1713 } 1714 } 1715 1716 return this.OVERLAY; 1717}; 1718 1719BX.CWindowDialog.prototype.Show = function() 1720{ 1721 BX.CWindowDialog.superclass.Show.apply(this, arguments); 1722 1723 this.CreateOverlay(); 1724 1725 this.OVERLAY.style.display = 'block'; 1726 1727 BX.unbind(window, 'resize', BX.proxy(this.__resizeOverlay, this)); 1728 BX.bind(window, 'resize', BX.proxy(this.__resizeOverlay, this)); 1729}; 1730 1731BX.CWindowDialog.prototype.onUnRegister = function(clean) 1732{ 1733 BX.CWindowDialog.superclass.onUnRegister.apply(this, arguments); 1734 1735 if (this.clean) 1736 { 1737 if (this.OVERLAY.parentNode) 1738 this.OVERLAY.parentNode.removeChild(this.OVERLAY); 1739 } 1740 else 1741 { 1742 this.OVERLAY.style.display = 'none'; 1743 } 1744 1745 BX.unbind(window, 'resize', BX.proxy(this.__resizeOverlay, this)); 1746}; 1747 1748/* standard bitrix dialog extends BX.CWindowDialog */ 1749/*
1750 arParams = { 1751 ( 1752 title: 'dialog title', 1753 head: 'head block html', 1754 content: 'dialog content', 1755 icon: 'head icon classname or filename', 1756 1757 resize_id: 'some id to save resize information'// useless if resizable = false 1758 ) 1759 or 1760 ( 1761 content_url: url to content load 1762 loaded content scripts can use BX.WindowManager.Get() to get access to the current window object 1763 ) 1764 1765 height: window_height_in_pixels, 1766 width: window_width_in_pixels, 1767 1768 draggable: true|false, 1769 resizable: true|false, 1770 1771 min_height: min_window_height_in_pixels, // useless if resizable = false 1772 min_width: min_window_width_in_pixels, // useless if resizable = false 1773 1774 buttons: [ 1775 'html_code', 1776 BX.CDialog.btnSave, BX.CDialog.btnCancel, BX.CDialog.btnClose 1777 ] 1778 } 1779*/ 1780BX.CDialog = function(arParams) 1781{ 1782 BX.CDialog.superclass.constructor.apply(this); 1783 1784 this._sender = 'core_window_cdialog'; 1785 1786 this.PARAMS = arParams || {}; 1787 1788 for (var i in this.defaultParams) 1789 { 1790 if (typeof this.PARAMS[i] == 'undefined') 1791 this.PARAMS[i] = this.defaultParams[i]; 1792 } 1793 1794 this.PARAMS.width = (!isNaN(parseInt(this.PARAMS.width))) 1795 ? this.PARAMS.width 1796 : this.defaultParams['width']; 1797 this.PARAMS.height = (!isNaN(parseInt(this.PARAMS.height))) 1798 ? this.PARAMS.height 1799 : this.defaultParams['height']; 1800 1801 if (this.PARAMS.resize_id || this.PARAMS.content_url) 1802 { 1803 var arSize = BX.WindowManager.getRuntimeWindowSize(this.PARAMS.resize_id || this.PARAMS.content_url); 1804 if (arSize) 1805 { 1806 this.PARAMS.width = arSize.width; 1807 this.PARAMS.height = arSize.height; 1808 } 1809 } 1810 1811 BX.addClass(this.DIV, 'bx-core-adm-dialog'); 1812 this.DIV.id = 'bx-admin-prefix'; 1813 1814 this.PARTS = {}; 1815 1816 this.DIV.style.height = null; 1817 this.DIV.style.width = null; 1818 1819 this.PARTS.TITLEBAR = this.DIV.appendChild(BX.create('DIV', {props: { 1820 className: 'bx-core-adm-dialog-head' 1821 } 1822 })); 1823 1824 this.PARTS.TITLE_CONTAINER = this.PARTS.TITLEBAR.appendChild(BX.create('SPAN', { 1825 props: {className: 'bx-core-adm-dialog-head-inner'}, 1826 text: this.PARAMS.title 1827 })); 1828 1829 this.PARTS.TITLEBAR_ICONS = this.PARTS.TITLEBAR.appendChild(BX.create('DIV', { 1830 props: { 1831 className: 'bx-core-adm-dialog-head-icons' 1832 }, 1833 children: (this.PARAMS.resizable ? [ 1834 BX.create('SPAN', {props: {className: 'bx-core-adm-icon-expand', title: BX.message('JS_CORE_WINDOW_EXPAND')}}), 1835 BX.create('SPAN', {props: {className: 'bx-core-adm-icon-close', title: BX.message('JS_CORE_WINDOW_CLOSE')}}) 1836 ] : [ 1837 BX.create('SPAN', {props: {className: 'bx-core-adm-icon-close', title: BX.message('JS_CORE_WINDOW_CLOSE')}}) 1838 ]) 1839 })); 1840 1841 1842 this.PARTS.CONTENT = this.DIV.appendChild(BX.create('DIV', { 1843 props: {className: 'bx-core-adm-dialog-content-wrap adm-workarea'} 1844 })); 1845 1846 this.PARTS.CONTENT_DATA = this.PARTS.CONTENT.appendChild(BX.create('DIV', { 1847 props: {className: 'bx-core-adm-dialog-content'}, 1848 style: { 1849 height: this.PARAMS.height + 'px', 1850 width: this.PARAMS.width + 'px' 1851 } 1852 })); 1853 1854 this.PARTS.HEAD = this.PARTS.CONTENT_DATA.appendChild(BX.create('DIV', { 1855 props: { 1856 className: 'bx-core-adm-dialog-head-block' + (this.PARAMS.icon ? ' ' + this.PARAMS.icon : '') 1857 } 1858 })); 1859 1860 this.SetHead(this.PARAMS.head); 1861 this.SetContent(this.PARAMS.content); 1862 this.SetTitle(this.PARAMS.title); 1863 this.SetClose(this.PARTS.TITLEBAR_ICONS.lastChild); 1864 1865 if (this.PARAMS.resizable) 1866 { 1867 this.SetExpand(this.PARTS.TITLEBAR_ICONS.firstChild); 1868 this.SetExpand(this.PARTS.TITLEBAR, 'dblclick'); 1869 1870 BX.addCustomEvent(this, 'onWindowExpand', BX.proxy(this.__onexpand, this)); 1871 BX.addCustomEvent(this, 'onWindowNarrow', BX.proxy(this.__onexpand, this)); 1872 } 1873 1874 this.PARTS.FOOT = this.PARTS.BUTTONS_CONTAINER = this.PARTS.CONTENT.appendChild(BX.create('DIV', { 1875 props: { 1876 className: 'bx-core-adm-dialog-buttons' 1877 }, 1878 //events: { 1879 // 'click': BX.delegateEvent({property:{type: /button|submit/}}, BX.delegate(function() {this.showWait(BX.proxy_context)}, this)) 1880 //}, 1881 children: this.ShowButtons() 1882 } 1883 )); 1884 1885 if (this.PARAMS.draggable) 1886 this.SetDraggable(this.PARTS.TITLEBAR); 1887 1888 if (this.PARAMS.resizable) 1889 { 1890 this.PARTS.RESIZER = this.DIV.appendChild(BX.create('DIV', { 1891 props: {className: 'bx-core-resizer'} 1892 })); 1893 1894 this.SetResize(this.PARTS.RESIZER); 1895 1896 this.SETTINGS.min_width = this.PARAMS.min_width; 1897 this.SETTINGS.min_height = this.PARAMS.min_height; 1898 } 1899 1900 this.auth_callback = BX.delegate(function(){ 1901 this.PARAMS.content = ''; 1902 this.hideNotify(); 1903 this.Show(); 1904 }, this) 1905}; 1906BX.extend(BX.CDialog, BX.CWindowDialog); 1907 1908BX.CDialog.prototype.defaultParams = { 1909 width: 700, 1910 height: 400, 1911 min_width: 500, 1912 min_height: 300, 1913 1914 resizable: true, 1915 draggable: true, 1916 1917 title: '', 1918 icon: '' 1919}; 1920 1921BX.CDialog.prototype.showWait = function(el) 1922{ 1923 if (BX.type.isElementNode(el) && (el.type == 'button' || el.type == 'submit')) 1924 { 1925 BX.defer(function(){el.disabled = true})(); 1926 1927 var bSave = (BX.hasClass(el, 'adm-btn-save') || BX.hasClass(el, 'adm-btn-save')), 1928 pos = BX.pos(el, true); 1929 1930 el.bxwaiter = this.PARTS.FOOT.appendChild(BX.create('DIV', { 1931 props: {className: 'adm-btn-load-img' + (bSave ? '-green' : '')}, 1932 style: { 1933 top: parseInt((pos.bottom + pos.top)/2 - 10) + 'px', 1934 left: parseInt((pos.right + pos.left)/2 - 10) + 'px' 1935 } 1936 })); 1937 1938 BX.addClass(el, 'adm-btn-load'); 1939 1940 this.lastWaitElement = el; 1941 1942 return el.bxwaiter; 1943 } 1944 return null; 1945}; 1946 1947BX.CDialog.prototype.closeWait = function(el) 1948{ 1949 el = el || this.lastWaitElement; 1950 1951 if (BX.type.isElementNode(el)) 1952 { 1953 if (el.bxwaiter) 1954 { 1955 if(el.bxwaiter.parentNode) 1956 { 1957 el.bxwaiter.parentNode.removeChild(el.bxwaiter); 1958 } 1959 1960 el.bxwaiter = null; 1961 } 1962 1963 el.disabled = false;
1964 BX.removeClass(el, 'adm-btn-load'); 1965 1966 if (this.lastWaitElement == el) 1967 this.lastWaitElement = null; 1968 } 1969}; 1970 1971BX.CDialog.prototype.Authorize = function(arAuthResult) 1972{ 1973 this.bSkipReplaceContent = true; 1974 this.ShowError(BX.message('JSADM_AUTH_REQ')); 1975 1976 BX.onCustomEvent(this, 'onWindowError', []); 1977 1978 BX.closeWait(); 1979 1980 (new BX.CAuthDialog({ 1981 content_url: this.PARAMS.content_url, 1982 auth_result: arAuthResult, 1983 callback: BX.delegate(function(){ 1984 if (this.auth_callback) 1985 this.auth_callback() 1986 }, this) 1987 })).Show(); 1988}; 1989 1990BX.CDialog.prototype.ShowError = function(str) 1991{ 1992 BX.onCustomEvent(this, 'onWindowError', [str]); 1993 1994 this.closeWait(); 1995 1996 if (this._wait) 1997 BX.closeWait(this._wait); 1998 1999 this.Notify(str, true); 2000}; 2001 2002 2003BX.CDialog.prototype.__expandGetSize = function() 2004{ 2005 var pDocElement = BX.GetDocElement(); 2006 pDocElement.style.overflow = 'hidden'; 2007 2008 var wndSize = BX.GetWindowInnerSize(); 2009 2010 pDocElement.scrollTop = 0; 2011 2012 this.DIV.style.top = '-' + this.dxShadow + 'px'; 2013 this.DIV.style.left = '-' + this.dxShadow + 'px'; 2014 2015 return { 2016 width: (wndSize.innerWidth - parseInt(BX.style(this.PARTS.CONTENT, 'padding-right')) - parseInt(BX.style(this.PARTS.CONTENT, 'padding-left'))) + this.dxShadow, 2017 height: (wndSize.innerHeight - this.PARTS.TITLEBAR.offsetHeight - this.PARTS.FOOT.offsetHeight - parseInt(BX.style(this.PARTS.CONTENT, 'padding-top')) - parseInt(BX.style(this.PARTS.CONTENT, 'padding-bottom'))) + this.dxShadow 2018 }; 2019}; 2020 2021BX.CDialog.prototype.__expand = function() 2022{ 2023 var pDocElement = BX.GetDocElement(); 2024 this.dxShadow = 2; 2025 2026 if (!this.bExpanded) 2027 { 2028 var wndScroll = BX.GetWindowScrollPos(); 2029 2030 this.__expand_settings = { 2031 resizable: this.SETTINGS.resizable, 2032 draggable: this.SETTINGS.draggable, 2033 width: this.PARTS.CONTENT_DATA.style.width, 2034 height: this.PARTS.CONTENT_DATA.style.height, 2035 left: this.DIV.style.left, 2036 top: this.DIV.style.top, 2037 scrollTop: wndScroll.scrollTop, 2038 scrollLeft: wndScroll.scrollLeft, 2039 overflow: BX.style(pDocElement, 'overflow') 2040 }; 2041 2042 this.SETTINGS.resizable = false; 2043 this.SETTINGS.draggable = false; 2044 2045 var pos = this.__expandGetSize(); 2046 2047 this.PARTS.CONTENT_DATA.style.width = pos.width + 'px'; 2048 this.PARTS.CONTENT_DATA.style.height = pos.height + 'px'; 2049 2050 window.scrollTo(0,0); 2051 pDocElement.style.overflow = 'hidden'; 2052 2053 this.bExpanded = true; 2054 2055 BX.onCustomEvent(this, 'onWindowExpand'); 2056 BX.onCustomEvent(this, 'onWindowResize'); 2057 BX.onCustomEvent(this, 'onWindowResizeExt', [{'width': pos.width, 'height': pos.height}]); 2058 2059 BX.bind(window, 'resize', BX.proxy(this.__expand_onresize, this)); 2060 } 2061 else 2062 { 2063 BX.unbind(window, 'resize', BX.proxy(this.__expand_onresize, this)); 2064 2065 this.SETTINGS.resizable = this.__expand_settings.resizable; 2066 this.SETTINGS.draggable = this.__expand_settings.draggable; 2067 2068 pDocElement.style.overflow = this.__expand_settings.overflow; 2069 2070 this.DIV.style.top = this.__expand_settings.top; 2071 this.DIV.style.left = this.__expand_settings.left; 2072 this.PARTS.CONTENT_DATA.style.width = this.__expand_settings.width; 2073 this.PARTS.CONTENT_DATA.style.height = this.__expand_settings.height; 2074 window.scrollTo(this.__expand_settings.scrollLeft, this.__expand_settings.scrollTop); 2075 this.bExpanded = false; 2076 2077 BX.onCustomEvent(this, 'onWindowNarrow'); 2078 BX.onCustomEvent(this, 'onWindowResize'); 2079 BX.onCustomEvent(this, 'onWindowResizeExt', [{'width': parseInt(this.__expand_settings.width), 'height': parseInt(this.__expand_settings.height)}]); 2080 } 2081}; 2082 2083BX.CDialog.prototype.__expand_onresize = function() 2084{ 2085 var pos = this.__expandGetSize(); 2086 2087 this.PARTS.CONTENT_DATA.style.width = pos.width + 'px'; 2088 this.PARTS.CONTENT_DATA.style.height = pos.height + 'px'; 2089 2090 BX.onCustomEvent(this, 'onWindowResize'); 2091 BX.onCustomEvent(this, 'onWindowResizeExt', [pos]); 2092}; 2093 2094BX.CDialog.prototype.__onexpand = function() 2095{ 2096 var ob = this.PARTS.TITLEBAR_ICONS.firstChild; 2097 ob.className = BX.toggle(ob.className, ['bx-core-adm-icon-expand', 'bx-core-adm-icon-narrow']); 2098 ob.title = BX.toggle(ob.title, [BX.message('JS_CORE_WINDOW_EXPAND'), BX.message('JS_CORE_WINDOW_NARROW')]); 2099 2100 if (this.PARTS.RESIZER) 2101 { 2102 this.PARTS.RESIZER.style.display = this.bExpanded ? 'none' : 'block'; 2103 } 2104}; 2105 2106 2107BX.CDialog.prototype.__startResize = function(e) 2108{ 2109 if (!this.SETTINGS.resizable) 2110 return false;
2111 2112 if(!e) e = window.event; 2113 2114 this.wndSize = BX.GetWindowScrollPos(); 2115 this.wndSize.innerWidth = BX.GetWindowInnerSize().innerWidth; 2116 2117 this.pos = BX.pos(this.PARTS.CONTENT_DATA); 2118 2119 this.x = e.clientX + this.wndSize.scrollLeft; 2120 this.y = e.clientY + this.wndSize.scrollTop; 2121 2122 this.dx = this.pos.left + this.pos.width - this.x; 2123 this.dy = this.pos.top + this.pos.height - this.y; 2124 2125 2126 // TODO: suspicious 2127 this.dw = this.pos.width - parseInt(this.PARTS.CONTENT_DATA.style.width) + parseInt(BX.style(this.PARTS.CONTENT, 'padding-right')); 2128 2129 BX.bind(document, "mousemove", BX.proxy(this.__moveResize, this)); 2130 BX.bind(document, "mouseup", BX.proxy(this.__stopResize, this)); 2131 2132 if(document.body.setCapture) 2133 document.body.setCapture(); 2134 2135 document.onmousedown = BX.False; 2136 2137 var b = document.body; 2138 b.ondrag = b.onselectstart = BX.False; 2139 b.style.MozUserSelect = this.DIV.style.MozUserSelect = 'none'; 2140 b.style.cursor = 'se-resize'; 2141 2142 BX.onCustomEvent(this, 'onWindowResizeStart'); 2143 2144 return true; 2145}; 2146 2147BX.CDialog.prototype.Resize = function(x, y) 2148{ 2149 var new_width = Math.max(x - this.pos.left + this.dx, this.SETTINGS.min_width); 2150 var new_height = Math.max(y - this.pos.top + this.dy, this.SETTINGS.min_height); 2151 2152 if (this.SETTINGS.resize_restrict) 2153 { 2154 var scrollSize = BX.GetWindowScrollSize(); 2155 2156 if (this.pos.left + new_width > scrollSize.scrollWidth - this.dw) 2157 new_width = scrollSize.scrollWidth - this.pos.left - this.dw; 2158 } 2159 2160 this.PARTS.CONTENT_DATA.style.width = new_width + 'px'; 2161 this.PARTS.CONTENT_DATA.style.height = new_height + 'px'; 2162 2163 BX.onCustomEvent(this, 'onWindowResize'); 2164 BX.onCustomEvent(this, 'onWindowResizeExt', [{'height': new_height, 'width': new_width}]); 2165}; 2166 2167BX.CDialog.prototype.SetSize = function(obSize) 2168{ 2169 this.PARTS.CONTENT_DATA.style.width = obSize.width + 'px'; 2170 this.PARTS.CONTENT_DATA.style.height = obSize.height + 'px'; 2171 2172 BX.onCustomEvent(this, 'onWindowResize'); 2173 BX.onCustomEvent(this, 'onWindowResizeExt', [obSize]); 2174}; 2175 2176BX.CDialog.prototype.GetParameters = function(form_name) 2177{ 2178 var form = this.GetForm(); 2179 2180 if(!form) 2181 return ""; 2182 2183 var i, s = ""; 2184 var n = form.elements.length; 2185 2186 var delim = ''; 2187 for(i=0; i<n; i++) 2188 { 2189 if (s != '') delim = '&'; 2190 var el = form.elements[i]; 2191 if (el.disabled) 2192 continue; 2193 2194 switch(el.type.toLowerCase()) 2195 { 2196 case 'text': 2197 case 'textarea': 2198 case 'password': 2199 case 'hidden': 2200 if (null == form_name && el.name.substr(el.name.length-4) == '_alt' && form.elements[el.name.substr(0, el.name.length-4)]) 2201 break; 2202 s += delim + el.name + '=' + BX.util.urlencode(el.value); 2203 break; 2204 case 'radio': 2205 if(el.checked) 2206 s += delim + el.name + '=' + BX.util.urlencode(el.value); 2207 break; 2208 case 'checkbox': 2209 s += delim + el.name + '=' + BX.util.urlencode(el.checked ? 'Y':'N'); 2210 break; 2211 case 'select-one': 2212 var val = ""; 2213 if (null == form_name && form.elements[el.name + '_alt'] && el.selectedIndex == 0) 2214 val = form.elements[el.name+'_alt'].value; 2215 else 2216 val = el.value; 2217 s += delim + el.name + '=' + BX.util.urlencode(val); 2218 break; 2219 case 'select-multiple': 2220 var j, bAdded = false; 2221 var l = el.options.length; 2222 for (j=0; j<l; j++) 2223 { 2224 if (el.options[j].selected) 2225 { 2226 s += delim + el.name + '=' + BX.util.urlencode(el.options[j].value); 2227 bAdded = true; 2228 } 2229 } 2230 if (!bAdded) 2231 s += delim + el.name + '='; 2232 break; 2233 default: 2234 break; 2235 } 2236 } 2237 2238 return s; 2239}; 2240 2241BX.CDialog.prototype.PostParameters = function(params) 2242{ 2243 var url = this.PARAMS.content_url; 2244 2245 if (null == params) 2246 params = ""; 2247 2248 params += (params == "" ? "" : "&") + "bxsender=" + this._sender; 2249 2250 var index = url.indexOf('?'); 2251 if (index == -1) 2252 url += '?' + params; 2253 else 2254 url = url.substring(0, index) + '?' + params + "&" + url.substring(index+1); 2255 2256 BX.showWait(); 2257 2258 this.auth_callback = BX.delegate(function(){ 2259 this.hideNotify(); 2260 this.PostParameters(params); 2261 }, this); 2262 2263 BX.ajax.Setup({skipAuthCheck:true},true); 2264 BX.ajax.post(url, this.GetParameters(), BX.delegate(function(result) { 2265 BX.closeWait(); 2266 if (!this.bSkipReplaceContent) 2267 { 2268 this.ClearButtons(); // buttons are appended during form reload, so we should clear footer 2269 this.SetContent(result); 2270 this.Show(true); 2271 } 2272 2273 this.bSkipReplaceContent = false;
2274 }, this)); 2275}; 2276 2277BX.CDialog.prototype.Submit = function(params, url) 2278{ 2279 var FORM = this.GetForm(); 2280 if (FORM) 2281 { 2282 FORM.onsubmit = null; 2283 2284 FORM.method = 'POST'; 2285 if (!FORM.action || url) 2286 { 2287 url = url || this.PARAMS.content_url; 2288 if (null != params) 2289 { 2290 var index = url.indexOf('?'); 2291 if (index == -1) 2292 url += '?' + params; 2293 else 2294 url = url.substring(0, index) + '?' + params + "&" + url.substring(index+1); 2295 } 2296 2297 FORM.action = url; 2298 } 2299 2300 if (!FORM._bxsender) 2301 { 2302 FORM._bxsender = FORM.appendChild(BX.create('INPUT', { 2303 attrs: { 2304 type: 'hidden', 2305 name: 'bxsender', 2306 value: this._sender 2307 } 2308 })); 2309 } 2310 2311 this._wait = BX.showWait(); 2312 2313 this.auth_callback = BX.delegate(function(){ 2314 this.hideNotify(); 2315 this.Submit(params); 2316 }, this); 2317 2318 BX.ajax.submit(FORM, BX.delegate(function(){this.closeWait()}, this)); 2319 } 2320 else 2321 { 2322 window.alert('no form registered!'); 2323 } 2324}; 2325 2326BX.CDialog.prototype.GetForm = function() 2327{ 2328 if (null == this.__form) 2329 { 2330 var forms = this.PARTS.CONTENT_DATA.getElementsByTagName('FORM'); 2331 this.__form = forms[0] ? forms[0] : null; 2332 } 2333 2334 return this.__form; 2335}; 2336 2337BX.CDialog.prototype.GetRealForm = function() 2338{ 2339 if (null == this.__rform) 2340 { 2341 var forms = this.PARTS.CONTENT_DATA.getElementsByTagName('FORM'); 2342 this.__rform = forms[1] ? forms[1] : (forms[0] ? forms[0] : null); 2343 } 2344 2345 return this.__rform; 2346}; 2347 2348BX.CDialog.prototype._checkButton = function(btn) 2349{ 2350 var arCustomButtons = ['btnSave', 'btnCancel', 'btnClose']; 2351 2352 for (var i = 0; i < arCustomButtons.length; i++) 2353 { 2354 if (this[arCustomButtons[i]] && (btn == this[arCustomButtons[i]])) 2355 return arCustomButtons[i]; 2356 } 2357 2358 return false; 2359}; 2360 2361BX.CDialog.prototype.ShowButtons = function() 2362{ 2363 var result = []; 2364 if (this.PARAMS.buttons) 2365 { 2366 if (this.PARAMS.buttons.title) this.PARAMS.buttons = [this.PARAMS.buttons]; 2367 2368 for (var i=0, len=this.PARAMS.buttons.length; i<len; i++) 2369 { 2370 if (BX.type.isNotEmptyString(this.PARAMS.buttons[i])) 2371 { 2372 result.push(this.PARAMS.buttons[i]); 2373 } 2374 else if (BX.type.isElementNode(this.PARAMS.buttons[i])) 2375 { 2376 result.push(this.PARAMS.buttons[i]); 2377 } 2378 else if (this.PARAMS.buttons[i]) 2379 { 2380 //if (!(this.PARAMS.buttons[i] instanceof BX.CWindowButton)) 2381 if (!BX.is_subclass_of(this.PARAMS.buttons[i], BX.CWindowButton)) 2382 { 2383 var b = this._checkButton(this.PARAMS.buttons[i]); // hack to set links to real CWindowButton object in btnSave etc; 2384 this.PARAMS.buttons[i] = new BX.CWindowButton(this.PARAMS.buttons[i]); 2385 if (b) this[b] = this.PARAMS.buttons[i]; 2386 } 2387 2388 result.push(this.PARAMS.buttons[i].Button(this)); 2389 } 2390 } 2391 } 2392 2393 return result; 2394}; 2395 2396BX.CDialog.prototype.setAutosave = function () { 2397 if (!this.bSetAutosaveDelay) 2398 { 2399 this.bSetAutosaveDelay = true; 2400 setTimeout(BX.proxy(this.setAutosave, this), 10); 2401 } 2402}; 2403 2404BX.CDialog.prototype.SetTitle = function(title) 2405{ 2406 this.PARAMS.title = title; 2407 BX.cleanNode(this.PARTS.TITLE_CONTAINER).appendChild(document.createTextNode(this.PARAMS.title)); 2408}; 2409 2410BX.CDialog.prototype.SetHead = function(head) 2411{ 2412 this.PARAMS.head = BX.util.trim(head); 2413 this.PARTS.HEAD.innerHTML = this.PARAMS.head || " "; 2414 this.PARTS.HEAD.style.display = this.PARAMS.head ? 'block' : 'none'; 2415 this.adjustSize(); 2416}; 2417 2418BX.CDialog.prototype.Notify = function(note, bError, html) 2419{ 2420 if (!this.PARTS.NOTIFY) 2421 { 2422 this.PARTS.NOTIFY = this.DIV.insertBefore(BX.create('DIV', { 2423 props: {className: 'adm-warning-block'}, 2424 children: [ 2425 BX.create('SPAN', { 2426 props: {className: 'adm-warning-text'} 2427 }), 2428 BX.create('SPAN', { 2429 props: {className: 'adm-warning-icon'} 2430 }), 2431 BX.create('SPAN', { 2432 props: {className: 'adm-warning-close'}, 2433 events: {click: BX.proxy(this.hideNotify, this)} 2434 }) 2435 ] 2436 }), this.DIV.firstChild); 2437 } 2438 2439 if (bError) 2440 BX.addClass(this.PARTS.NOTIFY, 'adm-warning-block-red'); 2441 else 2442 BX.removeClass(this.PARTS.NOTIFY, 'adm-warning-block-red'); 2443 2444 if(html !== true) 2445 { 2446 note = BX.util.htmlspecialchars(note); 2447 } 2448 2449 this.PARTS.NOTIFY.firstChild.innerHTML = note || ' '; 2450 this.PARTS.NOTIFY.firstChild.style.width = (this.PARAMS.width-50) + 'px'; 2451 BX.removeClass(this.PARTS.NOTIFY, 'adm-warning-animate'); 2452}; 2453 2454BX.CDialog.prototype.hideNotify = function() 2455{ 2456 BX.addClass(this.PARTS.NOTIFY, 'adm-warning-animate'); 2457}; 2458 2459BX.CDialog.prototype.__adjustHeadToIcon = function() 2460{ 2461 if (!this.PARTS.HEAD.offsetHeight) 2462 { 2463 setTimeout(BX.delegate(this.__adjustHeadToIcon, this), 50); 2464 } 2465 else 2466 { 2467 if (this.icon_image && this.icon_image.height && this.icon_image.height > this.PARTS.HEAD.offsetHeight - 5) 2468 { 2469 this.PARTS.HEAD.style.height = this.icon_image.height + 5 + 'px'; 2470 this.adjustSize(); 2471 } 2472 2473 this.icon_image.onload = null; 2474 this.icon_image = null; 2475 } 2476}; 2477 2478BX.CDialog.prototype.SetIcon = function(icon_class) 2479{ 2480 if (this.PARAMS.icon != icon_class) 2481 { 2482 if (this.PARAMS.icon) 2483 BX.removeClass(this.PARTS.HEAD, this.PARAMS.icon); 2484 2485 this.PARAMS.icon = icon_class; 2486 2487 if (this.PARAMS.icon) 2488 { 2489 BX.addClass(this.PARTS.HEAD, this.PARAMS.icon); 2490 2491 var icon_file = (BX.style(this.PARTS.HEAD, 'background-image') || BX.style(this.PARTS.HEAD, 'backgroundImage')); 2492 if (BX.type.isNotEmptyString(icon_file) && icon_file != 'none') 2493 { 2494 var match = icon_file.match(new RegExp('url\\s*\\(\\s*(\'|"|)(.+?)(\\1)\\s*\\)')); 2495 if(match) 2496 { 2497 icon_file = match[2]; 2498 if (BX.type.isNotEmptyString(icon_file)) 2499 { 2500 this.icon_image = new Image(); 2501 this.icon_image.onload = BX.delegate(this.__adjustHeadToIcon, this); 2502 this.icon_image.src = icon_file; 2503 } 2504 } 2505 } 2506 } 2507 } 2508 this.adjustSize(); 2509}; 2510 2511BX.CDialog.prototype.SetIconFile = function(icon_file) 2512{ 2513 this.icon_image = new Image(); 2514 this.icon_image.onload = BX.delegate(this.__adjustHeadToIcon, this); 2515 this.icon_image.src = icon_file; 2516 2517 BX.adjust(this.PARTS.HEAD, {style: {backgroundImage: 'url(' + icon_file + ')', backgroundPosition: 'right 9px'/*'99% center'*/}}); 2518 this.adjustSize(); 2519}; 2520 2521/* 2522BUTTON: { 2523 title: 'title',
2524 'action': function executed in window object context 2525} 2526BX.CDialog.btnSave || BX.CDialog.btnCancel - standard buttons 2527*/ 2528 2529BX.CDialog.prototype.SetButtons = function(a) 2530{ 2531 if (BX.type.isString(a)) 2532 { 2533 if (a.length > 0) 2534 { 2535 this.PARTS.BUTTONS_CONTAINER.innerHTML += a; 2536 2537 var btns = this.PARTS.BUTTONS_CONTAINER.getElementsByTagName('INPUT'); 2538 if (btns.length > 0) 2539 { 2540 this.PARAMS.buttons = []; 2541 for (var i = 0; i < btns.length; i++) 2542 { 2543 this.PARAMS.buttons.push(new BX.CWindowButton({btn: btns[i], parentWindow: this})); 2544 } 2545 } 2546 } 2547 } 2548 else 2549 { 2550 this.PARAMS.buttons = a; 2551 BX.adjust(this.PARTS.BUTTONS_CONTAINER, { 2552 children: this.ShowButtons() 2553 }); 2554 } 2555 this.adjustSize(); 2556}; 2557 2558BX.CDialog.prototype.ClearButtons = function() 2559{ 2560 BX.cleanNode(this.PARTS.BUTTONS_CONTAINER); 2561 this.adjustSize(); 2562}; 2563 2564BX.CDialog.prototype.SetContent = function(html) 2565{ 2566 this.__form = null; 2567 2568 if (BX.type.isElementNode(html)) 2569 { 2570 if (html.parentNode) 2571 html.parentNode.removeChild(html); 2572 } 2573 else if (BX.type.isString(html)) 2574 { 2575 html = BX.create('DIV', {html: html}); 2576 } 2577 2578 this.PARAMS.content = html; 2579 BX.cleanNode(this.PARTS.CONTENT_DATA); 2580 2581 BX.adjust(this.PARTS.CONTENT_DATA, { 2582 children: [ 2583 this.PARTS.HEAD, 2584 BX.create('DIV', { 2585 props: { 2586 className: 'bx-core-adm-dialog-content-wrap-inner' 2587 }, 2588 children: [this.PARAMS.content] 2589 }) 2590 ] 2591 }); 2592 2593 if (this.PARAMS.content_url && this.GetForm()) 2594 { 2595 this.__form.submitbtn = this.__form.appendChild(BX.create('INPUT', {props:{type:'submit'},style:{display:'none'}})); 2596 this.__form.onsubmit = BX.delegate(this.__submit, this); 2597 } 2598}; 2599 2600BX.CDialog.prototype.__submit = function(e) 2601{ 2602 for (var i=0,len=this.PARAMS.buttons.length; i<len; i++) 2603 { 2604 if ( 2605 this.PARAMS.buttons[i] 2606 && ( 2607 this.PARAMS.buttons[i].name && /save|apply/i.test(this.PARAMS.buttons[i].name) 2608 || 2609 this.PARAMS.buttons[i].btn && this.PARAMS.buttons[i].btn.name && /save|apply/i.test(this.PARAMS.buttons[i].btn.name) 2610 ) 2611 ) 2612 { 2613 this.PARAMS.buttons[i].emulate(); 2614 break; 2615 } 2616 } 2617 2618 return BX.PreventDefault(e); 2619}; 2620 2621BX.CDialog.prototype.SwapContent = function(cont) 2622{ 2623 cont = BX(cont); 2624 2625 BX.cleanNode(this.PARTS.CONTENT_DATA); 2626 cont.parentNode.removeChild(cont); 2627 this.PARTS.CONTENT_DATA.appendChild(cont); 2628 cont.style.display = 'block'; 2629 this.SetContent(cont.innerHTML); 2630}; 2631 2632// this method deprecated 2633BX.CDialog.prototype.adjustSize = function() 2634{ 2635}; 2636 2637// this method deprecated 2638BX.CDialog.prototype.__adjustSize = function() 2639{ 2640}; 2641 2642BX.CDialog.prototype.adjustSizeEx = function() 2643{ 2644 BX.defer(this.__adjustSizeEx, this)(); 2645}; 2646 2647BX.CDialog.prototype.__adjustSizeEx = function() 2648{ 2649 var ob = this.PARTS.CONTENT_DATA.firstChild, 2650 new_height = 0, 2651 marginTop, 2652 marginBottom; 2653 2654 while (ob) 2655 { 2656 if (BX.type.isElementNode(ob)) 2657 { 2658 marginTop = parseInt(BX.style(ob, 'margin-top'), 10); 2659 if (isNaN(marginTop)) 2660 marginTop = 0; 2661 marginBottom = parseInt(BX.style(ob, 'margin-bottom'), 10); 2662 if (isNaN(marginBottom)) 2663 marginBottom = 0; 2664 new_height += ob.offsetHeight + marginTop + marginBottom; 2665 } 2666 ob = BX.nextSibling(ob); 2667 } 2668 2669 if (new_height) 2670 this.PARTS.CONTENT_DATA.style.height = new_height + 'px'; 2671}; 2672 2673 2674BX.CDialog.prototype.__onResizeFinished = function() 2675{ 2676 BX.WindowManager.saveWindowSize( 2677 this.PARAMS.resize_id || this.PARAMS.content_url, {height: parseInt(this.PARTS.CONTENT_DATA.style.height), width: parseInt(this.PARTS.CONTENT_DATA.style.width)} 2678 ); 2679}; 2680 2681BX.CDialog.prototype.Show = function(bNotRegister) 2682{ 2683 if ((!this.PARAMS.content) && this.PARAMS.content_url && BX.ajax && !bNotRegister) 2684 { 2685 var wait = BX.showWait(); 2686 2687 BX.WindowManager.currently_loaded = this; 2688 2689 this.CreateOverlay(); 2690 this.OVERLAY.style.display = 'block'; 2691 this.OVERLAY.className = 'bx-core-dialog-overlay'; 2692 2693 var post_data = '', method = 'GET'; 2694 if (this.PARAMS.content_post) 2695 { 2696 post_data = this.PARAMS.content_post; 2697 method = 'POST'; 2698 } 2699 2700 var url = this.PARAMS.content_url 2701 + (this.PARAMS.content_url.indexOf('?')<0?'?':'&')+'bxsender=' + this._sender; 2702 2703 this.auth_callback = BX.delegate(function(){ 2704 this.PARAMS.content = ''; 2705 this.hideNotify(); 2706 this.Show(); 2707 }, this); 2708 2709 BX.ajax({ 2710 method: method, 2711 dataType: 'html', 2712 url: url, 2713 data: post_data, 2714 skipAuthCheck: true, 2715 onsuccess: BX.delegate(function(data) { 2716 BX.closeWait(null, wait); 2717 2718 this.SetContent(data || ' '); 2719 this.Show(); 2720 }, this) 2721 }); 2722 } 2723 else 2724 { 2725 BX.WindowManager.currently_loaded = null; 2726 BX.CDialog.superclass.Show.apply(this, arguments); 2727 2728 this.adjustPos(); 2729 2730 this.OVERLAY.className = 'bx-core-dialog-overlay'; 2731 2732 this.__adjustSize(); 2733 2734 BX.removeCustomEvent(this, 'onWindowResize', BX.proxy(this.__adjustSize, this)); 2735 BX.addCustomEvent(this, 'onWindowResize', BX.proxy(this.__adjustSize, this)); 2736 2737 if (this.PARAMS.resizable && (this.PARAMS.content_url || this.PARAMS.resize_id)) 2738 { 2739 BX.removeCustomEvent(this, 'onWindowResizeFinished', BX.proxy(this.__onResizeFinished, this)); 2740 BX.addCustomEvent(this, 'onWindowResizeFinished', BX.proxy(this.__onResizeFinished, this)); 2741 } 2742 } 2743}; 2744 2745BX.CDialog.prototype.GetInnerPos = function() 2746{ 2747 return {'width': parseInt(this.PARTS.CONTENT_DATA.style.width), 'height': parseInt(this.PARTS.CONTENT_DATA.style.height)}; 2748}; 2749 2750BX.CDialog.prototype.adjustPos = function() 2751{ 2752 if (!this.bExpanded) 2753 { 2754 var currentWindow = window; 2755 var topWindow = BX.PageObject.getRootWindow(); 2756 if (topWindow.BX.SidePanel && topWindow.BX.SidePanel.Instance && topWindow.BX.SidePanel.Instance.getTopSlider()) 2757 { 2758 currentWindow = topWindow.BX.SidePanel.Instance.getTopSlider().getWindow(); 2759 } 2760 var windowSize = currentWindow.BX.GetWindowInnerSize(); 2761 var windowScroll = currentWindow.BX.GetWindowScrollPos(); 2762 2763 var style = { 2764 left: parseInt(windowScroll.scrollLeft + windowSize.innerWidth / 2 - parseInt(this.DIV.offsetWidth) / 2) + 'px', 2765 top: Math.max(parseInt(windowScroll.scrollTop + windowSize.innerHe
2765ight / 2 - parseInt(this.DIV.offsetHeight) / 2), 0) + 'px' 2766 }; 2767 2768 BX.adjust(this.DIV, { 2769 style: style 2770 }); 2771 } 2772}; 2773 2774BX.CDialog.prototype.GetContent = function () {return this.PARTS.CONTENT_DATA}; 2775 2776BX.CDialog.prototype.btnSave = BX.CDialog.btnSave = { 2777 title: BX.message('JS_CORE_WINDOW_SAVE'), 2778 id: 'savebtn', 2779 name: 'savebtn', 2780 className: BX.browser.IsIE() && BX.browser.IsDoctype() && !BX.browser.IsIE10() ? '' : 'adm-btn-save', 2781 action: function () { 2782 this.disableUntilError(); 2783 this.parentWindow.PostParameters(); 2784 } 2785}; 2786 2787BX.CDialog.prototype.btnCancel = BX.CDialog.btnCancel = { 2788 title: BX.message('JS_CORE_WINDOW_CANCEL'), 2789 id: 'cancel', 2790 name: 'cancel', 2791 action: function () { 2792 this.parentWindow.Close(); 2793 } 2794}; 2795 2796BX.CDialog.prototype.btnClose = BX.CDialog.btnClose = { 2797 title: BX.message('JS_CORE_WINDOW_CLOSE'), 2798 id: 'close', 2799 name: 'close', 2800 action: function () { 2801 this.parentWindow.Close(); 2802 } 2803}; 2804 2805/* special child for admin forms loaded into public page */ 2806BX.CAdminDialog = function(arParams) 2807{ 2808 BX.CAdminDialog.superclass.constructor.apply(this, arguments); 2809 2810 this._sender = 'core_window_cadmindialog'; 2811 2812 BX.addClass(this.DIV, 'bx-core-adm-admin-dialog'); 2813 2814 this.PARTS.CONTENT.insertBefore(this.PARTS.HEAD, this.PARTS.CONTENT.firstChild); 2815 this.PARTS.HEAD.className = 'bx-core-adm-dialog-tabs'; 2816}; 2817BX.extend(BX.CAdminDialog, BX.CDialog); 2818 2819BX.CAdminDialog.prototype.SetHead = function() 2820{ 2821 BX.CAdminDialog.superclass.SetHead.apply(this, arguments); 2822 2823 if (this.PARTS.HEAD.firstChild && BX.type.isElementNode(this.PARTS.HEAD.firstChild)) 2824 { 2825 var ob = this.PARTS.HEAD.firstChild, new_width = 0, marginLeft = 0, marginRight = 0; 2826 2827 while (ob) 2828 { 2829 if (BX.type.isElementNode(ob)) 2830 { 2831 marginLeft = parseInt(BX.style(ob, 'margin-left'), 10); 2832 if (isNaN(marginLeft)) 2833 marginLeft = 0; 2834 marginRight = parseInt(BX.style(ob, 'margin-right'), 10); 2835 if (isNaN(marginRight)) 2836 marginRight = 0; 2837 new_width += ob.offsetWidth + marginLeft + marginRight; 2838 } 2839 ob = BX.nextSibling(ob); 2840 } 2841 2842 this.SETTINGS.min_width = Math.max(new_width, this.SETTINGS.min_width) - 2; 2843 if (this.PARAMS.width < this.SETTINGS.min_width) 2844 { 2845 BX.adjust(this.PARTS.CONTENT_DATA, { 2846 style: { 2847 width: this.SETTINGS.min_width + 'px' 2848 } 2849 }); 2850 } 2851 } 2852}; 2853 2854BX.CAdminDialog.prototype.SetContent = function(html) 2855{ 2856 this.__form = null; 2857 2858 if (BX.type.isElementNode(html)) 2859 { 2860 if (html.parentNode) 2861 html.parentNode.removeChild(html); 2862 } 2863 2864 this.PARAMS.content = html; 2865 BX.cleanNode(this.PARTS.CONTENT_DATA); 2866 2867 BX.adjust(this.PARTS.CONTENT_DATA, { 2868 children: [ 2869 this.PARAMS.content || ' ' 2870 ] 2871 }); 2872 2873 if (this.PARAMS.content_url && this.GetForm()) 2874 { 2875 this.__form.appendChild(BX.create('INPUT', {props:{type:'submit'},style:{display:'none'}})); 2876 this.__form.onsubmit = BX.delegate(this.__submit, this); 2877 } 2878}; 2879 2880BX.CAdminDialog.prototype.__expandGetSize = function() 2881{ 2882 var res = BX.CAdminDialog.superclass.__expandGetSize.apply(this, arguments); 2883 2884 res.width -= parseInt(BX.style(this.PARTS.CONTENT_DATA, 'padding-right')) + parseInt(BX.style(this.PARTS.CONTENT_DATA, 'padding-left')); 2885 res.height -= parseInt(BX.style(this.PARTS.CONTENT_DATA, 'padding-top')) + parseInt(BX.style(this.PARTS.CONTENT_DATA, 'padding-bottom')); 2886 2887 res.height -= this.PARTS.HEAD.offsetHeight; 2888 2889 return res; 2890}; 2891 2892BX.CAdminDialog.prototype.Submit = function() 2893{ 2894 var FORM = this.GetForm(); 2895 if (FORM && !FORM['bxpublic'] && !/bxpublic=/.test(FORM.action)) 2896 { 2897 FORM.appendChild(BX.create('INPUT', { 2898 props: { 2899 type: 'hidden', 2900 name: 'bxpublic', 2901 value: 'Y' 2902 } 2903 })); 2904 } 2905 2906 return BX.CAdminDialog.superclass.Submit.apply(this, arguments); 2907}; 2908 2909BX.CAdminDialog.prototype.btnSave = BX.CAdminDialog.btnSave = { 2910 title: BX.message('JS_CORE_WINDOW_SAVE'), 2911 id: 'savebtn', 2912 name: 'savebtn', 2913 className: 'adm-btn-save', 2914 action: function () { 2915 this.disableUntilError(); 2916 this.parentWindow.Submit(); 2917 } 2918}; 2919 2920BX.CAdminDialog.btnCancel = BX.CAdminDialog.superclass.btnCancel; 2921BX.CAdminDialog.btnClose = BX.CAdminDialog.superclass.btnClose; 2922 2923BX.CDebugDialog = function(arParams) 2924{ 2925 BX.CDebugDialog.superclass.constructor.apply(this, arguments); 2926}; 2927BX.extend(BX.CDebugDialog, BX.CDialog); 2928
2929BX.CDebugDialog.prototype.ShowDetails = function(div_id) 2930{ 2931 var div = BX(div_id); 2932 if (div) 2933 { 2934 if (this.div_detail_current) 2935 this.div_detail_current.style.display = 'none'; 2936 2937 div.style.display = 'block'; 2938 this.div_detail_current = div; 2939 } 2940}; 2941 2942BX.CDebugDialog.prototype.SetContent = function(html) 2943{ 2944 if (!html) 2945 return; 2946 2947 var arHtml = html.split('#DIVIDER#'); 2948 if (arHtml.length > 1) 2949 { 2950 this.PARAMS.content = arHtml[1]; 2951 2952 this.PARTS.CONTENT_DATA.style.overflow = 'hidden'; 2953 2954 BX.CDebugDialog.superclass.SetContent.apply(this, [arHtml[1]]); 2955 2956 this.PARTS.CONTENT_INNER = this.PARTS.CONTENT_DATA.firstChild.nextSibling; 2957 this.PARTS.CONTENT_TOP = this.PARTS.CONTENT_DATA.insertBefore(BX.create('DIV', { 2958 props: { 2959 className: 'bx-debug-content-top' 2960 }, 2961 html: arHtml[0] 2962 }), this.PARTS.CONTENT_INNER); 2963 this.PARTS.CONTENT_INNER.style.overflow = 'auto'; 2964 } 2965 else 2966 { 2967 BX.CDebugDialog.superclass.SetContent.apply(this, arguments); 2968 } 2969}; 2970 2971BX.CDebugDialog.prototype.__adjustSize = function() 2972{ 2973 BX.CDebugDialog.superclass.__adjustSize.apply(this, arguments); 2974 2975 if (this.PARTS.CONTENT_TOP) 2976 { 2977 var new_height = this.PARTS.CONTENT_DATA.offsetHeight - this.PARTS.HEAD.offsetHeight - this.PARTS.CONTENT_TOP.offsetHeight - 38; 2978 2979 if (new_height > 0) 2980 { 2981 this.PARTS.CONTENT_INNER.style.height = new_height + 'px'; 2982 } 2983 } 2984}; 2985 2986 2987/* class for dialog window with editors */ 2988 2989BX.CEditorDialog = function(arParams) 2990{ 2991 BX.CEditorDialog.superclass.constructor.apply(this, arguments); 2992 2993 BX.removeClass(this.PARTS.CONTENT, 'bx-core-adm-dialog-content-wrap'); 2994 BX.removeClass(this.PARTS.CONTENT_DATA, 'bx-core-adm-dialog-content'); 2995 2996 BX.removeClass(this.PARTS.CONTENT_DATA.lastChild, 'bx-core-adm-dialog-content-wrap-inner'); 2997 BX.removeClass(this.PARTS.BUTTONS_CONTAINER, 'bx-core-adm-dialog-buttons'); 2998 2999 BX.addClass(this.PARTS.CONTENT, 'bx-core-editor-dialog-content-wrap'); 3000 BX.addClass(this.PARTS.CONTENT_DATA, 'bx-core-editor-dialog-content'); 3001 BX.addClass(this.PARTS.BUTTONS_CONTAINER, 'bx-core-editor-dialog-buttons'); 3002}; 3003BX.extend(BX.CEditorDialog, BX.CDialog); 3004 3005BX.CEditorDialog.prototype.SetContent = function() 3006{ 3007 BX.CEditorDialog.superclass.SetContent.apply(this, arguments); 3008 3009 BX.removeClass(this.PARTS.CONTENT_DATA.lastChild, 'bx-core-adm-dialog-content-wrap-inner'); 3010}; 3011 3012/* class for wizards in admin section */ 3013BX.CWizardDialog = function(arParams) 3014{ 3015 BX.CWizardDialog.superclass.constructor.apply(this, arguments); 3016 3017 BX.removeClass(this.PARTS.CONTENT, 'bx-core-adm-dialog-content-wrap'); 3018 BX.removeClass(this.PARTS.CONTENT_DATA, 'bx-core-adm-dialog-content'); 3019 BX.removeClass(this.PARTS.CONTENT_DATA.lastChild, 'bx-core-adm-dialog-content-wrap-inner'); 3020 BX.removeClass(this.PARTS.BUTTONS_CONTAINER, 'bx-core-adm-dialog-buttons'); 3021 3022 BX.addClass(this.PARTS.CONTENT, 'bx-core-wizard-dialog-content-wrap'); 3023}; 3024 3025BX.extend(BX.CWizardDialog, BX.CDialog); 3026 3027/* class for auth dialog */ 3028BX.CAuthDialog = function(arParams) 3029{ 3030 arParams.resizable = false; 3031 arParams.width = 350;
3032 arParams.height = 200; 3033 3034 arParams.buttons = [this.btnSave]; 3035 3036 BX.CAuthDialog.superclass.constructor.apply(this, arguments); 3037 this._sender = 'core_window_cauthdialog'; 3038 3039 BX.addClass(this.DIV, 'bx-core-auth-dialog'); 3040 3041 BX.AUTHAGENT = this; 3042}; 3043BX.extend(BX.CAuthDialog, BX.CDialog); 3044 3045BX.CAuthDialog.prototype.btnSave = BX.CAuthDialog.btnSave = { 3046 title: BX.message('JS_CORE_WINDOW_AUTH'), 3047 id: 'savebtn', 3048 name: 'savebtn', 3049 className: 'adm-btn-save', 3050 action: function () { 3051 this.disableUntilError(); 3052 this.parentWindow.Submit('', this.parentWindow.PARAMS.content_url); 3053 } 3054}; 3055 3056BX.CAuthDialog.prototype.SetError = function(error) 3057{ 3058 BX.closeWait(); 3059 3060 if (!!error) 3061 this.ShowError(error.MESSAGE || error); 3062}; 3063 3064BX.CAuthDialog.prototype.setAuthResult = function(result) 3065{ 3066 BX.closeWait(); 3067 3068 if (result === false) 3069 { 3070 this.Close(); 3071 if (this.PARAMS.callback) 3072 this.PARAMS.callback(); 3073 } 3074 else 3075 { 3076 this.SetError(result); 3077 } 3078}; 3079 3080/* MENU CLASSES */ 3081 3082BX.CWindowFloat = function(node) 3083{ 3084 BX.CWindowFloat.superclass.constructor.apply(this, [node, 'float']); 3085 3086 this.SETTINGS.resizable = false; 3087}; 3088BX.extend(BX.CWindowFloat, BX.CWindow); 3089 3090BX.CWindowFloat.prototype.adjustPos = function() 3091{ 3092 if (this.PARAMS.parent) 3093 this.adjustToNode(); 3094 else if (this.PARAMS.x && this.PARAMS.y) 3095 this.adjustToPos([this.PARAMS.x, this.PARAMS.y]); 3096}; 3097 3098BX.CWindowFloat.prototype.adjustToPos = function(pos) 3099{ 3100 this.DIV.style.left = parseInt(pos[0]) + 'px'; 3101 this.DIV.style.top = parseInt(pos[1]) + 'px'; 3102}; 3103 3104BX.CWindowFloat.prototype.adjustToNodeGetPos = function() 3105{ 3106 return BX.pos(this.PARAMS.parent); 3107}; 3108 3109BX.CWindowFloat.prototype.adjustToNode = function(el) 3110{ 3111 el = el || this.PARAMS.parent; 3112 3113 this.PARAMS.parent = BX(el); 3114 3115 if (this.PARAMS.parent) 3116 { 3117 var pos = this.adjustToNodeGetPos(); 3118 3119 this.DIV.style.top = pos.top + 'px';//(pos.top - 26) + 'px'; 3120 this.DIV.style.left = pos.left + 'px'; 3121 3122 this.PARAMS.parent.OPENER = this; 3123 } 3124}; 3125 3126BX.CWindowFloat.prototype.Show = function() 3127{ 3128 this.adjustToPos([-1000, -1000]); 3129 BX.CWindowFloat.superclass.Show.apply(this, arguments); 3130 this.adjustPos(); 3131}; 3132 3133/* menu opener class */ 3134/* 3135{ 3136 DOMNode DIV, 3137 BX.CMenu or Array MENU, 3138 TYPE = 'hover' | 'click', 3139 TIMEOUT: 1000 3140 ATTACH_MODE: 'top' | 'right' 3141 ACTIVE_CLASS: className for opener element when menu is opened 3142} 3143*/ 3144BX.COpener = function(arParams) 3145{ 3146 this.PARAMS = arParams || {}; 3147 3148 this.MENU = arParams.MENU || []; 3149 3150 this.DIV = arParams.DIV; 3151 this.ATTACH = arParams.ATTACH || arParams.DIV; 3152 this.ATTACH_MODE = arParams.ATTACH_MODE || 'bottom'; 3153 3154 this.ACTIVE_CLASS = arParams.ACTIVE_CLASS || ''; 3155 this.PUBLIC_FRAME = arParams.PUBLIC_FRAME || 0; 3156 this.LEVEL = arParams.LEVEL || 0; 3157 3158 this.CLOSE_ON_CLICK = typeof arParams.CLOSE_ON_CLICK != 'undefined' ? !!arParams.CLOSE_ON_CLICK : true; 3159 this.ADJUST_ON_CLICK = typeof arParams.ADJUST_ON_CLICK != 'undefined' ? !!arParams.ADJUST_ON_CLICK : true; 3160 3161 this.TYPE = this.PARAMS.TYPE == 'hover' ? 'hover' : 'click'; 3162 3163 this._openTimeout = null; 3164 3165 if (this.PARAMS.TYPE == 'hover' && arParams.TIMEOUT !== 0)
3166 this.TIMEOUT = arParams.TIMEOUT || 1000; 3167 else 3168 this.TIMEOUT = 0; 3169 3170 this.bMenuInit = false; 3171 3172 if (!!this.PARAMS.MENU_URL) 3173 { 3174 this.bMenuLoaded = false; 3175 this.bMenuLoading = false; 3176 3177 this.MENU = [{ 3178 TEXT: BX.message('JS_CORE_LOADING'), 3179 CLOSE_ON_CLICK: false 3180 }]; 3181 3182 if (this.PARAMS.MENU_PRELOAD) 3183 { 3184 BX.defer(this.Load, this)(); 3185 } 3186 } 3187 3188 BX.ready(BX.defer(this.Init, this)); 3189}; 3190 3191BX.COpener.prototype.Init = function() 3192{ 3193 this.DIV = BX(this.DIV); 3194 3195 switch (this.TYPE) 3196 { 3197 case 'hover': 3198 BX.bind(this.DIV, 'mouseover', BX.proxy(this.Open, this)); 3199 BX.bind(this.DIV, 'click', BX.proxy(this.Toggle, this)); 3200 break; 3201 3202 case 'click': 3203 BX.bind(this.DIV, 'click', BX.proxy(this.Toggle, this)); 3204 break; 3205 } 3206 3207 //BX.bind(window, 'scroll', BX.delegate(this.__close_immediately, this)); 3208 3209 //this.bMenuInit = false; 3210}; 3211 3212BX.COpener.prototype.Load = function() 3213{ 3214 if (this.PARAMS.MENU_URL && !this.bMenuLoaded) 3215 { 3216 if (!this.bMenuLoading) 3217 { 3218 var url = this.PARAMS.MENU_URL; 3219 if (url.indexOf('sessid=') <= 0) 3220 url += (url.indexOf('?') > 0 ? '&' : '?') + 'sessid=' + BX.bitrix_sessid(); 3221 3222 this.bMenuLoading = true; 3223 BX.ajax.loadJSON(url, BX.proxy(this.SetMenu, this), BX.proxy(this.LoadFailed, this)); 3224 } 3225 } 3226}; 3227 3228BX.COpener.prototype.SetMenu = function(menu) 3229{ 3230 this.bMenuLoaded = true; 3231 this.bMenuLoading = false; 3232 if (this.bMenuInit) 3233 { 3234 this.MENU.setItems(menu); 3235 } 3236 else 3237 { 3238 this.MENU = menu; 3239 } 3240}; 3241 3242BX.COpener.prototype.LoadFailed = function(type, error) 3243{ 3244 this.bMenuLoading = false; 3245 this.SetMenu([{ 3246 TEXT: BX.message('JS_CORE_NO_DATA'), 3247 CLOSE_ON_CLICK: true 3248 }]); 3249 BX.debug(arguments); 3250}; 3251 3252BX.COpener.prototype.checkAdminMenu = function() 3253{ 3254 if (document.documentElement.id == 'bx-admin-prefix') 3255 return true; 3256 3257 return !!BX.findParent(this.DIV, {property: {id: 'bx-admin-prefix'}}); 3258}; 3259 3260BX.COpener.prototype.Toggle = function(e) 3261{ 3262 this.__clear_timeout(); 3263 3264 if (!this.bMenuInit || !this.MENU.visible()) 3265 { 3266 var t = this.TIMEOUT; 3267 this.TIMEOUT = 0; 3268 this.Open(e); 3269 this.TIMEOUT = t; 3270 } 3271 else 3272 { 3273 this.MENU.Close(); 3274 } 3275 3276 return !!(e||window.event) && BX.PreventDefault(e); 3277}; 3278 3279BX.COpener.prototype.GetMenu = function() 3280{ 3281 if (!this.bMenuInit) 3282 { 3283 if (BX.type.isArray(this.MENU)) 3284 { 3285 this.MENU = new BX.CMenu({ 3286 ITEMS: this.MENU, 3287 ATTACH_MODE: this.ATTACH_MODE, 3288 SET_ID: this.checkAdminMenu() ? 'bx-admin-prefix' : '', 3289 CLOSE_ON_CLICK: !!this.CLOSE_ON_CLICK, 3290 ADJUST_ON_CLICK: !!this.ADJUST_ON_CLICK, 3291 PUBLIC_FRAME: !!this.PUBLIC_FRAME, 3292 LEVEL: this.LEVEL, 3293 parent: BX(this.DIV), 3294 parent_attach: BX(this.ATTACH) 3295 }); 3296 3297 if (this.LEVEL > 0) 3298 { 3299 BX.bind(this.MENU.DIV, 'mouseover', BX.proxy(this._on_menu_hover, this)); 3300 BX.bind(this.MENU.DIV, 'mouseout', BX.proxy(this._on_menu_hout, this)); 3301 } 3302 } 3303 3304 BX.addCustomEvent(this.MENU, 'onMenuOpen', BX.proxy(this.handler_onopen, this)); 3305 BX.addCustomEvent(this.MENU, 'onMenuClose', BX.proxy(this.handler_onclose, this)); 3306 3307 BX.addCustomEvent('onMenuItemHover', BX.proxy(this.handler_onover, this)); 3308 3309 this.bMenuInit = true; 3310 } 3311 3312 return this.MENU; 3313}; 3314 3315BX.COpener.prototype.Open = function() 3316{ 3317 this.GetMenu(); 3318 3319 this.bOpen = true; 3320 3321 this.__clear_timeout(); 3322 3323 if (this.TIMEOUT > 0) 3324 { 3325 BX.bind(this.DIV, 'mouseout', BX.proxy(this.__clear_timeout, this)); 3326 this._openTimeout = setTimeout(BX.proxy(this.__open, this), this.TIMEOUT); 3327 } 3328 else 3329 { 3330 this.__open(); 3331 } 3332 3333 if (!!this.PARAMS.MENU_URL && !this.bMenuLoaded) 3334 { 3335 this._loadTimeout = setTimeout(BX.proxy(this.Load, this), parseInt(this.TIMEOUT/2)); 3336 } 3337 3338 return true; 3339}; 3340 3341BX.COpener.prototype.__clear_timeout = function() 3342{ 3343 if (!!this._openTimeout) 3344 clearTimeout(this._openTimeout); 3345 if (!!this._loadTimeout) 3346 clearTimeout(this._loadTimeout); 3347 3348 BX.unbind(this.DIV, 'mouseout', BX.proxy(this.__clear_timeout, this)); 3349}; 3350 3351BX.COpener.prototype._on_menu_hover = function() 3352{ 3353 this.bMenuHover = true; 3354 3355 this.__clear_timeout(); 3356 3357 if (this.ACTIVE_CLASS) 3358 BX.addClass(this.DIV, this.ACTIVE_CLASS); 3359 3360}; 3361 3362BX.COpener.prototype._on_menu_hout = function() 3363{ 3364 this.bMenuHover = false; 3365}; 3366 3367BX.COpener.prototype.handler_onover = function(level, opener) 3368{ 3369 if (this.bMenuHover) 3370 return; 3371 3372 if (opener != this && level == this.LEVEL-1 && this.ACTIVE_CLASS) 3373 { 3374 BX.removeClass(this.DIV, this.ACTIVE_CLASS); 3375 } 3376 3377 if (this.bMenuInit && level <= this.LEVEL-1 && this.MENU.visible()) 3378 { 3379 if (opener != this) 3380 { 3381 this.__clear_timeout(); 3382 this._openTimeout = setTimeout(BX.proxy(this.Close, this), this.TIMEOUT); 3383 } 3384 } 3385}; 3386 3387BX.COpener.prototype.handler_onopen = function() 3388{ 3389 this.bOpen = true; 3390 3391 if (this.ACTIVE_CLASS) 3392 BX.addClass(this.DIV, this.ACTIVE_CLASS); 3393 3394 BX.defer(function() { 3395 BX.onCustomEvent(this, 'onOpenerMenuOpen'); 3396 }, this)(); 3397}; 3398 3399BX.COpener.prototype.handler_onclose = function() 3400{ 3401 this.bOpen = false;
3402 BX.onCustomEvent(this, 'onOpenerMenuClose'); 3403 3404 if (this.ACTIVE_CLASS) 3405 BX.removeClass(this.DIV, this.ACTIVE_CLASS); 3406}; 3407 3408BX.COpener.prototype.Close = function() 3409{ 3410 if (!this.bMenuInit) 3411 return; 3412 3413 if (!!this._openTimeout) 3414 clearTimeout(this._openTimeout); 3415 3416 this.bOpen = false; 3417 3418 this.__close(); 3419}; 3420 3421BX.COpener.prototype.__open = function() 3422{ 3423 this.__clear_timeout(); 3424 3425 if (this.bMenuInit && this.bOpen && !this.MENU.visible()) 3426 this.MENU.Show(); 3427}; 3428 3429BX.COpener.prototype.__close = function() 3430{ 3431 if (this.bMenuInit && !this.bOpen && this.MENU.visible()) 3432 this.MENU.Hide(); 3433}; 3434 3435BX.COpener.prototype.__close_immediately = function() { 3436 this.bOpen = false; this.__close(); 3437}; 3438 3439BX.COpener.prototype.isMenuVisible = function() { 3440 return null != this.MENU.visible && this.MENU.visible() 3441}; 3442 3443/* common menu class */ 3444 3445BX.CMenu = function(arParams) 3446{ 3447 BX.CMenu.superclass.constructor.apply(this); 3448 3449 this.DIV.style.width = 'auto';//this.DIV.firstChild.offsetWidth + 'px'; 3450 this.DIV.style.height = 'auto';//this.DIV.firstChild.offsetHeight + 'px'; 3451 3452 this.PARAMS = arParams || {}; 3453 this.PARTS = {}; 3454 3455 this.PARAMS.ATTACH_MODE = this.PARAMS.ATTACH_MODE || 'bottom'; 3456 this.PARAMS.CLOSE_ON_CLICK = typeof this.PARAMS.CLOSE_ON_CLICK == 'undefined' ? true : this.PARAMS.CLOSE_ON_CLICK; 3457 this.PARAMS.ADJUST_ON_CLICK = typeof this.PARAMS.ADJUST_ON_CLICK == 'undefined' ? true : this.PARAMS.ADJUST_ON_CLICK; 3458 this.PARAMS.PUBLIC_FRAME = typeof this.PARAMS.PUBLIC_FRAME == 'undefined' ? false : this.PARAMS.PUBLIC_FRAME; 3459 this.PARAMS.LEVEL = this.PARAMS.LEVEL || 0; 3460 3461 this.DIV.className = 'bx-core-popup-menu bx-core-popup-menu-' + this.PARAMS.ATTACH_MODE + ' bx-core-popup-menu-level' + this.PARAMS.LEVEL + (typeof this.PARAMS.ADDITIONAL_CLASS != 'undefined' ? ' ' + this.PARAMS.ADDITIONAL_CLASS : ''); 3462 if (!!this.PARAMS.SET_ID) 3463 this.DIV.id = this.PARAMS.SET_ID; 3464 3465 if (this.PARAMS.LEVEL == 0) 3466 { 3467 this.ARROW = this.DIV.appendChild(BX.create('SPAN', {props: {className: 'bx-core-popup-menu-angle'}, style: {left:'15px'}})); 3468 } 3469 3470 if (!!this.PARAMS.CLASS_NAME) 3471 this.DIV.className += ' ' + this.PARAMS.CLASS_NAME; 3472 3473 BX.bind(this.DIV, 'click', BX.eventCancelBubble); 3474 3475 this.ITEMS = []; 3476 3477 this.setItems(this.PARAMS.ITEMS); 3478 3479 BX.addCustomEvent('onMenuOpen', BX.proxy(this._onMenuOpen, this)); 3480 BX.addCustomEvent('onMenuItemSelected', BX.proxy(this.Hide, this)); 3481}; 3482BX.extend(BX.CMenu, BX.CWindowFloat); 3483 3484BX.CMenu.broadcastCloseEvent = function() 3485{ 3486 BX.onCustomEvent("onMenuItemSelected"); 3487}; 3488 3489BX.CMenu._toggleChecked = function() 3490{ 3491 BX.toggleClass(this, 'bx-core-popup-menu-item-checked'); 3492}; 3493 3494BX.CMenu._itemDblClick = function() 3495{ 3496 window.location.href = this.href; 3497}; 3498 3499BX.CMenu.prototype.toggleArrow = function(v) 3500{ 3501 if (!!this.ARROW) 3502 { 3503 if (typeof v == 'undefined') 3504 { 3505 v = this.ARROW.style.visibility == 'hidden'; 3506 } 3507 3508 this.ARROW.style.visibility = !!v ? 'visible' : 'hidden'; 3509 } 3510}; 3511 3512BX.CMenu.prototype.visible = function() 3513{ 3514 return this.DIV.style.display !== 'none'; 3515}; 3516 3517BX.CMenu.prototype._onMenuOpen = function(menu, menu_level) 3518{ 3519 if (this.visible()) 3520 { 3521 if (menu_level == this.PARAMS.LEVEL && menu != this) 3522 { 3523 this.Hide(); 3524 } 3525 } 3526}; 3527 3528BX.CMenu.prototype.onUnRegister = function() 3529{ 3530 if (!this.visible()) 3531 return; 3532 3533 this.Hide(); 3534}; 3535 3536BX.CMenu.prototype.setItems = function(items) 3537{ 3538 this.PARAMS.ITEMS = items; 3539 3540 BX.cleanNode(this.DIV); 3541 3542 if (!!this.ARROW) 3543 this.DIV.appendChild(this.ARROW); 3544 3545 if (this.PARAMS.ITEMS) 3546 { 3547 this.PARAMS.ITEMS = BX.util.array_values(this.PARAMS.ITEMS); 3548 3549 var bIcons = false; 3550 var cnt = 0; 3551 for (var i = 0, len = this.PARAMS.ITEMS.length; i < len; i++) 3552 { 3553 if ((i == 0 || i == len-1) && this.PARAMS.ITEMS[i].SEPARATOR) 3554 continue; 3555 3556 cnt++; 3557 3558 if (!bIcons) 3559 bIcons = !!this.PARAMS.ITEMS[i].GLOBAL_ICON; 3560 3561 this.addItem(this.PARAMS.ITEMS[i], i); 3562 } 3563 3564 // Occam turning in his grave 3565 if (cnt === 1) 3566 BX.addClass(this.DIV, 'bx-core-popup-menu-single-item'); 3567 else 3568 BX.removeClass(this.DIV, 'bx-core-popup-menu-single-item'); 3569 3570 if (!bIcons) 3571 BX.addClass(this.DIV, 'bx-core-popup-menu-no-icons'); 3572 else 3573 BX.removeClass(this.DIV, 'bx-core-popup-menu-no-icons'); 3574 3575 } 3576}; 3577 3578BX.CMenu.prototype.addItem = function(item) 3579{ 3580 this.ITEMS.push(item); 3581 3582 if (item.SEPARATOR) 3583 { 3584 item.NODE = BX.create( 3585 'DIV', {props: {className: 'bx-core-popup-menu-separator'}} 3586 ); 3587 } 3588 else 3589 { 3590 var bHasMenu = (!!item.MENU 3591 && (
3592 (BX.type.isArray(item.MENU) && item.MENU.length > 0) 3593 || item.MENU instanceof BX.CMenu 3594 ) || !!item.MENU_URL 3595 ); 3596 3597 if (item.DISABLED) 3598 { 3599 item.CLOSE_ON_CLICK = false; 3600 item.LINK = null; 3601 item.ONCLICK = null; 3602 item.ACTION = null; 3603 } 3604 3605 var attrs = {}; 3606 if (!!item.LINK || BX.browser.IsIE() && !BX.browser.IsDoctype()) 3607 { 3608 attrs.href = item.LINK || 'javascript:void(0)'; 3609 } 3610 if (this.PARAMS.PUBLIC_FRAME) 3611 { 3612 attrs.target = '_top'; 3613 } 3614 3615 item.NODE = BX.create(!!item.LINK || BX.browser.IsIE() && !BX.browser.IsDoctype() ? 'A' : 'SPAN', { 3616 props: { 3617 className: 'bx-core-popup-menu-item' 3618 + (bHasMenu ? ' bx-core-popup-menu-item-opener' : '') 3619 + (!!item.DEFAULT ? ' bx-core-popup-menu-item-default' : '') 3620 + (!!item.DISABLED ? ' bx-core-popup-menu-item-disabled' : '') 3621 + (!!item.CHECKED ? ' bx-core-popup-menu-item-checked' : ''), 3622 title: !!BX.message['MENU_ENABLE_TOOLTIP'] || !!item.SHOW_TITLE ? item.TITLE || '' : '', 3623 BXMENULEVEL: this.PARAMS.LEVEL 3624 }, 3625 attrs: attrs, 3626 events: { 3627 mouseover: function() 3628 { 3629 BX.onCustomEvent('onMenuItemHover', [this.BXMENULEVEL, this.OPENER]) 3630 } 3631 }, 3632 html: '<span class="bx-core-popup-menu-item-icon' + (item.GLOBAL_ICON ? ' '+item.GLOBAL_ICON : '') + '"></span><span class="bx-core-popup-menu-item-text">'+(item.HTML||(item.TEXT? BX.util.htmlspecialchars(item.TEXT) : ''))+'</span>' 3633 }); 3634 3635 if (bHasMenu && !item.DISABLED) 3636 { 3637 item.NODE.OPENER = new BX.COpener({ 3638 DIV: item.NODE, 3639 ACTIVE_CLASS: 'bx-core-popup-menu-item-opened', 3640 TYPE: 'hover', 3641 MENU: item.MENU, 3642 MENU_URL: item.MENU_URL, 3643 MENU_PRELOAD: !!item.MENU_PRELOAD, 3644 LEVEL: this.PARAMS.LEVEL + 1, 3645 ATTACH_MODE:'right', 3646 TIMEOUT: 500 3647 }); 3648 } 3649 else if (this.PARAMS.CLOSE_ON_CLICK && (typeof item.CLOSE_ON_CLICK == 'undefined' || !!item.CLOSE_ON_CLICK)) 3650 { 3651 BX.bind(item.NODE, 'click', BX.CMenu.broadcastCloseEvent); 3652 } 3653 else if (this.PARAMS.ADJUST_ON_CLICK && (typeof item.ADJUST_ON_CLICK == 'undefined' || !!item.ADJUST_ON_CLICK)) 3654 { 3655 BX.bind(item.NODE, 'click', BX.defer(this.adjustPos, this)); 3656 } 3657 3658 if (bHasMenu && !!item.LINK) 3659 { 3660 BX.bind(item.NODE, 'dblclick', BX.CMenu._itemDblClick); 3661 } 3662 3663 if (typeof item.CHECKED != 'undefined') 3664 { 3665 BX.bind(item.NODE, 'click', BX.CMenu._toggleChecked); 3666 } 3667 3668 item.ONCLICK = item.ACTION || item.ONCLICK; 3669 if (!!item.ONCLICK) 3670 { 3671 if (BX.type.isString(item.ONCLICK)) 3672 { 3673 item.ONCLICK = new Function("event", item.ONCLICK); 3674 } 3675 3676 BX.bind(item.NODE, 'click', item.ONCLICK); 3677 } 3678 } 3679 3680 this.DIV.appendChild(item.NODE); 3681}; 3682 3683BX.CMenu.prototype._documentClickBind = function() 3684{ 3685 this._documentClickUnBind(); 3686 BX.bind(document, 'click', BX.proxy(this._documentClick, this)); 3687}; 3688 3689BX.CMenu.prototype._documentClickUnBind = function() 3690{ 3691 BX.unbind(document, 'click', BX.proxy(this._documentClick, this)); 3692}; 3693 3694BX.CMenu.prototype._documentClick = function(e) 3695{ 3696 e = e||window.event; 3697 if(!!e && !(BX.getEventButton(e) & BX.MSLEFT)) 3698 return; 3699 3700 this.Close(); 3701}; 3702 3703BX.CMenu.prototype.Show = function() 3704{ 3705 BX.onCustomEvent(this, 'onMenuOpen', [this, this.PARAMS.LEVEL]); 3706 BX.CMenu.superclass.Show.apply(this, []); 3707 3708 this.bCloseEventFired = false; 3709 3710 BX.addCustomEvent(this.PARAMS.parent_attach, 'onChangeNodePosition', BX.proxy(this.adjustToNode, this)); 3711 3712 (BX.defer(this._documentClickBind, this))(); 3713}; 3714 3715BX.CMenu.prototype.Close = // we shouldn't 'Close' window - only hide 3716BX.CMenu.prototype.Hide = function() 3717{ 3718 if (!this.visible()) 3719 return; 3720 3721 BX.removeCustomEvent(this.PARAMS.parent_attach, 'onChangeNodePosition', BX.proxy(this.adjustToNode, this)); 3722 3723 this._documentClickUnBind(); 3724 3725 if (!this.bCloseEventFired) 3726 { 3727 BX.onCustomEvent(this, 'onMenuClose', [this, this.PARAMS.LEVEL]); 3728 this.bCloseEventFired = true; 3729 } 3730 BX.CMenu.superclass.Hide.apply(this, arguments); 3731 3732 3733// this.DIV.onclick = null; 3734 //this.PARAMS.parent.onclick = null; 3735}; 3736 3737BX.CMenu.prototype.__adjustMenuToNode = function() 3738{ 3739 var pos = BX.pos(this.PARAMS.parent_attach), 3740 bFixed = !!BX.findParent(this.PARAMS.parent_attach, BX.is_fixed); 3741 3742 if (bFixed) 3743 this.DIV.style.position = 'fixed'; 3744 else 3745 this.DIV.style.position = 'absolute'; 3746 3747 if (!pos.top) 3748 { 3749 this.DIV.style.top = '-1000px'; 3750 this.DIV.style.left = '-1000px'; 3751 } 3752 3753 if (this.bTimeoutSet) return; 3754 3755 var floatWidth = this.DIV.offsetWidth, floatHeight = this.DIV.offsetHeight; 3756 if (!floatWidth) 3757 { 3758 setTimeout(BX.delegate(function(){ 3759 this.bTimeoutSet = false; this.__adjustMenuToNode(); 3760 }, this), 100); 3761 3762 this.bTimeoutSet = true; 3763 return; 3764 } 3765 3766 var menu_pos = {}, 3767 wndSize = BX.GetWindowSize(); 3768 3769/* 3770 if (BX.browser.IsIE() && !BX.browser.IsDoctype()) 3771 { 3772 pos.top -= 4; pos.bottom -= 4; 3773 pos.left -= 2; pos.right -= 2; 3774 } 3775*/ 3776 3777 switch (this.PARAMS.ATTACH_MODE) 3778 { 3779 case 'bottom': 3780 menu_pos.top = pos.bottom + 9; 3781 menu_pos.left = pos.left; 3782 3783 var arrowPos = 0; 3784 if (!!this.ARROW) 3785 { 3786 if (pos.width > floatWidth) 3787 arrowPos = parseInt(floatWidth/2 - 7); 3788 else 3789 arrowPos = parseInt(Math.min(floatWidth, pos.width)/2 - 7); 3790 3791 if (arrowPos < 7) 3792 { 3793 menu_pos.left -= 15; 3794 arrowPos += 15; 3795 } 3796 } 3797 3798 if (menu_pos.left > wndSize.scrollWidth - floatWidth - 10) 3799 { 3800 var orig_menu_pos = menu_pos.left; 3801 menu_pos.left = wndSize.scrollWidth - floatWidth - 10; 3802 3803 if (!!this.ARROW) 3804 arrowPos += orig_menu_pos - menu_pos.left; 3805 } 3806 3807 if (bFixed) 3808 { 3809 menu_pos.left -= wndSize.scrollLeft; 3810 } 3811 3812 if (!!this.ARROW) 3813 this.ARROW.style.left = arrowPos + 'px'; 3814 break; 3815 case 'right': 3816 menu_pos.top = pos.top-1; 3817 menu_pos.left = pos.right; 3818 3819 if (menu_pos.left > wndSize.scrollWidth - floatWidth - 10) 3820 { 3821 menu_pos.left = pos.left - floatWidth - 1; 3822 } 3823 break; 3824 } 3825 3826 if (bFixed) 3827 { 3828 menu_pos.top -= wndSize.scrollTop; 3829 } 3830 3831 if (!!this.ARROW) 3832 this.ARROW.className = 'bx-core-popup-menu-angle'; 3833 3834 if((menu_pos.top + floatHeight >
3834 wndSize.scrollTop + wndSize.innerHeight) 3835 || (menu_pos.top + floatHeight > wndSize.scrollHeight)) 3836 { 3837 var new_top = this.PARAMS.ATTACH_MODE == 'bottom' 3838 ? pos.top - floatHeight - 9 3839 : pos.bottom - floatHeight + 1; 3840 3841 if((new_top > wndSize.scrollTop) 3842 || (menu_pos.top + floatHeight > wndSize.scrollHeight)) 3843 { 3844 if ((menu_pos.top + floatHeight > wndSize.scrollHeight)) 3845 { 3846 menu_pos.top = Math.max(0, wndSize.scrollHeight-floatHeight); 3847 this.toggleArrow(false); 3848 } 3849 else 3850 { 3851 menu_pos.top = new_top; 3852 3853 if (!!this.ARROW) 3854 this.ARROW.className = 'bx-core-popup-menu-angle-bottom'; 3855 } 3856 } 3857 } 3858 3859 if (menu_pos.top + menu_pos.left == 0) 3860 { 3861 this.Hide(); 3862 } 3863 else 3864 { 3865 this.DIV.style.top = menu_pos.top + 'px'; 3866 this.DIV.style.left = menu_pos.left + 'px'; 3867 } 3868}; 3869 3870BX.CMenu.prototype.adjustToNode = function(el) 3871{ 3872 this.PARAMS.parent_attach = BX(el) || this.PARAMS.parent_attach || this.PARAMS.parent; 3873 this.__adjustMenuToNode(); 3874}; 3875 3876 3877/* components toolbar class */ 3878 3879BX.CMenuOpener = function(arParams) 3880{ 3881 BX.CMenuOpener.superclass.constructor.apply(this); 3882 3883 this.PARAMS = arParams || {}; 3884 this.setParent(this.PARAMS.parent); 3885 this.PARTS = {}; 3886 3887 this.SETTINGS.drag_restrict = true; 3888 3889 this.defaultAction = null; 3890 3891 this.timeout = 500; 3892 3893 this.DIV.className = 'bx-component-opener'; 3894 this.DIV.ondblclick = BX.PreventDefault; 3895 3896 if (this.PARAMS.component_id) 3897 { 3898 this.PARAMS.transform = !!this.PARAMS.transform; 3899 } 3900 3901 this.OPENERS = []; 3902 3903 this.DIV.appendChild(BX.create('SPAN', { 3904 props: {className: 'bx-context-toolbar' + (this.PARAMS.transform ? ' bx-context-toolbar-vertical-mode' : '')} 3905 })); 3906 3907 //set internal structure and register draggable element 3908 this.PARTS.INNER = this.DIV.firstChild.appendChild(BX.create('SPAN', { 3909 props: {className: 'bx-context-toolbar-inner'}, 3910 html: '<span class="bx-context-toolbar-drag-icon"></span><span class="bx-context-toolbar-vertical-line"></span><br>' 3911 })); 3912 3913 this.EXTRA_BUTTONS = {}; 3914 3915 var btnCount = 0; 3916 for (var i = 0, len = this.PARAMS.menu.length; i < len; i++) 3917 { 3918 var item = this.addItem(this.PARAMS.menu[i]); 3919 if (null != item) 3920 { 3921 btnCount++; 3922 this.PARTS.INNER.appendChild(item); 3923 this.PARTS.INNER.appendChild(BX.create('BR')); 3924 } 3925 } 3926 var bHasButtons = btnCount > 0; 3927 3928 //menu items will be attached here 3929 3930 this.PARTS.ICONS = this.PARTS.INNER.appendChild(BX.create('SPAN', { 3931 props: {className: 'bx-context-toolbar-icons'} 3932 })); 3933 3934 if (this.PARAMS.component_id) 3935 { 3936 this.PARAMS.pin = !!this.PARAMS.pin; 3937 3938 if (bHasButtons) 3939 this.PARTS.ICONS.appendChild(BX.create('SPAN', {props: {className: 'bx-context-toolbar-separator'}})); 3940 3941 this.PARTS.ICON_PIN = this.PARTS.ICONS.appendChild(BX.create('A', { 3942 attrs: { 3943 href: 'javascript:void(0)' 3944 }, 3945 props: { 3946 className: this.PARAMS.pin 3947 ? 'bx-context-toolbar-pin-fixed' 3948 : 'bx-context-toolbar-pin' 3949 }, 3950 events: { 3951 click: BX.delegate(this.__pin_btn_clicked, this) 3952 } 3953 })); 3954 } 3955 3956 3957 if (this.EXTRA_BUTTONS['components2_props']) 3958 { 3959 var btn = this.EXTRA_BUTTONS['components2_props'] || {URL: 'javascript:void(0)'}; 3960 if (null == this.defaultAction) 3961 { 3962 this.defaultAction = btn.ONCLICK; 3963 this.defaultActionTitle = btn.TITLE || btn.TEXT; 3964 } 3965 3966 btn.URL = 'javascript:' + BX.util.urlencode(btn.ONCLICK); 3967 3968 this.ATTACH = this.PARTS.ICONS.appendChild(BX.create('SPAN', { 3969 props: {className: 'bx-context-toolbar-button bx-context-toolbar-button-settings' }, 3970 children: 3971 [ 3972 BX.create('SPAN', 3973 { 3974 props:{className: 'bx-context-toolbar-button-inner'}, 3975 children: 3976 [ 3977 BX.create('A', { 3978 attrs: {href: btn.URL}, 3979 events: { 3980 mouseover: BX.proxy(this.__msover_text, this), 3981 mouseout: BX.proxy(this.__msout_text, this), 3982 mousedown: BX.proxy(this.__msdown_text, this) 3983 }, 3984 html: '<span class="bx-context-toolbar-button-icon bx-context-toolbar-settings-icon"></span>' 3985 }), 3986 BX.create('A', { 3987 attrs: {href: 'javascript: void(0)'}, 3988 props: {className: 'bx-context-toolbar-button-arrow'}, 3989 events: { 3990 mouseover: BX.proxy(this.__msover_arrow, this), 3991 mouseout: BX.proxy(this.__msout_arrow, this), 3992 mousedown: BX.proxy(this.__msdown_arrow, this) 3993 }, 3994 html: '<span class="bx-context-toolbar-button-arrow"></span>' 3995 }) 3996 ] 3997 }) 3998 ] 3999 })); 4000
4001 this.OPENER = this.ATTACH.firstChild.lastChild; 4002 4003 var opener = this.attachMenu(this.EXTRA_BUTTONS['components2_submenu']['MENU']); 4004 4005 BX.addCustomEvent(opener, 'onOpenerMenuOpen', BX.proxy(this.__menu_open, this)); 4006 BX.addCustomEvent(opener, 'onOpenerMenuClose', BX.proxy(this.__menu_close, this)); 4007 } 4008 4009 if (btnCount > 1) 4010 { 4011 this.PARTS.ICONS.appendChild(BX.create('span', { props: {className: 'bx-context-toolbar-separator bx-context-toolbar-separator-switcher'}})); 4012 4013 this.ICON_TRANSFORM = this.PARTS.ICONS.appendChild(BX.create('A', { 4014 attrs: {href: 'javascript: void(0)'}, 4015 props: {className: 'bx-context-toolbar-switcher'}, 4016 events: { 4017 click: BX.delegate(this.__trf_btn_clicked, this) 4018 } 4019 })); 4020 } 4021 4022 if (this.PARAMS.HINT) 4023 { 4024 this.DIV.BXHINT = this.HINT = new BX.CHint({ 4025 parent: this.DIV, 4026 hint:this.PARAMS.HINT.TEXT || '', 4027 title: this.PARAMS.HINT.TITLE || '', 4028 hide_timeout: this.timeout/2, 4029 preventHide: false 4030 }); 4031 } 4032 4033 BX.addCustomEvent(this, 'onWindowDragFinished', BX.delegate(this.__onMoveFinished, this)); 4034 BX.addCustomEvent('onDynamicModeChange', BX.delegate(this.__onDynamicModeChange, this)); 4035 BX.addCustomEvent('onTopPanelCollapse', BX.delegate(this.__onPanelCollapse, this)); 4036 4037 BX.addCustomEvent('onMenuOpenerMoved', BX.delegate(this.checkPosition, this)); 4038 BX.addCustomEvent('onMenuOpenerUnhide', BX.delegate(this.checkPosition, this)); 4039 4040 BX.Event.EventEmitter.incrementMaxListeners('onDynamicModeChange'); 4041 BX.Event.EventEmitter.incrementMaxListeners('onTopPanelCollapse'); 4042 BX.Event.EventEmitter.incrementMaxListeners('onMenuOpenerMoved'); 4043 BX.Event.EventEmitter.incrementMaxListeners('onMenuOpenerUnhide'); 4044 4045 if (this.OPENERS) 4046 { 4047 for (i=0,len=this.OPENERS.length; i<len; i++) 4048 { 4049 BX.addCustomEvent(this.OPENERS[i], 'onOpenerMenuOpen', BX.proxy(this.__hide_hint, this)); 4050 } 4051 } 4052}; 4053BX.extend(BX.CMenuOpener, BX.CWindowFloat); 4054 4055BX.CMenuOpener.prototype.setParent = function(new_parent) 4056{ 4057 new_parent = BX(new_parent); 4058 4059 if (!new_parent) 4060 { 4061 return; 4062 } 4063 4064 if(new_parent.OPENER && new_parent.OPENER != this) 4065 { 4066 new_parent.OPENER.Close(); 4067 new_parent.OPENER.clearHoverHoutEvents(); 4068 } 4069 4070 if(this.PARAMS.parent && this.PARAMS.parent != new_parent) 4071 { 4072 this.clearHoverHoutEvents(); 4073 this.PARAMS.parent.OPENER = null; 4074 } 4075 4076 this.PARAMS.parent = new_parent; 4077 this.PARAMS.parent.OPENER = this; 4078}; 4079 4080BX.CMenuOpener.prototype.setHoverHoutEvents = function(hover, hout) 4081{ 4082 if(!this.__opener_events_set) 4083 { 4084 BX.bind(this.Get(), 'mouseover', hover); 4085 BX.bind(this.Get(), 'mouseout', hout); 4086 this.__opener_events_set = true; 4087 } 4088}; 4089 4090BX.CMenuOpener.prototype.clearHoverHoutEvents = function() 4091{ 4092 if(this.Get()) 4093 { 4094 BX.unbindAll(this.Get()); 4095 this.__opener_events_set = false; 4096 } 4097}; 4098 4099 4100BX.CMenuOpener.prototype.unclosable = true; 4101 4102BX.CMenuOpener.prototype.__check_intersection = function(pos_self, pos_other) 4103{ 4104 return !(pos_other.right <= pos_self.left || pos_other.left >= pos_self.right 4105 || pos_other.bottom <= pos_self.top || pos_other.top >= pos_self.bottom); 4106}; 4107 4108 4109BX.CMenuOpener.prototype.__msover_text = function() { 4110 this.bx_hover = true; 4111 if (!this._menu_open) 4112 BX.addClass(this.ATTACH, 'bx-context-toolbar-button-text-hover'); 4113}; 4114 4115BX.CMenuOpener.prototype.__msout_text = function() { 4116 this.bx_hover = false; 4117 if (!this._menu_open) 4118 BX.removeClass(this.ATTACH, 'bx-context-toolbar-button-text-hover bx-context-toolbar-button-text-active'); 4119}; 4120 4121BX.CMenuOpener.prototype.__msover_arrow = function() { 4122 this.bx_hover = true; 4123 if (!this._menu_open) 4124 BX.addClass(this.ATTACH, 'bx-context-toolbar-button-arrow-hover'); 4125}; 4126 4127BX.CMenuOpener.prototype.__msout_arrow = function() { 4128 this.bx_hover = false; 4129 if (!this._menu_open) 4130 BX.removeClass(this.ATTACH, 'bx-context-toolbar-button-arrow-hover bx-context-toolbar-button-arrow-active'); 4131}; 4132 4133BX.CMenuOpener.prototype.__msdown_text = function() { 4134 this.bx_active = true; 4135 if (!this._menu_open) 4136 BX.addClass(this.ATTACH, 'bx-context-toolbar-button-text-active'); 4137}; 4138 4139BX.CMenuOpener.prototype.__msdown_arrow = function() { 4140 this.bx_active = true; 4141 if (!this._menu_open) 4142 BX.addClass(this.ATTACH, 'bx-context-toolbar-button-arrow-active'); 4143}; 4144 4145BX.CMenuOpener.prototype.__menu_close = function() { 4146 this._menu_open = false;
4147 this.bx_active = false; 4148 BX.removeClass(this.ATTACH, 'bx-context-toolbar-button-active bx-context-toolbar-button-text-active bx-context-toolbar-button-arrow-active'); 4149 if (!this.bx_hover) 4150 { 4151 BX.removeClass(this.ATTACH, 'bx-context-toolbar-button-hover bx-context-toolbar-button-text-hover bx-context-toolbar-button-arrow-hover'); 4152 this.bx_hover = false; 4153 } 4154}; 4155 4156BX.CMenuOpener.prototype.__menu_open = function() { 4157 this._menu_open = true; 4158}; 4159 4160BX.CMenuOpener.prototype.checkPosition = function() 4161{ 4162 if (this.isMenuVisible() || this.DIV.style.display == 'none' 4163 || this == BX.proxy_context || BX.proxy_context.zIndex > this.zIndex) 4164 return; 4165 4166 this.correctPosition(BX.proxy_context); 4167}; 4168 4169BX.CMenuOpener.prototype.correctPosition = function(opener) 4170{ 4171 var pos_self = BX.pos(this.DIV), pos_other = BX.pos(opener.Get()); 4172 if (this.__check_intersection(pos_self, pos_other)) 4173 { 4174 var new_top = pos_other.top - pos_self.height; 4175 if (new_top < 0) 4176 new_top = pos_other.bottom; 4177 4178 this.DIV.style.top = new_top + 'px'; 4179 4180 BX.addCustomEvent(opener, 'onMenuOpenerHide', BX.proxy(this.restorePosition, this)); 4181 BX.onCustomEvent(this, 'onMenuOpenerMoved'); 4182 } 4183}; 4184 4185BX.CMenuOpener.prototype.restorePosition = function() 4186{ 4187 if (!this.MOUSEOVER && !this.isMenuVisible()) 4188 { 4189 if (this.originalPos) 4190 this.DIV.style.top = this.originalPos.top + 'px'; 4191 4192 BX.removeCustomEvent(BX.proxy_context, 'onMenuOpenerHide', BX.proxy(this.restorePosition, this)); 4193 if (this.restore_pos_timeout) clearTimeout(this.restore_pos_timeout); 4194 } 4195 else 4196 { 4197 this.restore_pos_timeout = setTimeout(BX.proxy(this.restorePosition, this), this.timeout); 4198 } 4199}; 4200 4201 4202BX.CMenuOpener.prototype.Show = function() 4203{ 4204 BX.CMenuOpener.superclass.Show.apply(this, arguments); 4205 4206 this.SetDraggable(this.PARTS.INNER.firstChild); 4207 4208 this.DIV.style.width = 'auto'; 4209 this.DIV.style.height = 'auto'; 4210 4211 if (!this.PARAMS.pin) 4212 { 4213 this.DIV.style.left = '-1000px'; 4214 this.DIV.style.top = '-1000px'; 4215 4216 this.Hide(); 4217 } 4218 else 4219 { 4220 this.bPosAdjusted = true; 4221 this.bMoved = true; 4222 4223 if (this.PARAMS.top) this.DIV.style.top = this.PARAMS.top + 'px'; 4224 if (this.PARAMS.left) this.DIV.style.left = this.PARAMS.left + 'px'; 4225 4226 this.DIV.style.display = (!BX.admin.dynamic_mode || BX.admin.dynamic_mode_show_borders) ? 'block' : 'none'; 4227 4228 if (this.DIV.style.display == 'block') 4229 { 4230 setTimeout(BX.delegate(function() {BX.onCustomEvent(this, 'onMenuOpenerUnhide')}, this), 50); 4231 } 4232 } 4233}; 4234 4235BX.CMenuOpener.prototype.executeDefaultAction = function() 4236{ 4237 if (this.defaultAction) 4238 { 4239 if (BX.type.isFunction(this.defaultAction)) 4240 this.defaultAction(); 4241 else if(BX.type.isString(this.defaultAction)) 4242 BX.evalGlobal(this.defaultAction); 4243 } 4244}; 4245 4246BX.CMenuOpener.prototype.__onDynamicModeChange = function(val) 4247{ 4248 this.DIV.style.display = val ? 'block' : 'none'; 4249}; 4250 4251BX.CMenuOpener.prototype.__onPanelCollapse = function(bCollapsed, dy) 4252{ 4253 this.DIV.style.top = (parseInt(this.DIV.style.top) + dy) + 'px'; 4254 if (this.PARAMS.pin) 4255 { 4256 this.__savePosition(); 4257 } 4258}; 4259 4260BX.CMenuOpener.prototype.__onMoveFinished = function() 4261{ 4262 BX.onCustomEvent(this, 'onMenuOpenerMoved'); 4263 4264 this.bMoved = true; 4265 4266 if (this.PARAMS.pin) 4267 this.__savePosition(); 4268}; 4269 4270BX.CMenuOpener.prototype.__savePosition = function() 4271{ 4272 var arOpts = {}; 4273 4274 arOpts.pin = this.PARAMS.pin; 4275 if (!this.PARAMS.pin) 4276 { 4277 arOpts.top = false; arOpts.left = false; arOpts.transform = false; 4278 } 4279 else 4280 { 4281 arOpts.transform = this.PARAMS.transform; 4282 if (this.bMoved) 4283 { 4284 arOpts.left = parseInt(this.DIV.style.left); 4285 arOpts.top = parseInt(this.DIV.style.top); 4286 } 4287 } 4288 4289 BX.WindowManager.saveWindowOptions(this.PARAMS.component_id, arOpts); 4290}; 4291 4292BX.CMenuOpener.prototype.__pin_btn_clicked = function() {this.Pin()}; 4293BX.CMenuOpener.prototype.Pin = function(val) 4294{ 4295 if (null == val) 4296 this.PARAMS.pin = !this.PARAMS.pin; 4297 else 4298 this.PARAMS.pin = !!val; 4299 4300 this.PARTS.ICON_PIN.className = (this.PARAMS.pin ? 'bx-context-toolbar-pin-fixed' : 'bx-context-toolbar-pin'); 4301 4302 this.__savePosition(); 4303}; 4304 4305BX.CMenuOpener.prototype.__trf_btn_clicked = function() {this.Transform()}; 4306BX.CMenuOpener.prototype.Transform = function(val) 4307{ 4308 var pos = {}; 4309 4310 if (null == val) 4311 this.PARAMS.transform = !this.PARAMS.transform; 4312 else 4313 this.PARAMS.transform = !!val; 4314 4315 if (this.bMoved) 4316 { 4317 pos = BX.pos(this.DIV); 4318 } 4319 4320 if (this.PARAMS.transform) 4321 BX.addClass(this.DIV.firstChild, 'bx-context-toolbar-vertical-mode'); 4322 else 4323 BX.removeClass(this.DIV.firstChild, 'bx-context-toolbar-vertical-mode'); 4324 4325 if (!this.bMoved) 4326 { 4327 this.adjustPos(); 4328 } 4329 else 4330 { 4331 this.DIV.style.left = (pos.right - this.DIV.offsetWidth - (BX.browser.IsIE() && !BX.browser.IsDoctype() ? 2 : 0)) + 'px'; 4332 } 4333 4334 this.__savePosition(); 4335}; 4336 4337BX.CMenuOpener.prototype.adjustToNodeGetPos = function() 4338{ 4339 var pos = BX.pos(this.PARAMS.parent/*, true*/); 4340 4341 var scrollSize = BX.GetWindowScrollSize(); 4342 var floatWidth = this.DIV.offsetWidth; 4343 4344 pos.left -= BX.admin.__border_dx; 4345 pos.top -= BX.admin.__border_dx; 4346 4347 if (true || !this.PARAMS.transform) 4348 { 4349 pos.top -= 45; 4350 } 4351 4352 if (pos.left > scrollSize.scrollWidth - floatWidth) 4353 { 4354 pos.left = scrollSize.scrollWidth - floatWidth; 4355 } 4356 4357 return pos; 4358}; 4359 4360BX.CMenuOpener.prototype.addItem = function(item) 4361{ 4362 if (item.TYPE) 4363 { 4364 this.EXTRA_BUTTONS[item.TYPE] = item; 4365 return null; 4366 } 4367 else 4368 { 4369 var q = new BX.CMenuOpenerItem(item); 4370 if (null == this.defaultAction) 4371 { 4372 if (q.item.ONCLICK) 4373 { 4374 this.defaultAction = item.ONCLICK; 4375 } 4376 else if (q.item.MENU) 4377 { 4378 this.defaultAction = BX.delegate(function() {this.Open()}, q.item.OPENER); 4379 } 4380 4381 this.defaultActionTitle = item.TITLE || item.TEXT; 4382 4383 BX.addClass(q.Get(), 'bx-content-toolbar-default'); 4384 } 4385 if (q.item.OPENER) this.OPENERS[this.OPENERS.length] = q.item.OPENER; 4386 return q.Get(); 4387 } 4388}; 4389 4390BX.CMenuOpener.prototype.attachMenu = function(menu) 4391{ 4392 var opener = new BX.COpener({ 4393 'DIV': this.OPENER,
4394 'ATTACH': this.ATTACH, 4395 'MENU': menu, 4396 'TYPE': 'click' 4397 }); 4398 4399 this.OPENERS[this.OPENERS.length] = opener; 4400 4401 return opener; 4402}; 4403 4404BX.CMenuOpener.prototype.__hide_hint = function() 4405{ 4406 if (this.HINT) this.HINT.__hide_immediately(); 4407}; 4408 4409BX.CMenuOpener.prototype.isMenuVisible = function() 4410{ 4411 for (var i=0,len=this.OPENERS.length; i<len; i++) 4412 { 4413 if (this.OPENERS[i].isMenuVisible()) 4414 return true; 4415 } 4416 4417 return false; 4418}; 4419 4420BX.CMenuOpener.prototype.Hide = function() 4421{ 4422 if (!this.PARAMS.pin) 4423 { 4424 this.DIV.style.display = 'none'; 4425 BX.onCustomEvent(this, 'onMenuOpenerHide'); 4426 } 4427}; 4428BX.CMenuOpener.prototype.UnHide = function() 4429{ 4430 this.DIV.style.display = 'block'; 4431 if (!this.bPosAdjusted && !this.PARAMS.pin) 4432 { 4433 this.adjustPos(); 4434 this.bPosAdjusted = true; 4435 } 4436 4437 if (null == this.originalPos && !this.bMoved) 4438 { 4439 this.originalPos = BX.pos(this.DIV); 4440 } 4441 4442 BX.onCustomEvent(this, 'onMenuOpenerUnhide'); 4443}; 4444 4445BX.CMenuOpenerItem = function(item) 4446{ 4447 this.item = item; 4448 4449 if (this.item.ACTION && !this.item.ONCLICK) 4450 { 4451 this.item.ONCLICK = this.item.ACTION; 4452 } 4453 4454 this.DIV = BX.create('SPAN'); 4455 this.DIV.appendChild(BX.create('SPAN', {props: {className: 'bx-context-toolbar-button-underlay'}})); 4456 4457 this.WRAPPER = this.DIV.appendChild(BX.create('SPAN', { 4458 props: {className: 'bx-context-toolbar-button-wrapper'}, 4459 children: [ 4460 BX.create('SPAN', { 4461 props: {className: 'bx-context-toolbar-button', title: item.TITLE}, 4462 children: [ 4463 BX.create('SPAN', { 4464 props: {className: 'bx-context-toolbar-button-inner'} 4465 }) 4466 ] 4467 }) 4468 ] 4469 })); 4470 4471 var btn_icon = BX.create('SPAN', { 4472 props: {className: 'bx-context-toolbar-button-icon' + (this.item.ICON || this.item.ICONCLASS ? ' ' + (this.item.ICON || this.item.ICONCLASS) : '')}, 4473 attrs: ( 4474 !(this.item.ICON || this.item.ICONCLASS) 4475 && 4476 (this.item.SRC || this.item.IMAGE) 4477 ) 4478 ? { 4479 style: 'background: scroll transparent url(' + (this.item.SRC || this.item.IMAGE) + ') no-repeat center center !important;' 4480 } 4481 : {} 4482 }), btn_text = BX.create('SPAN', { 4483 props: {className: 'bx-context-toolbar-button-text'}, 4484 text: this.item.TEXT 4485 }); 4486 4487 if (this.item.ACTION && !this.item.ONCLICK) 4488 { 4489 this.item.ONCLICK = this.item.ACTION; 4490 } 4491 4492 this.bHasMenu = !!this.item.MENU; 4493 this.bHasAction = !!this.item.ONCLICK; 4494 4495 if (this.bHasAction) 4496 { 4497 this.LINK = this.WRAPPER.firstChild.firstChild.appendChild(BX.create('A', { 4498 attrs: { 4499 'href': 'javascript: void(0)' 4500 }, 4501 events: { 4502 mouseover: this.bHasMenu ? BX.proxy(this.__msover_text, this) : BX.proxy(this.__msover, this), 4503 mouseout: this.bHasMenu ? BX.proxy(this.__msout_text, this) : BX.proxy(this.__msout, this), 4504 mousedown: this.bHasMenu ? BX.proxy(this.__msdown_text, this) : BX.proxy(this.__msdown, this) 4505 }, 4506 children: [btn_icon, btn_text] 4507 })); 4508 4509 if (this.bHasMenu) 4510 { 4511 this.LINK_MENU = this.WRAPPER.firstChild.firstChild.appendChild(BX.create('A', { 4512 props: {className: 'bx-context-toolbar-button-arrow'}, 4513 attrs: { 4514 'href': 'javascript: void(0)' 4515 }, 4516 events: { 4517 mouseover: BX.proxy(this.__msover_arrow, this), 4518 mouseout: BX.proxy(this.__msout_arrow, this), 4519 mousedown: BX.proxy(this.__msdown_arrow, this) 4520 }, 4521 children: [ 4522 BX.create('SPAN', {props: {className: 'bx-context-toolbar-button-arrow'}}) 4523 ] 4524 })); 4525 } 4526 4527 } 4528 else if (this.bHasMenu) 4529 { 4530 this.item.ONCLICK = null; 4531 4532 this.LINK = this.LINK_MENU = this.WRAPPER.firstChild.firstChild.appendChild(BX.create('A', { 4533 attrs: { 4534 'href': 'javascript: void(0)' 4535 }, 4536 events: { 4537 mouseover: BX.proxy(this.__msover, this), 4538 mouseout: BX.proxy(this.__msout, this), 4539 mousedown: BX.proxy(this.__msdown, this) 4540 }, 4541 children: [ 4542 btn_icon, 4543 btn_text 4544 ] 4545 })); 4546 4547 this.LINK.appendChild(BX.create('SPAN', {props: {className: 'bx-context-toolbar-single-button-arrow'}})); 4548 4549 } 4550 4551 if (this.bHasMenu) 4552 { 4553 this.item.SUBMENU = new BX.CMenu({ 4554 ATTACH_MODE:'bottom', 4555 ITEMS:this.item['MENU'], 4556 //PARENT_MENU:this.parentMenu, 4557 parent: this.LINK_MENU, 4558 parent_attach: this.WRAPPER.firstChild 4559 }); 4560 4561 this.item.OPENER = new BX.COpener({ 4562 DIV: this.LINK_MENU, 4563 TYPE: 'click', 4564 MENU: this.item.SUBMENU 4565 }); 4566 4567 BX.addCustomEvent(this.item.OPENER, 'onOpenerMenuOpen', BX.proxy(this.__menu_open, this)); 4568 BX.addCustomEvent(this.item.OPENER, 'onOpenerMenuClose', BX.proxy(this.__menu_close, this)); 4569 } 4570 4571 if (this.bHasAction) 4572 { 4573 BX.bind(this.LINK, 'click', BX.delegate(this.__click, this)); 4574 } 4575}; 4576 4577BX.CMenuOpenerItem.prototype.Get = function() {return this.DIV;}; 4578BX.CMenuOpenerItem.prototype.__msover = function() { 4579 this.bx_hover = true; 4580 if (!this._menu_open) 4581 BX.addClass(this.LINK.parentNode.parentNode, 'bx-context-toolbar-button-hover'); 4582}; 4583BX.CMenuOpenerItem.prototype.__msout = function() { 4584 this.bx_hover = false;
4585 if (!this._menu_open) 4586 BX.removeClass(this.LINK.parentNode.parentNode, 'bx-context-toolbar-button-hover bx-context-toolbar-button-active'); 4587}; 4588BX.CMenuOpenerItem.prototype.__msover_text = function() { 4589 this.bx_hover = true; 4590 if (!this._menu_open) 4591 BX.addClass(this.LINK.parentNode.parentNode, 'bx-context-toolbar-button-text-hover'); 4592}; 4593BX.CMenuOpenerItem.prototype.__msout_text = function() { 4594 this.bx_hover = false; 4595 if (!this._menu_open) 4596 BX.removeClass(this.LINK.parentNode.parentNode, 'bx-context-toolbar-button-text-hover bx-context-toolbar-button-text-active'); 4597}; 4598BX.CMenuOpenerItem.prototype.__msover_arrow = function() { 4599 this.bx_hover = true; 4600 if (!this._menu_open) 4601 BX.addClass(this.LINK.parentNode.parentNode, 'bx-context-toolbar-button-arrow-hover'); 4602}; 4603BX.CMenuOpenerItem.prototype.__msout_arrow = function() { 4604 this.bx_hover = false; 4605 if (!this._menu_open) 4606 BX.removeClass(this.LINK.parentNode.parentNode, 'bx-context-toolbar-button-arrow-hover bx-context-toolbar-button-arrow-active'); 4607}; 4608BX.CMenuOpenerItem.prototype.__msdown = function() { 4609 this.bx_active = true; 4610 if (!this._menu_open) 4611 BX.addClass(this.LINK.parentNode.parentNode, 'bx-context-toolbar-button-active'); 4612}; 4613BX.CMenuOpenerItem.prototype.__msdown_text = function() { 4614 this.bx_active = true; 4615 if (!this._menu_open) 4616 BX.addClass(this.LINK.parentNode.parentNode, 'bx-context-toolbar-button-text-active'); 4617}; 4618BX.CMenuOpenerItem.prototype.__msdown_arrow = function() { 4619 this.bx_active = true; 4620 if (!this._menu_open) 4621 BX.addClass(this.LINK.parentNode.parentNode, 'bx-context-toolbar-button-arrow-active'); 4622}; 4623BX.CMenuOpenerItem.prototype.__menu_close = function() { 4624 4625 this._menu_open = false; 4626 this.bx_active = false; 4627 BX.removeClass(this.LINK.parentNode.parentNode, 'bx-context-toolbar-button-active bx-context-toolbar-button-text-active bx-context-toolbar-button-arrow-active'); 4628 if (!this.bx_hover) 4629 { 4630 BX.removeClass(this.LINK.parentNode.parentNode, 'bx-context-toolbar-button-hover bx-context-toolbar-button-text-hover bx-context-toolbar-button-arrow-hover'); 4631 this.bx_hover = false; 4632 } 4633}; 4634BX.CMenuOpenerItem.prototype.__menu_open = function() { 4635 this._menu_open = true; 4636}; 4637 4638BX.CMenuOpenerItem.prototype.__click = function() {BX.evalGlobal(this.item.ONCLICK)}; 4639 4640/* global page opener class */ 4641BX.CPageOpener = function(arParams) 4642{ 4643 //if (null == arParams.pin) arParams.pin = true; 4644 BX.CPageOpener.superclass.constructor.apply(this, arguments); 4645 4646 this.timeout = 505; 4647 4648 window.PAGE_EDIT_CONTROL = this; 4649}; 4650BX.extend(BX.CPageOpener, BX.CMenuOpener); 4651 4652BX.CPageOpener.prototype.checkPosition = function() 4653{ 4654 if (/*this.isMenuVisible() || this.DIV.style.display == 'none' || */this == BX.proxy_context) 4655 return; 4656 4657 this.correctPosition(BX.proxy_context); 4658}; 4659 4660BX.CPageOpener.prototype.correctPosition = function(opener) 4661{ 4662 if (this.bPosCorrected) return; 4663 var pos_self; 4664 if (this.DIV.style.display == 'none') 4665 { 4666 pos_self = this.adjustToNodeGetPos(); 4667 pos_self.bottom = pos_self.top + 30; 4668 pos_self.right = pos_self.left + 300; 4669 } 4670 else 4671 { 4672 pos_self = BX.pos(this.DIV); 4673 } 4674 4675 var pos_other = BX.pos(opener.Get()); 4676 if (this.__check_intersection(pos_self, pos_other)) 4677 { 4678 this.DIV.style.display = 'none'; 4679 4680 var handler = BX.proxy(this.restorePosition, this); 4681 4682 BX.removeCustomEvent(opener, 'onMenuOpenerHide', handler); 4683 BX.addCustomEvent(opener, 'onMenuOpenerHide', handler); 4684 4685 this.bPosCorrected = true; 4686 } 4687}; 4688 4689BX.CPageOpener.prototype.restorePosition = function() 4690{ 4691 if (BX.proxy_context && BX.proxy_context.Get().style.display == 'none') 4692 { 4693 this.bPosCorrected = false; 4694 4695 if (this.PARAMS.parent.bx_over || this.PARAMS.pin) 4696 this.UnHide(); 4697 4698 BX.removeCustomEvent('onMenuOpenerHide', BX.proxy(this.restorePosition, this)); 4699 } 4700}; 4701 4702BX.CPageOpener.prototype.UnHide = function() 4703{ 4704 if (!this.bPosCorrected) 4705 BX.CPageOpener.superclass.UnHide.apply(this, arguments); 4706}; 4707 4708BX.CPageOpener.prototype.Remove = function() 4709{ 4710 BX.admin.removeComponentBorder(this.PARAMS.parent); 4711 BX.userOptions.save('global', 'settings', 'page_edit_control_enable', 'N'); 4712 this.DIV.style.display = 'none'; 4713}; 4714 4715/******* HINT ***************/ 4716BX.CHintSimple = function() 4717{ 4718 BX.CHintSimple.superclass.constructor.apply(this, arguments); 4719}; 4720BX.extend(BX.CHintSimple, BX.CHint); 4721 4722BX.CHintSimple.prototype.Init = function() 4723{ 4724 this.DIV = document.body.appendChild(BX.create('DIV', {props: {className: 'bx-tooltip-simple'}, style: {display: 'none'}, children: [(this.CONTENT = BX.create('DIV'))]})); 4725 4726 BX.ZIndexManager.register(this.DIV); 4727 4728 if (this.HINT_TITLE) 4729 this.CONTENT.appendChild(BX.create('B', {text: this.HINT_TITLE})); 4730 4731 if (this.HINT) 4732 this.CONTENT_TEXT = this.CONTENT.appendChild(BX.create('DIV')).appendChild(BX.create('SPAN', {html: this.HINT})); 4733 4734 if (this.PARAMS.preventHide) 4735 { 4736 BX.bind(this.DIV, 'mouseout', BX.proxy(this.Hide, this)); 4737 BX.bind(this.DIV, 'mouseover', BX.proxy(this.Show, this)); 4738 } 4739 4740 this.bInited = true; 4741}; 4742 4743/*************************** admin informer **********************************/ 4744BX.adminInformer = { 4745 4746 itemsShow: 3, 4747 4748 Init: function (itemsShow) 4749 { 4750 if(itemsShow) 4751 BX.adminInformer.itemsShow = itemsShow; 4752 4753 var informer = BX("admin-informer"); 4754 4755 if(informer) 4756 { 4757 document.body.appendChild(informer); 4758 BX.ZIndexManager.register(informer); 4759 } 4760 4761 BX.addCustomEvent("onTopPanelCollapse", BX.proxy(BX.adminInformer.Close, BX.adminInformer)); 4762 }, 4763 4764 Toggle: function(notifyBlock) 4765 { 4766 var informer = BX("admin-informer"); 4767 4768 if(!informer) 4769 return false;
4770 4771 var pos = BX.pos(notifyBlock); 4772 4773 informer.style.top = (parseInt(pos.top)+parseInt(pos.height)+7)+'px'; 4774 informer.style.left = pos.left+'px'; 4775 4776 if(!BX.hasClass(informer, "adm-informer-active")) 4777 BX.adminInformer.Show(informer); 4778 else 4779 BX.adminInformer.Hide(informer); 4780 4781 return false; 4782 }, 4783 4784 Close: function() 4785 { 4786 BX.adminInformer.Hide(BX("admin-informer")); 4787 }, 4788 4789 OnInnerClick: function(event) 4790 { 4791 var target = event.target || event.srcElement; 4792 4793 if(target.nodeName.toLowerCase() != 'a' || BX.hasClass(target,"adm-informer-footer")) 4794 { 4795 return BX.PreventDefault(event); 4796 } 4797 4798 return true; 4799 }, 4800 4801 ToggleExtra : function() 4802 { 4803 var footerLink = BX("adm-informer-footer"); 4804 4805 if (BX.hasClass(footerLink, "adm-informer-footer-collapsed")) 4806 this.ShowAll(); 4807 else 4808 this.HideExtra(); 4809 4810 return false; 4811 }, 4812 4813 ShowAll: function() 4814 { 4815 var informer = BX("admin-informer"); 4816 for(var i=0; i<informer.children.length; i++) 4817 4818 if(BX.hasClass(informer.children[i], "adm-informer-item") && informer.children[i].style.display == "none") { 4819 informer.children[i].style.display = "block"; 4820 } 4821 4822 var footerLink = BX("adm-informer-footer"); 4823 4824 if(footerLink.textContent !== undefined) 4825 footerLink.textContent = BX.message('JSADM_AI_HIDE_EXTRA'); 4826 else 4827 footerLink.innerText = BX.message('JSADM_AI_HIDE_EXTRA'); 4828 4829 BX.removeClass(footerLink, "adm-informer-footer-collapsed"); 4830 4831 return false; 4832 }, 4833 4834 HideExtra: function() 4835 { 4836 var informer = BX("admin-informer"); 4837 var hided = 0; 4838 4839 for(var i=BX.adminInformer.itemsShow+1; i<informer.children.length; i++) 4840 { 4841 if (BX.hasClass(informer.children[i], "adm-informer-item") && informer.children[i].style.display == "block") { 4842 informer.children[i].style.display = "none"; 4843 hided++; 4844 } 4845 } 4846 4847 var footerLink = BX("adm-informer-footer"); 4848 4849 var linkText = BX.message('JSADM_AI_ALL_NOTIF')+" ("+(BX.adminInformer.itemsShow+parseInt(hided))+")"; 4850 4851 if(footerLink.textContent !== undefined) 4852 footerLink.textContent = linkText; 4853 else 4854 footerLink.innerText = linkText; 4855 4856 BX.addClass(footerLink, "adm-informer-footer-collapsed"); 4857 4858 return false; 4859 }, 4860 4861 Show: function(informer) 4862 { 4863 var notifButton = BX("adm-header-notif-block"); 4864 if (notifButton) 4865 BX.addClass(notifButton, "adm-header-notif-block-active"); 4866 4867 BX.onCustomEvent(informer, 'onBeforeAdminInformerShow'); 4868 setTimeout( 4869 BX.proxy(function() { 4870 BX.bind(document, "click", BX.proxy(BX.adminInformer.Close, BX.adminInformer)); 4871 }, 4872 BX.adminInformer 4873 ),0 4874 ); 4875 BX.addClass(informer, "adm-informer-active"); 4876 4877 BX.ZIndexManager.bringToFront(informer); 4878 4879 setTimeout(function() {BX.addClass(informer, "adm-informer-animate");},0); 4880 }, 4881 4882 Hide: function(informer) 4883 { 4884 var notifButton = BX("adm-header-notif-block"); 4885 if (notifButton) 4886 BX.removeClass(notifButton, "adm-header-notif-block-active"); 4887 4888 BX.unbind(document, "click", BX.proxy(BX.adminInformer.Close, BX.adminInformer)); 4889 4890 BX.removeClass(informer, "adm-informer-animate"); 4891 4892 if (this.IsAnimationSupported()) 4893 setTimeout(function() {BX.removeClass(informer, "adm-informer-active");}, 300); 4894 else 4895 BX.removeClass(informer, "adm-informer-active"); 4896 4897 BX.onCustomEvent(informer, 'onAdminInformerHide'); 4898 //setTimeout(function() {BX.adminInformer.HideExtra();},500); 4899 }, 4900 4901 IsAnimationSupported : function() 4902 { 4903 var d = document.body || document.documentElement; 4904 if (typeof(d.style.transition) == "string") 4905 return true; 4906 else if (typeof(d.style.MozTransition) == "string") 4907 return true; 4908 else if (typeof(d.style.OTransition) == "string") 4909 return true; 4910 else if (typeof(d.style.WebkitTransition) == "string") 4911 return true; 4912 else if (typeof(d.style.msTransition) == "string") 4913 return true; 4914 4915 return false; 4916 }, 4917 4918 4919 SetItemHtml: function(itemIdx, html) 4920 { 4921 var itemHtmlDiv = BX("adm-informer-item-html-"+itemIdx); 4922 4923 if(!itemHtmlDiv) 4924 return false; 4925 4926 itemHtmlDiv.innerHTML = html; 4927 4928 return true; 4929 }, 4930 4931 SetItemFooter: function(itemIdx, html) 4932 { 4933 var itemFooterDiv = BX("adm-informer-item-footer-"+itemIdx); 4934 4935 if(!itemFooterDiv) 4936 return false; 4937 4938 itemFooterDiv.innerHTML = html; 4939 4940 if(html) 4941 itemFooterDiv.style.display = "block"; 4942 else 4943 itemFooterDiv.style.display = "none"; 4944 4945 return true; 4946 } 4947 4948}; 4949 4950}
4950)(window); 4951 4952 4953/* End */ 4954; 4955; /* Start:"a:4:{s:4:"full";s:49:"/bitrix/js/main/date/main.date.js?168616490647122";s:6:"source";s:33:"/bitrix/js/main/date/main.date.js";s:3:"min";s:0:"";s:3:"map";s:0:"";}"*/ 4956this.BX = this.BX || {}; 4957(function (exports,main_core) { 4958 'use strict'; 4959 4960 function convertBitrixFormat(format) { 4961 if (!main_core.Type.isStringFilled(format)) { 4962 return ''; 4963 } 4964 return format.replace('YYYY', 'Y') // 1999 4965 .replace('MMMM', 'F') // January - December 4966 .replace('MM', 'm') // 01 - 12 4967 .replace('M', 'M') // Jan - Dec 4968 .replace('DD', 'd') // 01 - 31 4969 .replace('G', 'g') // 1 - 12 4970 .replace(/GG/i, 'G') // 0 - 23 4971 .replace('H', 'h') // 01 - 12 4972 .replace(/HH/i, 'H') // 00 - 24 4973 .replace('MI', 'i') // 00 - 59 4974 .replace('SS', 's') // 00 - 59 4975 .replace('TT', 'A') // AM - PM 4976 .replace('T', 'a'); // am - pm 4977 } 4978 4979 const formatsCache = new main_core.Cache.MemoryCache(); 4980 4981 /** 4982 * Returns culture-specific datetime format by code. 4983 * The full list with examples can be found in config.php of this extension in ['settings']['formats']. 4984 * All formats are compatible with this.format() without any additional transformations. 4985 * 4986 * @param code 4987 * @returns {string|null} 4988 */ 4989 function getFormat(code) { 4990 return formatsCache.remember(`main.date.format.${code}`, () => { 4991 let format = main_core.Extension.getSettings('main.date').get(`formats.${code}`); 4992 if (main_core.Type.isStringFilled(format) && (code === 'FORMAT_DATE' || code === 'FORMAT_DATETIME')) { 4993 format = convertBitrixFormat(format); 4994 } 4995 return format; 4996 }); 4997 } 4998 4999 /** 5000 * @memberOf BX.Main 5001 * @alias Date 5002 */ 5003 let DateTimeFormat = /*#__PURE__*/function () { 5004 function DateTimeFormat() { 5005 babelHelpers.classCallCheck(this, DateTimeFormat); 5006 } 5007 babelHelpers.createClass(DateTimeFormat, null, [{ 5008 key: "isAmPmMode", 5009 value: function isAmPmMode(returnConst) { 5010 if (returnConst === true) { 5011 return this._getMessage('AMPM_MODE'); 5012 } 5013 return this._getMessage('AMPM_MODE') !== false; 5014 } 5015 }, { 5016 key: "convertToUTC", 5017 value: function convertToUTC(date) { 5018 if (!main_core.Type.isDate(date)) { 5019 return null; 5020 } 5021 return new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds())); 5022 } 5023 /** 5024 * Function creates and returns Javascript Date() object from server timestamp regardless of local browser (system) timezone. 5025 * For example can be used to convert timestamp from some exact date on server to the JS Date object with the same value. 5026 * 5027 * @param timestamp - timestamp in seconds 5028 * @returns {Date} 5029 */ 5030 }, { 5031 key: "getNewDate", 5032 value: function getNewDate(timestamp) { 5033 return new Date(this.getBrowserTimestamp(timestamp)); 5034 } 5035 /** 5036 * Function transforms server timestamp (in sec) to javascript timestamp (calculated depend on local browser timezone offset). Returns timestamp in milliseconds. 5037 * Also see BX.Main.Date.getNewDate description. 5038 * 5039 * @param timestamp - timestamp in seconds 5040 * @returns {number} 5041 */ 5042 }, { 5043 key: "getBrowserTimestamp", 5044 value: function getBrowserTimestamp(timestamp) { 5045 timestamp = parseInt(timestamp, 10); 5046 const browserOffset = new Date(timestamp * 1000).getTimezoneOffset() * 60; 5047 return (parseInt(timestamp, 10) + parseInt(this._getMessage('SERVER_TZ_OFFSET')) + browserOffset) * 1000; 5048 } 5049 /** 5050 * Function transforms local browser timestamp (in ms) to server timestamp (calculated depend on local browser timezone offset). Returns timestamp in seconds. 5051 * 5052 * @param timestamp - timestamp in milliseconds 5053 * @returns {number} 5054 */ 5055 }, { 5056 key: "getServerTimestamp", 5057 value: function getServerTimestamp(timestamp) { 5058 timestamp = parseInt(timestamp, 10); 5059 const browserOffset = new Date(timestamp).getTimezoneOffset() * 60; 5060 return Math.round(timestamp / 1000 - (parseInt(this._getMessage('SERVER_TZ_OFFSET'), 10) + parseInt(browserOffset, 10))); 5061 } 5062 }, { 5063 key: "formatLastActivityDate", 5064 value: function formatLastActivityDate(timestamp, now, utc) { 5065 const ampm = this.isAmPmMode(true); 5066 const timeFormat = ampm === this.AM_PM_MODE.LOWER ? 'g:i a' : ampm === this.AM_PM_MODE.UPPER ? 'g:i A' : 'H:i'; 5067 const format = [['tomorrow', '#01#' + timeFormat], ['now', '#02#'], ['todayFuture', '#03#' + timeFormat], ['yesterday', '#04#' + timeFormat], ['-', this.convertBitrixFormat(this._getMessage('FORMAT_DATETIME')).replace(/:s/g, '')], ['
5067s60', 'sago'], ['i60', 'iago'], ['H5', 'Hago'], ['H24', '#03#' + timeFormat], ['d31', 'dago'], ['m12>1', 'mago'], ['m12>0', 'dago'], ['', '#05#']]; 5068 let formattedDate = this.format(format, timestamp, now, utc); 5069 let match = null; 5070 if ((match = /^#(\d+)#(.*)/.exec(formattedDate)) != null) { 5071 switch (match[1]) { 5072 case '01': 5073 formattedDate = this._getMessage('FD_LAST_SEEN_TOMORROW').replace('#TIME#', match[2]); 5074 break; 5075 case '02': 5076 formattedDate = this._getMessage('FD_LAST_SEEN_NOW'); 5077 break; 5078 case '03': 5079 formattedDate = this._getMessage('FD_LAST_SEEN_TODAY').replace('#TIME#', match[2]); 5080 break; 5081 case '04': 5082 formattedDate = this._getMessage('FD_LAST_SEEN_YESTERDAY').replace('#TIME#', match[2]); 5083 break; 5084 case '05': 5085 formattedDate = this._getMessage('FD_LAST_SEEN_MORE_YEAR'); 5086 break; 5087 default: 5088 formattedDate = match[2]; 5089 break; 5090 } 5091 } 5092 return formattedDate; 5093 } 5094 /** 5095 * The method is designed to replace the localization storage on sites without Bitrix Framework. 5096 * It gets overloaded with custom implementation: 5097 * 5098 * const CustomDate = Object.create(BX.Main.Date); 5099 * CustomDate._getMessage = () => ...new implementation...; 5100 * 5101 * This class should get messages only via this method. 5102 * Otherwise, the class won't work on sites without Bitrix Framework. 5103 * 5104 * @param message 5105 * @returns {*} 5106 * @private 5107 */ 5108 }, { 5109 key: "_getMessage", 5110 value: function _getMessage(message) { 5111 return main_core.Loc.getMessage(message); 5112 } 5113 /** 5114 * The method used to parse date from string by given format. 5115 * 5116 * @param {string} str - date in given format 5117 * @param {boolean} isUTC - is date in UTC 5118 * @param {string} formatDate - format of the date without time 5119 * @param {string} formatDatetime - format of the date with time 5120 * @returns {Date|null} - returns Date object if string was parsed or null 5121 */ 5122 }, { 5123 key: "parse", 5124 value: function parse(str, isUTC, formatDate, formatDatetime) { 5125 if (main_core.Type.isStringFilled(str)) { 5126 if (!formatDate) { 5127 formatDate = this._getMessage('FORMAT_DATE'); 5128 } 5129 if (!formatDatetime) { 5130 formatDatetime = this._getMessage('FORMAT_DATETIME'); 5131 } 5132 let regMonths = ''; 5133 for (let i = 1; i <= 12; i++) { 5134 regMonths = regMonths + '|' + this._getMessage('MON_' + i); 5135 }
5136 const expr = new RegExp('([0-9]+|[a-z]+' + regMonths + ')', 'ig'); 5137 const aDate = str.match(expr); 5138 let aFormat = formatDate.match(/(DD|MI|MMMM|MM|M|YYYY)/ig); 5139 const aDateArgs = []; 5140 const aFormatArgs = []; 5141 const aResult = {}; 5142 if (!aDate) { 5143 return null; 5144 } 5145 if (aDate.length > aFormat.length) { 5146 aFormat = formatDatetime.match(/(DD|MI|MMMM|MM|M|YYYY|HH|H|SS|TT|T|GG|G)/ig); 5147 } 5148 for (let i = 0, cnt = aDate.length; i < cnt; i++) { 5149 if (aDate[i].trim() !== '') { 5150 aDateArgs[aDateArgs.length] = aDate[i]; 5151 } 5152 } 5153 for (let i = 0, cnt = aFormat.length; i < cnt; i++) { 5154 if (aFormat[i].trim() !== '') { 5155 aFormatArgs[aFormatArgs.length] = aFormat[i]; 5156 } 5157 } 5158 let m = aFormatArgs.findIndex(item => item === 'MMMM'); 5159 if (m > 0) { 5160 aDateArgs[m] = this.getMonthIndex(aDateArgs[m]); 5161 aFormatArgs[m] = 'MM'; 5162 } else { 5163 m = aFormatArgs.findIndex(item => item === 'M'); 5164 if (m > 0) { 5165 aDateArgs[m] = this.getMonthIndex(aDateArgs[m]); 5166 aFormatArgs[m] = 'MM'; 5167 } 5168 } 5169 for (let i = 0, cnt = aFormatArgs.length; i < cnt; i++) { 5170 const k = aFormatArgs[i].toUpperCase(); 5171 aResult[k] = k === 'T' || k === 'TT' ? aDateArgs[i] : parseInt(aDateArgs[i], 10); 5172 } 5173 if (aResult['DD'] > 0 && aResult['MM'] > 0 && aResult['YYYY'] > 0) { 5174 const d = new Date(); 5175 if (isUTC) { 5176 d.setUTCDate(1); 5177 d.setUTCFullYear(aResult['YYYY']); 5178 d.setUTCMonth(aResult['MM'] - 1); 5179 d.setUTCDate(aResult['DD']); 5180 d.setUTCHours(0, 0, 0, 0); 5181 } else { 5182 d.setDate(1); 5183 d.setFullYear(aResult['YYYY']); 5184 d.setMonth(aResult['MM'] - 1); 5185 d.setDate(aResult['DD']); 5186 d.setHours(0, 0, 0, 0); 5187 } 5188 if ((!isNaN(aResult['HH']) || !isNaN(aResult['GG']) || !isNaN(aResult['H']) || !isNaN(aResult['G'])) && !isNaN(aResult['MI'])) { 5189 if (!isNaN(aResult['H']) || !isNaN(aResult['G'])) { 5190 const bPM = (aResult['T'] || aResult['TT'] || 'am').toUpperCase() === 'PM', 5191 h = parseInt(aResult['H'] || aResult['G'] || 0, 10); 5192 if (bPM) { 5193 aResult['HH'] = h + (h === 12 ? 0 : 12); 5194 } else { 5195 aResult['HH'] = h < 12 ? h : 0; 5196 } 5197 } else { 5198 aResult['HH'] = parseInt(aResult['HH'] || aResult['GG'] || 0, 10); 5199 } 5200 if (isNaN(aResult['SS'])) { 5201 aResult['SS'] = 0; 5202 } 5203 if (isUTC) { 5204 d.setUTCHours(aResult['HH'], aResult['MI'], aResult['SS']); 5205 } else { 5206 d.setHours(aResult['HH'], aResult['MI'], aResult['SS']); 5207 } 5208 } 5209 return d; 5210 } 5211 } 5212 return null; 5213 } 5214 }, { 5215 key: "getMonthIndex", 5216 value: function getMonthIndex(month) { 5217 const q = month.toUpperCase(); 5218 const wordMonthCut = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec']; 5219 const wordMonth = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december']; 5220 for (let i = 1; i <= 12; i++) { 5221 if (q === this._getMessage('MON_' + i).toUpperCase() || q === this._getMessage('MONTH_' + i).toUpperCase() || q === wordMonthCut[i - 1].toUpperCase() || q === wordMonth[i - 1].toUpperCase()) { 5222 return i; 5223 } 5224 } 5225 return month; 5226 } 5227 }, { 5228 key: "format", 5229 value: function format(_format, timestamp, now, utc) { 5230 /* 5231 PHP to Javascript: 5232 time() = new Date() 5233 mktime(...) = new Date(...) 5234 gmmktime(...) = new Date(Date.UTC(...)) 5235 mktime(0,0,0, 1, 1, 1970) != 0 new Date(1970,0,1).getTime() != 0 5236 gmmktime(0,0,0, 1, 1, 1970) == 0 new Date(Date.UTC(1970,0,1)).getTime() == 0 5237 date('d.m.Y H:i:s') = BX.Main.Date.format('d.m.Y H:i:s') 5238 gmdate('d.m.Y H:i:s') = BX.Main.Date.format('d.m.Y H:i:s', null, null, true); 5239 */ 5240 const date = main_core.Type.isDate(timestamp) ? new Date(timestamp.getTime()) : main_core.Type.isNumber(timestamp) ? new Date(timestamp * 1000) : new Date(); 5241 const nowDate = main_core.Type.isDate(now) ? new Date(now.getTime()) : main_core.Type.isNumber(now) ? new Date(now * 1000) : new Date(); 5242 const isUTC = !!utc; 5243 // used in hoisting inner functions, like _formatDateInterval 5244 const thisDateTimeFormat = this; 5245 if (main_core.Type.isArray(_format)) { 5246 return _formatDateInterval(_format, date, nowDate, isUTC); 5247 } else { 5248 if (!main_core.Type.isStringFilled(_format)) { 5249 return ''; 5250 } 5251 } 5252 const replaceMap = (_format.match(/{{([^{}]*)}}/g) || []).map(x => { 5253 return (x.match(/[^{}]+/) || [''])[0]; 5254 }); 5255 if (replaceMap.length > 0) {
5256 replaceMap.forEach((element, index) => { 5257 _format = _format.replace('{{' + element + '}}', '{{' + index + '}}'); 5258 }); 5259 } 5260 const formatRegex = /\\?(sago|iago|isago|Hago|dago|mago|Yago|sdiff|idiff|Hdiff|ddiff|mdiff|Ydiff|sshort|ishort|Hshort|dshort|mhort|Yshort|yesterday|today|tommorow|tomorrow|[a-z])/gi; 5261 const dateFormats = { 5262 d: () => { 5263 // Day of the month 01 to 31 5264 return getDate(date).toString().padStart(2, '0'); 5265 }, 5266 D: () => { 5267 //Mon through Sun 5268 return this._getMessage('DOW_' + getDay(date)); 5269 }, 5270 j: () => { 5271 //Day of the month 1 to 31 5272 return getDate(date); 5273 }, 5274 l: () => { 5275 //Sunday through Saturday 5276 return this._getMessage('DAY_OF_WEEK_' + getDay(date)); 5277 }, 5278 N: () => { 5279 //1 (for Monday) through 7 (for Sunday) 5280 return getDay(date) || 7; 5281 }, 5282 S: () => { 5283 //st, nd, rd or th. Works well with j 5284 if (getDate(date) % 10 == 1 && getDate(date) != 11) { 5285 return 'st'; 5286 } else if (getDate(date) % 10 == 2 && getDate(date) != 12) { 5287 return 'nd'; 5288 } else if (getDate(date) % 10 == 3 && getDate(date) != 13) { 5289 return 'rd'; 5290 } else { 5291 return 'th'; 5292 } 5293 }, 5294 w: () => { 5295 //0 (for Sunday) through 6 (for Saturday) 5296 return getDay(date); 5297 }, 5298 z: () => { 5299 //0 through 365 5300 const firstDay = new Date(getFullYear(date), 0, 1); 5301 const currentDay = new Date(getFullYear(date), getMonth(date), getDate(date)); 5302 return Math.ceil((currentDay - firstDay) / (24 * 3600 * 1000)); 5303 }, 5304 W: () => { 5305 //ISO-8601 week number of year 5306 const newDate = new Date(date.getTime()); 5307 const dayNumber = (getDay(date) + 6) % 7; 5308 setDate(newDate, getDate(newDate) - dayNumber + 3); 5309 const firstThursday = newDate.getTime(); 5310 setMonth(newDate, 0, 1); 5311 if (getDay(newDate) != 4) { 5312 setMonth(newDate, 0, 1 + (4 - getDay(newDate) + 7) % 7); 5313 } 5314 const weekNumber = 1 + Math.ceil((firstThursday - newDate) / (7 * 24 * 3600 * 1000)); 5315 return weekNumber.toString().padStart(2, '0'); 5316 }, 5317 F: () => { 5318 //January through December 5319 return this._getMessage('MONTH_' + (getMonth(date) + 1) + '_S'); 5320 }, 5321 f: () => { 5322 //January through December 5323 return this._getMessage('MONTH_' + (getMonth(date) + 1)); 5324 }, 5325 m: () => { 5326 //Numeric representation of a month 01 through 12 5327 return (getMonth(date) + 1).toString().padStart(2, '0'); 5328 }, 5329 M: () => { 5330 //A short textual representation of a month, three letters Jan through Dec 5331 return this._getMessage('MON_' + (getMonth(date) + 1)); 5332 }, 5333 n: () => { 5334 //Numeric representation of a month 1 through 12 5335 return getMonth(date) + 1; 5336 }, 5337 t: () => { 5338 //Number of days in the given month 28 through 31 5339 const lastMonthDay = isUTC ? new Date(Date.UTC(getFullYear(date), getMonth(date) + 1, 0)) : new Date(getFullYear(date), getMonth(date) + 1, 0); 5340 return getDate(lastMonthDay); 5341 }, 5342 L: () => { 5343 //1 if it is a leap year, 0 otherwise. 5344 const year = getFullYear(date); 5345 return year % 4 == 0 && year % 100 != 0 || year % 400 == 0 ? 1 : 0; 5346 }, 5347 o: () => { 5348 //ISO-8601 year number 5349 const correctDate = new Date(date.getTime()); 5350 setDate(correctDate, getDate(correctDate) - (getDay(date) + 6) % 7 + 3); 5351 return getFullYear(correctDate); 5352 }, 5353 Y: () => { 5354 //A full numeric representation of a year, 4 digits 5355 return getFullYear(date); 5356 }, 5357 y: () => { 5358 //A two digit representation of a year 5359 return getFullYear(date).toString().slice(2); 5360 }, 5361 a: () => { 5362 //am or pm 5363 return getHours(date) > 11 ? 'pm' : 'am'; 5364 }, 5365 A: () => { 5366 //AM or PM 5367 return getHours(date) > 11 ? 'PM' : 'AM'; 5368 }, 5369 B: () => { 5370 //000 through 999 5371 const swatch = (date.getUTCHours() + 1) % 24 + date.getUTCMinutes() / 60 + date.getUTCSeconds() / 3600; 5372 return Math.floor(swatch * 1000 / 24).toString().padStart(3, '0'); 5373 }, 5374 g: () => { 5375 //12-hour format of an hour without leading zeros 1 through 12 5376 return getHours(date) % 12 || 12; 5377 }, 5378 G: () => { 5379 //24-hour format of an hour without leading zeros 0 through 23 5380 return getHours(date); 5381 }, 5382 h: () => { 5383 //12-hour format of an hour with leading zeros 01 through 12 5384 return (getHours(date) % 12 || 12).toString().padStart(2, '0'); 5385 }, 5386 H: () => { 5387 //24-hour format of an hour with leading zeros 00 through 23 5388 return getHours(date).toString().padStart(2, '0'); 5389 }, 5390 i: () => { 5391 //Minutes with leading zeros 00 to 59 5392 return getMinutes(date).toString().padStart(2, '0'); 5393 }, 5394 s: () => { 5395 //Seconds, with leading zeros 00 through 59 5396 return getSeconds(date).toString().padStart(2, '0'); 5397 }, 5398 u: () => { 5399 //Microseconds 5400 return (getMilliseconds(date) * 1000).toString().padStart(6, '0'); 5401 }, 5402 e: () => { 5403 if (isUTC) { 5404 return 'UTC'; 5405 } 5406 return ''; 5407 }, 5408 I: () => { 5409 if (isUTC) { 5410 return 0; 5411 } 5412 5413 //Whether or not the date is in daylight saving time 1 if Daylight Saving Time, 0 otherwise 5414 const firstJanuary = new Date(getFullYear(date), 0, 1); 5415 const firstJanuaryUTC = Date.UTC(getFullYear(date), 0, 1); 5416 const firstJuly = new Date(getFullYear(date), 6, 0); 5417 const firstJulyUTC = Date.UTC(getFullYear(date), 6, 0); 5418 return 0 + (firstJanuary - firstJanuaryUTC !== firstJuly - firstJulyUTC); 5419 }, 5420 O: () => { 5421 if (isUTC) { 5422 return '+0000'; 5423 } 5424 5425 //Difference to Greenwich time (GMT) in hours +0200 5426 const timezoneOffset = date.getTimezoneOffset(); 5427 const timezoneOffsetAbs = Math.abs(timezoneOffset); 5428 return (timezoneOffset > 0 ? '-' : '+') + (Math.floor(timezoneOffsetAbs / 60) * 100 + timezoneOffsetAbs % 60).toString().padStart(4, '0'); 5429 }, 5430 //this method references 'O' method of the same object, arrow function is not suitable here 5431 P: function () { 5432 if (isUTC) { 5433 return '+00:00'; 5434 } 5435 5436 //Difference to Greenwich time (GMT) with colon between hours and minutes +02:00 5437 const difference = this.O(); 5438 return difference.substr(0, 3) + ':' + difference.substr(3); 5439 }, 5440 Z: () => { 5441 if (isUTC) { 5442 return 0; 5443 } 5444 //Timezone offset in seconds. The offset for timezones west of UTC is always negative, 5445 //and for those east of UTC is always positive. 5446 return -date.getTimezoneOffset() * 60; 5447 }, 5448 c: () => { 5449 //ISO 8601 date 5450 return 'Y-m-d\\TH:i:sP'.replace(formatRegex, _replaceDateFormat); 5451 }, 5452 r: () => { 5453 //RFC 2822 formatted date 5454 return 'D, d M Y H:i:s O'.replace(formatRegex, _replaceDateFormat); 5455 }, 5456 U: () => { 5457 //Seconds since the Unix Epoch 5458 return Math.floor(date.getTime() / 1000); 5459 }, 5460 sago: () => { 5461 return _formatDateMessage(intval((nowDate - date) / 1000), { 5462 '0': 'FD_SECOND_AGO_0', 5463 '1': 'FD_SECOND_AGO_1', 5464 '10_20': 'FD_SECOND_AGO_10_20', 5465 'MOD_1': 'FD_SECOND_AGO_MOD_1', 5466 'MOD_2_4': 'FD_SECOND_AGO_MOD_2_4', 5467 'MOD_OTHER': 'FD_SECOND_AGO_MOD_OTHER' 5468 }); 5469 }, 5470 sdiff: () => { 5471 return _formatDateMessage(intval((nowDate - date) / 1000), { 5472 '0': 'FD_SECOND_DIFF_0', 5473 '1': 'FD_SECOND_DIFF_1', 5474 '10_20': 'FD_SECOND_DIFF_10_20', 5475 'MOD_1': 'FD_SECOND_DIFF_MOD_1', 5476 'MOD_2_4': 'FD_SECOND_DIFF_MOD_2_4', 5477 'MOD_OTHER': 'FD_SECOND_DIFF_MOD_OTHER' 5478 }); 5479 },
5480 sshort: () => { 5481 return this._getMessage('FD_SECOND_SHORT').replace(/#VALUE#/g, intval((nowDate - date) / 1000)); 5482 }, 5483 iago: () => { 5484 return _formatDateMessage(intval((nowDate - date) / 60 / 1000), { 5485 '0': 'FD_MINUTE_AGO_0', 5486 '1': 'FD_MINUTE_AGO_1', 5487 '10_20': 'FD_MINUTE_AGO_10_20', 5488 'MOD_1': 'FD_MINUTE_AGO_MOD_1', 5489 'MOD_2_4': 'FD_MINUTE_AGO_MOD_2_4', 5490 'MOD_OTHER': 'FD_MINUTE_AGO_MOD_OTHER' 5491 }); 5492 }, 5493 idiff: () => { 5494 return _formatDateMessage(intval((nowDate - date) / 60 / 1000), { 5495 '0': 'FD_MINUTE_DIFF_0', 5496 '1': 'FD_MINUTE_DIFF_1', 5497 '10_20': 'FD_MINUTE_DIFF_10_20', 5498 'MOD_1': 'FD_MINUTE_DIFF_MOD_1', 5499 'MOD_2_4': 'FD_MINUTE_DIFF_MOD_2_4', 5500 'MOD_OTHER': 'FD_MINUTE_DIFF_MOD_OTHER' 5501 }); 5502 }, 5503 isago: () => { 5504 const minutesAgo = intval((nowDate - date) / 60 / 1000); 5505 let result = _formatDateMessage(minutesAgo, { 5506 '0': 'FD_MINUTE_0', 5507 '1': 'FD_MINUTE_1', 5508 '10_20': 'FD_MINUTE_10_20', 5509 'MOD_1': 'FD_MINUTE_MOD_1', 5510 'MOD_2_4': 'FD_MINUTE_MOD_2_4', 5511 'MOD_OTHER': 'FD_MINUTE_MOD_OTHER' 5512 }); 5513 result += ' '; 5514 const secondsAgo = intval((nowDate - date) / 1000) - minutesAgo * 60; 5515 result += _formatDateMessage(secondsAgo, { 5516 '0': 'FD_SECOND_AGO_0', 5517 '1': 'FD_SECOND_AGO_1', 5518 '10_20': 'FD_SECOND_AGO_10_20', 5519 'MOD_1': 'FD_SECOND_AGO_MOD_1', 5520 'MOD_2_4': 'FD_SECOND_AGO_MOD_2_4', 5521 'MOD_OTHER': 'FD_SECOND_AGO_MOD_OTHER' 5522 }); 5523 return result; 5524 }, 5525 ishort: () => { 5526 return this._getMessage('FD_MINUTE_SHORT').replace(/#VALUE#/g, intval((nowDate - date) / 60 / 1000)); 5527 }, 5528 Hago: () => { 5529 return _formatDateMessage(intval((nowDate - date) / 60 / 60 / 1000), { 5530 '0': 'FD_HOUR_AGO_0', 5531 '1': 'FD_HOUR_AGO_1', 5532 '10_20': 'FD_HOUR_AGO_10_20', 5533 'MOD_1': 'FD_HOUR_AGO_MOD_1', 5534 'MOD_2_4': 'FD_HOUR_AGO_MOD_2_4', 5535 'MOD_OTHER': 'FD_HOUR_AGO_MOD_OTHER' 5536 }); 5537 }, 5538 Hdiff: () => { 5539 return _formatDateMessage(intval((nowDate - date) / 60 / 60 / 1000), { 5540 '0': 'FD_HOUR_DIFF_0', 5541 '1': 'FD_HOUR_DIFF_1', 5542 '10_20': 'FD_HOUR_DIFF_10_20', 5543 'MOD_1': 'FD_HOUR_DIFF_MOD_1', 5544 'MOD_2_4': 'FD_HOUR_DIFF_MOD_2_4', 5545 'MOD_OTHER': 'FD_HOUR_DIFF_MOD_OTHER' 5546 }); 5547 }, 5548 Hshort: () => { 5549 return this._getMessage('FD_HOUR_SHORT').replace(/#VALUE#/g, intval((nowDate - date) / 60 / 60 / 1000)); 5550 }, 5551 yesterday: () => { 5552 return this._getMessage('FD_YESTERDAY'); 5553 }, 5554 today: () => { 5555 return this._getMessage('FD_TODAY'); 5556 }, 5557 tommorow: () => { 5558 return this._getMessage('FD_TOMORROW'); 5559 }, 5560 tomorrow: () => { 5561 return this._getMessage('FD_TOMORROW'); 5562 }, 5563 dago: () => { 5564 return _formatDateMessage(intval((nowDate - date) / 60 / 60 / 24 / 1000), { 5565 '0': 'FD_DAY_AGO_0', 5566 '1': 'FD_DAY_AGO_1', 5567 '10_20': 'FD_DAY_AGO_10_20', 5568 'MOD_1': 'FD_DAY_AGO_MOD_1', 5569 'MOD_2_4': 'FD_DAY_AGO_MOD_2_4', 5570 'MOD_OTHER': 'FD_DAY_AGO_MOD_OTHER' 5571 }); 5572 }, 5573 ddiff: () => { 5574 return _formatDateMessage(intval((nowDate - date) / 60 / 60 / 24 / 1000), { 5575 '0': 'FD_DAY_DIFF_0', 5576 '1': 'FD_DAY_DIFF_1', 5577 '10_20': 'FD_DAY_DIFF_10_20', 5578 'MOD_1': 'FD_DAY_DIFF_MOD_1', 5579 'MOD_2_4': 'FD_DAY_DIFF_MOD_2_4', 5580 'MOD_OTHER': 'FD_DAY_DIFF_MOD_OTHER' 5581 }); 5582 }, 5583 dshort: () => { 5584 return this._getMessage('FD_DAY_SHORT').replace(/#VALUE#/g, intval((nowDate - date) / 60 / 60 / 24 / 1000)); 5585 }, 5586 mago: () => { 5587 return _formatDateMessage(intval((nowDate - date) / 60 / 60 / 24 / 31 / 1000), { 5588 '0': 'FD_MONTH_AGO_0', 5589 '1': 'FD_MONTH_AGO_1', 5590 '10_20': 'FD_MONTH_AGO_10_20', 5591 'MOD_1': 'FD_MONTH_AGO_MOD_1', 5592 'MOD_2_4': 'FD_MONTH_AGO_MOD_2_4', 5593 'MOD_OTHER': 'FD_MONTH_AGO_MOD_OTHER' 5594 }); 5595 }, 5596 mdiff: () => { 5597 return _formatDateMessage(intval((nowDate - date) / 60 / 60 / 24 / 31 / 1000), { 5598 '0': 'FD_MONTH_DIFF_0', 5599 '1': 'FD_MONTH_DIFF_1', 5600 '10_20': 'FD_MONTH_DIFF_10_20', 5601 'MOD_1': 'FD_MONTH_DIFF_MOD_1', 5602 'MOD_2_4': 'FD_MONTH_DIFF_MOD_2_4', 5603 'MOD_OTHER': 'FD_MONTH_DIFF_MOD_OTHER' 5604 }); 5605 }, 5606 mshort: () => { 5607 return this._getMessage('FD_MONTH_SHORT').replace(/#VALUE#/g, intval((nowDate - date) / 60 / 60 / 24 / 31 / 1000)); 5608 }, 5609 Yago: () => { 5610 return _formatDateMessage(intval((nowDate - date) / 60 / 60 / 24 / 365 / 1000), { 5611 '0': 'FD_YEARS_AGO_0', 5612 '1': 'FD_YEARS_AGO_1', 5613 '10_20': 'FD_YEARS_AGO_10_20', 5614 'MOD_1': 'FD_YEARS_AGO_MOD_1', 5615 'MOD_2_4': 'FD_YEARS_AGO_MOD_2_4', 5616 'MOD_OTHER': 'FD_YEARS_AGO_MOD_OTHER' 5617 }); 5618 }, 5619 Ydiff: () => { 5620 return _formatDateMessage(intval((nowDate - date) / 60 / 60 / 24 / 365 / 1000), { 5621 '0': 'FD_YEARS_DIFF_0', 5622 '1': 'FD_YEARS_DIFF_1', 5623 '10_20': 'FD_YEARS_DIFF_10_20', 5624 'MOD_1': 'FD_YEARS_DIFF_MOD_1', 5625 'MOD_2_4': 'FD_YEARS_DIFF_MOD_2_4', 5626 'MOD_OTHER': 'FD_YEARS_DIFF_MOD_OTHER' 5627 }); 5628 }, 5629 Yshort: () => { 5630 return _formatDateMessage(intval((nowDate - date) / 60 / 60 / 24 / 365 / 1000), { 5631 '0': 'FD_YEARS_SHORT_0', 5632 '1': 'FD_YEARS_SHORT_1', 5633 '10_20': 'FD_YEARS_SHORT_10_20', 5634 'MOD_1': 'FD_YEARS_SHORT_MOD_1', 5635 'MOD_2_4': 'FD_YEARS_SHORT_MOD_2_4', 5636 'MOD_OTHER': 'FD_YEARS_SHORT_MOD_OTHER' 5637 }); 5638 }, 5639 x: () => { 5640 const ampm = this.isAmPmMode(true); 5641 const timeFormat = ampm === this.AM_PM_MODE.LOWER ? 'g:i a' : ampm === this.AM_PM_MODE.UPPER ? 'g:i A' : 'H:i'; 5642 return this.format([['tomorrow', 'tomorrow, ' + timeFormat], ['-', this.convertBitrixFormat(this._getMessage('FORMAT_DATETIME')).replace(/:s/g, '')], ['
5642s', 'sago'], ['i', 'iago'], ['today', 'today, ' + timeFormat], ['yesterday', 'yesterday, ' + timeFormat], ['', this.convertBitrixFormat(this._getMessage('FORMAT_DATETIME')).replace(/:s/g, '')]], date, nowDate, isUTC); 5643 }, 5644 X: () => { 5645 const ampm = this.isAmPmMode(true); 5646 const timeFormat = ampm === this.AM_PM_MODE.LOWER ? 'g:i a' : ampm === this.AM_PM_MODE.UPPER ? 'g:i A' : 'H:i'; 5647 const day = this.format([['tomorrow', 'tomorrow'], ['-', this.convertBitrixFormat(this._getMessage('FORMAT_DATE'))], ['today', 'today'], ['yesterday', 'yesterday'], ['', this.convertBitrixFormat(this._getMessage('FORMAT_DATE'))]], date, nowDate, isUTC); 5648 const time = this.format([['tomorrow', timeFormat], ['today', timeFormat], ['yesterday', timeFormat], ['', '']], date, nowDate, isUTC); 5649 if (time.length > 0) { 5650 return this._getMessage('FD_DAY_AT_TIME').replace(/#DAY#/g, day).replace(/#TIME#/g, time); 5651 } else { 5652 return day; 5653 } 5654 }, 5655 Q: () => { 5656 const daysAgo = intval((nowDate - date) / 60 / 60 / 24 / 1000); 5657 if (daysAgo == 0) { 5658 return this._getMessage('FD_DAY_DIFF_1').replace(/#VALUE#/g, 1); 5659 } else { 5660 return this.format([['d', 'ddiff'], ['m', 'mdiff'], ['', 'Ydiff']], date, nowDate); 5661 } 5662 } 5663 }; 5664 let cutZeroTime = false; 5665 if (_format[0] && _format[0] == '^') { 5666 cutZeroTime = true; 5667 _format = _format.substr(1); 5668 } 5669 let result = _format.replace(formatRegex, _replaceDateFormat); 5670 if (cutZeroTime) { 5671 /* 15.04.12 13:00:00 => 15.04.12 13:00 5672 00:01:00 => 00:01 5673 4 may 00:00:00 => 4 may 5674 01-01-12 00:00 => 01-01-12 5675 */ 5676 5677 result = result.replace(/\s*00:00:00\s*/g, '').replace(/(\d\d:\d\d)(:00)/g, '$1').replace(/(\s*00:00\s*)(?!:)/g, ''); 5678 } 5679 if (replaceMap.length > 0) { 5680 replaceMap.forEach(function (element, index) { 5681 result = result.replace('{{' + index + '}}', element); 5682 }); 5683 } 5684 return result; 5685 function _formatDateInterval(formats, date, nowDate, isUTC) { 5686 const secondsAgo = intval((nowDate - date) / 1000); 5687 for (let i = 0; i < formats.length; i++) { 5688 const formatInterval = formats[i][0]; 5689 const formatValue = formats[i][1]; 5690 let match = null; 5691 if (formatInterval == 's') { 5692 if (secondsAgo < 60) { 5693 return thisDateTimeFormat.format(formatValue, date, nowDate, isUTC); 5694 } 5695 } else if ((match = /^s(\d+)\>?(\d+)?/.exec(formatInterval)) != null) { 5696 if (match[1] && match[2]) { 5697 if (secondsAgo < match[1] && secondsAgo > match[2]) { 5698 return thisDateTimeFormat.format(formatValue, date, nowDate, isUTC); 5699 } 5700 } else if (secondsAgo < match[1]) { 5701 return thisDateTimeFormat.format(formatValue, date, nowDate, isUTC); 5702 } 5703 } else if (formatInterval == 'i') { 5704 if (secondsAgo < 60 * 60) { 5705 return thisDateTimeFormat.format(formatValue, date, nowDate, isUTC); 5706 } 5707 } else if ((match = /^i(\d+)\>?(\d+)?/.exec(formatInterval)) != null) { 5708 if (match[1] && match[2]) { 5709 if (secondsAgo < match[1] * 60 && secondsAgo > match[2] * 60) { 5710 return thisDateTimeFormat.format(formatValue, date, nowDate, isUTC); 5711 } 5712 } else if (secondsAgo < match[1] * 60) { 5713 return thisDateTimeFormat.format(formatValue, date, nowDate, isUTC); 5714 } 5715 } else if (formatInterval == 'H') { 5716 if (secondsAgo < 24 * 60 * 60) { 5717 return thisDateTimeFormat.format(formatValue, date, nowDate, isUTC); 5718 } 5719 } else if ((match = /^H(\d+)\>?(\d+)?/.exec(formatInterval)) != null) { 5720 if (match[1] && match[2]) { 5721 if (secondsAgo < match[1] * 60 * 60 && secondsAgo > match[2] * 60 * 60) { 5722 return thisDateTimeFormat.format(formatValue, date, nowDate, isUTC); 5723 } 5724 } else if (secondsAgo < match[1] * 60 * 60) { 5725 return thisDateTimeFormat.format(formatValue, date, nowDate, isUTC); 5726 } 5727 } else if (formatInterval == 'd') { 5728 if (secondsAgo < 31 * 24 * 60 * 60) { 5729 return thisDateTimeFormat.format(formatValue, date, nowDate, isUTC); 5730 } 5731 } else if ((match = /^d(\d+)\>?(\d+)?/.exec(formatInterval)) != null) { 5732 if (match[1] && match[2]) { 5733 if (secondsAgo < match[1] * 24 * 60 * 60 && secondsAgo > match[2] * 24 * 60 * 60) { 5734 return thisDateTimeFormat.format(formatValue, date, nowDate, isUTC); 5735 } 5736 } else if (secondsAgo < match[1] * 24 * 60 * 60) { 5737 return thisDateTimeFormat.format(formatValue, date, nowDate, isUTC); 5738 } 5739 } else if (formatInterval == 'm') { 5740 if (secondsAgo < 365 * 24 * 60 * 60) { 5741 return thisDateTimeFormat.format(formatValue, date, nowDate, isUTC); 5742 } 5743 } else if ((match = /^m(\d+)\>?(\d+)?/.exec(formatInterval)) != null) { 5744 if (match[1] && match[2]) { 5745 if (secondsAgo < match[1] * 31 * 24 * 60 * 60 && secondsAgo > match[2] * 31 * 24 * 60 * 60) { 5746 return thisDateTimeFormat.format(formatValue, date, nowDate, isUTC); 5747 } 5748 } else if (secondsAgo < match[1] * 31 * 24 * 60 * 60) { 5749 return thisDateTimeFormat.format(formatValue, date, nowDate, isUTC); 5750 } 5751 } else if (formatInterval == 'now') { 5752 if (date.getTime() == nowDate.getTime()) { 5753 return thisDateTimeFormat.format(formatValue, date, nowDate, isUTC); 5754 } 5755 } else if (formatInterval == 'today') { 5756 const year = getFullYear(nowDate);
5757 const month = getMonth(nowDate); 5758 const day = getDate(nowDate); 5759 const todayStart = isUTC ? new Date(Date.UTC(year, month, day, 0, 0, 0, 0)) : new Date(year, month, day, 0, 0, 0, 0); 5760 const todayEnd = isUTC ? new Date(Date.UTC(year, month, day + 1, 0, 0, 0, 0)) : new Date(year, month, day + 1, 0, 0, 0, 0); 5761 if (date >= todayStart && date < todayEnd) { 5762 return thisDateTimeFormat.format(formatValue, date, nowDate, isUTC); 5763 } 5764 } else if (formatInterval == 'todayFuture') { 5765 const year = getFullYear(nowDate); 5766 const month = getMonth(nowDate); 5767 const day = getDate(nowDate); 5768 const todayStart = nowDate.getTime(); 5769 const todayEnd = isUTC ? new Date(Date.UTC(year, month, day + 1, 0, 0, 0, 0)) : new Date(year, month, day + 1, 0, 0, 0, 0); 5770 if (date >= todayStart && date < todayEnd) { 5771 return thisDateTimeFormat.format(formatValue, date, nowDate, isUTC); 5772 } 5773 } else if (formatInterval == 'yesterday') { 5774 const year = getFullYear(nowDate);
5775 const month = getMonth(nowDate); 5776 const day = getDate(nowDate); 5777 const yesterdayStart = isUTC ? new Date(Date.UTC(year, month, day - 1, 0, 0, 0, 0)) : new Date(year, month, day - 1, 0, 0, 0, 0); 5778 const yesterdayEnd = isUTC ? new Date(Date.UTC(year, month, day, 0, 0, 0, 0)) : new Date(year, month, day, 0, 0, 0, 0); 5779 if (date >= yesterdayStart && date < yesterdayEnd) { 5780 return thisDateTimeFormat.format(formatValue, date, nowDate, isUTC); 5781 } 5782 } else if (formatInterval == 'tommorow' || formatInterval == 'tomorrow') { 5783 const year = getFullYear(nowDate); 5784 const month = getMonth(nowDate); 5785 const day = getDate(nowDate); 5786 const tomorrowStart = isUTC ? new Date(Date.UTC(year, month, day + 1, 0, 0, 0, 0)) : new Date(year, month, day + 1, 0, 0, 0, 0); 5787 const tomorrowEnd = isUTC ? new Date(Date.UTC(year, month, day + 2, 0, 0, 0, 0)) : new Date(year, month, day + 2, 0, 0, 0, 0); 5788 if (date >= tomorrowStart && date < tomorrowEnd) { 5789 return thisDateTimeFormat.format(formatValue, date, nowDate, isUTC); 5790 } 5791 } else if (formatInterval == '-') { 5792 if (secondsAgo < 0) { 5793 return thisDateTimeFormat.format(formatValue, date, nowDate, isUTC); 5794 } 5795 } 5796 } 5797 5798 //return formats.length > 0 ? thisDateTimeFormat.format(formats.pop()[1], date, nowDate, isUTC) : ''; 5799 return formats.length > 0 ? thisDateTimeFormat.format(formats[formats.length - 1][1], date, nowDate, isUTC) : ''; 5800 } 5801 function getFullYear(date) { 5802 return isUTC ? date.getUTCFullYear() : date.getFullYear(); 5803 } 5804 function getDate(date) { 5805 return isUTC ? date.getUTCDate() : date.getDate(); 5806 } 5807 function getMonth(date) { 5808 return isUTC ? date.getUTCMonth() : date.getMonth(); 5809 } 5810 function getHours(date) { 5811 return isUTC ? date.getUTCHours() : date.getHours(); 5812 } 5813 function getMinutes(date) { 5814 return isUTC ? date.getUTCMinutes() : date.getMinutes(); 5815 } 5816 function getSeconds(date) { 5817 return isUTC ? date.getUTCSeconds() : date.getSeconds(); 5818 } 5819 function getMilliseconds(date) { 5820 return isUTC ? date.getUTCMilliseconds() : date.getMilliseconds(); 5821 } 5822 function getDay(date) { 5823 return isUTC ? date.getUTCDay() : date.getDay(); 5824 } 5825 function setDate(date, dayValue) { 5826 return isUTC ? date.setUTCDate(dayValue) : date.setDate(dayValue); 5827 } 5828 function setMonth(date, monthValue, dayValue) { 5829 return isUTC ? date.setUTCMonth(monthValue, dayValue) : date.setMonth(monthValue, dayValue); 5830 } 5831 function _formatDateMessage(value, messages) { 5832 const val = value < 100 ? Math.abs(value) : Math.abs(value % 100); 5833 const dec = val % 10; 5834 let message = ''; 5835 if (val == 0) { 5836 message = thisDateTimeFormat._getMessage(messages['0']); 5837 } else if (val == 1) { 5838 message = thisDateTimeFormat._getMessage(messages['1']); 5839 } else if (val >= 10 && val <= 20) { 5840 message = thisDateTimeFormat._getMessage(messages['10_20']); 5841 } else if (dec == 1) { 5842 message = thisDateTimeFormat._getMessage(messages['MOD_1']); 5843 } else if (2 <= dec && dec <= 4) { 5844 message = thisDateTimeFormat._getMessage(messages['MOD_2_4']); 5845 } else { 5846 message = thisDateTimeFormat._getMessage(messages['MOD_OTHER']); 5847 } 5848 return message.replace(/#VALUE#/g, value); 5849 } 5850 function _replaceDateFormat(match, matchFull) { 5851 if (dateFormats[match]) { 5852 return dateFormats[match](); 5853 } else { 5854 return matchFull; 5855 } 5856 } 5857 function intval(number) { 5858 return number >= 0 ? Math.floor(number) : Math.ceil(number); 5859 } 5860 } 5861 }]); 5862 return DateTimeFormat; 5863 }(); 5864 babelHelpers.defineProperty(DateTimeFormat, "AM_PM_MODE", { 5865 UPPER: 1, 5866 LOWER: 2, 5867 NONE: false 5868 }); 5869 babelHelpers.defineProperty(DateTimeFormat, "convertBitrixFormat", convertBitrixFormat); 5870 babelHelpers.defineProperty(DateTimeFormat, "getFormat", getFormat); 5871 5872 const cache = new main_core.Cache.MemoryCache(); 5873 5874 /** 5875 * @memberOf BX.Main.Timezone 5876 * 5877 * WARNING! Don't use this class or any classes from Timezone namespace on sites without Bitrix Framework. 5878 * It is not designed to handle this case and will definitely break. 5879 */ 5880 const Offset = { 5881 get SERVER_TO_UTC() { 5882 return cache.remember('SERVER_TO_UTC', () => { 5883 return main_core.Text.toInteger(main_core.Loc.getMessage('SERVER_TZ_OFFSET')); 5884 }); 5885 }, 5886 get USER_TO_SERVER() { 5887 return cache.remember('USER_TO_SERVER', () => { 5888 return main_core.Text.toInteger(main_core.Loc.getMessage('USER_TZ_OFFSET')); 5889 }); 5890 }, 5891 // Date returns timezone offset in minutes by default, change it to seconds 5892 // Also offset is negative in UTC+ timezones and positive in UTC- timezones. 5893 // By convention Bitrix uses the opposite approach, so change offset sign. 5894 get BROWSER_TO_UTC() { 5895 return cache.remember('BROWSER_TO_UTC', () => { 5896 return main_core.Text.toInteger(new Date().getTimezoneOffset() * 60); 5897 }); 5898 } 5899 }; 5900 Object.freeze(Offset); 5901 5902 function _classStaticPrivateMethodGet(receiver, classConstructor, method) { _classCheckPrivateStaticAccess(receiver, classConstructor); return method; } 5903 function _classCheckPrivateStaticAccess(receiver, classConstructor) { if (receiver !== classConstructor) { throw new TypeError("Private static access of wrong provenance"); } } 5904
5905 /** 5906 * @memberOf BX.Main.Timezone 5907 * 5908 * WARNING! Don't use this class or any classes from Timezone namespace on sites without Bitrix Framework. 5909 * It is not designed to handle this case and will definitely break. 5910 */ 5911 let BrowserTime = /*#__PURE__*/function () { 5912 function BrowserTime() { 5913 babelHelpers.classCallCheck(this, BrowserTime); 5914 } 5915 babelHelpers.createClass(BrowserTime, null, [{ 5916 key: "getTimestamp", 5917 /** 5918 * Returns timestamp with current time in browser timezone. 5919 * 5920 * @returns {number} timestamp in seconds 5921 */ 5922 value: function getTimestamp() { 5923 return Math.round(Date.now() / 1000); 5924 } 5925 /** 5926 * Returns Date object with current time in browser timezone. 5927 * 5928 * @returns {Date} 5929 */ 5930 }, { 5931 key: "getDate", 5932 value: function getDate() { 5933 return new Date(this.getTimestamp() * 1000); 5934 } 5935 /** 5936 * Converts timestamp in browser timezone to timestamp in user timezone. 5937 * 5938 * @param browserTimestamp timestamp in browser timezone in seconds 5939 * @returns {number} timestamp in user timezone in seconds 5940 */ 5941 }, { 5942 key: "toUser", 5943 value: function toUser(browserTimestamp) { 5944 return main_core.Text.toInteger(browserTimestamp) + Offset.USER_TO_SERVER; 5945 } 5946 /** 5947 * Converts timestamp in browser timezone to timestamp in server timezone. 5948 * 5949 * @param browserTimestamp timestamp in browser timezone in seconds 5950 * @returns {number} timestamp in server timezone in seconds 5951 */ 5952 }, { 5953 key: "toServer", 5954 value: function toServer(browserTimestamp) { 5955 return _classStaticPrivateMethodGet(this, BrowserTime, _toUTC).call(this, browserTimestamp) + Offset.SERVER_TO_UTC; 5956 } 5957 }]); 5958 return BrowserTime; 5959 }(); 5960 function _toUTC(browserTimestamp) { 5961 return main_core.Text.toInteger(browserTimestamp) - Offset.BROWSER_TO_UTC; 5962 } 5963 5964 /** 5965 * @memberOf BX.Main.Timezone 5966 * 5967 * WARNING! Don't use this class or any classes from Timezone namespace on sites without Bitrix Framework. 5968 * It is not designed to handle this case and will definitely break. 5969 * 5970 * ATTENTION! In Bitrix user timezone !== browser timezone. Users can change their timezone from their profile settings 5971 * and the timezone will be different from browser timezone. 5972 */ 5973 let UserTime = /*#__PURE__*/function () { 5974 function UserTime() { 5975 babelHelpers.classCallCheck(this, UserTime); 5976 } 5977 babelHelpers.createClass(UserTime, null, [{ 5978 key: "getTimestamp", 5979 /** 5980 * Returns timestamp with current time in user timezone. 5981 * 5982 * @returns {number} timestamp in seconds 5983 */ 5984 value: function getTimestamp() { 5985 return BrowserTime.toUser(BrowserTime.getTimestamp()); 5986 } 5987 /** 5988 * Returns Date object with current time in user timezone. If you need to get 'now' in a user's perspective, 5989 * use this method instead of 'new Date()'. 5990 * 5991 * Note that 'getTimezoneOffset' will not return correct user timezone, its always returns browser offset 5992 * 5993 * @returns {Date} 5994 */ 5995 }, { 5996 key: "getDate", 5997 value: function getDate() { 5998 return new Date(this.getTimestamp() * 1000); 5999 } 6000 /** 6001 * Converts timestamp in user timezone to timestamp in browser timezone. 6002 * 6003 * @param userTimestamp timestamp in user timezone in seconds 6004 * @returns {number} timestamp in browser timezone in seconds 6005 */ 6006 }, { 6007 key: "toBrowser", 6008 value: function toBrowser(userTimestamp) { 6009 return main_core.Text.toInteger(userTimestamp) + Offset.BROWSER_TO_UTC - Offset.SERVER_TO_UTC - Offset.USER_TO_SERVER; 6010 } 6011 /** 6012 * Converts timestamp in user timezone to timestamp in server timezone. 6013 * 6014 * @param userTimestamp timestamp in user timezone in seconds 6015 * @returns {number} timestamp in server timezone in seconds 6016 */ 6017 }, { 6018 key: "toServer", 6019 value: function toServer(userTimestamp) { 6020 return main_core.Text.toInteger(userTimestamp) - Offset.USER_TO_SERVER; 6021 } 6022 }]); 6023 return UserTime; 6024 }(); 6025 6026 /** 6027 * @memberOf BX.Main.Timezone 6028 * 6029 * WARNING! Don't use this class or any classes from Timezone namespace on sites without Bitrix Framework. 6030 * It is not designed to handle this case and will definitely break. 6031 */ 6032 let ServerTime = /*#__PURE__*/function () { 6033 function ServerTime() { 6034 babelHelpers.classCallCheck(this, ServerTime); 6035 } 6036 babelHelpers.createClass(ServerTime, null, [{ 6037 key: "getTimestamp", 6038 /** 6039 * Returns timestamp with current time in server timezone. 6040 * 6041 * @returns {number} timestamp in seconds 6042 */ 6043 value: function getTimestamp() { 6044 return BrowserTime.toServer(BrowserTime.getTimestamp()); 6045 } 6046 /** 6047 * Returns Date object with current time in server timezone. 6048 * 6049 * Note that 'getTimezoneOffset' will not return correct server timezone, its always returns browser offset 6050 * 6051 * @returns {Date} 6052 */ 6053 }, { 6054 key: "getDate", 6055 value: function getDate() { 6056 return new Date(this.getTimestamp() * 1000); 6057 } 6058 /** 6059 * Converts timestamp in server timezone to timestamp in user timezone. 6060 * 6061 * @param serverTimestamp timestamp in server timezone in seconds 6062 * @returns {number} timestamp in user timezone in seconds 6063 */ 6064 }, { 6065 key: "toUser", 6066 value: function toUser(serverTimestamp) { 6067 return main_core.Text.toInteger(serverTimestamp) + Offset.USER_TO_SERVER; 6068 } 6069 /** 6070 * Converts timestamp in server timezone to timestamp in browser timezone. 6071 * 6072 * @param serverTimestamp timestamp in server timezone in seconds 6073 * @returns {number} timestamp in browser timezone in seconds 6074 */ 6075 }, { 6076 key: "toBrowser", 6077 value: function toBrowser(serverTimestamp) { 6078 return main_core.Text.toInteger(serverTimestamp) + Offset.BROWSER_TO_UTC - Offset.SERVER_TO_UTC; 6079 } 6080 }]); 6081 return ServerTime; 6082 }(); 6083 6084 //compatibility alias 6085 const Date$1 = DateTimeFormat; 6086 const Timezone = Object.freeze({ 6087 Offset, 6088 BrowserTime, 6089 UserTime, 6090 ServerTime 6091 }); 6092 6093 exports.DateTimeFormat = DateTimeFormat; 6094 exports.Date = Date$1; 6095 exports.Timezone = Timezone; 6096 6097}((this.BX.Main = this.BX.Main || {}),BX)); 6098//# sourceMappingURL=main.date.js.map 6099 6100/* End */ 6101; 6102; /* Start:"a:4:{s:4:"full";s:49:"/bitrix/js/main/core/core_date.js?163379651236080";s:6:"source";s:33:"/bitrix/js/main/core/core_date.js";s:3:"min";s:0:"";s:3:"map";s:0:"";}"*/ 6103;(function(){ 6104 6105if (BX.date) 6106 return; 6107 6108BX.date = BX.Main.Date; 6109 6110/************************************** calendar class **********************************/ 6111 6112var obCalendarSingleton = null; 6113 6114/* 6115params: { 6116 node: bind element || document.body 6117 6118 value - start value in site format (using 'field' param if 'value' does not exist) 6119 callback - date check handler. can return false to prevent calendar closing. 6120 callback_after - another handler, called after date picking 6121 6122 field - field to read/write data 6123 6124 bTime = true - whether to enable time control 6125 bHideTime = false - whether to hide time control by default 6126 6127 currentTime - current UTC time() 6128 6129} 6130*/ 6131 6132 6133BX.calendar = function(params) 6134{ 6135 return BX.calendar.get().Show(params); 6136}; 6137 6138BX.calendar.get = function() 6139{ 6140 if (!obCalendarSingleton)
6141 obCalendarSingleton = new BX.JCCalendar(); 6142 6143 return obCalendarSingleton; 6144}; 6145 6146// simple func for compatibility with the oldies 6147BX.calendar.InsertDaysBack = function(input, days) 6148{ 6149 if (days != '') 6150 { 6151 var d = new Date(); 6152 if(days > 0) 6153 { 6154 d.setTime(d.valueOf() - days*86400000); 6155 } 6156 6157 input.value = BX.date.format(BX.date.convertBitrixFormat(BX.message('FORMAT_DATE')), d, null); 6158 } 6159 else 6160 { 6161 input.value = ''; 6162 } 6163}; 6164 6165BX.calendar.ValueToString = function(value, bTime, bUTC) 6166{ 6167 return BX.date.format( 6168 BX.date.convertBitrixFormat(BX.message(bTime ? 'FORMAT_DATETIME' : 'FORMAT_DATE')), 6169 value, 6170 null, 6171 !!bUTC 6172 ); 6173}; 6174 6175BX.calendar.ValueToStringFormat = function(value, bitrixFormat, bUTC) 6176{ 6177 return BX.date.format( 6178 BX.date.convertBitrixFormat(bitrixFormat), 6179 value, 6180 null, 6181 !!bUTC 6182 ); 6183}; 6184 6185 6186BX.CalendarPeriod = 6187{ 6188 Init: function(inputFrom, inputTo, selPeriod) 6189 { 6190 if((inputFrom.value != "" || inputTo.value != "") && selPeriod.value == "") 6191 selPeriod.value = "interval"; 6192 6193 selPeriod.onchange(); 6194 }, 6195 6196 ChangeDirectOpts: function(peroidValue, selPParent) // "week" || "others" 6197 { 6198 var selDirect = BX.findChild(selPParent, {'className':'adm-select adm-calendar-direction'}, true); 6199 6200 if(peroidValue == "week") 6201 { 6202 selDirect.options[0].text = BX.message('JSADM_CALEND_PREV_WEEK'); 6203 selDirect.options[1].text = BX.message('JSADM_CALEND_CURR_WEEK'); 6204 selDirect.options[2].text = BX.message('JSADM_CALEND_NEXT_WEEK'); 6205 } 6206 else 6207 { 6208 selDirect.options[0].text = BX.message('JSADM_CALEND_PREV'); 6209 selDirect.options[1].text = BX.message('JSADM_CALEND_CURR'); 6210 selDirect.options[2].text = BX.message('JSADM_CALEND_NEXT'); 6211 } 6212 }, 6213 6214 SaveAndClearInput: function(oInput) 6215 { 6216 if(!window.SavedPeriodValues) 6217 window.SavedPeriodValues = {}; 6218 6219 window.SavedPeriodValues[oInput.id] = oInput.value; 6220 oInput.value=""; 6221 }, 6222 6223 RestoreInput: function(oInput) 6224 { 6225 if(!window.SavedPeriodValues || !window.SavedPeriodValues[oInput.id]) 6226 return; 6227 6228 oInput.value = window.SavedPeriodValues[oInput.id]; 6229 delete(window.SavedPeriodValues[oInput.id]); 6230 }, 6231 6232 OnChangeP: function(sel) 6233 { 6234 var selPParent = sel.parentNode.parentNode; 6235 var bShowFrom, bShowTo, bShowDirect, bShowSeparate; 6236 bShowFrom = bShowTo = bShowDirect = bShowSeparate = false; 6237 6238 var inputFromWrap = BX.findChild(selPParent, {'className':'adm-input-wrap adm-calendar-inp adm-calendar-first'}); 6239 var inputToWrap = BX.findChild(selPParent, {'className':'adm-input-wrap adm-calendar-second'}); 6240 var selDirectWrap = BX.findChild(selPParent, {'className':'adm-select-wrap adm-calendar-direction'}); 6241 var separator = BX.findChild(selPParent, {'className':'adm-calendar-separate'}); 6242 var inputFrom = BX.findChild(selPParent, {'className':'adm-input adm-calendar-from'},true); 6243 var inputTo = BX.findChild(selPParent, {'className':'adm-input adm-calendar-to'},true); 6244 6245 // define who must be shown 6246 switch (sel.value) 6247 { 6248 case "day": 6249 case "week": 6250 case "month": 6251 case "quarter": 6252 case "year": 6253 bShowDirect=true; 6254 BX.CalendarPeriod.OnChangeD(selDirectWrap.children[0]); 6255 break; 6256 6257 case "before": 6258 bShowTo = true; 6259 break; 6260 6261 case "after": 6262 bShowFrom = true; 6263 break; 6264 6265 case "exact": 6266 bShowFrom= true; 6267 break; 6268 6269 case "interval": 6270 bShowFrom = bShowTo = bShowSeparate = true; 6271 BX.CalendarPeriod.RestoreInput(inputFrom); 6272 BX.CalendarPeriod.RestoreInput(inputTo); 6273 6274 break; 6275 6276 case "": 6277 BX.CalendarPeriod.SaveAndClearInput(inputFrom); 6278 BX.CalendarPeriod.SaveAndClearInput(inputTo); 6279 break; 6280 6281 default: 6282 break; 6283 6284 } 6285 6286 BX.CalendarPeriod.ChangeDirectOpts(sel.value, selPParent); 6287 6288 inputFromWrap.style.display = (bShowFrom? 'inline-block':'none'); 6289 inputToWrap.style.display = (bShowTo? 'inline-block':'none'); 6290 selDirectWrap.style.display = (bShowDirect? 'inline-block':'none'); 6291 separator.style.display = (bShowSeparate? 'inline-block':'none'); 6292 }, 6293 6294 6295 OnChangeD: function(sel) 6296 { 6297 var selPParent = sel.parentNode.parentNode; 6298 var inputFrom = BX.findChild(selPParent, {'className':'adm-input adm-calendar-from'},true); 6299 var inputTo = BX.findChild(selPParent, {'className':'adm-input adm-calendar-to'},true); 6300 var selPeriod = BX.findChild(selPParent, {'className':'adm-select adm-calendar-period'},true); 6301 6302 var offset=0; 6303 6304 switch (sel.value) 6305 { 6306 case "previous": 6307 offset = -1; 6308 break; 6309 6310 case "next": 6311 offset = 1; 6312 break; 6313 6314 case "current": 6315 default: 6316 break; 6317 6318 } 6319 6320 var from = false;
6321 var to = false; 6322 6323 var today = new Date(); 6324 var year = today.getFullYear(); 6325 var month = today.getMonth(); 6326 var day = today.getDate(); 6327 var dayW = today.getDay(); 6328 6329 if (dayW == 0) 6330 dayW = 7; 6331 6332 switch (selPeriod.value) 6333 { 6334 case "day": 6335 from = new Date(year, month, day+offset, 0, 0, 0); 6336 to = new Date(year, month, day+offset, 23, 59, 59); 6337 break; 6338 6339 case "week": 6340 from = new Date(year, month, day-dayW+1+offset*7, 0, 0, 0); 6341 to = new Date(year, month, day+(7-dayW)+offset*7, 23, 59, 59); 6342 break; 6343 6344 case "month": 6345 from = new Date(year, month+offset, 1, 0, 0, 0); 6346 to = new Date(year, month+1+offset, 0, 23, 59, 59); 6347 break; 6348 6349 case "quarter": 6350 var quarterNum = Math.floor((month/3))+offset; 6351 from = new Date(year, 3*(quarterNum), 1, 0, 0, 0); 6352 to = new Date(year, 3*(quarterNum+1), 0, 23, 59, 59); 6353 break; 6354 6355 case "year": 6356 from = new Date(year+offset, 0, 1, 0, 0, 0); 6357 to = new Date(year+1+offset, 0, 0, 23, 59, 59); 6358 break; 6359 6360 default: 6361 break; 6362 } 6363 6364 var format = window[inputFrom.name+"_bTime"] ? BX.message('FORMAT_DATETIME') : BX.message('FORMAT_DATE'); 6365 6366 if(from) 6367 { 6368 inputFrom.value = BX.formatDate(from, format); 6369 BX.addClass(inputFrom,"adm-calendar-inp-setted"); 6370 } 6371 6372 if(to) 6373 { 6374 inputTo.value = BX.formatDate(to, format); 6375 BX.addClass(inputTo,"adm-calendar-inp-setted"); 6376 } 6377 } 6378}; 6379 6380 6381BX.JCCalendar = function() 6382{ 6383 this.params = {}; 6384 6385 this.bAmPm = BX.isAmPmMode(); 6386 6387 this.popup = null; 6388 this.popup_month = null; 6389 this.popup_year = null; 6390 this.month_popup_classname = ''; 6391 this.year_popup_classname = ''; 6392 this.value = null; 6393 this._layers = {}; 6394 this._current_layer = null; 6395 6396 this.DIV = null; 6397 this.PARTS = {}; 6398 6399 this.weekStart = 0; 6400 this.numRows = 6; 6401 6402 this._create = function(params) 6403 { 6404 this.popup = new BX.PopupWindow('calendar_popup_' + Math.random(), params.node, { 6405 closeByEsc: true, 6406 autoHide: false, 6407 content: this._get_content(), 6408 bindOptions: {forceBindPosition: true} 6409 }); 6410 6411 BX.bind(this.popup.popupContainer, 'click', function(event) { 6412 event.stopPropagation(); 6413 }); 6414 }; 6415 6416 this._auto_hide_disable = function() 6417 { 6418 BX.unbind(document, 'click', BX.proxy(this._auto_hide, this)); 6419 }; 6420 6421 this._auto_hide_enable = function() 6422 { 6423 BX.bind(document, 'click', BX.proxy(this._auto_hide, this)); 6424 }; 6425 6426 this._auto_hide = function(e) 6427 { 6428 this._auto_hide_disable(); 6429 this.popup.close(); 6430 }; 6431 6432 this._get_content = function() 6433 { 6434 var _layer_onclick = BX.delegate(function(e) { 6435 e = e||window.event; 6436 this.SetDate( 6437 new Date(parseInt(BX.proxy_context.getAttribute('data-date'))), 6438 (e.type === 'dblclick' || (this.params.bCompatibility && !this.params.bTimeVisibility)) 6439 ) 6440 }, this); 6441 6442 this.DIV = BX.create('DIV', { 6443 props: {className: 'bx-calendar'}, 6444 children: [ 6445 BX.create('DIV', { 6446 props: { 6447 className: 'bx-calendar-header' 6448 }, 6449 children: [ 6450 BX.create('A', { 6451 attrs: {href: 'javascript:void(0)'}, 6452 props: {className: 'bx-calendar-left-arrow'}, 6453 events: {click: BX.proxy(this._prev, this)} 6454 }), 6455 6456 BX.create('SPAN', { 6457 props: {className: 'bx-calendar-header-content'}, 6458 children: [ 6459 (this.PARTS.MONTH = BX.create('A', { 6460 attrs: {href: 'javascript:void(0)'}, 6461 props: {className: 'bx-calendar-top-month'}, 6462 events: {click: BX.proxy(this._menu_month, this)} 6463 })), 6464 6465 (this.PARTS.YEAR = BX.create('A', { 6466 attrs: {href: 'javascript:void(0)'}, 6467 props: {className: 'bx-calendar-top-year'}, 6468 events: {click: BX.proxy(this._menu_year, this)} 6469 })) 6470 ] 6471 }), 6472 6473 BX.create('A', { 6474 attrs: {href: 'javascript:void(0)'}, 6475 props: {className: 'bx-calendar-right-arrow'}, 6476 events: {click: BX.proxy(this._next, this)} 6477 }) 6478 ] 6479 }), 6480 6481 (this.PARTS.WEEK = BX.create('DIV', { 6482 props: { 6483 className: 'bx-calendar-name-day-wrap' 6484 } 6485 })), 6486 6487 (this.PARTS.LAYERS = BX.create('DIV', { 6488 props: { 6489 className: 'bx-calendar-cell-block' 6490 }, 6491 events: { 6492 click: BX.delegateEvent({className: 'bx-calendar-cell'}, _layer_onclick), 6493 dblclick: BX.delegateEvent({className: 'bx-calendar-cell'}, _layer_onclick) 6494 } 6495 })), 6496 6497 (this.PARTS.TIME = BX.create('DIV', { 6498 props: { 6499 className: 'bx-calendar-set-time-wrap' 6500 }, 6501 events: { 6502 click: BX.delegateEvent( 6503 {attr: 'data-action'}, 6504 BX.delegate(this._time_actions, this) 6505 ) 6506 }, 6507 html: '<a href="javascript:void(0)" data-action="time_show" class="bx-calendar-set-time"><i></i>'+BX.message('CAL_TIME_SET')+'</a><div class="bx-calendar-form-block"><span class="bx-calendar-form-text">'+BX.message('CAL_TIME')+'</span><span class="bx-calendar-form"><input type="text" class="bx-calendar-form-input" maxwidth="2" onkeyup="BX.calendar.get()._check_time()" /><span class="bx-calendar-form-separator"></span><input type="text" class="bx-calendar-form-input" maxwidth="2" onkeyup="BX.calendar.get()._check_time()" />'+(this.bAmPm?'<span class="bx-calendar-AM-PM-block"><span class="bx-calendar-AM-PM-text" data-action="time_ampm"></span><span class="bx-calendar-form-arrow-r"><a href="javascript:void(0)" class="bx-calendar-form-arrow-top" data-action="time_ampm_up"><i></i></a><a href="javascript:void(0)" class="bx-calendar-form-arrow-bottom" data-action="time_ampm_down"><i></i></a></span></span>':'')+'</span><a href="javascript:void(0)" data-action="time_hide" class="bx-calendar-form-close"><i></i></a></div>' 6508 })), 6509 6510 (this.PARTS.BUTTONS = BX.create('DIV', { 6511 props: {className: 'bx-calendar-button-block'}, 6512 events: { 6513 click: BX.delegateEvent( 6514 {attr: 'data-action'}, 6515 BX.delegate(this._button_actions, this) 6516 ) 6517 }, 6518 html: '<a href="javascript:void(0)" class="bx-calendar-button bx-calendar-button-select" data-action="submit"><span class="bx-calendar-button-left"></span><span class="bx-calendar-button-text">'+BX.message('CAL_BUTTON')+'</span><span class="bx-calendar-button-right"></span></a><a href="javascript:void(0)" class="bx-calendar-button bx-calendar-button-cancel" data-action="cancel"><span class="bx-calendar-button-left"></span><span class="bx-calendar-button-text">'+BX.message('JS_CORE_WINDOW_CLOSE')+'</span><span class="bx-calendar-button-right"></span></a>' 6519 })) 6520 ] 6521 }); 6522 6523 this.PARTS.TIME_INPUT_H = BX.findChild(this.PARTS.TIME, {tag: 'INPUT'}, true); 6524 this.PARTS.TIME_INPUT_M = this.PARTS.TIME_INPUT_H.nextSibling.nextSibling; 6525 6526 if (this.bAmPm) 6527 this.PARTS.TIME_AMPM = this.PARTS.TIME_INPUT_M.nextSibling.firstChild; 6528 6529 var spinner = (new BX.JCSpinner({
6530 input: this.PARTS.TIME_INPUT_H, 6531 callback_change: BX.proxy(this._check_time, this), 6532 bSaveValue: false 6533 })).Show(); 6534 spinner.className = 'bx-calendar-form-arrow-l'; 6535 this.PARTS.TIME_INPUT_H.parentNode.insertBefore(spinner, this.PARTS.TIME_INPUT_H); 6536 6537 spinner = (new BX.JCSpinner({ 6538 input: this.PARTS.TIME_INPUT_M, 6539 callback_change: BX.proxy(this._check_time, this), 6540 bSaveValue: true 6541 })).Show(); 6542 spinner.className = 'bx-calendar-form-arrow-r'; 6543 if (!this.PARTS.TIME_INPUT_M.nextSibling) 6544 this.PARTS.TIME_INPUT_M.parentNode.appendChild(spinner); 6545 else 6546 this.PARTS.TIME_INPUT_M.parentNode.insertBefore(spinner, this.PARTS.TIME_INPUT_M.nextSibling); 6547 6548 for (var i = 0; i < 7; i++) 6549 { 6550 this.PARTS.WEEK.appendChild(BX.create('SPAN', { 6551 props: { 6552 className: 'bx-calendar-name-day' 6553 }, 6554 text: BX.message('DOW_' + ((i + this.weekStart) % 7)) 6555 })); 6556 } 6557 6558 return this.DIV; 6559 }; 6560 6561 this._time_actions = function() 6562 { 6563 switch (BX.proxy_context.getAttribute('data-action')) 6564 { 6565 case 'time_show': 6566 BX.addClass(this.PARTS.TIME, 'bx-calendar-set-time-opened'); 6567 if (this.params.bCompatibility) 6568 { 6569 BX.removeClass(this.PARTS.BUTTONS, 'bx-calendar-buttons-disabled'); 6570 } 6571 this.popup.adjustPosition(); 6572 break; 6573 case 'time_hide': 6574 BX.removeClass(this.PARTS.TIME, 'bx-calendar-set-time-opened'); 6575 if (this.params.bCompatibility) 6576 { 6577 this._saveChoice('hide'); 6578 BX.addClass(this.PARTS.BUTTONS, 'bx-calendar-buttons-disabled'); 6579 } 6580 this.popup.adjustPosition(); 6581 break; 6582 case 'time_ampm': 6583 this.PARTS.TIME_AMPM.innerHTML = this.PARTS.TIME_AMPM.innerHTML == 'AM' ? 'PM' : 'AM'; 6584 break; 6585 case 'time_ampm_up': 6586 this._check_time({bSaveValue: false}, null, 12); 6587 return; 6588 break; 6589 case 'time_ampm_down': 6590 this._check_time({bSaveValue: false}, null, -12); 6591 return; 6592 break; 6593 } 6594 6595 this._check_time(); 6596 }; 6597 6598 this._button_actions = function() 6599 { 6600 switch (BX.proxy_context.getAttribute('data-action')) 6601 { 6602 case 'submit': 6603 if (this.params.bCompatibility) 6604 { 6605 this._saveChoice('show'); 6606 } 6607 this.SaveValue(); 6608 break; 6609 case 'cancel': 6610 this.Close(); 6611 break; 6612 } 6613 }; 6614 6615 this._saveChoice = function(state) 6616 { 6617 if (this.params.bCategoryTimeVisibilityOption) 6618 { 6619 BX.userOptions.save( 6620 this.params.bCategoryTimeVisibilityOption, 6621 this.params.bNameTimeVisibilityOption, 6622 'visibility', 6623 (state === 'show' ? 'Y' : 'N') 6624 ); 6625 } 6626 6627 this._bTimeVisibility = (state === 'show'); 6628 this.params.bTimeVisibility = this._bTimeVisibility; 6629 }; 6630 6631 this._check_time = function(params, value, direction) 6632 { 6633 var h = parseInt(this.PARTS.TIME_INPUT_H.value.substring(0,5),10)||0, 6634 m = parseInt(this.PARTS.TIME_INPUT_M.value.substring(0,5),10)||0, 6635 bChanged = false; 6636 6637 if (!!params && !params.bSaveValue) 6638 { 6639 this.value.setUTCHours(this.value.getUTCHours() + direction); 6640 } 6641 else if (!isNaN(h)) 6642 { 6643 if (this.bAmPm) 6644 { 6645 if (h != 12 && this.PARTS.TIME_AMPM.innerHTML == 'PM') 6646 { 6647 h += 12; 6648 } 6649 } 6650 6651 bChanged = true; 6652 this.value.setUTCHours(h % 24); 6653 } 6654 6655 if (!isNaN(m)) 6656 { 6657 bChanged = true; 6658 this.value.setUTCMinutes(m % 60); 6659 } 6660 6661 if (bChanged) 6662 { 6663 this.SetValue(this.value); 6664 } 6665 }; 6666 6667 this._set_layer = function() 6668 { 6669 var layerId = parseInt(this.value.getUTCFullYear() + '' + BX.util.str_pad_left(this.value.getUTCMonth()+'', 2, "0")); 6670 6671 if (!this._layers[layerId]) 6672 { 6673 this._layers[layerId] = this._create_layer(); 6674 this._layers[layerId].BXLAYERID = layerId; 6675 } 6676 6677 if (this._current_layer) 6678 { 6679 var v = new Date(this.value.valueOf()); 6680 v.setUTCHours(0); v.setUTCMinutes(0); 6681 6682 var cur_value = BX.findChild(this._layers[layerId], { 6683 tag: 'A', 6684 className: 'bx-calendar-active' 6685 }, true), 6686 new_value = BX.findChild(this._layers[layerId], { 6687 tag: 'A', 6688 attr: { 6689 'data-date' : v.valueOf() + '' 6690 } 6691 }, true); 6692 6693 if (cur_value) 6694 { 6695 BX.removeClass(cur_value, 'bx-calendar-active'); 6696 } 6697 6698 if (new_value) 6699 { 6700 BX.addClass(new_value, 'bx-calendar-active'); 6701 } 6702 6703 this._replace_layer(this._current_layer, this._layers[layerId]); 6704 } 6705 else 6706 { 6707 this.PARTS.LAYERS.appendChild(this._layers[layerId]); 6708 } 6709 6710 this._current_layer = this._layers[layerId]; 6711 }; 6712 6713 this._replace_layer = function(old_layer, new_layer) 6714 { 6715 if (old_layer != new_layer) 6716 { 6717 if (!BX.browser.IsIE() || BX.browser.IsDoctype()) 6718 { 6719 var dir = old_layer.BXLAYERID > new_layer.BXLAYERID ? 1 : -1; 6720 6721 var old_top = 0; 6722 var new_top = -dir * old_layer.offsetHeight; 6723 6724 old_layer.style.position = 'relative'; 6725 old_layer.style.top = "0px"; 6726 old_layer.style.zIndex = 5; 6727 6728 new_layer.style.position = 'absolute'; 6729 new_layer.style.top = new_top + 'px'; 6730 new_layer.style.zIndex = 6; 6731 6732 this.PARTS.LAYERS.appendChild(new_layer); 6733 6734 var delta = 15; 6735 6736 var f; 6737 (f = function() { 6738 new_top += dir * delta; 6739 old_top += dir * delta; 6740 6741 if (dir * new_top < 0) 6742 { 6743 old_layer.style.top = old_top + 'px'; 6744 new_layer.style.top = new_top + 'px'; 6745 setTimeout(f, 10); 6746 } 6747 else 6748 { 6749 old_layer.parentNode.removeChild(old_layer); 6750 6751 new_layer.style.top = "0px"; 6752 new_layer.style.position = 'static'; 6753 new_layer.style.zIndex = 0; 6754 } 6755 })(); 6756 } 6757 else 6758 {
6759 this.PARTS.LAYERS.replaceChild(new_layer, old_layer); 6760 } 6761 } 6762 }; 6763 6764 this._create_layer = function() 6765 { 6766 var l = BX.create('DIV', { 6767 props: { 6768 className: 'bx-calendar-layer' 6769 } 6770 }); 6771 6772 var month_start = new Date(this.value); 6773 month_start.setUTCHours(0); 6774 month_start.setUTCMinutes(0); 6775 6776 month_start.setUTCDate(1); 6777 6778 if (month_start.getUTCDay() != this.weekStart) 6779 { 6780 var d = month_start.getUTCDay() - this.weekStart; 6781 d += d < 0 ? 7 : 0; 6782 month_start.setUTCDate(month_start.getUTCDate()-d); 6783 } 6784 6785 var cur_month = this.value.getUTCMonth(), 6786 cur_day = this.value.getUTCDate(), 6787 s = ''; 6788 for (var i = 0; i < this.numRows; i++) 6789 { 6790 s += '<div class="bx-calendar-range' 6791 +(i == this.numRows-1 ? ' bx-calendar-range-noline' : '') 6792 +'">'; 6793 6794 for (var j = 0; j < 7; j++) 6795 { 6796 d = month_start.getUTCDate(); 6797 var wd = month_start.getUTCDay(); 6798 var className = 'bx-calendar-cell'; 6799 6800 if (cur_month != month_start.getUTCMonth()) 6801 className += ' bx-calendar-date-hidden'; 6802 else if (cur_day == d) 6803 className += ' bx-calendar-active'; 6804 6805 6806 if (wd == 0 || wd == 6) 6807 className += ' bx-calendar-weekend'; 6808 6809 s += '<a href="javascript:void(0)" class="'+className+'" data-date="' + month_start.valueOf() + '">' + d + '</a>'; 6810 6811 month_start.setUTCDate(month_start.getUTCDate()+1); 6812 } 6813 s += '</div>'; 6814 } 6815 6816 l.innerHTML = s; 6817 6818 return l; 6819 }; 6820 6821 this._prev = function() 6822 { 6823 this.SetMonth(this.value.getUTCMonth()-1); 6824 }; 6825 6826 this._next = function() 6827 { 6828 this.SetMonth(this.value.getUTCMonth()+1); 6829 }; 6830 6831 this._menu_month_content = function() 6832 { 6833 var months = '', cur_month = this.value.getMonth(), i; 6834 for (i = 0; i < 12; i++) 6835 { 6836 months += '<span class="bx-calendar-month'+(i == cur_month ? ' bx-calendar-month-active' : '')+'" data-bx-month="' + i + '">' + BX.message('MONTH_' + (i + 1)) + '</span>'; 6837 } 6838 6839 return '<div class="bx-calendar-month-popup"><div class="bx-calendar-month-title" data-bx-month="' + this.value.getUTCMonth() + '">' + BX.message('MONTH_' + (this.value.getUTCMonth() + 1)) + '</div><div class="bx-calendar-month-content">' + months + '</div></div>'; 6840 }; 6841 6842 this._menu_month = function() 6843 { 6844 if (!this.popup_month) 6845 { 6846 this.popup_month = new BX.PopupWindow( 6847 'calendar_popup_month_' + Math.random(), this.PARTS.MONTH, 6848 { 6849 content: this._menu_month_content(), 6850 closeByEsc: true, 6851 autoHide: true, 6852 offsetTop: -29, 6853 offsetLeft: -1, 6854 className: this.month_popup_classname, 6855 events: { 6856 onPopupShow: BX.delegate(function() { 6857 if (this.popup_year) 6858 { 6859 this.popup_year.close(); 6860 } 6861 }, this) 6862 } 6863 } 6864 ); 6865 6866 BX.bind(this.popup_month.popupContainer, 'click', BX.proxy(this.month_popup_click, this)); 6867 this.popup_month.BXMONTH = this.value.getUTCMonth(); 6868 } 6869 else if (this.popup_month.BXMONTH != this.value.getUTCMonth()) 6870 { 6871 this.popup_month.setContent(this._menu_month_content()); 6872 this.popup_month.BXMONTH = this.value.getUTCMonth(); 6873 } 6874 6875 this.popup_month.show(); 6876 }; 6877 6878 this.month_popup_click = function(e) 6879 { 6880 var target = e.target || e.srcElement; 6881 if (target && target.getAttribute && target.getAttribute('data-bx-month')) 6882 { 6883 this.SetMonth(parseInt(target.getAttribute('data-bx-month'))); 6884 this.popup_month.close(); 6885 } 6886 }; 6887 6888 this._menu_year_content = function() 6889 { 6890 var s = '<div class="bx-calendar-year-popup"><div class="bx-calendar-year-title" data-bx-year="' + this.value.getUTCFullYear() + '">' + this.value.getUTCFullYear() + '</div><div class="bx-calendar-year-content" id="bx-calendar-year-content">'; 6891 6892 for (var i=-3; i <= 3; i++) 6893 { 6894 s += '<span class="bx-calendar-year-number' + (i == 0?' bx-calendar-year-active' : '') + '" data-bx-year="' + (this.value.getUTCFullYear() - i) + '">' + (this.value.getUTCFullYear() - i)+'</span>'; 6895 } 6896 6897 s += '</div><input data-bx-year-input="Y" type="text" class="bx-calendar-year-input" maxlength="4" /></div>'; 6898 6899 return s; 6900 }; 6901 6902 this._menu_year = function() 6903 { 6904 if (!this.popup_year) 6905 { 6906 this.popup_year = new BX.PopupWindow( 6907 'calendar_popup_year_' + Math.random(), this.PARTS.YEAR, 6908 { 6909 content: this._menu_year_content(), 6910 closeByEsc: true, 6911 autoHide: true, 6912 offsetTop: -29, 6913 offsetLeft: -1, 6914 className: this.year_popup_classname, 6915 events: { 6916 onPopupShow: BX.delegate(function() { 6917 if (this.popup_month) 6918 { 6919 this.popup_month.close(); 6920 } 6921 }, this) 6922 } 6923 } 6924 ); 6925 6926 BX.bind(this.popup_year.popupContainer, 'click', BX.proxy(this.year_popup_click, this)); 6927 BX.bind(this.popup_year.popupContainer, 'keyup', BX.proxy(this.year_popup_keyup, this)); 6928 this.popup_year.BXYEAR = this.value.getUTCFullYear(); 6929 } 6930 else if (this.popup_year.BXYEAR != this.value.getUTCFullYear()) 6931 { 6932 this.popup_year.setContent(this._menu_year_content()); 6933 this.popup_year.BXYEAR = this.value.getUTCFullYear(); 6934 } 6935 6936 this.popup_year.show(); 6937 }; 6938 6939 this.year_popup_click = function(e) 6940 { 6941 var target = e.target || e.srcElement; 6942 if (target && target.getAttribute && target.getAttribute('data-bx-year')) 6943 { 6944 this.SetYear(parseInt(target.getAttribute('data-bx-year'))); 6945 this.popup_year.close(); 6946 } 6947 }; 6948 this.year_popup_keyup = function(e) 6949 { 6950 var target = e.target || e.srcElement; 6951 if (target && target.getAttribute && target.getAttribute('data-bx-year-input') == 'Y') 6952 { 6953 var value = parseInt(target.value); 6954 if(value >= 1900 && value <= 2100) 6955 { 6956 this.SetYear(value); 6957 this.popup_year.close(); 6958 } 6959 } 6960 }; 6961 6962 this._check_date = function(v) 6963 { 6964 var res = v; 6965 6966 if (BX.type.isString(v)) 6967 { 6968 res = BX.parseDate(v, true); 6969 } 6970 6971 if (!BX.type.isDate(res) || isNaN(res.valueOf())) 6972 { 6973 res = BX.date.convertToUTC(new Date()); 6974 if (this.params.bHideTime) 6975 { 6976 res.setUTCHours(0); 6977 res.setUTCMinutes(0); 6978 } 6979 } 6980 6981 res.setUTCMilliseconds(0); 6982 res.setUTCSeconds(0); 6983 6984 res.BXCHECKED = true; 6985 6986 return res; 6987 }; 6988}; 6989 6990BX.JCCalendar.prototype.Show = function(params) 6991{ 6992 if (!BX.isReady) 6993 { 6994 BX.ready(BX.delegate(function() {this.Show(params)}, this)); 6995 return; 6996 } 6997 6998 params.node = params.node||document.body; 6999 7000 if (BX.type.isNotEmptyString(params.node)) 7001 { 7002 var n = BX(params.node); 7003 if (!n) 7004 { 7005 n = document.getElementsByName(params.node); 7006 if (n && n.length > 0) 7007 { 7008 n = n[0] 7009 } 7010 } 7011 params.node = n; 7012 } 7013 7014 if (!params.node) 7015 return; 7016 7017 if (!!params.field) 7018 { 7019 if (BX.type.isString(params.field)) 7020 { 7021 n = BX(params.field); 7022 if (!!n) 7023 { 7024 params.field = n; 7025 } 7026 else 7027 {
7028 if (params.form) 7029 { 7030 if (BX.type.isString(params.form)) 7031 { 7032 params.form = document.forms[params.form]; 7033 } 7034 } 7035 7036 if (BX.type.isDomNode(params.form) && !!params.form[params.field]) 7037 { 7038 params.field = params.form[params.field]; 7039 } 7040 else 7041 { 7042 n = document.getElementsByName(params.field); 7043 if (n && n.length > 0) 7044 { 7045 n = n[0]; 7046 params.field = n; 7047 } 7048 } 7049 } 7050 7051 if (BX.type.isString(params.field)) 7052 { 7053 params.field = BX(params.field); 7054 } 7055 } 7056 } 7057 7058 var bShow = !this.popup || !this.popup.isShown() || this.params.node != params.node; 7059 7060 this.params = params; 7061 7062 this.params.bCompatibility = (typeof this.params.bCompatibility == 'undefined' ? false : this.params.bCompatibility); 7063 this.params.bTimeVisibility = (typeof this.params.bTimeVisibility == 'undefined' ? !this.params.bCompatibility : this.params.bTimeVisibility); 7064 if (this.params.bCompatibility) 7065 { 7066 this.params.bCategoryTimeVisibilityOption = ( 7067 this.params.bCategoryTimeVisibilityOption ? this.params.bCategoryTimeVisibilityOption : '' 7068 ); 7069 this.params.bNameTimeVisibilityOption = ( 7070 this.params.bNameTimeVisibilityOption ? this.params.bNameTimeVisibilityOption : 'time_visibility' 7071 ); 7072 7073 if (typeof this._bTimeVisibility !== 'undefined') 7074 { 7075 this.params.bTimeVisibility = this._bTimeVisibility; 7076 } 7077 } 7078 7079 this.params.bTime = typeof this.params.bTime == 'undefined' ? true : !!this.params.bTime; 7080 this.params.bHideTime = typeof this.params.bHideTime == 'undefined' ? true : !!this.params.bHideTime; 7081 this.params.bUseSecond = typeof this.params.bUseSecond == 'undefined' ? true : !!this.params.bUseSecond; 7082 7083 this.weekStart = parseInt(this.params.weekStart || this.params.weekStart || BX.message('WEEK_START')); 7084 if (isNaN(this.weekStart)) 7085 this.weekStart = 1; 7086 7087 if (!this.popup) 7088 { 7089 this._create(this.params); 7090 } 7091 else 7092 { 7093 this.popup.setBindElement(this.params.node); 7094 } 7095 7096 var bHideTime = !!this.params.bHideTime; 7097 if (this.params.value) 7098 { 7099 this.SetValue(this.params.value); 7100 bHideTime = this.value.getUTCHours() <= 0 && this.value.getUTCMinutes() <= 0; 7101 } 7102 else if (this.params.field) 7103 { 7104 this.SetValue(this.params.field.value); 7105 bHideTime = this.value.getUTCHours() <= 0 && this.value.getUTCMinutes() <= 0; 7106 } 7107 else if (!!this.params.currentTime) 7108 { 7109 this.SetValue(this.params.currentTime); 7110 } 7111 else 7112 { 7113 this.SetValue(); 7114 } 7115 7116 if (!!this.params.bTime) 7117 { 7118 this.activateTimeStyle(bHideTime); 7119 } 7120 else 7121 { 7122 this.activateDateStyle(bHideTime); 7123 } 7124 7125 if (bShow) 7126 { 7127 this._auto_hide_disable(); 7128 this.popup.show(); 7129 setTimeout(BX.proxy(this._auto_hide_enable, this), 0); 7130 } 7131 7132 this.params.bSetFocus = typeof this.params.bSetFocus == 'undefined' ? true : !!this.params.bSetFocus; 7133 if(this.params.bSetFocus) 7134 { 7135 params.node.blur(); 7136 } 7137 else 7138 { 7139 BX.bind(params.node, 'keyup', BX.defer(function(){ 7140 this.SetValue(params.node.value); 7141 if(!!this.params.bTime) 7142 { 7143 if(this.value.getUTCHours() <= 0 && this.value.getUTCMinutes() <= 0) 7144 BX.removeClass(this.PARTS.TIME, 'bx-calendar-set-time-opened'); 7145 else 7146 BX.addClass(this.PARTS.TIME, 'bx-calendar-set-time-opened'); 7147 } 7148 }, this)); 7149 } 7150 7151 return this; 7152}; 7153 7154BX.JCCalendar.prototype.activateDateStyle = function(bHideTime) 7155{ 7156 BX.addClass(this.DIV, 'bx-calendar-time-disabled'); 7157 7158 if (!!bHideTime) 7159 BX.removeClass(this.PARTS.TIME, 'bx-calendar-set-time-opened'); 7160 else 7161 BX.addClass(this.PARTS.TIME, 'bx-calendar-set-time-opened'); 7162}; 7163 7164BX.JCCalendar.prototype.activateTimeStyle = function(bHideTime) 7165{ 7166 if (this.params.bCompatibility && !this.params.bTimeVisibility) 7167 { 7168 BX.addClass(this.PARTS.BUTTONS, 'bx-calendar-buttons-disabled'); 7169 BX.addClass(this.PARTS.TIME, 'bx-calendar-set-time-wrap-simple'); 7170 BX.removeClass(this.PARTS.TIME, 'bx-calendar-set-time-opened'); 7171 } 7172 else 7173 { 7174 BX.removeClass(this.DIV, 'bx-calendar-time-disabled'); 7175 7176 if (!!bHideTime) 7177 BX.removeClass(this.PARTS.TIME, 'bx-calendar-set-time-opened'); 7178 else 7179 BX.addClass(this.PARTS.TIME, 'bx-calendar-set-time-opened'); 7180 } 7181}; 7182 7183BX.JCCalendar.prototype.SetDay = function(d) 7184{ 7185 this.value.setUTCDate(d); 7186 return this.SetValue(this.value); 7187}; 7188 7189BX.JCCalendar.prototype.SetMonth = function(m) 7190{ 7191 if (this.popup_month) 7192 this.popup_month.close(); 7193 7194 this.value.setUTCMonth(m); 7195 7196 if(m < 0) 7197 m += 12; 7198 else if (m >= 12) 7199 m -= 12; 7200 7201 while(this.value.getUTCMonth() > m) 7202 { 7203 this.value.setUTCDate(this.value.getUTCDate()-1); 7204 } 7205 7206 return this.SetValue(this.value); 7207}; 7208 7209BX.JCCalendar.prototype.SetYear = function(y) 7210{ 7211 if (this.popup_year) 7212 this.popup_year.close(); 7213 this.value.setUTCFullYear(y); 7214 return this.SetValue(this.value); 7215}; 7216 7217BX.JCCalendar.prototype.SetDate = function(v, bSet) 7218{ 7219 v = this._check_date(v); 7220 v.setUTCHours(this.value.getUTCHours()); 7221 v.setUTCMinutes(this.value.getUTCMinutes()); 7222 v.setUTCSeconds(this.value.getUTCSeconds()); 7223 7224 if (this.params.bTime && !bSet) 7225 { 7226 return this.SetValue(v); 7227 } 7228 else 7229 { 7230 this.SetValue(v); 7231 this.SaveValue(); 7232 } 7233}; 7234 7235BX.JCCalendar.prototype.SetValue = function(v) 7236{ 7237 this.value = (v && v.BXCHECKED) ? v : this._check_date(v); 7238 7239 this.PARTS.MONTH.innerHTML = BX.message('MONTH_' + (this.value.getUTCMonth()+1)); 7240 this.PARTS.YEAR.innerHTML = this.value.getUTCFullYear(); 7241 7242 if (!!this.params.bTime) 7243 {
7244 var h = this.value.getUTCHours(); 7245 if (this.bAmPm) 7246 { 7247 if (h >= 12) 7248 { 7249 this.PARTS.TIME_AMPM.innerHTML = 'PM'; 7250 7251 if (h != 12) 7252 h -= 12; 7253 } 7254 else 7255 { 7256 this.PARTS.TIME_AMPM.innerHTML = 'AM'; 7257 7258 if (h == 0) 7259 h = 12; 7260 } 7261 } 7262 7263 this.PARTS.TIME_INPUT_H.value = BX.util.str_pad_left(h.toString(), 2, "0"); 7264 this.PARTS.TIME_INPUT_M.value = BX.util.str_pad_left(this.value.getUTCMinutes().toString(), 2, "0"); 7265 } 7266 7267 this._set_layer(); 7268 7269 return this; 7270}; 7271 7272BX.JCCalendar.prototype.SaveValue = function() 7273{ 7274 if (this.popup_month) 7275 this.popup_month.close(); 7276 if (this.popup_year) 7277 this.popup_year.close(); 7278 7279 var bSetValue = true; 7280 if (!!this.params.callback) 7281 { 7282 var res = this.params.callback.apply(this, [new Date(this.value.valueOf()+this.value.getTimezoneOffset()*60000)]); 7283 if (res === false) 7284 bSetValue = false; 7285 } 7286 7287 if (bSetValue) 7288 { 7289 var bTime = !!this.params.bTime && BX.hasClass(this.PARTS.TIME, 'bx-calendar-set-time-opened'); 7290 7291 if (this.params.field) 7292 { 7293 var format = BX.message(bTime ? 'FORMAT_DATETIME' : 'FORMAT_DATE'); 7294 7295 if(bTime && !this.params.bUseSecond) 7296 { 7297 format = format.replace(':SS', ''); 7298 } 7299 7300 this.params.field.value = BX.calendar.ValueToStringFormat(this.value, format, true); 7301 BX.fireEvent(this.params.field, 'change'); 7302 } 7303 7304 this.popup.close(); 7305 7306 if (!!this.params.callback_after) 7307 { 7308 this.params.callback_after.apply(this, [new Date(this.value.valueOf()+this.value.getTimezoneOffset()*60000), bTime]); 7309 } 7310 } 7311 7312 return this; 7313}; 7314 7315BX.JCCalendar.prototype.Close = function() 7316{ 7317 if (!!this.popup) 7318 this.popup.close(); 7319 7320 return this; 7321}; 7322 7323BX.JCSpinner = function(params) 7324{ 7325 params = params || {}; 7326 this.params = { 7327 input: params.input || null, 7328 7329 delta: params.delta || 1, 7330 7331 timeout_start: params.timeout_start || 1000, 7332 timeout_cont: params.timeout_cont || 150, 7333 7334 callback_start: params.callback_start || null, 7335 callback_change: params.callback_change || null, 7336 callback_finish: params.callback_finish || null, 7337 7338 bSaveValue: typeof params.bSaveValue == 'undefined' ? !!params.input : !!params.bSaveValue 7339 }; 7340 7341 this.mousedown = false; 7342 this.direction = 1; 7343}; 7344 7345BX.JCSpinner.prototype.Show = function() 7346{ 7347 this.node = BX.create('span', { 7348 events: { 7349 mousedown: BX.delegateEvent( 7350 {attr: 'data-dir'}, 7351 BX.delegate(this.Start, this) 7352 ) 7353 }, 7354 html: '<a href="javascript:void(0)" class="bx-calendar-form-arrow bx-calendar-form-arrow-top" data-dir="1"><i></i></a><a href="javascript:void(0)" class="bx-calendar-form-arrow bx-calendar-form-arrow-bottom" data-dir="-1"><i></i></a>' 7355 }); 7356 return this.node; 7357}; 7358 7359BX.JCSpinner.prototype.Start = function() 7360{ 7361 this.mousedown = true; 7362 this.direction = BX.proxy_context.getAttribute('data-dir') > 0 ? 1 : -1; 7363 BX.bind(document, "mouseup", BX.proxy(this.MouseUp, this)); 7364 this.ChangeValue(true); 7365}; 7366 7367BX.JCSpinner.prototype.ChangeValue = function(bFirst) 7368{ 7369 if(!this.mousedown) 7370 return; 7371 7372 if (this.params.input) 7373 { 7374 var v = parseInt(this.params.input.value, 10) + this.params.delta * this.direction; 7375 7376 if (this.params.bSaveValue) 7377 this.params.input.value = v; 7378 7379 if (!!bFirst && this.params.callback_start) 7380 this.params.callback_start(this.params, v, this.direction); 7381 7382 if (this.params.callback_change) 7383 this.params.callback_change(this.params, v, this.direction); 7384 7385 setTimeout( 7386 BX.proxy(this.ChangeValue, this), 7387 !!bFirst ? this.params.timeout_start : this.params.timeout_cont 7388 ); 7389 } 7390}; 7391 7392BX.JCSpinner.prototype.MouseUp = function() 7393{ 7394 this.mousedown = false; 7395 BX.unbind(document, "mouseup", BX.proxy(this.MouseUp, this)); 7396 7397 if (this.params.callback_finish) 7398 this.params.callback_finish(this.params, this.params.input.value); 7399}; 7400 7401/**************** compatibility hacks ***************************/ 7402 7403window.jsCalendar = { 7404 Show: function(obj, field, fieldFrom, fieldTo, bTime, serverTime, form_name, bHideTimebar) 7405 { 7406 return BX.calendar({ 7407 node: obj, field: field, form: form_name, bTime: !!bTime, currentTime: serverTime, bHideTimebar: !!bHideTimebar 7408 }); 7409 }, 7410 7411 ValueToString: BX.calendar.ValueToString 7412}; 7413 7414 7415/************ clock popup transferred from timeman **************/ 7416 7417BX.CClockSelector = function(params) 7418{ 7419 this.params = params; 7420 7421 this.params.popup_buttons = this.params.popup_buttons || [ 7422 new BX.PopupWindowButton({ 7423 text : BX.message('CAL_BUTTON'), 7424 className : "popup-window-button-create", 7425 events : {click : BX.proxy(this.setValue, this)} 7426 }) 7427 ]; 7428 7429 this.isReady = false;
7430 7431 this.WND = new BX.PopupWindow( 7432 this.params.popup_id || 'clock_selector_popup', 7433 this.params.node, 7434 this.params.popup_config || { 7435 titleBar: BX.message('CAL_TIME'), 7436 offsetLeft: -45, 7437 offsetTop: -135, 7438 autoHide: true, 7439 closeIcon: true, 7440 closeByEsc: true 7441 } 7442 ); 7443 7444 this.SHOW = false; 7445 BX.addCustomEvent(this.WND, "onPopupClose", BX.delegate(this.onPopupClose, this)); 7446 7447 this.obClocks = {}; 7448 this.CLOCK_ID = this.params.clock_id || 'clock_selector'; 7449}; 7450 7451BX.CClockSelector.prototype.Show = function() 7452{ 7453 if (!this.isReady) 7454 { 7455 //BX.timeman.showWait(this.parent.DIV); 7456 7457 BX.addCustomEvent('onClockRegister', BX.proxy(this.onClockRegister, this)); 7458 return BX.ajax.get('/bitrix/tools/clock_selector.php', {start_time: this.params.start_time, clock_id: this.CLOCK_ID, sessid: BX.bitrix_sessid()}, BX.delegate(this.Ready, this)); 7459 } 7460 7461 this.WND.setButtons(this.params.popup_buttons); 7462 this.WND.show(); 7463 7464 this.SHOW = true; 7465 7466 if (window['bxClock_' + this.obClocks[this.CLOCK_ID]]) 7467 { 7468 setTimeout("window['bxClock_" + this.obClocks[this.CLOCK_ID] + "'].CalculateCoordinates()", 40); 7469 } 7470 7471 return true; 7472}; 7473 7474BX.CClockSelector.prototype.onClockRegister = function(obClocks) 7475{ 7476 if (obClocks[this.CLOCK_ID]) 7477 { 7478 this.obClocks[this.CLOCK_ID] = obClocks[this.CLOCK_ID]; 7479 BX.removeCustomEvent('onClockRegister', BX.proxy(this.onClockRegister, this)); 7480 } 7481}; 7482 7483BX.CClockSelector.prototype.Ready = function(data) 7484{ 7485 this.content = this.CreateContent(data); 7486 this.WND.setContent(this.content); 7487 7488 this.isReady = true; 7489 //BX.timeman.closeWait(); 7490 7491 setTimeout(BX.proxy(this.Show, this), 30); 7492}; 7493 7494BX.CClockSelector.prototype.CreateContent = function(data) 7495{ 7496 return BX.create('DIV', { 7497 events: {click: BX.PreventDefault}, 7498 html: 7499 '<div class="bx-tm-popup-clock">' + data + '</div>' 7500 }); 7501}; 7502 7503BX.CClockSelector.prototype.setValue = function(e) 7504{ 7505 if (this.params.callback) 7506 { 7507 var input = BX.findChild(this.content, {tagName: 'INPUT'}, true); 7508 this.params.callback.apply(this.params.node, [input.value]); 7509 } 7510 7511 return BX.PreventDefault(e); 7512}; 7513 7514BX.CClockSelector.prototype.closeWnd = function(e) 7515{ 7516 this.WND.close(); 7517 return (e || window.event) ? BX.PreventDefault(e) : true; 7518}; 7519 7520BX.CClockSelector.prototype.setNode = function(node) 7521{ 7522 this.WND.setBindElement(node); 7523}; 7524 7525BX.CClockSelector.prototype.setTime = function(timestamp) 7526{ 7527 this.params.start_time = timestamp; 7528 if (window['bxClock_' + this.obClocks[this.CLOCK_ID]]) 7529 { 7530 window['bxClock_' + this.obClocks[this.CLOCK_ID]].SetTime(parseInt(timestamp/3600), parseInt((timestamp%3600)/60)); 7531 } 7532}; 7533 7534BX.CClockSelector.prototype.setCallback = function(cb) 7535{ 7536 this.params.callback = cb; 7537}; 7538 7539BX.CClockSelector.prototype.onPopupClose = function() 7540{ 7541 this.SHOW = false;
7542}; 7543 7544})(); 7545 7546/* End */ 7547; 7548; /* Start:"a:4:{s:4:"full";s:40:"/bitrix/js/main/utils.js?163379651229279";s:6:"source";s:24:"/bitrix/js/main/utils.js";s:3:"min";s:0:"";s:3:"map";s:0:"";}"*/ 7549var phpVars; 7550if(!phpVars) 7551{ 7552 phpVars = { 7553 ADMIN_THEME_ID: '.default', 7554 LANGUAGE_ID: 'en', 7555 FORMAT_DATE: 'DD.MM.YYYY', 7556 FORMAT_DATETIME: 'DD.MM.YYYY HH:MI:SS', 7557 opt_context_ctrl: false, 7558 cookiePrefix: 'BITRIX_SM', 7559 titlePrefix: '', 7560 bitrix_sessid: '', 7561 messHideMenu: '', 7562 messShowMenu: '', 7563 messHideButtons: '', 7564 messShowButtons: '', 7565 messFilterInactive: '', 7566 messFilterActive: '', 7567 messFilterLess: '', 7568 messLoading: 'Loading...', 7569 messMenuLoading: '', 7570 messMenuLoadingTitle: '', 7571 messNoData: '', 7572 messExpandTabs: '', 7573 messCollapseTabs: '', 7574 messPanelFixOn: '', 7575 messPanelFixOff: '', 7576 messPanelCollapse: '', 7577 messPanelExpand: '' 7578 }; 7579} 7580 7581var jsUtils = 7582{ 7583 arEvents: Array(), 7584 7585 addEvent: function(el, evname, func, capture) 7586 { 7587 if(el.attachEvent) // IE 7588 el.attachEvent("on" + evname, func); 7589 else if(el.addEventListener) // Gecko / W3C 7590 el.addEventListener(evname, func, false); 7591 else 7592 el["on" + evname] = func; 7593 this.arEvents[this.arEvents.length] = {'element': el, 'event': evname, 'fn': func}; 7594 }, 7595 7596 removeEvent: function(el, evname, func) 7597 { 7598 if(el.detachEvent) // IE 7599 el.detachEvent("on" + evname, func); 7600 else if(el.removeEventListener) // Gecko / W3C 7601 el.removeEventListener(evname, func, false); 7602 else 7603 el["on" + evname] = null; 7604 }, 7605 7606 removeAllEvents: function(el) 7607 { 7608 var i; 7609 for(i=0; i<this.arEvents.length; i++) 7610 { 7611 if(this.arEvents[i] && (el==false || el==this.arEvents[i].element)) 7612 { 7613 jsUtils.removeEvent(this.arEvents[i].element, this.arEvents[i].event, this.arEvents[i].fn); 7614 this.arEvents[i] = null; 7615 } 7616 } 7617 if(el==false) 7618 this.arEvents.length = 0; 7619 }, 7620 7621 IsDoctype: function() 7622 { 7623 if (document.compatMode) 7624 return (document.compatMode == "CSS1Compat"); 7625 7626 if (document.documentElement && document.documentElement.clientHeight) 7627 return true; 7628 7629 return false; 7630 }, 7631 7632 GetRealPos: function(el) 7633 { 7634 if(window.BX) 7635 return BX.pos(el); 7636 7637 if(!el || !el.offsetParent) 7638 return false; 7639 7640 var res = Array(); 7641 res["left"] = el.offsetLeft; 7642 res["top"] = el.offsetTop; 7643 var objParent = el.offsetParent; 7644 7645 while(objParent && objParent.tagName != "BODY") 7646 { 7647 res["left"] += objParent.offsetLeft; 7648 res["top"] += objParent.offsetTop; 7649 objParent = objParent.offsetParent; 7650 } 7651 res["right"] = res["left"] + el.offsetWidth; 7652 res["bottom"] = res["top"] + el.offsetHeight; 7653 7654 return res; 7655 }, 7656 7657 FindChildObject: function(obj, tag_name, class_name, recursive) 7658 { 7659 if(!obj) 7660 return null; 7661 var tag = tag_name.toUpperCase(); 7662 var cl = (class_name? class_name.toLowerCase() : null); 7663 var n = obj.childNodes.length; 7664 for(var j=0; j<n; j++) 7665 { 7666 var child = obj.childNodes[j]; 7667 if(child.tagName && child.tagName.toUpperCase() == tag) 7668 if(!class_name || child.className.toLowerCase() == cl) 7669 return child; 7670 if(recursive == true) 7671 { 7672 var deepChild; 7673 if((deepChild = jsUtils.FindChildObject(child, tag_name, class_name, true))) 7674 return deepChild; 7675 } 7676 } 7677 return null; 7678 }, 7679 7680 FindParentObject: function(obj, tag_name, class_name) 7681 { 7682 if(!obj) 7683 return null; 7684 var o = obj; 7685 var tag = tag_name.toUpperCase(); 7686 var cl = (class_name? class_name.toLowerCase() : null); 7687 while(o.parentNode) 7688 { 7689 var parent = o.parentNode; 7690 if(parent.tagName && parent.tagName.toUpperCase() == tag) 7691 if(!class_name || parent.className.toLowerCase() == cl) 7692 return parent; 7693 o = parent; 7694 } 7695 return null; 7696 }, 7697 7698 FindNextSibling: function(obj, tag_name) 7699 { 7700 if(!obj) 7701 return null; 7702 var o = obj; 7703 var tag = tag_name.toUpperCase(); 7704 while(o.nextSibling) 7705 { 7706 var sibling = o.nextSibling; 7707 if(sibling.tagName && sibling.tagName.toUpperCase() == tag) 7708 return sibling; 7709 o = sibling; 7710 } 7711 return null; 7712 }, 7713 7714 FindPreviousSibling: function(obj, tag_name) 7715 { 7716 if(!obj) 7717 return null; 7718 var o = obj; 7719 var tag = tag_name.toUpperCase(); 7720 while(o.previousSibling) 7721 { 7722 var sibling = o.previousSibling; 7723 if(sibling.tagName && sibling.tagName.toUpperCase() == tag) 7724 return sibling; 7725 o = sibling; 7726 } 7727 return null; 7728 }, 7729 7730 bOpera : navigator.userAgent.toLowerCase().indexOf('opera') != -1, 7731 bIsIE : document.attachEvent && navigator.userAgent.toLowerCase().indexOf('opera') == -1, 7732 7733 IsIE: function() 7734 { 7735 return this.bIsIE; 7736 }, 7737 7738 IsOpera: function() 7739 { 7740 return this.bOpera; 7741 }, 7742 7743 IsSafari: function() 7744 { 7745 var userAgent = navigator.userAgent.toLowerCase(); 7746 return (/webkit/.test(userAgent)); 7747 }, 7748 7749 IsEditor: function() 7750 { 7751 var userAgent = navigator.userAgent.toLowerCase(); 7752 var version = (userAgent.match( /.+(msie)[\/: ]([\d.]+)/ ) || [])[2]; 7753 var safari = /webkit/.test(userAgent); 7754 7755 if (this.IsOpera() || (document.all && !document.compatMode && version < 6) || safari) 7756 return false;
7757 7758 return true; 7759 }, 7760 7761 ToggleDiv: function(div) 7762 { 7763 var style = document.getElementById(div).style; 7764 if(style.display!="none") 7765 style.display = "none"; 7766 else 7767 style.display = "block"; 7768 return (style.display != "none"); 7769 }, 7770 7771 urlencode: function(s) 7772 { 7773 return escape(s).replace(new RegExp('\\+','g'), '%2B'); 7774 }, 7775 7776 OpenWindow: function(url, width, height) 7777 { 7778 var w = screen.width, h = screen.height; 7779 if(this.IsOpera()) 7780 { 7781 w = document.body.offsetWidth; 7782 h = document.body.offsetHeight; 7783 } 7784 window.open(url, '', 'status=no,scrollbars=yes,resizable=yes,width='+width+',height='+height+',top='+Math.floor((h - height)/2-14)+',left='+Math.floor((w - width)/2-5)); 7785 }, 7786 7787 SetPageTitle: function(s) 7788 { 7789 document.title = phpVars.titlePrefix+s; 7790 var h1 = document.getElementsByTagName("H1"); 7791 if(h1) 7792 h1[0].innerHTML = s; 7793 }, 7794 7795 LoadPageToDiv: function(url, div_id) 7796 { 7797 var div = document.getElementById(div_id); 7798 if(!div) 7799 return; 7800 CHttpRequest.Action = function(result) 7801 { 7802 CloseWaitWindow(); 7803 document.getElementById(div_id).innerHTML = result; 7804 } 7805 ShowWaitWindow(); 7806 CHttpRequest.Send(url); 7807 }, 7808 7809 trim: function(s) 7810 { 7811 if (typeof s == 'string' || typeof s == 'object' && s.constructor == String) 7812 { 7813 var r, re; 7814 7815 re = /^[\s\r\n]+/g; 7816 r = s.replace(re, ""); 7817 re = /[\s\r\n]+$/g; 7818 r = r.replace(re, ""); 7819 return r; 7820 } 7821 else 7822 return s; 7823 }, 7824 7825 Redirect: function(args, url) 7826 { 7827 var e = null, bShift = false; 7828 if(args && args.length > 0) 7829 e = args[0]; 7830 if(!e) 7831 e = window.event; 7832 if(e) 7833 bShift = e.shiftKey; 7834 7835 if(bShift) 7836 window.open(url); 7837 else 7838 { 7839 window.location.href=url; 7840 } 7841 }, 7842 7843 False: function(){return false;}, 7844 7845 AlignToPos: function(pos, w, h) 7846 { 7847 var x = pos["left"], y = pos["bottom"]; 7848 7849 var scroll = jsUtils.GetWindowScrollPos(); 7850 var size = jsUtils.GetWindowInnerSize(); 7851 7852 if((size.innerWidth + scroll.scrollLeft) - (pos["left"] + w) < 0) 7853 { 7854 if(pos["right"] - w >= 0 ) 7855 x = pos["right"] - w; 7856 else 7857 x = scroll.scrollLeft; 7858 } 7859 7860 if((size.innerHeight + scroll.scrollTop) - (pos["bottom"] + h) < 0) 7861 { 7862 if(pos["top"] - h >= 0) 7863 y = pos["top"] - h; 7864 else 7865 y = scroll.scrollTop; 7866 } 7867 7868 return {'left':x, 'top':y}; 7869 }, 7870 7871 // evaluate js string in window scope 7872 EvalGlobal: function(script) 7873 { 7874 try { 7875 if (window.execScript) 7876 window.execScript(script, 'javascript'); 7877 else if (jsUtils.IsSafari()) 7878 window.setTimeout(script, 0); 7879 else 7880 window.eval(script); 7881 } catch (e) {/*alert("Error! jsUtils.EvalGlobal");*/} 7882 }, 7883 7884 GetStyleValue: function(el, styleProp) 7885 { 7886 var res; 7887 if(el.currentStyle) 7888 res = el.currentStyle[styleProp]; 7889 else if(window.getComputedStyle) 7890 res = document.defaultView.getComputedStyle(el, null).getPropertyValue(styleProp); 7891 if(!res) 7892 res = ''; 7893 return res; 7894 }, 7895 7896 GetWindowInnerSize: function(pDoc) 7897 { 7898 var width, height; 7899 if (!pDoc) 7900 pDoc = document; 7901 7902 if (self.innerHeight) // all except Explorer 7903 { 7904 width = self.innerWidth; 7905 height = self.innerHeight; 7906 } 7907 else if (pDoc.documentElement && (pDoc.documentElement.clientHeight || pDoc.documentElement.clientWidth)) // Explorer 6 Strict Mode 7908 { 7909 width = pDoc.documentElement.clientWidth; 7910 height = pDoc.documentElement.clientHeight; 7911 } 7912 else if (pDoc.body) // other Explorers 7913 { 7914 width = pDoc.body.clientWidth; 7915 height = pDoc.body.clientHeight; 7916 } 7917 return {innerWidth : width, innerHeight : height}; 7918 }, 7919 7920 GetWindowScrollPos: function(pDoc) 7921 { 7922 var left, top; 7923 if (!pDoc) 7924 pDoc = document; 7925 7926 if (self.pageYOffset) // all except Explorer 7927 { 7928 left = self.pageXOffset; 7929 top = self.pageYOffset; 7930 } 7931 else if (pDoc.documentElement && (pDoc.documentElement.scrollTop || pDoc.documentElement.scrollLeft)) // Explorer 6 Strict 7932 { 7933 left = document.documentElement.scrollLeft; 7934 top = document.documentElement.scrollTop; 7935 } 7936 else if (pDoc.body) // all other Explorers 7937 { 7938 left = pDoc.body.scrollLeft; 7939 top = pDoc.body.scrollTop; 7940 } 7941 return {scrollLeft : left, scrollTop : top}; 7942 }, 7943 7944 GetWindowScrollSize: function(pDoc) 7945 { 7946 var width, height; 7947 if (!pDoc) 7948 pDoc = document; 7949 7950 if ( (pDoc.compatMode && pDoc.compatMode == "CSS1Compat")) 7951 { 7952 width = pDoc.documentElement.scrollWidth; 7953 height = pDoc.documentElement.scrollHeight; 7954 } 7955 else 7956 { 7957 if (pDoc.body.scrollHeight > pDoc.body.offsetHeight) 7958 height = pDoc.body.scrollHeight; 7959 else 7960 height = pDoc.body.offsetHeight; 7961 7962 if (pDoc.body.scrollWidth > pDoc.body.offsetWidth || 7963 (pDoc.compatMode && pDoc.compatMode == "BackCompat") || 7964 (pDoc.documentElement && !pDoc.documentElement.clientWidth) 7965 ) 7966 width = pDoc.body.scrollWidth; 7967 else 7968 width = pDoc.body.offsetWidth; 7969 } 7970 return {scrollWidth : width, scrollHeight : height}; 7971 }, 7972 7973 GetWindowSize: function() 7974 { 7975 var innerSize = jsUtils.GetWindowInnerSize(); 7976 var scrollPos = jsUtils.GetWindowScrollPos(); 7977 var scrollSize = jsUtils.GetWindowScrollSize(); 7978 7979 return {
7980 innerWidth : innerSize.innerWidth, innerHeight : innerSize.innerHeight, 7981 scrollLeft : scrollPos.scrollLeft, scrollTop : scrollPos.scrollTop, 7982 scrollWidth : scrollSize.scrollWidth, scrollHeight : scrollSize.scrollHeight 7983 }; 7984 }, 7985 7986 7987 arCustomEvents: {}, 7988 7989 addCustomEvent: function(eventName, eventHandler, arParams, handlerContextObject) 7990 { 7991 if (!this.arCustomEvents[eventName]) 7992 this.arCustomEvents[eventName] = []; 7993 7994 if (!arParams) 7995 arParams = []; 7996 if (!handlerContextObject) 7997 handlerContextObject = false; 7998 7999 this.arCustomEvents[eventName].push( 8000 { 8001 handler: eventHandler, 8002 arParams: arParams, 8003 obj: handlerContextObject 8004 } 8005 ); 8006 }, 8007 8008 removeCustomEvent: function(eventName, eventHandler) 8009 { 8010 if (!this.arCustomEvents[eventName]) 8011 return; 8012 8013 var l = this.arCustomEvents[eventName].length; 8014 if (l == 1) 8015 { 8016 delete this.arCustomEvents[eventName]; 8017 return; 8018 } 8019 8020 for (var i = 0; i < l; i++) 8021 { 8022 if (!this.arCustomEvents[eventName][i]) 8023 continue; 8024 if (this.arCustomEvents[eventName][i].handler == eventHandler) 8025 { 8026 delete this.arCustomEvents[eventName][i]; 8027 return; 8028 } 8029 } 8030 }, 8031 8032 onCustomEvent: function(eventName, arEventParams) 8033 { 8034 if (!this.arCustomEvents[eventName]) 8035 return; 8036 8037 if (!arEventParams) 8038 arEventParams = []; 8039 8040 var h; 8041 for (var i = 0, l = this.arCustomEvents[eventName].length; i < l; i++) 8042 { 8043 h = this.arCustomEvents[eventName][i]; 8044 if (!h || !h.handler) 8045 continue; 8046 8047 if (h.obj) 8048 h.handler.call(h.obj, h.arParams, arEventParams); 8049 else 8050 h.handler(h.arParams, arEventParams); 8051 } 8052 }, 8053 8054 loadJSFile: function(arJs, oCallBack, pDoc) 8055 { 8056 if (!pDoc) 8057 pDoc = document; 8058 if (typeof arJs == 'string') 8059 arJs = [arJs]; 8060 var callback = function() 8061 { 8062 if (!oCallBack) 8063 return; 8064 if (typeof oCallBack == 'function') 8065 return oCallBack(); 8066 if (typeof oCallBack != 'object' || !oCallBack.func) 8067 return; 8068 var p = oCallBack.params || {}; 8069 if (oCallBack.obj) 8070 oCallBack.func.apply(oCallBack.obj, p); 8071 else 8072 oCallBack.func(p); 8073 }; 8074 var load_js = function(ind) 8075 { 8076 if (ind >= arJs.length) 8077 return callback(); 8078 var oSript = pDoc.body.appendChild(pDoc.createElement('script')); 8079 oSript.src = arJs[ind]; 8080 var bLoaded = false; 8081 oSript.onload = oSript.onreadystatechange = function() 8082 { 8083 if (!bLoaded && (!oSript.readyState || oSript.readyState == "loaded" || oSript.readyState == "complete")) 8084 { 8085 bLoaded = true; 8086 setTimeout(function (){load_js(++ind);}, 50); 8087 } 8088 }; 8089 }; 8090 load_js(0); 8091 }, 8092 8093 loadCSSFile: function(arCSS, pDoc, pWin) 8094 { 8095 if (typeof arCSS == 'string') 8096 { 8097 var bSingle = true; 8098 arCSS = [arCSS]; 8099 } 8100 var i, l = arCSS.length, pLnk = []; 8101 if (l == 0) 8102 return; 8103 if (!pDoc) 8104 pDoc = document; 8105 if (!pWin) 8106 pWin = window; 8107 if (!pWin.bxhead) 8108 { 8109 var heads = pDoc.getElementsByTagName('HEAD'); 8110 pWin.bxhead = heads[0]; 8111 } 8112 if (!pWin.bxhead) 8113 return; 8114 for (i = 0; i < l; i++) 8115 { 8116 var lnk = document.createElement('LINK'); 8117 lnk.href = arCSS[i]; 8118 lnk.rel = 'stylesheet'; 8119 lnk.type = 'text/css'; 8120 pWin.bxhead.appendChild(lnk); 8121 pLnk.push(lnk); 8122 } 8123 if (bSingle) 8124 return lnk; 8125 return pLnk; 8126 }, 8127 8128 appendBXHint : function(node, html) 8129 { 8130 if (!node || !node.parentNode || !html) 8131 return; 8132 var oBXHint = new BXHint(html); 8133 node.parentNode.insertBefore(oBXHint.oIcon, node); 8134 node.parentNode.removeChild(node); 8135 oBXHint.oIcon.style.marginLeft = "5px"; 8136 }, 8137 8138 PreventDefault : function(e) 8139 { 8140 if(!e) e = window.event; 8141 if(e.stopPropagation) 8142 { 8143 e.preventDefault(); 8144 e.stopPropagation(); 8145 } 8146 else 8147 { 8148 e.cancelBubble = true; 8149 e.returnValue = false; 8150 } 8151 return false; 8152 }, 8153 8154 CreateElement: function(tag, arAttr, arStyles, pDoc) 8155 { 8156 if (!pDoc) 8157 pDoc = document; 8158 var pEl = pDoc.createElement(tag), p; 8159 if(arAttr) 8160 { 8161 for(p in arAttr) 8162 { 8163 if(p == 'className' || p == 'class') 8164 { 8165 pEl.setAttribute('class', arAttr[p]); 8166 if (jsUtils.IsIE()) 8167 pEl.setAttribute('className', arAttr[p]); 8168 continue; 8169 } 8170 8171 if (arAttr[p] != undefined && arAttr[p] != null) 8172 pEl.setAttribute(p, arAttr[p]); 8173 } 8174 } 8175 if(arStyles) 8176 { 8177 for(p in arStyles) 8178 pEl.style[p] = arStyles[p]; 8179 } 8180 return pEl; 8181 }, 8182 8183 in_array: function(needle, haystack) 8184 { 8185 for(var i=0; i<haystack.length; i++) 8186 { 8187 if(haystack[i] == needle) 8188 return true; 8189 } 8190 return false;
8191 }, 8192 8193 htmlspecialchars: function(str) 8194 { 8195 if(!str.replace) 8196 return str; 8197 8198 return str.replace(/&/g, '&').replace(/"/g, '"').replace(/</g, '<').replace(/>/g, '>'); 8199 } 8200} 8201 8202/************************************************/ 8203 8204function JCFloatDiv() 8205{ 8206 var _this = this; 8207 this.floatDiv = null; 8208 this.x = this.y = 0; 8209 8210 this.Create = function(arParams) 8211 { 8212 var div = document.body.appendChild(document.createElement("DIV")); 8213 div.id = arParams.id; 8214 div.style.position = 'absolute'; 8215 div.style.left = '-10000px'; 8216 div.style.top = '-10000px'; 8217 if(arParams.className) 8218 div.className = arParams.className; 8219 if(arParams.zIndex) 8220 div.style.zIndex = arParams.zIndex; 8221 if(arParams.width) 8222 div.style.width = arParams.width+'px'; 8223 if(arParams.height) 8224 div.style.height = arParams.height+'px'; 8225 return div; 8226 } 8227 8228 this.Show = function(div, left, top, dxShadow, restrictDrag) 8229 { 8230 var component = BX.ZIndexManager.getComponent(div); 8231 if (!component) 8232 { 8233 BX.ZIndexManager.register(div); 8234 } 8235 8236 BX.ZIndexManager.bringToFront(div); 8237 8238 if (left < 0) 8239 left = 0; 8240 8241 if (top < 0) 8242 top = 0; 8243 8244 div.style.left = parseInt(left) + "px"; 8245 div.style.top = parseInt(top) + "px"; 8246 8247 /*Restrict drag*/ 8248 div.restrictDrag = restrictDrag || false; 8249 8250 /*shadow*/ 8251 if(isNaN(dxShadow)) 8252 dxShadow = 5; 8253 8254 div.dxShadow = dxShadow; 8255 } 8256 8257 this.Close = function(div) 8258 { 8259 if(!div) 8260 return; 8261 var sh = document.getElementById(div.id+"_shadow"); 8262 if(sh) 8263 sh.style.visibility = 'hidden'; 8264 8265 var frame = document.getElementById(div.id+"_frame"); 8266 if(frame) 8267 frame.style.visibility = 'hidden'; 8268 } 8269 8270 this.Move = function(div, x, y) 8271 { 8272 if(!div) 8273 return; 8274 8275 var dxShadow = div.dxShadow; 8276 var left = parseInt(div.style.left)+x; 8277 var top = parseInt(div.style.top)+y; 8278 8279 if (div.restrictDrag) 8280 { 8281 //Left side 8282 if (left < 0) 8283 left = 0; 8284 8285 //Right side 8286 if ( (document.compatMode && document.compatMode == "CSS1Compat")) 8287 windowWidth = document.documentElement.scrollWidth; 8288 else 8289 { 8290 if (document.body.scrollWidth > document.body.offsetWidth || 8291 (document.compatMode && document.compatMode == "BackCompat") || 8292 (document.documentElement && !document.documentElement.clientWidth) 8293 ) 8294 windowWidth = document.body.scrollWidth; 8295 else 8296 windowWidth = document.body.offsetWidth; 8297 } 8298 8299 var floatWidth = div.offsetWidth; 8300 if (left > (windowWidth - floatWidth - dxShadow)) 8301 left = windowWidth - floatWidth - dxShadow; 8302 8303 //Top side 8304 if (top < 0) 8305 top = 0; 8306 } 8307 8308 div.style.left = left+'px'; 8309 div.style.top = top+'px'; 8310 8311 this.AdjustShadow(div); 8312 } 8313 8314 this.HideShadow = function(div) 8315 { 8316 var sh = document.getElementById(div.id + "_shadow"); 8317 sh.style.visibility = 'hidden'; 8318 } 8319 8320 this.UnhideShadow = function(div) 8321 { 8322 var sh = document.getElementById(div.id + "_shadow"); 8323 sh.style.visibility = 'visible'; 8324 } 8325 8326 this.AdjustShadow = function(div) 8327 { 8328 var sh = document.getElementById(div.id + "_shadow"); 8329 if(sh && sh.style.visibility != 'hidden') 8330 { 8331 var dxShadow = div.dxShadow; 8332 8333 sh.style.width = div.offsetWidth+'px'; 8334 sh.style.height = div.offsetHeight+'px'; 8335 sh.style.left = parseInt(div.style.left)+dxShadow+'px'; 8336 sh.style.top = parseInt(div.style.top)+dxShadow+'px'; 8337 } 8338 8339 var frame = document.getElementById(div.id+"_frame"); 8340 if(frame) 8341 { 8342 frame.style.width = div.offsetWidth + "px"; 8343 frame.style.height = div.offsetHeight + "px"; 8344 frame.style.left = div.style.left; 8345 frame.style.top = div.style.top; 8346 } 8347 } 8348 8349 this.StartDrag = function(e, div) 8350 { 8351 if(!e) 8352 e = window.event; 8353 this.x = e.clientX + document.body.scrollLeft; 8354 this.y = e.clientY + document.body.scrollTop; 8355 this.floatDiv = div; 8356 8357 jsUtils.addEvent(document, "mousemove", this.MoveDrag); 8358 document.onmouseup = this.StopDrag; 8359 if(document.body.setCapture) 8360 document.body.setCapture(); 8361 8362 document.onmousedown = jsUtils.False; 8363 var b = document.body; 8364 b.ondrag = jsUtils.False; 8365 b.onselectstart = jsUtils.False; 8366 b.style.MozUserSelect = _this.floatDiv.style.MozUserSelect = 'none'; 8367 b.style.cursor = 'move'; 8368 } 8369 8370 this.StopDrag = function(e) 8371 { 8372 if(document.body.releaseCapture) 8373 document.body.releaseCapture(); 8374 8375 jsUtils.removeEvent(document, "mousemove", _this.MoveDrag); 8376 document.onmouseup = null; 8377 8378 this.floatDiv = null; 8379 8380 document.onmousedown = null; 8381 var b = document.body; 8382 b.ondrag = null; 8383 b.onselectstart = null; 8384 b.style.MozUserSelect = _this.floatDiv.style.MozUserSelect = ''; 8385 b.style.cursor = ''; 8386 } 8387 8388 this.MoveDrag = function(e) 8389 { 8390 var x = e.clientX + document.body.scrollLeft; 8391 var y = e.clientY + document.body.scrollTop; 8392 8393 if(_this.x == x && _this.y == y) 8394 return; 8395 8396 _this.Move(_this.floatDiv, (x - _this.x), (y - _this.y)); 8397 _this.x = x; 8398 _this.y = y; 8399 } 8400} 8401var jsFloatDiv = new JCFloatDiv(); 8402 8403/************************************************/ 8404 8405var BXHint = function(innerHTML, element, addParams) 8406{ 8407 this.oDivOver = false;
8408 this.timeOutID = null; 8409 this.oIcon = null; 8410 this.freeze = false; 8411 this.x = 0; 8412 this.y = 0; 8413 this.time = 700; 8414 8415 if (!innerHTML) 8416 innerHTML = ""; 8417 this.Create(innerHTML, element, addParams); 8418} 8419 8420BXHint.prototype.Create = function(innerHTML, element, addParams) 8421{ 8422 var 8423 _this = this, 8424 width = 0, 8425 height = 0, 8426 className = null, 8427 type = "icon"; 8428 this.bWidth = true; 8429 8430 if (addParams) 8431 { 8432 if (addParams.width === false) 8433 this.bWidth = false; 8434 else if (addParams.width) 8435 width = addParams.width; 8436 8437 if (addParams.height) 8438 height = addParams.height; 8439 8440 if (addParams.className) 8441 className = addParams.className; 8442 8443 if (addParams.type && (addParams.type == "link" || addParams.type == "icon")) 8444 type = addParams.type; 8445 if (addParams.time > 0) 8446 this.time = addParams.time; 8447 } 8448 8449 if (element) 8450 type = "element"; 8451 8452 if (type == "icon") 8453 { 8454 var element = document.createElement("IMG"); 8455 element.src = (addParams && addParams.iconSrc) ? addParams.iconSrc : "/bitrix/themes/"+phpVars.ADMIN_THEME_ID+"/public/popup/hint.gif"; 8456 element.ondrag = jsUtils.False; 8457 } 8458 else if (type == "link") 8459 { 8460 var element = document.createElement("A"); 8461 element.href = ""; 8462 element.onclick = function(e){return false;} 8463 element.innerHTML = "[?]"; 8464 } 8465 8466 this.element = element; 8467 if (type == "element") 8468 { 8469 if(addParams && addParams.show_on_click) 8470 { 8471 jsUtils.addEvent( 8472 element, 8473 "click", 8474 function (event) 8475 { 8476 if (!event) 8477 event = window.event; 8478 _this.GetMouseXY(event); 8479 _this.timeOutID = setTimeout(function () {_this.Show(innerHTML,width,height,className) }, 10); 8480 } 8481 ); 8482 } 8483 else 8484 { 8485 jsUtils.addEvent( 8486 element, 8487 "mouseover", 8488 function (event) 8489 { 8490 if (!event) 8491 event = window.event; 8492 _this.GetMouseXY(event); 8493 _this.timeOutID = setTimeout(function () {_this.Show(innerHTML,width,height,className) }, 750); 8494 } 8495 ); 8496 } 8497 8498 jsUtils.addEvent( 8499 element, 8500 "mouseout", 8501 function(event) 8502 { 8503 if (_this.timeOutID) 8504 clearTimeout(_this.timeOutID); 8505 _this.SmartHide(_this); 8506 } 8507 ); 8508 } 8509 else 8510 { 8511 this.oIcon = element; 8512 element.onmouseover = function(event) {if (!event) event = window.event; _this.GetMouseXY(event); _this.Show(innerHTML,width,height,className)}; 8513 element.onmouseout = function() {_this.SmartHide(_this);}; 8514 } 8515} 8516 8517BXHint.prototype.IsFrozen = function() 8518{ 8519 return this.freeze; 8520} 8521 8522BXHint.prototype.Freeze = function() 8523{ 8524 this.freeze = true; 8525 this.Hide(); 8526} 8527 8528BXHint.prototype.UnFreeze = function() 8529{ 8530 this.freeze = false; 8531} 8532 8533BXHint.prototype.GetMouseXY = function(event) 8534{ 8535 if (event.pageX || event.pageY) 8536 { 8537 this.x = event.pageX; 8538 this.y = event.pageY; 8539 } 8540 else if (event.clientX || event.clientY) 8541 { 8542 this.x = event.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) - document.documentElement.clientLeft; 8543 this.y = event.clientY + (document.documentElement.scrollTop || document.body.scrollTop) - document.documentElement.clientTop; 8544 } 8545} 8546 8547BXHint.prototype.Show = function(innerHTML, width, height, className) 8548{ 8549 //Delete previous hint 8550 var old = document.getElementById("__BXHint_div"); 8551 if (old) 8552 this.Hide(); 8553 8554 if (this.freeze) 8555 return; 8556 8557 var _this = this; 8558 var oDiv = document.body.appendChild(document.createElement("DIV")); 8559 oDiv.onmouseover = function(){_this.oDivOver = true}; 8560 oDiv.onmouseout = function(){_this.oDivOver = false; _this.SmartHide(_this);} 8561 oDiv.id = "__BXHint_div"; 8562 oDiv.className = (className) ? className : "bxhint"; 8563 oDiv.style.position = 'absolute'; 8564 if (width && this.bWidth) 8565 oDiv.style.width = width + "px"; 8566 8567 if (height) 8568 oDiv.style.height = height + "px"; 8569 oDiv.innerHTML = innerHTML; 8570 8571 var w = oDiv.offsetWidth; 8572 var h = oDiv.offsetHeight; 8573 if (this.bWidth) 8574 { 8575 if (!width && w>200) 8576 w = Math.round(Math.sqrt(1.618*w*h)); 8577 oDiv.style.width = w + "px"; 8578 h = oDiv.offsetHeight; 8579 } 8580 8581 var pos = {left : this.x + 10, right : this.x + w, top : this.y, bottom : this.y + h}; 8582 8583 pos = this.AlignToPos(pos, w, h); 8584 8585 jsFloatDiv.Show(oDiv, pos.left, pos.top,3); 8586 8587// oDiv.ondrag = jsUtils.False; 8588// oDiv.onselectstart = jsUtils.False; 8589// oDiv.style.MozUserSelect = 'none'; 8590 oDiv = null; 8591} 8592 8593BXHint.prototype.AlignToPos = function(pos, w, h) 8594{ 8595 var body = document.body; 8596 if((body.clientWidth + body.scrollLeft) < (pos.left + w)) 8597 pos.left = (pos.left - w >= 0) ? (pos.left - w) : body.scrollLeft; 8598 8599 if((body.clientHeight + body.scrollTop) - (pos["bottom"]) < 0) 8600 pos.top = (pos.top - h >= 0) ? (pos.top - h) : body.scrollTop; 8601 8602 return pos; 8603} 8604 8605BXHint.prototype.Hide = function() 8606{ 8607 var oDiv = document.getElementById("__BXHint_div"); 8608 8609 if (!oDiv) 8610 return; 8611 8612 BX.ZIndexManager.unregister(oDiv); 8613 8614 jsFloatDiv.Close(oDiv); 8615 oDiv.parentNode.removeChild(oDiv); 8616 oDiv = null; 8617} 8618 8619BXHint.prototype.SmartHide = function(_this) 8620{ 8621 setTimeout(function () 8622 { 8623 if (!_this.oDivOver) 8624 _this.Hide(); 8625 }, 100 8626 ); 8627} 8628 8629/************************************************/ 8630 8631function WaitOnKeyPress(e) 8632{ 8633 if(!e) e = window.event 8634 if(!e) return; 8635 if(e.keyCode == 27) 8636 CloseWaitWindow(); 8637} 8638 8639function ShowWaitWindow() 8640{ 8641 CloseWaitWindow(); 8642 8643 var obWndSize = jsUtils.GetWindowSize(); 8644 8645 var div = document.body.appendChild(document.createElement("DIV")); 8646 div.id = "wait_window_div"; 8647 div.innerHTML = phpVars.messLoading; 8648 div.className = "waitwindow"; 8649 //div.style.left = obWndSize.scrollLeft + (obWndSize.innerWidth - div.offsetWidth) - (jsUtils.IsIE() ? 5 : 20) + "px"; 8650 div.style.right = (5 - obWndSize.scrollLeft) + 'px'; 8651 div.style.top = obWndSize.scrollTop + 5 + "px"; 8652
8653 if(jsUtils.IsIE()) 8654 { 8655 var frame = document.createElement("IFRAME"); 8656 frame.src = "javascript:''"; 8657 frame.id = "wait_window_frame"; 8658 frame.className = "waitwindow"; 8659 frame.style.width = div.offsetWidth + "px"; 8660 frame.style.height = div.offsetHeight + "px"; 8661 frame.style.right = div.style.right; 8662 frame.style.top = div.style.top; 8663 document.body.appendChild(frame); 8664 } 8665 jsUtils.addEvent(document, "keypress", WaitOnKeyPress); 8666} 8667 8668function CloseWaitWindow() 8669{ 8670 jsUtils.removeEvent(document, "keypress", WaitOnKeyPress); 8671 8672 var frame = document.getElementById("wait_window_frame"); 8673 if(frame) 8674 frame.parentNode.removeChild(frame); 8675 8676 var div = document.getElementById("wait_window_div"); 8677 if(div) 8678 div.parentNode.removeChild(div); 8679} 8680 8681/************************************************/ 8682 8683var jsSelectUtils = 8684{ 8685 addNewOption: function(select_id, opt_value, opt_name, do_sort, check_unique) 8686 { 8687 var oSelect = (typeof(select_id) == 'string' || select_id instanceof String? document.getElementById(select_id) : select_id); 8688 if(oSelect) 8689 { 8690 var n = oSelect.length; 8691 if(check_unique !== false) 8692 { 8693 for(var i=0;i<n;i++) 8694 if(oSelect[i].value==opt_value) 8695 return; 8696 } 8697 var newoption = new Option(opt_name, opt_value, false, false); 8698 oSelect.options[n]=newoption; 8699 } 8700 if(do_sort === true) 8701 this.sortSelect(select_id); 8702 }, 8703 8704 deleteOption: function(select_id, opt_value) 8705 { 8706 var oSelect = (typeof(select_id) == 'string' || select_id instanceof String? document.getElementById(select_id) : select_id); 8707 if(oSelect) 8708 { 8709 for(var i=0;i<oSelect.length;i++) 8710 if(oSelect[i].value==opt_value) 8711 { 8712 oSelect.remove(i); 8713 break; 8714 } 8715 } 8716 }, 8717 8718 deleteSelectedOptions: function(select_id) 8719 { 8720 var oSelect = (typeof(select_id) == 'string' || select_id instanceof String? document.getElementById(select_id) : select_id); 8721 if(oSelect) 8722 { 8723 var i=0; 8724 while(i<oSelect.length) 8725 if(oSelect[i].selected) 8726 { 8727 oSelect[i].selected=false; 8728 oSelect.remove(i); 8729 } 8730 else 8731 i++; 8732 } 8733 }, 8734 8735 deleteAllOptions: function(oSelect) 8736 { 8737 if(oSelect) 8738 { 8739 for(var i=oSelect.length-1; i>=0; i--) 8740 oSelect.remove(i); 8741 } 8742 }, 8743 8744 optionCompare: function(record1, record2) 8745 { 8746 var value1 = record1.optText.toLowerCase(); 8747 var value2 = record2.optText.toLowerCase(); 8748 if (value1 > value2) return(1); 8749 if (value1 < value2) return(-1); 8750 return(0); 8751 }, 8752 8753 sortSelect: function(select_id) 8754 { 8755 var oSelect = (typeof(select_id) == 'string' || select_id instanceof String? document.getElementById(select_id) : select_id); 8756 if(oSelect) 8757 { 8758 var myOptions = []; 8759 var n = oSelect.options.length; 8760 for (var i=0;i<n;i++) 8761 { 8762 myOptions[i] = { 8763 optText:oSelect[i].text, 8764 optValue:oSelect[i].value 8765 }; 8766 } 8767 myOptions.sort(this.optionCompare); 8768 oSelect.length=0; 8769 n = myOptions.length; 8770 for(var i=0;i<n;i++) 8771 { 8772 var newoption = new Option(myOptions[i].optText, myOptions[i].optValue, false, false); 8773 oSelect[i]=newoption; 8774 } 8775 } 8776 }, 8777 8778 selectAllOptions: function(select_id) 8779 { 8780 var oSelect = (typeof(select_id) == 'string' || select_id instanceof String? document.getElementById(select_id) : select_id); 8781 if(oSelect) 8782 { 8783 var n = oSelect.length; 8784 for(var i=0;i<n;i++) 8785 oSelect[i].selected=true; 8786 } 8787 }, 8788 8789 selectOption: function(select_id, opt_value) 8790 { 8791 var oSelect = (typeof(select_id) == 'string' || select_id instanceof String? document.getElementById(select_id) : select_id); 8792 if(oSelect) 8793 { 8794 var n = oSelect.length; 8795 for(var i=0;i<n;i++) 8796 oSelect[i].selected = (oSelect[i].value == opt_value); 8797 } 8798 }, 8799 8800 addSelectedOptions: function(oSelect, to_select_id, check_unique, do_sort) 8801 { 8802 if(!oSelect) 8803 return; 8804 var n = oSelect.length; 8805 for(var i=0; i<n; i++) 8806 if(oSelect[i].selected) 8807 this.addNewOption(to_select_id, oSelect[i].value, oSelect[i].text, do_sort, check_unique); 8808 }, 8809 8810 moveOptionsUp: function(oSelect) 8811 { 8812 if(!oSelect) 8813 return; 8814 var n = oSelect.length; 8815 for(var i=0; i<n; i++) 8816 { 8817 if(oSelect[i].selected && i>0 && oSelect[i-1].selected == false) 8818 { 8819 var option1 = new Option(oSelect[i].text, oSelect[i].value); 8820 var option2 = new Option(oSelect[i-1].text, oSelect[i-1].value); 8821 oSelect[i] = option2; 8822 oSelect[i].selected = false;
8823 oSelect[i-1] = option1; 8824 oSelect[i-1].selected = true; 8825 } 8826 } 8827 }, 8828 8829 moveOptionsDown: function(oSelect) 8830 { 8831 if(!oSelect) 8832 return; 8833 var n = oSelect.length; 8834 for(var i=n-1; i>=0; i--) 8835 { 8836 if(oSelect[i].selected && i<n-1 && oSelect[i+1].selected == false) 8837 { 8838 var option1 = new Option(oSelect[i].text, oSelect[i].value); 8839 var option2 = new Option(oSelect[i+1].text, oSelect[i+1].value); 8840 oSelect[i] = option2; 8841 oSelect[i].selected = false; 8842 oSelect[i+1] = option1; 8843 oSelect[i+1].selected = true; 8844 } 8845 } 8846 } 8847 8848} 8849 8850/************************************************/ 8851 8852/* End */ 8853; 8854; /* Start:"a:4:{s:4:"full";s:49:"/bitrix/js/main/core/core_timer.js?16337965126316";s:6:"source";s:34:"/bitrix/js/main/core/core_timer.js";s:3:"min";s:0:"";s:3:"map";s:0:"";}"*/ 8855(function(window){ 8856if (window.BX.timer) return; 8857 8858var timers = [], 8859 timeout = 200, 8860 obTimer = null, 8861 last_index = 0; 8862 8863BX.timer = function(container, params) 8864{ 8865 params = params || {}; 8866 if (BX.type.isString(container) || BX.type.isElementNode(container)) 8867 params.container = container; 8868 else if (typeof (container) == "object") 8869 params = container; 8870 8871 if (!params.container) 8872 return false; 8873 8874 var ob = new BX.CTimer(params); 8875 BX.timer.start(ob); 8876 8877 if (null == obTimer) 8878 { 8879 obTimer = setInterval(_RunTimer, timeout); 8880 BX.garbage(BX.timer.clear); 8881 } 8882 8883 return ob; 8884} 8885 8886BX.timer.stop = function(timer) 8887{ 8888 timers[timer.TIMER_INDEX] = null; 8889} 8890 8891BX.timer.start = function(timer) 8892{ 8893 timer.TIMER_INDEX = last_index; 8894 timers[last_index++] = timer; 8895} 8896 8897BX.timer.clock = function(cont, dt) 8898{ 8899 return BX.timer({container: cont, dt: dt}); 8900} 8901 8902BX.timer.clear = function() 8903{ 8904 clearInterval(obTimer); 8905 timers = null; 8906} 8907 8908BX.timer.registerFormat = function(format_name, format_handler) 8909{ 8910 BX.CTimer.prototype.formatValueHandlers[format_name] = format_handler 8911} 8912 8913BX.timer.getHandler = function(format_name) 8914{ 8915 return BX.CTimer.prototype.formatValueHandlers[format_name]; 8916} 8917 8918BX.CTimer = function(params, index) 8919{ 8920 this.container = params.container; 8921 this.from = params.from ? parseInt(params.from.valueOf()) : null; 8922 this.to = params.to ? parseInt(params.to.valueOf()) : null; 8923 this.index = index; 8924 8925 this.dt = parseInt(params.dt); 8926 if (isNaN(this.dt)) 8927 this.dt = 0; 8928 8929 this.display = params.display || (BX.isAmPmMode() ? 'clock_am_pm' : 'clock'); // other variants - 'simple', 'worktime' 8930 8931 this.accuracy = params.accuracy || 60; // default timing acccuracy is 1 minute 8932 8933 // if (this.from) 8934 // this.from = new Date(parseInt(this.from.valueOf() / this.accuracy) * this.accuracy); 8935 // if (this.to) 8936 // this.to = new Date(parseInt(this.to.valueOf() / this.accuracy) * this.accuracy); 8937 8938 this.callback = this.from ? this._callback_from : (this.to ? this._callback_to : this._callback); 8939 this.callback_finish = params.callback_finish; 8940 8941 this.formatValue = this.formatValueHandlers.clock; 8942 8943 this.bInited = false; 8944 BX.ready(BX.delegate(this.Init, this)); 8945} 8946 8947BX.CTimer.prototype.Init = function() 8948{ 8949 if (this.bInited) 8950 return; 8951 8952 this.container = BX(this.container); 8953 this.container_value_fld = this.container.tagName.toUpperCase() == 'INPUT' ? 'value' : 'innerHTML'; 8954 if (this.container_value_fld == 'value' && (this.display == 'clock' || this.display == 'clock_am_pm')) 8955 { 8956 if (this.display == 'clock') 8957 { 8958 this.display = 'simple'; 8959 } 8960 else if (this.display == 'clock_am_pm') 8961 { 8962 this.display = 'simple_am_pm'; 8963 } 8964 } 8965 8966 this.formatValue = this.formatValueHandlers[this.display] ? this.formatValueHandlers[this.display] : this.formatValueHandlers.clock; 8967 8968 this.bInited = true; 8969} 8970 8971BX.CTimer.prototype.setFrom = function(from) 8972{ 8973 if (!this.from) return; 8974 this.from = from; 8975} 8976 8977BX.CTimer.prototype.setTo = function(to) 8978{ 8979 if (!this.to) return; 8980 this.to = to; 8981} 8982 8983BX.CTimer.prototype._callback = function(date) 8984{ 8985 if (this.dt !== 0) 8986 var date = new Date(date.valueOf() + this.dt); 8987 8988 this.setValue(this.formatValue(date.getHours(), date.getMinutes(), date.getSeconds())); 8989} 8990 8991BX.CTimer.prototype._callback_from = function(date) 8992{ 8993 var diff = (date.valueOf() - this.from.valueOf() + this.dt)/1000; 8994 this.setValue( 8995 this.formatValue( 8996 parseInt(diff / 3600), 8997 parseInt((diff % 3600) / 60), 8998 parseInt(diff % 60) 8999 ) 9000 ); 9001} 9002 9003BX.CTimer.prototype._callback_to = function(date) 9004{ 9005 var diff = (this.to.valueOf() - date.valueOf())/1000; 9006 if (diff > 0) 9007 { 9008 this.setValue( 9009 this.formatValue( 9010 parseInt(diff / 3600), 9011 parseInt((diff % 3600) / 60), 9012 parseInt(diff % 60) 9013 ) 9014 ); 9015 } 9016 else 9017 { 9018 this.Finish(); 9019 } 9020} 9021 9022BX.CTimer.prototype.formatValueHandlers = { 9023 clock: function(h, m, s) 9024 { 9025 var d = '<span class="bx-timer-semicolon">:</span>'; 9026 9027 return BX.util.str_pad(h, 2, '0', 'left') 9028 + d 9029 + (this.accuracy >= 3600 9030 ? '00' 9031 : BX.util.str_pad(m, 2, '0', 'left')) 9032 + (this.accuracy >= 60 9033 ? '' 9034 : 9035 (d + BX.util.str_pad(s, 2, '0', 'left')) 9036 ); 9037 }, 9038 clock_am_pm: function(h, m, s) 9039 { 9040 var mt = 'am'; 9041 var d = '<span class="bx-timer-semicolon">:</span>'; 9042 9043 if (h > 12) 9044 { 9045 h = h - 12; 9046 mt = 'pm'; 9047 } 9048 else if (h == 0) 9049 { 9050 h = 12; 9051 mt = 'am'; 9052 } 9053 else if (h == 12) 9054 { 9055 mt = 'pm'; 9056 } 9057 9058 return h 9059 + d 9060 + (this.accuracy >= 3600 9061 ? '00' 9062 : BX.util.str_pad(m, 2, '0', 'left')) 9063 + (this.accuracy >= 60 9064 ? '' 9065 : 9066 (d + BX.util.str_pad(s, 2, '0', 'left')) 9067 ) 9068 + ' ' + mt; 9069 }, 9070 simple: function(h, m, s) 9071 { 9072 return BX.util.str_pad(h, 2, '0', 'left') 9073 + ':' 9074 + (this.accuracy >= 3600 9075 ? '00' 9076 : BX.util.str_pad(m, 2, '0', 'left')) 9077 9078 + (this.accuracy >= 60 9079 ? '' 9080 : 9081 (':' + BX.util.str_pad(s, 2, '0', 'left')) 9082 ); 9083 }, 9084 simple_am_pm: function(h, m, s) 9085 { 9086 var mt = 'am'; 9087 9088 if (h > 12) 9089 { 9090 h = h - 12; 9091 mt = 'pm'; 9092 } 9093 else if (h == 0) 9094 { 9095 h = 12; 9096 mt = 'am'; 9097 } 9098 else if (h == 12) 9099 { 9100 mt = 'pm'; 9101 } 9102 return h 9103 + ':' 9104 + (this.accuracy >= 3600 9105 ? '00' 9106 : BX.util.str_pad(m, 2, '0', 'left')) 9107 9108 + (this.accuracy >= 60 9109 ? '' 9110 : 9111 (':' + BX.util.str_pad(s, 2, '0', 'left')) 9112 ) + ' ' + mt; 9113 }, 9114 worktime: function(h, m, s) 9115 { 9116 return h + BX.message('JS_CORE_H') + ' ' 9117 + (this.accuracy >= 3600 9118 ? '' 9119 : m + BX.message('JS_CORE_M') 9120 + (this.accuracy >= 60 9121 ? '' 9122 : ' ' + s + BX.message('JS_CORE_S') 9123 ) 9124 ); 9125 }, 9126 worktime_short: function(h, m, s) 9127 { 9128 return BX.util.rtrim((h > 0 ? h + BX.message('JS_CORE_H') + ' ' : '') 9129 + (m > 0 && this.accuracy < 3600 ? m + BX.message('JS_CORE_M') + ' ' : '') 9130 + (this.accuracy >= 60 9131 ? '' 9132 : (s > 0 ? s + BX.message('JS_CORE_S') : '') 9133 )); 9134 } 9135} 9136 9137BX.CTimer.prototype.setValue = function(value) 9138{ 9139 if (this.bInited) 9140 { 9141 if (value != this._last_value) 9142 this.container[this.container_value_fld] = value; 9143 9144 this._last_value = value; 9145 } 9146} 9147 9148BX.CTimer.prototype.Finish = function() 9149{ 9150 BX.timer.stop(this); 9151 9152 if (this.callback_finish) 9153 this.callback_finish.apply(this); 9154 9155 BX.cleanNode(this.container.parentNode); 9156} 9157 9158function _RunTimer() 9159{ 9160 var current_moment = new Date(); 9161 9162 for (var i=0,len=last_index;i<len;i++) 9163 { 9164 if (timers[i] && timers[i].callback) 9165 timers[i].callback.apply(timers[i], [current_moment]); 9166 } 9167 9168 current_moment = null; 9169} 9170})(window) 9171 9172/* End */ 9173; 9174; /* Start:"a:4:{s:4:"full";
9174s:37:"/bitrix/js/main/dd.js?168616490514809";s:6:"source";s:21:"/bitrix/js/main/dd.js";s:3:"min";s:0:"";s:3:"map";s:0:"";}"*/ 9175;(function(){ 9176 9177if (window.jsDD) 9178 return; 9179 9180jsDD = { 9181 arObjects: [], 9182 arDestinations: [], 9183 arDestinationsPriority: [], 9184 9185 arContainers: [], 9186 arContainersPos: [], 9187 9188 current_dest_index: false, 9189 current_node: null, 9190 9191 wndSize: null, 9192 9193 bStarted: false, 9194 bDisable: false, 9195 bDisableDestRefresh: false, 9196 9197 bEscPressed: false, 9198 9199 bScrollWindow: false, 9200 scrollViewTimer: null, 9201 scrollViewConfig: { 9202 checkerTimeout: 30, 9203 scrollZone: 25, 9204 scrollBy: 25, 9205 scrollContainer: null, 9206 bScrollH: true, 9207 bScrollV: true, 9208 pos: null 9209 }, 9210 9211 setScrollWindow: function(val) 9212 { 9213 jsDD.bScrollWindow = !!val; 9214 if (BX.type.isDomNode(val)) 9215 { 9216 jsDD.scrollViewConfig.scrollContainer = val; 9217 jsDD.scrollViewConfig.pos = BX.pos(val); 9218 9219 var s = BX.style(val, 'overflow') || 'visible', 9220 s1 = BX.style(val, 'overflow-x') || 'visible', 9221 s2 = BX.style(val, 'overflow-y') || 'visible'; 9222 9223 jsDD.scrollViewConfig.bScrollH = s != 'visible' || s1 != 'visible'; 9224 jsDD.scrollViewConfig.bScrollV = s != 'visible' || s2 != 'visible'; 9225 } 9226 }, 9227 9228 Reset: function() 9229 { 9230 jsDD.arObjects = []; 9231 jsDD.arDestinations = []; 9232 jsDD.arDestinationsPriority = []; 9233 jsDD.bStarted = false; 9234 jsDD.current_node = null; 9235 jsDD.current_dest_index = false; 9236 jsDD.bDisableDestRefresh = false; 9237 jsDD.bDisable = false; 9238 jsDD.x = null; 9239 jsDD.y = null; 9240 jsDD.start_x = null; 9241 jsDD.start_y = null; 9242 jsDD.wndSize = null; 9243 9244 jsDD.bEscPressed = false; 9245 9246 clearInterval(jsDD.scrollViewTimer) 9247 jsDD.bScrollWindow = false; 9248 jsDD.scrollViewTimer = null; 9249 jsDD.scrollViewConfig.scrollContainer = null; 9250 }, 9251 9252 registerObject: function (obNode) 9253 { 9254 BX.bind(obNode, 'mousedown', jsDD.startDrag); 9255 BX.Event.bind(obNode, 'touchstart', jsDD.startDrag, { passive: true }); 9256 9257 obNode.__bxddid = jsDD.arObjects.length; 9258 9259 jsDD.arObjects[obNode.__bxddid] = obNode; 9260 }, 9261 unregisterObject: function(obNode) 9262 { 9263 if(typeof(obNode["__bxddid"]) === "undefined") 9264 { 9265 return; 9266 } 9267 9268 delete jsDD.arObjects[obNode.__bxddid]; 9269 delete obNode.__bxddid; 9270 BX.unbind(obNode, 'mousedown', jsDD.startDrag); 9271 BX.unbind(obNode, 'touchstart', jsDD.startDrag); 9272 }, 9273 registerDest: function (obDest, priority) 9274 { 9275 if (!priority) 9276 priority = 100; 9277 9278 obDest.__bxddeid = jsDD.arDestinations.length; 9279 obDest.__bxddpriority = priority; 9280 9281 jsDD.arDestinations[obDest.__bxddeid] = obDest; 9282 if (!jsDD.arDestinationsPriority[priority]) 9283 jsDD.arDestinationsPriority[priority] = [obDest.__bxddeid] 9284 else 9285 jsDD.arDestinationsPriority[priority].push(obDest.__bxddeid); 9286 9287 jsDD.refreshDestArea(obDest.__bxddeid); 9288 }, 9289 unregisterDest: function(obDest) 9290 { 9291 if(typeof(obDest["__bxddeid"]) === "undefined") 9292 { 9293 return; 9294 } 9295 9296 delete jsDD.arDestinations[obDest.__bxddeid]; 9297 delete obDest.__bxddeid; 9298 delete obDest.__bxddpriority; 9299 9300 jsDD.refreshDestArea(); 9301 }, 9302 disableDest: function(obDest) 9303 { 9304 if (typeof(obDest.__bxddeid) !== "undefined") 9305 { 9306 obDest.__bxdddisabled = true; 9307 } 9308 }, 9309 9310 enableDest: function(obDest) 9311 { 9312 if (typeof(obDest.__bxddeid) !== "undefined") 9313 { 9314 obDest.__bxdddisabled = false; 9315 } 9316 }, 9317 9318 registerContainer: function (obCont) 9319 { 9320 jsDD.arContainers[jsDD.arContainers.length] = obCont; 9321 }, 9322 9323 getContainersScrollPos: function(x, y) 9324 { 9325 var pos = {'left':0, 'top':0}; 9326 for(var i=0, n=jsDD.arContainers.length; i<n; i++) 9327 { 9328 if(jsDD.arContainers[i] && x >= jsDD.arContainersPos[i]["left"] && x <= jsDD.arContainersPos[i]["right"] && y >= jsDD.arContainersPos[i]["top"] && y <= jsDD.arContainersPos[i]["bottom"]) 9329 { 9330 pos.left = jsDD.arContainers[i].scrollLeft; 9331 pos.top = jsDD.arContainers[i].scrollTop; 9332 } 9333 } 9334 return pos; 9335 }, 9336 9337 setContainersPos: function() 9338 { 9339 for(var i=0, n=jsDD.arContainers.length; i<n; i++) 9340 { 9341 if(jsDD.arContainers[i]) 9342 jsDD.arContainersPos[i] = BX.pos(jsDD.arContainers[i]); 9343 } 9344 }, 9345 9346 refreshDestArea: function(id) 9347 { 9348 if (id && typeof (id) == "object" && typeof (id.__bxddeid) != 'undefined') 9349 { 9350 id = id.__bxddeid; 9351 } 9352 9353 if (typeof id == 'undefined') 9354 { 9355 for (var i = 0, cnt = jsDD.arDestinations.length; i < cnt; i++) 9356 { 9357 jsDD.refreshDestArea(i); 9358 } 9359 } 9360 else 9361 { 9362 if (null == jsDD.arDestinations[id]) 9363 return; 9364 9365 var arPos = BX.pos(jsDD.arDestinations[id]);
9366 jsDD.arDestinations[id].__bxpos = [arPos.left, arPos.top, arPos.right, arPos.bottom]; 9367 } 9368 }, 9369 9370 _checkEsc: function(e) 9371 { 9372 e = e||window.event; 9373 if (jsDD.bStarted && e.keyCode == 27) 9374 { 9375 jsDD.stopCurrentDrag(); 9376 } 9377 }, 9378 9379 stopCurrentDrag: function() 9380 { 9381 if (jsDD.bStarted) 9382 { 9383 jsDD.bEscPressed = true; 9384 jsDD.stopDrag(); 9385 } 9386 }, 9387 9388 /* scroll checkers */ 9389 9390 _onscroll: function() { 9391 jsDD.wndSize = BX.GetWindowSize(); 9392 }, 9393 9394 _checkScroll: function() 9395 { 9396 if (jsDD.bScrollWindow) 9397 { 9398 var pseudo_e = { 9399 clientX: jsDD.x - jsDD.wndSize.scrollLeft, 9400 clientY: jsDD.y - jsDD.wndSize.scrollTop 9401 }, 9402 bChange = false, 9403 d = jsDD.scrollViewConfig.scrollZone; 9404 9405 // check whether window scroll needed 9406 if (pseudo_e.clientY < d && jsDD.wndSize.scrollTop > 0) 9407 { 9408 window.scrollBy(0, -jsDD.scrollViewConfig.scrollBy); 9409 bChange = true; 9410 } 9411 9412 if (pseudo_e.clientY > jsDD.wndSize.innerHeight - d && jsDD.wndSize.scrollTop < jsDD.wndSize.scrollHeight - jsDD.wndSize.innerHeight) 9413 { 9414 window.scrollBy(0, jsDD.scrollViewConfig.scrollBy); 9415 bChange = true; 9416 } 9417 9418 if (pseudo_e.clientX < d && jsDD.wndSize.scrollLeft > 0) 9419 { 9420 window.scrollBy(-jsDD.scrollViewConfig.scrollBy, 0); 9421 bChange = true; 9422 } 9423 9424 if (pseudo_e.clientX > jsDD.wndSize.innerWidth - d && jsDD.wndSize.scrollLeft < jsDD.wndSize.scrollWidth - jsDD.wndSize.innerWidth) 9425 { 9426 window.scrollBy(jsDD.scrollViewConfig.scrollBy, 0); 9427 bChange = true; 9428 } 9429 9430 // check whether container scroll needed 9431 9432 if (jsDD.scrollViewConfig.scrollContainer) 9433 { 9434 var c = jsDD.scrollViewConfig.scrollContainer; 9435 9436 if (jsDD.scrollViewConfig.bScrollH) 9437 { 9438 if (pseudo_e.clientX + jsDD.wndSize.scrollLeft < jsDD.scrollViewConfig.pos.left + d && c.scrollLeft > 0) 9439 { 9440 c.scrollLeft -= jsDD.scrollViewConfig.scrollBy; 9441 bChange = true; 9442 } 9443 9444 if (pseudo_e.clientX + jsDD.wndSize.scrollLeft > jsDD.scrollViewConfig.pos.right - d 9445 && c.scrollLeft < c.scrollWidth - c.offsetWidth) 9446 { 9447 c.scrollLeft += jsDD.scrollViewConfig.scrollBy; 9448 bChange = true; 9449 } 9450 } 9451 9452 if (jsDD.scrollViewConfig.bScrollV) 9453 { 9454 if (pseudo_e.clientY + jsDD.wndSize.scrollTop < jsDD.scrollViewConfig.pos.top + d && c.scrollTop > 0) 9455 { 9456 c.scrollTop -= jsDD.scrollViewConfig.scrollBy; 9457 bChange = true; 9458 } 9459 9460 if (pseudo_e.clientY + jsDD.wndSize.scrollTop > jsDD.scrollViewConfig.pos.bottom - d 9461 && c.scrollTop < c.scrollHeight - c.offsetHeight) 9462 { 9463 c.scrollTop += jsDD.scrollViewConfig.scrollBy; 9464 bChange = true; 9465 } 9466 } 9467 } 9468 9469 if (bChange) 9470 { 9471 jsDD._onscroll(); 9472 jsDD.drag(pseudo_e); 9473 } 9474 } 9475 }, 9476 9477 /* DD process */ 9478 9479 startDrag: function(e) 9480 { 9481 if (jsDD.bDisable) 9482 return true; 9483 9484 e = e || window.event; 9485 9486 if (!(BX.getEventButton(e)&BX.MSLEFT)) 9487 return true; 9488 9489 jsDD.current_node = null; 9490 if (e.currentTarget) 9491 { 9492 jsDD.current_node = e.currentTarget; 9493 if (null == jsDD.current_node || null == jsDD.current_node.__bxddid) 9494 { 9495 jsDD.current_node = null; 9496 return; 9497 } 9498 } 9499 else 9500 { 9501 jsDD.current_node = e.srcElement; 9502 if (null == jsDD.current_node) 9503 return; 9504 9505 while (null == jsDD.current_node.__bxddid) 9506 { 9507 jsDD.current_node = jsDD.current_node.parentNode; 9508 if (jsDD.current_node.tagName == 'BODY') 9509 return; 9510 } 9511 } 9512 9513 jsDD.bStarted = false; 9514 jsDD.bPreStarted = true; 9515 9516 jsDD.wndSize = BX.GetWindowSize(); 9517 9518 jsDD.start_x = e.clientX + jsDD.wndSize.scrollLeft; 9519 jsDD.start_y = e.clientY + jsDD.wndSize.scrollTop; 9520 9521 BX.bind(document, "mouseup", jsDD.stopDrag); 9522 BX.bind(document, "touchend", jsDD.stopDrag); 9523 BX.bind(document, "mousemove", jsDD.drag); 9524 BX.bind(document, "touchmove", jsDD.drag); 9525 BX.bind(window, 'scroll', jsDD._onscroll); 9526 9527 if(document.body.setCapture) 9528 document.body.setCapture(); 9529 9530 if (!jsDD.bDisableDestRefresh) 9531 jsDD.refreshDestArea(); 9532 9533 jsDD.setContainersPos(); 9534 9535 if(e.type !== "touchstart") 9536 { 9537 jsDD.denySelection(); 9538 return BX.PreventDefault(e); 9539 } 9540 else 9541 { 9542 return true; 9543 } 9544 }, 9545 9546 start: function() 9547 { 9548 if (jsDD.bDisable) 9549 return true; 9550 9551 document.body.style.cursor = 'move'; 9552 9553 if (jsDD.current_node.onbxdragstart) 9554 jsDD.current_node.onbxdragstart(); 9555 9556 for (var i = 0, cnt = jsDD.arDestinations.length; i < cnt; i++) 9557 { 9558 if (jsDD.arDestinations[i] && jsDD.arDestinations[i].onbxdestdragstart) 9559 jsDD.arDestinations[i].onbxdestdragstart(jsDD.current_node); 9560 } 9561 9562 jsDD.bStarted = true; 9563 jsDD.bPreStarted = false;
9564 9565 if (jsDD.bScrollWindow) 9566 { 9567 if (jsDD.scrollViewTimer) 9568 clearInterval(jsDD.scrollViewTimer); 9569 9570 jsDD.scrollViewTimer = setInterval(jsDD._checkScroll, jsDD.scrollViewConfig.checkerTimeout); 9571 } 9572 9573 BX.bind(document, 'keypress', this._checkEsc); 9574 }, 9575 9576 drag: function(e) 9577 { 9578 if (jsDD.bDisable) 9579 return true; 9580 9581 e = e || window.event; 9582 9583 jsDD.x = e.clientX + jsDD.wndSize.scrollLeft; 9584 jsDD.y = e.clientY + jsDD.wndSize.scrollTop; 9585 9586 if (!jsDD.bStarted) 9587 { 9588 var delta = 5; 9589 if(jsDD.x >= jsDD.start_x-delta && jsDD.x <= jsDD.start_x+delta && jsDD.y >= jsDD.start_y-delta && jsDD.y <= jsDD.start_y+delta) 9590 return true; 9591 9592 jsDD.start(); 9593 } 9594 9595 if (jsDD.current_node.onbxdrag) 9596 { 9597 jsDD.current_node.onbxdrag(jsDD.x, jsDD.y, e); 9598 } 9599 9600 var containersScroll = jsDD.getContainersScrollPos(jsDD.x, jsDD.y); 9601 var current_dest_index = jsDD.searchDest(jsDD.x+containersScroll.left, jsDD.y+containersScroll.top); 9602 9603 if (current_dest_index !== jsDD.current_dest_index) 9604 { 9605 if (jsDD.current_dest_index !== false) 9606 { 9607 if (jsDD.current_node.onbxdraghout) 9608 jsDD.current_node.onbxdraghout(jsDD.arDestinations[jsDD.current_dest_index], jsDD.x, jsDD.y); 9609 9610 if (jsDD.arDestinations[jsDD.current_dest_index].onbxdestdraghout) 9611 jsDD.arDestinations[jsDD.current_dest_index].onbxdestdraghout(jsDD.current_node, jsDD.x, jsDD.y); 9612 } 9613 9614 if (current_dest_index !== false) 9615 { 9616 if (jsDD.current_node.onbxdraghover) 9617 jsDD.current_node.onbxdraghover(jsDD.arDestinations[current_dest_index], jsDD.x, jsDD.y); 9618 9619 if (jsDD.arDestinations[current_dest_index].onbxdestdraghover) 9620 jsDD.arDestinations[current_dest_index].onbxdestdraghover(jsDD.current_node, jsDD.x, jsDD.y); 9621 } 9622 } 9623 9624 jsDD.current_dest_index = current_dest_index; 9625 }, 9626 9627 stopDrag: function(e) 9628 { 9629 BX.unbind(document, 'keypress', jsDD._checkEsc); 9630 9631 e = e || window.event; 9632 9633 jsDD.bPreStarted = false; 9634 9635 if (jsDD.bStarted) 9636 { 9637 if (!jsDD.bEscPressed) 9638 { 9639 jsDD.x = e.clientX + jsDD.wndSize.scrollLeft; 9640 jsDD.y = e.clientY + jsDD.wndSize.scrollTop; 9641 } 9642 9643 if (null != jsDD.current_node.onbxdragstop) 9644 jsDD.current_node.onbxdragstop(jsDD.x, jsDD.y, e); 9645 9646 var containersScroll = jsDD.getContainersScrollPos(jsDD.x, jsDD.y); 9647 var dest_index = jsDD.searchDest(jsDD.x+containersScroll.left, jsDD.y+containersScroll.top); 9648 9649 if (false !== dest_index) 9650 { 9651 if (jsDD.bEscPressed) 9652 { 9653 if (null != jsDD.arDestinations[dest_index].onbxdestdraghout) 9654 { 9655 if (!jsDD.arDestinations[dest_index].onbxdestdraghout(jsDD.current_node, jsDD.x, jsDD.y)) 9656 dest_index = false; 9657 else 9658 { 9659 if (null != jsDD.current_node.onbxdragfinish) 9660 jsDD.current_node.onbxdragfinish(jsDD.arDestinations[dest_index], jsDD.x, jsDD.y); 9661 } 9662 } 9663 9664 } 9665 else 9666 { 9667 if (null != jsDD.arDestinations[dest_index].onbxdestdragfinish) 9668 { 9669 if (!jsDD.arDestinations[dest_index].onbxdestdragfinish(jsDD.current_node, jsDD.x, jsDD.y, e)) 9670 dest_index = false; 9671 else 9672 { 9673 if (null != jsDD.current_node.onbxdragfinish) 9674 jsDD.current_node.onbxdragfinish(jsDD.arDestinations[dest_index], jsDD.x, jsDD.y); 9675 } 9676 } 9677 } 9678 } 9679 9680 if (false === dest_index) 9681 { 9682 if (null != jsDD.current_node.onbxdragrelease) 9683 jsDD.current_node.onbxdragrelease(jsDD.x, jsDD.y); 9684 } 9685 else 9686 { 9687 for (var i = 0, cnt = jsDD.arDestinations.length; i < cnt; i++) 9688 { 9689 if (i != dest_index && jsDD.arDestinations[i] && null != jsDD.arDestinations[i].onbxdestdragrelease) 9690 jsDD.arDestinations[i].onbxdestdragrelease(jsDD.current_node, jsDD.x, jsDD.y); 9691 } 9692 } 9693 9694 for (var i = 0, cnt = jsDD.arDestinations.length; i < cnt; i++) 9695 { 9696 if (jsDD.arDestinations[i] && null != jsDD.arDestinations[i].onbxdestdragstop) 9697 jsDD.arDestinations[i].onbxdestdragstop(jsDD.current_node, jsDD.x, jsDD.y); 9698 } 9699 } 9700 9701 if(document.body.releaseCapture) 9702 document.body.releaseCapture(); 9703 9704 BX.unbind(window, 'scroll', jsDD._onscroll); 9705 BX.unbind(document, "mousemove", jsDD.drag); 9706 BX.unbind(document, "touchmove", jsDD.drag); 9707 BX.unbind(document, "keypress", jsDD._checkEsc); 9708 BX.unbind(document, "mouseup", jsDD.stopDrag); 9709 BX.unbind(document, "touchend", jsDD.stopDrag); 9710 9711 jsDD.allowSelection(); 9712 document.body.style.cursor = ''; 9713 9714 jsDD.current_node = null; 9715 jsDD.current_dest_index = false;
9716 9717 if (jsDD.bScrollWindow) 9718 { 9719 if (jsDD.scrollViewTimer) 9720 clearInterval(jsDD.scrollViewTimer); 9721 } 9722 9723 if (jsDD.bStarted && !jsDD.bDisableDestRefresh) 9724 jsDD.refreshDestArea(); 9725 9726 jsDD.bStarted = false; 9727 jsDD.bEscPressed = false; 9728 }, 9729 9730 searchDest: function(x, y) 9731 { 9732 var p, len, p1, len1, i; 9733 for (p = 0, len = jsDD.arDestinationsPriority.length; p < len; p++) 9734 { 9735 if (jsDD.arDestinationsPriority[p] && BX.type.isArray(jsDD.arDestinationsPriority[p])) 9736 { 9737 for (p1 = 0, len1 = jsDD.arDestinationsPriority[p].length; p1 < len1; p1++) 9738 { 9739 i = jsDD.arDestinationsPriority[p][p1]; 9740 if (jsDD.arDestinations[i] && !jsDD.arDestinations[i].__bxdddisabled) 9741 { 9742 if ( 9743 jsDD.arDestinations[i].__bxpos[0] <= x && 9744 jsDD.arDestinations[i].__bxpos[2] >= x && 9745 9746 jsDD.arDestinations[i].__bxpos[1] <= y && 9747 jsDD.arDestinations[i].__bxpos[3] >= y 9748 ) 9749 { 9750 return i; 9751 } 9752 } 9753 } 9754 } 9755 } 9756 9757 return false; 9758 }, 9759 9760 allowSelection: function() 9761 { 9762 document.onmousedown = document.ontouchstart = null; 9763 var b = document.body; 9764 b.ondrag = null; 9765 b.onselectstart = null; 9766 b.style.MozUserSelect = ''; 9767 9768 if (jsDD.current_node) 9769 { 9770 jsDD.current_node.ondrag = null; 9771 jsDD.current_node.onselectstart = null; 9772 jsDD.current_node.style.MozUserSelect = ''; 9773 } 9774 }, 9775 9776 denySelection: function() 9777 { 9778 document.onmousedown = document.ontouchstart = BX.False; 9779 var b = document.body; 9780 b.ondrag = BX.False; 9781 b.onselectstart = BX.False; 9782 b.style.MozUserSelect = 'none'; 9783 if (jsDD.current_node) 9784 { 9785 jsDD.current_node.ondrag = BX.False; 9786 jsDD.current_node.onselectstart = BX.False; 9787 jsDD.current_node.style.MozUserSelect = 'none'; 9788 } 9789 }, 9790 9791 Disable: function() {jsDD.bDisable = true;}, 9792 Enable: function() {jsDD.bDisable = false;} 9793} 9794 9795})(); 9796 9797/* End */ 9798;
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.