Browse Source

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 years ago
parent
commit
dc24ce1fd6
3 changed files with 15 additions and 3 deletions
  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) {

File diff suppressed because it is too large
+ 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) {