motion-prime/sections/form.rb in motion-prime-0.4.4 vs motion-prime/sections/form.rb in motion-prime-0.4.5
- old
+ new
@@ -131,50 +131,19 @@
current_inset = table_view.contentInset
current_inset.bottom = self.table_element.computed_options[:bottom_content_inset] || 0
table_view.contentInset = current_inset
end
+ def table_delegate
+ @table_delegate ||= FormDelegate.new(section: self)
+ end
+
# ALIASES
def on_input_change(text_field); end
- def on_input_edit(text_field); end
+ def on_input_edit_begin(text_field); end
+ def on_input_edit_end(text_field); end
def on_input_return(text_field)
text_field.resignFirstResponder
- end
- def textFieldShouldReturn(text_field)
- on_input_return(text_field)
- end
- def textFieldShouldBeginEditing(text_field)
- text_field.respond_to?(:readonly) ? !text_field.readonly : true
- end
- def textFieldDidBeginEditing(text_field)
- on_input_edit(text_field)
- end
- def textViewDidBeginEditing(text_view)
- on_input_edit(text_view)
- end
- def textViewDidChange(text_view) # bug in iOS 7 - cursor is out of textView bounds
- line = text_view.caretRectForPosition(text_view.selectedTextRange.start)
- overflow = line.origin.y + line.size.height -
- (text_view.contentOffset.y + text_view.bounds.size.height - text_view.contentInset.bottom - text_view.contentInset.top)
- if overflow > 0
- offset = text_view.contentOffset
- offset.y += overflow + text_view.textContainerInset.bottom
- UIView.animate(duration: 0.2) do
- text_view.setContentOffset(offset)
- end
- end
- end
-
- def textView(text_view, shouldChangeTextInRange:range, replacementText:string)
- textField(text_view, shouldChangeCharactersInRange:range, replacementString:string)
- end
-
- def textField(text_field, shouldChangeCharactersInRange:range, replacementString:string)
- limit = (self.class.text_field_limits || {}).find do |field_name, limit|
- view("#{field_name}:input") == text_field
- end.try(:last)
- return true unless limit
- allow_string_replacement?(text_field, limit, range, string)
end
def allow_string_replacement?(target, limit, range, string)
if string.length.zero? || (range.length + limit - target.text.length) >= string.length
true
\ No newline at end of file