]*class\s*=\s*"[^"]*\bform-group\b[^"]*"[^>]*>(?:(?!
]*class\s*=\s*"[^"]*\bform-group\b[^"]*").)*?data-rule="[^"]*?(required|checked)[^"]*?"[^>]*>/si';
+ $result = preg_replace_callback($regex, function ($matches) use ($config) {
+ return str_replace("form-group", "form-group required-{$config['asteriskposition']}", $matches[0]);
+ }, $content);
+
+ $content = is_null($result) ? $content : $result;
+
+ // 匹配
+ $pattern = '/(
]*>)\s*| ]*>(.*?)<\/td>\s* | ]*>.*?]*data-rule="[^"]*required[^"]*"[^>]*>.*?<\/td>\s*<\/tr>/si';
+ $result = preg_replace_callback($pattern, function ($matches) use ($config) {
+ if (preg_match('/( |
]*)class\s*=\s*"[^"]*"/i', $matches[1])) {
+ return preg_replace('/(
]*)class\s*=\s*"([^"]*)"/i', '$1class="$2 required-' . $config['asteriskposition'] . '"', $matches[0]);
+ } else {
+ return str_replace("
getConfig();
+
+ $config['area'] = preg_match("/\[(.*?)\]/i", $config['area']) ? array_slice(array_values((array)json_decode($config['area'], true)), 0, 2) : $config['area'];
+ $config['shade'] = floatval($config['shade']);
+ $config['shadeClose'] = boolval($config['shadeClose']);
+ $params['betterform'] = $config;
+ }
+
+}
diff --git a/addons/betterform/bootstrap.js b/addons/betterform/bootstrap.js
new file mode 100644
index 0000000..aeec7da
--- /dev/null
+++ b/addons/betterform/bootstrap.js
@@ -0,0 +1,27 @@
+require(['fast', 'layer'], function (Fast, Layer) {
+ var _fastOpen = Fast.api.open;
+ Fast.api.open = function (url, title, options) {
+ options = options || {};
+ options.area = Config.betterform.area;
+ options.offset = Config.betterform.offset;
+ options.anim = Config.betterform.anim;
+ options.shadeClose = Config.betterform.shadeClose;
+ options.shade = Config.betterform.shade;
+ return _fastOpen(url, title, options);
+ };
+ if (isNaN(Config.betterform.anim)) {
+ var _layerOpen = Layer.open;
+ Layer.open = function (options) {
+ var classNameArr = {slideDown: "layer-anim-slide-down", slideLeft: "layer-anim-slide-left", slideUp: "layer-anim-slide-up", slideRight: "layer-anim-slide-right"};
+ var animClass = "layer-anim " + classNameArr[options.anim] || "layer-anim-fadein";
+ var index = _layerOpen(options);
+ var layero = $('#layui-layer' + index);
+
+ layero.addClass(classNameArr[options.anim] + "-custom");
+ layero.addClass(animClass).one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function () {
+ $(this).removeClass(animClass);
+ });
+ return index;
+ }
+ }
+});
\ No newline at end of file
diff --git a/addons/betterform/config.php b/addons/betterform/config.php
new file mode 100644
index 0000000..225d557
--- /dev/null
+++ b/addons/betterform/config.php
@@ -0,0 +1,102 @@
+ 'asteriskposition',
+ 'title' => '*号位置',
+ 'type' => 'radio',
+ 'group' => '',
+ 'visible' => '',
+ 'content' => [
+ 'before' => '位于文本前',
+ 'after' => '位于文本后',
+ ],
+ 'value' => 'before',
+ 'rule' => 'required',
+ 'msg' => '',
+ 'tip' => '',
+ 'ok' => '',
+ 'extend' => '',
+ ],
+ [
+ 'name' => 'offset',
+ 'title' => '弹窗位置',
+ 'type' => 'radio',
+ 'content' => [
+ 'auto' => '居中',
+ 't' => '顶部',
+ 'b' => '底部',
+ 'l' => '左部',
+ 'r' => '右部',
+ ],
+ 'value' => 'r',
+ 'rule' => 'required',
+ 'msg' => '',
+ 'tip' => '',
+ 'ok' => '',
+ 'extend' => '',
+ ],
+ [
+ 'name' => 'anim',
+ 'title' => '打开动画',
+ 'type' => 'select',
+ 'content' => [
+ '平滑放大',
+ '从上掉落',
+ '从最底部往上滑入',
+ '从左滑入',
+ '从左翻滚',
+ '渐显',
+ '抖动',
+ 'slideDown' => '从上边缘往下',
+ 'slideLeft' => '从右边缘往左',
+ 'slideUp' => '从下边缘往上',
+ 'slideRight' => '从左边缘往右',
+ ],
+ 'value' => 'slideLeft',
+ 'rule' => 'required',
+ 'msg' => '',
+ 'tip' => '',
+ 'ok' => '',
+ 'extend' => '',
+ ],
+ [
+ 'name' => 'area',
+ 'title' => '弹窗宽高',
+ 'type' => 'string',
+ 'content' => [],
+ 'value' => '["80%", "100%"]',
+ 'rule' => 'required',
+ 'msg' => '',
+ 'tip' => '',
+ 'ok' => '',
+ 'extend' => '',
+ ],
+ [
+ 'name' => 'shade',
+ 'title' => '阴影透明度',
+ 'type' => 'number',
+ 'content' => [],
+ 'value' => '0.3',
+ 'rule' => 'required',
+ 'msg' => '',
+ 'tip' => '',
+ 'ok' => '',
+ 'extend' => '',
+ ],
+ [
+ 'name' => 'shadeClose',
+ 'title' => '点击阴影关闭弹窗',
+ 'type' => 'bool',
+ 'content' => [
+ 1 => '开启',
+ 0 => '关闭',
+ ],
+ 'value' => '1',
+ 'rule' => 'required',
+ 'msg' => '',
+ 'tip' => '',
+ 'ok' => '',
+ 'extend' => '',
+ ],
+];
diff --git a/addons/betterform/controller/Index.php b/addons/betterform/controller/Index.php
new file mode 100644
index 0000000..c8a19d2
--- /dev/null
+++ b/addons/betterform/controller/Index.php
@@ -0,0 +1,15 @@
+error("当前插件暂无前台页面");
+ }
+
+}
diff --git a/addons/betterform/info.ini b/addons/betterform/info.ini
new file mode 100644
index 0000000..71e8dfa
--- /dev/null
+++ b/addons/betterform/info.ini
@@ -0,0 +1,10 @@
+name = betterform
+title = FastAdmin表单弹窗优化插件
+intro = 优化FastAdmin表单弹窗
+author = FastAdmin
+website = https://www.fastadmin.net
+version = 1.0.3
+state = 1
+url = http://fast.cc:8088/addons/betterform
+license = regular
+licenseto = 15976