Trigger getting started with backbone

This commit is contained in:
Benjamin Neff 2016-09-19 00:12:38 +02:00 committed by Steffen van Bergerem
parent 14304f3620
commit b8c76a3317
No known key found for this signature in database
GPG key ID: 315C9787D548DC6B
9 changed files with 13 additions and 19 deletions

View file

@ -18,7 +18,6 @@ app.views.PublisherGettingStarted = Backbone.View.extend({
// initiate all the popover message boxes
show: function() {
app.publisher.open();
this._addPopover(this.firstMessage, {
trigger: "manual",
id: "first_message_explain",

View file

@ -91,6 +91,7 @@ app.views.Publisher = Backbone.View.extend({
this.initSubviews();
this.checkSubmitAvailability();
this.triggerGettingStarted();
return this;
},
@ -184,7 +185,10 @@ app.views.Publisher = Backbone.View.extend({
// show the "getting started" popups around the publisher
triggerGettingStarted: function() {
this.viewGettingStarted.show();
if (gon.preloads.getting_started) {
this.open();
this.viewGettingStarted.show();
}
},
createStatusMessage : function(evt) {

View file

@ -28,7 +28,8 @@ class StreamsController < ApplicationController
end
def multi
stream_responder(Stream::Multi)
gon.preloads[:getting_started] = current_user.getting_started
stream_responder(Stream::Multi)
end
def commented

View file

@ -25,7 +25,7 @@ module InterimStreamHackinessHelper
if params[:prefill].present?
params[:prefill]
elsif defined?(@stream)
@stream.publisher.prefill
@stream.publisher.prefill
else
nil
end
@ -50,8 +50,4 @@ module InterimStreamHackinessHelper
def publisher_public
publisher_method(:public)
end
def publisher_explain
publisher_method(:explain)
end
end

View file

@ -1,9 +1,3 @@
-if publisher_explain
:javascript
$(document).ready(function() {
if( app.publisher ) app.publisher.triggerGettingStarted();
});
.row.publisher#publisher{class: ((aspect == :profile || publisher_open) ? "mention_popup" : "closed")}
.content_creation
= form_for(StatusMessage.new) do |status|

View file

@ -1,12 +1,11 @@
class Publisher
attr_accessor :user, :open, :prefill, :public, :explain
attr_accessor :user, :open, :prefill, :public
def initialize(user, opts={})
self.user = user
self.open = opts[:open]
self.prefill = opts[:prefill]
self.public = opts[:public]
self.explain = opts[:explain]
end
def text

View file

@ -23,9 +23,10 @@ class Stream::Multi < Stream::Base
end
private
def publisher_opts
if welcome?
{open: true, prefill: publisher_prefill, public: true, explain: true}
{open: true, prefill: publisher_prefill, public: true}
else
super
end

View file

@ -23,7 +23,7 @@ describe Publisher do
end
end
["open", "public", "explain"].each do |property|
%w(open public).each do |property|
describe "##{property}" do
it 'defaults to closed' do
expect(@publisher.send("#{property}".to_sym)).to be_falsey

View file

@ -26,7 +26,7 @@ describe Stream::Multi do
prefill_text = "sup?"
allow(@stream).to receive(:welcome?).and_return(true)
allow(@stream).to receive(:publisher_prefill).and_return(prefill_text)
expect(@stream.send(:publisher_opts)).to eq(open: true, prefill: prefill_text, public: true, explain: true)
expect(@stream.send(:publisher_opts)).to eq(open: true, prefill: prefill_text, public: true)
end
it 'provides no opts if welcome? is not set' do