Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert ui-vrecord Package to JS #6473

Merged
merged 8 commits into from
Mar 29, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/rocketchat-ui-message/client/messageBox.coffee
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import toastr from 'toastr'
import mime from 'mime-type/with-db'
import moment from 'moment'
import {VRecDialog} from 'meteor/rocketchat:ui-vrecord'

katexSyntax = ->
if RocketChat.katex.katex_enabled()
Expand Down
3 changes: 2 additions & 1 deletion packages/rocketchat-ui-message/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ Package.onUse(function(api) {
'underscore',
'tracker',
'rocketchat:lib',
'rocketchat:ui-account'
'rocketchat:ui-account',
'rocketchat:ui-vrecord'
]);

api.addFiles('client/message.html', 'client');
Expand Down
47 changes: 0 additions & 47 deletions packages/rocketchat-ui-vrecord/client/VRecDialog.coffee

This file was deleted.

63 changes: 63 additions & 0 deletions packages/rocketchat-ui-vrecord/client/VRecDialog.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
export const VRecDialog = new class {
static initClass() {
this.prototype.opened = false;
this.prototype.initiated = false;
this.prototype.width = 400;
this.prototype.height = 280;
}

init() {
if (this.initiated) {
return;
}

this.initiated = true;
return Blaze.render(Template.vrecDialog, document.body);
}

open(source) {
if (!this.initiated) {
this.init();
}

this.source = source;
const dialog = $('.vrec-dialog');
this.setPosition(dialog, source);
dialog.addClass('show');
this.opened = true;

return this.initializeCamera();
}

close() {
$('.vrec-dialog').removeClass('show');
this.opened = false;

if (this.video != null) {
return VideoRecorder.stop();
}
}

setPosition(dialog, source) {
const sourcePos = $(source).offset();
let left = (sourcePos.left - this.width) + 100;
let top = sourcePos.top - this.height - 40;

if (left < 0) {
left = 10;
}
if (top < 0) {
top = 10;
}

return dialog.css({ top: `${ top }px`, left: `${ left }px` });
}

initializeCamera() {
this.video = $('.vrec-dialog video').get('0');
if (!this.video) {
return;
}
return VideoRecorder.start(this.video);
}
};
3 changes: 2 additions & 1 deletion packages/rocketchat-ui-vrecord/client/vrecord.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* globals VideoRecorder, VRecDialog, fileUpload */
/* globals VideoRecorder, fileUpload */
import {VRecDialog} from './VRecDialog';

Template.vrecDialog.helpers({
recordIcon() {
Expand Down
3 changes: 1 addition & 2 deletions packages/rocketchat-ui-vrecord/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ Package.onUse(function(api) {
'mongo',
'ecmascript',
'templating',
'coffeescript',
'underscore',
'tracker',
'rocketchat:lib',
Expand All @@ -22,7 +21,7 @@ Package.onUse(function(api) {

api.addFiles('client/vrecord.html', 'client');
api.addFiles('client/vrecord.js', 'client');
api.addFiles('client/VRecDialog.coffee', 'client');

api.addFiles('server/settings.js', 'server');
api.mainModule('client/VRecDialog.js', 'client');
});