Некодим логотипНекодим
МодификацииПубликацииНекодИИмЦены
Некодим логотипНекодим

© 2020-2026 Некодим

Готовые модификации для вашего сайта. Улучшайте функциональность и дизайн без программирования.

Компания

  • Контакты
  • Публичная оферта
  • Политика конфиденциальности
  • Согласие на обработку данных
  • Лицензионное соглашение
  • Реферальная программа

Полезное

  • Модификации
  • Публикации
  • Каталог блоков Tilda
  • MCP для агентов
  • Журнал изменений
  • Доска почёта

Личный кабинет

  • Вход
  • Регистрация
  • Цены
Журнал измененийИстория GitФайлыTilda MCP
Каталог файлов

tilda-tooltip-1.0.js

Код файла
Версия от 18.08.2026, 07:00:16 МСК
Оригинал на CDNСнимок 56c3b845Полный текст
101		this.options.theme = this.options.theme.replace('.', '');102		// save events103		this.windowEvents = {};104		this.documentEvents = {};105		this.elementProxyEvents = {};106		// launch107		this._init();108	}109 110	Plugin.prototype = {111		_init: function () {112			var self = this;113
История файла и сравнение версий
  • 18.08.2026, 07:00:16 · 56c3b845
114 // disable the plugin on old browsers (including IE7 and lower)
115 if (document.querySelector) {
116 // note : the content is null (empty) by default and can stay that way if the plugin remains initialized but not fed any content. The tooltip will just not appear.
117 // let's save the initial value of the title attribute for later restoration if need be.
118 var initialTitle = null;
119 // it will already have been saved in case of multiple tooltips
120 if (!self.element['tooltipster-initialTitle']) {
121 initialTitle = self.element.getAttribute('title');
122
123 // we do not want initialTitle to have the value "undefined" because of how jQuery's .data() method works
124 if (!initialTitle) initialTitle = null;
125
126 self.element['tooltipster-initialTitle'] = initialTitle;
127 }
128
129 // if content is provided in the options, its has precedence over the title attribute.
130 // Note : an empty string is considered content, only 'null' represents the absence of content.
131 // Also, an existing title="" attribute will result in an empty string content
132 if (self.options.content !== null) {
133 self._content_set(self.options.content);
134 } else {
135 self._content_set(initialTitle);
136 }
137
138 var customFunction = self.options.functionInit.call(self.element, self.element, self.Content);
139
140 if (typeof customFunction !== 'undefined') self._content_set(customFunction);
141
142 // strip the title off of the element to prevent the default tooltips from popping up
143 self.element.removeAttribute('title');
144 // to be able to find all instances on the page later (upon window events in particular)
145 t_addClass(self.element, 'tooltipstered');
146
147 // a11y added aria-label in tooltip trigger for screen readers
148 var tooltipText = '';
149 if (self.Content) {
150 tooltipText = self.Content.replace(/(\<(\/?[^>]+)>)/g, '');
151 }
152 self.element.setAttribute('aria-label', tooltipText);
153
154 // detect if we're changing the tooltip origin to an icon
155 // note about this condition : if the device has touch capability and self.options.iconTouch is false, you'll have no icons event though you may consider your device as a desktop if it also has a mouse. Not sure why someone would have this use case though.
156 if (
157 (!deviceHasTouchCapability && self.options.iconDesktop) ||
158 (deviceHasTouchCapability && self.options.iconTouch)
159 ) {
160 // Until it's done, the icon feature does not really make sense since the user still has most of the work to do by himself
161 // if the icon provided is in the form of a string
162 if (typeof self.options.icon === 'string') {
163 // wrap it in a span with the icon class
164 self.elementProxy = document.createElement('span');
165 t_addClass(self.elementProxy, self.options.iconTheme);
166 self.elementProxy.textContent = self.options.icon;
167 } else {
168 // if it is an object (sensible choice)
169 // (deep) clone the object if iconCloning == true, to make sure every instance has its own proxy. We use the icon without wrapping, no need to. We do not give it a class either, as the user will undoubtedly style the object on his own and since our css properties may conflict with his own
170 if (self.options.iconCloning) {
171 self.elementProxy = self.options.icon.cloneNode(true);
172 } else {
173 self.elementProxy = self.options.icon;
174 }
175 }
176
177 self.elementProxy.appendChild(self.element);
178 } else {
179 self.elementProxy = self.element;
180 }
181
182 // for 'click' and 'hover' triggers : bind on events to open the tooltip. Closing is now handled in _showNow() because of its bindings.
183 // Notes about touch events :
184 // - mouseenter, mouseleave and clicks happen even on pure touch devices because they are emulated. deviceIsPureTouch() is a simple attempt to detect them.
185 // - on hybrid devices, we do not prevent touch gesture from opening tooltips. It would be too complex to differentiate real mouse events from emulated ones.
186 // - we check deviceIsPureTouch() at each event rather than prior to binding because the situation may change during browsing
187 if (self.options.trigger === 'hover') {
188 // these binding are for mouse interaction only
189 /**
190 * Save call event mouseenter for later removal
191 */
192 function elementProxyMouseEnter() {
193 if (!deviceIsPureTouch() || self.options.touchDevices) {
194 self.mouseIsOverProxy = true;
195 self._show();
196 }
197 }
198
199 /**
200 * Save call event mouseleave for later removal
Предыдущие 100 строкСледующие 100 строк