summaryrefslogtreecommitdiff
path: root/public/assets/javascripts/ui/editor/HelpCursor.js
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2014-10-15 12:04:00 -0400
committerJules Laplace <jules@okfoc.us>2014-10-15 12:04:00 -0400
commitd50fa94e9b758270b15dfeb5100063c6d876d64c (patch)
tree9896fd92b6ffcd77cd4e6d17885d1cb755742051 /public/assets/javascripts/ui/editor/HelpCursor.js
parent72ea86e603793ac17a9113ab031d31b369f74a4f (diff)
cursor that follows mouse
Diffstat (limited to 'public/assets/javascripts/ui/editor/HelpCursor.js')
-rw-r--r--public/assets/javascripts/ui/editor/HelpCursor.js38
1 files changed, 38 insertions, 0 deletions
diff --git a/public/assets/javascripts/ui/editor/HelpCursor.js b/public/assets/javascripts/ui/editor/HelpCursor.js
new file mode 100644
index 0000000..842e871
--- /dev/null
+++ b/public/assets/javascripts/ui/editor/HelpCursor.js
@@ -0,0 +1,38 @@
+
+var HelpCursor = View.extend({
+ el: "#helpCursor",
+
+ messages: {
+ start: "Welcome to Vvalls!",
+ move: "Use the up and down keys to move around. Use left and right to pivot. WASD works too.",
+ },
+ shown: {},
+
+ initialize: function(){
+ $(window).mousemove(function(e){
+ this.el.style.left = e.pageX + "px"
+ this.el.style.top = e.pageY + "px"
+ }.bind(this))
+ this.show("start")
+ },
+
+ show: function(name){
+ if (name) this.showMessage(name)
+ this.$el.show()
+ },
+
+ hide: function(){
+ this.$el.hide()
+ },
+
+ showMessage: function(name){
+ if (+(this.shown[name] || 0) < 2) {
+ this.$el.html(this.messages[name])
+ this.shown[name] = (+this.shown[name] || 0) + 1
+ }
+ else {
+ this.$el.html("")
+ }
+ },
+
+})