/[jquery]/tag_complete/jquery-tac.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/jquery-tac.js

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

revision 58 by dpavlin, Sun Aug 20 23:23:29 2006 UTC revision 59 by dpavlin, Sun Aug 20 23:37:52 2006 UTC
# Line 16  function tac( Line 16  function tac(
16                  exists: new Array()                  exists: new Array()
17          };          };
18    
19            // all tags indexed by first letter
20          this.all_tags = new Array();          this.all_tags = new Array();
21          this.suggested = new Array();          this.suggested = new Array();
22    
# Line 42  function tac( Line 43  function tac(
43          var obj = this;          var obj = this;
44          $( this.tags_selector ).each( function(i) {          $( this.tags_selector ).each( function(i) {
45                  var n = this.firstChild.nodeValue;                  var n = this.firstChild.nodeValue;
46                    var c = n.substr(0,1);
47    
48                  obj.t.obj[n] = this;                  obj.t.obj[n] = this;
49                  obj.t.exists[n] = true;                  obj.t.exists[n] = true;
50                  obj.all_tags.push( n );                  if (obj.all_tags[c] == null) {
51                            obj.all_tags[c] = new Array( n );
52                    } else {
53                            obj.all_tags[c].push( n );
54                    }
55    
56                  this.onclick = function() {                  this.onclick = function() {
57                          return obj.tag( n );                          return obj.tag( n );
58                  }                  }
59                  this.href = '#'+i;      // FIXME debug                  this.href = '#'+i;      // FIXME debug
60          });          });
61          $.log.info( 'found ' + this.all_tags.length + ' tags' );          $.log.info( 'found ' + this.t.obj.length + ' tags' );
62    
63          $.log.info( 'hook onchange to '+this.tags_form );          $.log.info( 'hook onchange to '+this.tags_form );
64          $( this.tags_form ).keyup( function(e) {          $( this.tags_form ).keyup( function(e) {
# Line 80  function tac( Line 86  function tac(
86                          case 8:         // backspace                          case 8:         // backspace
87                          case 46:        // del                          case 46:        // del
88                                  ret = false;                                  ret = false;
89                                    break;
90                          case 37:        // left                          case 37:        // left
91                          case 39:        // right                          case 39:        // right
92                                  return true;                                  return true;
# Line 118  tac.prototype.suggest = function( partia Line 125  tac.prototype.suggest = function( partia
125          var suggest = '';          var suggest = '';
126          this.suggested = new Array();          this.suggested = new Array();
127    
128          for(var i = 0; i < this.all_tags.length; i++) {          var c = partial.substr(0,1);
129                  var t = this.all_tags[i];  
130                  if ( t.substr(0, len) == partial ) {          for(var i = 0; i < this.all_tags[ c ].length; i++) {
131                          $.log.debug('suggested: ' + t );                  var t = this.all_tags[c][i];
132                    if ( t.substr(0, len) == partial && this.entered.tag[ t ] == null) {
133    
134                            //$.log.debug('suggested: ' + t );
135    
136                          jQuery.className.add( this.t.obj[t], 'suggested' );                          jQuery.className.add( this.t.obj[t], 'suggested' );
137    

Legend:
Removed from v.58  
changed lines
  Added in v.59

  ViewVC Help
Powered by ViewVC 1.1.26