diff -Naur tagging/tagging.css /var/www/migrate/inst/loc3/sites/all/modules/tagging/tagging.css --- tagging/tagging.css 2010-07-18 05:11:01.000000000 -0500 +++ /var/www/migrate/inst/loc3/sites/all/modules/tagging/tagging.css 2010-08-28 21:35:29.000000000 -0500 @@ -95,3 +95,8 @@ .clearfix { display:block; } +.ajax-wait { + background:url('ajax-loader.gif') transparent no-repeat center center; + width 50px; + height: 50px; +} diff -Naur tagging/tagging.module /var/www/migrate/inst/loc3/sites/all/modules/tagging/tagging.module --- tagging/tagging.module 2010-07-18 05:11:01.000000000 -0500 +++ /var/www/migrate/inst/loc3/sites/all/modules/tagging/tagging.module 2010-08-28 21:45:21.000000000 -0500 @@ -7,8 +7,18 @@ /** * hook_menu */ + +function tagging_perm() { + return array('ajax term extractor'); +} + function tagging_menu() { $items = array(); + $items['extracttags'] = array ( + 'page callback' => 'tagging_extracttags', + 'access arguments' => array('ajax term extractor'), + 'type' => MENU_CALLBACK + ); $items['admin/settings/tagging/settings'] = array ( 'type' => MENU_NORMAL_ITEM, 'title' => 'Tagging configuration', @@ -177,10 +187,10 @@ $suggested_tags .= $link; } // If we have any suggestions, then place the wrapper. - if($suggested_tags != '') { +// if($suggested_tags != '') { return "
$suggested_tags
"; - } +// } // We have no suggestions, so no need to show any output return ''; } @@ -237,3 +247,21 @@ variable_set('tagging_inject_'. $form_state['values']['vid'], $form_state['values']['tagging_inject']); return TRUE; } + +function tagging_extracttags() { + $text = $_POST['d']; + $terms = extractor_extract($text,'extractor_simple_ins_syn'); + + $result = array(); + foreach($terms as $key => $term) { + $result[] = array('#weight' => (1/$key), '#name' => $term); + } + uasort($result,'element_sort'); + + if(variable_get('tagging_show_max_suggestion', 20) > 0) { + $result = array_slice($result,0, variable_get('tagging_show_max_suggestion', 20)); + } + + drupal_json($result); + exit(); +} diff -Naur tagging/tagging.plugin.js /var/www/migrate/inst/loc3/sites/all/modules/tagging/tagging.plugin.js --- tagging/tagging.plugin.js 2010-07-18 05:11:01.000000000 -0500 +++ /var/www/migrate/inst/loc3/sites/all/modules/tagging/tagging.plugin.js 2010-08-28 21:42:03.000000000 -0500 @@ -139,6 +139,7 @@ else { $(input_sel).bind('keydown',check_enter); } + $('#edit-body').bind('focusout',tag_focus); } /* @@ -158,6 +159,23 @@ return true; } + function tag_focus(event) { + var tagUpdate = function(data) { + $(".ajax-wait").remove(); + for( var i in data) { + var term = data[i]; + $(suggestions_wrapper_sel).append(""+term['#name']+""); + } + bind_taglist_events(); + update_tags(); + check_dublicates(); + } + + $(suggest_sel).remove(); // Remove suggestions, in case text has changed + $(suggestions_wrapper_sel).append("
     " ); + $.ajax({ type: 'POST', url: '/extracttags', dataType: 'json', success: tagUpdate, data: { 'd' : this.value }}); + } + /* * Check for dupblicates in suggestions and allready assgined tags. * Hide suggestions on match. @@ -256,4 +274,4 @@ } ); } -})(jQuery); \ No newline at end of file +})(jQuery);