You are here

function itweak_upload_init in iTweak Upload 6.2

Same name and namespace in other branches
  1. 7.3 itweak_upload.module \itweak_upload_init()

Implementation of hook_init().

File

./itweak_upload.module, line 32
iTweakUpload - Tweak attachments display and file upload forms.

Code

function itweak_upload_init() {
  drupal_add_css(drupal_get_path('module', 'itweak_upload') . '/itweak_upload.css');
  $carousel_visible = ITU_CAROUSEL_VISIBLE_ITEMS;
  if (module_exists('jcarousellite')) {
    $selector = '.itu-attachment-thumbs-jcarousellite';
    $jcarousellite_options = <<<END
//    btnGo: ['.externalControl .1', '.externalControl .2', '.externalControl .3'],
    auto: null, //     auto: 800, speed: 1000,
    speed: 400,
    vertical: false,
    circular: false,
    visible: {<span class="php-variable">$carousel_visible</span>},
    start: 0,
    scroll: 1,
    mouseWheel: true,
END;
    $js = <<<END
\$(function() {
  \$("{<span class="php-variable">$selector</span>}").each(function(index) {
    l=\$(this);
    p=l.parents('.itu-attachment-images');
    if (!p[0].id) {p[0].id = 'itu-attachment-images-' + index;}
    c=l.parents('.item-list')
    c.jCarouselLite({
      btnPrev: "#" + p[0].id + " .itu-attachment-jcarousellite-prev",
      btnNext: "#" + p[0].id + " .itu-attachment-jcarousellite-next",
      {<span class="php-variable">$jcarousellite_options</span>}
    });
    // Fix jCarousel Lite width bug:
    ul=\$("ul",c);
    h=\$.css(ul[0],'width');
    h+=8;
    ul.css('width',h+"px")
  });
});
END;
    jcarousellite_add($js);
  }
  if (module_exists('jcarousel')) {
    $selector = '.itu-attachment-thumbs-jcarousel';
    $options = array(
      'scroll' => 1,
    );
    $skin = 0 ? 'ie7' : 'tango';
    $skin_path = '';
    jcarousel_add($selector, $options, $skin, $skin_path);
  }
}