1+ /* global WCF_ADDONS_JS */
2+
3+ ( function ( $ ) {
4+ /**
5+ * @param $scope The Widget wrapper element as a jQuery element
6+ * @param $ The jQuery alias
7+ */
8+
9+ // Make sure you run this code under Elementor.
10+ $ ( window ) . on ( 'elementor/frontend/init' , function ( ) {
11+ var device_width = $ ( window ) . width ( ) ;
12+ var elementorBreakpoints = elementorFrontend . config . responsive . activeBreakpoints ;
13+ var Modules = elementorModules . frontend . handlers . Base ;
14+ var contact_form_7 = function contact_form_7 ( $scope ) {
15+ var submit_btn = $ ( '.wpcf7-submit' , $scope ) ;
16+ var classes = submit_btn . attr ( 'class' ) ;
17+ classes += ' wcf-btn-default ' + $ ( '.wcf--form-wrapper' , $scope ) . attr ( 'btn-hover' ) ;
18+ submit_btn . replaceWith ( function ( ) {
19+ return $ ( '<button/>' , {
20+ html : $ ( '.btn-icon' ) . html ( ) + submit_btn . attr ( 'value' ) ,
21+ "class" : classes ,
22+ type : 'submit'
23+ } ) ;
24+ } ) ;
25+ } ;
26+ var Countdown = Modules . extend ( {
27+ bindEvents : function bindEvents ( ) {
28+ this . run ( ) ;
29+ } ,
30+ run : function run ( ) {
31+ var _this = this ;
32+ // Update the count down every 1 second
33+ var x = setInterval ( function ( ) {
34+ _this . count_down ( x ) ;
35+ } , 1000 ) ;
36+ this . count_down ( x ) ;
37+ } ,
38+ count_down : function count_down ( x ) {
39+ // Set the date we're counting down to
40+ var countDownDate = new Date ( this . getElementSettings ( 'countdown_timer_due_date' ) ) . getTime ( ) ;
41+
42+ // Get today's date and time
43+ var now = new Date ( ) . getTime ( ) ;
44+
45+ // Find the distance between now and the count down date
46+ var distance = countDownDate - now ;
47+
48+ // Time calculations for days, hours, minutes and seconds
49+ var days = Math . floor ( distance / ( 1000 * 60 * 60 * 24 ) ) ;
50+ var hours = Math . floor ( distance % ( 1000 * 60 * 60 * 24 ) / ( 1000 * 60 * 60 ) ) ;
51+ var minutes = Math . floor ( distance % ( 1000 * 60 * 60 ) / ( 1000 * 60 ) ) ;
52+ var seconds = Math . floor ( distance % ( 1000 * 60 ) / 1000 ) ;
53+
54+ // If the count down is over, write some text
55+ if ( distance < 0 ) {
56+ clearInterval ( x ) ;
57+ this . findElement ( '.wcf--countdown' ) . html ( this . time_finish_content ( ) ) ;
58+ } else {
59+ this . findElement ( '.wcf--countdown' ) . html ( this . timer_content ( {
60+ 'days' : days ,
61+ 'hours' : hours ,
62+ 'minutes' : minutes ,
63+ 'seconds' : seconds
64+ } ) ) ;
65+ }
66+ } ,
67+ timer_content : function timer_content ( ) {
68+ var _this2 = this ;
69+ var times = arguments . length > 0 && arguments [ 0 ] !== undefined ? arguments [ 0 ] : [ ] ;
70+ if ( 0 === times . length ) {
71+ return ;
72+ }
73+ var time_content = '' ;
74+ $ . each ( times , function ( index , time ) {
75+ var title = _this2 . getElementSettings ( "countdown_timer_" . concat ( index , "_label" ) ) ;
76+ time_content += "<div class=\"timer-content timer-item-" . concat ( index , " \"><span class=\"time-count " ) . concat ( index , "-count\">" ) . concat ( time , "</span><span class=\"time-title " ) . concat ( index , "-title\">" ) . concat ( title , "</span></div>" ) ;
77+ } ) ;
78+ return time_content ;
79+ } ,
80+ time_finish_content : function time_finish_content ( ) {
81+ var title = this . getElementSettings ( 'time_expire_title' ) ;
82+ var description = this . getElementSettings ( 'time_expire_desc' ) ;
83+ var finish_content = '<div class="countdown-expire">' ;
84+ if ( title ) {
85+ finish_content += "<div class=\"countdown-expire-title\">" . concat ( title , "</div>" ) ;
86+ }
87+ if ( description ) {
88+ finish_content += "<div class=\"countdown-expire-desc\">" . concat ( description , "</div>" ) ;
89+ }
90+ finish_content += '</div>' ;
91+ return finish_content ;
92+ }
93+ } ) ;
94+ elementorFrontend . hooks . addAction ( "frontend/element_ready/wcf--contact-form-7.default" , contact_form_7 ) ;
95+ elementorFrontend . hooks . addAction ( 'frontend/element_ready/wcf--countdown.default' , function ( $scope ) {
96+ elementorFrontend . elementsHandler . addHandler ( Countdown , {
97+ $element : $scope
98+ } ) ;
99+ } ) ;
100+ var Search = function Search ( $scope ) {
101+ var searchWrapper = $ ( '.search--wrapper' , $scope ) ;
102+ var toggle_open = $ ( '.toggle--open' , $scope ) ;
103+ var toggle_close = $ ( '.toggle--close' , $scope ) ;
104+ toggle_open . on ( 'click' , function ( e ) {
105+ searchWrapper . addClass ( 'search-visible' ) ;
106+ } ) ;
107+ toggle_close . on ( 'click' , function ( e ) {
108+ searchWrapper . removeClass ( 'search-visible' ) ;
109+ } ) ;
110+ $ ( "input" , $scope ) . focus ( function ( ) {
111+ $ ( ".wcf-search-form" , $scope ) . addClass ( 'wcf-search-form--focus' ) ;
112+ } ) ;
113+ $ ( "input" , $scope ) . focusout ( function ( ) {
114+ $ ( ".wcf-search-form" , $scope ) . removeClass ( 'wcf-search-form--focus' ) ;
115+ } ) ;
116+ } ;
117+ elementorFrontend . hooks . addAction ( 'frontend/element_ready/wcf--blog--search--form.default' , Search ) ;
118+ } ) ;
119+ } ) ( jQuery ) ;
0 commit comments