Remove use of getDOMNode from multiple files.

Этот коммит содержится в:
JoramWilander
2015-09-02 14:26:01 -04:00
родитель 86b474666c
Коммит b9e16f41f1
9 изменённых файлов: 72 добавлений и 87 удалений

Просмотреть файл

@@ -26,7 +26,7 @@ export default class ChannelNotifications extends React.Component {
componentDidMount() { componentDidMount() {
ChannelStore.addChangeListener(this.onListenerChange); ChannelStore.addChangeListener(this.onListenerChange);
$(this.refs.modal.getDOMNode()).on('show.bs.modal', function showModal(e) { $(React.findDOMNode(this.refs.modal)).on('show.bs.modal', function showModal(e) {
var button = e.relatedTarget; var button = e.relatedTarget;
var channelId = button.getAttribute('data-channelid'); var channelId = button.getAttribute('data-channelid');
@@ -95,11 +95,11 @@ export default class ChannelNotifications extends React.Component {
} }
handleRadioClick(notifyLevel) { handleRadioClick(notifyLevel) {
this.setState({notifyLevel: notifyLevel, quietMode: false}); this.setState({notifyLevel: notifyLevel, quietMode: false});
this.refs.modal.getDOMNode().focus(); React.findDOMNode(this.refs.modal).focus();
} }
handleQuietToggle(quietMode) { handleQuietToggle(quietMode) {
this.setState({notifyLevel: 'none', quietMode: quietMode}); this.setState({notifyLevel: 'none', quietMode: quietMode});
this.refs.modal.getDOMNode().focus(); React.findDOMNode(this.refs.modal).focus();
} }
createDesktopSection(serverError) { createDesktopSection(serverError) {
var handleUpdateSection; var handleUpdateSection;

Просмотреть файл

@@ -2,33 +2,24 @@
// See License.txt for license information. // See License.txt for license information.
var UserStore = require('../stores/user_store.jsx'); var UserStore = require('../stores/user_store.jsx');
var ZeroClipboardMixin = require('react-zeroclipboard-mixin');
ZeroClipboardMixin.ZeroClipboard.config({
swfPath: '../../static/flash/ZeroClipboard.swf'
});
export default class GetLinkModal extends React.Component { export default class GetLinkModal extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
this.zeroclipboardElementsSelector = '[data-copy-btn]';
this.mixins = [ZeroClipboardMixin];
this.handleClick = this.handleClick.bind(this); this.handleClick = this.handleClick.bind(this);
this.state = {copiedLink: false}; this.state = {copiedLink: false};
} }
componentDidMount() { componentDidMount() {
var self = this;
if (this.refs.modal) { if (this.refs.modal) {
$(this.refs.modal.getDOMNode()).on('show.bs.modal', function show(e) { $(React.findDOMNode(this.refs.modal)).on('show.bs.modal', function show(e) {
var button = e.relatedTarget; var button = e.relatedTarget;
self.setState({title: $(button).attr('data-title'), value: $(button).attr('data-value')}); this.setState({title: $(button).attr('data-title'), value: $(button).attr('data-value')});
}); }.bind(this));
$(this.refs.modal.getDOMNode()).on('hide.bs.modal', function hide() { $(React.findDOMNode(this.refs.modal)).on('hide.bs.modal', function hide() {
self.setState({copiedLink: false}); this.setState({copiedLink: false});
}); }.bind(this));
} }
} }
handleClick() { handleClick() {

Просмотреть файл

@@ -272,25 +272,25 @@ export default class Sidebar extends React.Component {
this.updateUnreadIndicators(); this.updateUnreadIndicators();
} }
updateUnreadIndicators() { updateUnreadIndicators() {
var container = $(this.refs.container.getDOMNode()); var container = $(React.findDOMNode(this.refs.container));
if (this.firstUnreadChannel) { if (this.firstUnreadChannel) {
var firstUnreadElement = $(this.refs[this.firstUnreadChannel].getDOMNode()); var firstUnreadElement = $(React.findDOMNode(this.refs[this.firstUnreadChannel]));
if (firstUnreadElement.position().top + firstUnreadElement.height() < 0) { if (firstUnreadElement.position().top + firstUnreadElement.height() < 0) {
$(this.refs.topUnreadIndicator.getDOMNode()).css('display', 'initial'); $(React.findDOMNode(this.refs.topUnreadIndicator)).css('display', 'initial');
} else { } else {
$(this.refs.topUnreadIndicator.getDOMNode()).css('display', 'none'); $(React.findDOMNode(this.refs.topUnreadIndicator)).css('display', 'none');
} }
} }
if (this.lastUnreadChannel) { if (this.lastUnreadChannel) {
var lastUnreadElement = $(this.refs[this.lastUnreadChannel].getDOMNode()); var lastUnreadElement = $(React.findDOMNode(this.refs[this.lastUnreadChannel]));
if (lastUnreadElement.position().top > container.height()) { if (lastUnreadElement.position().top > container.height()) {
$(this.refs.bottomUnreadIndicator.getDOMNode()).css('display', 'initial'); $(React.findDOMNode(this.refs.bottomUnreadIndicator)).css('display', 'initial');
} else { } else {
$(this.refs.bottomUnreadIndicator.getDOMNode()).css('display', 'none'); $(React.findDOMNode(this.refs.bottomUnreadIndicator)).css('display', 'none');
} }
} }
} }
@@ -315,10 +315,10 @@ export default class Sidebar extends React.Component {
if (unread) { if (unread) {
titleClass = 'unread-title'; titleClass = 'unread-title';
if (!self.firstUnreadChannel) { if (!this.firstUnreadChannel) {
self.firstUnreadChannel = channel.name; this.firstUnreadChannel = channel.name;
} }
self.lastUnreadChannel = channel.name; this.lastUnreadChannel = channel.name;
} }
var badge = null; var badge = null;
@@ -335,7 +335,7 @@ export default class Sidebar extends React.Component {
badge = <span className='badge pull-right small'>{channelMember.mention_count}</span>; badge = <span className='badge pull-right small'>{channelMember.mention_count}</span>;
this.badgesActive = true; this.badgesActive = true;
} }
} else if (self.state.loadingDMChannel === index && channel.type === 'D') { } else if (this.state.loadingDMChannel === index && channel.type === 'D') {
badge = ( badge = (
<img <img
className='channel-loading-gif pull-right' className='channel-loading-gif pull-right'
@@ -377,19 +377,19 @@ export default class Sidebar extends React.Component {
// It's a direct message channel that doesn't exist yet so let's create it now // It's a direct message channel that doesn't exist yet so let's create it now
var otherUserId = Utils.getUserIdFromChannelName(channel); var otherUserId = Utils.getUserIdFromChannelName(channel);
if (self.state.loadingDMChannel === -1) { if (this.state.loadingDMChannel === -1) {
handleClick = function clickHandler(e) { handleClick = function clickHandler(e) {
e.preventDefault(); e.preventDefault();
self.setState({loadingDMChannel: index}); this.setState({loadingDMChannel: index});
Client.createDirectChannel(channel, otherUserId, Client.createDirectChannel(channel, otherUserId,
function success(data) { function success(data) {
self.setState({loadingDMChannel: -1}); this.setState({loadingDMChannel: -1});
AsyncClient.getChannel(data.id); AsyncClient.getChannel(data.id);
Utils.switchChannel(data); Utils.switchChannel(data);
}, },
function error() { function error() {
self.setState({loadingDMChannel: -1}); this.setState({loadingDMChannel: -1});
window.location.href = TeamStore.getCurrentTeamUrl() + '/channels/' + channel.name; window.location.href = TeamStore.getCurrentTeamUrl() + '/channels/' + channel.name;
} }
); );

Просмотреть файл

@@ -52,7 +52,7 @@ export default class FeatureTab extends React.Component {
} }
handleValetRadio(val) { handleValetRadio(val) {
this.setState({allowValet: val}); this.setState({allowValet: val});
this.refs.wrapper.getDOMNode().focus(); React.findDOMNode(this.refs.wrapper).focus();
} }
onUpdateSection(e) { onUpdateSection(e) {
e.preventDefault(); e.preventDefault();
@@ -73,7 +73,6 @@ export default class FeatureTab extends React.Component {
} }
var valetSection; var valetSection;
var self = this;
if (this.props.activeSection === 'valet') { if (this.props.activeSection === 'valet') {
var valetActive = [false, false]; var valetActive = [false, false];
@@ -92,7 +91,7 @@ export default class FeatureTab extends React.Component {
<input <input
type='radio' type='radio'
checked={valetActive[0]} checked={valetActive[0]}
onChange={self.handleValetRadio.bind(this, 'true')} onChange={this.handleValetRadio.bind(this, 'true')}
> >
On On
</input> </input>
@@ -104,7 +103,7 @@ export default class FeatureTab extends React.Component {
<input <input
type='radio' type='radio'
checked={valetActive[1]} checked={valetActive[1]}
onChange={self.handleValetRadio.bind(this, 'false')} onChange={this.handleValetRadio.bind(this, 'false')}
> >
Off Off
</input> </input>

Просмотреть файл

@@ -20,15 +20,15 @@ export default class TeamSignupAllowedDomainsPage extends React.Component {
submitNext(e) { submitNext(e) {
e.preventDefault(); e.preventDefault();
if (this.refs.open_network.getDOMNode().checked) { if (React.findDOMNode(this.refs.open_network).checked) {
this.props.state.wizard = 'send_invites'; this.props.state.wizard = 'send_invites';
this.props.state.team.type = 'O'; this.props.state.team.type = 'O';
this.props.updateParent(this.props.state); this.props.updateParent(this.props.state);
return; return;
} }
if (this.refs.allow.getDOMNode().checked) { if (React.findDOMNode(this.refs.allow).checked) {
var name = this.refs.name.getDOMNode().value.trim(); var name = React.findDOMNode(this.refs.name).value.trim();
var domainRegex = /^\w+\.\w+$/; var domainRegex = /^\w+\.\w+$/;
if (!name) { if (!name) {
this.setState({nameError: 'This field is required'}); this.setState({nameError: 'This field is required'});

Просмотреть файл

@@ -22,7 +22,7 @@ export default class TeamSignupPasswordPage extends React.Component {
submitNext(e) { submitNext(e) {
e.preventDefault(); e.preventDefault();
var password = this.refs.password.getDOMNode().value.trim(); var password = React.findDOMNode(this.refs.password).value.trim();
if (!password || password.length < 5) { if (!password || password.length < 5) {
this.setState({passwordError: 'Please enter at least 5 characters'}); this.setState({passwordError: 'Please enter at least 5 characters'});
return; return;

Просмотреть файл

@@ -59,14 +59,14 @@ export default class UserSettingsAppearance extends React.Component {
} }
componentDidMount() { componentDidMount() {
if (this.props.activeSection === 'theme') { if (this.props.activeSection === 'theme') {
$(this.refs[this.state.theme].getDOMNode()).addClass('active-border'); $(React.findDOMNode(this.refs[this.state.theme])).addClass('active-border');
} }
$('#user_settings').on('hidden.bs.modal', this.handleClose); $('#user_settings').on('hidden.bs.modal', this.handleClose);
} }
componentDidUpdate() { componentDidUpdate() {
if (this.props.activeSection === 'theme') { if (this.props.activeSection === 'theme') {
$('.color-btn').removeClass('active-border'); $('.color-btn').removeClass('active-border');
$(this.refs[this.state.theme].getDOMNode()).addClass('active-border'); $(React.findDOMNode(this.refs[this.state.theme])).addClass('active-border');
} }
} }
componentWillUnmount() { componentWillUnmount() {

Просмотреть файл

@@ -107,7 +107,6 @@ export default class SecurityTab extends React.Component {
var updateSectionStatus; var updateSectionStatus;
var passwordSection; var passwordSection;
var self = this;
if (this.props.activeSection === 'password') { if (this.props.activeSection === 'password') {
var inputs = []; var inputs = [];
var submit = null; var submit = null;
@@ -163,10 +162,10 @@ export default class SecurityTab extends React.Component {
} }
updateSectionStatus = function resetSection(e) { updateSectionStatus = function resetSection(e) {
self.props.updateSection(''); this.props.updateSection('');
self.setState({currentPassword: '', newPassword: '', confirmPassword: '', serverError: null, passwordError: null}); this.setState({currentPassword: '', newPassword: '', confirmPassword: '', serverError: null, passwordError: null});
e.preventDefault(); e.preventDefault();
}; }.bind(this);
passwordSection = ( passwordSection = (
<SettingItemMax <SettingItemMax
@@ -201,8 +200,8 @@ export default class SecurityTab extends React.Component {
} }
updateSectionStatus = function updateSection() { updateSectionStatus = function updateSection() {
self.props.updateSection('password'); this.props.updateSection('password');
}; }.bind(this);
passwordSection = ( passwordSection = (
<SettingItemMin <SettingItemMin

Просмотреть файл

@@ -66,22 +66,21 @@ export default class ViewImageModal extends React.Component {
var fileType = Utils.getFileType(fileInfo.ext); var fileType = Utils.getFileType(fileInfo.ext);
if (fileType === 'image') { if (fileType === 'image') {
var self = this;
var img = new Image(); var img = new Image();
img.load(this.getPreviewImagePath(filename), img.load(this.getPreviewImagePath(filename),
function load() { function load() {
var progress = self.state.progress; var progress = this.state.progress;
progress[id] = img.completedPercentage; progress[id] = img.completedPercentage;
self.setState({progress: progress}); this.setState({progress: progress});
}); }.bind(this));
img.onload = (function onload(imgid) { img.onload = (function onload(imgid) {
return function onloadReturn() { return function onloadReturn() {
var loaded = self.state.loaded; var loaded = this.state.loaded;
loaded[imgid] = true; loaded[imgid] = true;
self.setState({loaded: loaded}); this.setState({loaded: loaded});
$(self.refs.image.getDOMNode()).css('max-height', imgHeight); $(React.findDOMNode(this.refs.image)).css('max-height', imgHeight);
}; }.bind(this);
}(id)); }.bind(this)(id));
var images = this.state.images; var images = this.state.images;
images[id] = img; images[id] = img;
this.setState({images: images}); this.setState({images: images});
@@ -95,48 +94,47 @@ export default class ViewImageModal extends React.Component {
componentDidUpdate() { componentDidUpdate() {
if (this.state.loaded[this.state.imgId]) { if (this.state.loaded[this.state.imgId]) {
if (this.refs.imageWrap) { if (this.refs.imageWrap) {
$(this.refs.imageWrap.getDOMNode()).removeClass('default'); $(React.findDOMNode(this.refs.imageWrap)).removeClass('default');
} }
} }
} }
componentDidMount() { componentDidMount() {
var self = this;
$('#' + this.props.modalId).on('shown.bs.modal', function onModalShow() { $('#' + this.props.modalId).on('shown.bs.modal', function onModalShow() {
self.setState({viewed: true}); this.setState({viewed: true});
self.loadImage(self.state.imgId); this.loadImage(this.state.imgId);
}); }.bind(this));
$(this.refs.modal.getDOMNode()).click(function onModalClick(e) { $(React.findDOMNode(this.refs.modal)).click(function onModalClick(e) {
if (e.target === this || e.target === self.refs.imageBody.getDOMNode()) { if (e.target === this || e.target === React.findDOMNode(this.refs.imageBody)) {
$('.image_modal').modal('hide'); $('.image_modal').modal('hide');
} }
}); }.bind(this));
$(this.refs.imageWrap.getDOMNode()).hover( $(React.findDOMNode(this.refs.imageWrap)).hover(
function onModalHover() { function onModalHover() {
$(self.refs.imageFooter.getDOMNode()).addClass('footer--show'); $(React.findDOMNode(this.refs.imageFooter)).addClass('footer--show');
}, function offModalHover() { }.bind(this), function offModalHover() {
$(self.refs.imageFooter.getDOMNode()).removeClass('footer--show'); $(React.findDOMNode(this.refs.imageFooter)).removeClass('footer--show');
} }.bind(this)
); );
if (this.refs.previewArrowLeft) { if (this.refs.previewArrowLeft) {
$(this.refs.previewArrowLeft.getDOMNode()).hover( $(React.findDOMNode(this.refs.previewArrowLeft)).hover(
function onModalHover() { function onModalHover() {
$(self.refs.imageFooter.getDOMNode()).addClass('footer--show'); $(React.findDOMNode(this.refs.imageFooter)).addClass('footer--show');
}, function offModalHover() { }.bind(this), function offModalHover() {
$(self.refs.imageFooter.getDOMNode()).removeClass('footer--show'); $(React.findDOMNode(this.refs.imageFooter)).removeClass('footer--show');
} }.bind(this)
); );
} }
if (this.refs.previewArrowRight) { if (this.refs.previewArrowRight) {
$(this.refs.previewArrowRight.getDOMNode()).hover( $(React.findDOMNode(this.refs.previewArrowRight)).hover(
function onModalHover() { function onModalHover() {
$(self.refs.imageFooter.getDOMNode()).addClass('footer--show'); $(React.findDOMNode(this.refs.imageFooter)).addClass('footer--show');
}, function offModalHover() { }.bind(this), function offModalHover() {
$(self.refs.imageFooter.getDOMNode()).removeClass('footer--show'); $(React.findDOMNode(this.refs.imageFooter)).removeClass('footer--show');
} }.bind(this)
); );
} }
@@ -242,17 +240,15 @@ export default class ViewImageModal extends React.Component {
// asynchronously request the actual size of this file // asynchronously request the actual size of this file
if (!(filename in this.state.fileSizes)) { if (!(filename in this.state.fileSizes)) {
var self = this;
Client.getFileInfo( Client.getFileInfo(
filename, filename,
function success(data) { function success(data) {
if (self.canSetState) { if (this.canSetState) {
var fileSizes = self.state.fileSizes; var fileSizes = this.state.fileSizes;
fileSizes[filename] = parseInt(data.size, 10); fileSizes[filename] = parseInt(data.size, 10);
self.setState(fileSizes); this.setState(fileSizes);
} }
}, }.bind(this),
function fail() {} function fail() {}
); );
} }