Permalink
Browse files

Reverted previous fix to bubble tip issue and applied different patch…

… to address the same problem
  • Loading branch information...
1 parent 63f40d7 commit 256b591a85bc630134b3f9e811965ad8c6a83f8e @winskie winskie committed Jan 6, 2017
Showing with 15 additions and 18 deletions.
  1. +1 −1 htsrv/anon_async.php
  2. +13 −16 rsc/js/bootstrap/usernames.js
  3. +1 −1 rsc/js/build/popover.bmin.js
@@ -212,7 +212,7 @@
$height = $thumbnail_sizes[$avatar_size][2];
// Display user avatar with login
// Attributes 'w' & 'h' we use for following js-scale div If image is downloading first time (Fix bubbletip)
- echo '<div class="center" w="'.$width.'" h="'.$height.'">';
+ echo '<div class="center" w="'.$width.'" h="'.$height.'" style="min-height: '.( $height + 20 ).'px; min-width: '.$width.'px;">';
echo get_avatar_imgtag( $User->login, 'login', true, $avatar_size, 'avatar_above_login', '', $avatar_overlay_text, $link_class, true, '' );
echo '</div>';
@@ -35,12 +35,6 @@ jQuery( document ).ready(function()
/** Init popover for User Avatar **/
var link_number = 1;
-
- // Add small container for bubbletip cache, tucked far away but NOT HIDDEN
- var bubbletipContainer = jQuery( '<div></div>' );
- bubbletipContainer.height( 1 ).width( 1 ).offset({ top: -1000, left: -1000 }).css({ overflow: 'hidden', position: 'absolute' });
- jQuery( 'body' ).append( bubbletipContainer );
-
jQuery( document ).on( 'mouseover', '[rel^=bubbletip_]', function()
{ // Prepare event mouseover for an element with popover effect
var link = jQuery( this );
@@ -70,12 +64,12 @@ jQuery( document ).ready(function()
placement: 'top',
html: true,
delay: { 'hide': 400 },
- template: '<div class="popover"><div class="arrow"></div><div class="popover-content"></div></div>'
+ template: '<div class="popover user_bubbletip"><div class="arrow"></div><div class="popover-content"></div></div>'
};
if( jQuery( '#' + div_cache_ID ).length == 0 )
{ // Create a div for cache user data
- var cache = jQuery( '<div id="' + div_cache_ID + '"></div>' );
- bubbletipContainer.append( cache );
+ jQuery( 'body' ).append( '<div id="' + div_cache_ID + '" style="display:none;"></div>' );
+ var cache = jQuery( '#' + div_cache_ID );
jQuery.ajax(
{ // Get user info
@@ -88,6 +82,13 @@ jQuery( document ).ready(function()
{ // Init Popover only if ajax content is received
result = ajax_debug_clear( result );
cache.html( result );
+
+ var img = cache.find( 'img' );
+ img.on( 'load', function() {
+ var popover = jQuery( '.popover.user_bubbletip' );
+ popover.css( 'top', link.offset().top - popover.outerHeight() );
+ });
+
var show_on_init = true;
if( link.hasClass( 'hide_popover' ) )
{ // We use this class as flag to understand that when ajax was loading
@@ -101,13 +102,10 @@ jQuery( document ).ready(function()
link.popover( popover_params );
if( show_on_init )
{ // Show popover
- window.setTimeout( function()
- {
- link.popover( 'show' );
- }, 10 );
+ link.popover( 'show' );
}
// Remove this from attr 'rel' to avoid of the repeating of init popover
- link.attr( 'rel', link.attr( 'rel' ).replace( /bubbletip_(user_|comment_)[\d\s]+/g, '' ) );
+ link.attr( 'rel', link.attr( 'rel').replace( /bubbletip_(user_|comment_)[\d\s]+/g, '' ) );
}
}
});
@@ -118,10 +116,9 @@ jQuery( document ).ready(function()
{ // Ajax content is downloaded and we can show a popover
// Remove a title temporary to don't display title on popover
var link_title = link.attr( 'title' );
- var cache = jQuery( '#' + div_cache_ID );
link.removeAttr( 'title' );
// Init popover
- popover_params.content = cache.html();
+ popover_params.content = jQuery( '#' + div_cache_ID ).html();
link.popover( popover_params );
link.popover( 'show' );
// Restore a title
@@ -1,2 +1,2 @@
/* This includes 5 files: bootstrap/usernames.js, bootstrap/plugins.js, bootstrap/userfields.js, bootstrap/colorpicker.js, bootstrap/formfields.js */
-function form_error_field_popover(a){var b=jQuery(a);if(b.hasClass("popovererror"))return!0;var c=jQuery('span.field_error[rel="'+b.attr("name")+'"]').html();if(""==c)return!0;var d=b.prop("tagName");if(b.popover("destroy"),"INPUT"==b.prop("tagName")&&b.hasClass("form_date_input"))try{$.datepicker._updateDatepicker($.datepicker._getInst(a))}catch(e){console.error("Unable to generate datepicker content using private methods _updateDatepicker() and _getInst()")}c&&b.popover({trigger:"manual",placement:function(){var a;if("INPUT"==b.prop("tagName")&&b.hasClass("form_date_input")){var c=jQuery(window),e=jQuery("#ui-datepicker-div");if(e.is(":visible"))a=e.offset().top>b.offset().top;else{var f=c.height()-(b.offset().top-c.scrollTop()+b.outerHeight());a=f>=e.outerHeight()}}return"SELECT"==d||"TEXTAREA"==d||"INPUT"==d&&a?"top":"bottom"},html:!0,content:'<span class="field_error">'+c+"</span>"}),b.on("show.bs.popover",function(){b.addClass("popovererror")})}var originalLeave=jQuery.fn.popover.Constructor.prototype.leave;jQuery.fn.popover.Constructor.prototype.leave=function(a){var b,c,d=a instanceof this.constructor?a:jQuery(a.currentTarget)[this.type](this.getDelegateOptions()).data("bs."+this.type);originalLeave.call(this,a),a.currentTarget&&(b=jQuery(a.currentTarget).siblings(".popover"),c=d.timeout,b.one("mouseenter",function(){clearTimeout(c),b.one("mouseleave",function(){jQuery.fn.popover.Constructor.prototype.leave.call(d,d)})}))},jQuery(document).ready(function(){var a=1,b=jQuery("<div></div>");b.height(1).width(1).offset({top:-1e3,left:-1e3}).css({overflow:"hidden",position:"absolute"}),jQuery("body").append(b),jQuery(document).on("mouseover","[rel^=bubbletip_]",function(){var c=jQuery(this),d="",e="";if(c.attr("rel").match("bubbletip_user_")){var f=c.attr("rel").replace(/bubbletip_user_(\d+).*/g,"$1");d="popover_cache_user_"+f,e="&userid="+f}else if(c.attr("rel").match("bubbletip_comment_")){var g=c.attr("rel").replace(/bubbletip_comment_(\d+).*/,"$1");d="popover_cache_comment_"+g,e="&commentid="+g}if(""!=d){c.attr("id","popoverlink"+a);var h={trigger:"hover",container:"body",placement:"top",html:!0,delay:{hide:400},template:'<div class="popover"><div class="arrow"></div><div class="popover-content"></div></div>'};if(0==jQuery("#"+d).length){var i=jQuery('<div id="'+d+'"></div>');b.append(i),jQuery.ajax({type:"POST",url:htsrv_url+"anon_async.php",data:"action=get_user_bubbletip&blog="+blog_id+e,success:function(a){if(ajax_response_is_correct(a)){a=ajax_debug_clear(a),i.html(a);var b=!0;c.hasClass("hide_popover")&&(b=!1,c.removeClass("hide_popover")),h.content=i.html(),c.popover(h),b&&window.setTimeout(function(){c.popover("show")},10),c.attr("rel",c.attr("rel").replace(/bubbletip_(user_|comment_)[\d\s]+/g,""))}}})}else if(""!=jQuery("#"+d).html()){var j=c.attr("title"),i=jQuery("#"+d);c.removeAttr("title"),h.content=i.html(),c.popover(h),c.popover("show"),c.attr("title",j),c.attr("rel",c.attr("rel").replace(/bubbletip_(user_|comment_)[\d\s]+/g,""))}a++}}),jQuery(document).on("mouseleave","[rel^=bubbletip_]",function(){jQuery(this).addClass("hide_popover")}),jQuery(document).on("mouseover",".popover",function(){jQuery(this).addClass("mouseover")}),jQuery(document).on("mouseleave",".popover",function(){jQuery(this).removeClass("mouseover"),jQuery(this).data("bs.popover").$element.popover("hide")}),jQuery(document).on("hide.bs.popover",function(a){jQuery(a.target).data("bs.popover").$tip.hasClass("mouseover")&&a.preventDefault()})});var plugin_number=1;jQuery(document).on("mouseover","a.help_plugin_icon",function(){if(jQuery(this).hasClass("popoverplugin"))return!0;jQuery(this).attr("title",""),jQuery(this).find("span").removeAttr("title");var a=jQuery(this).attr("rel");jQuery("#help_plugin_info_suffix").length>0&&(a+=jQuery("#help_plugin_info_suffix").html());var b="right";jQuery("body").width()-jQuery(this).position().left<220&&(b="left"),jQuery(this).popover({trigger:"hover",placement:b,html:!0,content:a,template:'<div class="popover popover-plugin"><div class="arrow"></div><div class="popover-content"></div></div>'}),jQuery(this).popover("show"),jQuery(this).addClass("popoverplugin"),plugin_number++}),jQuery(document).ready(function(){var a=1;jQuery(document).on("focus","[rel^=ufdf_]",function(){var b=jQuery(this),c="";if(!b.hasClass("popoverfield"))var d=b.attr("rel").replace("ufdf_",""),c="popover_cache_field_"+d;if(""!=c){var e={trigger:"focus",placement:"right",html:!0,template:'<div class="popover popover-userfield"><div class="arrow"></div><div class="popover-content"></div></div>'};if(0==jQuery("#"+c).length){jQuery("body").append('<div id="'+c+'" style="display:none"></div>');var f=jQuery("#"+c);jQuery.ajax({type:"POST",url:htsrv_url+"anon_async.php",data:"action=get_field_bubbletip&field_ID="+d+"&b2evo_icons_type=fontawesome",success:function(a){if(ajax_response_is_correct(a)){a=ajax_debug_clear(a),f.html(a);var c=!0;b.hasClass("popoverfield")&&(c=!1,b.removeClass("popoverfield")),e.content=f.html(),b.popover(e),c&&b.popover("show")}b.addClass("popoverfield")}})}else""!=jQuery("#"+c).html()&&(e.content=jQuery("#"+c).html(),b.popover(e),b.popover("show"),b.addClass("popoverfield"));a++}}),jQuery(document).on("blur","[rel^=ufdf_]",function(){jQuery(this).addClass("popoverfield")}),jQuery(document).on("click",".popover-userfield",function(){jQuery(this).next().find('span[class*="icon"]:first').click()})}),jQuery(document).ready(function(){var a=1;jQuery(".form_color_input").each(function(){var b="farbtastic_colorpicker_"+a;jQuery("body").append('<div id="'+b+'" style="display:none"></div>');var c=jQuery.farbtastic("#"+b);c.linkTo(this),jQuery(this).popover({trigger:"manual",placement:"right",html:!0,content:jQuery("#"+b)}),jQuery(this).focus(function(){var a=jQuery(this).parent().find(".popover");0==a.length?(jQuery("#"+b).show(),jQuery(this).popover("show")):a.show()}).blur(function(){var a=jQuery(this).parent().find(".popover");a.length>0&&a.hide()}),a++})});var form_error_fields_selector="input.field_error[type=text], input.field_error[type=radio], span.checkbox_error input[type=checkbox], select.field_error, textarea.field_error, input.field_error[type=file]";jQuery(document).on("mouseover focus",form_error_fields_selector,function(){form_error_field_popover(this),0==jQuery(this).next("div.popover:visible").length&&jQuery(this).popover("show")}).on("mouseout mouseleave blur",form_error_fields_selector,function(){jQuery(this).is(":focus")||jQuery(this).popover("hide")});
+function form_error_field_popover(a){var b=jQuery(a);if(b.hasClass("popovererror"))return!0;var c=jQuery('span.field_error[rel="'+b.attr("name")+'"]').html();if(""==c)return!0;var d=b.prop("tagName");if(b.popover("destroy"),"INPUT"==b.prop("tagName")&&b.hasClass("form_date_input"))try{$.datepicker._updateDatepicker($.datepicker._getInst(a))}catch(e){console.error("Unable to generate datepicker content using private methods _updateDatepicker() and _getInst()")}c&&b.popover({trigger:"manual",placement:function(){var a;if("INPUT"==b.prop("tagName")&&b.hasClass("form_date_input")){var c=jQuery(window),e=jQuery("#ui-datepicker-div");if(e.is(":visible"))a=e.offset().top>b.offset().top;else{var f=c.height()-(b.offset().top-c.scrollTop()+b.outerHeight());a=f>=e.outerHeight()}}return"SELECT"==d||"TEXTAREA"==d||"INPUT"==d&&a?"top":"bottom"},html:!0,content:'<span class="field_error">'+c+"</span>"}),b.on("show.bs.popover",function(){b.addClass("popovererror")})}var originalLeave=jQuery.fn.popover.Constructor.prototype.leave;jQuery.fn.popover.Constructor.prototype.leave=function(a){var b,c,d=a instanceof this.constructor?a:jQuery(a.currentTarget)[this.type](this.getDelegateOptions()).data("bs."+this.type);originalLeave.call(this,a),a.currentTarget&&(b=jQuery(a.currentTarget).siblings(".popover"),c=d.timeout,b.one("mouseenter",function(){clearTimeout(c),b.one("mouseleave",function(){jQuery.fn.popover.Constructor.prototype.leave.call(d,d)})}))},jQuery(document).ready(function(){var a=1;jQuery(document).on("mouseover","[rel^=bubbletip_]",function(){var b=jQuery(this),c="",d="";if(b.attr("rel").match("bubbletip_user_")){var e=b.attr("rel").replace(/bubbletip_user_(\d+).*/g,"$1");c="popover_cache_user_"+e,d="&userid="+e}else if(b.attr("rel").match("bubbletip_comment_")){var f=b.attr("rel").replace(/bubbletip_comment_(\d+).*/,"$1");c="popover_cache_comment_"+f,d="&commentid="+f}if(""!=c){b.attr("id","popoverlink"+a);var g={trigger:"hover",container:"body",placement:"top",html:!0,delay:{hide:400},template:'<div class="popover user_bubbletip"><div class="arrow"></div><div class="popover-content"></div></div>'};if(0==jQuery("#"+c).length){jQuery("body").append('<div id="'+c+'" style="display:none;"></div>');var h=jQuery("#"+c);jQuery.ajax({type:"POST",url:htsrv_url+"anon_async.php",data:"action=get_user_bubbletip&blog="+blog_id+d,success:function(a){if(ajax_response_is_correct(a)){a=ajax_debug_clear(a),h.html(a);var c=h.find("img");c.on("load",function(){var a=jQuery(".popover.user_bubbletip");a.css("top",b.offset().top-a.outerHeight())});var d=!0;b.hasClass("hide_popover")&&(d=!1,b.removeClass("hide_popover")),g.content=h.html(),b.popover(g),d&&b.popover("show"),b.attr("rel",b.attr("rel").replace(/bubbletip_(user_|comment_)[\d\s]+/g,""))}}})}else if(""!=jQuery("#"+c).html()){var i=b.attr("title");b.removeAttr("title"),g.content=jQuery("#"+c).html(),b.popover(g),b.popover("show"),b.attr("title",i),b.attr("rel",b.attr("rel").replace(/bubbletip_(user_|comment_)[\d\s]+/g,""))}a++}}),jQuery(document).on("mouseleave","[rel^=bubbletip_]",function(){jQuery(this).addClass("hide_popover")}),jQuery(document).on("mouseover",".popover",function(){jQuery(this).addClass("mouseover")}),jQuery(document).on("mouseleave",".popover",function(){jQuery(this).removeClass("mouseover"),jQuery(this).data("bs.popover").$element.popover("hide")}),jQuery(document).on("hide.bs.popover",function(a){jQuery(a.target).data("bs.popover").$tip.hasClass("mouseover")&&a.preventDefault()})});var plugin_number=1;jQuery(document).on("mouseover","a.help_plugin_icon",function(){if(jQuery(this).hasClass("popoverplugin"))return!0;jQuery(this).attr("title",""),jQuery(this).find("span").removeAttr("title");var a=jQuery(this).attr("rel");jQuery("#help_plugin_info_suffix").length>0&&(a+=jQuery("#help_plugin_info_suffix").html());var b="right";jQuery("body").width()-jQuery(this).position().left<220&&(b="left"),jQuery(this).popover({trigger:"hover",placement:b,html:!0,content:a,template:'<div class="popover popover-plugin"><div class="arrow"></div><div class="popover-content"></div></div>'}),jQuery(this).popover("show"),jQuery(this).addClass("popoverplugin"),plugin_number++}),jQuery(document).ready(function(){var a=1;jQuery(document).on("focus","[rel^=ufdf_]",function(){var b=jQuery(this),c="";if(!b.hasClass("popoverfield"))var d=b.attr("rel").replace("ufdf_",""),c="popover_cache_field_"+d;if(""!=c){var e={trigger:"focus",placement:"right",html:!0,template:'<div class="popover popover-userfield"><div class="arrow"></div><div class="popover-content"></div></div>'};if(0==jQuery("#"+c).length){jQuery("body").append('<div id="'+c+'" style="display:none"></div>');var f=jQuery("#"+c);jQuery.ajax({type:"POST",url:htsrv_url+"anon_async.php",data:"action=get_field_bubbletip&field_ID="+d+"&b2evo_icons_type=fontawesome",success:function(a){if(ajax_response_is_correct(a)){a=ajax_debug_clear(a),f.html(a);var c=!0;b.hasClass("popoverfield")&&(c=!1,b.removeClass("popoverfield")),e.content=f.html(),b.popover(e),c&&b.popover("show")}b.addClass("popoverfield")}})}else""!=jQuery("#"+c).html()&&(e.content=jQuery("#"+c).html(),b.popover(e),b.popover("show"),b.addClass("popoverfield"));a++}}),jQuery(document).on("blur","[rel^=ufdf_]",function(){jQuery(this).addClass("popoverfield")}),jQuery(document).on("click",".popover-userfield",function(){jQuery(this).next().find('span[class*="icon"]:first').click()})}),jQuery(document).ready(function(){var a=1;jQuery(".form_color_input").each(function(){var b="farbtastic_colorpicker_"+a;jQuery("body").append('<div id="'+b+'" style="display:none"></div>');var c=jQuery.farbtastic("#"+b);c.linkTo(this),jQuery(this).popover({trigger:"manual",placement:"right",html:!0,content:jQuery("#"+b)}),jQuery(this).focus(function(){var a=jQuery(this).parent().find(".popover");0==a.length?(jQuery("#"+b).show(),jQuery(this).popover("show")):a.show()}).blur(function(){var a=jQuery(this).parent().find(".popover");a.length>0&&a.hide()}),a++})});var form_error_fields_selector="input.field_error[type=text], input.field_error[type=radio], span.checkbox_error input[type=checkbox], select.field_error, textarea.field_error, input.field_error[type=file]";jQuery(document).on("mouseover focus",form_error_fields_selector,function(){form_error_field_popover(this),0==jQuery(this).next("div.popover:visible").length&&jQuery(this).popover("show")}).on("mouseout mouseleave blur",form_error_fields_selector,function(){jQuery(this).is(":focus")||jQuery(this).popover("hide")});

0 comments on commit 256b591

Please sign in to comment.