Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue #158 #215

Merged
merged 2 commits into from
Apr 8, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions platforms/web/resources.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
<property name="pages.index.html" location="${build.dir}/index.html" />
<property name="pages.index.tmpl" location="${listit.templates.paged}" />

<property name="asses" value="index" />
<property name="pages" value="index" />

<resources id="assets.index.css" refid="css.all"/>
<resources id="assets.index.css">
<resources refid="css.all" />
<file name="${listit.css.platform.dir}/warn-persistence.css" />
</resources>

<resources id="assets.index.js">
<resources refid="js.libs" />
Expand Down
12 changes: 12 additions & 0 deletions src/css/platforms/web/warn-persistence.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.warn-persistence {
display: none;
background: #FBE3E4;
color: #BA1F11;
text-align: center;
color:#9F6000;
padding:5px;
}

.not-logged-in .warn-persistence {
display: block;
}
2 changes: 1 addition & 1 deletion src/js/platforms/chrome/help-setup.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ListIt.lvent.once('setup:views', function(L, barr) {
'use strict';
L.addPage('help', new L.views.HelpPage({platform: "chrome"}));
L.addPage('help', new L.views.HelpPage());
});
3 changes: 2 additions & 1 deletion src/js/platforms/firefox/help-setup.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
ListIt.lvent.once('setup:views', function(L, barr) {
'use strict';
L.addPage('options', new L.views.HelpPage({platform: "firefox"}));

L.addPage('options', new L.views.HelpPage());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I wasn't clear about this. Because pretty much every platform has its own platform specific help, there is no reason to duplicate the code like this.

Instead, just check to see if any platform specific help exists by checking for the existence of L.templates['help'] and render it if it does. As this is common functionality, you can put it in the shared base-class.

Basically, while the help-text is platform specific, the code that renders it can be platform agnostic.

});
9 changes: 9 additions & 0 deletions src/js/platforms/web/templates.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/* Generated Template */

ListIt.templates['warn-persistence'] = function(obj){
var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'')};
with(obj||{}){
__p+='<div class="warn-persistence">\n Please <a href="#/options">log in</a> to sync your notes. If not, notes will be cleared if cookies are cleared.\n</div>\n\n';
}
return __p;
};
24 changes: 24 additions & 0 deletions src/js/platforms/web/web-setup.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
ListIt.lvent.once('setup:views', function(L, barr) {
'use strict';

var OldMainPage = L.views.MainPage;
L.views.MainPage = L.views.MainPage.extend({
initialize: function() {
OldMainPage.prototype.initialize.call(this);
this.listenTo(L.server, 'change:registered', function(){
this.togglePopUpAlert();
});
},

render: function() {
OldMainPage.prototype.render.call(this);
this.$el.prepend(L.templates['warn-persistence']());
if(!L.server.get('registered')){
this.$el.addClass('not-logged-in');
}
return this;
},

togglePopUpAlert: function() {
this.$el.toggleClass('not-logged-in', !L.server.get('registered'))
}
});

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly. However, the login state might change so you need to listen on changes to the registered attribute of L.server and update accordingly. Also, there's really no point in putting the if statement into the template, just put it outside the template and only render the warning if L.server.get('registered') returns false. This saves rendering an unused template.

L.addPage('main', new L.views.MainPage());
L.addPage('options', new L.views.OptionsPage());
L.addPage('help', new L.views.HelpPage());
Expand Down
12 changes: 2 additions & 10 deletions src/js/views/help.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,12 @@
L.views.HelpPage = Backbone.View.extend({
id: 'page-help',
className: 'page',
initialize: function(options) {
if (options) {
this.platform = options.platform;
}
},
render: function() {
this.$el.html(L.templates["pages/help"]());

if(this.platform) {
var main = this.$('#help-main');
if (L.templates["help"] !== undefined){ // has platform-specific help messages
var platformHelp = L.templates["help"]();
main.append(platformHelp);
this.$("#help-main").append(platformHelp);
}

return this;
}
});
Expand Down
4 changes: 4 additions & 0 deletions src/templates/platforms/web/warn-persistence.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<div class="warn-persistence">
Please <a href="#/options">log in</a> to sync your notes. If not, notes will be cleared if cookies are cleared.
</div>