Exemple #1
0
 protected function attached($presenter)
 {
     parent::attached($presenter);
     if ($presenter instanceof Nette\Application\IPresenter) {
         $this->onAttached($this);
     }
 }
Exemple #2
0
 /**
  * @param \Nette\ComponentModel\Container $obj
  */
 protected function attached($obj)
 {
     if ($obj instanceof \Nette\Application\IPresenter) {
         $this->attachHandlers();
     }
     parent::attached($obj);
 }
Exemple #3
0
	/**
	 * This method will be called when the component (or component's parent)
	 * becomes attached to a monitored object. Do not call this method yourself.
	 * @param  Nette\Application\IComponent
	 * @return void
	 */
	protected function attached($presenter)
	{
		parent::attached($presenter);
		if ($this->getContext()->hasService('translator')) {
			$this->setTranslator($this->getContext()->translator);
		}
	}
Exemple #4
0
 protected function attached($presenter)
 {
     parent::attached($presenter);
     if ($presenter instanceof \Nette\Application\UI\Presenter) {
         $this->builder->setDefaults($this);
     }
 }
Exemple #5
0
 protected function attached($control)
 {
     parent::attached($control);
     if (!is_array($this->onSuccess)) {
         $this->onSuccess = [];
     }
     array_unshift($this->onSuccess, function () {
         $this->flashMessage($this->formatFlashMessage('success'), 'success');
     });
     $this->onSuccess[] = function () {
         if (!$this->getPresenter()->isAjax()) {
             $this->getControl()->redirect('this');
         }
     };
     if (!is_array($this->onError)) {
         $this->onError = [];
     }
     array_unshift($this->onError, function () {
         $this->flashMessage($this->formatFlashMessage('error'), 'danger');
     });
     if (!is_array($this->onSubmit)) {
         $this->onSubmit = [];
     }
     array_unshift($this->onSubmit, function () {
         $this->getControl()->redrawControl();
     });
 }
Exemple #6
0
 /**
  * @param \Nette\ComponentModel\Container $parent
  */
 protected function attached($parent)
 {
     parent::attached($parent);
     if ($parent instanceof Control) {
         $this->setRenderer(new \FoundationFormRenderer\Renderer());
     }
 }
Exemple #7
0
 /**
  * @param \Nette\ComponentModel\IComponent $component
  */
 protected function attached($component)
 {
     parent::attached($component);
     if (!$component instanceof Presenter) {
         return;
     }
     $this->configure($component);
 }
 /**
  * @param Nette\Application\IPresenter
  */
 protected function attached($presenter)
 {
     parent::attached($presenter);
     if ($presenter instanceof Nette\Application\IPresenter) {
         $this->beforeSetup();
         $this->setup();
     }
 }
Exemple #9
0
 /**
  * Autofocus AJAX handling.
  *
  * @param $presenter
  */
 public function attached($presenter)
 {
     parent::attached($presenter);
     if ($this->autofocus !== NULL) {
         $this[$this->autofocus]->setAttribute('autofocus');
         if ($presenter->isAjax()) {
             $presenter->payload->focus = $this[$this->autofocus]->getHtmlId();
         }
     }
 }
Exemple #10
0
 public function attached($presenter)
 {
     parent::attached($presenter);
     /** @var App\GameModule\DTO\Unit $unit */
     foreach ($this->units as $unit) {
         $this->addText($unit->getId() . 'number', $unit->getName())->setAttribute('class', 'text')->addCondition(Nette\Forms\Form::NUMERIC);
     }
     $this->addSubmit('submit', 'Train')->setAttribute('type', 'image')->setAttribute('class', 'dynamic_img')->setAttribute('id', 'btn_train');
     return $this;
 }
Exemple #11
0
 protected function attached($parent)
 {
     parent::attached($parent);
     if (!$parent instanceof UI\Presenter || !Debugger::isEnabled()) {
         return;
     }
     Debugger::$bar->addPanel($this);
     $this->addText('destination', 'Destination')->addRule($this::FILLED, 'Je třeba zadat destinaci.')->getControlPrototype()->placeholder = 'Please enter destination';
     $this->addSubmit('redirect', 'Redirect')->onClick[] = callback($this, 'processRedirect');
     $this->addSubmit('showLink', 'Show link')->onClick[] = callback($this, 'processShowLink');
 }
Exemple #12
0
 /**
  * This method will be called when the component (or component's parent)
  * becomes attached to a monitored object. Do not call this method yourself.
  * @param  Nette\ComponentModel\IComponent
  * @return void
  */
 protected function attached($presenter)
 {
     parent::attached($presenter);
     if (empty($this->uploadDir)) {
         $this->cache = new Nette\Caching\Cache($this->presenter->context->getService('cacheStorage'), 'nette-plupload');
         $this->uploadDir = $this->presenter->context->expand('%tempDir%') . '/nette-plupload-files';
         if (!is_dir($this->uploadDir) && !mkdir($this->uploadDir, 0775, TRUE)) {
             throw new \RuntimeException(sprintf('Cannot create upload dir %s', $this->uploadDir));
         }
     }
 }
Exemple #13
0
 /**
  * @param $presenter
  */
 public function attached($presenter)
 {
     parent::attached($presenter);
     $renderer = new BootstrapRenderer();
     $this->setRenderer($renderer);
     if ($presenter instanceof Presenter) {
         $this->setTranslator($presenter->getTranslator());
         if ($presenter->isAjax()) {
             $this->getElementPrototype()->class[] = 'ajax';
         }
     }
 }
Exemple #14
0
 /**
  * @param \Nette\ComponentModel\Container
  */
 protected function attached($obj)
 {
     if ($obj instanceof Nette\Application\IPresenter) {
         if ($this->getComponents()->count() === 0) {
             # form was created by operator new
             $this->beforeSetup();
             $this->setup();
             $this->afterSetup();
         }
         $this->attachHandlers();
     }
     parent::attached($obj);
 }
Exemple #15
0
 /**
  * @param \Nette\ComponentModel\Container $obj
  */
 protected function attached($obj)
 {
     parent::attached($obj);
     if ($this->mapper) {
         $this->mapper->assign($this->data, $this);
     }
     $this->onAttached($this);
     if ($obj instanceof \Nette\Application\UI\Presenter) {
         if (!$this->isSubmitted()) {
             if ($this->mapper) {
                 $this->mapper->load();
             }
             $this->onLoad($this);
         }
     }
 }
Exemple #16
0
 /**
  * @param ITranslatableComponent $parent
  */
 protected function attached($parent)
 {
     parent::attached($parent);
     $this->setTranslator($parent->getTranslator());
 }