User tests: Successful: Unsuccessful:
Previously isValid method was looking once for fields to validate and second time for invalid fields. Now it filters fields which were already found at the beginning.
Previously when invalid field was found, it was not using label from DATA attribute which was created on validator initialization, but it was looking for label one more time, depending only on attribute FOR, instead of ID.
This patch makes only improvements and fixes labels. You can only test if validation still works.
Go to new article view and try to save without any title. You will see error message with invalid field label.
Remember to enable debug mode in Global Configuration as this patch contains only uncompressed file.
Which tool do you use in Joomla to compress JS, that I could create one?
Lately when I was developing a component I had problems with labels. I was creating new fields on the fly and I was attaching data attribute with existing label and it was not working as rendering error message was not consistent with method attachToForm.
In attachToForm method jQuery.each has been changed to FOR loop which is much faster.
isValid method can also be attached to which is also a submit button.
validate method will no longer be attached to buttons as it should only be attached to fields.
Labels |
Added:
?
|
Category | ⇒ | JavaScript |
looks not bad, but I see one more thing to optimize
about compress JS look https://gist.github.com/phproberto/6933178
thanks
you now can replace .each
to
for(var i, l = invalid.length; i < l; i++ ) {
label = jQuery(invalid[i]).data('label');
...
...
}
it a little bit faster http://jsperf.com/for-vs-foreach/37
Thanks for a nice test with loops, that was interesting. I have updated code.
What do you think about one more improvement as for loop is much faster than $.each?
It could be improved in isValid and attachToForm methods.
var fields = jQuery(form).find('input, textarea, select, fieldset, button') || [];
for(var i, l = fields.length; i < l; i++ ) {
...
}
yes, good idea
Patch ready to test again. I have made further improvements to isValid and attachToForm methods.
Title |
|
looks good,
left only one important thing: compressed version
All improvements done
all good except one thing, it not work on administrator/index.php?option=com_menus&view=menu&layout=edit
replacing to label = jQuery(invalid[i]).data("label");
opened hidden bug .... see code comments
do not forget update compressed version
thanks!
test
works good,
one more tester?
@test works fine for me! Also the field order is correct
Setting RTC
Status | Pending | ⇒ | Ready to Commit |
Labels |
Added:
?
|
Status | Ready to Commit | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2015-03-13 09:37:55 |
Merged. Thanks!
Labels |
Removed:
?
|
@test No problems found, code looks also good to me.
I'am not sure, but I think you can use a random javascript compressor like: http://javascriptcompressor.com/
Or will this files compressed automatically when creating the next build?
This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/6294.