remotestorage-widget
Advanced tools
Comparing version 1.1.1 to 1.2.0
{ | ||
"name": "remotestorage-widget", | ||
"version": "1.1.1", | ||
"version": "1.2.0", | ||
"description": "remoteStorage.js connect widget", | ||
@@ -5,0 +5,0 @@ "main": "build/widget.js", |
# remotestorage-widget | ||
[![npm](https://img.shields.io/npm/v/remotestorage-widget.svg)](https://www.npmjs.com/package/remotestorage-widget) | ||
[![Dependency Status](http://img.shields.io/david/remotestorage/remotestorage-widget.svg?style=flat)](https://david-dm.org/remotestorage/remotestorage-widget#info=dependencies) | ||
[![devDependency Status](http://img.shields.io/david/dev/remotestorage/remotestorage-widget.svg?style=flat)](https://david-dm.org/remotestorage/remotestorage-widget#info=devDependencies) | ||
A ready-to-use connect/sync widget, as add-on library for | ||
@@ -32,2 +36,3 @@ [remoteStorage.js](https://github.com/remotestorage/remotestorage.js/). | ||
| `autoCloseAfter` | Timeout after which the widget closes automatically (in milliseconds). The widget only closes when a storage is connected. | Number | 1500 | | ||
| `skipInitial` | Don't show the initial connect hint, but show sign-in screen directly instead | Boolean | false | | ||
| `logging` | Enable logging for debugging purposes | Boolean | false | | ||
@@ -34,0 +39,0 @@ |
@@ -5,9 +5,12 @@ /** | ||
* | ||
* @param {object} remoteStorage - remoteStorage instance | ||
* @param {object} options - Widget options | ||
* @param {boolean} options.leaveOpen - Do not minimize widget when user clicks | ||
* outside of it (default: false) | ||
* @param {number} options.autoCloseAfter - Time after which the widget closes | ||
* automatically in ms (default: 1500) | ||
* @param {boolean} options.logging - Enable logging (default: false) | ||
* @param {object} remoteStorage - remoteStorage instance | ||
* @param {object} options - Widget options | ||
* @param {boolean} options.leaveOpen - Do not minimize widget when user clicks | ||
* outside of it (default: false) | ||
* @param {number} options.autoCloseAfter - Time after which the widget closes | ||
* automatically in ms (default: 1500) | ||
* @param {boolean} options.skipInitial - Don't show the initial connect hint, | ||
* but show sign-in screen directly instead | ||
* (default: false) | ||
* @param {boolean} options.logging - Enable logging (default: false) | ||
*/ | ||
@@ -17,3 +20,6 @@ let Widget = function(remoteStorage, options={}) { | ||
this.state = 'initial'; | ||
this.leaveOpen = options.leaveOpen ? options.leaveOpen : false; | ||
this.autoCloseAfter = options.autoCloseAfter ? options.autoCloseAfter : 1500; | ||
this.skipInitial = options.skipInitial ? options.skipInitial : false; | ||
this.logging = options.logging ? options.logging : false; | ||
@@ -29,8 +35,2 @@ // true if we have remoteStorage connection's info | ||
this.leaveOpen = options.leaveOpen ? options.leaveOpen : false; | ||
this.logging = typeof options.logging === 'boolean' ? options.logging : false; | ||
this.autoCloseAfter = options.autoCloseAfter ? options.autoCloseAfter : 1500; | ||
this.lastSynced = null; | ||
@@ -40,3 +40,2 @@ this.lastSyncedUpdateLoop = null; | ||
Widget.prototype = { | ||
@@ -80,3 +79,4 @@ | ||
this.setBackendClass(); // removes all backend CSS classes | ||
this.setState('initial'); | ||
this.open(); | ||
this.setInitialState(); | ||
break; | ||
@@ -143,3 +143,17 @@ case 'connected': | ||
/** | ||
* Set widget to its inital state | ||
* | ||
* @private | ||
*/ | ||
setInitialState () { | ||
if (this.skipInitial) { | ||
this.showChooseOrSignIn(); | ||
} else { | ||
this.setState('initial'); | ||
} | ||
}, | ||
/** | ||
* Create the widget element and add styling. | ||
@@ -175,3 +189,3 @@ * | ||
this.rsConnectedLabel = document.querySelector('.rs-box-connected .rs-sub-headline') | ||
this.rsConnectedLabel = document.querySelector('.rs-box-connected .rs-sub-headline'); | ||
this.rsChooseRemoteStorageButton = document.querySelector('button.rs-choose-rs'); | ||
@@ -244,2 +258,3 @@ this.rsChooseDropboxButton = document.querySelector('button.rs-choose-dropbox'); | ||
this.setupHandlers(); | ||
this.setInitialState(); | ||
}, | ||
@@ -354,8 +369,9 @@ | ||
this.rsWidget.classList.add('rs-closed'); | ||
} else if (this.active) { | ||
this.setState('connected'); | ||
} else { | ||
this.setState(this.active ? 'connected' : 'initial'); | ||
this.setInitialState(); | ||
} | ||
}, | ||
/** | ||
@@ -444,3 +460,3 @@ * Mark the widget as offline. | ||
updateLastSyncedOutput () { | ||
if (!this.lastSynced) { return } // don't do anything when we've never synced yet | ||
if (!this.lastSynced) { return; } // don't do anything when we've never synced yet | ||
let now = new Date(); | ||
@@ -447,0 +463,0 @@ let secondsSinceLastSync = Math.round((now.getTime() - this.lastSynced.getTime())/1000); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
351624
1035
72