Skip to content

Commit

Permalink
Merge branch 'MOODLE_37_DEV' of https://github.com/kaltura/moodle_plugin
Browse files Browse the repository at this point in the history
 into MOODLE_37_DEV
  • Loading branch information
noychn-kaltura committed Jul 8, 2019
2 parents 9789f68 + 2d83243 commit ff9fd50
Show file tree
Hide file tree
Showing 10 changed files with 209 additions and 189 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
var buttonJs = window.opener.buttonJs;
var embedButton = Y.Node.create('<button></button>');
embedButton.setAttribute('id', 'KalturaMediaSubmit');
embedButton.setAttribute('class', 'btn btn-primary');
embedButton.setAttribute('disabled', 'disabled');
embedButton.setHTML("<?php echo get_string('embedbuttontext', 'atto_kalturamedia'); ?>");
embedButton.hide();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,123 +44,121 @@ var COMPONENTNAME = 'atto_kalturamedia',
};

Y.namespace('M.atto_kalturamedia').Button = Y.Base.create('button', Y.M.editor_atto.EditorPlugin, [], {
_currentSelection: null,
embedWindow: null,

initializer: function() {
this.addButton({
icon: 'icon',
iconComponent: COMPONENTNAME,
callback: this._kalturamedia
});
},
_kalturamedia: function() {
this._currentSelection = this.get('host').getSelection();
if (this._currentSelection === false) {
return;
}
_currentSelection: null,
embedWindow: null,

initializer: function() {
this.addButton({
icon: 'icon',
iconComponent: COMPONENTNAME,
callback: this._kalturamedia
});
},
_kalturamedia: function() {
this._currentSelection = this.get('host').getSelection();
if (this._currentSelection === false) {
return;
}

var w = 1200;
var h = 700;
var dualScreenLeft = window.screenLeft != undefined ? window.screenLeft : screen.left;
var dualScreenTop = window.screenTop != undefined ? window.screenTop : screen.top;
var w = 1200;
var h = 700;
var dualScreenLeft = window.screenLeft != undefined ? window.screenLeft : screen.left;
var dualScreenTop = window.screenTop != undefined ? window.screenTop : screen.top;

var width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : screen.width;
var height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : screen.height;
var width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : screen.width;
var height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : screen.height;

var left = ((width / 2) - (w / 2)) + dualScreenLeft;
var top = ((height / 2) - (h / 2)) + dualScreenTop;
var newWindow = window.open(this._getIframeURL(), M.util.get_string("browse_and_embed", COMPONENTNAME), 'scrollbars=no, width=' + w + ', height=' + h + ', top=' + top + ', left=' + left);
var left = ((width / 2) - (w / 2)) + dualScreenLeft;
var top = ((height / 2) - (h / 2)) + dualScreenTop;
var newWindow = window.open(this._getIframeURL(), M.util.get_string("browse_and_embed", COMPONENTNAME), 'scrollbars=no, width=' + w + ', height=' + h + ', top=' + top + ', left=' + left);

window.buttonJs = this;
window.buttonJs = this;

if (window.focus) {
newWindow.focus();
}
if (window.focus) {
newWindow.focus();
}

this.embedWindow = newWindow;
},
this.embedWindow = newWindow;
},

_getIframeURL: function() {
_getIframeURL: function() {

var args = Y.mix({
var args = Y.mix({
elementid: this.get('host').get('elementid'),
contextid: this.get('contextid'),
height: '600px',
width: '1112px'
},
this.get('area'));
return M.cfg.wwwroot + '/lib/editor/atto/plugins/kalturamedia/ltibrowse_container.php?' +
return M.cfg.wwwroot + '/lib/editor/atto/plugins/kalturamedia/ltibrowse_container.php?' +
Y.QueryString.stringify(args);
},
},

_getCourseId: function() {
var courseId;
var bodyClasses = document.getElementsByTagName('body')[0].className;
var classes = bodyClasses.split(' ');
for(i in classes)
{
if(classes[i].indexOf('course-') > -1)
_getCourseId: function() {
var courseId;
var bodyClasses = document.getElementsByTagName('body')[0].className;
var classes = bodyClasses.split(' ');
for(i in classes)
{
if(classes[i].indexOf('course-') > -1)
{
var parts = classes[i].split('-');
courseId = parts[1];
}
}
}

return courseId;
},
return courseId;
},

_removeProtocolFromUrl: function(fullUrl) {
return fullUrl.replace(/^https?:\/\//,'');
},
_removeProtocolFromUrl: function(fullUrl) {
return fullUrl.replace(/^https?:\/\//,'');
},

embedItem: function(what, data) {
var embedInfo = {};
for(param in data)
{
var isEmbedInfo = param.split('-');
if(isEmbedInfo[0] == 'embedinfo')
embedItem: function(what, data) {
var embedInfo = {};
for(param in data)
{
embedInfo[isEmbedInfo[1]] = data[param];
var isEmbedInfo = param.split('-');
if(isEmbedInfo[0] == 'embedinfo')
{
embedInfo[isEmbedInfo[1]] = data[param];
}
}
}

var kafUri = this.get('kafuri');
var sourceUrl = embedInfo.url;
var url = this._removeProtocolFromUrl(kafUri);
url = sourceUrl.replace(kafUri, url);
var parser = document.createElement('a');
parser.href = sourceUrl;
url += parser.search;

var content = '<a href="http://'+url+'">tinymce-kalturamedia-embed||'+embedInfo.title+'||'+embedInfo.width+'||'+embedInfo.height+'</a>';

host = this.get('host');
host.setSelection(this._currentSelection);
host.insertContentAtFocusPoint(content);
this.markUpdated();
this.embedWindow.close();
}

} , {
ATTRS: {
/**
* The contextid to use when generating this preview.
*
* @attribute contextid
* @type String
*/
contextid: {
value: null
},
var sourceUrl = embedInfo.url;
var url = this._removeProtocolFromUrl(sourceUrl);
var parser = document.createElement('a');
parser.href = sourceUrl;
url += parser.search;

/**
* The KAF URI, as configured in Kaltura's plugin settings.
*/
kafuri: {
value: null
var content = '<a href="http://'+url+'">tinymce-kalturamedia-embed||'+embedInfo.title+'||'+embedInfo.width+'||'+embedInfo.height+'</a>';

host = this.get('host');
host.setSelection(this._currentSelection);
host.insertContentAtFocusPoint(content);
this.markUpdated();
this.embedWindow.close();
}
}}

} , {
ATTRS: {
/**
* The contextid to use when generating this preview.
*
* @attribute contextid
* @type String
*/
contextid: {
value: null
},

/**
* The KAF URI, as configured in Kaltura's plugin settings.
*/
kafuri: {
value: null
}
}}
);


Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit ff9fd50

Please sign in to comment.