1 | /* |
---|
2 | mediaboxAdvanced v1.3.4b - The ultimate extension of Slimbox and Mediabox; an all-media script |
---|
3 | updated 2010.09.21 |
---|
4 | (c) 2007-2010 John Einselen <http://iaian7.com> |
---|
5 | based on Slimbox v1.64 - The ultimate lightweight Lightbox clone |
---|
6 | (c) 2007-2008 Christophe Beyls <http://www.digitalia.be> |
---|
7 | MIT-style license. |
---|
8 | */ |
---|
9 | |
---|
10 | // [VB] Get script directory path |
---|
11 | var scriptPath = (function() |
---|
12 | { |
---|
13 | // Get script source |
---|
14 | var scripts = document.getElementsByTagName('script'), |
---|
15 | script = scripts[scripts.length - 1]; |
---|
16 | //No need to perform the same test we do for the Fully Qualified |
---|
17 | script = script.getAttribute('src', 2); //this works in all browser even in FF/Chrome/Safari |
---|
18 | //return directory path only |
---|
19 | return script.substr(0,script.lastIndexOf("/")+1); |
---|
20 | }()); |
---|
21 | |
---|
22 | var Mediabox; |
---|
23 | |
---|
24 | (function() { |
---|
25 | // Global variables, accessible to Mediabox only |
---|
26 | var options, images, activeImage, prevImage, nextImage, top, mTop, left, mLeft, winWidth, winHeight, fx, preload, preloadPrev = new Image(), preloadNext = new Image(), foxfix = false, iefix = false, |
---|
27 | // DOM elements |
---|
28 | overlay, center, image, bottom, captionSplit, title, caption, prevLink, number, nextLink, |
---|
29 | // Mediabox specific vars |
---|
30 | URL, WH, WHL, elrel, mediaWidth, mediaHeight, mediaType = "none", mediaSplit, mediaId = "mediaBox", mediaFmt, margin; |
---|
31 | |
---|
32 | /* Initialization */ |
---|
33 | |
---|
34 | window.addEvent("domready", function() { |
---|
35 | // Create and append the Mediabox HTML code at the bottom of the document |
---|
36 | document.id(document.body).adopt( |
---|
37 | $$([ |
---|
38 | overlay = new Element("div", {id: "mbOverlay"}).addEvent("click", close), |
---|
39 | center = new Element("div", {id: "mbCenter"}) |
---|
40 | ]).setStyle("display", "none") |
---|
41 | ); |
---|
42 | |
---|
43 | image = new Element("div", {id: "mbImage"}).injectInside(center); |
---|
44 | bottom = new Element("div", {id: "mbBottom"}).injectInside(center).adopt( |
---|
45 | closeLink = new Element("a", {id: "mbCloseLink", href: "#"}).addEvent("click", close), |
---|
46 | nextLink = new Element("a", {id: "mbNextLink", href: "#"}).addEvent("click", next), |
---|
47 | prevLink = new Element("a", {id: "mbPrevLink", href: "#"}).addEvent("click", previous), |
---|
48 | //[VB] |
---|
49 | hdLink = new Element("a", {id: "mbHdLink", href: "#"}).addEvent("click", hd), |
---|
50 | downloadLink = new Element("a", {id: "mbDownloadLink", href: "#"}).addEvent("click", download), |
---|
51 | favoriteLink = new Element("a", {id: "mbFavoriteLink", href: "#"}).addEvent("click", addToFavorites), |
---|
52 | basketLink = new Element("a", {id: "mbBasketLink", href: "#"}).addEvent("click", addToBasket), |
---|
53 | // |
---|
54 | title = new Element("div", {id: "mbTitle"}), |
---|
55 | number = new Element("div", {id: "mbNumber"}), |
---|
56 | caption = new Element("div", {id: "mbCaption"}) |
---|
57 | ); |
---|
58 | |
---|
59 | fx = { |
---|
60 | overlay: new Fx.Tween(overlay, {property: "opacity", duration: 360}).set(0), |
---|
61 | image: new Fx.Tween(image, {property: "opacity", duration: 360, onComplete: captionAnimate}), |
---|
62 | bottom: new Fx.Tween(bottom, {property: "opacity", duration: 240}).set(0) |
---|
63 | }; |
---|
64 | }); |
---|
65 | |
---|
66 | /* API */ |
---|
67 | |
---|
68 | Mediabox = { |
---|
69 | close: function(){ |
---|
70 | close(); // Thanks to Yosha on the google group for fixing the close function API! |
---|
71 | }, |
---|
72 | |
---|
73 | open: function(_images, startImage, _options) { |
---|
74 | options = $extend({ |
---|
75 | // Set "previous", "next", "close", "HD", "donwload", "basket", "addFavorite", "removeFavorite" button content |
---|
76 | //(HTML code should be written as entity codes or properly escaped) |
---|
77 | //[VB] |
---|
78 | text: ['<big>«</big>','<big>»</big>','<big>×</big>','<big>‹¤›</big>','<big>•</big>','<big>#</big>','<big>+</big>','<big>–</big>'], |
---|
79 | loop: false, // Allows to navigate between first and last images |
---|
80 | keyboard: true, // Enables keyboard control; escape key, left arrow, and right arrow |
---|
81 | alpha: true, // Adds 'x', 'c', 'p', and 'n' when keyboard control is also set to true |
---|
82 | stopKey: false, // Stops all default keyboard actions while overlay is open (such as up/down arrows) |
---|
83 | // Does not apply to iFrame content, does not affect mouse scrolling |
---|
84 | overlayOpacity: 0.7, // 1 is opaque, 0 is completely transparent (change the color in the CSS file) |
---|
85 | resizeOpening: true, // Determines if box opens small and grows (true) or starts at larger size (false) |
---|
86 | resizeDuration: 240, // Duration of each of the box resize animations (in milliseconds) |
---|
87 | resizeTransition: false, // Mootools transition effect (false leaves it at the default) |
---|
88 | initialWidth: 320, // Initial width of the box (in pixels) |
---|
89 | initialHeight: 180, // Initial height of the box (in pixels) |
---|
90 | defaultWidth: 640, // Default width of the box (in pixels) for undefined media (MP4, FLV, etc.) |
---|
91 | defaultHeight: 480, // Default height of the box (in pixels) for undefined media (MP4, FLV, etc.) |
---|
92 | showCaption: true, // Display the title and caption, true / false |
---|
93 | showCounter: true, // If true, a counter will only be shown if there is more than 1 image to display |
---|
94 | counterText: '({x} of {y})', // Translate or change as you wish |
---|
95 | // Image options |
---|
96 | imgBackground: false, // Embed images as CSS background (true) or <img> tag (false) |
---|
97 | // CSS background is naturally non-clickable, preventing downloads |
---|
98 | // IMG tag allows automatic scaling for smaller screens |
---|
99 | // (all images have no-click code applied, albeit not Opera compatible. To remove, comment lines 212 and 822) |
---|
100 | imgPadding: 100, // Clearance necessary for images larger than the window size (only used when imgBackground is false) |
---|
101 | // Change this number only if the CSS style is significantly divergent from the original, and requires different sizes |
---|
102 | // Inline options |
---|
103 | // overflow: 'auto', // If set, overides CSS settings for inline content only |
---|
104 | // Global media options |
---|
105 | html5: 'true', // HTML5 settings for YouTube and Vimeo, false = off, true = on |
---|
106 | scriptaccess: 'true', // Allow script access to flash files |
---|
107 | fullscreen: 'true', // Use fullscreen |
---|
108 | fullscreenNum: '1', // 1 = true |
---|
109 | autoplay: 'true', // Plays the video as soon as it's opened |
---|
110 | autoplayNum: '1', // 1 = true |
---|
111 | autoplayYes: 'yes', // yes = true |
---|
112 | volume: '100', // 0-100, used for NonverBlaster and Quicktime players |
---|
113 | medialoop: 'true', // Loop video playback, true / false, used for NonverBlaster and Quicktime players |
---|
114 | bgcolor: '#000000', // Background color, used for flash and QT media |
---|
115 | wmode: 'opaque', // Background setting for Adobe Flash ('opaque' and 'transparent' are most common) |
---|
116 | // NonverBlaster |
---|
117 | useNB: true, // use NonverBlaster (true) or JW Media Player (false) for .flv and .mp4 files |
---|
118 | playerpath: scriptPath +'NonverBlaster.swf', // Path to NonverBlaster.swf |
---|
119 | controlColor: '0xFFFFFF', // set the controlbar color |
---|
120 | controlBackColor: '0x000000', // set the controlbar color |
---|
121 | showTimecode: 'false', // turn timecode display off or on |
---|
122 | // JW Media Player settings and options |
---|
123 | JWplayerpath: scriptPath +'player.swf', // Path to the mediaplayer.swf or flvplayer.swf file |
---|
124 | backcolor: '000000', // Base color for the controller, color name / hex value (0x000000) |
---|
125 | frontcolor: '999999', // Text and button color for the controller, color name / hex value (0x000000) |
---|
126 | lightcolor: '000000', // Rollover color for the controller, color name / hex value (0x000000) |
---|
127 | screencolor: '000000', // Rollover color for the controller, color name / hex value (0x000000) |
---|
128 | controlbar: 'over', // bottom, over, none (this setting is ignored when playing audio files) |
---|
129 | // Quicktime options |
---|
130 | controller: 'true', // Show controller, true / false |
---|
131 | // Flickr options |
---|
132 | flInfo: 'true', // Show title and info at video start |
---|
133 | // Revver options |
---|
134 | revverID: '187866', // Revver affiliate ID, required for ad revinue sharing |
---|
135 | revverFullscreen: 'true', // Fullscreen option |
---|
136 | revverBack: '000000', // Background color |
---|
137 | revverFront: 'ffffff', // Foreground color |
---|
138 | revverGrad: '000000', // Gradation color |
---|
139 | // Ustream options |
---|
140 | usViewers: 'true', // Show online viewer count (true/false) |
---|
141 | // Youtube options |
---|
142 | ytBorder: '0', // Outline (1=true, 0=false) |
---|
143 | ytColor1: '000000', // Outline color |
---|
144 | ytColor2: '333333', // Base interface color (highlight colors stay consistent) |
---|
145 | ytQuality: '&ap=%2526fmt%3D18', // Leave empty for standard quality, use '&ap=%2526fmt%3D18' for high quality, and '&ap=%2526fmt%3D22' for HD (note that not all videos are availible in high quality, and very few in HD) |
---|
146 | ytRel: '0', // Show related videos (1=true, 0=false) |
---|
147 | ytInfo: '1', // Show video info (1=true, 0=false) |
---|
148 | ytSearch: '0', // Show search field (1=true, 0=false) |
---|
149 | // Viddyou options |
---|
150 | vuPlayer: 'basic', // Use 'full' or 'basic' players |
---|
151 | // Vimeo options |
---|
152 | vmTitle: '1', // Show video title |
---|
153 | vmByline: '1', // Show byline |
---|
154 | vmPortrait: '1', // Show author portrait |
---|
155 | vmColor: 'ffffff' // Custom controller colors, hex value minus the # sign, defult is 5ca0b5 |
---|
156 | }, _options || {}); |
---|
157 | |
---|
158 | prevLink.set('html', options.text[0]); |
---|
159 | nextLink.set('html', options.text[1]); |
---|
160 | closeLink.set('html', options.text[2]); |
---|
161 | //[VB] hdLink initialization |
---|
162 | hdLink.set('html', options.text[3]); |
---|
163 | hdLink.style.display = "none"; |
---|
164 | hdLink.title = 'HD'; |
---|
165 | hdLink.className = 'sd-link'; |
---|
166 | downloadLink.set('html', options.text[4]); |
---|
167 | downloadLink.style.display = "none"; |
---|
168 | basketLink.set('html', options.text[5]); |
---|
169 | basketLink.style.display = "none"; |
---|
170 | favoriteLink.style.display = "none"; |
---|
171 | favoriteLink.set('html', (_images[startImage][3]["fav"] == 0) ? options.text[6] : options.text[7]); |
---|
172 | // |
---|
173 | |
---|
174 | margin = center.getStyle('padding-left').toInt()+image.getStyle('margin-left').toInt()+image.getStyle('padding-left').toInt(); |
---|
175 | |
---|
176 | if ((Browser.Engine.gecko) && (Browser.Engine.version<19)) { // Fixes Firefox 2 and Camino 1.6 incompatibility with opacity + flash |
---|
177 | foxfix = true; |
---|
178 | options.overlayOpacity = 1; |
---|
179 | overlay.className = 'mbOverlayFF'; |
---|
180 | } |
---|
181 | |
---|
182 | if ((Browser.Engine.trident) && (Browser.Engine.version<5)) { // Fixes IE 6 and earlier incompatibilities with CSS position: fixed; |
---|
183 | iefix = true; |
---|
184 | overlay.className = 'mbOverlayIE'; |
---|
185 | overlay.setStyle("position", "absolute"); |
---|
186 | position(); |
---|
187 | } |
---|
188 | |
---|
189 | if (typeof _images == "string") { // Used for single images only, with URL and Title as first two arguments |
---|
190 | _images = [[_images,startImage,_options]]; |
---|
191 | startImage = 0; |
---|
192 | } |
---|
193 | |
---|
194 | images = _images; |
---|
195 | options.loop = options.loop && (images.length > 1); |
---|
196 | |
---|
197 | size(); |
---|
198 | setup(true); |
---|
199 | top = window.getScrollTop() + (window.getHeight()/2); |
---|
200 | left = window.getScrollLeft() + (window.getWidth()/2); |
---|
201 | fx.resize = new Fx.Morph(center, $extend({duration: options.resizeDuration, onComplete: imageAnimate}, options.resizeTransition ? {transition: options.resizeTransition} : {})); |
---|
202 | center.setStyles({top: top, left: left, width: options.initialWidth, height: options.initialHeight, marginTop: -(options.initialHeight/2)-margin, marginLeft: -(options.initialWidth/2)-margin, display: ""}); |
---|
203 | fx.overlay.start(options.overlayOpacity); |
---|
204 | return changeImage(startImage); |
---|
205 | } |
---|
206 | }; |
---|
207 | |
---|
208 | Element.implement({ |
---|
209 | mediabox: function(_options, linkMapper) { |
---|
210 | $$(this).mediabox(_options, linkMapper); // The processing of a single element is similar to the processing of a collection with a single element |
---|
211 | |
---|
212 | return this; |
---|
213 | } |
---|
214 | }); |
---|
215 | |
---|
216 | Elements.implement({ |
---|
217 | /* |
---|
218 | options: Optional options object, see Mediabox.open() |
---|
219 | linkMapper: Optional function taking a link DOM element and an index as arguments and returning an array containing 3 elements: |
---|
220 | the image URL and the image caption (may contain HTML) |
---|
221 | linksFilter:Optional function taking a link DOM element and an index as arguments and returning true if the element is part of |
---|
222 | the image collection that will be shown on click, false if not. "this" refers to the element that was clicked. |
---|
223 | This function must always return true when the DOM element argument is "this". |
---|
224 | */ |
---|
225 | mediabox: function(_options, linkMapper, linksFilter) { |
---|
226 | // add the support of custome parameter in the a.rel |
---|
227 | linkMapper = linkMapper || function(el) { |
---|
228 | // [VB] get the params in the a.rel attribut |
---|
229 | elrel = el.rel.split(';'); |
---|
230 | mediaboxRel = elrel[0]; |
---|
231 | elrel.shift(); // remove the first element |
---|
232 | params = Array(); |
---|
233 | for ( var i = 0; i < elrel.length; i++) { |
---|
234 | keyValue = elrel[i].split('='); |
---|
235 | params[keyValue[0].trim()] = (keyValue.lenght == 1) ? true : keyValue[1].trim(); |
---|
236 | } |
---|
237 | // parse: lightbox[gallery_name width height] |
---|
238 | elrel = mediaboxRel.split(/[\[\]]/); |
---|
239 | elrel = elrel[1]; |
---|
240 | // [VB] add optional params at the end of the array |
---|
241 | return [el.href, el.title, elrel, params]; |
---|
242 | }; |
---|
243 | |
---|
244 | linksFilter = linksFilter || function() { |
---|
245 | return true; |
---|
246 | }; |
---|
247 | |
---|
248 | var links = this; |
---|
249 | |
---|
250 | links.addEvent('contextmenu', function(e){ |
---|
251 | if (this.toString().match(/\.gif|\.jpg|\.jpeg|\.png/i)) e.stop(); |
---|
252 | }); |
---|
253 | |
---|
254 | links.removeEvents("click").addEvent("click", function() { |
---|
255 | // Build the list of images that will be displayed |
---|
256 | var filteredArray = links.filter(linksFilter, this); |
---|
257 | var filteredLinks = []; |
---|
258 | var filteredHrefs = []; |
---|
259 | |
---|
260 | filteredArray.each(function(item, index){ |
---|
261 | if(filteredHrefs.indexOf(item.toString()) < 0) { |
---|
262 | filteredLinks.include(filteredArray[index]); |
---|
263 | filteredHrefs.include(filteredArray[index].toString()); |
---|
264 | }; |
---|
265 | }); |
---|
266 | |
---|
267 | return Mediabox.open(filteredLinks.map(linkMapper), filteredHrefs.indexOf(this.toString()), _options); |
---|
268 | }); |
---|
269 | |
---|
270 | return links; |
---|
271 | } |
---|
272 | }); |
---|
273 | |
---|
274 | /* Internal functions */ |
---|
275 | |
---|
276 | function position() { |
---|
277 | overlay.setStyles({top: window.getScrollTop(), left: window.getScrollLeft()}); |
---|
278 | } |
---|
279 | |
---|
280 | function size() { |
---|
281 | winWidth = window.getWidth(); |
---|
282 | winHeight = window.getHeight(); |
---|
283 | overlay.setStyles({width: winWidth, height: winHeight}); |
---|
284 | } |
---|
285 | |
---|
286 | function setup(open) { |
---|
287 | // Hides on-page objects and embeds while the overlay is open, nessesary to counteract Firefox stupidity |
---|
288 | if (Browser.Engine.gecko) { |
---|
289 | ["object", window.ie ? "select" : "embed"].forEach(function(tag) { |
---|
290 | Array.forEach(document.getElementsByTagName(tag), function(el) { |
---|
291 | if (open) el._mediabox = el.style.visibility; |
---|
292 | el.style.visibility = open ? "hidden" : el._mediabox; |
---|
293 | }); |
---|
294 | }); |
---|
295 | } |
---|
296 | |
---|
297 | overlay.style.display = open ? "" : "none"; |
---|
298 | |
---|
299 | var fn = open ? "addEvent" : "removeEvent"; |
---|
300 | if (iefix) window[fn]("scroll", position); |
---|
301 | window[fn]("resize", size); |
---|
302 | if (options.keyboard) document[fn]("keydown", keyDown); |
---|
303 | } |
---|
304 | |
---|
305 | function keyDown(event) { |
---|
306 | if (options.alpha) { |
---|
307 | switch(event.code) { |
---|
308 | case 27: // Esc |
---|
309 | case 88: // 'x' |
---|
310 | case 67: // 'c' |
---|
311 | close(); |
---|
312 | break; |
---|
313 | case 37: // Left arrow |
---|
314 | case 80: // 'p' |
---|
315 | previous(); |
---|
316 | break; |
---|
317 | case 39: // Right arrow |
---|
318 | case 78: // 'n' |
---|
319 | next(); |
---|
320 | break |
---|
321 | case 96: // [VB] 0 (NUM LOCK) |
---|
322 | case 66: // 'b' |
---|
323 | addToBasket(); |
---|
324 | break; |
---|
325 | case 106: // [VB] * (NUM LOCK) |
---|
326 | case 68: // 'd' |
---|
327 | download(); |
---|
328 | break; |
---|
329 | case 107: // [VB] + (NUM LOCK) |
---|
330 | case 70: // 'f' |
---|
331 | addToFavorites(); |
---|
332 | break; |
---|
333 | } |
---|
334 | } else { |
---|
335 | switch(event.code) { |
---|
336 | case 27: // Esc |
---|
337 | close(); |
---|
338 | break; |
---|
339 | case 37: // Left arrow |
---|
340 | previous(); |
---|
341 | break; |
---|
342 | case 39: // Right arrow |
---|
343 | next(); |
---|
344 | break |
---|
345 | case 96: // [VB] + (NUM LOCK) |
---|
346 | addToBasket(); |
---|
347 | break; |
---|
348 | case 106: // [VB] * (NUM LOCK) |
---|
349 | download(); |
---|
350 | break; |
---|
351 | case 107: // [VB] + (NUM LOCK) |
---|
352 | addToFavorites(); |
---|
353 | break; |
---|
354 | } |
---|
355 | } |
---|
356 | if (options.stopKey) { return false; }; |
---|
357 | } |
---|
358 | |
---|
359 | function previous() { |
---|
360 | return changeImage(prevImage); |
---|
361 | } |
---|
362 | |
---|
363 | function next() { |
---|
364 | return changeImage(nextImage); |
---|
365 | } |
---|
366 | |
---|
367 | // [VB] |
---|
368 | function hd() { |
---|
369 | var hdURL = images[activeImage][3]["hdurl"]; |
---|
370 | if (hdURL && hdURL.length > 0) { |
---|
371 | image.set('html', ''); |
---|
372 | stop(); |
---|
373 | center.className = "mbLoading"; |
---|
374 | |
---|
375 | // is HD ? |
---|
376 | if (hdLink.className == 'hd-link') { |
---|
377 | URL = images[activeImage][0]; |
---|
378 | hdLink.set('html', options.text[3]); |
---|
379 | hdLink.title = 'HD'; |
---|
380 | hdLink.className = 'sd-link'; |
---|
381 | } else { |
---|
382 | URL = hdURL; |
---|
383 | hdLink.set('html', '<big>¤</big>'); |
---|
384 | hdLink.title = 'SD'; |
---|
385 | hdLink.className = 'hd-link'; |
---|
386 | } |
---|
387 | URL = encodeURI(URL).replace("(","%28").replace(")","%29"); |
---|
388 | |
---|
389 | captionSplit = images[activeImage][1].split('::'); |
---|
390 | mediaType = 'img'; |
---|
391 | preload = new Image(); |
---|
392 | preload.onload = startEffect; |
---|
393 | preload.src = URL; |
---|
394 | } |
---|
395 | } |
---|
396 | function download() { |
---|
397 | // displayed only if HD picture available |
---|
398 | window.location.href = 'action.php?id='+ images[activeImage][3]["id"] +'&part=h'; |
---|
399 | return true; |
---|
400 | } |
---|
401 | function addToBasket() { |
---|
402 | var rootUrl = options.piwigoRootUrl; |
---|
403 | var cat = options.piwigoCategory; |
---|
404 | var id = images[activeImage][3]["id"]; |
---|
405 | images[activeImage][3]["href"] = 'picture.php?/'+ id +'/category/'+ cat +'&action=add_to_caddie'; |
---|
406 | |
---|
407 | // From addToCadie function in the picture.tpl file |
---|
408 | |
---|
409 | if (basketLink.className.contains('disabled-link')) |
---|
410 | return false; |
---|
411 | basketLink.className = 'disabled-link'; |
---|
412 | |
---|
413 | var y = new PwgWS(rootUrl); |
---|
414 | y.callService( |
---|
415 | "pwg.caddie.add", {image_id: id} , |
---|
416 | { |
---|
417 | onFailure: function(num, text) { alert(num + " " + text); document.location=images[activeImage][3]["href"];}, |
---|
418 | onSuccess: function(result) {basketLink.className = '';} |
---|
419 | } |
---|
420 | ); |
---|
421 | |
---|
422 | return false; |
---|
423 | } |
---|
424 | function addToFavorites() { |
---|
425 | var iid = images[activeImage][3]["id"]; |
---|
426 | var cid = options.piwigoCategory; |
---|
427 | var href = 'picture.php?/'+ iid +'/category/'+ cid; |
---|
428 | |
---|
429 | if (favoriteLink.className.contains('disabled-link')) |
---|
430 | return false; |
---|
431 | favoriteLink.className = 'disabled-link'; |
---|
432 | |
---|
433 | href += (images[activeImage][3]["fav"] == 0) ? '&action=add_to_favorites' : '&action=remove_from_favorites'; |
---|
434 | |
---|
435 | var favRequest = new Request({ |
---|
436 | url: href, |
---|
437 | onSuccess: function(responseText, responseXML) { |
---|
438 | var fav = (images[activeImage][3]["fav"] == 0) ? 1 : 0; |
---|
439 | images[activeImage][3]["fav"] = fav; |
---|
440 | favoriteLink.className = ''; |
---|
441 | favoriteLink.set('html', options.text[6 + fav]); |
---|
442 | }, |
---|
443 | onFailure: function(xhr) { |
---|
444 | image.setStyles({backgroundImage: "none", display: ""}); |
---|
445 | image.set('html', '<div id="mbError">'+ xhr.responseText +'</div>'); |
---|
446 | }, |
---|
447 | onException: function(headerName, value) { |
---|
448 | alert('Exception: '+ headerName +' - '+ value); |
---|
449 | } |
---|
450 | }).send(); |
---|
451 | return false; |
---|
452 | } |
---|
453 | // |
---|
454 | |
---|
455 | |
---|
456 | function changeImage(imageIndex) { |
---|
457 | if (imageIndex >= 0) { |
---|
458 | image.set('html', ''); |
---|
459 | activeImage = imageIndex; |
---|
460 | prevImage = ((activeImage || !options.loop) ? activeImage : images.length) - 1; |
---|
461 | nextImage = activeImage + 1; |
---|
462 | if (nextImage == images.length) nextImage = options.loop ? 0 : -1; |
---|
463 | stop(); |
---|
464 | center.className = "mbLoading"; |
---|
465 | |
---|
466 | /* mediaboxAdvanced link formatting and media support */ |
---|
467 | |
---|
468 | if (!images[imageIndex][2]) images[imageIndex][2] = ''; // Thanks to Leo Feyer for offering this fix |
---|
469 | WH = images[imageIndex][2].split(' '); |
---|
470 | WHL = WH.length; |
---|
471 | if (WHL>1) { |
---|
472 | mediaWidth = (WH[WHL-2].match("%")) ? (window.getWidth()*((WH[WHL-2].replace("%", ""))*0.01))+"px" : WH[WHL-2]+"px"; |
---|
473 | mediaHeight = (WH[WHL-1].match("%")) ? (window.getHeight()*((WH[WHL-1].replace("%", ""))*0.01))+"px" : WH[WHL-1]+"px"; |
---|
474 | } else { |
---|
475 | mediaWidth = ""; |
---|
476 | mediaHeight = ""; |
---|
477 | } |
---|
478 | URL = images[imageIndex][0]; |
---|
479 | URL = encodeURI(URL).replace("(","%28").replace(")","%29"); |
---|
480 | captionSplit = images[activeImage][1].split('::'); |
---|
481 | |
---|
482 | // Quietube and yFrog support |
---|
483 | if (URL.match(/quietube\.com/i)) { |
---|
484 | mediaSplit = URL.split('v.php/'); |
---|
485 | URL = mediaSplit[1]; |
---|
486 | } else if (URL.match(/\/\/yfrog/i)) { |
---|
487 | mediaType = (URL.substring(URL.length-1)); |
---|
488 | if (mediaType.match(/b|g|j|p|t/i)) mediaType = 'image'; |
---|
489 | if (mediaType == 's') mediaType = 'flash'; |
---|
490 | if (mediaType.match(/f|z/i)) mediaType = 'video'; |
---|
491 | URL = URL+":iphone"; |
---|
492 | } |
---|
493 | |
---|
494 | // [VB] |
---|
495 | hdLink.style.display = "none"; |
---|
496 | downloadLink.style.display = "none"; |
---|
497 | favoriteLink.style.display = "none"; |
---|
498 | basketLink.style.display = (options.displayAddToBasket) ? "inline" : "none"; |
---|
499 | // |
---|
500 | |
---|
501 | /* Specific Media Types */ |
---|
502 | |
---|
503 | // GIF, JPG, PNG |
---|
504 | if (URL.match(/\.gif|\.jpg|\.jpeg|\.png|twitpic\.com/i) || mediaType == 'image') { |
---|
505 | // [VB] |
---|
506 | hdLink.style.display = (options.displayHdPicture && images[imageIndex][3]["hdurl"]) ? "inline" : "none"; |
---|
507 | downloadLink.style.display = (options.displayDownload && images[imageIndex][3]["hdurl"]) ? "inline" : "none"; |
---|
508 | favoriteLink.style.display = (options.displayFavorite && images[imageIndex][3]["fav"]) ? "inline" : "none"; |
---|
509 | favoriteLink.set('html', (images[imageIndex][3]["fav"] == 0) ? options.text[6] : options.text[7]); |
---|
510 | // |
---|
511 | |
---|
512 | mediaType = 'img'; |
---|
513 | URL = URL.replace(/twitpic\.com/i, "twitpic.com/show/full"); |
---|
514 | preload = new Image(); |
---|
515 | preload.onload = startEffect; |
---|
516 | preload.src = URL; |
---|
517 | // FLV, MP4 |
---|
518 | } else if (URL.match(/\.flv|\.mp4/i) || mediaType == 'video') { |
---|
519 | mediaType = 'obj'; |
---|
520 | mediaWidth = mediaWidth || options.defaultWidth; |
---|
521 | mediaHeight = mediaHeight || options.defaultHeight; |
---|
522 | if (options.useNB) { |
---|
523 | preload = new Swiff(''+options.playerpath+'?mediaURL='+URL+'&allowSmoothing=true&autoPlay='+options.autoplay+'&buffer=6&showTimecode='+options.showTimecode+'&loop='+options.medialoop+'&controlColor='+options.controlColor+'&controlBackColor='+options.controlBackColor+'&defaultVolume='+options.volume+'&scaleIfFullScreen=true&showScalingButton=true&crop=false', { |
---|
524 | id: 'MediaboxSWF', |
---|
525 | width: mediaWidth, |
---|
526 | height: mediaHeight, |
---|
527 | params: {wmode: options.wmode, bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen} |
---|
528 | }); |
---|
529 | } else { |
---|
530 | preload = new Swiff(''+options.JWplayerpath+'?file='+URL+'&backcolor='+options.backcolor+'&frontcolor='+options.frontcolor+'&lightcolor='+options.lightcolor+'&screencolor='+options.screencolor+'&autostart='+options.autoplay+'&controlbar='+options.controlbar, { |
---|
531 | id: 'MediaboxSWF', |
---|
532 | width: mediaWidth, |
---|
533 | height: mediaHeight, |
---|
534 | params: {wmode: options.wmode, bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen} |
---|
535 | }); |
---|
536 | } |
---|
537 | startEffect(); |
---|
538 | // MP3, AAC |
---|
539 | } else if (URL.match(/\.mp3|\.aac|tweetmic\.com|tmic\.fm/i) || mediaType == 'audio') { |
---|
540 | mediaType = 'obj'; |
---|
541 | mediaWidth = mediaWidth || options.defaultWidth; |
---|
542 | mediaHeight = mediaHeight || "20px"; |
---|
543 | if (URL.match(/tweetmic\.com|tmic\.fm/i)) { |
---|
544 | URL = URL.split('/'); |
---|
545 | URL[4] = URL[4] || URL[3]; |
---|
546 | URL = "http://media4.fjarnet.net/tweet/tweetmicapp-"+URL[4]+'.mp3'; |
---|
547 | } |
---|
548 | if (options.useNB) { |
---|
549 | preload = new Swiff(''+options.playerpath+'?mediaURL='+URL+'&allowSmoothing=true&autoPlay='+options.autoplay+'&buffer=6&showTimecode='+options.showTimecode+'&loop='+options.medialoop+'&controlColor='+options.controlColor+'&controlBackColor='+options.controlBackColor+'&defaultVolume='+options.volume+'&scaleIfFullScreen=true&showScalingButton=true&crop=false', { |
---|
550 | id: 'MediaboxSWF', |
---|
551 | width: mediaWidth, |
---|
552 | height: mediaHeight, |
---|
553 | params: {wmode: options.wmode, bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen} |
---|
554 | }); |
---|
555 | } else { |
---|
556 | preload = new Swiff(''+options.JWplayerpath+'?file='+URL+'&backcolor='+options.backcolor+'&frontcolor='+options.frontcolor+'&lightcolor='+options.lightcolor+'&screencolor='+options.screencolor+'&autostart='+options.autoplay, { |
---|
557 | id: 'MediaboxSWF', |
---|
558 | width: mediaWidth, |
---|
559 | height: mediaHeight, |
---|
560 | params: {wmode: options.wmode, bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen} |
---|
561 | }); |
---|
562 | } |
---|
563 | startEffect(); |
---|
564 | // SWF |
---|
565 | } else if (URL.match(/\.swf/i) || mediaType == 'flash') { |
---|
566 | mediaType = 'obj'; |
---|
567 | mediaWidth = mediaWidth || options.defaultWidth; |
---|
568 | mediaHeight = mediaHeight || options.defaultHeight; |
---|
569 | preload = new Swiff(URL, { |
---|
570 | id: 'MediaboxSWF', |
---|
571 | width: mediaWidth, |
---|
572 | height: mediaHeight, |
---|
573 | params: {wmode: options.wmode, bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen} |
---|
574 | }); |
---|
575 | startEffect(); |
---|
576 | // MOV, M4V, M4A, MP4, AIFF, etc. |
---|
577 | } else if (URL.match(/\.mov|\.m4v|\.m4a|\.aiff|\.avi|\.caf|\.dv|\.mid|\.m3u|\.mp3|\.mp2|\.mp4|\.qtz/i) || mediaType == 'qt') { |
---|
578 | mediaType = 'qt'; |
---|
579 | mediaWidth = mediaWidth || options.defaultWidth; |
---|
580 | mediaHeight = (parseInt(mediaHeight)+16)+"px" || options.defaultHeight; |
---|
581 | preload = new Quickie(URL, { |
---|
582 | id: 'MediaboxQT', |
---|
583 | width: mediaWidth, |
---|
584 | height: mediaHeight, |
---|
585 | container: 'mbImage', |
---|
586 | attributes: {controller: options.controller, autoplay: options.autoplay, volume: options.volume, loop: options.medialoop, bgcolor: options.bgcolor} |
---|
587 | }); |
---|
588 | startEffect(); |
---|
589 | |
---|
590 | /* Social Media Sites */ |
---|
591 | |
---|
592 | // Blip.tv |
---|
593 | } else if (URL.match(/blip\.tv/i)) { |
---|
594 | mediaType = 'obj'; |
---|
595 | mediaWidth = mediaWidth || "640px"; |
---|
596 | mediaHeight = mediaHeight || "390px"; |
---|
597 | preload = new Swiff(URL, { |
---|
598 | src: URL, |
---|
599 | width: mediaWidth, |
---|
600 | height: mediaHeight, |
---|
601 | params: {wmode: options.wmode, bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen} |
---|
602 | }); |
---|
603 | startEffect(); |
---|
604 | // Break.com |
---|
605 | } else if (URL.match(/break\.com/i)) { |
---|
606 | mediaType = 'obj'; |
---|
607 | mediaWidth = mediaWidth || "464px"; |
---|
608 | mediaHeight = mediaHeight || "376px"; |
---|
609 | mediaId = URL.match(/\d{6}/g); |
---|
610 | preload = new Swiff('http://embed.break.com/'+mediaId, { |
---|
611 | width: mediaWidth, |
---|
612 | height: mediaHeight, |
---|
613 | params: {wmode: options.wmode, bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen} |
---|
614 | }); |
---|
615 | startEffect(); |
---|
616 | // DailyMotion |
---|
617 | } else if (URL.match(/dailymotion\.com/i)) { |
---|
618 | mediaType = 'obj'; |
---|
619 | mediaWidth = mediaWidth || "480px"; |
---|
620 | mediaHeight = mediaHeight || "381px"; |
---|
621 | preload = new Swiff(URL, { |
---|
622 | id: mediaId, |
---|
623 | width: mediaWidth, |
---|
624 | height: mediaHeight, |
---|
625 | params: {wmode: options.wmode, bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen} |
---|
626 | }); |
---|
627 | startEffect(); |
---|
628 | // Facebook |
---|
629 | } else if (URL.match(/facebook\.com/i)) { |
---|
630 | mediaType = 'obj'; |
---|
631 | mediaWidth = mediaWidth || "320px"; |
---|
632 | mediaHeight = mediaHeight || "240px"; |
---|
633 | mediaSplit = URL.split('v='); |
---|
634 | mediaSplit = mediaSplit[1].split('&'); |
---|
635 | mediaId = mediaSplit[0]; |
---|
636 | preload = new Swiff('http://www.facebook.com/v/'+mediaId, { |
---|
637 | movie: 'http://www.facebook.com/v/'+mediaId, |
---|
638 | classid: 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000', |
---|
639 | width: mediaWidth, |
---|
640 | height: mediaHeight, |
---|
641 | params: {wmode: options.wmode, bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen} |
---|
642 | }); |
---|
643 | startEffect(); |
---|
644 | // Flickr |
---|
645 | } else if (URL.match(/flickr\.com/i)) { |
---|
646 | mediaType = 'obj'; |
---|
647 | mediaWidth = mediaWidth || "500px"; |
---|
648 | mediaHeight = mediaHeight || "375px"; |
---|
649 | mediaSplit = URL.split('/'); |
---|
650 | mediaId = mediaSplit[5]; |
---|
651 | preload = new Swiff('http://www.flickr.com/apps/video/stewart.swf', { |
---|
652 | id: mediaId, |
---|
653 | classid: 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000', |
---|
654 | width: mediaWidth, |
---|
655 | height: mediaHeight, |
---|
656 | params: {flashvars: 'photo_id='+mediaId+'&show_info_box='+options.flInfo, wmode: options.wmode, bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen} |
---|
657 | }); |
---|
658 | startEffect(); |
---|
659 | // GameTrailers Video |
---|
660 | } else if (URL.match(/gametrailers\.com/i)) { |
---|
661 | mediaType = 'obj'; |
---|
662 | mediaWidth = mediaWidth || "480px"; |
---|
663 | mediaHeight = mediaHeight || "392px"; |
---|
664 | mediaId = URL.match(/\d{5}/g); |
---|
665 | preload = new Swiff('http://www.gametrailers.com/remote_wrap.php?mid='+mediaId, { |
---|
666 | id: mediaId, |
---|
667 | width: mediaWidth, |
---|
668 | height: mediaHeight, |
---|
669 | params: {wmode: options.wmode, bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen} |
---|
670 | }); |
---|
671 | startEffect(); |
---|
672 | // Google Video |
---|
673 | } else if (URL.match(/google\.com\/videoplay/i)) { |
---|
674 | mediaType = 'obj'; |
---|
675 | mediaWidth = mediaWidth || "400px"; |
---|
676 | mediaHeight = mediaHeight || "326px"; |
---|
677 | mediaSplit = URL.split('='); |
---|
678 | mediaId = mediaSplit[1]; |
---|
679 | preload = new Swiff('http://video.google.com/googleplayer.swf?docId='+mediaId+'&autoplay='+options.autoplayNum, { |
---|
680 | id: mediaId, |
---|
681 | width: mediaWidth, |
---|
682 | height: mediaHeight, |
---|
683 | params: {wmode: options.wmode, bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen} |
---|
684 | }); |
---|
685 | startEffect(); |
---|
686 | // Megavideo - Thanks to Robert Jandreu for suggesting this code! |
---|
687 | } else if (URL.match(/megavideo\.com/i)) { |
---|
688 | mediaType = 'obj'; |
---|
689 | mediaWidth = mediaWidth || "640px"; |
---|
690 | mediaHeight = mediaHeight || "360px"; |
---|
691 | mediaSplit = URL.split('='); |
---|
692 | mediaId = mediaSplit[1]; |
---|
693 | preload = new Swiff('http://wwwstatic.megavideo.com/mv_player.swf?v='+mediaId, { |
---|
694 | id: mediaId, |
---|
695 | width: mediaWidth, |
---|
696 | height: mediaHeight, |
---|
697 | params: {wmode: options.wmode, bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen} |
---|
698 | }); |
---|
699 | startEffect(); |
---|
700 | // Metacafe |
---|
701 | } else if (URL.match(/metacafe\.com\/watch/i)) { |
---|
702 | mediaType = 'obj'; |
---|
703 | mediaWidth = mediaWidth || "400px"; |
---|
704 | mediaHeight = mediaHeight || "345px"; |
---|
705 | mediaSplit = URL.split('/'); |
---|
706 | mediaId = mediaSplit[4]; |
---|
707 | preload = new Swiff('http://www.metacafe.com/fplayer/'+mediaId+'/.swf?playerVars=autoPlay='+options.autoplayYes, { |
---|
708 | id: mediaId, |
---|
709 | width: mediaWidth, |
---|
710 | height: mediaHeight, |
---|
711 | params: {wmode: options.wmode, bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen} |
---|
712 | }); |
---|
713 | startEffect(); |
---|
714 | // Myspace |
---|
715 | } else if (URL.match(/vids\.myspace\.com/i)) { |
---|
716 | mediaType = 'obj'; |
---|
717 | mediaWidth = mediaWidth || "425px"; |
---|
718 | mediaHeight = mediaHeight || "360px"; |
---|
719 | preload = new Swiff(URL, { |
---|
720 | id: mediaId, |
---|
721 | width: mediaWidth, |
---|
722 | height: mediaHeight, |
---|
723 | params: {wmode: options.wmode, bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen} |
---|
724 | }); |
---|
725 | startEffect(); |
---|
726 | // Revver |
---|
727 | } else if (URL.match(/revver\.com/i)) { |
---|
728 | mediaType = 'obj'; |
---|
729 | mediaWidth = mediaWidth || "480px"; |
---|
730 | mediaHeight = mediaHeight || "392px"; |
---|
731 | mediaSplit = URL.split('/'); |
---|
732 | mediaId = mediaSplit[4]; |
---|
733 | preload = new Swiff('http://flash.revver.com/player/1.0/player.swf?mediaId='+mediaId+'&affiliateId='+options.revverID+'&allowFullScreen='+options.revverFullscreen+'&autoStart='+options.autoplay+'&backColor=#'+options.revverBack+'&frontColor=#'+options.revverFront+'&gradColor=#'+options.revverGrad+'&shareUrl=revver', { |
---|
734 | id: mediaId, |
---|
735 | width: mediaWidth, |
---|
736 | height: mediaHeight, |
---|
737 | params: {wmode: options.wmode, bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen} |
---|
738 | }); |
---|
739 | startEffect(); |
---|
740 | // Rutube |
---|
741 | } else if (URL.match(/rutube\.ru/i)) { |
---|
742 | mediaType = 'obj'; |
---|
743 | mediaWidth = mediaWidth || "470px"; |
---|
744 | mediaHeight = mediaHeight || "353px"; |
---|
745 | mediaSplit = URL.split('='); |
---|
746 | mediaId = mediaSplit[1]; |
---|
747 | preload = new Swiff('http://video.rutube.ru/'+mediaId, { |
---|
748 | movie: 'http://video.rutube.ru/'+mediaId, |
---|
749 | width: mediaWidth, |
---|
750 | height: mediaHeight, |
---|
751 | params: {wmode: options.wmode, bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen} |
---|
752 | }); |
---|
753 | startEffect(); |
---|
754 | // Seesmic |
---|
755 | } else if (URL.match(/seesmic\.com/i)) { |
---|
756 | mediaType = 'obj'; |
---|
757 | mediaWidth = mediaWidth || "435px"; |
---|
758 | mediaHeight = mediaHeight || "355px"; |
---|
759 | mediaSplit = URL.split('/'); |
---|
760 | mediaId = mediaSplit[5]; |
---|
761 | preload = new Swiff('http://seesmic.com/Standalone.swf?video='+mediaId, { |
---|
762 | id: mediaId, |
---|
763 | width: mediaWidth, |
---|
764 | height: mediaHeight, |
---|
765 | params: {wmode: options.wmode, bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen} |
---|
766 | }); |
---|
767 | startEffect(); |
---|
768 | // Tudou |
---|
769 | } else if (URL.match(/tudou\.com/i)) { |
---|
770 | mediaType = 'obj'; |
---|
771 | mediaWidth = mediaWidth || "400px"; |
---|
772 | mediaHeight = mediaHeight || "340px"; |
---|
773 | mediaSplit = URL.split('/'); |
---|
774 | mediaId = mediaSplit[5]; |
---|
775 | preload = new Swiff('http://www.tudou.com/v/'+mediaId, { |
---|
776 | width: mediaWidth, |
---|
777 | height: mediaHeight, |
---|
778 | params: {wmode: options.wmode, bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen} |
---|
779 | }); |
---|
780 | startEffect(); |
---|
781 | // Twitvcam |
---|
782 | } else if (URL.match(/twitcam\.com/i)) { |
---|
783 | mediaType = 'obj'; |
---|
784 | mediaWidth = mediaWidth || "320px"; |
---|
785 | mediaHeight = mediaHeight || "265px"; |
---|
786 | mediaSplit = URL.split('/'); |
---|
787 | mediaId = mediaSplit[3]; |
---|
788 | preload = new Swiff('http://static.livestream.com/chromelessPlayer/wrappers/TwitcamPlayer.swf?hash='+mediaId, { |
---|
789 | width: mediaWidth, |
---|
790 | height: mediaHeight, |
---|
791 | params: {wmode: options.wmode, bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen} |
---|
792 | }); |
---|
793 | startEffect(); |
---|
794 | // Twiturm |
---|
795 | } else if (URL.match(/twiturm\.com/i)) { |
---|
796 | mediaType = 'obj'; |
---|
797 | mediaWidth = mediaWidth || "402px"; |
---|
798 | mediaHeight = mediaHeight || "48px"; |
---|
799 | mediaSplit = URL.split('/'); |
---|
800 | mediaId = mediaSplit[3]; |
---|
801 | preload = new Swiff('http://twiturm.com/flash/twiturm_mp3.swf?playerID=0&sf='+mediaId, { |
---|
802 | width: mediaWidth, |
---|
803 | height: mediaHeight, |
---|
804 | params: {wmode: options.wmode, bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen} |
---|
805 | }); |
---|
806 | startEffect(); |
---|
807 | // Twitvid |
---|
808 | } else if (URL.match(/twitvid\.com/i)) { |
---|
809 | mediaType = 'obj'; |
---|
810 | mediaWidth = mediaWidth || "600px"; |
---|
811 | mediaHeight = mediaHeight || "338px"; |
---|
812 | mediaSplit = URL.split('/'); |
---|
813 | mediaId = mediaSplit[3]; |
---|
814 | preload = new Swiff('http://www.twitvid.com/player/'+mediaId, { |
---|
815 | width: mediaWidth, |
---|
816 | height: mediaHeight, |
---|
817 | params: {wmode: options.wmode, bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen} |
---|
818 | }); |
---|
819 | startEffect(); |
---|
820 | // Ustream.tv |
---|
821 | } else if (URL.match(/ustream\.tv/i)) { |
---|
822 | mediaType = 'obj'; |
---|
823 | mediaWidth = mediaWidth || "400px"; |
---|
824 | mediaHeight = mediaHeight || "326px"; |
---|
825 | preload = new Swiff(URL+'&viewcount='+options.usViewers+'&autoplay='+options.autoplay, { |
---|
826 | width: mediaWidth, |
---|
827 | height: mediaHeight, |
---|
828 | params: {wmode: options.wmode, bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen} |
---|
829 | }); |
---|
830 | startEffect(); |
---|
831 | // YouKu |
---|
832 | } else if (URL.match(/youku\.com/i)) { |
---|
833 | mediaType = 'obj'; |
---|
834 | mediaWidth = mediaWidth || "480px"; |
---|
835 | mediaHeight = mediaHeight || "400px"; |
---|
836 | mediaSplit = URL.split('id_'); |
---|
837 | mediaId = mediaSplit[1]; |
---|
838 | preload = new Swiff('http://player.youku.com/player.php/sid/'+mediaId+'=/v.swf', { |
---|
839 | width: mediaWidth, |
---|
840 | height: mediaHeight, |
---|
841 | params: {wmode: options.wmode, bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen} |
---|
842 | }); |
---|
843 | startEffect(); |
---|
844 | // YouTube Video (now includes HTML5 option) |
---|
845 | } else if (URL.match(/youtube\.com\/watch/i)) { |
---|
846 | mediaSplit = URL.split('v='); |
---|
847 | if (options.html5) { |
---|
848 | mediaType = 'url'; |
---|
849 | mediaWidth = mediaWidth || "640px"; |
---|
850 | mediaHeight = mediaHeight || "385px"; |
---|
851 | mediaId = "mediaId_"+new Date().getTime(); // Safari may not update iframe content with a static id. |
---|
852 | preload = new Element('iframe', { |
---|
853 | 'src': 'http://www.youtube.com/embed/'+mediaSplit[1], |
---|
854 | 'id': mediaId, |
---|
855 | 'width': mediaWidth, |
---|
856 | 'height': mediaHeight, |
---|
857 | 'frameborder': 0 |
---|
858 | }); |
---|
859 | startEffect(); |
---|
860 | } else { |
---|
861 | mediaType = 'obj'; |
---|
862 | mediaId = mediaSplit[1]; |
---|
863 | if (mediaId.match(/fmt=22/i)) { |
---|
864 | mediaFmt = '&ap=%2526fmt%3D22'; |
---|
865 | mediaWidth = mediaWidth || "640px"; |
---|
866 | mediaHeight = mediaHeight || "385px"; |
---|
867 | } else if (mediaId.match(/fmt=18/i)) { |
---|
868 | mediaFmt = '&ap=%2526fmt%3D18'; |
---|
869 | mediaWidth = mediaWidth || "560px"; |
---|
870 | mediaHeight = mediaHeight || "345px"; |
---|
871 | } else { |
---|
872 | mediaFmt = options.ytQuality; |
---|
873 | mediaWidth = mediaWidth || "480px"; |
---|
874 | mediaHeight = mediaHeight || "295px"; |
---|
875 | } |
---|
876 | preload = new Swiff('http://www.youtube.com/v/'+mediaId+'&autoplay='+options.autoplayNum+'&fs='+options.fullscreenNum+mediaFmt+'&border='+options.ytBorder+'&color1=0x'+options.ytColor1+'&color2=0x'+options.ytColor2+'&rel='+options.ytRel+'&showinfo='+options.ytInfo+'&showsearch='+options.ytSearch, { |
---|
877 | id: mediaId, |
---|
878 | width: mediaWidth, |
---|
879 | height: mediaHeight, |
---|
880 | params: {wmode: options.wmode, bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen} |
---|
881 | }); |
---|
882 | startEffect(); |
---|
883 | } |
---|
884 | // YouTube Playlist |
---|
885 | } else if (URL.match(/youtube\.com\/view/i)) { |
---|
886 | mediaType = 'obj'; |
---|
887 | mediaSplit = URL.split('p='); |
---|
888 | mediaId = mediaSplit[1]; |
---|
889 | mediaWidth = mediaWidth || "480px"; |
---|
890 | mediaHeight = mediaHeight || "385px"; |
---|
891 | preload = new Swiff('http://www.youtube.com/p/'+mediaId+'&autoplay='+options.autoplayNum+'&fs='+options.fullscreenNum+mediaFmt+'&border='+options.ytBorder+'&color1=0x'+options.ytColor1+'&color2=0x'+options.ytColor2+'&rel='+options.ytRel+'&showinfo='+options.ytInfo+'&showsearch='+options.ytSearch, { |
---|
892 | id: mediaId, |
---|
893 | width: mediaWidth, |
---|
894 | height: mediaHeight, |
---|
895 | params: {wmode: options.wmode, bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen} |
---|
896 | }); |
---|
897 | startEffect(); |
---|
898 | // Veoh |
---|
899 | } else if (URL.match(/veoh\.com/i)) { |
---|
900 | mediaType = 'obj'; |
---|
901 | mediaWidth = mediaWidth || "410px"; |
---|
902 | mediaHeight = mediaHeight || "341px"; |
---|
903 | URL = URL.replace('%3D','/'); |
---|
904 | mediaSplit = URL.split('watch/'); |
---|
905 | mediaId = mediaSplit[1]; |
---|
906 | preload = new Swiff('http://www.veoh.com/static/swf/webplayer/WebPlayer.swf?version=AFrontend.5.5.2.1001&permalinkId='+mediaId+'&player=videodetailsembedded&videoAutoPlay='+options.AutoplayNum+'&id=anonymous', { |
---|
907 | id: mediaId, |
---|
908 | width: mediaWidth, |
---|
909 | height: mediaHeight, |
---|
910 | params: {wmode: options.wmode, bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen} |
---|
911 | }); |
---|
912 | startEffect(); |
---|
913 | // Viddler |
---|
914 | } else if (URL.match(/viddler\.com/i)) { |
---|
915 | mediaType = 'obj'; |
---|
916 | mediaWidth = mediaWidth || "437px"; |
---|
917 | mediaHeight = mediaHeight || "370px"; |
---|
918 | mediaSplit = URL.split('/'); |
---|
919 | mediaId = mediaSplit[4]; |
---|
920 | preload = new Swiff(URL, { |
---|
921 | id: 'viddler_'+mediaId, |
---|
922 | movie: URL, |
---|
923 | classid: 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000', |
---|
924 | width: mediaWidth, |
---|
925 | height: mediaHeight, |
---|
926 | params: {wmode: options.wmode, bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen, id: 'viddler_'+mediaId, movie: URL} |
---|
927 | }); |
---|
928 | startEffect(); |
---|
929 | // Viddyou |
---|
930 | } else if (URL.match(/viddyou\.com/i)) { |
---|
931 | mediaType = 'obj'; |
---|
932 | mediaWidth = mediaWidth || "416px"; |
---|
933 | mediaHeight = mediaHeight || "312px"; |
---|
934 | mediaSplit = URL.split('='); |
---|
935 | mediaId = mediaSplit[1]; |
---|
936 | preload = new Swiff('http://www.viddyou.com/get/v2_'+options.vuPlayer+'/'+mediaId+'.swf', { |
---|
937 | id: mediaId, |
---|
938 | movie: 'http://www.viddyou.com/get/v2_'+options.vuPlayer+'/'+mediaId+'.swf', |
---|
939 | width: mediaWidth, |
---|
940 | height: mediaHeight, |
---|
941 | params: {wmode: options.wmode, bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen} |
---|
942 | }); |
---|
943 | startEffect(); |
---|
944 | // Vimeo (now includes HTML5 option) |
---|
945 | } else if (URL.match(/vimeo\.com/i)) { |
---|
946 | mediaWidth = mediaWidth || "640px"; // site defualt: 400px |
---|
947 | mediaHeight = mediaHeight || "360px"; // site defualt: 225px |
---|
948 | mediaSplit = URL.split('/'); |
---|
949 | mediaId = mediaSplit[3]; |
---|
950 | |
---|
951 | if (options.html5) { |
---|
952 | mediaType = 'url'; |
---|
953 | mediaId = "mediaId_"+new Date().getTime(); // Safari may not update iframe content with a static id. |
---|
954 | preload = new Element('iframe', { |
---|
955 | 'src': 'http://player.vimeo.com/video/'+mediaSplit[3]+'?portrait='+options.vmPortrait, |
---|
956 | 'id': mediaId, |
---|
957 | 'width': mediaWidth, |
---|
958 | 'height': mediaHeight, |
---|
959 | 'frameborder': 0 |
---|
960 | }); |
---|
961 | startEffect(); |
---|
962 | } else { |
---|
963 | mediaType = 'obj'; |
---|
964 | preload = new Swiff('http://www.vimeo.com/moogaloop.swf?clip_id='+mediaId+'&server=www.vimeo.com&fullscreen='+options.fullscreenNum+'&autoplay='+options.autoplayNum+'&show_title='+options.vmTitle+'&show_byline='+options.vmByline+'&show_portrait='+options.vmPortrait+'&color='+options.vmColor, { |
---|
965 | id: mediaId, |
---|
966 | width: mediaWidth, |
---|
967 | height: mediaHeight, |
---|
968 | params: {wmode: options.wmode, bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen} |
---|
969 | }); |
---|
970 | startEffect(); |
---|
971 | } |
---|
972 | // 12seconds |
---|
973 | } else if (URL.match(/12seconds\.tv/i)) { |
---|
974 | mediaType = 'obj'; |
---|
975 | mediaWidth = mediaWidth || "430px"; |
---|
976 | mediaHeight = mediaHeight || "360px"; |
---|
977 | mediaSplit = URL.split('/'); |
---|
978 | mediaId = mediaSplit[5]; |
---|
979 | preload = new Swiff('http://embed.12seconds.tv/players/remotePlayer.swf', { |
---|
980 | id: mediaId, |
---|
981 | width: mediaWidth, |
---|
982 | height: mediaHeight, |
---|
983 | params: {flashvars: 'vid='+mediaId+'', wmode: options.wmode, bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen} |
---|
984 | }); |
---|
985 | startEffect(); |
---|
986 | |
---|
987 | /* Specific Content Types */ |
---|
988 | |
---|
989 | // INLINE |
---|
990 | } else if (URL.match(/\#mb_/i)) { |
---|
991 | mediaType = 'inline'; |
---|
992 | mediaWidth = mediaWidth || options.defaultWidth; |
---|
993 | mediaHeight = mediaHeight || options.defaultHeight; |
---|
994 | URLsplit = URL.split('#'); |
---|
995 | preload = document.id(URLsplit[1]).get('html'); |
---|
996 | startEffect(); |
---|
997 | // HTML |
---|
998 | } else { |
---|
999 | mediaType = 'url'; |
---|
1000 | mediaWidth = mediaWidth || options.defaultWidth; |
---|
1001 | mediaHeight = mediaHeight || options.defaultHeight; |
---|
1002 | mediaId = "mediaId_"+new Date().getTime(); // Safari may not update iframe content with a static id. |
---|
1003 | preload = new Element('iframe', { |
---|
1004 | 'src': URL, |
---|
1005 | 'id': mediaId, |
---|
1006 | 'width': mediaWidth, |
---|
1007 | 'height': mediaHeight, |
---|
1008 | 'frameborder': 0 |
---|
1009 | }); |
---|
1010 | startEffect(); |
---|
1011 | } |
---|
1012 | } |
---|
1013 | return false; |
---|
1014 | } |
---|
1015 | |
---|
1016 | function startEffect() { |
---|
1017 | if (mediaType == "img"){ |
---|
1018 | mediaWidth = preload.width; |
---|
1019 | mediaHeight = preload.height; |
---|
1020 | if (options.imgBackground) { |
---|
1021 | image.setStyles({backgroundImage: "url("+URL+")", display: ""}); |
---|
1022 | } else { // Thanks to Dusan Medlin for fixing large 16x9 image errors in a 4x3 browser |
---|
1023 | if (mediaHeight >= winHeight-options.imgPadding && (mediaHeight / winHeight) >= (mediaWidth / winWidth)) { |
---|
1024 | mediaHeight = winHeight-options.imgPadding; |
---|
1025 | mediaWidth = preload.width = parseInt((mediaHeight/preload.height)*mediaWidth); |
---|
1026 | preload.height = mediaHeight; |
---|
1027 | } else if (mediaWidth >= winWidth-options.imgPadding && (mediaHeight / winHeight) < (mediaWidth / winWidth)) { |
---|
1028 | mediaWidth = winWidth-options.imgPadding; |
---|
1029 | mediaHeight = preload.height = parseInt((mediaWidth/preload.width)*mediaHeight); |
---|
1030 | preload.width = mediaWidth; |
---|
1031 | } |
---|
1032 | if (Browser.Engine.trident) preload = document.id(preload); |
---|
1033 | preload.addEvent('mousedown', function(e){ e.stop(); }).addEvent('contextmenu', function(e){ e.stop(); }); |
---|
1034 | image.setStyles({backgroundImage: "none", display: ""}); |
---|
1035 | preload.inject(image); |
---|
1036 | } |
---|
1037 | } else if (mediaType == "obj") { |
---|
1038 | if (Browser.Plugins.Flash.version<8) { |
---|
1039 | image.setStyles({backgroundImage: "none", display: ""}); |
---|
1040 | image.set('html', '<div id="mbError"><b>Error</b><br/>Adobe Flash is either not installed or not up to date, please visit <a href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" title="Get Flash" target="_new">Adobe.com</a> to download the free player.</div>'); |
---|
1041 | mediaWidth = options.DefaultWidth; |
---|
1042 | mediaHeight = options.DefaultHeight; |
---|
1043 | } else { |
---|
1044 | image.setStyles({backgroundImage: "none", display: ""}); |
---|
1045 | preload.inject(image); |
---|
1046 | } |
---|
1047 | } else if (mediaType == "qt") { |
---|
1048 | image.setStyles({backgroundImage: "none", display: ""}); |
---|
1049 | preload; |
---|
1050 | } else if (mediaType == "inline") { |
---|
1051 | // if (options.overflow) image.setStyles({overflow: options.overflow}); |
---|
1052 | image.setStyles({backgroundImage: "none", display: ""}); |
---|
1053 | image.set('html', preload); |
---|
1054 | } else if (mediaType == "url") { |
---|
1055 | image.setStyles({backgroundImage: "none", display: ""}); |
---|
1056 | preload.inject(image); |
---|
1057 | } else { |
---|
1058 | image.setStyles({backgroundImage: "none", display: ""}); |
---|
1059 | image.set('html', '<div id="mbError"><b>Error</b><br/>A file type error has occoured, please visit <a href="iaian7.com/webcode/mediaboxAdvanced" title="mediaboxAdvanced" target="_new">iaian7.com</a> or contact the website author for more information.</div>'); |
---|
1060 | mediaWidth = options.defaultWidth; |
---|
1061 | mediaHeight = options.defaultHeight; |
---|
1062 | } |
---|
1063 | image.setStyles({width: mediaWidth, height: mediaHeight}); |
---|
1064 | caption.setStyles({width: mediaWidth}); |
---|
1065 | |
---|
1066 | title.set('html', (options.showCaption) ? captionSplit[0] : ""); |
---|
1067 | caption.set('html', (options.showCaption && (captionSplit.length > 1)) ? captionSplit[1] : ""); |
---|
1068 | number.set('html', (options.showCounter && (images.length > 1)) ? options.counterText.replace(/{x}/, activeImage + 1).replace(/{y}/, images.length) : ""); |
---|
1069 | |
---|
1070 | if ((prevImage >= 0) && (images[prevImage][0].match(/\.gif|\.jpg|\.jpeg|\.png|twitpic\.com/i))) preloadPrev.src = images[prevImage][0].replace(/twitpic\.com/i, "twitpic.com/show/full"); |
---|
1071 | if ((nextImage >= 0) && (images[nextImage][0].match(/\.gif|\.jpg|\.jpeg|\.png|twitpic\.com/i))) preloadNext.src = images[nextImage][0].replace(/twitpic\.com/i, "twitpic.com/show/full"); |
---|
1072 | |
---|
1073 | mediaWidth = image.offsetWidth; |
---|
1074 | mediaHeight = image.offsetHeight+bottom.offsetHeight; |
---|
1075 | if (mediaHeight >= top+top) { mTop = -top } else { mTop = -(mediaHeight/2) }; |
---|
1076 | if (mediaWidth >= left+left) { mLeft = -left } else { mLeft = -(mediaWidth/2) }; |
---|
1077 | if (options.resizeOpening) { fx.resize.start({width: mediaWidth, height: mediaHeight, marginTop: mTop-margin, marginLeft: mLeft-margin}); |
---|
1078 | } else { center.setStyles({width: mediaWidth, height: mediaHeight, marginTop: mTop-margin, marginLeft: mLeft-margin}); imageAnimate(); } |
---|
1079 | } |
---|
1080 | |
---|
1081 | function imageAnimate() { |
---|
1082 | fx.image.start(1); |
---|
1083 | } |
---|
1084 | |
---|
1085 | function captionAnimate() { |
---|
1086 | center.className = ""; |
---|
1087 | if (prevImage >= 0) prevLink.style.display = ""; |
---|
1088 | if (nextImage >= 0) nextLink.style.display = ""; |
---|
1089 | fx.bottom.start(1); |
---|
1090 | } |
---|
1091 | |
---|
1092 | function stop() { |
---|
1093 | if (preload) preload.onload = $empty; |
---|
1094 | fx.resize.cancel(); |
---|
1095 | fx.image.cancel().set(0); |
---|
1096 | fx.bottom.cancel().set(0); |
---|
1097 | $$(prevLink, nextLink).setStyle("display", "none"); |
---|
1098 | } |
---|
1099 | |
---|
1100 | function close() { |
---|
1101 | if (activeImage >= 0) { |
---|
1102 | preload.onload = $empty; |
---|
1103 | image.set('html', ''); |
---|
1104 | for (var f in fx) fx[f].cancel(); |
---|
1105 | center.setStyle("display", "none"); |
---|
1106 | fx.overlay.chain(setup).start(0); |
---|
1107 | } |
---|
1108 | return false; |
---|
1109 | } |
---|
1110 | })(); |
---|
1111 | |
---|
1112 | /* Autoload code block */ |
---|
1113 | |
---|
1114 | Mediabox.scanPage = function() { |
---|
1115 | // $$('#mb_').each(function(hide) { hide.set('display', 'none'); }); |
---|
1116 | var links = $$("a").filter(function(el) { |
---|
1117 | return el.rel && el.rel.test(/^lightbox/i); |
---|
1118 | }); |
---|
1119 | //[VB] |
---|
1120 | //$$(links).mediabox({/* Put custom options here */}, null, function(el) { |
---|
1121 | var _options = shadogoOptions || {}; |
---|
1122 | $$(links).mediabox(_options, null, function(el) { |
---|
1123 | var rel0 = this.rel.replace(/[[]|]/gi," "); |
---|
1124 | var relsize = rel0.split(" "); |
---|
1125 | return (this == el) || ((this.rel.length > 8) && el.rel.match(relsize[1])); |
---|
1126 | }); |
---|
1127 | }; |
---|
1128 | window.addEvent("domready", Mediabox.scanPage); |
---|