From 16a7adc0d9526ee54e020f94bac4674512176032 Mon Sep 17 00:00:00 2001 From: Eike Foken Date: Thu, 18 Aug 2011 03:29:20 +0200 Subject: [PATCH] Add jTip --- application/views/header.php | 1 + assets/images/ajax-loader.gif | Bin 0 -> 1844 bytes assets/images/arrow-left.gif | Bin 0 -> 102 bytes assets/images/arrow-right.gif | Bin 0 -> 102 bytes assets/js/jtip.js | 158 ++++++++++++++++++++++++++++++++++ 5 files changed, 159 insertions(+) create mode 100644 assets/images/ajax-loader.gif create mode 100644 assets/images/arrow-left.gif create mode 100644 assets/images/arrow-right.gif create mode 100644 assets/js/jtip.js diff --git a/application/views/header.php b/application/views/header.php index 0eda012..964f0a8 100644 --- a/application/views/header.php +++ b/application/views/header.php @@ -14,6 +14,7 @@ + diff --git a/assets/images/ajax-loader.gif b/assets/images/ajax-loader.gif new file mode 100644 index 0000000000000000000000000000000000000000..b5ed0ce8000c0a90f7a51335622ba87c958f7c81 GIT binary patch literal 1844 zcmb8wZBSF$83*voz31lM+?V7KkqyW?Ap}iAV!~U9;@X=4g1}N>6?Stzmo29Ixgl#@qhQwXfH`Vb(_8(drriN@x6Dp z#L2?9Q)W6{lfzF`Ds8*Z> zz_aPQuw8oUYBC3TZ=IkPvazC68%Q4|&8lA`b^ieR*hxNF`BD zf2|d(KV}zewik-Oo!>m3ojaHoAA?d*?m&%FmPc21ebBBn7M5w;2T+zPlerzuS#|a# zL)|I{3&bqvGLzuLxFX36uktg3kPye}17B z5vLwswp}1^eqx%=l^@lS&WEQ@hA-~Yd@tdXv{D6J3V_LDG^Nt&AGT@^Dh+S<9XQfK zXZ3e>lp30Ky3@LqTtFbDdU-@*e=bt;hIhS>(zcFf#wQR={XnnH03yd|%WFBwXPCRc z4c_TWdwLg+hkm;D+uF4-{PEzkQOifn!mhnpab<-?f1B+ra9@h8`f(w!a6hTf&}bS= zKWKGVHb)(HAJz3AiCO{Rfq-T|;MXc2z#%1_-tZ|UbugK+W~(j9*U_03lny-zBXe2;7`w z)i6XU!6+16YJx;YczKOK)m66kwOApwrWgH^|aaVU+5;u+VAR> zYeESke?tWi@(B|mR4C*Off4T>D9h{x?c2&q1jI%`dQB49DO=SLftuxoUe=&W)gg&| zN;x6_-k4Y{iWLWqNq$*0c5jDyPb4q>*f~q1`2De`nc8;CRo$eAD`?s^j011N=T}l| z##*Cgg4;j)#wKPcehGo6BUmG!&+bRK7|;Y51{D&o#ZW}-5j8)}oQPH{RxMETP`*%y zTZCvx3CvLBqpO*7Q#Le-MS0#WZdC}B1j9^KeW~ewNAcSZK$`e|Z zG+%?`Ti`&948!)VYN$X>z5mrLXH#8#PWF%*%Y?PXzwp#D@dKv3;w3@i8vD|gFhR$M zi(to_k=n^RL#kfPr0g5+{W1jqQ$}v3HF#p)isbc!9;YFfv#o5pNeJ)=xvvl@QUXPQ>=nYN?f4T@Dyw_zycB~z?EKWD3o i##-Ul*quUH%0sE2R)D@^8`;{oWfbSvB>O+2<@yf6PyWet1_o;YKk+K% literal 0 HcmV?d00001 diff --git a/assets/js/jtip.js b/assets/js/jtip.js new file mode 100644 index 0000000..d023e8f --- /dev/null +++ b/assets/js/jtip.js @@ -0,0 +1,158 @@ +/* + * JTip + * By Cody Lindley (http://www.codylindley.com) + * Under an Attribution, Share Alike License + * JTip is built on top of the very light weight jquery library. + */ + +/** + * On page load (as soon as it's ready) call JT_init + */ +$(document).ready(JT_init); + +/** + * Initializes JTip. + */ +function JT_init() { + $('a.jTip').hover(function() { + JT_show(this.href, this.id, this.name); + }, function() { + $('#JT').remove(); + }).click(function() { + return false; + }); +} + +/** + * Shows a tooltip. + * + * @param url + * @param linkId + * @param title + */ +function JT_show(url, linkId, title) { + if (title == false) title = ' '; + + var de = document.documentElement; + var w = self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth; + var hasArea = w - getAbsoluteLeft(linkId); + + var clickElementY = getAbsoluteTop(linkId) - 3; // set y position + var clickElementX = 0; + + var queryString = url.replace(/^[^\?]+\??/,''); + var params = parseQuery(queryString); + + if (params['width'] === undefined) { + params['width'] = 250; + } + if (params['link'] !== undefined) { + $('#' + linkId).bind('click', function() { + window.location = params['link']; + }); + $('#' + linkId).css('cursor','pointer'); + } + + if (hasArea > (params['width'] * 1) + 75) { + $('body').append('
' + title + '
'); // right side + var arrowOffset = getElementWidth(linkId) + 11; + clickElementX = getAbsoluteLeft(linkId) + arrowOffset; // set x position + } else { + $('body').append('
' + title + '
'); // left side + clickElementX = getAbsoluteLeft(linkId) - ((params['width']*1) + 15); //set x position + } + + $('#JT').css({ left: clickElementX + 'px', top: clickElementY + 'px' }); + $('#JT').show(); + $('#JT_copy').load(url); +} + +/** + * Gets the width of the tooltip. + * + * @param objectId + * @returns + */ +function getElementWidth(objectId) { + x = document.getElementById(objectId); + return x.offsetWidth; +} + +/** + * No description yet. + * + * @param objectId + * @returns + */ +function getAbsoluteLeft(objectId) { + // get an object left position from the upper left viewport corner + o = document.getElementById(objectId); + // get left position from the parent object + oLeft = o.offsetLeft; + // parse the parent hierarchy up to the document element + while (o.offsetParent != null) { + oParent = o.offsetParent; // get parent object reference + oLeft += oParent.offsetLeft; // add parent left position + o = oParent; + } + return oLeft; +} + +/** + * No description yet. + * + * @param objectId + * @returns + */ +function getAbsoluteTop(objectId) { + // get an object top position from the upper left viewport corner + o = document.getElementById(objectId); + // get top position from the parent object + oTop = o.offsetTop; + // parse the parent hierarchy up to the document element + while (o.offsetParent != null) { + oParent = o.offsetParent; // get parent object reference + oTop += oParent.offsetTop; // add parent top position + o = oParent; + } + return oTop; +} + +/** + * No description yet. + * + * @param query + */ +function parseQuery(query) { + var params = new Object(); + if (!query) { + return params; // return empty object + } + var pairs = query.split(/[;&]/); + + for (var i = 0; i < pairs.length; i++) { + var keyValue = pairs[i].split('='); + if (!keyValue || keyValue.length != 2) { + continue; + } + var key = unescape(keyValue[0]); + var val = unescape(keyValue[1]); + + val = val.replace(/\+/g, ' '); + params[key] = val; + } + return params; +} + +/** + * No description yet. + * + * @param event + */ +function blockEvents(event) { + if (event.target) { + event.preventDefault(); + } else { + event.returnValue = false; + } +}