shibori 1.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +20 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +27 -0
- data/Procfile +1 -0
- data/README.md +24 -0
- data/Rakefile +2 -0
- data/app.json +11 -0
- data/builder/lineage_hunter.js +80 -0
- data/builder/list_item_hunter.js +106 -0
- data/builder/media_hunter.js +51 -0
- data/builder/object_factory.js +60 -0
- data/builder/parameter_hunter.js +69 -0
- data/builder/pattern_assembler.js +258 -0
- data/builder/pattern_exporter.js +43 -0
- data/builder/patternlab.js +365 -0
- data/builder/patternlab_grunt.js +38 -0
- data/builder/patternlab_gulp.js +26 -0
- data/builder/pseudopattern_hunter.js +78 -0
- data/config.json +34 -0
- data/docs/Pattern Lab Node.md +225 -0
- data/favicon.ico +0 -0
- data/gulpfile.js +148 -0
- data/index.js +20 -0
- data/lib/shibori/version.rb +3 -0
- data/lib/shibori.rb +11 -0
- data/package.json +44 -0
- data/public/data/annotations.js +109 -0
- data/public/styleguide/css/static.css +458 -0
- data/public/styleguide/css/static.scss +404 -0
- data/public/styleguide/css/styleguide-specific.css +170 -0
- data/public/styleguide/css/styleguide-specific.scss +204 -0
- data/public/styleguide/css/styleguide.css +880 -0
- data/public/styleguide/css/styleguide.scss +950 -0
- data/public/styleguide/css/vendor/prism.css +112 -0
- data/public/styleguide/css/vendor/typeahead.css +66 -0
- data/public/styleguide/fonts/icomoon.eot +0 -0
- data/public/styleguide/fonts/icomoon.svg +22 -0
- data/public/styleguide/fonts/icomoon.ttf +0 -0
- data/public/styleguide/fonts/icomoon.woff +0 -0
- data/public/styleguide/html/README +1 -0
- data/public/styleguide/images/spinner.gif +0 -0
- data/public/styleguide/js/annotations-pattern.js +308 -0
- data/public/styleguide/js/annotations-viewer.js +289 -0
- data/public/styleguide/js/code-pattern.js +120 -0
- data/public/styleguide/js/code-viewer.js +443 -0
- data/public/styleguide/js/data-saver.js +169 -0
- data/public/styleguide/js/pattern-finder.js +114 -0
- data/public/styleguide/js/postmessage.js +127 -0
- data/public/styleguide/js/styleguide.js +600 -0
- data/public/styleguide/js/url-handler.js +182 -0
- data/public/styleguide/js/vendor/classlist-polyfill.js +176 -0
- data/public/styleguide/js/vendor/jquery.js +4 -0
- data/public/styleguide/js/vendor/jwerty.js +523 -0
- data/public/styleguide/js/vendor/prism.js +7 -0
- data/public/styleguide/js/vendor/typeahead.bundle.min.js +7 -0
- data/script/bootstrap +58 -0
- data/shibori.gemspec +18 -0
- data/shibori.jpg +0 -0
- data/source/_data/annotations.js +109 -0
- data/source/_data/data.json +93 -0
- data/source/_data/listitems.json +782 -0
- data/source/_patternlab-files/README +1 -0
- data/source/_patternlab-files/index.mustache +94 -0
- data/source/_patternlab-files/partials/ishControls.mustache +64 -0
- data/source/_patternlab-files/partials/patternNav.mustache +17 -0
- data/source/_patternlab-files/partials/patternPaths.mustache +3 -0
- data/source/_patternlab-files/partials/viewAllPaths.mustache +3 -0
- data/source/_patternlab-files/pattern-header-footer/README +1 -0
- data/source/_patternlab-files/pattern-header-footer/footer.html +34 -0
- data/source/_patternlab-files/pattern-header-footer/header.html +44 -0
- data/source/_patternlab-files/styleguide.mustache +75 -0
- data/source/_patternlab-files/viewall.mustache +75 -0
- data/source/_patterns/00-atoms/00-typography/00-headings.mustache +6 -0
- data/source/_patterns/00-atoms/00-typography/01-headings-options.mustache +7 -0
- data/source/_patterns/00-atoms/00-typography/02-body.mustache +2 -0
- data/source/_patterns/00-atoms/00-typography/03-text-manipulation.mustache +12 -0
- data/source/_patterns/00-atoms/00-typography/04-blockquotes.mustache +3 -0
- data/source/_patterns/00-atoms/00-typography/05-lists.mustache +64 -0
- data/source/_patterns/00-atoms/01-colors/00-colors-monochromatic.mustache +36 -0
- data/source/_patterns/00-atoms/01-colors/01-colors-brand.mustache +26 -0
- data/source/_patterns/00-atoms/01-colors/02-colors-gradients.mustache +38 -0
- data/source/_patterns/00-atoms/02-buttons/00-btn-lg.mustache +7 -0
- data/source/_patterns/00-atoms/02-buttons/01-btn-sm.mustache +7 -0
- data/source/_patterns/00-atoms/02-buttons/02-btn-xs.mustache +7 -0
- data/source/_patterns/00-atoms/02-buttons/03-btn-block.mustache +7 -0
- data/source/_patterns/00-atoms/02-buttons/04-btn-deploy.mustache +4 -0
- data/source/_patterns/00-atoms/03-forms/00-text-fields.mustache +24 -0
- data/source/_patterns/00-atoms/03-forms/01-select-menu.mustache +6 -0
- data/source/_patterns/00-atoms/03-forms/02-checkbox.mustache +10 -0
- data/source/_patterns/00-atoms/03-forms/03-radios.mustache +10 -0
- data/source/_patterns/00-atoms/03-forms/04-validation.mustache +14 -0
- data/source/_patterns/00-atoms/04-quote/00-pullquote.mustache +7 -0
- data/source/_patterns/00-atoms/04-quote/01-quote-small.mustache +7 -0
- data/source/_patterns/00-atoms/05-code/01-pre.mustache +11 -0
- data/source/_patterns/00-atoms/06-tooltips/00-text.mustache +3 -0
- data/source/_patterns/00-atoms/06-tooltips/01-diagram-callout.mustache +1 -0
- data/source/_patterns/00-atoms/07-loader/00-spinner.mustache +5 -0
- data/source/_patterns/00-atoms/08-readmore/00-readmore.mustache +3 -0
- data/source/_patterns/00-atoms/09-slider/00-dots.mustache +8 -0
- data/source/_patterns/00-atoms/10-tables/00-tables.mustache +26 -0
- data/source/_patterns/00-atoms/12-modal/00-modal.mustache +14 -0
- data/source/_patterns/00-atoms/13-panel/00-panel.mustache +3 -0
- data/source/_patterns/00-atoms/14-users/00-avatar.mustache +3 -0
- data/source/_patterns/00-atoms/15-icons/00-icons.mustache +333 -0
- data/source/_patterns/00-atoms/15-icons/04-icon-colors.mustache +38 -0
- data/source/_patterns/00-atoms/15-icons/05-icon-sizes.mustache +31 -0
- data/source/_patterns/00-atoms/15-icons/_02-languages.mustache +0 -0
- data/source/_patterns/00-atoms/15-icons/_03-social.mustache +0 -0
- data/source/_patterns/00-atoms/15-icons/_05-icon-containers.mustache +0 -0
- data/source/_patterns/00-atoms/16-video/01-video.mustache +3 -0
- data/source/_patterns/00-atoms/16-video/_00-play-button.mustache +0 -0
- data/source/_patterns/00-atoms/17-utilities/00-visibility.mustache +8 -0
- data/source/_patterns/00-atoms/17-utilities/01-ui-elements.mustache +3 -0
- data/source/_patterns/00-atoms/18-grid/_00-grid.mustache +0 -0
- data/source/_patterns/01-molecules/00-text/00-header-groups.mustache +4 -0
- data/source/_patterns/01-molecules/00-text/01-intro-text.mustache +5 -0
- data/source/_patterns/01-molecules/01-layout/00-one-up.mustache +8 -0
- data/source/_patterns/01-molecules/01-layout/01-two-up.mustache +9 -0
- data/source/_patterns/01-molecules/01-layout/02-three-up.mustache +10 -0
- data/source/_patterns/01-molecules/01-layout/03-four-up.mustache +11 -0
- data/source/_patterns/01-molecules/01-layout/04-masonary-2.mustache +24 -0
- data/source/_patterns/01-molecules/01-layout/05-masonary-3.mustache +24 -0
- data/source/_patterns/01-molecules/02-navigation/01-subnav.mustache +21 -0
- data/source/_patterns/01-molecules/02-navigation/02-breadcrumbs.mustache +25 -0
- data/source/_patterns/01-molecules/02-navigation/03-side-nav.mustache +11 -0
- data/source/_patterns/01-molecules/02-navigation/04-side-nav-small.mustache +32 -0
- data/source/_patterns/01-molecules/02-navigation/05-pagination.mustache +0 -0
- data/source/_patterns/01-molecules/02-navigation/06-tabs.mustache +46 -0
- data/source/_patterns/01-molecules/03-forms/_00-search.mustache +0 -0
- data/source/_patterns/01-molecules/04-slider/00-slider.mustache +8 -0
- data/source/_patterns/01-molecules/05-messages/00-alert.mustache +15 -0
- data/source/_patterns/01-molecules/06-components/_00-social-share.mustache +0 -0
- data/source/_patterns/01-molecules/07-Elements/01-Addons-Card.mustache +79 -0
- data/source/_patterns/01-molecules/07-Elements/02-Buttons-Card.mustache +131 -0
- data/source/_patterns/01-molecules/07-Elements/03-Buildpack-Card.mustache +109 -0
- data/source/_patterns/01-molecules/08-vertical-tabs/01-vertical-tabs.mustache +30 -0
- data/source/_patterns/02-organisms/03-sections/00-purple.mustache +11 -0
- data/source/_patterns/02-organisms/03-sections/01-purple-dark.mustache +12 -0
- data/source/_patterns/02-organisms/03-sections/03-gray-light.mustache +12 -0
- data/source/css/hk-icon-rails.scss +13 -0
- data/source/css/scss/base/_base.scss +62 -0
- data/source/css/scss/base/_fonts.scss +12 -0
- data/source/css/scss/base/_normalize.scss +431 -0
- data/source/css/scss/base/_type.scss +128 -0
- data/source/css/scss/base/_utilities.scss +78 -0
- data/source/css/scss/components/_alert.scss +38 -0
- data/source/css/scss/components/_animate.scss +3340 -0
- data/source/css/scss/components/_animation.scss +15 -0
- data/source/css/scss/components/_buttons.scss +175 -0
- data/source/css/scss/components/_code.scss +26 -0
- data/source/css/scss/components/_forms.scss +136 -0
- data/source/css/scss/components/_hero.scss +18 -0
- data/source/css/scss/components/_hr.scss +11 -0
- data/source/css/scss/components/_icons.scss +85 -0
- data/source/css/scss/components/_lists.scss +45 -0
- data/source/css/scss/components/_logos.scss +15 -0
- data/source/css/scss/components/_masonary.scss +46 -0
- data/source/css/scss/components/_modal.scss +218 -0
- data/source/css/scss/components/_owlCarousel.scss +270 -0
- data/source/css/scss/components/_panel.scss +11 -0
- data/source/css/scss/components/_pill-box.scss +38 -0
- data/source/css/scss/components/_quote.scss +96 -0
- data/source/css/scss/components/_readmore.scss +11 -0
- data/source/css/scss/components/_slider.scss +96 -0
- data/source/css/scss/components/_spinner.scss +64 -0
- data/source/css/scss/components/_sprites.scss +3 -0
- data/source/css/scss/components/_sr-only.scss +10 -0
- data/source/css/scss/components/_tables.scss +62 -0
- data/source/css/scss/components/_tooltips.scss +93 -0
- data/source/css/scss/components/_users.scss +11 -0
- data/source/css/scss/components/_vertical-tabs.scss +129 -0
- data/source/css/scss/components/_video.scss +7 -0
- data/source/css/scss/ecosystem/_addons-card.scss +3 -0
- data/source/css/scss/ecosystem/_cards.scss +369 -0
- data/source/css/scss/ecosystem/_elements-brand.scss +32 -0
- data/source/css/scss/ecosystem/_elements.scss +4 -0
- data/source/css/scss/globals/_colors.scss +189 -0
- data/source/css/scss/globals/_mixins.scss +45 -0
- data/source/css/scss/globals/_variables.scss +87 -0
- data/source/css/scss/layout/_grid-settings.scss +13 -0
- data/source/css/scss/layout/_layout.scss +95 -0
- data/source/css/scss/page-elements/_headers.scss +3 -0
- data/source/css/scss/page-elements/_navigation.scss +254 -0
- data/source/css/scss/page-elements/_sections.scss +66 -0
- data/source/css/scss/page-elements/_sidebar.scss +34 -0
- data/source/css/shibori.scss +63 -0
- data/source/fonts/bentonsans/bentonsans-book.eot +0 -0
- data/source/fonts/bentonsans/bentonsans-book.svg +400 -0
- data/source/fonts/bentonsans/bentonsans-book.ttf +0 -0
- data/source/fonts/bentonsans/bentonsans-book.woff +0 -0
- data/source/fonts/bentonsans/bentonsans-medium.eot +0 -0
- data/source/fonts/bentonsans/bentonsans-medium.svg +416 -0
- data/source/fonts/bentonsans/bentonsans-medium.ttf +0 -0
- data/source/fonts/bentonsans/bentonsans-medium.woff +0 -0
- data/source/fonts/bentonsans/bentonsans-regular.eot +0 -0
- data/source/fonts/bentonsans/bentonsans-regular.svg +416 -0
- data/source/fonts/bentonsans/bentonsans-regular.ttf +0 -0
- data/source/fonts/bentonsans/bentonsans-regular.woff +0 -0
- data/source/fonts/hk-icon/hk-icon.eot +0 -0
- data/source/fonts/hk-icon/hk-icon.svg +261 -0
- data/source/fonts/hk-icon/hk-icon.ttf +0 -0
- data/source/fonts/hk-icon/hk-icon.woff +0 -0
- data/source/fonts/inconsolata/inconsolata-bold.eot +0 -0
- data/source/fonts/inconsolata/inconsolata-bold.svg +239 -0
- data/source/fonts/inconsolata/inconsolata-bold.ttf +0 -0
- data/source/fonts/inconsolata/inconsolata-bold.woff +0 -0
- data/source/fonts/inconsolata/inconsolata-regular.eot +0 -0
- data/source/fonts/inconsolata/inconsolata-regular.svg +239 -0
- data/source/fonts/inconsolata/inconsolata-regular.ttf +0 -0
- data/source/fonts/inconsolata/inconsolata-regular.woff +0 -0
- data/source/images/blockquote/close-sm.png +0 -0
- data/source/images/blockquote/close.png +0 -0
- data/source/images/blockquote/close@2x.png +0 -0
- data/source/images/blockquote/open-sm.png +0 -0
- data/source/images/blockquote/open.png +0 -0
- data/source/images/blockquote/open@2x.png +0 -0
- data/source/images/elements/heroku_suported.svg +32 -0
- data/source/images/forms/select-input-arrows.svg +8 -0
- data/source/js/init.js +26 -0
- data/source/js/main.js +22 -0
- data/source/js/vendor/bourbon-modal.js +17 -0
- data/source/js/vendor/fitvids.js +77 -0
- data/source/js/vendor/fixto.js +719 -0
- data/source/js/vendor/jquery-2.0.0b2.js +8690 -0
- data/source/js/vendor/modernizr.js +4 -0
- data/source/js/vendor/owl.carousel.js +3069 -0
- data/source/js/vendor/readmore.js +11 -0
- data/source/js/vendor/unslider.js +1 -0
- data/source/js/vendor/vertical-tabs.js +34 -0
- data/test/files/test.css +19 -0
- data/test/lineage_hunter_tests.js +262 -0
- data/test/list_item_hunter_tests.js +167 -0
- data/test/media_hunter_tests.js +74 -0
- data/test/object_factory_tests.js +62 -0
- data/test/parameter_hunter_tests.js +298 -0
- data/test/pattern_assembler_tests.js +43 -0
- data/test/patternlab_tests.js +8 -0
- metadata +320 -0
@@ -0,0 +1,114 @@
|
|
1
|
+
/*!
|
2
|
+
* Pattern Finder
|
3
|
+
*
|
4
|
+
* Copyright (c) 2014 Dave Olsen, http://dmolsen.com
|
5
|
+
* Licensed under the MIT license
|
6
|
+
*
|
7
|
+
*/
|
8
|
+
|
9
|
+
var patternFinder = {
|
10
|
+
|
11
|
+
data: [],
|
12
|
+
active: false,
|
13
|
+
|
14
|
+
init: function() {
|
15
|
+
|
16
|
+
for (var patternType in patternPaths) {
|
17
|
+
if (patternPaths.hasOwnProperty(patternType)) {
|
18
|
+
for (var pattern in patternPaths[patternType]) {
|
19
|
+
var obj = {};
|
20
|
+
obj.patternPartial = patternType+"-"+pattern;
|
21
|
+
obj.patternPath = patternPaths[patternType][pattern];
|
22
|
+
this.data.push(obj);
|
23
|
+
}
|
24
|
+
}
|
25
|
+
}
|
26
|
+
|
27
|
+
// instantiate the bloodhound suggestion engine
|
28
|
+
var patterns = new Bloodhound({
|
29
|
+
datumTokenizer: function(d) { return Bloodhound.tokenizers.nonword(d.patternPartial); },
|
30
|
+
queryTokenizer: Bloodhound.tokenizers.nonword,
|
31
|
+
limit: 10,
|
32
|
+
local: this.data
|
33
|
+
});
|
34
|
+
|
35
|
+
// initialize the bloodhound suggestion engine
|
36
|
+
patterns.initialize();
|
37
|
+
|
38
|
+
$('#sg-find .typeahead').typeahead({ highlight: true }, {
|
39
|
+
displayKey: 'patternPartial',
|
40
|
+
source: patterns.ttAdapter()
|
41
|
+
}).on('typeahead:selected', patternFinder.onAutocompleted).on('typeahead:autocompleted', patternFinder.onSelected);
|
42
|
+
|
43
|
+
},
|
44
|
+
|
45
|
+
passPath: function(item) {
|
46
|
+
// update the iframe via the history api handler
|
47
|
+
patternFinder.closeFinder();
|
48
|
+
var obj = JSON.stringify({ "path": urlHandler.getFileName(item.patternPartial) });
|
49
|
+
document.getElementById("sg-viewport").contentWindow.postMessage(JSON.parse(obj), urlHandler.targetOrigin);
|
50
|
+
},
|
51
|
+
|
52
|
+
onSelected: function(e,item) {
|
53
|
+
patternFinder.passPath(item);
|
54
|
+
},
|
55
|
+
|
56
|
+
onAutocompleted: function(e,item) {
|
57
|
+
patternFinder.passPath(item);
|
58
|
+
},
|
59
|
+
|
60
|
+
toggleFinder: function() {
|
61
|
+
if (!patternFinder.active) {
|
62
|
+
patternFinder.openFinder();
|
63
|
+
} else {
|
64
|
+
patternFinder.closeFinder();
|
65
|
+
}
|
66
|
+
},
|
67
|
+
|
68
|
+
openFinder: function() {
|
69
|
+
patternFinder.active = true;
|
70
|
+
$('#sg-find .typeahead').val("");
|
71
|
+
$("#sg-find").addClass('show-overflow');
|
72
|
+
$('#sg-find .typeahead').focus();
|
73
|
+
},
|
74
|
+
|
75
|
+
closeFinder: function() {
|
76
|
+
patternFinder.active = false;
|
77
|
+
$("#sg-find").removeClass('show-overflow');
|
78
|
+
$('.sg-acc-handle, .sg-acc-panel').removeClass('active');
|
79
|
+
$('#sg-find .typeahead').val("");
|
80
|
+
},
|
81
|
+
|
82
|
+
receiveIframeMessage: function(event) {
|
83
|
+
|
84
|
+
var data = (typeof event.data !== "string") ? event.data : JSON.parse(event.data);
|
85
|
+
|
86
|
+
// does the origin sending the message match the current host? if not dev/null the request
|
87
|
+
if ((window.location.protocol !== "file:") && (event.origin !== window.location.protocol+"//"+window.location.host)) {
|
88
|
+
return;
|
89
|
+
}
|
90
|
+
|
91
|
+
if (data.keyPress !== undefined) {
|
92
|
+
if (data.keyPress == 'ctrl+shift+f') {
|
93
|
+
patternFinder.toggleFinder();
|
94
|
+
return false;
|
95
|
+
}
|
96
|
+
}
|
97
|
+
|
98
|
+
}
|
99
|
+
|
100
|
+
}
|
101
|
+
|
102
|
+
patternFinder.init();
|
103
|
+
|
104
|
+
window.addEventListener("message", patternFinder.receiveIframeMessage, false);
|
105
|
+
|
106
|
+
$('#sg-find .typeahead').focus(function() {
|
107
|
+
if (!patternFinder.active) {
|
108
|
+
patternFinder.openFinder();
|
109
|
+
}
|
110
|
+
});
|
111
|
+
|
112
|
+
$('#sg-find .typeahead').blur(function() {
|
113
|
+
patternFinder.closeFinder();
|
114
|
+
});
|
@@ -0,0 +1,127 @@
|
|
1
|
+
/*!
|
2
|
+
* Basic postMessage Support - v0.1
|
3
|
+
*
|
4
|
+
* Copyright (c) 2013-2014 Dave Olsen, http://dmolsen.com
|
5
|
+
* Licensed under the MIT license
|
6
|
+
*
|
7
|
+
* Handles the postMessage stuff in the pattern, view-all, and style guide templates.
|
8
|
+
*
|
9
|
+
*/
|
10
|
+
|
11
|
+
// alert the iframe parent that the pattern has loaded assuming this view was loaded in an iframe
|
12
|
+
if (self != top) {
|
13
|
+
|
14
|
+
// handle the options that could be sent to the parent window
|
15
|
+
// - all get path
|
16
|
+
// - pattern & view all get a pattern partial, styleguide gets all
|
17
|
+
// - pattern shares lineage
|
18
|
+
var path = window.location.toString();
|
19
|
+
var parts = path.split("?");
|
20
|
+
var options = { "path": parts[0] };
|
21
|
+
options.patternpartial = (patternPartial !== "") ? patternPartial : "all";
|
22
|
+
if (lineage !== "") {
|
23
|
+
options.lineage = lineage;
|
24
|
+
}
|
25
|
+
|
26
|
+
var targetOrigin = (window.location.protocol == "file:") ? "*" : window.location.protocol+"//"+window.location.host;
|
27
|
+
parent.postMessage(options, targetOrigin);
|
28
|
+
|
29
|
+
// find all links and add an onclick handler for replacing the iframe address so the history works
|
30
|
+
var aTags = document.getElementsByTagName('a');
|
31
|
+
for (var i = 0; i < aTags.length; i++) {
|
32
|
+
aTags[i].onclick = function(e) {
|
33
|
+
e.preventDefault();
|
34
|
+
var href = this.getAttribute("href");
|
35
|
+
if (href != "#") {
|
36
|
+
window.location.replace(href);
|
37
|
+
}
|
38
|
+
};
|
39
|
+
}
|
40
|
+
|
41
|
+
// bind the keyboard shortcuts for various viewport resizings + pattern search
|
42
|
+
var keys = [ "s", "m", "l", "d", "h", "f" ];
|
43
|
+
for (var i = 0; i < keys.length; i++) {
|
44
|
+
jwerty.key('ctrl+shift+'+keys[i], function (k,t) {
|
45
|
+
return function(e) {
|
46
|
+
parent.postMessage({ "keyPress": "ctrl+shift+"+k },t);
|
47
|
+
return false;
|
48
|
+
}
|
49
|
+
}(keys[i],targetOrigin));
|
50
|
+
}
|
51
|
+
|
52
|
+
// bind the keyboard shortcuts for mqs
|
53
|
+
var i = 0;
|
54
|
+
while (i < 10) {
|
55
|
+
jwerty.key('ctrl+shift+'+i, function (k,t) {
|
56
|
+
return function(e) {
|
57
|
+
var targetOrigin = (window.location.protocol == "file:") ? "*" : window.location.protocol+"//"+window.location.host;
|
58
|
+
parent.postMessage({ "keyPress": "ctrl+shift+"+k },t);
|
59
|
+
return false;
|
60
|
+
}
|
61
|
+
}(i,targetOrigin));
|
62
|
+
i++;
|
63
|
+
}
|
64
|
+
|
65
|
+
}
|
66
|
+
|
67
|
+
// if there are clicks on the iframe make sure the nav in the iframe parent closes
|
68
|
+
var body = document.getElementsByTagName('body');
|
69
|
+
body[0].onclick = function() {
|
70
|
+
var targetOrigin = (window.location.protocol == "file:") ? "*" : window.location.protocol+"//"+window.location.host;
|
71
|
+
parent.postMessage({ "bodyclick": "bodyclick" },targetOrigin);
|
72
|
+
};
|
73
|
+
|
74
|
+
// watch the iframe source so that it can be sent back to everyone else.
|
75
|
+
function receiveIframeMessage(event) {
|
76
|
+
|
77
|
+
var path;
|
78
|
+
var data = (typeof event.data !== "string") ? event.data : JSON.parse(event.data);
|
79
|
+
|
80
|
+
// does the origin sending the message match the current host? if not dev/null the request
|
81
|
+
if ((window.location.protocol != "file:") && (event.origin !== window.location.protocol+"//"+window.location.host)) {
|
82
|
+
return;
|
83
|
+
}
|
84
|
+
|
85
|
+
// see if it got a path to replace
|
86
|
+
if (data.path !== undefined) {
|
87
|
+
|
88
|
+
if (patternPartial !== "") {
|
89
|
+
|
90
|
+
if(baseurl){
|
91
|
+
// create main site url
|
92
|
+
var siteurl = window.location.protocol+"//"+window.location.host;
|
93
|
+
// add a trailing slash if it doesn't exist
|
94
|
+
siteurl = siteurl.replace(/\/?$/, '/');
|
95
|
+
// remove a begining slash for baseurl if it exists
|
96
|
+
baseurl = baseurl.replace(/^\//, '');
|
97
|
+
// connect baseurl to siteurl
|
98
|
+
siteurl = siteurl + baseurl;
|
99
|
+
// add a trailing slash if it doesn't exist
|
100
|
+
siteurl = siteurl.replace(/\/?$/, '/');
|
101
|
+
// build our final path
|
102
|
+
path = siteurl+data.path+'?'+Date.now();
|
103
|
+
} else {
|
104
|
+
// handle patterns and the view all page
|
105
|
+
var re = /patterns\/(.*)$/;
|
106
|
+
path = window.location.protocol+"//"+window.location.host+window.location.pathname.replace(re,'')+data.path+'?'+Date.now();
|
107
|
+
}
|
108
|
+
|
109
|
+
window.location.replace(path);
|
110
|
+
|
111
|
+
} else {
|
112
|
+
|
113
|
+
// handle the style guide
|
114
|
+
path = window.location.protocol+"//"+window.location.host+window.location.pathname.replace("styleguide\/html\/styleguide.html","")+data.path+'?'+Date.now();
|
115
|
+
window.location.replace(path);
|
116
|
+
|
117
|
+
}
|
118
|
+
|
119
|
+
} else if (data.reload !== undefined) {
|
120
|
+
|
121
|
+
// reload the location if there was a message to do so
|
122
|
+
window.location.reload();
|
123
|
+
|
124
|
+
}
|
125
|
+
|
126
|
+
}
|
127
|
+
window.addEventListener("message", receiveIframeMessage, false);
|