Sha256: 348791162fc99244f673400b963ac1e630ed67ec9f8cf80c581ba969501aa5a0

Contents?: true

Size: 1.84 KB

Versions: 18

Compression:

Stored size: 1.84 KB

Contents

(function($) {
  $.widget('pageflow.shareMenu', {
    _create: function() {
      var $element = this.element,
          options = this.options,
          $links = options.links || $('a', $element),
          $subMenu = options.subMenu || $($element.find('.sub_share')),
          $subLinks = $('a', $subMenu),
          $closeOnMouseLeaving = options.closeOnMouseLeaving,
          scroller = options.scroller;

      $links.on('click', function(event) {

        var $this = $(this),
            $a = $this.find('a').length ? $this.find('a') : $this,
            active = $a.hasClass('active');

        if ($a.data('share-page')) {
          $links.removeClass('active');
          $a.addClass('active');

          event.preventDefault();

          var $currentPage = pageflow.slides.currentPage(),
              id = $currentPage.attr('id') || $currentPage.data('perma-id'),
              siteShareUrl = $a.data('share-page').replace(/permaId$/, id),
              $insertAfter = options.insertAfter || $a;

          $($subLinks[0]).attr('href', $a.attr('href'));
          $($subLinks[1]).attr('href', siteShareUrl);

          if (!$insertAfter.next().hasClass('sub_share')) {
            $insertAfter.after($subMenu);
          }

          if (active) {
            $subMenu.toggle();
            $a.toggleClass('active');
          }
          else {
            $subMenu.show();
            $links.find('.button').removeClass('pressed');
            $(this).find('.button').addClass('pressed');
          }

          if (scroller) {
            scroller.refresh();
          }
        }
      });

      if(!!$closeOnMouseLeaving) {
        $closeOnMouseLeaving.on('mouseleave', function() {
          $links.removeClass('active').blur();
          $(this).find('.button').removeClass('pressed');
          $subMenu.hide();
        });
      }
    }
  });
}(jQuery));

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
pageflow-14.5.2 app/assets/javascripts/pageflow/widgets/share_menu.js
pageflow-15.0.2 app/assets/javascripts/pageflow/widgets/share_menu.js
pageflow-15.0.1 app/assets/javascripts/pageflow/widgets/share_menu.js
pageflow-15.0.0 app/assets/javascripts/pageflow/widgets/share_menu.js
pageflow-14.5.1 app/assets/javascripts/pageflow/widgets/share_menu.js
pageflow-14.5.0 app/assets/javascripts/pageflow/widgets/share_menu.js
pageflow-15.0.0.rc2 app/assets/javascripts/pageflow/widgets/share_menu.js
pageflow-15.0.0.rc1 app/assets/javascripts/pageflow/widgets/share_menu.js
pageflow-15.0.0.beta4 app/assets/javascripts/pageflow/widgets/share_menu.js
pageflow-15.0.0.beta3 app/assets/javascripts/pageflow/widgets/share_menu.js
pageflow-14.4.0 app/assets/javascripts/pageflow/widgets/share_menu.js
pageflow-15.0.0.beta2 app/assets/javascripts/pageflow/widgets/share_menu.js
pageflow-15.0.0.beta1 app/assets/javascripts/pageflow/widgets/share_menu.js
pageflow-14.3.0 app/assets/javascripts/pageflow/widgets/share_menu.js
pageflow-14.2.1 app/assets/javascripts/pageflow/widgets/share_menu.js
pageflow-14.2.0 app/assets/javascripts/pageflow/widgets/share_menu.js
pageflow-14.1.1 app/assets/javascripts/pageflow/widgets/share_menu.js
pageflow-14.1.0 app/assets/javascripts/pageflow/widgets/share_menu.js