1"use strict"; 2 3!function (Booqi, $) { 4 "use strict"; 5 6 Booqi.Package.name = "Booqi"; 7 Booqi.Package.version = "2.0"; 8 var $win = $(window), 9 $body = $('body'), 10 $doc = $(document), 11 //class names 12 _body_theme = 'nio-theme', 13 _menu = 'nk-menu', 14 _mobile_nav = 'mobile-menu', 15 _header = 'nk-header', 16 _header_menu = 'nk-header-menu', 17 _sidebar = 'nk-sidebar', 18 _sidebar_mob = 'nk-sidebar-mobile', 19 //breakpoints 20 _break = Booqi.Break; 21 22 function extend(obj, ext) { 23 Object.keys(ext).forEach(function (key) { 24 obj[key] = ext[key]; 25 }); 26 return obj; 27 } // ClassInit @v1.0 28 29 30 Booqi.ClassBody = function () { 31 Booqi.AddInBody(_sidebar); 32 }; // ClassInit @v1.0 33 34 35 Booqi.ClassNavMenu = function () { 36 Booqi.BreakClass('.' + _header_menu, _break.lg, { 37 timeOut: 0 38 }); 39 $win.on('resize', function () { 40 Booqi.BreakClass('.' + _header_menu, _break.lg); 41 }); 42 }; // Code Prettify @v1.0 43 44 45 Booqi.Prettify = function () { 46 window.prettyPrint && prettyPrint(); 47 }; // Copied @v1.0 48 49 50 Booqi.Copied = function () { 51 var clip = '.clipboard-init', 52 target = '.clipboard-text', 53 sclass = 'clipboard-success', 54 eclass = 'clipboard-error'; // Feedback 55 56 function feedback(el, state) { 57 var $elm = $(el), 58 $elp = $elm.parent(), 59 copy = { 60 text: 'Copy', 61 done: 'Copied', 62 fail: 'Failed' 63 }, 64 data = { 65 text: $elm.data('clip-text'), 66 done: $elm.data('clip-success'), 67 fail: $elm.data('clip-error') 68 }; 69 copy.text = data.text ? data.text : copy.text; 70 copy.done = data.done ? data.done : copy.done; 71 copy.fail = data.fail ? data.fail : copy.fail; 72 var copytext = state === 'success' ? copy.done : copy.fail, 73 addclass = state === 'success' ? sclass : eclass; 74 $elp.addClass(addclass).find(target).html(copytext); 75 setTimeout(function () { 76 $elp.removeClass(sclass + ' ' + eclass).find(target).html(copy.text).blur(); 77 $elp.find('input').blur(); 78 }, 2000); 79 } // Init ClipboardJS 80 81 82 if (ClipboardJS.isSupported()) { 83 var clipboard = new ClipboardJS(clip); 84 clipboard.on('success', function (e) { 85 feedback(e.trigger, 'success'); 86 e.clearSelection(); 87 }).on('error', function (e) { 88 feedback(e.trigger, 'error'); 89 }); 90 } else { 91 $(clip).css('display', 'none'); 92 } 93 94 ; 95 }; // CurrentLink Detect @v1.0 96 97 98 Booqi.CurrentLink = function () { 99 var _link = '.nk-menu-link, .menu-link, .nav-link', 100 _currentURL = window.location.href, 101 fileName = _currentURL.substring(0, _currentURL.indexOf("#") == -1 ? _currentURL.length : _currentURL.indexOf("#")), 102 fileName = fileName.substring(0, fileName.indexOf("?") == -1 ? fileName.length : fileName.indexOf("?")); 103 104 $(_link).each(function () { 105 var self = $(this), 106 _self_link = self.attr('href'); 107 108 if (fileName.match(_self_link)) { 109 self.closest("li").addClass('active current-page').parents().closest("li").addClass("active current-page"); 110 self.closest("li").children('.nk-menu-sub').css('display', 'block'); 111 self.parents().closest("li").children('.nk-menu-sub').css('display', 'block'); 112 } else { 113 self.closest("li").removeClass('active current-page').parents().closest("li:not(.current-page)").removeClass("active"); 114 } 115 }); 116 }; // PasswordSwitch @v1.0 117 118 119 Booqi.PassSwitch = function () { 120 Booqi.Passcode('.passcode-switch'); 121 }; // Toastr Message @v1.0 122 123 124 Booqi.Toast = function (msg, ttype, opt) { 125 var ttype = ttype ? ttype : 'info', 126 msi = '', 127 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' : '', 128 def = { 129 position: 'bottom-right', 130 ui: '', 131 icon: 'auto', 132 clear: false 133 }, 134 attr = opt ? extend(def, opt) : def; 135 attr.position = attr.position ? 'toast-' + attr.position : 'toast-bottom-right'; 136 attr.icon = attr.icon === 'auto' ? ticon : attr.icon ? attr.icon : ''; 137 attr.ui = attr.ui ? ' ' + attr.ui : ''; 138 msi = attr.icon !== '' ? '<span class="toastr-icon"><em class="icon ' + attr.icon + '"></em></span>' : '', msg = msg !== '' ? msi + '<div class="toastr-text">' + msg + '</div>' : ''; 139 140 if (msg !== "") { 141 if (attr.clear === true) { 142 toastr.clear(); 143 } 144 145 var option = { 146 "closeButton": true, 147 "debug": false, 148 "newestOnTop": false, 149 "progressBar": false, 150 "positionClass": attr.position + attr.ui, 151 "closeHtml": '<span class="btn-trigger">Close</span>', 152 "preventDuplicates": true, 153 "progressBar": true, 154 "showDuration": "1500", 155 "hideDuration": "1500", 156 "timeOut": "5000", 157 "toastClass": "toastr", 158 "extendedTimeOut": "30000" 159 }; 160 toastr.options = extend(option, attr); 161 toastr[ttype](msg); 162 } 163 }; // Toggle Screen @v1.0 164 165 166 Booqi.TGL.screen = function (elm) { 167 if ($(elm).exists()) { 168 $(elm).each(function () { 169 var ssize = $(this).data('toggle-screen'); 170 171 if (ssize) { 172 $(this).addClass('toggle-screen-' + ssize); 173 } 174 }); 175 } 176 }; // Toggle Content @v1.0 177 178 179 Booqi.TGL.content = function (elm, opt) { 180 var toggle = elm ? elm : '.toggle', 181 $toggle = $(toggle), 182 $contentD = $('[data-content]'), 183 toggleBreak = true, 184 toggleCurrent = false, 185 def = { 186 active: 'active', 187 content: 'content-active', 188 "break": toggleBreak 189 }, 190 attr = opt ? extend(def, opt) : def; 191 Booqi.TGL.screen($contentD); 192 $toggle.on('click', function (e) { 193 toggleCurrent = this; 194 Booqi.Toggle.trigger($(this).data('target'), attr); 195 e.preventDefault(); 196 }); 197 $doc.on('mouseup', function (e) { 198 if (toggleCurrent) { 199 var $toggleCurrent = $(toggleCurrent); 200 201 if (!$toggleCurrent.is(e.target) && $toggleCurrent.has(e.target).length === 0 && !$contentD.is(e.target) && $contentD.has(e.target).length === 0) { 202 Booqi.Toggle.removed($toggleCurrent.data('target'), attr); 203 toggleCurrent = false;
204 } 205 } 206 }); 207 $win.on('resize', function () { 208 $contentD.each(function () { 209 var content = $(this).data('content'), 210 ssize = $(this).data('toggle-screen'), 211 toggleBreak = _break[ssize]; 212 213 if (Booqi.Win.width > toggleBreak) { 214 Booqi.Toggle.removed(content, attr); 215 } 216 }); 217 }); 218 }; // ToggleExpand @v1.0 219 220 221 Booqi.TGL.expand = function (elm, opt) { 222 var toggle = elm ? elm : '.expand', 223 def = { 224 toggle: true 225 }, 226 attr = opt ? extend(def, opt) : def; 227 $(toggle).on('click', function (e) { 228 Booqi.Toggle.trigger($(this).data('target'), attr); 229 e.preventDefault(); 230 }); 231 }; // Dropdown Menu @v1.0 232 233 234 Booqi.TGL.ddmenu = function (elm, opt) { 235 var imenu = elm ? elm : '.nk-menu-toggle', 236 def = { 237 active: 'active', 238 self: 'nk-menu-toggle', 239 child: 'nk-menu-sub' 240 }, 241 attr = opt ? extend(def, opt) : def; 242 $(imenu).on('click', function (e) { 243 if (Booqi.Win.width < _break.lg || $(this).parents().hasClass(_sidebar)) { 244 Booqi.Toggle.dropMenu($(this), attr); 245 } 246 247 e.preventDefault(); 248 }); 249 }; // Show Menu @v1.0 250 251 252 Booqi.TGL.showmenu = function (elm, opt) { 253 var toggle = elm ? elm : '.nk-nav-toggle', 254 $toggle = $(toggle), 255 $contentD = $('[data-content]'), 256 toggleBreak = $contentD.hasClass(_header_menu) ? _break.lg : _break.xl, 257 toggleOlay = _sidebar + '-overlay', 258 toggleClose = { 259 profile: true, 260 menu: false 261 }, 262 def = { 263 active: 'toggle-active', 264 content: _sidebar + '-active', 265 body: 'nav-shown', 266 overlay: toggleOlay, 267 "break": toggleBreak, 268 close: toggleClose 269 }, 270 attr = opt ? extend(def, opt) : def; 271 $toggle.on('click', function (e) { 272 Booqi.Toggle.trigger($(this).data('target'), attr); 273 e.preventDefault(); 274 }); 275 $doc.on('mouseup', function (e) { 276 if (!$toggle.is(e.target) && $toggle.has(e.target).length === 0 && !$contentD.is(e.target) && $contentD.has(e.target).length === 0 && Booqi.Win.width < toggleBreak) { 277 Booqi.Toggle.removed($toggle.data('target'), attr); 278 } 279 }); 280 $win.on('resize', function () { 281 if (Booqi.Win.width < _break.xl || Booqi.Win.width < toggleBreak) { 282 Booqi.Toggle.removed($toggle.data('target'), attr); 283 } 284 }); 285 }; // Compact Sidebar @v1.0 286 287 288 Booqi.sbCompact = function () { 289 var toggle = '.nk-nav-compact', 290 $toggle = $(toggle), 291 $content = $('[data-content]'); 292 $toggle.on('click', function (e) { 293 e.preventDefault(); 294 var $self = $(this), 295 get_target = $self.data('target'), 296 $self_content = $('[data-content=' + get_target + ']'); 297 $self.toggleClass('compact-active'); 298 $self_content.toggleClass('is-compact'); 299 }); 300 }; // Animate FormSearch @v1.0 301 302 303 Booqi.Ani.formSearch = function (elm, opt) { 304 var def = { 305 active: 'active', 306 timeout: 400, 307 target: '[data-search]' 308 }, 309 attr = opt ? extend(def, opt) : def; 310 var $elem = $(elm), 311 $target = $(attr.target); 312 313 if ($elem.exists()) { 314 $elem.on('click', function (e) { 315 e.preventDefault(); 316 var $self = $(this), 317 the_target = $self.data('target'), 318 $self_st = $('[data-search=' + the_target + ']'), 319 $self_tg = $('[data-target=' + the_target + ']'); 320 321 if (!$self_st.hasClass(attr.active)) { 322 $self_tg.add($self_st).addClass(attr.active); 323 $self_st.find('input').focus(); 324 } else { 325 $self_tg.add($self_st).removeClass(attr.active); 326 setTimeout(function () { 327 $self_st.find('input').val(''); 328 }, attr.timeout); 329 } 330 }); 331 $doc.on({ 332 keyup: function keyup(e) { 333 if (e.key === "Escape") { 334 $elem.add($target).removeClass(attr.active); 335 } 336 }, 337 mouseup: function mouseup(e) { 338 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) { 339 $elem.add($target).removeClass(attr.active); 340 } 341 } 342 }); 343 } 344 }; // Animate FormElement @v1.0 345 346 347 Booqi.Ani.formElm = function (elm, opt) { 348 var def = { 349 focus: 'focused' 350 }, 351 attr = opt ? extend(def, opt) : def; 352 353 if ($(elm).exists()) { 354 $(elm).each(function () { 355 var $self = $(this); 356 357 if ($self.val()) {
358 $self.parent().addClass(attr.focus); 359 } 360 361 $self.on({ 362 focus: function focus() { 363 $self.parent().addClass(attr.focus); 364 }, 365 blur: function blur() { 366 if (!$self.val()) { 367 $self.parent().removeClass(attr.focus); 368 } 369 } 370 }); 371 }); 372 } 373 }; // Form Validate @v1.0 374 375 376 Booqi.Validate = function (elm, opt) { 377 if ($(elm).exists()) { 378 $(elm).each(function () { 379 var def = { 380 errorElement: "span" 381 }, 382 attr = opt ? extend(def, opt) : def; 383 $(this).validate(attr); 384 }); 385 } 386 }; 387 388 Booqi.Validate.init = function () { 389 Booqi.Validate('.form-validate', { 390 errorElement: "span", 391 errorClass: "invalid", 392 errorPlacement: function errorPlacement(error, element) { 393 error.appendTo(element.parent()); 394 } 395 }); 396 }; // Dropzone @v1.0 397 398 399 Booqi.Dropzone = function (elm, opt) { 400 if ($(elm).exists()) { 401 $(elm).each(function () { 402 var def = { 403 autoDiscover: false 404 }, 405 attr = opt ? extend(def, opt) : def; 406 $(this).addClass('dropzone').dropzone(attr); 407 }); 408 } 409 }; // Wizard @v1.0 410 411 412 Booqi.GenerateUUID = function () { 413 var d = new Date().getTime(); 414 var d2 = ((typeof performance !== 'undefined') && performance.now && (performance.now() * 1000)) || 0; 415 return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { 416 var r = Math.random() * 16; 417 if (d > 0) { 418 r = (d + r) % 16 | 0; 419 d = Math.floor(d / 16); 420 } else { 421 r = (d2 + r) % 16 | 0; 422 d2 = Math.floor(d2 / 16); 423 } 424 return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16); 425 }); 426 }; 427 428 429 Booqi.Quill = function (attrs = {}) { 430 431 var options = Array.isArray(attrs.options) ? attrs.options : []; 432 var transform = typeof attrs.transform === 'function' ? attrs.transform : null; 433 434 var $config = { 435 theme: 'snow', 436 modules: { 437 toolbar: [ 438 [ 439 {'header': [1, 2, 3, 4]} 440 ], 441 [ 442 'bold', 'italic', 'underline', 'strike' 443 ], 444 [ 445 {'list': 'ordered'}, 446 {'list': 'bullet'} 447 ], 448 [ 449 {'color': []}, 450 {'background': []} 451 ], 452 [ 453 'clean' 454 ] 455 ] 456 } 457 } 458 459 if (options.includes('hyperlinks')) { 460 $config.modules.toolbar[1].push('link'); 461 } 462 463 if (options.includes('indent')) { 464 $config.modules.toolbar[2].push({'indent': '-1'}); 465 $config.modules.toolbar[2].push({'indent': '+1'}); 466 } 467 468 if (options.includes('align')) { 469 $config.modules.toolbar[2].push({'align': []}); 470 } 471 472 if (options.includes('fonts')) { 473 var font = Quill.import('formats/font'); 474 var fonts = ['roboto', 'open-sans', 'montserrat', 'poppins', 'nunito', 'rubik', 's
474ource-serif']; 475 font.whitelist = fonts; 476 Quill.register(font, true); 477 $config.modules.toolbar[0].push({'font': fonts}); 478 } 479 480 if (options.includes('sizes')) { 481 var size = Quill.import('attributors/style/size'); 482 var sizes = ['8px', '10px', '12px', '14px', '16px', '20px', '24px', '28px', '32px']; 483 size.whitelist = sizes; 484 Quill.register(size, true); 485 $config.modules.toolbar[0].push({'size': sizes}); 486 } 487 488 if (options.includes('html')) { 489 Quill.register('modules/quill-html', quill_html); 490 $config.modules['quill-html'] = {}; 491 $config.modules.toolbar.push(['html-editor']); 492 } 493 494 var $quill = new Quill(attrs.bind, $config); 495 var updateOutput = function () { 496 if (!attrs.output) { 497 return; 498 } 499 500 var content = $quill.root.innerHTML; 501 if (transform) { 502 content = transform(content, $quill); 503 } 504 505 $(attrs.output).val(content); 506 }; 507 508 $quill.on('text-change', function () { 509 updateOutput(); 510 }); 511 512 updateOutput(); 513 514 return $quill; 515 516 }; 517 518 Booqi.Quill.transforms = Booqi.Quill.transforms || {}; 519 Booqi.Quill.transforms.email = function (html) { 520 if (!html) { 521 return ''; 522 } 523 524 var container = document.createElement('div'); 525 container.innerHTML = html; 526 527 var paragraphs = container.querySelectorAll('p'); 528 var total = paragraphs.length; 529 530 for (var index = 0; index < total; index++) { 531 var paragraph = paragraphs[index]; 532 var normalized = paragraph.innerHTML.replace(/ /g, ' ').replace(/<br\s*\/?>(?=$)/gi, '').trim(); 533 534 if (!normalized && index === total - 1) { 535 paragraph.innerHTML = ''; 536 } 537 538 paragraph.style.marginTop = '0'; 539 paragraph.style.marginBottom = (index === total - 1) ? '0' : '16px'; 540 } 541 542 return container.innerHTML; 543 }; 544 545 546 Booqi.Wizard = function () { 547 var $wizard = $(".nk-wizard").show(); 548 $wizard.steps({ 549 headerTag: ".nk-wizard-head", 550 bodyTag: ".nk-wizard-content", 551 labels: { 552 finish: "Submit", 553 next: "Next", 554 previous: "Prev", 555 loading: "Loading ..." 556 }, 557 onStepChanging: function onStepChanging(event, currentIndex, newIndex) { 558 // Allways allow previous action even if the current form is not valid! 559 if (currentIndex > newIndex) { 560 return true; 561 } // Needed in some cases if the user went back (clean up) 562 563 564 if (currentIndex < newIndex) { 565 // To remove error styles 566 $wizard.find(".body:eq(" + newIndex + ") label.error").remove(); 567 $wizard.find(".body:eq(" + newIndex + ") .error").removeClass("error"); 568 } 569 570 $wizard.validate().settings.ignore = ":disabled,:hidden"; 571 return $wizard.valid(); 572 }, 573 onFinishing: function onFinishing(event, currentIndex) { 574 $wizard.validate().settings.ignore = ":disabled"; 575 return $wizard.valid(); 576 }, 577 onFinished: function onFinished(event, currentIndex) { 578 window.location.href = "#"; 579 } 580 }).validate({ 581 errorElement: "span", 582 errorClass: "invalid", 583 errorPlacement: function errorPlacement(error, element) { 584 error.appendTo(element.parent()); 585 } 586 }); 587 }; // DataTable @1.0 588 589 590 Booqi.DataTable = function (elm, opt) { 591 if ($(elm).exists()) { 592 $(elm).each(function () { 593 var auto_responsive = $(this).data('auto-responsive'); 594 var def = { 595 responsive: true, 596 autoWidth: false, 597 dom: '<"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>>', 598 language: { 599 search: "", 600 searchPlaceholder: "Type in to Search", 601 lengthMenu: "<span class='d-none d-sm-inline-block'>Show</span><div class='form-control-select'> _MENU_ </div>", 602 info: "_START_ -_END_ of _TOTAL_", 603 infoEmpty: "No records found", 604 infoFiltered: "( Total _MAX_ )", 605 paginate: { 606 "first": "First", 607 "last": "Last", 608 "next": "Next", 609 "previous": "Prev" 610 } 611 } 612 }, 613 attr = opt ? extend(def, opt) : def; 614 attr = auto_responsive === false ? extend(attr, { 615 responsive: false 616 }) : attr; 617 $(this).DataTable(attr); 618 }); 619 } 620 }; // BootStrap Extended 621 622 623 Booqi.BS.ddfix = function (elm, exc) { 624 var dd = elm ? elm : '.dropdown-menu', 625 ex = exc ? exc : 'a:not(.clickable), button:not(.clickable), a:not(.clickable) *, button:not(.clickable) *'; 626 $(dd).on('click', function (e) { 627 if (!$(e.target).is(ex)) { 628 e.stopPropagation(); 629 return; 630 } 631 }); 632
633 if (Booqi.State.isRTL) { 634 var $dMenu = $('.dropdown-menu'); 635 $dMenu.each(function () { 636 var $self = $(this); 637 638 if ($self.hasClass('dropdown-menu-right') && !$self.hasClass('dropdown-menu-center')) { 639 $self.prev('[data-toggle="dropdown"]').dropdown({ 640 popperConfig: { 641 placement: 'bottom-start' 642 } 643 }); 644 } else if (!$self.hasClass('dropdown-menu-right') && !$self.hasClass('dropdown-menu-center')) { 645 $self.prev('[data-toggle="dropdown"]').dropdown({ 646 popperConfig: { 647 placement: 'bottom-end' 648 } 649 }); 650 } 651 }); 652 } 653 }; // BootStrap Specific Tab Open 654 655 656 Booqi.BS.tabfix = function (elm) { 657 var tab = elm ? elm : '[data-toggle="modal"]'; 658 $(tab).on('click', function () { 659 var _this = $(this), 660 target = _this.data('target'), 661 target_href = _this.attr('href'), 662 tg_tab = _this.data('tab-target'); 663 664 var modal = target ? $body.find(target) : $body.find(target_href); 665 666 if (tg_tab && tg_tab !== '#' && modal) { 667 modal.find('[href="' + tg_tab + '"]').tab('show'); 668 } else if (modal) { 669 var tabdef = modal.find('.nk-nav.nav-tabs'); 670 var link = $(tabdef[0]).find('[data-toggle="tab"]'); 671 $(link[0]).tab('show'); 672 } 673 }); 674 }; // Dark Mode Switch @since v2.0 675 676 677 Booqi.ModeSwitch = function () { 678 var toggle = $('.dark-switch'); 679 680 if ($body.hasClass('dark-mode')) { 681 toggle.addClass('active'); 682 } else { 683 toggle.removeClass('active'); 684 } 685 686 toggle.on('click', function (e) { 687 e.preventDefault(); 688 $(this).toggleClass('active'); 689 $body.toggleClass('dark-mode'); 690 }); 691 }; // Knob @v1.0 692 693 694 Booqi.Knob.init = function () { 695 var knob = { 696 "default": { 697 readOnly: true, 698 lineCap: "round" 699 }, 700 half: { 701 angleOffset: -90, 702 angleArc: 180, 703 readOnly: true, 704 lineCap: "round" 705 } 706 }; 707 Booqi.Knob('.knob', knob["default"]); 708 Booqi.Knob('.knob-half', knob.half); 709 }; // Range @v1.0 710 711 712 Booqi.Range.init = function () { 713 Booqi.Range('.form-range-slider'); 714 }; 715 716 Booqi.Select2.init = function () { 717 // Booqi.Select2('.select'); 718 Booqi.Select2('.form-select'); 719 }; // Slick Init @v1.0 720 721 722 Booqi.Slider.init = function () { 723 Booqi.Slick('.slider-init'); 724 }; // Dropzone Init @v1.0 725 726 727 Booqi.Dropzone.init = function () { 728 var dataUrlToBlob = function (dataUrl) { 729 var parts = dataUrl.split(','); 730 var mime = parts[0].match(/:(.*?);/)[1]; 731 var binary = atob(parts[1]); 732 var length = binary.length; 733 var bytes = new Uint8Array(length); 734 735 while (length--) { 736 bytes[length] = binary.charCodeAt(length); 737 } 738 739 return new Blob([bytes], {type: mime}); 740 }; 741 742 var cropImageBeforeUpload = function (dropzone, file, done) { 743 var width = parseInt(dropzone.element.dataset.cropWidth, 10); 744 var height = parseInt(dropzone.element.dataset.cropHeight, 10); 745 746 if (!width || !height || !file.type || file.type.indexOf('image/') !== 0 || typeof ImageCrop === 'undefined') { 747 done(file); 748 return; 749 } 750 751 var reader = new FileReader(); 752 reader.onload = function (event) { 753 var image = new Image(); 754 image.onload = function () { 755 var cropper; 756 var $modal = $('#upload-image-cropper-modal'); 757 var $container = $('#upload-image-cropper-preview'); 758 var $crop = $('#upload-image-cropper-crop'); 759 var $skip = $('#upload-image-cropper-skip'); 760 761 if (!$modal.length || !$container.length) { 762 done(file); 763 return; 764 } 765 766 $container.empty(); 767 $(image).attr('id', 'upload-image-cropper-image'); 768 $container.html(image); 769 $modal.modal('show'); 770 cropper = new ImageCrop('#upload-image-cropper-image', width, height); 771 var completed = false; 772 773 var cleanup = function () { 774 $crop.off('click.uploadImageCropper'); 775 $skip.off('click.uploadImageCropper'); 776 $modal.off('hidden.bs.modal.uploadImageCropper'); 777 setTimeout(function () { 778 $container.empty(); 779 }, 250); 780 }; 781 782 $crop.on('click.uploadImageCropper', function (e) { 783 e.preventDefault(); 784 var cropped = cropper.crop(); 785 786 if (!cropped) { 787 completed = true; 788 done(file); 789 $modal.modal('hide'); 790 return; 791 } 792 793 var blob = dataUrlToBlob(cropped.img.src); 794 blob.name = file.name; 795 blob.lastModifiedDate = new Date(); 796 completed = true; 797 done(blob); 798 $modal.modal('hide'); 799 }); 800 801 $skip.on('click.uploadImageCropper', function (e) { 802 e.preventDefault(); 803 completed = true; 804 done(file); 805 $modal.modal('hide'); 806 }); 807 808 $modal.on('hidden.bs.modal.uploadImageCropper', function () { 809 if (!completed) { 810 completed = true; 811 done(file); 812 } 813 cleanup(); 814 }); 815 }; 816 image.src = event.target.result; 817 };
818 reader.readAsDataURL(file); 819 }; 820 821 Booqi.Dropzone('.upload-zone', { 822 url: '/admin/upload', 823 paramName: 'file', 824 maxFilesize: 2, 825 transformFile: function (file, done) { 826 cropImageBeforeUpload(this, file, done); 827 }, 828 init: function () { 829 this.on('success', function (file, result) { 830 let target = this.element.dataset.target; 831 let src = this.element.dataset.src; 832 if (result.ok === true) { 833 $(target).val(result.response.path).trigger('change'); 834 if (src) { 835 let cdn = $(src).data('cdn'); 836 $(src).attr('src', `${cdn}/${result.response.path}`); 837 } 838 } 839 }); 840 } 841 }); 842 }; // DataTable Init @v1.0 843 844 845 Booqi.DataTable.init = function () { 846 Booqi.DataTable('.datatable-init', { 847 responsive: { 848 details: true 849 } 850 }); 851 $.fn.DataTable.ext.pager.numbers_length = 7; 852 }; // Extra @v1.1 853 854 855 Booqi.OtherInit = function () { 856 Booqi.ClassBody(); 857 Booqi.PassSwitch(); 858 Booqi.CurrentLink(); 859 Booqi.LinkOff('.is-disable'); 860 Booqi.ClassNavMenu(); //v1.5 861 862 Booqi.SetHW('[data-height]', 'height'); 863 Booqi.SetHW('[data-width]', 'width'); 864 }; // Animate Init @v1.0 865 866 867 Booqi.Ani.init = function () { 868 Booqi.Ani.formElm('.form-control-animate'); 869 Booqi.Ani.formSearch('.toggle-search'); 870 }; // BootstrapExtend Init @v1.0 871 872 873 Booqi.BS.init = function () { 874 Booqi.BS.menutip('a.nk-menu-link'); 875 Booqi.BS.tooltip('.nk-tooltip'); 876 Booqi.BS.tooltip('.btn-tooltip', { 877 placement: 'top' 878 }); 879 Booqi.BS.tooltip('[data-toggle="tooltip"]'); 880 Booqi.BS.tooltip('.tipinfo,.nk-menu-tooltip', { 881 placement: 'right' 882 }); 883 Booqi.BS.popover('[data-toggle="popover"]'); 884 Booqi.BS.progress('[data-progress]'); 885 Booqi.BS.fileinput('.custom-file-input'); 886 Booqi.BS.modalfix(); 887 Booqi.BS.ddfix(); 888 Booqi.BS.tabfix(); 889 }; // Picker Init @v1.0 890 891 892 Booqi.Picker.init = function () { 893 Booqi.Picker.date('.date-picker'); 894 Booqi.Picker.dob('.date-picker-alt'); 895 Booqi.Picker.time('.time-picker'); 896 }; // Addons @v1 897 898 899 Booqi.Addons.Init = function () { 900 Booqi.Knob.init(); 901 Booqi.Range.init(); 902 Booqi.Select2.init(); 903 Booqi.Dropzone.init(); 904 Booqi.Slider.init(); 905 Booqi.DataTable.init(); 906 }; // Toggler @v1 907 908 909 Booqi.TGL.init = function () { 910 Booqi.TGL.content('.toggle'); 911 Booqi.TGL.expand('.toggle-expand'); 912 Booqi.TGL.expand('.toggle-opt', { 913 toggle: false 914 }); 915 Booqi.TGL.showmenu('.nk-nav-toggle'); 916 Booqi.TGL.ddmenu('.' + _menu + '-toggle', { 917 self: _menu + '-toggle', 918 child: _menu + '-sub' 919 }); 920 }; 921 922 Booqi.BS.modalOnInit = function () { 923 $('.modal').on('shown.bs.modal', function () { 924 Booqi.Select2.init(); 925 Booqi.Validate.init(); 926 }); 927 }; // Initial by default 928 ///////////////////////////// 929 930 931 Booqi.init = function () { 932 Booqi.coms.docReady.push(Booqi.OtherInit); 933 Booqi.coms.docReady.push(Booqi.Prettify); 934 Booqi.coms.docReady.push(Booqi.ColorBG); 935 Booqi.coms.docReady.push(Booqi.ColorTXT); 936 Booqi.coms.docReady.push(Booqi.Copied); 937 Booqi.coms.docReady.push(Booqi.Ani.init); 938 Booqi.coms.docReady.push(Booqi.TGL.init); 939 Booqi.coms.docReady.push(Booqi.BS.init); 940 Booqi.coms.docReady.push(Booqi.Validate.init); 941 Booqi.coms.docReady.push(Booqi.Picker.init); 942 Booqi.coms.docReady.push(Booqi.Addons.Init); 943 Booqi.coms.docReady.push(Booqi.Wizard); 944 Booqi.coms.docReady.push(Booqi.sbCompact); 945 Booqi.coms.winLoad.push(Booqi.ModeSwitch); 946 }; 947 948 Booqi.init(); 949 return Booqi; 950}(Booqi, 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.