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 rocketchat-ui part 2 #6539

Merged
merged 2 commits into from
Apr 3, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
91 changes: 0 additions & 91 deletions packages/rocketchat-ui/client/lib/accountBox.coffee

This file was deleted.

106 changes: 106 additions & 0 deletions packages/rocketchat-ui/client/lib/accountBox.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
this.AccountBox = (function() {
let status = 0;
const self = {};
const items = new ReactiveVar([]);
function setStatus(status) {
return Meteor.call('UserPresence:setDefaultStatus', status);
}
function open() {
if (SideNav.flexStatus()) {
SideNav.closeFlex();
return;
}
status = 1;
self.options.removeClass('animated-hidden');
self.box.addClass('active');
return SideNav.toggleArrow(1);
}
function close() {
status = 0;
self.options.addClass('animated-hidden');
self.box.removeClass('active');
return SideNav.toggleArrow(-1);
}
function toggle() {
if (status) {
return close();
} else {
return open();
}
}
function openFlex() {
status = 0;
self.options.addClass('animated-hidden');
return self.box.removeClass('active');
}
function init() {
self.box = $('.account-box');
return self.options = self.box.find('.options');
}

/*
* @param newOption:
* name: Button label
* icon: Button icon
* class: Class of the item
* permissions: Which permissions a user should have (all of them) to see this item
*/
function addItem(newItem) {
return Tracker.nonreactive(function() {
const actual = items.get();
actual.push(newItem);
return items.set(actual);
});
}
function checkCondition(item) {
return (item.condition == null) || item.condition();
}
function getItems() {
return _.filter(items.get(), function(item) {
if (checkCondition(item)) {
return true;
}
});
}
function addRoute(newRoute, router) {
if (router == null) {
router = FlowRouter;
}
const routeConfig = {
center: 'pageContainer',
pageTemplate: newRoute.pageTemplate
};
if (newRoute.i18nPageTitle != null) {
routeConfig.i18nPageTitle = newRoute.i18nPageTitle;
}
if (newRoute.pageTitle != null) {
routeConfig.pageTitle = newRoute.pageTitle;
}
return router.route(newRoute.path, {
name: newRoute.name,
action() {
Session.set('openedRoom');
return BlazeLayout.render('main', routeConfig);
},
triggersEnter: [
function() {
if (newRoute.sideNav != null) {
SideNav.setFlex(newRoute.sideNav);
return SideNav.openFlex();
}
}
]
});
}
return {
setStatus,
toggle,
open,
close,
openFlex,
init,
addRoute,
addItem,
getItems
};
}());
6 changes: 0 additions & 6 deletions packages/rocketchat-ui/client/lib/accounts.coffee

This file was deleted.

9 changes: 9 additions & 0 deletions packages/rocketchat-ui/client/lib/accounts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import toastr from 'toastr';
Accounts.onEmailVerificationLink(function(token, done) {
Accounts.verifyEmail(token, function(error) {
if (error == null) {
toastr.success(t('Email_verified'));
}
return done();
});
});
26 changes: 0 additions & 26 deletions packages/rocketchat-ui/client/lib/avatar.coffee

This file was deleted.

31 changes: 31 additions & 0 deletions packages/rocketchat-ui/client/lib/avatar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
Blaze.registerHelper('avatarUrlFromUsername', getAvatarUrlFromUsername);

this.getAvatarAsPng = function(username, cb) {
const image = new Image;
image.src = getAvatarUrlFromUsername(username);
image.onload = function() {

const canvas = document.createElement('canvas');
canvas.width = image.width;
canvas.height = image.height;
const context = canvas.getContext('2d');
context.drawImage(image, 0, 0);
return cb(canvas.toDataURL('image/png'));
};
return image.onerror = function() {
return cb('');
};
};

this.updateAvatarOfUsername = function(username) {

const key = `avatar_random_${ username }`;
Session.set(key, Math.round(Math.random() * 1000));

Object.keys(RoomManager.openedRooms).forEach((key) => {
const room = RoomManager.openedRooms[key];
const url = getAvatarUrlFromUsername(username);
$(room.dom).find(`.message[data-username='${ username }'] .avatar-image`).css('background-image', `url(${ url })`);
});
return true;
};
29 changes: 0 additions & 29 deletions packages/rocketchat-ui/client/lib/cordova/facebook-login.coffee

This file was deleted.

31 changes: 31 additions & 0 deletions packages/rocketchat-ui/client/lib/cordova/facebook-login.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/* globals facebookConnectPlugin Facebook*/
Meteor.loginWithFacebookCordova = function(options, callback) {
if (!callback && typeof options === 'function') {
callback = options;
options = null;
}
const credentialRequestCompleteCallback = Accounts.oauth.credentialRequestCompleteHandler(callback);
const fbLoginSuccess = function(data) {
data.cordova = true;
return Accounts.callLoginMethod({
methodArguments: [data],
userCallback: callback
});
};
if (typeof facebookConnectPlugin !== 'undefined') {
return facebookConnectPlugin.getLoginStatus(function(response) {
if (response.status !== 'connected') {
return facebookConnectPlugin.login(['public_profile', 'email'], fbLoginSuccess, function(error) {
console.log('login', JSON.stringify(error), error);
return callback(error);
});
} else {
return fbLoginSuccess(response);
}
}, function(error) {
console.log('getLoginStatus', JSON.stringify(error), error);
return callback(error);
});
}
return Facebook.requestCredential(options, credentialRequestCompleteCallback);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happened with the else?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there are one return (line 16) if the "if" match this return never happens.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, sorry :)

};
25 changes: 0 additions & 25 deletions packages/rocketchat-ui/client/lib/cordova/keyboard-fix.coffee

This file was deleted.

32 changes: 32 additions & 0 deletions packages/rocketchat-ui/client/lib/cordova/keyboard-fix.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/* globals device cordova*/
if (Meteor.isCordova) {
const body = $(document.body);
document.addEventListener('deviceready', function() {
if (typeof device !== 'undefined' && device !== null && device.platform.toLowerCase() !== 'android') {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
return cordova.plugins.Keyboard.disableScroll(true);
}
});
window.addEventListener('native.keyboardshow', function() {
if (typeof device !== 'undefined' && device !== null && device.platform.toLowerCase() !== 'android') {
if (Meteor.userId() != null) {
$('.main-content').css('height', window.innerHeight);
$('.sweet-alert').css('transform', `translateY(-${ (document.height - window.innerHeight) / 2 }px)`).css('-webkit-transform', `translateY(-${ (document.height - window.innerHeight) / 2 }px)`);
} else {
body.css('height', window.innerHeight);
body.css('overflow', 'scroll');
}
}
});
window.addEventListener('native.keyboardhide', function() {
if (typeof device !== 'undefined' && device !== null && device.platform.toLowerCase() !== 'android') {
if (Meteor.userId() != null) {
$('.main-content').css('height', window.innerHeight);
$('.sweet-alert').css('transform', '').css('-webkit-transform', '');
} else {
body.css('height', window.innerHeight);
body.css('overflow', 'visible');
}
}
});
}
Loading