Permalink
Browse files

Improve tooltip handling on themerollered demo

  • Loading branch information...
1 parent 9050de7 commit 3d79fc8cc7e0c116625f48f4c42c109c944ecc90 @jzaefferer jzaefferer committed Nov 22, 2011
Showing with 13 additions and 8 deletions.
  1. +13 −8 demo/themerollered.html
View
@@ -116,22 +116,28 @@
<script type="text/javascript">
$.validator.setDefaults({
submitHandler: function() { alert("submitted!"); },
- highlight: function(input) {
- $(input).addClass("ui-state-highlight");
- },
- unhighlight: function(input) {
- $(input).removeClass("ui-state-highlight");
- },
showErrors: function(map, list) {
+ // there's probably a way to simplify this
+ var focussed = document.activeElement;
+ if (focussed && $(focussed).is("input, textarea")) {
+ $(this.currentForm).tooltip("close", { currentTarget: focussed }, true)
+ }
this.currentElements.removeAttr("title").removeClass("ui-state-highlight");
$.each(list, function(index, error) {
$(error.element).attr("title", error.message).addClass("ui-state-highlight");
});
+ if (focussed && $(focussed).is("input, textarea")) {
+ $(this.currentForm).tooltip("open", { target: focussed });
+ }
}
});
(function() {
- $("#commentForm, #signupForm").tooltip();
+ // use custom tooltip; disable animations for now to work around lack of refresh method on tooltip
+ $("#commentForm, #signupForm").tooltip({
+ show: false,
+ hide: false
+ });
// validate the comment form when it is submitted
$("#commentForm").validate();
@@ -211,7 +217,6 @@
$(":submit").button();
})();
</script>
-
<script src="http://jqueryui.com/themeroller/themeswitchertool/"></script>
<script>
$.fn.themeswitcher && $('<div/>').css({

0 comments on commit 3d79fc8

Please sign in to comment.