mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-27 03:27:46 +01:00
d686fa266b
This removes the usage of `wp_localize_script()` for passing translations to the script and instead adds the translatable strings in the script directly through the use of `wp.i18n` and its utilities. Props swissspidy, ocean90. See #20491. Fixes #50525. Built from https://develop.svn.wordpress.org/trunk@48266 git-svn-id: http://core.svn.wordpress.org/trunk@48035 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2 lines
3.5 KiB
JavaScript
2 lines
3.5 KiB
JavaScript
/*! This file is auto-generated */
|
|
!function(s){var i=0,e=9999;s.widget("wp.pointer",{options:{pointerClass:"wp-pointer",pointerWidth:320,content:function(){return s(this).text()},buttons:function(t,i){return s('<a class="close" href="#"></a>').text(wp.i18n.__("Dismiss")).bind("click.pointer",function(t){t.preventDefault(),i.element.pointer("close")})},position:"top",show:function(t,i){i.pointer.show(),i.opened()},hide:function(t,i){i.pointer.hide(),i.closed()},document:document},_create:function(){var t;this.content=s('<div class="wp-pointer-content"></div>'),this.arrow=s('<div class="wp-pointer-arrow"><div class="wp-pointer-arrow-inner"></div></div>'),t="absolute",this.element.parents().add(this.element).filter(function(){return"fixed"===s(this).css("position")}).length&&(t="fixed"),this.pointer=s("<div />").append(this.content).append(this.arrow).attr("id","wp-pointer-"+i++).addClass(this.options.pointerClass).css({position:t,width:this.options.pointerWidth+"px",display:"none"}).appendTo(this.options.document.body)},_setOption:function(t,i){var e=this.options,n=this.pointer;"document"===t&&i!==e.document?n.detach().appendTo(i.body):"pointerClass"===t&&n.removeClass(e.pointerClass).addClass(i),s.Widget.prototype._setOption.apply(this,arguments),"position"===t?this.reposition():"content"===t&&this.active&&this.update()},destroy:function(){this.pointer.remove(),s.Widget.prototype.destroy.call(this)},widget:function(){return this.pointer},update:function(i){var t,e=this,n=this.options,o=s.Deferred();if(!n.disabled)return o.done(function(t){e._update(i,t)}),(t="string"==typeof n.content?n.content:n.content.call(this.element[0],o.resolve,i,this._handoff()))&&o.resolve(t),o.promise()},_update:function(t,i){var e,n=this.options;i&&(this.pointer.stop(),this.content.html(i),(e=n.buttons.call(this.element[0],t,this._handoff()))&&e.wrap('<div class="wp-pointer-buttons" />').parent().appendTo(this.content),this.reposition())},reposition:function(){var t;this.options.disabled||(t=this._processPosition(this.options.position),this.pointer.css({top:0,left:0,zIndex:e++}).show().position(s.extend({of:this.element,collision:"fit none"},t)),this.repoint())},repoint:function(){var t,i=this.options;i.disabled||(t="string"==typeof i.position?i.position:i.position.edge,this.pointer[0].className=this.pointer[0].className.replace(/wp-pointer-[^\s'"]*/,""),this.pointer.addClass("wp-pointer-"+t))},_processPosition:function(t){var i,e={top:"bottom",bottom:"top",left:"right",right:"left"};return(i="string"==typeof t?{edge:t+""}:s.extend({},t)).edge&&("top"==i.edge||"bottom"==i.edge?(i.align=i.align||"left",i.at=i.at||i.align+" "+e[i.edge],i.my=i.my||i.align+" "+i.edge):(i.align=i.align||"top",i.at=i.at||e[i.edge]+" "+i.align,i.my=i.my||i.edge+" "+i.align)),i},open:function(t){var i=this,e=this.options;this.active||e.disabled||this.element.is(":hidden")||this.update().done(function(){i._open(t)})},_open:function(t){var i=this,e=this.options;this.active||e.disabled||this.element.is(":hidden")||(this.active=!0,this._trigger("open",t,this._handoff()),this._trigger("show",t,this._handoff({opened:function(){i._trigger("opened",t,i._handoff())}})))},close:function(t){if(this.active&&!this.options.disabled){var i=this;this.active=!1,this._trigger("close",t,this._handoff()),this._trigger("hide",t,this._handoff({closed:function(){i._trigger("closed",t,i._handoff())}}))}},sendToTop:function(){this.active&&this.pointer.css("z-index",e++)},toggle:function(t){this.pointer.is(":hidden")?this.open(t):this.close(t)},_handoff:function(t){return s.extend({pointer:this.pointer,element:this.element},t)}})}(jQuery); |