move swfobject & media record stuff into async chunk

closes: CNVS-36809

test plan:
* go to a wiki page and try to upload a video and an audio recording
* everything should work as before and there should be no errors
* when you click on the "record media" button, you should see
  a new download for a "mediaRecord" javascript file.
* the common bundle should be smaller than it was before

Change-Id: I1725e03d057db38f38b2b237360b5c682667a985
Reviewed-on: https://gerrit.instructure.com/111113
Tested-by: Jenkins
Reviewed-by: brian kirkby <bkirkby@instructure.com>
QA-Review: Tucker McKnight <tmcknight@instructure.com>
Product-Review: Ryan Shaw <ryan@instructure.com>
This commit is contained in:
Ryan Shaw 2017-05-08 12:12:45 -06:00
parent 75043f3203
commit ebc9f85b2a
2 changed files with 9 additions and 5 deletions

View File

@ -17,14 +17,11 @@
*/
define([
'swfobject',
'i18n!media_comments',
'underscore',
'vendor/jquery.ba-tinypubsub',
'jquery' /* $ */,
'str/htmlEscape',
'jst/MediaComments',
'compiled/media_comments/js_uploader',
'compiled/jquery/mediaComment' /* $.fn.mediaComment */,
'jquery.ajaxJSON' /* ajaxJSON */,
'jqueryui/dialog',
@ -32,7 +29,7 @@ define([
'jquery.instructure_misc_plugins' /* .dim, /\.log\(/ */,
'jqueryui/progressbar' /* /\.progressbar/ */,
'jqueryui/tabs' /* /\.tabs/ */
], function (swfobject, I18n, _, pubsub, $, htmlEscape, mediaCommentsTemplate, JsUploader) {
], function (I18n, _, pubsub, $, htmlEscape) {
"use strict"
var jsUploader
@ -264,6 +261,9 @@ define([
var reset_selectors = false;
var lastInit = null;
$.mediaComment.init = function(mediaType, opts) {
require.ensure([], function () {
var swfobject = require('swfobject');
lastInit = lastInit || new Date();
mediaType = mediaType || "any";
opts = opts || {};
@ -483,6 +483,7 @@ define([
// Do JS uploader is appropriate
if (INST.kalturaSettings.js_uploader) {
var JsUploader = require('compiled/media_comments/js_uploader');
jsUploader = new JsUploader(mediaType, opts);
jsUploader.onReady = mediaCommentReady;
jsUploader.addEntry = addEntry;
@ -524,6 +525,7 @@ define([
// **********************************************************************
var checkForKS = function() {
if($div.data('ks')) {
var mediaCommentsTemplate = require('jst/MediaComments');
$div.html(mediaCommentsTemplate());
$div.find("#media_record_tabs").tabs({activate: $.mediaComment.video_delegate.expectReady});
mediaCommentReady();
@ -540,7 +542,9 @@ define([
// only call mediaCommentReady if we are not doing js uploader
mediaCommentReady();
}
}, 'mediaCommentRecordAsyncChunk')
} // End of init function
$(document).ready(function() {
$(document).bind('reset_media_comment_forms', function() {
$("#audio_record_holder_message,#video_record_holder_message").removeClass('saving')

View File

@ -37,7 +37,7 @@ module SubmissionsCommon
def open_media_comment_dialog
move_to_click('.media_comment_link')
# swf and stuff loads, give it a sec to do its thing
sleep 0.5
expect(f('#media_record_tabs')).to be_displayed
end
def submit_media_comment_1