[
  {
    "path": ".gitignore",
    "content": "node_modules"
  },
  {
    "path": "LICENSE",
    "content": "The MIT License (MIT)\n\nCopyright (c) 2014 xvfeng\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE."
  },
  {
    "path": "Makefile",
    "content": "build:\n\tnode_modules/.bin/coffee -c ionic-rating.coffee\n\nuglify:\n\tnode_modules/.bin/uglifyjs ionic-rating.js > ionic-rating.min.js\n\nclean:\n\trm -rf dist\n\n.PHONY: all clean\n\nall: clean build uglify"
  },
  {
    "path": "README.md",
    "content": "ionic-rating\n============\n\nAn angularjs directive that take care of visualising a star rating bar, build\nfor ionic.\n\n![rating](https://cloud.githubusercontent.com/assets/1183541/3007107/3cee642c-de6c-11e3-8449-18b86ca130a7.png)\n\nAlso able to print half star (display only) :\n\n![rating-half](https://cloud.githubusercontent.com/assets/7658059/12101509/67ee6d6c-b335-11e5-9ef6-0ceb92018fd2.png)\n\n#### Why?\n\n`angular-ui` has the same [rating](http://angular-ui.github.io/bootstrap/#/rating) directive,\nbut it is build on top of bootstrap. This repo just reuse most of the js code, but build for\nthe [ionic](http://ionicframework.com/) framework.\n\n#### How to use?\n\nInstall with bower:\n\n```\n$ bower install ionic-rating\n```\n\nIn your index.html\n\n```HTML\n<script src=\"lib/ionic-rating/ionic-rating.min.js\"></script>\n```\n\nIn you template:\n\n```HTML\n<rating ng-model=\"rating.rate\" max=\"rating.max\"></rating>\n```\n\nIn you controller:\n\n```JavaScript\n// first inject it into your app\nangular.module('youApp', ['ionic.rating'])\n\n.controller('yourCtrl', function($scope) {\n\n  // set the rate and max variables\n  $scope.rating = {};\n  $scope.rating.rate = 3;\n  $scope.rating.max = 5;\n\n});\n\n```\n\nFor strict-di, you can use\n\n```\n.controller('RatingController', [ '$scope', '$attrs', 'ratingConfig', function($scope, $attrs, ratingConfig) ]\n```\n\nIf you want to make it read only\n\n> added readonly=\"readOnly\" to rating directive, and $scope.readOnly = true; to the controller.\n\n**Note:** You may also need to include the style file. But I suggest you just copy it to your\nproject.\n\n#### Build\n\n```\n$ npm i\n$ make all\n```\n\n#### License\n\nMIT\n"
  },
  {
    "path": "bower.json",
    "content": "{\n  \"name\": \"ionic-rating\",\n  \"main\": [\n    \"ionic-rating.js\",\n    \"ionic-rating.css\"\n  ],\n  \"version\": \"0.3.0\",\n  \"homepage\": \"https://github.com/fraserxu/ionic-rating\",\n  \"authors\": [\n    \"fraserxu <xvfeng123@gmail.com>\"\n  ],\n  \"description\": \"Star rating bar for ionic\",\n  \"keywords\": [\n    \"ionic\",\n    \"angularjs\",\n    \"rating\",\n    \"web\"\n  ],\n  \"license\": \"MIT\",\n  \"ignore\": [\n    \"**/.*\",\n    \"node_modules\",\n    \"bower_components\",\n    \"test\",\n    \"tests\"\n  ]\n}\n"
  },
  {
    "path": "ionic-rating.coffee",
    "content": "angular.module 'ionic.rating', []\n\n.constant 'ratingConfig', {\n    max: 5\n    stateOn: null\n    stateOff: null\n}\n\n.controller 'RatingController', ($scope, $attrs, ratingConfig) ->\n    ngModelCtrl = { $setViewValue: angular.noop }\n\n    this.init = (ngModelCtrl_) ->\n        ngModelCtrl = ngModelCtrl_\n        ngModelCtrl.$render = this.render\n\n        this.stateOn = if angular.isDefined($attrs.stateOn)\n        then $scope.$parent.$eval($attrs.stateOn)\n        else ratingConfig.stateOn\n\n        this.stateOff = if angular.isDefined($attrs.stateOff)\n        then $scope.$parent.$eval($attrs.stateOff)\n        else ratingConfig.stateOff\n\n        max = if angular.isDefined($attrs.max) then $scope.$parent.$eval($attrs.max) else ratingConfig.max\n\n        ratingStates = if angular.isDefined($attrs.ratingStates)\n        then $scope.$parent.$eval($attrs.ratingStates)\n        else new Array(max)\n\n        $scope.range = this.buildTemplateObjects(ratingStates)\n\n    this.buildTemplateObjects = (states) ->\n        for i in states.length\n            states[i] = angular.extend { index: 1 }, { stateOn: this.stateOn, stateOff: this.stateOff }, states[i]\n        return states\n\n    $scope.rate = (value) ->\n        if not $scope.readonly and value >= 0 && value <= $scope.range.length\n            ngModelCtrl.$setViewValue value\n            ngModelCtrl.$render()\n\n    $scope.reset = ->\n        $scope.value = ngModelCtrl.$viewValue\n        $scope.onLeave()\n\n    $scope.enter = (value) ->\n        if not $scope.readonly\n            $scope.value = value\n        $scope.onHover({value: value})\n\n    $scope.onKeydown = (evt) ->\n        if /(37|38|39|40)/.test evt.which\n            evt.preventDefault()\n            evt.stopPropagation()\n            $scope.rate $scope.value + (if evt.which is 38 or evt.which is 39 then 1 : -1 )\n\n    this.render = ->\n        $scope.value = ngModelCtrl.$viewValue\n\n    return this\n\n.directive 'rating', ->\n    return {\n        restrict: 'EA'\n        require: ['rating', 'ngModel']\n        scope:\n            readonly: '@'\n            onHover: '&'\n            onLeave: '&'\n        controller: 'RatingController'\n        template: '<ul class=\"rating\" ng-mouseleave=\"reset()\" ng-keydown=\"onKeydown($event)\">' +\n            '<li ng-repeat=\"r in range track by $index\" ng-click=\"rate($index + 1)\"><i class=\"icon\" ng-class=\"$index < value && (r.stateOn || \\'ion-ios-star\\') || (r.stateOff || \\'ion-ios-star-outline\\')\"></i></li>' +\n            '</ul>'\n        replace: true\n        link: (scope, element, attrs, ctrls) ->\n            ratingCtrl = ctrls[0]\n            ngModelCtrl = ctrls[1]\n\n            if ngModelCtrl\n                ratingCtrl.init ngModelCtrl\n    }\n\n"
  },
  {
    "path": "ionic-rating.css",
    "content": "ul.rating li {\n  display: inline;\n  border: 0px;\n  background: none;\n  padding: 5px 10px;\n}\nul.rating li i {\n  font-size: 30px;\n}"
  },
  {
    "path": "ionic-rating.js",
    "content": "// Generated by CoffeeScript 1.9.1\n(function() {\n  angular.module('ionic.rating', []).constant('ratingConfig', {\n    max: 5\n  }).controller('RatingController', function($scope, $attrs, ratingConfig) {\n    var ngModelCtrl;\n    ngModelCtrl = {\n      $setViewValue: angular.noop\n    };\n    this.init = function(ngModelCtrl_) {\n      var max, ratingStates;\n      ngModelCtrl = ngModelCtrl_;\n      ngModelCtrl.$render = this.render;\n      max = angular.isDefined($attrs.max) ? $scope.$parent.$eval($attrs.max) : ratingConfig.max;\n      return $scope.range = this.buildTemplateObjects(ngModelCtrl.$modelValue, max);\n    };\n    this.buildTemplateObjects = function(stateValue, max) {\n      var i, j, len, states = [];\n\n      for (j = 0; j < max; j++) {\n        if(stateValue > j && stateValue < j+1)\n          states[j] = 2;\n        else if(stateValue > j)\n          states[j] = 1;\n        else\n          states[j] = 0;\n      }\n\n      return states;\n    };\n    $scope.rate = function(value) {\n      if (!$scope.readonly && value >= 0 && value <= $scope.range.length) {\n        ngModelCtrl.$setViewValue(value);\n        return ngModelCtrl.$render();\n      }\n    };\n    $scope.onKeydown = function(evt) {\n      if (/(37|38|39|40)/.test(evt.which)) {\n        evt.preventDefault();\n        evt.stopPropagation();\n        return $scope.rate($scope.value + (evt.which === 38 || evt.which === 39 ? {\n              1: -1\n            } : void 0));\n      }\n    };\n    this.render = function() {\n      return $scope.value = ngModelCtrl.$viewValue;\n    };\n    return this;\n  }).directive('rating', function($timeout) {\n    return {\n      restrict: 'EA',\n      require: ['rating', 'ngModel'],\n      scope: {\n        readonly: '@'\n      },\n      controller: 'RatingController',\n      template: '<ul class=\"rating\" ng-keydown=\"onKeydown($event)\">' + '<li ng-repeat=\"r in range track by $index\" ng-click=\"rate($index + 1)\"><i class=\"icon\" ng-class=\"value === undefined ? (r === 1 ? \\'ion-ios-star\\' : (r === 2 ? \\'ion-ios-star-half\\' : \\'ion-ios-star-outline\\')) : (value > $index ? (value < $index+1 ? \\'ion-ios-star-half\\' : \\'ion-ios-star\\') : \\'ion-ios-star-outline\\')\"></i></li>' + '</ul>',\n      replace: true,\n      link: function(scope, element, attrs, ctrls) {\n        var ngModelCtrl, ratingCtrl;\n        ratingCtrl = ctrls[0];\n        ngModelCtrl = ctrls[1];\n        if (ngModelCtrl) {\n          $timeout(function(){\n          return ratingCtrl.init(ngModelCtrl);\n          })\n        }\n      }\n    };\n  });\n\n}).call(this);\n"
  },
  {
    "path": "package.json",
    "content": "{\n  \"name\": \"ionic-rating\",\n  \"version\": \"0.3.0\",\n  \"devDependencies\": {\n    \"uglify-js\": \"^2.4.14\",\n    \"coffee-script\": \"^1.7.1\"\n  },\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"https://github.com/fraserxu/ionic-rating.git\"\n  },\n  \"keywords\": [\n    \"ionic\",\n    \"angularjs\"\n  ],\n  \"author\": \"fraserxu\",\n  \"license\": \"MIT\",\n  \"bugs\": {\n    \"url\": \"https://github.com/fraserxu/ionic-rating/issues\"\n  },\n  \"homepage\": \"https://github.com/fraserxu/ionic-rating\"\n}\n"
  }
]