arctic-vendor 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +51 -0
- data/CHANGELOG.md +12 -0
- data/Gemfile.lock +2 -3
- data/documentation/CHANGELOG.md +137 -0
- data/documentation/CODE_OF_CONDUCT.md +46 -0
- data/documentation/Gemfile +11 -0
- data/documentation/Gemfile.lock +130 -0
- data/documentation/LICENSE +13 -0
- data/documentation/Procfile +1 -0
- data/documentation/README.md +118 -0
- data/documentation/build/fonts/slate.eot +0 -0
- data/documentation/build/fonts/slate.svg +14 -0
- data/documentation/build/fonts/slate.ttf +0 -0
- data/documentation/build/fonts/slate.woff +0 -0
- data/documentation/build/fonts/slate.woff2 +0 -0
- data/documentation/build/images/logo.png +0 -0
- data/documentation/build/images/navbar.png +0 -0
- data/documentation/build/index.html +564 -0
- data/documentation/build/javascripts/all.js +131 -0
- data/documentation/build/javascripts/all_nosearch.js +31 -0
- data/documentation/build/stylesheets/print.css +1 -0
- data/documentation/build/stylesheets/screen.css +1 -0
- data/documentation/config.rb +57 -0
- data/documentation/deploy.sh +215 -0
- data/documentation/font-selection.json +148 -0
- data/documentation/lib/multilang.rb +16 -0
- data/documentation/lib/nesting_unique_head.rb +22 -0
- data/documentation/lib/toc_data.rb +30 -0
- data/documentation/lib/unique_head.rb +24 -0
- data/documentation/source/fonts/slate.eot +0 -0
- data/documentation/source/fonts/slate.svg +14 -0
- data/documentation/source/fonts/slate.ttf +0 -0
- data/documentation/source/fonts/slate.woff +0 -0
- data/documentation/source/fonts/slate.woff2 +0 -0
- data/documentation/source/images/logo.png +0 -0
- data/documentation/source/images/navbar.png +0 -0
- data/documentation/source/includes/_errors.md +17 -0
- data/documentation/source/index.html.md +150 -0
- data/documentation/source/javascripts/all.js +2 -0
- data/documentation/source/javascripts/all_nosearch.js +16 -0
- data/documentation/source/javascripts/app/_lang.js +164 -0
- data/documentation/source/javascripts/app/_search.js +98 -0
- data/documentation/source/javascripts/app/_toc.js +114 -0
- data/documentation/source/javascripts/lib/_energize.js +169 -0
- data/documentation/source/javascripts/lib/_imagesloaded.min.js +7 -0
- data/documentation/source/javascripts/lib/_jquery.highlight.js +108 -0
- data/documentation/source/javascripts/lib/_jquery.js +9831 -0
- data/documentation/source/javascripts/lib/_lunr.js +1910 -0
- data/documentation/source/layouts/layout.erb +116 -0
- data/documentation/source/stylesheets/_icon-font.scss +38 -0
- data/documentation/source/stylesheets/_normalize.scss +427 -0
- data/documentation/source/stylesheets/_rtl.scss +140 -0
- data/documentation/source/stylesheets/_variables.scss +103 -0
- data/documentation/source/stylesheets/_variables2.scss +147 -0
- data/documentation/source/stylesheets/print.css.scss +148 -0
- data/documentation/source/stylesheets/screen.css.scss +712 -0
- data/lib/arctic/vendor/api.rb +38 -4
- data/lib/arctic/vendor/product.rb +47 -0
- data/lib/arctic/vendor/vendor.rb +7 -6
- data/lib/arctic/vendor/version.rb +1 -1
- data/vendor.gemspec +1 -1
- metadata +57 -16
@@ -0,0 +1,98 @@
|
|
1
|
+
//= require ../lib/_lunr
|
2
|
+
//= require ../lib/_jquery
|
3
|
+
//= require ../lib/_jquery.highlight
|
4
|
+
;(function () {
|
5
|
+
'use strict';
|
6
|
+
|
7
|
+
var content, searchResults;
|
8
|
+
var highlightOpts = { element: 'span', className: 'search-highlight' };
|
9
|
+
var searchDelay = 0;
|
10
|
+
var timeoutHandle = 0;
|
11
|
+
|
12
|
+
var index = new lunr.Index();
|
13
|
+
|
14
|
+
index.ref('id');
|
15
|
+
index.field('title', { boost: 10 });
|
16
|
+
index.field('body');
|
17
|
+
index.pipeline.add(lunr.trimmer, lunr.stopWordFilter);
|
18
|
+
|
19
|
+
$(populate);
|
20
|
+
$(bind);
|
21
|
+
|
22
|
+
function populate() {
|
23
|
+
$('h1, h2').each(function() {
|
24
|
+
var title = $(this);
|
25
|
+
var body = title.nextUntil('h1, h2');
|
26
|
+
index.add({
|
27
|
+
id: title.prop('id'),
|
28
|
+
title: title.text(),
|
29
|
+
body: body.text()
|
30
|
+
});
|
31
|
+
});
|
32
|
+
|
33
|
+
determineSearchDelay();
|
34
|
+
}
|
35
|
+
function determineSearchDelay() {
|
36
|
+
if(index.tokenStore.length>5000) {
|
37
|
+
searchDelay = 300;
|
38
|
+
}
|
39
|
+
}
|
40
|
+
|
41
|
+
function bind() {
|
42
|
+
content = $('.content');
|
43
|
+
searchResults = $('.search-results');
|
44
|
+
|
45
|
+
$('#input-search').on('keyup',function(e) {
|
46
|
+
var wait = function() {
|
47
|
+
return function(executingFunction, waitTime){
|
48
|
+
clearTimeout(timeoutHandle);
|
49
|
+
timeoutHandle = setTimeout(executingFunction, waitTime);
|
50
|
+
};
|
51
|
+
}();
|
52
|
+
wait(function(){
|
53
|
+
search(e);
|
54
|
+
}, searchDelay );
|
55
|
+
});
|
56
|
+
}
|
57
|
+
|
58
|
+
function search(event) {
|
59
|
+
|
60
|
+
var searchInput = $('#input-search')[0];
|
61
|
+
|
62
|
+
unhighlight();
|
63
|
+
searchResults.addClass('visible');
|
64
|
+
|
65
|
+
// ESC clears the field
|
66
|
+
if (event.keyCode === 27) searchInput.value = '';
|
67
|
+
|
68
|
+
if (searchInput.value) {
|
69
|
+
var results = index.search(searchInput.value).filter(function(r) {
|
70
|
+
return r.score > 0.0001;
|
71
|
+
});
|
72
|
+
|
73
|
+
if (results.length) {
|
74
|
+
searchResults.empty();
|
75
|
+
$.each(results, function (index, result) {
|
76
|
+
var elem = document.getElementById(result.ref);
|
77
|
+
searchResults.append("<li><a href='#" + result.ref + "'>" + $(elem).text() + "</a></li>");
|
78
|
+
});
|
79
|
+
highlight.call(searchInput);
|
80
|
+
} else {
|
81
|
+
searchResults.html('<li></li>');
|
82
|
+
$('.search-results li').text('No Results Found for "' + searchInput.value + '"');
|
83
|
+
}
|
84
|
+
} else {
|
85
|
+
unhighlight();
|
86
|
+
searchResults.removeClass('visible');
|
87
|
+
}
|
88
|
+
}
|
89
|
+
|
90
|
+
function highlight() {
|
91
|
+
if (this.value) content.highlight(this.value, highlightOpts);
|
92
|
+
}
|
93
|
+
|
94
|
+
function unhighlight() {
|
95
|
+
content.unhighlight(highlightOpts);
|
96
|
+
}
|
97
|
+
})();
|
98
|
+
|
@@ -0,0 +1,114 @@
|
|
1
|
+
//= require ../lib/_jquery
|
2
|
+
//= require ../lib/_imagesloaded.min
|
3
|
+
;(function () {
|
4
|
+
'use strict';
|
5
|
+
|
6
|
+
var loaded = false;
|
7
|
+
|
8
|
+
var debounce = function(func, waitTime) {
|
9
|
+
var timeout = false;
|
10
|
+
return function() {
|
11
|
+
if (timeout === false) {
|
12
|
+
setTimeout(function() {
|
13
|
+
func();
|
14
|
+
timeout = false;
|
15
|
+
}, waitTime);
|
16
|
+
timeout = true;
|
17
|
+
}
|
18
|
+
};
|
19
|
+
};
|
20
|
+
|
21
|
+
var closeToc = function() {
|
22
|
+
$(".toc-wrapper").removeClass('open');
|
23
|
+
$("#nav-button").removeClass('open');
|
24
|
+
};
|
25
|
+
|
26
|
+
function loadToc($toc, tocLinkSelector, tocListSelector, scrollOffset) {
|
27
|
+
var headerHeights = {};
|
28
|
+
var pageHeight = 0;
|
29
|
+
var windowHeight = 0;
|
30
|
+
var originalTitle = document.title;
|
31
|
+
|
32
|
+
var recacheHeights = function() {
|
33
|
+
headerHeights = {};
|
34
|
+
pageHeight = $(document).height();
|
35
|
+
windowHeight = $(window).height();
|
36
|
+
|
37
|
+
$toc.find(tocLinkSelector).each(function() {
|
38
|
+
var targetId = $(this).attr('href');
|
39
|
+
if (targetId[0] === "#") {
|
40
|
+
headerHeights[targetId] = $(targetId).offset().top;
|
41
|
+
}
|
42
|
+
});
|
43
|
+
};
|
44
|
+
|
45
|
+
var refreshToc = function() {
|
46
|
+
var currentTop = $(document).scrollTop() + scrollOffset;
|
47
|
+
|
48
|
+
if (currentTop + windowHeight >= pageHeight) {
|
49
|
+
// at bottom of page, so just select last header by making currentTop very large
|
50
|
+
// this fixes the problem where the last header won't ever show as active if its content
|
51
|
+
// is shorter than the window height
|
52
|
+
currentTop = pageHeight + 1000;
|
53
|
+
}
|
54
|
+
|
55
|
+
var best = null;
|
56
|
+
for (var name in headerHeights) {
|
57
|
+
if ((headerHeights[name] < currentTop && headerHeights[name] > headerHeights[best]) || best === null) {
|
58
|
+
best = name;
|
59
|
+
}
|
60
|
+
}
|
61
|
+
|
62
|
+
// Catch the initial load case
|
63
|
+
if (currentTop == scrollOffset && !loaded) {
|
64
|
+
best = window.location.hash;
|
65
|
+
loaded = true;
|
66
|
+
}
|
67
|
+
|
68
|
+
var $best = $toc.find("[href='" + best + "']").first();
|
69
|
+
if (!$best.hasClass("active")) {
|
70
|
+
// .active is applied to the ToC link we're currently on, and its parent <ul>s selected by tocListSelector
|
71
|
+
// .active-expanded is applied to the ToC links that are parents of this one
|
72
|
+
$toc.find(".active").removeClass("active");
|
73
|
+
$toc.find(".active-parent").removeClass("active-parent");
|
74
|
+
$best.addClass("active");
|
75
|
+
$best.parents(tocListSelector).addClass("active").siblings(tocLinkSelector).addClass('active-parent');
|
76
|
+
$best.siblings(tocListSelector).addClass("active");
|
77
|
+
$toc.find(tocListSelector).filter(":not(.active)").slideUp(150);
|
78
|
+
$toc.find(tocListSelector).filter(".active").slideDown(150);
|
79
|
+
// TODO remove classnames
|
80
|
+
document.title = $best.data("title") + " – " + originalTitle;
|
81
|
+
}
|
82
|
+
};
|
83
|
+
|
84
|
+
var makeToc = function() {
|
85
|
+
recacheHeights();
|
86
|
+
refreshToc();
|
87
|
+
|
88
|
+
$("#nav-button").click(function() {
|
89
|
+
$(".toc-wrapper").toggleClass('open');
|
90
|
+
$("#nav-button").toggleClass('open');
|
91
|
+
return false;
|
92
|
+
});
|
93
|
+
$(".page-wrapper").click(closeToc);
|
94
|
+
$(".toc-link").click(closeToc);
|
95
|
+
|
96
|
+
// reload immediately after scrolling on toc click
|
97
|
+
$toc.find(tocLinkSelector).click(function() {
|
98
|
+
setTimeout(function() {
|
99
|
+
refreshToc();
|
100
|
+
}, 0);
|
101
|
+
});
|
102
|
+
|
103
|
+
$(window).scroll(debounce(refreshToc, 200));
|
104
|
+
$(window).resize(debounce(recacheHeights, 200));
|
105
|
+
};
|
106
|
+
|
107
|
+
makeToc();
|
108
|
+
|
109
|
+
window.recacheHeights = recacheHeights;
|
110
|
+
window.refreshToc = refreshToc;
|
111
|
+
}
|
112
|
+
|
113
|
+
window.loadToc = loadToc;
|
114
|
+
})();
|
@@ -0,0 +1,169 @@
|
|
1
|
+
/**
|
2
|
+
* energize.js v0.1.0
|
3
|
+
*
|
4
|
+
* Speeds up click events on mobile devices.
|
5
|
+
* https://github.com/davidcalhoun/energize.js
|
6
|
+
*/
|
7
|
+
|
8
|
+
(function() { // Sandbox
|
9
|
+
/**
|
10
|
+
* Don't add to non-touch devices, which don't need to be sped up
|
11
|
+
*/
|
12
|
+
if(!('ontouchstart' in window)) return;
|
13
|
+
|
14
|
+
var lastClick = {},
|
15
|
+
isThresholdReached, touchstart, touchmove, touchend,
|
16
|
+
click, closest;
|
17
|
+
|
18
|
+
/**
|
19
|
+
* isThresholdReached
|
20
|
+
*
|
21
|
+
* Compare touchstart with touchend xy coordinates,
|
22
|
+
* and only fire simulated click event if the coordinates
|
23
|
+
* are nearby. (don't want clicking to be confused with a swipe)
|
24
|
+
*/
|
25
|
+
isThresholdReached = function(startXY, xy) {
|
26
|
+
return Math.abs(startXY[0] - xy[0]) > 5 || Math.abs(startXY[1] - xy[1]) > 5;
|
27
|
+
};
|
28
|
+
|
29
|
+
/**
|
30
|
+
* touchstart
|
31
|
+
*
|
32
|
+
* Save xy coordinates when the user starts touching the screen
|
33
|
+
*/
|
34
|
+
touchstart = function(e) {
|
35
|
+
this.startXY = [e.touches[0].clientX, e.touches[0].clientY];
|
36
|
+
this.threshold = false;
|
37
|
+
};
|
38
|
+
|
39
|
+
/**
|
40
|
+
* touchmove
|
41
|
+
*
|
42
|
+
* Check if the user is scrolling past the threshold.
|
43
|
+
* Have to check here because touchend will not always fire
|
44
|
+
* on some tested devices (Kindle Fire?)
|
45
|
+
*/
|
46
|
+
touchmove = function(e) {
|
47
|
+
// NOOP if the threshold has already been reached
|
48
|
+
if(this.threshold) return false;
|
49
|
+
|
50
|
+
this.threshold = isThresholdReached(this.startXY, [e.touches[0].clientX, e.touches[0].clientY]);
|
51
|
+
};
|
52
|
+
|
53
|
+
/**
|
54
|
+
* touchend
|
55
|
+
*
|
56
|
+
* If the user didn't scroll past the threshold between
|
57
|
+
* touchstart and touchend, fire a simulated click.
|
58
|
+
*
|
59
|
+
* (This will fire before a native click)
|
60
|
+
*/
|
61
|
+
touchend = function(e) {
|
62
|
+
// Don't fire a click if the user scrolled past the threshold
|
63
|
+
if(this.threshold || isThresholdReached(this.startXY, [e.changedTouches[0].clientX, e.changedTouches[0].clientY])) {
|
64
|
+
return;
|
65
|
+
}
|
66
|
+
|
67
|
+
/**
|
68
|
+
* Create and fire a click event on the target element
|
69
|
+
* https://developer.mozilla.org/en/DOM/event.initMouseEvent
|
70
|
+
*/
|
71
|
+
var touch = e.changedTouches[0],
|
72
|
+
evt = document.createEvent('MouseEvents');
|
73
|
+
evt.initMouseEvent('click', true, true, window, 0, touch.screenX, touch.screenY, touch.clientX, touch.clientY, false, false, false, false, 0, null);
|
74
|
+
evt.simulated = true; // distinguish from a normal (nonsimulated) click
|
75
|
+
e.target.dispatchEvent(evt);
|
76
|
+
};
|
77
|
+
|
78
|
+
/**
|
79
|
+
* click
|
80
|
+
*
|
81
|
+
* Because we've already fired a click event in touchend,
|
82
|
+
* we need to listed for all native click events here
|
83
|
+
* and suppress them as necessary.
|
84
|
+
*/
|
85
|
+
click = function(e) {
|
86
|
+
/**
|
87
|
+
* Prevent ghost clicks by only allowing clicks we created
|
88
|
+
* in the click event we fired (look for e.simulated)
|
89
|
+
*/
|
90
|
+
var time = Date.now(),
|
91
|
+
timeDiff = time - lastClick.time,
|
92
|
+
x = e.clientX,
|
93
|
+
y = e.clientY,
|
94
|
+
xyDiff = [Math.abs(lastClick.x - x), Math.abs(lastClick.y - y)],
|
95
|
+
target = closest(e.target, 'A') || e.target, // needed for standalone apps
|
96
|
+
nodeName = target.nodeName,
|
97
|
+
isLink = nodeName === 'A',
|
98
|
+
standAlone = window.navigator.standalone && isLink && e.target.getAttribute("href");
|
99
|
+
|
100
|
+
lastClick.time = time;
|
101
|
+
lastClick.x = x;
|
102
|
+
lastClick.y = y;
|
103
|
+
|
104
|
+
/**
|
105
|
+
* Unfortunately Android sometimes fires click events without touch events (seen on Kindle Fire),
|
106
|
+
* so we have to add more logic to determine the time of the last click. Not perfect...
|
107
|
+
*
|
108
|
+
* Older, simpler check: if((!e.simulated) || standAlone)
|
109
|
+
*/
|
110
|
+
if((!e.simulated && (timeDiff < 500 || (timeDiff < 1500 && xyDiff[0] < 50 && xyDiff[1] < 50))) || standAlone) {
|
111
|
+
e.preventDefault();
|
112
|
+
e.stopPropagation();
|
113
|
+
if(!standAlone) return false;
|
114
|
+
}
|
115
|
+
|
116
|
+
/**
|
117
|
+
* Special logic for standalone web apps
|
118
|
+
* See http://stackoverflow.com/questions/2898740/iphone-safari-web-app-opens-links-in-new-window
|
119
|
+
*/
|
120
|
+
if(standAlone) {
|
121
|
+
window.location = target.getAttribute("href");
|
122
|
+
}
|
123
|
+
|
124
|
+
/**
|
125
|
+
* Add an energize-focus class to the targeted link (mimics :focus behavior)
|
126
|
+
* TODO: test and/or remove? Does this work?
|
127
|
+
*/
|
128
|
+
if(!target || !target.classList) return;
|
129
|
+
target.classList.add("energize-focus");
|
130
|
+
window.setTimeout(function(){
|
131
|
+
target.classList.remove("energize-focus");
|
132
|
+
}, 150);
|
133
|
+
};
|
134
|
+
|
135
|
+
/**
|
136
|
+
* closest
|
137
|
+
* @param {HTMLElement} node current node to start searching from.
|
138
|
+
* @param {string} tagName the (uppercase) name of the tag you're looking for.
|
139
|
+
*
|
140
|
+
* Find the closest ancestor tag of a given node.
|
141
|
+
*
|
142
|
+
* Starts at node and goes up the DOM tree looking for a
|
143
|
+
* matching nodeName, continuing until hitting document.body
|
144
|
+
*/
|
145
|
+
closest = function(node, tagName){
|
146
|
+
var curNode = node;
|
147
|
+
|
148
|
+
while(curNode !== document.body) { // go up the dom until we find the tag we're after
|
149
|
+
if(!curNode || curNode.nodeName === tagName) { return curNode; } // found
|
150
|
+
curNode = curNode.parentNode; // not found, so keep going up
|
151
|
+
}
|
152
|
+
|
153
|
+
return null; // not found
|
154
|
+
};
|
155
|
+
|
156
|
+
/**
|
157
|
+
* Add all delegated event listeners
|
158
|
+
*
|
159
|
+
* All the events we care about bubble up to document,
|
160
|
+
* so we can take advantage of event delegation.
|
161
|
+
*
|
162
|
+
* Note: no need to wait for DOMContentLoaded here
|
163
|
+
*/
|
164
|
+
document.addEventListener('touchstart', touchstart, false);
|
165
|
+
document.addEventListener('touchmove', touchmove, false);
|
166
|
+
document.addEventListener('touchend', touchend, false);
|
167
|
+
document.addEventListener('click', click, true); // TODO: why does this use capture?
|
168
|
+
|
169
|
+
})();
|
@@ -0,0 +1,7 @@
|
|
1
|
+
/*!
|
2
|
+
* imagesLoaded PACKAGED v3.1.8
|
3
|
+
* JavaScript is all like "You images are done yet or what?"
|
4
|
+
* MIT License
|
5
|
+
*/
|
6
|
+
|
7
|
+
(function(){function e(){}function t(e,t){for(var n=e.length;n--;)if(e[n].listener===t)return n;return-1}function n(e){return function(){return this[e].apply(this,arguments)}}var i=e.prototype,r=this,o=r.EventEmitter;i.getListeners=function(e){var t,n,i=this._getEvents();if("object"==typeof e){t={};for(n in i)i.hasOwnProperty(n)&&e.test(n)&&(t[n]=i[n])}else t=i[e]||(i[e]=[]);return t},i.flattenListeners=function(e){var t,n=[];for(t=0;e.length>t;t+=1)n.push(e[t].listener);return n},i.getListenersAsObject=function(e){var t,n=this.getListeners(e);return n instanceof Array&&(t={},t[e]=n),t||n},i.addListener=function(e,n){var i,r=this.getListenersAsObject(e),o="object"==typeof n;for(i in r)r.hasOwnProperty(i)&&-1===t(r[i],n)&&r[i].push(o?n:{listener:n,once:!1});return this},i.on=n("addListener"),i.addOnceListener=function(e,t){return this.addListener(e,{listener:t,once:!0})},i.once=n("addOnceListener"),i.defineEvent=function(e){return this.getListeners(e),this},i.defineEvents=function(e){for(var t=0;e.length>t;t+=1)this.defineEvent(e[t]);return this},i.removeListener=function(e,n){var i,r,o=this.getListenersAsObject(e);for(r in o)o.hasOwnProperty(r)&&(i=t(o[r],n),-1!==i&&o[r].splice(i,1));return this},i.off=n("removeListener"),i.addListeners=function(e,t){return this.manipulateListeners(!1,e,t)},i.removeListeners=function(e,t){return this.manipulateListeners(!0,e,t)},i.manipulateListeners=function(e,t,n){var i,r,o=e?this.removeListener:this.addListener,s=e?this.removeListeners:this.addListeners;if("object"!=typeof t||t instanceof RegExp)for(i=n.length;i--;)o.call(this,t,n[i]);else for(i in t)t.hasOwnProperty(i)&&(r=t[i])&&("function"==typeof r?o.call(this,i,r):s.call(this,i,r));return this},i.removeEvent=function(e){var t,n=typeof e,i=this._getEvents();if("string"===n)delete i[e];else if("object"===n)for(t in i)i.hasOwnProperty(t)&&e.test(t)&&delete i[t];else delete this._events;return this},i.removeAllListeners=n("removeEvent"),i.emitEvent=function(e,t){var n,i,r,o,s=this.getListenersAsObject(e);for(r in s)if(s.hasOwnProperty(r))for(i=s[r].length;i--;)n=s[r][i],n.once===!0&&this.removeListener(e,n.listener),o=n.listener.apply(this,t||[]),o===this._getOnceReturnValue()&&this.removeListener(e,n.listener);return this},i.trigger=n("emitEvent"),i.emit=function(e){var t=Array.prototype.slice.call(arguments,1);return this.emitEvent(e,t)},i.setOnceReturnValue=function(e){return this._onceReturnValue=e,this},i._getOnceReturnValue=function(){return this.hasOwnProperty("_onceReturnValue")?this._onceReturnValue:!0},i._getEvents=function(){return this._events||(this._events={})},e.noConflict=function(){return r.EventEmitter=o,e},"function"==typeof define&&define.amd?define("eventEmitter/EventEmitter",[],function(){return e}):"object"==typeof module&&module.exports?module.exports=e:this.EventEmitter=e}).call(this),function(e){function t(t){var n=e.event;return n.target=n.target||n.srcElement||t,n}var n=document.documentElement,i=function(){};n.addEventListener?i=function(e,t,n){e.addEventListener(t,n,!1)}:n.attachEvent&&(i=function(e,n,i){e[n+i]=i.handleEvent?function(){var n=t(e);i.handleEvent.call(i,n)}:function(){var n=t(e);i.call(e,n)},e.attachEvent("on"+n,e[n+i])});var r=function(){};n.removeEventListener?r=function(e,t,n){e.removeEventListener(t,n,!1)}:n.detachEvent&&(r=function(e,t,n){e.detachEvent("on"+t,e[t+n]);try{delete e[t+n]}catch(i){e[t+n]=void 0}});var o={bind:i,unbind:r};"function"==typeof define&&define.amd?define("eventie/eventie",o):e.eventie=o}(this),function(e,t){"function"==typeof define&&define.amd?define(["eventEmitter/EventEmitter","eventie/eventie"],function(n,i){return t(e,n,i)}):"object"==typeof exports?module.exports=t(e,require("wolfy87-eventemitter"),require("eventie")):e.imagesLoaded=t(e,e.EventEmitter,e.eventie)}(window,function(e,t,n){function i(e,t){for(var n in t)e[n]=t[n];return e}function r(e){return"[object Array]"===d.call(e)}function o(e){var t=[];if(r(e))t=e;else if("number"==typeof e.length)for(var n=0,i=e.length;i>n;n++)t.push(e[n]);else t.push(e);return t}function s(e,t,n){if(!(this instanceof s))return new s(e,t);"string"==typeof e&&(e=document.querySelectorAll(e)),this.elements=o(e),this.options=i({},this.options),"function"==typeof t?n=t:i(this.options,t),n&&this.on("always",n),this.getImages(),a&&(this.jqDeferred=new a.Deferred);var r=this;setTimeout(function(){r.check()})}function f(e){this.img=e}function c(e){this.src=e,v[e]=this}var a=e.jQuery,u=e.console,h=u!==void 0,d=Object.prototype.toString;s.prototype=new t,s.prototype.options={},s.prototype.getImages=function(){this.images=[];for(var e=0,t=this.elements.length;t>e;e++){var n=this.elements[e];"IMG"===n.nodeName&&this.addImage(n);var i=n.nodeType;if(i&&(1===i||9===i||11===i))for(var r=n.querySelectorAll("img"),o=0,s=r.length;s>o;o++){var f=r[o];this.addImage(f)}}},s.prototype.addImage=function(e){var t=new f(e);this.images.push(t)},s.prototype.check=function(){function e(e,r){return t.options.debug&&h&&u.log("confirm",e,r),t.progress(e),n++,n===i&&t.complete(),!0}var t=this,n=0,i=this.images.length;if(this.hasAnyBroken=!1,!i)return this.complete(),void 0;for(var r=0;i>r;r++){var o=this.images[r];o.on("confirm",e),o.check()}},s.prototype.progress=function(e){this.hasAnyBroken=this.hasAnyBroken||!e.isLoaded;var t=this;setTimeout(function(){t.emit("progress",t,e),t.jqDeferred&&t.jqDeferred.notify&&t.jqDeferred.notify(t,e)})},s.prototype.complete=function(){var e=this.hasAnyBroken?"fail":"done";this.isComplete=!0;var t=this;setTimeout(function(){if(t.emit(e,t),t.emit("always",t),t.jqDeferred){var n=t.hasAnyBroken?"reject":"resolve";t.jqDeferred[n](t)}})},a&&(a.fn.imagesLoaded=function(e,t){var n=new s(this,e,t);return n.jqDeferred.promise(a(this))}),f.prototype=new t,f.prototype.check=function(){var e=v[this.img.src]||new c(this.img.src);if(e.isConfirmed)return this.confirm(e.isLoaded,"cached was confirmed"),void 0;if(this.img.complete&&void 0!==this.img.naturalWidth)return this.confirm(0!==this.img.naturalWidth,"naturalWidth"),void 0;var t=this;e.on("confirm",function(e,n){return t.confirm(e.isLoaded,n),!0}),e.check()},f.prototype.confirm=function(e,t){this.isLoaded=e,this.emit("confirm",this,t)};var v={};return c.prototype=new t,c.prototype.check=function(){if(!this.isChecked){var e=new Image;n.bind(e,"load",this),n.bind(e,"error",this),e.src=this.src,this.isChecked=!0}},c.prototype.handleEvent=function(e){var t="on"+e.type;this[t]&&this[t](e)},c.prototype.onload=function(e){this.confirm(!0,"onload"),this.unbindProxyEvents(e)},c.prototype.onerror=function(e){this.confirm(!1,"onerror"),this.unbindProxyEvents(e)},c.prototype.confirm=function(e,t){this.isConfirmed=!0,this.isLoaded=e,this.emit("confirm",this,t)},c.prototype.unbindProxyEvents=function(e){n.unbind(e.target,"load",this),n.unbind(e.target,"error",this)},s});
|
@@ -0,0 +1,108 @@
|
|
1
|
+
/*
|
2
|
+
* jQuery Highlight plugin
|
3
|
+
*
|
4
|
+
* Based on highlight v3 by Johann Burkard
|
5
|
+
* http://johannburkard.de/blog/programming/javascript/highlight-javascript-text-higlighting-jquery-plugin.html
|
6
|
+
*
|
7
|
+
* Code a little bit refactored and cleaned (in my humble opinion).
|
8
|
+
* Most important changes:
|
9
|
+
* - has an option to highlight only entire words (wordsOnly - false by default),
|
10
|
+
* - has an option to be case sensitive (caseSensitive - false by default)
|
11
|
+
* - highlight element tag and class names can be specified in options
|
12
|
+
*
|
13
|
+
* Usage:
|
14
|
+
* // wrap every occurrance of text 'lorem' in content
|
15
|
+
* // with <span class='highlight'> (default options)
|
16
|
+
* $('#content').highlight('lorem');
|
17
|
+
*
|
18
|
+
* // search for and highlight more terms at once
|
19
|
+
* // so you can save some time on traversing DOM
|
20
|
+
* $('#content').highlight(['lorem', 'ipsum']);
|
21
|
+
* $('#content').highlight('lorem ipsum');
|
22
|
+
*
|
23
|
+
* // search only for entire word 'lorem'
|
24
|
+
* $('#content').highlight('lorem', { wordsOnly: true });
|
25
|
+
*
|
26
|
+
* // don't ignore case during search of term 'lorem'
|
27
|
+
* $('#content').highlight('lorem', { caseSensitive: true });
|
28
|
+
*
|
29
|
+
* // wrap every occurrance of term 'ipsum' in content
|
30
|
+
* // with <em class='important'>
|
31
|
+
* $('#content').highlight('ipsum', { element: 'em', className: 'important' });
|
32
|
+
*
|
33
|
+
* // remove default highlight
|
34
|
+
* $('#content').unhighlight();
|
35
|
+
*
|
36
|
+
* // remove custom highlight
|
37
|
+
* $('#content').unhighlight({ element: 'em', className: 'important' });
|
38
|
+
*
|
39
|
+
*
|
40
|
+
* Copyright (c) 2009 Bartek Szopka
|
41
|
+
*
|
42
|
+
* Licensed under MIT license.
|
43
|
+
*
|
44
|
+
*/
|
45
|
+
|
46
|
+
jQuery.extend({
|
47
|
+
highlight: function (node, re, nodeName, className) {
|
48
|
+
if (node.nodeType === 3) {
|
49
|
+
var match = node.data.match(re);
|
50
|
+
if (match) {
|
51
|
+
var highlight = document.createElement(nodeName || 'span');
|
52
|
+
highlight.className = className || 'highlight';
|
53
|
+
var wordNode = node.splitText(match.index);
|
54
|
+
wordNode.splitText(match[0].length);
|
55
|
+
var wordClone = wordNode.cloneNode(true);
|
56
|
+
highlight.appendChild(wordClone);
|
57
|
+
wordNode.parentNode.replaceChild(highlight, wordNode);
|
58
|
+
return 1; //skip added node in parent
|
59
|
+
}
|
60
|
+
} else if ((node.nodeType === 1 && node.childNodes) && // only element nodes that have children
|
61
|
+
!/(script|style)/i.test(node.tagName) && // ignore script and style nodes
|
62
|
+
!(node.tagName === nodeName.toUpperCase() && node.className === className)) { // skip if already highlighted
|
63
|
+
for (var i = 0; i < node.childNodes.length; i++) {
|
64
|
+
i += jQuery.highlight(node.childNodes[i], re, nodeName, className);
|
65
|
+
}
|
66
|
+
}
|
67
|
+
return 0;
|
68
|
+
}
|
69
|
+
});
|
70
|
+
|
71
|
+
jQuery.fn.unhighlight = function (options) {
|
72
|
+
var settings = { className: 'highlight', element: 'span' };
|
73
|
+
jQuery.extend(settings, options);
|
74
|
+
|
75
|
+
return this.find(settings.element + "." + settings.className).each(function () {
|
76
|
+
var parent = this.parentNode;
|
77
|
+
parent.replaceChild(this.firstChild, this);
|
78
|
+
parent.normalize();
|
79
|
+
}).end();
|
80
|
+
};
|
81
|
+
|
82
|
+
jQuery.fn.highlight = function (words, options) {
|
83
|
+
var settings = { className: 'highlight', element: 'span', caseSensitive: false, wordsOnly: false };
|
84
|
+
jQuery.extend(settings, options);
|
85
|
+
|
86
|
+
if (words.constructor === String) {
|
87
|
+
words = [words];
|
88
|
+
}
|
89
|
+
words = jQuery.grep(words, function(word, i){
|
90
|
+
return word != '';
|
91
|
+
});
|
92
|
+
words = jQuery.map(words, function(word, i) {
|
93
|
+
return word.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
94
|
+
});
|
95
|
+
if (words.length == 0) { return this; };
|
96
|
+
|
97
|
+
var flag = settings.caseSensitive ? "" : "i";
|
98
|
+
var pattern = "(" + words.join("|") + ")";
|
99
|
+
if (settings.wordsOnly) {
|
100
|
+
pattern = "\\b" + pattern + "\\b";
|
101
|
+
}
|
102
|
+
var re = new RegExp(pattern, flag);
|
103
|
+
|
104
|
+
return this.each(function () {
|
105
|
+
jQuery.highlight(this, re, settings.element, settings.className);
|
106
|
+
});
|
107
|
+
};
|
108
|
+
|