hexo-theme-shokax 0.2.9 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. package/LICENSE +68 -81
  2. package/README.md +8 -6
  3. package/UsageRestrictions.md +21 -0
  4. package/_config.yml +9 -16
  5. package/layout/_mixin/comment.pug +2 -1
  6. package/layout/_mixin/widgets.pug +2 -1
  7. package/layout/_partials/layout.pug +8 -8
  8. package/layout/post.pug +2 -1
  9. package/package.json +8 -4
  10. package/scripts/generaters/script.js +33 -7
  11. package/scripts/plugin/check.js +30 -0
  12. package/scripts/plugin/index.js +5 -0
  13. package/source/css/_common/components/tags/tabs.styl +0 -2
  14. package/source/js/_app/{components.js → components/sidebar.js} +26 -27
  15. package/source/js/_app/fireworks.js +28 -42
  16. package/source/js/_app/globals/globalVars.js +26 -0
  17. package/source/js/_app/globals/handles.js +105 -0
  18. package/source/js/_app/globals/themeColor.js +48 -0
  19. package/source/js/_app/globals/thirdparty.js +60 -0
  20. package/source/js/_app/globals/tools.js +75 -0
  21. package/source/js/_app/library/anime.js +85 -0
  22. package/source/js/_app/library/dom.js +22 -0
  23. package/source/js/_app/library/loadFile.js +32 -0
  24. package/source/js/_app/library/proto.js +105 -0
  25. package/source/js/_app/library/scriptPjax.js +57 -0
  26. package/source/js/_app/library/storage.js +11 -0
  27. package/source/js/_app/{vue.js → library/vue.js} +6 -6
  28. package/source/js/_app/page/comment.js +19 -0
  29. package/source/js/_app/page/common.js +57 -0
  30. package/source/js/_app/page/fancybox.js +59 -0
  31. package/source/js/_app/page/post.js +232 -0
  32. package/source/js/_app/page/search.js +111 -0
  33. package/source/js/_app/page/tab.js +50 -0
  34. package/source/js/_app/pjax/domInit.js +68 -0
  35. package/source/js/_app/pjax/refresh.js +42 -0
  36. package/source/js/_app/pjax/siteInit.js +34 -0
  37. package/source/js/_app/player.js +87 -91
  38. package/source/js/_app/global.js +0 -314
  39. package/source/js/_app/library.js +0 -312
  40. package/source/js/_app/page.js +0 -674
@@ -1,4 +1,4 @@
1
- const sideBarToggleHandle = function (event, force) {
1
+ const sideBarToggleHandle = (event, force) => {
2
2
  if (sideBar.hasClass('on')) {
3
3
  sideBar.removeClass('on');
4
4
  menuToggle.removeClass('close');
@@ -14,25 +14,24 @@ const sideBarToggleHandle = function (event, force) {
14
14
  sideBar.style = '';
15
15
  }
16
16
  else {
17
- transition(sideBar, 'slideRightIn', function () {
17
+ transition(sideBar, 'slideRightIn', () => {
18
18
  sideBar.addClass('on');
19
19
  menuToggle.addClass('close');
20
20
  });
21
21
  }
22
22
  }
23
23
  };
24
- const sideBarTab = function () {
24
+ const sideBarTab = () => {
25
25
  const sideBarInner = sideBar.child('.inner');
26
- const panels = sideBar.find('.panel');
27
26
  if (sideBar.child('.tab')) {
28
27
  sideBarInner.removeChild(sideBar.child('.tab'));
29
28
  }
30
29
  const list = document.createElement('ul');
31
30
  let active = 'active';
32
31
  list.className = 'tab';
33
- ['contents', 'related', 'overview'].forEach(function (item) {
32
+ ['contents', 'related', 'overview'].forEach((item) => {
34
33
  const element = sideBar.child('.panel.' + item);
35
- if (element.innerHTML.replace(/(^\s*)|(\s*$)/g, '').length < 1) {
34
+ if (element.innerHTML.trim().length < 1) {
36
35
  if (item === 'contents') {
37
36
  showContents.display('none');
38
37
  }
@@ -54,14 +53,14 @@ const sideBarTab = function () {
54
53
  else {
55
54
  element.removeClass('active');
56
55
  }
57
- tab.addEventListener('click', function (event) {
56
+ tab.addEventListener('click', (event) => {
58
57
  const target = event.currentTarget;
59
58
  if (target.hasClass('active'))
60
59
  return;
61
- sideBar.find('.tab .item').forEach(function (element) {
60
+ sideBar.find('.tab .item').forEach((element) => {
62
61
  element.removeClass('active');
63
62
  });
64
- sideBar.find('.panel').forEach(function (element) {
63
+ sideBar.find('.panel').forEach((element) => {
65
64
  element.removeClass('active');
66
65
  });
67
66
  sideBar.child('.panel.' + target.className.replace(' item', '')).addClass('active');
@@ -78,18 +77,18 @@ const sideBarTab = function () {
78
77
  sideBar.child('.panels').style.paddingTop = '.625rem';
79
78
  }
80
79
  };
81
- const sidebarTOC = function () {
82
- const activateNavByIndex = function (index, lock) {
80
+ const sidebarTOC = () => {
81
+ const activateNavByIndex = (index) => {
83
82
  const target = navItems[index];
84
83
  if (!target)
85
84
  return;
86
85
  if (target.hasClass('current')) {
87
86
  return;
88
87
  }
89
- $dom.each('.toc .active', function (element) {
88
+ $dom.each('.toc .active', (element) => {
90
89
  element && element.removeClass('active current');
91
90
  });
92
- sections.forEach(function (element) {
91
+ sections.forEach((element) => {
93
92
  element && element.removeClass('active');
94
93
  });
95
94
  target.addClass('active current');
@@ -113,32 +112,32 @@ const sidebarTOC = function () {
113
112
  if (navItems.length < 1) {
114
113
  return;
115
114
  }
116
- let sections = Array.prototype.slice.call(navItems) || [];
115
+ let sections = [...navItems];
117
116
  let activeLock = null;
118
- sections = sections.map(function (element, index) {
117
+ sections = sections.map((element, index) => {
119
118
  const link = element.child('a.toc-link');
120
119
  const anchor = $dom(decodeURI(link.attr('href')));
121
120
  if (!anchor)
122
121
  return null;
123
122
  const alink = anchor.child('a.anchor');
124
- const anchorScroll = function (event) {
123
+ const anchorScroll = (event) => {
125
124
  event.preventDefault();
126
125
  const target = $dom(decodeURI(event.currentTarget.attr('href')));
127
126
  activeLock = index;
128
- pageScroll(target, null, function () {
127
+ pageScroll(target, null, () => {
129
128
  activateNavByIndex(index);
130
129
  activeLock = null;
131
130
  });
132
131
  };
133
132
  link.addEventListener('click', anchorScroll);
134
- alink && alink.addEventListener('click', function (event) {
133
+ alink && alink.addEventListener('click', (event) => {
135
134
  anchorScroll(event);
136
135
  clipBoard(CONFIG.hostname + '/' + LOCAL.path + event.currentTarget.attr('href'));
137
136
  });
138
137
  return anchor;
139
138
  });
140
139
  const tocElement = sideBar.child('.contents.panel');
141
- const findIndex = function (entries) {
140
+ const findIndex = (entries) => {
142
141
  let index = 0;
143
142
  let entry = entries[index];
144
143
  if (entry.boundingClientRect.top > 0) {
@@ -155,8 +154,8 @@ const sidebarTOC = function () {
155
154
  }
156
155
  return sections.indexOf(entry.target);
157
156
  };
158
- const createIntersectionObserver = function () {
159
- const observer = new IntersectionObserver(function (entries, observe) {
157
+ const createIntersectionObserver = () => {
158
+ const observer = new IntersectionObserver((entries) => {
160
159
  const index = findIndex(entries) + (diffY < 0 ? 1 : 0);
161
160
  if (activeLock === null) {
162
161
  activateNavByIndex(index);
@@ -164,23 +163,23 @@ const sidebarTOC = function () {
164
163
  }, {
165
164
  rootMargin: '0px 0px -100% 0px', threshold: 0
166
165
  });
167
- sections.forEach(function (element) {
166
+ sections.forEach((element) => {
168
167
  element && observer.observe(element);
169
168
  });
170
169
  };
171
170
  createIntersectionObserver();
172
171
  };
173
- const backToTopHandle = function () {
172
+ const backToTopHandle = () => {
174
173
  pageScroll(0);
175
174
  };
176
- const goToBottomHandle = function () {
175
+ const goToBottomHandle = () => {
177
176
  pageScroll(parseInt(String(Container.changeOrGetHeight())));
178
177
  };
179
- const goToCommentHandle = function () {
178
+ const goToCommentHandle = () => {
180
179
  pageScroll($dom('#comments'));
181
180
  };
182
- const menuActive = function () {
183
- $dom.each('.menu .item:not(.title)', function (element) {
181
+ const menuActive = () => {
182
+ $dom.each('.menu .item:not(.title)', (element) => {
184
183
  const target = element.child('a[href]');
185
184
  const parentItem = element.parentNode.parentNode;
186
185
  if (!target)
@@ -29,51 +29,41 @@ function setParticuleDirection(p) {
29
29
  }
30
30
  function createParticule(x, y) {
31
31
  const p = {
32
- x: undefined,
33
- y: undefined,
32
+ x,
33
+ y,
34
34
  color: undefined,
35
35
  radius: undefined,
36
36
  endPos: undefined,
37
- draw: undefined
37
+ draw() {
38
+ ctx.beginPath();
39
+ ctx.arc(p.x, p.y, p.radius, 0, 2 * Math.PI, true);
40
+ ctx.fillStyle = p.color;
41
+ ctx.fill();
42
+ }
38
43
  };
39
- p.x = x;
40
- p.y = y;
41
44
  p.color = colors[anime.random(0, colors.length - 1)];
42
45
  p.radius = anime.random(16, 32);
43
46
  p.endPos = setParticuleDirection(p);
44
- p.draw = function () {
45
- ctx.beginPath();
46
- ctx.arc(p.x, p.y, p.radius, 0, 2 * Math.PI, true);
47
- ctx.fillStyle = p.color;
48
- ctx.fill();
49
- };
50
47
  return p;
51
48
  }
52
49
  function createCircle(x, y) {
53
50
  const p = {
54
- x: undefined,
55
- y: undefined,
56
- color: undefined,
57
- radius: undefined,
51
+ x,
52
+ y,
53
+ color: '#FFF',
54
+ radius: 0.1,
58
55
  endPos: undefined,
59
- alpha: undefined,
60
- lineWidth: undefined,
61
- draw: undefined
62
- };
63
- p.x = x;
64
- p.y = y;
65
- p.color = '#FFF';
66
- p.radius = 0.1;
67
- p.alpha = 0.5;
68
- p.lineWidth = 6;
69
- p.draw = function () {
70
- ctx.globalAlpha = p.alpha;
71
- ctx.beginPath();
72
- ctx.arc(p.x, p.y, p.radius, 0, 2 * Math.PI, true);
73
- ctx.lineWidth = p.lineWidth;
74
- ctx.strokeStyle = p.color;
75
- ctx.stroke();
76
- ctx.globalAlpha = 1;
56
+ alpha: 0.5,
57
+ lineWidth: 6,
58
+ draw() {
59
+ ctx.globalAlpha = p.alpha;
60
+ ctx.beginPath();
61
+ ctx.arc(p.x, p.y, p.radius, 0, 2 * Math.PI, true);
62
+ ctx.lineWidth = p.lineWidth;
63
+ ctx.strokeStyle = p.color;
64
+ ctx.stroke();
65
+ ctx.globalAlpha = 1;
66
+ }
77
67
  };
78
68
  return p;
79
69
  }
@@ -93,12 +83,8 @@ function animateParticules(x, y) {
93
83
  duration: anime.random(1200, 1800),
94
84
  easing: 'easeOutExpo',
95
85
  update: renderParticule,
96
- x: function (p) {
97
- return p.endPos.x;
98
- },
99
- y: function (p) {
100
- return p.endPos.y;
101
- },
86
+ x: p => p.endPos.x,
87
+ y: p => p.endPos.y,
102
88
  radius: 0.1
103
89
  }).add({
104
90
  targets: circle,
@@ -116,11 +102,11 @@ function animateParticules(x, y) {
116
102
  }
117
103
  const render = anime({
118
104
  duration: Infinity,
119
- update: function () {
105
+ update() {
120
106
  ctx.clearRect(0, 0, canvasEl.width, canvasEl.height);
121
107
  }
122
108
  });
123
- const hasAncestor = function (node, name) {
109
+ const hasAncestor = (node, name) => {
124
110
  name = name.toUpperCase();
125
111
  do {
126
112
  if (node === null || node === undefined)
@@ -130,7 +116,7 @@ const hasAncestor = function (node, name) {
130
116
  } while ((node = node.parentNode) !== null);
131
117
  return false;
132
118
  };
133
- document.addEventListener(tap, function (e) {
119
+ document.addEventListener(tap, (e) => {
134
120
  if (hasAncestor(e.target, 'a')) {
135
121
  return;
136
122
  }
@@ -0,0 +1,26 @@
1
+ const statics = CONFIG.statics.indexOf('//') > 0 ? CONFIG.statics : CONFIG.root;
2
+ const scrollAction = { x: 0, y: 0 };
3
+ let diffY = 0;
4
+ let originTitle, titleTime;
5
+ const BODY = document.getElementsByTagName('body')[0];
6
+ const HTML = document.documentElement;
7
+ const Container = $dom('#container');
8
+ const loadCat = $dom('#loading');
9
+ const siteNav = $dom('#nav');
10
+ const siteHeader = $dom('#header');
11
+ const menuToggle = siteNav.child('.toggle');
12
+ const quickBtn = $dom('#quick');
13
+ const sideBar = $dom('#sidebar');
14
+ const siteBrand = $dom('#brand');
15
+ let toolBtn = $dom('#tool');
16
+ let toolPlayer;
17
+ let backToTop;
18
+ let goToComment;
19
+ let showContents;
20
+ let siteSearch = $dom('#search');
21
+ let siteNavHeight, headerHightInner, headerHight;
22
+ let oWinHeight = window.innerHeight;
23
+ let oWinWidth = window.innerWidth;
24
+ let LOCAL_HASH = 0;
25
+ let LOCAL_URL = window.location.href;
26
+ let pjax;
@@ -0,0 +1,105 @@
1
+ const resizeHandle = (event) => {
2
+ siteNavHeight = siteNav.changeOrGetHeight();
3
+ headerHightInner = siteHeader.changeOrGetHeight();
4
+ headerHight = headerHightInner + $dom('#waves').changeOrGetHeight();
5
+ if (oWinWidth !== window.innerWidth) {
6
+ sideBarToggleHandle(null, 1);
7
+ }
8
+ oWinHeight = window.innerHeight;
9
+ oWinWidth = window.innerWidth;
10
+ };
11
+ const scrollHandle = (event) => {
12
+ const winHeight = window.innerHeight;
13
+ const docHeight = getDocHeight();
14
+ const contentVisibilityHeight = docHeight > winHeight ? docHeight - winHeight : document.body.scrollHeight - winHeight;
15
+ const SHOW = window.scrollY > headerHightInner;
16
+ const startScroll = window.scrollY > 0;
17
+ if (SHOW) {
18
+ changeMetaTheme('#FFF');
19
+ }
20
+ else {
21
+ changeMetaTheme('#222');
22
+ }
23
+ siteNav.toggleClass('show', SHOW);
24
+ toolBtn.toggleClass('affix', startScroll);
25
+ siteBrand.toggleClass('affix', startScroll);
26
+ sideBar.toggleClass('affix', window.scrollY > headerHight && document.body.offsetWidth > 991);
27
+ if (typeof scrollAction.y === 'undefined') {
28
+ scrollAction.y = window.scrollY;
29
+ }
30
+ diffY = scrollAction.y - window.scrollY;
31
+ if (diffY < 0) {
32
+ siteNav.removeClass('up');
33
+ siteNav.toggleClass('down', SHOW);
34
+ }
35
+ else if (diffY > 0) {
36
+ siteNav.removeClass('down');
37
+ siteNav.toggleClass('up', SHOW);
38
+ }
39
+ else { }
40
+ scrollAction.y = window.scrollY;
41
+ const scrollPercent = Math.round(Math.min(100 * window.scrollY / contentVisibilityHeight, 100)) + '%';
42
+ if (backToTop.child('span').innerText !== scrollPercent) {
43
+ backToTop.child('span').innerText = scrollPercent;
44
+ }
45
+ if ($dom('#sidebar').hasClass('affix') || $dom('#sidebar').hasClass('on')) {
46
+ $dom('.percent').changeOrGetWidth(scrollPercent);
47
+ }
48
+ };
49
+ const clickMenu = () => {
50
+ const menuElement = $dom('#clickMenu');
51
+ window.oncontextmenu = function (event) {
52
+ if (event.ctrlKey) {
53
+ return;
54
+ }
55
+ event.preventDefault();
56
+ let x = event.offsetX;
57
+ let y = event.offsetY;
58
+ const winWidth = window.innerWidth;
59
+ const winHeight = window.innerHeight;
60
+ const menuWidth = menuElement.offsetWidth;
61
+ const menuHeight = menuElement.offsetHeight;
62
+ x = winWidth - menuWidth >= x ? x : winWidth - menuWidth;
63
+ y = winHeight - menuHeight >= y ? y : winHeight - menuHeight;
64
+ menuElement.style.top = y + 'px';
65
+ menuElement.style.left = x + 'px';
66
+ menuElement.classList.add('active');
67
+ $dom.each('.clickSubmenu', (submenu) => {
68
+ if (x > (winWidth - menuWidth - submenu.offsetWidth)) {
69
+ submenu.style.left = '-200px';
70
+ }
71
+ else {
72
+ submenu.style.left = '';
73
+ submenu.style.right = '-200px';
74
+ }
75
+ });
76
+ };
77
+ window.addEventListener('click', () => {
78
+ menuElement.classList.remove('active');
79
+ });
80
+ };
81
+ const visibilityListener = () => {
82
+ const iconNode = $dom('[rel="icon"]');
83
+ document.addEventListener('visibilitychange', () => {
84
+ switch (document.visibilityState) {
85
+ case 'hidden':
86
+ iconNode.attr('href', statics + CONFIG.favicon.hidden);
87
+ document.title = LOCAL.favicon.hide;
88
+ if (CONFIG.loader.switch) {
89
+ Loader.show();
90
+ }
91
+ clearTimeout(titleTime);
92
+ break;
93
+ case 'visible':
94
+ iconNode.attr('href', statics + CONFIG.favicon.normal);
95
+ document.title = LOCAL.favicon.show;
96
+ if (CONFIG.loader.switch) {
97
+ Loader.hide(1000);
98
+ }
99
+ titleTime = setTimeout(() => {
100
+ document.title = originTitle;
101
+ }, 2000);
102
+ break;
103
+ }
104
+ });
105
+ };
@@ -0,0 +1,48 @@
1
+ const changeTheme = (type) => {
2
+ const btn = $dom('.theme .ic');
3
+ if (type === 'dark') {
4
+ HTML.attr('data-theme', type);
5
+ btn.removeClass('i-sun');
6
+ btn.addClass('i-moon');
7
+ }
8
+ else {
9
+ HTML.attr('data-theme', null);
10
+ btn.removeClass('i-moon');
11
+ btn.addClass('i-sun');
12
+ }
13
+ };
14
+ const autoDarkmode = () => {
15
+ if (CONFIG.auto_dark.enable) {
16
+ if (new Date().getHours() >= CONFIG.auto_dark.start || new Date().getHours() <= CONFIG.auto_dark.end) {
17
+ changeTheme('dark');
18
+ }
19
+ else {
20
+ changeTheme();
21
+ }
22
+ }
23
+ };
24
+ const changeMetaTheme = (color) => {
25
+ if (HTML.attr('data-theme') === 'dark') {
26
+ color = '#222';
27
+ }
28
+ $dom('meta[name="theme-color"]').attr('content', color);
29
+ };
30
+ const themeColorListener = () => {
31
+ window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', (mediaQueryList) => {
32
+ if (mediaQueryList.matches) {
33
+ changeTheme('dark');
34
+ }
35
+ else {
36
+ changeTheme();
37
+ }
38
+ });
39
+ const t = $storage.get('theme');
40
+ if (t) {
41
+ changeTheme(t);
42
+ }
43
+ else {
44
+ if (CONFIG.darkmode) {
45
+ changeTheme('dark');
46
+ }
47
+ }
48
+ };
@@ -0,0 +1,60 @@
1
+ const lazyload = lozad('img, [data-background-image]', {
2
+ loaded(el) {
3
+ el.addClass('lozaded');
4
+ }
5
+ });
6
+ const Loader = {
7
+ timer: undefined,
8
+ lock: false,
9
+ show() {
10
+ clearTimeout(this.timer);
11
+ document.body.removeClass('loaded');
12
+ loadCat.attr('style', 'display:block');
13
+ Loader.lock = false;
14
+ },
15
+ hide(sec) {
16
+ if (!CONFIG.loader.start) {
17
+ sec = -1;
18
+ }
19
+ this.timer = setTimeout(this.vanish, sec || 3000);
20
+ },
21
+ vanish() {
22
+ if (Loader.lock) {
23
+ return;
24
+ }
25
+ if (CONFIG.loader.start) {
26
+ transition(loadCat, 0);
27
+ }
28
+ document.body.addClass('loaded');
29
+ Loader.lock = true;
30
+ }
31
+ };
32
+ const isOutime = () => {
33
+ let updateTime;
34
+ if (CONFIG.outime.enable && LOCAL.outime) {
35
+ const times = document.getElementsByTagName('time');
36
+ if (times.length === 0) {
37
+ return;
38
+ }
39
+ const posts = document.getElementsByClassName('body md');
40
+ if (posts.length === 0) {
41
+ return;
42
+ }
43
+ const now = Date.now();
44
+ const pubTime = new Date(times[0].dateTime);
45
+ if (times.length === 1) {
46
+ updateTime = pubTime;
47
+ }
48
+ else {
49
+ updateTime = new Date(times[1].dateTime);
50
+ }
51
+ const interval = parseInt(String(now - updateTime));
52
+ const days = parseInt(String(CONFIG.outime.days)) || 30;
53
+ if (interval > (days * 86400000)) {
54
+ const publish = parseInt(String((now - pubTime) / 86400000));
55
+ const updated = parseInt(String(interval / 86400000));
56
+ const template = LOCAL.template.replace('{{publish}}', String(publish)).replace('{{updated}}', String(updated));
57
+ posts[0].insertAdjacentHTML('afterbegin', template);
58
+ }
59
+ }
60
+ };
@@ -0,0 +1,75 @@
1
+ const showtip = (msg) => {
2
+ if (!msg) {
3
+ return;
4
+ }
5
+ const tipbox = BODY.createChild('div', {
6
+ innerHTML: msg,
7
+ className: 'tip'
8
+ });
9
+ setTimeout(() => {
10
+ tipbox.addClass('hide');
11
+ setTimeout(() => {
12
+ BODY.removeChild(tipbox);
13
+ }, 300);
14
+ }, 3000);
15
+ };
16
+ const pagePosition = () => {
17
+ if (CONFIG.auto_scroll) {
18
+ $storage.set(LOCAL_URL, String(scrollAction.y));
19
+ }
20
+ };
21
+ const positionInit = (comment) => {
22
+ const anchor = window.location.hash;
23
+ let target = null;
24
+ if (LOCAL_HASH) {
25
+ $storage.del(LOCAL_URL);
26
+ return;
27
+ }
28
+ if (anchor) {
29
+ target = $dom(decodeURI(anchor));
30
+ }
31
+ else {
32
+ target = CONFIG.auto_scroll ? parseInt($storage.get(LOCAL_URL)) : 0;
33
+ }
34
+ if (target) {
35
+ pageScroll(target);
36
+ LOCAL_HASH = 1;
37
+ }
38
+ if (comment && anchor && !LOCAL_HASH) {
39
+ pageScroll(target);
40
+ LOCAL_HASH = 1;
41
+ }
42
+ };
43
+ const clipBoard = (str, callback) => {
44
+ if (navigator.clipboard && window.isSecureContext) {
45
+ navigator.clipboard.writeText(str).then(() => {
46
+ callback && callback(true);
47
+ }, () => {
48
+ callback && callback(false);
49
+ });
50
+ }
51
+ else {
52
+ const ta = BODY.createChild('textarea', {
53
+ style: {
54
+ top: window.scrollY + 'px',
55
+ position: 'absolute',
56
+ opacity: '0'
57
+ },
58
+ readOnly: true,
59
+ value: str
60
+ });
61
+ const selection = document.getSelection();
62
+ const selected = selection.rangeCount > 0 ? selection.getRangeAt(0) : false;
63
+ ta.select();
64
+ ta.setSelectionRange(0, str.length);
65
+ ta.readOnly = false;
66
+ const result = document.execCommand('copy');
67
+ callback && callback(result);
68
+ ta.blur();
69
+ if (selected) {
70
+ selection.removeAllRanges();
71
+ selection.addRange(selected);
72
+ }
73
+ BODY.removeChild(ta);
74
+ }
75
+ };
@@ -0,0 +1,85 @@
1
+ const transition = (target, type, complete, begin) => {
2
+ let animation;
3
+ let display = 'none';
4
+ switch (type) {
5
+ case 0:
6
+ animation = { opacity: [1, 0] };
7
+ break;
8
+ case 1:
9
+ animation = { opacity: [0, 1] };
10
+ display = 'block';
11
+ break;
12
+ case 'bounceUpIn':
13
+ animation = {
14
+ begin(anim) {
15
+ target.display('block');
16
+ },
17
+ translateY: [
18
+ { value: -60, duration: 200 },
19
+ { value: 10, duration: 200 },
20
+ { value: -5, duration: 200 },
21
+ { value: 0, duration: 200 }
22
+ ],
23
+ opacity: [0, 1]
24
+ };
25
+ display = 'block';
26
+ break;
27
+ case 'shrinkIn':
28
+ animation = {
29
+ begin(anim) {
30
+ target.display('block');
31
+ },
32
+ scale: [
33
+ { value: 1.1, duration: 300 },
34
+ { value: 1, duration: 200 }
35
+ ],
36
+ opacity: 1
37
+ };
38
+ display = 'block';
39
+ break;
40
+ case 'slideRightIn':
41
+ animation = {
42
+ begin(anim) {
43
+ target.display('block');
44
+ },
45
+ translateX: ['100%', '0%'],
46
+ opacity: [0, 1]
47
+ };
48
+ display = 'block';
49
+ break;
50
+ case 'slideRightOut':
51
+ animation = {
52
+ translateX: ['0%', '100%'],
53
+ opacity: [1, 0]
54
+ };
55
+ break;
56
+ default:
57
+ animation = type;
58
+ display = type.display;
59
+ break;
60
+ }
61
+ anime(Object.assign({
62
+ targets: target,
63
+ duration: 200,
64
+ easing: 'linear',
65
+ begin() {
66
+ begin && begin();
67
+ },
68
+ complete() {
69
+ target.display(display);
70
+ complete && complete();
71
+ }
72
+ }, animation)).play();
73
+ };
74
+ const pageScroll = (target, offset, complete) => {
75
+ const opt = {
76
+ targets: typeof offset === 'number' ? target.parentNode : document.scrollingElement,
77
+ duration: 500,
78
+ easing: 'easeInOutQuad',
79
+ scrollTop: offset || (typeof target === 'number' ? target : (target ? target.getTop() + document.documentElement.scrollTop - siteNavHeight : 0)),
80
+ complete() {
81
+ complete && complete();
82
+ }
83
+ };
84
+ anime(opt).play();
85
+ };