Skip to content

Commit

Permalink
Merge branch 'master' into production
Browse files Browse the repository at this point in the history
  • Loading branch information
kyuwoo.choi committed Apr 13, 2018
2 parents d5cf9d2 + dc88503 commit 0cd31ce
Show file tree
Hide file tree
Showing 11 changed files with 127 additions and 31 deletions.
29 changes: 26 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* [Examples](#-examples)
* [Install](#-install)
* [Via Package Manager](#via-package-manager)
* [Via Contents Delivery Network (CDN)](#via-contents-delivery-network-cdn)
* [Download Source Files](#download-source-files)
* [Usage](#-usage)
* [HTML](#html)
Expand All @@ -29,9 +30,9 @@


## 🌏 Browser Support
| <img src="https://user-images.githubusercontent.com/1215767/34348387-a2e64588-ea4d-11e7-8267-a43365103afe.png" alt="Chrome" width="16px" height="16px" /> Chrome | <img src="https://user-images.githubusercontent.com/1215767/34348383-9e7ed492-ea4d-11e7-910c-03b39d52f496.png" alt="Firefox" width="16px" height="16px" /> Firefox | <img src="https://user-images.githubusercontent.com/1215767/34348394-a981f892-ea4d-11e7-9156-d128d58386b9.png" alt="Safari" width="16px" height="16px" /> Safari | <img src="https://user-images.githubusercontent.com/1215767/34348380-93e77ae8-ea4d-11e7-8696-9a989ddbbbf5.png" alt="Edge" width="16px" height="16px" /> Edge | <img src="https://user-images.githubusercontent.com/1215767/34348590-250b3ca2-ea4f-11e7-9efb-da953359321f.png" alt="IE" width="16px" height="16px" /> Internet Explorer |
| <img src="https://user-images.githubusercontent.com/1215767/34348387-a2e64588-ea4d-11e7-8267-a43365103afe.png" alt="Chrome" width="16px" height="16px" /> Chrome | <img src="https://user-images.githubusercontent.com/1215767/34348590-250b3ca2-ea4f-11e7-9efb-da953359321f.png" alt="IE" width="16px" height="16px" /> Internet Explorer | <img src="https://user-images.githubusercontent.com/1215767/34348380-93e77ae8-ea4d-11e7-8696-9a989ddbbbf5.png" alt="Edge" width="16px" height="16px" /> Edge | <img src="https://user-images.githubusercontent.com/1215767/34348394-a981f892-ea4d-11e7-9156-d128d58386b9.png" alt="Safari" width="16px" height="16px" /> Safari | <img src="https://user-images.githubusercontent.com/1215767/34348383-9e7ed492-ea4d-11e7-910c-03b39d52f496.png" alt="Firefox" width="16px" height="16px" /> Firefox |
| :---------: | :---------: | :---------: | :---------: | :---------: |
| Yes | Yes | Yes | Yes | 8+ |
| Yes | 8+ | Yes | Yes | Yes |


## 🎨 Features
Expand Down Expand Up @@ -71,6 +72,28 @@ $ bower install tui-gesture-reader # Latest version
$ bower install tui-gesture-reader#<tag> # Specific version
```

### Via Contents Delivery Network (CDN)
TOAST UI products are available over the CDN powered by [TOAST Cloud](https://www.toast.com).

You can use the CDN as below.

```html
<script src="https://uicdn.toast.com/tui-gesture-reader/latest/tui-gesture-reader.js"></script>
```

If you want to use a specific version, use the tag name instead of `latest` in the url's path.

The CDN directory has the following structure.

```
tui-gesture-reader/
├─ latest/
│ ├─ tui-gesture-reader.js
│ └─ tui-gesture-reader.min.js
├─ v2.1.0/
│ ├─ ...
```

### Download Source Files
* [Download bundle files](https://github.com/nhnent/tui.gesture-reader/tree/production/dist)
* [Download all sources for each version](https://github.com/nhnent/tui.gesture-reader/releases)
Expand Down Expand Up @@ -174,7 +197,7 @@ You can also see the older versions of API page on the [releases page](https://g


## 🔩 Dependency
* [tui-code-snippet](https://github.com/nhnent/tui.code-snippet) >=1.2.5
* [tui-code-snippet](https://github.com/nhnent/tui.code-snippet) >=1.3.0


## 📜 License
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
"package.json"
],
"dependencies": {
"tui-code-snippet": "^1.2.5"
"tui-code-snippet": "^1.3.0"
}
}
2 changes: 1 addition & 1 deletion examples/example01-basic.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<span id="type">Type : <em></em></span>
</div>
</div>
<script type="text/javascript" src="https://cdn.rawgit.com/nhnent/tui.code-snippet/v1.2.5/dist/tui-code-snippet.js"></script>
<script type="text/javascript" src="https://uicdn.toast.com/tui.code-snippet/v1.3.0/tui-code-snippet.min.js"></script>
<script type="text/javascript" src="../dist/tui-gesture-reader.js"></script>
<script type="text/javascript" class="code-js">

Expand Down
2 changes: 1 addition & 1 deletion examples/example02-dblclick.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<span id="type">Type : <em></em></span>
</div>
</div>
<script type="text/javascript" src="https://cdn.rawgit.com/nhnent/tui.code-snippet/v1.2.5/dist/tui-code-snippet.js"></script>
<script type="text/javascript" src="https://uicdn.toast.com/tui.code-snippet/v1.3.0/tui-code-snippet.min.js"></script>
<script type="text/javascript" src="../dist/tui-gesture-reader.js"></script>
<script type="text/javascript" class="code-js">

Expand Down
2 changes: 1 addition & 1 deletion examples/example03-longtab.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
</ul>
</div>
</div>
<script type="text/javascript" src="https://cdn.rawgit.com/nhnent/tui.code-snippet/v1.2.5/dist/tui-code-snippet.js"></script>
<script type="text/javascript" src="https://uicdn.toast.com/tui.code-snippet/v1.3.0/tui-code-snippet.min.js"></script>
<script type="text/javascript" src="../dist/tui-gesture-reader.js"></script>
<script type="text/javascript" class="code-js">

Expand Down
2 changes: 1 addition & 1 deletion examples/example04-flick-mobile.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<span id="type">Type : <em></em></span>
</div>
</div>
<script type="text/javascript" src="https://cdn.rawgit.com/nhnent/tui.code-snippet/v1.2.5/dist/tui-code-snippet.js"></script>
<script type="text/javascript" src="https://uicdn.toast.com/tui.code-snippet/v1.3.0/tui-code-snippet.min.js"></script>
<script type="text/javascript" src="../dist/tui-gesture-reader.js"></script>
<script type="text/javascript" class="code-js">

Expand Down
2 changes: 1 addition & 1 deletion examples/example05-longtab-mobile.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
</ul>
</div>
</div>
<script type="text/javascript" src="https://cdn.rawgit.com/nhnent/tui.code-snippet/v1.2.5/dist/tui-code-snippet.js"></script>
<script type="text/javascript" src="https://uicdn.toast.com/tui.code-snippet/v1.3.0/tui-code-snippet.min.js"></script>
<script type="text/javascript" src="../dist/tui-gesture-reader.js"></script>
<script type="text/javascript" class="code-js">

Expand Down
47 changes: 27 additions & 20 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tui-gesture-reader",
"version": "2.0.0",
"version": "2.1.0",
"main": "dist/tui-gesture-reader",
"scripts": {
"test": "karma start --no-single-run",
Expand Down Expand Up @@ -47,6 +47,6 @@
"webpack-dev-server": "^1.11.0"
},
"dependencies": {
"tui-code-snippet": "^1.2.5"
"tui-code-snippet": "^1.3.0"
}
}
33 changes: 33 additions & 0 deletions src/js/reader.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ var Flick = require('./flick');
var LongTab = require('./longtab');
var DoubleClick = require('./doubleClick');

var hostnameSent = false;

/**
* To find out it's flick or click or nothing from event datas.
* @class Reader
Expand All @@ -22,6 +24,7 @@ var DoubleClick = require('./doubleClick');
* @param {number} [options.flickRange] - (Flick) If not in time, compare move distance with flick ragne.
* @param {number} [options.longTabTerm] - (LongTab) Term for checking longtab
* @param {number} [options.minDist] - (Flick, LongTab) Minimum distance for check available movement.
* @param {boolean} [options.usageStatistics=true] - Let us know the hostname. If you don't want to send the hostname, please set to false.
* @example
* var GestureReader = tui.GestureReader; // or require('tui-gesture-reader');
* var instance = new GestureReader({
Expand All @@ -30,6 +33,10 @@ var DoubleClick = require('./doubleClick');
*/
var Reader = snippet.defineClass(/** @lends Reader.prototype */{
init: function(options) {
options = snippet.extend({
usageStatistics: true
}, options);

if (options.type === 'flick') {
snippet.extend(this, Flick);
} else if (options.type === 'longtab') {
Expand All @@ -38,7 +45,33 @@ var Reader = snippet.defineClass(/** @lends Reader.prototype */{
snippet.extend(this, DoubleClick);
}
this.initialize(options);

if (options.usageStatistics) {
sendHostname();
}
}
});

/**
* send hostname
* @ignore
*/
function sendHostname() {
var hostname = location.hostname;

if (hostnameSent) {
return;
}
hostnameSent = true;

snippet.imagePing('https://www.google-analytics.com/collect', {
v: 1,
t: 'event',
tid: 'UA-115377265-9',
cid: hostname,
dp: hostname,
dh: 'gesture-reader'
});
}

module.exports = Reader;
33 changes: 33 additions & 0 deletions test/reader.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
'use strict';

var Reader = require('../src/js/reader');
var snippet = require('tui-code-snippet');

describe('GestureReader Option', function() {
// hostnameSent module scope variable can not be reset.
// maintain cases with xit as it always fail, if you want to test these cases, change xit to fit one by one
describe('usageStatistics', function() {
var reader; // eslint-disable-line no-unused-vars

beforeEach(function() {
spyOn(snippet, 'imagePing');
});

xit('should send hostname by default', function() {
reader = new Reader({
type: 'dblclick'
});

expect(snippet.imagePing).toHaveBeenCalled();
});

xit('should not send hostname on usageStatistics option false', function() {
reader = new Reader({
type: 'dblclick',
usageStatistics: false
});

expect(snippet.imagePing).not.toHaveBeenCalled();
});
});
});

0 comments on commit 0cd31ce

Please sign in to comment.