You are here

function itweak_upload_init in iTweak Upload 7.3

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

Implements hook_init().

File

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

Code

function itweak_upload_init() {
  $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")
  });
})(jQuery);
END;
    jcarousellite_add($js);
  }
  if (module_exists('jcarousel')) {
    $selector = '.itu-attachment-thumbs-jcarousel';
    $options = array(
      'scroll' => 1,
      //      'visible' => $carousel_visible,  // FIXME: jCarousel scales images to fit into the given width
      'skin' => 0 ? 'ie7' : 'tango',
      'skin path' => '',
    );
    jcarousel_add($selector, $options);
  }
}