Browse Source

Updates to docs

pull/1177/head
jlukic 10 years ago
parent
commit
2321e322eb
6 changed files with 61 additions and 44 deletions
  1. 2
      server/documents/collections/message.html.eco
  2. 53
      server/documents/modules/api.html.eco
  3. 32
      server/documents/modules/dimmer.html.eco
  4. 3
      server/files/javascript/api.js
  5. 9
      server/files/javascript/semantic.js
  6. 6
      server/files/stylesheets/semantic.css

2
server/documents/collections/message.html.eco

@ -58,7 +58,7 @@ themes : ['Default', 'GitHub', 'Google']
</div>
<div class="another example">
<div class="ui icon message">
<i class="circular notched circle loading icon"></i>
<i class="notched circle loading icon"></i>
<div class="content">
<div class="header">
Just one second

53
server/documents/modules/api.html.eco

@ -98,7 +98,8 @@ type : 'UI Behavior'
</div>
<div class="no example">
<h4 class="ui header">Working with URLs</h4>
<p>Named API actions are offered for convenience and maintanability, but are not required. You can also specify the url in each request, templated or not.</p>
<p>Named API actions are offered for convenience and maintanability, but are not required.</p>
<p>You can also specify the url in each request, templated or not:</p>
<div class="code">
$('.search.button')
.api({
@ -112,7 +113,7 @@ type : 'UI Behavior'
<div class="ui top attached info message">
<div class="ui header">Open Your Web Console</div>
The following examples work best while viewing logs in your web console. This experienced is optimized for Firebug, but will also appear in webkit browsers <a href="https://code.google.com/p/chromium/issues/detail?id=306120" target="_blank">with minor issues.</a>
<p>The following examples work best while viewing logs in your web console. This experienced is optimized for Firebug, but will also appear in webkit browsers <a href="https://code.google.com/p/chromium/issues/detail?id=306120" target="_blank">with minor issues.</a></p>
</div>
<div class="ui bottom attached message">
API requests for the following demos have been faked using <a href="http://sinonjs.org/">SinonJS</a> to avoid rate throttling from public APIs. No actual data is returned.
@ -233,36 +234,31 @@ type : 'UI Behavior'
</div>
<div class="no example">
<h4 class="ui header">Request Information in Data Attributes</h4>
<h4 class="ui header">Data Specified in Data Attributes</h4>
<p>You can include url values as html5 metadata attributes</p>
<p>This is often easiest to include unique url data for each triggering element, for example, many follow buttons will trigger the same endpoint, but each will have its own user id.</p>
<p>As a convenience, you can also specify your API action in metadata, to allow you to instantiate multiple types of api actions in one statement.</p>
<div class="ui ignored warning message">
Only variables specified in your API's URL will be searched for in metadata.
</div>
<div class="code" data-type="html">
<div class="ui button" data-action="follow user" data-id="11">
<div class="ui button" data-id="11">
Follow 1
</div>
<div class="ui button" data-action="add user" data-id="11">
Add Stevie
</div>
<div class="ui button" data-action="follow user" data-id="22">
<div class="ui button" data-id="22">
Follow Jenny
</div>
<div class="ui button" data-action="add user" data-id="22">
Add Jennie
</div>
</div>
<div class="code" data-type="javascript">
$('.follow.button')
.api()
.api({
action: 'follow user'
})
;
</div>
</div>
<div class="no example">
<h4 class="ui header">Data specified in Javascript</h4>
<h4 class="ui header">Data Specified in Javascript</h4>
<p>URL variable, and GET/POST data can be specified at run-time in the javascript object </p>
<div class="code" data-type="javascript">
$('.follow.button')
@ -329,17 +325,17 @@ type : 'UI Behavior'
<h2 class="ui dividing header">Sending Data</h2>
<div class="example">
<h4 class="ui header">Automatically Routed Data</h4>
<h4 class="ui header">Serializing Form Data</h4>
<p>Calling API on any element inside of a form, will automatically include serialized form content in your request when using a special setting <code>serializeForm</code>, or using a form as the <code>stateContext</code>.</p>
<p>Unlike jQuery's serialize, Form data is serialized as a <b>javascript object</b>.
<div class="ui ignored message">
Using <code>serializeForm</code> requires including the serialize-object dependency.
Using <code>serializeForm</code> requires including <a href="https://github.com/macek/jquery-serialize-object" target="_blank">macek's serialize object</a> converter.
</div>
<p>Unlike jQuery's serialize, data will be serialized as a javascript object using <a href="https://github.com/macek/jquery-serialize-object" target="_blank">macek's serialize object</a>.
<h5 class="ui header">Benefits of Structured Data</h5>
<ul class="ui list">
<li>Serialized Form Data can be modified in javascript in <code>beforeSend</code></li>
<li>Structured data can be used by using names like <code>name="user[name]"</code> in your form</li>
<li>Form data will automatically be converted to useful values, for instance, checkbox to to <code>boolean</code> values.</li>
<li>You can send structured data by using form names like <code>name="name[first]"</code> in your form</li>
<li>Form data will automatically be converted to their javascript equivalents, for instance, checkboxes will be converted to <code>boolean</code> values.</li>
<p>
<form class="ui form">
<div class="two fields">
@ -391,6 +387,10 @@ type : 'UI Behavior'
action: 'create user',
serializeForm: true,
beforeSend: function(settings) {
// form data is editable in before send
if(username == '') {
settings.data.username = 'New User';
}
// open console to inspect object
console.log(settings.data);
return settings;
@ -402,19 +402,24 @@ type : 'UI Behavior'
<div class="no example">
<h4 class="ui header">Included in Javascript</h4>
<p>POST or GET data can be included, when setting up API requests, through automatic inclusion, or during the beforeSend callback. This data will be joined together</p>
<h4 class="ui header">Specifying Data in Javascript</h4>
<p>POST or GET data can be specified directly when initializing an API requests, or included in Before Send</p>
<div class="code" data-type="javascript">
$('.form .submit')
.api({
action: 'create user',
serializeForm: true,
// manually specified POST/GET data across all requests
data: {
sessionID: '232'
session: generateSession()
},
beforeSend: function(settings) {
settings.data.token = window.generateToken();
// will include serialized data, session id, and token
// cancel request if no id
if( !$(this).data('id') ) {
return false;
}
// server POST/GET data for EACH request
settings.data.userID = $(this).data('id');
return settings;
}
})

32
server/documents/modules/dimmer.html.eco

@ -39,18 +39,19 @@ themes : ['Default']
Overlayable Section
</h3>
<div class="ui small images">
<img src="/images/wireframe/image.png">
<img src="/images/wireframe/image.png">
<img src="/images/wireframe/image.png">
<img class="ui wireframe image" src="/images/wireframe/image.png">
<img class="ui wireframe image" src="/images/wireframe/image.png">
<img class="ui wireframe image" src="/images/wireframe/image.png">
</div>
<img class="ui medium wireframe image" src="/images/wireframe/media-paragraph.png">
</div>
<div class="ui ignored icon buttons">
<div class="ui ignored ignored icon buttons">
<div class="ui show button"><i class="plus icon"></i></div>
<div class="ui hide button"><i class="minus icon"></i></div>
</div>
<div class="ui existing code">
<div class="ui segment">
<!-- Dimmer Generated Automatically No Need to Include !-->
<h3 class="ui header">
Overlayable Section
</h3>
@ -73,9 +74,9 @@ themes : ['Default']
Overlayable Section
</h3>
<div class="ui small images">
<img src="/images/wireframe/image.png">
<img src="/images/wireframe/image.png">
<img src="/images/wireframe/image.png">
<img class="ui wireframe image" src="/images/wireframe/image.png">
<img class="ui wireframe image" src="/images/wireframe/image.png">
<img class="ui wireframe image" src="/images/wireframe/image.png">
</div>
<img class="ui medium wireframe image" src="/images/wireframe/media-paragraph.png">
<div class="ui dimmer">
@ -89,7 +90,7 @@ themes : ['Default']
</div>
</div>
</div>
<div class="ui icon buttons">
<div class="ui ignored icon buttons">
<div class="ui show button"><i class="plus icon"></i></div>
<div class="ui hide button"><i class="minus icon"></i></div>
</div>
@ -155,7 +156,7 @@ themes : ['Default']
<img class="ui wireframe image" src="/images/wireframe/paragraph.png">
<img class="ui wireframe image" src="/images/wireframe/paragraph.png">
</div>
<div class="ignore ui icon buttons">
<div class="ignored ui icon buttons">
<div class="ui show button"><i class="plus icon"></i></div>
<div class="ui hide button"><i class="minus icon"></i></div>
</div>
@ -163,6 +164,8 @@ themes : ['Default']
</div>
<div class="ui tab" data-tab="examples">
<h2 class="ui dividing header">Examples</h2>
<div class="event example">
<h4 class="ui header">Dimmer Events</h4>
<p>A dimmer can trigger a visibility change on an event</p>
@ -183,7 +186,7 @@ themes : ['Default']
</div>
</div>
</div>
<img src="/images/wireframe/image.png">
<img class="ui wireframe image" src="/images/wireframe/image.png">
</div>
<div class="ui circular image">
<div class="ui dimmer">
@ -208,7 +211,7 @@ themes : ['Default']
<img class="ui wireframe image" src="/images/wireframe/short-paragraph.png">
<img class="ui wireframe image" src="/images/wireframe/short-paragraph.png">
</div>
<div class="ignore ui icon buttons">
<div class="ignored ui icon buttons">
<div class="ui show button"><i class="plus icon"></i></div>
<div class="ui hide button"><i class="minus icon"></i></div>
</div>
@ -223,7 +226,7 @@ themes : ['Default']
<div class="no example">
<h4 class="ui header">Display</h4>
<p>You can display a dimmer by either invoking .dimmer('show') on a section or a dimmer itself. If you choose to dim a dimmable section, a dimmer will automatically be created.</p>
<div class="ignore code">
<div class="ignored code">
// these two are the same
$('.ui.dimmable)
.dimmer('show')
@ -454,7 +457,7 @@ themes : ['Default']
<table class="ui sortable celled definition table">
<thead>
<th></th>
<th class="six wide">Default</th>
<th class="eight wide">Default</th>
<th>Description</th>
</thead>
@ -530,13 +533,14 @@ themes : ['Default']
</tr>
<tr>
<td>errors</td>
<td colspan="2">
<td>
<div class="code">
error : {
method : 'The method you called is not defined.'
}
</div>
</td>
<td>Error messages displayed to console</td>
</tr>
</tbody>
</table>

3
server/files/javascript/api.js

@ -29,6 +29,9 @@ semantic.api.ready = function() {
server
.respondWith(/\/follow\/(\d+)/, [responseCode, headers, body])
;
server
.respondWith(/\/create\/(.*)/, [responseCode, headers, body])
;
server
.respondWith(/\/search\/(.*)/, [responseCode, headers, body])
;

9
server/files/javascript/semantic.js

@ -737,7 +737,7 @@ semantic.ready = function() {
code = $code.html(),
existingCode = $code.hasClass('existing'),
evaluatedCode = $code.hasClass('evaluated'),
contentType = $code.data('type') || 'javascript',
contentType = $code.data('type') || 'html',
title = $code.data('title') || false,
demo = $code.data('demo') || false,
preview = $code.data('preview') || false,
@ -768,6 +768,8 @@ semantic.ready = function() {
"/": '&#x2F;'
};
contentType = contentType.toLowerCase();
function escapeHTML(string) {
return String(string).replace(/[&<>"'\/]/g, function (s) {
return entityMap[s];
@ -782,7 +784,10 @@ semantic.ready = function() {
// trim whitespace & escape
whiteSpace = new RegExp('\\n\\s{' + indent + '}', 'g');
formattedCode = $.trim(code).replace(whiteSpace, '\n');
formattedCode = escapeHTML(formattedCode);
if(contentType != 'javascript') {
formattedCode = escapeHTML(formattedCode);
}
// replace with <code>
$codeTag

6
server/files/stylesheets/semantic.css

@ -626,13 +626,13 @@ body#example.hide {
#example .example .wireframe.image {
opacity: 0.5;
}
#example .example .wireframe.image {
#example .example :not(.images) > .wireframe.image {
margin: 1rem 0em;
}
#example .example .wireframe.image:first-child {
#example .example :not(.images) > .wireframe.image:first-child {
margin-top: 0em;
}
#example .example .wireframe.image:last-child {
#example .example :not(.images) > .wireframe.image:last-child {
margin-bottom: 0em;
}

Loading…
Cancel
Save