ソースを参照

Multiline message supported

Dante 12 年 前
コミット
97fe097fd9

+ 12 - 4
examples/assets/bootstrap-dialog/js/bootstrap-dialog.js

@@ -147,12 +147,20 @@ var BootstrapDialog = null;
             return this;
         },
         createDynamicContent: function(rawContent) {
-            var contentType = typeof rawContent;
-            if (contentType === 'function') {
-                return rawContent.call(rawContent, this);
+            var content = null;
+            if (typeof rawContent === 'function') {
+                content = rawContent.call(rawContent, this);
+            } else {
+                content = rawContent;
+            }
+            if (typeof content === 'string') {
+                content = this.formatStringContent(content);
             }
 
-            return rawContent;
+            return content;
+        },
+        formatStringContent: function(content) {
+            return content.replace(/\r\n/g, '<br />').replace(/[\r\n]/g, '<br />');
         },
         setData: function(key, value) {
             this.options.data[key] = value;

+ 12 - 4
js/bootstrap-dialog.js

@@ -147,12 +147,20 @@ var BootstrapDialog = null;
             return this;
         },
         createDynamicContent: function(rawContent) {
-            var contentType = typeof rawContent;
-            if (contentType === 'function') {
-                return rawContent.call(rawContent, this);
+            var content = null;
+            if (typeof rawContent === 'function') {
+                content = rawContent.call(rawContent, this);
+            } else {
+                content = rawContent;
+            }
+            if (typeof content === 'string') {
+                content = this.formatStringContent(content);
             }
 
-            return rawContent;
+            return content;
+        },
+        formatStringContent: function(content) {
+            return content.replace(/\r\n/g, '<br />').replace(/[\r\n]/g, '<br />');
         },
         setData: function(key, value) {
             this.options.data[key] = value;