Skip to content

Commit

Permalink
Merge branch 'live-docs'
Browse files Browse the repository at this point in the history
  • Loading branch information
ericf committed Nov 7, 2011
2 parents d0f8b4d + b314fc1 commit 7c4e29e
Show file tree
Hide file tree
Showing 14 changed files with 557 additions and 435 deletions.
13 changes: 6 additions & 7 deletions src/panel/docs/component.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
"name" : "panel",
"displayName": "Panel",
"description": "The Panel is a UI Control that is meant to behave similarly to an OS window. The Panel control extends the functionality of Overlay, adding support for modality, close/dismiss buttons, autohiding and autofocus. Plugins to make it draggable and resizable are supported as well. Panel includes a pre-defined stylesheet to support default look and feel characteristics.",
"author" : ["ericf"],
"author" : ["ericf", "tilomitra"],

"tags": ["widget", "beta", "panel", "extension"],
"use" : ["panel"],

"examples" : [
{
"name" : "panel-form",
"displayName": "Creating a modal form",
"displayName": "Creating a Modal Form",
"description": "Shows how to instantiate multiple Panel instances, and use nested modality to interact with a Datatable.",
"modules" : ["panel", "datatable"],
"tags" : ["panel", "datatable"],
Expand All @@ -19,7 +19,7 @@
},
{
"name" : "panel-animate",
"displayName": "Creating an animated panel",
"displayName": "Creating an Animated Panel",
"description": "Shows how to create a panel that animates as it is shown and hidden",
"modules" : ["panel", "transition"],
"tags" : ["panel", "transition"],
Expand All @@ -31,13 +31,12 @@
"pages": {
"panel-form-example": {
"displayName": "Using a panel to show a modal form",
"layout": "panel-example"

"layout" : "panel-example"
},

"panel-animate-example": {
"displayName": "Creating an animated panel using transitions",
"layout": "panel-example"

"layout" : "panel-example"
}
}
}
38 changes: 19 additions & 19 deletions src/panel/docs/index.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ This simple example will create a Panel with default functionality. By default,
</p>

```javascript
YUI().use('panel', function(Y) {
YUI().use('panel', function (Y) {
var panel = new Y.Panel({
srcNode : '#myPanelContent',
Expand All @@ -32,7 +32,7 @@ A Panel is not modal by default. This functionality can be changed through the `
</p>

```javascript
YUI().use('panel', function(Y) {
YUI().use('panel', function (Y) {
var panel = new Y.Panel({
srcNode: '#myPanelContent',
Expand Down Expand Up @@ -62,7 +62,7 @@ The following code snippet shows how to change the default "hide" behavior. Inst
</p>

```javascript
YUI().use('panel', function(Y) {
YUI().use('panel', function (Y) {
var panel = new Y.Panel({
srcNode : '#myPanelContent',
Expand Down Expand Up @@ -134,9 +134,9 @@ Panel supports header/footer buttons through the <a href="{{apiDocs}}/classes/Wi
</p>

```javascript
YUI().use('panel', function(Y) {
YUI().use('panel', function (Y) {
function doSomethingElse () {
function doSomethingElse() {
// ...
}

Expand All @@ -155,7 +155,7 @@ YUI().use('panel', function(Y) {
// The `action` property takes the Function that should be
// executed on a click event.
action: function (e) {
action: function(e) {
e.preventDefault();
panel.hide();
doSomethingElse();
Expand All @@ -165,7 +165,7 @@ YUI().use('panel', function(Y) {
// should be `Y.WidgetStdMod.HEADER` or `Y.WidgetStdMod.FOOTER`.
section: Y.WidgetStdMod.FOOTER

// Optional `classNames` property to add CSS classes to the
// Optional `classNames` property to add CSS classes to the
// button Node.

// optional `href` property if you are linking to an URL.
Expand All @@ -183,18 +183,18 @@ If you want to append buttons to the ones that are already present within the Pa
</p>

```javascript
var cancelButton = {
value : 'Cancel',
action: function (e) {
e.preventDefault();
// ...
},

// 'header', 'footer' or Y.WidgetStdMod.HEADER also work here.
section: Y.WidgetStdMod.FOOTER
};

panel.addButton(cancelButton);
var cancelButton = {
value : 'Cancel',
action: function(e) {
e.preventDefault();
// ...
},

// 'header', 'footer' or Y.WidgetStdMod.HEADER also work here.
section: Y.WidgetStdMod.FOOTER
};

panel.addButton(cancelButton);
```

<h2>Notes Regarding Older Browsers</h2>
Expand Down
6 changes: 3 additions & 3 deletions src/panel/docs/panel-animate-example.mustache
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@

<style type="text/css">
{{>panel-animate-css-source}}
{{>panel-animate-css-source}}
</style>

{{>panel-animate-html-source}}

<script type="text/javascript">
{{>panel-animate-js-source}}
{{>panel-animate-js-source}}
</script>
134 changes: 77 additions & 57 deletions src/panel/docs/panel-animate.mustache
Original file line number Diff line number Diff line change
@@ -1,107 +1,127 @@
<div class="intro">
<p>This example demonstrates how to instantiate a panel and use it in conjunction with the `"transition"` module to create an animated panel.</p>
<p>
This example demonstrates how to instantiate a panel and use it in conjunction with the `"transition"` module to create an animated panel.
</p>
</div>

<div class="example newwindow">
<a href="panel-animate-example.html" target="_blank" class="button">
View Example in New Window
</a>
</div>

<h2>Creating an animated panel</h2>

<h3>Setting Up The YUI Instance</h3>

<p>To create an instance of a Panel on your page, the only module you need to request is the `panel` module. The `panel` module will pull in the `widget`, `widget-stack`, `widget-position`, `widget-position-align`, `widget-position-constrain`, `widget-stdmod`, `widget-buttons`, `widget-modality` and `widget-autohide` extensions it uses.</p>
<p>
To create an instance of a Panel on your page, the only module you need to request is the `panel` module. The `panel` module will pull in the `widget`, `widget-stack`, `widget-position`, `widget-position-align`, `widget-position-constrain`, `widget-stdmod`, `widget-buttons`, `widget-modality` and `widget-autohide` extensions it uses.
</p>

<p>For this example, we also need to use the `transition` module. This module allows us to easily create animations using CSS3 transitions, with a JavaScript timer fallback.
<p>
For this example, we also need to use the `transition` module. This module allows us to easily create animations using CSS3 transitions, with a JavaScript timer fallback.
</p>

```
YUI({...}).use("panel", "transition", function(Y) {
```javascript
YUI().use('panel', 'transition', function (Y) {
// We'll write example code here
});
```
<p>Note, using the `panel` module, will also pull down the default CSS required for panel. The CSS that styles the Panel requires you to have the class `yui3-skin-sam` on a parent element, commonly the `<body>` tag.</p>
<p>
Note, using the `panel` module, will also pull down the default CSS required for panel. The CSS that styles the Panel requires you to have the class `yui3-skin-sam` on a parent element, commonly the `<body>` tag.
</p>
<h3>Instantiating the Panel</h3>
<p>For this example, we'll instantiate a modal panel, set its visibility to false, and set some CSS properties. The following HTML will be used as the markup for the panel.</p>
<p>
For this example, we'll instantiate a modal panel, set its visibility to false, and set some CSS properties. The following HTML will be used as the markup for the panel.
</p>
```
```html
<div id="panelContent">
<div class="yui3-widget-hd">
Showing an animated panel
</div>
<div class="yui3-widget-bd">
<p>Making panels animate is easy with the "transition" module!</p>
</div>
<div class="yui3-widget-hd">
Showing an animated panel
</div>
<div class="yui3-widget-bd">
<p>Making panels animate is easy with the "transition" module!</p>
</div>
</div>
```
<p>The JavaScript to instantiate the panel is as follows:</p>
```
```javascript
var panel = new Y.Panel({
srcNode: "#panelContent",
width:330,
xy: [300, -300], //we render the panel off the page
modal:true,
visible:false,
zIndex: 5,
buttons: [
{
value: "Close the panel",
action: function(e) {
e.preventDefault();
hidePanel();
},
section: "footer"
}
],
render:true
srcNode: '#panelContent',
width : 330,
xy : [300, -300],
zIndex : 5,
modal : true,
visible: false,
render : true,
buttons: [
{
value : 'Close the panel',
section: 'footer',
action : function (e) {
e.preventDefault();
hidePanel();
}
}
]
});
```


<h3>Adding Animation</h3>

<p>To create the animations, we need to set up transition properties on the panel's `boundingBox`. These properties consist of key/value pairs of CSS properties that we want to alter.</p>
<p>
To create the animations, we need to set up transition properties on the panel's `boundingBox`. These properties consist of key/value pairs of CSS properties that we want to alter.
</p>

<p>We define two methods `showPanel()` and `hidePanel()` that define transitions. We could also use the `visibleChange` event to toggle the animation based on the state. However, the benefit of this method is that it allows us to use callback functions after the `transition` has ended.</p>
<p>
We define two methods `showPanel()` and `hidePanel()` that define transitions. We could also use the `visibleChange` event to toggle the animation based on the state. However, the benefit of this method is that it allows us to use callback functions after the `transition` has ended.
</p>


```
function showPanel () {
panel.show(); //show the panel to make it visible, then transition it in.
bb.transition({
duration: 0.5,
top:"80px"
});
```javascript
function showPanel() {
panel.show();
bb.transition({
duration: 0.5,
top : '80px'
});
}

function hidePanel () {
bb.transition({
duration: 0.5,
top:"-300px"
}, function() {
panel.hide(); //hide the panel after this transition ends
});
function hidePanel() {
bb.transition({
duration: 0.5,
top : '-300px'
}, function () {
panel.hide();
});
}
```


<h3>Adding Buttons to toggle visibility</h3>

<p>Finally, we create two buttons, one to show the panel and one to hide it.</p>
<p>
Finally, we create two buttons, one to show the panel and one to hide it.
</p>

<p>The button to close the panel was specified in the instantiation of the panel. The button to open the panel can be defined as:</p>
```
//Add Panel Show Button
openBtn.on('click', function(e) {
showPanel();
<p>
The button to close the panel was specified in the instantiation of the panel. The button to open the panel can be defined as:
</p>

```javascript
// Add Panel show button.
openBtn.on('click', function (e) {
showPanel();
});
```

<h3>Complete Example Source</h3>

```
{{>panel-animate-source}}
{{>panel-animate-source}}
```
8 changes: 4 additions & 4 deletions src/panel/docs/panel-form-example.mustache
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@

<style type="text/css">
{{>panel-form-css-source}}
{{>panel-form-css-source}}
</style>
<h1>Using a panel to show a modal form</h1>

{{>panel-form-html-source}}

<script type="text/javascript">
{{>panel-form-js-source}}
{{>panel-form-js-source}}
</script>
Loading

0 comments on commit 7c4e29e

Please sign in to comment.