diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e48d4c9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +.idea +node_modules +.DS_Store +npm-debug.log \ No newline at end of file diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..bd29f19 --- /dev/null +++ b/.npmignore @@ -0,0 +1,4 @@ +.DS_Store +node_modules +*.orig +.idea diff --git a/README.md b/README.md deleted file mode 100644 index e69de29..0000000 diff --git a/lib/about.css b/lib/about.css new file mode 100644 index 0000000..374f5b9 --- /dev/null +++ b/lib/about.css @@ -0,0 +1,15 @@ +/* About popup +*******************************/ + +.p-zb-about {} + .p-zb-about__container { + width: 360px; + height: 140px; + background: #fff url(about.png) 10px 50% no-repeat; + color: #000; + box-sizing: border-box; + overflow: hidden; + padding: 10px; + padding-left: 120px; + border: 4px solid #A9A9A9; + } diff --git a/lib/about.js b/lib/about.js new file mode 100644 index 0000000..6bd208a --- /dev/null +++ b/lib/about.js @@ -0,0 +1,98 @@ +goog.provide('zb.popups.About'); +goog.require('zb.ext.about.popups.templates.about'); +goog.require('zb.layers.CutePopup'); +goog.require('zb.packageInfo'); + + + +/** + * @extends {zb.layers.CutePopup} + * @constructor + */ +zb.popups.About = function() { + goog.base(this); + this._addContainerClass('p-zb-about'); + this._keyProcessCounter = 0; +}; +goog.inherits(zb.popups.About, zb.layers.CutePopup); + + +/** + * @inheritDoc + */ +zb.popups.About.prototype._renderTemplate = function() { + return zb.ext.about.popups.templates.about(this._getTemplateData(), this._getTemplateOptions()); +}; + + +/** + * @inheritDoc + */ +zb.popups.About.prototype._processKey = function() { + if (this._keyProcessCounter > 0) { + this.close(0); + } + this._keyProcessCounter++; + return true; +}; + + +/** + * @type {zb.ext.about.popups.templates.AboutOut} + * @protected + */ +zb.popups.About.prototype._exported; + + +/** + * @type {number} + * @private + */ +zb.popups.About.prototype._keyProcessCounter; + + +/** + * @param {Array.} seq + */ +zb.popups.About.setKeySequence = function(seq) { + zb.popups.About._sequence = seq; + zb.popups.About._currentPosition = 0; +}; + + +/** + * @param {zb.device.input.Keys} zbKey + */ +zb.popups.About.processKey = function(zbKey) { + var seq = zb.popups.About._sequence; + zb.popups.About._currentPosition = zb.popups.About._currentPosition || 0; + if (seq[zb.popups.About._currentPosition] !== zbKey) { + zb.popups.About._currentPosition = 0; + } else if (zb.popups.About._currentPosition === seq.length - 1) { + app.showChildLayer(zb.popups.About); + } else { + zb.popups.About._currentPosition++; + } +}; + + +/** + * @type {number} + * @private + */ +zb.popups.About._currentPosition; + + +/** + * Default value is '1235789' like Z + * @type {Array.} + */ +zb.popups.About._sequence = [ + zb.device.input.Keys.DIGIT_1, + zb.device.input.Keys.DIGIT_2, + zb.device.input.Keys.DIGIT_3, + zb.device.input.Keys.DIGIT_5, + zb.device.input.Keys.DIGIT_7, + zb.device.input.Keys.DIGIT_8, + zb.device.input.Keys.DIGIT_9 +]; diff --git a/lib/about.jst b/lib/about.jst new file mode 100644 index 0000000..38daf6c --- /dev/null +++ b/lib/about.jst @@ -0,0 +1,12 @@ +{{$ zb.ext.about.popups.templates.about }} + +
+
+
+ Application name: {{- zb.packageInfo.name }}
+ Application version: {{- zb.packageInfo.version }}
+ Zombiebox version: {{- zb.packageInfo.dependencies.zombiebox }}
+ Zombiebox in web: http://zombiebox.net/ +
+
+
diff --git a/lib/about.png b/lib/about.png new file mode 100644 index 0000000..b361a1a Binary files /dev/null and b/lib/about.png differ diff --git a/package.json b/package.json new file mode 100644 index 0000000..53e5773 --- /dev/null +++ b/package.json @@ -0,0 +1,5 @@ +{ + "name": "zombiebox-extension-about", + "version": "0.1.0", + "main": "zombiebox-extension.js" +} diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..831bce2 --- /dev/null +++ b/readme.md @@ -0,0 +1,17 @@ + +Integration +------- + +Add code like this to your application.js + +```javascript + +/** + * @inheritDoc + */ +yourApp.Application.prototype.processKey = function(zbKey, e) { + zb.popups.About.processKey(zbKey); + + return goog.base(this, 'processKey', zbKey, e); +}; +``` diff --git a/zombiebox-extension.js b/zombiebox-extension.js new file mode 100644 index 0000000..bcaa094 --- /dev/null +++ b/zombiebox-extension.js @@ -0,0 +1,39 @@ +var path = require('path'); + + +/** + * @implements {IZBAddon} + */ +var extension = function() { + +}; + + +/** + * @return {string} + */ +extension.prototype.getName = function() { + return 'about'; +}; + + +/** + * @return {string} + */ +extension.prototype.getPublicDir = function() { + return path.join(__dirname, 'lib'); +}; + + +/** + * @return {Object} + */ +extension.prototype.getConfig = function() { + return {}; +}; + + +/** + * @type {IZBAddon} + */ +module.exports = extension;