lutman.module in SWF Tools 5
File
lutman/lutman.module
View source
<?php
function lutman_swftools_methods() {
$methods = array();
$methods[SWFTOOLS_EMBED_METHOD]['lutman_replace'] = array(
'name' => 'lutman_replace',
'module' => 'lutman',
'shared_file' => 'lutman/jquery.flash.js',
'title' => t('jQuery Plugin - Luke Lutman'),
);
return $methods;
}
function lutman_swftools_embed($action = 'add_js', $methods = FALSE, $vars = FALSE, $html_alt = '') {
static $lutman_has_run;
if (!$lutman_has_run) {
drupal_add_js(swftools_get_player_path() . '/lutman/jquery.flash.js');
drupal_add_js(_lutman_header_js(), 'inline', 'header');
$lutman_has_run = TRUE;
if ($action == 'add_js') {
return;
}
}
static $unique_id = 0;
$unique_id++;
$id = time() . $unique_id;
$html = '<div id="swfobject-id-' . $id . '" class="swftools lutman" ' . swftools_json_params($vars->params, 'swftools') . ' ' . ">\n" . $html_alt . '</div>';
return $html;
}
function _lutman_header_js() {
$js = "\n \$(document).ready(function(){\n \$('.lutman').flash(null, {version:7}, function(htmlOptions) {\n htmlOptions = Drupal.parseJson(\$(this).attr('swftools'));\n \$(this).parent().prepend(\$.fn.flash.transform(htmlOptions));\n \$(this).remove();\n });\n });\n ";
return $js;
}
Functions
Name |
Description |
lutman_swftools_embed |
Implementation of swftools_embed hook
Returns the markup for the page, plus set necessary javascript. |
lutman_swftools_methods |
SWF Tools - Luke Lutman Flash Replacement |
_lutman_header_js |
The jQuery code that will try to replace all elements after the page loads.
This parses the JSON out of the 'data' attribute of all swftools-embed divs. |