diff --git a/app/assets/javascripts/app/views/publisher/publisher_aspect_selector.js b/app/assets/javascripts/app/views/publisher/aspect_selector.js similarity index 100% rename from app/assets/javascripts/app/views/publisher/publisher_aspect_selector.js rename to app/assets/javascripts/app/views/publisher/aspect_selector.js diff --git a/app/assets/javascripts/app/views/publisher/getting_started.js b/app/assets/javascripts/app/views/publisher/getting_started.js index 815f05585..cee509884 100644 --- a/app/assets/javascripts/app/views/publisher/getting_started.js +++ b/app/assets/javascripts/app/views/publisher/getting_started.js @@ -3,63 +3,63 @@ * the COPYRIGHT file. */ -(function(){ - // mixin-object, used in conjunction with the publisher to provide the - // functionality for displaying 'getting-started' information - app.views.PublisherGettingStarted = { +// Getting started view for the publisher. +// Provides "getting started" popups around the elements of the publisher +// for describing their use to new users. +app.views.PublisherGettingStarted = Backbone.View.extend({ - // initiate all the popover message boxes - triggerGettingStarted: function() { - this._addPopover(this.el_input, { - trigger: 'manual', - offset: 30, - id: 'first_message_explain', - placement: 'right', - html: true - }, 600); - this._addPopover(this.$('.dropdown'), { - trigger: 'manual', - offset: 10, - id: 'message_visibility_explain', - placement: 'bottom', - html: true - }, 1000); - this._addPopover($('#gs-shim'), { - trigger: 'manual', - offset: -5, - id: 'stream_explain', - placement: 'left', - html: true - }, 1400); + // initiate all the popover message boxes + show: function() { + this._addPopover(this.options.el_first_msg, { + trigger: 'manual', + offset: 30, + id: 'first_message_explain', + placement: 'right', + html: true + }, 600); + this._addPopover(this.options.el_visibility, { + trigger: 'manual', + offset: 10, + id: 'message_visibility_explain', + placement: 'bottom', + html: true + }, 1000); + this._addPopover(this.options.el_stream, { + trigger: 'manual', + offset: -5, + id: 'stream_explain', + placement: 'left', + html: true + }, 1400); - // hide some popovers when a post is created - this.$('.button.creation').click(function() { - this.$('.dropdown').popover('hide'); - this.el_input.popover('hide'); - }); - }, + // hide some popovers when a post is created + this.$('.button.creation').click(function() { + this.options.el_visibility.popover('hide'); + this.options.el_first_msg.popover('hide'); + }); + }, - _addPopover: function(el, opts, timeout) { - el.popover(opts); - el.click(function() { + _addPopover: function(el, opts, timeout) { + el.popover(opts); + el.click(function() { + el.popover('hide'); + }); + + // show the popover after the given timeout + setTimeout(function() { + el.popover('show'); + + // disable 'getting started' when the last popover is closed + var popup = el.data('popover').$tip[0]; + var close = $(popup).find('.close'); + + close.click(function() { + if( $('.popover').length==1 ) { + $.get('/getting_started_completed'); + } el.popover('hide'); + return false; }); - - // show the popover after the given timeout - setTimeout(function() { - el.popover('show'); - - // disable 'getting started' when the last popover is closed - var popup = el.data('popover').$tip[0]; - var close = $(popup).find('.close'); - - close.click(function() { - if( $('.popover').length==1 ) { - $.get('/getting_started_completed'); - } - el.popover('hide'); - }); - }, timeout); - } - }; -})(); \ No newline at end of file + }, timeout); + } +}); diff --git a/app/assets/javascripts/app/views/publisher/publisher_services.js b/app/assets/javascripts/app/views/publisher/services.js similarity index 100% rename from app/assets/javascripts/app/views/publisher/publisher_services.js rename to app/assets/javascripts/app/views/publisher/services.js diff --git a/app/assets/javascripts/app/views/publisher_view.js b/app/assets/javascripts/app/views/publisher_view.js index 9a8cd2ee3..cf1f2fda0 100644 --- a/app/assets/javascripts/app/views/publisher_view.js +++ b/app/assets/javascripts/app/views/publisher_view.js @@ -3,8 +3,8 @@ * the COPYRIGHT file. */ -//= require ./publisher/publisher_services -//= require ./publisher/publisher_aspect_selector +//= require ./publisher/services +//= require ./publisher/aspect_selector //= require ./publisher/getting_started //= require jquery.textchange @@ -82,6 +82,12 @@ app.views.Publisher = Backbone.View.extend(_.extend( el: this.$('.public_toggle > .dropdown'), form: form }); + + this.view_getting_started = new app.views.PublisherGettingStarted({ + el_first_msg: this.el_input, + el_visibility: this.$('.public_toggle > .dropdown'), + el_stream: $('#gs-shim') + }); }, // set the selected aspects in the dropdown by their ids @@ -89,6 +95,11 @@ app.views.Publisher = Backbone.View.extend(_.extend( this.view_aspect_selector.updateAspectsSelector(ids); }, + // show the "getting started" popups around the publisher + triggerGettingStarted: function() { + this.view_getting_started.show(); + }, + createStatusMessage : function(evt) { if(evt){ evt.preventDefault(); }