From 92cbcae9c35a97b04e80b08672e48b3c014198f3 Mon Sep 17 00:00:00 2001 From: danielgrippi Date: Wed, 23 May 2012 12:16:35 -0700 Subject: [PATCH] DG MS; moved framer controls into a subview & off to the side --- app/assets/javascripts/app/pages/framer.js | 66 ++++++++++++------- .../stylesheets/new_styles/_composer.scss | 65 +++++++++--------- .../templates/composer-controls.jst.hbs | 6 +- app/assets/templates/flow.jst.hbs | 8 +-- app/assets/templates/framer-content.jst.hbs | 8 +++ app/assets/templates/framer-controls.jst.hbs | 20 ++---- app/assets/templates/post-form.jst.hbs | 18 +++-- spec/javascripts/app/pages/framer_spec.js | 4 -- 8 files changed, 99 insertions(+), 96 deletions(-) create mode 100644 app/assets/templates/framer-content.jst.hbs diff --git a/app/assets/javascripts/app/pages/framer.js b/app/assets/javascripts/app/pages/framer.js index f50ef5676..e22cbda6b 100644 --- a/app/assets/javascripts/app/pages/framer.js +++ b/app/assets/javascripts/app/pages/framer.js @@ -4,7 +4,7 @@ app.pages.Framer = app.views.Base.extend({ id : "post-content", subviews : { - ".flow-content" : "postView", + ".flow-content" : "framerContent", ".flow-controls .controls" : "framerControls" }, @@ -13,9 +13,9 @@ app.pages.Framer = app.views.Base.extend({ if(!this.model.get("frame_name")) this.model.setFrameName() this.model.authorIsCurrentUser = function(){ return true } - this.model.bind("change:frame_name", this.render, this) this.model.bind("sync", this.navigateNext, this) + this.framerContent = new app.views.framerContent({model : this.model}) this.framerControls = new app.views.framerControls({model : this.model}) }, @@ -23,10 +23,6 @@ app.pages.Framer = app.views.Base.extend({ this.model.off() }, - postView : function(){ - return new app.views.Post.SmallFrame({model : this.model}) - }, - navigateNext : function(){ if(parent.location.pathname == '/new_bookmarklet') { this.bookmarkletNavigation() @@ -45,6 +41,45 @@ app.pages.Framer = app.views.Base.extend({ } }); +app.views.framerContent = app.views.Base.extend({ + templateName : "framer-content", + + events : { + "change input" : "setFormAttrs" + }, + + subviews : { + ".preview" : "smallFrameView", + ".template-picker" : 'templatePicker' + }, + + formAttrs : { + "input.mood:checked" : "frame_name" + }, + + initialize : function(){ + this.model.bind("change:frame_name", this.render, this) + }, + + smallFrameView : function() { + return new app.views.Post.SmallFrame({model : this.model}) + }, + + presenter : function() { + var selectedFrame = this.model.get("frame_name") + , templates = app.models.Post.frameMoods; + + return _.extend(this.defaultPresenter(), { + templates : _.map(templates, function(template) { + return { + name : template, + checked : selectedFrame === template + } + }) + }) + } +}); + app.views.framerControls = app.views.Base.extend({ templateName : 'framer-controls', @@ -55,13 +90,11 @@ app.views.framerControls = app.views.Base.extend({ }, subviews:{ - ".template-picker":'templatePicker', - ".aspect-selector":"aspectsDropdown", - ".service-selector":"servicesSelector" + ".aspect-selector" : "aspectsDropdown", + ".service-selector" : "servicesSelector" }, formAttrs : { - "input.mood:checked" : "frame_name", "input.aspect_ids" : "aspect_ids[]", "input.services" : "services[]" }, @@ -71,19 +104,6 @@ app.views.framerControls = app.views.Base.extend({ this.servicesSelector = new app.views.ServicesSelector({model:this.model}); }, - presenter : function() { - var selectedFrame = this.model.get("frame_name") - , templates = app.models.Post.frameMoods //subtract re-implemented templates - return _.extend(this.defaultPresenter(), { - templates :_.map(templates, function(template) { - return { - name : template, - checked : selectedFrame === template - } - }) - }) - }, - saveFrame : function(){ this.$('button').prop('disabled', 'disabled').addClass('disabled') this.setFormAttrs() diff --git a/app/assets/stylesheets/new_styles/_composer.scss b/app/assets/stylesheets/new_styles/_composer.scss index 811414c71..85f6e4ff3 100644 --- a/app/assets/stylesheets/new_styles/_composer.scss +++ b/app/assets/stylesheets/new_styles/_composer.scss @@ -43,6 +43,36 @@ padding : 10px; } + .template-picker { + margin-bottom : 1em; + + input { + display : none; + } + + label { + @include transition(background-color); + @include border-radius(); + + cursor : pointer; + + margin-right: 11px; + padding: 7px; + color: #999; + font-size: 14px; + line-height: 2em; + + &:hover { + background-color: #222; + text-decoration: none; + } + } + + input:checked + label { + background-color: #222; + } + } + .flow-controls { padding: 20px 0; max-height: 68px; @@ -84,45 +114,12 @@ } .service-selector { - margin-left: 100px; display : inline-block; } .dropdown-menu { text-align: left; } - - .template-picker { - margin-bottom : 1em; - - input { - display : none; - } - - label { - @include transition(background-color); - @include border-radius(); - - cursor : pointer; - - display: inline; - margin-right: 11px; - padding: 7px; - color: #999; - font-size: 14px; - line-height: 2em; - - &:hover { - background-color: #222; - text-decoration: none; - } - } - - input:checked + label { - background-color: #222; - } - } - } // this is about the service toggle icons, there is a jasmine test that tests this in service_selector spec @@ -171,7 +168,7 @@ input[type="image"] { } } -#controls-wrapper { +.flow-controls { text-align : center; } diff --git a/app/assets/templates/composer-controls.jst.hbs b/app/assets/templates/composer-controls.jst.hbs index 52c1ed9b0..0abe0249b 100644 --- a/app/assets/templates/composer-controls.jst.hbs +++ b/app/assets/templates/composer-controls.jst.hbs @@ -1,4 +1,2 @@ -
- - -
\ No newline at end of file + + diff --git a/app/assets/templates/flow.jst.hbs b/app/assets/templates/flow.jst.hbs index 8bddd2d17..1535ce062 100644 --- a/app/assets/templates/flow.jst.hbs +++ b/app/assets/templates/flow.jst.hbs @@ -1,15 +1,13 @@
-
+
-
-
-
-
+
+
diff --git a/app/assets/templates/framer-content.jst.hbs b/app/assets/templates/framer-content.jst.hbs new file mode 100644 index 000000000..448dca397 --- /dev/null +++ b/app/assets/templates/framer-content.jst.hbs @@ -0,0 +1,8 @@ +
+ +
+ {{#each templates}} + + + {{/each}} +
diff --git a/app/assets/templates/framer-controls.jst.hbs b/app/assets/templates/framer-controls.jst.hbs index 5d7f01ecd..f6981b496 100644 --- a/app/assets/templates/framer-controls.jst.hbs +++ b/app/assets/templates/framer-controls.jst.hbs @@ -1,16 +1,4 @@ -
-
- {{#each templates}} - - - {{/each}} -
- -
-
-
- -
- - -
\ No newline at end of file + +
+
+ diff --git a/app/assets/templates/post-form.jst.hbs b/app/assets/templates/post-form.jst.hbs index 47852d522..bad094e72 100644 --- a/app/assets/templates/post-form.jst.hbs +++ b/app/assets/templates/post-form.jst.hbs @@ -1,14 +1,12 @@ -

+

Make something!

-
+
-
-
-
- - +