示例#1
2
 public function init()
 {
     $this->themeUrl = Yii::app()->getAssetManager()->publish(Yii::getPathOfAlias('application.assets.css.jui'));
     $this->theme = Yii::app()->params['juiTheme'];
     $this->language = Yii::app()->language;
     parent::init();
 }
 public function init() {
     parent::init();
     $this->options = CMap::mergeArray($this->options,array(
             'dateFormat'=>Yii::app()->getLocale()->getDateFormat('short'),
             'changeMonth'=>true,
             'changeYear'=>true,
     ));
 }
示例#3
0
 public function init() {
     parent::init();
     $this->options = CMap::mergeArray($this->options, array(
         'dateFormat'=>'yy-mm-dd',
         'changeMonth'=>true,
         'changeYear'=>true,
         'showMonthAfterYear'=>false
     ));
 }
 public function init()
 {
     if (!in_array($this->mode, array('date', 'time', 'datetime'))) {
         throw new CException('unknow mode "' . $this->mode . '"');
     }
     if (!isset($this->language)) {
         $this->language = Yii::app()->getLanguage();
     }
     return parent::init();
 }
示例#5
0
 /**
  * Initialize widget.
  */
 public function init()
 {
     if (!in_array($this->mode, array('date', 'time', 'datetime'))) {
         throw new CException('unknown mode "' . $this->mode . '"');
     }
     if (!isset($this->language)) {
         $this->language = Yii::app()->getLanguage();
     }
     // Overwrite options for time picker
     if ($this->mode === 'time') {
         $this->options = array_merge($this->options, $this->timeOptions);
         $this->htmlOptions = array_merge($this->htmlOptions, $this->timeHtmlOptions);
     }
     return parent::init();
 }
示例#6
0
 public function init()
 {
     parent::init();
     if (!in_array($this->row, array('vertical', 'horizontal'))) {
         $this->row = false;
     }
     $options = array('showAnim' => 'fold', 'dateFormat' => 'yy-mm-dd', 'changeMonth' => true, 'changeYear' => true, 'showOn' => 'both');
     if (YdHelper::isMobileBrowser()) {
         $options['showOn'] = 'button';
         $options['onClose'] = 'js:function(dateText, inst){$(this).attr("disabled", false);}';
         $options['beforeShow'] = 'js:function(input, inst){$(this).attr("disabled", true);}';
     }
     $this->options = CMap::mergeArray($options, $this->options);
     $this->htmlOptions = CMap::mergeArray(array('autocomplete' => 'off'), $this->htmlOptions);
     parent::init();
 }
 /**
  * Run widget.
  */
 public function run()
 {
     if ($this->mode == 'date') {
         parent::run();
     } else {
         list($name, $id) = $this->resolveNameID();
         if (isset($this->htmlOptions['id'])) {
             $id = $this->htmlOptions['id'];
         } else {
             $this->htmlOptions['id'] = $id;
         }
         if (isset($this->htmlOptions['name'])) {
             $name = $this->htmlOptions['name'];
         }
         if ($this->flat === false) {
             if ($this->hasModel()) {
                 echo CHtml::activeTextField($this->model, $this->attribute, $this->htmlOptions);
             } else {
                 echo CHtml::textField($name, $this->value, $this->htmlOptions);
             }
         } else {
             if ($this->hasModel()) {
                 echo CHtml::activeHiddenField($this->model, $this->attribute, $this->htmlOptions);
                 $attribute = $this->attribute;
                 $this->options['defaultDate'] = $this->model->{$attribute};
             } else {
                 echo CHtml::hiddenField($name, $this->value, $this->htmlOptions);
                 $this->options['defaultDate'] = $this->value;
             }
             if (!isset($this->options['onSelect'])) {
                 $this->options['onSelect'] = new CJavaScriptExpression("function( selectedDate ) { jQuery('#{$id}').val(selectedDate);}");
             }
             $this->options['altField'] = '#' . $id;
             $id = $this->htmlOptions['id'] = $id . '_container';
             $this->htmlOptions['name'] = $name . '_container';
             echo CHtml::tag('div', $this->htmlOptions, '');
         }
         // set current time
         $this->options['hour'] = date('H');
         $this->options['minute'] = date('i');
         $this->options['second'] = date('s');
         $this->registerClientScript();
     }
 }
 public function run()
 {
     if ($this->mode == 'date') {
         parent::run();
     } else {
         list($name, $id) = $this->resolveNameID();
         if (isset($this->htmlOptions['id'])) {
             $id = $this->htmlOptions['id'];
         } else {
             $this->htmlOptions['id'] = $id;
         }
         if (isset($this->htmlOptions['name'])) {
             $name = $this->htmlOptions['name'];
         }
         if ($this->flat === false) {
             if ($this->hasModel()) {
                 echo CHtml::activeTextField($this->model, $this->attribute, $this->htmlOptions);
             } else {
                 echo CHtml::textField($name, $this->value, $this->htmlOptions);
             }
         } else {
             if ($this->hasModel()) {
                 echo CHtml::activeHiddenField($this->model, $this->attribute, $this->htmlOptions);
                 $attribute = $this->attribute;
                 $this->options['defaultDate'] = $this->model->{$attribute};
             } else {
                 echo CHtml::hiddenField($name, $this->value, $this->htmlOptions);
                 $this->options['defaultDate'] = $this->value;
             }
             if (!isset($this->options['onSelect'])) {
                 $this->options['onSelect'] = new CJavaScriptExpression("function( selectedDate ) { jQuery('#{$id}').val(selectedDate);}");
             }
             $id = $this->htmlOptions['id'] = $id . '_container';
             $this->htmlOptions['name'] = $name . '_container';
             echo CHtml::tag('div', $this->htmlOptions, '');
         }
         //set now time..
         $this->options['hour'] = date('H');
         $this->options['minute'] = date('i');
         $this->options['second'] = date('s');
         $options = CJavaScript::encode($this->options);
         $js = "jQuery('#{$id}').{$this->mode}picker({$options});";
         $assetsDir = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'assets';
         $assets = Yii::app()->assetManager->publish($assetsDir);
         $cs = Yii::app()->clientScript;
         $min = YII_DEBUG ? '' : '.min';
         $cs->registerCssFile($assets . '/jquery-ui-timepicker-addon.css');
         $cs->registerScriptFile($assets . '/jquery-ui-timepicker-addon' . $min . '.js', CClientScript::POS_END);
         if ($this->language != 'en') {
             $this->registerScriptFile($this->i18nScriptFile);
             //TimePicker localization load..
             $i18nScriptFile = 'jquery-ui-timepicker-' . $this->language . '.js';
             $i18nScriptPath = $assetsDir . DIRECTORY_SEPARATOR . 'localization' . DIRECTORY_SEPARATOR . $i18nScriptFile;
             if (file_exists($i18nScriptPath)) {
                 $cs->registerScriptFile($assets . '/localization/' . $i18nScriptFile, CClientScript::POS_END);
             }
             $js = "jQuery('#{$id}').{$this->mode}picker(jQuery.extend(jQuery.datepicker.regional['{$this->language}'], {$options}));";
         }
         if (isset($this->defaultOptions)) {
             $this->registerScriptFile($this->i18nScriptFile);
             $cs->registerScript(__CLASS__, $this->defaultOptions !== null ? "jQuery.{$this->mode}picker.setDefaults(" . CJavaScript::encode($this->defaultOptions) . ');' : '');
         }
         $cs->registerScript(__CLASS__ . '#' . $id, $js);
     }
 }
 public function init()
 {
     parent::init();
     $this->registerAssets();
     $this->registerTheme();
 }
示例#10
0
 public function init()
 {
     $this->options = array('showAnim' => 'fold', 'dateFormat' => 'yy-mm-dd');
     $this->htmlOptions = array('style' => 'height:20px;');
     parent::init();
 }