341 if (!initialvalue) { |
341 if (!initialvalue) { |
342 initialvalue = node.value; |
342 initialvalue = node.value; |
343 } |
343 } |
344 options.initialvalue = initialvalue; |
344 options.initialvalue = initialvalue; |
345 Widgets.SuggestField.__init__(this, node, options); |
345 Widgets.SuggestField.__init__(this, node, options); |
346 } |
|
347 }); |
|
348 |
|
349 /** |
|
350 * .. class:: Widgets.SuggestForm |
|
351 * |
|
352 * suggestform displays a suggest field and associated validate / cancel buttons |
|
353 * constructor's argumemts are the same that BaseSuggestField widget |
|
354 */ |
|
355 Widgets.SuggestForm = defclass("SuggestForm", null, { |
|
356 |
|
357 __init__: function(inputid, initfunc, varargs, validatefunc, options) { |
|
358 this.validatefunc = validatefunc || $.noop; |
|
359 this.sgfield = new Widgets.BaseSuggestField(inputid, initfunc, varargs, options); |
|
360 this.oklabel = options.oklabel || 'ok'; |
|
361 this.cancellabel = options.cancellabel || 'cancel'; |
|
362 bindMethods(this); |
|
363 connect(this.sgfield, 'validate', this, this.entryValidated); |
|
364 }, |
|
365 |
|
366 show: function(parentnode) { |
|
367 var sgnode = this.sgfield.builddom(); |
|
368 var buttons = DIV({ |
|
369 'class': "sgformbuttons" |
|
370 }, |
|
371 [A({ |
|
372 'href': "javascript: $.noop();", |
|
373 'onclick': this.onValidateClicked |
|
374 }, |
|
375 this.oklabel), ' / ', A({ |
|
376 'href': "javascript: $.noop();", |
|
377 'onclick': this.destroy |
|
378 }, |
|
379 escapeHTML(this.cancellabel))]); |
|
380 var formnode = DIV({ |
|
381 'class': "sgform" |
|
382 }, |
|
383 [sgnode, buttons]); |
|
384 appendChildNodes(parentnode, formnode); |
|
385 this.sgfield.textinput.focus(); |
|
386 this.formnode = formnode; |
|
387 return formnode; |
|
388 }, |
|
389 |
|
390 destroy: function() { |
|
391 signal(this, 'destroy'); |
|
392 this.sgfield.destroy(); |
|
393 removeElement(this.formnode); |
|
394 }, |
|
395 |
|
396 onValidateClicked: function() { |
|
397 this.validatefunc(this, this.sgfield.taglist()); |
|
398 }, |
|
399 /* just an indirection to pass the form instead of the sgfield as first parameter */ |
|
400 entryValidated: function(sgfield, taglist) { |
|
401 this.validatefunc(this, taglist); |
|
402 } |
346 } |
403 }); |
347 }); |
404 |
348 |
405 /** |
349 /** |
406 * .. function:: toggleTree(event) |
350 * .. function:: toggleTree(event) |