-( ( $ ) ->
+do ( $ = jQuery ) ->
 
   # TODO try optimize, excepting Edge and search in siblings for next cycle
   $.fn.nearestFind = (selector, extremeEdgeSelector = 'form, body') ->
     jEdge = @
-    jResult = jEdge.find selector
-    until jResult.length or jEdge.is extremeEdgeSelector
+    jResult = jEdge.find(selector)
+    until jResult.length or jEdge.is(extremeEdgeSelector)
       jEdge = jEdge.parent()
       jResult = jEdge.find selector
     jResult

      @find("input:not([readonly])#{if onlyVisible then ':visible' else ''}").each ->
        $(@).attr 'tabindex', ++$.fillTabIndexesCounter
    @

)( jQuery )

  # @param strongById: Boolean = false
  $.fn.closestLabel = ( strongById = false, passCache = false ) ->
    (if @is(':input') then @ else @find(':input')).filter(':not(input[type="hidden"])').map ->
      jInput = $(@)
      jLabel = jInput.data('closestLabel')  unless passCache
      unless jLabel
        if jLabel is false
          return null
        else
          jLabel = {length: 0}
          inputId = jInput.attr('id')
          if inputId
            # try search label by id linkage
            jLabel = jInput.nearestFind("label[for=\"#{inputId}\"]:first")
          # try get first labet in the edge area
          unless jLabel.length
            jLabel = jInput.nearestFind('label')
            if jLabel.length is 1
              jReverseInput = jLabel.nearestFind(':input')
              unless jReverseInput.length is 1 and jReverseInput[0] is jInput[0]
                jLabel = {length: 0}
            else if jLabel.length > 1
              jLabel = {length: 0}
          # taken!
          if jLabel.length
            # oh, this label already linked
            if jLabel.data('closestInput')
              jLabel = {length: 0}
            else
              jLabel.data 'closestInput', jInput
