This commit is contained in:
Devin Howard 2016-10-02 18:21:56 +08:00
parent bfd23c6d32
commit 0778179ba7
4 changed files with 13 additions and 20 deletions

View file

@ -4,7 +4,7 @@ import outdent from 'outdent'
const Metacode = Backbone.Model.extend({ const Metacode = Backbone.Model.extend({
initialize: function () { initialize: function () {
var image = new Image() var image = new window.Image()
image.crossOrigin = 'Anonymous' image.crossOrigin = 'Anonymous'
image.src = this.get('icon') image.src = this.get('icon')
this.set('image', image) this.set('image', image)

View file

@ -11,7 +11,6 @@ import Realtime from '../Realtime'
import SynapseCard from '../SynapseCard' import SynapseCard from '../SynapseCard'
import Visualize from '../Visualize' import Visualize from '../Visualize'
/* /*
* Dependencies: * Dependencies:
* - Metamaps.Mappings * - Metamaps.Mappings
@ -46,8 +45,7 @@ const Synapse = Backbone.Model.extend({
if (permBefore === 'private' && model.get('permission') !== 'private') { if (permBefore === 'private' && model.get('permission') !== 'private') {
model.trigger('noLongerPrivate') model.trigger('noLongerPrivate')
} } else if (permBefore !== 'private' && model.get('permission') === 'private') {
else if (permBefore !== 'private' && model.get('permission') === 'private') {
model.trigger('nowPrivate') model.trigger('nowPrivate')
} }
} }
@ -104,8 +102,8 @@ const Synapse = Backbone.Model.extend({
return Metamaps.Topics.get(this.get('topic2_id')) return Metamaps.Topics.get(this.get('topic2_id'))
}, },
getDirection: function () { getDirection: function () {
var t1 = this.getTopic1(), var t1 = this.getTopic1()
t2 = this.getTopic2() var t2 = this.getTopic2()
return t1 && t2 ? [ return t1 && t2 ? [
t1.get('node').id, t1.get('node').id,
@ -130,7 +128,7 @@ const Synapse = Backbone.Model.extend({
nodeTo: this.get('topic2_id'), nodeTo: this.get('topic2_id'),
data: { data: {
$synapses: [], $synapses: [],
$synapseIDs: [synapseID], $synapseIDs: [synapseID]
} }
} }
@ -167,7 +165,7 @@ const Synapse = Backbone.Model.extend({
var edge = this.get('edge') var edge = this.get('edge')
// update synapse card, if this synapse is the one open there // update synapse card, if this synapse is the one open there
if (onPageWithSynapseCard && edge == SynapseCard.openSynapseCard) { if (onPageWithSynapseCard && edge === SynapseCard.openSynapseCard) {
SynapseCard.showCard(edge) SynapseCard.showCard(edge)
} }
}, },

View file

@ -46,8 +46,7 @@ const Topic = Backbone.Model.extend({
if (permBefore === 'private' && model.get('permission') !== 'private') { if (permBefore === 'private' && model.get('permission') !== 'private') {
model.trigger('noLongerPrivate') model.trigger('noLongerPrivate')
} } else if (permBefore !== 'private' && model.get('permission') === 'private') {
else if (permBefore !== 'private' && model.get('permission') === 'private') {
model.trigger('nowPrivate') model.trigger('nowPrivate')
} }
} }
@ -87,8 +86,8 @@ const Topic = Backbone.Model.extend({
authorizeToEdit: function (mapper) { authorizeToEdit: function (mapper) {
if (mapper && if (mapper &&
(this.get('user_id') === mapper.get('id') || (this.get('user_id') === mapper.get('id') ||
this.get('calculated_permission') === 'commons' || this.get('calculated_permission') === 'commons' ||
this.get('collaborator_ids').includes(mapper.get('id')))) { this.get('collaborator_ids').includes(mapper.get('id')))) {
return true return true
} else { } else {
return false return false
@ -148,7 +147,7 @@ const Topic = Backbone.Model.extend({
var onPageWithTopicCard = Active.Map || Active.Topic var onPageWithTopicCard = Active.Map || Active.Topic
var node = this.get('node') var node = this.get('node')
// update topic card, if this topic is the one open there // update topic card, if this topic is the one open there
if (onPageWithTopicCard && this == TopicCard.openTopicCard) { if (onPageWithTopicCard && this === TopicCard.openTopicCard) {
TopicCard.showCard(node) TopicCard.showCard(node)
} }
@ -162,7 +161,7 @@ const Topic = Backbone.Model.extend({
var onPageWithTopicCard = Active.Map || Active.Topic var onPageWithTopicCard = Active.Map || Active.Topic
var node = this.get('node') var node = this.get('node')
// update topic card, if this topic is the one open there // update topic card, if this topic is the one open there
if (onPageWithTopicCard && this == TopicCard.openTopicCard) { if (onPageWithTopicCard && this === TopicCard.openTopicCard) {
TopicCard.showCard(node) TopicCard.showCard(node)
} }
}, },

View file

@ -49,7 +49,7 @@ const DataModel = {
Mapping: Mapping, Mapping: Mapping,
MappingCollection: MappingCollection, MappingCollection: MappingCollection,
init: function() { init: function () {
var self = DataModel var self = DataModel
Metamaps.Metacodes = Metamaps.Metacodes ? new self.MetacodeCollection(Metamaps.Metacodes) : new self.MetacodeCollection() Metamaps.Metacodes = Metamaps.Metacodes ? new self.MetacodeCollection(Metamaps.Metacodes) : new self.MetacodeCollection()
@ -93,10 +93,6 @@ const DataModel = {
} }
} }
export { export { Map, MapCollection, Mapper, MapperCollection, Mapping, MappingCollection, Message, MessageCollection, Metacode, MetacodeCollection, Synapse, SynapseCollection, Topic, TopicCollection }
Map, MapCollection, Mapper, MapperCollection, Mapping, MappingCollection,
Message, MessageCollection, Metacode, MetacodeCollection,
Synapse, SynapseCollection, Topic, TopicCollection
}
export default DataModel export default DataModel