diff --git a/packages/mdg:camera/photo-browser.js b/packages/mdg:camera/photo-browser.js index b54cead..fdfb94d 100644 --- a/packages/mdg:camera/photo-browser.js +++ b/packages/mdg:camera/photo-browser.js @@ -1,5 +1,35 @@ -var stream; -var closeAndCallback; +// merge defaults settings with Meteor settings if exists +var settings = (function(defaults) { + var settings = + { + camera: { + type: "back", + width: 640, + height: 480 + }, + quality: 80, + viewFinder: { + width: 320, + height: 240 + } + }; + + if (!defaults) return settings; + + if (defaults.camera) { + settings.camera = _.extend(settings.camera, defaults.camera); + } + + if (defaults.quality && check(defaults.quality, Number)) { + settings.quality = defaults.quality; + } + + if (defaults.viewFinder) { + settings.viewFinder = _.extend(settings.viewFinder, defaults.viewFinder); + } + + return settings; +})(Meteor.settings.public.MeteorCamera); var photo = new ReactiveVar(null); var error = new ReactiveVar(null); @@ -8,9 +38,7 @@ var waitingForPermission = new ReactiveVar(null); var canvasWidth = 0; var canvasHeight = 0; -var quality = 80; - -Template.viewfinder.rendered = function() { +Template.viewfinder.onRendered(function() { var template = this; waitingForPermission.set(true); @@ -19,13 +47,13 @@ Template.viewfinder.rendered = function() { // stream webcam video to the