marijnh/CodeMirror — pull request #1853 by nwidger (2013-09-30 17:46:52+00:00)
Title: [dialog addon] Add closeOn and onButtonClick options

[dialog addon] Add closeOn and onButtonClick options

Use new options.closeOn array if defined to decide when dialog should be
automatically closed. If defined, the array should contain one or more
of 'blur', 'click' or a key name returned by CodeMirror.keyName (i.e.,
'Enter', 'Esc', etc.).

Add a 'click' handler to all button elements inside the dialog's HTML
template. If defined, use the new options.onButtonClick function to
allow the user to specify additional behavior beyond the default action
of closing the dialog and returning focus to the editor (unless
options.closeOn is defined and does not contain the value 'click'). The
onButtonClick function should take the form function(event, close,
query) and return true if the default action should not also be
executed. If the dialog's HTML template did not contain an input
element, than the 'query' argument will be undefined.

[search addon] Pass options to dialog / Default button click handler

Add optional 'options' argument to CodeMirror.commands.find,
CodeMirror.commands.findNext and CodeMirror.commands.findPrev.

Use new options.queryDialog value if defined to override the default
template passed to openDialog.

Pass options.dialogOptions to openDialog if defined.

Modify doSearch to define a default options.dialogOptions.onButtonClick
function if not already defined. The default handler looks at name
attribute of the clicked element and runs forward/reverse search if the
name is 'findNext'/'findPrev', respectively, otherwise it closes the
dialog and returns focus to the editor.

Modify doSearch to allow running a search using the existing state.query
search term. Logic for using existing query or reparsing new query if
input from dialog has changed is in new function doQuery.