/[jquery]/tag_complete/tag_complete.js
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /tag_complete/tag_complete.js

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 45 by dpavlin, Fri Aug 18 21:58:54 2006 UTC revision 46 by dpavlin, Fri Aug 18 22:59:04 2006 UTC
# Line 47  var _tag = { Line 47  var _tag = {
47                  }                  }
48    
49                  var c = _tag.current;                  var c = _tag.current;
50                  if (c == null) return;                  if (c == null) return c;
51    
52                  $('#suggest').html('');                  $('#suggest').html('');
53                  _tag.current = null;                  _tag.current = null;
54    
55                    return c;
56          },          },
57    
58    
59          take_suggested: function() {          take_suggested: function() {
60                  if (_tag.current == null) return;                  var c = _tag.current;
61                  var s = $('#suggest li:nth('+_tag.current+')').html();                  if (c == null) {
62                            $.log.debug('no current, return true');
63                            return true;
64                    }
65    
66                    var s = $('#suggest li:nth('+c+')').html();
67                    if (s == null) {
68                            $.log.debug('no suggest, return true');
69                            return true;
70                    }
71    
72                  $.log.info('take suggestion: '+s);                  $.log.info('take suggestion: '+s);
73                  $('#tags').val(                  $('#tags').val(
74                          $('#tags').val().replace(                          $('#tags').val().replace(
75                                  /^([^ ][^ ]* )*[^ ]*$/, '$1' + s + ' '                                  /[^ ]*$/, s + ' '
76                          )                          )
77                  );                  );
78                  _tag.focus();                  _tag.clean_selected();
79                    return false;
80          },          },
81    
82          move_suggested: function( where ) {          move_suggested: function( where ) {
# Line 115  $(document).ready( function() { Line 128  $(document).ready( function() {
128                                  e.preventDefault();                                  e.preventDefault();
129                                  _tag.move_suggested( -1 );                                  _tag.move_suggested( -1 );
130                                  return false;                                  return false;
                                 break;  
131                          case 40:        // down                          case 40:        // down
132                                  e.preventDefault();                                  e.preventDefault();
133                                  _tag.move_suggested( +1 );                                  _tag.move_suggested( +1 );
134                                  return false;                                  return false;
                                 break;  
135                          case 9:         // tab                          case 9:         // tab
136                          case 13:        // return                          case 13:        // return
137                                    if (_tag.current != null) _tag.focus();
138                                  e.preventDefault();                                  e.preventDefault();
                                 _tag.take_suggested();  
   
139                                  return false;                                  return false;
                                 break;  
140                  }                  }
141    
142    
# Line 146  $(document).ready( function() { Line 155  $(document).ready( function() {
155                  return true;                  return true;
156          }).submit( function() {          }).submit( function() {
157                  $.log.debug('submit');                  $.log.debug('submit');
158                  if (_tag.current == null) {                  return _tag.take_suggested();
                         _tag.clean_selected();  
                         return true;  
                 } else {  
                         return false;  
                 }  
159          }).blur( function() {          }).blur( function() {
160                  $.log.debug('blur');                  $.log.debug('blur');
161                  _tag.clean_selected();                  return _tag.take_suggested();
                 if (_tag.current == null) {  
                         return true;  
                 } else {  
                         _tag.focus();  
                         return false;  
                 }  
162          });          });
163    
164          $.log.toggle();          $.log.toggle();

Legend:
Removed from v.45  
changed lines
  Added in v.46

  ViewVC Help
Powered by ViewVC 1.1.26