From 7395e8ab670d01f183cf196ec98d09b71c59e7b9 Mon Sep 17 00:00:00 2001 From: aamir-khan Date: Fri, 15 May 2015 16:23:58 +0500 Subject: [PATCH 1/3] ECOM-1472: fixed the tab issue for taking photo --- .../verify_student/views/webcam_photo_view.js | 28 ++++++++++++++++--- .../verify_student/webcam_photo.underscore | 4 +-- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/lms/static/js/verify_student/views/webcam_photo_view.js b/lms/static/js/verify_student/views/webcam_photo_view.js index 6e60b180bc..a865dd493c 100644 --- a/lms/static/js/verify_student/views/webcam_photo_view.js +++ b/lms/static/js/verify_student/views/webcam_photo_view.js @@ -2,7 +2,10 @@ * Interface for retrieving webcam photos. * Supports HTML5 and Flash. */ - var edx = edx || {}; + var edx = edx || {}, + key = { + enter: 13 + }; (function( $, _, Backbone, gettext ) { 'use strict'; @@ -12,6 +15,7 @@ edx.verify_student.WebcamPhotoView = Backbone.View.extend({ template: "#webcam_photo-tpl", + el: "#webcam", backends: { "html5": { @@ -241,12 +245,18 @@ ); $( this.el ).html( renderedHtml ); + var resetBtn = this.$el.find('#webcam_reset_button'); + var captureBtn = this.$el.find('#webcam_capture_button'); + // Install event handlers - $( "#webcam_reset_button", this.el ).on( 'click', _.bind( this.reset, this ) ); - $( "#webcam_capture_button", this.el ).on( 'click', _.bind( this.capture, this ) ); + resetBtn.on( 'click', _.bind( this.reset, this ) ); + captureBtn.on( 'click', _.bind( this.capture, this ) ); + + resetBtn.on( 'keyup', _.bind( this.reset_by_enter, this ) ); + captureBtn.on( 'keyup', _.bind( this.capture_by_enter, this ) ); // Show the capture button - $( "#webcam_capture_button", this.el ).removeClass('is-hidden'); + captureBtn.removeClass('is-hidden'); return this; }, @@ -266,6 +276,16 @@ $( "#webcam_capture_button", this.el ).removeClass('is-hidden'); }, + capture_by_enter: function(event){ + if(event.keyCode == key.enter){ + this.capture(); + } + }, + reset_by_enter: function(event){ + if(event.keyCode == key.enter){ + this.reset(); + } + }, capture: function() { // Take a snapshot of the video var success = this.backend.snapshot(); diff --git a/lms/templates/verify_student/webcam_photo.underscore b/lms/templates/verify_student/webcam_photo.underscore index 69da45b7ae..8e12108ac0 100644 --- a/lms/templates/verify_student/webcam_photo.underscore +++ b/lms/templates/verify_student/webcam_photo.underscore @@ -21,10 +21,10 @@
From be5a1a33eb13edb3ee8534714f989e08556f18c8 Mon Sep 17 00:00:00 2001 From: aamir-khan Date: Thu, 21 May 2015 18:53:33 +0500 Subject: [PATCH 2/3] ECOM-1472: js nitpick fixes --- .../js/verify_student/views/webcam_photo_view.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lms/static/js/verify_student/views/webcam_photo_view.js b/lms/static/js/verify_student/views/webcam_photo_view.js index a865dd493c..e9fef0b165 100644 --- a/lms/static/js/verify_student/views/webcam_photo_view.js +++ b/lms/static/js/verify_student/views/webcam_photo_view.js @@ -245,18 +245,18 @@ ); $( this.el ).html( renderedHtml ); - var resetBtn = this.$el.find('#webcam_reset_button'); - var captureBtn = this.$el.find('#webcam_capture_button'); + var $resetBtn = this.$el.find('#webcam_reset_button'), + $captureBtn = this.$el.find('#webcam_capture_button'); // Install event handlers - resetBtn.on( 'click', _.bind( this.reset, this ) ); - captureBtn.on( 'click', _.bind( this.capture, this ) ); + $resetBtn.on( 'click', _.bind( this.reset, this ) ); + $captureBtn.on( 'click', _.bind( this.capture, this ) ); - resetBtn.on( 'keyup', _.bind( this.reset_by_enter, this ) ); - captureBtn.on( 'keyup', _.bind( this.capture_by_enter, this ) ); + $resetBtn.on( 'keyup', _.bind( this.reset_by_enter, this ) ); + $captureBtn.on( 'keyup', _.bind( this.capture_by_enter, this ) ); // Show the capture button - captureBtn.removeClass('is-hidden'); + $captureBtn.removeClass('is-hidden'); return this; }, From 1323a8e2e8775db0066ba8f1a6d5f240fb797015 Mon Sep 17 00:00:00 2001 From: aamir-khan Date: Fri, 22 May 2015 11:44:24 +0500 Subject: [PATCH 3/3] ECOM-1472: js nitpick fixes --- lms/static/js/verify_student/views/webcam_photo_view.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lms/static/js/verify_student/views/webcam_photo_view.js b/lms/static/js/verify_student/views/webcam_photo_view.js index e9fef0b165..b0aac41718 100644 --- a/lms/static/js/verify_student/views/webcam_photo_view.js +++ b/lms/static/js/verify_student/views/webcam_photo_view.js @@ -233,7 +233,9 @@ }, render: function() { - var renderedHtml; + var renderedHtml, + $resetBtn, + $captureBtn; // Set the submit button to disabled by default this.setSubmitButtonEnabled( false ); @@ -245,8 +247,8 @@ ); $( this.el ).html( renderedHtml ); - var $resetBtn = this.$el.find('#webcam_reset_button'), - $captureBtn = this.$el.find('#webcam_capture_button'); + $resetBtn = this.$el.find('#webcam_reset_button'); + $captureBtn = this.$el.find('#webcam_capture_button'); // Install event handlers $resetBtn.on( 'click', _.bind( this.reset, this ) );