Skip to content

Instantly share code, notes, and snippets.

@lucas1
Last active January 3, 2016 17:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lucas1/8494608 to your computer and use it in GitHub Desktop.
Save lucas1/8494608 to your computer and use it in GitHub Desktop.

NAME

DHX::Accordion - Generate XML for defining interfaces with DHTMLX

SYNOPSIS

use DHX;

my $accordion = DHX::Accordion->new;

$accordion->cell(
    {
        id => "bar",
        text => "Bar"
    },
    {
        id => "foo",
        text => "Foo"
    }
);

print $accordion->result;

ATTRIBUTES

skin

Set skin, default skin is dhx_skyblue.

$accordion->skin('dhx_terrace');
mode

Set mode, default mode is single.

$accordion->mode('multi');
iconsPath

Set iconsPath, default iconsPath is '../common/'.

$accordion->iconsPath('/var/www/app/public/icons');
openEffect

Set openEffect, default openEffect is false.

$accordion->openEffect('true');

METHODS

new
my $accordion = DHX::Accordion->new(encoding => value);

Set encoding is optional. Default is utf-8.

cell
$accordion->cell(%args);

%args has all parameters defined on dhtmlxAccordion, exception parameter text that is same appendTextNode in XML::LibXML.

result
print $accordion->result(format);

return XML string, ready for output.

If format is 0, than the document is dumped as it was originally parsed.

print $accordion->result;

If format is 1, libxml2 will add ignorable white spaces, so the nodes content is easier to read. Existing text nodes will not be altered.

print $accordion->result(1);

If format is 2 (or higher), libxml2 will act as $format == 1 but it add a leading and a trailing line break to each text node.

print $accordion->result(2);

EXAMPLES

example 1

use DHX;

my $accordion = DHX::Accordion->new;

$accordion->cell(
    {
        id => "bar",
        text => "Bar",
        height => 120
    },
    {
        id => "foo",
        text => "Foo",
        icon => "icon.gif"
    },
    {
        id => "baz",
        text => "Baz",
        open => "true"
    }
);

print $accordion->header_cgi;
print $accordion->result;

return

<?xml version="1.0" encoding="utf-8"?>
<accordion skin="dhx_skyblue" mode="single" iconsPath="../common/" openEffect="false">
  <cell id="bar" height="120">Bar</cell>
  <cell icon="icon.gif" id="foo">Foo</cell>
  <cell open="true" id="baz">Baz</cell>
</accordion>

example 2

use DHX;

my $accordion = DHX::Accordion->new(encoding => 'iso-8859-1');

$accordion->cell(
    {
        id => "bar",
        text => "Bar",
        height => 120
    }
);

$accordion->cell(
    {
        id => "foo",
        text => "Foo",
        icon => "icon.gif"
    }
);

$accordion->cell(
    {
        id => "baz",
        text => "Baz",
        open => "true"
    }
);

print $accordion->header_cgi;
print $accordion->result;

return

<?xml version="1.0" encoding="iso-8859-1"?>
<accordion skin="dhx_skyblue" mode="single" iconsPath="../common/" openEffect="false">
  <cell id="bar" height="120">Bar</cell>
  <cell icon="icon.gif" id="foo">Foo</cell>
  <cell open="true" id="baz">Baz</cell>
</accordion>

AUTHOR

Lucas Tiago de Moraes <lucastiagodemoraes {at} gmail.com>

LICENSE

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment