prestashop-module/retailcrm/views/js/retailcrm.min.js

37 lines
4.4 KiB
JavaScript
Raw Normal View History

/**
* MIT License
*
* Copyright (c) 2020 DIGITAL RETAIL TECHNOLOGIES SL
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author DIGITAL RETAIL TECHNOLOGIES SL <mail@simlachat.com>
* @copyright 2020 DIGITAL RETAIL TECHNOLOGIES SL
* @license https://opensource.org/licenses/MIT The MIT License
*
* Don't forget to prefix your containers with your own identifier
* to avoid any conflicts with others containers.
*/$(function(){({init:function init(){this.player.init(),this.tabs.init(),this.uploadForm.init(this.settingsTabs.init()),this.selects.init(),this.popup.init(),this.toggleBox(),this.trimConsultant(),this.showSettings()},selects:{init:function init(){try{$(".jq-select").SumoSelect(),$("li.opt").each(function(a,b){if(0===$(b).find("label").html().length){var c=$(b).closest("ul").closest("div").parent().find("select");$(b).find("label").html(c.attr("placeholder")),$(b).addClass("disabled")}})}catch(a){console.warn("Cannot initialize select: "+a.message)}}},player:{init:function init(){window.player={},window.onYouTubeIframeAPIReady=function(){window.player=new YT.Player("player",{height:"100%",width:"100%",videoId:window.RCRMPROMO})};var a=document.createElement("script");a.src="https://www.youtube.com/iframe_api",document.body.appendChild(a)}},settingsTabs:{init:function init(){if("undefined"!=typeof RCRMTabs){var a=new RCRMTabs("div[id^=\"rcrm_tab_\"]",".retail-menu__btn","retail-tab__enabled","retail-tab__disabled","retail-menu__btn_active","retail-menu__btn_inactive","tab-trigger",".rcrm-form-submit-trigger"),b={beforeActivate:function beforeActivate(){$("#main-submit").hide()},afterDeactivate:function afterDeactivate(){$("#main-submit").show()}};return a.tabsCallbacks({rcrm_tab_consultant:b,rcrm_tab_orders_upload:b}),a.initializeTabs(),a}}},uploadForm:{init:function init(a){"undefined"==typeof RetailcrmUploadForm||new RetailcrmUploadForm(a)}},tabs:{init:function init(){$(".retail-tabs__btn").on("click",this.swithTab)},swithTab:function swithTab(a){a.preventDefault();var b=$(this).attr("href");$(".retail-tabs__btn_active").removeClass("retail-tabs__btn_active"),$(".retail-tabs__item_active").removeClass("retail-tabs__item_active").fadeOut(150,function(){$(b).addClass("retail-tabs__item_active").fadeIn(150)}),$(this).addClass("retail-tabs__btn_active")}},popup:{init:function init(){var a=this;$("[data-popup]").on("click",function(){var b=$(this).data("popup");a.open($(b))}),$(".retail-popup-wrap").on("click",function(b){if($(b.target).hasClass("js-popup-close")){var c=$(this).find(".retail-popup");a.close(c)}})},open:function open(a){if(a){var b=a.closest(".retail-popup-wrap");b.fadeIn(200),a.addClass("open"),player.playVideo()}},close:function close(a){var b=a.closest(".retail-popup-wrap");a.removeClass("open"),b.fadeOut(200),player.stopVideo()}},toggleBox:function toggleBox(){$(".toggle-btn").on("click",function(a){a.preventDefault();var b=$(this).attr("href"),c=$(b),d=$(this).closest(".retail-btns");d.addClass("retail-btns_hide").slideUp(100),c.slideDown(100)})},trimConsultant:function trimConsultant(){var a=$("#rcrm_tab_consultant textarea");a.text(a.text().trim())},showSettings:function showSettings(){$(".retail.retail-wrap.hidden").removeClass("hidden")}}).init()});