solrkit
Version:
  UI Components for Solr, using TypeScript + React
84 lines • 4.39 kB
JavaScript
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __assign = (this && this.__assign) || Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
import * as React from 'react';
import { DetailLayout } from '../../../layout/DetailLayout';
import { MoreLikeThis } from '../../../component/MoreLikeThis';
import { SearchBox } from '../../../component/SearchBox';
import { AppDataStore } from './data/AppDataStore';
import { databind } from '../../../context/DataBinding';
import { suggestions } from './data/suggestions';
import { Link } from 'react-router-dom';
var VideoPlayer = (function (_super) {
__extends(VideoPlayer, _super);
function VideoPlayer() {
return _super !== null && _super.apply(this, arguments) || this;
}
VideoPlayer.prototype.youtubeId = function (url) {
return url.replace(/.*v=/, '');
};
VideoPlayer.prototype.render = function () {
var url = this.props.url_s;
var ytUrl = url ? ('https://www.youtube.com/embed/' + this.youtubeId(url)
+ '?modestbranding=true') : undefined;
return (React.createElement("div", null,
React.createElement("iframe", { id: "player", width: "100%", height: "390", src: ytUrl }),
React.createElement("h2", null, this.props.title_s)));
};
return VideoPlayer;
}(React.Component));
function ytId(url) {
return url.split('v=')[1].split('&')[0];
}
var dataStore = new AppDataStore();
var DetailPageApp = (function (_super) {
__extends(DetailPageApp, _super);
function DetailPageApp() {
var _this = _super.call(this) || this;
_this.left = databind(dataStore.talks.onGet, dataStore.talks, function (talk) { return (React.createElement(VideoPlayer, __assign({}, talk))); });
_this.right = databind(dataStore.talks.onMoreLikeThis, dataStore.talks, function (talks) { return (React.createElement(MoreLikeThis, { title: "More Like This:", docs: talks, render: function (talk) { return (talk.url_s.indexOf('youtube.com') > 0 ? (React.createElement("table", { style: { width: '100%' } },
React.createElement("tr", null,
React.createElement("td", { style: { width: '50%' } },
React.createElement(Link, { to: '/view/' + talk.id },
React.createElement("img", { style: { width: '100%' }, src: 'https://img.youtube.com/vi/' + ytId(talk.url_s) + '/mqdefault.jpg', alt: talk.title_s }))),
React.createElement("td", null,
React.createElement(Link, { to: '/view/' + talk.id },
React.createElement("b", null, talk.title_s)))))) : null); } })); });
_this.header = databind(dataStore.talks.onMoreLikeThis, dataStore.talks, function (talk) { return (React.createElement(SearchBox, { placeholder: "Search...", loading: false, sampleSearches: suggestions })); });
return _this;
}
DetailPageApp.prototype.init = function () {
dataStore.talks.doGet(this.props.id);
dataStore.talks.doMoreLikeThis(this.props.id);
};
DetailPageApp.prototype.componentWillReceiveProps = function () {
this.init();
};
DetailPageApp.prototype.componentDidMount = function () {
this.init();
};
DetailPageApp.prototype.componentWillUnmount = function () {
dataStore.clearEvents();
};
DetailPageApp.prototype.render = function () {
return (React.createElement(DetailLayout, { leftComponent: this.left, rightComponent: this.right, headerComponent: this.header }));
};
return DetailPageApp;
}(React.Component));
export { DetailPageApp };
//# sourceMappingURL=DetailPage.js.map