PageSourceSearch

https://beeorder.vn/App_Themes/AdminNew45/assets/js/custom/custom-script.js

js beeorder.vn collected 2026-10-02 02:10:46 UTC 13,240 bytes, 430 lines download raw bytes

1/*================================================================================
2	Item Name: Materialize - Material Design Admin Template
3	Version: 5.0
4	Author: PIXINVENT
5	Author URL: https://themeforest.net/user/pixinvent/portfolio
6================================================================================
7
8NOTE:
9------
10PLACE HERE YOUR OWN JS CODES AND IF NEEDED.
11WE WILL RELEASE FUTURE UPDATES SO IN ORDER TO NOT OVERWRITE YOUR CUSTOM SCRIPT IT'S BETTER LIKE THIS. */
12
13$(document).ready(function() {
14    $(".notification-button").dropdown({
15        hover: true,
16    coverTrigger: false,
17    closeOnClick: false
18  });
19  function formatMoney(
20    amount,
21    decimalCount = 2,
22    decimal = ".",
23    thousands = ","
24  ) {
25    try {
26      decimalCount = Math.abs(decimalCount);
27      decimalCount = isNaN(decimalCount) ? 2 : decimalCount;
28
29      const negativeSign = amount < 0 ? "-" : "";
30
31      let i = parseInt(
32        (amount = Math.abs(Number(amount) || 0).toFixed(decimalCount))
33      ).toString();
34      let j = i.length > 3 ? i.length % 3 : 0;
35
36      return (
37        negativeSign +
38        (j ? i.substr(0, j) + thousands : "") +
39        i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + thousands)
40      );
41    } catch (e) {
42      console.log(e);
43    }
44  }
45
46  //init modal trigger open
47  $(".modal").modal();
48
49  //Dropdown
50  $(".table .dropdown-trigger").dropdown({
51    inDuration: 350,
52    outDuration: 225,
53    constrainWidth: false, // Does not change width of dropdown to that of the activator
54    hover: false, // Activate on hover
55    gutter: 0, // Spacing from edge
56    coverTrigger: false, // Displays dropdown below the button
57    alignment: "left", // Displays dropdown with edge aligned to the left of button
58    stopPropagation: false // Stops event propagation
59  });
60  // ===== Scroll to Top ====
61  $(window).scroll(function() {
62    if ($(this).scrollTop() >= 50) {
63      // If page is scrolled more than 50px
64      $("#return-to-top").fadeIn(200); // Fade in the arrow
65    } else {
66      $("#return-to-top").fadeOut(200); // Else fade out the arrow
67    }
68  });
69  $("#return-to-top").click(function() {
70    // When arrow is clicked
71    $("body,html").animate(
72      {
73        scrollTop: 0 // Scroll to top of body
74      },
75      500
76    );
77  });
78  //lightbox
79  $(".materialboxed").materialbox();
80  //filter toggle
81    $("#filter-btn").on("click", function () {
82        $(this).toggleClass("active");
83        $(this).closest(".row").find('.filter-wrap')
84            .slideToggle();
85    });
86    $.datetimepicker.setLocale('vi');
87    $('.datetimepicker').each(function () {
88        $(this).attr('autocomplete', 'off');
89        $(this).datetimepicker({
90            format: 'd/m/Y H:00',
91            formatDate: 'd/m/Y',
92            allowTimes: [
93                '00:00',
94                '01:00',
95                '02:00',
96                '03:00',
97                '04:00',
98                '05:00',
99                '06:00',
100                '07:00',
101                '08:00',
102                '09:00',
103                '10:00',
104                '11:00',
105                '12:00',
106                '13:00',
107                '14:00',
108                '15:00',
109                '16:00',
110                '17:00',
111                '18:00',
112                '19:00',
113                '20:00',
114                '21:00',
115                '22:00',
116                '23:00',
117            ],
118            // theme:'dark',
119            // defaultDate:new Date(),
120            onShow: function (ct, element) {
121                if ($(element).hasClass('to-date')) {
122                    var minDate = $(element).closest('.row').find('.from-date').val();
123                    console.log(minDate);
124                    this.setOptions({
125                        minDate: minDate ? minDate : false,
126                    })
127                }
128                if ($(element).hasClass('date-only')) {
129                    this.setOptions({
130                        timepicker: false
131                    })
132                }
133            }
134        });
135    })
136    $("body").on("input", '[data-type="number"]', function () {
137        var value = $(this)
138            .val()
139            .replace(/[^0-9]/, "");
140        $(this).val(value);
141    });
142    //add attribute data-type="currency" for input to set input type currency format
143    var inputMoney = document.querySelectorAll('[data-type="currency"]');
144    function inputNumberTest() {
145        var regx = /\D+/g;
146        var number = this.value.replace(regx, "");
147        this.setAttribute('origin-money', number);
148        return (this.value = number.replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,"));
149    }
150    inputMoney.forEach(function (input, index) {
151        input.addEventListener("input", inputNumberTest);
152    });
153  //Select price
154  $(".from-price").on("change", function() {
155    console.log($(this).val());
156    $(".to-price").attr("min", $(this).val());
157  });
158
159  //select all dropdown
160  $("select").formSelect();
161  $("select.select_all")
162    .siblings("ul")
163    .prepend("<li id=sm_select_all><span>Chọn tất cả</span></li>");
164  $("li#sm_select_all").on("click", function() {
165    var jq_elem = $(this),
166      jq_elem_span = jq_elem.find("span"),
167      select_all = jq_elem_span.text() == "Chọn tất cả",
168      set_text = select_all ? "Bỏ chọn tất cả" : "Chọn tất cả";
169    jq_elem_span.text(set_text);
170    jq_elem
171      .siblings("li")
172      .filter(function() {
173        return (
174          $(this)
175            .find("input")
176            .prop("checked") != select_all
177        );
178      })
179      .click();
180  });
181
182  //Mask input type
183  $('[data-type="phone-number"]').formatter({
184    pattern: "{{99999999999}}"
185  });
186  $('[data-type="dateofbirth"]').formatter({
187    pattern: "{{99}}-{{99}}-{{9999}}"
188  });
189
190  //click upload file
191  $("body").on("click", ".btn-upload", function(e) {
192    e.preventDefault();
193    $(this)
194      .siblings('input[type="file"]')
195      .trigger("click");
196  });
197
198  //Print btn
199  $(".btn-print").each(function() {
200    $(this).on("click", function() {
201      window.focus();
202      window.print();
203      window.close();
204    });
205  });
206  //Edit mode
207  $("body").on("click", ".edit-mode", function(e) {
208    e.preventDefault();
209    $("body").addClass("edit-mode-open");
210    $(".detail-fixed").animate({ scrollTop: 0 }, "fast");
211  });
212  $("body").on("click", ".close-editmode", function(e) {
213    e.preventDefault();
214    $("body").removeClass("edit-mode-open");
215  });
216  $(document).click(function(event) {
217    //if you click on anything except the modal itself or the "open modal" link, close the modal
218
219    if (
220      !$(event.target).closest(
221        ".edit-mode,.detail-fixed,.detail-fixed::-webkit-scrollbar"
222      ).length
223    ) {
224      $("body").removeClass("edit-mode-open");
225    }
226  });
227
228  // Table type design
229  // if ($(".fixed-header-tb").length) {
230  //   $(".fixed-header-tb").DataTable({
231  //     responsive: false,
232  //     scrollY: "60vh",
233  //     scrollCollapse: true,
234  //     paging: true,
235  //     ordering: true,
236  //     info: true,
237  //     language: {
238  //       searchPlaceholder: "Tìm kiếm",
239  //       sLengthMenu: "Hiển thị _MENU_ kết quả tìm kiếm"
240  //     }
241  //   });
242  // }
243
244    $('body').on('focus', 'input:not(.select2-search__field),select,textarea', function () {
245        $(this).css('outline', '2px solid #ED462F');
246    });
247    $('body').on('blur', 'input,select,textarea', function () {
248        $(this).attr('style', '');
249    });
250
251
252    function changeLayout(x) {
253        if (x.matches) { // If media query matches
254            $('.sidenav-main').removeClass('nav-collapsed').addClass('nav-lock');
255            $('.navbar-toggler .material-icons').text('radio_button_checked');
256            $('#main').removeClass('main-full');
257        } else {
258            $('.sidenav-main').addClass('nav-collapsed');
259            $('.navbar-toggler .material-icons').text('radio_button_unchecked');
260            $('#main').addClass('main-full');
261        }
262    }
263
264    var media = window.matchMedia("(min-width: 1920px)")
265    changeLayout(media) // Call listener function at run time
266    media.addListener(changeLayout) // Attach listener function on state changes
267});
268
269window.addEventListener("DOMContentLoaded", function() {
270  //Drag tabble
271  var elementScroll = document.querySelectorAll(".responsive-tb");
272
273  if (elementScroll != undefined || elementScroll != null) {
274    elementScroll.forEach(function(element) {
275      var mx = 0;
276      element.addEventListener("mousedown", function(e) {
277        this.sx = this.scrollLeft;
278        mx = e.pageX - this.offsetLeft;
279
280        this.addEventListener("mousemove", mouseMoveFunction);
281      });
282      element.addEventListener("mouseup", function(e) {
283        this.removeEventListener("mousemove", mouseMoveFunction);
284        mx = 0;
285      });
286      function mouseMoveFunction(e) {
287        var mx2 = e.pageX - this.offsetLeft;
288        if (mx) this.scrollLeft = this.sx + mx - mx2;
289      }
290    });
291  }
292
293  //resize table
294  var tables = document.querySelectorAll(".list-package table");
295  for (var i = 0; i < tables.length; i++) {
296    resizableGrid(tables[i]);
297  }
298
299  function resizableGrid(table) {
300    var row = table.getElementsByTagName("tr")[0],
301      cols = row ? row.children : undefined;
302    if (!cols) return;
303
304    table.style.overflow = "hidden";
305
306    var tableHeight = table.offsetHeight;
307
308    for (var i = 0; i < cols.length; i++) {
309      var div = createDiv(tableHeight);
310      cols[i].appendChild(div);
311      cols[i].style.position = "relative";
312      setListeners(div);
313    }
314
315    function setListeners(div) {
316      var pageX, curCol, nxtCol, curColWidth, nxtColWidth;
317
318      div.addEventListener("mousedown", function(e) {
319        curCol = e.target.parentElement;
320        nxtCol = curCol.nextElementSibling;
321        pageX = e.pageX;
322
323        var padding = paddingDiff(curCol);
324
325        curColWidth = curCol.offsetWidth - padding;
326        if (nxtCol) nxtColWidth = nxtCol.offsetWidth - padding;
327      });
328
329      div.addEventListener("mouseover", function(e) {
330        e.target.style.borderRight = "1px solid #000";
331      });
332
333      div.addEventListener("mouseout", function(e) {
334        e.target.style.borderRight = "";
335      });
336
337      document.addEventListener("mousemove", function(e) {
338        if (curCol) {
339          var diffX = e.pageX - pageX;
340
341          if (nxtCol) nxtCol.style.width = nxtColWidth - diffX + "px";
342
343          curCol.style.width = curColWidth + diffX + "px";
344        }
345      });
346
347      document.addEventListener("mouseup", function(e) {
348        curCol = undefined;
349        nxtCol = undefined;
350        pageX = undefined;
351        nxtColWidth = undefined;
352        curColWidth = undefined;
353      });
354    }
355
356    function createDiv(height) {
357      var div = document.createElement("div");
358      div.style.top = 0;
359      div.style.right = 0;
360      div.style.width = "5px";
361      div.style.position = "absolute";
362      div.style.cursor = "col-resize";
363      div.style.userSelect = "none";
364      div.style.height = height + "px";
365      return div;
366    }
367
368    function paddingDiff(col) {
369      if (getStyleVal(col, "box-sizing") == "border-box") {
370        return 0;
371      }
372
373      var padLeft = getStyleVal(col, "padding-left");
374      var padRight = getStyleVal(col, "padding-right");
375      return parseInt(padLeft) + parseInt(padRight);
376    }
377
378    function getStyleVal(elm, css) {
379      return window.getComputedStyle(elm, null).getPropertyValue(css);
380    }
381  }
382});
383
384//Upload image preview
385function previewFiles(e) {
386  var preview = e.parentNode.nextElementSibling;
387  var files = e.files;
388  function readAndPreview(file) {
389    // Make sure `file.name` matches our extensions criteria
390    if (/\.(jpe?g|png|gif)$/i.test(file.name)) {
391      var reader = new FileReader();
392
393      reader.addEventListener(
394        "load",
395        function() {
396          var image = new Image();
397          image.height = 50;
398          image.title = file.name;
399          image.src = this.result;
400          image.classList = "materialboxed";
401          var wrap = document.createElement("div");
402          wrap.classList = "img-block";
403          wrap.appendChild(image);
404          var close = document.createElement("span");
405          close.classList = "material-icons red-text delete";
406          close.innerHTML = "clear";
407          close.onclick = function() {
408            this.parentNode.parentNode.removeChild(this.parentNode);
409          };
410          wrap.appendChild(close);
411          preview.appendChild(wrap);
412        },
413        false
414      );
415
416      reader.readAsDataURL(file);
417    }
418  }
419
420  if (files) {
421    var promise = new Promise(function(resolve, reject) {
422      resolve([].forEach.call(files, readAndPreview));
423    });
424    promise.then(function() {
425      setTimeout(function() {
426        $(".materialboxed").materialbox();
427      }, 1000);
428    });
429  }
430}

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.