PageSourceSearch

https://qalamnass.com/wp-content/plugins/easy-bookmark/public/assets/js/public.js?ver=1.0.3

js qalamnass.com collected 2026-10-03 18:10:13 UTC 7,512 bytes, 173 lines download raw bytes

1(function($) {
2
3    $(document).ready(function(){
4
5        let EASYBOOKMARK = {
6            init: function () { 
7                $( document )
8                .on( 'click.EASYBOOKMARK', '.esbmrk-counter-box .esbmrk-counter', this.openBookmarkedPopup )
9                .on( 'click.EASYBOOKMARK', '#esbmrk_popup_modal .esbmrk-modal-close', this.closeBookmarkedPopup )
10                .on( 'click.EASYBOOKMARK', '.esbmrk-add-to-bookmark-btn', this.addToBookmark )
11                .on( 'click.EASYBOOKMARK', '.esbmrk_delete_all_trigger', this.deleteAllPost )
12                .on( 'change.EASYBOOKMARK', '.esbmrk-posts .esbmrk-remove-btn input[type="checkbox"]', this.deleteSinglePost )
13                ;
14            },
15            openBookmarkedPopup: function (that) { 
16
17                let perPage = $(this).data('per-page');
18
19
20                 // Send AJAX request
21                 $.ajax({
22                    type: "POST",
23                    url: ebm_ajax.ajaxurl,
24                    data: {
25                        action: 'esbmrk_get_easy_bookmarked_posts_list_html', 
26                        perPage: perPage,
27                        nonce: ebm_ajax.nonce,
28                    },
29                    success: function (response) {
30                        if (response) {
31                            $('#esbmrk_popup_modal .esbmrk-modal-body').html(response);
32                        } 
33
34                        $('#esbmrk_popup_modal').css('display', 'block');
35                    }
36                });
37                
38            },
39            closeBookmarkedPopup: function () { 
40                $('#esbmrk_popup_modal').css('display', 'none');
41            },
42            addToBookmark: function (e, that) { 
43
44                // Prevent default action
45               e.preventDefault();
46
47               // Get post ID from the clicked button
48               let bookmarkBtn = $(this);
49               let postId = $(bookmarkBtn).data('post-id');
50               let currentPostCount = $('.esbmrk-counter .esbmrk-total-marked').html();
51               let bookmarkedTooltip = $(bookmarkBtn).data('bookmarked-tooltip');
52               let bookmarkedLabel = $(bookmarkBtn).data('bookmarked-label');
53
54               if(!$(this).hasClass('esbmrk-marked')){
55                   $('.esbmrk-counter .esbmrk-total-marked').html(parseFloat(currentPostCount) + parseFloat(1));
56                   $.ajax({
57
58                       type: "POST",
59                       url: ebm_ajax.ajaxurl,
60                       data: {
61                           action: 'esbmrk_add_to_easy_bookmark',
62                           postId: postId,
63                           nonce: ebm_ajax.nonce,
64                       },
65                       success: function (response) {
66                           $(bookmarkBtn).addClass('esbmrk-marked');
67                           $(bookmarkBtn).find('.esbmrk-tooltip').html(bookmarkedTooltip);
68                           $(bookmarkBtn).find('.esbmrk-bookmark-label').html(bookmarkedLabel);
69                       }
70                   });
71               }else{
72                   EASYBOOKMARK.deletePost(postId);
73                   $(bookmarkBtn).removeClass('esbmrk-marked');
74                   
75               }
76              
77            },
78            deletePost: function (postId) { 
79
80                let bookmarkBtn = $('a[data-post-id="'+postId+'"].esbmrk-add-to-bookmark-btn');
81                let bookmarkTooltip = $(bookmarkBtn).data('bookmark-tooltip');
82                let bookmarklabel = $(bookmarkBtn).data('bookmark-label');
83               
84                let emptyBookmarkLabel = 'Your bookmark is empty!';
85                
86
87
88                // Send AJAX request
89                $.ajax({
90                    type: "POST",
91                    url: ebm_ajax.ajaxurl,
92                    data: {
93                        action: 'esbmrk_delete_from_easy_bookmarked', 
94                        postId: postId,  // Send array of post IDs
95                        nonce: ebm_ajax.nonce,
96                    },
97                    success: function (response) {
98                        
99                      
100                        if (response.success) {
101
102                            if(response.data.empty_bookmark_label != ''){
103                                emptyBookmarkLabel = response.data.empty_bookmark_label;
104                            }
105                            
106                            // Optionally, remove the deleted posts from the UI
107                            $('input[data-post-id="'+postId+'"]').closest('.esbmrk-checkbox-label').parent().remove();
108
109                            $(bookmarkBtn).removeClass('esbmrk-marked');
110                            $(bookmarkBtn).find('.esbmrk-tooltip').html(bookmarkTooltip);
111                            $(bookmarkBtn).find('.esbmrk-bookmark-label').html(bookmarklabel);
112                            
113
114                            let currentPostCount = $('.esbmrk-counter .esbmrk-total-marked').html();
115                            let updatedPostCount = parseFloat(currentPostCount) - parseFloat(1);
116
117                            
118                            
119
120                            $('.esbmrk-counter .esbmrk-total-marked').html(updatedPostCount);
121
122                            if(updatedPostCount < 1) {
123                                $('#esbmrk_popup_modal .esbmrk-action-bar').remove();
124                                $('.esbmrk-posts').html('<div class="esbmrk-empty-posts">' + emptyBookmarkLabel + '</div>');
125                            }
126                        } else {
127                            console.log(response.data.message); // Show error message
128                        }
129                    }
130                });
131            },
132            deleteSinglePost: function (that) { 
133                let postId = $(this).data('post-id');
134                EASYBOOKMARK.deletePost(postId);
135               
136                
137            },
138            deleteAllPost: function (that) { 
139
140                $('.esbmrk-deleteing-loader').css('display', 'flex');
141            
142                // Send AJAX request
143                $.ajax({
144                    type: "POST",
145                    url: ebm_ajax.ajaxurl,
146                    data: {
147                        action: 'esbmrk_delete_all_from_easy_bookmarked', 
148                        nonce: ebm_ajax.nonce,
149                    },
150                    success: function (response) {
151                        if (response.success) {
152                            // Optionally, remove the deleted posts from the UI
153                            $('#esbmrk_popup_modal .esbmrk-action-bar').remove();
154                            $('.esbmrk-posts').html('<div class="esbmrk-empty-posts">Empty Bookmark!</div>');
155                            $('.esbmrk-counter .esbmrk-total-marked').html(0);
156                            
157                            setTimeout(() => {
158                                $('#esbmrk_popup_modal .esbmrk-deleteing-loader').css('display', 'none');
159                            }, 2000);
160                        } else {
161                            console.log(response.data.message); // Show error message
162                        }
163                    }
164                });
165            }
166            
167        }
168        EASYBOOKMARK.init();
169        
170
171    });
172
173})(jQuery);

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.