Welcome, Guest. Please login or register.
Did you miss your activation email?
Feb. 04, 2012, 03:04:41 AM
55060 Posts in 12346 Topics by 65335 Members
Latest Member: Ward52lor
News:
 
The PRADO Community » Prado v3.x » Component Repository » Simple YTabPanel « previous next »
Pages: [1] 2 Print
Author Topic: Simple YTabPanel  (Read 12920 times)
Ykee
Senior Member
***

Karma: 10
Offline Offline

Posts: 80



View Profile WWW
« on: Mar. 20, 2007, 12:46:21 AM »

Hi All

Sorry for my English...

I have read it Component: TabPanel, and I think, that I have found other way.
My component does not need other new files JavaScript, as it uses with existing files (Prototype.js).

The usage is:
Code:
<com:YTabPanel [ID="MyTabPanelID"]
      [CssClass = "(@string)"]
      [PageCssClass = "@string"]
      [ActiveTabCssClass = "(@string)"]
      [InactiveTabCssClass = "(@string)"]  >
   <com:YTabPage Caption="(@string)" Text="(@string)" />
   <com:YTabPage Caption="(@string)">
      Content (other controls)
   </com:YTabPage>
</com:YTabPanel>

[ ] - optional parameters
CssClass - default name: tab-panel
PageCssClass - default name: tab-page
ActiveTabCssClass - tab-active
InactiveTabCssClass - tab-inactive

Caption is required.

Like You see - We need four css class in order to display our TabPanel

Simple TabPanel
In my Css files i wrote this code:
Code:
.tab-panel {
  position: relative;
  margin: 3px;
  padding: 0;
  z-index: 1;
  height: 100px;
}

.tab-menu-active {
  position: relative;
  z-index: 4;
  background: white;
  border-top: solid 1px #aba9aa;
  border-left: solid 1px #aba9aa;
  border-right: solid 1px #737373;
  padding: 5px 5px 3px 5px;
  display: block;
  float: left;
}
.tab-menu-inactive {
  position: relative;
  border-top: solid 1px #aba9aa;
  border-left: solid 1px #aba9aa;
  border-right: solid 1px #737373;
  top: 1px;
  z-index: 2;
  margin-right: -1px;
  padding: 3px;
  display: block;
  float: left;
}
.tab-page {
  position: absolute;
  width: 90%;
  top: 21px;
  padding: 3px;
  display: block;
  clear: both;
  background: white;
  z-index: 3;
  border-top: solid 1px #aba9aa;
  border-left: solid 1px #aba9aa;
  border-right: solid 1px #737373;
  border-bottom: solid 1px #737373;
  height: 70px;
}

hmm... That's all! I hope You liked it...

Changes and suggestions is required.

ps. Lourival Júnior thanks for You work.

File has been deleted... Look below
« Last Edit: Jul. 25, 2007, 06:37:28 PM by Ykee » Logged

- - ----[ pzdr. Ykee ]---- - -
rojaro
Administrator
Platinum Member
*****

Karma: 43
Offline Offline

Posts: 799


PRADO aint no voodoo ...


View Profile WWW
« Reply #1 on: Mar. 20, 2007, 09:29:10 AM »

Great work Smiley
Logged

A mathematician is a device for turning coffee into theorems. ~ Alfred Renyi (*1921 - †1970)
Ykee
Senior Member
***

Karma: 10
Offline Offline

Posts: 80



View Profile WWW
« Reply #2 on: Mar. 23, 2007, 07:25:22 AM »

thanks!  Grin

...any sugestions?

Smiley
Logged

- - ----[ pzdr. Ykee ]---- - -
eirikhm
PRADO v3.x Developer
Platinum Member
*****

Karma: 30
Offline Offline

Posts: 845



View Profile WWW
« Reply #3 on: Mar. 23, 2007, 07:58:57 AM »

Nice work. This is a neat and handy control that we should have included in the Prado Framework. Cross your fingers for someone to notice it Smiley
Logged

Lourival Júnior
Senior Member
***

Karma: 8
Offline Offline

Posts: 62


It's me :)


View Profile
« Reply #4 on: Mar. 25, 2007, 01:43:22 PM »

Excellent Work Smiley! Prototype has amazing tools that we can use, avoiding other libraries and reusing what we already have in PRADO. My suggestion is to avoid the use of obtrusive javascript code, and write a json class to your component. For example, you can replace the onclick attribute and write in this file a Event.observe() function handling the event. Just a suggestion Smiley . See prototype documentation for more examples..

Regards,
Logged
Ykee
Senior Member
***

Karma: 10
Offline Offline

Posts: 80



View Profile WWW
« Reply #5 on: Mar. 25, 2007, 03:00:00 PM »

Hi!
Due to for suggestion Lourival Júnior. I think of it earlier, but I did not penetrate to problem deeper. Problem of time.
While I have found in code small bug, but I have corrected it already

Error relied on it, that if we had two panels, JavaScript code not working.

but now You can (for example):
Code:
<com:YTabPanel [ID="MyTabPanelID"]
      [CssClass = "(@string)"]
      [PageCssClass = "@string"]
      [ActiveTabCssClass = "(@string)"]
      [InactiveTabCssClass = "(@string)"]  >
   <com:YTabPage Caption="(@string)" Text="(@string)" />
   <com:YTabPage Caption="(@string)">
      Content (other controls)
   </com:YTabPage>
   <com:YTabPage Caption="(@string)">
      <com:YTabPanel [ID="MyOtherTabPanelID"]
            [... css clases ... if you want...]
         <com:YTabPage Caption="(@string)" >
            Content
         </com:YTabPage>
         <com:YTabPage Caption="(@string)" Text="(@string)" />
      </com:YTabPanel>
   </com:YTabPage>
</com:YTabPanel>

Now i read prototype documentation...  Grin

* YTabPanel.zip (2.29 KB - downloaded 89 times.)
« Last Edit: Mar. 25, 2007, 07:01:20 PM by Ykee » Logged

- - ----[ pzdr. Ykee ]---- - -
wei
PRADO v3.x Developer
Diamond Member
*****

Karma: 65
Offline Offline

Posts: 2869



View Profile
« Reply #6 on: Apr. 01, 2007, 01:57:53 AM »

Look great! I actually like the way you described your component

Code:
<com:YTabPanel [ID="MyTabPanelID"]
      [CssClass = "(@string)"]
      [PageCssClass = "@string"]
      [ActiveTabCssClass = "(@string)"]
      [InactiveTabCssClass = "(@string)"]  >

may be this can be used to describe the components automatically in some documentation (with links and colouring).
Logged
Ykee
Senior Member
***

Karma: 10
Offline Offline

Posts: 80



View Profile WWW
« Reply #7 on: Apr. 06, 2007, 03:05:11 PM »

Thanks wei!

Tell me please, how You have use my component to "...describe the components automatically in some documentation" ?
I can't imagine this.  Smiley

Meantime, i added 'DefaultPage' property in to my component.
Now it is possible to be checked off indicate which tab is active in first display:
Code:
<com:YTabPanel [ID="MyTabPanelID"]
               [CssClass = "(@string)"]
               [PageCssClass = "@string"]
               [ActiveTabCssClass = "(@string)"]
               [InactiveTabCssClass = "(@string)"]  >
   <com:YTabPage Caption="(@string)" Text="(@string)" />
   <com:YTabPage Caption="(@string)"    DeafultPage="true" >
      Content (other controls)
   </com:YTabPage>
   <com:YTabPage Caption="(@string)" >
[...]
   </com:YTabPage>
</com:YTabPanel>

It will be displayed like:
                            _______
| inactive | inactive | active | inactive |
--------------------            -------------
|                                                        |
------------------------------------------

DefaultPage property default is false ..... Smiley

Greetings for all

* YTabPanel.zip (2.39 KB - downloaded 68 times.)
« Last Edit: Apr. 06, 2007, 03:32:44 PM by Ykee » Logged

- - ----[ pzdr. Ykee ]---- - -
durgis
Senior Member
***

Karma: 25
Offline Offline

Posts: 434


View Profile
« Reply #8 on: Apr. 25, 2007, 06:26:08 PM »

Hello, I have been using your component, and noticed that there is an XHTML validation problem. since YTabPage is rendering as a div element, there are nested divs with the same id. I'm not sure how you would like to refactor this, but I would suggest one of the following.

Change the YTabPage class to make it so that it only renders it's contents, and not a tag.
Code:
class YTabPage extends TControl
{
/**
* @return string
*/   
public function getCaption()
{
    return $this->getViewState('Caption','');
  }
  /**
* @param string
*/
public function setCaption($value)
{
$this->setViewState('Caption',TPropertyValue::ensureString($value),'');
}
/**
* @return string
*/   
public function getText()
{
    return $this->getViewState('Text','');
  }
  /**
* @param string
*/
public function setText($value)
{
$this->setViewState('Text',TPropertyValue::ensureString($value),'');
}

  /**
* Renders body contents of the table cell.
* @param THtmlWriter the writer used for the rendering purpose.
*/
public function renderContents($writer)
{
if(($text=$this->getText())!=='')
$writer->write($text);
else if($this->getHasControls())
parent::renderContents($writer);
else
$writer->write('&nbsp;');
}
}

Or change the following line in YTabPanel renderContents function to remove the id of the div element there.
Code:
Old: $writer->write('<div class="'.$this->getPageCssClass().'" id="'.$tabpage->getClientID().'"');
New: $writer->write('<div class="'.$this->getPageCssClass().'"');
Logged
Ykee
Senior Member
***

Karma: 10
Offline Offline

Posts: 80



View Profile WWW
« Reply #9 on: Apr. 25, 2007, 10:05:28 PM »

Hello

Dear Durgis, I appologize, but i don't know, if I be able to help You, because i dont see error. Tell me please, in which moment error appears?
I have made my component so, in order to each had uniqe 'id' - PRADO transmits Unique ID, hwo I overwrite for HTML tag.

Look heare: when Prado render YTabPanel, and YTabPages, we receive such code as:
Code:

<div class="tab-panel" id="ctl0">  ................................ ctl0           PRADO uniqe ID, meybe different in somebody other
   <span id="tm_ctl1"  class="tab-active"> .................. tm_ctl1     PRADO unique ID with my prefix 'tm' - For distinguishing from Control with this ID
      <a href="#" onclick=" .... some js code ...">Caption 1</a>
   </span>
   <span id="tm_ctl2"  class="tab-inactive">
      <a href="#" onclick=" .... some js code ...">Caption 2</a>
   </span>

   <div class="tab-page" id="ctl1"> ...........................  ctl1         PRADO unique ID
      <div>.... some content 1 .... </div> ................. this is rendered YTabPage
   </div>
   <div class="tab-page" id="ctl2" style="display: none;">
      <div> .... some content 2 .... </div>
   </div>
</div>


Quote

$writer->write('<div class="'.$this->getPageCssClass().'" id="'.$tabpage->getClientID().'"');

I need this 'id' in order to JavaScript code acted ...

Tell me more about You problem please...

I tested my Component in IE, FF and OP... and working fine... but meybe i don't see something
« Last Edit: Apr. 25, 2007, 10:07:23 PM by Ykee » Logged

- - ----[ pzdr. Ykee ]---- - -
Ykee
Senior Member
***

Karma: 10
Offline Offline

Posts: 80



View Profile WWW
« Reply #10 on: Apr. 26, 2007, 10:16:02 AM »

OK Durgis, i see now my bad... You have right...

I think i know, how to rebuild... but tomorow...

bye
Logged

- - ----[ pzdr. Ykee ]---- - -
durgis
Senior Member
***

Karma: 25
Offline Offline

Posts: 434


View Profile
« Reply #11 on: Apr. 26, 2007, 01:33:01 PM »

I can't wait to see it. Thanks for making this wonderful component.
Logged
Ykee
Senior Member
***

Karma: 10
Offline Offline

Posts: 80



View Profile WWW
« Reply #12 on: Apr. 29, 2007, 01:11:15 AM »

I greet all, who follow evolution of this component... Wink

a now version 0004 from day 29.04.2007 (meybe better from night...)

What has been changed:

1. rebuild it a bit and now no XHTML validation problem... - i hope;
2. No 'DefaultPage' on YTabPage, now You have 'DefaultPageIndex' and 'DefaultPageID' (on YTabPanel) for mark, which page has to be displayed as first...
3. Better - i hope - JS code - more elegant. I write a json class, but best as I can... And still You don't need additional JS files. Prototype will suffice.


 
Code:

 *   <com:YTabPanel [CssClass = "(@string)"]
 *                  [PageCssClass = "@string"]
 *                  [ActiveTabCssClass = "(@string)"]
 *                  [InactiveTabCssClass = "(@string)"]
 *                  [DefaltPageIndex="(@Integer)" | DefaultPageID="(@string)"]   >
 *     <com:YTabPage [ID="(@string)"] Caption="(@string)" Text="(@string)" />
 *     <com:YTabPage [ID="(@string)"] Caption="(@string)">
 *       Content (other controls)
 *     </com:YTabPage>
 *   </com:YTabPanel>
 

 LEGEND:
 [ ] - optional parameters
 CssClass - default name: tab-panel
 PageCssClass - default name: tab-page
 ActiveTabCssClass - default name: tab-active
 InactiveTabCssClass - default name: tab-inactive
 DefaultPageIndex - param: @integer - index of page for first display
 DefaultPageID - param: @string - this same as DefaultPageIndex, but param is a ID (PRADO) of page for first display

IMPORTAND: DefaultPageID has highest priority(!), and DefaultPageIndex value (if it use both, and both are correct) will be ignored!   
IMPORTAND: Unsuitable values in DefaultPageIndex or DefaultPageID, will be ignored!

How work it:
Example: http://www.polecam.to.pl/demos/YTabPanel/

Any suggestion is indispensable... Cheesy

I salute...

* YTabPanel_0004_200704290244.zip (2.95 KB - downloaded 101 times.)
Logged

- - ----[ pzdr. Ykee ]---- - -
durgis
Senior Member
***

Karma: 25
Offline Offline

Posts: 434


View Profile
« Reply #13 on: May. 01, 2007, 01:41:47 PM »

I plugged in the new file, and it just worked; nice work, and thanks for the updates.
Logged
Ykee
Senior Member
***

Karma: 10
Offline Offline

Posts: 80



View Profile WWW
« Reply #14 on: May. 01, 2007, 08:09:04 PM »

[...], and it just worked;
And there had to be so. It fairest accolade. Thanks
Logged

- - ----[ pzdr. Ykee ]---- - -
Pages: [1] 2 Print 
« previous next »
Jump to: