PageSourceSearch

https://nzbusiness.co.nz/wp-content/plugins/cubewp-framework/cube/…/frontend/js/cubewp-alerts.js?ver=1.1.23

js nzbusiness.co.nz collected 2026-10-02 02:13:09 UTC 9,778 bytes, 211 lines download raw bytes

1jQuery(document).ready(function () {
2    jQuery(document).on("click", ".cwp-alert .cwp-alert-close", function () {
3        var $this = jQuery(this),
4            $parent = $this.closest('.cwp-alert');
5        $parent.slideUp(200, function () {
6            if ($parent.hasClass("cwp-js-alert")) {
7                $parent.hide();
8            } else {
9                $parent.remove();
10            }
11        });
12    });
13
14    jQuery(document).on('click', '.cubewp-modal-trigger', function (event) {
15        event.preventDefault();
16        var $this = jQuery(this),
17            target = jQuery($this.attr('data-cubewp-modal'));
18        if (target.length > 0) {
19            target.addClass('shown').fadeIn();
20        }
21    });
22    jQuery(document).on('click', '.cubewp-modal-close', function (event) {
23        event.preventDefault();
24        var $this = jQuery(this),
25            target = $this.closest('.cubewp-modal');
26        target.removeClass('shown').fadeOut();
27    });
28
29    var view_all_child_terms = jQuery('.cwp-taxonomy-term-child-terms-see-more');
30    if (view_all_child_terms.length > 0) {
31        view_all_child_terms.on('click', function (e) {
32            e.preventDefault();
33            var $this = jQuery(this),
34                more = $this.attr('data-more'),
35                less = $this.attr('data-less'),
36                all_child_terms = $this.closest('.cwp-taxonomy-term-child-terms').find('.cwp-taxonomy-term-child-terms-more');
37            if ($this.hasClass('cwp-viewing-less')) {
38                $this.text(more);
39                $this.removeClass('cwp-viewing-less');
40                all_child_terms.slideUp('hide');
41            } else {
42                $this.text(less);
43                $this.addClass('cwp-viewing-less');
44                all_child_terms.slideDown('show');
45            }
46        });
47    }
48    //JQuery For CubeWP Post Slider 
49    if (jQuery('.cubewp-post-slider').length > 0) {
50        jQuery('.cubewp-post-slider').each(function () {
51            var sliderElement = jQuery(this);
52            var prevArrowHtml = sliderElement.data('prev-arrow');
53            var nextArrowHtml = sliderElement.data('next-arrow');
54            var previcon_type = sliderElement.data('prev-icon-type');
55            var nexticon_type = sliderElement.data('next-icon-type');
56            var slidesToShow = sliderElement.data('slides-to-show');
57            var slidesToScroll = sliderElement.data('slides-to-scroll');
58            var slidesToShowTablet = sliderElement.data('slides-to-show-tablet');
59            var slidesToShowTabletPortrait = sliderElement.data('slides-show-tablet-portrait');
60            var slidesToShowMobile = sliderElement.data('slides-to-show-mobile');
61            var slidesToScrollTablet = sliderElement.data('slides-to-scroll-tablet');
62            var slidesToScrollTabletPortrait = sliderElement.data('slides-scroll-tablet-portrait');
63            var slidesToScrollMobile = sliderElement.data('slides-to-scroll-mobile');
64            var autoplay = sliderElement.data('autoplay') === true || sliderElement.data('autoplay') === 'true';
65            var autoplaySpeed = sliderElement.data('autoplay-speed');
66            var Speed = sliderElement.data('speed');
67            var infinite = sliderElement.data('infinite') === true || sliderElement.data('infinite') === 'true';
68            var variableWidth = sliderElement.data('variable-width') === true || sliderElement.data('variable-width') === 'true';
69
70            if (previcon_type) {
71                var prevArrowButton = '<button type="button" class="slick-prev"><i class="' + prevArrowHtml + '"></i></button>';
72            } else {
73                var prevArrowButton = '<button type="button" class="slick-prev">' + prevArrowHtml + '</button>';
74            }
75            if (nexticon_type) {
76                var nextArrowButton = '<button type="button" class="slick-next"><i class="' + nextArrowHtml + '"></i></button>';
77            } else {
78                var nextArrowButton = '<button type="button" class="slick-next">sadsads' + nextArrowHtml + '</button>';
79            }
80            var CustomArrows = sliderElement.data('custom-arrows') === true || sliderElement.data('custom-arrows') === 'true';
81            var CustomDots = sliderElement.data('custom-dots') === true || sliderElement.data('custom-dots') === 'true';
82            var enableProgressBar = sliderElement.data('enable-progress-bar') === true || sliderElement.data('enable-progress-bar') === 'true';
83
84            sliderElement.slick({
85                slidesToShow: slidesToShow,
86                slidesToScroll: slidesToScroll,
87                autoplay: autoplay,
88                autoplaySpeed: autoplaySpeed,
89                speed: Speed,
90                infinite: infinite,
91                variableWidth: variableWidth,
92                prevArrow: prevArrowButton,
93                nextArrow: nextArrowButton,
94                arrows: CustomArrows,
95                dots: CustomDots,
96                responsive: [{
97                        breakpoint: 1025,
98                        settings: {
99                            slidesToShow: slidesToShowTablet,
100                            slidesToScroll: slidesToScrollTablet
101                        }
102                    },
103                    {
104                        breakpoint: 768,
105                        settings: {
106                            slidesToShow: slidesToShowTabletPortrait,
107                            slidesToScroll: slidesToScrollTabletPortrait
108                        }
109                    },
110                    {
111                        breakpoint: 481,
112                        settings: {
113                            slidesToShow: slidesToShowMobile,
114                            slidesToScroll: slidesToScrollMobile
115                        }
116                    }
117                ]
118            });
119            if (enableProgressBar == true) {
120                sliderElement.after(
121                    '<div class="slick-progress"><div class="slick-progress-bar"></div></div>'
122                );
123                var totalSlides = sliderElement.slick("getSlick").slideCount;
124                sliderElement.on("afterChange", function (event, slick, currentSlide) {
125                    var progress = ((currentSlide + 1) / totalSlides) * 100;
126                    sliderElement.next('.slick-progress').find('.slick-progress-bar').css("width", progress + "%");
127                });
128            }
129        });
130    }
131});
132
133function cwp_notification_ui(notification_type, notification_content) {
134    var $cwp_alert = jQuery(".cwp-alert.cwp-js-alert"),
135        $alert_class = '',
136        $cwp_alert_content = $cwp_alert.find('.cwp-alert-content');
137
138    if ($cwp_alert.is(":visible") && $cwp_alert_content.html() === notification_content) {
139        return false;
140    }
141    if ($cwp_alert.is(":visible")) {
142        $cwp_alert.find('.cwp-alert-close').trigger("click");
143    }
144    if (notification_type === 'success') {
145        $alert_class = 'cwp-alert-success';
146    } else if (notification_type === 'warning') {
147        $alert_class = 'cwp-alert-warning';
148    } else if (notification_type === 'info') {
149        $alert_class = 'cwp-alert-info';
150    } else if (notification_type === 'error') {
151        $alert_class = 'cwp-alert-danger';
152    }
153    $cwp_alert.removeClass("cwp-alert-danger cwp-alert-success cwp-alert-warning cwp-alert-info").addClass($alert_class);
154    $cwp_alert.find('.cwp-alert-heading').text(notification_type + "!");
155    $cwp_alert_content.html(notification_content);
156    $cwp_alert.slideDown();
157    setTimeout(function () {
158        $cwp_alert.find('.cwp-alert-close').trigger("click");
159    }, 3000);
160}
161
162jQuery(document).on('click', '.cwp-post-confirmation-wrap .cwp-confirmation-bottom-bar', function (e) {
163    jQuery('.cwp-post-confirmation').slideToggle(700);
164});
165jQuery(document).on('click', '.cwp-post-confirmation-wrap .cwp-confirmation-bottom-bar', function (e) {
166    jQuery('.cwp-post-confirmation').slideToggle(700);
167});
168jQuery(document).on('click', '.cwp-save-post', function (e) {
169    var thisObj = jQuery(this);
170    var pid = thisObj.data('pid');
171    thisObj.addClass('cubewp-active-ajax');
172    jQuery.ajax({
173        url: cwp_alert_ui_params.ajax_url,
174        type: 'POST',
175        data: 'action=cubewp_save_post&post-id=' + pid + '&nonce=' + cwp_alert_ui_params.nonce,
176        dataType: "json",
177        success: function (response) {
178            cwp_notification_ui(response.type, response.msg);
179            if (typeof response.text != 'undefined' && response.text != '') {
180                thisObj.addClass('cwp-saved-post');
181                thisObj.removeClass('cwp-save-post');
182                thisObj.find('.cwp-saved-text').html(response.text);
183                thisObj.removeClass('cubewp-active-ajax');
184            }
185        }
186    });
187});
188jQuery(document).on('click', '.cwp-saved-post', function (e) {
189    var thisObj = jQuery(this);
190    var pid = thisObj.data('pid');
191    var action = thisObj.data('action');
192    thisObj.addClass('cubewp-active-ajax');
193    jQuery.ajax({
194        url: cwp_alert_ui_params.ajax_url,
195        type: 'POST',
196        data: 'action=cubewp_remove_saved_posts&post-id=' + pid + '&nonce=' + cwp_alert_ui_params.nonce,
197        dataType: "json",
198        success: function (response) {
199            cwp_notification_ui(response.type, response.msg);
200            if (typeof response.text != 'undefined' && response.text != '') {
201                if (action == 'remove') {
202                    thisObj.closest('tr').remove();
203                }
204                thisObj.addClass('cwp-save-post');
205                thisObj.removeClass('cwp-saved-post');
206                thisObj.find('.cwp-saved-text').html(response.text);
207                thisObj.removeClass('cubewp-active-ajax');
208            }
209        }
210    });
211});

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.