Labs/Ubiquity/Ubiquity Source Tip Author Tutorial: Difference between revisions

Jump to navigation Jump to search
Line 446: Line 446:
=== Writing a Noun Type Object ===
=== Writing a Noun Type Object ===


The most involved way of creating a custom nountype is to write an object that implements a <code>suggest()</code> method (and, optionally, a <code>default()</code> method.)
Of course, not every type of noun you'd be interested in can be represented
as a finite list or as a regexp.  If you want to be able to accept or reject input based on some algorithmic test, you can do so by writing a custom JavaScript object that implements a <code>suggest()</code> method (and, optionally, a <code>default()</code> method.)


Here's an example of what a noun type looks like:
There is an example of how to do this in the section on the tab commands, below.
<pre>
var noun_type_foo = {
  _name: "foo",
  suggest: function( text, html, callback ) {
  },
  default: function() {
  }
};
</pre>


== Insert Email: the Contact noun type ==
== Insert Email: the Contact noun type ==
1,007

edits

Navigation menu