当前位置: 首页>>代码示例>>PHP>>正文


PHP ZendX_JQuery_View_Helper_JQuery类代码示例

本文整理汇总了PHP中ZendX_JQuery_View_Helper_JQuery的典型用法代码示例。如果您正苦于以下问题:PHP ZendX_JQuery_View_Helper_JQuery类的具体用法?PHP ZendX_JQuery_View_Helper_JQuery怎么用?PHP ZendX_JQuery_View_Helper_JQuery使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ZendX_JQuery_View_Helper_JQuery类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 public function __construct($options = null)
 {
     Zmz_Form_Initialize::init($this);
     $jqueryHelper = new ZendX_JQuery_View_Helper_JQuery();
     $this->_jquery = $jqueryHelper->jQuery();
     parent::__construct($options);
 }
开发者ID:massimozappino,项目名称:zmz,代码行数:7,代码来源:Form.php

示例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);
 }
开发者ID:omusico,项目名称:wildfire_php,代码行数:36,代码来源:DatePicker.php

示例3: 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);
    }
开发者ID:BGCX261,项目名称:zoocms-svn-to-git,代码行数:37,代码来源:ZooColorPicker.php

示例4: 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 '';
 }
开发者ID:laiello,项目名称:digitalus-cms,代码行数:39,代码来源:AccordionContainer.php

示例5: __construct

 public function __construct($options = null)
 {
     if (!is_array($options) || count($options) <= 0) {
         throw new Zend_Form_Decorator_Exception('$option is not array or there is\'t any value');
     }
     foreach ($options as $k => $v) {
         if (is_array($v)) {
             $this->_validators[(string) $k] = $v;
         } else {
             $this->_validators[null] = $options;
             break;
         }
     }
     $jqueryHelper = new ZendX_JQuery_View_Helper_JQuery();
     $this->_jquery = $jqueryHelper->jQuery();
 }
开发者ID:massimozappino,项目名称:zmz,代码行数:16,代码来源:Abstract.php

示例6: 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);
 }
开发者ID:ei-grad,项目名称:phorm,代码行数:16,代码来源:LatLong.php

示例7: 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);
 }
开发者ID:BackupTheBerlios,项目名称:dkplusengine,代码行数:47,代码来源:DependentSelect.php

示例8: 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);
 }
开发者ID:starflash,项目名称:ZtChart-ZF1-Example,代码行数:41,代码来源:DatePicker.php

示例9: 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;
 }
开发者ID:BGCX261,项目名称:zoocms-svn-to-git,代码行数:37,代码来源:FileBrowser.php

示例10: 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);
 }
开发者ID:BackupTheBerlios,项目名称:dkplusengine,代码行数:45,代码来源:Tooltip.php

示例11: 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;
 }
开发者ID:albertobraschi,项目名称:zstarter,代码行数:25,代码来源:select_from_database.php

示例12: 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);
 }
开发者ID:rtsantos,项目名称:mais,代码行数:36,代码来源:SubmitAjax.php

示例13: 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;
    }
开发者ID:ei-grad,项目名称:phorm,代码行数:30,代码来源:Multi.php

示例14: 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);
 }
开发者ID:ei-grad,项目名称:phorm,代码行数:68,代码来源:MediaFile.php

示例15: 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;
 }
开发者ID:omusico,项目名称:wildfire_php,代码行数:69,代码来源:Slider.php


注:本文中的ZendX_JQuery_View_Helper_JQuery类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。