forked from vitalets/x-editable-yii
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEditableConfig.php
50 lines (44 loc) · 1.32 KB
/
EditableConfig.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
/**
* EditableConfig class file.
*
* @author Vitaliy Potapov <noginsk@rambler.ru>
* @link https://github.com/vitalets/x-editable-yii
* @copyright Copyright © Vitaliy Potapov 2012
* @version 1.3.0
*/
class EditableConfig extends CApplicationComponent
{
const FORM_BOOTSTRAP = 'bootstrap';
const FORM_JQUERYUI = 'jqueryui';
const FORM_PLAIN = 'plain';
const POPUP = 'popup';
const INLINE = 'inline';
/**
* @var string editable form engine: bootstrap, jqueryui, plain
*/
public $form = self::FORM_BOOTSTRAP;
/**
* @var string editable container type: popup or inline
*/
public $mode = self::POPUP;
/**
* @var array defaults for editable configuration
*/
public $defaults = array();
/**
* initializes editable component and sets defaults
*
*/
public function init()
{
parent::init();
if(empty($this->defaults)) $this->defaults = array();
//copy mode from first level config to defaults (for compability)
if(empty($this->defaults['mode'])) $this->defaults['mode'] = $this->mode;
$defaults = CJavaScript::encode($this->defaults);
Yii::app()->getClientScript()->registerScript(
'editable-defaults', 'if($.fn.editable) $.extend($.fn.editable.defaults, '.$defaults.');'
);
}
}