|
|
@@ -84,6 +84,39 @@ 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
|
+ var positions = [
|
|
|
94
|
+ {side: 'top', gravity: 's'},
|
|
|
95
|
+ {side: 'left', gravity: 'e'},
|
|
|
96
|
+ {side: 'right', gravity: 'w'},
|
|
|
97
|
+ {side: 'bottom', gravity: 'n'},
|
|
|
98
|
+ {side: 'top-left', gravity: 'se'},
|
|
|
99
|
+ {side: 'top-right', gravity: 'sw'},
|
|
|
100
|
+ {side: 'bottom-left', gravity: 'ne'},
|
|
|
101
|
+ {side: 'bottom-right', gravity: 'nw'}
|
|
|
102
|
+ ];
|
|
|
103
|
+
|
|
|
104
|
+ function getTitle () {
|
|
|
105
|
+ return this.getAttribute('content');
|
|
|
106
|
+ }
|
|
|
107
|
+
|
|
|
108
|
+ positions.forEach(function (config) {
|
|
|
109
|
+ AJS.$('.tooltip-' + config.gravity).tooltip({
|
|
|
110
|
+ gravity: config.gravity,
|
|
|
111
|
+ title: getTitle,
|
|
|
112
|
+ html: true, // handle multiline tooltips
|
|
|
113
|
+ // two options to prevent tooltips from being stuck:
|
|
|
114
|
+ live: true, // attach listener to document element
|
|
|
115
|
+ hoverable: false // make custom tooltips to behave like native
|
|
|
116
|
+ });
|
|
|
117
|
+ });
|
|
|
118
|
+ },
|
|
|
119
|
+
|
|
87
|
120
|
/**
|
|
88
|
121
|
* Sets the tooltip to the given element.
|
|
89
|
122
|
*
|
|
|
@@ -103,13 +136,13 @@ import KeyboardShortcut from '../../keyboardshortcut/keyboardshortcut';
|
|
103
|
136
|
'top-right': 'sw'
|
|
104
|
137
|
};
|
|
105
|
138
|
|
|
106
|
|
- element.setAttribute("data-i18n", "[content]" + key);
|
|
107
|
|
- APP.translation.translateElement($(element));
|
|
|
139
|
+ $(element).each(function () {
|
|
|
140
|
+ var el = $(this);
|
|
|
141
|
+
|
|
|
142
|
+ el.addClass('tooltip-' + positions[position])
|
|
|
143
|
+ .attr("data-i18n", "[content]" + key);
|
|
108
|
144
|
|
|
109
|
|
- AJS.$(element).tooltip({
|
|
110
|
|
- gravity: positions[position],
|
|
111
|
|
- title: this._getTooltipText.bind(this, element),
|
|
112
|
|
- html: true
|
|
|
145
|
+ APP.translation.translateElement(el);
|
|
113
|
146
|
});
|
|
114
|
147
|
},
|
|
115
|
148
|
|