UNPKG

brackets-npm-registry

Version:

Install your extensions into Brackets using npm

74 lines (67 loc) 2.37 kB
define(function (require, exports) { 'use strict'; var Promise = require('bluebird'); var Strings = require('strings'); var Dialogs = brackets.getModule('widgets/Dialogs'); var React = brackets.getModule('thirdparty/react'); var ReactDOM = brackets.getModule('thirdparty/react-dom'); var dialog = null; var QuestionDialog = React.createClass({ displayName: 'QuestionDialog', render: function render() { return React.createElement( 'div', { id: 'brackets-npm-registry-question-dialog' }, React.createElement( 'div', { className: 'modal-header' }, React.createElement( 'h1', { className: 'dialog-title' }, this.props.title ) ), React.createElement( 'div', { className: 'modal-body' }, React.createElement( 'p', null, this.props.question ), React.createElement('input', { type: 'text', defaultValue: this.props['default'] }) ), React.createElement( 'div', { className: 'modal-footer' }, React.createElement( 'button', { 'data-button-id': 'cancel', className: 'dialog-button btn' }, Strings.CANCEL ), React.createElement( 'button', { 'data-button-id': 'ok', className: 'dialog-button btn primary' }, Strings.OK ) ) ); } }); function show(title, question, defValue) { var template = '<div class="template modal"/>'; dialog = Dialogs.showModalDialogUsingTemplate(template); var $dialog = dialog.getElement(); ReactDOM.render(React.createElement(QuestionDialog, { title: title, question: question, 'default': defValue }), $dialog[0]); return new Promise(function (resolve, reject) { dialog.done(function (buttonId) { var $input = dialog.getElement().find('input'); var inputValue = $input.val().trim() || null; return buttonId === 'ok' ? resolve(inputValue) : reject(); }); }); } exports.show = show; exports._QuestionDialog = QuestionDialog; }); //# sourceMappingURL=C:\Users\Zaggi\AppData\Roaming\Brackets-Electron\extensions\user\brackets-npm-registry\dist//../ui/react-components/question-dialog.js.map