setControl($control); } if ($labelName) { $this->setLabelName($labelName); } } /** * Get the Control * * @api * @return Control */ public function getControl() { return $this->control; } /** * Set the Control * * @api * @param Control $control Map Info Control * @return static */ public function setControl(Control $control) { $control->checkId(); if ($control instanceof Scriptable) { $control->setScriptEvents(true); } $this->control = $control; return $this; } /** * Get the Script Label name * * @api * @return string */ public function getLabelName() { return $this->labelName; } /** * Set the Script Label name * * @api * @param string $labelName Script Label name * @return static */ public function setLabelName($labelName) { $this->labelName = (string)$labelName; return $this; } /** * @see ScriptFeature::prepare() */ public function prepare(Script $script) { $script->appendGenericScriptLabel($this->labelName, $this->getScriptText()); return $this; } /** * Get the script text * * @return string */ protected function getScriptText() { if ($this->control) { // Control event $controlId = Builder::escapeText($this->control->getId()); return " if (Event.Control.ControlId == {$controlId}) { ShowCurChallengeCard(); }"; } // Other events return " ShowCurChallengeCard();"; } }