// Prototip 1.2.0_pre1 - 17-12-2007 // Copyright (c) 2007 Nick Stakenburg (http://www.nickstakenburg.com) // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // More information on this project: // http://www.nickstakenburg.com/projects/prototip/ var Prototip = { Version: '1.2.0_pre1', REQUIRED_Prototype: '1.6.0', REQUIRED_Scriptaculous: '1.8.0', start: function() { this.require('Prototype'); Tips.initialize(); Element.observe(window, 'unload', this.unload); }, require: function(library) { if ((typeof window[library] == 'undefined') || (this.convertVersionString(window[library].Version) < this.convertVersionString(this['REQUIRED_' + library]))) throw('Prototip requires ' + library + ' >= ' + this['REQUIRED_' + library]); }, convertVersionString: function(versionString) { var r = versionString.split('.'); return parseInt(r[0])*100000 + parseInt(r[1])*1000 + parseInt(r[2]); }, viewport: { getDimensions: function() { var dimensions = { }; var B = Prototype.Browser; $w('width height').each(function(d) { var D = d.capitalize(); dimensions[d] = (B.WebKit && !document.evaluate) ? self['inner' + D] : (B.Opera) ? document.body['client' + D] : document.documentElement['client' + D]; }); return dimensions; } }, capture: function(func) { if (!Prototype.Browser.IE) { func = func.wrap(function(proceed, event) { var rel = event.relatedTarget, cur = event.currentTarget; if (rel && rel.nodeType == Node.TEXT_NODE) rel = rel.parentNode; if (rel && rel != cur && rel.descendantOf && !(rel.descendantOf(cur))) proceed(event); }); } return func; }, unload: function() { Tips.removeAll(); } }; var Tips = { // Configuration closeButtons: false, zIndex: 1200, tips : [], visible : [], initialize: function() { this.zIndexTop = this.zIndex; }, useEvent : (function(IE) { return { 'mouseover': (IE ? 'mouseenter' : 'mouseover'), 'mouseout': (IE ? 'mouseleave' : 'mouseout'), 'mouseenter': (IE ? 'mouseenter' : 'mouseover'), 'mouseleave': (IE ? 'mouseleave' : 'mouseout') };})(Prototype.Browser.IE), fixIE: (function(agent) { var version = new RegExp('MSIE ([\\d.]+)').exec(agent); return version ? (parseFloat(version[1]) <= 6) : false; })(navigator.userAgent), add: function(tip) { this.tips.push(tip); }, remove: function(element) { var tip = this.tips.find(function(t){ return t.element == $(element); }); if (tip) { tip.deactivate(); if (tip.tooltip) { tip.wrapper.remove(); if (Tips.fixIE) tip.iframeShim.remove(); } this.tips = this.tips.without(tip); } }, removeAll: function() { this.tips.each(function(tip) { this.remove(tip.element); }.bind(this)); }, raise: function(tip) { if (tip.highest) return; if (this.visible.length == 0) { this.zIndexTop = this.zIndex; for (var i=0;i viewport[pair[z]]) pos[z] = pos[z] - tipd[pair[z]] - 2*offset[z]; } } var setPos = { left: pos.left + 'px', top: pos.top + 'px' }; this.wrapper.setStyle(setPos); if (Tips.fixIE) this.iframeShim.setStyle(setPos); } }); Prototip.start();