shibori 1.0.0.beta1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,289 @@
|
|
1
|
+
/*!
|
2
|
+
* Annotations Support for the Viewer - v0.3
|
3
|
+
*
|
4
|
+
* Copyright (c) 2013 Brad Frost, http://bradfrostweb.com & Dave Olsen, http://dmolsen.com
|
5
|
+
* Licensed under the MIT license
|
6
|
+
*
|
7
|
+
*/
|
8
|
+
|
9
|
+
var annotationsViewer = {
|
10
|
+
|
11
|
+
// set-up default sections
|
12
|
+
commentsActive: false,
|
13
|
+
commentsViewAllActive: false,
|
14
|
+
targetOrigin: (window.location.protocol === "file:") ? "*" : window.location.protocol+"//"+window.location.host,
|
15
|
+
moveToOnInit: 0,
|
16
|
+
|
17
|
+
/**
|
18
|
+
* add the onclick handler to the annotations link in the main nav
|
19
|
+
*/
|
20
|
+
onReady: function() {
|
21
|
+
|
22
|
+
// not sure this is used anymore...
|
23
|
+
$('body').addClass('comments-ready');
|
24
|
+
|
25
|
+
$(window).resize(function() {
|
26
|
+
if(!annotationsViewer.commentsActive) {
|
27
|
+
annotationsViewer.slideComment($('#sg-annotation-container').outerHeight());
|
28
|
+
}
|
29
|
+
});
|
30
|
+
|
31
|
+
$('#sg-t-annotations').click(function(e) {
|
32
|
+
|
33
|
+
e.preventDefault();
|
34
|
+
|
35
|
+
// remove the class from the "eye" nav item
|
36
|
+
$('#sg-t-toggle').removeClass('active');
|
37
|
+
|
38
|
+
// turn the annotations section on and off
|
39
|
+
annotationsViewer.toggleComments();
|
40
|
+
|
41
|
+
});
|
42
|
+
|
43
|
+
// initialize the annotations viewer
|
44
|
+
annotationsViewer.commentContainerInit();
|
45
|
+
|
46
|
+
// load the query strings in case code view has to show by default
|
47
|
+
var queryStringVars = urlHandler.getRequestVars();
|
48
|
+
if ((queryStringVars.view !== undefined) && ((queryStringVars.view === "annotations") || (queryStringVars.view === "a"))) {
|
49
|
+
annotationsViewer.openComments();
|
50
|
+
if (queryStringVars.number !== undefined) {
|
51
|
+
annotationsViewer.moveToOnInit = queryStringVars.number;
|
52
|
+
}
|
53
|
+
}
|
54
|
+
|
55
|
+
},
|
56
|
+
|
57
|
+
/**
|
58
|
+
* decide on if the annotations panel should be open or closed
|
59
|
+
*/
|
60
|
+
toggleComments: function() {
|
61
|
+
|
62
|
+
if (!annotationsViewer.commentsActive) {
|
63
|
+
annotationsViewer.openComments();
|
64
|
+
} else {
|
65
|
+
annotationsViewer.closeComments();
|
66
|
+
}
|
67
|
+
|
68
|
+
},
|
69
|
+
|
70
|
+
/**
|
71
|
+
* open the annotations panel
|
72
|
+
*/
|
73
|
+
openComments: function() {
|
74
|
+
|
75
|
+
// make sure the code view overlay is off before showing the annotations view
|
76
|
+
$('#sg-t-code').removeClass('active');
|
77
|
+
codeViewer.codeActive = false;
|
78
|
+
var obj = JSON.stringify({ "codeToggle": "off" });
|
79
|
+
document.getElementById('sg-viewport').contentWindow.postMessage(obj,annotationsViewer.targetOrigin);
|
80
|
+
codeViewer.slideCode(999);
|
81
|
+
|
82
|
+
// tell the iframe annotation view has been turned on
|
83
|
+
var obj = JSON.stringify({ "commentToggle": "on" });
|
84
|
+
document.getElementById('sg-viewport').contentWindow.postMessage(obj,annotationsViewer.targetOrigin);
|
85
|
+
|
86
|
+
// note that it's turned on in the viewer
|
87
|
+
annotationsViewer.commentsActive = true;
|
88
|
+
$('#sg-t-annotations').addClass('active');
|
89
|
+
},
|
90
|
+
|
91
|
+
/**
|
92
|
+
* close the annotations panel
|
93
|
+
*/
|
94
|
+
closeComments: function() {
|
95
|
+
annotationsViewer.commentsActive = false;
|
96
|
+
var obj = JSON.stringify({ "commentToggle": "off" });
|
97
|
+
document.getElementById('sg-viewport').contentWindow.postMessage(obj,annotationsViewer.targetOrigin);
|
98
|
+
annotationsViewer.slideComment($('#sg-annotation-container').outerHeight());
|
99
|
+
$('#sg-t-annotations').removeClass('active');
|
100
|
+
},
|
101
|
+
|
102
|
+
/**
|
103
|
+
* add the basic mark-up and events for the annotations container
|
104
|
+
*/
|
105
|
+
commentContainerInit: function() {
|
106
|
+
|
107
|
+
// the bulk of this template is in core/templates/index.mustache
|
108
|
+
if (document.getElementById("sg-annotation-container") === null) {
|
109
|
+
$('<div id="sg-annotation-container" class="sg-view-container"></div>').html($("#annotations-template").html()).appendTo('body').css('bottom',-$(document).outerHeight());
|
110
|
+
setTimeout(function(){ $('#sg-annotation-container').addClass('anim-ready'); },50); //Add animation class once container is positioned out of frame
|
111
|
+
}
|
112
|
+
|
113
|
+
// make sure the close button handles the click
|
114
|
+
$('body').delegate('#sg-annotation-close-btn','click',function() {
|
115
|
+
annotationsViewer.commentsActive = false;
|
116
|
+
$('#sg-t-annotations').removeClass('active');
|
117
|
+
annotationsViewer.slideComment($('#sg-annotation-container').outerHeight());
|
118
|
+
var obj = JSON.stringify({ "commentToggle": "off" });
|
119
|
+
document.getElementById('sg-viewport').contentWindow.postMessage(obj,annotationsViewer.targetOrigin);
|
120
|
+
return false;
|
121
|
+
});
|
122
|
+
|
123
|
+
},
|
124
|
+
|
125
|
+
/**
|
126
|
+
* slides the panel
|
127
|
+
*/
|
128
|
+
slideComment: function(pos) {
|
129
|
+
$('#sg-annotation-container').css('bottom',-pos);
|
130
|
+
},
|
131
|
+
|
132
|
+
/**
|
133
|
+
* moves to a particular item in the viewer
|
134
|
+
*/
|
135
|
+
moveTo: function(number) {
|
136
|
+
if (document.getElementById("annotation-"+number) !== undefined) {
|
137
|
+
var top = document.getElementById("annotation-"+number).offsetTop;
|
138
|
+
$('#sg-annotation-container').animate({scrollTop: top - 10}, 600);
|
139
|
+
}
|
140
|
+
},
|
141
|
+
|
142
|
+
/**
|
143
|
+
* when turning on or switching between patterns with annotations view on make sure we get
|
144
|
+
* the annotations from from the pattern via post message
|
145
|
+
*/
|
146
|
+
updateComments: function(comments) {
|
147
|
+
|
148
|
+
var commentsContainer = document.getElementById("sg-comments-container");
|
149
|
+
|
150
|
+
// clear out the comments container
|
151
|
+
if (commentsContainer.innerHTML !== "") {
|
152
|
+
commentsContainer.innerHTML = "";
|
153
|
+
}
|
154
|
+
|
155
|
+
// see how many comments this pattern might have. if more than zero write them out. if not alert the user to the fact their aren't any
|
156
|
+
var count = Object.keys(comments).length;
|
157
|
+
if (count > 0) {
|
158
|
+
|
159
|
+
for (i = 1; i <= count; i++) {
|
160
|
+
|
161
|
+
var displayNum = comments[i].number;
|
162
|
+
|
163
|
+
var span = document.createElement("span");
|
164
|
+
span.id = "annotation-state-" + displayNum;
|
165
|
+
span.style.fontSize = "0.8em";
|
166
|
+
span.style.color = "#666";
|
167
|
+
if (comments[i].state === false) {
|
168
|
+
span.innerHTML = " hidden";
|
169
|
+
}
|
170
|
+
|
171
|
+
var h2 = document.createElement("h2");
|
172
|
+
h2.innerHTML = displayNum + ". " + comments[i].title;
|
173
|
+
h2.appendChild(span);
|
174
|
+
|
175
|
+
var div = document.createElement("div");
|
176
|
+
div.innerHTML = comments[i].comment;
|
177
|
+
|
178
|
+
var commentDiv = document.createElement("div");
|
179
|
+
commentDiv.classList.add("sg-comment-container");
|
180
|
+
commentDiv.id = "annotation-" + displayNum;
|
181
|
+
commentDiv.appendChild(h2);
|
182
|
+
commentDiv.appendChild(div);
|
183
|
+
|
184
|
+
commentsContainer.appendChild(commentDiv);
|
185
|
+
|
186
|
+
}
|
187
|
+
|
188
|
+
} else {
|
189
|
+
|
190
|
+
var h2 = document.createElement("h2");
|
191
|
+
h2.innerHTML = "No Annotations";
|
192
|
+
|
193
|
+
var div = document.createElement("div");
|
194
|
+
div.innerHTML = "There are no annotations for this pattern.";
|
195
|
+
|
196
|
+
var commentDiv = document.createElement("div");
|
197
|
+
commentDiv.classList.add("sg-comment-container");
|
198
|
+
commentDiv.appendChild(h2);
|
199
|
+
commentDiv.appendChild(div);
|
200
|
+
|
201
|
+
commentsContainer.appendChild(commentDiv);
|
202
|
+
|
203
|
+
}
|
204
|
+
|
205
|
+
// slide the comment section into view
|
206
|
+
annotationsViewer.slideComment(0);
|
207
|
+
|
208
|
+
if (annotationsViewer.moveToOnInit != "0") {
|
209
|
+
annotationsViewer.moveTo(annotationsViewer.moveToOnInit);
|
210
|
+
annotationsViewer.moveToOnInit = "0";
|
211
|
+
}
|
212
|
+
|
213
|
+
},
|
214
|
+
|
215
|
+
/**
|
216
|
+
* toggle the comment pop-up based on a user clicking on the pattern
|
217
|
+
* based on the great MDN docs at https://developer.mozilla.org/en-US/docs/Web/API/window.postMessage
|
218
|
+
* @param {Object} event info
|
219
|
+
*/
|
220
|
+
receiveIframeMessage: function(event) {
|
221
|
+
|
222
|
+
var data = (typeof event.data !== "string") ? event.data : JSON.parse(event.data);
|
223
|
+
|
224
|
+
// does the origin sending the message match the current host? if not dev/null the request
|
225
|
+
if ((window.location.protocol !== "file:") && (event.origin !== window.location.protocol+"//"+window.location.host)) {
|
226
|
+
return;
|
227
|
+
}
|
228
|
+
|
229
|
+
if (data.commentOverlay !== undefined) {
|
230
|
+
if (data.commentOverlay === "on") {
|
231
|
+
annotationsViewer.updateComments(data.comments);
|
232
|
+
} else {
|
233
|
+
annotationsViewer.slideComment($('#sg-annotation-container').outerHeight());
|
234
|
+
}
|
235
|
+
} else if (data.annotationState !== undefined) {
|
236
|
+
document.getElementById("annotation-state-"+data.displayNumber).innerHTML = (data.annotationState == true) ? "" : " hidden";
|
237
|
+
} else if (data.displaynumber !== undefined) {
|
238
|
+
annotationsViewer.moveTo(data.displaynumber);
|
239
|
+
} else if (data.keyPress !== undefined) {
|
240
|
+
if (data.keyPress == 'ctrl+shift+a') {
|
241
|
+
annotationsViewer.toggleComments();
|
242
|
+
return false;
|
243
|
+
} else if (data.keyPress == 'esc') {
|
244
|
+
if (annotationsViewer.commentsActive) {
|
245
|
+
annotationsViewer.closeComments();
|
246
|
+
return false;
|
247
|
+
}
|
248
|
+
}
|
249
|
+
} else if (data.patternpartial !== undefined) {
|
250
|
+
if (annotationsViewer.commentsViewAllActive && (data.patternpartial.indexOf("viewall-") != -1)) {
|
251
|
+
var obj = JSON.stringify({ "commentToggle": "on" });
|
252
|
+
document.getElementById('sg-viewport').contentWindow.postMessage(obj,annotationsViewer.targetOrigin);
|
253
|
+
}
|
254
|
+
}
|
255
|
+
|
256
|
+
}
|
257
|
+
|
258
|
+
};
|
259
|
+
|
260
|
+
$(document).ready(function() { annotationsViewer.onReady(); });
|
261
|
+
window.addEventListener("message", annotationsViewer.receiveIframeMessage, false);
|
262
|
+
|
263
|
+
// make sure if a new pattern or view-all is loaded that comments are turned on as appropriate
|
264
|
+
$('#sg-viewport').load(function() {
|
265
|
+
if (annotationsViewer.commentsActive) {
|
266
|
+
var obj = JSON.stringify({ "commentToggle": "on" });
|
267
|
+
document.getElementById('sg-viewport').contentWindow.postMessage(obj,annotationsViewer.targetOrigin);
|
268
|
+
}
|
269
|
+
});
|
270
|
+
|
271
|
+
// no idea why this has to be outside. there's something funky going on with the JS pattern
|
272
|
+
$('#sg-view li a').click(function() {
|
273
|
+
$(this).parent().parent().removeClass('active');
|
274
|
+
$(this).parent().parent().parent().parent().removeClass('active');
|
275
|
+
});
|
276
|
+
|
277
|
+
// toggle the annotations panel
|
278
|
+
jwerty.key('ctrl+shift+a', function (e) {
|
279
|
+
annotationsViewer.toggleComments();
|
280
|
+
return false;
|
281
|
+
});
|
282
|
+
|
283
|
+
// close the annotations panel if using escape
|
284
|
+
jwerty.key('esc', function (e) {
|
285
|
+
if (annotationsViewer.commentsActive) {
|
286
|
+
annotationsViewer.closeComments();
|
287
|
+
return false;
|
288
|
+
}
|
289
|
+
});
|
@@ -0,0 +1,120 @@
|
|
1
|
+
/*!
|
2
|
+
* Code View Support for Patterns - v0.3
|
3
|
+
*
|
4
|
+
* Copyright (c) 2013-2014 Dave Olsen, http://dmolsen.com
|
5
|
+
* Licensed under the MIT license
|
6
|
+
*
|
7
|
+
*/
|
8
|
+
|
9
|
+
var codePattern = {
|
10
|
+
|
11
|
+
codeOverlayActive: false,
|
12
|
+
codeEmbeddedActive: false,
|
13
|
+
targetOrigin: (window.location.protocol === "file:") ? "*" : window.location.protocol+"//"+window.location.host,
|
14
|
+
|
15
|
+
/**
|
16
|
+
* toggle the annotation feature on/off
|
17
|
+
* based on the great MDN docs at https://developer.mozilla.org/en-US/docs/Web/API/window.postMessage
|
18
|
+
* @param {Object} event info
|
19
|
+
*/
|
20
|
+
receiveIframeMessage: function(event) {
|
21
|
+
|
22
|
+
var data = (typeof event.data !== "string") ? event.data : JSON.parse(event.data);
|
23
|
+
|
24
|
+
// does the origin sending the message match the current host? if not dev/null the request
|
25
|
+
if ((window.location.protocol != "file:") && (event.origin !== window.location.protocol+"//"+window.location.host)) {
|
26
|
+
return;
|
27
|
+
}
|
28
|
+
|
29
|
+
if (data.codeToggle !== undefined) {
|
30
|
+
|
31
|
+
var els, i;
|
32
|
+
|
33
|
+
// if this is an overlay make sure it's active for the onclick event
|
34
|
+
codePattern.codeOverlayActive = false;
|
35
|
+
codePattern.codeEmbeddedActive = false;
|
36
|
+
|
37
|
+
// see which flag to toggle based on if this is a styleguide or view-all page
|
38
|
+
if ((data.codeToggle == "on") && (document.getElementById("sg-patterns") !== null)) {
|
39
|
+
codePattern.codeEmbeddedActive = true;
|
40
|
+
} else if (data.codeToggle == "on") {
|
41
|
+
codePattern.codeOverlayActive = true;
|
42
|
+
}
|
43
|
+
|
44
|
+
// if comments embedding is turned off make sure to hide the annotations div
|
45
|
+
if (!codePattern.codeEmbeddedActive && (document.getElementById("sg-patterns") !== null)) {
|
46
|
+
els = document.getElementsByClassName("sg-code");
|
47
|
+
for (i = 0; i < els.length; i++) {
|
48
|
+
els[i].style.display = "none";
|
49
|
+
}
|
50
|
+
}
|
51
|
+
|
52
|
+
// if comments overlay is turned on add the has-comment class and pointer
|
53
|
+
if (codePattern.codeOverlayActive) {
|
54
|
+
|
55
|
+
var obj = JSON.stringify({ "codeOverlay": "on", "lineage": lineage, "lineageR": lineageR, "patternPartial": patternPartial, "patternState": patternState, "cssEnabled": cssEnabled });
|
56
|
+
parent.postMessage(obj,codePattern.targetOrigin);
|
57
|
+
|
58
|
+
} else if (codePattern.codeEmbeddedActive) {
|
59
|
+
|
60
|
+
// if code embedding is turned on simply display them
|
61
|
+
els = document.getElementsByClassName("sg-code");
|
62
|
+
for (i = 0; i < els.length; ++i) {
|
63
|
+
els[i].style.display = "block";
|
64
|
+
}
|
65
|
+
|
66
|
+
}
|
67
|
+
|
68
|
+
}
|
69
|
+
|
70
|
+
}
|
71
|
+
|
72
|
+
};
|
73
|
+
|
74
|
+
// add the onclick handlers to the elements that have an annotations
|
75
|
+
window.addEventListener("message", codePattern.receiveIframeMessage, false);
|
76
|
+
|
77
|
+
// before unloading the iframe make sure any active overlay is turned off/closed
|
78
|
+
window.onbeforeunload = function() {
|
79
|
+
var obj = JSON.stringify({ "codeOverlay": "off" });
|
80
|
+
parent.postMessage(obj,codePattern.targetOrigin);
|
81
|
+
};
|
82
|
+
|
83
|
+
// tell the parent iframe that keys were pressed
|
84
|
+
|
85
|
+
// toggle the code panel
|
86
|
+
jwerty.key('ctrl+shift+c', function (e) {
|
87
|
+
var obj = JSON.stringify({ "keyPress": "ctrl+shift+c" });
|
88
|
+
parent.postMessage(obj,codePattern.targetOrigin);
|
89
|
+
return false;
|
90
|
+
});
|
91
|
+
|
92
|
+
// when the code panel is open hijack cmd+a so that it only selects the code view
|
93
|
+
jwerty.key('cmd+a/ctrl+a', function (e) {
|
94
|
+
if (codePattern.codeOverlayActive) {
|
95
|
+
var obj = JSON.stringify({ "keyPress": "cmd+a" });
|
96
|
+
parent.postMessage(obj,codePattern.targetOrigin);
|
97
|
+
return false;
|
98
|
+
}
|
99
|
+
});
|
100
|
+
|
101
|
+
// open the mustache panel
|
102
|
+
jwerty.key('ctrl+shift+u', function (e) {
|
103
|
+
var obj = JSON.stringify({ "keyPress": "ctrl+shift+u" });
|
104
|
+
parent.postMessage(obj,codePattern.targetOrigin);
|
105
|
+
return false;
|
106
|
+
});
|
107
|
+
|
108
|
+
// open the html panel
|
109
|
+
jwerty.key('ctrl+shift+h', function (e) {
|
110
|
+
var obj = JSON.stringify({ "keyPress": "ctrl+shift+h" });
|
111
|
+
parent.postMessage(obj,codePattern.targetOrigin);
|
112
|
+
return false;
|
113
|
+
});
|
114
|
+
|
115
|
+
// close the code panel if using escape
|
116
|
+
jwerty.key('esc', function (e) {
|
117
|
+
var obj = JSON.stringify({ "keyPress": "esc" });
|
118
|
+
parent.postMessage(obj,codePattern.targetOrigin);
|
119
|
+
return false;
|
120
|
+
});
|