opencart.js (2731B)
1 $(document).ready(function() { 2 // Override summernotes image manager 3 $('[data-toggle=\'summernote\']').each(function() { 4 var element = this; 5 6 if ($(this).attr('data-lang')) { 7 $('head').append('<script type="text/javascript" src="view/javascript/summernote/lang/summernote-' + $(this).attr('data-lang') + '.js"></script>'); 8 } 9 10 $(element).summernote({ 11 lang: $(this).attr('data-lang'), 12 disableDragAndDrop: true, 13 height: 300, 14 emptyPara: '', 15 codemirror: { // codemirror options 16 mode: 'text/html', 17 htmlMode: true, 18 lineNumbers: true, 19 theme: 'monokai' 20 }, 21 fontsize: ['8', '9', '10', '11', '12', '14', '16', '18', '20', '24', '30', '36', '48' , '64'], 22 toolbar: [ 23 ['style', ['style']], 24 ['font', ['bold', 'underline', 'clear']], 25 ['fontname', ['fontname']], 26 ['fontsize', ['fontsize']], 27 ['color', ['color']], 28 ['para', ['ul', 'ol', 'paragraph']], 29 ['table', ['table']], 30 ['insert', ['link', 'image', 'video']], 31 ['view', ['fullscreen', 'codeview', 'help']] 32 ], 33 popover: { 34 image: [ 35 ['custom', ['imageAttributes']], 36 ['imagesize', ['imageSize100', 'imageSize50', 'imageSize25']], 37 ['float', ['floatLeft', 'floatRight', 'floatNone']], 38 ['remove', ['removeMedia']] 39 ], 40 }, 41 buttons: { 42 image: function() { 43 var ui = $.summernote.ui; 44 45 // create button 46 var button = ui.button({ 47 contents: '<i class="note-icon-picture" />', 48 tooltip: $.summernote.lang[$.summernote.options.lang].image.image, 49 click: function () { 50 $('#modal-image').remove(); 51 52 $.ajax({ 53 url: 'index.php?route=common/filemanager&user_token=' + getURLVar('user_token'), 54 dataType: 'html', 55 beforeSend: function() { 56 $('#button-image i').replaceWith('<i class="fa fa-circle-o-notch fa-spin"></i>'); 57 $('#button-image').prop('disabled', true); 58 }, 59 complete: function() { 60 $('#button-image i').replaceWith('<i class="fa fa-upload"></i>'); 61 $('#button-image').prop('disabled', false); 62 }, 63 success: function(html) { 64 $('body').append('<div id="modal-image" class="modal">' + html + '</div>'); 65 66 $('#modal-image').modal('show'); 67 68 $('#modal-image').delegate('a.thumbnail', 'click', function(e) { 69 e.preventDefault(); 70 71 $(element).summernote('insertImage', $(this).attr('href')); 72 73 $('#modal-image').modal('hide'); 74 }); 75 } 76 }); 77 } 78 }); 79 80 return button.render(); 81 } 82 } 83 }); 84 }); 85 });