浏览代码

commit 4da60d46fc036c8bc8920f4c365e6cdc11ccd459
Author: codepiano <codepiano.li@gmail.com>
Date: Thu Nov 5 23:07:50 2015 +0800

Add code to distinguish cmd and electron envirmonment

The way to judge whether in CommonJs style can not distinguish real
CommonJs from electron, will case BootstrapDialog object set to
window.module.exports.
Same problem may occur in node webkit,but I do not test this situation.

Dante 10 年之前
父节点
当前提交
dc24ce1fd6
共有 3 个文件被更改,包括 15 次插入3 次删除
  1. 7 1
      dist/js/bootstrap-dialog.js
  2. 1 1
      dist/js/bootstrap-dialog.min.js
  3. 7 1
      src/js/bootstrap-dialog.js

+ 7 - 1
dist/js/bootstrap-dialog.js

@@ -17,7 +17,13 @@
 
     // CommonJS module is defined
     if (typeof module !== 'undefined' && module.exports) {
-        module.exports = factory(require('jquery'), require('bootstrap'));
+        var isNode = (typeof process !== "undefined");
+        var isElectron = isNode && ('electron' in process.versions);
+        if(isElectron) {
+            root.BootstrapDialog = factory(root.jQuery);
+        } else {
+            module.exports = factory(require('jquery'), require('bootstrap'));
+        }
     }
     // AMD module is defined
     else if (typeof define === "function" && define.amd) {

文件差异内容过多而无法显示
+ 1 - 1
dist/js/bootstrap-dialog.min.js


+ 7 - 1
src/js/bootstrap-dialog.js

@@ -17,7 +17,13 @@
 
     // CommonJS module is defined
     if (typeof module !== 'undefined' && module.exports) {
-        module.exports = factory(require('jquery'), require('bootstrap'));
+        var isNode = (typeof process !== "undefined");
+        var isElectron = isNode && ('electron' in process.versions);
+        if(isElectron) {
+            root.BootstrapDialog = factory(root.jQuery);
+        } else {
+            module.exports = factory(require('jquery'), require('bootstrap'));
+        }
     }
     // AMD module is defined
     else if (typeof define === "function" && define.amd) {