diff --git a/README.md b/README.md index 8635f5e..794331a 100644 --- a/README.md +++ b/README.md @@ -132,6 +132,11 @@ You may wonder why it is not possible to access your scope in the card template. A click on this button would execute the `doSomething()` function in your scope. +When click card you can display the index of the card +## UI +![angular-img](clickcard.png) + + ## In action Do you use the `angular-deckgrid` and would like to be featured here? Just send me an [email](mailto:andre.koenig@posteo.de) and I will add you and your application to this list. diff --git a/angular-deckgrid.js b/angular-deckgrid.js index e57bda8..4bdf89b 100644 --- a/angular-deckgrid.js +++ b/angular-deckgrid.js @@ -136,6 +136,40 @@ angular.module('akoenig.deckgrid').factory('DeckgridDescriptor', [ scope.mother = scope.$parent; this.$$deckgrid = Deckgrid.create(scope, elem[0]); + + //add index when click card start + + var index = 0; //create index + var medias = this.$$deckgrid.$$scope.model; + scope.clickCard = function(card){ + if(card.card.isselect == true && card.card.isadd ==true){ + index -=1; + for (var i = 0, l = medias.length; i < l; i++) { + if(!!medias[i].index && medias[i].index > card.card.index) { + medias[i].index -=1; + } + } + card.card.isadd = false; + }else if(card.card.isadd ==false && card.card.isselect == false){ + index +=1; + card.card.isadd = true; + }else if(card.card.isadd == true && !card.card.isselect){ + index -=1; + for (var i = 0, l = medias.length; i < l; i++) { + if(!!medias[i].index && medias[i].index > card.card.index) { + medias[i].index -=1; + } + } + card.card.isadd = false; + }else{ + index +=1; + card.card.isadd = true; + } + scope.clickMedia(card); + card.card.index = index; + }; + //add index when click card end + }; return { diff --git a/clickcard.png b/clickcard.png new file mode 100644 index 0000000..a380bfb Binary files /dev/null and b/clickcard.png differ