Commits

Konstantin Semenov committed 2e96df2

Video support, heading styles

Comments (0)

Files changed (3)

 PATH
   remote: .
   specs:
-    bootsy (1.2.3)
+    bootsy (1.2.4)
       carrierwave (~> 0.9.0)
       mini_magick (~> 3.6.0)
       remotipart (~> 1.2.1)

app/assets/javascripts/bootsy/bootstrap-wysihtml5.js

               "<i class='icon-font'></i>&nbsp;<span class='current-font'>" + locale.font_styles.normal + "</span>&nbsp;<b class='caret'></b>" +
               "</a>" +
               "<ul class='dropdown-menu'>" +
-                "<li><a data-wysihtml5-command='formatBlock' data-wysihtml5-command-value='div' tabindex='-1'>" + locale.font_styles.normal + "</a></li>" +
+                "<li><a data-wysihtml5-command='formatBlock' data-wysihtml5-command-value='p' tabindex='-1'>" + locale.font_styles.normal + "</a></li>" +
                 "<li><a data-wysihtml5-command='formatBlock' data-wysihtml5-command-value='h1' tabindex='-1'>" + locale.font_styles.h1 + "</a></li>" +
                 "<li><a data-wysihtml5-command='formatBlock' data-wysihtml5-command-value='h2' tabindex='-1'>" + locale.font_styles.h2 + "</a></li>" +
                 "<li><a data-wysihtml5-command='formatBlock' data-wysihtml5-command-value='h3' tabindex='-1'>" + locale.font_styles.h3 + "</a></li>" +
+                "<li><a data-wysihtml5-command='formatBlock' data-wysihtml5-command-value='h4' tabindex='-1'>" + locale.font_styles.h4 + "</a></li>" +
+                "<li><a data-wysihtml5-command='formatBlock' data-wysihtml5-command-value='h5' tabindex='-1'>" + locale.font_styles.h5 + "</a></li>" +
+                "<li><a data-wysihtml5-command='formatBlock' data-wysihtml5-command-value='blockquote' tabindex='-1'>" + locale.font_styles.blockquote + "</a></li>" +
               "</ul>" +
             "</li>";
         },
             "</li>";
         },
 
-        "blockquote": function(locale, options) {
+        "video": function(locale, options) {
             var size = (options && options.size) ? ' btn-'+options.size : '';
             return "<li>" +
-                "<div class='btn-group'>" +
-                "<a class='btn" + size + "' data-wysihtml5-command='blockquote' title='" + locale.blockquote + "' tabindex='-1'><i class='icon-comment'></i></a>" +
+                "<div class='bootstrap-wysihtml5-insert-video-modal modal hide fade'>" +
+                "<div class='modal-header'>" +
+                "<a class='close' data-dismiss='modal'>&times;</a>" +
+                "<h3>" + locale.video.insert + "</h3>" +
+                "</div>" +
+                "<div class='modal-body'>" +
+                "<textarea class='bootstrap-wysihtml5-insert-video-content'></textarea>" +
                 "</div>" +
+                "<div class='modal-footer'>" +
+                "<a href='#' class='btn' data-dismiss='modal'>" + locale.video.cancel + "</a>" +
+                "<a href='#' class='btn btn-primary' data-dismiss='modal'>" + locale.video.insert + "</a>" +
+                "</div>" +
+                "</div>" +
+                "<a class='btn" + size + "' data-wysihtml5-command='insertVideo' title='" + locale.video.insert + "' tabindex='-1'><i class='icon-film'></i></a>" +
                 "</li>";
         },
 
                         this.initHtml(toolbar);
                     }
 
+                    if(key === "video") {
+                        this.initInsertVideo(toolbar);
+                    }
+
                     if(key === "link") {
                         this.initInsertLink(toolbar);
                     }
             });
         },
 
+        initInsertVideo: function(toolbar) {
+            var self = this;
+            var insertVideoModal = toolbar.find('.bootstrap-wysihtml5-insert-video-modal');
+            var videoInput = toolbar.find('.bootstrap-wysihtml5-insert-video-content');
+            var insertButton = insertVideoModal.find('a.btn-primary');
+            var initialValue = videoInput.val();
+
+            var insertVideo = function() {
+                var video = videoInput.val();
+                videoInput.val(initialValue);
+                self.editor.currentView.element.focus();
+                self.editor.composer.commands.exec("insertHTML", video);
+            };
+
+            videoInput.keypress(function(e) {
+                if(e.which == 13) {
+                    insertVideo();
+                    insertVideoModal.modal('hide');
+                }
+            });
+
+            insertButton.click(insertVideo);
+
+            insertVideoModal.on('shown', function() {
+                videoInput.focus();
+            });
+
+            insertVideoModal.on('hide', function() {
+                self.editor.currentView.element.focus();
+            });
+
+            toolbar.find('a[data-wysihtml5-command=insertVideo]').click(function() {
+                insertVideoModal.appendTo('body').modal('show');
+                insertVideoModal.on('click.dismiss.modal', '[data-dismiss="modal"]', function(e) {
+                    e.stopPropagation();
+                });
+            });
+        },
+
         initInsertImage: function(toolbar) {
             var self = this;
             var insertImageModal = toolbar.find('.bootstrap-wysihtml5-insert-image-modal');
                 normal: "Normal text",
                 h1: "Heading 1",
                 h2: "Heading 2",
-                h3: "Heading 3"
+                h3: "Heading 3",
+                h4: "Heading 4",
+                h5: "Heading 5"
             },
             emphasis: {
                 bold: "Bold",
                 insert: "Insert link",
                 cancel: "Cancel"
             },
+            video: {
+                insert: "Insert video",
+                cancel: "Cancel"
+            },
             image: {
                 insert: "Insert image",
                 cancel: "Cancel"

lib/bootsy/version.rb

 module Bootsy
-  VERSION = '1.2.4'
+  VERSION = '1.2.5'
 end