Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

adding fake confirm

  • Loading branch information...
commit e0aa787d04d600d833a31998bbc7cd31e11e9e21 1 parent 1e7fa7a
nic luciano authored
Showing with 77 additions and 5 deletions.
  1. +39 −4 public/js/brain.js
  2. +38 −1 src/js/brain.coffee
View
43 public/js/brain.js
@@ -2,7 +2,7 @@
var __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };
$(function() {
- var Nav, Router, pages, router;
+ var $confirm, $nob, $p, $yesb, Nav, Router, bcss, close, install, pages, router;
pages = $('#content').pages();
Nav = new GH.Views.Nav({
el: $('#nav')
@@ -55,9 +55,44 @@
router = new Router;
Backbone.history.start();
if (navigator.mozApps) {
- if (confirm('Wow! You\'re totally on B2G!! Install this one your home screen?')) {
- navigator.mozApps.install('http://gh.nodejitsu.com/manifest.json');
- }
+ bcss = {
+ 'padding': '10px 20px',
+ 'background': '#666',
+ 'border-radius': '4px',
+ 'color': '#fff',
+ 'margin-right': '15px'
+ };
+ $nob = $('<a class="no" href="#">No</a>').css(bcss);
+ $yesb = $('<a class="yes" href="#">Yes</a>').css(bcss);
+ $confirm = $('<div id="confirm" />').css({
+ 'border-radius': '4px',
+ 'box-sizing': 'border-box',
+ 'position': 'absolute',
+ 'width': '100%',
+ 'background': '#bbb',
+ 'padding': '15px 15px 20px',
+ 'margin': '10px'
+ });
+ $p = $('<p>Wow! You\'re totally on B2G!! Install this one your home screen?</p>').css({
+ 'margin': '0 0 20px'
+ });
+ close = function() {
+ return $confirm.remove();
+ };
+ install = function() {
+ return navigator.mozApps.install('http://gh.nodejitsu.com/manifest.json');
+ };
+ $confirm.append($p);
+ $confirm.append($nob);
+ $confirm.append($yesb);
+ $('body').append($confirm);
+ $('a.yes', $confirm).click(function() {
+ close();
+ return install();
+ });
+ $('a.no', $confirm).click(function() {
+ return close();
+ });
}
return $(function() {
return $('a').live('click', function(e) {
View
39 src/js/brain.coffee
@@ -36,9 +36,46 @@ $ ->
Backbone.history.start()
# b2g install
+ # crap code to make a confirm message because b2g cannot lolol
+ # if confirm 'Wow! You\'re totally on B2G!! Install this one your home screen?'
+ # E/GeckoConsole(87): [JavaScript Error: "Couldn't play common dialog event sound:
+ # TypeError: Cc['@mozilla.org/sound;1'] is undefined"
+ # {file: "resource://gre/modules/CommonDialog.jsm" line: 213}]
if navigator.mozApps
- if confirm 'Wow! You\'re totally on B2G!! Install this one your home screen?'
+ # style
+ bcss =
+ 'padding': '10px 20px'
+ 'background': '#666'
+ 'border-radius': '4px'
+ 'color': '#fff'
+ 'margin-right': '15px'
+ $nob = $('<a class="no" href="#">No</a>').css bcss
+ $yesb = $('<a class="yes" href="#">Yes</a>').css bcss
+ $confirm = $('<div id="confirm" />').css
+ 'border-radius': '4px'
+ 'box-sizing': 'border-box'
+ 'position': 'absolute'
+ 'width': '100%'
+ 'background': '#bbb'
+ 'padding': '15px 15px 20px'
+ 'margin': '10px'
+ $p = $('<p>Wow! You\'re totally on B2G!! Install this one your home screen?</p>').css
+ 'margin': '0 0 20px'
+ # build
+ close = ->
+ $confirm.remove()
+ install = ->
navigator.mozApps.install 'http://gh.nodejitsu.com/manifest.json'
+ $confirm.append $p
+ $confirm.append $nob
+ $confirm.append $yesb
+ # bind
+ $('body').append $confirm
+ $('a.yes', $confirm).click ->
+ close()
+ install()
+ $('a.no', $confirm).click ->
+ close()
# all anchors are routes
$ ->
Please sign in to comment.
Something went wrong with that request. Please try again.