diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/dom_utils.coffee | 14 | 
1 files changed, 10 insertions, 4 deletions
| diff --git a/lib/dom_utils.coffee b/lib/dom_utils.coffee index 21018049..dfaa5d5f 100644 --- a/lib/dom_utils.coffee +++ b/lib/dom_utils.coffee @@ -91,17 +91,23 @@ DomUtils =      null    # -  # Selectable means the element has a text caret; this is not the same as "focusable". +  # Selectable means that we should use the simulateSelect method to activate the element instead of a click. +  # +  # The html5 input types that should use simulateSelect are: +  #   ["date", "datetime", "datetime-local", "email", "month", "number", "password", "range", "search", +  #    "submit", "tel", "text", "time", "url", "week"] +  # An unknown type will be treated the same as "text", in the same way that the browser does.    #    isSelectable: (element) -> -    selectableTypes = ["search", "text", "password"] -    (element.nodeName.toLowerCase() == "input" && selectableTypes.indexOf(element.type) >= 0) || +    unselectableTypes = ["button", "checkbox", "color", "file", "hidden", "image", "radio", "reset"] +    (element.nodeName.toLowerCase() == "input" && unselectableTypes.indexOf(element.type) == -1) ||          element.nodeName.toLowerCase() == "textarea"    simulateSelect: (element) ->      element.focus()      # When focusing a textbox, put the selection caret at the end of the textbox's contents. -    element.setSelectionRange(element.value.length, element.value.length) +    # For some HTML5 input types (eg. date) we can't position the caret, so we wrap this with a try. +    try element.setSelectionRange(element.value.length, element.value.length)    simulateClick: (element, modifiers) ->      modifiers ||= {} | 
