1"use strict"; 2!function (mg_app, $) { 3 "use strict"; 4 mg_app.Package.name = "smtm"; 5 mg_app.Package.version = "2.2"; 6 var $win = $(window), 7 $body = $('body'), 8 $doc = $(document), 9 _body_theme = 'nio-theme', 10 _menu = 'nk-menu', 11 _mobile_nav = 'mobile-menu', 12 _header = 'nk-header', 13 _header_menu = 'nk-header-menu', 14 _sidebar = 'nk-sidebar', 15 _sidebar_mob = 'nk-sidebar-mobile', 16 _break = mg_app.Break; 17 18 function extend(obj, ext) { 19 Object.keys(ext).forEach(function (key) { 20 obj[key] = ext[key]; 21 }); 22 return obj; 23 } 24 mg_app.ClassBody = function () { 25 mg_app.AddInBody(_sidebar); 26 }; 27 mg_app.ClassNavMenu = function () { 28 mg_app.BreakClass('.' + _header_menu, _break.lg, { 29 timeOut: 0 30 }); 31 $win.on('resize', function () { 32 mg_app.BreakClass('.' + _header_menu, _break.lg); 33 }); 34 }; 35 mg_app.Prettify = function () { 36 window.prettyPrint && prettyPrint(); 37 }; 38 mg_app.Copied = function () { 39 var clip = '.clipboard-init', 40 target = '.clipboard-text', 41 sclass = 'clipboard-success', 42 eclass = 'clipboard-error'; 43 44 function feedback(el, state) { 45 var $elm = $(el), 46 $elp = $elm.parent(), 47 copy = { 48 text: 'Copy', 49 done: 'Copied', 50 fail: 'Failed' 51 }, 52 data = { 53 text: $elm.data('clip-text'), 54 done: $elm.data('clip-success'), 55 fail: $elm.data('clip-error') 56 }; 57 copy.text = data.text ? data.text : copy.text; 58 copy.done = data.done ? data.done : copy.done; 59 copy.fail = data.fail ? data.fail : copy.fail; 60 var copytext = state === 'success' ? copy.done : copy.fail, 61 addclass = state === 'success' ? sclass : eclass; 62 $elp.addClass(addclass).find(target).html(copytext); 63 setTimeout(function () { 64 $elp.removeClass(sclass + ' ' + eclass).find(target).html(copy.text).blur(); 65 $elp.find('input').blur(); 66 }, 2000); 67 } 68 69 if (ClipboardJS.isSupported()) { 70 var clipboard = new ClipboardJS(clip); 71 clipboard.on('success', function (e) { 72 feedback(e.trigger, 'success'); 73 e.clearSelection(); 74 }).on('error', function (e) { 75 feedback(e.trigger, 'error'); 76 }); 77 } else { 78 $(clip).css('display', 'none'); 79 }; 80 }; 81 mg_app.CurrentLink = function () { 82 var _link = '.nk-menu-link, .menu-link, .nav-link', 83 _currentURL = window.location.href, 84 fileName = _currentURL.substring(0, _currentURL.indexOf("#") == -1 ? _currentURL.length : _currentURL.indexOf("#")), 85 fileName = fileName.substring(0, fileName.indexOf("?") == -1 ? fileName.length : fileName.indexOf("?")); 86 87 $(_link).each(function () { 88 var self = $(this), 89 _self_link = self.attr('href'); 90 91 if (fileName.match(_self_link)) { 92 self.closest("li").addClass('active current-page').parents().closest("li").addClass("active current-page"); 93 self.closest("li").children('.nk-menu-sub').css('display', 'block'); 94 self.parents().closest("li").children('.nk-menu-sub').css('display', 'block'); 95 } else { 96 self.closest("li").removeClass('active current-page').parents().closest("li:not(.current-page)").removeClass("active"); 97 } 98 }); 99 }; 100 mg_app.PassSwitch = function () { 101 mg_app.Passcode('.passcode-switch'); 102 }; 103 mg_app.Toast = function (msg, ttype, opt) { 104 var ttype = ttype ? ttype : 'info', 105 msi = '', 106 ticon = ttype === 'info' ? 'ni ni-info-fill' : ttype === 'success' ? 'ni ni-check-circle-fill' : ttype === 'error' ? 'ni ni-cross-circle-fill' : ttype === 'warning' ? 'ni ni-alert-fill' : '', 107 def = { 108 position: 'bottom-right', 109 ui: '', 110 icon: 'auto', 111 clear: false 112 }, 113 attr = opt ? extend(def, opt) : def; 114 attr.position = attr.position ? 'toast-' + attr.position : 'toast-bottom-right'; 115 attr.icon = attr.icon === 'auto' ? ticon : attr.icon ? attr.icon : ''; 116 attr.ui = attr.ui ? ' ' + attr.ui : ''; 117 msi = attr.icon !== '' ? '<span class="toastr-icon"><em class="icon ' + attr.icon + '"></em></span>' : '', msg = msg !== '' ? msi + '<div class="toastr-text">' + msg + '</div>' : ''; 118 119 if (msg !== "") { 120 if (attr.clear === true) { 121 toastr.clear(); 122 } 123 var option = { 124 "closeButton": true, 125 "debug": false, 126 "newestOnTop": false, 127 "progressBar": false, 128 "positionClass": attr.position + attr.ui, 129 "closeHtml": '<span class="btn-trigger">Close</span>', 130 "preventDuplicates": true, 131 "showDuration": "1500", 132 "hideDuration": "1500", 133 "timeOut": "3000", 134 "toastClass": "toastr", 135 "extendedTimeOut": "3000" 136 }; 137 toastr.options = extend(option, attr); 138 toastr[ttype](msg); 139 } 140 }; 141 mg_app.TGL.screen = function (elm) { 142 if ($(elm).exists()) { 143 $(elm).each(function () { 144 var ssize = $(this).data('toggle-screen'); 145 146 if (ssize) { 147 $(this).addClass('toggle-screen-' + ssize); 148 } 149 }); 150 } 151 }; 152 mg_app.TGL.content = function (elm, opt) { 153 var toggle = elm ? elm : '.toggle', 154 $toggle = $(toggle), 155 $contentD = $('[data-content]'), 156 toggleBreak = true, 157 toggleCurrent = false, 158 def = { 159 active: 'active', 160 content: 'content-active', 161 "break": toggleBreak 162 }, 163 attr = opt ? extend(def, opt) : def; 164 mg_app.TGL.screen($contentD); 165 $toggle.on('click', function (e) { 166 toggleCurrent = this; 167 mg_app.Toggle.trigger($(this).data('target'), attr); 168 e.preventDefault(); 169 }); 170 $doc.on('mouseup', function (e) { 171 if (toggleCurrent) { 172 var $toggleCurrent = $(toggleCurrent); 173 174 if (!$toggleCurrent.is(e.target) && $toggleCurrent.has(e.target).length === 0 && !$contentD.is(e.target) && $contentD.has(e.target).length === 0) { 175 mg_app.Toggle.removed($toggleCurrent.data('target'), attr); 176 toggleCurrent = false; 177 } 178 } 179 }); 180 $win.on('resize', function () { 181 $contentD.each(function () { 182 var content = $(this).data('content'), 183 ssize = $(this).data('toggle-screen'), 184 toggleBreak = _break[ssize]; 185 186 if (mg_app.Win.width > toggleBreak) { 187 mg_app.Toggle.removed(content, attr); 188 } 189 }); 190 }); 191 }; 192 mg_app.TGL.expand = function (elm, opt) { 193 var toggle = elm ? elm : '.expand', 194 def = { 195 toggle: true 196 }, 197 attr = opt ? extend(def, opt) : def; 198 $(toggle).on('click', function (e) { 199 mg_app.Toggle.trigger($(this).data('target'), attr); 200 e.preventDefault(); 201 }); 202 }; 203 mg_app.TGL.ddmenu = function (elm, opt) { 204 var imenu = elm ? elm : '.nk-menu-toggle', 205 def = { 206 active: 'active', 207 self: 'nk-menu-toggle', 208 child: 'nk-menu-sub' 209 }, 210 attr = opt ? extend(def, opt) : def; 211 $(imenu).on('click', function (e) { 212 if (mg_app.Win.width < _break.lg || $(this).parents().hasClass(_sidebar)) { 213 mg_app.Toggle.dropMenu($(this), attr); 214 } 215 e.preventDefault(); 216 }); 217 }; 218 mg_app.TGL.showmenu = function (elm, opt) { 219 var toggle = elm ? elm : '.nk-nav-toggle', 220 $toggle = $(toggle), 221 $contentD = $('[data-content]'), 222 toggleBreak = $contentD.hasClass(_header_menu) ? _break.lg : _break.xl, 223 toggleOlay = _sidebar + '-overlay', 224 toggleClose = { 225 profile: true, 226 menu: false 227 }, 228 def = { 229 active: 'toggle-active', 230 content: _sidebar + '-active', 231 body: 'nav-shown', 232 overlay: toggleOlay, 233 "break": toggleBreak, 234 close: toggleClose 235 }, 236 attr = opt ? extend(def, opt) : def; 237 $toggle.on('click', function (e) { 238 mg_app.Toggle.trigger($(this).data('target'), attr); 239 e.preventDefault(); 240 }); 241 $doc.on('mouseup', function (e) { 242 if (!$toggle.is(e.target) && $toggle.has(e.target).length === 0 && !$contentD.is(e.target) && $contentD.has(e.target).length === 0 && mg_app.Win.width < toggleBreak) { 243 mg_app.Toggle.removed($toggle.data('target'), attr); 244 } 245 }); 246 $win.on('resize', function () { 247 if (mg_app.Win.width < _break.xl || mg_app.Win.width < toggleBreak) { 248 mg_app.Toggle.removed($toggle.data('target'), attr); 249 } 250 }); 251 }; 252 mg_app.sbCompact = function () { 253 var toggle = '.nk-nav-compact', 254 $toggle = $(toggle), 255 $content = $('[data-content]'); 256 $toggle.on('click', function (e) { 257 e.preventDefault(); 258 var $self = $(this), 259 get_target = $self.data('target'), 260 $self_content = $('[data-content=' + get_target + ']'); 261 $self.toggleClass('compact-active'); 262 $self_content.toggleClass('is-compact'); 263 }); 264 }; 265 mg_app.Ani.formSearch = function (elm, opt) { 266 var def = { 267 active: 'active', 268 timeout: 400, 269 target: '[data-search]' 270 }, 271 attr = opt ? extend(def, opt) : def; 272 var $elem = $(elm), 273 $target = $(attr.target); 274 275 if ($elem.exists()) { 276 $elem.on('click', function (e) { 277 e.preventDefault(); 278 var $self = $(this), 279 the_target = $self.data('target'), 280 $self_st = $('[data-search=' + the_target + ']'), 281 $self_tg = $('[data-target=' + the_target + ']'); 282 283 if (!$self_st.hasClass(attr.active)) { 284 $self_tg.add($self_st).addClass(attr.active); 285 $self_st.find('input').focus(); 286 } else { 287 $self_tg.add($self_st).removeClass(attr.active); 288 setTimeout(function () { 289 $self_st.find('input').val(''); 290 }, attr.timeout); 291 } 292 }); 293 $doc.on({ 294 keyup: function keyup(e) { 295 if (e.key === "Escape") { 296 $elem.add($target).removeClass(attr.active); 297 } 298 }, 299 mouseup: function mouseup(e) { 300 if (!$target.find('input').val() && !$target.is(e.target) && $target.has(e.target).length === 0 && !$elem.is(e.target) && $elem.has(e.target).length === 0) { 301 $elem.add($target).removeClass(attr.active); 302 } 303 } 304 }); 305 } 306 }; 307 mg_app.Ani.formElm = function (elm, opt) { 308 var def = { 309 focus: 'focused' 310 }, 311 attr = opt ? extend(def, opt) : def; 312 313 if ($(elm).exists()) { 314 $(elm).each(function () { 315 var $self = $(this); 316 317 if ($self.val()) {
318 $self.parent().addClass(attr.focus); 319 } 320 321 $self.on({ 322 focus: function focus() { 323 $self.parent().addClass(attr.focus); 324 }, 325 blur: function blur() { 326 if (!$self.val()) { 327 $self.parent().removeClass(attr.focus); 328 } 329 } 330 }); 331 }); 332 } 333 }; 334 mg_app.Validate = function (elm, opt) { 335 if ($(elm).exists()) { 336 $(elm).each(function () { 337 var def = { 338 errorElement: "span" 339 }, 340 attr = opt ? extend(def, opt) : def; 341 $(this).validate(attr); 342 }); 343 } 344 }; 345 mg_app.Validate.init = function () { 346 mg_app.Validate('.form-validate', { 347 errorElement: "span", 348 errorClass: "invalid", 349 errorPlacement: function errorPlacement(error, element) { 350 error.appendTo(element.parent()); 351 } 352 }); 353 }; 354 mg_app.Dropzone = function (elm, opt) { 355 if ($(elm).exists()) { 356 $(elm).each(function () { 357 var def = { 358 autoDiscover: false 359 }, 360 attr = opt ? extend(def, opt) : def; 361 $(this).addClass('dropzone').dropzone(attr); 362 }); 363 } 364 }; 365 mg_app.Wizard = function () { 366 var $wizard = $(".nk-wizard").show(); 367 $wizard.steps({ 368 headerTag: ".nk-wizard-head", 369 bodyTag: ".nk-wizard-content", 370 labels: { 371 finish: "Submit", 372 next: "Next", 373 previous: "Prev", 374 loading: "Loading ..." 375 }, 376 onStepChanging: function onStepChanging(event, currentIndex, newIndex) { 377 if (currentIndex > newIndex) { 378 return true; 379 } 380 381 if (currentIndex < newIndex) { 382 $wizard.find(".body:eq(" + newIndex + ") label.error").remove(); 383 $wizard.find(".body:eq(" + newIndex + ") .error").removeClass("error"); 384 } 385 386 $wizard.validate().settings.ignore = ":disabled,:hidden"; 387 return $wizard.valid(); 388 }, 389 onFinishing: function onFinishing(event, currentIndex) { 390 $wizard.validate().settings.ignore = ":disabled"; 391 return $wizard.valid(); 392 }, 393 onFinished: function onFinished(event, currentIndex) { 394 window.location.href = "#"; 395 } 396 }).validate({ 397 errorElement: "span", 398 errorClass: "invalid", 399 errorPlacement: function errorPlacement(error, element) { 400 error.appendTo(element.parent()); 401 } 402 }); 403 }; 404 mg_app.DataTable = function (elm, opt) { 405 if ($(elm).exists()) { 406 $(elm).each(function () { 407 var auto_responsive = $(this).data('auto-responsive'); 408 var dom_normal = '<"row justify-between g-2"<"col-7 col-sm-6 text-left"f><"col-5 col-sm-6 text-right"<"datatable-filter"l>>><"datatable-wrap my-3"t><"row align-items-center"<"col-7 col-sm-12 col-md-9"p><"col-5 col-sm-12 col-md-3 text-left text-md-right"i>>'; 409 var dom_separate = '<"row justify-between g-2"<"col-7 col-sm-6 text-left"f><"col-5 col-sm-6 text-right"<"datatable-filter"l>>><"my-3"t><"row align-items-center"<"col-7 col-sm-12 col-md-9"p><"col-5 col-sm-12 col-md-3 text-left text-md-right"i>>'; 410 var dom = $(this).hasClass('is-separate') ? dom_separate : dom_normal; 411 var def = { 412 responsive: true, 413 autoWidth: false, 414 dom: dom, 415 language: { 416 search: "", 417 searchPlaceholder: "Type in to Search", 418 lengthMenu: "<span class='d-none d-sm-inline-block'>Show</span><div class='form-control-select'> _MENU_ </div>", 419 info: "_START_ -_END_ of _TOTAL_",
420 infoEmpty: "No records found", 421 infoFiltered: "( Total _MAX_ )", 422 paginate: { 423 "first": "First", 424 "last": "Last", 425 "next": "Next", 426 "previous": "Prev" 427 } 428 } 429 }, 430 attr = opt ? extend(def, opt) : def; 431 attr = auto_responsive === false ? extend(attr, { 432 responsive: false 433 }) : attr; 434 $(this).DataTable(attr); 435 }); 436 } 437 }; 438 mg_app.BS.ddfix = function (elm, exc) { 439 var dd = elm ? elm : '.dropdown-menu', 440 ex = exc ? exc : 'a:not(.clickable), button:not(.clickable), a:not(.clickable) *, button:not(.clickable) *'; 441 $(dd).on('click', function (e) { 442 if (!$(e.target).is(ex)) { 443 e.stopPropagation(); 444 return; 445 } 446 }); 447 448 if (mg_app.State.isRTL) { 449 var $dMenu = $('.dropdown-menu'); 450 $dMenu.each(function () { 451 var $self = $(this); 452 453 if ($self.hasClass('dropdown-menu-right') && !$self.hasClass('dropdown-menu-center')) { 454 $self.prev('[data-toggle="dropdown"]').dropdown({ 455 popperConfig: { 456 placement: 'bottom-start' 457 } 458 }); 459 } else if (!$self.hasClass('dropdown-menu-right') && !$self.hasClass('dropdown-menu-center')) { 460 $self.prev('[data-toggle="dropdown"]').dropdown({ 461 popperConfig: { 462 placement: 'bottom-end' 463 } 464 }); 465 } 466 }); 467 } 468 }; 469 mg_app.BS.tabfix = function (elm) { 470 var tab = elm ? elm : '[data-toggle="modal"]'; 471 $(tab).on('click', function () { 472 var _this = $(this), 473 target = _this.data('target'), 474 target_href = _this.attr('href'), 475 tg_tab = _this.data('tab-target'); 476 477 var modal = target ? $body.find(target) : $body.find(target_href); 478 479 if (tg_tab && tg_tab !== '#' && modal) { 480 modal.find('[href="' + tg_tab + '"]').tab('show'); 481 } else if (modal) { 482 var tabdef = modal.find('.nk-nav.nav-tabs'); 483 var link = $(tabdef[0]).find('[data-toggle="tab"]'); 484 $(link[0]).tab('show'); 485 } 486 }); 487 }; 488 mg_app.ModeSwitch = function () { 489 var toggle = $('.dark-switch'); 490 491 if ($body.hasClass('dark-mode')) { 492 toggle.addClass('active'); 493 } else { 494 toggle.removeClass('active'); 495 } 496 497 toggle.on('click', function (e) { 498 e.preventDefault(); 499 $(this).toggleClass('active'); 500 $body.toggleClass('dark-mode'); 501 }); 502 }; 503 mg_app.Knob.init = function () { 504 var knob = { 505 "default": { 506 readOnly: true, 507 lineCap: "round" 508 }, 509 half: { 510 angleOffset: -90, 511 angleArc: 180, 512 readOnly: true, 513 lineCap: "round" 514 } 515 }; 516 mg_app.Knob('.knob', knob["default"]); 517 mg_app.Knob('.knob-half', knob.half); 518 }; 519 mg_app.Range.init = function () { 520 mg_app.Range('.form-range-slider'); 521 }; 522 mg_app.Select2.init = function () { 523 mg_app.Select2('.form-select'); 524 }; 525 mg_app.Slider.init = function () { 526 mg_app.Slick('.slider-init'); 527 }; 528 mg_app.Dropzone.init = function () { 529 mg_app.Dropzone('.upload-zone', { 530 url: "/images" 531 }); 532 }; 533 mg_app.DataTable.init = function () { 534 mg_app.DataTable('.datatable-init', { 535 responsive: { 536 details: true 537 } 538 }); 539 $.fn.DataTable.ext.pager.numbers_length = 7; 540 }; 541 mg_app.OtherInit = function () { 542 mg_app.ClassBody(); 543 mg_app.PassSwitch(); 544 mg_app.CurrentLink(); 545 mg_app.LinkOff('.is-disable'); 546 mg_app.ClassNavMenu(); 547 548 mg_app.SetHW('[data-height]', 'height'); 549 mg_app.SetHW('[data-width]', 'width'); 550 551 if ($(".sidebarlines").is(":visible")) { 552 $(".nk-header-search").hide(); 553 } 554 else { 555 $(".nk-header-search").show(); 556 } 557 558 $(window).resize(function () { 559 if ($(".sidebarlines").is(":visible")) { 560 $(".nk-header-search").hide(); 561 } 562 else { 563 $(".nk-header-search").show(); 564 } 565 }); 566 }; 567 mg_app.Ani.init = function () { 568 mg_app.Ani.formElm('.form-control-outlined'); 569 mg_app.Ani.formSearch('.toggle-search'); 570 }; 571 mg_app.BS.init = function () { 572 mg_app.BS.menutip('a.nk-menu-link'); 573 mg_app.BS.tooltip('.nk-tooltip'); 574 mg_app.BS.tooltip('.btn-tooltip', { 575 placement: 'top' 576 }); 577 mg_app.BS.tooltip('[data-toggle="tooltip"]'); 578 mg_app.BS.tooltip('.tipinfo,.nk-menu-tooltip', { 579 placement: 'right' 580 }); 581 mg_app.BS.popover('[data-toggle="popover"]'); 582 mg_app.BS.progress('[data-progress]'); 583 mg_app.BS.fileinput('.custom-file-input'); 584 mg_app.BS.modalfix(); 585 mg_app.BS.ddfix(); 586 mg_app.BS.tabfix(); 587 }; 588 mg_app.Picker.init = function () { 589 mg_app.Picker.date('.date-picker'); 590 mg_app.Picker.dob('.date-picker-alt'); 591 mg_app.Picker.time('.time-picker'); 592 }; 593 mg_app.Addons.Init = function () { 594 mg_app.Knob.init();
595 mg_app.Range.init(); 596 mg_app.Select2.init(); 597 mg_app.Dropzone.init(); 598 mg_app.Slider.init(); 599 mg_app.DataTable.init(); 600 }; 601 mg_app.TGL.init = function () { 602 mg_app.TGL.content('.toggle'); 603 mg_app.TGL.expand('.toggle-expand'); 604 mg_app.TGL.expand('.toggle-opt', { 605 toggle: false 606 }); 607 mg_app.TGL.showmenu('.nk-nav-toggle'); 608 mg_app.TGL.ddmenu('.' + _menu + '-toggle', { 609 self: _menu + '-toggle', 610 child: _menu + '-sub' 611 }); 612 }; 613 mg_app.BS.modalOnInit = function () { 614 $('.modal').on('shown.bs.modal', function () { 615 mg_app.Select2.init(); 616 mg_app.Validate.init(); 617 }); 618 }; 619 mg_app.init = function () { 620 mg_app.coms.docReady.push(mg_app.OtherInit); 621 mg_app.coms.docReady.push(mg_app.Prettify); 622 mg_app.coms.docReady.push(mg_app.ColorBG); 623 mg_app.coms.docReady.push(mg_app.ColorTXT); 624 mg_app.coms.docReady.push(mg_app.Copied); 625 mg_app.coms.docReady.push(mg_app.Ani.init); 626 mg_app.coms.docReady.push(mg_app.TGL.init); 627 mg_app.coms.docReady.push(mg_app.BS.init); 628 mg_app.coms.docReady.push(mg_app.Validate.init); 629 mg_app.coms.docReady.push(mg_app.Picker.init); 630 mg_app.coms.docReady.push(mg_app.Addons.Init); 631 mg_app.coms.docReady.push(mg_app.Wizard); 632 mg_app.coms.docReady.push(mg_app.sbCompact); 633 mg_app.coms.winLoad.push(mg_app.ModeSwitch); 634 }; 635 mg_app.init(); 636 return mg_app; 637}(mg_app, 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.