summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2014-10-16 14:31:13 -0400
committerJules Laplace <jules@okfoc.us>2014-10-16 14:31:13 -0400
commitf8a4bb4609511393c92c618962f990673328d2f0 (patch)
treee6fe5c8b2b8b30b0786af990a52a03cc24068056
parentd02bf26b1a25923197dc85dbf0dc999f29bf13d1 (diff)
cursor stuff, hit esc to exit wallpaper mode
-rw-r--r--public/assets/javascripts/rectangles/models/floor.js2
-rw-r--r--public/assets/javascripts/rectangles/models/wall.js2
-rw-r--r--public/assets/javascripts/ui/editor/ColorControl.js4
-rw-r--r--public/assets/javascripts/ui/editor/HelpCursor.js15
-rw-r--r--public/assets/javascripts/ui/editor/WallpaperPicker.js46
5 files changed, 39 insertions, 30 deletions
diff --git a/public/assets/javascripts/rectangles/models/floor.js b/public/assets/javascripts/rectangles/models/floor.js
index 9838232..a144ecd 100644
--- a/public/assets/javascripts/rectangles/models/floor.js
+++ b/public/assets/javascripts/rectangles/models/floor.js
@@ -40,7 +40,7 @@
if (Scenery.nextWallpaper) {
var oldState = base.serialize()
base.wallpaper(Scenery.nextWallpaper)
- Scenery.nextWallpaper = null
+ // Scenery.nextWallpaper = null
UndoStack.push({
type: 'update-wallpaper',
diff --git a/public/assets/javascripts/rectangles/models/wall.js b/public/assets/javascripts/rectangles/models/wall.js
index 542c99a..eb445a7 100644
--- a/public/assets/javascripts/rectangles/models/wall.js
+++ b/public/assets/javascripts/rectangles/models/wall.js
@@ -104,7 +104,7 @@
else if (Scenery.nextWallpaper) {
var oldState = base.serialize()
base.wallpaper(Scenery.nextWallpaper)
- Scenery.nextWallpaper = null
+ // Scenery.nextWallpaper = null
UndoStack.push({
type: 'update-wallpaper',
diff --git a/public/assets/javascripts/ui/editor/ColorControl.js b/public/assets/javascripts/ui/editor/ColorControl.js
index 4d8a7bb..459ac1e 100644
--- a/public/assets/javascripts/ui/editor/ColorControl.js
+++ b/public/assets/javascripts/ui/editor/ColorControl.js
@@ -73,11 +73,13 @@ var ColorControl = View.extend({
},
toggle: function(state){
+ if (state) {
+ this.parent.cursor.message("colors")
+ }
this.$el.toggleClass("active", state);
},
show: function(){
- this.parent.cursor.message("colors")
this.toggle(true)
},
diff --git a/public/assets/javascripts/ui/editor/HelpCursor.js b/public/assets/javascripts/ui/editor/HelpCursor.js
index 9b6807e..06f6ab2 100644
--- a/public/assets/javascripts/ui/editor/HelpCursor.js
+++ b/public/assets/javascripts/ui/editor/HelpCursor.js
@@ -43,9 +43,12 @@ var HelpCursor = View.extend({
document.removeEventListener("mousemove", this.moveFn)
},
+ offset: 100,
+ lastPosition: { pageX: 0, pageY: 0 },
move: function(e){
- this.el.style.left = e.pageX + "px"
+ this.el.style.right = clamp(window.innerWidth - e.pageX, this.offset, window.innerWidth) + "px"
this.el.style.top = e.pageY + "px"
+ this.lastPosition = e
},
show: function(name){
@@ -54,6 +57,16 @@ var HelpCursor = View.extend({
message: function(name){
if (! this.active) return
+ if (name == "start" || name == "media" || name == "settings") {
+ this.offset = 100
+ }
+ else if (name == "colors") {
+ this.offset = 270
+ }
+ else {
+ this.offset = 290
+ }
+ this.move(this.lastPosition)
this.$el.html(this.messages[name])
},
diff --git a/public/assets/javascripts/ui/editor/WallpaperPicker.js b/public/assets/javascripts/ui/editor/WallpaperPicker.js
index 6bcd859..afdfca7 100644
--- a/public/assets/javascripts/ui/editor/WallpaperPicker.js
+++ b/public/assets/javascripts/ui/editor/WallpaperPicker.js
@@ -28,19 +28,28 @@ var WallpaperPicker = UploadView.extend({
loaded: false,
show: function(){
- if (! this.loaded) {
- this.parent.cursor.message("wallpaper")
- this.load()
- }
- else {
- this.toggle(true)
- }
+ this.toggle(true)
},
-
hide: function(){
- this.__super__.hide.call(this)
+ this.toggle(false)
},
-
+// hide: function(){
+// this.__super__.hide.call(this)
+// },
+
+ toggle: function (state) {
+ app.tube('cancel-wallpaper')
+ this.$el.toggleClass("active", state)
+ if (state) {
+ this.parent.cursor.message("wallpaper")
+ if (! this.loaded) {
+ this.load()
+ }
+ }
+ // toggle the class that makes the cursor a paintbucket
+ // $("body").removeClass("pastePaper")
+ },
+
load: function(){
$.get("/api/media/user", { tag: this.mediaTag }, this.populate.bind(this))
},
@@ -86,21 +95,6 @@ var WallpaperPicker = UploadView.extend({
}.bind(this))
},
- toggle: function (state) {
- if (state && ! this.loaded) {
- this.show()
- }
- else {
- this.$el.toggleClass("active", state)
- }
- // toggle the class that makes the cursor a paintbucket
- // $("body").removeClass("pastePaper")
- },
-
- hide: function(){
- this.toggle(false)
- },
-
beforeUpload: function(){
},
@@ -145,7 +139,7 @@ var WallpaperPicker = UploadView.extend({
$floatingSwatch.removeClass("scissors").hide()
}
$(window).on('mousemove', _followCursor)
- $(window).one('click', _hideCursor);
+ // $(window).one('click', _hideCursor);
app.on('cancel-wallpaper', _hideCursor)
$floatingSwatch.show()
_followCursor(e);