You are here

function _manualcrop_attach_files in Manual Crop 7

Attach the required css, javascript and libraries.

Parameters

$element: The form element on which the files should be attached. Use to NULL to invoke the Internet Explorer lazy loading css fix.

2 calls to _manualcrop_attach_files()
manualcrop_field_widget_form_alter in ./manualcrop.module
Implements hook_field_widget_form_alter().
_manualcrop_attach_dependencies in ./manualcrop.helpers.inc
Attach the required croptool dependencies (files and settings).

File

./manualcrop.helpers.inc, line 360
Helper functions for the Manual Crop module.

Code

function _manualcrop_attach_files(&$element = NULL) {
  $ie = !empty($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE;
  if ($ie || $element) {
    $path = drupal_get_path('module', 'manualcrop');
    if ($ie) {

      // IE has some issues with the lazy loading of css files, so we preload
      // anything that contains CSS. See http://drupal.org/node/1071818 for more info.
      drupal_add_css($path . '/manualcrop.css');
      libraries_load('jquery.imgareaselect');
    }
    if ($element) {
      $element['#attached']['css'][] = $path . '/manualcrop.css';
      $element['#attached']['js'][] = $path . '/manualcrop.js';
      $element['#attached']['libraries_load'][] = array(
        'jquery.imgareaselect',
      );
      $element['#attached']['libraries_load'][] = array(
        'jquery.imagesloaded',
      );
    }
  }
}