Server IP : 162.0.232.140 / Your IP : 3.144.216.188 Web Server : LiteSpeed System : Linux premium139.web-hosting.com 4.18.0-513.24.1.lve.2.el8.x86_64 #1 SMP Fri May 24 12:42:50 UTC 2024 x86_64 User : micrcvoy ( 740) PHP Version : 8.1.32 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/micrcvoy/public_html/controlPanel/assets/plugins/summernote/src/js/module/ |
Upload File : |
define([ 'summernote/core/key' ], function (key) { var ImageDialog = function (handler) { /** * toggle button status * * @private * @param {jQuery} $btn * @param {Boolean} isEnable */ var toggleBtn = function ($btn, isEnable) { $btn.toggleClass('disabled', !isEnable); $btn.attr('disabled', !isEnable); }; /** * bind enter key * * @private * @param {jQuery} $input * @param {jQuery} $btn */ var bindEnterKey = function ($input, $btn) { $input.on('keypress', function (event) { if (event.keyCode === key.code.ENTER) { $btn.trigger('click'); } }); }; this.show = function (layoutInfo) { var $dialog = layoutInfo.dialog(), $editable = layoutInfo.editable(); handler.invoke('editor.saveRange', $editable); this.showImageDialog($editable, $dialog).then(function (data) { handler.invoke('editor.restoreRange', $editable); if (typeof data === 'string') { // image url handler.invoke('editor.insertImage', $editable, data); } else { // array of files handler.insertImages(layoutInfo, data); } }).fail(function () { handler.invoke('editor.restoreRange', $editable); }); }; /** * show image dialog * * @param {jQuery} $editable * @param {jQuery} $dialog * @return {Promise} */ this.showImageDialog = function ($editable, $dialog) { return $.Deferred(function (deferred) { var $imageDialog = $dialog.find('.note-image-dialog'); var $imageInput = $dialog.find('.note-image-input'), $imageUrl = $dialog.find('.note-image-url'), $imageBtn = $dialog.find('.note-image-btn'); $imageDialog.one('shown.bs.modal', function () { // Cloning imageInput to clear element. $imageInput.replaceWith($imageInput.clone() .on('change', function () { deferred.resolve(this.files || this.value); $imageDialog.modal('hide'); }) .val('') ); $imageBtn.click(function (event) { event.preventDefault(); deferred.resolve($imageUrl.val()); $imageDialog.modal('hide'); }); $imageUrl.on('keyup paste', function (event) { var url; if (event.type === 'paste') { url = event.originalEvent.clipboardData.getData('text'); } else { url = $imageUrl.val(); } toggleBtn($imageBtn, url); }).val('').trigger('focus'); bindEnterKey($imageUrl, $imageBtn); }).one('hidden.bs.modal', function () { $imageInput.off('change'); $imageUrl.off('keyup paste keypress'); $imageBtn.off('click'); if (deferred.state() === 'pending') { deferred.reject(); } }).modal('show'); }); }; }; return ImageDialog; });