diff --git a/dist/angular-camera.js b/dist/angular-camera.js
index 2284cc9..e6942b8 100644
--- a/dist/angular-camera.js
+++ b/dist/angular-camera.js
@@ -6,7 +6,7 @@
function ($timeout, $sce) {
return {
require: 'ngModel',
- template: '
Loading Camera...
Couldn\'t find a camera to use
Install Browser\'s latest version Take Picture
',
+ template: ' Loading Camera...
Couldn\'t find a camera to use
Install Browser\'s latest version Take Picture
',
replace: false,
transclude: true,
restrict: 'E',
@@ -30,6 +30,9 @@
scope.stream.stop();
}
});
+ /**
+ * @description Set mediastream source and notify camera
+ */
scope.enableCamera = function () {
return navigator.getUserMedia({
audio: false,
@@ -47,6 +50,9 @@
});
});
};
+ /**
+ * @description Disable mediastream source and notify camera
+ */
scope.disableCamera = function () {
return navigator.getUserMedia({
audio: false,
@@ -57,6 +63,9 @@
});
});
};
+ /**
+ * @description Capture current state of video stream as photo
+ */
scope.takePicture = function () {
var canvas, context, countdownTick, countdownTime;
canvas = window.document.getElementById('ng-photo-canvas');
@@ -109,6 +118,10 @@
}
return false;
};
+ /**
+ * @description Add overlay frame to canvas render
+ * @param {Object} context Reference to target canvas context
+ */
scope.addFrame = function (context, url, callback) {
var overlay;
if (callback == null) {
@@ -124,11 +137,18 @@
overlay.crossOrigin = '';
return overlay.src = url;
};
+ /**
+ * @description Keeps a packaged version of media ready
+ * @param {Base64} newVal Prefix-stripped Base64 of of canvas image
+ */
scope.$watch('media', function (newVal) {
if (newVal != null) {
return scope.packagedMedia = scope.media.replace(/^data:image\/\w+;base64,/, '');
}
});
+ /**
+ * @description Preloader for overlay image
+ */
scope.$watch('overlaySrc', function (newVal, oldVal) {
var preloader;
if (scope.overlaySrc != null) {
@@ -145,6 +165,9 @@
return scope.isLoaded = true;
}
});
+ /**
+ * @description Watch for when to turn on/off camera feed
+ */
scope.$watch('enabled', function (newVal, oldVal) {
if (newVal) {
if (!oldVal) {
@@ -156,6 +179,10 @@
}
}
});
+ /**
+ * @description Check format type of camera.
+ * @todo Future support for different media types (GIF, Video)
+ */
return scope.$watch('type', function () {
switch (scope.type) {
case 'photo':
diff --git a/dist/angular-camera.min.js b/dist/angular-camera.min.js
index 7257f81..f9c803c 100644
--- a/dist/angular-camera.min.js
+++ b/dist/angular-camera.min.js
@@ -1 +1 @@
-(function(){"use strict";angular.module("omr.directives",[]).directive("ngCamera",["$timeout","$sce",function(a,b){return{require:"ngModel",template:' Loading Camera...
Couldn\'t find a camera to use
Install Browser\'s latest version Take Picture
',replace:!1,transclude:!0,restrict:"E",scope:{type:"@",media:"=ngModel",width:"@",height:"@",overlaySrc:"=",countdown:"@",captureCallback:"&capture",enabled:"=",captureMessage:"@"},link:function(c){return c.activeCountdown=!1,navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia,window.URL=window.URL||window.webkitURL||window.mozURL||window.msURL,c.$on("$destroy",function(){c.stream&&"function"==typeof c.stream.stop&&c.stream.stop()}),c.enableCamera=function(){return navigator.getUserMedia({audio:!1,video:!0},function(a){return c.$apply(function(){return c.stream=a,c.isLoaded=!0,c.videoStream=b.trustAsResourceUrl(window.URL.createObjectURL(a))})},function(){return c.$apply(function(){return c.isLoaded=!0,c.noCamera=!0})})},c.disableCamera=function(){return navigator.getUserMedia({audio:!1,video:!0},function(){return c.$apply(function(){return c.videoStream=""})})},c.takePicture=function(){var b,d,e,f;return b=window.document.getElementById("ng-photo-canvas"),f=null!=c.countdown?1e3*parseInt(c.countdown):0,null!=b&&(f>0&&(c.activeCountdown=!0,c.hideUI=!0),d=b.getContext("2d"),c.countdownTimer&&a.cancel(c.countdownTimer),c.countdownTimer=a(function(){var a;return c.activeCountdown=!1,a=window.document.getElementById("ng-camera-feed"),d.drawImage(a,0,0,c.width,c.height),null!=c.overlaySrc?c.addFrame(d,c.overlaySrc,function(){return c.$apply(function(){return c.media=b.toDataURL("image/jpeg")}),null!=c.captureCallback?c.captureCallback(c.media):void 0}):(c.media=b.toDataURL("image/jpeg"),null!=c.captureCallback&&c.captureCallback(c.media)),c.hideUI=!1},f+1e3),c.countdownText=parseInt(c.countdown),e=setInterval(function(){return c.$apply(function(){var a;return a=parseInt(c.countdownText)-1,0===a?(c.countdownText=null!=c.captureMessage?c.captureMessage:"GO!",clearInterval(e)):c.countdownText=a})},1e3)),!1},c.addFrame=function(a,b,d){var e;return null==d&&(d=!1),e=new Image,e.onload=function(){return a.drawImage(e,0,0,c.width,c.height),d?d(a):void 0},e.crossOrigin="",e.src=b},c.$watch("media",function(a){return null!=a?c.packagedMedia=c.media.replace(/^data:image\/\w+;base64,/,""):void 0}),c.$watch("overlaySrc",function(a){var b;return null!=c.overlaySrc?(c.isLoaded=!1,b=new Image,b.crossOrigin="",b.src=a,b.onload=function(){return c.$apply(function(){return c.isLoaded=!0})}):c.isLoaded=!0}),c.$watch("enabled",function(a,b){if(a){if(!b)return c.enableCamera()}else if(null!=b)return c.disableCamera()}),c.$watch("type",function(){switch(c.type){case"photo":if(c.enabled)return c.enableCamera();break;default:if(c.enabled)return c.enableCamera()}})}}}])}).call(this);
\ No newline at end of file
+(function(){"use strict";angular.module("omr.directives",[]).directive("ngCamera",["$timeout","$sce",function(a,b){return{require:"ngModel",template:' Loading Camera...
Couldn\'t find a camera to use
Install Browser\'s latest version Take Picture
',replace:!1,transclude:!0,restrict:"E",scope:{type:"@",media:"=ngModel",width:"@",height:"@",overlaySrc:"=",countdown:"@",captureCallback:"&capture",enabled:"=",captureMessage:"@"},link:function(c){return c.activeCountdown=!1,navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia,window.URL=window.URL||window.webkitURL||window.mozURL||window.msURL,c.$on("$destroy",function(){c.stream&&"function"==typeof c.stream.stop&&c.stream.stop()}),c.enableCamera=function(){return navigator.getUserMedia({audio:!1,video:!0},function(a){return c.$apply(function(){return c.stream=a,c.isLoaded=!0,c.videoStream=b.trustAsResourceUrl(window.URL.createObjectURL(a))})},function(){return c.$apply(function(){return c.isLoaded=!0,c.noCamera=!0})})},c.disableCamera=function(){return navigator.getUserMedia({audio:!1,video:!0},function(){return c.$apply(function(){return c.videoStream=""})})},c.takePicture=function(){var b,d,e,f;return b=window.document.getElementById("ng-photo-canvas"),f=null!=c.countdown?1e3*parseInt(c.countdown):0,null!=b&&(f>0&&(c.activeCountdown=!0,c.hideUI=!0),d=b.getContext("2d"),c.countdownTimer&&a.cancel(c.countdownTimer),c.countdownTimer=a(function(){var a;return c.activeCountdown=!1,a=window.document.getElementById("ng-camera-feed"),d.drawImage(a,0,0,c.width,c.height),null!=c.overlaySrc?c.addFrame(d,c.overlaySrc,function(){return c.$apply(function(){return c.media=b.toDataURL("image/jpeg")}),null!=c.captureCallback?c.captureCallback(c.media):void 0}):(c.media=b.toDataURL("image/jpeg"),null!=c.captureCallback&&c.captureCallback(c.media)),c.hideUI=!1},f+1e3),c.countdownText=parseInt(c.countdown),e=setInterval(function(){return c.$apply(function(){var a;return a=parseInt(c.countdownText)-1,0===a?(c.countdownText=null!=c.captureMessage?c.captureMessage:"GO!",clearInterval(e)):c.countdownText=a})},1e3)),!1},c.addFrame=function(a,b,d){var e;return null==d&&(d=!1),e=new Image,e.onload=function(){return a.drawImage(e,0,0,c.width,c.height),d?d(a):void 0},e.crossOrigin="",e.src=b},c.$watch("media",function(a){return null!=a?c.packagedMedia=c.media.replace(/^data:image\/\w+;base64,/,""):void 0}),c.$watch("overlaySrc",function(a){var b;return null!=c.overlaySrc?(c.isLoaded=!1,b=new Image,b.crossOrigin="",b.src=a,b.onload=function(){return c.$apply(function(){return c.isLoaded=!0})}):c.isLoaded=!0}),c.$watch("enabled",function(a,b){if(a){if(!b)return c.enableCamera()}else if(null!=b)return c.disableCamera()}),c.$watch("type",function(){switch(c.type){case"photo":if(c.enabled)return c.enableCamera();break;default:if(c.enabled)return c.enableCamera()}})}}}])}).call(this);
\ No newline at end of file
diff --git a/src/directives/angular-camera.coffee b/src/directives/angular-camera.coffee
index 57aa1e7..362f4b4 100644
--- a/src/directives/angular-camera.coffee
+++ b/src/directives/angular-camera.coffee
@@ -10,7 +10,7 @@ angular.module('omr.directives', [])
-
+
Install Browser\'s latest version
@@ -191,4 +191,4 @@ angular.module('omr.directives', [])
scope.enableCamera() if scope.enabled
else
# Defaulting to photo
- scope.enableCamera() if scope.enabled
\ No newline at end of file
+ scope.enableCamera() if scope.enabled