Skip to content

Commit 195c251

Browse files
committed
Merge branch 'master' into production
2 parents 60e3d67 + 6fe19a8 commit 195c251

7 files changed

+128
-88
lines changed

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License
22

3-
Copyright (c) 2018 NHN Entertainment Corp.
3+
Copyright (c) 2018 NHN Corp.
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
It includes several features like `class simulation`, `browser detecting`, `type checking` and +30 more.
66

7-
`tui-code-snippet` supports IE8+ and modern browsers and already has been used for [open source javascript components](http://github.com/nhnent/) and many commercial projects in [NHN](http://www.nhn.com) corporation.
7+
`tui-code-snippet` supports IE8+ and modern browsers and already has been used for [open source javascript components](http://github.com/nhn/) and many commercial projects in [NHN](http://www.nhn.com) corporation.
88

99
## Feature
1010
* browser.js
@@ -50,8 +50,8 @@ It includes several features like `class simulation`, `browser detecting`, `type
5050
* Support utils to define modules
5151

5252
## Documentation
53-
* API: [https://nhnent.github.io/tui.code-snippet/latest/](https://nhnent.github.io/tui.code-snippet/latest/)
54-
* Tutorial: [https://github.com/nhnent/fe.javascript/wiki/Toast-UI-CodeSnippet](https://github.com/nhnent/fe.javascript/wiki/Toast-UI-CodeSnippet)
53+
* API: [https://nhn.github.io/tui.code-snippet/latest/](https://nhn.github.io/tui.code-snippet/latest/)
54+
* Tutorial: [https://github.com/nhn/fe.javascript/wiki/Toast-UI-CodeSnippet](https://github.com/nhn/fe.javascript/wiki/Toast-UI-CodeSnippet)
5555

5656
## Tested Browsers
5757
* browser:
@@ -102,8 +102,8 @@ var util = tui.util;
102102
```
103103

104104
### Download
105-
* [Download bundle files from `dist` folder](https://github.com/nhnent/tui.code-snippet/tree/production/dist)
106-
* [Download all sources for each version](https://github.com/nhnent/tui.code-snippet/releases)
105+
* [Download bundle files from `dist` folder](https://github.com/nhn/tui.code-snippet/tree/production/dist)
106+
* [Download all sources for each version](https://github.com/nhn/tui.code-snippet/releases)
107107

108108
## License
109-
[MIT LICENSE](https://github.com/nhnent/tui.code-snippet/blob/master/LICENSE)
109+
[MIT LICENSE](https://github.com/nhn/tui.code-snippet/blob/master/LICENSE)

jsdoc.conf.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"url": "https://cloud.githubusercontent.com/assets/12269563/20029815/01133928-a39a-11e6-80f3-12500a91c755.png",
1313
"width": "150px",
1414
"height": "13px",
15-
"link": "https://github.com/nhnent/tui.jsdoc-template"
15+
"link": "https://github.com/nhn/tui.jsdoc-template"
1616
}
1717
},
1818
"opts": {

package-lock.json

+55-23
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "tui-code-snippet",
3-
"version": "1.5.1",
3+
"version": "1.5.2",
44
"description": "TOAST UI Utility: CodeSnippet",
55
"main": "dist/tui-code-snippet.js",
66
"scripts": {
@@ -12,15 +12,13 @@
1212
},
1313
"repository": {
1414
"type": "git",
15-
"url": "https://github.com/nhnent/tui.code-snippet.git"
15+
"url": "https://github.com/nhn/tui.code-snippet.git"
1616
},
1717
"keywords": [
1818
"nhn",
19-
"nhnent",
2019
"tui",
2120
"utility",
22-
"code-snippet",
23-
"nhn"
21+
"code-snippet"
2422
],
2523
"author": "NHN. FE Development Lab <dl_javascript@nhn.com>",
2624
"license": "MIT",
@@ -43,7 +41,7 @@
4341
"karma-junit-reporter": "^1.2.0",
4442
"karma-safari-launcher": "^1.0.0",
4543
"karma-sourcemap-loader": "^0.3.7",
46-
"karma-webdriver-launcher": "git+https://github.com/nhnent/karma-webdriver-launcher.git#v1.1.0",
44+
"karma-webdriver-launcher": "git+https://github.com/nhn/karma-webdriver-launcher.git#v1.1.0",
4745
"karma-webpack": "^2.0.3",
4846
"safe-umd-webpack-plugin": "0.0.2",
4947
"tui-jsdoc-template": "^1.0.4",

src/js/browser.js

+58-48
Original file line numberDiff line numberDiff line change
@@ -39,65 +39,75 @@ var browser = {
3939
version: 0
4040
};
4141

42-
var nav = window.navigator;
43-
var appName = nav.appName.replace(/\s/g, '_');
44-
var userAgent = nav.userAgent;
42+
if (window && window.navigator) {
43+
detectBrowser();
44+
}
4545

46-
var rIE = /MSIE\s([0-9]+[.0-9]*)/;
47-
var rIE11 = /Trident.*rv:11\./;
48-
var rEdge = /Edge\/(\d+)\./;
49-
var versionRegex = {
50-
firefox: /Firefox\/(\d+)\./,
51-
chrome: /Chrome\/(\d+)\./,
52-
safari: /Version\/([\d.]+).*Safari\/(\d+)/
53-
};
46+
/**
47+
* Detect the browser.
48+
* @private
49+
*/
50+
function detectBrowser() {
51+
var nav = window.navigator;
52+
var appName = nav.appName.replace(/\s/g, '_');
53+
var userAgent = nav.userAgent;
5454

55-
var key, tmp;
55+
var rIE = /MSIE\s([0-9]+[.0-9]*)/;
56+
var rIE11 = /Trident.*rv:11\./;
57+
var rEdge = /Edge\/(\d+)\./;
58+
var versionRegex = {
59+
firefox: /Firefox\/(\d+)\./,
60+
chrome: /Chrome\/(\d+)\./,
61+
safari: /Version\/([\d.]+).*Safari\/(\d+)/
62+
};
5663

57-
var detector = {
58-
Microsoft_Internet_Explorer: function() { // eslint-disable-line camelcase
59-
var detectedVersion = userAgent.match(rIE);
64+
var key, tmp;
6065

61-
if (detectedVersion) { // ie8 ~ ie10
62-
browser.msie = true;
63-
browser.version = parseFloat(detectedVersion[1]);
64-
} else { // no version information
65-
browser.others = true;
66-
}
67-
},
68-
Netscape: function() { // eslint-disable-line complexity
69-
var detected = false;
66+
var detector = {
67+
Microsoft_Internet_Explorer: function() { // eslint-disable-line camelcase
68+
var detectedVersion = userAgent.match(rIE);
69+
70+
if (detectedVersion) { // ie8 ~ ie10
71+
browser.msie = true;
72+
browser.version = parseFloat(detectedVersion[1]);
73+
} else { // no version information
74+
browser.others = true;
75+
}
76+
},
77+
Netscape: function() { // eslint-disable-line complexity
78+
var detected = false;
7079

71-
if (rIE11.exec(userAgent)) {
72-
browser.msie = true;
73-
browser.version = 11;
74-
detected = true;
75-
} else if (rEdge.exec(userAgent)) {
76-
browser.edge = true;
77-
browser.version = userAgent.match(rEdge)[1];
78-
detected = true;
79-
} else {
80-
for (key in versionRegex) {
81-
if (versionRegex.hasOwnProperty(key)) {
82-
tmp = userAgent.match(versionRegex[key]);
83-
if (tmp && tmp.length > 1) { // eslint-disable-line max-depth
84-
browser[key] = detected = true;
85-
browser.version = parseFloat(tmp[1] || 0);
86-
break;
80+
if (rIE11.exec(userAgent)) {
81+
browser.msie = true;
82+
browser.version = 11;
83+
detected = true;
84+
} else if (rEdge.exec(userAgent)) {
85+
browser.edge = true;
86+
browser.version = userAgent.match(rEdge)[1];
87+
detected = true;
88+
} else {
89+
for (key in versionRegex) {
90+
if (versionRegex.hasOwnProperty(key)) {
91+
tmp = userAgent.match(versionRegex[key]);
92+
if (tmp && tmp.length > 1) { // eslint-disable-line max-depth
93+
browser[key] = detected = true;
94+
browser.version = parseFloat(tmp[1] || 0);
95+
break;
96+
}
8797
}
8898
}
8999
}
100+
if (!detected) {
101+
browser.others = true;
102+
}
90103
}
91-
if (!detected) {
92-
browser.others = true;
93-
}
94-
}
95-
};
104+
};
96105

97-
var fn = detector[appName];
106+
var fn = detector[appName];
98107

99-
if (fn) {
100-
detector[appName]();
108+
if (fn) {
109+
detector[appName]();
110+
}
101111
}
102112

103113
module.exports = browser;

test/defineNamespace.test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,16 @@ describe('defineNamespace', function() {
4141
});
4242

4343
it('for class', function() {
44-
var name = 'Nhnent';
44+
var name = 'nhn';
4545
var mInstance;
4646

47-
defineNamespace('asdf.Nhnent', function() {
47+
defineNamespace('asdf.nhn', function() {
4848
this.name = name;
4949
this.getName = function() {
5050
return this.name;
5151
};
5252
}, true);
53-
mInstance = new asdf.Nhnent();
53+
mInstance = new asdf.nhn();
5454

5555
expect(mInstance.getName()).toBe(name);
5656
});

0 commit comments

Comments
 (0)