/** * Render Accordion with the currently registered elements. * * If no arguments are given, the accordion object is returned so that * chaining the {@link addPane()} function allows to register new elements * for an accordion. * * @link http://docs.jquery.com/UI/Accordion * @param string $id * @param array $params * @param array $attribs * @return string|ZendX_JQuery_View_Helper_AccordionContainer */ public function accordionContainer($id = null, array $params = array(), array $attribs = array()) { if (0 === func_num_args()) { return $this; } if (!isset($attribs['id'])) { $attribs['id'] = $id; } if (isset($this->_panes[$id])) { $html = ""; foreach ($this->_panes[$id] as $element) { $html .= sprintf($this->_elementHtmlTemplate, $element['name'], $element['content']) . PHP_EOL; } if (count($params) > 0) { $params = ZendX_JQuery::encodeJson($params); } else { $params = "{}"; } $js = sprintf('%s("#%s").accordion(%s);', ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(), $attribs['id'], $params); $this->jquery->addOnLoad($js); $html = '<div' . $this->_htmlAttribs($attribs) . '>' . PHP_EOL . $html . '</div>' . PHP_EOL; return $html; unset($this->_panes[$id]); } return ''; }
/** * Render a File browser * * @param string $id * @param string $value * @param array $params * @param array $attribs * @return string */ public function fileBrowser($id, $value = '', array $params = array(), array $attribs = array()) { $attribs = $this->_prepareAttributes($id, $value, $attribs); if (strlen($value) >= 6) { $params['color'] = $value; } if (count($params) > 0) { $params = ZendX_JQuery::encodeJson($params); } else { $params = "{}"; } $js = sprintf('%s("#%s").click(function(){window.open("%s", "%s", "location=0,status=1,scrollbars=1,width=800,height=500");});', ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(), $attribs['id'] . "_image", "/filemanager/file/browse?elementid=" . $attribs['id'], $attribs['id'] . "_window", $params); $this->jquery->addOnLoad($js); $js2 = sprintf("function callFunction(id, url, element_id) {\n \telement_id = '#' + element_id\n \tvar image_id = element_id + '_image';\n \t%s(image_id).attr('src', url);\n \t%s(element_id).attr('value', id);\n\t }", ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(), ZendX_JQuery_View_Helper_JQuery::getJQueryHandler()); $this->view->headScript()->appendScript($js2); // XHTML or HTML end tag? $endTag = ' />'; if ($this->view instanceof Zend_View_Abstract && !$this->view->doctype()->isXhtml()) { $endTag = '>'; } if ($value && ($file = Zoo::getService('filemanager')->find($value)->current())) { $xhtml = '<img id="' . $attribs['id'] . '_image" src="' . $file->getUrl(150, 150) . '" ' . $endTag; } else { $xhtml = '<img id="' . $attribs['id'] . '_image" src="/images/crystal_project/128x128/mimetypes/ascii.png" ' . $endTag; } $xhtml .= $this->view->formHidden($id, $value, $attribs); return $xhtml; }
/** * Builds an AutoComplete ready input field. * * This view helper builds an input field with the {@link Zend_View_Helper_FormText} FormText * Helper and adds additional javascript to the jQuery stack to initialize an AutoComplete * field. Make sure you have set one out of the two following options: $params['data'] or * $params['url']. The first one accepts an array as data input to the autoComplete, the * second accepts an url, where the autoComplete content is returned from. For the format * see jQuery documentation. * * @link http://docs.jquery.com/UI/Autocomplete * @throws ZendX_JQuery_Exception * @param String $id * @param String $value * @param array $params * @param array $attribs * @return String */ public function dependentSelect($id, $value = null, array $params = array(), array $attribs = array()) { if (is_array($value) && count($params) == 0 && count($attribs) == 0) { $params = $value; $value = null; } $attribs = $this->_prepareAttributes($id, $value, $attribs); if (!isset($params['url']) || !isset($params['dependentElement'])) { ////require_once "ZendX/JQuery/Exception.php"; throw new ZendX_JQuery_Exception("Cannot construct DependentSelect field without specifying Parameters Url and DependentElement"); } $params['dependentElement'] = '#' . $params['dependentElement']; if ((!isset($attribs['translate']) || $attribs['translate']) && isset($params['defaultOption'])) { $params['defaultOption'] = $this->view->translate($params['defaultOption']); } $params = ZendX_JQuery::encodeJson($params); if (isset($attribs['translate'])) { unset($attribs['translate']); } $js = sprintf('%s("#%s").dependentSelect(%s);', ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(), $attribs['id'], $params); $this->jquery->addOnLoad($js); if (isset($attribs['justDecorate']) && $attribs['justDecorate']) { return ''; } if (isset($attribs['justDecorate'])) { unset($attribs['justDecorate']); } return $this->view->formText($id, $value, $attribs); }
/** * Builds an AutoComplete ready input field. * * This view helper builds an input field with the {@link Zend_View_Helper_FormText} FormText * Helper and adds additional javascript to the jQuery stack to initialize an AutoComplete * field. Make sure you have set one out of the two following options: $params['data'] or * $params['url']. The first one accepts an array as data input to the autoComplete, the * second accepts an url, where the autoComplete content is returned from. For the format * see jQuery documentation. * * @link http://docs.jquery.com/UI/Autocomplete * @throws ZendX_JQuery_Exception * @param String $id * @param String $value * @param array $params * @param array $attribs * @return String */ public function tooltip($id, $value = null, array $params = array(), array $attribs = array()) { if (is_array($value) && count($params) == 0 && count($attribs) == 0) { $params = $value; $value = null; } elseif (is_string($value) and !isset($params['content'])) { $params['content'] = $value; } $params = array_merge(self::$_defaults, $params); $attribs = $this->_prepareAttributes($id, $value, $attribs); if ((!isset($attribs['translate']) || $attribs['translate']) && isset($params['content'])) { $params['content'] = $this->view->translate($params['content']); } $params = ZendX_JQuery::encodeJson($params); if (isset($attribs['translate'])) { unset($attribs['translate']); } $js = sprintf('%s("#%s").wTooltip(%s);', ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(), $attribs['id'], $params); $this->jquery->addOnLoad($js); if (isset($attribs['justDecorate']) && $attribs['justDecorate']) { return ''; } if (isset($attribs['justDecorate'])) { unset($attribs['justDecorate']); } return $this->view->formText($id, $value, $attribs); }
/** * Create a jQuery UI Widget Date Picker * * @link http://docs.jquery.com/UI/Datepicker * @param string $id * @param string $value * @param array $params jQuery Widget Parameters * @param array $attribs HTML Element Attributes * @return string */ public function datePicker($id, $value = null, array $params = array(), array $attribs = array()) { $attribs = $this->_prepareAttributes($id, $value, $attribs); if (Zend_Registry::isRegistered('Zend_Locale')) { if (!isset($params['dateFormat'])) { $params['dateFormat'] = self::resolveZendLocaleToDatePickerFormat(); } $days = Zend_Locale::getTranslationList('Days'); if (!isset($params['dayNames'])) { $params['dayNames'] = array_values($days['format']['wide']); } if (!isset($params['dayNamesShort'])) { $params['dayNamesShort'] = array_values($days['format']['abbreviated']); } if (!isset($params['dayNamesMin'])) { $params['dayNamesMin'] = array_values($days['stand-alone']['narrow']); } $months = Zend_Locale::getTranslationList('Months'); if (!isset($params['monthNames'])) { $params['monthNames'] = array_values($months['stand-alone']['wide']); } if (!isset($params['monthNamesShort'])) { $params['monthNamesShort'] = array_values($months['stand-alone']['narrow']); } } // TODO: Allow translation of DatePicker Text Values to get this action from client to server $params = ZendX_JQuery::encodeJson($params); $js = sprintf('%s("#%s").datepicker(%s);', ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(), $attribs['id'], $params); $this->jquery->addOnLoad($js); return $this->view->formText($id, $value, $attribs); }
/** * Cria um campo texto com validador de email * * @param string $id * @param string $value * @param array $params jQuery Widget Parameters * @param array $attribs HTML Element Attributes * @return string */ public function submitAjax($id, $value = null, array $params = array(), array $attribs = array()) { $attribs = $this->_prepareAttributes($id, $value, $attribs); $params = ZendX_JQuery::encodeJson($params); $js = sprintf('%s("#%s").click(function(){ var formFields = $(".required"); var requiredNull = ""; if(formFields.length > 1){ for(i=0;i<formFields.length;i++){ if(formFields[i].value == ""){ requiredNull = $("label[for=\'"+formFields[i].id+"\']").text(); } } }else{ if(formFields.val() == ""){ requiredNull = $("label[for=\'"+formFields.attr(\'id\')+"\']").text(); } } if(requiredNull != ""){ alert("O campo "+requiredNull+" é obrigatório"); } //$("form").submit(); });', ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(), $attribs['id'], $params); #$js = sprintf('%s("#%s").TEmail(%s);', ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(), $attribs['id'], $params); $this->jquery->addOnLoad($js); return $this->view->formText($id, $value, $attribs); }
/** * Cria um campo texto para numeros, com incremento, verificação, valor maximo e outro (ler arquivo TNumeric.js) * * @param string $id * @param string $value * @param array $params jQuery Widget Parameters * @param array $attribs HTML Element Attributes * @return string */ public function numeric($id, $value = null, array $attribs = array()) { $this->view->headScript()->appendFile(ZendT_Url::getBaseDiretoryPublic() . '/scripts/jquery/widget/TNumeric.js'); $this->view->headScript()->appendFile(ZendT_Url::getBaseDiretoryPublic() . '/scripts/jquery/extra/autoNumeric.js'); $params = ZendX_JQuery::encodeJson($attribs['jQueryParams']); unset($attribs['jQueryParams']); $this->jquery->addOnLoad('jQuery("#' . $id . '").TNumeric(' . $params . ');'); /*$styles = explode(';', $attribs['style']); if ($styles) { foreach ($styles as $style) { list($styleName,$styleValue) = explode(':',$style); if ($styleName == 'width'){ $old = $style; $width = (str_replace('px', '', trim($styleValue)) * 1); $styleValue = $width - 25; $new = 'width:'.$styleValue.'px'; } } $attribs['style'] = str_replace($old,$new,$attribs['style']); } if (!$width){ $width = 100; $attribs['style'].= 'width:75px;'; }*/ $attribs['class'] .= ' item ui-input-num icon'; $btns = ' <span class="item numeric"> ' . ' <div class="ui-button ui-state-default up" nofocus="1" parent="' . $id . '" onClick="if(!$(this).attr(\'disabled\')){jQuery(\'#\' + $(this).attr(\'parent\')).Tdata(\'TNumeric\').incNumber();}" type="button"> ' . ' <span class="ui-icon ui-icon-triangle-1-n"/> ' . ' </div> ' . ' <div class="ui-button ui-state-default down" nofocus="1" parent="' . $id . '" onClick="if(!$(this).attr(\'disabled\')){jQuery(\'#\' + $(this).attr(\'parent\')).Tdata(\'TNumeric\').decNumber();}" type="button"> ' . ' <span class="ui-icon ui-icon-spinner-down"/> ' . ' </div> ' . ' </span> '; $xhtml = '<div class="ui-form-group"> ' . ' ' . $this->view->formText($id, $value, $attribs) . $btns . '</div>'; return $xhtml; }
/** * Рисуем элемент * * @param string $id Id HTML-элемента * @param string $value Значение элемента * @param array $params Массив опций из секции JQueryParams * @param array $attribs Массив аттрибутов из секции options * @return string */ public function LatLong($id, $value = null, array $params = array(), array $attribs = array()) { $attribs = $this->_prepareAttributes($id, $value, $attribs); $js = sprintf('%s("#%s").phormLatLong(%s);', ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(), $attribs['id'], ZendX_JQuery::encodeJson($params)); $this->jquery->addOnLoad($js); return $this->view->formText($id, $value, $attribs); }
/** * Render a Color Picker in an FormText field. * * @link http://docs.jquery.com/UI/ColorPicker * @param string $id * @param string $value * @param array $params * @param array $attribs * @return string */ public function zooColorPicker($id, $value = '', array $params = array(), array $attribs = array()) { $this->jquery->addJavascriptFile(Zend_Controller_Front::getInstance()->getBaseUrl() . '/js/jquery/colorpicker/js/colorpicker.js', 'text/javascript'); $this->jquery->addStylesheet(Zend_Controller_Front::getInstance()->getBaseUrl() . "/js/jquery/colorpicker/css/colorpicker.css"); $attribs = $this->_prepareAttributes($id, $value, $attribs); if (strlen($value) >= 6) { $params['color'] = $value; } if (count($params) > 0) { $params = ZendX_JQuery::encodeJson($params); } else { $params = "{}"; } $js = sprintf('%s("#%s").ColorPicker({onSubmit: function(hsb, hex, rgb, el) { %s(el).val(hex); %s(el).ColorPickerHide(); }, onBeforeShow: function () { %s(this).ColorPickerSetColor(this.value); } }) .bind("keyup", function(){ %s(this).ColorPickerSetColor(this.value); });', ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(), $attribs['id'], ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(), ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(), ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(), ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(), $params); $this->jquery->addOnLoad($js); return $this->view->formText($id, $value, $attribs); }
/** * Cria um campo de ComboCustom * * @param string $id * @param string $value * @param array $params jQuery Widget Parameters * @param array $attribs HTML Element Attributes * @return string */ public function comboCustom($id, $value = null, array $params = array(), array $attribs = array()) { $this->view->headScript()->appendFile(ZendT_Url::getBaseDiretoryPublic() . '/scripts/jquery/widget/TComboCustom.js')->appendFile(ZendT_Url::getBaseDiretoryPublic() . '/scripts/jquery/widget/TOpenDownBox.js'); $params = ZendX_JQuery::encodeJson($params); $js = sprintf('%s("#%s").TComboCustom(%s);', ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(), $attribs['id'], $params); $this->jquery->addOnLoad($js); return $this->view->formText($id, $value, $attribs); }
/** * Cria um campo texto com validador de data e datepicker * * @param string $id * @param string $value * @param array $params jQuery Widget Parameters * @param array $attribs HTML Element Attributes * @return string */ public function dateMonthYear($id, $value = null, array $attribs = array()) { $this->view->headScript()->appendFile(ZendT_Url::getBaseDiretoryPublic() . '/scripts/jquery/extra/jquery.maskedinput-1.4.1.min.js'); $this->view->headScript()->appendFile(ZendT_Url::getBaseDiretoryPublic() . '/scripts/jquery/widget/TDateMonthYear.js'); $params = ZendX_JQuery::encodeJson($attribs['jQueryParams']); unset($attribs['jQueryParams']); $this->jquery->addOnLoad('jQuery("#' . $id . '").TDateMonthYear(' . $params . ');'); return $this->view->formText($id, $value, $attribs); }
/** * Рисуем элемент * * @param string $id Id HTML-элемента * @param string $value Значение элемента * @param array $params Массив конфигурации из секции options * @return string */ public function structuresResource($id, $value = null, array $params = array(), array $options = array()) { $translate = $params['translate']; /** * Определяем id выбранной структуры на основе текущего значения */ $structureid = null; if (is_array($value)) { foreach ($value as $structureid => $group) { break; } } /** * Определяем массив опций для селекта структур и формируем сам селект * @todo Добавить свой отдельный prepareAttribs */ if (count($params['forms']) > 1) { $attribs = array(); foreach ($params as $k => $v) { if (is_string($v) && $k != 'isexcluded') { $attribs[$k] = $v; } } $select = $this->view->formSelect(null, $structureid, $attribs, $options); } /** * Определяем форму с элементами каждой из структур * Добавляем форму в JS */ $js_var = $id . '_subforms'; if (isset($params['renderforms'])) { $this->jquery->addJavascript('var ' . $js_var . ' = ' . ZendX_JQuery::encodeJson($params['renderforms']) . ';'); } /** * Вешаем JS-обработку на смену структуры в селекте */ $jquery_handler = ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(); $js = sprintf('%s(document).on("change","#%s",function(){ %s("#%s .zend_form").remove(); %s(this).after(%s[%s(this).val()]); return false; })', $jquery_handler, $id, $jquery_handler, $id . '-element', $jquery_handler, $js_var, $jquery_handler); $this->jquery->addOnLoad($js); /** * Устанавливаем пришедшие значения * Либо форму из первой структуры */ if (isset($params['forms'][$structureid])) { $xhtml = $params['forms'][$structureid]->render(); } else { foreach ($params['forms'] as $form) { $xhtml = $form->render(); break; } } return $select . $xhtml; }
/** * Cria um campo texto para numeros, com incremento, verificação, valor maximo e outro (ler arquivo TNumericMulti.js) * * @param string $id * @param string $value * @param array $params jQuery Widget Parameters * @param array $attribs HTML Element Attributes * @return string */ public function numericMulti($id, $value = null, array $attribs = array()) { $this->view->headScript()->appendFile(ZendT_Url::getBaseDiretoryPublic() . '/scripts/jquery/widget/TNumericMulti.js'); $this->view->headScript()->appendFile(ZendT_Url::getBaseDiretoryPublic() . '/scripts/jquery/extra/autoNumeric.js'); $params = ZendX_JQuery::encodeJson($attribs['jQueryParams']); unset($attribs['jQueryParams']); $this->jquery->addOnLoad('jQuery("#' . $id . '").TNumericMulti(' . $params . ');'); return $this->view->formText($id, $value, $attribs); }
public function tagIt($id, $value = null, array $params = array(), array $attribs = array()) { $attribs = $this->_prepareAttributes($id, $value, $attribs); $this->jquery->addJavascriptFile($this->view->BaseUrl() . '/ui/tag-it/js/tag-it.min.js'); $this->jquery->addStyleSheet($this->view->BaseUrl() . '/ui/tag-it/css/jquery.tagit.css'); $params = ZendX_JQuery::encodeJson($params); $js = sprintf('%s("#%s").tagit(%s);', ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(), $attribs['id'], $params); $this->jquery->addOnLoad($js); return $this->view->formText($id, $value, $attribs); }
/** * Cria um campo texto com validador de data e datepicker * * @param string $id * @param string $value * @param array $params jQuery Widget Parameters * @param array $attribs HTML Element Attributes * @return string */ public function date($id, $value = null, array $attribs = array()) { $data = date('dmy'); $this->view->headScript()->appendFile(ZendT_Url::getBaseDiretoryPublic() . '/layout/jquery/widget/TDate.js?' . $data); $params = ZendX_JQuery::encodeJson($attribs['jQueryParams']); unset($attribs['jQueryParams']); $attribs['class'] .= ' ui-input-date'; $xhtml .= '<div class="ui-form-group">' . $this->view->formText($id, $value, $attribs) . '</div>'; $this->jquery->addOnLoad('jQuery("#' . $id . '").TDate(' . $params . ');'); return $xhtml; }
/** * Builds an AutoComplete ready input field. * * This view helper builds an input field with the {@link Zend_View_Helper_FormText} FormText * Helper and adds additional javascript to the jQuery stack to initialize an AutoComplete * field. Make sure you have set one out of the two following options: $params['data'] or * $params['url']. The first one accepts an array as data input to the autoComplete, the * second accepts an url, where the autoComplete content is returned from. For the format * see jQuery documentation. * * @link http://docs.jquery.com/UI/Autocomplete * @throws ZendX_JQuery_Exception * @param String $id * @param String $value * @param array $params * @param array $attribs * @return String */ public function autoComplete($id, $value = null, array $params = array(), array $attribs = array()) { $attribs = $this->_prepareAttributes($id, $value, $attribs); if (!isset($params['data']) && !isset($params['url'])) { require_once "ZendX/JQuery/Exception.php"; throw new ZendX_JQuery_Exception("Cannot construct AutoComplete field without specifying Parameters Data and Url"); } $params = ZendX_JQuery::encodeJson($params); $js = sprintf('%s("#%s").autocomplete(%s);', ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(), $attribs['id'], $params); $this->jquery->addOnLoad($js); return $this->view->formText($id, $value, $attribs); }
public function preRender() { if (!isset($this->_options['stringResult'])) { $this->_options['stringResult'] = true; } $js = sprintf('%s("#%s").filterToolbar(%s);', ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(), $this->getGrid()->getId(), ZendX_JQuery::encodeJson($this->_options)); $this->addOnLoad($js); $columns = $this->getGrid()->getColumns(); foreach ($columns as $column) { $column->setOption('search', true); } }
/** * Рисуем элемент * * @param string $id Id HTML-элемента * @param string $value Значение элемента * @param array $params Массив опций из секции JQueryParams * @param array $attribs Массив аттрибутов из секции options * @return string */ public function WisyBB($id, $value = null, array $params = array(), array $attribs = array()) { $attribs = $this->_prepareAttributes($id, $value, $attribs); /** * Файлы подключаем через CDN */ $this->jquery->addJavascriptFile('http://cdn.wysibb.com/js/jquery.wysibb.min.js'); $this->jquery->addStylesheet('http://cdn.wysibb.com/css/default/wbbtheme.css'); $js = sprintf('%s("#%s").wysibb(%s);', ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(), $attribs['id'], ZendX_JQuery::encodeJson($params)); $this->jquery->addOnLoad($js); return $this->view->formText($id, $value, $attribs); }
/** * Create a jQuery UI Widget Date Picker * * @link http://docs.jquery.com/UI/Datepicker * @param string $id * @param string $value * @param array $params jQuery Widget Parameters * @param array $attribs HTML Element Attributes * @return string */ public function datePicker($id, $value = null, array $params = array(), array $attribs = array()) { $attribs = $this->_prepareAttributes($id, $value, $attribs); if (!isset($params['dateFormat']) && Zend_Registry::isRegistered('Zend_Locale')) { $params['dateFormat'] = self::resolveZendLocaleToDatePickerFormat(); } // TODO: Allow translation of DatePicker Text Values to get this action from client to server $params = ZendX_JQuery::encodeJson($params); $js = sprintf('%s("#%s").datepicker(%s);', ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(), $attribs['id'], $params); $this->jquery->addOnLoad($js); return $this->view->formText($id, $value, $attribs); }
/** * Create a jQuery UI Widget Date Picker * * @link http://docs.jquery.com/UI/Datepicker * @link http://trentrichardson.com/examples/timepicker * * @static boolean $sayThisOnlyOnce Output JavaScript only once. * @param string $id * @param string $value * @param array $params jQuery Widget Parameters * @param array $attribs HTML Element Attributes * @return string */ public function datePicker($id, $value = null, array $params = array(), array $attribs = array()) { static $sayThisOnlyOnce = true; $attribs = $this->_prepareAttributes($id, $value, $attribs); $picker = 'datepicker'; $formatDate = isset($params['dateFormat']) && $params['dateFormat']; $formatTime = isset($params['timeFormat']) && $params['timeFormat']; // \MUtil_Echo::track($params['dateFormat'], $params['timeFormat']); if (!isset($params['dateFormat']) && !isset($params['timeFormat']) && \Zend_Registry::isRegistered('Zend_Locale')) { $params['dateFormat'] = self::resolveZendLocaleToDatePickerFormat(); } if ($formatDate) { if ($formatTime) { $picker = 'datetimepicker'; } } elseif ($formatTime) { $picker = 'timepicker'; } if (isset($params['timeJsUrl'])) { $baseurl = $params['timeJsUrl']; unset($params['timeJsUrl']); } else { $baseurl = false; } $js = sprintf('%s("#%s").%s(%s);', \ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(), $attribs['id'], $picker, \ZendX_JQuery::encodeJson($params)); if ($formatTime && $sayThisOnlyOnce) { $files[] = 'jquery-ui-timepicker-addon.js'; if ($locale = \Zend_Registry::get('Zend_Locale')) { $language = $locale->getLanguage(); // We have a language, but only when not english if ($language && $language != 'en') { $files[] = sprintf('i18n/jquery-ui-timepicker-addon-%s.js', $language); } } if ($baseurl) { foreach ($files as $file) { $this->jquery->addJavascriptFile($baseurl . '/' . $file); } } else { foreach ($files as $file) { if (file_exists(__DIR__ . '/js/' . $file)) { $js = "\n// File: {$file}\n\n" . file_get_contents(__DIR__ . '/js/' . $file) . "\n\n" . $js; } } } $sayThisOnlyOnce = false; } $this->jquery->addOnLoad($js); $onload = $this->onLoadJs($id, $picker, isset($attribs['readonly']) && $attribs['readonly'] || isset($attribs['disabled']) && $attribs['disabled']); $onload->render($this->view); return $this->view->formText($id, $value, $attribs); }
/** * Builds an AutoComplete ready input field. * * This view helper builds an input field with the {@link Zend_View_Helper_FormText} FormText * Helper and adds additional javascript to the jQuery stack to initialize an AutoComplete * field. Make sure you have set one out of the two following options: $params['data'] or * $params['url']. The first one accepts an array as data input to the autoComplete, the * second accepts an url, where the autoComplete content is returned from. For the format * see jQuery documentation. * * @link http://docs.jquery.com/UI/Autocomplete * @throws ZendX_JQuery_Exception * @param String $id * @param String $value * @param array $params * @param array $attribs * @return String */ public function autogrow($id, $value = null, array $params = array(), array $attribs = array()) { $attribs = $this->_prepareAttributes($id, $value, $attribs); $params = ZendX_JQuery::encodeJson($params); $js = sprintf('%s("#%s").autogrow(%s);', ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(), $attribs['id'], $params); $this->jquery->addOnLoad($js); if (isset($attribs['justDecorate']) && $attribs['justDecorate']) { return ''; } if (isset($attribs['justDecorate'])) { unset($attribs['justDecorate']); } return $this->view->formText($id, $value, $attribs); }
/** * Рисуем кнопку * * @param string $id Id HTML-элемента * @param string $value Значение элемента * @param array $params Массив параметров, передаваемых в JS-скрипт инициализации UI-компоненты * @param array $attribs Массив атрибутов HTML-элемента * @return string */ public function button($id, $value = null, array $params = array(), array $attribs = array()) { $attribs = $this->_prepareAttributes($id, $value, $attribs); $translate = $this->view->translate()->getTranslator(); $value = $translate->_($value); if (count($params) > 0) { $params = ZendX_JQuery::encodeJson($params); } else { $params = "{}"; } $js = sprintf('%s("#%s").button(%s);', ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(), $attribs['id'], $params); $this->jquery->addOnLoad($js); return $this->view->formButton($id, $value, $attribs); }
public function dateTimePicker($id, $value = null, array $params = array(), array $attribs = array()) { $attribs = $this->_prepareAttributes($id, $value, $attribs); $params2 = ZendX_JQuery::encodeJson($params); $pr = array(); foreach ($params as $key => $val) { $pr[] = '"' . $key . '":' . ZendX_JQuery::encodeJson($val); } $pr = '{' . implode(",", $pr) . '}'; $js = sprintf('%s("#%s").datetimepicker(%s);', ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(), $attribs['id'], $pr); $this->jquery->addOnLoad($js); $this->jquery->addJavascriptFile(MEDIA_PATH . 'jquery/js/jquery-ui-timepicker-addon.js'); return $this->view->formText($id, $value, $attribs); }
/** * Create FormText field for numeric values that can be spinned through its values. * * @link http://docs.jquery.com/UI/Spinner * @param string $id * @param string $value * @param array $params * @param array $attribs * @return string */ public function spinner($id, $value = "", array $params = array(), array $attribs = array()) { $attribs = $this->_prepareAttributes($id, $value, $attribs); if (!isset($params['start']) && is_numeric($value)) { $params['start'] = $value; } if (count($params)) { $params = ZendX_JQuery::encodeJson($params); } else { $params = '{}'; } $js = sprintf('%s("#%s").spinner(%s);', ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(), $attribs['id'], $params); $this->jquery->addOnLoad($js); return $this->view->formText($id, $value, $attribs); }
/** * Render jqGrid * * @param Zrt_JQuery_JqGrid $grid */ public function jqGrid(Zrt_JQuery_JqGrid $grid) { $html = array(); $js = array(); $onload = array(); $onload[] = sprintf('%s("#%s").jqGrid(%s);', ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(), $grid->getId(), ZendX_JQuery::encodeJson($grid->getOptions())); $html[] = '<table id="' . $grid->getId() . '"></table>'; // Load the jqGrid plugin view variables $html = array_merge($html, $this->view->jqGridPluginBroker['html']); $js = array_merge($js, $this->view->jqGridPluginBroker['js']); $onload = array_merge($onload, $this->view->jqGridPluginBroker['onload']); $this->jquery->addOnLoad(implode("\n", $onload)); $this->view->headScript()->appendScript(implode("\n", $js)); return implode("\n", $html); }
/** * Create a jQuery UI Dialog filled with the given content * * @link http://docs.jquery.com/UI/Dialog * @param string $id * @param string $content * @param array $params * @param array $attribs * @return string */ public function dialogContainer($id, $content, $params = array(), $attribs = array()) { if (!array_key_exists('id', $attribs)) { $attribs['id'] = $id; } if (count($params) > 0) { $params = ZendX_JQuery::encodeJson($params); } else { $params = "{}"; } $js = sprintf('%s("#%s").dialog(%s);', ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(), $attribs['id'], $params); $this->jquery->addOnLoad($js); $html = '<div' . $this->_htmlAttribs($attribs) . '>' . $content . '</div>'; return $html; }
/** * Render a Color Picker in an FormText field. * * @link http://docs.jquery.com/UI/ColorPicker * @param string $id * @param string $value * @param array $params * @param array $attribs * @return string */ public function colorPicker($id, $value = '', array $params = array(), array $attribs = array()) { $attribs = $this->_prepareAttributes($id, $value, $attribs); if (strlen($value) >= 6) { $params['color'] = $value; } if (count($params) > 0) { $params = ZendX_JQuery::encodeJson($params); } else { $params = "{}"; } $js = sprintf('%s("#%s").colorpicker(%s);', ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(), $attribs['id'], $params); $this->jquery->addOnLoad($js); return $this->view->formText($id, $value, $attribs); }
public function formJQueryMultiselect($name, $value = null, $attribs = null, $options = null, $listsep = "<br />\n") { if (array_key_exists('jQueryParams', $attribs)) { $jQueryParams = $attribs['jQueryParams']; $jQueryParams = ZendX_JQuery::encodeJson($jQueryParams); unset($attribs['jQueryParams']); } else { $jQueryParams = array(); } $js = sprintf('%s("#%s").multiselect(%s);', ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(), $attribs['id'], $jQueryParams); $this->view->headScript()->appendFile($this->view->baseUrl('/scripts/jquery-plugins/multiselect/src/jquery.multiselect.js', false)); $this->view->headLink()->prependStylesheet($this->view->baseUrl('/scripts/jquery-plugins/multiselect/jquery.multiselect.css', false), 'screen'); $this->view->jQuery()->enable()->uiEnable()->addOnLoad($js); return parent::formSelect($name, $value, $attribs, $options, $listsep); }
/** * Render a Color Picker in an FormText field. * * @param string $id * @param string $value * @param array $params * @param array $attribs * @return string */ public function miniColorPicker($id, $value = '', array $params = array(), array $attribs = array()) { $attribs = $this->_prepareAttributes($id, $value, $attribs); if (strlen($value) >= 6) { $params['color'] = $value; } if (count($params) > 0) { $params = ZendX_JQuery::encodeJson($params); } else { $params = "{}"; } $this->jquery->addJavascriptFile($this->view->BaseUrl() . '/ui/minicolors/jquery.miniColors.min.js'); $this->jquery->addStylesheet($this->view->BaseUrl() . '/ui/minicolors/jquery.miniColors.css'); $js = sprintf('%s("#%s").miniColors(%s);', ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(), $attribs['id'], $params); $this->jquery->addOnLoad($js); return $this->view->formText($id, $value, $attribs); }
/** * Builds an AutoComplete ready input field. * * This view helper builds an input field with the {@link Zend_View_Helper_FormText} FormText * Helper and adds additional javascript to the jQuery stack to initialize an AutoComplete * field. Make sure you have set one out of the two following options: $params['data'] or * $params['url']. The first one accepts an array as data input to the autoComplete, the * second accepts an url, where the autoComplete content is returned from. For the format * see jQuery documentation. * * @link http://docs.jquery.com/UI/Autocomplete * @throws ZendX_JQuery_Exception * @param String $id * @param String $value * @param array $params * @param array $attribs * @return String */ public function onChangeSave($id, $value = null, array $params = array(), array $attribs = array()) { $attribs = $this->_prepareAttributes($id, $value, $attribs); if (!isset($params['url'])) { ////require_once "ZendX/JQuery/Exception.php"; throw new ZendX_JQuery_Exception("Cannot construct OnChangeSave field without specifying Parameter Url"); } $params = ZendX_JQuery::encodeJson($params); $js = sprintf('%s("#%s").onChangeSave(%s);', ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(), $attribs['id'], $params); $this->jquery->addOnLoad($js); if (isset($attribs['justDecorate']) && $attribs['justDecorate']) { return ''; } if (isset($attribs['justDecorate'])) { unset($attribs['justDecorate']); } return $this->view->formText($id, $value, $attribs); }