[IMP] website: media editor: add embed video
authorchm@openerp.com <>
Mon, 31 Mar 2014 13:55:58 +0000 (15:55 +0200)
committerchm@openerp.com <>
Mon, 31 Mar 2014 13:55:58 +0000 (15:55 +0200)
bzr revid: chm@openerp.com-20140331135558-ulr1nzhwwvcnwswm

addons/website/static/src/js/website.editor.js
addons/website/static/src/xml/website.editor.xml

index 2de0e92..5ef5359 100644 (file)
         template: 'website.editor.dialog.video',
         events : _.extend({}, website.editor.Dialog.prototype.events, {
             'blur input#urlvideo': 'get_video',
+            'blur input#embedvideo': 'get_embed_video',
         }),
         start: function () {
             this.$iframe = this.$("iframe");
                     return "//player.vimeo.com/video/" + video_id + "?autoplay=" + (this.$("#autoplay").is(":checked") ? 1 : 0);
                 case "dailymotion":
                     return "//www.dailymotion.com/embed/video/" + video_id + "?autoplay=" + (this.$("#autoplay").is(":checked") ? 1 : 0);
+                default:
+                    return video_id;
             }
         },
+        get_embed_video: function () {
+            var embedvideo = this.$("input#embedvideo").val().match(/src=["']?([^"']+)["' ]?/);
+            this.$("input#urlvideo").val(embedvideo ? embedvideo[1] : "");
+            this.get_video();
+        },
         get_video: function () {
             var needle = this.$("input#urlvideo").val();
             var video_id;
             } else if (needle.indexOf(".dailymotion.") != -1) {
                 video_type = "dailymotion";
                 video_id = needle.match(/dailymotion\.[a-z]+\/(embed\/)?(video\/)?([^\/?&]+)/i)[3];
+            } else {
+                video_type = "";
+                video_id = needle;
             }
 
             this.$("#video_id").val(video_id);
index 8e6f976..ca8a264 100644 (file)
         <form action="#" class="form-inline">
             <div class="well">
                 <div class="form-group">
-                    <label for="urlvideo">Video URL</label>
+                    <label for="urlvideo" style="width: 200px;">Video URL</label>
                     <input type="text"
                         name="url"
                         class="form-control url"
                         placeholder="http://openerp.com"
                         value="//www.youtube.com/embed/yws1tbgNV7k"/>
                     <span class="text-muted">
-                        Youtube, Vimeo, Dailymotion
+                        (Youtube, Vimeo, Dailymotion)
                     </span>
                 </div>
+                <div class="form-group">
+                    <label for="urlvideo" style="width: 200px;">Html Embed Video</label>
+                    <input type="text"
+                        name="embed"
+                        class="form-control url"
+                        style="width: 400px;"
+                        id="embedvideo"
+                        placeholder='&lt;iframe src="//www.youtube.com/embed/yws1tbgNV7k"&gt;&lt;/iframe&gt;'/>
+                </div>
             </div>
             
             <div id="video-preview" style="width: 450px; margin: 0 auto;">