View source
<?php
define('JOYRIDE_LIBRARY_VERSION', '2.0.3');
function joyride_libraries_info() {
$libraries['joyride'] = array(
'name' => 'Joyride',
'vendor url' => 'http://www.zurb.com/',
'download url' => 'https://github.com/zurb/joyride',
'version callback' => 'joyride_version',
'version arguments' => array(
'file' => 'jquery.joyride-' . JOYRIDE_LIBRARY_VERSION . '.js',
'pattern' => '/jQuery Foundation Joyride Plugin ([\\d][\\d\\.\\0]+)/',
'lines' => 2,
),
'files' => array(
'js' => array(
'jquery.joyride-' . JOYRIDE_LIBRARY_VERSION . '.js',
'modernizr.mq.js',
),
'css' => array(
'joyride-' . JOYRIDE_LIBRARY_VERSION . '.css',
),
),
);
return $libraries;
}
function joyride_version($library, $options) {
$options += array(
'file' => '',
'pattern' => '',
'lines' => 20,
'cols' => 200,
);
$file = DRUPAL_ROOT . '/' . $library['library path'] . '/' . $options['file'];
if (empty($options['file']) || !file_exists($file)) {
return;
}
$file = fopen($file, 'r');
while ($options['lines'] && ($line = fgets($file, $options['cols']))) {
if (preg_match($options['pattern'], $line, $version)) {
if ($version[1] == JOYRIDE_LIBRARY_VERSION) {
fclose($file);
return $version[1];
}
}
$options['lines']--;
}
fclose($file);
}
function joyride_context_plugins() {
$plugins = array();
$plugins['joyride_context_reaction_add'] = array(
'handler' => array(
'path' => drupal_get_path('module', 'joyride') . '/plugins/context',
'file' => 'joyride_context_reaction_add.inc',
'class' => 'joyride_context_reaction_add',
'parent' => 'context_reaction',
),
);
return $plugins;
}
function joyride_context_registry() {
return array(
'reactions' => array(
'joyride_add' => array(
'title' => t('Joyride Tour'),
'description' => t('Add Joyride code to the page.'),
'plugin' => 'joyride_context_reaction_add',
),
),
);
}
function joyride_ctools_plugin_api($module, $api) {
if ($module !== 'context') {
return FALSE;
}
switch ($api) {
case 'context':
return array(
'version' => 3,
);
case 'plugins':
return array(
'version' => 3,
'path' => drupal_get_path('module', 'joyride') . '/plugins/context',
);
default:
return FALSE;
}
}
function joyride_init() {
$plugin = context_get_plugin('reaction', 'joyride_add');
if ($plugin) {
$plugin
->execute();
}
}
function joyride_theme($existing, $type, $theme, $path) {
return array(
'joyride_tips' => array(
'variables' => array(
'tips_content' => NULL,
),
'template' => 'templates/joyride-tips',
),
'joyride_help' => array(
'variables' => array(),
'template' => 'templates/joyride-help',
),
'joyride_demo' => array(
'variables' => array(),
'template' => 'templates/joyride-demo',
),
'joyride_start_link' => array(
'variables' => array(
'link_title' => NULL,
'options' => array(),
),
'template' => 'templates/joyride-start-link',
'file' => 'inc/joyride.theme.inc',
),
);
}
function joyride_help($path, $arg) {
switch ($path) {
case 'admin/help#joyride':
return theme('joyride_help');
case 'admin/help#joyride#demo#default':
return theme('joyride_demo');
case 'admin/help#joyride#demo#manual-trigger':
return theme('joyride_demo');
case 'admin/help#joyride#demo#play-only-once':
return theme('joyride_demo');
}
}
function joyride_menu() {
$items = array();
$items['admin/config/user-interface/joyride'] = array(
'title' => 'Joyride Demo',
'page callback' => 'theme',
'page arguments' => array(
'joyride_demo',
),
'access arguments' => array(
'access administration pages',
),
'type' => MENU_NORMAL_ITEM,
);
$items['admin/config/user-interface/joyride/auto-start'] = array(
'title' => 'Joyride Demo (Start tour automatically)',
'page callback' => 'theme',
'page arguments' => array(
'joyride_demo',
),
'access arguments' => array(
'access administration pages',
),
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => -10,
);
$items['admin/config/user-interface/joyride/manual-trigger'] = array(
'title' => 'Joyride Demo (Use manual trigger to start tour)',
'page callback' => 'theme',
'page arguments' => array(
'joyride_demo',
),
'access arguments' => array(
'access administration pages',
),
'type' => MENU_LOCAL_TASK,
'weight' => 10,
);
$items['admin/config/user-interface/joyride/play-once'] = array(
'title' => 'Joyride Demo (Play tour only once)',
'page callback' => 'theme',
'page arguments' => array(
'joyride_demo',
),
'access arguments' => array(
'access administration pages',
),
'type' => MENU_LOCAL_TASK,
'weight' => 20,
);
return $items;
}
function joyride_context_default_contexts() {
$export = array();
$context = new stdClass();
$context->disabled = FALSE;
$context->api_version = 3;
$context->name = 'joyride_demo_default';
$context->description = '';
$context->tag = 'joyride';
$context->conditions = array(
'path' => array(
'values' => array(
'admin/config/user-interface/joyride' => 'admin/config/user-interface/joyride',
'admin/config/user-interface/joyride/auto-start' => 'admin/config/user-interface/joyride/auto-start',
),
),
);
$context->reactions = array(
'joyride_add' => array(
'joyride_auto_start' => 1,
'joyride_play_once' => 0,
'joyride_tour_content' => '<li data-class="so-awesome" data-text="Next" class="custom">
<h2>Stop #1</h2>
<p>You can control all the details for you tour stop. Any valid HTML will work inside of Joyride.</p>
</li>
<li data-id="numero2" data-button="Next" data-options="tipLocation:top;tipAnimation:fade">
<h2>Stop #2</h2>
<p>Get the details right by styling Joyride with a custom stylesheet!</p>
</li>
<li data-id="numero3" data-button="Next" data-options="tipLocation:right">
<h2>Stop #3</h2>
<p>It works right aligned.</p>
</li>
<li data-button="Next">
<h2>Stop #4</h2>
<p>It works as a modal too!</p>
</li>
<li data-id="numero5" data-button="Close">
<h2>Stop #5</h2>
<p>Now what are you waiting for? Add this to your projects and get the most out of your apps!</p>
</li>',
),
);
$context->condition_mode = 0;
t('joyride');
$export[$context->name] = $context;
$context = new stdClass();
$context->disabled = FALSE;
$context->api_version = 3;
$context->name = 'joyride_demo_manual_trigger';
$context->description = '';
$context->tag = 'joyride';
$context->conditions = array(
'path' => array(
'values' => array(
'admin/config/user-interface/joyride/manual-trigger' => 'admin/config/user-interface/joyride/manual-trigger',
),
),
);
$context->reactions = array(
'joyride_add' => array(
'joyride_auto_start' => 0,
'joyride_play_once' => FALSE,
'joyride_tour_content' => '<li data-class="so-awesome" data-text="Next" class="custom">
<h2>Stop #1</h2>
<p>You can control all the details for you tour stop. Any valid HTML will work inside of Joyride.</p>
</li>
<li data-id="numero2" data-button="Next" data-options="tipLocation:top;tipAnimation:fade">
<h2>Stop #2</h2>
<p>Get the details right by styling Joyride with a custom stylesheet!</p>
</li>
<li data-id="numero3" data-button="Next" data-options="tipLocation:right">
<h2>Stop #3</h2>
<p>It works right aligned.</p>
</li>
<li data-button="Next">
<h2>Stop #4</h2>
<p>It works as a modal too!</p>
</li>
<li data-id="numero5" data-button="Close">
<h2>Stop #5</h2>
<p>Now what are you waiting for? Add this to your projects and get the most out of your apps!</p>
</li>',
),
);
$context->condition_mode = 0;
t('joyride');
$export[$context->name] = $context;
$context = new stdClass();
$context->disabled = FALSE;
$context->api_version = 3;
$context->name = 'joyride_demo_play_once';
$context->description = '';
$context->tag = 'joyride';
$context->conditions = array(
'path' => array(
'values' => array(
'admin/config/user-interface/joyride/play-once' => 'admin/config/user-interface/joyride/play-once',
),
),
);
$context->reactions = array(
'joyride_add' => array(
'joyride_auto_start' => 1,
'joyride_play_once' => 1,
'joyride_tour_content' => '<li data-class="so-awesome" data-text="Next" class="custom">
<h2>Stop #1</h2>
<p>You can control all the details for you tour stop. Any valid HTML will work inside of Joyride.</p>
</li>
<li data-id="numero2" data-button="Next" data-options="tipLocation:top;tipAnimation:fade">
<h2>Stop #2</h2>
<p>Get the details right by styling Joyride with a custom stylesheet!</p>
</li>
<li data-id="numero3" data-button="Next" data-options="tipLocation:right">
<h2>Stop #3</h2>
<p>It works right aligned.</p>
</li>
<li data-button="Next">
<h2>Stop #4</h2>
<p>It works as a modal too!</p>
</li>
<li data-id="numero5" data-button="Close">
<h2>Stop #5</h2>
<p>Now what are you waiting for? Add this to your projects and get the most out of your apps!</p>
</li>',
),
);
$context->condition_mode = 0;
t('joyride');
$export[$context->name] = $context;
return $export;
}
function joyride_enable() {
drupal_flush_all_caches();
}
function joyride_block_info() {
$blocks['joyride_start_link'] = array(
'info' => t('Joyride Start Link'),
'cache' => DRUPAL_NO_CACHE,
);
return $blocks;
}
function joyride_block_view($delta = '') {
$block = array();
switch ($delta) {
case 'joyride_start_link':
$block['subject'] = '<none>';
$block['content'] = array(
'#theme' => 'joyride_start_link',
);
break;
}
return $block;
}
function joyride_context_page_reaction() {
if ($plugin = context_get_plugin('reaction', 'joyride_add')) {
$plugin
->execute();
}
}