From a1e1b52d6e851528a439b84724fa794e44019245 Mon Sep 17 00:00:00 2001 From: Samuel Georges Date: Sat, 4 Jul 2015 09:33:05 +1000 Subject: [PATCH] Fixes bug where select2 cannot be selected in a popup OL and UL and sane rich editor elements Disable search on list setup form --- .../richeditor/assets/js/plugin.figure.js | 62 +-- .../richeditor/assets/js/richeditor.js | 4 +- .../widgets/lists/partials/_setup_form.htm | 2 +- .../assets/ui/vendor/bootstrap/js/modal.js | 441 +++++++++--------- 4 files changed, 232 insertions(+), 277 deletions(-) diff --git a/modules/backend/formwidgets/richeditor/assets/js/plugin.figure.js b/modules/backend/formwidgets/richeditor/assets/js/plugin.figure.js index 8fffeabd6..b27da0697 100644 --- a/modules/backend/formwidgets/richeditor/assets/js/plugin.figure.js +++ b/modules/backend/formwidgets/richeditor/assets/js/plugin.figure.js @@ -20,61 +20,10 @@ controlGroup: ['up', 'down', 'remove'], init: function () { - this.observeCaptions() this.observeToolbars() this.observeKeyboard() }, - observeCaptions: function () { - - /* - * Adding a line-break to empty captions and citations on click will place the cursor in the expected place - */ - this.redactor.$editor.on('click.figure', 'figcaption:empty, cite:empty', $.proxy(function (event) { - $(event.target).prepend('
') - this.redactor.caret.setEnd(event.target) - event.stopPropagation() - }, this)) - - /* - * Remove generated line-breaks empty figcaptions - */ - $(window).on('click', $.proxy(this.cleanCaptions, this)) - this.redactor.$editor.on('blur.figure', $.proxy(this.cleanCaptions, this)) - this.redactor.$editor.closest('form').one('submit', $.proxy(this.clearCaptions, this)) - - /* - * Prevent user from removing captions or citations with delete/backspace keys - */ - this.redactor.$editor.on('keydown.figure', $.proxy(function (event) { - var current = this.redactor.selection.getCurrent(), - isEmpty = !current.length, - isCaptionNode = !!$(current).closest('figcaption, cite').length, - isDeleteKey = $.inArray(event.keyCode, [this.redactor.keyCode.BACKSPACE, this.redactor.keyCode.DELETE]) >= 0 - - if (isEmpty && isDeleteKey && isCaptionNode) { - event.preventDefault() - } - }, this)) - - }, - - cleanCaptions: function () { - this.redactor.$editor.find('figcaption, cite').filter(function () { - return $(this).text() == '' - }).empty() - }, - - clearCaptions: function () { - this.redactor.$editor.find('figcaption, cite').filter(function () { - return $(this).text() == '' - }).remove() - - if (this.redactor.opts.visual) { - this.redactor.code.sync() - } - }, - showToolbar: function (event) { var $figure = $(event.currentTarget), type = $figure.data('type') || 'default', @@ -285,11 +234,11 @@ * Delete key */ if ( - event.keyCode === 8 - && !redactor.caret.getOffset(currentNode) - && currentNode.previousSibling - && currentNode.previousSibling.nodeName === 'FIGURE' - ) { + event.keyCode === 8 + && !redactor.caret.getOffset(currentNode) + && currentNode.previousSibling + && currentNode.previousSibling.nodeName === 'FIGURE' + ) { event.preventDefault() } }) @@ -297,7 +246,6 @@ destroy: function() { this.redactor.$editor.off('.figure') - $(window).off('click', $.proxy(this.cleanCaptions, this)) for (var type in this.toolbar) { this.toolbar[type].find('span').off('.figure') diff --git a/modules/backend/formwidgets/richeditor/assets/js/richeditor.js b/modules/backend/formwidgets/richeditor/assets/js/richeditor.js index 94e3c2c3b..bc25afd18 100755 --- a/modules/backend/formwidgets/richeditor/assets/js/richeditor.js +++ b/modules/backend/formwidgets/richeditor/assets/js/richeditor.js @@ -168,8 +168,8 @@ } RichEditor.prototype.sanityCheckContent = function() { - // First and last elements should always be paragraphs or pre - var safeElements = 'p, h1, h2, h3, h4, h5, pre, figure'; + // First and last elements should always be paragraphs, lists or pre + var safeElements = 'p, h1, h2, h3, h4, h5, pre, figure, ol, ul'; if (!this.$editor.children(':last-child').is(safeElements)) { this.$editor.append('


') diff --git a/modules/backend/widgets/lists/partials/_setup_form.htm b/modules/backend/widgets/lists/partials/_setup_form.htm index 3d51f8d21..fe287d5b6 100644 --- a/modules/backend/widgets/lists/partials/_setup_form.htm +++ b/modules/backend/widgets/lists/partials/_setup_form.htm @@ -38,7 +38,7 @@

- diff --git a/modules/system/assets/ui/vendor/bootstrap/js/modal.js b/modules/system/assets/ui/vendor/bootstrap/js/modal.js index 20ff27046..9b44a8463 100644 --- a/modules/system/assets/ui/vendor/bootstrap/js/modal.js +++ b/modules/system/assets/ui/vendor/bootstrap/js/modal.js @@ -8,236 +8,243 @@ +function ($) { - 'use strict'; + 'use strict'; - // MODAL CLASS DEFINITION - // ====================== + // MODAL CLASS DEFINITION + // ====================== - var Modal = function (element, options) { - this.options = options - this.$element = $(element) - this.$backdrop = - this.isShown = null + var Modal = function (element, options) { + this.options = options + this.$element = $(element) + this.$backdrop = + this.isShown = null - if (this.options.remote) { - this.$element - .find('.modal-content') - .load(this.options.remote, $.proxy(function () { - this.$element.trigger('loaded.bs.modal') - }, this)) - } - } - - Modal.DEFAULTS = { - backdrop: true, - keyboard: true, - show: true - } - - Modal.prototype.toggle = function (_relatedTarget) { - return this[!this.isShown ? 'show' : 'hide'](_relatedTarget) - } - - Modal.prototype.show = function (_relatedTarget) { - var that = this - var e = $.Event('show.bs.modal', { relatedTarget: _relatedTarget }) - - this.$element.trigger(e) - - if (this.isShown || e.isDefaultPrevented()) return - - this.isShown = true - - this.escape() - - this.$element.on('click.dismiss.bs.modal', '[data-dismiss="modal"]', $.proxy(this.hide, this)) - - this.backdrop(function () { - var transition = $.support.transition && that.$element.hasClass('fade') - - if (!that.$element.parent().length) { - that.$element.appendTo(document.body) // don't move modals dom position - } - - that.$element - .show() - .scrollTop(0) - - if (transition) { - that.$element[0].offsetWidth // force reflow - } - - that.$element - .addClass('in') - .attr('aria-hidden', false) - - that.enforceFocus() - - var e = $.Event('shown.bs.modal', { relatedTarget: _relatedTarget }) - - transition ? - that.$element.find('.modal-dialog') // wait for modal to slide in - .one($.support.transition.end, function () { - that.$element.focus().trigger(e) - }) - .emulateTransitionEnd(300) : - that.$element.focus().trigger(e) - }) - } - - Modal.prototype.hide = function (e) { - if (e) e.preventDefault() - - e = $.Event('hide.bs.modal') - - this.$element.trigger(e) - - if (!this.isShown || e.isDefaultPrevented()) return - - this.isShown = false - - this.escape() - - $(document).off('focusin.bs.modal') - - this.$element - .removeClass('in') - .attr('aria-hidden', true) - .off('click.dismiss.bs.modal') - - $.support.transition && this.$element.hasClass('fade') ? - this.$element - .one($.support.transition.end, $.proxy(this.hideModal, this)) - .emulateTransitionEnd(300) : - this.hideModal() - } - - Modal.prototype.enforceFocus = function () { - $(document) - .off('focusin.bs.modal') // guard against infinite focus loop - .on('focusin.bs.modal', $.proxy(function (e) { - if (this.$element[0] !== e.target && !this.$element.has(e.target).length) { - this.$element.focus() + if (this.options.remote) { + this.$element + .find('.modal-content') + .load(this.options.remote, $.proxy(function () { + this.$element.trigger('loaded.bs.modal') + }, this)) } - }, this)) - } - - Modal.prototype.escape = function () { - if (this.isShown && this.options.keyboard) { - this.$element.on('keyup.dismiss.bs.modal', $.proxy(function (e) { - e.which == 27 && this.hide() - }, this)) - } else if (!this.isShown) { - this.$element.off('keyup.dismiss.bs.modal') } - } - Modal.prototype.hideModal = function () { - var that = this - this.$element.hide() - this.backdrop(function () { - that.removeBackdrop() - that.$element.trigger('hidden.bs.modal') - }) - } - - Modal.prototype.removeBackdrop = function () { - this.$backdrop && this.$backdrop.remove() - this.$backdrop = null - } - - Modal.prototype.backdrop = function (callback) { - var animate = this.$element.hasClass('fade') ? 'fade' : '' - - if (this.isShown && this.options.backdrop) { - var doAnimate = $.support.transition && animate - - this.$backdrop = $('