PluginProbe
Responsive Menu – Create Mobile-Friendly Menu / 3.0.14
Responsive Menu – Create Mobile-Friendly Menu v3.0.14
4.7.3 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.1.0 4.1.1 4.1.10 4.1.11 4.1.12 4.1.2 4.1.3 4.1.4 4.1.5 4.1.6 4.1.7 4.1.8 4.1.9 4.2.0 All 90 releases
responsive-menu / src / app / Form / MenuOrdering.php

MenuOrdering.php in Responsive Menu – Create Mobile-Friendly Menu 3.0.14, at src/app/Form/MenuOrdering.php

49 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace ResponsiveMenu\Form;
4 use ResponsiveMenu\Models\Option;
5 use ResponsiveMenu\Form\FormComponent;
6
7 class MenuOrdering implements FormComponent {
8
9 public function render(Option $option) {
10
11 $required = ['title' => '', 'menu' => '', 'search' => '', 'additional content' => ''];
12 $current_options = (array) json_decode($option->getValue());
13 $all_options = array_merge($current_options, $required);
14
15 $output = '<ul id="menu-sortable">';
16 foreach($all_options as $name => $val):
17 $current_value = isset($current_options[$name]) ? $current_options[$name] : '';
18 $on_class = $current_value == 'on' ? 'menu-order-option-switch-on' : '';
19
20 $output .= '<li class="draggable">'
21 . ucwords($name)
22 . '<input type="text" class="orderable-item" value="'.$current_value.'" name="menu['.$option->getName().']['.$name.']" />'
23 . '<div class="menu-order-option-switch ' . $on_class . '"></div>'
24 . '</li>';
25 endforeach;
26 $output .= '</ul>';
27
28 $output .= '<script>
29 jQuery(document).ready(function($) {
30 $(document).on("click", ".menu-order-option-switch", function() {
31 if($(this).siblings("input.orderable-item").val() != "on") {
32 $(this).siblings("input.orderable-item").val("on");
33 $(this).addClass("menu-order-option-switch-on");
34 } else {
35 $(this).siblings("input.orderable-item").val("");
36 $(this).removeClass("menu-order-option-switch-on");
37 }
38 });
39 $( "#menu-sortable" ).sortable({
40 revert: true
41 });
42 $( "#sortable, .draggable" ).disableSelection();
43 });
44 </script>';
45 return $output;
46 }
47
48 }
49