/[drupal]/contributions/modules/swftools/ufo/ufo.module
ViewVC logotype

Contents of /contributions/modules/swftools/ufo/ufo.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.4 - (show annotations) (download) (as text)
Fri Mar 6 19:48:00 2009 UTC (8 months, 3 weeks ago) by stuartgreenfield
Branch: MAIN
CVS Tags: HEAD
Changes since 1.3: +9 -6 lines
File MIME type: text/x-php
Accidentally committed a version that wasn't intended. This (hopefully) reverses the error.
1 <?php
2 // $Id: ufo.module,v 1.3 2009/03/06 16:45:47 stuartgreenfield Exp $
3
4 /**
5 * SWF Tools - UFO
6 *
7 * Enables the use of Bobby Van der Sluis's ufo.js which provides image replacement
8 * for Flash content. ufo.js must be downloaded separately (add the whole zip
9 * file to swftools/shared/
10 *
11 * Author's Site.
12 * http://www.bobbyvandersluis.com/ufo/
13 */
14
15 /**
16 * Implementation of hook_swftools_methods().
17 */
18 function ufo_swftools_methods() {
19
20 $methods = array();
21
22 $methods[SWFTOOLS_EMBED]['ufo_replace'] = array (
23 'name' => 'ufo_replace',
24 'module' => 'ufo',
25 'shared_file' => 'ufo/ufo.js',
26 'title' => t('UFO - JavaScript'),
27 'download' => 'http://www.bobbyvandersluis.com/ufo/',
28 );
29
30 return $methods;
31 }
32
33 /**
34 * Implementation of hook_swftools_embed().
35 * Returns the markup for the page, plus set necessary javascript.
36 */
37 function ufo_swftools_embed($action = 'add_js', $methods = FALSE, $vars = FALSE, $html_alt = '') {
38
39 static $ufo_has_run;
40 static $ufo_id = 0;
41
42 // Output javascript to the header
43 if (!$ufo_has_run) {
44 // Add ufo.js
45 drupal_add_js(swftools_get_player_path() .'/ufo/ufo.js');
46 drupal_add_js(_ufo_header_js(), 'inline', 'header');
47 $ufo_has_run = TRUE;
48 if ($action == 'add_js') {
49 // Exit early having put the javascript in the header.
50 return;
51 }
52 }
53
54 static $unique_id = 0;
55 $unique_id++;
56
57 $html = '<div id="ufo-id-'. time() . $unique_id . '" class="swftools ufo" '.
58 swftools_json_params($vars->params, 'swftools') .' '.">\n".
59 $html_alt .
60 '</div>';
61 return $html;
62 }
63
64 /**
65 * The jQuery code that will try to replace all elements after the page loads.
66 * This parses the JSON out of the 'swftools' attribute of all class="ufo" divs. *
67 */
68 function _ufo_header_js() {
69
70 $js = "
71 $(document).ready(function(){
72 $('.ufo').each(function(i){
73 params = Drupal.parseJson($(this).attr('swftools'));
74 var FO = { movie: params['src'], width: params['width'], height: params['height'],
75 majorversion: params['version'], build: '0', xi: 'false',
76 quality: params['quality'], wmode: params['wmode'], align: params['align'],
77 salign: params['salign'], play: params['play'], loop: params['loop'],
78 menu: params['menu'], base: params['base'], flashvars: params['flashvars'],
79 allowfullscreen: 'true'
80 };
81 UFO.create(FO, this.id);
82 });
83 });
84 ";
85 return $js;
86 }

  ViewVC Help
Powered by ViewVC 1.1.2