PluginProbe ʕ •ᴥ•ʔ
Nested Pages / 3.2.14
Nested Pages v3.2.14
3.2.15 3.2.14 3.1.8 3.1.9 3.2.0 3.2.1 3.2.10 3.2.11 3.2.12 3.2.13 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8 3.2.9 trunk 1.0 1.1 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.2.1 1.3.0 1.3.1 1.3.10 1.3.11 1.3.12 1.3.13 1.3.14 1.3.15 1.3.2 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.6.1 1.6.2 1.6.3 1.6.3.1 1.6.3.2 1.6.4 1.6.5 1.6.5.1 1.6.5.2 1.6.6 1.6.7 1.6.8 1.7.0 1.7.1 2.0.1 2.0.2 2.0.3 2.0.4 3.0.1 3.0.10 3.0.11 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.10 3.1.11 3.1.12 3.1.13 3.1.14 3.1.15 3.1.16 3.1.17 3.1.18 3.1.19 3.1.2 3.1.20 3.1.21 3.1.22 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7
wp-nested-pages / assets / js / lib / nestedpages.menu-search.js
wp-nested-pages / assets / js / lib Last commit date
jquery.mjs.nestedSortable.js 4 years ago jquery.ui.touch-punch.min.js 11 years ago nestedpages-factory.js 3 years ago nestedpages.bulk-actions.js 4 years ago nestedpages.check-all.js 9 years ago nestedpages.clone.js 3 years ago nestedpages.confirm-delete.js 8 years ago nestedpages.dropdowns.js 8 years ago nestedpages.formatter.js 3 years ago nestedpages.hidden-item-count.js 9 years ago nestedpages.manual-sync.js 9 years ago nestedpages.menu-links.js 3 years ago nestedpages.menu-search.js 4 days ago nestedpages.menu-toggle.js 8 years ago nestedpages.modals.js 8 years ago nestedpages.move-post.js 8 years ago nestedpages.nesting.js 3 years ago nestedpages.new-post.js 6 years ago nestedpages.page-toggle.js 4 years ago nestedpages.post-search.js 9 years ago nestedpages.quickedit-link.js 8 years ago nestedpages.quickedit-post.js 3 years ago nestedpages.settings-admin-customization.js 6 years ago nestedpages.settings-reset.js 6 years ago nestedpages.settings.js 3 years ago nestedpages.sync-menu-setting.js 8 years ago nestedpages.tabs.js 6 years ago nestedpages.trash-with-children.js 6 years ago nestedpages.trash.js 8 years ago nestedpages.userprefs-reset.js 7 years ago nestedpages.wpml.js 8 years ago
nestedpages.menu-search.js
129 lines
1 var NestedPages = NestedPages || {};
2
3 /**
4 * Menu Item Search in Modal Link Form
5 * @package Nested Pages
6 * @author Kyle Phillips - https://github.com/kylephillips/wp-nested-pages
7 */
8 NestedPages.MenuSearch = function()
9 {
10 var plugin = this;
11 var $ = jQuery;
12
13 plugin.selectors = {
14 searchForms : '*[data-np-menu-search]', // Search form selector
15 defaultResults : '[data-default-result]', // Default results list items
16 loadingIndicator : '.np-menu-search-loading', // loading indicator
17 noResults : '.np-menu-search-noresults', // No results
18 searchType : 'data-search-type', // The search object type (post_type, taxonomy)
19 searchObject : 'data-search-object', // The object to search (post, category, etc)
20 searchResults : '[data-np-search-result]', // Appended search result rows
21 }
22
23 plugin.activeForm = ''; // The active form
24 plugin.results = ''; // Search results
25 plugin.defaultResults = ''; // The default, loaded results
26 plugin.searchType = ''; // The type of search (post_type, taxonomy)
27 plugin.searchObject = ''; // The object being searched (post, category, post_tag, etc…)
28
29 plugin.formatter = new NestedPages.Formatter;
30
31 plugin.bindEvents = function()
32 {
33 $(document).on('keyup', plugin.selectors.searchForms, function(){
34 plugin.activeForm = $(this);
35 $(plugin.selectors.searchResults).remove();
36 plugin.performSearch();
37 });
38 }
39
40
41 // Perform the search
42 plugin.performSearch = function()
43 {
44 plugin.defaultResults = $(plugin.activeForm).parent('li').siblings(plugin.selectors.defaultResults);
45 if ( $(plugin.activeForm).val().length > 2 ){
46 $(plugin.defaultResults).hide();
47 plugin.toggleLoading(true);
48 plugin.query();
49 return;
50 }
51 plugin.toggleLoading(false);
52 $(plugin.defaultResults).show();
53 }
54
55
56 // Query Search
57 plugin.query = function()
58 {
59 plugin.searchType = $(plugin.activeForm).attr(plugin.selectors.searchType);
60 plugin.searchObject = $(plugin.activeForm).attr(plugin.selectors.searchObject);
61 $.ajax({
62 url: NestedPages.jsData.ajaxurl,
63 type: 'post',
64 datatype: 'json',
65 data: {
66 action : NestedPages.formActions.search,
67 nonce : NestedPages.jsData.nonce,
68 term : $(plugin.activeForm).val(),
69 searchType : plugin.searchType,
70 searchObject : plugin.searchObject,
71 },
72 success: function(data){
73 if ( data.results ){
74 plugin.results = data.results;
75 plugin.toggleLoading(false);
76 if ( plugin.searchType === 'post_type' ){
77 plugin.appendPosts();
78 } else {
79 plugin.appendTaxonomies();
80 }
81 } else {
82 plugin.toggleLoading(false);
83 $(plugin.activeForm).siblings(plugin.selectors.noResults).show();
84 }
85 }
86 });
87 }
88
89
90 // Append post type results
91 plugin.appendPosts = function()
92 {
93 $('[data-np-search-result]').remove();
94 var html = "";
95 $.each(plugin.results, function(i, v){
96 html = '<li data-np-search-result><a href="#" data-np-menu-object="' + plugin.searchObject + '" data-np-menu-type="post_type" data-np-menu-objectid="' + v.ID + '" data-np-permalink="' + v.permalink + '" data-np-object-name="' + v.singular_name + '" data-np-menu-selection></a></li>';
97 $(html).insertAfter($(plugin.activeForm).parent('li'));
98 $('[data-np-menu-objectid="' + v.ID + '"').text(v.post_title);
99 });
100 plugin.toggleLoading(false);
101 }
102
103
104 // Append taxonomy results
105 plugin.appendTaxonomies = function()
106 {
107 var html = "";
108 $.each(plugin.results, function(i, v){
109 html += '<li data-np-search-result><a href="#" data-np-menu-object="' + plugin.searchObject + '" data-np-menu-type="post_type" data-np-menu-objectid="' + v.term_id + '" data-np-permalink="' + v.permalink + '" data-np-object-name="' + v.taxonomy + '" data-np-menu-selection>' + v.name + '</a></li>';
110 });
111 $(html).insertAfter($(plugin.activeForm).parent('li'));
112 plugin.toggleLoading(false);
113 }
114
115
116 // Toggle the loading indicator
117 plugin.toggleLoading = function(loading)
118 {
119 var loadingIndicator = $(plugin.activeForm).siblings(plugin.selectors.loadingIndicator);
120 $(plugin.selectors.noResults).hide();
121 if ( loading ){
122 $(loadingIndicator).show();
123 return;
124 }
125 $(loadingIndicator).hide();
126 }
127
128 return plugin.bindEvents();
129 }