Advertisement
Da_Gamer

Carousel Directive JS

Apr 19th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. (function () {
  3.     'use strict';
  4.  
  5.     angular
  6.         .module(usbeefConstants.generateName(usbeefConstants.appModule, usbeefConstants.NAMETYPES.module))
  7.         .directive(usbeefConstants.generateName('pivot', usbeefConstants.NAMETYPES.directive), pivot);
  8.  
  9.     pivot.$inject = ['pivotservice', 'logger'];
  10.     function pivot(pivotservice, logger) {
  11.         // Usage:
  12.         //     <usbeefcorp-metrodb-pivot></usbeefcorp-metrodb-pivot>
  13.         // Creates:
  14.         //     usbeefcorpMetrodbTemplate in javascript
  15.         //    
  16.  
  17.         var directive = {
  18.  
  19.             restrict: 'E',
  20.             scope: {
  21.                 attribute1: '@',
  22.                 attribute2: '='
  23.             },
  24.             link: function (scope, element, attrs, controller) {
  25.                 // pasted previous code here because don't know what to do from here
  26.                 $(function () {
  27.                     var car_m_2 = $('#section').data('carousel');
  28.                     var thumbs = $('#section-indexes > .pivot');
  29.                     $.each(thumbs, function () {
  30.                         var thumb = $(this), index = thumb.data('index') - 1;
  31.                         thumb.on('click', function () {
  32.                             car_m_2.slideTo(index);
  33.                         });
  34.                     });
  35.                 });
  36.             },
  37.             controller: pivotController,
  38.             controllerAs: 'temp',
  39.             //TEMPLATEURL should not be changed
  40.             templateUrl: '/App/directives/pivot.directive.html'
  41.         };
  42.  
  43.         return directive;
  44.     }
  45.  
  46.     pivotController.$inject = ['$scope', 'pivotservice', 'logger'];
  47.     function pivotController($scope, pivotservice, logger) {
  48.  
  49.         var pivot = this;
  50.         pivot.pivot = [];
  51.         activate();
  52.  
  53.         function activate() {
  54.             logger.log('pivot.directive.js - activate() completed');
  55.         }
  56.  
  57.     }
  58.  
  59. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement