-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathseedstack.js
More file actions
80 lines (66 loc) · 2.48 KB
/
seedstack.js
File metadata and controls
80 lines (66 loc) · 2.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
(function (seedstack) {
seedstack.strings = {
parseQueryString: function (value) {
var query = {};
value.search.substr(1).split("&").forEach(function (item) {
var k = item.split("=")[0], v = decodeURIComponent(item.split("=")[1]).replace(/\+/g, ' ');
(k in query) ? query[k].push(v) : query[k] = [v]
});
return query;
},
toTitleCase: function (value) {
var smallWords = /^(a|an|and|as|at|but|by|en|for|if|in|nor|of|on|or|per|the|to|vs?\.?|via)$/i;
return value.replace(/[A-Za-z0-9\u00C0-\u00FF]+[^\s-]*/g, function (match, index, title) {
if (index > 0 && index + match.length !== title.length &&
match.search(smallWords) > -1 && title.charAt(index - 2) !== ":" &&
(title.charAt(index + match.length) !== '-' || title.charAt(index - 1) === '-') &&
title.charAt(index - 1).search(/[^\s-]/) < 0) {
return match.toLowerCase();
}
if (match.substr(1).search(/[A-Z]|\../) > -1) {
return match;
}
return match.charAt(0).toUpperCase() + match.substr(1);
});
}
};
seedstack.ui = {
openSearch: function () {
$('.search-open').show();
$('.search-btn').removeClass('fa-search').addClass('fa-times');
$('#search-field').focus();
},
closeSearch: function searchClose() {
$('#search-field').blur();
$('.search-open').hide();
$('.search-btn').addClass('fa-search').removeClass('fa-times');
},
openHelp: function () {
$('#hotkeys-modal').modal('show');
},
closeHelp: function () {
$('#hotkeys-modal').modal('hide');
},
openVersions: function () {
$('#versions-modal').modal('show');
},
closeVersions: function () {
$('#versions-modal').modal('hide');
},
shortcuts: {
"h": "/",
"d": "/docs",
"a": "/addons",
"g": "/guides"
}
};
var event;
try {
event = new CustomEvent('seedstack')
} catch (e) {
// older browsers
event = document.createEvent('CustomEvent');
event.initCustomEvent('seedstack', true, false, null);
}
document.dispatchEvent(event);
})(window.seedstack);