Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small CSS fix #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions EDropzone.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@ public function run() {

/**
* I prefer to render HTML from view file. But if you override Widget you must to override all view's.
* review: you need to add style manually into your project css:
* .dz-browser-not-supported .fallback {display:none !important}
*/
protected function renderHtml() {
$htmlOptions = CMap::mergeArray(array('class' => 'dropzone', 'enctype'=> 'multipart/form-data'), $this->htmlOptions);
Expand All @@ -117,6 +115,22 @@ protected function renderHtml() {
}

protected function registerAssets() {
$this->registerAssetsBase();
if($this->customStyle)
Yii::app()->getClientScript()->registerCssFile($this->customStyle);
}

/**
* To update JS or CSS register your own package in component 'clientScript'
* @throws CException
*/
protected function registerAssetsBase() {
$cs = Yii::app()->getClientScript();
if (!empty($cs->packages['dropzone'])) {
$cs->registerPackage('dropzone');
return;
}

if ( $this->assetsVersion == self::VER_3_10_2 ) {
$basePath = dirname(__FILE__) . '/assets/';
$js = '/js/dropzone.js';
Expand All @@ -133,12 +147,12 @@ protected function registerAssets() {
}

$baseUrl = Yii::app()->getAssetManager()->publish($basePath, false, 1, YII_DEBUG);
Yii::app()->getClientScript()
$cs
->registerScriptFile($baseUrl . $js, CClientScript::POS_BEGIN)
->registerCssFile($baseUrl . $css);

if($this->customStyle)
Yii::app()->getClientScript()->registerCssFile($this->customStyle);
//review: i have created the issue https://github.com/enyo/dropzone/issues/1019 , but till it did not resolved we must to add this style manually
$cs->registerCss(__METHOD__ . '#' . $this->getId(), '.dz-browser-not-supported .fallback {display:block !important}');
}

protected function jsOptions() {
Expand Down
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,20 @@ Now you can use all of the events and set a custom CSS file. See the code for mo
'htmlOptions' => array('style'=>'height:95%; overflow: hidden;'),
'customStyle'=> $this->module->assetsPath.'/css/customdropzone.css'
));

To update JS or CSS register your own package 'dropzone' in component 'clientScript'.
Eg. in config file:

return array(
'components' => array(
'clientScript' => array(
'packages' => array(
'dropzone' => array(
'basePath' => 'application.www.assets.vendor',
'js' => array('dropzone.min.js'),
'css' => array('dropzone.min.css'),
),
),
),
),
);