Changeset 1925275
- Timestamp:
- 08/15/2018 02:53:15 PM (8 years ago)
- Location:
- wp-search-category-admin/trunk
- Files:
-
- 2 edited
-
js/script.js (modified) (3 diffs)
-
wp-search-cat-admin.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
wp-search-category-admin/trunk/js/script.js
r1689793 r1925275 11 11 }, 12 12 init : function(){ 13 $.expr[':'].Contains = function(a, i, m) { 14 return $(a).text().toUpperCase() 15 .indexOf(m[3].toUpperCase()) >= 0; 16 }; 17 18 // Can edit in post edit page or in quick edit 19 var isQuickEditPage = $('.quick-edit-row').length > 0; 20 if (isQuickEditPage === true) { 21 this.initQuickEdit(); 22 } else { 23 this.initEditPage(); 24 } 25 }, 26 27 getSearchBox: function() { 28 var nameSearchField = this.getNameSearchField(); 29 var nameButtonGo = this.getNameSearchButton(); 30 return '<input type="text" name="'+ nameSearchField +'" id="'+ nameSearchField +'" class="meta-box-search-field" placeholder="Search" />'; 31 }, 32 33 initEditPage: function() { 13 34 var globalObject = this; 14 35 15 $.expr[':'].Contains = function(a, i, m) { 16 return $(a).text().toUpperCase() 17 .indexOf(m[3].toUpperCase()) >= 0; 18 }; 19 36 var search_box = this.getSearchBox(); 20 37 var nameSearchField = this.getNameSearchField(); 21 var nameButtonGo = this.getNameSearchButton();22 23 var search_box = '<input type="text" name="'+ nameSearchField +'" id="'+ nameSearchField +'" class="meta-box-search-field" placeholder="Recherche" />';24 38 25 39 $('#category-tabs').before(search_box); 26 40 27 globalObject.initSearch('autocomplete', $('#'+nameSearchField) );41 globalObject.initSearch('autocomplete', $('#'+nameSearchField), false); 28 42 }, 29 43 30 initSearch: function(method, element){ 44 initQuickEdit: function() { 45 var globalObject = this; 46 $('.editinline').on('click', function(event) { 47 setTimeout(function() { 48 var search_box = globalObject.getSearchBox(); 49 var nameSearchField = globalObject.getNameSearchField(); 50 $('.meta-box-search-field').remove(); 51 $('.cat-checklist.category-checklist').before(search_box); 52 globalObject.initSearch('autocomplete', $('#'+nameSearchField), true); 53 },50); 54 }); 55 56 }, 57 58 initSearch: function(method, element, isQuickEdit){ 31 59 switch(method){ 32 60 case 'click': … … 34 62 break; 35 63 case 'autocomplete': 36 this.initAutocomplete(element );64 this.initAutocomplete(element, isQuickEdit); 37 65 break; 38 66 } … … 51 79 }, 52 80 53 initAutocomplete: function(element ){81 initAutocomplete: function(element, isQuickEdit){ 54 82 var that = this; 55 83 element.keyup($.debounce(500, function(){ 56 84 var s = $(this).val(); 57 that.searchCat(s, element );85 that.searchCat(s, element, isQuickEdit); 58 86 })); 59 87 }, 60 88 61 searchCat: function(s, elementEvent){ 89 searchCat: function(s, elementEvent, isQuickEdit){ 90 var parentClass = 'categorydiv'; 91 var categoryChecklistClass = 'categorychecklist'; 92 if (isQuickEdit) { 93 parentClass = 'inline-edit-col'; 94 categoryChecklistClass = 'category-checklist'; 95 } 62 96 if ( $.trim(s) == "" ){ 63 elementEvent.parents('. categorydiv').first().find('.categorychecklistli').show();97 elementEvent.parents('.' + parentClass).first().find('.'+ categoryChecklistClass +' li').show(); 64 98 } 65 99 else 66 100 { 67 var result = elementEvent.parents('. categorydiv').first().find('.categorychecklistli:Contains("'+s+'")');101 var result = elementEvent.parents('.' + parentClass).first().find('.'+categoryChecklistClass+' li:Contains("'+s+'")'); 68 102 69 elementEvent.parents('. categorydiv').first().find('.categorychecklistli').hide();103 elementEvent.parents('.' + parentClass).first().find('.'+categoryChecklistClass+' li').hide(); 70 104 result.each(function(){ 71 105 $(this).show(); -
wp-search-category-admin/trunk/wp-search-cat-admin.php
r1689793 r1925275 11 11 function register_wpsca_custom_script($hook) 12 12 { 13 if ( 'post.php' != $hook && $hook != 'post-new.php' )13 if ( 'post.php' != $hook && $hook != 'post-new.php' && $hook != 'edit.php' ) 14 14 { 15 15 return;
Note: See TracChangeset
for help on using the changeset viewer.