diff options
Diffstat (limited to 'resources/assets')
| -rw-r--r-- | resources/assets/javascripts/init.js | 2 | ||||
| -rw-r--r-- | resources/assets/javascripts/jquery-bundle.js | 1 | ||||
| -rw-r--r-- | resources/assets/javascripts/lib/multi_select.js | 47 | ||||
| -rw-r--r-- | resources/assets/javascripts/studip-jquery.multi-select.tweaks.js | 81 | ||||
| -rw-r--r-- | resources/assets/stylesheets/studip-jquery-ui.less | 63 |
5 files changed, 0 insertions, 194 deletions
diff --git a/resources/assets/javascripts/init.js b/resources/assets/javascripts/init.js index 3ec1960..6818d85 100644 --- a/resources/assets/javascripts/init.js +++ b/resources/assets/javascripts/init.js @@ -44,7 +44,6 @@ import Markup from './lib/markup.js'; import Members from './lib/members.js'; import Messages from './lib/messages.js'; import MultiPersonSearch from './lib/multi_person_search.js'; -import MultiSelect from './lib/multi_select.js'; import NavigationShrinker from './lib/navigation_shrinker.js'; import OER from './lib/oer.js'; import OldUpload from './lib/old_upload.js'; @@ -132,7 +131,6 @@ window.STUDIP = _.assign(window.STUDIP || {}, { Members, Messages, MultiPersonSearch, - MultiSelect, NavigationShrinker, OER, OldUpload, diff --git a/resources/assets/javascripts/jquery-bundle.js b/resources/assets/javascripts/jquery-bundle.js index bdee32d..63230cf 100644 --- a/resources/assets/javascripts/jquery-bundle.js +++ b/resources/assets/javascripts/jquery-bundle.js @@ -66,7 +66,6 @@ import 'jquery.qrcode'; import 'jquery-ui-touch-punch'; import './studip-jquery-tweaks.js'; -import './studip-jquery.multi-select.tweaks.js'; import './studip-jquery-selection-helper.js'; import select2 from 'select2/dist/js/select2.full.js'; diff --git a/resources/assets/javascripts/lib/multi_select.js b/resources/assets/javascripts/lib/multi_select.js deleted file mode 100644 index b4abeb9..0000000 --- a/resources/assets/javascripts/lib/multi_select.js +++ /dev/null @@ -1,47 +0,0 @@ -import { $gettext } from './gettext.js'; - -/** - * Turns a select-box into an easy to use multiple select-box - */ - -const MultiSelect = { - create: function (id, itemName, options = {}) { - const count = $(id).find('option:selected').length; - const count_template = _.template(_('<%= count %> ausgewählt')); - const update_counter = function () { - const count = $(id).find('option:selected').length; - $(id).next().find('.counter').text(count_template({count: count})); - }; - - if (!$(id).attr('multiple')) { - $(id).attr('multiple', 'multiple').css('height', '6em'); - } - $(id).multiSelect({ - selectableHeader: - `<div class="header"> - <a href="#" class="button select-all">${$gettext('Alle hinzufügen')}</a> - </div>`, - selectionHeader: - `<div class="header"> - <div class="counter">${count_template({count: count})}.</div> - <a href="#" class="button deselect-all">${$gettext('Alle entfernen')}</a> - </div>`, - keepOrder: true, - cssClass: ['studip-multi-select', options.cssClass || ''].join(' ').trim(), - afterInit: function () { - $(id).next().find('.ms-elem-selectable,.ms-elem-selection').find('br').remove(); - }, - afterSelect: update_counter, - afterDeselect: update_counter - }); - - $(id).next().find('.select-all').click(function () { - $(id).multiSelect('select_all'); - }); - $(id).next().find('.deselect-all').click(function () { - $(id).multiSelect('deselect_all'); - }); - } -}; - -export default MultiSelect; diff --git a/resources/assets/javascripts/studip-jquery.multi-select.tweaks.js b/resources/assets/javascripts/studip-jquery.multi-select.tweaks.js deleted file mode 100644 index 547dd9f..0000000 --- a/resources/assets/javascripts/studip-jquery.multi-select.tweaks.js +++ /dev/null @@ -1,81 +0,0 @@ -import { $gettext } from './lib/gettext.js'; - - -/** - * Neccessary tweaks/adjustments for the jQuery UI multiselect addon. - * - * The tweaks essentially enable the list elements to include images as well - * as newlines and to create disabled elements without the addon interfering. - * - * This is accomplished by refining the defined methods of the addon: - * - * - For icons, the generateLisFromOption() checks for a special format of - * the text parameter and injects a background image to the generated - * option element - * - New lines are created by adjusting the escapeHTML method, any new line - * character is replaced by <br> - * - The disabled elements require a hack involving the methods - * generateLisFromOption, addOption and the jQuery extension insertAt. - * If the item should be disabled, the index is set to -1 and handled in - * each and every method as it would not have been set in the first place. - * This way, a disabled item is always added at the end of the list but - * this is exactly what we want to achieve. - * - * Note: - * - * With every update of the multi select addon, this needs to be checked and - * eventually adjusted to the new conditions. - */ -(function ($, MultiSelect) { - 'use strict'; - - const originals = { - generateLisFromOption: MultiSelect.prototype.generateLisFromOption, - addOption: MultiSelect.prototype.addOption, - escapeHTML: MultiSelect.prototype.escapeHTML, - insertAt: $.fn.insertAt - }; - - MultiSelect.prototype.generateLisFromOption = function (option, index, $container) { - let $option = $(option), - chunks = $option.text().split(/\s--\s/); - if (index === -1) { - $option.prop('disabled', true); - index = undefined; - } - - if (chunks.length > 1) { - $option.text(chunks.join("\n")); - - if ($option.is(':disabled')) { - $option.attr('title', $gettext('Die Person ist bereits eingetragen.')); - } - } - - originals.generateLisFromOption.call(this, $option.get(0), index, $container); - }; - - MultiSelect.prototype.addOption = function (options) { - if (options.disabled) { - options.index = -1; - delete options.disabled; - } - options.text = this.escapeHTML(options.text); - return originals.addOption.call(this, options); - }; - - MultiSelect.prototype.escapeHTML = function (text) { - const result = originals.escapeHTML.call(this, text); - return result.replace("\n", '<br>'); - }; - - $.fn.insertAt = function (index, $parent) { - if (index === -1) { - index = $parent.children().length; - } - - return originals.insertAt.call(this, index, $parent); - }; - - -}(jQuery, jQuery.fn.multiSelect.Constructor)); diff --git a/resources/assets/stylesheets/studip-jquery-ui.less b/resources/assets/stylesheets/studip-jquery-ui.less index 4da59c9..aed72f8 100644 --- a/resources/assets/stylesheets/studip-jquery-ui.less +++ b/resources/assets/stylesheets/studip-jquery-ui.less @@ -108,69 +108,6 @@ .ms-optgroup-label { color: var(--dark-gray-color-60); } - - // Default multi select with STUDIP.MultiSelect.create() - &.studip-multi-select { - display: flex; - flex-direction: row; - flex-wrap: nowrap; - - form.default & { - max-width: 48em; - } - - .ms-selectable, - .ms-selection { - flex: 1; - width: auto; - } - - .header { - display: flex; - flex-direction: row; - flex-wrap:nowrap; - align-items: center; - justify-content: space-between; - - background: var(--dark-gray-color-10); - border: 1px solid var(--dark-gray-color-30); - border-bottom: 0; - - padding-left: 0.5em; - } - - .button { - font-size: smaller; - } - - .ms-focus { - border-color: var(--brand-color-dark); - box-shadow: none; - } - - .ms-selectable { - order: 2; - - .header { - justify-content: flex-end; - } - - li::after { - display: none; - } - li { - .icon('before', 'arr_2left', 'info_alt', @icon-size); - } - } - - .ms-selection { - order: 1; - li { - padding-left: 20px; - .icon('before', 'arr_2right', 'info_alt', @icon-size); - } - } - } } .ui-menu .ui-menu-item { |
