function focused(evt, errors) {
	let form = evt.target

	const output = errors.map((error)=> {

		// Find first component with error on form and set focus to it

		let focusedInput = (Object.keys(error) == "phonebookId") ? Object.keys(error) :
			(Object.keys(error) == "phonebook_str") ? Object.keys(error) :
				(Object.keys(error) == "message") ? Object.keys(error) :
					(Object.keys(error) == "image") ? Object.keys(error) :
						(Object.keys(error) == "buttonLink") ? Object.keys(error) :
							(Object.keys(error) == "messageSms") ? Object.keys(error) : false
		return focusedInput.shift()
	})

	const selector = output.shift()
	form.querySelector('[id="' + selector + '"]').focus()

	return selector
}

What can I say... If you plan to work with freelancers with low rate then you should be ready to find it in them code :)

By Ya, 2016-10-02 12:16:46