<|start_filename|>Gruntfile.js<|end_filename|>
module.exports = function(grunt) {

	grunt.initConfig({
		pkg: grunt.file.readJSON('package.json'),
		
		files : {
			src: ['src/angular-help-overlay.js']
		},
		
		jshint: {
			all: {
				src: '<%= files.src %>'
			}
		},
		
		concat: {
			dist: {
				src: '<%= files.src %>',
				dest: 'lib/<%= pkg.name %>.js'
			}
		},
		
		uglify: {
			options: {
				preserveComments: false,
				banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n',
				report: 'min',
				compress: {
					drop_console: true
				}
			},
			dist: {
				files: {
					'lib/<%= pkg.name %>.min.js': ['<%= concat.dist.dest %>']
				}
			}
		},
		
		watch : {
			js: {
				files: '<%= files.src %>',
				tasks: ['jshint', 'concat']
			}
		},
		
		connect: {
			server: {
				options: {
					port: 8000,
					base: '.',
					keepalive: true
				}
			}
		}
	});
	
	grunt.loadNpmTasks('grunt-contrib-uglify');
	grunt.loadNpmTasks('grunt-contrib-concat');
	grunt.loadNpmTasks('grunt-contrib-jshint');
	grunt.loadNpmTasks('grunt-contrib-watch');
	grunt.loadNpmTasks('grunt-contrib-connect');
	
	grunt.registerTask('default', ['jshint', 'concat', 'uglify']);
};

<|start_filename|>src/angular-help-overlay.js<|end_filename|>
/*global angular:false */

angular.module('angularHelpOverlay', []).directive('helpOverlay', ['$document', function ($document) {
  var noop = false; // Special flag in case we get an a chardinJs change event outside of our control.
  return {
    restrict: 'A',
    scope: {
      helpOverlay: '=',
      overlayStart: '&overlayStartCallback',
      overlayStop: '&overlayStopCallback'
    },
    link: function (scope, element, attrs) {

      $document.on('chardinJs:start', function (event) {
        if (angular.isFunction(scope.overlayStart)) {
          scope.overlayStart(event);
        }

        if (scope.helpOverlay === false) {
          scope.$apply(function () {
            noop = true;
            scope.helpOverlay = true;
          });
        }
      });

      $document.on('chardinJs:stop', function (event) {
        if (angular.isFunction(scope.overlayStop)) {
          scope.overlayStop(event);
        }

        if (scope.helpOverlay === true) {
          scope.$apply(function () {
            noop = true;
            scope.helpOverlay = false;
          });
        }
      });

      scope.$watch('helpOverlay', function (newValue, oldValue) {
        if (newValue !== oldValue) {
          if (noop === true) {
            noop = false;
          } else if (newValue === true) {
            $(element).chardinJs('start');
          } else if (newValue === false) {
            $(element).chardinJs('stop');
          }
        }
      });
    }
  };
}]);

<|start_filename|>bower.json<|end_filename|>
{
  "name": "angular-help-overlay",
  "version": "0.1.2",
  "homepage": "https://github.com/jordanburke/angular-help-overlay",
  "authors": [
    "<NAME> <@jordanburke>"
  ],
  "main": "lib/angular-help-overlay.js",
  "description": "Directive for chardin.js instruction overlay",
  "keywords": [
  ],
  "license": "MIT",
  "ignore": [
    "**/.*",
    "node_modules",
    "bower_components",
    "test",
    "tests"
  ],
  "dependencies": {
    "jquery": ">=1.6.0 <2.0.0",
    "chardin.js": "~0.1.3",
    "angular": ">=1.2.0"
  }
}


<|start_filename|>package.json<|end_filename|>
{
  "name": "angular-help-overlay",
  "description": "Angular Wrapper for chardin.js instruction overlay",
  "version": "0.1.3",
  "homepage": "https://github.com/jordanburke/angular-help-overlay",
  "author": {
    "name": "<NAME>",
    "url": "https://github.com/jordanburke/"
  },
  "repository": {
    "type": "git",
    "url": "git://github.com/jordanburke/angular-help-overlay.git"
  },
  "licenses": [
    {
      "type": "MIT"
    }
  ],
  "dependencies": {
    "chardin.js": "^0.1.3"
  },
  "devDependencies": {
    "grunt": "~0.4.1",
    "grunt-cli": "~0.1.7",
    "grunt-contrib-jshint": "latest",
    "grunt-contrib-uglify": "~0.2.0",
    "grunt-contrib-concat": "~0.2.0",
    "grunt-contrib-watch": "latest",
    "grunt-contrib-connect": "~0.5.0"
  }
}


<|start_filename|>example/js/app.js<|end_filename|>
angular.module('app', ['angularHelpOverlay']).controller('MainCtrl', function ($scope) {
  $scope.showHelp = false;

  $scope.onStart = function(event) {
    console.log('STARTING');
    return '1';
  };

  $scope.onStop = function(event) {
    console.log('ENDING');
    return '0';
  };

  $scope.toggleHelp = function() {
    $scope.showHelp = !$scope.showHelp;
    /*var picture = $('.jumbotron img');
    if (picture.is(':visible')) {
      return ($('body').data('chardinJs')).toggle();
    } else {
      return picture.animate({
        height: 250
      }, 600, function() {
        return ($('body').data('chardinJs')).toggle();
      });
    }*/
  };

});
