diff --git a/build/Spin/Spin.html b/build/Spin/Spin.html index e1faf5e..7bcca41 100644 --- a/build/Spin/Spin.html +++ b/build/Spin/Spin.html @@ -1,6 +1,6 @@
-
+
@@ -10,7 +10,7 @@
-
+
diff --git a/build/Spin/Spin.js b/build/Spin/Spin.js index 0dd9706..89ddf31 100644 --- a/build/Spin/Spin.js +++ b/build/Spin/Spin.js @@ -1,36 +1,43 @@ import template from "./Spin.html"; angular.module("esNgAntd").directive("antdSpin", function () { - return { - controllerAs: "antdSpin", - restrict: "E", - transclude: true, - replace: true, - scope: { - size: "@", - spinning: "@", - }, - template: template, - controller: function ($scope, $element, $attrs) { - this.getContext = function () { - return $scope; - }; + return { + template: template, + restrict: "E", + replace: true, + transclude: true, + scope: { + size: "@", + spinning: "=" + }, + controller: function ($scope, $element, $attrs) { + $scope.state = { + className: [], + hasChildren: false + }; + }, + link: function ($scope, $element, $attrs, $controllers, $transclude) { + [$element, $attrs, $controllers, $transclude].forEach(function (value, key) { + if ([undefined, null, ""].includes(value)) { + throw new Error(`${["$element", "$attrs", "$controllers", "$transclude"][key]} parameter of constructor method is required.`); + } + }); + $scope.state.className = ["ant-spin", "ant-spin-spinning"]; - $scope.state = { - className: [], - hasChildren: false, - }; - }, - link: function ($scope, $element, $attrs, $controllers, $transclude) { - $scope.state.className = ["ant-spin", "ant-spin-spinning"]; - $scope.state.hasChildren = JSON.stringify($transclude()) !== "{}"; + if ($transclude()) { + let len = $transclude().lenght; - if ($scope.size === "small") { - $scope.state.className.splice(1, 0, "ant-spin-sm"); - } + if (len > 0) { + $scope.state.hasChildren = true; + } + } - if ($scope.size === "large") { - $scope.state.className.splice(1, 0, "ant-spin-lg"); - } - }, - }; -}); + if ($scope.size === "small") { + $scope.state.className.splice(1, 0, "ant-spin-sm"); + } + + if ($scope.size === "large") { + $scope.state.className.splice(1, 0, "ant-spin-lg"); + } + } + }; +}); \ No newline at end of file diff --git a/src/Spin/Spin.html b/src/Spin/Spin.html index c5b2e92..5f60eb5 100644 --- a/src/Spin/Spin.html +++ b/src/Spin/Spin.html @@ -1,6 +1,6 @@
{state.hasChildren &&
- {spinning === 'true' &&
+ {spinning === true &&
@@ -10,7 +10,7 @@
} -
{children}
+
{children}
} {!state.hasChildren &&
diff --git a/src/Spin/Spin.js b/src/Spin/Spin.js index aac4e1e..1338787 100644 --- a/src/Spin/Spin.js +++ b/src/Spin/Spin.js @@ -1,21 +1,21 @@ import template from "./Spin.html"; class Spin { - props = { - size: String, - spinning: Boolean - }; state = { className: [], hasChildren: false, }; - template = template; - - constructor() { + constructor($element, $attrs, $controllers, $transclude) { this.state.className = ["ant-spin", "ant-spin-spinning"]; - this.state.hasChildren = JSON.stringify($transclude()) !== "{}"; + + if ($transclude()) { + let len = $transclude().lenght; + if (len > 0) { + this.state.hasChildren = true; + } + } if (this.size === "small") { this.state.className.splice(1, 0, "ant-spin-sm"); @@ -25,4 +25,13 @@ class Spin { this.state.className.splice(1, 0, "ant-spin-lg"); } } + + render() { + return template; + } +} + +Spin.propTypes = { + size: PropTypes.string, + spinning: PropTypes.boolean, } diff --git a/temp.txt b/temp.txt index 6cb2b65..186843b 100644 --- a/temp.txt +++ b/temp.txt @@ -1,3 +1,7 @@ image - [mvo] - preview=["']\{\{(.*?)\}\}["'] => preview="$1" \ No newline at end of file + [mvo|boss] + preview=["']?\{\{(.*?)\}\}["']? => preview="$1" + +spin + [boss] + spinning=["']?\{\{(.*?)\}\}["']? => spinning="$1" \ No newline at end of file diff --git a/webpack.config.js b/webpack.config.js index 700bc4e..57039d4 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -8,9 +8,9 @@ module.exports = { // bpms // path: "/Users/shann/Project/essa/bpms/bpms-webapp/src/main/webapp/lib/ng-antd", // boss - // path: "/Users/shann/Project/essa/boss/trunk/vendor-lib/ng-antd", + path: "/Users/shann/Project/essa/boss/trunk/vendor-lib/ng-antd", // mvo - path: "/Users/shann/Project/essa/mvo/mvo-webapp/public/browser-vendor/ng-antd", + // path: "/Users/shann/Project/essa/mvo/mvo-webapp/public/browser-vendor/ng-antd", // local // path: path.resolve(__dirname, "dist"), filename: "ng-antd.js", -- libgit2 0.21.2