Browse Source

iteration on module docs

beta
jlukic 11 years ago
parent
commit
23b82eb515
  1. 11
      RELEASE NOTES.md
  2. 78
      server/documents/module.html.eco
  3. 76
      server/documents/modules/accordion.html.eco
  4. 556
      server/documents/modules/checkbox.html.eco
  5. 1
      server/draft/chat.html
  6. 1
      server/draft/tab.html.eco
  7. 45
      server/files/javascript/semantic.js
  8. 2
      server/files/stylesheets/semantic.css
  9. 10
      server/partials/header.html.eco

11
RELEASE NOTES.md

@ -4,11 +4,15 @@
### Version 0.7.0 - Oct 17, 2013
**New**
- Added responsive style to ui tables
- Adds sortable tables to docs
- Adds new tabbed doc style for modules
- Popups can now have a different target than itself
- Adds onTabInit for local tabs on first load
- Adds documentation for module format
**Fixes**
- Fixes border radius on tabular menu
- Fixes border radius on tabular menu, fixes one pixel jump on active state
- Removes vertical label width line missing units
- Fixes pointing dropdown to appear correctly in menu
- Fixes issue with borders on selection dropdown
@ -17,8 +21,13 @@
- Popup .toggle() now always hides/shows popup correctly
- Dropdown cannot display inside item image
- Dropdown links were being prevented by event.preventDefault used for touch devices
- Fixes some code samples not being properly indented
**Updates**
- Increased padding on attached labels
- Leading on bulleted and ordered list slightly increased
- Horizontal padding on icon list slightly increased
- Increase opacity of icons on icon messages
- Ribbon labels now have a shadow color
- Popups are no longer inline by default
- Optimizes dimmer init on modal to occur on modal init and not modal show

78
server/documents/module.html.eco

@ -13,17 +13,14 @@ type : 'Semantic'
<div class="peek">
<div class="ui vertical pointing secondary menu">
<a class="active item">Design Pattern</a>
<a class="active item">Overview</a>
<a class="item">Initializing</a>
<a class="item">Behaviors</a>
<a class="item">Settings</a>
</div>
</div>
<h2 class="ui dividing header">Design Pattern</h2>
<h2 class="ui dividing header">Overview</h2>
<p>All official javascript modules in Semantic are designed using a singular design pattern. This pattern allows several useful features common to all javascript components</p>
<a class="ui secondary labeled icon button" href="/spec/docs/module.commented.html">
<i class="book icon"></i>
View Commented Example
</a>
<div class="ui relaxed list">
<div class="item">
<i class="check icon"></i>
@ -61,21 +58,66 @@ type : 'Semantic'
</div>
</div>
</div>
<a class="ui secondary labeled icon button" href="/spec/docs/module.commented.html">
<i class="book icon"></i>
View Commented Example
</a>
<h2 class="ui dividing header">Initializing</h2>
<p>UI Modules are not automatically initialized on page load. You must attach event handlers to trigger the behavior you require for each element</p>
<p>Its okay to initialize an element multiple times, the element will automatically destroy the previous instance and re-initiale with the settings provided.</p>
<div class="evaluated code" data-type="javascript">
$(document)
.ready(function() {
// just initializing
$('.help.icon')
.popup()
;
// initializing with settings
$('.ui.image')
.popup({
position: 'top right'
})
;
})
;
</div>
<div class="code" data-type="html" data-preview="true">
<i class="help link icon" data-content="This appears in the default location"></i>
<img class="ui medium image" src="/images/demo/photo.jpg" data-content="This pop-up appears to the top right">
</div>
<h2 class="ui dividing header">Behaviors</h2>
<p>Behaviors are an elements API. These can be invoke functionality or return aspects of the current state for an element</p>
<h3 class="ui header">Triggering a Behavior</h3>
<p>Behaviors are triggered in Semantic using a familiar syntax. API behaviors can be called using spaced words, camelcase or dot notation. The preferred method however is <b>spaced words</b>. Method lookup is done internally.</p>
<div class="code" data-title="Using Behaviors Programatically">
// generically
$('.ui.element')
.module('method', valueOne, valueTwo)
;
<div class="code" data-title="Invoking Behaviors with arguments">
// Sets a popup to top left position with an offset of negative five
$('.ui.popup')
$('.popup.icon')
.popup('set position', 'top left', -5)
;
</div>
<div class="code" data-title="Invoking Behaviors that does not Chain">
// returns boolean value instead of jQuery chain
$('.popup.icon').popup('is visible');
</div>
<div class="code" data-title="Returning multiple values">
// if selector size > 1 returns array of values [boolean, boolean...]
$('.many.popup').popup('is visible');
</div>
<h3 class="ui header">Overriding Internals</h3>
<p>Internal methods can be overwritten at run-time for individual instances of a module as well. For example:</p>
<div class="code" data-title="Changing Popup Logging">
// this instance will popup an alert for each log
$('.popup.icon')
.popup('internal', 'debug', function() {
window.alert(arguments[0]);
})
;
</div>
<h3 class="ui header">Common Behaviors</h3>
<p>All modules have a set of core behaviors which allow you to configure the component</p>
@ -106,7 +148,7 @@ type : 'Semantic'
<td>Internal method used for translating sentence case method into an internal method</td>
</tr>
<tr>
<td>log(comment, values)</td>
<td>debug(comment, values)</td>
<td>Displays a log if a user has logging enabled</td>
</tr>
<tr>
@ -186,13 +228,13 @@ type : 'Semantic'
<div class="item">
<div class="header">Setting module defaults</div>
Default settings for the module can be overridden by modifying <b>$.fn.module.settings</b>.
<br><div class="code">$.fn.popup.settings.moduleName = 'Godzilla';</div>
<br><div class="code" data-title="Example: Overriding a Popup's Log Name">$.fn.popup.settings.moduleName = 'Godzilla';</div>
</div>
<div class="item">
<div class="header">At initialization</div>
A settings object can be passed in when initializing the plugin
<br>
<div class="code">
<div class="code" data-title="Example: Settings popup's log name at initialization">
$('.foo')
.popup({
moduleName : 'Godzilla',
@ -205,7 +247,7 @@ type : 'Semantic'
<div class="header">After initialization</div>
Settings can be changed after a module is initialized by calling the 'settings' method on the module with either a settings object or a name, value pair.
<br>
<div class="code">
<div class="code" data-title="Example: Changing a Popup's log name after Initialization">
$('.foo')
// lets initialize that!
.popup()
@ -222,8 +264,8 @@ type : 'Semantic'
</div>
<h3 class="ui header">Reading Settings</h3>
<p>Settings can also be read programmatically:
<div class="code">
// outputs godzilla
<div class="code" data-title="Reading Settings">
// outputs 'godzilla' (1) or ['godzilla', 'godzilla'...] (2 or more)
$('.foo').popup('setting', 'moduleName');
</div>
</div>

76
server/documents/modules/accordion.html.eco

@ -111,9 +111,12 @@ type : 'UI Module'
</div>
</div>
<h2 class="ui dividing header">Behavior</h2>
<h2 class="ui dividing header">Behaviors</h2>
All the following behaviors can be called using the syntax <code>$('.foo').accordion('behavior name', argumentOne, argumentTwo)</code>
<p>Behaviors are accessible with javascript using the syntax:<p>
<div class="code">
$('.ui.accordion').accordion('behavior', argumentOne, argumentTwo...);
</div>
<table class="ui definition celled table segment">
<tr>
@ -126,7 +129,7 @@ type : 'UI Module'
</tr>
<tr>
<td>toggle (index)</td>
<td>Closes accordion content at index</td>
<td>Toggles accordion content at index</td>
</tr>
</table>
@ -135,33 +138,36 @@ type : 'UI Module'
<div class="ui tab" data-tab="examples">
<div class="example">
<h4 class="ui header">Form</h4>
<h3 class="ui header">Form</h3>
<p>An accordion can be used anywhere where content can be shown or hidden. For example, to show optional form fields.</p>
<div class="ui basic accordion form">
<div class="two fields">
<div class="field">
<label>First Name</label>
<input placeholder="First Name" type="text">
<div class="ui segment">
<div class="ui basic fluid accordion form">
<div class="two fields">
<div class="field">
<label>First Name</label>
<input placeholder="First Name" type="text">
</div>
<div class="field">
<label>Last Name</label>
<input placeholder="Last Name" type="text">
</div>
</div>
<div class="field">
<label>Last Name</label>
<input placeholder="Last Name" type="text">
<div class="title">
<i class="icon dropdown"></i>
Optional Details
</div>
</div>
<div class="title">
<i class="icon dropdown"></i>
Optional Details
</div>
<div class="content">
<div class="field">
<label>Maiden Name</label>
<input placeholder="Maiden Name" type="text">
<div class="content">
<div class="field">
<label>Maiden Name</label>
<input placeholder="Maiden Name" type="text">
</div>
</div>
<div class="ui secondary submit button">Sign Up</div>
</div>
</div>
</div>
<div class="example">
<h4 class="ui header">Menu</h4>
<h3 class="ui header">Menu</h3>
<p>An accordion can be used to create content drawers inside a menu</p>
<div class="ui basic vertical accordion menu">
<div class="item">
@ -250,7 +256,8 @@ type : 'UI Module'
<div class="ui tab" data-tab="usage">
<h3 class="ui header">Initializing an accordion</h3>
<div class="code">
<p>After including accordion html in a page you can attach behaviors with javascript</p>
<div class="test code">
$('.ui.accordion')
.accordion()
;
@ -342,10 +349,11 @@ type : 'UI Module'
<tr>
<td>selector</td>
<td>
<div class="code" data-type="css">{
title : '.title',
content : '.content'
}
<div class="code" data-type="css">
{
title : '.title',
content : '.content'
}
</div>
</td>
<td>Object containing selectors used by module.</td>
@ -354,9 +362,9 @@ type : 'UI Module'
<td>className</td>
<td>
<div class="code">
className : {
active : 'active'
},
className : {
active : 'active'
}
</div>
</td>
<td>Class names used to attach style to state</td>
@ -400,10 +408,10 @@ type : 'UI Module'
<td>errors</td>
<td colspan="2">
<div class="code">
error : {
method : 'The method you called is not defined.',
notFound : 'There were no elements that matched the specified selector'
}
error : {
method : 'The method you called is not defined.',
notFound : 'There were no elements that matched the specified selector'
}
</div>
</td>
</tr>

556
server/documents/modules/checkbox.html.eco

@ -8,316 +8,326 @@ type : 'UI Module'
---
<script src="/javascript/checkbox.js"></script>
<%- @partial('header') %>
<%- @partial('header', { tabs: 'module' }) %>
<div class="main container">
<div class="peek">
<div class="ui vertical pointing secondary menu">
<a class="active item">Usage</a>
<a class="item">Types</a>
<a class="item">Variations</a>
<a class="item">Behavior</a>
<a class="item">Examples</a>
</div>
</div>
<h2 class="ui dividing header">Usage</h2>
<div class="example">
<h4 class="ui header">Check Box</h4>
<p>A standard checkbox</p>
<div class="ui tab" data-tab="definition">
<div class="ui language label">Javascript</div>
<div class="code">
$('.ui.checkbox')
.checkbox()
;
</div>
<div class="ui language label">HTML</div>
<div class="code" data-type="html" data-preview="true">
<div class="ui checkbox">
<input type="checkbox">
<label>Poodle</label>
</div>
</div>
<div class="static example">
<h4 class="ui header">Static Check Box</h4>
<p>A checkbox can also be used without using javascript by creating the check box as a label with a for tag matching the <code>id</code> attribute of the input field.</p>
<div class="ui language label">HTML Only</div>
<div class="code" data-type="html" data-preview="true">
<div class="ui checkbox">
<input type="checkbox" id="unique-id" />
<label for="unique-id">Poodle</label>
</div>
<div class="peek">
<div class="ui vertical pointing secondary menu">
<a class="active item">Types</a>
<a class="item">Variations</a>
<a class="item">Behavior</a>
</div>
</div>
</div>
<h2 class="ui dividing header">Types</h2>
<h2 class="ui dividing header">Types</h2>
<div class="example">
<h4 class="ui header">Checkbox</h4>
<p>A standard checkbox</p>
<div class="ui checkbox">
<input type="checkbox" name="fun" />
<label>I enjoy having fun</label>
</div>
</div>
<div class="example">
<h4 class="ui header">Slider</h4>
<p>A checkbox can be formatted to show user selection as a slider</p>
<div class="ui slider checkbox">
<input type="checkbox" name="walk" />
<label>Allow others to see when your dog is on a walk</label>
<div class="example">
<h4 class="ui header">Slider</h4>
<p>A checkbox can be formatted to show user selection as a slider</p>
<div class="ui slider checkbox">
<input type="checkbox" name="walk" />
<label>Allow others to see when your dog is on a walk</label>
</div>
</div>
</div>
<div class="example">
<h4 class="ui header">Toggle</h4>
<p>A checkbox can be formatted to show user selection as a toggle</p>
<div class="ui toggle checkbox">
<input type="checkbox" name="pet" />
<label>Allow other people to pet my dog</label>
<div class="example">
<h4 class="ui header">Toggle</h4>
<p>A checkbox can be formatted to show user selection as a toggle</p>
<div class="ui toggle checkbox">
<input type="checkbox" name="pet" />
<label>Allow other people to pet my dog</label>
</div>
</div>
</div>
<div class="example">
<h4 class="ui header">Radio Box</h4>
<p>A checkbox can be formatted as a radio element. This means it is an exclusive option.</p>
<div class="ui form">
<div class="grouped inline fields">
<div class="field">
<div class="ui radio checkbox">
<input type="radio" name="fruit" checked="checked" />
<label>Apples</label>
<div class="example">
<h4 class="ui header">Radio Box</h4>
<p>A checkbox can be formatted as a radio element. This means it is an exclusive option.</p>
<div class="ui form">
<div class="grouped inline fields">
<div class="field">
<div class="ui radio checkbox">
<input type="radio" name="fruit" checked="checked" />
<label>Apples</label>
</div>
</div>
</div>
<div class="field">
<div class="ui radio checkbox">
<input type="radio" name="fruit" />
<label>Oranges</label>
<div class="field">
<div class="ui radio checkbox">
<input type="radio" name="fruit" />
<label>Oranges</label>
</div>
</div>
</div>
<div class="field">
<div class="ui radio checkbox">
<input type="radio" name="fruit" />
<label>Pears</label>
<div class="field">
<div class="ui radio checkbox">
<input type="radio" name="fruit" />
<label>Pears</label>
</div>
</div>
</div>
<div class="field">
<div class="ui radio checkbox">
<input type="radio" name="fruit" />
<label>Grapefruit</label>
<div class="field">
<div class="ui radio checkbox">
<input type="radio" name="fruit" />
<label>Grapefruit</label>
</div>
</div>
</div>
</div>
</div>
</div>
<h2 class="ui dividing header">Variations</h2>
<h2 class="ui dividing header">Variations</h2>
<div class="example">
<h4 class="ui header">Size</h4>
<p>A checkbox can be a different size.</p>
<div class="ui large checkbox">
<input type="checkbox" />
<label>Add a pro membership</label>
<div class="example">
<h4 class="ui header">Size</h4>
<p>A checkbox can be a different size.</p>
<div class="ui large checkbox">
<input type="checkbox" />
<label>Add a pro membership</label>
</div>
</div>
</div>
<div class="another example">
<div class="ui huge checkbox">
<input type="checkbox" />
<label>Signup for our mailing list</label>
<div class="another example">
<div class="ui huge checkbox">
<input type="checkbox" />
<label>Signup for our mailing list</label>
</div>
</div>
</div>
<h2 class="ui dividing header">Behavior</h2>
<h2 class="ui dividing header">Behavior</h2>
<table class="ui definition celled table segment">
<tr>
<td>enable</td>
<td>A checkbox can change to show a user has selected it</td>
</tr>
<tr>
<td>disable</td>
<td>A checkbox can change to show a user has deselected it</td>
</tr>
<tr>
<td>toggle</td>
<td>A checkbox can toggle its current selection state</td>
</tr>
</table>
<div class="example">
<p>A checkbox can change to show a user has selected it</p>
<div class="ignore code">
$('.ui.checkbox')
.checkbox('enable')
;
</div>
</div>
<div class="example">
<p>A checkbox can change to show a user has not selected it</p>
<div class="ignore code">
$('.ui.checkbox')
.checkbox('disable')
;
</div>
</div>
<div class="example">
<p>A checkbox can toggle between states</p>
<div class="ignore code">
$('.ui.checkbox')
.checkbox('toggle')
;
<div class="ui tab" data-tab="usage">
<h2 class="ui dividing header">Usage</h2>
<div class="example">
<h4 class="ui header">Check Box</h4>
<p>A checkbox can be initialized with javascript</p>
<div class="ui language label">Javascript</div>
<div class="code">
$('.ui.checkbox')
.checkbox()
;
</div>
<div class="ui language label">HTML</div>
<div class="code" data-type="html" data-preview="true">
<div class="ui checkbox">
<input type="checkbox">
<label>Poodle</label>
</div>
</div>
<div class="static example">
<h4 class="ui header">Check Box without Javascript</h4>
<p>A checkbox can also be used without using javascript by matching the <code>id</code> attribute of the input field to the <code>for</code> attribute of the accompanying label</p>
<div class="ui language label">HTML Only</div>
<div class="code" data-type="html" data-preview="true">
<div class="ui checkbox">
<input type="checkbox" id="unique-id" />
<label for="unique-id">Poodle</label>
</div>
</div>
</div>
</div>
</div>
<h2>Examples</h2>
<div class="example">
<p>Example of using checkbox states to alter multiple checkboxes</p>
<div class="evaluated code">
$('.enable.button')
.on('click', function() {
$(this)
.parent()
.nextAll('.checkbox')
.checkbox('enable')
;
})
;
$('.disable.button')
.on('click', function() {
$(this)
.parent()
.nextAll('.checkbox')
.checkbox('disable')
;
})
;
$('.toggle.button')
.on('click', function() {
$(this)
.parent()
.nextAll('.checkbox')
.checkbox('toggle')
;
})
;
</div>
<div class="ui buttons">
<div class="ui enable button">Enable</div>
<div class="ui disable button">Disable</div>
<div class="ui toggle button">Toggle</div>
</div>
<br><br>
<div class="ui slider checkbox">
<input type="checkbox" />
<div class="box"></div>
</div>
<div class="ui slider checkbox">
<input type="checkbox" checked="checked" />
<div class="box"></div>
</div>
<div class="ui slider checkbox">
<input type="checkbox" />
<div class="box"></div>
</div>
<div class="ui slider checkbox">
<input type="checkbox" checked="checked" />
<div class="box"></div>
</div>
<div class="ui slider checkbox">
<input type="checkbox" />
<div class="box"></div>
</div>
<div class="ui slider checkbox">
<input type="checkbox" />
<div class="box"></div>
</div>
<div class="ui slider checkbox">
<input type="checkbox" checked="checked" />
<div class="box"></div>
</div>
<div class="ui slider checkbox">
<input type="checkbox" />
<div class="box"></div>
</div>
<div class="ui slider checkbox">
<input type="checkbox" checked="checked" />
<div class="box"></div>
</div>
<div class="ui slider checkbox">
<input type="checkbox" />
<div class="box"></div>
<div class="ui tab" data-tab="examples">
<h2>Examples</h2>
<div class="example">
<p>Example of using checkbox states to alter multiple checkboxes</p>
<div class="evaluated code">
$('.enable.button')
.on('click', function() {
$(this)
.parent()
.nextAll('.checkbox')
.checkbox('enable')
;
})
;
$('.disable.button')
.on('click', function() {
$(this)
.parent()
.nextAll('.checkbox')
.checkbox('disable')
;
})
;
$('.toggle.button')
.on('click', function() {
$(this)
.parent()
.nextAll('.checkbox')
.checkbox('toggle')
;
})
;
</div>
<div class="ui buttons">
<div class="ui enable button">Enable</div>
<div class="ui disable button">Disable</div>
<div class="ui toggle button">Toggle</div>
</div>
<br><br>
<div class="ui slider checkbox">
<input type="checkbox" />
<div class="box"></div>
</div>
<div class="ui slider checkbox">
<input type="checkbox" checked="checked" />
<div class="box"></div>
</div>
<div class="ui slider checkbox">
<input type="checkbox" />
<div class="box"></div>
</div>
<div class="ui slider checkbox">
<input type="checkbox" checked="checked" />
<div class="box"></div>
</div>
<div class="ui slider checkbox">
<input type="checkbox" />
<div class="box"></div>
</div>
<div class="ui slider checkbox">
<input type="checkbox" />
<div class="box"></div>
</div>
<div class="ui slider checkbox">
<input type="checkbox" checked="checked" />
<div class="box"></div>
</div>
<div class="ui slider checkbox">
<input type="checkbox" />
<div class="box"></div>
</div>
<div class="ui slider checkbox">
<input type="checkbox" checked="checked" />
<div class="box"></div>
</div>
<div class="ui slider checkbox">
<input type="checkbox" />
<div class="box"></div>
</div>
</div>
</div>
<h3 class="ui header">Settings</h3>
<table class="ui red celled sortable definition table segment">
<thead>
<th colspan="3">Checkbox Settings</th>
</thead>
<tbody>
<tr>
<td>required</td>
<td>auto</td>
<td>Setting to true/false will determine whether an input will allow no selection. Auto will set disallow this behavior only for radio boxes</td>
</tr>
<tr>
<td>context</td>
<td>false</td>
<td>A selector or jQuery object to use as a delegated event context</td>
</tr>
</tbody>
</table>
<table class="ui teal celled sortable definition table segment">
<thead>
<th colspan="3">Callbacks</th>
</thead>
<tbody>
<tr>
<td>onChange</td>
<td>None</td>
<td>Callback after a checkbox is either disabled or enabled.</td>
</tr>
<tr>
<td>onEnable</td>
<td>None</td>
<td>Callback after a checkbox is enabled.</td>
</tr>
<tr>
<td>onDisable</td>
<td>None</td>
<td>Callback after a checkbox is disabled.</td>
</tr>
</tbody>
</table>
<h4 class="ui header">DOM Settings</h4>
<p>DOM settings specify how this module should interface with the DOM</p>
<table class="ui celled sortable definition table segment">
<thead>
<th>Setting</th>
<th class="four wide">Default</th>
<th>Description</th>
</thead>
<tbody>
<tr>
<td>namespace</td>
<td>checkbox</td>
<td>Event namespace. Makes sure module teardown does not effect other events attached to an element.</td>
</tr>
<tr>
<td>selector</td>
<td colspan="2">
<div class="code">
selector : {
input : 'input',
label : 'label'
}
</div>
</td>
</tr>
<tr>
<td>className</td>
<td colspan="2">
<div class="code">
<div class="ui tab" data-tab="settings">
className : {
radio : 'radio'
}
<h3 class="ui header">Settings</h3>
<table class="ui red celled sortable definition table segment">
<thead>
<th colspan="3">Checkbox Settings</th>
</thead>
<tbody>
<tr>
<td>required</td>
<td>auto</td>
<td>Setting to true/false will determine whether an input will allow no selection. Auto will set disallow this behavior only for radio boxes</td>
</tr>
<tr>
<td>context</td>
<td>false</td>
<td>A selector or jQuery object to use as a delegated event context</td>
</tr>
</tbody>
</table>
</div>
</td>
</tr>
</tbody>
</table>
<table class="ui teal celled sortable definition table segment">
<thead>
<th colspan="3">Callbacks</th>
</thead>
<tbody>
<tr>
<td>onChange</td>
<td>None</td>
<td>Callback after a checkbox is either disabled or enabled.</td>
</tr>
<tr>
<td>onEnable</td>
<td>None</td>
<td>Callback after a checkbox is enabled.</td>
</tr>
<tr>
<td>onDisable</td>
<td>None</td>
<td>Callback after a checkbox is disabled.</td>
</tr>
</tbody>
</table>
<h4 class="ui header">DOM Settings</h4>
<p>DOM settings specify how this module should interface with the DOM</p>
<table class="ui celled sortable definition table segment">
<thead>
<th>Setting</th>
<th class="four wide">Default</th>
<th>Description</th>
</thead>
<tbody>
<tr>
<td>namespace</td>
<td>checkbox</td>
<td>Event namespace. Makes sure module teardown does not effect other events attached to an element.</td>
</tr>
<tr>
<td>selector</td>
<td colspan="2">
<div class="code">
selector : {
input : 'input',
label : 'label'
}
</div>
</td>
</tr>
<tr>
<td>className</td>
<td colspan="2">
<div class="code">
className : {
radio : 'radio'
}
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</body>

1
server/draft/chat.html

@ -1,6 +1,7 @@
---
layout : 'default'
css : 'chatroom'
ignored : true
title : 'Chatroom'
description : 'A chatroom allows users to communicate with each other in real time.'

1
server/draft/tab.html.eco

@ -43,6 +43,7 @@ type : 'UI Module'
})
;
</div>
<div class="code" data-type="html" data-label="true">
<div class="ui pointing secondary menu">
<a class="active item" data-tab="first">First</a>

45
server/files/javascript/semantic.js

@ -42,7 +42,7 @@ semantic.ready = function() {
$menuPopup = $('.ui.main.menu .popup.item'),
$menuDropdown = $('.ui.main.menu .dropdown'),
$pageTabs = $('.tab.segment .menu .item'),
$pageTabs = $('body > .tab.segment .menu .item'),
$downloadDropdown = $('.download.buttons .dropdown'),
@ -236,6 +236,33 @@ semantic.ready = function() {
;
},
getIndent: function(text) {
var
lines = text.split("\n"),
firstLine = (lines[0] === '')
? lines[1]
: lines[0],
spacesPerIndent = 2,
leadingSpaces = firstLine.length - firstLine.replace(/^\s*/g, '').length,
indent
;
if(leadingSpaces !== 0) {
indent = leadingSpaces;
}
else {
// string has already been trimmed, get first indented line and subtract 2
$.each(lines, function(index, line) {
leadingSpaces = line.length - line.replace(/^\s*/g, '').length;
if(leadingSpaces !== 0) {
indent = leadingSpaces - spacesPerIndent;
console.log('returning' + indent);
return false;
}
});
}
return indent || 4;
},
generateCode: function() {
var
$example = $(this).closest('.example'),
@ -243,7 +270,6 @@ semantic.ready = function() {
$code = $annotation.find('.code'),
$header = $example.children('.ui.header:first-of-type').eq(0).add('p:first-of-type'),
$demo = $example.children().not($header).not('i.code:first-child, .code, .instructive, .language.label, .annotation, br, .ignore, .ignored'),
whiteSpace = new RegExp('\\n\\s{4}', 'g'),
code = ''
;
if( $code.size() === 0) {
@ -370,16 +396,18 @@ semantic.ready = function() {
text : 'Command Line',
sh : 'Command Line'
},
whiteSpace = new RegExp('\\n\\s{4}', 'g'),
indent = handler.getIndent(code) || 4,
padding = 20,
whiteSpace,
$label,
padding = 20,
editor,
editorSession,
codeHeight
;
// trim whitespace
code = $.trim(code.replace(whiteSpace, '\n'));
whiteSpace = new RegExp('\\n\\s{' + indent + '}', 'g');
code = $.trim(code).replace(whiteSpace, '\n');
if(contentType == 'html') {
$code.text(code);
@ -618,8 +646,11 @@ semantic.ready = function() {
if( $pageTabs.size() > 0 ) {
$pageTabs
.tab({
history: false,
onTabInit: handler.makeCode
onTabInit : handler.makeCode,
onTabLoad : function() {
$.waypoints('refresh');
$peekItem.removeClass('active').first().addClass('active');
}
})
;
}

2
server/files/stylesheets/semantic.css

@ -856,7 +856,7 @@ body.guide .main.container > * {
background-color: transparent;
}
#example .label + div.code {
margin-top: 1em;
margin-top: 1.5em;
}
#example div.code .ace_gutter {
background-color: #FAFAFA;

10
server/partials/header.html.eco

@ -10,12 +10,18 @@
</h1>
<p><%=@document.description %></p>
<% if @document.type is 'UI Element' or @document.type is 'UI View' or @document.type is 'UI Collection' or @document.type is 'UI Module': %>
<% if @document.type is 'UI Element' or @document.type is 'UI View' or @document.type is 'UI Collection': %>
<div class="ui basic labeled icon toggle overview button">
Overview
Definition Mode
<i class="book icon"></i>
</div>
<% end %>
<% if @document.type is 'UI Module': %>
<a href="/module.html" class="ui basic labeled icon button">
How to Use
<i class="help icon"></i>
</a>
<% end %>
</div>
<div class="advertisement">
<div id="carbonads-container"><div class="carbonad"><div id="azcarbon"></div><script type="text/javascript">var z = document.createElement("script"); z.type = "text/javascript"; z.async = true; z.src = "http://engine.carbonads.com/z/51619/azcarbon_2_1_0_HORIZ"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(z, s);</script></div></div>

Loading…
Cancel
Save