Skip to content

Commit

Permalink
Notify about LiveStyle campaign
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeche committed Aug 23, 2016
1 parent 838f206 commit f290181
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 19 deletions.
18 changes: 1 addition & 17 deletions index.js
Expand Up @@ -141,7 +141,7 @@ module.exports.config = {
title: 'Debug Mode', title: 'Debug Mode',
description: 'Makes excessive logging into DevTools console, helps in finding bugs in plugin', description: 'Makes excessive logging into DevTools console, helps in finding bugs in plugin',
type: 'boolean', type: 'boolean',
default: true default: false
}, },
analyzer: require('./lib/analyzer/config') analyzer: require('./lib/analyzer/config')
}; };
Expand Down Expand Up @@ -245,22 +245,6 @@ function setupAnalyzer() {
} }
}) })
); );

displayLiveStyleNotification();
}
}

/**
* Display notification about available LiveStyle Analyzer
* @return {[type]} [description]
*/
function displayLiveStyleNotification() {
let key = `${pkg.name}.analyzer.notify`;
if (atom.config.get(key)) {
atom.notifications.addInfo(`**LiveStyle can help you with LESS and SCSS!**<br>A new [LiveStyle Analyzer experimental UI](https://github.com/livestyle/atom#livestyle-analyzer) displays instant code hints for LESS and SCSS stylesheets.`, {
dismissable: true
});
atom.config.set(key, false);
} }
} }


Expand Down
4 changes: 2 additions & 2 deletions lib/analyzer/config.js
Expand Up @@ -26,10 +26,10 @@ module.exports = {
description: 'Automatically display resolved CSS selector tooltip when caret moves inside selector token. When disabled, use `livestyle:show-widget` command to display tooltip.', description: 'Automatically display resolved CSS selector tooltip when caret moves inside selector token. When disabled, use `livestyle:show-widget` command to display tooltip.',
order: 3 order: 3
}, },
notify: { notifyCampaign: {
type: 'boolean', type: 'boolean',
default: true, default: true,
title: 'Notify about available LiveStyle Analyzer', title: 'Notify about LiveStyle Analyzer campaign',
description: 'Displays LiveStyle Analyzer notification when new window is opened. This config setting is automatically set to `false` after a new window is created and the notification is shown.', description: 'Displays LiveStyle Analyzer notification when new window is opened. This config setting is automatically set to `false` after a new window is created and the notification is shown.',
order: 4 order: 4
} }
Expand Down
23 changes: 23 additions & 0 deletions lib/analyzer/widget/registry.js
Expand Up @@ -6,6 +6,7 @@
'use strict'; 'use strict';


const hasWidgetClass = 'has-livestyle-widget'; const hasWidgetClass = 'has-livestyle-widget';
const pkg = require('../../../package.json');


module.exports = class WidgetRegistry { module.exports = class WidgetRegistry {
constructor() { constructor() {
Expand All @@ -22,6 +23,7 @@ module.exports = class WidgetRegistry {
widgets.add(widget); widgets.add(widget);
atom.views.getView(editor).classList.add(hasWidgetClass); atom.views.getView(editor).classList.add(hasWidgetClass);
widget.onDidDestroy(() => this.delete(editor, widget)); widget.onDidDestroy(() => this.delete(editor, widget));
widget.onDidShow(notifyPromo);
} }
} }


Expand Down Expand Up @@ -64,3 +66,24 @@ module.exports = class WidgetRegistry {
// this._registry = null; // this._registry = null;
} }
}; };


var promoNotificationTimer = null;
function notifyPromo() {
if (!promoNotificationTimer) {
promoNotificationTimer = setTimeout(displayPromoNotification, 15000);
}
}

/**
* Display notification about LiveStyle campaign
*/
function displayPromoNotification() {
let key = `${pkg.name}.analyzer.notifyCampaign`;
if (atom.config.get(key)) {
atom.notifications.addInfo(`**Do you like LiveStyle Analyzer?**<br>Help make this project better by supporting [crowdfunding campaign](https://www.indiegogo.com/projects/livestyle-analyzer/).`, {
dismissable: true
});
atom.config.set(key, false);
}
}

0 comments on commit f290181

Please sign in to comment.