Server IP : 80.87.202.40 / Your IP : 216.73.216.169 Web Server : Apache System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64 User : bitrix ( 600) PHP Version : 8.2.27 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/bitrix/ext_www/rospirotorg.ru/bitrix/js/skyweb24.popuppro/admin/ |
Upload File : |
BX.ready(function () { BX.namespace("PopupproAdminTimer"); BX.PopupproAdminTimer = function (){ this.init(); }; BX.PopupproAdminTimer.prototype = { timer: undefined, init: function () { this._timerSettingBlock = $('.block.timer'); this._nameTimerClass = "skyweb24_popup_pro_timer"; this.getTemplate().then(html => { this.timer = html; this.updateData(); this.startTimer($('.preview-iframe').contents().find('.clock')); this.correctPositionBecauseTimer() }); this.renderFormPositionTimer(); this._events(); }, getTemplate: function () { return new Promise(resolve => { $.ajax({ type: "POST", url: "/bitrix/admin/skyweb24_popuppro.php?ajax=y&command=gettimertemplate", async: false, success: data => resolve(data) }); }); }, getHtml: function () { let html = '' if (this._isPopupSupport && this._isOnTimer) { let jElement = $(this.timer); jElement.css('box-sizing', 'border-box'); //position jElement[0].className = this._nameTimerClass; this._classesPos.forEach((v) => jElement[0].className += ' ' + v); //text jElement.find("span.title").text(this._text); html = jElement[0].outerHTML; } return html; }, isTop: function () { return this._isTop; }, isPopSuppot: function () { return this._isPopupSupport; }, isOnTimer: function () { return this._isOnTimer; }, updateData: function () { this._isPopupSupport = this._timerSettingBlock.css('display') != 'none'; this._isOnTimer = this._timerSettingBlock.find('input[name="timer_enable"]').is(':checked'); this._text = this._timerSettingBlock.find('input[name="timer_text"]').val(); this._dateEnd = parseDateTime(this._timerSettingBlock.find('input[name="timer_date"]').val()); this._dateServer = parseDateTime(this._timerSettingBlock.find('div.dateServer').text()); var classesPos = this._timerSettingBlock.find('.positionTimer .active').prop('className').split(' '); this._classesPos = []; this._isTop = false; classesPos.forEach((v) => { if (v == "top" || "bottom" || "left" || "right") { this._classesPos.push(v); if (v == "top") { this._isTop = true; } } }); }, startTimer: function (clockElem) { this.stopTimer(); if (!(this._isPopupSupport && this._isOnTimer)) { return; } this._leftSeconds = Math.abs(this._dateEnd - this._dateServer) / 1000; this._interval = setInterval(() => { let days = Math.floor(this._leftSeconds / 86400); let hours = Math.floor((this._leftSeconds - 86400 * days) / 3600 % 3600); let mins = Math.floor(this._leftSeconds / 60 % 60); let seconds = Math.floor(this._leftSeconds % 60); if (this._leftSeconds < 0) { this.stopTimer(); days = 0; hours = 0; mins = 0; seconds = 0; } if (hours < 10) { hours = '0' + hours; } if (mins < 10) { mins = '0' + mins; } if (seconds < 10) { seconds = '0' + seconds; } let html = `<span>${days}</span>` + '<span class="sep">:</span>'; html += `<span>${hours}</span>` + '<span class="sep">:</span>'; html += `<span>${mins}</span>` + '<span class="sep">:</span>'; html += `<span>${seconds}</span>`; clockElem.html(html); this._leftSeconds--; }, 1000); }, stopTimer: function () { if (this._interval != undefined) { clearInterval(this._interval); } this._interval = undefined; }, renderFormPositionTimer: function () { var positionBlockTimer = null; var checkedTimer = $('.block.timer').find('input[name=timer_enable]').prop('checked'); var positionBlockLeft = $('.block.timer').find('input[name=timer_left]'); var positionBlockRight = $('.block.timer').find('input[name=timer_right]'); var positionBlockTop = $('.block.timer').find('input[name=timer_top]'); var positionBlockBottom = $('.block.timer').find('input[name=timer_bottom]'); if (positionBlockLeft.length > 0) { $('.block.timer').find('input[name=timer_left],input[name=timer_right],input[name=timer_top],input[name=timer_bottom]').closest('label').css('display', 'none'); if (!positionBlockTimer) { positionBlockTimer = $('.positionTimer'); } if (checkedTimer) { positionBlockTimer.css('display', 'block'); } positionBlockTimer.children().removeClass('active'); positionBlockTimer.insertBefore(positionBlockLeft.closest('label')); var activeSelector = ''; if (positionBlockLeft.val() == 'Y') { activeSelector += '.left'; } if (positionBlockRight.val() == 'Y') { activeSelector += '.right'; } if (positionBlockTop.val() == 'Y') { activeSelector += '.top'; } if (positionBlockBottom.val() == 'Y') { activeSelector += '.bottom'; } if (activeSelector == '') { activeSelector = '.left.top'; } positionBlockTimer.find(activeSelector).addClass('active'); $('.positionTimer').find('.top, .bottom').click(function () { $('.block.timer').find('input[name=timer_left],input[name=timer_right],input[name=timer_top],input[name=timer_bottom]').val('N'); $(this).parent().children().removeClass('active'); $(this).addClass('active'); var leftRight = ($(this).hasClass('left')) ? 'left' : 'right'; topBottom = ($(this).hasClass('top')) ? 'top' : 'bottom'; $('.block.timer').find('input[name^=timer_' + leftRight + ']').val('Y'); $('.block.timer').find('input[name^=timer_' + topBottom + ']').val('Y'); }); if (!checkedTimer) { $('.block.timer').find('label.toggle').css('display', 'none'); } } }, correctPositionBecauseTimer: function () { var detail_area_elem = $('.preview-iframe').contents().find('#detail_template_area'); detail_area_elem.css({ "margin-top": "0", "maring-bottom": "0" }); if (this.isOnTimer && this.isPopSuppot) { if (this.isTop) { detail_area_elem.css('margin-top', '50px'); } else { detail_area_elem.css('margin-bottom', '50px'); } } }, _events: function () { let _self = this; $('.block.timer input:not(:hidden)').on('change', function () { if ($(this).attr('name') == 'timer_enable') { let modeBlock = 'none', modeLabel = 'none'; if ($(this).prop('checked')) { modeBlock = 'block'; modeLabel = 'flex'; } $('.block.timer').find('label.toggle').css('display', modeLabel); $('.block.timer').find('div.toggle').css('display', modeBlock); } _self.updateData(); BX.onCustomEvent("onPreviewUpdate", [this]); }); $('.block.timer .positionTimer').on('click', function () { _self.updateData(); BX.onCustomEvent("onPreviewUpdate", [this]); }); } }; });