Added condition to check if there is enough space on the right side

Added condition to check if there is enough space on the right side of an input field

When the input field is close to the right side of the page and the calendar width
is bigger than the width of input field + right offset then calendard will be placed
on the left side of the field (by default it's placed on the right side).