--- jq_eyecandy.module 2008-04-14 13:50:13.000000000 -0500
+++ jq_eyecandy.module 2009-08-28 16:52:36.000000000 -0500
@@ -11,6 +11,7 @@
*/
function _jq_eyecandy_plugins() {
+ module_load_include('module', 'jquery_update');
// to add support for additional plugins, add them as keys to the $plugins array
$plugins = array ('colorblend' => '', 'curvycorners' => '', 'dropshadow' => '', 'gradient' => '', 'reflect' => '');
@@ -18,6 +19,9 @@ function _jq_eyecandy_plugins() {
$plugins[$k] = drupal_get_path('module', 'jquery_plugin') .'/jquery.' . $k . '.min.js';
}
+ $plugins['jquery_version'] = jquery_update_get_version('misc/jquery.js');
+ $plugins['jquery_version'] = intval(str_replace('.', '', $plugins['jquery_version']));
+
return $plugins;
}
@@ -30,9 +34,6 @@ function jq_eyecandy_init() {
foreach ($plugins as $k => $v) {
if (is_file($plugins[$k]) && variable_get('jq_eyecandy_'. $k .'_enabled', '')) {
jquery_plugin_add($k);
- if ((($k == 'dropshadow') || ($k == 'gradient')) && is_file(drupal_get_path('module', 'jquery_plugin') .'/jquery.dimensions.min.js')){
- jquery_plugin_add('dimensions');
- }
drupal_add_js(variable_get('jq_eyecandy_' . $k . '_code', NULL), 'inline');
}
}
@@ -63,6 +64,13 @@ function jq_eyecandy_admin_settings() {
$plugins = _jq_eyecandy_plugins();
+ // As of jquery version 1.2.6, dimensions is included in jquery core
+ $dimensions_installed = (($plugins['jquery_version'] >= 126) || is_file(drupal_get_path('module', 'jquery_plugin') .'/jquery.dimensions.min.js')) ? 1:0;
+
+ if (!$dimensions_installed){
+ $print_dimensions_required = ''. t('This plugin requires the dimensions plugin which is unavailable or not located in the jquery_plugin module directory.') .'';
+ }
+
//colorblend plugin
$form['jq_eyecandy_colorblend'] = array(
'#type' => 'fieldset',
@@ -116,11 +124,12 @@ function jq_eyecandy_admin_settings() {
'#description' => t('Enter jQuery Corners code to be applied to all pages in all themes. Documentation is available at http://blue-anvil.com/archives/anti-aliased-rounded-corners-with-jquery. Enter everything that should appear within the <script> tags.')
);
+
//dropshadow plugin
$form['jq_eyecandy_dropshadow'] = array(
'#type' => 'fieldset',
'#title' => t('DropShadow Plugin'),
- '#description' => is_file(drupal_get_path('module', 'jquery_plugin') .'/jquery.dimensions.min.js') ? t('This plugin requires the dimensions plugin which is available at: /') . $plugins['dropshadow'] : ''. t('This plugin requires the dimensions plugin which is unavailable or not located in the jquery_plugin module directory.') .'',
+ '#description' => $print_dimensions_required,
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#weight' => -8
@@ -129,8 +138,8 @@ function jq_eyecandy_admin_settings() {
$form['jq_eyecandy_dropshadow']['jq_eyecandy_dropshadow_enabled'] = array(
'#type' => 'checkbox',
'#title' => t('Enable the jQuery DropShadow Plugin'),
- '#default_value' => is_file(drupal_get_path('module', 'jquery_plugin') .'/jquery.dimensions.min.js') ? variable_get(jq_eyecandy_dropshadow_enabled, '') : 0,
- '#disabled' => !is_file($plugins['dropshadow']) || !is_file(drupal_get_path('module', 'jquery_plugin') .'/jquery.dimensions.min.js'),
+ '#default_value' => $dimensions_installed ? variable_get(jq_eyecandy_dropshadow_enabled, '') : 0,
+ '#disabled' => !is_file($plugins['dropshadow']) || !$dimensions_installed,
'#description' => is_file($plugins['dropshadow']) ? t('The jQuery DropShadow plugin is available at: /') . $plugins['dropshadow'] : ''. t('The jQuery DropShadow plugin is unavailable or not located in the jquery_plugin module directory.') .''
);
@@ -139,7 +148,7 @@ function jq_eyecandy_admin_settings() {
'#title' => t('jQuery DropShadow code to apply on all pages'),
'#default_value' => variable_get('jq_eyecandy_dropshadow_code', ''),
'#rows' => 10,
- '#disabled' => !is_file($plugins['dropshadow']) || !is_file(drupal_get_path('module', 'jquery_plugin') .'/jquery.dimensions.min.js'),
+ '#disabled' => !is_file($plugins['dropshadow']) || !$dimensions_installed,
'#description' => t('Enter jQuery DropShadow code to be applied to all pages in all themes. Documentation is available at http://plugins.jquery.com/project/DropShadow. Enter everything that should appear within the <script> tags.')
);
@@ -147,7 +156,7 @@ function jq_eyecandy_admin_settings() {
$form['jq_eyecandy_gradient'] = array(
'#type' => 'fieldset',
'#title' => t('Gradient Plugin'),
- '#description' => is_file(drupal_get_path('module', 'jquery_plugin') .'/jquery.dimensions.min.js') ? t('This plugin requires the dimensions plugin which is available at: /') . $plugins['dropshadow'] : ''. t('This plugin requires the dimensions plugin which is unavailable or not located in the jquery_plugin module directory.') .'',
+ '#description' => $print_dimensions_required,
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#weight' => -7
@@ -156,8 +165,8 @@ function jq_eyecandy_admin_settings() {
$form['jq_eyecandy_gradient']['jq_eyecandy_gradient_enabled'] = array(
'#type' => 'checkbox',
'#title' => t('Enable the jQuery Gradient Plugin'),
- '#default_value' => is_file(drupal_get_path('module', 'jquery_plugin') .'/jquery.dimensions.min.js') ? variable_get(jq_eyecandy_gradient_enabled, '') : 0,
- '#disabled' => !is_file($plugins['gradient']) || !is_file(drupal_get_path('module', 'jquery_plugin') .'/jquery.dimensions.min.js'),
+ '#default_value' => $dimensions_installed ? variable_get(jq_eyecandy_gradient_enabled, '') : 0,
+ '#disabled' => !is_file($plugins['gradient']) || !$dimensions_installed,
'#description' => is_file($plugins['gradient']) ? t('The jQuery Gradient plugin is available at: /') . $plugins['gradient'] : ''. t('The jQuery Gradient plugin is unavailable or not located in the jquery_plugin module directory.') .''
);
@@ -166,7 +175,7 @@ function jq_eyecandy_admin_settings() {
'#title' => t('jQuery Gradient code to apply on all pages'),
'#default_value' => variable_get('jq_eyecandy_gradient_code', ''),
'#rows' => 10,
- '#disabled' => !is_file($plugins['gradient']) || !is_file(drupal_get_path('module', 'jquery_plugin') .'/jquery.dimensions.min.js'),
+ '#disabled' => !is_file($plugins['gradient']) || !$dimensions_installed,
'#description' => t('Enter jQuery Gradient code to be applied to all pages in all themes. Documentation is available at http://plugins.jquery.com/project/gradient. Enter everything that should appear within the <script> tags.')
);