wp/wp-includes/js/wp-pointer.js
author ymh <ymh.work@gmail.com>
Mon, 14 Oct 2019 18:28:13 +0200
changeset 9 177826044cd9
parent 7 cf61fcea0001
child 16 a86126ab1dd4
permissions -rw-r--r--
upgrade wordpress to 5.2.3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
/**
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
     2
 * @output wp-includes/js/wp-pointer.js
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
     3
 */
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
     4
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
     5
/* global wpPointerL10n */
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
     6
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
     7
/**
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
     8
 * Initializes the wp-pointer widget using jQuery UI Widget Factory.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    10
(function($){
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    11
	var identifier = 0,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    12
		zindex = 9999;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    13
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    14
	$.widget('wp.pointer',/** @lends $.widget.wp.pointer.prototype */{
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    15
		options: {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    16
			pointerClass: 'wp-pointer',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    17
			pointerWidth: 320,
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    18
			content: function() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    19
				return $(this).text();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    20
			},
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    21
			buttons: function( event, t ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    22
				var close  = ( wpPointerL10n ) ? wpPointerL10n.dismiss : 'Dismiss',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    23
					button = $('<a class="close" href="#">' + close + '</a>');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    24
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    25
				return button.bind( 'click.pointer', function(e) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    26
					e.preventDefault();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    27
					t.element.pointer('close');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    28
				});
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    29
			},
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    30
			position: 'top',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    31
			show: function( event, t ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    32
				t.pointer.show();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    33
				t.opened();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    34
			},
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    35
			hide: function( event, t ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    36
				t.pointer.hide();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    37
				t.closed();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    38
			},
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    39
			document: document
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    40
		},
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    41
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    42
		/**
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    43
		 * A class that represents a WordPress pointer.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    44
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    45
		 * @since 3.3.0
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    46
		 * @private
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    47
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    48
		 * @constructs $.widget.wp.pointer
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    49
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    50
		_create: function() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    51
			var positioning,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    52
				family;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    53
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    54
			this.content = $('<div class="wp-pointer-content"></div>');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    55
			this.arrow   = $('<div class="wp-pointer-arrow"><div class="wp-pointer-arrow-inner"></div></div>');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    56
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    57
			family = this.element.parents().add( this.element );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    58
			positioning = 'absolute';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    59
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    60
			if ( family.filter(function(){ return 'fixed' === $(this).css('position'); }).length )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    61
				positioning = 'fixed';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    62
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    63
			this.pointer = $('<div />')
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    64
				.append( this.content )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    65
				.append( this.arrow )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    66
				.attr('id', 'wp-pointer-' + identifier++)
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    67
				.addClass( this.options.pointerClass )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    68
				.css({'position': positioning, 'width': this.options.pointerWidth+'px', 'display': 'none'})
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    69
				.appendTo( this.options.document.body );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    70
		},
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    71
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    72
		/**
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    73
		 * Sets an option on the pointer instance.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    74
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    75
		 * There are 4 special values that do something extra:
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    76
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    77
		 * - `document`     will transfer the pointer to the body of the new document
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    78
		 *                  specified by the value.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    79
		 * - `pointerClass` will change the class of the pointer element.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    80
		 * - `position`     will reposition the pointer.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    81
		 * - `content`      will update the content of the pointer.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    82
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    83
		 * @since 3.3.0
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    84
		 * @private
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    85
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    86
		 * @param {string} key   The key of the option to set.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    87
		 * @param {*}      value The value to set the option to.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    88
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    89
		_setOption: function( key, value ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    90
			var o   = this.options,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    91
				tip = this.pointer;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    92
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    93
			// Handle document transfer
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    94
			if ( key === 'document' && value !== o.document ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    95
				tip.detach().appendTo( value.body );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    96
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    97
			// Handle class change
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    98
			} else if ( key === 'pointerClass' ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    99
				tip.removeClass( o.pointerClass ).addClass( value );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   100
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   101
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   102
			// Call super method.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   103
			$.Widget.prototype._setOption.apply( this, arguments );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   104
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   105
			// Reposition automatically
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   106
			if ( key === 'position' ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   107
				this.reposition();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   108
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   109
			// Update content automatically if pointer is open
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   110
			} else if ( key === 'content' && this.active ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   111
				this.update();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   112
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   113
		},
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   114
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   115
		/**
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   116
		 * Removes the pointer element from of the DOM.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   117
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   118
		 * Makes sure that the widget and all associated bindings are destroyed.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   119
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   120
		 * @since 3.3.0
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   121
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   122
		destroy: function() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   123
			this.pointer.remove();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   124
			$.Widget.prototype.destroy.call( this );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   125
		},
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   126
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   127
		/**
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   128
		 * Returns the pointer element.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   129
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   130
		 * @since 3.3.0
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   131
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   132
		 * @return {Object} Pointer The pointer object.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   133
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   134
		widget: function() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   135
			return this.pointer;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   136
		},
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   137
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   138
		/**
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   139
		 * Updates the content of the pointer.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   140
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   141
		 * This function doesn't update the content of the pointer itself. That is done
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   142
		 * by the `_update` method. This method will make sure that the `_update` method
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   143
		 * is called with the right content.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   144
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   145
		 * The content in the options can either be a string or a callback. If it is a
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   146
		 * callback the result of this callback is used as the content.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   147
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   148
		 * @since 3.3.0
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   149
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   150
		 * @param {Object} event The event that caused the update.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   151
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   152
		 * @return {Promise} Resolves when the update has been executed.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   153
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   154
		update: function( event ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   155
			var self = this,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   156
				o    = this.options,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   157
				dfd  = $.Deferred(),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   158
				content;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   159
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   160
			if ( o.disabled )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   161
				return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   162
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   163
			dfd.done( function( content ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   164
				self._update( event, content );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   165
			});
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   166
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   167
			// Either o.content is a string...
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   168
			if ( typeof o.content === 'string' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   169
				content = o.content;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   170
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   171
			// ...or o.content is a callback.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   172
			} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   173
				content = o.content.call( this.element[0], dfd.resolve, event, this._handoff() );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   174
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   175
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   176
			// If content is set, then complete the update.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   177
			if ( content )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   178
				dfd.resolve( content );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   179
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   180
			return dfd.promise();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   181
		},
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   182
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   183
		/**
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   184
		 * Updates the content of the pointer.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   185
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   186
		 * Will make sure that the pointer is correctly positioned.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   187
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   188
		 * @since 3.3.0
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   189
		 * @private
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   190
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   191
		 * @param {Object} event   The event that caused the update.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   192
		 * @param {*}      content The content object. Either a string or a jQuery tree.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   193
		 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   194
		_update: function( event, content ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   195
			var buttons,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   196
				o = this.options;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   197
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   198
			if ( ! content )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   199
				return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   200
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   201
			// Kill any animations on the pointer.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   202
			this.pointer.stop();
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   203
			this.content.html( content );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   204
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   205
			buttons = o.buttons.call( this.element[0], event, this._handoff() );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   206
			if ( buttons ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   207
				buttons.wrap('<div class="wp-pointer-buttons" />').parent().appendTo( this.content );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   208
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   209
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   210
			this.reposition();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   211
		},
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   212
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   213
		/**
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   214
		 * Repositions the pointer.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   215
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   216
		 * Makes sure the pointer is the correct size for its content and makes sure it
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   217
		 * is positioned to point to the right element.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   218
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   219
		 * @since 3.3.0
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   220
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   221
		reposition: function() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   222
			var position;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   223
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   224
			if ( this.options.disabled )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   225
				return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   226
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   227
			position = this._processPosition( this.options.position );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   228
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   229
			// Reposition pointer.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   230
			this.pointer.css({
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   231
				top: 0,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   232
				left: 0,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   233
				zIndex: zindex++ // Increment the z-index so that it shows above other opened pointers.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   234
			}).show().position($.extend({
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   235
				of: this.element,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   236
				collision: 'fit none'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   237
			}, position )); // the object comes before this.options.position so the user can override position.of.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   238
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   239
			this.repoint();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   240
		},
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   241
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   242
		/**
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   243
		 * Sets the arrow of the pointer to the correct side of the pointer element.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   244
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   245
		 * @since 3.3.0
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   246
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   247
		repoint: function() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   248
			var o = this.options,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   249
				edge;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   250
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   251
			if ( o.disabled )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   252
				return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   253
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   254
			edge = ( typeof o.position == 'string' ) ? o.position : o.position.edge;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   255
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   256
			// Remove arrow classes.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   257
			this.pointer[0].className = this.pointer[0].className.replace( /wp-pointer-[^\s'"]*/, '' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   258
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   259
			// Add arrow class.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   260
			this.pointer.addClass( 'wp-pointer-' + edge );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   261
		},
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   262
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   263
		/**
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   264
		 * Calculates the correct position based on a position in the settings.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   265
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   266
		 * @since 3.3.0
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   267
		 * @private
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   268
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   269
		 * @param {string|Object} position Either a side of a pointer or an object
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   270
		 *                                 containing a pointer.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   271
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   272
		 * @return {Object} result  An object containing position related data.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   273
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   274
		_processPosition: function( position ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   275
			var opposite = {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   276
					top: 'bottom',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   277
					bottom: 'top',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   278
					left: 'right',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   279
					right: 'left'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   280
				},
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   281
				result;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   282
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   283
			// If the position object is a string, it is shorthand for position.edge.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   284
			if ( typeof position == 'string' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   285
				result = {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   286
					edge: position + ''
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   287
				};
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   288
			} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   289
				result = $.extend( {}, position );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   290
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   291
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   292
			if ( ! result.edge )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   293
				return result;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   294
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   295
			if ( result.edge == 'top' || result.edge == 'bottom' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   296
				result.align = result.align || 'left';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   297
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   298
				result.at = result.at || result.align + ' ' + opposite[ result.edge ];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   299
				result.my = result.my || result.align + ' ' + result.edge;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   300
			} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   301
				result.align = result.align || 'top';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   302
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   303
				result.at = result.at || opposite[ result.edge ] + ' ' + result.align;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   304
				result.my = result.my || result.edge + ' ' + result.align;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   305
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   306
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   307
			return result;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   308
		},
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   309
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   310
		/**
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   311
		 * Opens the pointer.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   312
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   313
		 * Only opens the pointer widget in case it is closed and not disabled, and
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   314
		 * calls 'update' before doing so. Calling update makes sure that the pointer
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   315
		 * is correctly sized and positioned.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   316
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   317
		 * @since 3.3.0
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   318
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   319
		 * @param {Object} event The event that triggered the opening of this pointer.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   320
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   321
		open: function( event ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   322
			var self = this,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   323
				o    = this.options;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   324
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   325
			if ( this.active || o.disabled || this.element.is(':hidden') )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   326
				return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   327
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   328
			this.update().done( function() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   329
				self._open( event );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   330
			});
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   331
		},
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   332
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   333
		/**
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   334
		 * Opens and shows the pointer element.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   335
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   336
		 * @since 3.3.0
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   337
		 * @private
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   338
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   339
		 * @param {Object} event An event object.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   340
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   341
		_open: function( event ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   342
			var self = this,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   343
				o    = this.options;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   344
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   345
			if ( this.active || o.disabled || this.element.is(':hidden') )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   346
				return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   347
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   348
			this.active = true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   349
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   350
			this._trigger( 'open', event, this._handoff() );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   351
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   352
			this._trigger( 'show', event, this._handoff({
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   353
				opened: function() {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   354
					self._trigger( 'opened', event, self._handoff() );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   355
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   356
			}));
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   357
		},
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   358
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   359
		/**
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   360
		 * Closes and hides the pointer element.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   361
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   362
		 * @since 3.3.0
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   363
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   364
		 * @param {Object} event An event object.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   365
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   366
		close: function( event ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   367
			if ( !this.active || this.options.disabled )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   368
				return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   369
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   370
			var self = this;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   371
			this.active = false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   372
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   373
			this._trigger( 'close', event, this._handoff() );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   374
			this._trigger( 'hide', event, this._handoff({
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   375
				closed: function() {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   376
					self._trigger( 'closed', event, self._handoff() );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   377
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   378
			}));
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   379
		},
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   380
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   381
		/**
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   382
		 * Puts the pointer on top by increasing the z-index.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   383
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   384
		 * @since 3.3.0
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   385
		 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   386
		sendToTop: function() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   387
			if ( this.active )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   388
				this.pointer.css( 'z-index', zindex++ );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   389
		},
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   390
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   391
		/**
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   392
		 * Toggles the element between shown and hidden.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   393
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   394
		 * @since 3.3.0
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   395
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   396
		 * @param {Object} event An event object.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   397
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   398
		toggle: function( event ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   399
			if ( this.pointer.is(':hidden') )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   400
				this.open( event );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   401
			else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   402
				this.close( event );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   403
		},
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   404
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   405
		/**
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   406
		 * Extends the pointer and the widget element with the supplied parameter, which
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   407
		 * is either an element or a function.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   408
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   409
		 * @since 3.3.0
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   410
		 * @private
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   411
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   412
		 * @param {Object} extend The object to be merged into the original object.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   413
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   414
		 * @return {Object} The extended object.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   415
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   416
		_handoff: function( extend ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   417
			return $.extend({
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   418
				pointer: this.pointer,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   419
				element: this.element
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   420
			}, extend);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   421
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   422
	});
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   423
})(jQuery);