PageSourceSearch

https://businessdisabilityforum.org.uk/wp-content/plugins/cbxwpboo…/assets/js/cbxwpbookmarkaddon.js?ver=2.0.8

js businessdisabilityforum.org.uk collected 2026-10-02 02:39:43 UTC 9,365 bytes, 242 lines download raw bytes

1(function ($) {
2    'use strict';
3
4    $(document).ready(function () {
5        var ajaxurl = cbxwpbookmark.ajaxurl;
6
7        var awn_options = {
8            labels: {
9                tip          : cbxwpbookmark.awn_options.tip,
10                info         : cbxwpbookmark.awn_options.info,
11                success      : cbxwpbookmark.awn_options.success,
12                warning      : cbxwpbookmark.awn_options.warning,
13                alert        : cbxwpbookmark.awn_options.alert,
14                async        : cbxwpbookmark.awn_options.async,
15                confirm      : cbxwpbookmark.awn_options.confirm,
16                confirmOk    : cbxwpbookmark.awn_options.confirmOk,
17                confirmCancel: cbxwpbookmark.awn_options.confirmCancel
18            }
19        };
20
21        //delete a bookmark from grid shortcode (core has delete bookmark feature but it doesn;t work with grid shortcode)
22        $('.cbxbookmark_card_wrap').on('click', '.cbxbookmark-post-delete', function (event) {
23            event.preventDefault();
24
25            var $this    = $(this);
26            var $wrapper = $this.closest('div.cbxbookmark_card_wrap');
27
28            var $bookmark_id = $this.data('bookmark_id');
29            var $object_id   = $this.data('object_id');
30            var $object_type = $this.data('object_type');
31            var $busy        = parseInt($this.data('busy'));
32
33            var data = {
34                'action'     : 'cbx_delete_bookmark_post',
35                'security'   : cbxwpbookmark.nonce,
36                'object_id'  : $object_id,
37                'object_type': $object_type,
38                'bookmark_id': $bookmark_id
39            };
40
41            // We can also pass the url value separately from ajaxurl for front end AJAX implementations
42
43            if ($busy === 0) {
44                var notifier = new AWN(awn_options);
45
46                var onCancel = () => {
47
48                };
49
50                var onOk = () => {
51                    //$wrapper.find('.cbxbookmark-alert').remove();
52                    $this.data('busy', 1);
53                    //$this.addClass('cbxbookmark-delete-btn-busy');
54                    $this.addClass('running');
55
56                    $.post(ajaxurl, data, function (response) {
57                        response = $.parseJSON(response);
58
59                        if (response.msg === 0) {
60                            // Remove the li tag if the bookmark is deleted
61
62                            $this.closest('div.cbxbookmark_card_col').hide('slow', function () {
63                                $(this).remove();
64                            });
65
66                            if ($wrapper.find('div.cbxbookmark_card').length === 0) {
67                                $wrapper.append(
68                                    '<div class="cbxbookmark-alert cbxbookmark-alert-error">' +
69                                    cbxwpbookmark.bookmark_removed_empty + '</div>');
70                            } else {
71                                new AWN(awn_options).success(cbxwpbookmark.bookmark_removed);
72                            }
73                        } else if (response.msg === 1) {
74                            new AWN(awn_options).warning(cbxwpbookmark.bookmark_removed_failed);
75
76                            //$this.removeClass('cbxbookmark-delete-btn-busy');
77                            $this.removeClass('running');
78                        }
79
80
81                    });
82                };
83
84                notifier.confirm(
85                    cbxwpbookmark.are_you_sure_delete_desc,
86                    onOk,
87                    onCancel,
88                    {
89                        labels: {
90                            confirm: cbxwpbookmark.are_you_sure_global
91                        }
92                    }
93                );
94            }
95        });
96
97        //implementing the bookmark load more feature for bookmark grid
98        $('.cbxbookmark_cards_wrapper_postgrid').on('click', '.cbxbookmark-more', function (e) {
99            e.preventDefault();
100
101            var _this           = $(this);
102            var $busy = Number(_this.data('busy'));
103            if($busy === 1) return;
104
105            var $wrapper_parent = _this.closest('div.cbxbookmark_cards_wrapper');
106            var $wrapper        = $wrapper_parent.find('.cbxbookmark_card_wrap');
107
108            //$wrapper_parent.find('.cbxwpbm_ajax_icon').show();
109
110            var limit  = _this.data('limit');
111            var offset = _this.data('offset');
112            var catid  = _this.data('catid');
113            var type   = _this.data('type');
114
115            var order   = _this.data('order');
116            var orderby = _this.data('orderby');
117            var userid  = _this.data('userid');
118
119            var totalpage   = _this.data('totalpage');
120            var currpage    = _this.data('currpage');
121            var allowdelete = _this.data('allowdelete');
122            var show_thumb  = _this.data('show_thumb');
123
124            if (currpage + 1 >= totalpage) {
125                _this.hide();
126            } else {
127                _this.show();
128            }
129
130            var addcat = {
131                'action'     : 'cbx_bookmark_postgrid_loadmore',
132                'security'   : cbxwpbookmark.nonce,
133                'limit'      : limit,
134                'offset'     : offset,
135                'catid'      : catid,
136                'type'       : type,
137                'order'      : order,
138                'orderby'    : orderby,
139                'userid'     : userid,
140                'allowdelete': allowdelete,
141                'show_thumb' : show_thumb
142            };
143
144            _this.data('busy', 1);
145            _this.addClass('running');
146
147            $.post(ajaxurl, addcat, function (response) {
148
149                response = $.parseJSON(response);
150
151                if (response.code) {
152                    _this.data('offset', limit + offset);
153                    _this.data('currpage', currpage + 1);
154
155                    $wrapper.append(response.data);
156                    //$wrapper_parent.find('.cbxwpbm_ajax_icon').hide();
157
158                } else {
159                    //console.log('Error loading data. Response code=' + response.code);
160                    //var $error_html = $('<div class="cbxbookmark-alert cbxbookmark-alert-error">' + cbxwpbookmark.error_msg + response.code + '</div>');
161                    //$wrapper.append($error_html);
162
163                    new AWN(awn_options).warning(cbxwpbookmark.error_msg + response.code);
164                }
165
166                _this.data('busy', 0);
167                _this.removeClass('running');
168            });
169        });
170
171        //implementing the bookmark load more feature for bookmark most grid
172        $('.cbxbookmark_cards_wrapper_mostgrid').on('click', '.cbxbookmark-more', function (e) {
173            e.preventDefault();
174
175            var _this    = $(this);
176            var $busy = Number(_this.data('busy'));
177            if($busy === 1) return;
178
179
180            var $wrapper = _this.closest('div.cbxbookmark_cards_wrapper').find('.cbxbookmark_card_wrap');
181
182            //$wrapper.find('.cbxwpbm_ajax_icon').show();
183
184            var limit      = _this.data('limit');
185            var offset     = _this.data('offset');
186            var type       = _this.data('type');
187            var order      = _this.data('order');
188            var orderby    = _this.data('orderby');
189            var totalpage  = _this.data('totalpage');
190            var currpage   = _this.data('currpage');
191            var show_thumb = _this.data('show_thumb');
192
193
194            if (currpage + 1 >= totalpage) {
195                _this.hide();
196            } else {
197                _this.show();
198            }
199
200            var addcat = {
201                'action'    : 'cbx_bookmark_mostgrid_loadmore',
202                'security'  : cbxwpbookmark.nonce,
203                'limit'     : limit,
204                'offset'    : offset,
205                'type'      : type,
206                'order'     : order,
207                'orderby'   : orderby,
208                'show_thumb': show_thumb
209            };
210
211            _this.data('busy', 1);
212            _this.addClass('running');
213
214
215            $.post(ajaxurl, addcat, function (response) {
216
217                response = $.parseJSON(response);
218
219                if (response.code) {
220                    _this.data('offset', limit + offset);
221                    _this.data('currpage', currpage + 1);
222
223                    $wrapper.append(response.data);
224                    //$wrapper.find('.cbxwpbm_ajax_icon').hide();
225
226                } else {
227                    //console.log('Error loading data. Response code=' + response.code);
228                   /* var $error_html = $(
229                        '<div class="cbxbookmark-alert cbxbookmark-alert-error">' +
230                        cbxwpbookmark.error_msg + response.code + '</div>');
231                    $wrapper.append($error_html);*/
232
233                    new AWN(awn_options).warning(cbxwpbookmark.error_msg + response.code);
234                }
235
236                _this.data('busy', 0);
237                _this.removeClass('running');
238            });
239        });
240    });
241})(jQuery);
242

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.