Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Building Desktop Apps with Ember and Node-Webkit

Building Desktop Apps with Ember and Node-Webkit

Ember SF Meetup - April 29, 2014

Source code used in the demos will be published at blog.nitrous.io soon, please follow @NitrousIO on Twitter for updates.

Peter Jihoon Kim

April 29, 2014
Tweet

More Decks by Peter Jihoon Kim

Other Decks in Programming

Transcript

  1. App.UiSwitchComponent = Ember.Component.extend({ classNames: ['ui-switch'], classNameBindings: ['enabled:on'], enabled: false, !

    click: function() { this.toggleProperty('enabled'); } }); {{ui-switch enabled=enabled}}
  2. App.UiFileDialogComponent = Ember.Component.extend({ classNames: ['ui-file-dialog'], tagName: 'input', attributeBindings: [ 'type',

    'accept', 'style', 'directory:nwdirectory', 'save:nwsaveas' ], type: 'file', style: 'display: none', ! value: '', accept: null, directory: false, save: false, ! open: function() { this.$().click(); }, ! change: function() { this.set('value', this.$().val()); } });
  3. Debugging Dev Tools Refresh var gui = require('nw.gui'), win =

    gui.Window.get(); ! $('#debug .refresh').click(function() { win.reloadIgnoringCache(); }); ! $('#debug .devtools').click(function() { win.showDevTools(); });
  4. On/Offline Detection MyDesktopApp = Ember.Application.extend({ online: navigator.onLine, offline: Em.computed.not('online') });

    ! App = MyDesktopApp.create(); ! $(window).on('online offline', function() { App.set('online', navigator.onLine); }); {{#if App.offline}} No Internet Connection? :-( {{else}} Yay! {{/if}}
  5. Platform Detection var os = require('os'); ! MyDesktopApp = Ember.Application.extend({

    platform: { isWindows: os.type() == 'Windows_NT', isMac: os.type() == 'Darwin', isLinux: os.type() == 'Linux' } });
 ! App = MyDesktopApp.create(); {{#if App.platform.isMac}} Hi, I am a Mac. {{else}}{{#if App.platform.isWindows}} I am a PC. {{/if}}{{/if}}
  6. var win = require('nw.gui').Window.get(); ! App.SignInRoute = Em.Route.extend({ deactivate: function()

    { win.hide(); } }); ! App.MainRoute = Em.Route.extend({ activate: function() { win.resizeTo(1000, 500); win.moveTo(...); win.show(); } });
  7. Windows or place a folder containing
 app code named ‘package.nw’

    place a zip archive containing
 app code named ‘package.nw’ copy /b nw.exe+package.nw myapp.exe optional