summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--public/assets/javascripts/app.js2
-rw-r--r--public/assets/javascripts/mx/extensions/mx.movementsMobile.js203
-rw-r--r--public/assets/javascripts/ui/editor/EditorSettings.js2
-rw-r--r--public/assets/javascripts/ui/editor/WallpaperPicker.js4
-rw-r--r--public/assets/javascripts/ui/reader/ReaderView.js2
-rw-r--r--server/lib/views/staff.js8
-rw-r--r--views/controls/editor/media-drawer.ejs24
-rw-r--r--views/staff/_gallery.ejs38
-rw-r--r--views/staff/users/media.ejs4
9 files changed, 218 insertions, 69 deletions
diff --git a/public/assets/javascripts/app.js b/public/assets/javascripts/app.js
index cfbe4bf..9b46a3e 100644
--- a/public/assets/javascripts/app.js
+++ b/public/assets/javascripts/app.js
@@ -68,8 +68,6 @@ app.launch = function () {
scene.update()
}
- window.inAnimation = true
-
var loader = new Loader(function(){
$("#loader").hide()
window.environment && window.environment.init()
diff --git a/public/assets/javascripts/mx/extensions/mx.movementsMobile.js b/public/assets/javascripts/mx/extensions/mx.movementsMobile.js
index 994c8d7..8810649 100644
--- a/public/assets/javascripts/mx/extensions/mx.movementsMobile.js
+++ b/public/assets/javascripts/mx/extensions/mx.movementsMobile.js
@@ -14,56 +14,169 @@ MX.MobileMovements = function (cam) {
var pos = { x: 0, y: viewHeight, z: 0, rotationX: 0, rotationY: 0 }
var pointX, pointY, deltaX, deltaY, distX = 0, distY = 0, absDistX = 0, absDistY = 0, startTime
-
- return {
+
+ var rotationX = 0, rotationY = 0, destRotationX = 0, destRotationY = 0
+ var rotationSum = 0
+ var rotationMedian = 0
+ var orientationMax = 0
+ var samples = 0
+ var sampleThreshold = 120
+ var lastAlpha
+
+ var is_portrait
+
+ var exports = {
init: function () {
- document.addEventListener("touchstart", function(e){
- if (e.touches.length == 1) {
- touching = true
-
- startTime = Date.now()
-
- var point = event.touches[0]
- pointX = point.pageX
- pointY = point.pageY
- distX = distY = 0
- pos.x = cam.x
- pos.z = cam.z
- pos.rotationY = cam.rotationY
- }
- })
- document.addEventListener("touchmove", function(e){
- e.preventDefault()
- if (e.touches.length == 1) {
+ exports.orientationchange()
+
+ document.addEventListener("touchstart", exports.touchstart)
+ document.addEventListener("touchmove", exports.touchmove)
+ document.addEventListener("touchend", exports.touchend)
+ window.addEventListener('orientationchange', exports.orientationchange)
+ window.addEventListener("devicemotion", exports.devicemotion)
+ window.addEventListener("deviceorientation", exports.deviceorientation)
+ },
+ touchstart: function(e){
+ if (e.touches.length == 1) {
+ touching = true
+
+ startTime = Date.now()
+
+ var point = event.touches[0]
+ pointX = point.pageX
+ pointY = point.pageY
+ distX = distY = 0
+ pos.x = cam.x
+ pos.z = cam.z
+ pos.rotationY = cam.rotationY
+ }
+ },
+ touchmove: function(e){
+ e.preventDefault()
+ if (e.touches.length == 1) {
+
+ var timestamp = Date.now()
+ var point = event.touches[0]
+ deltaX = point.pageX - pointX
+ deltaY = point.pageY - pointY
+
+ pointX = point.pageX
+ pointY = point.pageY
+
+ distX += deltaX
+ distY += deltaY
+ absDistX = abs(distX)
+ absDistY = abs(distY)
+ }
+ },
+ touchend: function(e){
+ e.preventDefault()
+ if (e.touches.length == 0) {
+ touching = directionLocked = false
+ var timestamp = Date.now()
+ var duration = startTime - timestamp
+ if (duration < 300) {
+ }
+ }
+ },
+ orientationchange: function(e){
+ is_portrait = window.innerWidth < window.innerHeight
+ if (is_portrait) {
+ lastAlpha = 0
+ }
+ },
+ devicemotion: function(e) {
+ if (! is_portrait) return;
+ var rotationBeta = e.rotationRate.alpha; // weird!
+ rotationSum += rotationBeta;
+ samples += 1;
+ },
+ deviceorientation: function (e) {
+ if (! lastAlpha) { lastAlpha = e.alpha }
+ is_portrait ? exports.portraitorientation(e) : exports.landscapeorientation(e)
+ },
+ portraitorientation: function(e) {
+ // compass gives most accurate orientation in portrait mode
+ var alpha, dx = 0, dy = 0
+
+ if (e.webkitCompassHeading) {
+ alpha = 180 - e.webkitCompassHeading;
+ }
+ else {
+ alpha = 180 - e.alpha;
+ }
+
+ // android rotates in reverse
+ if (is_android) {
+ alpha = 360 - alpha
+ }
+
+ // use rotationRate to gauge if we've tilted the screen past vertical
+ // for looking at ceiling
+ if (e.beta > orientationMax) {
+ orientationMax = e.beta
+ rotationMedian = rotationSum
+ }
+
+ // this number was only going to 83 max.. not 90.. weird
+ var beta = e.beta + 7;
+
+ // if we've got enough motion data, we should be able to determine
+ // if we've tilted backwards. otherwise, lock to the horizon.
+ if (! is_android && samples > sampleThreshold) {
+ dx = rotationSum > rotationMedian ? e.beta - 90 : 90 - e.beta
+ }
+ else {
+ dx = 0
+ }
+
+ // avoid jumping around in a circle
+ if (Math.abs(alpha - lastAlpha) < 100 || Math.abs(alpha - lastAlpha) > 300) {
+ dy = alpha - lastAlpha
+ lastAlpha = alpha
+ }
+
+ // avoid jumping around in a circle #2
+ if (dy > 300) {
+ dy -= 360
+ } else if (dy < -300) {
+ dy += 360
+ }
+
+ destRotationX = MX.toRad(dx)
+ destRotationY += MX.toRad(dy)
+ },
+
+ landscapeorientation: function (e) {
+ var dx, dy
+
+ dx = e.gamma > 0 ? 90 - e.gamma : 90 + e.gamma
+ dy = e.alpha - lastAlpha
+ lastAlpha = e.alpha
- var timestamp = Date.now()
- var point = event.touches[0]
- deltaX = point.pageX - pointX
- deltaY = point.pageY - pointY
-
- pointX = point.pageX
- pointY = point.pageY
+ // avoid the sudden jump from 0 to -360
+ if (dy > 300) {
+ dy -= 360
+ }
+ else if (dy < -300) {
+ dy += 360
+ }
- distX += deltaX
- distY += deltaY
- absDistX = abs(distX)
- absDistY = abs(distY)
- }
- })
- document.addEventListener("touchend", function(e){
- e.preventDefault()
- if (e.touches.length == 0) {
- touching = directionLocked = false
- var timestamp = Date.now()
- var duration = startTime - timestamp
- if (duration < 300) {
- }
- }
- })
+ destRotationX = MX.toRad(dx)
+ destRotationY += MX.toRad(dy)
},
update: function () {
+ var drx, dry
+
+ dry = (destRotationY - rotationY) / 6
+ drx = (destRotationX - rotationX) / 6
+ rotationY += dry
+ rotationX += drx
+ cam.rotationY = pos.rotationY += dry
+ cam.rotationX = pos.rotationX += drx
+
if (distX || distY) {
var oldDistY = absDistY, oldDistX = absDistX
absDistY = avg(absDistY, 0, 5)
@@ -77,8 +190,7 @@ MX.MobileMovements = function (cam) {
pos.x -= dy * Math.cos(pos.rotationY + Math.PI / 2)
pos.z -= dy * Math.sin(pos.rotationY + Math.PI / 2)
- pos.rotationY += dx / (window.innerWidth) * Math.PI / 2
- cam.rotationY = pos.rotationY
+ cam.rotationY = pos.rotationY += dx / (window.innerWidth) * Math.PI / 2
app.tube("move", pos)
}
@@ -93,6 +205,7 @@ MX.MobileMovements = function (cam) {
jumpVelocity: function(n){ jumpV = clamp(n, 1, 50) },
}
+ return exports
}
diff --git a/public/assets/javascripts/ui/editor/EditorSettings.js b/public/assets/javascripts/ui/editor/EditorSettings.js
index 240f713..430acc7 100644
--- a/public/assets/javascripts/ui/editor/EditorSettings.js
+++ b/public/assets/javascripts/ui/editor/EditorSettings.js
@@ -62,7 +62,7 @@ var EditorSettings = FormView.extend({
}
if (data.isNew) {
- this.$name.val( "Untitled Room" )
+ this.$name.val( "Untitled" )
}
else {
this.thumbnailIsStale()
diff --git a/public/assets/javascripts/ui/editor/WallpaperPicker.js b/public/assets/javascripts/ui/editor/WallpaperPicker.js
index 994fe74..6e0d5c6 100644
--- a/public/assets/javascripts/ui/editor/WallpaperPicker.js
+++ b/public/assets/javascripts/ui/editor/WallpaperPicker.js
@@ -40,9 +40,6 @@ var WallpaperPicker = UploadView.extend({
hide: function(){
this.toggle(false)
},
-// hide: function(){
-// this.__super__.hide.call(this)
-// },
toggle: function (state) {
Scenery.nextWallpaper = null
@@ -158,6 +155,7 @@ var WallpaperPicker = UploadView.extend({
pickWall: function(wall){
if (! wall.background || wall.background.src == "none") {
this.$wallpaperResizeControls.addClass('disabled')
+ this.$scale.val( 0.0 )
return;
}
this.$wallpaperResizeControls.removeClass('disabled')
diff --git a/public/assets/javascripts/ui/reader/ReaderView.js b/public/assets/javascripts/ui/reader/ReaderView.js
index 5f2db0f..8531244 100644
--- a/public/assets/javascripts/ui/reader/ReaderView.js
+++ b/public/assets/javascripts/ui/reader/ReaderView.js
@@ -33,6 +33,8 @@ var ReaderView = View.extend({
data.media && Scenery.deserialize(data.media)
data.startPosition && scene.camera.move(data.startPosition)
+ cam.y = window.viewHeight = data.viewHeight || app.defaults.viewHeight
+
var colors = data.colors || app.defaults.colors
var modes = [ "wall", "outline", "floor", "ceiling" ]
modes.forEach(function(mode){
diff --git a/server/lib/views/staff.js b/server/lib/views/staff.js
index da09d83..49f492b 100644
--- a/server/lib/views/staff.js
+++ b/server/lib/views/staff.js
@@ -73,11 +73,11 @@ var staff = module.exports = {
paginationInfo.sort = req.query.sort
paginationInfo.sortOptions = ["date", "name"]
switch (req.query.sort) {
+ default:
case 'date':
- sort = {'created_at': -1}
+ sort = {'updated_at': -1}
break
case 'name':
- default:
paginationInfo.sort = "name"
sort = {'slug': 1}
break
@@ -288,14 +288,14 @@ var staff = module.exports = {
project: function(project){
project = project.toObject()
- project.date = moment( project.updated_at || project.created_at ).format("M/DD/YYYY H:MM")
+ project.date = moment( project.updated_at || project.created_at ).format("M/DD/YYYY hh:mm a")
project.user = {}
return project
},
media: function(media){
media = media.toObject()
- media.date = moment( media.updated_at || media.created_at ).format("M/DD/YYYY H:MM")
+ media.date = moment( media.updated_at || media.created_at ).format("M/DD/YYYY hh:mm a")
media.user = {}
media.shortUrl = media.url.replace(/^http.:\/\//,"")
return media
diff --git a/views/controls/editor/media-drawer.ejs b/views/controls/editor/media-drawer.ejs
index 1404d86..3e64cc3 100644
--- a/views/controls/editor/media-drawer.ejs
+++ b/views/controls/editor/media-drawer.ejs
@@ -21,17 +21,6 @@
<a href="#" class="viewMore btn">view more</a>
</div>
- <span class="fileUpload">
- <input type="hidden" name="_csrf" value="[[- token ]]">
- <form>
- <span class="ion-ios7-upload-outline upload-icon"></span><br>
- Upload File
- <input type="file" accept="image/*" multiple>
- </form>
- <small>~ or ~</small><br>
- <input type="text" placeholder="Enter Vimeo or YouTube or image link" class="url">
- </span>
-
<div class="foundMedia">
<span class="container"></span>
</div>
@@ -40,4 +29,15 @@
<span class="container"></span>
</div>
-</div> \ No newline at end of file
+</div>
+
+<span class="fileUpload">
+ <input type="hidden" name="_csrf" value="[[- token ]]">
+ <form>
+ <span class="ion-ios7-upload-outline upload-icon"></span><br>
+ Upload File
+ <input type="file" accept="image/*" multiple>
+ </form>
+ <small>~ or ~</small><br>
+ <input type="text" placeholder="Enter Vimeo or YouTube or image link" class="url">
+</span>
diff --git a/views/staff/_gallery.ejs b/views/staff/_gallery.ejs
new file mode 100644
index 0000000..d5948e3
--- /dev/null
+++ b/views/staff/_gallery.ejs
@@ -0,0 +1,38 @@
+[[ media.forEach(function(media){ ]]
+ <div class="media">
+ [[ if (media.type == "image") { ]]
+ <a class="medialink" href="[[- media.url ]]" target="_blank"><img src="[[- media.url ]]"></a>
+ [[ } else { ]]
+ <a class="medialink" href="[[- media.url ]]" target="_blank">[[- media.shortUrl ]]</a>
+ [[ } ]]
+ <br>
+ <a href="/staff/media/[[- media._id ]]">[view]</a>
+ <a href="/staff/users/[[- media.user.username ]]">[[- media.user.username ]]</a>
+ [[- media.date ]]
+ </div>
+[[ }) ]]
+</table>
+
+<style>
+.media {
+ height: 28vw;
+ width: 24vw;
+ margin: 1vw;
+ display: inline-block;
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
+}
+.staff .body a.medialink {
+ width: 24vw;
+ height: 24vw;
+ display: block;
+ overflow: hidden;
+ color: #00f;
+ border: 0;
+ text-decoration: underline;
+}
+.staff .body a.medialink img {
+ max-width: 100%;
+}
+</style> \ No newline at end of file
diff --git a/views/staff/users/media.ejs b/views/staff/users/media.ejs
index b13e5fb..c1097dd 100644
--- a/views/staff/users/media.ejs
+++ b/views/staff/users/media.ejs
@@ -1,6 +1,6 @@
[[ include ../_header ]]
- <h1>Users</h1>
+ <h1>User Media: [[- profile.username ]]</h1>
<nav>
<a href="/staff">home</a>
@@ -12,7 +12,7 @@
<hr>
[[ include ../_pagination ]]
-[[ include ../_media ]]
+[[ include ../_gallery ]]
[[ include ../_pagination ]]
[[ include ../_footer ]]