PageSourceSearch

https://www.theengineeringprojects.com/res/js/BlogPostCreate.5eykyvtdf5.js

js theengineeringprojects.com collected 2026-09-24 18:14:03 UTC 12,797 bytes, 338 lines download raw bytes

1$(document).ready(function () {
2    var SiteUrl = "https://localhost:7025/";
3    
4    /*********** SummerNote Editor *************/
5    $('#summernote').summernote({
6        height: 500,                 // set editor height
7        minHeight: null,             // set minimum height of editor
8        maxHeight: null,             // set maximum height of editor
9        focus: true,                  // set focus to editable area after initializing summernote
10        toolbar: [
11            ['style', ['bold', 'italic', 'underline', 'clear']],
12            ['font', ['strikethrough', 'superscript', 'subscript']],
13            ['para', ['ul', 'ol']],
14            ['insert', ['link', 'picture', 'video']],
15            ['view', ['codeview']],
16
17        ],
18        callbacks: {
19            onImageUpload: function (files) {
20                //$('#exampleModalCenter').modal('show');
21                //UploadImage(files);
22            },
23            onPaste: function (e) {
24                var bufferText = ((e.originalEvent || e).clipboardData || window.clipboardData).getData('text/html');
25                e.preventDefault();
26                var div = $('<div />');
27                div.append(bufferText);
28                div.find('*').removeAttr('style');
29                div.find('*').removeAttr('dir');
30                div.find('*').removeAttr('aria-level');
31                div.find('*').removeAttr('id');
32                div.find('*').removeAttr('role');
33                div.find('span').contents().unwrap();
34                div.find('*').after('\r\n');
35                //div.replace('<br>', '');
36
37                setTimeout(function () {
38                    document.execCommand('insertHtml', false, div.html());
39                }, 10);
40            }
41        }
42    });
43
44    /*********** Image Click to open Meta Data *************/
45    $('#SnapsModalThumbnailJS').on('click', '.SnapsImgClassJS', function (e) {
46
47        var ImagesId = $(this).attr("id");
48        $.each($("div[class^='SnapsMetaBoxJS']"), function (i, item) { $(item).addClass("DivHidden"); });
49        var ImageNo = ImagesId.replace('SnapsImgClassJS', '')
50        $("#SnapsMetaBoxJS" + ImageNo).removeClass("DivHidden");
51
52    });
53
54    $('#SnapsSidebarJS').on('click', '.SnapsImgClassJS', function (e) {
55
56        $('#SnapsModalJS').css("display", "block");
57
58    });
59
60    $('#DocumentsModalThumbnailJS').on('click', '.DocumentsImgClassJS', function (e) {
61
62        var ImagesId = $(this).attr("id");
63        $.each($("div[class^='DocumentsMetaBoxJS']"), function (i, item) { $(item).addClass("DivHidden"); });
64        var ImageNo = ImagesId.replace('DocumentsImgClassJS', '')
65        $("#DocumentsMetaBoxJS" + ImageNo).removeClass("DivHidden");
66
67    });
68
69    $('#DocumentsSidebarJS').on('click', '.DocumentsImgClassJS', function (e) {
70
71        $('#DocumentsModalJS').css("display", "block");
72
73    });
74
75
76    $('#VideosModalThumbnailJS').on('click', '.VideosImgClassJS', function (e) {
77
78        var ImagesId = $(this).attr("id");
79        $.each($("div[class^='VideosMetaBoxJS']"), function (i, item) { $(item).addClass("DivHidden"); });
80        var ImageNo = ImagesId.replace('VideosImgClassJS', '')
81        $("#VideosMetaBoxJS" + ImageNo).removeClass("DivHidden");
82
83    });
84
85    $('#VideosSidebarJS').on('click', '.VideosImgClassJS', function (e) {
86
87        $('#VideosModalJS').css("display", "block");
88
89    });
90    /***************** Code Ends Here *****************/
91
92    /*********** Tags AutoComplete *************/
93    var TotalTags = [];
94    $.ajax({
95        type: "GET",
96        url: "/blog/post/createtags",
97        contentType: "application/json; charset=utf-8",
98        dataType: "json",
99        success: function (data) {
100            //alert(JSON.stringify(data));
101            TotalTags = data;
102        },
103    });
104
105    $(function () {
106
107        $("#TagsTextBox").autocomplete({
108            source: function (request, response) {
109                response($.map(TotalTags, function (item) {
110                    var position = item.title.toLowerCase().search(request.term.toLowerCase());
111                    if (position >= 0) {
112                        //$("#TagsIdTextBox").val(item.id);
113                        return item.title;
114                    }
115                }))
116            },
117            select: function (event, ui) {
118
119                var SelectedTag = $("#TagsTextBox").val();
120                $("#TagsTextBox").val("");
121                TotalTags.forEach(myFunction);
122
123                //var TagIndex = 0;
124                function myFunction(item, index) {
125                    if (item.title == SelectedTag) {
126                        var SelectedTagTitle = item.title;
127                        var SelectedTagSlug = item.slug;
128                        var NewTagId = 0;
129                        if ($(".SelectedTagsJS")[0]) {
130                            NewTagId = parseInt($('.SelectedTagsJS').last().attr("id").substring(5, 6)) + 1;
131                        }
132
133                        $('#TagSlugs').val($('#TagSlugs').val() + SelectedTagSlug + ",");
134                        $('#TagNames').val(NewTagId);
135                        var ConOpen = "<div>";
136                        var Input1 = "<input type=\"text\" id=\"Tags_" + NewTagId + "_Title\" " +
137                            " name=\"Tags[" + NewTagId + "].Title\" value=\"" + SelectedTagTitle + "\" class=\"SelectedTagsJS\" hidden=\"\">";
138
139                        var Input2 = "<input type=\"text\" id=\"Tags_" + NewTagId + "_Slug\" " +
140                            " name=\"Tags[" + NewTagId + "].Slug\" value=\"" + SelectedTagSlug + "\" hidden=\"\">";
141
142                        var Input3 = "<input type=\"checkbox\" checked /><span>" + SelectedTag + "</span><br />";
143
144                        var Input4 = "<span>" + SelectedTag + "</span> <i class=\"fa fa-times-circle TagDelete\" aria-hidden=\"true\"></i>";
145                        var ConClose = "</div>";
146
147                        var Input = ConOpen + Input1 + Input2 + Input4 + ConClose;
148
149                        $("#TagSelecteddiv").append(Input);
150
151                        TotalTags = jQuery.grep(TotalTags, function (val) { return val != item; }); // Remove selected item from list
152                    }
153                }
154
155                return false;
156            },
157            open: function () {
158                $(this).removeClass("ui-corner-all").addClass("ui-corner-top");
159            },
160            close: function () {
161                $(this).removeClass("ui-corner-top").addClass("ui-corner-all");
162            },
163            minLength: 1
164        });
165
166    });
167
168    $(".TagDelete").click(function () {
169        $(this).parent('div').remove();   // .remove();
170
171        var DeletedTagId = parseInt($(this).siblings('.SelectedTagsJS').attr('id').substring(5, 6));
172        var TotalTagsCount = $('.SelectedTagsJS').length;
173        $('#TagNames').val(DeletedTagId.toString() + " , " + TotalTagsCount.toString());
174
175        for (var i = DeletedTagId; i < TotalTagsCount; i++) {
176            var PrevTagId = i
177            var NextTagId = PrevTagId + 1;
178
179            $("#Tags_" + NextTagId + "_Title").attr("name", "Tags_[" + PrevTagId + "].Title");
180            $("#Tags_" + NextTagId + "_Slug").attr("name", "Tags_[" + PrevTagId + "].Slug");
181
182            $("#Tags_" + NextTagId + "_Title").attr("id", "Tags_" + PrevTagId + "_Title");
183            $("#Tags_" + NextTagId + "_Slug").attr("id", "Tags_" + PrevTagId + "_Slug");
184
185        }
186    });
187
188
189
190    /*********** SlugChange *************/
191    //function onchange() {
192    //    //Since you have JQuery, why aren't you using it?
193    //    var box1 = $('#Title');
194    //    var box2 = $('#TopSlug');
195    //    box2.val(box1.val().toLowerCase().replaceAll(" ", "-") + ".html");
196    //}
197    //$('#Title').on('change', onchange);
198
199
200    //var markupStr = $("#BodyOutput").val();
201    //$('#summernote').summernote('code', markupStr);
202
203    //$(".PublishBtnJS").click(function (event) {
204    //    var markupStr = $('#summernote').summernote('code');
205    //    $("#BodyOutput").val(markupStr);
206    //});
207
208    //Category-Checkbox
209    $("input:checkbox").on('click', function () {
210        // in the handler, 'this' refers to the box clicked on
211        var $box = $(this);
212        if ($box.is(":checked")) {
213            // the name of the box is retrieved using the .attr() method
214            // as it is assumed and expected to be immutable
215            var group = "input:checkbox[name='" + $box.attr("name") + "']";
216            // the checked state of the group/box on the other hand will change
217            // and the current value is retrieved using .prop() method
218            $(group).prop("checked", false);
219            $box.prop("checked", true);
220        } else {
221            $box.prop("checked", false);
222        }
223    });
224
225    // LEFT-SIDEBAR 
226    $('.open-sidebar__left').on('click', function () {
227        $('.sidebar-left').toggleClass('active');
228        $('.open-sidebar__left').toggleClass('active');
229    });
230    $('body').on('click', function (e) {
231        if (!e.target.closest('.open-sidebar__left') && !e.target.closest('.sidebar-left')) {
232            $('.sidebar-left').removeClass('active');
233            $('.open-sidebar__left').removeClass('active');
234        }
235    });
236    $('.left-menu__hero').on('click', function () {
237        $(this).toggleClass('active');
238        if ($(this).hasClass('active')) {
239            $(this).parents('.left-menu__item').find('.left-menu__drop').animate({
240                height: 'show'
241            }, 300);
242        } else {
243            $(this).parents('.left-menu__item').find('.left-menu__drop').animate({
244                height: 'hide'
245            }, 300);
246        }
247    });
248
249
250
251
252    // RIGHT-SIDEBAR 
253    $('.open-sidebar__right').on('click', function () {
254        $('.sidebar-right').toggleClass('active');
255        $('.open-sidebar__right').toggleClass('active');
256    });
257    $('body').on('click', function (e) {
258        if (!e.target.closest('.open-sidebar__right') && !e.target.closest('.sidebar-right')) {
259            $('.sidebar-right').removeClass('active');
260            $('.open-sidebar__right').removeClass('active');
261        }
262    });
263    $('.right-item-top').on('click', function () {
264        $(this).toggleClass('active');
265        if ($(this).hasClass('active')) {
266            $(this).parents('.right-item').find('.right-item__middle').animate({
267                height: 'show'
268            }, 300);
269        } else {
270            $(this).parents('.right-item').find('.right-item__middle').animate({
271                height: 'hide'
272            }, 300);
273        }
274    });
275
276
277    // EDIT permalink 
278    $('.permalink button').on('click', function (e) {
279        e.preventDefault();
280        if ($(this).text() !== 'Save') {
281            let link = $('.permalink input').val();
282            $('.permalink input').val('');
283            $('.permalink input').attr('disabled', false).focus().addClass('active').val(link);
284            $('.permalink button').text('Save');
285        } else {
286            $('.permalink input').attr('disabled', true).removeClass('active');
287            $('.permalink button').text('Edit');
288        }
289    });
290
291    //Ajax Call
292    //$.ajax({
293    //    type: "GET",
294    //    url: "/BlogPost/GetCategoriesAjax",
295    //    success: function (response) {
296
297    //        $("#newPostAjax").append(response);
298    //    }
299    //});
300
301
302
303
304    /***************** Code to upload Image using Browse Button ******************/
305    //$('#UploadImage').on("change", function () { uploadFiles() });
306    //function uploadFiles() {
307    //    var input = document.getElementById("UploadImage");
308    //    var files = input.files;
309    //    var formData = new FormData();
310
311    //    for (var i = 0; i != files.length; i++) {
312    //        formData.append("files", files[i]);
313    //    }
314
315
316    //    $.ajax(
317    //        {
318    //            url: "/uploader",
319    //            data: formData,
320    //            processData: false,
321    //            contentType: false,
322    //            type: "POST",
323    //            success: function (data) {
324    //                var ImageLink = data;
325
326    //                $('.Testing2').prepend('<img id="theImg" style="width:100px;" src="' + ImageLink +'" />')
327
328    //                $(".Testing").val(ImageLink);
329    //            },
330    //            error: function () {
331    //                $(".Testing").val("Error");
332    //            }
333    //        }
334    //    );
335    //}
336    /***************** Code Ends Here *****************/
337
338});

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.