Beispiel #1
0
 public function render(Zend_View_Interface $view = null)
 {
     $a = $this->getAttribs();
     $regional = @$a['regional'] ? $a['regional'] : 'ru';
     unset($a['regional']);
     unset($a['helper']);
     if (@$a['type'] == 'birth') {
         $lang = array('en' => array(), 'ru' => array('months' => array('short' => array('Янв', 'Фев', 'Мар', 'Апр', 'Май', 'Июн', 'Июл', 'Авг', 'Сен', 'Окт', 'Ноя', 'Дек'), 'long' => array('Январь', 'Февраль', 'Март', 'Апрель', 'Май', 'Июнь', 'Июль', 'Август', 'Сентябрь', 'Октябрь', 'Ноябрь', 'Декабрь')), 'titles' => array('Год', 'Месяц', 'День')));
         $o = array('maxAge' => '90', 'maxYear' => date('Y') - 5, 'monthFormat' => 'long', 'dateFormat' => 'littleEndian');
         $o = array_merge($o, $lang[$regional]);
         $js = '$.include(["/zkernel/js/jquery/jquery.birthdaypicker.js"], function() {$("input[name=' . $this->getName() . ']").birthdaypicker(' . Zend_Json::encode($o, false, array('enableJsonExprFinder' => true)) . ');});';
     } else {
         $o = array('dateFormat' => 'dd.mm.yy', 'firstDay' => '1');
         if ($a) {
             $o = array_merge($o, $a);
         }
         $callbacks = array('create', 'beforeShow', 'beforeShowDay', 'onChangeMonthYear', 'onClose', 'onSelect');
         foreach ($o as $k => $val) {
             if (in_array($k, $callbacks)) {
                 $o[$k] = new Zend_Json_Expr($val);
             }
         }
         $js = @$o['type'] == 'multyrange' ? '$.include(["/zkernel/js/jquery/ui/ui.datepicker.js", "/zkernel/js/jquery/ui/i18n/jquery.ui.datepicker-' . $regional . '.js", "/zkernel/js/jquery/ui/ui.multidatespicker.js"], function() {$("input[name=' . $this->getName() . ']").multiDatesPicker(' . Zend_Json::encode($o) . ');});' : '$.include(["/zkernel/js/jquery/ui/ui.datepicker.js", "/zkernel/js/jquery/ui/i18n/jquery.ui.datepicker-' . $regional . '.js"], function() {$("input[name=' . $this->getName() . ']").datepicker(' . Zend_Json::encode($o, false, array('enableJsonExprFinder' => true)) . ');});';
     }
     $this->getView()->inlineScript('script', $js);
     return parent::render($view);
 }
Beispiel #2
0
    public function render(Zend_View_Interface $view = null)
    {
        $type = $this->getAttrib('type');
        $value = $this->getValue();
        $height = $this->getAttrib('height');
        $search = $this->getAttrib('search');
        $width = $this->getAttrib('width');
        $scrollwheel = $this->getAttrib('scrollwheel');
        $center = $this->getAttrib('center');
        $zoom = $this->getAttrib('zoom');
        $maptypeid = $this->getAttrib('maptypeid');
        $js = 'if (typeof window.cb_gmap_' . $this->getName() . '_loaded == "undefined") window.cb_gmap_' . $this->getName() . '_loaded = false;
window.cb_gmap_' . $this->getName() . ' = function(a1, a2) {
	window.cb_gmap_' . $this->getName() . '_loaded = true;
	gmap.init("' . $this->getName() . '", ' . ($value ? '["' . str_replace(array('|', ' '), array('","', '","'), $value) . '"]' : 'null') . ', {' . '"type": "' . ($type ? $type : 'point') . '",' . ($search ? '"search": ' . $search . ',' : '') . ($width ? '"width": ' . $width . ',' : '') . ($height ? '"height": ' . $height . ',' : '') . ($scrollwheel ? '"scrollwheel": ' . $scrollwheel . ',' : '') . ($maptypeid ? '"mapTypeId": "' . $maptypeid . '",' : '') . ($zoom ? '"zoom": ' . $zoom . ',' : '') . ($center ? '"center": ["' . str_replace('|', ', ', $center) . '"],' : '') . '});
};
$.include([
	"/zkernel/ctl/gmap/gmap.js?' . rand(0, 111111111) . '",
	"http://maps.google.com/maps/api/js?sensor=false&callback=cb_gmap_' . $this->getName() . '",
], function() {
    if (window.cb_gmap_' . $this->getName() . '_loaded) window.cb_gmap_' . $this->getName() . '();
});
';
        $js = str_replace(',}', '}', $js);
        $this->getView()->inlineScript('script', $js);
        return parent::render($view);
    }
Beispiel #3
0
    public function render(Zend_View_Interface $view = null)
    {
        $this->class = $this->class . " ui-widget-content ui-corner-all";
        $this->id = $this->id ? $this->id : rand(1000000, 10000000);
        $this->format = $this->format ? $this->format : 'yy-mm-dd';
        if (!$this->getValue()) {
            $this->setValue(date('Y-m-d'));
        }
        jQuery::evalScript('$("#' . $this->id . '").datepicker({
    		changeMonth: true,
			changeYear: true,
			dateFormat: "' . $this->format . '"
			});
		');
        return parent::render($view);
    }
Beispiel #4
0
    public function render(Zend_View_Interface $view = null)
    {
        $a = $this->getAttribs();
        $regional = @$a['regional'] ? $a['regional'] : 'ru';
        unset($a['helper']);
        unset($a['regional']);
        $o = array('dateFormat' => 'dd.mm.yy', 'firstDay' => '1');
        if ($a) {
            $o = array_merge($o, $a);
        }
        $js = '$.include("/zkernel/ctl/timepicker/jquery-ui-timepicker-addon.css|link");
 $.include(["/zkernel/ctl/timepicker/jquery-ui-timepicker-addon.js", "/zkernel/js/jquery/ui/i18n/jquery.ui.datepicker-' . $regional . '.js", "/zkernel/ctl/timepicker/localization/jquery-ui-timepicker-' . $regional . '.js"], function() {
	$("input[name=' . $this->getName() . ']").datetimepicker(' . Zend_Json::encode($o) . ');
});';
        $this->getView()->inlineScript('script', $js);
        return parent::render($view);
    }
Beispiel #5
0
    public function render(Zend_View_Interface $view = null)
    {
        $model = $this->getAttrib('model');
        if ($model) {
            $this->setAttrib('model', '');
        }
        $min_length = (int) $this->getAttrib('min_length');
        $min_length = $min_length ? $min_length : 1;
        $must_match = $this->getAttrib('must_match');
        $add_param = $this->getAttrib('add_param');
        $s = new Zend_Session_Namespace();
        $s->form[$this->getName()] = array('model' => $model);
        $js = '$.include(["/zkernel/js/jquery/ui/ui.position.js", "/zkernel/js/jquery/ui/ui.autocomplete.js"], function() {
	var i = $("input[name=' . $this->getName() . ']");
	i.autocomplete({
		source: function(request, response) {
			var add = "";
			' . ($add_param ? 'var ap = ' . Zend_Json::encode($add_param) . ';
			for (k in ap) {
				if (String(ap[k]).slice(0, 3) == "jq:") {
					var o = $(ap[k].slice(3));
					if (o.length && o.val()) add += "/" + k + "/" + o.val();
				}
				else add += "/" + k + "/" + ap[k];
			}' : '') . '
			$.ajax({
				url: "/z/suggest/name/' . $this->getName() . '" + add,
				dataType: "json",
				data: request,
				success: function(data) {
					' . ($must_match ? 'if (data.length == 0) i.val("");' : '') . '
					response(data);
				}
			});
		}
		' . ($min_length == 1 ? '' : ',minLength: ' . $min_length) . '
		' . ($must_match ? ',select: function(event, ui) { i.data("matched", ui.item.value); }' : '') . '
	}).data("matched", i.val())' . ($must_match ? '.blur(function() { if (i.data("matched") != i.val()) i.val(""); })' : '') . ';
});
';
        $js = str_replace(',}', '}', $js);
        $this->getView()->inlineScript('script', $js);
        return parent::render($view);
    }
Beispiel #6
0
    public function render(Zend_View_Interface $view = null)
    {
        $js = '$.include("/zkernel/ctl/colorpicker/css/colorpicker.css|link");
$.include("/zkernel/ctl/colorpicker/colorpicker.js", function() {
	$(\'input[name="' . $this->getName() . '"]\').ColorPicker({
    	color: "' . $this->getValue() . '",
    	onBeforeShow: function () {
			$(this).ColorPickerSetColor(this.value);
		},
    	onSubmit: function(hsb, hex, rgb, el) {
    		$(el).val("#" + hex);
    		$(el).ColorPickerHide();
    	}
    });
});
';
        $this->getView()->inlineScript('script', $js);
        return parent::render($view);
    }
Beispiel #7
0
    public function render(Zend_View_Interface $view = null)
    {
        $color = $this->getAttrib('color');
        $type = $this->getAttrib('type');
        $value = $this->getValue();
        $value = explode(';', $value);
        if (count($value) == 1) {
            $val = explode('|', $value[0]);
        } else {
            $val = array();
            foreach ($value as $el) {
                $val[] = explode('|', $el);
            }
        }
        $js = '$.include("/zkernel/ctl/point/point.js", function() {
	window.setTimeout(function() { point.init("' . $this->getName() . '", ' . ($value ? Zend_Json::encode($val) : 'null') . ', {
    	"url": "' . $this->getAttrib('url') . '",' . ($type ? '"type": "' . $type . '",' : '') . ($color ? '"color": "' . $color . '",' : '') . '}); }, 1000);
});
';
        $js = str_replace(',}', '}', $js);
        $this->getView()->inlineScript('script', $js);
        return parent::render($view);
    }