Sha256: e71ff737e9d451193467f93cc9131b8f3998a455eb8c8db81daa4072a65a917a

Contents?: true

Size: 1.32 KB

Versions: 1

Compression:

Stored size: 1.32 KB

Contents

angular.module('EssayApp.directives').directive "ngOwl", ['$timeout', ($timeout) ->
  restrict: 'A'
  scope: true
  link: (scope, element, attrs) ->
    defaults = {
      items: 4
      nav: false
      mouseDrag: false
      dots: false
      responsive:
        0:
          items: 1
          nav: true
          loop: true
          dots: true
        768:
          items: 4
          nav: false
          loop: false
          dots: false
      onChanged: (evt)->
        if this.settings?.items is 1
          curr = element.data?('owlCarousel')?.current?() || 0
          item = element.find('.owl-item').eq(curr)
          if item.hasClass('cloned')
            uid = item.find('[uid]').attr('uid')
            item = element.find(".owl-item:not(.cloned) [uid=#{uid}]").closest('.owl-item') if uid?
          item.find('a').trigger('click') if curr >= 0
    }
      # available callbacks
      # onInitialize
      # onInitialized
      # onResize
      # onResized
      # onRefresh
      # onRefreshed
      # onDrag
      # onDragged
      # onChange
      # onChanged
    options = scope.$eval(attrs.ngOwl) || {}
    options = $.extend defaults, options

    init = ->
      return unless element.children().length > 1
      $timeout (->
        element.owlCarousel(options)
        return
      ), 10, false

    $timeout init, 10, false
]

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
translation_cms-0.1.5 app/assets/javascripts/app/directives/ng-owl.js.coffee