2016-10-02 22:28:00 +08:00
|
|
|
/* global $, CanvasLoader, Countable, Hogan, embedly */
|
2017-01-13 00:45:21 -05:00
|
|
|
import React, { PropTypes, Component } from 'react'
|
2016-04-24 11:50:35 -04:00
|
|
|
|
2017-01-13 00:45:21 -05:00
|
|
|
import Util from '../Metamaps/Util'
|
2016-04-24 11:50:35 -04:00
|
|
|
|
2017-01-13 00:45:21 -05:00
|
|
|
var funcs = {
|
|
|
|
buildObject: function(topic, ActiveMapper) {
|
|
|
|
var nodeValues = {}
|
|
|
|
var authorized = topic.authorizeToEdit(ActiveMapper)
|
|
|
|
var inmapsAr = topic.get('inmaps') || []
|
|
|
|
var inmapsLinks = topic.get('inmapsLinks') || []
|
|
|
|
nodeValues.inmaps = ''
|
|
|
|
if (inmapsAr.length < 6) {
|
|
|
|
for (let i = 0; i < inmapsAr.length; i++) {
|
|
|
|
const url = '/maps/' + inmapsLinks[i]
|
|
|
|
nodeValues.inmaps += '<li><a href="' + url + '">' + inmapsAr[i] + '</a></li>'
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for (let i = 0; i < 5; i++) {
|
|
|
|
const url = '/maps/' + inmapsLinks[i]
|
|
|
|
nodeValues.inmaps += '<li><a href="' + url + '">' + inmapsAr[i] + '</a></li>'
|
|
|
|
}
|
|
|
|
const extra = inmapsAr.length - 5
|
|
|
|
nodeValues.inmaps += '<li><span class="showMore">See ' + extra + ' more...</span></li>'
|
|
|
|
for (let i = 5; i < inmapsAr.length; i++) {
|
|
|
|
const url = '/maps/' + inmapsLinks[i]
|
|
|
|
nodeValues.inmaps += '<li class="hideExtra extraText"><a href="' + url + '">' + inmapsAr[i] + '</a></li>'
|
|
|
|
}
|
2016-10-03 08:32:37 +08:00
|
|
|
}
|
2017-01-13 00:45:21 -05:00
|
|
|
nodeValues.permission = topic.get('permission')
|
|
|
|
nodeValues.mk_permission = topic.get('permission').substring(0, 2)
|
|
|
|
nodeValues.map_count = topic.get('map_count').toString()
|
|
|
|
nodeValues.synapse_count = topic.get('synapse_count').toString()
|
|
|
|
nodeValues.id = topic.isNew() ? topic.cid : topic.id
|
|
|
|
nodeValues.metacode = topic.getMetacode().get('name')
|
|
|
|
nodeValues.metacode_class = 'mbg' + topic.get('metacode_id')
|
|
|
|
nodeValues.imgsrc = topic.getMetacode().get('icon')
|
|
|
|
nodeValues.name = topic.get('name')
|
|
|
|
nodeValues.userid = topic.get('user_id')
|
|
|
|
nodeValues.username = topic.get('user_name')
|
|
|
|
nodeValues.userimage = topic.get('user_image')
|
|
|
|
nodeValues.date = topic.getDate()
|
|
|
|
// the code for this is stored in /views/main/_metacodeOptions.html.erb
|
|
|
|
nodeValues.metacode_select = $('#metacodeOptions').html()
|
|
|
|
nodeValues.desc_nil = 'Click to add description...'
|
|
|
|
nodeValues.desc_markdown = (topic.get('desc') === '' && authorized)
|
|
|
|
? nodeValues.desc_nil
|
|
|
|
: topic.get('desc')
|
|
|
|
nodeValues.desc_html = Util.mdToHTML(nodeValues.desc_markdown)
|
|
|
|
return nodeValues
|
2016-10-03 08:32:37 +08:00
|
|
|
},
|
2016-11-07 15:25:08 -05:00
|
|
|
bindShowCardListeners: function(topic) {
|
2016-09-22 15:21:59 +08:00
|
|
|
var self = TopicCard
|
2016-04-24 11:50:35 -04:00
|
|
|
|
|
|
|
var selectingMetacode = false
|
|
|
|
// attach the listener that shows the metacode title when you hover over the image
|
2016-11-07 15:25:08 -05:00
|
|
|
$('.showcard .metacodeImage').mouseenter(function() {
|
2016-04-24 11:50:35 -04:00
|
|
|
$('.showcard .icon').css('z-index', '4')
|
|
|
|
$('.showcard .metacodeTitle').show()
|
|
|
|
})
|
2016-11-07 15:25:08 -05:00
|
|
|
$('.showcard .linkItem.icon').mouseleave(function() {
|
2016-04-24 11:50:35 -04:00
|
|
|
if (!selectingMetacode) {
|
|
|
|
$('.showcard .metacodeTitle').hide()
|
|
|
|
$('.showcard .icon').css('z-index', '1')
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2016-11-07 15:25:08 -05:00
|
|
|
var metacodeLiClick = function() {
|
2016-04-24 11:50:35 -04:00
|
|
|
selectingMetacode = false
|
|
|
|
var metacodeId = parseInt($(this).attr('data-id'))
|
2016-10-02 22:28:00 +08:00
|
|
|
var metacode = DataModel.Metacodes.get(metacodeId)
|
2016-04-24 11:50:35 -04:00
|
|
|
$('.CardOnGraph').find('.metacodeTitle').html(metacode.get('name'))
|
2017-01-13 00:45:21 -05:00
|
|
|
.append('<div class="expandMetacodeSelect"></div>')
|
|
|
|
.attr('class', 'metacodeTitle mbg' + metacode.id)
|
2016-04-24 11:50:35 -04:00
|
|
|
$('.CardOnGraph').find('.metacodeImage').css('background-image', 'url(' + metacode.get('icon') + ')')
|
|
|
|
topic.save({
|
|
|
|
metacode_id: metacode.id
|
|
|
|
})
|
2016-09-22 17:36:47 +08:00
|
|
|
Visualize.mGraph.plot()
|
2016-04-24 11:50:35 -04:00
|
|
|
$('.metacodeSelect').hide().removeClass('onRightEdge onBottomEdge')
|
|
|
|
$('.metacodeTitle').hide()
|
|
|
|
$('.showcard .icon').css('z-index', '1')
|
|
|
|
}
|
|
|
|
|
2016-11-07 15:25:08 -05:00
|
|
|
var openMetacodeSelect = function(event) {
|
2016-04-24 11:50:35 -04:00
|
|
|
var TOPICCARD_WIDTH = 300
|
|
|
|
var METACODESELECT_WIDTH = 404
|
|
|
|
var MAX_METACODELIST_HEIGHT = 270
|
|
|
|
|
|
|
|
if (!selectingMetacode) {
|
|
|
|
selectingMetacode = true
|
|
|
|
|
|
|
|
// this is to make sure the metacode
|
|
|
|
// select is accessible onscreen, when opened
|
|
|
|
// while topic card is close to the right
|
|
|
|
// edge of the screen
|
2016-09-23 14:12:27 +08:00
|
|
|
var windowWidth = $(window).width()
|
|
|
|
var showcardLeft = parseInt($('.showcard').css('left'))
|
|
|
|
var distanceFromEdge = windowWidth - (showcardLeft + TOPICCARD_WIDTH)
|
2016-04-24 11:50:35 -04:00
|
|
|
if (distanceFromEdge < METACODESELECT_WIDTH) {
|
|
|
|
$('.metacodeSelect').addClass('onRightEdge')
|
|
|
|
}
|
|
|
|
|
|
|
|
// this is to make sure the metacode
|
|
|
|
// select is accessible onscreen, when opened
|
|
|
|
// while topic card is close to the bottom
|
|
|
|
// edge of the screen
|
2016-09-23 14:12:27 +08:00
|
|
|
var windowHeight = $(window).height()
|
|
|
|
var showcardTop = parseInt($('.showcard').css('top'))
|
|
|
|
var topicTitleHeight = $('.showcard .title').height() + parseInt($('.showcard .title').css('padding-top')) + parseInt($('.showcard .title').css('padding-bottom'))
|
|
|
|
var distanceFromBottom = windowHeight - (showcardTop + topicTitleHeight)
|
2016-04-24 11:50:35 -04:00
|
|
|
if (distanceFromBottom < MAX_METACODELIST_HEIGHT) {
|
|
|
|
$('.metacodeSelect').addClass('onBottomEdge')
|
|
|
|
}
|
|
|
|
|
|
|
|
$('.metacodeSelect').show()
|
|
|
|
event.stopPropagation()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-07 15:25:08 -05:00
|
|
|
var hideMetacodeSelect = function() {
|
2016-04-24 11:50:35 -04:00
|
|
|
selectingMetacode = false
|
|
|
|
$('.metacodeSelect').hide().removeClass('onRightEdge onBottomEdge')
|
|
|
|
$('.metacodeTitle').hide()
|
|
|
|
$('.showcard .icon').css('z-index', '1')
|
|
|
|
}
|
|
|
|
|
|
|
|
if (authorized) {
|
|
|
|
$('.showcard .metacodeTitle').click(openMetacodeSelect)
|
|
|
|
$('.showcard').click(hideMetacodeSelect)
|
2016-11-07 15:25:08 -05:00
|
|
|
$('.metacodeSelect > ul > li').click(function(event) {
|
2016-04-24 11:50:35 -04:00
|
|
|
event.stopPropagation()
|
|
|
|
})
|
|
|
|
$('.metacodeSelect li li').click(metacodeLiClick)
|
|
|
|
|
|
|
|
var bipName = $(showCard).find('.best_in_place_name')
|
2016-11-07 15:25:08 -05:00
|
|
|
bipName.bind('best_in_place:activate', function() {
|
2016-04-24 11:50:35 -04:00
|
|
|
var $el = bipName.find('textarea')
|
|
|
|
var el = $el[0]
|
|
|
|
|
|
|
|
$el.attr('maxlength', '140')
|
|
|
|
|
|
|
|
$('.showcard .title').append('<div class="nameCounter forTopic"></div>')
|
|
|
|
|
2016-11-07 15:25:08 -05:00
|
|
|
var callback = function(data) {
|
2016-04-24 11:50:35 -04:00
|
|
|
$('.nameCounter.forTopic').html(data.all + '/140')
|
|
|
|
}
|
|
|
|
Countable.live(el, callback)
|
|
|
|
})
|
2016-11-07 15:25:08 -05:00
|
|
|
bipName.bind('best_in_place:deactivate', function() {
|
2016-04-24 11:50:35 -04:00
|
|
|
$('.nameCounter.forTopic').remove()
|
|
|
|
})
|
2016-10-08 16:42:34 +08:00
|
|
|
bipName.keypress(function(e) {
|
|
|
|
const ENTER = 13
|
|
|
|
if (e.which === ENTER) { // enter
|
|
|
|
$(this).data('bestInPlaceEditor').update()
|
|
|
|
}
|
|
|
|
})
|
2016-04-24 11:50:35 -04:00
|
|
|
|
|
|
|
// bind best_in_place ajax callbacks
|
2016-11-07 15:25:08 -05:00
|
|
|
bipName.bind('ajax:success', function() {
|
2016-09-22 17:36:47 +08:00
|
|
|
var name = Util.decodeEntities($(this).html())
|
2016-04-24 11:50:35 -04:00
|
|
|
topic.set('name', name)
|
|
|
|
topic.trigger('saved')
|
|
|
|
})
|
|
|
|
|
2016-10-07 17:23:11 +08:00
|
|
|
// this is for all subsequent renders after in-place editing the desc field
|
2016-10-07 17:26:20 +08:00
|
|
|
const bipDesc = $(showCard).find('.best_in_place_desc')
|
2016-11-07 15:25:08 -05:00
|
|
|
bipDesc.bind('ajax:success', function() {
|
2016-10-07 17:26:20 +08:00
|
|
|
var desc = $(this).html() === $(this).data('bip-nil')
|
2017-01-13 00:45:21 -05:00
|
|
|
? ''
|
|
|
|
: $(this).text()
|
2016-04-24 11:50:35 -04:00
|
|
|
topic.set('desc', desc)
|
2016-10-07 17:26:20 +08:00
|
|
|
$(this).data('bip-value', desc)
|
2016-10-07 17:23:11 +08:00
|
|
|
this.innerHTML = Util.mdToHTML(desc)
|
2016-04-24 11:50:35 -04:00
|
|
|
topic.trigger('saved')
|
|
|
|
})
|
2016-10-08 16:42:34 +08:00
|
|
|
bipDesc.keypress(function(e) {
|
|
|
|
// allow typing Enter with Shift+Enter
|
|
|
|
const ENTER = 13
|
|
|
|
if (e.shiftKey === false && e.which === ENTER) {
|
|
|
|
$(this).data('bestInPlaceEditor').update()
|
|
|
|
}
|
|
|
|
})
|
2016-04-24 11:50:35 -04:00
|
|
|
}
|
|
|
|
|
2016-11-07 15:25:08 -05:00
|
|
|
var permissionLiClick = function(event) {
|
2016-04-24 11:50:35 -04:00
|
|
|
selectingPermission = false
|
|
|
|
var permission = $(this).attr('class')
|
|
|
|
topic.save({
|
|
|
|
permission: permission,
|
|
|
|
defer_to_map_id: null
|
|
|
|
})
|
|
|
|
$('.showcard .mapPerm').removeClass('co pu pr minimize').addClass(permission.substring(0, 2))
|
|
|
|
$('.showcard .permissionSelect').remove()
|
|
|
|
}
|
|
|
|
|
2016-11-07 15:25:08 -05:00
|
|
|
var openPermissionSelect = function(event) {
|
2016-04-24 11:50:35 -04:00
|
|
|
if (!selectingPermission) {
|
|
|
|
selectingPermission = true
|
|
|
|
$(this).addClass('minimize') // this line flips the drop down arrow to a pull up arrow
|
|
|
|
if ($(this).hasClass('co')) {
|
|
|
|
$(this).append('<ul class="permissionSelect"><li class="public"></li><li class="private"></li></ul>')
|
|
|
|
} else if ($(this).hasClass('pu')) {
|
|
|
|
$(this).append('<ul class="permissionSelect"><li class="commons"></li><li class="private"></li></ul>')
|
|
|
|
} else if ($(this).hasClass('pr')) {
|
|
|
|
$(this).append('<ul class="permissionSelect"><li class="commons"></li><li class="public"></li></ul>')
|
|
|
|
}
|
|
|
|
$('.showcard .permissionSelect li').click(permissionLiClick)
|
|
|
|
event.stopPropagation()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-07 15:25:08 -05:00
|
|
|
var hidePermissionSelect = function() {
|
2016-04-24 11:50:35 -04:00
|
|
|
selectingPermission = false
|
|
|
|
$('.showcard .yourTopic .mapPerm').removeClass('minimize') // this line flips the pull up arrow to a drop down arrow
|
|
|
|
$('.showcard .permissionSelect').remove()
|
|
|
|
}
|
|
|
|
// ability to change permission
|
|
|
|
var selectingPermission = false
|
2016-09-22 17:36:47 +08:00
|
|
|
if (topic.authorizePermissionChange(Active.Mapper)) {
|
2016-04-24 11:50:35 -04:00
|
|
|
$('.showcard .yourTopic .mapPerm').click(openPermissionSelect)
|
|
|
|
$('.showcard').click(hidePermissionSelect)
|
|
|
|
}
|
|
|
|
|
2016-11-07 15:25:08 -05:00
|
|
|
$('.links .mapCount').unbind().click(function(event) {
|
2016-04-24 11:50:35 -04:00
|
|
|
$('.mapCount .tip').toggle()
|
|
|
|
$('.showcard .hoverTip').toggleClass('hide')
|
|
|
|
})
|
2016-11-07 15:25:08 -05:00
|
|
|
$('.showcard').unbind('.hideTip').bind('click.hideTip', function() {
|
2016-04-24 11:50:35 -04:00
|
|
|
$('.mapCount .tip').hide()
|
|
|
|
$('.showcard .hoverTip').removeClass('hide')
|
|
|
|
})
|
|
|
|
|
|
|
|
var originalText = $('.showMore').html()
|
|
|
|
$('.mapCount .tip .showMore').unbind().toggle(
|
2016-11-07 15:25:08 -05:00
|
|
|
function(event) {
|
2016-04-24 11:50:35 -04:00
|
|
|
$('.extraText').toggleClass('hideExtra')
|
|
|
|
$('.showMore').html('Show less...')
|
|
|
|
},
|
2016-11-07 15:25:08 -05:00
|
|
|
function(event) {
|
2016-04-24 11:50:35 -04:00
|
|
|
$('.extraText').toggleClass('hideExtra')
|
|
|
|
$('.showMore').html(originalText)
|
|
|
|
})
|
2017-01-13 00:45:21 -05:00
|
|
|
}
|
2017-01-24 12:17:34 -05:00
|
|
|
}
|
2016-04-24 11:50:35 -04:00
|
|
|
|
2017-01-13 00:45:21 -05:00
|
|
|
class ReactTopicCard extends Component {
|
|
|
|
constructor(props) {
|
|
|
|
super(props)
|
|
|
|
|
|
|
|
this.state = {
|
|
|
|
nameEdit: '',
|
|
|
|
descEdit: '',
|
|
|
|
linkEdit: '',
|
|
|
|
embedlyLinkError: false,
|
|
|
|
embedlyLinkStarted: false,
|
|
|
|
embedlyLinkLoaded: false
|
|
|
|
}
|
|
|
|
}
|
2016-04-24 11:50:35 -04:00
|
|
|
|
2017-01-13 00:45:21 -05:00
|
|
|
componentDidMount = () => {
|
|
|
|
const { topic } = this.props
|
|
|
|
embedly('on', 'card.rendered', this.embedlyCardRendered)
|
|
|
|
topic.get('link') && topic.get('link') !== '' && this.loadLink()
|
|
|
|
}
|
2016-04-24 11:50:35 -04:00
|
|
|
|
2017-01-13 00:45:21 -05:00
|
|
|
componentWillUnmount = () => {
|
|
|
|
embedly('off')
|
|
|
|
}
|
2016-04-24 11:50:35 -04:00
|
|
|
|
2017-01-13 00:45:21 -05:00
|
|
|
componentDidUpdate = () => {
|
|
|
|
const { topic } = this.props
|
|
|
|
const { embedlyLinkStarted } = this.state
|
|
|
|
!embedlyLinkStarted && topic.get('link') && topic.get('link') !== '' && this.loadLink()
|
|
|
|
}
|
2016-04-24 11:50:35 -04:00
|
|
|
|
2017-01-13 00:45:21 -05:00
|
|
|
embedlyCardRendered = (iframe, test) => {
|
|
|
|
this.setState({embedlyLinkLoaded: true, embedlyLinkError: false})
|
|
|
|
}
|
2016-04-24 11:50:35 -04:00
|
|
|
|
2017-01-13 00:45:21 -05:00
|
|
|
resetLinkInput = () => {
|
|
|
|
this.setState({linkEdit: ''})
|
|
|
|
this.linkInput.focus()
|
|
|
|
}
|
2016-04-24 11:50:35 -04:00
|
|
|
|
2017-01-13 00:45:21 -05:00
|
|
|
onLinkChangeHandler = e => {
|
|
|
|
this.setState({linkEdit: e.target.value})
|
|
|
|
}
|
2016-04-24 11:50:35 -04:00
|
|
|
|
2017-01-13 00:45:21 -05:00
|
|
|
onLinkKeyUpHandler = e => {
|
|
|
|
const { addLink } = this.props
|
|
|
|
const { linkEdit } = this.state
|
|
|
|
let finalLink
|
|
|
|
const ENTER_KEY = 13
|
|
|
|
if (e.which === ENTER_KEY) {
|
|
|
|
// TODO evaluate converting this to '//' no matter what (infer protocol)
|
|
|
|
if (linkEdit.slice(0, 7) !== 'http://' &&
|
|
|
|
linkEdit.slice(0, 8) !== 'https://' &&
|
|
|
|
linkEdit.slice(0, 2) !== '//') {
|
|
|
|
finalLink = '//' + linkEdit
|
|
|
|
}
|
|
|
|
this.setState({linkEdit: ''})
|
|
|
|
addLink(finalLink)
|
2016-04-24 11:50:35 -04:00
|
|
|
}
|
2017-01-13 00:45:21 -05:00
|
|
|
}
|
2016-04-24 11:50:35 -04:00
|
|
|
|
2017-01-13 00:45:21 -05:00
|
|
|
loadLink = () => {
|
|
|
|
this.setState({embedlyLinkStarted: true})
|
|
|
|
var e = embedly('card', document.getElementById('embedlyLink'))
|
|
|
|
if (e.type === 'error') this.setState({embedlyLinkError: true})
|
|
|
|
}
|
2016-04-24 11:50:35 -04:00
|
|
|
|
2017-01-13 00:45:21 -05:00
|
|
|
removeLink = () => {
|
|
|
|
const { removeLink } = this.props
|
|
|
|
this.setState({
|
|
|
|
embedlyLinkStarted: false,
|
|
|
|
embedlyLinkLoaded: false,
|
|
|
|
embedlyLinkError: false
|
|
|
|
})
|
|
|
|
removeLink()
|
|
|
|
}
|
2016-04-24 11:50:35 -04:00
|
|
|
|
2017-01-13 00:45:21 -05:00
|
|
|
render = () => {
|
|
|
|
const { topic, ActiveMapper, removeLink } = this.props
|
|
|
|
const { linkEdit, embedlyLinkLoaded, embedlyLinkStarted, embedlyLinkError } = this.state
|
|
|
|
const values = funcs.buildObject(topic, ActiveMapper)
|
|
|
|
var authorizedToEdit = topic.authorizeToEdit(ActiveMapper)
|
2017-01-24 17:25:28 -05:00
|
|
|
|
2017-01-13 00:45:21 -05:00
|
|
|
let classname = 'permission'
|
2017-01-24 17:25:28 -05:00
|
|
|
if (authorizedToEdit) {
|
|
|
|
classname += ' canEdit'
|
|
|
|
} else {
|
|
|
|
classname += ' cannotEdit'
|
|
|
|
}
|
|
|
|
|
2017-01-13 00:45:21 -05:00
|
|
|
if (topic.authorizePermissionChange(ActiveMapper)) classname += ' yourTopic'
|
|
|
|
const hasAttachment = topic.get('link') && topic.get('link') !== ''
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className={classname}>
|
|
|
|
<div className={`CardOnGraph ${hasAttachment ? 'hasAttachment' : ''}`} id={`topic_${values.id}`}>
|
|
|
|
<span className="title">
|
|
|
|
<div className="titleWrapper" id="titleActivator">
|
|
|
|
<span className="best_in_place best_in_place_name">
|
|
|
|
{values.name}
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
</span>
|
2017-01-24 12:17:34 -05:00
|
|
|
<div className="links">
|
|
|
|
<div className="linkItem icon">
|
|
|
|
<div className={`metacodeTitle ${values.metacode_class}`}>
|
|
|
|
{values.metacode}
|
|
|
|
<div className="expandMetacodeSelect"></div>
|
|
|
|
</div>
|
|
|
|
<div className="metacodeImage" style={{backgroundImage: `url(${values.imgsrc})`}} title="click and drag to move card"></div>
|
|
|
|
<div className="metacodeSelect">{values.metacode_select}</div>
|
|
|
|
</div>
|
|
|
|
<div className="linkItem contributor">
|
|
|
|
<a href={`/explore/mapper/${values.userid}`} target="_blank"><img src={values.userimage} className="contributorIcon" width="32" height="32" /></a>
|
|
|
|
<div className="contributorName">{values.username}</div>
|
|
|
|
</div>
|
|
|
|
<div className="linkItem mapCount">
|
|
|
|
<div className="mapCountIcon"></div>
|
|
|
|
{values.map_count}
|
|
|
|
<div className ="hoverTip">Click to see which maps topic appears on</div>
|
|
|
|
<div className="tip"><ul>{values.inmaps}</ul></div>
|
|
|
|
</div>
|
|
|
|
<a href={`/topics/${values.id}`} target="_blank" className="linkItem synapseCount">
|
|
|
|
<div className="synapseCountIcon"></div>
|
|
|
|
{values.synapse_count}
|
|
|
|
<div className="tip">Click to see this topics synapses</div>
|
|
|
|
</a>
|
|
|
|
<div className={`linkItem mapPerm ${values.mk_permission}`} title={values.permission}></div>
|
|
|
|
<div className="clearfloat"></div>
|
|
|
|
</div>
|
2017-01-13 00:45:21 -05:00
|
|
|
<div className="scroll">
|
|
|
|
<div className="desc">
|
|
|
|
<span className="best_in_place best_in_place_desc"
|
|
|
|
dangerouslySetInnerHTML={{__html: values.desc_html}}
|
|
|
|
>
|
|
|
|
</span>
|
|
|
|
<div className="clearfloat"></div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{hasAttachment && <div className={`embeds ${embedlyLinkLoaded ? '' : 'nonEmbedlyLink'}`}>
|
|
|
|
<a href={topic.get('link')} id="embedlyLink" target="_blank" data-card-description="0">
|
|
|
|
{topic.get('link')}
|
|
|
|
</a>
|
|
|
|
{embedlyLinkStarted && !embedlyLinkLoaded && !embedlyLinkError && <div id="embedlyLinkLoader">loading...</div>}
|
|
|
|
{authorizedToEdit && <div id="linkremove" onClick={this.removeLink}></div>}
|
|
|
|
</div>}
|
|
|
|
{authorizedToEdit && !hasAttachment && <div className='attachments'>
|
|
|
|
<div className="addLink">
|
|
|
|
<div id="addLinkIcon"></div>
|
|
|
|
<div id="addLinkInput">
|
|
|
|
<input ref={input => this.linkInput = input}
|
|
|
|
placeholder="Enter or paste a link"
|
|
|
|
value={linkEdit}
|
|
|
|
onChange={this.onLinkChangeHandler}
|
|
|
|
onKeyUp={this.onLinkKeyUpHandler}></input>
|
|
|
|
{linkEdit && <div id="addLinkReset"></div>}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>}
|
|
|
|
<div className="clearfloat"></div>
|
|
|
|
</div>
|
|
|
|
</div>)
|
2016-04-24 11:50:35 -04:00
|
|
|
}
|
2016-09-22 15:21:59 +08:00
|
|
|
}
|
|
|
|
|
2017-01-13 00:45:21 -05:00
|
|
|
ReactTopicCard.propTypes = {
|
|
|
|
topic: PropTypes.object,
|
|
|
|
ActiveMapper: PropTypes.object,
|
|
|
|
removeLink: PropTypes.func,
|
|
|
|
addLink: PropTypes.func
|
|
|
|
}
|
|
|
|
|
|
|
|
export default ReactTopicCard
|
|
|
|
|