Skip to content

Commit

Permalink
Various docs fixes of JavaScript section
Browse files Browse the repository at this point in the history
  • Loading branch information
adamkudrna committed Jul 29, 2015
1 parent fa5bedd commit f03833f
Show file tree
Hide file tree
Showing 8 changed files with 143 additions and 117 deletions.
36 changes: 18 additions & 18 deletions src/less/components/javascript/ckeditor-loader.less
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
/*
CKEditor Loader
Initializes CKEditor WYSIWYG editor (http://ckeditor.com) on the given textarea element.
It does no more then to run the $.ckeditor() method. It is possible to initialize the editor with default or custom options.
Initializes [CKEditor WYSIWYG editor](http://ckeditor.com) on the given `<textarea>` element.
It does no more then to run the `$.ckeditor()` method. It is possible to initialize the editor with default or custom
options.
<div class="panel panel-danger">
<div class="panel-heading"><h4 class="panel-title">JavaScript Required</h4></div>
<div class="panel-body">
Script `ckeditor-loader.js` `CKEditor package` and `CKEditor jQuery adapter` must be included.
Script `ckeditor-loader.js`, **CKEditor package** and **CKEditor jQuery adapter** must be included.
</div>
</div>
<h3>Usage</h3>
### Usage
<h4>Data-api</h4>
This loader only calls the jQuery plugin defined in CKEditor jQuery adapter with appropriate arguments. Id does nothing else.
This loader only calls the jQuery plugin defined in CKEditor jQuery adapter with appropriate arguments. Id does nothing
else.
<h4>Data-api</h4>
If a textarea html element has the attribute `data-onload-ckeditor` defined it will be initialized as a CKEditor upon page load.
The editor can be configured by the value passed to the attribute.
If no value is passed then CKEditor is initiated with the default configuration.
If it the value is a valid json then it will be parsed and used as a configuration object
(see http://docs.ckeditor.com/#!/api/CKEDITOR.config for supported options).
If the value is not a valid json, then it will be used as a path to a editor config file to be used
(see http://docs.ckeditor.com/#!/guide/dev_configuration-section-using-a-custom-configuration-file for custom config file documentation).
#### Data-API
If a `<textarea>` HTML element has the attribute `data-onload-ckeditor` defined, it will be initialized as a CKEditor
upon page load. The editor can be configured by the value passed to the attribute. If no value is passed, then CKEditor
is initiated with default configuration. If the value is a valid JSON, then it will be parsed and used as a
configuration object (see http://docs.ckeditor.com/#!/api/CKEDITOR.config for supported options). If the value is not a
valid JSON, then it will be used as a path to an editor config file to be used
(see http://docs.ckeditor.com/#!/guide/dev_configuration-section-using-a-custom-configuration-file for custom config
file documentation).
Markup:
<form>
<textarea data-onload-ckeditor='{"uiColor": "6D9000"}'>Hi, I'm a textarea and Im wearing a fancy CKEditor dress.</textarea>
</form>
<textarea data-onload-ckeditor='{"language": "en"}'>Hi, I’m a textarea and I’m wearing a fancy CKEditor dress.</textarea>
Styleguide 6.5
Styleguide 6.6
*/
23 changes: 14 additions & 9 deletions src/less/components/javascript/confirmation.less
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,21 @@ appropriately or by overriding the plugin default options which affects all inst
</div>
</div>
<h3>Usage</h3>
### Usage
<h4>Data-api</h4>
#### Data-API
To bind confirmation dialog to an element, the element must have `data-toggle="confirm"` attribute defined.
To overload the default options, you can use the same options as the JavaScript api prepended with `data-` (i.e. `data-confirm-yes="Oui"`).
To override default options, you can use the same options as the JavaScript API prepended with `data-`
(i.e. `data-confirm-yes="Oui"`).
This components data-api only supports `<button>` elements.
**Note that this component only supports `<button>` elements.**
<h4>JavaScript</h4>
#### JavaScript
##### Options
<h5>Options</h5>
<table class="table table-bordered table-striped">
<thead>
<tr>
Expand Down Expand Up @@ -74,11 +76,14 @@ This components data-api only supports `<button>` elements.
</tbody>
</table>
<h5>Methods</h5>
<h6>$().showConfirmation()</h6>
##### Methods
###### $().showConfirmation()
Triggers a confirmation dialog on the given element.
<h3>Events</h3>
##### Events
<table class="table table-bordered table-striped">
<thead>
<tr>
Expand Down
14 changes: 8 additions & 6 deletions src/less/components/javascript/datetimepicker-loader.less
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,18 @@ Initializes [Bootstrap Datetimepicker](http://eonasdan.github.io/bootstrap-datet
<div class="panel panel-danger">
<div class="panel-heading"><h4 class="panel-title">JavaScript Required</h4></div>
<div class="panel-body">
Scripts `datetimepicker-loader.js`, `moment.js`, `bootstrap.js` and `bootstrap-datetimepicker.js` must be included.
Scripts `datetimepicker-loader.js`, `moment.js` (this one before `bootstrap.js`) and `bootstrap-datetimepicker.js` must be included.
</div>
</div>
<h3>Usage</h3>
### Usage
This loader only calls the jQuery plugin defined in bootstrap-datetimepicker component. It does nothing else.
<h4>Data-API</h4>
If an input has the attribute `data-onload-datetimepicker` defined it will be initialized with a datetimepicker
upon page load. The picker can be configured by the value passed to the attribute. If no value is passed, picker is
#### Data-API
If an input group has the attribute `data-onload-datetimepicker` defined, it will be initialized with a datetimepicker
upon page load. The picker can be configured by the value passed to the attribute. If no value is passed, the picker is
initiated with default configuration. If the value is a valid JSON, then it will be parsed and used as a configuration
object (see http://eonasdan.github.io/bootstrap-datetimepicker/Options for supported options).
Expand Down Expand Up @@ -47,5 +49,5 @@ Markup:
</div>
</div>
Styleguide 6.6
Styleguide 6.7
*/
19 changes: 11 additions & 8 deletions src/less/components/javascript/disable.less
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
Disable
Toogles the disabled property on DOM elements.
Toggles the disabled property on DOM elements.
<div class="panel panel-danger">
<div class="panel-heading"><h4 class="panel-title">JavaScript Required</h4></div>
Expand All @@ -10,25 +10,28 @@ Toogles the disabled property on DOM elements.
</div>
</div>
<h3>Usage</h3>
### Usage
<h4>Data-api</h4>
#### Data-API
To use an element as control element for toggling disable status on other elements, it must possess the
`data-toggle="disable"` attribute. It also must define the `data-disable-target` attribute that holds a string which,
when evaluated as a jQuery selector, returns a jQuery object referencing the elements that are to be disabled or
enabled.
By default the control element triggers the disable() method on the JS event `change`. This can be changed by
By default the control element triggers the `disable()` method on the JS event `change`. This can be changed by
specifying the `data-disable-event` attribute on the control element (i.e. `data-disable-event="click"`).
<h4>JavaScript</h4>
#### JavaScript
##### Methods
###### $().toggle()
<h5>Methods</h5>
<h6>$().toggle()</h6>
Toggles between enabled and disabled states.
<h3>Events</h3>
##### Events
<table class="table table-bordered table-striped">
<thead>
<tr>
Expand Down
35 changes: 21 additions & 14 deletions src/less/components/javascript/filterable.less
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ filtered. If a data attribute is not provided, the element is ignored by the fil
is treated as if it passed the filter.
The options to be passed to the Filterable plugin are always an array of filter definition objects. If using the
data-api, each of these object has to be represented by a single `:input` element with the appropriate `data-*`
data-API, each of these objects has to be represented by a single `:input` element with the appropriate `data-*`
attributes.
To allow users to view all filterable elements when using the data-api, simply place a button with `type="reset"`
To allow users to view all filterable elements when using the data-API, simply place a button with `type="reset"`
attribute within the filter `<form>`.
<div class="panel panel-danger">
Expand All @@ -22,21 +22,23 @@ attribute within the filter `<form>`.
</div>
</div>
<h3>Usage</h3>
### Usage
<h4>Data-api</h4>
#### Data-API
The filter has to be a `<form>` with a `data-filter-target` attribute containing a string which, when evaluated as a jQuery
selector, returns a jQuery object holding the DOM elements to be filtered.
The filter has to be a `<form>` with a `data-filter-target` attribute containing a string which, when evaluated as a
jQuery selector, returns a jQuery object holding the DOM elements to be filtered.
Each of the `:input` elements of the form that are to be used for filtering have to define the `data-toggle="filter"` attribute.
Further each one also has to possess the `data-filter-attrib` and `data-filter-operator` attributes (see the Filter Object section bellow)
Each of the `:input` elements of the form that are to be used for filtering have to define the `data-toggle="filter"`
attribute. Further each one also has to possess the `data-filter-attrib` and `data-filter-operator` attributes (see the
Filter Object section below).
The element that is to reset the filter on click has to have the `data-toggle="reset-filter"` attribute defined.
<h4>JavaScript</h4>
#### JavaScript
##### Filter Object
<h5>Filter Object</h5>
<table class="table table-bordered table-striped">
<thead>
<tr>
Expand Down Expand Up @@ -139,13 +141,18 @@ The element that is to reset the filter on click has to have the `data-toggle="r
</tbody>
</table>
<h5>Methods</h5>
<h6>$().filter(filterObjects)</h6>
##### Methods
###### $().filter(filterObjects)
Filters the set of elements on which it is called according to the given array of filter objects.
<h6>$().resetFilter)</h6>
###### $().resetFilter)
Displays all filterable elements.
<h3>Events</h3>
##### Events
<table class="table table-bordered table-striped">
<thead>
<tr>
Expand Down
41 changes: 20 additions & 21 deletions src/less/components/javascript/select2-loader.less
Original file line number Diff line number Diff line change
@@ -1,36 +1,35 @@
/*
Select2 Loader
Initializes select2 (https://select2.github.io) on the given html element.
It does no more then to run the $.select2() method. It is possible to initialize the widget with default or custom options.
Initializes [select2](https://select2.github.io) on the given `<select>` element.
It does no more then to run the `$.select2()` method. It is possible to initialize the widget with default or custom
options.
<div class="panel panel-danger">
<div class="panel-heading"><h4 class="panel-title">JavaScript Required</h4></div>
<div class="panel-body">
Scripts `select2-loader.js` and `select2 package` must be included.
Script `select2-loader.js` and **select2 package** must be included.
</div>
</div>
<h3>Usage</h3>
### Usage
<h4>Data-api</h4>
This loader only calls the jQuery plugin defined in the select2 library with appropriate arguments. Id does nothing else.
This loader only calls the jQuery plugin defined in the select2 library with appropriate arguments. It does nothing
else.
<h4>Data-api</h4>
If a html element has the attribute `data-onload-select2` defined it will be initialized as a select2 upon page load.
The widget can be configured by the value passed to the attribute.
If no value is passed then select2 is initiated with teh default configuration.
If a json object is passed in then it will be parsed and used as a configuration object
(see https://select2.github.io/options.html for supported options).
#### Data-API
If a `<select>` element has the attribute `data-onload-select2` defined, it will be initialized as a select2 upon page
load. The widget can be configured by the value passed to the attribute. If no value is passed, then select2 is
initiated with default configuration. If a JSON object is passed, then it will be parsed and used as a configuration
object (see https://select2.github.io/options.html for supported options).
Markup:
<form>
<select multi data-onload-select2='{"minimumResultsForSearch": "Infinity"}'>
<option>Option 1</option>
<option>Option 2</option>
<option>Option 3</option>
</select>
</form>
Styleguide 6.6
<select class="form-control" multiple data-onload-select2='{"minimumResultsForSearch": "Infinity"}'>
<option selected>Option 1</option>
<option>Option 2</option>
<option>Option 3</option>
</select>
Styleguide 6.8
*/
59 changes: 32 additions & 27 deletions src/less/components/javascript/slugger.less
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
Slugger
Creates a slug in one HTML form element based on value in another.
The relationship is unidirectional in the sense that changes made to source element affect the target element, but not vice versa.
The relationship is unidirectional in the sense that changes made to source element affect the target element, but not
vice versa.
<div class="panel panel-danger">
<div class="panel-heading"><h4 class="panel-title">JavaScript Required</h4></div>
Expand All @@ -11,21 +12,24 @@ The relationship is unidirectional in the sense that changes made to source elem
</div>
</div>
<h3>Usage</h3>
### Usage
<h4>Data-api</h4>
#### Data-API
To make this component function there must be two HTML form elements.
One is the source where user types text and the other is the target where slugger dynamically generates the slug.
To make this component function there must be two HTML form elements. One is the source where user types text and the
other is the target where slugger dynamically generates the slug.
Two attributes have to be defined on the source element.
`data-toggle="slugger"`indicates that the elements value will be used as the string from which the slug is to be generated..
`data-slugger-target="#id-of-the-target-element"` defines the jQuery selector of the HTML form element where
Two attributes have to be defined on the source element:
* `data-toggle="slugger"`indicates that the element’s value will be used as the string from which the slug is to be
generated.
* `data-slugger-target="#id-of-the-target-element"` defines the jQuery selector of the HTML form element where
the generated slug is to be displayed.
<h4>JavaScript</h4>
#### JavaScript
##### Options
<h5>Options</h5>
<table class="table table-bordered table-striped">
<thead>
<tr>
Expand All @@ -45,11 +49,14 @@ the generated slug is to be displayed.
</tbody>
</table>
<h5>Methods</h5>
<h6>$().updateSlug()</h6>
##### Methods
###### $().updateSlug()
Sets slug generated as the value of the target element based on the value of the source element.
<h3>Events</h3>
##### Events
<table class="table table-bordered table-striped">
<thead>
<tr>
Expand All @@ -70,22 +77,20 @@ Sets slug generated as the value of the target element based on the value of the
</table>
Markup:
<form>
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<label>Source</label>
<input type="text" class="form-control" data-toggle="slugger" data-slugger-target="#slugger-target" />
</div>
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<label>Source</label>
<input type="text" class="form-control" data-toggle="slugger" data-slugger-target="#slugger-target" />
</div>
<div class="col-sm-6">
<div class="form-group">
<label>Target</label>
<input type="text" class="form-control" id="slugger-target" />
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<label>Target</label>
<input type="text" class="form-control" id="slugger-target" />
</div>
</div>
</form>
</div>
Styleguide 6.7
Styleguide 6.5
*/
Loading

0 comments on commit f03833f

Please sign in to comment.