From 1b052d312e692fd232fdcee3ff114451be25a47d Mon Sep 17 00:00:00 2001 From: Gentilhomme Date: Mon, 20 Apr 2015 15:29:03 +0200 Subject: [PATCH] Version 1.0 --- api/index.js | 8 ++ api/notifyjs.d.ts.txt | 106 +++++++++++++++ gulpfile.coffee | 27 ++++ node_modules/.bin/brfs | 15 +++ node_modules/.bin/brfs.cmd | 7 + node_modules/.bin/browserify | 15 +++ node_modules/.bin/browserify.cmd | 7 + node_modules/.bin/cake | 15 +++ node_modules/.bin/cake.cmd | 7 + node_modules/.bin/coffee | 15 +++ node_modules/.bin/coffee.cmd | 7 + node_modules/.bin/gulp | 15 +++ node_modules/.bin/gulp.cmd | 7 + node_modules/notifyjs/.jshintrc | 20 +++ node_modules/notifyjs/.npmignore | 1 + node_modules/notifyjs/.travis.yml | 8 ++ node_modules/notifyjs/LICENSE.md | 9 ++ node_modules/notifyjs/README.md | 107 +++++++++++++++ node_modules/notifyjs/bower.json | 27 ++++ node_modules/notifyjs/karma.conf.js | 69 ++++++++++ node_modules/notifyjs/notify.js | 194 +++++++++++++++++++++++++++ node_modules/notifyjs/package.json | 51 +++++++ node_modules/notifyjs/test/tests.js | 113 ++++++++++++++++ package.json | 25 ++++ public/api.js | 8 ++ public/componentEditors.js | 0 public/components.js | 0 public/data.js | 0 public/runtime.js | 201 ++++++++++++++++++++++++++++ runtime/index.js | 3 + 30 files changed, 1087 insertions(+) create mode 100644 api/index.js create mode 100644 api/notifyjs.d.ts.txt create mode 100644 gulpfile.coffee create mode 100644 node_modules/.bin/brfs create mode 100644 node_modules/.bin/brfs.cmd create mode 100644 node_modules/.bin/browserify create mode 100644 node_modules/.bin/browserify.cmd create mode 100644 node_modules/.bin/cake create mode 100644 node_modules/.bin/cake.cmd create mode 100644 node_modules/.bin/coffee create mode 100644 node_modules/.bin/coffee.cmd create mode 100644 node_modules/.bin/gulp create mode 100644 node_modules/.bin/gulp.cmd create mode 100644 node_modules/notifyjs/.jshintrc create mode 100644 node_modules/notifyjs/.npmignore create mode 100644 node_modules/notifyjs/.travis.yml create mode 100644 node_modules/notifyjs/LICENSE.md create mode 100644 node_modules/notifyjs/README.md create mode 100644 node_modules/notifyjs/bower.json create mode 100644 node_modules/notifyjs/karma.conf.js create mode 100644 node_modules/notifyjs/notify.js create mode 100644 node_modules/notifyjs/package.json create mode 100644 node_modules/notifyjs/test/tests.js create mode 100644 package.json create mode 100644 public/api.js create mode 100644 public/componentEditors.js create mode 100644 public/components.js create mode 100644 public/data.js create mode 100644 public/runtime.js create mode 100644 runtime/index.js diff --git a/api/index.js b/api/index.js new file mode 100644 index 0000000..8d4b555 --- /dev/null +++ b/api/index.js @@ -0,0 +1,8 @@ +var fs = require('fs'); + +SupAPI.registerPlugin('typescript', 'Notify ', { + code: "declare var Notify;", + defs: fs.readFileSync(__dirname + '/notifyjs.d.ts.txt', { + encoding: 'utf8' + }) +}); \ No newline at end of file diff --git a/api/notifyjs.d.ts.txt b/api/notifyjs.d.ts.txt new file mode 100644 index 0000000..d5a91db --- /dev/null +++ b/api/notifyjs.d.ts.txt @@ -0,0 +1,106 @@ +// Type definitions for notify.js 1.2.0 +// Project: https://github.com/alexgibson/notify.js +// Definitions by: soundTricker +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare var Notify: { + new (title : string , options? : notifyjs.INotifyOption): notifyjs.INotify; + + /** + * Check is permission is needed for the user to receive notifications. + * @return true : needs permission, false : does not need + */ + needsPermission() : boolean; + + /** + * Asks the user for permission to display notifications + * @param onPermissionGrantedCallback A callback for permmision is granted. + * @param onPermissionDeniedCallback A callback for permmision is denied. + */ + requestPermission(onPermissionGrantedCallback?: ()=> any, onPermissionDeniedCallback? : ()=> any) : void; + + /** + * return true if the browser supports HTML5 Notification + * @param true : the browser supports HTML5 Notification, false ; the browswer does not supports HTML5 Notification. + */ + isSupported() : boolean; +} + +declare module notifyjs { + + /** + * Interface for Web Notifications API Wrapper. + */ + interface INotify { + /** + * Show the notification. + */ + show() : void; + + /** + * Remove all event listener. + */ + destroy() : void; + + /** + * Close the notification. + */ + close() : void; + onShowNotification(e : Event) : void; + onCloseNotification() : void; + onClickNotification() : void; + onErrorNotification() : void; + handleEvent(e : Event) : void; + } + + /** + * Interface for the Notify's optional parameter. + */ + interface INotifyOption { + + /** + * notification message body + */ + body? : string; + + /** + * path for icon to display in notification + */ + icon? : string; + + /** + * unique identifier to stop duplicate notifications + */ + tag? : string; + + /** + * number of seconds to close the notification automatically + */ + timeout? : number; + + /** + * callback when notification is shown + */ + notifyShow? (e : Event): any; + /** + * callback when notification is closed + */ + notifyClose? : Function; + /** + * callback when notification is clicked + */ + notifyClick? : Function; + /** + * callback when notification throws an error + */ + notifyError? : Function; + /** + * callback when user has granted permission + */ + permissionGranted? : Function; + /** + * callback when user has denied permission + */ + permissionDenied? : Function; + } +} \ No newline at end of file diff --git a/gulpfile.coffee b/gulpfile.coffee new file mode 100644 index 0000000..eb56bbf --- /dev/null +++ b/gulpfile.coffee @@ -0,0 +1,27 @@ +gulp = require 'gulp' +tasks = [] + +# Browserify +browserify = require 'browserify' +vinylSourceStream = require 'vinyl-source-stream' + +makeBrowserify = (source, destination, output) -> + gulp.task "#{output}-browserify", -> + bundler = browserify source, extensions: ['.coffee'] + bundler.transform 'coffeeify' + bundler.transform 'brfs' + bundle = -> bundler.bundle().pipe(vinylSourceStream("#{output}.js")).pipe gulp.dest(destination) + bundle() + + tasks.push "#{output}-browserify" + +makeBrowserify "./api/index.js", "./public", "api" +makeBrowserify "./runtime/index.js", "./public", "runtime" + +gulp.task "watch", -> + gulp.watch ["./api/*"], ["api-browserify"] + gulp.watch "./runtime/*", ["runtime-browserify"] + +# All +gulp.task 'default', tasks + diff --git a/node_modules/.bin/brfs b/node_modules/.bin/brfs new file mode 100644 index 0000000..3262968 --- /dev/null +++ b/node_modules/.bin/brfs @@ -0,0 +1,15 @@ +#!/bin/sh +basedir=`dirname "$0"` + +case `uname` in + *CYGWIN*) basedir=`cygpath -w "$basedir"`;; +esac + +if [ -x "$basedir/node" ]; then + "$basedir/node" "$basedir/../brfs/bin/cmd.js" "$@" + ret=$? +else + node "$basedir/../brfs/bin/cmd.js" "$@" + ret=$? +fi +exit $ret diff --git a/node_modules/.bin/brfs.cmd b/node_modules/.bin/brfs.cmd new file mode 100644 index 0000000..9c05e77 --- /dev/null +++ b/node_modules/.bin/brfs.cmd @@ -0,0 +1,7 @@ +@IF EXIST "%~dp0\node.exe" ( + "%~dp0\node.exe" "%~dp0\..\brfs\bin\cmd.js" %* +) ELSE ( + @SETLOCAL + @SET PATHEXT=%PATHEXT:;.JS;=;% + node "%~dp0\..\brfs\bin\cmd.js" %* +) \ No newline at end of file diff --git a/node_modules/.bin/browserify b/node_modules/.bin/browserify new file mode 100644 index 0000000..5c73708 --- /dev/null +++ b/node_modules/.bin/browserify @@ -0,0 +1,15 @@ +#!/bin/sh +basedir=`dirname "$0"` + +case `uname` in + *CYGWIN*) basedir=`cygpath -w "$basedir"`;; +esac + +if [ -x "$basedir/node" ]; then + "$basedir/node" "$basedir/../browserify/bin/cmd.js" "$@" + ret=$? +else + node "$basedir/../browserify/bin/cmd.js" "$@" + ret=$? +fi +exit $ret diff --git a/node_modules/.bin/browserify.cmd b/node_modules/.bin/browserify.cmd new file mode 100644 index 0000000..6b8801d --- /dev/null +++ b/node_modules/.bin/browserify.cmd @@ -0,0 +1,7 @@ +@IF EXIST "%~dp0\node.exe" ( + "%~dp0\node.exe" "%~dp0\..\browserify\bin\cmd.js" %* +) ELSE ( + @SETLOCAL + @SET PATHEXT=%PATHEXT:;.JS;=;% + node "%~dp0\..\browserify\bin\cmd.js" %* +) \ No newline at end of file diff --git a/node_modules/.bin/cake b/node_modules/.bin/cake new file mode 100644 index 0000000..da84bdc --- /dev/null +++ b/node_modules/.bin/cake @@ -0,0 +1,15 @@ +#!/bin/sh +basedir=`dirname "$0"` + +case `uname` in + *CYGWIN*) basedir=`cygpath -w "$basedir"`;; +esac + +if [ -x "$basedir/node" ]; then + "$basedir/node" "$basedir/../coffee-script/bin/cake" "$@" + ret=$? +else + node "$basedir/../coffee-script/bin/cake" "$@" + ret=$? +fi +exit $ret diff --git a/node_modules/.bin/cake.cmd b/node_modules/.bin/cake.cmd new file mode 100644 index 0000000..5053d93 --- /dev/null +++ b/node_modules/.bin/cake.cmd @@ -0,0 +1,7 @@ +@IF EXIST "%~dp0\node.exe" ( + "%~dp0\node.exe" "%~dp0\..\coffee-script\bin\cake" %* +) ELSE ( + @SETLOCAL + @SET PATHEXT=%PATHEXT:;.JS;=;% + node "%~dp0\..\coffee-script\bin\cake" %* +) \ No newline at end of file diff --git a/node_modules/.bin/coffee b/node_modules/.bin/coffee new file mode 100644 index 0000000..04d88bf --- /dev/null +++ b/node_modules/.bin/coffee @@ -0,0 +1,15 @@ +#!/bin/sh +basedir=`dirname "$0"` + +case `uname` in + *CYGWIN*) basedir=`cygpath -w "$basedir"`;; +esac + +if [ -x "$basedir/node" ]; then + "$basedir/node" "$basedir/../coffee-script/bin/coffee" "$@" + ret=$? +else + node "$basedir/../coffee-script/bin/coffee" "$@" + ret=$? +fi +exit $ret diff --git a/node_modules/.bin/coffee.cmd b/node_modules/.bin/coffee.cmd new file mode 100644 index 0000000..72881d8 --- /dev/null +++ b/node_modules/.bin/coffee.cmd @@ -0,0 +1,7 @@ +@IF EXIST "%~dp0\node.exe" ( + "%~dp0\node.exe" "%~dp0\..\coffee-script\bin\coffee" %* +) ELSE ( + @SETLOCAL + @SET PATHEXT=%PATHEXT:;.JS;=;% + node "%~dp0\..\coffee-script\bin\coffee" %* +) \ No newline at end of file diff --git a/node_modules/.bin/gulp b/node_modules/.bin/gulp new file mode 100644 index 0000000..f93f3fe --- /dev/null +++ b/node_modules/.bin/gulp @@ -0,0 +1,15 @@ +#!/bin/sh +basedir=`dirname "$0"` + +case `uname` in + *CYGWIN*) basedir=`cygpath -w "$basedir"`;; +esac + +if [ -x "$basedir/node" ]; then + "$basedir/node" "$basedir/../gulp/bin/gulp.js" "$@" + ret=$? +else + node "$basedir/../gulp/bin/gulp.js" "$@" + ret=$? +fi +exit $ret diff --git a/node_modules/.bin/gulp.cmd b/node_modules/.bin/gulp.cmd new file mode 100644 index 0000000..8f13560 --- /dev/null +++ b/node_modules/.bin/gulp.cmd @@ -0,0 +1,7 @@ +@IF EXIST "%~dp0\node.exe" ( + "%~dp0\node.exe" "%~dp0\..\gulp\bin\gulp.js" %* +) ELSE ( + @SETLOCAL + @SET PATHEXT=%PATHEXT:;.JS;=;% + node "%~dp0\..\gulp\bin\gulp.js" %* +) \ No newline at end of file diff --git a/node_modules/notifyjs/.jshintrc b/node_modules/notifyjs/.jshintrc new file mode 100644 index 0000000..94cc21d --- /dev/null +++ b/node_modules/notifyjs/.jshintrc @@ -0,0 +1,20 @@ +{ + "globals": { + "define": false, + "Notification": false + }, + "browser": true, + "node": true, + "esnext": true, + "curly": true, + "eqeqeq": true, + "immed": true, + "latedef": false, + "newcap": true, + "undef": true, + "strict": true, + "trailing": true, + "white": true, + "indent": false, + "unused": false +} diff --git a/node_modules/notifyjs/.npmignore b/node_modules/notifyjs/.npmignore new file mode 100644 index 0000000..3c3629e --- /dev/null +++ b/node_modules/notifyjs/.npmignore @@ -0,0 +1 @@ +node_modules diff --git a/node_modules/notifyjs/.travis.yml b/node_modules/notifyjs/.travis.yml new file mode 100644 index 0000000..15a35ef --- /dev/null +++ b/node_modules/notifyjs/.travis.yml @@ -0,0 +1,8 @@ +language: node_js +node_js: + - "0.8" +before_install: + - "export DISPLAY=:99.0" + - "sh -e /etc/init.d/xvfb start" +addons: + firefox: "29.0" diff --git a/node_modules/notifyjs/LICENSE.md b/node_modules/notifyjs/LICENSE.md new file mode 100644 index 0000000..b5cf4a5 --- /dev/null +++ b/node_modules/notifyjs/LICENSE.md @@ -0,0 +1,9 @@ +Copyright (c) 2014 Alex Gibson + +http://alxgbsn.co.uk/ + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction except as noted below, including without limitation the rights to use, copy, modify, merge, publish, distribute, and/or sublicense, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE diff --git a/node_modules/notifyjs/README.md b/node_modules/notifyjs/README.md new file mode 100644 index 0000000..a74cf93 --- /dev/null +++ b/node_modules/notifyjs/README.md @@ -0,0 +1,107 @@ +Notify.js +========= + +[![Build Status](https://travis-ci.org/alexgibson/notify.js.png?branch=master)](https://travis-ci.org/alexgibson/notify.js) + +A handy wrapper for using the [Web Notifications API](http://www.w3.org/TR/notifications/). Notify.js aims to simplify requesting user permission and associated Web Notification API events, as well as providing a few extra callbacks and convenience methods. + +[Online demo](http://alxgbsn.co.uk/notify.js/) + +Installation +--------------------------------------- + +* Download: [zip](https://github.com/alexgibson/notify.js/zipball/master) +* [NPM](https://www.npmjs.org/): `npm install notifyjs` +* [Bower](https://github.com/twitter/bower/): `bower install notify.js` +* Git: `git clone https://github.com/alexgibson/notify.js` + +Setup +--------- + +This component can be used as an AMD module, CommonJS module, or a global. + +### for AMD module: +``` +define(['./notify'], function(Notify) { + var myNotification = new Notify(); + // ... +}); +``` + +### for CommonJS: +``` +var Notify = require('notifyjs'); +``` + +To initialize a web notification create a new `Notify` instance, passing the message `title` as well as any other options you wish to use. + +``` +var myNotification = new Notify('Yo dawg!', { + body: 'This is an awesome notification', + notifyShow: onNotifyShow +}); + +function onNotifyShow() { + console.log('notification was shown!'); +} +``` + +Then show the notification. + +``` +myNotification.show(); +``` + +Required parameters +------------------- + +* title (string) - notification title + +Optional parameters +------------------- + +* body: (string) - notification message body +* icon: (string) - path for icon to display in notification +* tag: (string) - unique identifier to stop duplicate notifications +* timeout: (integer) - number of seconds to close the notification automatically +* notifyShow: (function) - callback when notification is shown +* notifyClose: (function) - callback when notification is closed +* notifyClick: (function) - callback when notification is clicked +* notifyError: (function) - callback when notification throws an error + +Static methods and properties +----------------------------- + +* `Notify.requestPermission(onPermissionGrantedCallback, onPermissionDeniedCallback)` - requests permission from the user if needed and handles permission callbacks. +* `Notify.isSupported` - Boolean property to test for Web Notifications API browser support +* `Notify.needsPermission` - Boolean property to check if permission is needed for the user to receive notifications. +* `Notify.permissionLevel` - shows the user's current permission level (granted, denied or default), returns null if notifications are not supported. + +A note about Chrome +------------------- + +Prior to Chrome v37, `Notification.requestPermission` could not be called on page load events, it required a user interaction such as a `click` event. This has been fixed in current versions to be more consistent with other browsers, but please keep this in mind when writing your application. You can find out more in the [Chromium bug for this issue](https://code.google.com/p/chromium/issues/detail?id=274284). + +Testing +------- + +Install [Node](http://nodejs.org). Testing relies on the Karma test-runner, which can be installed globally using the following command. + +``` +npm install -g karma +``` + +In the project root, to perform a single pass of the tests using Firefox run: + +``` +npm test +``` + +Browser support +--------------------------------------- + +- Chrome (desktop) +- Safari +- Firefox +- Firefox OS (v1.2+) +- Firefox Mobile (Android) diff --git a/node_modules/notifyjs/bower.json b/node_modules/notifyjs/bower.json new file mode 100644 index 0000000..fd597b8 --- /dev/null +++ b/node_modules/notifyjs/bower.json @@ -0,0 +1,27 @@ +{ + "name": "notify.js", + "description": "A handy wrapper for the Web Notifications API", + "version": "1.2.5", + "author": { + "name": "Alex Gibson", + "email": "alxgbsn@gmail.com" + }, + "keywords": ["javascript", "web notifications", "notification", "notify"], + "main": "./notify.js", + "repository": { + "type": "git", + "url": "https://github.com/alexgibson/notify.js.git" + }, + "readme": "README.md", + "licenses": [{ + "type": "MIT", + "url": "http://opensource.org/licenses/MIT" + }], + "ignore": [ + "test", + ".jshintrc", + "karma.conf.js", + "package.json", + ".travis.yml" + ] +} diff --git a/node_modules/notifyjs/karma.conf.js b/node_modules/notifyjs/karma.conf.js new file mode 100644 index 0000000..fe5cc75 --- /dev/null +++ b/node_modules/notifyjs/karma.conf.js @@ -0,0 +1,69 @@ +// Karma configuration +// Generated on Sun Aug 04 2013 21:16:15 GMT+0100 (BST) + + +// base path, that will be used to resolve files and exclude +basePath = ''; + + +// list of files / patterns to load in the browser +files = [ + JASMINE, + JASMINE_ADAPTER, + 'notify.js', + 'test/*.js', + + { pattern: 'node_modules/sinon/pkg/sinon.js', watched: false, included: true } +]; + + +// list of files to exclude +exclude = [ + +]; + + +// test results reporter to use +// possible values: 'dots', 'progress', 'junit' +reporters = ['dots']; + + +// web server port +port = 9876; + + +// cli runner port +runnerPort = 9100; + + +// enable / disable colors in the output (reporters and logs) +colors = true; + + +// level of logging +// possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG +logLevel = LOG_INFO; + + +// enable / disable watching file and executing tests whenever any file changes +autoWatch = true; + + +// Start these browsers, currently available: +// - Chrome +// - ChromeCanary +// - Firefox +// - Opera +// - Safari (only Mac) +// - PhantomJS +// - IE (only Windows) +browsers = ['Firefox']; + + +// If browser does not capture in given timeout [ms], kill it +captureTimeout = 60000; + + +// Continuous Integration mode +// if true, it capture browsers, run tests and exit +singleRun = false; diff --git a/node_modules/notifyjs/notify.js b/node_modules/notifyjs/notify.js new file mode 100644 index 0000000..a45c6d3 --- /dev/null +++ b/node_modules/notifyjs/notify.js @@ -0,0 +1,194 @@ +/* + * Author: Alex Gibson + * https://github.com/alexgibson/notify.js + * License: MIT license + */ + +(function(global, factory) { + if (typeof define === 'function' && define.amd) { + // AMD environment + define(function() { + return factory(global, global.document); + }); + } else if (typeof module !== 'undefined' && module.exports) { + // CommonJS environment + module.exports = factory(global, global.document); + } else { + // Browser environment + global.Notify = factory(global, global.document); + } +} (typeof window !== 'undefined' ? window : this, function (w, d) { + + 'use strict'; + + function isFunction (item) { + return typeof item === 'function'; + } + + function Notify(title, options) { + + if (typeof title !== 'string') { + throw new Error('Notify(): first arg (title) must be a string.'); + } + + this.title = title; + + this.options = { + icon: '', + body: '', + tag: '', + notifyShow: null, + notifyClose: null, + notifyClick: null, + notifyError: null, + timeout: null + }; + + this.permission = null; + + if (!Notify.isSupported) { + return; + } + + //User defined options for notification content + if (typeof options === 'object') { + + for (var i in options) { + if (options.hasOwnProperty(i)) { + this.options[i] = options[i]; + } + } + + //callback when notification is displayed + if (isFunction(this.options.notifyShow)) { + this.onShowCallback = this.options.notifyShow; + } + + //callback when notification is closed + if (isFunction(this.options.notifyClose)) { + this.onCloseCallback = this.options.notifyClose; + } + + //callback when notification is clicked + if (isFunction(this.options.notifyClick)) { + this.onClickCallback = this.options.notifyClick; + } + + //callback when notification throws error + if (isFunction(this.options.notifyError)) { + this.onErrorCallback = this.options.notifyError; + } + } + } + + // true if the browser supports HTML5 Notification + Notify.isSupported = 'Notification' in w; + + // true if the permission is not granted + Notify.needsPermission = !(Notify.isSupported && Notification.permission === 'granted'); + + // returns current permission level ('granted', 'default', 'denied' or null) + Notify.permissionLevel = (Notify.isSupported ? Notification.permission : null); + + // asks the user for permission to display notifications. Then calls the callback functions is supplied. + Notify.requestPermission = function (onPermissionGrantedCallback, onPermissionDeniedCallback) { + if (!Notify.isSupported) { + return; + } + w.Notification.requestPermission(function (perm) { + switch (perm) { + case 'granted': + Notify.needsPermission = false; + if (isFunction(onPermissionGrantedCallback)) { + onPermissionGrantedCallback(); + } + break; + case 'denied': + if (isFunction(onPermissionDeniedCallback)) { + onPermissionDeniedCallback(); + } + break; + } + }); + }; + + + Notify.prototype.show = function () { + + if (!Notify.isSupported) { + return; + } + + this.myNotify = new Notification(this.title, { + 'body': this.options.body, + 'tag' : this.options.tag, + 'icon' : this.options.icon + }); + + if (this.options.timeout && !isNaN(this.options.timeout)) { + setTimeout(this.close.bind(this), this.options.timeout * 1000); + } + + this.myNotify.addEventListener('show', this, false); + this.myNotify.addEventListener('error', this, false); + this.myNotify.addEventListener('close', this, false); + this.myNotify.addEventListener('click', this, false); + }; + + Notify.prototype.onShowNotification = function (e) { + if (this.onShowCallback) { + this.onShowCallback(e); + } + }; + + Notify.prototype.onCloseNotification = function (e) { + if (this.onCloseCallback) { + this.onCloseCallback(e); + } + this.destroy(); + }; + + Notify.prototype.onClickNotification = function (e) { + if (this.onClickCallback) { + this.onClickCallback(e); + } + }; + + Notify.prototype.onErrorNotification = function (e) { + if (this.onErrorCallback) { + this.onErrorCallback(e); + } + this.destroy(); + }; + + Notify.prototype.destroy = function () { + this.myNotify.removeEventListener('show', this, false); + this.myNotify.removeEventListener('error', this, false); + this.myNotify.removeEventListener('close', this, false); + this.myNotify.removeEventListener('click', this, false); + }; + + Notify.prototype.close = function () { + this.myNotify.close(); + }; + + Notify.prototype.handleEvent = function (e) { + switch (e.type) { + case 'show': + this.onShowNotification(e); + break; + case 'close': + this.onCloseNotification(e); + break; + case 'click': + this.onClickNotification(e); + break; + case 'error': + this.onErrorNotification(e); + break; + } + }; + + return Notify; + +})); diff --git a/node_modules/notifyjs/package.json b/node_modules/notifyjs/package.json new file mode 100644 index 0000000..fde897f --- /dev/null +++ b/node_modules/notifyjs/package.json @@ -0,0 +1,51 @@ +{ + "name": "notifyjs", + "version": "1.2.5", + "description": "A handy wrapper for the Web Notifications API", + "main": "notify.js", + "devDependencies": { + "karma": "~0.8.5", + "sinon": "~1.7.3" + }, + "repository": { + "type": "git", + "url": "https://github.com/alexgibson/notify.js.git" + }, + "keywords": [ + "web", + "notification", + "nofity" + ], + "author": { + "name": "Alex Gibson" + }, + "license": "MIT", + "bugs": { + "url": "https://github.com/alexgibson/notify.js/issues" + }, + "scripts": { + "test": "karma start --browsers Firefox --single-run" + }, + "gitHead": "d20781ee87c5a1f089caea4bc8a2bcb300df22ff", + "homepage": "https://github.com/alexgibson/notify.js", + "_id": "notifyjs@1.2.5", + "_shasum": "d88ed5f2804b149ca450e05f045bbff6bfc703af", + "_from": "notifyjs@", + "_npmVersion": "1.4.21", + "_npmUser": { + "name": "alexgibson", + "email": "alxgbsn@gmail.com" + }, + "maintainers": [ + { + "name": "alexgibson", + "email": "alxgbsn@gmail.com" + } + ], + "dist": { + "shasum": "d88ed5f2804b149ca450e05f045bbff6bfc703af", + "tarball": "http://registry.npmjs.org/notifyjs/-/notifyjs-1.2.5.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/notifyjs/-/notifyjs-1.2.5.tgz" +} diff --git a/node_modules/notifyjs/test/tests.js b/node_modules/notifyjs/test/tests.js new file mode 100644 index 0000000..22ddc29 --- /dev/null +++ b/node_modules/notifyjs/test/tests.js @@ -0,0 +1,113 @@ +describe('instantiation', function () { + + it('should create a new Notify instance', function () { + var notification = new Notify('foo'); + expect(notification instanceof window.Notify).toBeTruthy(); + }); + + it('should throw an exception if has no title', function () { + expect(function () { + var notification = new Notify(); + }).toThrow(); + }); +}); + +describe('permission', function () { + + it('should check if permission is needed', function () { + expect(typeof Notify.needsPermission).toBe('boolean'); + }); + + it('should request permission from the user', function () { + spyOn(window.Notification, 'requestPermission'); + Notify.requestPermission(); + expect(window.Notification.requestPermission).toHaveBeenCalled(); + }); + + it('should update Notify.needsPermission to false if the user accepts the request', function () { + spyOn(window.Notification, 'requestPermission').andCallFake(function (cb) { + cb('granted'); + }); + + runs(Notify.requestPermission); + + waitsFor(function () { + return Notify.needsPermission === false; + }, 'Notify.needsPermission to be false', 750); + + runs(function () { + expect(Notify.needsPermission).toBe(false); + }); + }); +}); + +describe('callbacks', function () { + + var callback; + + beforeEach(function() { + callback = jasmine.createSpy(); + }); + + it('should fire show callback', function () { + var notification = new Notify('foo', { + notifyShow: callback + }); + notification.onShowNotification(); + expect(callback).toHaveBeenCalled(); + }); + + it('should fire close callback', function () { + var notification = new Notify('foo', { + notifyClose: callback + }); + notification.show(); + notification.onCloseNotification(); + expect(callback).toHaveBeenCalled(); + }); + + it('should fire click callback', function () { + var notification = new Notify('foo', { + notifyClick: callback + }); + notification.onClickNotification(); + expect(callback).toHaveBeenCalled(); + }); + + it('should fire error callback', function () { + var notification = new Notify('foo', { + notifyError: callback + }); + notification.show(); + notification.onErrorNotification(); + expect(callback).toHaveBeenCalled(); + }); + + it('should destroy a notification once closed', function () { + var notification = new Notify('foo', { + notifyClose: callback + }); + spyOn(notification, 'destroy'); + notification.onCloseNotification(); + expect(notification.destroy).toHaveBeenCalled(); + + }); +}); + +describe('timeout', function () { + + beforeEach(function () { + jasmine.Clock.useMock(); + }); + + it('should close a notification automatically', function () { + var notification = new Notify('foo', { + timeout: 1 + }); + spyOn(window.Notification.prototype, 'close'); + notification.show(); + expect(window.Notification.prototype.close).not.toHaveBeenCalled(); + jasmine.Clock.tick(1000); + expect(window.Notification.prototype.close).toHaveBeenCalled(); + }); +}); diff --git a/package.json b/package.json new file mode 100644 index 0000000..844cd9f --- /dev/null +++ b/package.json @@ -0,0 +1,25 @@ +{ + "name": "sup-notifyJS-plugin", + "version": "1.0.0", + "description": "notifyJS plugin for Superpowers, the extensible HTML5 2D+3D game engine.", + "homepage": "https://github.com/fraxken/superpowers-notifyjs-plugin", + "repository": { + "type": "git", + "url": "https://github.com/fraxken/superpowers-notifyjs-plugin" + }, + "dependencies": { + "notifyjs": "^1.2.5" + }, + "keywords": [ + "superpowers", + "plugin", + "notifyJS" + ], + "bugs": { + "url": "https://github.com/fraxken/superpowers-notifyjs-plugin/issues" + }, + "maintainers": [ + "GENTILHOMME Thomas " + ], + "license": "MIT" +} diff --git a/public/api.js b/public/api.js new file mode 100644 index 0000000..922b60c --- /dev/null +++ b/public/api.js @@ -0,0 +1,8 @@ +(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o\r\n// Definitions: https://github.com/borisyankov/DefinitelyTyped\r\n\r\ndeclare var Notify: {\r\n new (title : string , options? : notifyjs.INotifyOption): notifyjs.INotify;\r\n\r\n /**\r\n * Check is permission is needed for the user to receive notifications.\r\n * @return true : needs permission, false : does not need\r\n */\r\n needsPermission() : boolean;\r\n\r\n /**\r\n * Asks the user for permission to display notifications\r\n * @param onPermissionGrantedCallback A callback for permmision is granted.\r\n * @param onPermissionDeniedCallback A callback for permmision is denied.\r\n */\r\n requestPermission(onPermissionGrantedCallback?: ()=> any, onPermissionDeniedCallback? : ()=> any) : void;\r\n\r\n /**\r\n * return true if the browser supports HTML5 Notification\r\n * @param true : the browser supports HTML5 Notification, false ; the browswer does not supports HTML5 Notification.\r\n */\r\n isSupported() : boolean;\r\n}\r\n\r\ndeclare module notifyjs {\r\n \r\n /**\r\n * Interface for Web Notifications API Wrapper.\r\n */\r\n interface INotify {\r\n /**\r\n * Show the notification.\r\n */\r\n show() : void;\r\n\r\n /**\r\n * Remove all event listener.\r\n */\r\n destroy() : void;\r\n\r\n /**\r\n * Close the notification.\r\n */\r\n close() : void;\r\n onShowNotification(e : Event) : void;\r\n onCloseNotification() : void;\r\n onClickNotification() : void;\r\n onErrorNotification() : void;\r\n handleEvent(e : Event) : void;\r\n }\r\n \r\n /**\r\n * Interface for the Notify's optional parameter.\r\n */\r\n interface INotifyOption {\r\n\r\n /**\r\n * notification message body\r\n */\r\n body? : string;\r\n\r\n /**\r\n * path for icon to display in notification\r\n */\r\n icon? : string;\r\n\r\n /**\r\n * unique identifier to stop duplicate notifications\r\n */\r\n tag? : string;\r\n \r\n /**\r\n * number of seconds to close the notification automatically\r\n */\r\n timeout? : number;\r\n\r\n /**\r\n * callback when notification is shown\r\n */\r\n notifyShow? (e : Event): any;\r\n /**\r\n * callback when notification is closed\r\n */\r\n notifyClose? : Function;\r\n /**\r\n * callback when notification is clicked\r\n */\r\n notifyClick? : Function;\r\n /**\r\n * callback when notification throws an error\r\n */\r\n notifyError? : Function;\r\n /**\r\n * callback when user has granted permission\r\n */\r\n permissionGranted? : Function;\r\n /**\r\n * callback when user has denied permission\r\n */\r\n permissionDenied? : Function;\r\n }\r\n}" +}); +},{}]},{},[1]); diff --git a/public/componentEditors.js b/public/componentEditors.js new file mode 100644 index 0000000..e69de29 diff --git a/public/components.js b/public/components.js new file mode 100644 index 0000000..e69de29 diff --git a/public/data.js b/public/data.js new file mode 100644 index 0000000..e69de29 diff --git a/public/runtime.js b/public/runtime.js new file mode 100644 index 0000000..fc824ed --- /dev/null +++ b/public/runtime.js @@ -0,0 +1,201 @@ +(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o