Skip to content

Commit

Permalink
add tweets and drag and drop
Browse files Browse the repository at this point in the history
  • Loading branch information
mizzao committed Aug 2, 2013
1 parent a1c6b65 commit d264b31
Show file tree
Hide file tree
Showing 21 changed files with 793 additions and 24 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
.idea
Meteor
dump.rdb

packages
client/lib/*
Expand Down
3 changes: 1 addition & 2 deletions .meteor/packages
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,5 @@ user-status
bootboxjs
publish-with-relations
accounts-testing
turkserver
collection-hooks
sharejs
turkserver
27 changes: 27 additions & 0 deletions client/css/datastream.styl
Original file line number Diff line number Diff line change
@@ -1 +1,28 @@
ul.popout-elements
padding: 4px

.data-cell
position: relative
width: 100%
overflow: hidden
margin-bottom: 3px
border-radius: 5px
border: 3px dotted #CCCCCC

.data-remove
position: absolute
bottom: 0
right: 0

.data-cell:hover,
.data-cell.ui-draggable-dragging
transform: rotate(-3deg)
-webkit-transform: rotate(-3deg)
-moz-transform: rotate(-3deg)
-ms-transform: rotate(-3deg)
-o-transform: rotate(-3deg)
-moz-box-shadow: 8px 8px 5px #666666
-webkit-box-shadow: 8px 8px 5px #666666
box-shadow: 8px 8px 5px #666666
background: white
border: 3px solid #CFF09E
7 changes: 7 additions & 0 deletions client/css/index.styl
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,15 @@ blockquote:before, blockquote:after, q:before, q:after
table
border-collapse: collapse;
border-spacing: 0;
table-layout: fixed
// word-wrap: normal
word-wrap: break-word

.user-list
height: 80px
max-height: 80px
overflow: auto

.scroll-vertical
overflow-x: hidden
overflow-y: auto
12 changes: 6 additions & 6 deletions client/css/mapper.styl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
position: relative

.stack > .pages:not(.active)
visibility: hidden
visibility: hidden

.pages
// overflow: hidden // become a BFC (height wrap), no longer relevant
Expand All @@ -17,9 +17,14 @@
position: absolute
top: 30px
bottom: 0px
-webkit-box-shadow: 0px 0px 5px 5px rgba(0, 0, 0, 0.2);
box-shadow: 0px 0px 5px 5px rgba(0, 0, 0, 0.2);

#map, #events
display: block
-webkit-box-shadow: 0px 0px 5px 5px rgba(0, 0, 0, 0.2);
box-shadow: 0px 0px 5px 5px rgba(0, 0, 0, 0.2);
border-radius: 4px

.popover-fix
position: relative
Expand All @@ -40,11 +45,6 @@ newevent-height = 30px
height: newevent-height
bottom: 0px

table
table-layout: fixed
word-wrap: normal
// word-wrap: break-word

.header-buttons, .header-location
width: 71px

Expand Down
1 change: 1 addition & 0 deletions client/subscriptions.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Meteor.subscribe("chatrooms")
# Chat messages are subscribed to individually

Meteor.subscribe("datastream")
Meteor.subscribe("docs")
Meteor.subscribe("events")

13 changes: 13 additions & 0 deletions client/views/datastream.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Template.datastream.data = ->
Datastream.find()

Template.dataItem.rendered = ->
$(this.firstNode).draggable
addClasses: false
revert: "invalid"
zIndex: 1000
cursorAt: { top: 0, left: 0 }
helper: ->
# Set explicit width on the clone
currentWidth = $(this).width()
return $(this).clone().width(currentWidth)
15 changes: 13 additions & 2 deletions client/views/datastream.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
<template name="datastream">
<div class="well full-height">
<ul class="well full-height scroll-vertical popout-elements">
{{#each data}}
{{> dataItem}}
{{/each}}
</ul>
</template>

</div>
<template name="dataItem">
<li class="data-cell">
{{{text}}}
<button class="btn btn-danger btn-mini data-remove" title="Hide this">
<i class="icon-white icon-remove"></i>
</button>
</li>
</template>
6 changes: 6 additions & 0 deletions client/views/docs.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,9 @@ Template.docCurrent.events =
id = Session.get("document")
Documents.remove(id)
Session.set("document", null)

Template.docCurrent.config = ->
(editor) ->
# Set some reasonable options on the editor
editor.setShowPrintMargin(false)
editor.getSession().setUseWrapMode(true)
2 changes: 1 addition & 1 deletion client/views/docs.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@
{{#if document}}
<input class="input-xlarge" type="text" value="{{title}}">
<button class="btn btn-danger btn-small">Delete this document</button>
{{sharejsAce document id="editor"}}
{{sharejsAce document callback=config id="editor"}}
{{/if}}
</template>
23 changes: 18 additions & 5 deletions client/views/events.coffee
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
Template.events.eventRecords = ->
sort = {}

key = Session.get("eventSortKey")
sort[key] = Session.get("eventSortOrder") || 1 if key?
return Events.find() unless key

Events.find {},
sort: sort
sort = {}
sort[key] = Session.get("eventSortOrder") || 1 if key?
return Events.find {}, { sort: sort }

edit = (e) ->
Events.update @_id,
Expand Down Expand Up @@ -32,7 +33,7 @@ Template.events.events =
region: "",
type: "",
description: "",
sources: ""
sources: []

"click span.sorter": (e) ->
key = $(e.target).closest("span").attr("data-key")
Expand All @@ -54,6 +55,18 @@ Template.events.iconClass = ->
else
"icon-resize-vertical"

Template.eventRow.rendered = ->
data = @data
$(@firstNode).droppable
addClasses: false
hoverClass: "success"
tolerance: "pointer"
drop: (event, ui) ->
tweet = Spark.getDataContext(ui.draggable.context)

Events.update data._id,
$addToSet: { sources: tweet._id }

Template.eventRow.events =
"click .button-locate": (e) ->
# In the future, bring to map edit interface
Expand Down
16 changes: 14 additions & 2 deletions client/views/events.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,19 @@
</template>

<template name="eventRow">
<tr {{#if editing}} class="info" {{/if}}>
<tr class="{{#if editing}}info{{/if}}">

{{#each eventFields}}
{{eventCell ../this this}}
{{/each}}

{{eventCell this "sources"}}
<td>
<div>
{{#each sources}}
{{> tweetIcon this}}
{{/each}}
</div>
</td>

<td><div>
{{#if location}}
Expand Down Expand Up @@ -69,6 +75,12 @@
</tr>
</template>

<template name="tweetIcon">
<span class="label label-info">
<i class="icon-white icon-tag"></i>
</span>
</template>

<template name="_eventCell">
<td><div class="{{#if editable}}editable{{/if}}">
{{value}}
Expand Down
6 changes: 5 additions & 1 deletion client/views/index.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
<head>
<title>CrowdMapper</title>
<title>CrowdMapper</title>

<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.min.js"></script>
<link href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" rel="stylesheet" type="text/css"/>
</head>

<template name="home">
<div class="hero-unit">
<h1>Welcome to CrowdMapper.</h1>
<p>Instructions would be here.</p>
<a href="/mapper" class="btn btn-success">Get started!</a>
</div>
</template>
Expand Down
3 changes: 2 additions & 1 deletion client/views/map.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ Template.map.rendered = ->

changed: (id, fields) ->
feature = vectorLayer.getFeatureById(id)
return unless feature # this should just draw the feature, probably
# don't draw unless the feature exists and location changed
return unless feature and fields.location

feature.geometry.x = fields.location[0]
feature.geometry.y = fields.location[1]
Expand Down
3 changes: 3 additions & 0 deletions models/model.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ this.ChatRooms = new Meteor.Collection("chatrooms")
this.ChatUsers = new Meteor.Collection("chatusers")
this.ChatMessages = new Meteor.Collection("chatmessages")

# Datastream
this.Datastream = new Meteor.Collection("datastream")

# Docs
this.Documents = new Meteor.Collection("docs")

Expand Down
Loading

0 comments on commit d264b31

Please sign in to comment.