PDA

View Full Version : tab



alien3d
28 Jun 2007, 8:34 PM
I found out tab.activated only are the sub function of class tab.So when you want to write some code like this it will clash the function activate twise since at return code i redirect page.What my suggestion are more tab1.function x more to avoid conflict activate.Currently 3 tab i use at the same page while 1 more tab i redirect to other page.It make the page render less code then put all the php and js code together in page.


tab1=new tab1
tab1.activate=function () {
return code
}
tab 2 =new tab2

tab.activate

alien3d
30 Jun 2007, 1:40 AM
E.g what i mean it is at https://sourceforge.net/projects/idcms/
I used tab to navigate the grid .I not good in explanation thing.But tab based + grid are clean interface .Only the problem just lack sub tab function .

mystix
30 Jun 2007, 8:21 AM
Umm... you gotta be clearer than that... after reading both your posts 5 times i still don't get what you're trying to say.:-/

alien3d
30 Jun 2007, 8:26 PM
var tab = new Ext.TabPanel('tab1');
var tab1=tab.addTab('day', '<?php echo $language['calendar']['day']; ?>');
var tab2=tab.addTab('week','<?php echo $language['calendar']['week']; ?>');
var tab3=tab.addTab('month', '<?php echo $language['calendar']['month']; ?>');
var tab4=tab.addTab('year', '<?php echo $language['calendar']['year']; ?>');

// i cannot use click function so ask php to disable js function before clash active
// suppose the element of object.on not limited to the page itself
<?php if (!($_GET['calendar']=='day')) { ?>
tab1.on('activate', function(){
window.location.replace("asset_sales.php?date=<?php echo date("Y-m-d"); ?>&calendar=day");
});
<?php } ?>
<?php if(!($_GET['calendar']=='week')) {
// it actually targer first day of the week
$lowEnd=date("w");
$lowEnd=-$lowEnd;
$highEnd=$lowEnd + 6;
$weekday=0;
for ($i=$lowEnd; $i<=$highEnd; $i++) {

$WeekDate[$weekday]=date("Y-m-d",mktime(0, 0, 0, date("m") , date("d")+$i +1, date("Y")));
$weekday++;
}
?>

tab2.on('activate', function(){

window.location.replace("asset_sales.php?date=<?php echo date("Y-m-d"); ?>&start_date=<?php echo $WeekDate[0]; ?>&end_date=<?php echo $WeekDate[6]; ?>&calendar=week");
});
<?php } ?>

<?php if(!($_GET['calendar']=='month')) { ?>
tab3.on('activate', function(){

window.location.replace("asset_sales.php?date=<?php echo date("Y-m-d"); ?>&calendar=month");
});
<?php } ?>

<?php if(!($_GET['calendar']=='year')) { ?>
tab4.on('activate', function(){

window.location.replace("asset_sales.php?date=<?php echo date("Y-m-d"); ?>&calendar=year");
});
<?php } ?>
tab.activate('<?php echo $_GET['calendar']; ?>');

tab1.on('activate', function(){ }
and tab.activate(x)

The same code run twice again.In my case,if php doesn't responce it will redirect the page again and again.

What i really wanted is
tab1.on('onClick',function() { } or tab1.on('onMouseOver',function (){ } .The code might expand more idea on tab based code.

but i i try using the aptana.the sub class of it wouldn't appear and it wouldn't execute.
The output of the application might be download at
http://sourceforge.net/projects/idcms/

mystix
2 Jul 2007, 7:14 AM
my goodness... finally understood what you're trying to say...
had a hard time trying to figure out your code comments too...

you're setting handlers for the 'activate' event for all 4 of your tabs, then activating the 1st tab via tab1.activate. then your infinite loop kicks in 'cos you're reloading the window which contains all your 4 tabs, which is the asset_sales.php page.

why are you doing this? if you're just passing params back to the page itself, just make your 'activate' handlers get and set values of existing DOM elements in the page, or perform an XHR.

if you call window.reload, all js variables will be cleared and reset and you're never going to be able to stop the loop via js.

alien3d
2 Jul 2007, 6:56 PM
If i used xhr.Might be good idea but how?Since i use lot of parsing variable.So it bit difficult to maintain the variable output and input.I will try the idea next.
If i used DOM.What code should i do.Can you give the example to do it.Soory ma