-
Notifications
You must be signed in to change notification settings - Fork 0
/
contributing.html
222 lines (175 loc) · 9.24 KB
/
contributing.html
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
<!DOCTYPE html>
<!--[if lt IE 7]>
<html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>
<html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>
<html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!-->
<html class="no-js">
<!--<![endif]-->
<head>
<meta charset="utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<meta name="fragment" content="!"/>
<title>Contributing</title>
<link rel="stylesheet" href="assets-demo/richwidgets-demo.min.css">
<script src="assets-demo/richwidgets-demo.min.js"></script>
<link rel="stylesheet" href="assets-demo/highlightjs/styles/github.css">
<script src="assets-demo/modernizr/modernizr.js"></script>
<script src="assets-demo/highlightjs/highlight.pack.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
<script src="assets-demo/bootstrap/js/dropdown.js"></script>
<script src="assets-demo/bootstrap/js/collapse.js"></script>
</head>
<body class="">
<nav class="navbar-rcue navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href=".">RichWidgets</a>
</div>
<div class="collapse navbar-collapse navbar-ex1-collapse">
<ul class="nav navbar-nav navbar-primary navbar-left">
<li ><a href=".">Home</a></li>
<li class="dropdown ">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Widgets <b class="caret"></b></a>
<ul class="dropdown-menu">
<li ><a href="input/autocomplete.html">Autocomplete</a></li>
<li ><a href="output/charts.html">Charts</a></li>
<li ><a href="select/ordering-list.html">OrderingList</a></li>
<li ><a href="select/pick-list.html">PickList</a></li>
</ul>
</li>
<li><a href="/api">API Docs</a></li>
</ul>
<ul class="nav navbar-nav navbar-primary navbar-right">
<li ><a href="about.html">About</a></li>
<li ><a href="tests.html">Testing</a></li>
<li class="active"><a href="contributing.html">Contributing</a></li>
</ul>
</div>
</div>
</nav>
<div class="container">
<a id="fork-me-on-github-ribbon" href="https://github.com/richwidgets/richwidgets"><img src="https://s3.amazonaws.com/github/ribbons/forkme_right_red_aa0000.png" alt="Fork me on GitHub"></a>
<h1 id="contributing-to-richwidgets-build-status-https-travis-ci-org-richwidgets-richwidgets-png-branch-master-https-travis-ci-org-richwidgets-richwidgets-">Contributing to RichWidgets <a href="https://travis-ci.org/richwidgets/richwidgets"><img src="https://travis-ci.org/richwidgets/richwidgets.png?branch=master" alt="Build Status"></a></h1>
<blockquote>
<p>A JavaScript project containing standalone javascript widgets based on Bootstrap, jQuery UI and other third-party widgets, styled with LESS.</p>
</blockquote>
<h2 id="hacking-on-richwidgets">Hacking on RichWidgets</h2>
<p>Begin by setting you your environment and making sure you can build RichWidgets as described the
<a href="https://github.com/richwidgets/richwidgets/blob/master/README.md#build">README.md</a>.</p>
<p>Widgets are highly visual constructs, and we are more effective in developing them when we get rapid feedback as we introduce changes.
Without this rapid feedback, we are like sculptors carving blindfolded!</p>
<p>Run the <code>grunt dev</code> command from the richwidgets root folder to start up a development version of the online demo with
integrated <a href="https://github.com/livereload/livereload-js">live-reload</a>. You will see this demo runnin locally at:</p>
<blockquote>
<p><a href="http://localhost:9000">http://localhost:9000</a></p>
</blockquote>
<p>As you make changes to the html, javascript, and LESS
source, the source will be compiled and the demo site will be updated.</p>
<p>Additionally, this development version of the demo uses unminified versions of the sources making it easier to debug your widget
in your browsers development tools.</p>
<p>The demo pages themselves use <a href="http://handlebarsjs.com/">handlebars.js</a> for templating. This allows us to keep our demo
code <a href="http://en.wikipedia.org/wiki/Don%27t_Repeat_Yourself">DRY</a> by using the same code to both run the page sample as well as display
the code on the page. Handlebars is easily extensible through it's <a href="http://assemble.io/docs/Custom-Helpers.html">helper</a>
mechanism. If you find yourself bending over backwards to make something work, consider writing such a helper.</p>
<h2 id="publishing-the-demos">Publishing the demos</h2>
<p>Publish the demos to github pages using the grunt task <code>grunt site</code></p>
<h2 id="coding-style">Coding Style</h2>
<p>It helps to be consistent. Here are the coding style conventions we have agreed to follow in this project. this will be
updated as new discrepancies are discovered and cleaned up. Wherever possible these conventions are being monitored by
jshint.</p>
<ul>
<li>Indentation<ul>
<li>Use spaces (not tabs)</li>
<li>Indentation size is 2 spaces</li>
</ul>
</li>
<li>Filenames<ul>
<li>All filenames will use a lowercase-hyphenated naming convention (e.g. <code>popup-panel.js</code>)</li>
</ul>
</li>
<li>LESS<ul>
<li>CSS class names use lowercase-hyphenated naming convention (e.g. <code>popup-panel</code>)</li>
<li>Define variables centrally in <code>src/widgets/variables.less</code></li>
<li>Define mixins centrally in <code>src/widgets/mixins.less</code></li>
</ul>
</li>
<li>JavaScript<ul>
<li>Functions and variables names use camelCase (e.g. <code>popupPanelWidth</code>, <code>showPopup()</code>)</li>
<li>Single quotes <code>'</code> for strings</li>
<li>do not use <code>self</code> for capturing a reference to <code>this</code><ul>
<li>use <code>widget</code> where it makes sense to do so, <code>that</code> otherwise</li>
</ul>
</li>
<li>function white-spaces<ul>
<li>named functions<ul>
<li><code>function name(param1, param2) {}</code></li>
</ul>
</li>
<li>unnamed functions<ul>
<li><code>function (param1, param2) {}</code></li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<li>Widget Factory<ul>
<li>Use the <code>rich</code> jquery plugin namespace</li>
<li>No widget name prefix when it is not required<ul>
<li>i.e. when we extend upstream plugin's functionality, we make sure the API is compatible (e.g. <code>rich.autocomplete</code> extending <code>ui.autocomplete</code>)</li>
</ul>
</li>
<li>Widget event prefix: stick with the default name of the widget (eg. no underscores or abbreviating)</li>
<li>Initialize all options, using <code>null</code> as default value is required</li>
<li>Widget state should be collected for use in _trigger invocations using a method called <code>_uiHash</code></li>
<li>order of methods inside widget definition<ol>
<li>lifecycle methods (e.g. <code>_create()</code>, <code>_destroy()</code>)</li>
<li>public API methods (e.g. <code>showPopup()</code>)</li>
<li>private methods<ol>
<li>initialization methods (e.g. <code>_setOption()</code>, <code>_initDom()</code>, <code>_bindListeners()</code>)</li>
<li>cleanup methods (E.g. <code>_cleanDom()</code>)</li>
<li>common utility methods (e.g. <code>_enable()</code>, <code>_disable()</code>, <code>_uiHash()</code>)</li>
<li>event handlers</li>
<li>other private methods (E.g. <code>_uiHash()</code>)</li>
</ol>
</li>
</ol>
</li>
<li>use <code>this._super(key, value)</code> or <code>this._superApply(arguments)</code> for delegation to parent implementation</li>
</ul>
</li>
</ul>
<h2 id="creating-a-new-widget">Creating a new widget</h2>
<p>To create a new widget called "My widget", start by creating the files:</p>
<ul>
<li><code>src/widget/<widget-family>/my-widget.less</code></li>
<li><code>src/widget/<widget-family>/my-widget.js</code></li>
</ul>
<p>Create a demo for your widget in</p>
<ul>
<li><code>src/demo/pages/<widget-family/my-widget.hbs</code></li>
</ul>
<p>The demo pages use <a href="http://handlebarsjs.com/">handlebars.js</a>, and will be added to the site navigation automatically.</p>
<h2 id="testing">Testing</h2>
<p>Read about our approach to testing in the <a href="https://github.com/richwidgets/richwidgets/blob/master/TESTS.md">TESTS.md</a> guide.</p>
</div>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-7306415-8', 'richwidgets.io');
ga('send', 'pageview');
</script>
</body>
</html>