From 27df01e2a3d175abe8f3f094f0fad1a939aa9f1c Mon Sep 17 00:00:00 2001 From: Arjan Kempes Date: Mon, 30 Nov 2015 22:05:00 +0100 Subject: [PATCH] New release --- bower.json | 2 +- dist/ng-rateit.js | 5 +---- dist/ng-rateit.min.js | 2 +- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/bower.json b/bower.json index a6531cd..376bcc9 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-rateit", - "version": "2.0.3", + "version": "2.0.4", "homepage": "https://github.com/akempes/angular-rateit", "authors": [ "Arjan Kempes " diff --git a/dist/ng-rateit.js b/dist/ng-rateit.js index 939aaf6..838ca01 100644 --- a/dist/ng-rateit.js +++ b/dist/ng-rateit.js @@ -113,10 +113,7 @@ module $scope.offsetLeft = 0; var el = event.originalTarget || event.srcElement; - while( el && !isNaN( el.offsetLeft ) && !isNaN( el.offsetTop ) ) { - $scope.offsetLeft += el.offsetLeft - el.scrollLeft; - el = el.offsetParent; - } + $scope.offsetLeft = el.getBoundingClientRect().left; }; $scope.onHover = function (event) { $scope.isHovering = true; diff --git a/dist/ng-rateit.min.js b/dist/ng-rateit.min.js index 63dcf41..4fc6522 100644 --- a/dist/ng-rateit.min.js +++ b/dist/ng-rateit.min.js @@ -1 +1 @@ -var module=angular.module("ngRateIt",["ng"]);module.directive("ngRateIt",["$q",function(a){"use strict";var b=function(b,c,d){d.readOnly||(b.readOnly=function(){return!1}),d.resetable||(b.resetable=function(){return!0}),d.beforeRated||(b.beforeRated=function(){var b=a.defer();return b.resolve(),b.promise}),d.rated||(b.rated=function(){}),d.beforeReset||(b.beforeReset=function(){var b=a.defer();return b.resolve(),b.promise}),d.reset||(b.reset=function(){}),d.over||(b.over=function(){})};return{scope:{ngModel:"=",min:"=?min",max:"=?max",step:"=?step",readOnly:"&?readOnly",pristine:"=?pristine",resetable:"&?resetable",starWidth:"=?starWidth",starHeight:"=?starHeight",rated:"=?rated",reset:"=?reset",over:"=?over",beforeRated:"=?beforeRated",beforeReset:"=?beforeReset"},templateUrl:"ngRateIt/ng-rate-it.html",require:"ngModel",replace:!0,link:b,controller:"ngRateItController"}}]).controller("ngRateItController",["$scope","$timeout",function(a,b){"use strict";a.isHovering=!1,a.offsetLeft=0,a.orgValue=angular.copy(a.ngModel),a.hoverValue=0,a.min=a.min||0,a.max=a.max||5,a.step=a.step||.5,a.pristine=a.orgValue===a.ngModel,a.starWidth=a.starWidth||16,a.starHeight=a.starHeight||16,a.resetCssOffset=4;var c=a.$watch("ngModel",function(){a.pristine=a.orgValue===a.ngModel});a.removeRating=function(){a.resetable()&&!a.readOnly()&&a.beforeReset().then(function(){a.ngModel=a.min,a.reset()})},a.setValue=function(){if(a.isHovering&&!a.readOnly()){var c=angular.copy(a.min+a.hoverValue);a.beforeRated(c).then(function(){a.ngModel=c,a.isHovering=!1,b(function(){a.rated()})})}},a.onEnter=function(b){a.isHovering=!0,a.offsetLeft=0;for(var c=b.originalTarget||b.srcElement;c&&!isNaN(c.offsetLeft)&&!isNaN(c.offsetTop);)a.offsetLeft+=c.offsetLeft-c.scrollLeft,c=c.offsetParent},a.onHover=function(b){a.isHovering=!0,a.hoverValue=Math.round((b.clientX-a.offsetLeft)/a.starWidth/a.step)*a.step,a.over(b,a.hoverValue)},a.onLeave=function(){a.isHovering=!1,a.hoverValue=0},a.$on("$destroy",function(){c()})}]).run(["$templateCache",function(a){"use strict";a.put("ngRateIt/ng-rate-it.html",'
'+"
0 && hoverValue!==(ngModel-min)\" ng-style=\"{'width': (ngModel-min)*starWidth+'px', 'background-position': '0 '+(-2*starHeight)+'px'}\">
")}]); \ No newline at end of file +var module=angular.module("ngRateIt",["ng"]);module.directive("ngRateIt",["$q",function(a){"use strict";var b=function(b,c,d){d.readOnly||(b.readOnly=function(){return!1}),d.resetable||(b.resetable=function(){return!0}),d.beforeRated||(b.beforeRated=function(){var b=a.defer();return b.resolve(),b.promise}),d.rated||(b.rated=function(){}),d.beforeReset||(b.beforeReset=function(){var b=a.defer();return b.resolve(),b.promise}),d.reset||(b.reset=function(){}),d.over||(b.over=function(){})};return{scope:{ngModel:"=",min:"=?min",max:"=?max",step:"=?step",readOnly:"&?readOnly",pristine:"=?pristine",resetable:"&?resetable",starWidth:"=?starWidth",starHeight:"=?starHeight",rated:"=?rated",reset:"=?reset",over:"=?over",beforeRated:"=?beforeRated",beforeReset:"=?beforeReset"},templateUrl:"ngRateIt/ng-rate-it.html",require:"ngModel",replace:!0,link:b,controller:"ngRateItController"}}]).controller("ngRateItController",["$scope","$timeout",function(a,b){"use strict";a.isHovering=!1,a.offsetLeft=0,a.orgValue=angular.copy(a.ngModel),a.hoverValue=0,a.min=a.min||0,a.max=a.max||5,a.step=a.step||.5,a.pristine=a.orgValue===a.ngModel,a.starWidth=a.starWidth||16,a.starHeight=a.starHeight||16,a.resetCssOffset=4;var c=a.$watch("ngModel",function(){a.pristine=a.orgValue===a.ngModel});a.removeRating=function(){a.resetable()&&!a.readOnly()&&a.beforeReset().then(function(){a.ngModel=a.min,a.reset()})},a.setValue=function(){if(a.isHovering&&!a.readOnly()){var c=angular.copy(a.min+a.hoverValue);a.beforeRated(c).then(function(){a.ngModel=c,a.isHovering=!1,b(function(){a.rated()})})}},a.onEnter=function(b){a.isHovering=!0,a.offsetLeft=0;var c=b.originalTarget||b.srcElement;a.offsetLeft=c.getBoundingClientRect().left},a.onHover=function(b){a.isHovering=!0,a.hoverValue=Math.round((b.clientX-a.offsetLeft)/a.starWidth/a.step)*a.step,a.over(b,a.hoverValue)},a.onLeave=function(){a.isHovering=!1,a.hoverValue=0},a.$on("$destroy",function(){c()})}]).run(["$templateCache",function(a){"use strict";a.put("ngRateIt/ng-rate-it.html",'
'+"
0 && hoverValue!==(ngModel-min)\" ng-style=\"{'width': (ngModel-min)*starWidth+'px', 'background-position': '0 '+(-2*starHeight)+'px'}\">
")}]); \ No newline at end of file