Child pages
  • Tutorial - Rich Text Inline Edit

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
{warning}This is work in progress. Please do not use as reference.{warning} {section} {column:width=60%} {info}This documentation refers to the latest trunk version of the Rich Text Inline Edit code. For documentation specific earlier releases, please see [Previous Versions of Tutorials] {info} This page will walk you through an example of adding the Fluid [Rich Text Inline Edit] component to an HTML file. For more general information about the Inline Edit API, see [Rich Text Inline Edit API]. This tutorial assumes that: * you are already familiar with HTML, Javascript and CSS * you are familiar with what the Inline Edit is and does * now you just want to know how to add it to your file. h1. Tutorial: How to Use the Inline Edit h2. Scenario You've created a database to keep track of your vast collection of CDs, and you're working on a web interface for it. When viewing the details of a CD, you would like to very easily add a personal review. Prone to rambling, you know you will want to add some basic styling so the text is easier to read. This tutorial will show you how to use the Fluid Rich Text Inline Edit for this. There are four basic steps to adding the Inline Edit to your application: * Step 1: Add the Markup * Step 2: Write the script * Step 3: Add the required libraries to your HTML * Step 4: Apply styles The rest of this tutorial will explain each of these steps in detail. {column} {column} {panel:title= On This Page| borderStyle=solid| borderColor=#566b30| titleBGColor=#D3E3C4| bgColor=#fff} {toc:minLevel=2|maxLevel=2} {panel} {panel:title=See Also|borderStyle=solid|borderColor=#321137|titleBGColor=#c1b7c3|bgColor=#fff} * [Inline Edit] * [Simple Text Inline Edit API] {panel} {panel:title=Still need help?|borderStyle=solid|borderColor=#321137|titleBGColor=#cccccc|bgColor=#fff} Join the [infusion-users mailing list|http://fluidproject.org/mailman/listinfo/infusion-users] and ask your questions there. {panel} {column} {section} ---- h2. Step 1: Prepare your markup {section} {column} Let's assume that you're working with some HTML that displays the information about a CD in your collection - something simple like this: {code:html}
Wiki Markup
Warning

This is work in progress. Please do not use as reference.

Section
Column
width60%
Info

This documentation refers to the latest trunk version of the Rich Text Inline Edit code. For documentation specific earlier releases, please see Previous Versions of Tutorials

This page will walk you through an example of adding the Fluid Rich Text Inline Edit component to an HTML file. For more general information about the Inline Edit API, see Rich Text Inline Edit API.

This tutorial assumes that:

  • you are already familiar with HTML, Javascript and CSS
  • you are familiar with what the Inline Edit is and does
  • now you just want to know how to add it to your file.

Tutorial: How to Use the Inline Edit

Scenario

You've created a database to keep track of your vast collection of CDs, and you're working on a web interface for it. When viewing the details of a CD, you would like to very easily add a personal review. Prone to rambling, you know you will want to add some basic styling so the text is easier to read. This tutorial will show you how to use the Fluid Rich Text Inline Edit for this.

There are four basic steps to adding the Inline Edit to your application:

  • Step 1: Add the Markup
  • Step 2: Write the script
  • Step 3: Add the required libraries to your HTML
  • Step 4: Apply styles

The rest of this tutorial will explain each of these steps in detail.

Column
Panel
borderColor#566b30
bgColor#fff
titleBGColor#D3E3C4
titleOn This Page
borderStylesolid
Table of Contents
minLevel2
maxLevel2
Panel
borderColor#321137
bgColor#fff
titleBGColor#c1b7c3
titleSee Also
borderStylesolid
Panel
borderColor#321137
bgColor#fff
titleBGColor#cccccc
titleStill need help?
borderStylesolid

Join the infusion-users mailing list and ask your questions there.

...

Step 1: Prepare your markup

Section
Column

Let's assume that you're working with some HTML that displays the information about a CD in your collection - something simple like this:

Code Block
html
html

<h1>Album Details</h1>

<h2>Artist</h2>
Portishead

<h2>Album</h2>
Third

<h2>Year</h2>
2008

<h2>Label</h2>
Universal Music

<h2>Review</h2>
<p>After a hiatus, <strong>Portishead</strong> is back with their first studio 
album in 6 years. <em>Third</em> brings back the familiar and
the new, and none of this is best exemplified than in the track
<em>Machine Gun</em>.</p>

<p>It seems that regardless of how <strong>Portishead</strong> sounds now, the one
thing that has stayed constant is their refusal to be ordinary.</p>
{code} {column} {column} In a browser window, this might look something like this: !inline-edit-1.jpeg! {column} {section} h3. The Changes {section} {column} The simplest way to make many pieces of text editable requires you to do three things: # define the block of text you want to make editable by using a container. # define how you want the rich inline edit component to look by using a container. # group the above two containers inside a parent container. If we want to make the review editable editable, then we could # wrap entire review text inside a {{<span>}} element and give it the default class {{flc-inlineEdit-text}}. # create a new {{<span>}} element with the default class name {{flc-inlineEdit-editContainer}}. We also define how big we want the rich edit field to be, and add _Save_ and _Cancel_ buttons. # place the above two {{<span>}} containers inside a {{<div>}} and give it a unique ID. This might look like the HTML sample to the right. {column} {column} {code:html}
Column

In a browser window, this might look something like this:

Image Added

The Changes

Section
Column

The simplest way to make many pieces of text editable requires you to do three things:

  1. define the block of text you want to make editable by using a container.
  2. define how you want the rich inline edit component to look by using a container.
  3. group the above two containers inside a parent container.

If we want to make the review editable editable, then we could

  1. wrap entire review text inside a <span> element and give it the default class flc-inlineEdit-text.
  2. create a new <span> element with the default class name flc-inlineEdit-editContainer. We also define how big we want the rich edit field to be, and add Save and Cancel buttons.
  3. place the above two <span> containers inside a <div> and give it a unique ID.

This might look like the HTML sample to the right.

Column
Code Block
html
html

<h1>Album Details</h1>

<h2>Artist</h2>
Portishead

<h2>Album</h2>
Third

<h2>Year</h2>
2008

<h2>Label</h2>
Universal Music

<h2>Review</h2>
<div id="cd-review">
  <span class="flc-inlineEdit-text">
    <p>After a hiatus, <strong>Portishead</strong> is back with their first studio 
    album in 6 years. <em>Third</em> brings back the familiar and
    the new, and none of this is best exemplified than in the track
    <em>Machine Gun</em>.</p>

    <p>It seems that regardless of how <strong>Portishead</strong> sounds now, the one
    thing that has stayed constant is their refusal to be ordinary.</p>
  </span>

  <span class="flc-inlineEdit-editContainer">
    <textarea rows="10" cols="80" ></textarea>
    <button class="save">Save</button> <button class="cancel">Cancel</button>
  </span>
</div>
{code} {column} {section}

That's

...

all

...

-

...

these

...

are

...

the

...

only

...

changes

...

you

...

need

...

to

...

make

...

to

...

your

...

HTML.

...

...

Step 2:

...

Write

...

the

...

script

...

There

...

are

...

a

...

some

...

scripts

...

you

...

will

...

need

...

to

...

add

...

to

...

your

...

HTML

...

file

...

before

...

the

...

Rich

...

Text

...

Inline

...

Edit

...

will

...

function

...

properly.

...

Define

...

Button

...

Behaviour

...

The

...

<button>

...

elements

...

by

...

themselves

...

will

...

not

...

do

...

anything

...

special

...

unless

...

we

...

specify

...

some

...

behaviour.

...

This

...

can

...

be

...

done

...

by

...

adding

...

the

...

following

...

script:

...

:}
Code Block
javascript
javascript
function makeButtons(editor) {
  $(".save", editor.container).click(function(){
    editor.finish();
    return false;
  });

  $(".cancel", editor.container).click(function(){
    editor.cancel();
    return false;
  });
}
{code}

This

...

will

...

make

...

the

...

Save

...

and

...

Cancel

...

buttons

...

perform

...

what

...

we'd

...

expect.

...

Initialize

...

the

...

Rich

...

Text

...

Inline

...

Editor

...

Now

...

you

...

need

...

to

...

initialize

...

the

...

Rich

...

Text

...

Inline

...

Editor.

...

If

...

using

...

TinyMCE

...

,

...

this

...

can

...

be

...

accomplished

...

by

...

the

...

following

...

code:

...

:}
Code Block
javascript
javascript
var richEditor = fluid.inlineEdit.tinyMCE("#cd-review", {tinyMCE: {width: 1024}});
makeButtons(richEditor);
{code}

If

...

using

...

FCKEditor

...

,

...

this

...

can

...

be

...

accomplished

...

by

...

the

...

following

...

code:

...

:}
Code Block
javascript
javascript
var richEditor = fluid.inlineEdit.FCKEditor("#cd-review", 
  {FCKEditor: {BasePath: "/lib/fckeditor/"}});
makeButtons(richEditor);
{code}

This

...

function

...

(regardless

...

of

...

the

...

editor

...

being

...

used)

...

will

...

look

...

inside

...

the

...

element

...

with

...

the

...

"cd-review"

...

ID

...

(in

...

this

...

case,

...

your

...

<div>

...

element)

...

for

...

anything

...

with

...

the

...

flc-inlineEdit-text

...

and

...

flc-inlineEdit-editContainer

...

class,

...

and

...

convert

...

it

...

into

...

an

...

Rich

...

Text

...

Inline

...

Edit

...

field.

...

Note:

...

We

...

specify

...

an

...

optional

...

width

...

for

...

the

...

TinyMCE

...

editor

...

so

...

that

...

it

...

fits

...

the

...

width

...

of

...

the

...

container

...

more

...

closely.

...

Putting

...

it

...

All

...

Together

...

Combining

...

all

...

of

...

the

...

above

...

scripts

...

together,

...

it

...

will

...

look

...

like

...

this:

...

:}
Code Block
javascript
javascript
function makeButtons(editor) {
  $(".save", editor.container).click(function(){
    editor.finish();
    return false;
  });

  $(".cancel", editor.container).click(function(){
    editor.cancel();
    return false;
  });
}

var richEditor = fluid.inlineEdit.tinyMCE("#cd-review", {tinyMCE: {width: 1024}});
makeButtons(richEditor);
{code}

By

...

putting

...

these

...

functions

...

inside

...

the

...

jQuery(document).ready()

...

call,

...

you

...

ensure

...

that

...

all

...

of

...

your

...

markup

...

is

...

ready

...

before

...

you

...

try

...

to

...

initialize

...

the

...

Rich

...

Text

...

Inline

...

Edit

...

components.

...

This

...

script

...

can

...

also

...

be

...

placed

...

in

...

a

...

<script>

...

block

...

at

...

the

...

end

...

of

...

your

...

document.

...

...

Step 3:

...

Add

...

the

...

Fluid

...

library

...

to

...

your

...

HTML

...

You'll

...

need

...

to

...

add

...

the

...

Fluid

...

library

...

to

...

you

...

HTML

...

file.

...

In

...

the

...

header

...

of

...

the

...

file,

...

link

...

to

...

the

...

Javascript

...

files

...

with

...

<script>

...

tags:

...

FCKEditor

...

Inetgration:

...

:}
Code Block
html
html
<script type="text/javascript" src="lib/fckeditor/fckeditor.js"></script>
<script type="text/javascript" src="InfusionAll.js"></script>
{code}

*TinyMCE 

TinyMCE Inetgration:

...

:}
Code Block
html
html
<script type="text/javascript" src="lib/tiny_mce//tiny_mce.js"></script>
<script type="text/javascript" src="InfusionAll.js"></script>
{code}

Alternatively,

...

the

...

individual

...

file

...

requirements

...

if

...

using

...

FCKEditor

...

are:

...

:}
Code Block
html
html
<script type="text/javascript" src="lib/fckeditor/fckeditor.js"></script>
<script type="text/javascript" src="lib/jquery/core/js/jquery.js"></script>
<script type="text/javascript" src="lib/jquery/ui/js/ui.core.js"></script>
<script type="text/javascript" src="lib/jquery/plugins/tooltip/js/jquery.tooltip.js"></script>
<script type="text/javascript" src="framework/core/js/jquery.keyboard-a11y.js"></script>
<script type="text/javascript" src="framework/core/js/Fluid.js"></script>
<script type="text/javascript" src="components/inlineEdit/js/InlineEdit.js"></script>
<script type="text/javascript" src="components/inlineEdit/js/InlineEditIntegrations.js"></script>
{code}

Otherwise,

...

the

...

individual

...

file

...

requirements

...

if

...

using

...

TinyMCE

...

are:

...

:}
Code Block
html
html
<script type="text/javascript" src="lib/tiny_mce//tiny_mce.js"></script>
<script type="text/javascript" src="lib/jquery/core/js/jquery.js"></script>
<script type="text/javascript" src="lib/jquery/ui/js/ui.core.js"></script>
<script type="text/javascript" src="lib/jquery/plugins/tooltip/js/jquery.tooltip.js"></script>
<script type="text/javascript" src="framework/core/js/jquery.keyboard-a11y.js"></script>
<script type="text/javascript" src="framework/core/js/Fluid.js"></script>
<script type="text/javascript" src="components/inlineEdit/js/jquery.tinymce.js"></script>
<script type="text/javascript" src="components/inlineEdit/js/InlineEdit.js"></script>
<script type="text/javascript" src="components/inlineEdit/js/InlineEditIntegrations.js"></script>
{code}

h3. Important 

Important Note:

...

FCKEditor

...

and

...

TinyMCE

...

FCKEditor

...

and

...

TinyMCE

...

are

...

not

...

included

...

in

...

the

...

Infusion

...

bundle,

...

but

...

can

...

be

...

downloaded

...

from

...

their

...

respective

...

websites.

...

Refer

...

to

...

components/inlineEdit/js/InlineEditInegrations.js

...

-

...

the

...

integration

...

file

...

-

...

to

...

see

...

how

...

to

...

technically

...

integrate

...

these

...

editors

...

into

...

your

...

application.

...

...