opds-web-client
Version:
32 lines (31 loc) • 1.63 kB
JavaScript
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var React = require("react");
require("../stylesheets/url_form.scss");
var UrlForm = (function (_super) {
__extends(UrlForm, _super);
function UrlForm(props) {
_super.call(this, props);
this.onSubmit = this.onSubmit.bind(this);
}
UrlForm.prototype.render = function () {
var placeholder = "e.g. http://feedbooks.github.io/opds-test-catalog/catalog/root.xml";
return (React.createElement("div", {className: "url-form"}, React.createElement("h2", null, "View OPDS Feed"), React.createElement("form", {onSubmit: this.onSubmit, className: "form-inline"}, React.createElement("input", {ref: "input", name: "collection", type: "text", className: "form-control input-lg", defaultValue: this.props.collectionUrl, placeholder: placeholder}), " ", React.createElement("button", {type: "submit", className: "btn btn-lg btn-default"}, "Go"))));
};
UrlForm.prototype.onSubmit = function (event) {
var url = this.refs["input"]["value"];
this.context.router.push(this.context.pathFor(url, null));
event.preventDefault();
};
UrlForm.contextTypes = {
router: React.PropTypes.object.isRequired,
pathFor: React.PropTypes.func.isRequired
};
return UrlForm;
}(React.Component));
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = UrlForm;
;