summaryrefslogtreecommitdiff
path: root/public/assets/javascripts/ui
diff options
context:
space:
mode:
Diffstat (limited to 'public/assets/javascripts/ui')
-rw-r--r--public/assets/javascripts/ui/editor/MediaEditor.js1
-rw-r--r--public/assets/javascripts/ui/editor/MediaViewer.js18
-rw-r--r--public/assets/javascripts/ui/editor/WallpaperPicker.js10
-rw-r--r--public/assets/javascripts/ui/reader/ReaderView.js5
-rw-r--r--public/assets/javascripts/ui/reader/Tracker.js123
5 files changed, 138 insertions, 19 deletions
diff --git a/public/assets/javascripts/ui/editor/MediaEditor.js b/public/assets/javascripts/ui/editor/MediaEditor.js
index eaa3134..59fdc70 100644
--- a/public/assets/javascripts/ui/editor/MediaEditor.js
+++ b/public/assets/javascripts/ui/editor/MediaEditor.js
@@ -181,6 +181,7 @@ var MediaEditor = FormView.extend({
var scenery = this.scenery
this.hide()
Scenery.remove(scenery.id)
+ Scenery.resize.hide()
}.bind(this))
},
diff --git a/public/assets/javascripts/ui/editor/MediaViewer.js b/public/assets/javascripts/ui/editor/MediaViewer.js
index 15245cf..0ac6755 100644
--- a/public/assets/javascripts/ui/editor/MediaViewer.js
+++ b/public/assets/javascripts/ui/editor/MediaViewer.js
@@ -136,19 +136,6 @@ var MediaViewer = ModalView.extend({
return
}
-// else {
-// this.picked = {}
-// this.picked.media = media
-// this.picked.image = image
-// }
-// },
-//
-// drag: function(e){
-// if (! this.pickedMedia) return
-// var media = this.picked.media
-// var image = this.picked.image
-// this.picked = null
-
this.hide()
var $ants = $('.ants');
@@ -156,8 +143,6 @@ var MediaViewer = ModalView.extend({
Scenery.nextMedia = media
-// console.log(media.type)
-
switch (media.type) {
case "video":
$floatingImg.attr('src', '/assets/img/playbutton.png')
@@ -185,12 +170,13 @@ var MediaViewer = ModalView.extend({
$floatingImg.attr('src', '')
$(window).off('mousemove', _followCursor)
$(window).off('mousedown', _hideCursor)
+ app.off('cancel-scenery', _hideCursor)
$floatingImg.parent().removeClass('edit')
}
$(window).on('mousemove', _followCursor)
$(window).on('mousedown', _hideCursor)
+ app.on('cancel-scenery', _hideCursor)
$ants.addClass('edit')
_followCursor(e)
},
-
})
diff --git a/public/assets/javascripts/ui/editor/WallpaperPicker.js b/public/assets/javascripts/ui/editor/WallpaperPicker.js
index 0dd2921..3756e88 100644
--- a/public/assets/javascripts/ui/editor/WallpaperPicker.js
+++ b/public/assets/javascripts/ui/editor/WallpaperPicker.js
@@ -97,11 +97,15 @@ var WallpaperPicker = UploadView.extend({
left: (e.pageX + 10) + 'px',
});
}
- $(window).on('mousemove', _followCursor)
- $(window).one('click', function () {
+ function _hideCursor (e) {
$(window).off('mousemove', _followCursor)
+ $(window).off('click', _hideCursor)
+ app.off('cancel-wallpaper', _hideCursor)
$floatingSwatch.removeClass("scissors").hide()
- });
+ }
+ $(window).on('mousemove', _followCursor)
+ $(window).one('click', _hideCursor);
+ app.on('cancel-wallpaper', _hideCursor)
$floatingSwatch.show()
_followCursor(e);
})
diff --git a/public/assets/javascripts/ui/reader/ReaderView.js b/public/assets/javascripts/ui/reader/ReaderView.js
index d80f225..82db048 100644
--- a/public/assets/javascripts/ui/reader/ReaderView.js
+++ b/public/assets/javascripts/ui/reader/ReaderView.js
@@ -15,6 +15,9 @@ var ReaderView = View.extend({
if (window.location.search.indexOf("noui") !== -1) {
$(".logo,.topLinks,#editorView").hide()
}
+ else {
+ this.tracker = new Tracker ()
+ }
if (window.location.search.indexOf("mute") !== -1) {
app.muted = true
}
@@ -72,10 +75,12 @@ var ReaderView = View.extend({
pick: function(scenery){
this.mediaPlayer.pick(scenery)
+ app.tube("pick-scenery", { scenery: scenery })
},
hideExtras: function(){
this.mediaPlayer.hide()
+ app.tube("close-scenery")
}
})
diff --git a/public/assets/javascripts/ui/reader/Tracker.js b/public/assets/javascripts/ui/reader/Tracker.js
new file mode 100644
index 0000000..beef071
--- /dev/null
+++ b/public/assets/javascripts/ui/reader/Tracker.js
@@ -0,0 +1,123 @@
+var Tracker = Fiber.extend(function(base){
+
+ var exports = {
+ init: function(opt){
+ this.wall_id = null
+ this.scenery_id = null
+ this.clicks = 0
+
+ this.wallTimer = new Timer ()
+ this.roomTimer = new Timer ()
+ this.sceneryTimer = new Timer ()
+
+ this.events = []
+
+ this.bind()
+ this.trackPageview()
+ },
+
+ bind: function () {
+ window.addEventListener("click", this.trackClick.bind(this), true)
+ app.on("change-wall", this.changeWall.bind(this))
+ app.on("pick-scenery", this.pickScenery.bind(this))
+ app.on("close-scenery", this.trackScenery.bind(this))
+ app.on("change-room", this.changeRoom.bind(this))
+ },
+
+ pushEvent: function(event){
+ this.events.push(event)
+ },
+
+ trackPageview: function(opt){
+ this.pushEvent([ "view" ])
+ },
+
+ //
+ // how long they spend in front of each wall
+
+ changeWall: function(opt){
+ var duration = this.wallTimer.currentTime()
+ if (this.wall_id && duration > 5000) {
+ this.pushEvent([ "wall", this.wall_id, duration ])
+ }
+ this.wall_id = opt.wall.id
+ this.wallTimer.start()
+ },
+
+ //
+ // how long the user spends on each item they click
+
+ pickScenery: function(opt){
+ if (this.scenery_id && opt.scenery.id !== this.scenery_id) {
+ this.trackScenery()
+ }
+ else {
+ this.sceneryTimer.start()
+ }
+ this.scenery_id = opt.scenery.id
+ },
+
+ trackScenery: function(){
+ var duration = this.sceneryTimer.currentTime()
+ if (this.scenery_id && duration > 5000) {
+ this.pushEvent([ "scenery", this.scenery_id, duration ])
+ }
+ this.scenery_id = null
+ this.sceneryTimer.reset()
+ },
+
+ //
+ // how long they spend in the room
+
+ changeRoom: function(opt){
+ var duration = this.roomTimer.currentTime()
+ if (this.room_id !== opt.room.id) {
+ if (this.room_id && duration > 5000) {
+ this.pushEvent([ "room", this.room_id, duration ])
+ }
+ this.roomTimer.start()
+ this.room_id = opt.room.id
+ }
+ },
+
+ //
+ // how many clicks per room
+
+ trackClick: function(opt){
+ this.clicks += 1
+ },
+
+ save: function () {
+ // possibly just push to google analytics
+ },
+
+ }
+
+ return exports
+})
+
+
+var Timer = Fiber.extend(function(base){
+ var exports = {
+
+ init: function(opt){
+ this.time = 0
+ },
+
+ reset: function(){
+ this.time = 0
+ },
+
+ start: function(){
+ this.time = Date.now()
+ },
+
+ currentTime: function(){
+ return this.time ? Date.now() - this.time : 0
+ },
+ }
+
+ return exports
+})
+
+