예제 #1
0
파일: Form.php 프로젝트: massimozappino/zmz
 public function __construct($options = null)
 {
     Zmz_Form_Initialize::init($this);
     $jqueryHelper = new ZendX_JQuery_View_Helper_JQuery();
     $this->_jquery = $jqueryHelper->jQuery();
     parent::__construct($options);
 }
예제 #2
0
 /**
  * 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
0
    /**
     * 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);
    }
예제 #4
0
 /**
  * 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 '';
 }
예제 #5
0
 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();
 }
예제 #6
0
파일: LatLong.php 프로젝트: ei-grad/phorm
 /**
  * Рисуем элемент
  *
  * @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);
 }
 /**
  * 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);
 }
예제 #8
0
 /**
  * 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);
 }
예제 #9
0
 /**
  * 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;
 }
예제 #10
0
 /**
  * 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);
 }
 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;
 }
예제 #12
0
 /**
  * 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);
 }
예제 #13
0
파일: Multi.php 프로젝트: ei-grad/phorm
    /**
     * Добавляет 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;
    }
예제 #14
0
파일: MediaFile.php 프로젝트: ei-grad/phorm
 /**
  * Рисуем элемент
  *
  * @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);
 }
예제 #15
0
 /**
  * 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;
 }
예제 #16
0
 /**
  * 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);
 }
예제 #17
0
    /**
     * Рисуем элемент
     *
     * @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;
    }
예제 #18
0
파일: SelectBox.php 프로젝트: ei-grad/phorm
 public function selectBox($name, $value = null, $attribs = null, $options = null, $listsep = "<br />\n")
 {
     $params = $this->_prepareAttributes($name, $value, $attribs);
     $this->jquery->addJavascriptFile($this->view->BaseUrl() . '/ui/selectbox/jquery.selectBox.min.js');
     $this->jquery->addStyleSheet($this->view->BaseUrl() . '/ui/selectbox/jquery.selectBox.css');
     $js = sprintf('%s("#%s").selectBox();', ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(), $params['id']);
     $this->jquery->addOnLoad($js);
     return $this->view->formSelect($name, $value, $attribs, $options, $listsep);
 }
예제 #19
0
 /**
  * Get cache ID - although this also benefits from the fact that this code is never cached, so HEAD javascript can be added
  * @see library/Zoo/Block/Zoo_Block_Abstract#getCacheId()
  */
 function getCacheId()
 {
     $view = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer')->view;
     $view->jQuery()->enable()->uiEnable();
     $view->jQuery()->addJavascriptFile('/js/jquery/treeview/jquery.treeview.js', 'text/javascript');
     $view->jQuery()->addStylesheet('/js/jquery/treeview/jquery.treeview.css');
     $js = ZendX_JQuery_View_Helper_JQuery::getJQueryHandler() . '("#treeview").treeview({collapsed: true, persist: "location"});';
     $view->jQuery()->addOnLoad($js);
     return parent::getCacheId();
 }
예제 #20
0
파일: Pager.php 프로젝트: josmel/adminwap
 public function preRender()
 {
     $pagerName = $this->_grid->getId() . '_pager';
     $js = sprintf('%s("#%s").navGrid("#%s",{%s})', ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(), $this->_grid->getId(), $pagerName, 'edit:false,add:false,del:false');
     $js .= ';';
     $html = '<div id="' . $pagerName . '"></div>';
     $this->addOnLoad($js);
     $this->addHtml($html);
     $this->_grid->setOption('pager', $pagerName);
 }
예제 #21
0
파일: TagIt.php 프로젝트: ei-grad/phorm
 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);
 }
    public function toggleCheckboxes($id, $value = null, array $params = array())
    {
        $js = sprintf('%1$s("#%2$s").click(function(){
            var checkboxes = %1$s("%3$s");
            checkboxes.prop("checked", !checkboxes.prop("checked"));
});', \ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(), $id, $params['selector']);
        unset($params['selector']);
        $this->jquery->addOnLoad($js);
        //Now do something to add the jquery stuff
        return $this->view->formButton($id, $value, $params);
    }
예제 #23
0
 /**
  * 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);
 }
예제 #24
0
 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);
     }
 }
예제 #25
0
파일: WisyBB.php 프로젝트: ei-grad/phorm
 /**
  * Рисуем элемент
  *
  * @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);
 }
예제 #26
0
 /**
  * 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);
 }
예제 #27
0
 private function renderAlert($messages)
 {
     $sMessageOutput = '';
     foreach ($messages as $sMessage) {
         $sMessageOutput .= '- ' . $sMessage . '\\n';
     }
     $jQuery = $this->view->jQuery();
     $jqHandler = ZendX_JQuery_View_Helper_JQuery::getJQueryHandler();
     $sJqueryScript = 'alert("' . $sMessageOutput . '")';
     $jQuery->addOnload($sJqueryScript);
     return '';
 }
예제 #28
0
 /**
  * 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);
 }
예제 #29
0
 public function __construct(Zend_Form $form)
 {
     parent::__construct();
     $this->view = Zend_Layout::getMvcInstance()->getView();
     $this->formName = $form->getName();
     $elementsBelongTo = $form->getElementsBelongTo();
     $this->elementPrefix = '';
     if ($elementsBelongTo) {
         $this->elementPrefix = Zmz_Utils::stripFormArrayNotation($elementsBelongTo);
         $this->elementPrefix .= '-';
     }
     $this->init();
 }
예제 #30
0
파일: TinyMCE.php 프로젝트: ei-grad/phorm
 /**
  * Рисуем редактор
  *
  * @param string $id Id HTML-элемента
  * @param string $value Значение элемента
  * @param array $params Массив параметров, path: путь к библиотеке, set: название сета, skin: имя скина, name: имя переменной в сете
  * @param array $attribs Массив атрибутов HTML-элемента
  * @return string
  */
 public function tinyMCE($id, $value = null, array $params = array(), array $attribs = array())
 {
     $attribs = $this->_prepareAttributes($id, $value, $attribs);
     $params['path'] = isset($params['path']) ? $this->view->BaseUrl() . $params['path'] : $this->view->BaseUrl() . '/ui/tinymce/';
     $this->jquery->addJavascriptFile($params['path'] . 'jquery.tinymce.js');
     $this->jquery->addJavascriptFile($params['path'] . 'tiny_mce.js');
     $this->jquery->addJavascriptFile($params['path'] . 'sets/' . $params['set'] . '.js');
     $this->jquery->addOnLoad(sprintf('%s.language="%s";', $params['name'], 'ru'));
     $this->jquery->addOnLoad(sprintf('%s.document_base_url="%s";', $params['name'], $this->view->BaseUrl()));
     $js = sprintf('%s("#%s").tinymce(%s);', ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(), $attribs['id'], $params['name']);
     $this->jquery->addOnLoad($js);
     return $this->view->formTextarea($id, $value, $attribs);
 }