Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
  • 5 commits
  • 10 files changed
  • 0 commit comments
  • 1 contributor
View
1 .rspec
@@ -1 +1,2 @@
--colour
+--drb
View
53 app/assets/javascripts/editor.js.coffee
@@ -0,0 +1,53 @@
+initBrowserWarning = ->
+ isChrome = navigator.userAgent.toLowerCase().indexOf("chrome") > -1
+ isFirefox = navigator.userAgent.toLowerCase().indexOf("firefox") > -1
+ $("#browser-warning").fadeIn 125 if not isChrome and not isFirefox
+initDnD = ->
+ $("html").bind "dragenter", onDragEnter
+ document.getElementById("drop-box-overlay").addEventListener "dragleave", onDragLeave, false
+ document.getElementById("drop-box-overlay").addEventListener "dragover", noopHandler, false
+ document.getElementById("drop-box-overlay").addEventListener "drop", onDrop, false
+initEditor = ->
+noopHandler = (evt) ->
+ evt.stopPropagation()
+ evt.preventDefault()
+onDragEnter = (evt) ->
+ $("#drop-box-overlay").show()
+ $("#drop-box-prompt").show()
+ false
+onDragLeave = (evt) ->
+ $("#drop-box-overlay").fadeOut 125
+ $("#drop-box-prompt").fadeOut 125
+onDrop = (evt) ->
+ noopHandler evt
+ $("#drop-box-overlay").fadeOut 0
+ $("#drop-box-prompt").fadeOut 0
+ files = evt.dataTransfer.files
+ return if typeof files == "undefined" or files.length == 0
+ uploadFile files[0], length
+uploadFile = (file, totalFiles) ->
+ reader = new FileReader()
+ reader.onerror = (evt) ->
+ switch evt.target.error.code
+ when 1
+ message = file.name + " not found."
+ when 2
+ message = file.name + " has changed on disk, please re-try."
+ when 3
+ messsage = "Upload cancelled."
+ when 4
+ message = "Cannot read " + file.name + "."
+ when 5
+ message = "File too large for browser to upload."
+ $("#upload-status-text").html message
+
+ reader.onloadend = (evt) ->
+ data = evt.currentTarget.result
+ buffer = $("#fileBuffer")
+ buffer.attr "value", data
+
+ reader.readAsText file
+$(document).ready ->
+ initBrowserWarning()
+ initDnD()
+ initEditor()
View
28 app/assets/stylesheets/editor.css.sass
@@ -0,0 +1,28 @@
+#drop-box-overlay
+ display: none
+ position: absolute
+ width: 100%
+ height: 100%
+ background-color: #585858
+ top: 0px
+ left: 0px
+ opacity: 0.7
+
+#upload-status-text
+ display: block
+ position: relative
+ width: 100%
+
+#fileBuffer, #sharingList
+ display: inline-block
+
+#fileBuffer
+ position: relative
+ width: 77%
+ height: 460px
+
+#sharingList
+ width: 19%
+ height: 100%
+ vertical-align: top
+ padding-left: 1em
View
19 app/assets/stylesheets/pair_me.css.sass
@@ -1,18 +1,21 @@
@import "mixins"
@import "font_faces"
-$bg_color: #A8BEA9
+$bg_color: #A8BEA9
+$bg_from_color: #1F1F1F
+$bg_to_color: #4B4B4B
+$even_bg_color: #DCDCDC
+$odd_bg_color: #B9B9B9
.field
label
display: block
-.blue
- color: #3F65CE
html
height: 100%
- +gradient-bg(#B9B9B9, #DCDCDC)
+ +gradient-bg($bg_from_color, $bg_to_color)
+ //+gradient-bg(#B9B9B9, #DCDCDC)
body
padding: 0 10%
@@ -32,9 +35,13 @@ body
border: solid 1px
+border-radius(5px)
+ header#appHeader
+ color: white
+ .highlite
+ color: red
.even
- background-color: #DCDCDC !important
+ background-color: $even_bg_color !important
.odd
- background-color: #B9B9B9 !important
+ background-color: $odd_bg_color !important
View
4 app/controllers/users_controller.rb
@@ -11,4 +11,8 @@ def create
render "new"
end
end
+
+ def editor
+ @friend = current_user.friends.find(params[:friend_id])
+ end
end
View
2 app/views/home/index.html.haml
@@ -4,7 +4,7 @@
%ul#friendsList
-current_user.friends.each do |friend|
%li.friend{ :class => cycle("even", "odd") }
- =link_to friend.email
+ =link_to friend.email, "/users/#{current_user.id}/editor/#{friend.id}"
%section#inviteSection
%h1 Your friend is not here?
View
2 app/views/layouts/application.html.haml
@@ -8,6 +8,6 @@
%body
%header#appHeader
Pair
- %span.blue Me
+ %span.highlite Me
= yield
View
17 app/views/users/editor.html.haml
@@ -0,0 +1,17 @@
+.container
+ #upload-status-text
+ %textarea#fileBuffer{ :class => "brush: ruby" }
+
+ #drop-box-overlay
+ #drop-box-prompt
+ Drag a file to the window to start sharing!
+
+
+ #sharingList
+ %h4 You're sharing with..
+ %ul#friendsList
+ %li.friend{ :title => "Waiting for #{@friend.email}" }
+ = @friend.email
+
+
+
View
2 config/routes.rb
@@ -6,6 +6,8 @@
post 'sessions' => 'sessions#create'
get 'sessions/destroy' => 'sessions#destroy', :as => :logout
+ match 'users/:id/editor/:friend_id' => 'users#editor', :as => :user_editor
+
# The priority is based upon order of creation:
# first created -> highest priority.
View
18 spec/requests/editor_spec.rb
@@ -0,0 +1,18 @@
+require 'spec_helper'
+
+describe "Editor" do
+ let(:eddie) { Summoner.summon(:user, :email => "ed@vedder.com", :password => "secret") }
+ let(:jeff) { Summoner.summon(:user, :email => "jeff@ament.com", :password => "not_so_secret") }
+
+ it "should invite a friend to share a file" do
+ eddie.add_friend(jeff)
+ login "ed@vedder.com", "secret"
+
+ visit root_path
+ click "jeff@ament.com"
+ current_path.should == "/users/#{eddie.id}/editor/#{jeff.id}"
+
+ page.should have_content "Waiting for jeff@ament.com"
+ page.should have_content "Drag a file to the window"
+ end
+end

No commit comments for this range

Something went wrong with that request. Please try again.