| @@ -16,11 +16,8 @@ | ||
| 16 | 16 | if ( ! defined( 'ABSPATH' ) ) { |
| 17 | 17 | exit( 'This script cannot be accessed directly.' ); |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | -/** | |
| 21 | - * Select2AjaxControl Register | |
| 22 | - */ | |
| 23 | 20 | class Select2AjaxControl extends Base_Data_Control { |
| 24 | 21 | |
| 25 | 22 | /** |
| 26 | 23 | * Set control name. |
| @@ -28,56 +25,45 @@ | ||
| 28 | 25 | * @var string |
| 29 | 26 | */ |
| 30 | 27 | public static $controlName = 'rt-select2'; |
| 31 | 28 | |
| 32 | - /** | |
| 33 | - * @return string | |
| 34 | - */ | |
| 35 | 29 | public function get_type() { |
| 36 | 30 | return self::$controlName; |
| 37 | 31 | } |
| 38 | 32 | |
| 39 | - /** | |
| 40 | - * @return void | |
| 41 | - */ | |
| 42 | 33 | public function enqueue() { |
| 43 | 34 | wp_enqueue_script( 'rtsb-editor-script' ); |
| 44 | 35 | wp_localize_script( |
| 45 | 36 | 'rtsb-editor-script', |
| 46 | - 'rtsbSelect2Obj', | |
| 37 | + 'rtSelect2Obj', | |
| 47 | 38 | [ |
| 48 | - 'ajaxurl' => esc_url( admin_url( 'admin-ajax.php' ) ), | |
| 49 | - 'search_text' => esc_html__( 'Please Select', 'shopbuilder' ), | |
| 50 | - 'nonceId' => rtsb()->nonceId, | |
| 51 | - rtsb()->nonceId => wp_create_nonce( rtsb()->nonceText ), | |
| 39 | + 'ajaxurl' => esc_url( admin_url( 'admin-ajax.php' ) ), | |
| 40 | + 'search_text' => esc_html__( 'Please Select', 'textdomain' ), | |
| 52 | 41 | ] |
| 53 | 42 | ); |
| 54 | 43 | ?> |
| 55 | - <style> | |
| 56 | - .rt-select2-main-wrapper ul.select2-selection__rendered li:last-child { | |
| 57 | - pointer-events: none; | |
| 58 | - } | |
| 44 | + <style> | |
| 45 | + .rt-select2-main-wrapper ul.select2-selection__rendered li:last-child { | |
| 46 | + pointer-events: none; | |
| 47 | + } | |
| 59 | 48 | |
| 60 | - .rt-select2-main-wrapper ul.select2-selection__rendered li:last-child::before { | |
| 61 | - background: var(--e-a-btn-bg); | |
| 62 | - content: '+'; | |
| 63 | - padding: 1px 5px; | |
| 64 | - position: relative; | |
| 65 | - top: 1px; | |
| 66 | - margin-right: 5px; | |
| 67 | - color: #fff; | |
| 68 | - } | |
| 49 | + .rt-select2-main-wrapper ul.select2-selection__rendered li:last-child::before { | |
| 50 | + background: var(--e-a-btn-bg); | |
| 51 | + content: '+'; | |
| 52 | + padding: 1px 5px; | |
| 53 | + position: relative; | |
| 54 | + top: 1px; | |
| 55 | + margin-right: 5px; | |
| 56 | + color: #fff; | |
| 57 | + } | |
| 69 | 58 | |
| 70 | - .rt-select2-main-wrapper ul.select2-selection__rendered li[title=search] { | |
| 71 | - display: none; | |
| 72 | - } | |
| 73 | - </style> | |
| 59 | + .rt-select2-main-wrapper ul.select2-selection__rendered li[title=search] { | |
| 60 | + display: none; | |
| 61 | + } | |
| 62 | + </style> | |
| 74 | 63 | <?php |
| 75 | 64 | } |
| 76 | 65 | |
| 77 | - /** | |
| 78 | - * @return array | |
| 79 | - */ | |
| 80 | 66 | protected function get_default_settings() { |
| 81 | 67 | return [ |
| 82 | 68 | 'multiple' => false, |
| 83 | 69 | 'label_block' => true, |
| @@ -87,34 +73,31 @@ | ||
| 87 | 73 | 'maximum_selection_length' => - 1, |
| 88 | 74 | ]; |
| 89 | 75 | } |
| 90 | 76 | |
| 91 | - /** | |
| 92 | - * @return void | |
| 93 | - */ | |
| 94 | 77 | public function content_template() { |
| 95 | 78 | $control_uid = $this->get_control_uid(); |
| 96 | 79 | ?> |
| 97 | 80 | |
| 98 | - <# var controlUID = '<?php echo esc_html( $control_uid ); ?>'; #> | |
| 99 | - <# var currentID = elementor.panel.currentView.currentPageView.model.attributes.settings.attributes[data.name]; #> | |
| 100 | - <# var maxSelection = (data.maximum_selection_length > 0) ? 'max-select'+data.maximum_selection_length : 'unlimited-select' #> | |
| 101 | - <div class="elementor-control-field rt-select2-main-wrapper {{maxSelection}}"> | |
| 102 | - <# if ( data.label ) { #> | |
| 103 | - <label for="<?php echo esc_attr( $control_uid ); ?>" class="elementor-control-title">{{{data.label }}}</label> | |
| 104 | - <# } #> | |
| 105 | - <div class="elementor-control-input-wrapper elementor-control-unit-5"> | |
| 106 | - <# var multiple = ( data.multiple ) ? 'multiple' : ''; #> | |
| 107 | - <select id="<?php echo esc_attr( $control_uid ); ?>" {{ multiple }} class="rt-select2" data-setting="{{ data.name }}"></select> | |
| 108 | - </div> | |
| 109 | - <# if ( data.description ) { #> | |
| 110 | - <div class="elementor-control-field-description rtsb-description">{{{ data.description }}}</div> | |
| 111 | - <# } #> | |
| 112 | - </div> | |
| 113 | - <# | |
| 114 | - ( function( $ ) { | |
| 115 | - $( document.body ).trigger( 'rt_select2_event',{currentID:data.controlValue,data:data,controlUID:controlUID,multiple:data.multiple} ); | |
| 116 | - }( jQuery ) ); | |
| 117 | - #> | |
| 81 | + <# var controlUID = '<?php echo esc_html( $control_uid ); ?>'; #> | |
| 82 | + <# var currentID = elementor.panel.currentView.currentPageView.model.attributes.settings.attributes[data.name]; #> | |
| 83 | + <# var maxSelection = (data.maximum_selection_length > 0) ? 'max-select'+data.maximum_selection_length : 'unlimited-select' #> | |
| 84 | + <div class="elementor-control-field rt-select2-main-wrapper {{maxSelection}}"> | |
| 85 | + <# if ( data.label ) { #> | |
| 86 | + <label for="<?php echo esc_attr( $control_uid ); ?>" class="elementor-control-title">{{{data.label }}}</label> | |
| 87 | + <# } #> | |
| 88 | + <div class="elementor-control-input-wrapper elementor-control-unit-5"> | |
| 89 | + <# var multiple = ( data.multiple ) ? 'multiple' : ''; #> | |
| 90 | + <select id="<?php echo esc_attr( $control_uid ); ?>" {{ multiple }} class="rt-select2" data-setting="{{ data.name }}"></select> | |
| 91 | + </div> | |
| 92 | + <# if ( data.description ) { #> | |
| 93 | + <div class="elementor-control-field-description rtsb-description">{{{ data.description }}}</div> | |
| 94 | + <# } #> | |
| 95 | + </div> | |
| 96 | + <# | |
| 97 | + ( function( $ ) { | |
| 98 | + $( document.body ).trigger( 'rt_select2_event',{currentID:data.controlValue,data:data,controlUID:controlUID,multiple:data.multiple} ); | |
| 99 | + }( jQuery ) ); | |
| 100 | + #> | |
| 118 | 101 | <?php |
| 119 | 102 | } |
| 120 | 103 | } |