equal
deleted
inserted
replaced
1 /** |
1 /** |
2 * @output wp-includes/js/wp-pointer.js |
2 * @output wp-includes/js/wp-pointer.js |
3 */ |
3 */ |
4 |
|
5 /* global wpPointerL10n */ |
|
6 |
4 |
7 /** |
5 /** |
8 * Initializes the wp-pointer widget using jQuery UI Widget Factory. |
6 * Initializes the wp-pointer widget using jQuery UI Widget Factory. |
9 */ |
7 */ |
10 (function($){ |
8 (function($){ |
17 pointerWidth: 320, |
15 pointerWidth: 320, |
18 content: function() { |
16 content: function() { |
19 return $(this).text(); |
17 return $(this).text(); |
20 }, |
18 }, |
21 buttons: function( event, t ) { |
19 buttons: function( event, t ) { |
22 var close = ( wpPointerL10n ) ? wpPointerL10n.dismiss : 'Dismiss', |
20 var button = $('<a class="close" href="#"></a>').text( wp.i18n.__( 'Dismiss' ) ); |
23 button = $('<a class="close" href="#">' + close + '</a>'); |
|
24 |
21 |
25 return button.bind( 'click.pointer', function(e) { |
22 return button.bind( 'click.pointer', function(e) { |
26 e.preventDefault(); |
23 e.preventDefault(); |
27 t.element.pointer('close'); |
24 t.element.pointer('close'); |
28 }); |
25 }); |
88 */ |
85 */ |
89 _setOption: function( key, value ) { |
86 _setOption: function( key, value ) { |
90 var o = this.options, |
87 var o = this.options, |
91 tip = this.pointer; |
88 tip = this.pointer; |
92 |
89 |
93 // Handle document transfer |
90 // Handle document transfer. |
94 if ( key === 'document' && value !== o.document ) { |
91 if ( key === 'document' && value !== o.document ) { |
95 tip.detach().appendTo( value.body ); |
92 tip.detach().appendTo( value.body ); |
96 |
93 |
97 // Handle class change |
94 // Handle class change. |
98 } else if ( key === 'pointerClass' ) { |
95 } else if ( key === 'pointerClass' ) { |
99 tip.removeClass( o.pointerClass ).addClass( value ); |
96 tip.removeClass( o.pointerClass ).addClass( value ); |
100 } |
97 } |
101 |
98 |
102 // Call super method. |
99 // Call super method. |
103 $.Widget.prototype._setOption.apply( this, arguments ); |
100 $.Widget.prototype._setOption.apply( this, arguments ); |
104 |
101 |
105 // Reposition automatically |
102 // Reposition automatically. |
106 if ( key === 'position' ) { |
103 if ( key === 'position' ) { |
107 this.reposition(); |
104 this.reposition(); |
108 |
105 |
109 // Update content automatically if pointer is open |
106 // Update content automatically if pointer is open. |
110 } else if ( key === 'content' && this.active ) { |
107 } else if ( key === 'content' && this.active ) { |
111 this.update(); |
108 this.update(); |
112 } |
109 } |
113 }, |
110 }, |
114 |
111 |
232 left: 0, |
229 left: 0, |
233 zIndex: zindex++ // Increment the z-index so that it shows above other opened pointers. |
230 zIndex: zindex++ // Increment the z-index so that it shows above other opened pointers. |
234 }).show().position($.extend({ |
231 }).show().position($.extend({ |
235 of: this.element, |
232 of: this.element, |
236 collision: 'fit none' |
233 collision: 'fit none' |
237 }, position )); // the object comes before this.options.position so the user can override position.of. |
234 }, position )); // The object comes before this.options.position so the user can override position.of. |
238 |
235 |
239 this.repoint(); |
236 this.repoint(); |
240 }, |
237 }, |
241 |
238 |
242 /** |
239 /** |