source: trunk/www.guidonia.net/wp/wp-content/plugins/odlinks/includes/previewbubble.js@ 44

Last change on this file since 44 was 44, checked in by luciano, 15 years ago
File size: 6.3 KB
Line 
1/*
2 WebSnapr - Preview Bubble Javascript
3 Written by Juan Xavier Larrea
4 http://www.websnapr.com - xavier@websnapr.com
5
6*/
7
8// DO NOT EDIT BENEATH THIS
9if(typeof Array.prototype.push!="function"){
10 Array.prototype.push=ArrayPush;
11 function ArrayPush(_1){
12 this[this.length]=_1;
13 }
14}
15function WSR_getElementsByClassName(_2,_3,_4){
16 var _5=(_3=="*"&&_2.all)?_2.all:_2.getElementsByTagName(_3);
17 var _6=new Array();
18 _4=_4.replace(/\-/g,"\\-");
19 var _7=new RegExp("(^|\\s)"+_4+"(\\s|$)");
20 var _8;
21 for(var i=0;i<_5.length;i++){
22 _8=_5[i];
23 if(_7.test(_8.className)){
24 _6.push(_8);
25 }
26 }
27 return (_6);
28}
29function bindBubbles(e){
30 lbActions=WSR_getElementsByClassName(document,"a","previewlink");
31 for(i=0;i<lbActions.length;i++){
32 if(window.addEventListener){
33 lbActions[i].addEventListener("mouseover",attachBubble,false);
34 lbActions[i].addEventListener("mouseout",detachBubble,false);
35 }else{
36 lbActions[i].attachEvent("onmouseover",attachBubble);
37 lbActions[i].attachEvent("onmouseout",detachBubble);
38 }
39 }
40}
41function attachBubble(_b){
42 var _c;
43 if(_b["srcElement"]){
44 _c=_b["srcElement"];
45 }else{
46 _c=_b["target"];
47 }
48 var _d=_c.href;
49 var _e=findPos(_c)[0]+5;
50 var _f=findPos(_c)[1]+17;
51 var _10=document.createElement("div");
52 document.getElementsByTagName("body")[0].appendChild(_10);
53 _10.className="previewbubble";
54 if (BrowserDetect.browser == 'Explorer') {
55 _10.style.width="240px";
56 _10.style.position="absolute";
57 _10.style.top=_f;
58 _10.style.zIndex=99999;
59 _10.style.left=_e;
60 _10.style.textAlign="left";
61 _10.style.height="190px";
62 _10.style.paddingTop="0";
63 _10.style.paddingLeft="0";
64 _10.style.paddingBottom="0";
65 _10.style.paddingRight="0";
66 _10.style.marginTop="0";
67 _10.style.marginLeft="0";
68 _10.style.marginBottom="0";
69 _10.style.marginRight="0";
70 _10.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + bubbleImagePath + "',sizingMethod='image')";
71 } else {
72 _10.setAttribute("style","text-align: center; z-index: 99999; position: absolute; top: "+_f+"px ; left: "+_e+"px ; background: url("+ bubbleImagePath +") no-repeat; width: 240px; height: 190px; padding: 0; margin: 0;");
73 }
74 if (BrowserDetect.browser == 'Safari' || BrowserDetect.browser == 'Konqueror' ) {
75 var _height = _f;
76 _10.setAttribute("style","text-align: center; z-index: 99999; position: absolute; top: "+ _height +"px ; left: "+_e+"px ; background: url("+ bubbleImagePath +") no-repeat; width: 240px; height: 190px; padding: 0; margin: 0;");
77 }
78 var img=document.createElement("img");
79 _10.appendChild(img);
80 if (BrowserDetect.browser == 'Explorer') {
81 img.style.paddingTop="0";
82 img.style.paddingLeft="0";
83 img.style.paddingBottom="0";
84 img.style.paddingRight="0";
85 img.style.margin="auto";
86 img.style.marginTop="27px";
87 img.style.marginLeft="25px";
88 img.style.marginBottom="0";
89 img.style.marginRight="0";
90 img.style.borderTop="0";
91 img.style.borderLeft="0";
92 img.style.borderBottom="0";
93 img.style.borderRight="0";
94 } else {
95 img.setAttribute("style","padding-top: 0; padding-left: 0; padding-right: 0; padding-bottom: 0; margin-top: 27px; margin-left: 12px; margin-bottom: 0; margin-right: 0; border: 0");
96 }
97 img.setAttribute("src","http://images.websnapr.com/?url="+_d);
98 img.setAttribute("width",202);
99 img.setAttribute("height",152);
100 img.setAttribute("alt","Snapshot");
101}
102function detachBubble(_12){
103 lbActions=WSR_getElementsByClassName(document,"div","previewbubble");
104 for(i=0;i<lbActions.length;i++){
105 lbActions[i].parentNode.removeChild(lbActions[i]);
106 }
107}
108if(window.addEventListener){
109 addEventListener("load",bindBubbles,false);
110}else{
111 attachEvent("onload",bindBubbles);
112}
113function findPos(obj){
114 var _14=curtop=0;
115 if(obj.offsetParent){
116 _14=obj.offsetLeft;
117 curtop=obj.offsetTop;
118 while(obj=obj.offsetParent){
119 _14+=obj.offsetLeft;
120 curtop+=obj.offsetTop;
121 }
122 }
123 return [_14,curtop];
124}
125
126var BrowserDetect = {
127 init: function () {
128 this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
129 this.version = this.searchVersion(navigator.userAgent)
130 || this.searchVersion(navigator.appVersion)
131 || "an unknown version";
132 this.OS = this.searchString(this.dataOS) || "an unknown OS";
133 },
134 searchString: function (data) {
135 for (var i=0;i<data.length;i++) {
136 var dataString = data[i].string;
137 var dataProp = data[i].prop;
138 this.versionSearchString = data[i].versionSearch || data[i].identity;
139 if (dataString) {
140 if (dataString.indexOf(data[i].subString) != -1)
141 return data[i].identity;
142 }
143 else if (dataProp)
144 return data[i].identity;
145 }
146 },
147 searchVersion: function (dataString) {
148 var index = dataString.indexOf(this.versionSearchString);
149 if (index == -1) return;
150 return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
151 },
152 dataBrowser: [
153 { string: navigator.userAgent,
154 subString: "OmniWeb",
155 versionSearch: "OmniWeb/",
156 identity: "OmniWeb"
157 },{
158 string: navigator.vendor,
159 subString: "Apple",
160 identity: "Safari"
161 },{
162 prop: window.opera,
163 identity: "Opera"
164 },{
165 string: navigator.vendor,
166 subString: "iCab",
167 identity: "iCab"
168 },{
169 string: navigator.vendor,
170 subString: "KDE",
171 identity: "Konqueror"
172 },{
173 string: navigator.userAgent,
174 subString: "Firefox",
175 identity: "Firefox"
176 },{
177 string: navigator.vendor,
178 subString: "Camino",
179 identity: "Camino"
180 },{ // for newer Netscapes (6+)
181 string: navigator.userAgent,
182 subString: "Netscape",
183 identity: "Netscape"
184 },{
185 string: navigator.userAgent,
186 subString: "MSIE",
187 identity: "Explorer",
188 versionSearch: "MSIE"
189 },{
190 string: navigator.userAgent,
191 subString: "Gecko",
192 identity: "Mozilla",
193 versionSearch: "rv"
194 },{ // for older Netscapes (4-)
195 string: navigator.userAgent,
196 subString: "Mozilla",
197 identity: "Netscape",
198 versionSearch: "Mozilla"
199 }
200 ],
201 dataOS : [
202 {
203 string: navigator.platform,
204 subString: "Win",
205 identity: "Windows"
206 },{
207 string: navigator.platform,
208 subString: "Mac",
209 identity: "Mac"
210 },{
211 string: navigator.platform,
212 subString: "Linux",
213 identity: "Linux"
214 }
215 ]
216};
217
218
219function addbookmark(bookmarkurl,bookmarktitle) {
220 if (window.sidebar) {
221 window.sidebar.addPanel(bookmarktitle, bookmarkurl,"");
222 } else if( document.all ) {
223 window.external.AddFavorite(bookmarkurl,bookmarktitle)
224 } else if( window.opera && window.print ) {
225 return true;
226 }
227}
228
229BrowserDetect.init();
Note: See TracBrowser for help on using the repository browser.