PageSourceSearch

https://wrestdag.ru/wa-data/public/blog/themes/dummy/js/dummy.blog.js?v1.2.7.48

js wrestdag.ru collected 2026-09-26 05:43:31 UTC 12,155 bytes, 417 lines download raw bytes

1// Blog :: CommentForm
2var CommentForm = ( function($) {
3
4    CommentForm = function(options) {
5        var that = this;
6
7        // DOM
8        that.$formWrapper = options["$formWrapper"];
9        that.$commentsWrapper = options["$commentsWrapper"];
10        that.$form = that.$formWrapper.find("form");
11        that.$guestAuth = that.$form.find(".b-guest-auth");
12        that.$authProviders = that.$form.find(".b-auth-providers");
13        that.$textarea = that.$formWrapper.find("textarea");
14        that.$postWrapper = that.$form.closest(".b-post-wrapper");
15        that.$post = that.$postWrapper.find(".b-post");
16
17
18        // VARS
19        that.selected_class = "is-selected";
20        that.authorized = options["authorized"];
21        that.auth_source = options["auth_source"];
22        that.require_auth = options['$require_auth'];
23
24        // DYNAMIC VARS
25        that.is_locked = false;
26        that.$activeProvider = false;
27
28        // INIT
29        that.bindEvents();
30    };
31
32    CommentForm.prototype.bindEvents = function() {
33        var that = this;
34
35        $(document).on("click", ".comment-reply", function () {
36            that.onReply( $(this) );
37            return false;
38        });
39
40        that.$form.on("click", ".b-cancel-button", function() {
41            that.moveForm( that.$post, "", false);
42            return false;
43        });
44
45        that.$form.on("submit", function() {
46            if (!that.is_locked) {
47                that.onSubmit();
48            }
49            return false;
50        });
51
52        that.$form.on("click", ".b-guest-provider a", function() {
53            that.onProviderClick( $(this), true );
54            return false;
55        });
56
57        that.$form.on("click", ".b-provider-link a", function() {
58            that.onProviderClick( $(this) );
59            return false;
60        });
61    };
62
63    CommentForm.prototype.moveForm = function(target, id, set_focus) {
64        var that = this;
65        id = (id) ? id : "";
66
67        $(".b-comment").removeClass("in-reply-to");
68
69        // Refresh
70        that.refreshForm( true );
71        // Id
72        that.$form.find("input[name=parent]").val( id );
73        // Move
74        that.$formWrapper.insertAfter(target);
75        // Focus
76        if (set_focus) {
77            that.$textarea.focus();
78        }
79    };
80
81    CommentForm.prototype.refreshForm = function(empty) {
82        var that = this,
83            $form = that.$form;
84
85        $form.find(".errormsg").remove();
86        $form.find(".error").removeClass("error");
87        $form.find(".wa-captcha-refresh").click();
88
89        if (empty) {
90            $form[0].reset();
91            $form.find("textarea").val("");
92        }
93    };
94
95    CommentForm.prototype.onSubmit = function() {
96        var that = this,
97            $form = that.$form,
98            href = $form.attr('action')+'?json=1',
99            data = $form.serialize();
100
101        that.is_locked = true;
102
103        $.post(href, data, function(response){
104            if ( response.status && response.status == 'ok' && response.data) {
105                if (response.data.redirect) {
106                    window.location.replace(response.data.redirect);
107                    window.location.href = response.data.redirect;
108                } else {
109                    var $comment = $(response.data.template),
110                        count_str = response.data["count_str"],
111                        hidden_class = "is-hidden",
112                        new_class = "is-new",
113                        $target;
114
115                    $target = that.$form.closest(".b-comment-wrapper");
116
117                    // If first comment
118                    if (!$target.length) {
119                        that.$commentsWrapper.removeClass(hidden_class);
120                        $target = that.$commentsWrapper.find(".b-comments");
121                    }
122
123                    // Render new comment
124                    $target.append( $("<div class='b-comment-wrapper' />").append($comment) );
125
126                    // marking
127                    $comment.addClass(new_class);
128                    setTimeout( function () {
129                        $comment.removeClass(new_class);
130                    }, 10000);
131
132                    // scroll
133                    $("html, body").animate({
134                        scrollTop: $comment.offset().top - 100
135                    }, 800);
136
137                    // Reset comment form
138                    that.refreshForm(true);
139                    that.moveForm( that.$post, "", false);
140
141                    // Change counter
142                    $("#b-comments-count").html(count_str);
143
144                    // Plugins
145                    $comment.trigger("plugin.comment_add");
146                }
147            } else if ( response.status && response.status == 'fail' ) {
148                // error
149                that.refreshForm();
150
151                var errors = response.errors;
152                $(errors).each( function(){
153                    var error = this;
154                    for (var name in error) {
155                        if (error.hasOwnProperty(name)) {
156                            var elem = that.$form.find('[name='+name+']');
157                            elem.after( $('<em class="errormsg"></em>').text(error[name]) ).addClass('error');
158                        }
159                    }
160                });
161            } else {
162                that.refreshForm( false );
163            }
164
165            that.is_locked = false;
166
167        }, "json").error(function(){
168            that.refreshForm(false);
169        });
170
171    };
172
173    CommentForm.prototype.onReply = function( $link ) {
174        var that = this;
175
176        var $comment = $link.closest(".b-comment"),
177            comment_id = $comment.data("comment-id"),
178            reply_class = "in-reply-to";
179
180        that.moveForm( $link.closest(".b-actions"), comment_id, true);
181
182        $(".b-comment").removeClass(reply_class);
183
184        $comment.addClass(reply_class);
185    };
186
187    CommentForm.prototype.onProviderClick = function( $link, is_guest ) {
188        var that = this,
189            selected_class = that.selected_class,
190            $li = $link.closest("li"),
191            $captcha = that.$form.find(".wa-captcha"),
192            $guestAuth = that.$guestAuth,
193            $user = that.$form.find(".b-auth-user"),
194            provider = $li.data("provider"),
195            is_selected = $li.hasClass(selected_class);
196
197        // Show window
198        if (!is_selected && !is_guest &&  provider) {
199            var width = 600,
200                height = 400,
201                left = (screen.width - width) / 2,
202                top = (screen.height - height) / 2,
203                href = (that.require_auth) ? $link.attr("href") + "&guest=1" : $link.attr("href");
204
205            window.open(href,"oauth", "width=" + width + ",height=" + height + ",left="+left+",top="+top+",status=no,toolbar=no,menubar=no");
206        }
207
208        // Show captcha
209        if (is_guest) {
210            $guestAuth.show();
211            $captcha.show();
212            $user.hide();
213        } else {
214            $guestAuth.hide();
215            $captcha.hide();
216            $user.show();
217        }
218
219        // Render link
220        if (that.$activeProvider) {
221            that.$activeProvider.removeClass(selected_class);
222        } else {
223            that.$authProviders.find("." + selected_class).removeClass(selected_class);
224        }
225        $li.addClass(selected_class);
226        that.$activeProvider = $li;
227
228        // Set data
229        that.$form.find("input[name=auth_provider]").val(provider);
230    };
231
232    return CommentForm;
233
234})(jQuery);
235
236// Blog :: Lazy Loading
237var LazyLoading = ( function($) {
238
239    var onScroll;
240
241    LazyLoading = function(options) {
242        var that = this;
243
244        // VARS
245        that.list_name = options["names"]["list"];
246        that.items_name = options["names"]["items"];
247        that.pagind_name = options["names"]["paging"];
248        that.load_class = "is-loading";
249
250        // DOM
251        that.$wrapper = ( options["$wrapper"] || false );
252        that.$list = that.$wrapper.find(that.list_name);
253        that.$window = $(window);
254
255        // DYNAMIC VARS
256        that.$paging = that.$wrapper.find(that.pagind_name);
257
258        // INIT
259        that.initLazyLoading();
260    };
261
262    LazyLoading.prototype.initLazyLoading = function() {
263        var that = this;
264
265        that.addWatcher();
266    };
267
268    LazyLoading.prototype.addWatcher = function() {
269        var that = this;
270
271        onScroll = function() {
272            that.onScroll();
273        };
274
275        that.$window.on("scroll", onScroll);
276    };
277
278    LazyLoading.prototype.stopWatcher = function() {
279        var that = this;
280
281        if (typeof onScroll == "function") {
282            that.$window.off("scroll", onScroll);
283        }
284    };
285
286    LazyLoading.prototype.onScroll = function() {
287        var that = this,
288            is_paging_exist = ( $.contains(document, that.$paging[0]) );
289
290        if (is_paging_exist) {
291
292            var $window = that.$window,
293                scroll_top = $window.scrollTop(),
294                display_height = $window.height(),
295                paging_top = that.$paging.offset().top;
296
297            // If we see paging, stop watcher and run load
298            if (scroll_top + display_height >= paging_top) {
299                that.stopWatcher();
300                that.loadNextPage();
301            }
302
303        } else {
304            that.stopWatcher();
305        }
306    };
307
308    LazyLoading.prototype.loadNextPage = function() {
309        var that = this,
310            next_page_url = getNextUrl(),
311            $paging = that.$paging;
312
313        function getNextUrl() {
314            var $nextPage = that.$paging.find(".selected").next(),
315                result = false;
316
317            if ($nextPage.length) {
318                result = $nextPage.find("a").attr("href");
319            }
320
321            return result;
322        }
323
324        function showLoad() {
325            var $loading = '<div class="s-loading-wrapper"><i class="icon16 loading"></i>&nbsp;' + $paging.data("loading-text") + '</div>';
326
327            $paging
328                .addClass(that.load_class)
329                .append($loading);
330        }
331
332        if (next_page_url) {
333
334            showLoad();
335
336            $.get(next_page_url, function(response) {
337                var $category = $(response),
338                    $newItems = $category.find(that.list_name + " " + that.items_name),
339                    $newPaging = $category.find(that.pagind_name);
340
341                that.$list.append($newItems);
342
343                $paging.after($newPaging);
344
345                $paging.remove();
346
347                that.$paging = $newPaging;
348
349                that.addWatcher();
350            });
351        }
352    };
353
354    return LazyLoading;
355
356})(jQuery);
357
358// Blog :: Post
359var Post = ( function($) {
360
361    Post = function(options) {
362        var that = this;
363
364        // DOM
365        that.$wrapper = options["$wrapper"];
366
367        // VARS
368        that.search_query = ( options["search_query"] || false );
369        that.is_review = ( options["is_review"] || false );
370        that.use_retina = ( options["use_retina"] || false );
371
372        // DYNAMIC VARS
373
374        // INIT
375        that.initClass();
376    };
377
378    Post.prototype.initClass = function() {
379        var that = this;
380
381        if (that.use_retina) {
382            that.useRetina();
383        }
384
385        if (that.search_query) {
386            that.highlightSearch( that.search_query );
387        }
388    };
389
390    Post.prototype.useRetina = function() {
391        var that = this,
392            $images = that.$wrapper.find("img.retinify");
393
394        if ($images.length && $.fn.retina) {
395            $images.retina();
396        }
397    };
398
399    Post.prototype.highlightSearch = function( query ) {
400        var that = this,
401            $nodes = that.$wrapper.find(".b-post-name, .b-content"),
402            highlighted_class = "highlighted";
403
404        $nodes.each(function() {
405            var $node = $(this),
406                html = $node.html(),
407                replaced_html;
408
409            replaced_html = html.replace( new RegExp("(" + query + ")", "i"), "<span class=" + highlighted_class + ">$1</span>");
410
411            $node.html(replaced_html);
412        });
413    };
414
415    return Post;
416
417})(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.