-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
}; | ||
}()); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
29
packages/rocketchat-ui/client/lib/cordova/facebook-login.coffee
This file was deleted.
Oops, something went wrong.
31 changes: 31 additions & 0 deletions
31
packages/rocketchat-ui/client/lib/cordova/facebook-login.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}; |
25 changes: 0 additions & 25 deletions
25
packages/rocketchat-ui/client/lib/cordova/keyboard-fix.coffee
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
} | ||
} | ||
}); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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
?There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, sorry :)