Пример #1
0
 public function testControl()
 {
     $menuElement = new MenuElement();
     $control = new Label();
     $this->assertNull($menuElement->getControl());
     $this->assertSame($menuElement, $menuElement->setControl($control));
     $this->assertSame($control, $menuElement->getControl());
 }
Пример #2
0
 /**
  * @see ScriptFeature::prepare()
  */
 public function prepare(Script $script)
 {
     $updateFunctionName = self::FUNCTION_UPDATE_MENU;
     $elementsArrayText = $this->getElementsArrayText();
     // OnInit
     if ($this->startElement) {
         $startControlId = Builder::escapeText($this->startElement->getControl()->getId());
         $initScriptText = "\n{$updateFunctionName}({$elementsArrayText}, {$startControlId});";
         $script->appendGenericScriptLabel(ScriptLabel::ONINIT, $initScriptText, true);
     }
     // MouseClick
     $scriptText = "\ndeclare MenuElements = {$elementsArrayText};\nif (MenuElements.existskey(Event.Control.ControlId)) {\n\tdeclare ShownControlId = MenuElements[Event.Control.ControlId];\n\t{$updateFunctionName}(MenuElements, ShownControlId);\n}";
     $script->appendGenericScriptLabel(ScriptLabel::MOUSECLICK, $scriptText, true);
     // Update menu function
     $updateFunctionText = "\nVoid {$updateFunctionName}(Text[Text] _Elements, Text _ShownControlId) {\n\tforeach (ItemId => ControlId in _Elements) {\n\t\tdeclare Control <=> (Page.GetFirstChild(ControlId));\n\t\tControl.Visible = (ControlId == _ShownControlId);\n\t}\n}";
     $script->addScriptFunction($updateFunctionName, $updateFunctionText);
     return $this;
 }