diff --git a/protected/humhub/modules/space/widgets/Picker.php b/protected/humhub/modules/space/widgets/Picker.php deleted file mode 100644 index 7e6e939bd8..0000000000 --- a/protected/humhub/modules/space/widgets/Picker.php +++ /dev/null @@ -1,112 +0,0 @@ - - * - * echo humhub\modules\space\widgets\Picker::widget([ - * 'inputId' => 'space_filter', - * 'value' => $spaceGuidsString, - * 'maxSpaces' => 3 - * ]); - * - * - * - * @since 0.5 - * @deprecated since version 1.2 use SpacePickerField instead - * @author Luke - */ -class Picker extends Widget -{ - /** - * @var string The id of input element which should replaced - */ - public $inputId = ''; - - /** - * JSON Search URL - default: /space/browse/search-json - * The token -keywordPlaceholder- will replaced by the current search query. - * - * @var string the search url - */ - public $spaceSearchUrl = ''; - - /** - * @var int the maximum of spaces - */ - public $maxSpaces = 10; - - /** - * @var \yii\base\Model the data model associated with this widget. (Optional) - */ - public $model = null; - - /** - * The name can contain square brackets (e.g. 'name[1]') which is used to collect tabular data input. - * @var string the attribute associated with this widget. (Optional) - */ - public $attribute = null; - - /** - * @var string the initial value of comma separated space guids - */ - public $value = ''; - - /** - * @var string placeholder message, when no space is set - */ - public $placeholder = null; - - /** - * Displays / Run the Widgets - */ - public function run() - { - // Try to get current field value, when model & attribute attributes are specified. - if ($this->model != null && $this->attribute != null) { - $attribute = $this->attribute; - $this->value = $this->model->$attribute; - } - - if ($this->spaceSearchUrl == '') - $this->spaceSearchUrl = Url::to(['/space/browse/search-json', 'keyword' => '-keywordPlaceholder-']); - - if ($this->placeholder === null) { - $this->placeholder = Yii::t('SpaceModule.chooser', 'Add {n,plural,=1{space} other{spaces}}', ['n' => $this->maxSpaces]); - } - - // Currently populated spaces - $spaces = []; - foreach (explode(",", $this->value) as $guid) { - $space = Space::findOne(['guid' => trim($guid)]); - if ($space != null) { - $spaces[] = $space; - } - } - - return $this->render('spacePicker', [ - 'spaceSearchUrl' => $this->spaceSearchUrl, - 'maxSpaces' => $this->maxSpaces, - 'value' => $this->value, - 'spaces' => $spaces, - 'placeholder' => $this->placeholder, - 'inputId' => $this->inputId, - ]); - } - -} diff --git a/protected/humhub/modules/space/widgets/views/spacePicker.php b/protected/humhub/modules/space/widgets/views/spacePicker.php deleted file mode 100644 index fd322ab08e..0000000000 --- a/protected/humhub/modules/space/widgets/views/spacePicker.php +++ /dev/null @@ -1,27 +0,0 @@ -registerJsFile('@web-static/resources/space/spacepicker.js', ['position' => View::POS_END]); - -// Resolve guids to space tags -$selectedSpaces = ''; -foreach ($spaces as $space) { - $name = Html::encode($space->name); - $selectedSpaces .= '
  • ' . Image::widget(['space' => $space, 'width' => 24]) . ' ' . addslashes($name) . '
  • '; -} -?> - - diff --git a/static/resources/space/spacechooser.js b/static/resources/space/spacechooser.js deleted file mode 100644 index 49cb349d60..0000000000 --- a/static/resources/space/spacechooser.js +++ /dev/null @@ -1,174 +0,0 @@ -/** - * Handling space chooser user input - */ - -$(document).ready(function () { - - var chosen = []; // Array for visible space menu entries - var arrPosition = ""; // Save the current position inside the chosen array - - - - /** - * Show and navigate through spaces depends on user input - */ - $('#space-menu-search').keyup(function (event) { - - if (event.keyCode == 40) { - - // set current array position - if (arrPosition === "") { - arrPosition = 1; - } else if ((arrPosition) < chosen.length - 1) { - arrPosition++; - } - - // remove selection from last space entry - $('#space-menu-dropdown li ul li').removeClass('selected'); - - // add selection to the current space entry - $('#space-menu-dropdown li ul li:eq(' + chosen[arrPosition] + ')').addClass('selected'); - - return false; - - } else if (event.keyCode == 38) { - - // set current array position - if (arrPosition === "") { - arrPosition = 1; - } else if ((arrPosition) > 0) { - arrPosition--; - } - - $('#space-menu-dropdown li ul li').removeClass('selected'); - - // add selection to the current space entry - $('#space-menu-dropdown li ul li:eq(' + chosen[arrPosition] + ')').addClass('selected'); - - return false; - - } else if (event.keyCode == 13) { - - // check if one space is selected - if ($('#space-menu-spaces li').hasClass("selected")) { - - // move to selected space, by hitting enter - window.location.href = $('#space-menu-dropdown li ul li.selected a').attr('href'); - } - - } else { - - // lowercase and save entered string in variable - var input = $(this).val().toLowerCase(); - - if (input > 0) { - // remove max-height property to hide the nicescroll scrollbar - $('#space-menu-spaces').css({'max-height': 'none'}); - } else { - // set max-height property to show the nicescroll scrollbar - $('#space-menu-spaces').css({'max-height': '400px'}); - } - - // empty variable and array - chosen = []; - arrPosition = ""; - - $("#space-menu-dropdown li ul li").each(function (index) { - - // remove selected classes from all space entries - $('#space-menu-dropdown li ul li').removeClass('selected'); - - - // lowercase and save space strings in variable - var str = $(this).text().toLowerCase(); - - if (str.search(input) == -1) { - // hide elements when not matched - $(this).css('display', 'none'); - } else { - // show elements when matched - $(this).css('display', 'block'); - - // update array with the right li element - chosen.push(index); - } - - }); - - - // add selection to the first space entry - $('#space-menu-dropdown li ul li:eq(' + chosen[0] + ')').addClass('selected'); - - // check if entered string is empty or not - if (input.length == 0) { - // reset inputs - resetSpaceSearch(); - } else { - // show search reset icon - $('#space-search-reset').fadeIn('fast'); - } - - // remove hightlight - $("#space-menu-dropdown li ul li").removeHighlight(); - - // add new highlight matching strings - $("#space-menu-dropdown li ul li").highlight(input); - - - } - - //return event.returnValue; - - }); - - /** - * Disable enter key - */ - $('#space-menu-search').keypress(function (event) { - if (event.keyCode == 13) { - // deactivate the standard press event - event.preventDefault(); - return false; - } - }); - - - /** - * Click handler to reset user input - */ - $('#space-search-reset').click(function () { - resetSpaceSearch(); - }); - - /** - * Reset user input - */ - function resetSpaceSearch() { - - // fade out the cross icon - $('#space-search-reset').fadeOut('fast'); - - // empty input field - $('#space-menu-search').val(''); - - // set focus to input field - $('#space-menu-search').focus(); - - $("#space-menu-dropdown li ul li").each(function () { - - // show all space entries - $(this).css('display', 'block'); - - // remove search result highlighting - $("#space-menu-dropdown li ul li").removeHighlight(); - - // remove the curren tspace entry selection - $('#space-menu-dropdown li ul li').removeClass('selected'); - - }); - - // set max-height property to show the nicescroll scrollbar - $('#space-menu-spaces').css({'max-height': '400px'}); - } - -}); \ No newline at end of file diff --git a/static/resources/space/spacepicker.js b/static/resources/space/spacepicker.js deleted file mode 100644 index 9683f8cc14..0000000000 --- a/static/resources/space/spacepicker.js +++ /dev/null @@ -1,352 +0,0 @@ -/* - * SpacePicker - * Version 1.0.0 - * Written by: Andreas Strobel - * - * @property String $inputId is the ID of the input HTML Element - * @property Int $maxSpaces the maximum of users in this dropdown - * @property String $spaceSearchUrl the url of the search, to find the spaces - * @property String $currentValue is the current value of the parent field. - * @property String $templates.inputStructure is the HTML structure to replace the original input element. - * - * License: MIT License - http://www.opensource.org/licenses/mit-license.php - */ - - -var chosen = ""; -var spaceCount = 0; - -$.fn.spacepicker = function (options) { - - // set standard options - options = $.extend({ - inputId: "", - maxSpaces: 0, - searchUrl: "", - placeholder: "", - currentValue: "", - }, options); - - // add input structure template - options = $.extend({ - templates: { - inputStructure: '
    ' - } - }, options); - - - init(); - - - function init() { - - // remove picker if existing - $('.space_picker_container').remove(); - - // insert the new input structure after the original input element - $(options.inputId).after(options.templates.inputStructure); - - // hide original input element - $(options.inputId).hide(); - - if (options.currentValue != "") { - - // restore data from database - restoreSpaceTags(options.currentValue); - } - - // simulate focus in - $('#space_input_field').focusin(function () { - $('#space_tags').addClass('focus'); - }) - - // simulate focus out - $('#space_input_field').focusout(function () { - $('#space_tags').removeClass('focus'); - }); - - $('body').append($('#spacepicker')); - } - - function restoreSpaceTags(html) { - - // add html structure for input element - $('#space_tags').prepend(html); - - // create function for every space tag to remove the element - $('#space_tags .spaceInput i').each(function () { - - $(this).click(function () { - - // remove user tag - $(this).parent().remove(); - - // reduce the count of added spaces - spaceCount--; - - }) - - // raise the count of added spaces - spaceCount++; - - }) - - - } - - - // Set focus on the input field, by clicking the