本文整理汇总了PHP中ZendX_JQuery_View_Helper_JQuery::getJQueryHandler方法的典型用法代码示例。如果您正苦于以下问题:PHP ZendX_JQuery_View_Helper_JQuery::getJQueryHandler方法的具体用法?PHP ZendX_JQuery_View_Helper_JQuery::getJQueryHandler怎么用?PHP ZendX_JQuery_View_Helper_JQuery::getJQueryHandler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ZendX_JQuery_View_Helper_JQuery
的用法示例。
在下文中一共展示了ZendX_JQuery_View_Helper_JQuery::getJQueryHandler方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: datePicker
/**
* 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);
}
示例2: datePicker
/**
* 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);
//
// Prepare params
//
if (!isset($params['dateFormat']) && Zend_Registry::isRegistered('Zend_Locale')) {
$params['dateFormat'] = $this->_resolveLocaleToDatePickerFormat();
}
// TODO: Allow translation of DatePicker Text Values to get this action from client to server
if (count($params) > 0) {
/**
* @see Zend_Json
*/
require_once "Zend/Json.php";
$params = Zend_Json::encode($params);
} else {
$params = "{}";
}
$js = sprintf('%s("#%s").datepicker(%s);', ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(), $attribs['id'], $params);
//
// Add DatePicker callup to onLoad Stack
//
$this->jquery->addOnLoad($js);
return $this->view->formText($id, $value, $attribs);
}
示例3: accordionContainer
/**
* 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 '';
}
示例4: zooColorPicker
/**
* 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);
}
示例5: fileBrowser
/**
* 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;
}
示例6: dependentSelect
/**
* 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);
}
示例7: tooltip
/**
* 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);
}
示例8: initJavaScript
/**
* Добавляет JS-код управления элементом
*
* @return self
*/
protected function initJavaScript()
{
$jquery_handler = ZendX_JQuery_View_Helper_JQuery::getJQueryHandler();
if (isset($this->_params['sortable']) && $this->_params['sortable'] != 0) {
$js = sprintf('%s("#%s").sortable().find("li").css({cursor:"move"});', $jquery_handler, $this->_ulid);
$this->jquery->addOnLoad($js);
}
$js = sprintf('%s("#%s").click(function(){
var src = %s(this).next("ul").find("li:last"); var trgt = src.clone().insertBefore(src).show();
trgt.find(":disabled").attr("disabled",false);
trgt.find(".delete").click(function(){
if(confirm("' . $this->view->escape($this->_params['delete']) . '?")) %s(this).parent("li").remove();
return false;
});
return false;
});', $jquery_handler, $this->_buttonid, $jquery_handler, $jquery_handler);
$this->jquery->addOnLoad($js);
$js = sprintf('%s("#%s .delete").click(function(){
if(confirm("' . $this->view->escape($this->_params['delete']) . '?")) {
%s(this).parent("li").remove();
} return false;
});', $jquery_handler, $this->_ulid, $jquery_handler);
$this->jquery->addOnLoad($js);
return $this;
}
示例9: toStep3
public function toStep3($view)
{
$jquery = $view->jQuery();
$jquery->enable();
// enable jQuery Core Library
// get current jQuery handler based on noConflict settings
$jqHandler = ZendX_JQuery_View_Helper_JQuery::getJQueryHandler();
//$function = '("#s_tables").click(function() '
// . '{ alert("noConflict Mode Save Helper!"); }'
// . ')';
$function = "\n \$(\"#s_tables\").change(function() {\n \$(\"#s_tables_id\").load(\n 'http://taryk/admin/adminstruct/step3/getdesc/',\n {\n tablename: \$(\"#s_tables\").get(0).options[\$(\"#s_tables\").get(0).selectedIndex].value,\n notemplate: 'yes',\n stype: 'ID'\n }\n );\n \$(\"#s_tables_description\").load(\n 'http://taryk/admin/adminstruct/step3/getdesc/',\n {\n tablename: \$(\"#s_tables\").get(0).options[\$(\"#s_tables\").get(0).selectedIndex].value,\n notemplate: 'yes',\n stype: 'Description'\n }\n );\n })\n ";
$jquery->addOnload($jqHandler . $function);
$list = $this->getList();
// list: tables
$out = "<fieldset><legend>Connect a table:</legend>\n <table border='0' cellspacing='0' cellspadding='0'>\n <tr>\n <td>Table:</td>\n <td>\n <select name='s_tables[]' id='s_tables'>\n <option selected='selected'>Select...</option>";
foreach ($list as $item) {
$out .= "<option value='" . $item['Tables_in_taryk'] . "'>" . $item['Tables_in_taryk'] . "</option>";
}
$out .= "</select></td></tr>";
// list: ID
$out .= "<tr><td>ID:</td><td><select name='s_tables_id[]' id='s_tables_id'><option>Select...</option></select></td></tr>";
// list: Description
$out .= "<tr><td>Description:</td><td><select name='s_tables_description[]' id='s_tables_description'><option>Select...</option></select></td></tr>\n </table>\n </fieldset>";
return $out;
}
示例10: submitAjax
/**
* 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);
}
示例11: LatLong
/**
* Рисуем элемент
*
* @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);
}
示例12: mediaFile
/**
* Рисуем элемент
*
* @param string $name Имя HTML-элемента
* @param mixed $value Значение элемента
* @param array $params Массив параметров
* @param array $attribs Массив атрибутов HTML-элемента
* @return string
*/
public function mediaFile($name, $value = null, array $params = array(), $attribs = null)
{
$translate = $params['translate'];
unset($params['translate']);
$jquery_handler = ZendX_JQuery_View_Helper_JQuery::getJQueryHandler();
/**
* Переделываем свойство mediatype в data-mediatype (для совместимости с JQuery.data())
*/
if (!isset($params['mediatype'])) {
$params['mediatype'] = 'image';
}
$params['data-mediatype'] = $params['mediatype'];
unset($params['mediatype']);
/**
* Имя элемента типа File делаем просто рандомным, на форме обрабатываться будет поле hidden
*/
$params['id'] = uniqid();
/**
* Значение может быть массивом MediaInfo или числом mediaid
* Если значение не является массивом, то приводим его к массиву MediaInfo
*/
if (!is_array($value) && $value > 0) {
require_once 'Phorm/Media.php';
$Media = new Phorm_Media();
if ($MediaInfo = $Media->getMediaInfo($value)) {
$value = $MediaInfo;
}
}
/**
* Добавляем базовый JS
*/
//$this->jquery->addJavascriptFile($this->view->BaseUrl().'/ui/phorm/phorm.js');
$this->jquery->addJavascriptFile($this->view->BaseUrl() . '/ui/js/jquery.livequery.min.js');
$this->jquery->addJavascriptFile($this->view->BaseUrl() . '/ui/blueimp/js/jquery.fileupload.js');
/** @todo мб перенести в phorm.js поскольку подпорка под IE требует переопределения Phorm_Controller_Module_Control_Media::uploadAction */
$forceIframeTransport = false;
$agent = new Zend_Http_UserAgent();
$device = $agent->getDevice();
if (strtolower($device->getBrowser()) == 'internet explorer' && $device->getBrowserVersion() <= 8) {
$this->jquery->addJavascriptFile($this->view->BaseUrl() . '/ui/blueimp/js/jquery.iframe-transport.js');
$forceIframeTransport = true;
}
$url = isset($params['url']) ? ', url: "' . $params['url'] . '"' : '';
$js = sprintf('var %s; %s("#%s").livequery(function(){%s = %s(this).phormMediaUploader(%s)});', 'var_' . $params['id'], $jquery_handler, $params['id'], 'var_' . $params['id'], $jquery_handler, '{type:"' . $params['data-mediatype'] . '", forceIframeTransport: ' . (int) $forceIframeTransport . $url . '}');
$js = sprintf('%s("%s").livequery(function(){%s(this).phormMediaUploader(%s).setValue($(this).data("mediainfo"))});', $jquery_handler, '[data-mediatype]', $jquery_handler, '{type:"' . $params['data-mediatype'] . '", forceIframeTransport: ' . (int) $forceIframeTransport . $url . '}');
$this->jquery->addOnLoad($js);
/**
* Устанавливаем пришедшие значения
*/
if (!empty($value)) {
$params['data-mediainfo'] = Zend_Json::encode($value);
//$js = sprintf('%s.setValue(%s)','var_' . $params['id'],Zend_Json::encode($value));
//$this->jquery->addOnLoad($js);
}
/**
* Возвращаем поле выбора файла и hidden в котором хранится mediaid
*/
return $this->view->formFile($params['id'], $params) . $this->view->formHidden($name);
}
示例13: slider
/**
* Create jQuery slider that updates its values into a hidden form input field.
*
* @link http://docs.jquery.com/UI/Slider
* @param string $id
* @param string $value
* @param array $params
* @param array $attribs
* @return string
*/
public function slider($id, $value = null, array $params = array(), array $attribs = array())
{
if (!isset($attribs['id'])) {
$attribs['id'] = $id;
}
$jqh = ZendX_JQuery_View_Helper_JQuery::getJQueryHandler();
$handleCount = 1;
if (isset($params['handles']) && is_array($params['handles'])) {
$handleCount = min(count($params['handles']), 1);
}
if (!isset($params['handles'][0]['start'])) {
if (is_numeric($value)) {
$params['startValue'] = $value;
} elseif (!isset($params['startValue'])) {
$params['startValue'] = 0;
}
}
// Build the Change/Update functionality of the Slider via javascript, updating hidden fields. aswell as hidden fields
$hidden = "";
$sliderUpdateFnName = "zfjSliderUpdate" . preg_replace('/([^a-zA-Z0-9]+)/', '', $attribs['id']);
if (!isset($params['change'])) {
$sliderUpdateFn = sprintf('function %s(e, ui) {' . PHP_EOL, $sliderUpdateFnName);
for ($i = 0; $i < $handleCount; $i++) {
// Js Func
if ($i === 0) {
$sliderHiddenId = $attribs['id'];
} else {
$sliderHiddenId = $attribs['id'] . "-" . $i;
}
$sliderUpdateFn .= sprintf(' %s("#%s").attr("value", %s("#%s-slider").slider("value", %d));' . PHP_EOL, $jqh, $sliderHiddenId, $jqh, $attribs['id'], $i);
// Hidden Fields
$startValue = isset($params['handles'][$i]['start']) ? $params['handles'][$i]['start'] : $params['startValue'];
$hiddenAttribs = array('type' => 'hidden', 'id' => $sliderHiddenId, 'name' => $sliderHiddenId, 'value' => $startValue);
$hidden .= '<input' . $this->_htmlAttribs($hiddenAttribs) . $this->getClosingBracket() . PHP_EOL;
}
$sliderUpdateFn .= "}" . PHP_EOL;
$params['change'] = $sliderUpdateFnName;
$this->jquery->addJavascript($sliderUpdateFn);
}
$attribs['id'] .= "-slider";
if (count($params) > 0) {
/**
* @see Zend_Json
*/
require_once "Zend/Json.php";
$params = Zend_Json::encode($params);
$params = str_replace('"' . $sliderUpdateFnName . '"', $sliderUpdateFnName, $params);
} else {
$params = '{}';
}
$js = sprintf('%s("#%s").slider(%s);', $jqh, $attribs['id'], $params);
$this->jquery->addOnLoad($js);
$html = '<div' . $this->_htmlAttribs($attribs) . '>';
for ($i = 0; $i < $handleCount; $i++) {
$html .= '<div class="ui-slider-handle"></div>';
}
$html .= '</div>';
return $hidden . $html;
}
示例14: comboCustom
/**
* 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);
}
示例15: structuresResource
/**
* Рисуем элемент
*
* @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;
}