From e791f10e794b7ecdd77baf172ddaffc42c379e71 Mon Sep 17 00:00:00 2001 From: Nicola Peduzzi Date: Mon, 27 Oct 2014 15:07:49 +0100 Subject: [PATCH] Flexslider callbacks expression still receive a `$slider` object, but it is no longer the jQuery slider element. It now is a plain object containing a single key `element` with the previous jQuery element in it. Fix #28 and #34 --- angular-flexslider.coffee | 2 +- angular-flexslider.js | 18 ++++++------------ 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/angular-flexslider.coffee b/angular-flexslider.coffee index 737564b..189c8e0 100644 --- a/angular-flexslider.coffee +++ b/angular-flexslider.coffee @@ -106,7 +106,7 @@ angular.module('angular-flexslider', []) if attrKey in ['start', 'before', 'after', 'end', 'added', 'removed'] options[attrKey] = do (attrVal) -> f = $parse(attrVal) - (slider) -> $scope.$apply -> f($scope, { '$slider': slider }) + (slider) -> $scope.$apply -> f($scope, { '$slider': { element: slider } }) continue options[attrKey] = attrVal diff --git a/angular-flexslider.js b/angular-flexslider.js index 0fa0b27..cbf3869 100644 --- a/angular-flexslider.js +++ b/angular-flexslider.js @@ -1,6 +1,7 @@ -// Generated by CoffeeScript 1.6.2 +// Generated by CoffeeScript 1.7.1 (function() { - 'use strict'; angular.module('angular-flexslider', []).directive('flexSlider', [ + 'use strict'; + angular.module('angular-flexslider', []).directive('flexSlider', [ '$parse', '$timeout', function($parse, $timeout) { return { restrict: 'AE', @@ -11,7 +12,6 @@ compile: function(element, attr, linker) { return function($scope, $element) { var addSlide, collectionString, flexsliderDiv, getTrackFromItem, indexString, match, removeSlide, slidesItems, trackBy; - match = (attr.slide || attr.flexSlide).match(/^\s*(.+)\s+in\s+(.*?)(?:\s+track\s+by\s+(.+?))?\s*$/); indexString = match[1]; collectionString = match[2]; @@ -20,7 +20,6 @@ slidesItems = {}; getTrackFromItem = function(collectionItem, index) { var locals; - locals = {}; locals[indexString] = collectionItem; locals['$index'] = index; @@ -28,7 +27,6 @@ }; addSlide = function(collectionItem, index, callback) { var childScope, track; - track = getTrackFromItem(collectionItem, index); if (slidesItems[track] != null) { throw "Duplicates in a repeater are not allowed. Use 'track by' expression to specify unique keys."; @@ -38,7 +36,6 @@ childScope['$index'] = index; return linker(childScope, function(clone) { var slideItem; - slideItem = { collectionItem: collectionItem, childScope: childScope, @@ -50,7 +47,6 @@ }; removeSlide = function(collectionItem, index) { var slideItem, track; - track = getTrackFromItem(collectionItem, index); slideItem = slidesItems[track]; if (slideItem == null) { @@ -62,7 +58,6 @@ }; return $scope.$watchCollection(collectionString, function(collection) { var attrKey, attrVal, c, currentSlidesLength, e, i, idx, n, options, slider, slides, t, toAdd, toRemove, trackCollection, _i, _j, _k, _l, _len, _len1, _len2, _len3; - if (!(collection != null ? collection.length : void 0)) { return; } @@ -79,7 +74,6 @@ } toAdd = (function() { var _j, _len1, _results; - _results = []; for (i = _j = 0, _len1 = collection.length; _j < _len1; i = ++_j) { c = collection[i]; @@ -94,7 +88,6 @@ })(); toRemove = (function() { var _results; - _results = []; for (t in slidesItems) { i = slidesItems[t]; @@ -156,12 +149,13 @@ if (attrKey === 'start' || attrKey === 'before' || attrKey === 'after' || attrKey === 'end' || attrKey === 'added' || attrKey === 'removed') { options[attrKey] = (function(attrVal) { var f; - f = $parse(attrVal); return function(slider) { return $scope.$apply(function() { return f($scope, { - '$slider': slider + '$slider': { + element: slider + } }); }); };