From 83eae1b64a3d16466bc872bc78a284896e8c60eb Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Thu, 26 Nov 2015 15:15:45 +0000 Subject: [PATCH] Move and merge EditableText into React SDK --- src/skins/vector/skindex.js | 2 +- src/skins/vector/views/atoms/EditableText.js | 76 ------------------- .../views/molecules/ChangeDisplayName.js | 2 +- .../vector/views/molecules/RoomHeader.js | 2 +- 4 files changed, 3 insertions(+), 79 deletions(-) delete mode 100644 src/skins/vector/views/atoms/EditableText.js diff --git a/src/skins/vector/skindex.js b/src/skins/vector/skindex.js index 41ee39e18..3cce47dcc 100644 --- a/src/skins/vector/skindex.js +++ b/src/skins/vector/skindex.js @@ -32,9 +32,9 @@ skin['messages.MessageTimestamp'] = require('../../components/views/messages/Mes skin['avatars.RoomAvatar'] = require('matrix-react-sdk/lib/components/views/avatars/RoomAvatar'); skin['avatars.MemberAvatar'] = require('matrix-react-sdk/lib/components/views/avatars/MemberAvatar'); skin['settings.EnableNotificationsButton'] = require('matrix-react-sdk/lib/components/views/settings/EnableNotificationsButton'); +skin['elements.EditableText'] = require('matrix-react-sdk/lib/components/views/elements/EditableText'); // Old style stuff -skin['atoms.EditableText'] = require('./views/atoms/EditableText'); skin['atoms.create_room.CreateRoomButton'] = require('./views/atoms/create_room/CreateRoomButton'); skin['atoms.create_room.Presets'] = require('./views/atoms/create_room/Presets'); skin['atoms.create_room.RoomAlias'] = require('./views/atoms/create_room/RoomAlias'); diff --git a/src/skins/vector/views/atoms/EditableText.js b/src/skins/vector/views/atoms/EditableText.js deleted file mode 100644 index 1848b029a..000000000 --- a/src/skins/vector/views/atoms/EditableText.js +++ /dev/null @@ -1,76 +0,0 @@ -/* -Copyright 2015 OpenMarket Ltd - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -'use strict'; - -var React = require('react'); - -var EditableTextController = require('matrix-react-sdk/lib/controllers/atoms/EditableText') - -module.exports = React.createClass({ - displayName: 'EditableText', - mixins: [EditableTextController], - - onKeyUp: function(ev) { - if (ev.key == "Enter") { - this.onFinish(ev); - } else if (ev.key == "Escape") { - this.cancelEdit(); - } - }, - - onClickDiv: function() { - this.setState({ - phase: this.Phases.Edit, - }) - }, - - onFocus: function(ev) { - ev.target.setSelectionRange(0, ev.target.value.length); - }, - - onFinish: function(ev) { - if (ev.target.value) { - this.setValue(ev.target.value, ev.key === "Enter"); - } else { - this.cancelEdit(); - } - }, - - render: function() { - var editable_el; - - if (this.state.phase == this.Phases.Display) { - if (this.state.value) { - editable_el =
{this.state.value}
; - } else { - editable_el =
{this.props.label}
; - } - } else if (this.state.phase == this.Phases.Edit) { - editable_el = ( -
- -
- ); - } - - return ( -
- {editable_el} -
- ); - } -}); diff --git a/src/skins/vector/views/molecules/ChangeDisplayName.js b/src/skins/vector/views/molecules/ChangeDisplayName.js index f645bbbe4..2798d6c12 100644 --- a/src/skins/vector/views/molecules/ChangeDisplayName.js +++ b/src/skins/vector/views/molecules/ChangeDisplayName.js @@ -46,7 +46,7 @@ module.exports = React.createClass({
{this.state.errorString}
); } else { - var EditableText = sdk.getComponent('atoms.EditableText'); + var EditableText = sdk.getComponent('elements.EditableText'); return ( ); diff --git a/src/skins/vector/views/molecules/RoomHeader.js b/src/skins/vector/views/molecules/RoomHeader.js index e90865490..802881729 100644 --- a/src/skins/vector/views/molecules/RoomHeader.js +++ b/src/skins/vector/views/molecules/RoomHeader.js @@ -43,7 +43,7 @@ module.exports = React.createClass({ }, render: function() { - var EditableText = sdk.getComponent("atoms.EditableText"); + var EditableText = sdk.getComponent("elements.EditableText"); var RoomAvatar = sdk.getComponent('avatars.RoomAvatar'); var header;