forked from OpenNHP/opennhp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Docs Translation: Widget(Accordion to Figure)
- Loading branch information
hongdp
committed
Jul 10, 2015
1 parent
d53b893
commit cbdc68d
Showing
12 changed files
with
403 additions
and
6 deletions.
There are no files selected for viewing
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
# Accordion | ||
--- | ||
|
||
This widget help building a beautiful accordion panel. | ||
|
||
## Usage | ||
|
||
### Copy and Paste | ||
|
||
- Copy the codes in examples, and paste it to the `<body>` of the Amaze UI HTML template([Download](/getting-started)); | ||
- Replace the contents in examples with your own contents. | ||
|
||
### Using Handlebars | ||
|
||
First, import Handlebars library and `amui.widget.helper.js`(See `widget.html` file in [Amaze UI HTML Template](/getting-started)). | ||
|
||
Then use either following ways to bind data. | ||
|
||
__1. Insert the script of widget into the template:__ | ||
|
||
```html | ||
<script type="text/x-handlebars-template" id="my-tpl"> | ||
{{>accordion accordionData}} | ||
</script> | ||
``` | ||
|
||
Then query the template and pass the data to it. | ||
|
||
```javascript | ||
$(function() { | ||
var $tpl = $('#my-tpl'), | ||
tpl = $tpl.text(), | ||
template = Handlebars.compile(tpl), | ||
data = { | ||
accordionData: { | ||
"theme": "basic", | ||
"content": [ | ||
{ | ||
"title": "Title 1", | ||
"content": "Content 1", | ||
"active": true | ||
}, | ||
{ | ||
"title": "Title 2", | ||
"content": "Content 2" | ||
}, | ||
{ | ||
"title": "Title 3", | ||
"content": "Content 3" | ||
} | ||
] | ||
} | ||
}, | ||
html = template(data); | ||
|
||
$tpl.before(html); | ||
}); | ||
``` | ||
|
||
The rendered HTML looks like this: | ||
|
||
```html | ||
<section data-am-widget="accordion" class="am-accordion am-accordion-basic doc-accordion-class" | ||
id="doc-accordion-example" data-accordion-settings="{ }"> | ||
<dl class="am-accordion-item am-active"> | ||
<dt class="am-accordion-title">Title 1</dt> | ||
<dd class="am-accordion-content">Content 1</dd> | ||
</dl> | ||
<dl class="am-accordion-item"> | ||
<dt class="am-accordion-title">Title 2</dt> | ||
<dd class="am-accordion-content">Content 2</dd> | ||
</dl> | ||
<dl class="am-accordion-item"> | ||
<dt class="am-accordion-title">Title 3</dt> | ||
<dd class="am-accordion-content">Content 3</dd> | ||
</dl> | ||
</section> | ||
``` | ||
|
||
If there are other widget or templates in the same page, we recommend using this way. Maintenance will be easier in this way. | ||
|
||
__Second, Directly render the widget with Handlebars:__ | ||
|
||
```javascript | ||
var template = Handlebars.compile('{{>accordion}}'), | ||
data = { | ||
accordionData: { | ||
"id": "doc-accordion-example", | ||
"className": "doc-accordion-class", | ||
"theme": "basic", | ||
"content": [ | ||
{ | ||
"title": "Title 1", | ||
"content": "Content 1", | ||
"active": true | ||
}, | ||
{ | ||
"title": "Title 2", | ||
"content": "Content 2" | ||
}, | ||
{ | ||
"title": "Title 3", | ||
"content": "Content 3" | ||
} | ||
] | ||
} | ||
}, | ||
html = template(data.accordionData); | ||
|
||
$('body').append(html); | ||
``` | ||
|
||
### Allmobilize WebIDE | ||
|
||
- Drag the widget to the edit interface; | ||
- Click the `Data binding` button on the right panel, and bind data using following format. | ||
|
||
```javascript | ||
var data = [ | ||
{ | ||
"title": "", // Title. Support using html | ||
"content": "" // Content. Support using html | ||
} | ||
]; | ||
|
||
return data; | ||
``` | ||
|
||
## Data Interface | ||
|
||
```javascript | ||
{ | ||
// ID | ||
"id": "", | ||
|
||
// Customized class | ||
"className": "", | ||
|
||
// Theme | ||
"theme": "", | ||
|
||
"options": { | ||
"multiple": false // Allow opening multiple panel at the same time. Default value is FALSE. | ||
}, | ||
|
||
// Content(* means required) | ||
"content": [ | ||
{ | ||
"title": "", // Title. Support using html | ||
"content": "", // Content. Support using html | ||
"active": false // Whether activate current panel. | ||
// New in Amaze UI 2.3 | ||
"disabled": null // Whether diable current panel. | ||
} | ||
] | ||
} | ||
``` | ||
|
||
## Attention: | ||
|
||
- **Don't use `padding`/`margin`/`border` for `.am-accordion-bd`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# blank | ||
--- | ||
|
||
This blank widget allow developers to build their own widget. | ||
|
||
## Structure | ||
|
||
```javascript | ||
// Blank. Write your own data structure according to the HTML of your widget. | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Container | ||
--- | ||
|
||
Container widget. | ||
|
||
|
||
## API | ||
|
||
```javascript | ||
{ | ||
"id": "", | ||
"className": "", | ||
"theme": "" | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Divider | ||
--- | ||
|
||
This widget is used to create beautiful dividers. | ||
|
||
## Usage | ||
|
||
### Copy and Paste | ||
|
||
- Copy the codes in examples, and paste it to the `<body>` of the Amaze UI HTML template([Download](/getting-started)); | ||
|
||
### Using Handlebars | ||
|
||
The Handlebars partial name of this widget is `divider`. See more details in [Accordion](/widgets/accordion). | ||
|
||
### Allmobilize WebIDE | ||
|
||
This widget don't need data-binding. | ||
|
||
## Structure | ||
|
||
```javascript | ||
{ | ||
"id": "", | ||
|
||
"className": "", | ||
|
||
"theme": "default" | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Duoshuo | ||
--- | ||
|
||
This is the DuoShuo comment widget. | ||
|
||
<div class="am-alert am-alert-danger"> | ||
Please use your own DuoShuo website ID to replace <code>amazeui</code> in <code>data-ds-short-name="amazeui"</code>. Otherwise, your comments will all come to Amaze UI. | ||
</div> | ||
|
||
<div class="am-alert am-alert-warning"> | ||
This widget is provided by <a href="http://dev.duoshuo.com/" target="_blank">DuoShuo</a>. See more details in <a href="http://dev.duoshuo.com/docs" target="_blank">Official Docs</a>. | ||
</div> | ||
|
||
## Usage | ||
|
||
The shortName is required, and others are optional. | ||
|
||
## API | ||
|
||
```javascript | ||
{ | ||
"id": "", | ||
"className": "", | ||
"theme": "", | ||
"options": { | ||
"shortName": "", | ||
}, | ||
"content": { | ||
"threadKey": "", | ||
"title": "", | ||
"url": "" | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# Figure | ||
--- | ||
|
||
The Figure widget is used to place single image. Please use [Gallery](/widgets/gallery) for multiple images. | ||
|
||
## Usage | ||
|
||
### Copy and Paste | ||
|
||
- Copy the codes in examples, and paste it to the `<body>` of the Amaze UI HTML template([Download](/getting-started)); | ||
- Replace the contents in examples with your own contents. | ||
|
||
### Using Handlebars | ||
|
||
The Handlebars partial of Figure widget is `figure`. See [Accordion](/widgets/accordion) for more details | ||
|
||
### Allmobilize WebIDE | ||
|
||
- Drag the widget to the edit interface; | ||
- Click the `Data binding` button on the right panel, and bind data using following format. | ||
|
||
```javascript | ||
var data = { | ||
"img": "", // Path of image. | ||
"imgAlt": "", // Alternative text. If this is empty then use figcaption. | ||
"figcaption": "" // The caption of image. Shown at the bottom of image. | ||
}; | ||
|
||
return data; | ||
``` | ||
|
||
## Data Interface | ||
|
||
If the image is too big, use the thumbnail in `img`, and use the original image in `rel`. | ||
|
||
```javascript | ||
{ | ||
"id": "", | ||
"className": "", | ||
"theme": "", | ||
"options": { | ||
"figcaptionPosition": "bottom", // Caption position: top | bottom | ||
"zoomble": false // Whether allow zooming: ['auto'|true|false] | ||
// 'auto' - Judge by the width of image. Allow zooming if the width of image is larger than viewport. | ||
// This option will be used as the data-am-figure="{pureview: {{zoomable}} }" option in pureview. | ||
}, | ||
"content": [ | ||
{ | ||
"img": "", // Path of image(thumbnail) | ||
"rel": "", // Path of original image. | ||
"imgAlt": "", // Alternative text. If this is empty then use figcaption. | ||
"figcaption": "" // Caption. | ||
} | ||
] | ||
} | ||
``` |
Oops, something went wrong.