port 'getting started' to a backbone view, revert filename changes

This commit is contained in:
Florian Staudacher 2013-08-30 14:51:52 +02:00
parent 9560a8ec61
commit 4090f134f2
4 changed files with 68 additions and 57 deletions

View file

@ -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);
}
};
})();
}, timeout);
}
});

View file

@ -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(); }