|
@@ -84,6 +84,30 @@ import KeyboardShortcut from '../../keyboardshortcut/keyboardshortcut';
|
84
|
84
|
context.putImageData(imgData, 0, 0);
|
85
|
85
|
},
|
86
|
86
|
|
|
87
|
+ /**
|
|
88
|
+ * Sets global handler for all tooltips. Once this function is invoked
|
|
89
|
+ * all you need to create new tooltip is to update DOM node with
|
|
90
|
+ * appropriate class (ex. "tooltip-n") and "content" attribute.
|
|
91
|
+ */
|
|
92
|
+ activateTooltips: function () {
|
|
93
|
+ function getTitle () {
|
|
94
|
+ return this.getAttribute('content');
|
|
95
|
+ }
|
|
96
|
+
|
|
97
|
+ function getGravity () {
|
|
98
|
+ return this.getAttribute('data-tooltip');
|
|
99
|
+ }
|
|
100
|
+
|
|
101
|
+ AJS.$('[data-tooltip]').tooltip({
|
|
102
|
+ gravity: getGravity,
|
|
103
|
+ title: getTitle,
|
|
104
|
+ html: true, // handle multiline tooltips
|
|
105
|
+ // two options to prevent tooltips from being stuck:
|
|
106
|
+ live: true, // attach listener to document element
|
|
107
|
+ hoverable: false // make custom tooltips to behave like native
|
|
108
|
+ });
|
|
109
|
+ },
|
|
110
|
+
|
87
|
111
|
/**
|
88
|
112
|
* Sets the tooltip to the given element.
|
89
|
113
|
*
|
|
@@ -103,13 +127,13 @@ import KeyboardShortcut from '../../keyboardshortcut/keyboardshortcut';
|
103
|
127
|
'top-right': 'sw'
|
104
|
128
|
};
|
105
|
129
|
|
106
|
|
- element.setAttribute("data-i18n", "[content]" + key);
|
107
|
|
- APP.translation.translateElement($(element));
|
|
130
|
+ $(element).each(function () {
|
|
131
|
+ var el = $(this);
|
|
132
|
+
|
|
133
|
+ el.attr("data-i18n", "[content]" + key)
|
|
134
|
+ .attr('data-tooltip', positions[position]);
|
108
|
135
|
|
109
|
|
- AJS.$(element).tooltip({
|
110
|
|
- gravity: positions[position],
|
111
|
|
- title: this._getTooltipText.bind(this, element),
|
112
|
|
- html: true
|
|
136
|
+ APP.translation.translateElement(el);
|
113
|
137
|
});
|
114
|
138
|
},
|
115
|
139
|
|