Browse Source

Tab: begin tab documentation

pull/176/merge
jlukic 11 years ago
parent
commit
54ce44aaa3
11 changed files with 388 additions and 72 deletions
  1. 2
      RELEASE NOTES.md
  2. 23
      build/less/modules/tab.js
  3. 23
      build/minified/modules/tab.js
  4. 23
      build/uncompressed/modules/tab.js
  5. 2
      node/src/documents/introduction/getting-started.html.eco
  6. 265
      node/src/documents/modules/tab.html.eco
  7. 23
      node/src/files/build/less/modules/tab.js
  8. 23
      node/src/files/build/minified/modules/tab.js
  9. 23
      node/src/files/build/uncompressed/modules/tab.js
  10. 30
      node/src/files/javascript/tab.js
  11. 23
      src/modules/tab.js

2
RELEASE NOTES.md

@ -1,6 +1,6 @@
## RELEASE NOTES
### Version 0.2.5- Sep 28, 2013
### Version 0.2.5- Sep 30, 2013
**Fixes**
- Fixes checkbox selector issue with multiple inputs inside a checkbox

23
build/less/modules/tab.js

@ -80,6 +80,7 @@
}
// attach events if navigation wasn't set to window
if( !$.isWindow( element ) ) {
module.debug('Attaching events to tab activator', $module);
$module
.on('click' + eventNamespace, module.event.click)
;
@ -172,9 +173,9 @@
// only get default path if not remote content
pathArray = (remoteContent && !shouldIgnoreLoad)
? module.utilities.pathToArray(tabPath)
: module.get.defaultPathArray(tabPath),
tabPath = module.utilities.arrayToPath(pathArray)
: module.get.defaultPathArray(tabPath)
;
tabPath = module.utilities.arrayToPath(pathArray);
module.deactivate.all();
$.each(pathArray, function(index, tab) {
var
@ -241,8 +242,6 @@
fetch: function(tabPath, fullTabPath) {
var
$tab = module.get.tabElement(tabPath),
fullTabPath = fullTabPath || tabPath,
cachedContent = module.cache.read(fullTabPath),
apiSettings = {
dataType : 'html',
stateContext : $tab,
@ -262,8 +261,13 @@
urlData: { tab: fullTabPath }
},
request = $tab.data(metadata.promise) || false,
existingRequest = ( request && request.state() === 'pending' )
existingRequest = ( request && request.state() === 'pending' ),
cachedContent
;
fullTabPath = fullTabPath || tabPath;
cachedContent = module.cache.read(fullTabPath);
if(settings.cache && cachedContent) {
module.debug('Showing existing content', fullTabPath);
module.content.update(tabPath, cachedContent);
@ -630,7 +634,6 @@
// uses pjax style endpoints fetching content from same url with remote-content headers
auto : false,
history : false,
path : false,
@ -649,12 +652,12 @@
error: {
api : 'You attempted to load content without API module',
noContent : 'The tab you specified is missing a content url.',
method : 'The method you called is not defined',
state : 'The state library has not been initialized',
missingTab : 'Tab cannot be found',
noContent : 'The tab you specified is missing a content url.',
path : 'History enabled, but no path was specified',
recursion : 'Max recursive depth reached'
recursion : 'Max recursive depth reached',
state : 'The state library has not been initialized'
},
metadata : {
@ -669,7 +672,7 @@
},
selector : {
tabs : '.tab'
tabs : '.ui.tab'
}
};

23
build/minified/modules/tab.js

@ -80,6 +80,7 @@
}
// attach events if navigation wasn't set to window
if( !$.isWindow( element ) ) {
module.debug('Attaching events to tab activator', $module);
$module
.on('click' + eventNamespace, module.event.click)
;
@ -172,9 +173,9 @@
// only get default path if not remote content
pathArray = (remoteContent && !shouldIgnoreLoad)
? module.utilities.pathToArray(tabPath)
: module.get.defaultPathArray(tabPath),
tabPath = module.utilities.arrayToPath(pathArray)
: module.get.defaultPathArray(tabPath)
;
tabPath = module.utilities.arrayToPath(pathArray);
module.deactivate.all();
$.each(pathArray, function(index, tab) {
var
@ -241,8 +242,6 @@
fetch: function(tabPath, fullTabPath) {
var
$tab = module.get.tabElement(tabPath),
fullTabPath = fullTabPath || tabPath,
cachedContent = module.cache.read(fullTabPath),
apiSettings = {
dataType : 'html',
stateContext : $tab,
@ -262,8 +261,13 @@
urlData: { tab: fullTabPath }
},
request = $tab.data(metadata.promise) || false,
existingRequest = ( request && request.state() === 'pending' )
existingRequest = ( request && request.state() === 'pending' ),
cachedContent
;
fullTabPath = fullTabPath || tabPath;
cachedContent = module.cache.read(fullTabPath);
if(settings.cache && cachedContent) {
module.debug('Showing existing content', fullTabPath);
module.content.update(tabPath, cachedContent);
@ -630,7 +634,6 @@
// uses pjax style endpoints fetching content from same url with remote-content headers
auto : false,
history : false,
path : false,
@ -649,12 +652,12 @@
error: {
api : 'You attempted to load content without API module',
noContent : 'The tab you specified is missing a content url.',
method : 'The method you called is not defined',
state : 'The state library has not been initialized',
missingTab : 'Tab cannot be found',
noContent : 'The tab you specified is missing a content url.',
path : 'History enabled, but no path was specified',
recursion : 'Max recursive depth reached'
recursion : 'Max recursive depth reached',
state : 'The state library has not been initialized'
},
metadata : {
@ -669,7 +672,7 @@
},
selector : {
tabs : '.tab'
tabs : '.ui.tab'
}
};

23
build/uncompressed/modules/tab.js

@ -80,6 +80,7 @@
}
// attach events if navigation wasn't set to window
if( !$.isWindow( element ) ) {
module.debug('Attaching events to tab activator', $module);
$module
.on('click' + eventNamespace, module.event.click)
;
@ -172,9 +173,9 @@
// only get default path if not remote content
pathArray = (remoteContent && !shouldIgnoreLoad)
? module.utilities.pathToArray(tabPath)
: module.get.defaultPathArray(tabPath),
tabPath = module.utilities.arrayToPath(pathArray)
: module.get.defaultPathArray(tabPath)
;
tabPath = module.utilities.arrayToPath(pathArray);
module.deactivate.all();
$.each(pathArray, function(index, tab) {
var
@ -241,8 +242,6 @@
fetch: function(tabPath, fullTabPath) {
var
$tab = module.get.tabElement(tabPath),
fullTabPath = fullTabPath || tabPath,
cachedContent = module.cache.read(fullTabPath),
apiSettings = {
dataType : 'html',
stateContext : $tab,
@ -262,8 +261,13 @@
urlData: { tab: fullTabPath }
},
request = $tab.data(metadata.promise) || false,
existingRequest = ( request && request.state() === 'pending' )
existingRequest = ( request && request.state() === 'pending' ),
cachedContent
;
fullTabPath = fullTabPath || tabPath;
cachedContent = module.cache.read(fullTabPath);
if(settings.cache && cachedContent) {
module.debug('Showing existing content', fullTabPath);
module.content.update(tabPath, cachedContent);
@ -630,7 +634,6 @@
// uses pjax style endpoints fetching content from same url with remote-content headers
auto : false,
history : false,
path : false,
@ -649,12 +652,12 @@
error: {
api : 'You attempted to load content without API module',
noContent : 'The tab you specified is missing a content url.',
method : 'The method you called is not defined',
state : 'The state library has not been initialized',
missingTab : 'Tab cannot be found',
noContent : 'The tab you specified is missing a content url.',
path : 'History enabled, but no path was specified',
recursion : 'Max recursive depth reached'
recursion : 'Max recursive depth reached',
state : 'The state library has not been initialized'
},
metadata : {
@ -669,7 +672,7 @@
},
selector : {
tabs : '.tab'
tabs : '.ui.tab'
}
};

2
node/src/documents/introduction/getting-started.html.eco

@ -67,7 +67,7 @@ $(document)
<div class="ui active tab segment" data-tab="first">First</div>
<div class="ui tab segment" data-tab="second">Second</div>
<div class="ui tab segment" data-tab="third">Third</div>
</div>
</div>
<h3 class="ui header">Opening a new tab with a behavior</h3>
<p>Modules have simple behaviors for triggering common actions</p>
<div class="code" data-demo="true">

265
node/src/documents/modules/tab.html.eco

@ -0,0 +1,265 @@
---
layout : 'default'
css : 'side'
title : 'Tab'
description : 'A tab is a section of content tied to a navigation menu'
type : 'UI Module'
---
<script src="/javascript/tab.js"></script>
<%- @partial('header') %>
<div class="main container">
<div class="peek">
<div class="ui vertical pointing secondary menu">
<a class="item">Usage</a>
<a class="item">Examples</a>
<a class="item">Behavior</a>
<a class="item">Settings</a>
</div>
</div>
<h2 class="ui dividing header">Usage</h2>
<h4 class="ui header">Opening tabs with menus</h4>
<p>Tabs are usually used in concert with an element that activates the tab.</p>
<p>When using tabs, unlike other UI components, the menu or activating element is initialized instead of the tab.</p>
<div class="ignored ui info message">
Tabs are connected to their activators with a metadata attribute <code>data-tab</code>. This should be added to both the activating element and the tab itself.
</div>
<div class="code" data-type="javascript" data-demo="true">
$('.demo.menu .item')
.tab()
;
</div>
<div class="code" data-type="html" data-label="true" data-preview="true">
<div class="ui pointing secondary demo menu">
<a class="active item" data-tab="1">First</a>
<a class="item" data-tab="2">Second</a>
<a class="item" data-tab="3">Third</a>
</div>
<div class="ui active tab segment" data-tab="first">
First Tab
</div>
<div class="ui tab segment" data-tab="second">
Second Tab
</div>
<div class="ui tab segment" data-tab="third">
Third Tab
</div>
</div>
<h4 class="ui header">Managing Back/Forward Buttons with Tabs</h4>
<p>Tabs can attach to a history change event to allow for tabs to maintain history events. Tabs use Asual's <a href="https://github.com/asual/jquery-address">Address library</a> to provide cross-browser push state support. This makes sure in browser that don't support push state, <code>hashchange</code> is used with in page anchors to provide history functionality.</p>
<div class="ignored ui warning message">
<div class="header">Use proper path</div>
Make sure when you use history to specify the proper path. This is required for determining the stem url from the part of the url maintaining in page history. Using the incorrect path will cause the module to work incorrectly, producing unexpected results.
</div>
<div class="ignored ui warning message">
<div class="header">Route your URLs</div>
Be sure to set up routes on your server for any url used with history. If you use history to change the url to a location that does not exist, it will 404 on the next refresh. For example this documentation will 404 on refresh because Github Pages are only set up to server static site content.
</div>
<div class="code" data-type="javascript" data-demo="true">
$('.history.menu .item')
.tab({
history : true,
path : '/modules/tab.html'
})
;
</div>
<div class="code" data-type="html" data-label="true" data-preview="true">
<div class="ui pointing secondary history menu">
<a class="active item" data-tab="first">First</a>
<a class="item" data-tab="second">Second</a>
<a class="item" data-tab="third">Third</a>
</div>
<div class="ui active tab segment" data-tab="first">
First Tab
</div>
<div class="ui tab segment" data-tab="second">
Second Tab
</div>
<div class="ui tab segment" data-tab="third">
Third Tab
</div>
</div>
<h2 class="ui dividing header">Examples</h2>
<h2 class="ui dividing header">Behavior</h2>
All the following behaviors can be called using the syntax <code>$('.foo').tab('behavior name', argumentOne, argumentTwo)</code>
<table class="ui definition celled table segment">
<tr>
<td>attach events(selector, event)</td>
<td>Attaches tab action to given selector. Default event if none specified is toggle</td>
</tr>
<tr>
<td>show</td>
<td>Shows tab</td>
</tr>
<tr>
<td>hide</td>
<td>Hides tab</td>
</tr>
<tr>
<td>toggle</td>
<td>Toggles visibility of tab</td>
</tr>
<tr>
<td>is open</td>
<td>Returns whether tab is open</td>
</tr>
<tr>
<td>is closed</td>
<td>Returns whether tab is closed</td>
</tr>
<tr>
<td>push page</td>
<td>Pushes page content to be visible alongside tab</td>
</tr>
<tr>
<td>get direction</td>
<td>Returns direction of current tab</td>
</tr>
<tr>
<td>pull page</td>
<td>Returns page content to original position</td>
</tr>
<tr>
<td>add body css</td>
<td>Adds stylesheet to page head to trigger tab animations</td>
</tr>
<tr>
<td>remove body css</td>
<td>Removes any inline stylesheets for tab animation</td>
</tr>
<tr>
<td>get transition event</td>
<td>Returns vendor prefixed transition end event</td>
</tr>
</table>
<h2 class="ui dividing header">Settings</h2>
<h3 class="ui header">
Transition Settings
<div class="sub header">Form settings modify the transition behavior</div>
</h3>
<table class="ui red celled definition table segment">
<thead>
<th>Setting</th>
<th class="four wide">Default</th>
<th>Description</th>
</thead>
<tbody>
<tr>
<td>overlay</td>
<td>false</td>
<td>Whether tab should overlay page instead of pushing page to the side</td>
</tr>
<tr>
<td>useCSS</td>
<td>true</td>
<td>Whether to use css animations or fallback javascript animations</td>
</tr>
<tr>
<td>duration</td>
<td>300</td>
<td>Duration of side bar animation</td>
</tr>
</tbody>
</table>
<h3 class="ui header">
DOM Settings
<div class="sub header">DOM settings specify how this module should interface with the DOM</div>
</h3>
<table class="ui celled purple definition table segment">
<thead>
<th>Setting</th>
<th class="six wide">Default</th>
<th>Description</th>
</thead>
<tbody>
<tr>
<td>namespace</td>
<td>tab</td>
<td>Event namespace. Makes sure module teardown does not effect other events attached to an element.</td>
</tr>
<tr>
<td>className</td>
<td>
<div class="code">
className: {
active : 'active',
pushed : 'pushed',
top : 'top',
left : 'left',
right : 'right',
bottom : 'bottom'
}
</div>
</td>
<td>Class names used to attach style to state</td>
</tr>
</tbody>
</table>
<div class="ui horizontal divider"><i class="icon setting"></i></div>
<h3 class="ui header">
Debug Settings
<div class="sub header">Debug settings controls debug output to the console</div>
</h3>
<table class="ui blue celled definition table segment">
<thead>
<th>Setting</th>
<th class="four wide">Default</th>
<th>Description</th>
</thead>
<tbody>
<tr>
<td>name</td>
<td>Tab</td>
<td>Name used in debug logs</td>
</tr>
<tr>
<td>debug</td>
<td>True</td>
<td>Provides standard debug output to console</td>
</tr>
<tr>
<td>performance</td>
<td>True</td>
<td>Provides standard debug output to console</td>
</tr>
<tr>
<td>verbose</td>
<td>True</td>
<td>Provides ancillary debug output to console</td>
</tr>
<tr>
<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'
}
</div>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>

23
node/src/files/build/less/modules/tab.js

@ -80,6 +80,7 @@
}
// attach events if navigation wasn't set to window
if( !$.isWindow( element ) ) {
module.debug('Attaching events to tab activator', $module);
$module
.on('click' + eventNamespace, module.event.click)
;
@ -172,9 +173,9 @@
// only get default path if not remote content
pathArray = (remoteContent && !shouldIgnoreLoad)
? module.utilities.pathToArray(tabPath)
: module.get.defaultPathArray(tabPath),
tabPath = module.utilities.arrayToPath(pathArray)
: module.get.defaultPathArray(tabPath)
;
tabPath = module.utilities.arrayToPath(pathArray);
module.deactivate.all();
$.each(pathArray, function(index, tab) {
var
@ -241,8 +242,6 @@
fetch: function(tabPath, fullTabPath) {
var
$tab = module.get.tabElement(tabPath),
fullTabPath = fullTabPath || tabPath,
cachedContent = module.cache.read(fullTabPath),
apiSettings = {
dataType : 'html',
stateContext : $tab,
@ -262,8 +261,13 @@
urlData: { tab: fullTabPath }
},
request = $tab.data(metadata.promise) || false,
existingRequest = ( request && request.state() === 'pending' )
existingRequest = ( request && request.state() === 'pending' ),
cachedContent
;
fullTabPath = fullTabPath || tabPath;
cachedContent = module.cache.read(fullTabPath);
if(settings.cache && cachedContent) {
module.debug('Showing existing content', fullTabPath);
module.content.update(tabPath, cachedContent);
@ -630,7 +634,6 @@
// uses pjax style endpoints fetching content from same url with remote-content headers
auto : false,
history : false,
path : false,
@ -649,12 +652,12 @@
error: {
api : 'You attempted to load content without API module',
noContent : 'The tab you specified is missing a content url.',
method : 'The method you called is not defined',
state : 'The state library has not been initialized',
missingTab : 'Tab cannot be found',
noContent : 'The tab you specified is missing a content url.',
path : 'History enabled, but no path was specified',
recursion : 'Max recursive depth reached'
recursion : 'Max recursive depth reached',
state : 'The state library has not been initialized'
},
metadata : {
@ -669,7 +672,7 @@
},
selector : {
tabs : '.tab'
tabs : '.ui.tab'
}
};

23
node/src/files/build/minified/modules/tab.js

@ -80,6 +80,7 @@
}
// attach events if navigation wasn't set to window
if( !$.isWindow( element ) ) {
module.debug('Attaching events to tab activator', $module);
$module
.on('click' + eventNamespace, module.event.click)
;
@ -172,9 +173,9 @@
// only get default path if not remote content
pathArray = (remoteContent && !shouldIgnoreLoad)
? module.utilities.pathToArray(tabPath)
: module.get.defaultPathArray(tabPath),
tabPath = module.utilities.arrayToPath(pathArray)
: module.get.defaultPathArray(tabPath)
;
tabPath = module.utilities.arrayToPath(pathArray);
module.deactivate.all();
$.each(pathArray, function(index, tab) {
var
@ -241,8 +242,6 @@
fetch: function(tabPath, fullTabPath) {
var
$tab = module.get.tabElement(tabPath),
fullTabPath = fullTabPath || tabPath,
cachedContent = module.cache.read(fullTabPath),
apiSettings = {
dataType : 'html',
stateContext : $tab,
@ -262,8 +261,13 @@
urlData: { tab: fullTabPath }
},
request = $tab.data(metadata.promise) || false,
existingRequest = ( request && request.state() === 'pending' )
existingRequest = ( request && request.state() === 'pending' ),
cachedContent
;
fullTabPath = fullTabPath || tabPath;
cachedContent = module.cache.read(fullTabPath);
if(settings.cache && cachedContent) {
module.debug('Showing existing content', fullTabPath);
module.content.update(tabPath, cachedContent);
@ -630,7 +634,6 @@
// uses pjax style endpoints fetching content from same url with remote-content headers
auto : false,
history : false,
path : false,
@ -649,12 +652,12 @@
error: {
api : 'You attempted to load content without API module',
noContent : 'The tab you specified is missing a content url.',
method : 'The method you called is not defined',
state : 'The state library has not been initialized',
missingTab : 'Tab cannot be found',
noContent : 'The tab you specified is missing a content url.',
path : 'History enabled, but no path was specified',
recursion : 'Max recursive depth reached'
recursion : 'Max recursive depth reached',
state : 'The state library has not been initialized'
},
metadata : {
@ -669,7 +672,7 @@
},
selector : {
tabs : '.tab'
tabs : '.ui.tab'
}
};

23
node/src/files/build/uncompressed/modules/tab.js

@ -80,6 +80,7 @@
}
// attach events if navigation wasn't set to window
if( !$.isWindow( element ) ) {
module.debug('Attaching events to tab activator', $module);
$module
.on('click' + eventNamespace, module.event.click)
;
@ -172,9 +173,9 @@
// only get default path if not remote content
pathArray = (remoteContent && !shouldIgnoreLoad)
? module.utilities.pathToArray(tabPath)
: module.get.defaultPathArray(tabPath),
tabPath = module.utilities.arrayToPath(pathArray)
: module.get.defaultPathArray(tabPath)
;
tabPath = module.utilities.arrayToPath(pathArray);
module.deactivate.all();
$.each(pathArray, function(index, tab) {
var
@ -241,8 +242,6 @@
fetch: function(tabPath, fullTabPath) {
var
$tab = module.get.tabElement(tabPath),
fullTabPath = fullTabPath || tabPath,
cachedContent = module.cache.read(fullTabPath),
apiSettings = {
dataType : 'html',
stateContext : $tab,
@ -262,8 +261,13 @@
urlData: { tab: fullTabPath }
},
request = $tab.data(metadata.promise) || false,
existingRequest = ( request && request.state() === 'pending' )
existingRequest = ( request && request.state() === 'pending' ),
cachedContent
;
fullTabPath = fullTabPath || tabPath;
cachedContent = module.cache.read(fullTabPath);
if(settings.cache && cachedContent) {
module.debug('Showing existing content', fullTabPath);
module.content.update(tabPath, cachedContent);
@ -630,7 +634,6 @@
// uses pjax style endpoints fetching content from same url with remote-content headers
auto : false,
history : false,
path : false,
@ -649,12 +652,12 @@
error: {
api : 'You attempted to load content without API module',
noContent : 'The tab you specified is missing a content url.',
method : 'The method you called is not defined',
state : 'The state library has not been initialized',
missingTab : 'Tab cannot be found',
noContent : 'The tab you specified is missing a content url.',
path : 'History enabled, but no path was specified',
recursion : 'Max recursive depth reached'
recursion : 'Max recursive depth reached',
state : 'The state library has not been initialized'
},
metadata : {
@ -669,7 +672,7 @@
},
selector : {
tabs : '.tab'
tabs : '.ui.tab'
}
};

30
node/src/files/javascript/tab.js

@ -0,0 +1,30 @@
semantic.dropdown = {};
// ready event
semantic.dropdown.ready = function() {
// selector cache
var
$examples = $('.example'),
// alias
handler
;
// event handlers
handler = {
};
$('.demo.menu')
.first()
.find('.item')
.tab()
;
};
// attach ready event
$(document)
.ready(semantic.dropdown.ready)
;

23
src/modules/tab.js

@ -80,6 +80,7 @@
}
// attach events if navigation wasn't set to window
if( !$.isWindow( element ) ) {
module.debug('Attaching events to tab activator', $module);
$module
.on('click' + eventNamespace, module.event.click)
;
@ -172,9 +173,9 @@
// only get default path if not remote content
pathArray = (remoteContent && !shouldIgnoreLoad)
? module.utilities.pathToArray(tabPath)
: module.get.defaultPathArray(tabPath),
tabPath = module.utilities.arrayToPath(pathArray)
: module.get.defaultPathArray(tabPath)
;
tabPath = module.utilities.arrayToPath(pathArray);
module.deactivate.all();
$.each(pathArray, function(index, tab) {
var
@ -241,8 +242,6 @@
fetch: function(tabPath, fullTabPath) {
var
$tab = module.get.tabElement(tabPath),
fullTabPath = fullTabPath || tabPath,
cachedContent = module.cache.read(fullTabPath),
apiSettings = {
dataType : 'html',
stateContext : $tab,
@ -262,8 +261,13 @@
urlData: { tab: fullTabPath }
},
request = $tab.data(metadata.promise) || false,
existingRequest = ( request && request.state() === 'pending' )
existingRequest = ( request && request.state() === 'pending' ),
cachedContent
;
fullTabPath = fullTabPath || tabPath;
cachedContent = module.cache.read(fullTabPath);
if(settings.cache && cachedContent) {
module.debug('Showing existing content', fullTabPath);
module.content.update(tabPath, cachedContent);
@ -630,7 +634,6 @@
// uses pjax style endpoints fetching content from same url with remote-content headers
auto : false,
history : false,
path : false,
@ -649,12 +652,12 @@
error: {
api : 'You attempted to load content without API module',
noContent : 'The tab you specified is missing a content url.',
method : 'The method you called is not defined',
state : 'The state library has not been initialized',
missingTab : 'Tab cannot be found',
noContent : 'The tab you specified is missing a content url.',
path : 'History enabled, but no path was specified',
recursion : 'Max recursive depth reached'
recursion : 'Max recursive depth reached',
state : 'The state library has not been initialized'
},
metadata : {
@ -669,7 +672,7 @@
},
selector : {
tabs : '.tab'
tabs : '.ui.tab'
}
};

Loading…
Cancel
Save