PluginProbe ʕ •ᴥ•ʔ
Widget Options – Advanced Conditional Visibility for Gutenberg Blocks & Classic Widgets / 3.7.13
Widget Options – Advanced Conditional Visibility for Gutenberg Blocks & Classic Widgets v3.7.13
4.2.5 4.2.4 trunk 3.7.10 3.7.11 3.7.12 3.7.13 3.7.14 3.7.2 3.7.5 3.7.6 3.7.7 3.7.8 3.7.9 3.8 3.8.1 3.8.10 3.8.2 3.8.3 3.8.4 3.8.5 3.8.6 3.8.7 3.8.8 3.8.9 3.8.9.1 3.9.0 3.9.1 3.9.2 3.9.3 3.9.4 3.9.5 3.9.6 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.0.5 4.0.5.1 4.0.6 4.0.6.1 4.0.7 4.0.8 4.0.9 4.1.0 4.1.1 4.1.2 4.1.3 4.2.0 4.2.1 4.2.2 4.2.3
widget-options / assets / js / widgets.js
widget-options / assets / js Last commit date
jquery.liveFilter.js 4 years ago jquery.liveFilter.min.js 4 years ago jquery.widgetopts.beaver.js 4 years ago jquery.widgetopts.beaver.min.js 4 years ago select2-settings.js 4 years ago select2-settings.min.js 4 years ago select2.min.js 4 years ago settings.js 4 years ago settings.min.js 4 years ago widgets.js 4 years ago widgets.min.js 4 years ago wpWidgetOpts.js 4 years ago wpWidgetOpts.min.js 4 years ago
widgets.js
223 lines
1 (function( $, window, document, undefined ) {
2 if( $('.extended-widget-opts-tabs').length > 0 ){
3 extended_widget_opts_init( '', 'loaded' );
4 }
5
6 $(document).ready(function(){
7 $(".widget-liquid-right .widget, .inactive-sidebar .widget, #accordion-panel-widgets .customize-control-widget_form").each(function (i, widget) {
8 extended_widget_opts_init( '', 'loaded' );
9 });
10 $(document).on('widget-added', function(event, widget) {
11 extended_widget_opts_init( widget, 'added' );
12
13 // if( $( '.widgets-chooser .widgets-chooser-sidebars' ).length > 0 ){
14 // $( '.widgets-chooser .widgets-chooser-sidebars li' ).removeClass( 'widgetopts-is-hidden' );
15 // }
16 //
17 // if( $( '#widgetopts-search-chooser' ).length > 0 ){
18 // $( '#widgetopts-search-chooser' ).val('');
19 // }
20
21 });
22 $(document).on('widget-updated', function(event, widget) {
23 extended_widget_opts_init( widget, 'updated' );
24 });
25 $(document).on( 'click', '.extended-widget-opts-inner-lists h4',function(){
26 getid = $(this).attr('id');
27 $('.extended-widget-opts-inner-lists .'+ getid).slideToggle(250);
28 } );
29 $(document).on( 'click', '.widget-opts-toggler-note',function(e){
30 $(this).parent('p').parent('.widget-opts-logic').find('.widget-opts-toggle-note').slideToggle(250);
31
32 e.preventDefault();
33 e.stopPropagation();
34 } );
35
36 //admin settings
37 $(document).on( 'click', '.opts-add-class-btn',function(e){
38 getVal = $('.opts-add-class-txtfld').val();
39 var fname = 'extwopts_class_settings[classlists][]';
40 if( $(this).hasClass('widgetopts-add-class-btn') ){
41 fname = 'classes[classlists][]';
42 }
43 if( getVal.length > 0 ){
44 $('#opts-predefined-classes ul').append('<li><input type="hidden" name="'+ fname +'" value="'+ getVal +'" /><span class"opts-li-value">'+ getVal +'</span> <a href="#" class="opts-remove-class-btn"><span class="dashicons dashicons-dismiss"></span></a></li>');
45 $('.opts-add-class-txtfld').val('');
46 }
47
48 e.preventDefault();
49 e.stopPropagation();
50 } );
51 $(document).on( 'click', '.opts-remove-class-btn',function(e){
52 $(this).parent('li').fadeOut('fast',function(){
53 $(this).remove();
54 });
55 e.preventDefault();
56 e.stopPropagation();
57 } );
58
59 if( $('.wp-admin.widgets-php .wrap a.page-title-action').length > 0 ){
60 $('.wp-admin.widgets-php .wrap a.page-title-action').after('<a href="'+ widgetopts10n.opts_page +'" class="page-title-action hide-if-no-customize">'+ widgetopts10n.translation.manage_settings +'</a>');
61 }
62
63 //add live filter
64 if ( typeof $.fn.liveFilter !== 'undefined' && $( '#widgetopts-widgets-search' ).length > 0 ) {
65 // Add separator to distinguish between visible and hidden widgets
66 $('.widget:last-of-type').after('<div class="widgetopts-separator" />');
67
68 // Add data attribute for order to each widget
69 $('#widgets-left .widget').each(function() {
70 var index = $(this).index() + 1;
71 $(this).attr( 'data-widget-index', index );
72 });
73
74 // Add liveFilter : credits to https://wordpress.org/plugins/widget-search-filter/ plugin
75 $('#widgets-left').liveFilter('#widgetopts-widgets-search', '.widget', {
76 filterChildSelector: '.widget-title h4, .widget-title h3',
77 after: function(contains, containsNot) {
78
79 // Move all hidden widgets to end.
80 containsNot.each(function() {
81 $(this).insertAfter($(this).parent().find('.widgetopts-separator'));
82 });
83
84 // Sort all visible widgets by original index
85 contains.sort(function(a,b) {
86 return a.getAttribute('data-widget-index') - b.getAttribute('data-widget-index');
87 });
88
89 // Move all visible back
90 contains.each(function() {
91 $(this).insertBefore($(this).parent().find('.widgetopts-separator'));
92 });
93
94 }
95 });
96
97 //add clear search
98 $( '#wpbody-content' ).on( 'keyup', '.widgetopts-widgets-search', function(e){
99 p = $(this).parent().find( '.widgetopts-clear-results' );
100 if ( '' !== $(this).val() ) {
101 p.addClass( 'widgetopts-is-visible' );
102 }else{
103 p.removeClass( 'widgetopts-is-visible' );
104 }
105 } );
106
107 $( '#wpbody-content' ).on( 'click', '.widgetopts-clear-results', function(e){
108 s = $(this).parent().find( '.widgetopts-widgets-search' );
109 s.val( '' ).focus().trigger( 'keyup' );
110
111 if( s.attr( 'id' ) == 'widgetopts-search-chooser' ){
112 $( '.widgets-chooser-sidebars li:not(:first)' ).removeClass( 'widgets-chooser-selected' );
113 }
114
115 e.preventDefault();
116 e.stopPropagation();
117 return false;
118 } );
119
120 //add sidebar chooser search field
121 $('.widgets-chooser').prepend( widgetopts10n.search_form );
122 //live filter
123 $('.widgets-chooser').liveFilter('#widgetopts-search-chooser', '.widgets-chooser-sidebars li', {
124 // filterChildSelector: 'li',
125 after: function( contains, containsNot ) {
126 //hide
127 containsNot.each(function() {
128 $(this).addClass( 'widgetopts-is-hidden' ).removeClass( 'widgets-chooser-selected' );
129 });
130 contains.each(function() {
131 $(this).removeClass( 'widgetopts-is-hidden' ).removeClass( 'widgets-chooser-selected' );
132 });
133 if( contains.length > 0 ){
134 $( contains[0] ).addClass( 'widgets-chooser-selected' );
135 }
136
137 }
138 });
139
140 // if( $( '.widgets-chooser-cancel' ).length > 0 ){
141 // $('.widgets-chooser').on( 'click', '.widgets-chooser-cancel', function(e){
142 // if( $( '.widgets-chooser .widgets-chooser-sidebars' ).length > 0 ){
143 // $( '.widgets-chooser .widgets-chooser-sidebars li' ).removeClass( 'widgetopts-is-hidden' );
144 // }
145 //
146 // if( $( '#widgetopts-search-chooser' ).length > 0 ){
147 // $( '#widgetopts-search-chooser' ).val('');
148 // }
149 // });
150 // }
151
152 }
153
154 });
155
156 function extended_widget_opts_init( widget, action ){
157 selected = 0;
158 selected_visibility = 0;
159 selected_settings = 0;
160 in_customizer = false;
161 // check for wp.customize return boolean
162 if ( typeof wp !== 'undefined' ) {
163 in_customizer = typeof wp.customize !== 'undefined' ? true : false;
164 }
165 if( '' != widget ){
166 if( $( '#' + widget.attr('id') ).find('#extended-widget-opts-selectedtab').length > 0 ){
167 selected = $( '#' + widget.attr('id') ).find('#extended-widget-opts-selectedtab').val();
168 selected = parseInt( selected );
169 }
170
171 if( $( '#' + widget.attr('id') ).find('#extended-widget-opts-visibility-selectedtab').length > 0 ){
172 selected_visibility = $( '#' + widget.attr('id') ).find('#extended-widget-opts-visibility-selectedtab').val();
173 selected_visibility = parseInt( selected_visibility );
174 }
175
176 if( $( '#' + widget.attr('id') ).find('#extended-widget-opts-visibility-selectedtab').length > 0 ){
177 selected_settings = $( '#' + widget.attr('id') ).find('#extended-widget-opts-settings-selectedtab').val();
178 selected_settings = parseInt( selected_settings );
179 }
180 // console.log( in_customizer );
181 }
182 if( action == 'added' ){
183 selected = 0;
184 selected_visibility = 0;
185 selected_settings = 0;
186 }
187
188 if( '' != widget ){
189 if( $( '#' + widget.attr('id') ).find('.extended-widget-opts-tabs').length > 0 ){
190 $( '#' + widget.attr('id') ).find('.extended-widget-opts-tabs').tabs({ active: selected });
191 }
192 if( $( '#' + widget.attr('id') ).find('.extended-widget-opts-visibility-tabs').length > 0 ){
193 $( '#' + widget.attr('id') ).find('.extended-widget-opts-visibility-tabs').tabs({ active: selected_visibility });
194 }
195 if( $( '#' + widget.attr('id') ).find('.extended-widget-opts-settings-tabs').length > 0 ){
196 $( '#' + widget.attr('id') ).find('.extended-widget-opts-settings-tabs').tabs({ active: selected_settings });
197 }
198 }else{
199 $('.extended-widget-opts-tabs').tabs({ active: selected });
200 $('.extended-widget-opts-visibility-tabs').tabs({ active: selected_visibility });
201 $('.extended-widget-opts-settings-tabs').tabs({ active: selected_settings });
202 }
203
204 $('.extended-widget-opts-tabs').click('tabsselect', function (event, ui) {
205 if( $(this).find('#extended-widget-opts-selectedtab').length > 0 ){
206 $(this).find('#extended-widget-opts-selectedtab').val( $(this).tabs('option', 'active') );
207 }
208 });
209
210 $('.extended-widget-opts-visibility-tabs').click('tabsselect', function (event, ui) {
211 if( $(this).find('#extended-widget-opts-visibility-selectedtab').length > 0 ){
212 $(this).find('#extended-widget-opts-visibility-selectedtab').val( $(this).tabs('option', 'active') );
213 }
214 });
215
216 $('.extended-widget-opts-settings-tabs').click('tabsselect', function (event, ui) {
217 if( $(this).find('#extended-widget-opts-settings-selectedtab').length > 0 ){
218 $(this).find('#extended-widget-opts-settings-selectedtab').val( $(this).tabs('option', 'active') );
219 }
220 });
221 }
222 })( jQuery, window, document );
223