PluginProbe
Responsive Menu – Create Mobile-Friendly Menu / 3.1.21
Responsive Menu – Create Mobile-Friendly Menu v3.1.21
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 / public / js / admin / base.js

base.js in Responsive Menu – Create Mobile-Friendly Menu 3.1.21, at public/js/admin/base.js

203 lines 6.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 Responsive Menu JS file.
3 Safe to Copy
4 **/
5
6 jQuery(function($) {
7
8 /* --> File Upload Options */
9 $(':file').filestyle({
10 icon: false,
11 buttonName: 'btn btn-primary btn-rm',
12 placeholder: 'No file'
13 });
14 /* <-- End File Upload Options */
15
16 /* --> Image Upload Options */
17 var custom_uploader;
18
19 $(document).on('click', '.image_button', function(e) {
20 e.preventDefault();
21 window.imgFor = $(this).attr('for');
22 //If the uploader object has already been created, reopen the dialog
23 if (custom_uploader) {
24 custom_uploader.open();
25 return;
26 }
27 //Extend the wp.media object
28 custom_uploader = wp.media.frames.file_frame = wp.media({
29 title: 'Choose Image',
30 button: {
31 text: 'Choose Image',
32 id: 'test'
33 },
34 multiple: false
35 });
36
37 //When a file is selected, grab the URL and set it as the text field's value
38 custom_uploader.on('select', function () {
39 attachment = custom_uploader.state().get('selection').first().toJSON();
40 $('#' + window.imgFor).val(attachment.url);
41 });
42
43 //Open the uploader dialog
44 custom_uploader.open();
45 });
46 /* <-- End Image Upload Options */
47
48 /* --> Scroll to Option */
49 $(document).on('click', '.scroll-to-option', function(e) {
50 e.preventDefault();
51 var id_to_scroll_to = $(this).attr('href');
52 var parent_panel_id = $(id_to_scroll_to).parents('.tab-pane').attr('id');
53 var parent_tab = $('a[href="#' + parent_panel_id + '"]').parent('li');
54
55 $('tr').removeClass('option-highlight');
56 $('ul.nav-tabs li').removeClass('active');
57 parent_tab.addClass('active');
58
59 $('#responsive-menu-current-page').val(parent_panel_id);
60
61 $('.tab-content .tab-pane').removeClass('active').removeClass('in');
62
63 $('#' + parent_panel_id).addClass('active').addClass('in');
64
65 $('html, body').animate({
66 scrollTop: $(id_to_scroll_to).offset().top - 50
67 }, 1000);
68
69 $(id_to_scroll_to).closest('tr').addClass('option-highlight');
70 });
71 /* <-- End Scroll to Option */
72
73 /* --> Filter Options */
74 $(document).on('keyup', '#filter-options', function() {
75 var search_query = $(this).val();
76 $('#options-area').css('width', '99%');
77 $('.nav-tabs, #banner-area, .top-submit-buttons').hide();
78
79 if(search_query) {
80 $('.tab-pane').show().css('opacity', '1');
81 $('.panel-body small').css('display', 'block');
82 $('#responsive-menu-desktop-menu-container').parent('.panel').hide();
83
84 $('.control-label').closest('tr').hide();
85 $('.control-label').each(function() {
86 if ($(this).text().toLowerCase().indexOf(search_query.toLowerCase()) >= 0) {
87 $(this).closest('tr').show();
88 }
89 });
90
91 $('#options-area .table-bordered').each(function() {
92
93 var visible_rows = $(this).children('tbody').children('tr').filter(function() {
94 return $(this).css('display') == 'table-row';
95 });
96
97 if(visible_rows.length > 0) {
98 $(this).parents('.panel').show();
99 } else {
100 $(this).parents('.panel').hide();
101 }
102 });
103
104 } else {
105 $('.tab-pane').css('display', '').css('opacity', '');
106 $('.control-label').closest('tr').show();
107 $('.nav-tabs, #banner-area, .panel, .top-submit-buttons').show();
108 $('#options-area').css('width', '');
109 $('.panel-body small').css('display', '');
110 }
111 });
112 /* <-- End Filter Options */
113
114 /* --> Navigation Tabs */
115 $(document).on('click', '.nav-tabs li a', function() {
116 var tab_name = $(this).attr('href').replace('#', '');
117 $('#responsive-menu-current-page').val(tab_name);
118 });
119 /* <-- End Navigation Tabs */
120
121 /* --> Trigger Types */
122 $('#responsive-menu-button-trigger-type').selectize({
123 plugins: ['remove_button'],
124 options: [
125 {
126 value:'click',
127 text:'Click'
128 },
129 {
130 value:'mouseover',
131 text:'Hover'
132 }
133 ]
134 });
135 /* <-- End Trigger Types */
136
137 /* --> Keyboard Shortcuts */
138 $('.keyboard-shortcuts').selectize({
139 plugins: ['remove_button'],
140 options: [
141 {
142 value:27,
143 text:'Esc'
144 },
145 {
146 value:13,
147 text:'Enter'
148 },
149 {
150 value:32,
151 text:'Space'
152 },
153 {
154 value:37,
155 text:'Left'
156 },
157 {
158 value:38,
159 text:'Up'
160 },
161 {
162 value:39,
163 text:'Right'
164 },
165 {
166 value:40,
167 text:'Down'
168 }
169 ]
170 });
171 /* <-- End Keyboard Shortcuts */
172
173 /* --> Menu Order Scripts */
174 $(document).on('click', '.menu-order-option-switch', function() {
175 var siblings = $(this).siblings('input.orderable-item');
176 if(siblings.val() != 'on') {
177 siblings.val('on');
178 $(this).addClass('menu-order-option-switch-on');
179 } else {
180 siblings.val('');
181 $(this).removeClass('menu-order-option-switch-on');
182 }
183 });
184
185 $('#menu-sortable').sortable({
186 revert: true,
187 placeholder: 'dashed-placeholder'
188 });
189
190 $('#sortable, .draggable').disableSelection();
191 /* <-- End Menu Order Scripts */
192
193 /* --> Theme Selector Script */
194 $('#responsive-menu-menu-theme').on('changed.bs.select', function() {
195 var selected_theme_key = $(this).val();
196 var preview_image_url = THEMES_FOLDER_URL + selected_theme_key + '/preview.png';
197 var $preview_image = $('#responsive-menu-theme-preview');
198
199 $preview_image.attr('src', preview_image_url);
200 });
201 /* <-- End Theme Selector Script */
202 });
203