getControl() public method

Generates control's HTML element.
public getControl ( ) : Nette\Utils\Html
return Nette\Utils\Html
Exemplo n.º 1
0
 /**
  * Generates control's HTML element
  *
  * @return Html
  */
 public function getControl()
 {
     $control = parent::getControl()->addClass('pswdinput');
     $this->data['fid'] = $this->getForm()->getElementPrototype()->id;
     $control->data('lohini-pswd', \Nette\Utils\Json::encode(array_filter($this->data)));
     return Html::el('span', ['style' => 'position: relative; float: left;'])->add($control);
 }
Exemplo n.º 2
0
 /**
  * @return Html
  */
 public function getControl()
 {
     $control = parent::getControl();
     $control->value = implode(",", (array) $this->getValue());
     $control->addAttributes(array("data-role" => "tagsinput"));
     return $control;
 }
Exemplo n.º 3
0
 /**
  * Generates control's HTML element
  *
  * @return \Nette\Utils\Html
  */
 public function getControl()
 {
     $control = parent::getControl();
     $control->class = 'datetimepicker form-control';
     $control->readonly = TRUE;
     return $control;
 }
Exemplo n.º 4
0
 public function getControl()
 {
     $input = parent::getControl();
     $input->class = 'hidden';
     //$input = Html::el('input')->id($this->getHtmlId() . '_file');
     $timestamp = time();
     $input->timestamp($timestamp);
     $input->token(md5('unique_salt' . $timestamp));
     $input->upload($this->imageOnly ? '/js/uploadifive/uploadifive-image-only.php' : '/js/uploadifive/uploadifive.php');
     $input->buttonText($this->buttonText);
     $input->multi($this->multiple ? 'true' : 'false');
     $input->class('uploadifive');
     $control = Html::el()->add($input);
     //edit - zobrazim obrazek
     if ($this->getValue() != '') {
         if (!$this->multiple) {
             if ($this->imageOnly) {
                 $image = Html::el('img')->src($this->getParent()->getParent()->link('Image:preview', $this->getValue(), 100, 100));
                 $control->add($image);
             } else {
                 $link = Html::el('a')->href('/images/upload/' . substr($this->getValue(), 0, 4) . '/' . $this->getValue())->setText($this->getValue());
                 $control->add($link);
             }
         } else {
         }
     }
     return $control;
 }
Exemplo n.º 5
0
 public function getControl()
 {
     $control = parent::getControl();
     $control->class = 'text datepicker';
     $control->autocomplete = 'off';
     return $control;
 }
Exemplo n.º 6
0
 /**
  * @inheritdoc
  * @return Html
  */
 public function getControl()
 {
     $control = clone $this->fullControl;
     $control->insert(0, parent::getControl());
     // the original text input control is injected only there
     return $control;
 }
Exemplo n.º 7
0
 /**
  * Generates control's HTML element.
  *
  * @return \Nette\Utils\Html
  */
 public function getControl()
 {
     $container = clone $this->container;
     $container->add(' <div class="input-group">' . parent::getControl());
     $dest = '';
     $s = null;
     foreach ($this->items as $key => $value) {
         if (!is_array($value)) {
             $value = array($key => $value);
         }
         foreach ($value as $key2 => $value2) {
             if ($value2 instanceof \Nette\Utils\Html) {
                 $dest .= '<li><a href="#">' . $value2 . '</a></li>';
             } else {
                 $key2 = $this->useKeys ? $key2 : $value2;
                 $value2 = $this->translate((string) $value2);
                 if ($key2 == $this->value) {
                     $s = $value2;
                 }
                 $dest .= '<li><a href="#">' . $value2 . '</a></li>';
             }
         }
     }
     $container->add('<div class="input-group-btn">
     <button type="button" class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown"><span class="textWithSelect-text">' . $s . '</span> <span class="caret"></span></button>
     <ul class="dropdown-menu pull-right">');
     $container->add($dest);
     $container->add('</div></div>');
     return $container;
 }
Exemplo n.º 8
0
 public function getControl()
 {
     $container = Html::el()->add(parent::getControl());
     $javascript = Html::el();
     $javascript->setHtml('<script type="text/javascript">' . '$(document).ready(function(){' . '$("#' . $this->getHtmlId() . '").datepicker({' . 'dateFormat: "' . $this->formatUi . '"' . '});' . '});' . '</script>');
     $container->add($javascript);
     return $container;
 }
Exemplo n.º 9
0
 /**
  * @return Html
  */
 public function getControl()
 {
     $control = parent::getControl();
     $control->appendAttribute('class', ['js', 'date-input']);
     $control->data('format', $this->format);
     $control->data('settings', $this->settings);
     if ($this->value) {
         $control->value($this->value->format($this->format));
     }
     return $control;
 }
Exemplo n.º 10
0
 /**
  * Generates control's HTML element.
  * @return Nette\Utils\Html
  */
 public function getControl()
 {
     $input = parent::getControl();
     if (!is_array($input->class)) {
         if ($input->class) {
             $input->class[] = $input->class;
         } else {
             $input->class = [];
         }
     }
     $input->class[] = 'date-picker';
     return $input;
 }
Exemplo n.º 11
0
 /**
  * @return Nette\Utils\Html
  */
 public function getControl($needLink = TRUE)
 {
     $control = parent::getControl();
     if (!$this->link) {
         $presenter = $this->lookup('Nette\\Application\\IPresenter', FALSE);
         if ($presenter || $needLink) {
             $url = $this->lookup('Nette\\Application\\IPresenter')->link('suggestion', array('path' => base64_encode($this->lookupPath('Nette\\Application\\IPresenter'))));
             $control->data('url', urldecode($url));
         }
     } else {
         $url = $this->link;
         $control->data('url', urldecode($url));
     }
     $control->appendAttribute('class', 'suggestion-input');
     $control->data('suggestion', $this->settings);
     return $control;
 }
Exemplo n.º 12
0
 public function getControl()
 {
     $container = Nette\Utils\Html::el('span');
     $control = parent::getControl();
     $control->class[] = 'form-control integerPicker';
     /*$template = $this->getForm()->getPresenter()->createTemplate();
     		$template->setFile(__DIR__.'/Templates/control.latte');
     		$template->input = $control; */
     $context = $this->getForm()->getPresenter()->getContext();
     $template = new Nette\Templating\FileTemplate(__DIR__ . '/Templates/control.latte');
     $latte = $context->getService('nette.latte');
     $template->registerFilter($latte);
     vBuilder\Latte\Macros\SystemMacros::install($latte->compiler);
     $template->context = $context;
     $template->input = $control;
     $template->_control = $this->getForm()->lookup('Nette\\Application\\UI\\Control', true);
     $container->setHtml($template);
     return $container;
 }
Exemplo n.º 13
0
 /**
  * @return Html
  */
 public function getControl()
 {
     $control = parent::getControl();
     $control->value = implode(',', (array) $this->getValue());
     $control->class[] = 'tag-input';
     return $control;
 }
 /**
  * @throws \Exception
  * @return string|\Nette\Utils\Html
  */
 public function getControl()
 {
     $latte = new Engine();
     $params = ['editable' => $this->editable, 'control' => $this, 'input' => parent::getControl(), 'editors' => $this->getValue(), 'entity' => $this->entity, 'cascaded' => $this->getCascadedAllows()];
     return $latte->renderToString(__DIR__ . '/../../templates/controls/editorSelector.latte', $params);
 }
Exemplo n.º 15
0
 /**
  * Generates control's HTML element
  *
  * @return \Nette\Utils\Html
  */
 public function getControl()
 {
     $control = parent::getControl();
     $control->readonly = TRUE;
     return $control;
 }
Exemplo n.º 16
0
 /**
  * Generates control's HTML element.
  * @return \Nette\Utils\Html
  */
 public function getControl()
 {
     $container = \Nette\Utils\Html::el('div');
     /** @var $control \Nette\Utils\Html */
     $control = parent::getControl();
     if ($this->delimiter !== NULL && Strings::trim($this->delimiter) !== '') {
         $control->attrs['data-tag-delimiter'] = $this->delimiter;
     }
     if ($this->joiner !== NULL && Strings::trim($this->joiner) !== '') {
         $control->attrs['data-tag-joiner'] = $this->joiner;
     }
     if ($this->suggestCallback !== NULL) {
         $form = $this->getForm();
         if (!$form || !$form instanceof Form) {
             throw new InvalidStateException("TagInput supports only Nette\\Application\\UI\\Form.");
         }
         $control->attrs['data-tag-suggest'] = $form->getPresenter()->link('this', array('do' => $this->lookupPath('Nette\\Application\\UI\\Presenter') . '-suggest'));
     }
     $container->add($control);
     return $container;
 }
Exemplo n.º 17
0
 public function getControl()
 {
     $control = parent::getControl();
     $control->addClass('typeahead');
     return $control;
 }
Exemplo n.º 18
0
 public function getControl()
 {
     $control = parent::getControl();
     $control->value = $this->value;
     return $control;
 }
Exemplo n.º 19
0
 /**
  * Returns the control's HTML
  *
  * Adds the javascript code for initializing the functionality
  * 
  * @return Html
  * @throws InvalidStateException If no suggest link is provided
  */
 public function getControl()
 {
     $control = parent::getControl();
     if ($this->suggestLink === NULL) {
         throw new InvalidStateException('SuggustInput::$suggestLink cannot be NULL');
     }
     $control->data('nette-suggestLink', $this->suggestLink);
     $options = $this->getJsOptions();
     if (!isset($options['lang'])) {
         $options['lang'] = self::$defaultUiLanguage;
     }
     $options = substr(PHP_VERSION_ID >= 50400 ? json_encode($options, JSON_UNESCAPED_UNICODE) : json_encode($options), 1, -1);
     $options = preg_replace('#"([a-z0-9_]+)":#i', '$1:', $options);
     $options = preg_replace('#(?<!\\\\)"(?!:[^a-z])([^\\\\\',]*)"#i', "'\$1'", $options);
     $control->data('nette-suggestInput-options', '{' . $options . '}');
     $control->class[] = 'suggestInput';
     return $control;
 }
Exemplo n.º 20
0
 /**
  * @return Html
  */
 public function getControl()
 {
     $control = parent::getControl();
     $control->addClass(self::HTML_CLASS);
     return $control;
 }
Exemplo n.º 21
0
 /**
  * Generates control's HTML element.
  * @return Nette\Utils\Html
  */
 public function getControl()
 {
     $control = parent::getControl();
     $control->data('datepicker-format', $this->translateFormatToJs($this->format));
     return $control;
 }
Exemplo n.º 22
0
 /**
  * Generates control's HTML element.
  *
  * @return Nette\Utils\Html
  */
 public function getControl()
 {
     $inputEl = parent::getControl();
     // JS Object
     $jsObject = new \StdClass();
     // Input group
     $inputGroupId = $inputEl->attrs['id'] . '-input-group';
     $inputGroup = Html::el('div')->class('bootstrap-select input-group')->id($inputGroupId);
     // Text input field
     $inputGroup->add(Html::el('input')->type('text')->autocomplete('off')->name($inputEl->attrs['name'] . '_label')->id($inputEl->attrs['id'])->class('form-control')->placeholder($this->translate('Click to choose')));
     // Hidden field
     $inputGroup->add(Html::el('input')->type('hidden')->name($inputEl->attrs['name'])->value($inputEl->attrs['value']));
     // Button group
     $inputGroup->add($buttonGroup = Html::el('div')->class('input-group-btn'));
     // Dropdown button
     $buttonGroup->add(Html::el('button')->type('button')->class('btn btn-default dropdown-toggle')->tabindex('-1')->add(Html::el('span')->class('caret')));
     // Dropdown menu
     $buttonGroup->add($menu = Html::el('ul')->class('pull-right dropdown-menu primary')->tabindex('-1'));
     // Dropdown menu items
     foreach ($this->items as $key => $value) {
         $menu->add(Html::el('li')->add($a = Html::el('a', $value instanceof Html ? '' : $this->translate($value))->href($key)->tabindex("-1")));
         if ($value instanceof Html) {
             $a->add($value);
         }
     }
     // Custom entry
     if ($this->customEntryAllowed) {
         if (($customEntryValue = array_search($this->customEntryLabel, $this->items)) === FALSE) {
             $menu->add(Html::el('li')->class('divider'));
             $customEntryValue = $inputEl->attrs['id'] . '-custom';
             $menu->add(Html::el('li')->add($a = Html::el('a', $this->customEntryLabel instanceof Html ? '' : $this->translate($this->customEntryLabel))->href($customEntryValue)->tabindex("-1")));
             if ($this->customEntryLabel instanceof Html) {
                 $a->add($this->customEntryLabel);
             }
         }
         $jsObject->{'custom-value'} = $customEntryValue;
         if ($this->customEntryPrefixLabel) {
             $jsObject->{'custom-prefix'} = $this->translate($this->customEntryPrefixLabel);
         }
     }
     // Wrapper with script
     return Html::el('div')->add($inputGroup)->add(Html::el('script', "\$('#{$inputGroupId}').bootstrapSelect(" . json_encode($jsObject) . ");")->type('text/javascript'));
 }
Exemplo n.º 23
0
 /**
  * Generates control's HTML element.
  *
  * @return Html
  */
 public function getControl()
 {
     $control = parent::getControl();
     $control->addAttributes(array("data-format" => $this->format));
     $container = clone $this->container;
     $container->class[] = 'input-group date';
     $container->add($control);
     $container->add('<span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>');
     return $container;
 }
Exemplo n.º 24
0
 /**
  * @param string $key
  *
  * @return Utils\Html
  *
  * @throws Exceptions\InvalidArgumentException
  */
 public function getControlPart($key)
 {
     $name = $this->getHtmlName();
     // Try to get translator
     $translator = $this->getTranslator();
     if ($translator instanceof Localization\ITranslator && method_exists($translator, 'getLocale') === TRUE) {
         try {
             $locale = $translator->getLocale();
         } catch (\Exception $ex) {
             $locale = 'en_US';
         }
     } else {
         $locale = 'en_US';
     }
     if ($key === static::FIELD_COUNTRY) {
         $control = Forms\Helpers::createSelectBox(array_reduce($this->getAllowedCountries(), function (array $result, $row) use($locale) {
             $countryName = FormPhone\Locale\Locale::getDisplayRegion(FormPhone\Locale\Locale::countryCodeToLocale($row), $locale);
             $result[$row] = Utils\Html::el('option')->setText('+' . $this->phoneUtils->getCountryCodeForCountry($row) . ' (' . $countryName . ')')->addAttributes(['data-mask' => preg_replace('/[0-9]/', '9', $this->phoneUtils->getExampleNationalNumber($row))])->value($row);
             return $result;
         }, []), ['selected?' => $this->country === NULL ? $this->defaultCountry : $this->country]);
         $control->addAttributes(['name' => $name . '[' . static::FIELD_COUNTRY . ']', 'id' => $this->getHtmlId() . '-' . static::FIELD_COUNTRY, 'data-ipub-forms-phone' => '', 'data-settings' => json_encode(['field' => $name . '[' . static::FIELD_NUMBER . ']'])]);
         if ($this->isDisabled()) {
             $control->disabled(TRUE);
         }
         return $control;
     } else {
         if ($key === static::FIELD_NUMBER) {
             $input = parent::getControl();
             $control = Utils\Html::el('input');
             $control->addAttributes(['name' => $name . '[' . static::FIELD_NUMBER . ']', 'id' => $this->getHtmlId() . '-' . static::FIELD_NUMBER, 'value' => $this->number, 'type' => 'text', 'data-nette-empty-value' => Utils\Strings::trim($this->translate($this->emptyValue)), 'data-nette-rules' => $input->{'data-nette-rules'}]);
             if ($this->isDisabled()) {
                 $control->disabled(TRUE);
             }
             return $control;
         }
     }
     throw new Exceptions\InvalidArgumentException('Part ' . $key . ' does not exist.');
 }
Exemplo n.º 25
0
 /**
  * @return Nette\Utils\Html
  */
 public function getControl()
 {
     $control = parent::getControl();
     $this->createRule();
     if ($this->settings) {
         $control->data('mask-input', $this->settings);
     }
     return $control;
 }
Exemplo n.º 26
0
 /**
  * @return Html
  */
 public function getControl()
 {
     $control = parent::getControl();
     $control->addClass('datetimepicker');
     return $control;
 }
Exemplo n.º 27
0
 /**
  * @return TextInput
  */
 public function getControl()
 {
     $control = parent::getControl();
     $control = $this->addAntispamScript($control);
     return $control;
 }
Exemplo n.º 28
0
 /**
  * @inheritdoc
  */
 public function getControl()
 {
     $input = parent::getControl();
     $input->addAttributes(['data-tagInput' => Json::encode($this->dataSourceDescriptor)]);
     return $input;
 }