$logged_on_userid = $userservice->getCurrentUserId();
$userPopularTags =& $tagservice->getPopularTags($logged_on_userid, 25, $logged_on_userid);
-$userPopularTagsCloud =& $tagservice->tagCloud($userPopularTags, 5, 90, 175);
+$userAllTags =& $tagservice->getPopularTags($logged_on_userid, 10000, $logged_on_userid);
+$userPopularTagsCloud =& $tagservice->tagCloud($userPopularTags, 5, 90, 175);
$userPopularTagsCount = count($userPopularTags);
if ($userPopularTagsCount > 0) {
function addonload(addition) {
var existing = window.onload;
window.onload = function () {
- existing();
- addition();
+ existing;
+ addition;
}
}
document.write('<?php echo $taglist ?>');
document.write('<\/p>');
document.write('<\/div>');
+
+var availableTags = [
+<?php
+
+foreach(array_keys($userAllTags) as $key) {
+ print '"'.$userAllTags[$key]['tag'].'",'."\n";
+}
+?>
+];
+function split( val ) {
+ return val.split( /,\s*/ );
+}
+function extractLast( term ) {
+ return split( term ).pop();
+}
+
+$( "#tags" )
+ // don't navigate away from the field on tab when selecting an item
+ .bind( "keydown", function( event ) {
+ if ( event.keyCode === $.ui.keyCode.TAB &&
+ $( this ).data( "autocomplete" ).menu.active ) {
+ event.preventDefault();
+ }
+ })
+ .autocomplete({
+ minLength: 2,
+ delay: 50,
+ source: function( request, response ) {
+ // if the term is >2 in legth delegate back to autocomplete
+ if (extractLast ( request.term ).length < 3) {
+ response( [] );
+ } else {
+ response( $.ui.autocomplete.filter(
+ availableTags, extractLast( request.term ) ) );
+ }
+ },
+ focus: function() {
+ // prevent value inserted on focus
+ return false;
+ },
+ select: function( event, ui ) {
+ var terms = split( this.value );
+ // remove the current input
+ terms.pop();
+ // add the selected item
+ var newterm = ui.item.value;
+ terms.push( newterm );
+
+ $("#popularTags").children().each(function() {
+ if (this.innerHTML == newterm) {
+ this.className = 'selected';
+ }
+ });
+ // add placeholder to get the comma-and-space at the end
+ terms.push( "" );
+ this.value = terms.join( ", " );
+ return false;
+ }
+});
+
+
</script>
-<?php } ?>
\ No newline at end of file
+<?php } ?>