From bbfe4462dcb2d82dd9d2306998f10791bf663673 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 15 Sep 2018 13:31:25 +0200 Subject: [PATCH] NEW Add lib for multiselect with checkboxes NEW Can select several prospect level in thirdparty filter. Remove old multiselect lib that was not used by core. --- htdocs/core/class/html.form.class.php | 101 +++-- .../plugins/multiselect/MIT-LICENSE.txt | 20 - .../multiselect/css/ui.multiselect.css | 144 ------- .../multiselect/jquery.multi-select.js | 360 ++++++++++++++++++ .../multiselect/jquery.multi-select.min.js | 9 + .../plugins/multiselect/js/ui.multiselect.js | 336 ---------------- htdocs/main.inc.php | 6 +- htdocs/societe/list.php | 114 +----- htdocs/theme/eldy/style.css.php | 80 +++- htdocs/theme/md/style.css.php | 78 +++- 10 files changed, 606 insertions(+), 642 deletions(-) delete mode 100755 htdocs/includes/jquery/plugins/multiselect/MIT-LICENSE.txt delete mode 100755 htdocs/includes/jquery/plugins/multiselect/css/ui.multiselect.css create mode 100644 htdocs/includes/jquery/plugins/multiselect/jquery.multi-select.js create mode 100644 htdocs/includes/jquery/plugins/multiselect/jquery.multi-select.min.js delete mode 100755 htdocs/includes/jquery/plugins/multiselect/js/ui.multiselect.js diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 177b05850ed..4ed9b4dd4f9 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -5730,7 +5730,7 @@ class Form * @param string $morecss Add more class to css styles * @param int $callurlonselect If set to 1, some code is added so an url return by the ajax is called when value is selected. * @param string $placeholder String to use as placeholder - * @param integer $acceptdelayedhtml 1 if caller request to have html js content not returned but saved into global $delayedhtmlcontent (so caller can show it at end of page to avoid flash FOUC effect) + * @param integer $acceptdelayedhtml 1 = caller is requesting to have html js content not returned but saved into global $delayedhtmlcontent (so caller can show it at end of page to avoid flash FOUC effect) * @return string HTML select string * @see selectArrayFilter, ajax_combobox in ajax.lib.php */ @@ -5832,7 +5832,7 @@ class Form * @param string $morecss Add more class to css styles * @param int $callurlonselect If set to 1, some code is added so an url return by the ajax is called when value is selected. * @param string $placeholder String to use as placeholder - * @param integer $acceptdelayedhtml 1 if caller request to have html js content not returned but saved into global $delayedhtmlcontent (so caller can show it at end of page to avoid flash FOUC effect) + * @param integer $acceptdelayedhtml 1 = caller is requesting to have html js content not returned but saved into global $delayedhtmlcontent (so caller can show it at end of page to avoid flash FOUC effect) * @return string HTML select string * @see selectArrayAjax, ajax_combobox in ajax.lib.php */ @@ -5949,55 +5949,76 @@ class Form * @param int $width Force width of select box. May be used only when using jquery couch. Example: 250, 95% * @param string $moreattrib Add more options on select component. Example: 'disabled' * @param string $elemtype Type of element we show ('category', ...) + * @param string $placeholder String to use as placeholder + * @param int $addjscombo Add js combo * @return string HTML multiselect string * @see selectarray */ - static function multiselectarray($htmlname, $array, $selected=array(), $key_in_label=0, $value_as_key=0, $morecss='', $translate=0, $width=0, $moreattrib='',$elemtype='') + static function multiselectarray($htmlname, $array, $selected=array(), $key_in_label=0, $value_as_key=0, $morecss='', $translate=0, $width=0, $moreattrib='', $elemtype='', $placeholder='', $addjscombo=1) { global $conf, $langs; $out = ''; + // Add code for jquery to use multiselect if (! empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) || defined('REQUIRE_JQUERY_MULTISELECT')) { - $tmpplugin=empty($conf->global->MAIN_USE_JQUERY_MULTISELECT)?constant('REQUIRE_JQUERY_MULTISELECT'):$conf->global->MAIN_USE_JQUERY_MULTISELECT; - $out.="\n".' - '; + $out.="\n".' + '; } // Try also magic suggest diff --git a/htdocs/includes/jquery/plugins/multiselect/MIT-LICENSE.txt b/htdocs/includes/jquery/plugins/multiselect/MIT-LICENSE.txt deleted file mode 100755 index 1076f8b4b2b..00000000000 --- a/htdocs/includes/jquery/plugins/multiselect/MIT-LICENSE.txt +++ /dev/null @@ -1,20 +0,0 @@ -Copyright (c) 2009 Michael Aufreiter, http://www.quasipartikel.at - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/htdocs/includes/jquery/plugins/multiselect/css/ui.multiselect.css b/htdocs/includes/jquery/plugins/multiselect/css/ui.multiselect.css deleted file mode 100755 index 2072baa57c4..00000000000 --- a/htdocs/includes/jquery/plugins/multiselect/css/ui.multiselect.css +++ /dev/null @@ -1,144 +0,0 @@ -/* Multiselect -----------------------------------*/ -.multiselect { - width: 600px; - height: 150px; -} - -.ui-multiselect { - border: solid 1px; - font-size: 0.8em; -} - -.ui-multiselect ul { - -moz-user-select: none; -} - -.ui-multiselect li { - margin: 0; - padding: 0; - cursor: default; - line-height: 20px; - height: 20px; - font-size: 11px; - list-style: none; -} - -.ui-multiselect li a { - color: #999; - text-decoration: none; - padding: 0; - display: block; - float: left; - cursor: pointer; -} - -.ui-multiselect li.ui-draggable-dragging { - padding-left: 10px; -} - -.ui-multiselect div.selected { - position: relative; - padding: 0; - margin: 0; - border: 0; - float: left; -} - -.ui-multiselect ul.selected { - position: relative; - padding: 0; - overflow: auto; - overflow-x: hidden; - background: #fff; - margin: 0; - list-style: none; - border: 0; - position: relative; - width: 100%; -} - -.ui-multiselect ul.selected li { - -} - -.ui-multiselect div.available { - position: relative; - padding: 0; - margin: 0; - border: 0; - float: left; - border-left: 1px solid; -} - -.ui-multiselect ul.available { - position: relative; - padding: 0; - overflow: auto; - overflow-x: hidden; - background: #fff; - margin: 0; - list-style: none; - border: 0; - width: 100%; -} - -.ui-multiselect ul.available li { - padding-left: 10px; -} - -.ui-multiselect .ui-state-default { - border: none; - margin-bottom: 1px; - position: relative; - padding-left: 20px; -} - -.ui-multiselect .ui-state-hover { - border: none; -} - -.ui-multiselect .ui-widget-header { - border: none; - font-size: 11px; - margin-bottom: 1px; -} - -.ui-multiselect .add-all { - float: right; - padding: 7px; -} - -.ui-multiselect .remove-all { - float: right; - padding: 7px; -} - -.ui-multiselect .search { - float: left; - padding: 4px; -} - -.ui-multiselect .count { - float: left; - padding: 7px; -} - -.ui-multiselect li span.ui-icon-arrowthick-2-n-s { - position: absolute; - left: 2px; -} - -.ui-multiselect li a.action { - position: absolute; - right: 2px; - top: 2px; -} - -.ui-multiselect input.search { - height: 14px; - padding: 1px; - opacity: 0.5; - margin: 4px; - width: 100px; -} \ No newline at end of file diff --git a/htdocs/includes/jquery/plugins/multiselect/jquery.multi-select.js b/htdocs/includes/jquery/plugins/multiselect/jquery.multi-select.js new file mode 100644 index 00000000000..ee62d1f588d --- /dev/null +++ b/htdocs/includes/jquery/plugins/multiselect/jquery.multi-select.js @@ -0,0 +1,360 @@ +// jquery.multi-select.js +// by mySociety +// https://github.com/mysociety/jquery-multi-select + +;(function($) { + + "use strict"; + + var pluginName = "multiSelect", + defaults = { + 'containerHTML': '
', + 'menuHTML': '
', + 'buttonHTML': '', + 'menuItemsHTML': '
', + 'menuItemHTML': '