j1-template 2021.1.10 → 2021.1.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/_includes/themes/j1/layouts/content_generator_app.html +1 -1
- data/_includes/themes/j1/layouts/content_generator_blog_archive.html +1 -1
- data/_includes/themes/j1/layouts/content_generator_collection.html +1 -1
- data/_includes/themes/j1/layouts/content_generator_page.html +4 -1
- data/_includes/themes/j1/layouts/content_generator_post.html +1 -1
- data/_includes/themes/j1/layouts/content_generator_raw.html +1 -1
- data/_includes/themes/j1/layouts/layout_metadata_generator.html +55 -0
- data/_includes/themes/j1/modules/connectors/comment/commento.html +31 -0
- data/_includes/themes/j1/modules/connectors/comment/custom-provider.html +7 -8
- data/_includes/themes/j1/modules/connectors/comment/disqus.html +12 -54
- data/_includes/themes/j1/modules/connectors/comment/facebook.html +7 -8
- data/_includes/themes/j1/modules/connectors/comment/hyvor.html +33 -0
- data/_includes/themes/j1/modules/connectors/comment/just-comments.html +31 -0
- data/_includes/themes/j1/modules/connectors/comments +3 -0
- data/_layouts/default.html +51 -0
- data/assets/data/disqus.js +81 -0
- data/assets/data/hyvor.js +72 -0
- data/assets/error_pages/HTTP204.html +4 -0
- data/assets/error_pages/HTTP400.html +4 -0
- data/assets/error_pages/HTTP401.html +4 -0
- data/assets/error_pages/HTTP403.html +4 -0
- data/assets/error_pages/HTTP404.html +4 -0
- data/assets/error_pages/HTTP444.html +93 -0
- data/assets/error_pages/HTTP500.html +4 -0
- data/assets/error_pages/HTTP501.html +4 -0
- data/assets/error_pages/HTTP502.html +4 -0
- data/assets/error_pages/HTTP503.html +4 -0
- data/assets/themes/j1/adapter/js/algolia.js +10 -10
- data/assets/themes/j1/adapter/js/asciidoctor.js +6 -6
- data/assets/themes/j1/adapter/js/attic.js +17 -17
- data/assets/themes/j1/adapter/js/bmd.js +6 -6
- data/assets/themes/j1/adapter/js/carousel.js +10 -10
- data/assets/themes/j1/adapter/js/clipboard.js +10 -10
- data/assets/themes/j1/adapter/js/cookieConsent.js +60 -41
- data/assets/themes/j1/adapter/js/fam.js +34 -34
- data/assets/themes/j1/adapter/js/framer.js +6 -6
- data/assets/themes/j1/adapter/js/j1.js +537 -237
- data/assets/themes/j1/adapter/js/justifiedGallery.js +11 -11
- data/assets/themes/j1/adapter/js/justifiedGalleryCustomizer.js +19 -19
- data/assets/themes/j1/adapter/js/lightbox.js +6 -6
- data/assets/themes/j1/adapter/js/logger.js +7 -7
- data/assets/themes/j1/adapter/js/mmenu.js +25 -25
- data/assets/themes/j1/adapter/js/navigator.js +58 -48
- data/assets/themes/j1/adapter/js/quicksearch.js +6 -6
- data/assets/themes/j1/adapter/js/rouge.js +7 -7
- data/assets/themes/j1/adapter/js/rtable.js +6 -6
- data/assets/themes/j1/adapter/js/themer.js +149 -96
- data/assets/themes/j1/adapter/js/toccer.js +9 -9
- data/assets/themes/j1/core/js/template.js +24 -4
- data/assets/themes/j1/core/js/template.js.map +1 -1
- data/assets/themes/j1/core/js/template.min.js +24 -4
- data/assets/themes/j1/core/js/template.min.js.map +1 -1
- data/assets/themes/j1/modules/backstretch/js/backstretch.js +3 -3
- data/assets/themes/j1/modules/cookieConsent/js/cookieConsent.js +35 -23
- data/assets/themes/j1/modules/cookieConsent/js/cookieConsent.min.js +2 -2
- data/assets/themes/j1/modules/lunrSearch/js/quicksearch.js +1 -1
- data/assets/themes/j1/modules/themeSwitcher/js/switcher.js +74 -55
- data/assets/themes/j1/modules/themeSwitcher/js/switcher.min.js +75 -57
- data/lib/j1/version.rb +1 -1
- data/lib/starter_web/Gemfile +1 -1
- data/lib/starter_web/_config.yml +42 -24
- data/lib/starter_web/_data/j1_config.yml +22 -11
- data/lib/starter_web/_data/modules/defaults/cookieconsent.yml +11 -9
- data/lib/starter_web/_data/modules/defaults/themer.yml +2 -0
- data/lib/starter_web/_data/resources.yml +0 -4
- data/lib/starter_web/_includes/attributes.asciidoc +1 -1
- data/lib/starter_web/_plugins/lunr_index.rb +1 -1
- data/lib/starter_web/assets/images/modules/attics/matthew-dockery-1920x1280.jpg +0 -0
- data/lib/starter_web/index.html +3 -3
- data/lib/starter_web/package.json +1 -1
- data/lib/starter_web/pages/public/asciidoc_skeletons/book/book.adoc +3 -0
- data/lib/starter_web/pages/public/asciidoc_skeletons/multi-document/multi.adoc +3 -0
- data/lib/starter_web/pages/public/asciidoc_skeletons/simple-document/simple.adoc +3 -0
- data/lib/starter_web/pages/public/blog/navigator/archive.html +4 -0
- data/lib/starter_web/pages/public/blog/navigator/archive/categoryview.html +4 -0
- data/lib/starter_web/pages/public/blog/navigator/archive/dateview.html +4 -0
- data/lib/starter_web/pages/public/blog/navigator/archive/tagview.html +5 -1
- data/lib/starter_web/pages/public/blog/navigator/index.html +4 -0
- data/lib/starter_web/pages/public/cookieConsent.adoc +3 -0
- data/lib/starter_web/pages/public/learn/quickstart.adoc +473 -0
- data/lib/starter_web/pages/public/learn/roundtrip/100_present_images.adoc +0 -1
- data/lib/starter_web/pages/public/learn/roundtrip/100_present_videos.adoc +2 -1
- data/lib/starter_web/pages/public/learn/roundtrip/200_typography.adoc +0 -2
- data/lib/starter_web/pages/public/learn/roundtrip/300_icon_fonts.adoc +0 -2
- data/lib/starter_web/pages/public/learn/roundtrip/400_asciidoc_extensions.adoc +0 -1
- data/lib/starter_web/pages/public/learn/roundtrip/410_bs_modals_extentions.adoc +0 -1
- data/lib/starter_web/pages/public/learn/roundtrip/420_responsive_tables_extensions.adoc +0 -1
- data/lib/starter_web/pages/public/learn/roundtrip/500_themes.adoc +0 -1
- data/lib/starter_web/pages/public/learn/roundtrip/600_quicksearch.adoc +0 -1
- data/lib/starter_web/pages/public/learn/where_to_go.adoc +0 -1
- data/lib/starter_web/pages/public/legal/en/100_copyright.adoc +3 -1
- data/lib/starter_web/pages/public/legal/en/200_impress.adoc +3 -1
- data/lib/starter_web/pages/public/legal/en/300_privacy.adoc +81 -20
- data/lib/starter_web/pages/public/legal/en/400_comment_policy.adoc +34 -16
- data/lib/starter_web/utilsrv/_defaults/package.json +1 -1
- data/lib/starter_web/utilsrv/package.json +1 -1
- metadata +10 -8
- data/assets/themes/j1/adapter/js/themer.1.js +0 -326
- data/assets/themes/j1/modules/util/js/js.cookie.js +0 -163
- data/assets/themes/j1/modules/util/js/lite-url.js +0 -203
- data/assets/themes/j1/modules/util/js/lite-url.min.js +0 -7
- data/assets/themes/j1/modules/util/js/platform.js +0 -1260
- data/lib/starter_web/pages/public/learn/roundtrip/100_present_images.org.asciidoc +0 -244
@@ -1,326 +0,0 @@
|
|
1
|
-
---
|
2
|
-
regenerate: true
|
3
|
-
---
|
4
|
-
|
5
|
-
{% capture cache %}
|
6
|
-
|
7
|
-
{% comment %}
|
8
|
-
# -----------------------------------------------------------------------------
|
9
|
-
# ~/assets/themes/j1/adapter/js/themer.js
|
10
|
-
# Liquid template to adapt theme functions
|
11
|
-
#
|
12
|
-
# Product/Info:
|
13
|
-
# https://jekyll.one
|
14
|
-
#
|
15
|
-
# Copyright (C) 2021 Juergen Adams
|
16
|
-
#
|
17
|
-
# J1 Template is licensed under the MIT License.
|
18
|
-
# For details, see https://jekyll.one
|
19
|
-
#
|
20
|
-
# -----------------------------------------------------------------------------
|
21
|
-
# Test data:
|
22
|
-
# {{config| debug }}
|
23
|
-
# -----------------------------------------------------------------------------
|
24
|
-
{% endcomment %}
|
25
|
-
|
26
|
-
{% comment %} Liquid procedures
|
27
|
-
-------------------------------------------------------------------------------- {% endcomment %}
|
28
|
-
|
29
|
-
{% comment %} Set global settings
|
30
|
-
-------------------------------------------------------------------------------- {% endcomment %}
|
31
|
-
{% assign environment = site.environment %}
|
32
|
-
{% assign template_version = site.version %}
|
33
|
-
{% assign asset_path = "/assets/themes/j1" %}
|
34
|
-
|
35
|
-
{% comment %} Process YML config data
|
36
|
-
================================================================================ {% endcomment %}
|
37
|
-
|
38
|
-
{% comment %} Set config files
|
39
|
-
-------------------------------------------------------------------------------- {% endcomment %}
|
40
|
-
{% assign template_config = site.data.j1_config %}
|
41
|
-
{% assign blocks = site.data.blocks %}
|
42
|
-
{% assign modules = site.data.modules %}
|
43
|
-
|
44
|
-
{% comment %} Set config data
|
45
|
-
-------------------------------------------------------------------------------- {% endcomment %}
|
46
|
-
{% assign themer_defaults = modules.defaults.themer.defaults %}
|
47
|
-
{% assign themer_settings = modules.themer.settings %}
|
48
|
-
|
49
|
-
{% comment %} Set config options
|
50
|
-
-------------------------------------------------------------------------------- {% endcomment %}
|
51
|
-
{% assign themer_options = themer_defaults| merge: themer_settings %}
|
52
|
-
{% assign default_theme = template_config.theme %}
|
53
|
-
{% assign theme_base = "core/css/themes" %}
|
54
|
-
|
55
|
-
{% if environment == "development" or environment == "test" %}
|
56
|
-
{% assign theme_ext = "css" %}
|
57
|
-
{% else %}
|
58
|
-
{% assign theme_ext = "min.css" %}
|
59
|
-
{% endif %}
|
60
|
-
|
61
|
-
{% assign production = false %}
|
62
|
-
{% if environment == 'prod' or environment == 'production' %}
|
63
|
-
{% assign production = true %}
|
64
|
-
{% endif %}
|
65
|
-
|
66
|
-
/*
|
67
|
-
# -----------------------------------------------------------------------------
|
68
|
-
# ~/assets/themes/j1/adapter/js/themer.js
|
69
|
-
# JS Adapter for J1 themer (bootstrapThemeSwitcher)
|
70
|
-
#
|
71
|
-
# Product/Info:
|
72
|
-
# https://jekyll.one
|
73
|
-
# https://github.com/jguadagno/bootstrapThemeSwitcher
|
74
|
-
#
|
75
|
-
# Copyright (C) 2021 Juergen Adams
|
76
|
-
# Copyright (C) 2014 Joseph Guadagno
|
77
|
-
#
|
78
|
-
# J1 Template is licensed under the MIT License.
|
79
|
-
# For details, see https://jekyll.one
|
80
|
-
# bootstrapThemeSwitcher is licensed under the MIT License.
|
81
|
-
# For details, see https://github.com/jguadagno/bootstrapThemeSwitcher/blob/master/LICENSE
|
82
|
-
# -----------------------------------------------------------------------------
|
83
|
-
# NOTE:
|
84
|
-
# Setup of theme loaders for local_themes|remote_themes moved
|
85
|
-
# to adapter navigator.js
|
86
|
-
# -----------------------------------------------------------------------------
|
87
|
-
# Adapter generated: {{site.time}}
|
88
|
-
# -----------------------------------------------------------------------------
|
89
|
-
*/
|
90
|
-
|
91
|
-
// -----------------------------------------------------------------------------
|
92
|
-
// ESLint shimming
|
93
|
-
// -----------------------------------------------------------------------------
|
94
|
-
/* eslint indent: "off" */
|
95
|
-
/* eslint quotes: "off" */
|
96
|
-
// -----------------------------------------------------------------------------
|
97
|
-
|
98
|
-
'use strict';
|
99
|
-
|
100
|
-
j1.adapter['themer'] = (function (j1, window) {
|
101
|
-
// ---------------------------------------------------------------------------
|
102
|
-
// globals
|
103
|
-
// ---------------------------------------------------------------------------
|
104
|
-
var environment = '{{environment}}';
|
105
|
-
var themerOptions = $.extend({}, {{themer_options | replace: '=>', ':' | replace: 'nil', '""' }});
|
106
|
-
var user_state = {};
|
107
|
-
var user_consent = {};
|
108
|
-
var cookie_names = j1.getCookieNames();
|
109
|
-
var user_state_detected = false;
|
110
|
-
var styleLoaded = false;
|
111
|
-
var id = 'default';
|
112
|
-
var user_state_cookie;
|
113
|
-
var theme_css_html;
|
114
|
-
var _this;
|
115
|
-
var logger;
|
116
|
-
var logText;
|
117
|
-
|
118
|
-
var cssExtension = (environment === 'production')
|
119
|
-
? '.min.css'
|
120
|
-
: '.css';
|
121
|
-
|
122
|
-
var default_theme_name = '{{default_theme.name}}';
|
123
|
-
var default_theme_author = '{{default_theme.author}}';
|
124
|
-
var default_theme_author_url = '{{default_theme.author_url}}';
|
125
|
-
var default_theme_css_name = default_theme_name.toLowerCase().replace(' ', '-');
|
126
|
-
var default_theme_css = '{{asset_path}}/{{theme_base}}/' + default_theme_css_name + '/bootstrap' + cssExtension;
|
127
|
-
|
128
|
-
// ---------------------------------------------------------------------------
|
129
|
-
// helper functions
|
130
|
-
// ---------------------------------------------------------------------------
|
131
|
-
|
132
|
-
function styleSheetLoaded(styleSheet) {
|
133
|
-
var sheets = document.styleSheets, stylesheet = sheets[(sheets.length - 1)];
|
134
|
-
|
135
|
-
// find CSS file 'styleSheetName' in document
|
136
|
-
for(var i in document.styleSheets) {
|
137
|
-
if(sheets[i].href && sheets[i].href.indexOf(styleSheet) > -1) {
|
138
|
-
return true;
|
139
|
-
}
|
140
|
-
}
|
141
|
-
return false;
|
142
|
-
}
|
143
|
-
|
144
|
-
// ---------------------------------------------------------------------------
|
145
|
-
// Main object
|
146
|
-
// ---------------------------------------------------------------------------
|
147
|
-
return {
|
148
|
-
// -------------------------------------------------------------------------
|
149
|
-
// initializer
|
150
|
-
// -------------------------------------------------------------------------
|
151
|
-
init: function () {
|
152
|
-
// -----------------------------------------------------------------------
|
153
|
-
// globals
|
154
|
-
// -----------------------------------------------------------------------
|
155
|
-
_this = j1.adapter.themer;
|
156
|
-
logger = log4javascript.getLogger('j1.adapter.themer');
|
157
|
-
|
158
|
-
// initialize state flag
|
159
|
-
_this.state = 'started';
|
160
|
-
logger.info('state: ' + _this.getState());
|
161
|
-
|
162
|
-
// detect|set user state cookie
|
163
|
-
user_state_detected = j1.existsCookie(cookie_names.user_state);
|
164
|
-
if (user_state_detected) {
|
165
|
-
user_state = j1.readCookie(cookie_names.user_state);
|
166
|
-
user_consent = j1.readCookie(cookie_names.user_consent);
|
167
|
-
}
|
168
|
-
|
169
|
-
// initial theme data
|
170
|
-
if (user_state.theme_css === '') {
|
171
|
-
user_state.theme_name = default_theme_name;
|
172
|
-
user_state.theme_css = default_theme_css;
|
173
|
-
user_state.theme_author = default_theme_author;
|
174
|
-
user_state.theme_author_url = default_theme_author_url;
|
175
|
-
}
|
176
|
-
|
177
|
-
styleLoaded = styleSheetLoaded(user_state.theme_css);
|
178
|
-
theme_css_html = '<link rel="stylesheet" id="' + id + '" href="' + user_state.theme_css + '" type="text/css" />';
|
179
|
-
|
180
|
-
// skip loading theme UNO css file except NOT loaded
|
181
|
-
if (!user_state.theme_name.includes('Uno') || !styleLoaded) {
|
182
|
-
$('head').append(theme_css_html);
|
183
|
-
}
|
184
|
-
|
185
|
-
// store if theme_switcher is enabled
|
186
|
-
user_state.theme_switcher = themerOptions.enabled;
|
187
|
-
|
188
|
-
if (!user_consent.analyses || !user_consent.personalization) {
|
189
|
-
// expire state cookie to session
|
190
|
-
j1.writeCookie({
|
191
|
-
name: cookie_names.user_state,
|
192
|
-
data: user_state,
|
193
|
-
samesite: 'Strict'
|
194
|
-
});
|
195
|
-
} else {
|
196
|
-
j1.writeCookie({
|
197
|
-
name: cookie_names.user_state,
|
198
|
-
data: user_state,
|
199
|
-
samesite: 'Strict',
|
200
|
-
expires: 365
|
201
|
-
});
|
202
|
-
}
|
203
|
-
|
204
|
-
// jadams, 2021-01-03: dependency has to be checked in more detail
|
205
|
-
var dependencies_met_j1_finished = setInterval (function () {
|
206
|
-
if (j1.getState() == 'finished') {
|
207
|
-
if (themerOptions.enabled) {
|
208
|
-
// enable BS ThemeSwitcher
|
209
|
-
logger.info('themes detected as: enabled');
|
210
|
-
logger.info('theme is being initialized: ' + user_state.theme_name);
|
211
|
-
|
212
|
-
// jadams, 2021-02-22: make sure that remote themes are loaded
|
213
|
-
// max retries = max_count
|
214
|
-
|
215
|
-
// load list of remote themes
|
216
|
-
//
|
217
|
-
if ( $('#remote_themes').length ) {
|
218
|
-
var themes_count;
|
219
|
-
var interval_count = 0;
|
220
|
-
var max_count = themerOptions.retries;
|
221
|
-
|
222
|
-
/* eslint-disable */
|
223
|
-
// initialize Bootswatch Theme Switcher
|
224
|
-
$('#remote_themes').bootstrapThemeSwitcher.defaults = {
|
225
|
-
debug: themerOptions.debug,
|
226
|
-
saveToCookie: themerOptions.saveToCookie,
|
227
|
-
cssThemeLink: themerOptions.cssThemeLink,
|
228
|
-
cookieThemeName: themerOptions.cookieThemeName,
|
229
|
-
cookieDefaultThemeName: themerOptions.cookieDefaultThemeName,
|
230
|
-
cookieThemeCss: themerOptions.cookieThemeCss,
|
231
|
-
cookieThemeExtensionCss: themerOptions.cookieThemeExtensionCss,
|
232
|
-
cookieExpiration: themerOptions.cookieExpiration,
|
233
|
-
cookiePath: themerOptions.cookiePath,
|
234
|
-
defaultCssFile: themerOptions.defaultCssFile,
|
235
|
-
bootswatchApiUrl: themerOptions.bootswatchApiUrl,
|
236
|
-
bootswatchApiVersion: themerOptions.bootswatchApiVersion,
|
237
|
-
loadFromBootswatch: themerOptions.loadFromBootswatch,
|
238
|
-
localFeed: themerOptions.localThemes,
|
239
|
-
excludeBootswatch: themerOptions.excludeBootswatch,
|
240
|
-
includeBootswatch: themerOptions.includeBootswatch,
|
241
|
-
skipIncludeBootswatch: themerOptions.skipIncludeBootswatch
|
242
|
-
}
|
243
|
-
/* eslint-enable */
|
244
|
-
|
245
|
-
// var dependencies_met_remote_themes_loaded = setInterval(function() {
|
246
|
-
// interval_count += 1;
|
247
|
-
// themes_count = document.getElementById("remote_themes").getElementsByTagName("li").length;
|
248
|
-
// if ( themes_count > 0 ) {
|
249
|
-
// logger.info('remote themes loaded: successfully');
|
250
|
-
// logger.info('remote themes loaded: successfully after: ' + interval_count * 25 + ' ms');
|
251
|
-
//
|
252
|
-
// clearInterval(dependencies_met_remote_themes_loaded);
|
253
|
-
// } else {
|
254
|
-
// logger.debug('wait for theme to be loaded: ' + user_state.theme_name);
|
255
|
-
// }
|
256
|
-
// if (interval_count > max_count) {
|
257
|
-
// logger.warn('remote themes loading: failed');
|
258
|
-
// logger.warn('continue processing');
|
259
|
-
// clearInterval(dependencies_met_remote_themes_loaded);
|
260
|
-
// }
|
261
|
-
// }, 25);
|
262
|
-
|
263
|
-
logger.info('theme loaded: ' + user_state.theme_name);
|
264
|
-
logger.info('theme css file: ' + user_state.theme_css);
|
265
|
-
_this.setState('finished');
|
266
|
-
logger.info('state: ' + _this.getState());
|
267
|
-
logger.info('module initialized successfully');
|
268
|
-
logger.info('met dependencies for: j1.adapter');
|
269
|
-
}
|
270
|
-
} else {
|
271
|
-
_this.setState('finished');
|
272
|
-
logger.info('state: ' + _this.getState());
|
273
|
-
logger.info('themes detected as: disabled');
|
274
|
-
}
|
275
|
-
clearInterval(dependencies_met_j1_finished);
|
276
|
-
}
|
277
|
-
}, 25); // END 'dependencies_met_j1_finished'
|
278
|
-
}, // END init
|
279
|
-
|
280
|
-
// -------------------------------------------------------------------------
|
281
|
-
// messageHandler
|
282
|
-
// Manage messages send from other J1 modules
|
283
|
-
// -------------------------------------------------------------------------
|
284
|
-
messageHandler: function (sender, message) {
|
285
|
-
var json_message = JSON.stringify(message, undefined, 2);
|
286
|
-
|
287
|
-
logText = 'received message from ' + sender + ': ' + json_message;
|
288
|
-
logger.info(logText);
|
289
|
-
|
290
|
-
// -----------------------------------------------------------------------
|
291
|
-
// Process commands|actions
|
292
|
-
// -----------------------------------------------------------------------
|
293
|
-
if (message.type === 'command' && message.action === 'module_initialized') {
|
294
|
-
logger.info(message.text);
|
295
|
-
//
|
296
|
-
// Place handling of other command|action here
|
297
|
-
//
|
298
|
-
}
|
299
|
-
}, // END messageHandler
|
300
|
-
|
301
|
-
// -------------------------------------------------------------------------
|
302
|
-
// setState()
|
303
|
-
// Sets the current (processing) state of the module
|
304
|
-
// -------------------------------------------------------------------------
|
305
|
-
setState: function (stat) {
|
306
|
-
_this.state = stat;
|
307
|
-
}, // END setState
|
308
|
-
|
309
|
-
// -------------------------------------------------------------------------
|
310
|
-
// getState()
|
311
|
-
// Returns the current (processing) state of the module
|
312
|
-
// -------------------------------------------------------------------------
|
313
|
-
getState: function () {
|
314
|
-
return _this.state;
|
315
|
-
} // END getState
|
316
|
-
|
317
|
-
}; // END return
|
318
|
-
})(j1, window);
|
319
|
-
|
320
|
-
{% endcapture %}
|
321
|
-
{% if production %}
|
322
|
-
{{cache| minifyJS }}
|
323
|
-
{% else %}
|
324
|
-
{{cache| strip_empty_lines }}
|
325
|
-
{% endif %}
|
326
|
-
{% assign cache = nil %}
|
@@ -1,163 +0,0 @@
|
|
1
|
-
/*!
|
2
|
-
* JavaScript Cookie v2.2.1
|
3
|
-
* https://github.com/js-cookie/js-cookie
|
4
|
-
*
|
5
|
-
* Copyright 2006 - 2019 Klaus Hartl & Fagner Brack
|
6
|
-
* Released under the MIT license
|
7
|
-
*/
|
8
|
-
;(function (factory) {
|
9
|
-
var registeredInModuleLoader;
|
10
|
-
if (typeof define === 'function' && define.amd) {
|
11
|
-
define(factory);
|
12
|
-
registeredInModuleLoader = true;
|
13
|
-
}
|
14
|
-
if (typeof exports === 'object') {
|
15
|
-
module.exports = factory();
|
16
|
-
registeredInModuleLoader = true;
|
17
|
-
}
|
18
|
-
if (!registeredInModuleLoader) {
|
19
|
-
var OldCookies = window.Cookies;
|
20
|
-
var api = window.Cookies = factory();
|
21
|
-
api.noConflict = function () {
|
22
|
-
window.Cookies = OldCookies;
|
23
|
-
return api;
|
24
|
-
};
|
25
|
-
}
|
26
|
-
}(function () {
|
27
|
-
function extend () {
|
28
|
-
var i = 0;
|
29
|
-
var result = {};
|
30
|
-
for (; i < arguments.length; i++) {
|
31
|
-
var attributes = arguments[ i ];
|
32
|
-
for (var key in attributes) {
|
33
|
-
result[key] = attributes[key];
|
34
|
-
}
|
35
|
-
}
|
36
|
-
return result;
|
37
|
-
}
|
38
|
-
|
39
|
-
function decode (s) {
|
40
|
-
return s.replace(/(%[0-9A-Z]{2})+/g, decodeURIComponent);
|
41
|
-
}
|
42
|
-
|
43
|
-
function init (converter) {
|
44
|
-
function api() {}
|
45
|
-
|
46
|
-
function set (key, value, attributes) {
|
47
|
-
if (typeof document === 'undefined') {
|
48
|
-
return;
|
49
|
-
}
|
50
|
-
|
51
|
-
attributes = extend({
|
52
|
-
path: '/'
|
53
|
-
}, api.defaults, attributes);
|
54
|
-
|
55
|
-
if (typeof attributes.expires === 'number') {
|
56
|
-
attributes.expires = new Date(new Date() * 1 + attributes.expires * 864e+5);
|
57
|
-
}
|
58
|
-
|
59
|
-
// We're using "expires" because "max-age" is not supported by IE
|
60
|
-
attributes.expires = attributes.expires ? attributes.expires.toUTCString() : '';
|
61
|
-
|
62
|
-
try {
|
63
|
-
var result = JSON.stringify(value);
|
64
|
-
if (/^[\{\[]/.test(result)) {
|
65
|
-
value = result;
|
66
|
-
}
|
67
|
-
} catch (e) {}
|
68
|
-
|
69
|
-
value = converter.write ?
|
70
|
-
converter.write(value, key) :
|
71
|
-
encodeURIComponent(String(value))
|
72
|
-
.replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g, decodeURIComponent);
|
73
|
-
|
74
|
-
key = encodeURIComponent(String(key))
|
75
|
-
.replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent)
|
76
|
-
.replace(/[\(\)]/g, escape);
|
77
|
-
|
78
|
-
var stringifiedAttributes = '';
|
79
|
-
for (var attributeName in attributes) {
|
80
|
-
if (!attributes[attributeName]) {
|
81
|
-
continue;
|
82
|
-
}
|
83
|
-
stringifiedAttributes += '; ' + attributeName;
|
84
|
-
if (attributes[attributeName] === true) {
|
85
|
-
continue;
|
86
|
-
}
|
87
|
-
|
88
|
-
// Considers RFC 6265 section 5.2:
|
89
|
-
// ...
|
90
|
-
// 3. If the remaining unparsed-attributes contains a %x3B (";")
|
91
|
-
// character:
|
92
|
-
// Consume the characters of the unparsed-attributes up to,
|
93
|
-
// not including, the first %x3B (";") character.
|
94
|
-
// ...
|
95
|
-
stringifiedAttributes += '=' + attributes[attributeName].split(';')[0];
|
96
|
-
}
|
97
|
-
|
98
|
-
return (document.cookie = key + '=' + value + stringifiedAttributes);
|
99
|
-
}
|
100
|
-
|
101
|
-
function get (key, json) {
|
102
|
-
if (typeof document === 'undefined') {
|
103
|
-
return;
|
104
|
-
}
|
105
|
-
|
106
|
-
var jar = {};
|
107
|
-
// To prevent the for loop in the first place assign an empty array
|
108
|
-
// in case there are no cookies at all.
|
109
|
-
var cookies = document.cookie ? document.cookie.split('; ') : [];
|
110
|
-
var i = 0;
|
111
|
-
|
112
|
-
for (; i < cookies.length; i++) {
|
113
|
-
var parts = cookies[i].split('=');
|
114
|
-
var cookie = parts.slice(1).join('=');
|
115
|
-
|
116
|
-
if (!json && cookie.charAt(0) === '"') {
|
117
|
-
cookie = cookie.slice(1, -1);
|
118
|
-
}
|
119
|
-
|
120
|
-
try {
|
121
|
-
var name = decode(parts[0]);
|
122
|
-
cookie = (converter.read || converter)(cookie, name) ||
|
123
|
-
decode(cookie);
|
124
|
-
|
125
|
-
if (json) {
|
126
|
-
try {
|
127
|
-
cookie = JSON.parse(cookie);
|
128
|
-
} catch (e) {}
|
129
|
-
}
|
130
|
-
|
131
|
-
jar[name] = cookie;
|
132
|
-
|
133
|
-
if (key === name) {
|
134
|
-
break;
|
135
|
-
}
|
136
|
-
} catch (e) {}
|
137
|
-
}
|
138
|
-
|
139
|
-
return key ? jar[key] : jar;
|
140
|
-
}
|
141
|
-
|
142
|
-
api.set = set;
|
143
|
-
api.get = function (key) {
|
144
|
-
return get(key, false /* read as raw */);
|
145
|
-
};
|
146
|
-
api.getJSON = function (key) {
|
147
|
-
return get(key, true /* read as json */);
|
148
|
-
};
|
149
|
-
api.remove = function (key, attributes) {
|
150
|
-
set(key, '', extend(attributes, {
|
151
|
-
expires: -1
|
152
|
-
}));
|
153
|
-
};
|
154
|
-
|
155
|
-
api.defaults = {};
|
156
|
-
|
157
|
-
api.withConverter = init;
|
158
|
-
|
159
|
-
return api;
|
160
|
-
}
|
161
|
-
|
162
|
-
return init(function () {});
|
163
|
-
}));
|