2016-05-12 14:54:22 -07:00
NEWSBLUR . ReaderNewsletters = function ( options ) {
2016-05-12 18:32:56 -07:00
var defaults = {
'width' : 800
} ;
2016-05-12 14:54:22 -07:00
this . options = $ . extend ( { } , defaults , options ) ;
this . model = NEWSBLUR . assets ;
this . runner ( ) ;
} ;
NEWSBLUR . ReaderNewsletters . prototype = new NEWSBLUR . Modal ;
NEWSBLUR . ReaderNewsletters . prototype . constructor = NEWSBLUR . ReaderNewsletters ;
_ . extend ( NEWSBLUR . ReaderNewsletters . prototype , {
runner : function ( ) {
this . make _modal ( ) ;
2016-05-12 18:32:56 -07:00
this . open _modal ( _ . bind ( function ( ) {
$ ( '.NB-newsletters-email' ) . click ( ) ;
} , this ) ) ;
2016-05-12 14:54:22 -07:00
this . $modal . bind ( 'click' , $ . rescope ( this . handle _click , this ) ) ;
} ,
make _modal : function ( ) {
var self = this ;
2016-05-12 18:32:56 -07:00
var email = NEWSBLUR . Globals . username + "-" + NEWSBLUR . Globals . secret _token + "@newsletters.newsblur.com" ;
2016-05-12 14:54:22 -07:00
this . $modal = $ . make ( 'div' , { className : 'NB-modal-newsletters NB-modal' } , [
$ . make ( 'h2' , { className : 'NB-modal-title' } , [
$ . make ( 'div' , { className : 'NB-icon' } ) ,
'Email Newsletters' ,
$ . make ( 'div' , { className : 'NB-icon-dropdown' } )
] ) ,
$ . make ( 'fieldset' , [
$ . make ( 'legend' , 'Forwarding email address' )
] ) ,
$ . make ( 'div' , { className : 'NB-newsletters-group' } , [
2016-05-12 18:32:56 -07:00
$ . make ( 'input' , { type : 'text' , value : email , className : 'NB-newsletters-email' } )
2016-05-12 14:54:22 -07:00
] ) ,
$ . make ( 'fieldset' , [
$ . make ( 'legend' , 'Setup instructions' )
2016-05-12 18:32:56 -07:00
] ) ,
$ . make ( 'div' , { className : 'NB-newsletters-group' } , [
$ . make ( 'p' , 'To read your email newsletters in NewsBlur, forward your newsletters to your custom email address shown above.' ) ,
$ . make ( 'p' , [
'In Gmail, go to ' ,
$ . make ( 'b' , 'Settings > Forwarding' ) ,
' and click on ' ,
$ . make ( 'b' , 'Add a forwarding address' ) ,
'. Add your custom NewsBlur email address.'
] ) ,
$ . make ( 'p' , 'Gmail will walk you through confirming the email address. You\'ll want to come back to NewsBlur and look for the confirmation email under the "Newsletters" folder.' ) ,
$ . make ( 'p' , 'Next, create a filter with all of your newsletters so that they forward to the custom address on NewsBlur.' ) ,
$ . make ( 'img' , { src : NEWSBLUR . Globals . MEDIA _URL + "/img/reader/newsletters_gmail.png" , className : 'NB-newsletters-gmail' } )
2016-05-12 14:54:22 -07:00
] )
] ) ;
} ,
// ===========
// = Actions =
// ===========
handle _click : function ( elem , e ) {
var self = this ;
2016-05-12 18:32:56 -07:00
$ . targetIs ( e , { tagSelector : '.NB-newsletters-email' } , function ( $t , $p ) {
2016-05-12 14:54:22 -07:00
e . preventDefault ( ) ;
$t . select ( ) ;
} ) ;
}
} ) ;