Explorar o código

GC-590: use switchery

ensure to require without error
Yuki Takei %!s(int64=7) %!d(string=hai) anos
pai
achega
3ab0f6b2ee

+ 4 - 0
config/webpack.common.js

@@ -86,6 +86,10 @@ module.exports = (options) => {
             basenameAsNamespace: true,
           }
         },
+        { // see https://github.com/abpetkov/switchery/issues/120
+          test: /switchery\.js$/,
+          loader: 'imports-loader?module=>false,exports=>false,define=>false,this=>window'
+        },
         {
           test: /\.css$/,
           use: ['style-loader', 'css-loader'],

+ 2 - 0
lib/views/admin/global-notification.html

@@ -25,6 +25,8 @@
     {% for globalNotif in globalNotifications %}
     <tr class="clickable-row" data-href="{{ detailPageUrl }}" data-updatepost-id="{{ globalNotif._id.toString() }}">
       <td class="unclickable align-middle">
+        <!-- TBD -->
+        <!-- <input type="checkbox" class="js-switch" data-size="small" checked /> -->
         <label class="switch">
           <input type="checkbox" class="isEnabledToggle" {% if globalNotif.isEnabled %}checked{% endif %}>
           <span class="slider round"></span>

+ 1 - 0
package.json

@@ -141,6 +141,7 @@
     "extract-text-webpack-plugin": "^4.0.0-beta.0",
     "file-loader": "^1.1.0",
     "i18next-browser-languagedetector": "^2.2.0",
+    "imports-loader": "^0.8.0",
     "jquery-slimscroll": "^1.3.8",
     "jquery-ui": "^1.12.1",
     "jquery.cookie": "~1.4.1",

+ 3 - 1
resource/js/legacy/crowi-admin.js

@@ -1,7 +1,9 @@
 require('bootstrap-select');
 require('./thirdparty-js/jQuery.style.switcher');
 
-const Switchery = require('./thirdparty-js/switchery/switchery');
+// see https://github.com/abpetkov/switchery/issues/120
+// see https://github.com/abpetkov/switchery/issues/120#issuecomment-286337221
+require('./thirdparty-js/switchery/switchery');
 require('./thirdparty-js/switchery/switchery.css');
 
 $(function() {

+ 7 - 0
yarn.lock

@@ -4045,6 +4045,13 @@ import-local@^1.0.0:
     pkg-dir "^2.0.0"
     resolve-cwd "^2.0.0"
 
+imports-loader@^0.8.0:
+  version "0.8.0"
+  resolved "https://registry.yarnpkg.com/imports-loader/-/imports-loader-0.8.0.tgz#030ea51b8ca05977c40a3abfd9b4088fe0be9a69"
+  dependencies:
+    loader-utils "^1.0.2"
+    source-map "^0.6.1"
+
 imurmurhash@^0.1.4:
   version "0.1.4"
   resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea"