Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | 68x 68x 122x 122x 122x 2x 2x 2x | 'use strict'; /** * Wysiwyg field * * @author Julien Sanchez <julien@akeneo.com> * @author Filips Alpe <filips@akeneo.com> * @copyright 2015 Akeneo SAS (http://www.akeneo.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ define( [ 'jquery', 'pim/field', 'underscore', 'pim/template/product/field/textarea', 'summernote' ], function ( $, Field, _, fieldTemplate ) { return Field.extend({ fieldTemplate: _.template(fieldTemplate), events: { 'change .field-input:first textarea:first': 'updateModel', 'click .note-insert': 'moveModalBackdrop' }, /** * @inheritDoc */ renderInput: function (context) { return this.fieldTemplate(context); }, /** * @inheritDoc */ postRender: function () { this.$('textarea:not(.note-codable)').summernote({ onToolbarClick: this.setStyleForLinkModal, disableResizeEditor: true, height: 200, iconPrefix: 'icon-', toolbar: [ ['font', ['bold', 'italic', 'underline', 'clear']], ['para', ['ul', 'ol']], ['insert', ['link']], ['view', ['codeview']] ], prettifyHtml: false }) .on('summernote.blur', this.updateModel.bind(this)) .on('summernote.keyup', this.removeEmptyTags.bind(this)); this.$('.note-codable').on('blur', function () { this.removeEmptyTags(); this.updateModel(); }.bind(this)); }, removeEmptyTags: function () { var textarea = this.$('.field-input:first textarea:first'); var editorHTML = $.parseHTML(textarea.code()); var textIsEmpty = $(editorHTML).text().length === 0; if (textIsEmpty) { textarea.code(''); } }, /** * @inheritDoc */ updateModel: function () { var data = this.$('.field-input:first textarea:first').code(); data = '' === data ? this.attribute.empty_value : data; this.setCurrentValue(data); }, /** * @inheritDoc */ setFocus: function () { this.$('.field-input:first .note-editable').trigger('focus'); }, /** * Places the modal backdrop in the page itself, and not outside of the body. * This allows the z-index to work properly in the mass-edit form, as it is * itself in a modal with its own z-index. */ moveModalBackdrop: function () { $('.modal-backdrop').prependTo('.AknFullPage'); }, /** * Since 3.0, default pages includes a lot of .sticky and .fixed elements. It implies it's impossible to * display elements on top of the page, without setting z-index in every element of the page. * Here, summernote create a modal directly from the button, and this modal is hidden in the bottom of the * page. We override the default behavior of the modal opening, to put it in the root of the <body>, then * put it back once user selected its link. * * @param jqueryEvent */ setStyleForLinkModal: function (jqueryEvent) { const source = $(jqueryEvent.originalEvent.path[0]); if (source.hasClass('icon-link') || source.hasClass('btn-sm')) { const modal = $('.note-link-dialog.modal'); // Set PIM style modal.find('.note-link-text, .note-link-url').addClass('AknTextField'); modal.find('label').addClass('AknFieldContainer-label'); modal.find('.form-group.row').addClass('AknFieldContainer'); modal.find('.modal-title').addClass('AknFullPage-subTitle'); modal.find('.btn.btn-primary.note-link-btn').addClass('AknButton AknButton--apply'); modal.find('.modal-footer').addClass('AknButtonList AknButtonList--single'); modal.find('.close').addClass('AknFullPage-cancel'); // Move Dialog to <body> const oreviousParent = modal.parent(); modal.appendTo('body'); modal.one('hidden.bs.modal', function () { modal.appendTo(oreviousParent); }); } } }); } ); |