summaryrefslogtreecommitdiff
path: root/public/assets/javascripts/ui/editor
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2014-10-02 11:07:04 -0400
committerJules Laplace <jules@okfoc.us>2014-10-02 11:07:04 -0400
commitb1556ef6f9854e08f5bb20907c57a9558005af95 (patch)
treec772649ff6b235fbaa8809ff72daf917fce3857f /public/assets/javascripts/ui/editor
parent61bb2d3bf1929201f61599ea1dd99f82e521878d (diff)
parentddac735a463278e245e566105ace3e32c723128c (diff)
merge
Diffstat (limited to 'public/assets/javascripts/ui/editor')
-rw-r--r--public/assets/javascripts/ui/editor/EditorSettings.js7
-rw-r--r--public/assets/javascripts/ui/editor/EditorToolbar.js89
-rw-r--r--public/assets/javascripts/ui/editor/EditorView.js7
-rw-r--r--public/assets/javascripts/ui/editor/MediaEditor.js35
-rw-r--r--public/assets/javascripts/ui/editor/MediaUpload.js1
-rw-r--r--public/assets/javascripts/ui/editor/MediaViewer.js89
-rw-r--r--public/assets/javascripts/ui/editor/TextEditor.js41
-rw-r--r--public/assets/javascripts/ui/editor/WallpaperPicker.js26
8 files changed, 219 insertions, 76 deletions
diff --git a/public/assets/javascripts/ui/editor/EditorSettings.js b/public/assets/javascripts/ui/editor/EditorSettings.js
index 8a88f7a..eb0d044 100644
--- a/public/assets/javascripts/ui/editor/EditorSettings.js
+++ b/public/assets/javascripts/ui/editor/EditorSettings.js
@@ -65,6 +65,10 @@ var EditorSettings = FormView.extend({
data.media && Scenery.deserialize(data.media)
}
+
+ app.on("rooms-built", function(){
+ Walls.paint()
+ })
},
showCollaborators: function(e){
@@ -109,7 +113,8 @@ var EditorSettings = FormView.extend({
toggle: function(state){
var state = typeof state == 'boolean' ? state : ! this.$el.hasClass("active")
this.$el.toggleClass("active", state)
-
+
+ $(".inuse").removeClass("inuse")
$("[data-role='toggle-project-settings']").toggleClass("inuse", state)
},
diff --git a/public/assets/javascripts/ui/editor/EditorToolbar.js b/public/assets/javascripts/ui/editor/EditorToolbar.js
index e91da0f..513306d 100644
--- a/public/assets/javascripts/ui/editor/EditorToolbar.js
+++ b/public/assets/javascripts/ui/editor/EditorToolbar.js
@@ -6,11 +6,11 @@ var EditorToolbar = View.extend({
"click [data-role='toggle-map-view']": 'toggleMap',
"click [data-role='toggle-project-settings']": 'toggleSettings',
"click [data-role='open-media-viewer']": 'openMediaViewer',
- "click [data-role='resize-media']": 'resizeMedia',
+// "click [data-role='resize-media']": 'resizeMedia',
"click [data-role='destroy-media']": 'destroyMedia',
"click [data-role='toggle-wallpaper-panel']": 'toggleWallpaper',
"click [data-role='toggle-light-control']": 'toggleLightControl',
- "click [data-role='edit-wall-text']": 'editWallText',
+ "click [data-role='toggle-text-editor']": 'toggleTextEditor',
},
initialize: function(opt){
@@ -23,8 +23,8 @@ var EditorToolbar = View.extend({
},
toggleSettings: function(){
- this.resetMode()
- $(".inuse").removeClass("inuse")
+// this.resetMode()
+ this.parent.textEditor.hide()
this.parent.lightControl.hide()
this.parent.wallpaperPicker.hide()
this.parent.mediaEditor.hide()
@@ -37,38 +37,51 @@ var EditorToolbar = View.extend({
this.resetMode()
this.resetControls()
},
-
+
resetMode: function(){
- this.resizeMedia(false)
- this.destroyMedia(false)
+ // this.resizeMedia(true)
+ // this.destroyMedia(false)
+ $(".inuse").removeClass("inuse")
+ this.parent.hideExtras()
+ this.resetPermissions()
},
resetControls: function(){
+ $(".inuse").removeClass("inuse")
+ this.parent.textEditor.hide()
this.parent.wallpaperPicker.hide()
this.parent.lightControl.hide()
+ this.parent.settings.hide()
},
- resizeMedia: function(e, state){
- this.resetControls()
- if (! state && typeof e == "boolean") {
- state = e
- editor.permissions.assign("resize", state)
- }
- else {
- state = editor.permissions.toggle("resize")
- }
- ! state && editor.permissions.assign("move", true)
- $(".inuse").removeClass("inuse")
- $("[data-role='resize-media']").toggleClass("inuse", state)
- if (state) {
- if (this.parent.mediaEditor.scenery) {
- Scenery.resize.show( this.parent.mediaEditor.scenery )
- }
- }
- else {
- Scenery.resize.hide()
- }
+ resetPermissions: function(){
+ editor.permissions.add("pick")
+ editor.permissions.add("move")
+ editor.permissions.add("resize")
+ editor.permissions.remove("destroy")
},
+
+// resizeMedia: function(e, state){
+// this.resetControls()
+// if (! state && typeof e == "boolean") {
+// state = e
+// editor.permissions.assign("resize", state)
+// }
+// else {
+// state = editor.permissions.toggle("resize")
+// }
+// ! state && editor.permissions.assign("move", true)
+// $(".inuse").removeClass("inuse")
+// $("[data-role='resize-media']").toggleClass("inuse", state)
+// if (state) {
+// if (this.parent.mediaEditor.scenery) {
+// Scenery.resize.show( this.parent.mediaEditor.scenery )
+// }
+// }
+// else {
+// Scenery.resize.hide()
+// }
+// },
destroyMedia: function(e, state){
this.resetControls()
@@ -79,7 +92,12 @@ var EditorToolbar = View.extend({
else {
state = editor.permissions.toggle("destroy")
}
- ! state && editor.permissions.assign("move", true)
+ if (! state) {
+ this.resetPermissions()
+ }
+ else {
+ app.controller.hideExtras()
+ }
$(".inuse").removeClass("inuse")
$("[data-role='destroy-media']").toggleClass("inuse", state)
$("body").toggleClass("destroyActive", state)
@@ -91,6 +109,7 @@ var EditorToolbar = View.extend({
$("[data-role='toggle-wallpaper-panel']").toggleClass("inuse", state)
this.parent.mediaEditor.hide()
this.parent.lightControl.hide()
+ this.parent.textEditor.hide()
this.parent.settings.hide()
this.parent.wallpaperPicker.toggle(state)
},
@@ -101,12 +120,20 @@ var EditorToolbar = View.extend({
$("[data-role='toggle-light-control']").toggleClass("inuse", state)
this.parent.mediaEditor.hide()
this.parent.wallpaperPicker.hide()
+ this.parent.textEditor.hide()
this.parent.settings.hide()
this.parent.lightControl.toggle(state)
},
- editWallText: function(){
- },
+ toggleTextEditor: function(){
+ var state = ! $("[data-role='toggle-text-editor']").hasClass("inuse")
+ this.resetMode()
+ $("[data-role='toggle-text-editor']").toggleClass("inuse", state)
+ this.parent.mediaEditor.hide()
+ this.parent.wallpaperPicker.hide()
+ this.parent.settings.hide()
+ this.parent.textEditor.toggle(state)
+ },
})
@@ -114,7 +141,7 @@ var editor = new function(){
this.permissions = new Permissions({
'pick': true,
'move': true,
- 'resize': false,
+ 'resize': true,
'destroy': false,
})
} \ No newline at end of file
diff --git a/public/assets/javascripts/ui/editor/EditorView.js b/public/assets/javascripts/ui/editor/EditorView.js
index e11f189..83db532 100644
--- a/public/assets/javascripts/ui/editor/EditorView.js
+++ b/public/assets/javascripts/ui/editor/EditorView.js
@@ -16,6 +16,7 @@ var EditorView = View.extend({
this.mediaEditor = new MediaEditor ({ parent: this })
this.wallpaperPicker = new WallpaperPicker ({ parent: this })
this.lightControl = new LightControl ({ parent: this })
+ this.textEditor = new TextEditor ({ parent: this })
this.collaborators = new Collaborators ({ parent: this })
},
@@ -31,7 +32,7 @@ var EditorView = View.extend({
ready: function(data){
$("#map").hide()
-
+
this.settings.load(data)
},
@@ -46,6 +47,8 @@ var EditorView = View.extend({
hideExtras: function(){
this.mediaEditor.hide()
- }
+ Scenery.resize.hide()
+ Scenery.hovering = false
+ }
})
diff --git a/public/assets/javascripts/ui/editor/MediaEditor.js b/public/assets/javascripts/ui/editor/MediaEditor.js
index 9b20a43..e4f93df 100644
--- a/public/assets/javascripts/ui/editor/MediaEditor.js
+++ b/public/assets/javascripts/ui/editor/MediaEditor.js
@@ -3,7 +3,7 @@ var MediaEditor = FormView.extend({
el: "#mediaEditor",
events: {
- "keydown": 'stopPropagation',
+ "keydown": 'taint',
"focus [name]": "clearMinotaur",
"click [data-role=play-media]": "togglePaused",
"mousedown [name=keyframe]": "stopPropagation",
@@ -58,9 +58,16 @@ var MediaEditor = FormView.extend({
this.bind(scenery)
this.$el.addClass("active")
+// app.controller.toolbar.resetMode()
+ app.controller.toolbar.resetControls()
+ Scenery.resize.show(scenery)
+ Scenery.hovering = true
+
var media = scenery.media
- this.$name.val(media.title)
+ console.log(media)
+
+ this.$name.val(media.title || filenameFromUrl(media.url) )
this.$description.val(media.description)
this.setDimensions()
this.$units.val( "ft" )
@@ -98,12 +105,14 @@ var MediaEditor = FormView.extend({
seek: function(){
var n = parseFloat( this.$keyframe.val() )
this.scenery.seek(n)
+ this.tainted = true
this.scenery.media.keyframe = n
},
setAutoplay: function(){
var checked = this.$autoplay.prop('checked')
this.scenery.media.autoplay = checked
+ this.tainted = true
if (checked && this.scenery.paused()) {
this.togglePaused()
}
@@ -111,17 +120,20 @@ var MediaEditor = FormView.extend({
setLoop: function(){
var checked = this.$loop.prop('checked')
this.scenery.setLoop(checked)
+ this.tainted = true
},
setMute: function(){
var checked = this.$mute.prop('checked')
this.scenery.media.mute = checked
this.scenery.mute(checked)
+ this.tainted = true
},
setDimensions: function(){
if (! this.scenery) return
this.$width.unitVal( Number(this.scenery.naturalDimensions.a * this.scenery.scale) || "" )
this.$height.unitVal( Number(this.scenery.naturalDimensions.b * this.scenery.scale) || "" )
+ this.tainted = true
},
changeWidth: function(e){
e.stopPropagation()
@@ -137,6 +149,11 @@ var MediaEditor = FormView.extend({
app.units = this.$units.val()
this.$('.units').resetUnitVal()
},
+
+ taint: function(e){
+ e.stopPropagation()
+ this.tainted = true
+ },
bind: function(scenery){
this.scenery = scenery
@@ -145,7 +162,7 @@ var MediaEditor = FormView.extend({
},
unbind: function(){
- if (this.scenery) {
+ if (this.scenery && this.tainted) {
this.scenery.media.title = this.$name.val()
this.scenery.media.description = this.$description.val()
Minotaur.watch( app.router.editorView.settings )
@@ -155,15 +172,17 @@ var MediaEditor = FormView.extend({
this.scenery.mx.el.classList.remove("picked")
}
}
+ this.tainted = false
this.scenery = null
},
destroy: function(){
- ConfirmModal.confirm("Are you sure you want delete to this media?", function(){
- var scenery = this.scenery
- this.hide()
- Scenery.remove(scenery.id)
- }.bind(this))
+// ConfirmModal.confirm("Are you sure you want delete this object?", function(){
+// }.bind(this))
+ var scenery = this.scenery
+ this.hide()
+ Scenery.remove(scenery.id)
+ Scenery.resize.hide()
},
})
diff --git a/public/assets/javascripts/ui/editor/MediaUpload.js b/public/assets/javascripts/ui/editor/MediaUpload.js
index 92cf2bd..971fb15 100644
--- a/public/assets/javascripts/ui/editor/MediaUpload.js
+++ b/public/assets/javascripts/ui/editor/MediaUpload.js
@@ -56,6 +56,7 @@ var MediaUpload = UploadView.extend({
add: function(media){
console.log(media)
this.parent.mediaViewer.add(media)
+ this.parent.mediaViewer.$deleteMedia.show()
},
beforeUpload: function(){
diff --git a/public/assets/javascripts/ui/editor/MediaViewer.js b/public/assets/javascripts/ui/editor/MediaViewer.js
index 436c0cb..b51d8f2 100644
--- a/public/assets/javascripts/ui/editor/MediaViewer.js
+++ b/public/assets/javascripts/ui/editor/MediaViewer.js
@@ -3,6 +3,7 @@ var MediaViewer = ModalView.extend({
el: ".mediaDrawer.mediaViewer",
destroyAction: "/api/media/destroy",
usesFileUpload: true,
+ loaded: false,
events: {
'click .foundToggle': "foundToggle",
@@ -14,30 +15,31 @@ var MediaViewer = ModalView.extend({
initialize: function(opt){
this.__super__.initialize.call(this)
this.parent = opt.parent
- this.$foundMedia = this.$(".foundMedia")
this.$myMedia = this.$(".myMedia")
- this.$foundToggle = this.$(".foundToggle")
this.$userToggle = this.$(".userToggle")
+ this.$foundMedia = this.$(".foundMedia")
+ this.$foundToggle = this.$(".foundToggle")
this.$deleteMedia = this.$("#deleteMedia")
- },
+ },
foundToggle: function(){
- this.foundMedia.addClass("active");
- this.myMedia.addClass("inactive");
+ this.$foundMedia.addClass("active");
+ this.$myMedia.addClass("inactive");
this.$("a").removeClass("active");
- this.foundToggle.addClass("active");
+ this.$foundToggle.addClass("active");
},
userToggle: function(){
- this.foundMedia.removeClass("active");
- this.myMedia.removeClass("inactive");
+ this.$foundMedia.removeClass("active");
+ this.$myMedia.removeClass("inactive");
this.$("a").removeClass("active");
- this.userToggle.addClass("active");
+ this.$userToggle.addClass("active");
},
show: function(){
if (! this.loaded) {
this.load()
+ this.loadTrending()
}
else {
this.__super__.show.call(this)
@@ -53,11 +55,55 @@ var MediaViewer = ModalView.extend({
load: function(){
$.get("/api/media/user", this.populate.bind(this))
},
+
+ loadTrending: function(){
+ var trending_imagery = [
+ 'https://d1ycxz9plii3tb.cloudfront.net/post_images/52ec0e20c9dc24f1d8000067/large.jpg',
+ 'https://d1ycxz9plii3tb.cloudfront.net/additional_images/4e6bf67bc23f490001004579/1/tall.jpg',
+ 'https://d1ycxz9plii3tb.cloudfront.net/additional_images/52dcca28139b2135030002a8/tall.jpg',
+ 'https://d1ycxz9plii3tb.cloudfront.net/additional_images/52927bb2b202a3669d000704/larger.jpg',
+ 'https://d1ycxz9plii3tb.cloudfront.net/additional_images/4f9f3a3ce262e60001000fb3/large.jpg',
+ 'http://2.bp.blogspot.com/-GD6IxUvsdOo/UdrcMFLVYNI/AAAAAAAAF2E/kbRfxMxiUlQ/s1600/okeeffe.jpg',
+ 'http://www.bobkessel.com/wordpress/wp-content/uploads/2009/10/moma-bob-kessel-410.jpg',
+ 'http://static1.artsy.net/partner_show_images/52f28f348b3b81f2fc000364/large.jpg',
+ 'http://static3.artsy.net/partner_show_images/52e83674c9dc24397f0000d8/large.jpg',
+ 'http://static0.artsy.net/partner_show_images/52d96d484b84801ef0000273/large.jpg',
+ 'http://static1.artsy.net/partner_show_images/52778616275b24f95c00011d/1/large.jpg',
+ 'http://static1.artsy.net/partner_show_images/52dc65311a1e86be6b000205/large.jpg',
+ ]
+ trending_imagery.forEach(function(url){
+ var loaded = false
+ var img = new Image ()
+ img.onload = function(){
+ if (loaded) return
+ loaded = true
+ var media = {
+ type: 'image',
+ url: url,
+ width: img.naturalWidth,
+ height: img.naturalHeight,
+ }
+ this.add(media, this.$foundMedia)
+ }.bind(this)
+ img.src = url
+ if (img.complete && ! loaded) { img.onload() }
+ }.bind(this))
+ },
+
+ randomize: function(){
+ var media_data = $(".mediaContainer").toArray().map(function(el){
+ return $(el).data("media")
+ })
+ Scenery.randomize( media_data )
+ },
populate: function(data){
this.loaded = true
if (data && data.length) {
- data.forEach(this.add.bind(this))
+ data.forEach(function(media){
+ this.add(media, this.$myMedia)
+ }.bind(this))
+ this.$deleteMedia.show()
}
else {
this.$deleteMedia.hide()
@@ -65,7 +111,7 @@ var MediaViewer = ModalView.extend({
this.__super__.show.call(this)
},
- add: function(media){
+ add: function(media, $container){
var image = new Image ()
var $span = $("<span>")
$span.addClass("mediaContainer")
@@ -92,8 +138,7 @@ var MediaViewer = ModalView.extend({
$span.data("media", media)
$span.append(image)
- this.$(".myMedia").prepend($span)
- this.$deleteMedia.show()
+ $container.prepend($span)
},
deleteIsArmed: false,
@@ -136,19 +181,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 +188,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 +215,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/TextEditor.js b/public/assets/javascripts/ui/editor/TextEditor.js
new file mode 100644
index 0000000..0319a31
--- /dev/null
+++ b/public/assets/javascripts/ui/editor/TextEditor.js
@@ -0,0 +1,41 @@
+
+var TextEditor = FormView.extend({
+ el: "#textEditor",
+
+ events: {
+ "keydown": 'taint',
+ "focus [name]": "clearMinotaur",
+ "mousedown": "stopPropagation",
+ "change [name=font-family]": 'changeFontFamily',
+ "change [name=font-size]": 'changeFontSize',
+ "input [name=text-body]": 'changeText',
+ "click [data-role=destroy-media]": "destroy",
+ },
+
+ initialize: function(opt){
+ this.parent = opt.parent
+ this.__super__.initialize.call(this)
+
+ this.$fontFamily = this.$("[name=font-family]")
+ this.$fontSize = this.$("[name=font-size]")
+ this.$textBody = this.$("[name=text-body]")
+ },
+
+ toggle: function(state){
+ this.$el.toggleClass("active", state);
+ },
+
+ taint: function(e){
+ e.stopPropagation()
+ },
+
+ changeFontFamily: function(){
+ },
+
+ changeFontSize: function(){
+ },
+
+ changeText: function(){
+ },
+
+})
diff --git a/public/assets/javascripts/ui/editor/WallpaperPicker.js b/public/assets/javascripts/ui/editor/WallpaperPicker.js
index 0dd2921..7f9b8f7 100644
--- a/public/assets/javascripts/ui/editor/WallpaperPicker.js
+++ b/public/assets/javascripts/ui/editor/WallpaperPicker.js
@@ -39,6 +39,10 @@ var WallpaperPicker = UploadView.extend({
this.loaded = true
if (data && data.length) {
data.forEach(this.add.bind(this))
+ this.$(".txt").hide()
+ }
+ else {
+ this.$(".txt").show()
}
this.toggle(true)
},
@@ -50,6 +54,7 @@ var WallpaperPicker = UploadView.extend({
swatch.style.backgroundImage = "url(" + media.url + ")"
this.$swatches.append(swatch)
this.$swatches.show()
+ this.$(".txt").hide()
},
toggle: function (state) {
@@ -71,14 +76,21 @@ var WallpaperPicker = UploadView.extend({
},
pick: function(e){
+ app.tube('cancel-wallpaper')
var $swatch = $(e.currentTarget)
this.follow( e, $swatch.css('background-image') )
this.$remove.show()
},
remove: function(e){
- this.follow( e, "none" )
- $(".floatingSwatch").addClass("scissors")
+ if (Scenery.nextWallpaper) {
+ Scenery.nextWallpaper = null
+ app.tube('cancel-wallpaper')
+ }
+ else {
+ this.follow( e, "none" )
+ $(".floatingSwatch").addClass("scissors")
+ }
},
follow: function(e, wallpaper, icon){
@@ -97,11 +109,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);
})