Blame view

framework/admin/javascript/LeftAndMain.FieldHelp.js 1.04 KB
70f4f18b   Administrator   first_commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
  (function($) {
  	$.entwine('ss', function($) {
  		/**
  		 * Converts an inline field description into a tooltip
  		 * which is shown on hover over any part of the field container,
  		 * as well as when focusing into an input element within the field container.
  		 *
  		 * Note that some fields don't have distinct focusable
  		 * input fields (e.g. GridField), and aren't compatible
  		 * with showing tooltips.
  		 */
  		$(".cms .field.cms-description-tooltip").entwine({
  			onmatch: function() {
  				this._super();
  
  				var descriptionEl = this.find('.description'), inputEl, tooltipEl;
  				if(descriptionEl.length) {
  					this
  						// TODO Remove title setting, shouldn't be necessary
  						.attr('title', descriptionEl.text())
  						.tooltip({content: descriptionEl.html()});
  					descriptionEl.remove();
  				}
  			},
  		});
  
  		$(".cms .field.cms-description-tooltip :input").entwine({
  			onfocusin: function(e) {
  				this.closest('.field').tooltip('open');
  			},
  			onfocusout: function(e) {
  				this.closest('.field').tooltip('close');
  				}
  		});
  
  		});
  }(jQuery));