Sha256: 7d1b29e08b6d27d08885c27197a6365beb55ce78541527801b4e27fe85afc895

Contents?: true

Size: 1.96 KB

Versions: 13

Compression:

Stored size: 1.96 KB

Contents

(function($) {
  $.widget('pageflow.linkmapAreaIndicators', {
    _create: function() {
      this.touchIndicator = this.element.find('.touch_indicator');
      this.externalLinkLoadingIndicator = this.element.find('.external_link_loading_indicator');
    },

    displayForSelectedArea: function(area, event) {
      if (!area.hasClass('dynamic_marker') &&
          !area.hasClass('text_only_area')) {
        this._animateTouchIndicator(event);
      }
    },

    displayForClickedArea: function(area, event) {
      if (!area.hasClass('dynamic_marker') &&
          area.hasClass('external_site_area') &&
          area.hasClass('target_self')) {
        this._displayExternalLinkLoadingIndicator(event);
      }
    },

    reset: function() {
      this.externalLinkLoadingIndicator.hide();
    },

    _animateTouchIndicator: function(event) {
      this._updatePosition(this.touchIndicator, event);
      this._animate(this.touchIndicator);
    },

    _displayExternalLinkLoadingIndicator: function(event) {
      this._updatePosition(this.externalLinkLoadingIndicator, event);
      this.externalLinkLoadingIndicator.show();
    },

    _animate: function(element) {
      element.hide();

      setTimeout(function() {
        element.show();
      }, 500);

      setTimeout(function() {
        element.hide();
      }, 1200);
    },

    _updatePosition: function(element, event) {
      if (event) {
        this._updatePositionByEvent(element, event);
      }
      else {
        this._center(element);
      }
    },

    _updatePositionByEvent: function(element, event) {
      var touch = event.touches ? event.touches[0] : event;
      var parentClientRect = this.options.pageElement[0].getBoundingClientRect();

      element.css({
        left: touch.clientX - parentClientRect.left,
        top: touch.clientY - parentClientRect.top
      });
    },

    _center: function(element) {
      element.css({
        left: '50%',
        top: '40%'
      });
    }
  });
}(jQuery));

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
pageflow-linkmap-page-2.10.0 app/assets/javascript/pageflow/linkmap_page/widgets/linkmap_area_indicators.js
pageflow-linkmap-page-2.9.0 app/assets/javascript/pageflow/linkmap_page/widgets/linkmap_area_indicators.js
pageflow-linkmap-page-2.8.0 app/assets/javascript/pageflow/linkmap_page/widgets/linkmap_area_indicators.js
pageflow-linkmap-page-2.7.1 app/assets/javascript/pageflow/linkmap_page/widgets/linkmap_area_indicators.js
pageflow-linkmap-page-2.7.0 app/assets/javascript/pageflow/linkmap_page/widgets/linkmap_area_indicators.js
pageflow-linkmap-page-2.6.1 app/assets/javascript/pageflow/linkmap_page/widgets/linkmap_area_indicators.js
pageflow-linkmap-page-2.6.0 app/assets/javascript/pageflow/linkmap_page/widgets/linkmap_area_indicators.js
pageflow-linkmap-page-2.5.0 app/assets/javascript/pageflow/linkmap_page/widgets/linkmap_area_indicators.js
pageflow-linkmap-page-2.4.0 app/assets/javascript/pageflow/linkmap_page/widgets/linkmap_area_indicators.js
pageflow-linkmap-page-2.3.0 app/assets/javascript/pageflow/linkmap_page/widgets/linkmap_area_indicators.js
pageflow-linkmap-page-2.2.0 app/assets/javascript/pageflow/linkmap_page/widgets/linkmap_area_indicators.js
pageflow-linkmap-page-2.1.0 app/assets/javascript/pageflow/linkmap_page/widgets/linkmap_area_indicators.js
pageflow-linkmap-page-2.0.0 app/assets/javascript/pageflow/linkmap_page/widgets/linkmap_area_indicators.js