Files
JiboSDK/lib/animation-editor/views/properties/video-input.js
2026-03-22 03:21:45 +02:00

1 line
3.3 KiB
JavaScript

"use strict";var e=function(e){return e&&e.__esModule?e["default"]:e},t=e(require("react")),o=e(require("../../../atom-react/mixins/modal-mixin")),n=e(require("path")),i=e(require("fs")),s=e(require("normalize-path")),r=e(require("../../../common/directory-tree-view")),a=t.createClass({displayName:"VideoChooserModal",getInitialState:function(){return{uri:this.props.uri,filter:""}},onSelected:function(e){this.state.uri=s(e),this.setState(this.state)},onChosen:function(e){this.state.uri=s(e),this.onChoose()},onChoose:function(){this.props.onChoose(this.state.uri),this.props.onClose()},render:function(){return t.createElement("div",{className:"block"},t.createElement("div",{className:"panel-heading"},t.createElement("h1",{style:{textAlign:"center"}},"Choose a Video")),t.createElement("label",{style:{marginLeft:10}},"Search"),t.createElement("atom-text-editor",{ref:"editor",style:{marginLeft:10,marginRight:10,marginBottom:10},mini:!0}),t.createElement("div",null,t.createElement("div",{className:"inline-block",style:{height:600,overflowY:"auto",overflowX:"hidden"}},t.createElement(r,{uri:this.props.root,onChosen:this.onChosen,onSelected:this.onSelected,extension:[".m4v",".mp4",".mov"],filter:this.state.filter}))),t.createElement("hr",null),t.createElement("div",{className:"btn-group"},t.createElement("button",{className:"btn",onClick:this.onChoose},"Choose"),t.createElement("button",{className:"btn",onClick:this.props.onClose},"Close")))},componentDidMount:function(){var e=this,o=t.findDOMNode(this.refs.editor),n=o.getModel();n.onDidChange(function(){e.state.filter=n.getText(),e.setState(e.state)}),this.onSelected(this.props.uri)}}),l=t.createClass({displayName:"VideoInput",mixins:[o],getInitialState:function(){return{content:this.props.content}},componentWillReceiveProps:function(e){this.setState({content:e.content}),this.refs.editor.getDOMNode().getModel().setText(e.content)},render:function(){var e={};try{i.statSync(this.getUri())}catch(o){e={disabled:!0}}var n=e.disabled?t.createElement("div",{className:"error-messages"},"No video file by that name"):null;return t.createElement("div",{style:{width:"100%"}},t.createElement("div",{className:"block"},t.createElement("div",{className:"fileBlock"},t.createElement("button",{style:{"float":"right"},className:"btn",onClick:this.onChoose},"..."),t.createElement("atom-text-editor",{onBlur:this.onBlur,ref:"editor",mini:!0},this.state.content)),n,t.createElement("br",null)))},getUri:function(){var e=n.resolve(this.props.projectRoot,this.state.content);return e},onChoose:function(){var e=this;this.createModal(t.createElement(a,{root:this.props.projectRoot,uri:this.getUri(),onChoose:function(o){var i=n.relative(e.props.projectRoot,o);e.state.content=s(i);var r=t.findDOMNode(e.refs.editor);r.getModel().setText(e.state.content),e.setState(e.state),e.props.onChange(e.state.content)},onClose:function(){e.destroyModal()}}))},onBlur:function(){this.props.onChange(this.state.content)},componentWillUnmount:function(){this.disposable.dispose()},componentDidMount:function(){var e=this,o=t.findDOMNode(this.refs.editor),n=o.getModel();n.onDidChange(function(){e.setState({content:n.getText()})}),this.disposable=atom.commands.add(o,"core:confirm",function(){e.props.onChange(e.state.content)})}});module.exports=function(e,o,n,i){return t.createElement(l,{key:100,content:o,onChange:e,projectRoot:n,animationPath:i})};