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

Added ability to ignore assets #222

Open
wants to merge 10 commits 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
11 changes: 6 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"name": "wbraganca/yii2-dynamicform",
"name": "mabentley85/yii2-dynamicform",
"description": "It is widget to yii2 framework to clone form elements in a nested manner, maintaining accessibility.",
"keywords": [
"mabentley85",
"wbraganca",
"yii2",
"extension",
Expand All @@ -13,9 +14,9 @@
"type": "yii2-extension",
"license": "BSD-3-Clause",
"support": {
"issues": "https://github.com/wbraganca/yii2-dynamicform/issues",
"wiki": "https://github.com/wbraganca/yii2-dynamicform/wiki/",
"source": "https://github.com/wbraganca/yii2-dynamicform"
"issues": "https://github.com/mabentley85/yii2-dynamicform/issues",
"wiki": "https://github.com/mabentley85/yii2-dynamicform/wiki/",
"source": "https://github.com/mabentley85/yii2-dynamicform"
},
"authors": [
{
Expand All @@ -31,7 +32,7 @@
},
"autoload": {
"psr-4": {
"wbraganca\\dynamicform\\": "src"
"mabentley85\\dynamicform\\": "src"
}
}
}
41 changes: 7 additions & 34 deletions src/DynamicFormAsset.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@
* @license https://github.com/wbraganca/yii2-dynamicform/blob/master/LICENSE
*/

namespace wbraganca\dynamicform;
namespace mabentley85\dynamicform;

use yii\web\AssetBundle;

/**
* Asset bundle for dynamicform Widget
*
* @author Wanderson Bragança <[email protected]>
*/
class DynamicFormAsset extends \yii\web\AssetBundle
class DynamicFormAsset extends AssetBundle
{
/**
* @inheritdoc
Expand All @@ -22,42 +24,13 @@ class DynamicFormAsset extends \yii\web\AssetBundle
'yii\widgets\ActiveFormAsset'
];

/**
* Set up CSS and JS asset arrays based on the base-file names
* @param string $type whether 'css' or 'js'
* @param array $files the list of 'css' or 'js' basefile names
*/
protected function setupAssets($type, $files = [])
{
$srcFiles = [];
$minFiles = [];
foreach ($files as $file) {
$srcFiles[] = "{$file}.{$type}";
$minFiles[] = "{$file}.min.{$type}";
}
if (empty($this->$type)) {
$this->$type = YII_DEBUG ? $srcFiles : $minFiles;
}
}

/**
* @inheritdoc
*/
public function init()
{
$this->setSourcePath(__DIR__ . '/assets');
$this->setupAssets('js', ['yii2-dynamic-form']);
parent::init();
}
public $sourcePath = '@vendor/mabentley85/yii2-dynamicform/src/assets';

/**
* Sets the source path if empty
* @param string $path the path to be set
* @inheritdoc
*/
protected function setSourcePath($path)
{
if (empty($this->sourcePath)) {
$this->sourcePath = $path;
}
}
public $js = ['yii2-dynamic-form.js'];
}
2 changes: 1 addition & 1 deletion src/DynamicFormWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @license https://github.com/wbraganca/yii2-dynamicform/blob/master/LICENSE
*/

namespace wbraganca\dynamicform;
namespace mabentley85\dynamicform;

use Yii;
use yii\helpers\Html;
Expand Down
13 changes: 10 additions & 3 deletions src/assets/yii2-dynamic-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,15 @@

// remove "error/success" css class
var yiiActiveFormData = $('#' + widgetOptions.formId).yiiActiveForm('data');
$template.find('.' + yiiActiveFormData.settings.errorCssClass).removeClass(yiiActiveFormData.settings.errorCssClass);
$template.find('.' + yiiActiveFormData.settings.successCssClass).removeClass(yiiActiveFormData.settings.successCssClass);
if (typeof yiiActiveFormData !== "undefined" && typeof yiiActiveFormData.settings !== "undefined" ) {
if(typeof yiiActiveFormData.settings.errorCssClass !== "undefined" && yiiActiveFormData.settings.errorCssClass.length > 0) {
$template.find('.' + yiiActiveFormData.settings.errorCssClass).removeClass(yiiActiveFormData.settings.errorCssClass);
}

if(typeof yiiActiveFormData.settings.successCssClass !== "undefined" && yiiActiveFormData.settings.successCssClass.length > 0) {
$template.find('.' + yiiActiveFormData.settings.successCssClass).removeClass(yiiActiveFormData.settings.successCssClass);
}
}

return $template;
};
Expand All @@ -115,7 +122,7 @@
var count = _count($elem, widgetOptions);

if (count < widgetOptions.limit) {
$toclone = widgetOptions.template;
$toclone = $(widgetOptions.widgetItem).first();
$newclone = $toclone.clone(false, false);

if (widgetOptions.insertPosition === 'top') {
Expand Down
Loading