<?php set_include_path(get_include_path() . PATH_SEPARATOR . realpath('../../library')); include_once 'PhpExt/Javascript.php'; PhpExt_Javascript::sendContentType(); include_once 'PhpExt/Ext.php'; include_once 'PhpExt/Element.php'; include_once 'PhpExt/Handler.php'; include_once 'PhpExt/MessageBox.php'; include_once 'PhpExt/MessageBoxOptions.php'; include_once 'PhpExt/ProgressBarWaitConfig.php'; $mb1Element = PhpExt_Element::getById('mb1'); $mb1Handler = PhpExt_Javascript::functionDef(null, PhpExt_MessageBox::confirm("Confirm", "Are you sure you want to do that", PhpExt_Javascript::variable('showResult')), array("e")); $mb2Element = PhpExt_Element::getById('mb2'); $mb2Handler = PhpExt_Javascript::functionDef(null, PhpExt_MessageBox::prompt("Name", "Please enter your name:", PhpExt_Javascript::variable('showResultText')), array("e")); $mb3Element = PhpExt_Element::getById('mb3'); $mb3Options = PhpExt_MessageBoxOptions::createMsgOptions()->setTitle('Address')->setMsg('Please enter your address:')->setWidth(300)->setButtons(PhpExt_MessageBox::OKCANCEL())->setMultiline(true)->setFn(PhpExt_Javascript::variable('showResultText'))->setAnimEl('mb3'); $mb3Handler = PhpExt_Javascript::functionDef(null, PhpExt_MessageBox::show($mb3Options)); $mb4Element = PhpExt_Element::getById('mb4'); $mb4Options = PhpExt_MessageBoxOptions::createMsgOptions()->setTitle('Save Changes?')->setMsg('You are closing a tab that has unsaved changes. <br />Would you like to save your changes?')->setButtons(PhpExt_MessageBox::YESNOCANCEL())->setFn(PhpExt_Javascript::variable('showResult'))->setAnimEl('mb4')->setIcon(PhpExt_MessageBox::QUESTION()); $mb4Handler = PhpExt_Javascript::functionDef(null, PhpExt_MessageBox::show($mb4Options)); $mb6Element = PhpExt_Element::getById('mb6'); $mb6Options = PhpExt_MessageBoxOptions::createMsgOptions()->setTitle('Please wait')->setMsg('Loading items...')->setProgressText('Initializing...')->setWidth(300)->setProgress(true)->setClosable(false)->setAnimEl('mb6'); $mb6Hide = PhpExt_MessageBox::hide()->output(); $mb6Progress = PhpExt_MessageBox::updateProgress(PhpExt_Javascript::variable("i"), PhpExt_Javascript::inlineStm("Math.round(100*i)+'% completed'"))->output(); $mb6Handler = PhpExt_Javascript::functionDef(null, PhpExt_MessageBox::show($mb6Options)->output() . "\r\n\t\t// this hideous block creates the bogus progress\r\n var f = function(v){\r\n return function(){\r\n if(v == 12){\r\n " . $mb6Hide . ";\r\n Ext.example.msg('Done', 'Your fake items were loaded!');\r\n }else{\r\n var i = v/11;\r\n\t\t\t\t\t" . $mb6Progress . "; \r\n }\r\n };\r\n };\r\n for(var i = 1; i < 13; i++){\r\n setTimeout(f(i), i*500);\r\n }"); $mb7Element = PhpExt_Element::getById('mb7'); $mb7Options = PhpExt_MessageBoxOptions::createMsgOptions()->setMsg('Saving your data, please wait...')->setProgressText('Saving...')->setWait(true)->setWaitConfig(PhpExt_ProgressBarWaitConfig::createWaitConfig()->setInterval(200))->setIcon('ext-mb-download')->setAnimEl('mb7'); $mb7Handler = PhpExt_Javascript::functionDef(null, PhpExt_MessageBox::show($mb7Options)->output() . "\r\n\t\tsetTimeout(function(){\r\n //This simulates a long-running operation like a database save or XHR call.\r\n //In real code, this would be in a callback function.\r\n " . PhpExt_MessageBox::hide()->output() . ";\r\n Ext.example.msg('Done', 'Your fake data was saved!');\r\n }, 8000);"); $mb8Element = PhpExt_Element::getById('mb8'); $mb8Handler = PhpExt_Javascript::functionDef(null, PhpExt_MessageBox::alert("Status", "Changes saved successfully.", PhpExt_Javascript::variable('showResult')));