tooltip_js

   Usages of this macro
... in ui_components.naml
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
<macro name="tooltip_js">
    <script type="text/javascript">
        <![CDATA[
        Nabble.startTooltip = function(e, position, delay) {
            if (e.nabbletooltip)
                return;
            e.nabbletooltip = true;
            var $this = $(e);
            var $arrow = $this.children().last();
            var $elem = $this.prev();
            $elem.hover(
                function() {
                    setTip();
                    setTimer();
                },
                function() {
                    stopTimer();
                    $this.hide();
                }
            );
            function setTimer() {
                $this.showTipTimer = setTimeout(function() {
                    $('div.nabble-tooltip').hide();
                    stopTimer();
                    $this.fadeTo('fast', .8);
                }, delay);
            };
            function stopTimer() {
                clearInterval($this.showTipTimer);
            };
            function setTip(){
                if ($this.parent().get() != document.body)
                    $(document.body).append($this);
                var useTitle = $this.attr('use_title') == 'true';
                if (useTitle) {
                    var title = $elem.attr('title');
                    if (title != '') {
                        $arrow.remove();
                        $this.html(title);
                        $elem.attr('title','');
                        $this.append($arrow);
                    }
                }
                var win = $(window).width();
                if (position == 'up') {
                    var w = $this.outerWidth();
                    if (w > 250) {
                        w = 250;
                        $this.width(w);
                    }
                    var xMid = $elem.offset().left + $elem.outerWidth()/2;
                    var xTip = xMid - w/2;
                    if (xTip+w > win-5)
                        xTip = win-w-5;
                    if (xTip < 0)
                        xTip = 0;
                    var xArrow = xMid-xTip-11;
                    var yTip = $elem.offset().top-$this.outerHeight()-12;
                    $arrow.css('left', xArrow);
                    $this.css({'top' : yTip, 'left' : xTip});
                } else if (position == 'right') {
                    var h = $this.outerHeight();
                    var yMid = $elem.offset().top + $elem.outerHeight()/2;
                    var yTip = yMid - h/2;
                    var xTip = $elem.offset().left + $elem.outerWidth() + 10;
                    $arrow.width(8).height(24).css({bottom:0,left:-8});
                    var yArrow = (h - 24)/2;
                    $arrow.css({top:yArrow});
                    var $d1 = $arrow.children().first();
                    var $d2 = $arrow.children().last();
                    $d1.css({top:-11});
                    $d2.css({top:-11,left:1});
                    $this.css({'top' : yTip, 'left' : xTip});
                }
            };
        };
        ]]>
    </script>
</macro>