diff --git a/lib/editor/atto/plugins/kalturamedia/lang/en/atto_kalturamedia.php b/lib/editor/atto/plugins/kalturamedia/lang/en/atto_kalturamedia.php
index 9021aef7..38cc855f 100644
--- a/lib/editor/atto/plugins/kalturamedia/lang/en/atto_kalturamedia.php
+++ b/lib/editor/atto/plugins/kalturamedia/lang/en/atto_kalturamedia.php
@@ -27,3 +27,4 @@
$string['embedbuttontext'] = 'Embed';
$string['browse_and_embed'] = 'Browse and Embed';
$string['privacy:metadata'] = 'The atto_kalturamedia plugin does not store any personal data.';
+$string['kalturamedia:view'] = 'Permission to use Embed Kaltura Media atto plugin';
diff --git a/lib/editor/atto/plugins/kalturamedia/lib.php b/lib/editor/atto/plugins/kalturamedia/lib.php
index b40b177a..8491f30a 100644
--- a/lib/editor/atto/plugins/kalturamedia/lib.php
+++ b/lib/editor/atto/plugins/kalturamedia/lib.php
@@ -39,8 +39,11 @@ function atto_kalturamedia_params_for_js($elementid, $options, $fpoptions) {
if (!$context) {
$context = context_system::instance();
}
-
+
+ $active = has_capability('atto/kalturamedia:view', $context);
+
return array(
+ 'active' => $active,
'contextid' => $context->id,
'kafuri' => local_kaltura_get_config()->kaf_uri
);
diff --git a/lib/editor/atto/plugins/kalturamedia/version.php b/lib/editor/atto/plugins/kalturamedia/version.php
index ebb6728a..d25f5ffa 100644
--- a/lib/editor/atto/plugins/kalturamedia/version.php
+++ b/lib/editor/atto/plugins/kalturamedia/version.php
@@ -24,7 +24,7 @@
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2021051701; // The current plugin version (Date: YYYYMMDDXX).
+$plugin->version = 2021051702; // The current plugin version (Date: YYYYMMDDXX).
$plugin->release = 'Kaltura release 4.3.1';
$plugin->requires = 2018120300; // Requires this Moodle version.
$plugin->component = 'atto_kalturamedia'; // Full name of the plugin (used for diagnostics).
diff --git a/lib/editor/atto/plugins/kalturamedia/yui/build/moodle-atto_kalturamedia-button/moodle-atto_kalturamedia-button-debug.js b/lib/editor/atto/plugins/kalturamedia/yui/build/moodle-atto_kalturamedia-button/moodle-atto_kalturamedia-button-debug.js
index 2d22a45c..2d4b233e 100644
--- a/lib/editor/atto/plugins/kalturamedia/yui/build/moodle-atto_kalturamedia-button/moodle-atto_kalturamedia-button-debug.js
+++ b/lib/editor/atto/plugins/kalturamedia/yui/build/moodle-atto_kalturamedia-button/moodle-atto_kalturamedia-button-debug.js
@@ -1,155 +1,166 @@
YUI.add('moodle-atto_kalturamedia-button', function (Y, NAME) {
-// This file is part of Moodle - http://moodle.org/
-//
-// Moodle is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Moodle is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Moodle. If not, see .
-
-/*
- * @package atto_kalturamedia
- * @copyright 2Kaltura
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-/**
- * @module moodle-atto_kalturamedia-button
- */
-
-/**
- * Atto text editor kalturamedia plugin.
- *
- * @namespace M.atto_kalturamedia
- * @class button
- * @extends M.editor_atto.EditorPlugin
- */
-
-var COMPONENTNAME = 'atto_kalturamedia',
- CSS = {
- URLINPUT: 'atto_kalturamedia_urlentry',
- NAMEINPUT: 'atto_kalturamedia_nameentry'
- },
- SELECTORS = {
- URLINPUT: '.' + CSS.URLINPUT,
- NAMEINPUT: '.' + CSS.NAMEINPUT
- };
-
-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;
- }
-
- 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 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;
-
- if (window.focus) {
- newWindow.focus();
- }
-
- this.embedWindow = newWindow;
- },
-
- _getIframeURL: function() {
-
- 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?' +
- 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)
- {
- var parts = classes[i].split('-');
- courseId = parts[1];
- }
- }
-
- return courseId;
- },
-
- _removeProtocolFromUrl: function(fullUrl) {
- return fullUrl.replace(/^https?:\/\//,'');
- },
-
- embedItem: function(what, data) {
- var sourceUrl = data.url;
- var url = this._removeProtocolFromUrl(sourceUrl);
- var parser = document.createElement('a');
- parser.href = sourceUrl;
- url += parser.search;
-
- var content = 'tinymce-kalturamedia-embed||'+data.title+'||'+data.width+'||'+data.height+'';
-
- 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
- }
- }}
-);
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see .
+
+/*
+ * @package atto_kalturamedia
+ * @copyright 2Kaltura
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+/**
+ * @module moodle-atto_kalturamedia-button
+ */
+
+/**
+ * Atto text editor kalturamedia plugin.
+ *
+ * @namespace M.atto_kalturamedia
+ * @class button
+ * @extends M.editor_atto.EditorPlugin
+ */
+
+var COMPONENTNAME = 'atto_kalturamedia',
+ CSS = {
+ URLINPUT: 'atto_kalturamedia_urlentry',
+ NAMEINPUT: 'atto_kalturamedia_nameentry'
+ },
+ SELECTORS = {
+ URLINPUT: '.' + CSS.URLINPUT,
+ NAMEINPUT: '.' + CSS.NAMEINPUT
+ };
+
+Y.namespace('M.atto_kalturamedia').Button = Y.Base.create('button', Y.M.editor_atto.EditorPlugin, [], {
+ _currentSelection: null,
+ embedWindow: null,
+
+ initializer: function() {
+ if (this.get('active')) {
+ 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 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);
+
+ window.buttonJs = this;
+
+ if (window.focus) {
+ newWindow.focus();
+ }
+
+ this.embedWindow = newWindow;
+ },
+
+ _getIframeURL: function() {
+
+ 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?' +
+ 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)
+ {
+ var parts = classes[i].split('-');
+ courseId = parts[1];
+ }
+ }
+
+ return courseId;
+ },
+
+ _removeProtocolFromUrl: function(fullUrl) {
+ return fullUrl.replace(/^https?:\/\//,'');
+ },
+
+ embedItem: function(what, data) {
+ var sourceUrl = data.url;
+ var url = this._removeProtocolFromUrl(sourceUrl);
+ var parser = document.createElement('a');
+ parser.href = sourceUrl;
+ url += parser.search;
+
+ var content = 'tinymce-kalturamedia-embed||'+data.title+'||'+data.width+'||'+data.height+'';
+
+ host = this.get('host');
+ host.setSelection(this._currentSelection);
+ host.insertContentAtFocusPoint(content);
+ this.markUpdated();
+ this.embedWindow.close();
+ }
+
+ } , {
+ ATTRS: {
+ /**
+ * Whether the button should be active.
+ *
+ * @attribute active
+ * @type Boolean
+ */
+ active: {
+ value: false
+ },
+ /**
+ * 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
+ }
+ }}
+);
}, '@VERSION@', {"requires": ["moodle-editor_atto-plugin"]});
diff --git a/lib/editor/atto/plugins/kalturamedia/yui/build/moodle-atto_kalturamedia-button/moodle-atto_kalturamedia-button-min.js b/lib/editor/atto/plugins/kalturamedia/yui/build/moodle-atto_kalturamedia-button/moodle-atto_kalturamedia-button-min.js
index 196c77e7..d7e4d614 100644
--- a/lib/editor/atto/plugins/kalturamedia/yui/build/moodle-atto_kalturamedia-button/moodle-atto_kalturamedia-button-min.js
+++ b/lib/editor/atto/plugins/kalturamedia/yui/build/moodle-atto_kalturamedia-button/moodle-atto_kalturamedia-button-min.js
@@ -1 +1 @@
-YUI.add("moodle-atto_kalturamedia-button",function(e,t){var n="atto_kalturamedia",r={URLINPUT:"atto_kalturamedia_urlentry",NAMEINPUT:"atto_kalturamedia_nameentry"},s={URLINPUT:"."+r.URLINPUT,NAMEINPUT:"."+r.NAMEINPUT};e.namespace("M.atto_kalturamedia").Button=e.Base.create("button",e.M.editor_atto.EditorPlugin,[],{_currentSelection:null,embedWindow:null,initializer:function(){this.addButton({icon:"icon",iconComponent:n,callback:this._kalturamedia})},_kalturamedia:function(){this._currentSelection=this.get("host").getSelection();if(this._currentSelection===!1)return;var e=1200,t=700,r=window.screenLeft!=undefined?window.screenLeft:screen.left,i=window.screenTop!=undefined?window.screenTop:screen.top,s=window.innerWidth?window.innerWidth:document.documentElement.clientWidth?document.documentElement.clientWidth:screen.width,o=window.innerHeight?window.innerHeight:document.documentElement.clientHeight?document.documentElement.clientHeight:screen.height,u=s/2-e/2+r,a=o/2-t/2+i,f=window.open(this._getIframeURL(),M.util.get_string("browse_and_embed",n),"scrollbars=no, width="+e+", height="+t+", top="+a+", left="+u);window.buttonJs=this,window.focus&&f.focus(),this.embedWindow=f},_getIframeURL:function(){var t=e.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?"+e.QueryString.stringify(t)},_getCourseId:function(){var e,t=document.getElementsByTagName("body")[0].className,n=t.split(" ");for(i in n)if(n[i].indexOf("course-")>-1){var r=n[i].split("-");e=r[1]}return e},_removeProtocolFromUrl:function(e){return e.replace(/^https?:\/\//,"")},embedItem:function(e,t){var n=t.url,r=this._removeProtocolFromUrl(n),i=document.createElement("a");i.href=n,r+=i.search;var s='tinymce-kalturamedia-embed||'+t.title+"||"+t.width+"||"+t.height+"";host=this.get("host"),host.setSelection(this._currentSelection),host.insertContentAtFocusPoint(s),this.markUpdated(),this.embedWindow.close()}},{ATTRS:{contextid:{value:null},kafuri:{value:null}}})},"@VERSION@",{requires:["moodle-editor_atto-plugin"]});
+YUI.add("moodle-atto_kalturamedia-button",function(t,e){var a="atto_kalturamedia";t.namespace("M.atto_kalturamedia").Button=t.Base.create("button",t.M.editor_atto.EditorPlugin,[],{_currentSelection:null,embedWindow:null,initializer:function(){this.get("active")&&this.addButton({icon:"icon",iconComponent:a,callback:this._kalturamedia})},_kalturamedia:function(){var e,t,i,n,o,r,d;this._currentSelection=this.get("host").getSelection(),!1!==this._currentSelection&&(e=1200,t=700,i=window.screenLeft!=undefined?window.screenLeft:screen.left,n=window.screenTop!=undefined?window.screenTop:screen.top,o=(window.innerWidth?window.innerWidth:document.documentElement.clientWidth?document.documentElement.clientWidth:screen.width)/2-e/2+i,r=(window.innerHeight?window.innerHeight:document.documentElement.clientHeight?document.documentElement.clientHeight:screen.height)/2-t/2+n,d=window.open(this._getIframeURL(),M.util.get_string("browse_and_embed",a),"scrollbars=no, width="+e+", height="+t+", top="+r+", left="+o),window.buttonJs=this,window.focus&&d.focus(),this.embedWindow=d)},_getIframeURL:function(){var e=t.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?"+t.QueryString.stringify(e)},_getCourseId:function(){var e,t=document.getElementsByTagName("body")[0].className,n=t.split(" ");for(i in n)-1tinymce-kalturamedia-embed||'+t.title+"||"+t.width+"||"+t.height+"",host=this.get("host"),host.setSelection(this._currentSelection),host.insertContentAtFocusPoint(i),this.markUpdated(),this.embedWindow.close()}},{ATTRS:{active:{value:!1},contextid:{value:null},kafuri:{value:null}}})},"@VERSION@",{requires:["moodle-editor_atto-plugin"]});
\ No newline at end of file
diff --git a/lib/editor/atto/plugins/kalturamedia/yui/build/moodle-atto_kalturamedia-button/moodle-atto_kalturamedia-button.js b/lib/editor/atto/plugins/kalturamedia/yui/build/moodle-atto_kalturamedia-button/moodle-atto_kalturamedia-button.js
index 2d22a45c..2d4b233e 100644
--- a/lib/editor/atto/plugins/kalturamedia/yui/build/moodle-atto_kalturamedia-button/moodle-atto_kalturamedia-button.js
+++ b/lib/editor/atto/plugins/kalturamedia/yui/build/moodle-atto_kalturamedia-button/moodle-atto_kalturamedia-button.js
@@ -1,155 +1,166 @@
YUI.add('moodle-atto_kalturamedia-button', function (Y, NAME) {
-// This file is part of Moodle - http://moodle.org/
-//
-// Moodle is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Moodle is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Moodle. If not, see .
-
-/*
- * @package atto_kalturamedia
- * @copyright 2Kaltura
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-/**
- * @module moodle-atto_kalturamedia-button
- */
-
-/**
- * Atto text editor kalturamedia plugin.
- *
- * @namespace M.atto_kalturamedia
- * @class button
- * @extends M.editor_atto.EditorPlugin
- */
-
-var COMPONENTNAME = 'atto_kalturamedia',
- CSS = {
- URLINPUT: 'atto_kalturamedia_urlentry',
- NAMEINPUT: 'atto_kalturamedia_nameentry'
- },
- SELECTORS = {
- URLINPUT: '.' + CSS.URLINPUT,
- NAMEINPUT: '.' + CSS.NAMEINPUT
- };
-
-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;
- }
-
- 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 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;
-
- if (window.focus) {
- newWindow.focus();
- }
-
- this.embedWindow = newWindow;
- },
-
- _getIframeURL: function() {
-
- 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?' +
- 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)
- {
- var parts = classes[i].split('-');
- courseId = parts[1];
- }
- }
-
- return courseId;
- },
-
- _removeProtocolFromUrl: function(fullUrl) {
- return fullUrl.replace(/^https?:\/\//,'');
- },
-
- embedItem: function(what, data) {
- var sourceUrl = data.url;
- var url = this._removeProtocolFromUrl(sourceUrl);
- var parser = document.createElement('a');
- parser.href = sourceUrl;
- url += parser.search;
-
- var content = 'tinymce-kalturamedia-embed||'+data.title+'||'+data.width+'||'+data.height+'';
-
- 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
- }
- }}
-);
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see .
+
+/*
+ * @package atto_kalturamedia
+ * @copyright 2Kaltura
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+/**
+ * @module moodle-atto_kalturamedia-button
+ */
+
+/**
+ * Atto text editor kalturamedia plugin.
+ *
+ * @namespace M.atto_kalturamedia
+ * @class button
+ * @extends M.editor_atto.EditorPlugin
+ */
+
+var COMPONENTNAME = 'atto_kalturamedia',
+ CSS = {
+ URLINPUT: 'atto_kalturamedia_urlentry',
+ NAMEINPUT: 'atto_kalturamedia_nameentry'
+ },
+ SELECTORS = {
+ URLINPUT: '.' + CSS.URLINPUT,
+ NAMEINPUT: '.' + CSS.NAMEINPUT
+ };
+
+Y.namespace('M.atto_kalturamedia').Button = Y.Base.create('button', Y.M.editor_atto.EditorPlugin, [], {
+ _currentSelection: null,
+ embedWindow: null,
+
+ initializer: function() {
+ if (this.get('active')) {
+ 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 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);
+
+ window.buttonJs = this;
+
+ if (window.focus) {
+ newWindow.focus();
+ }
+
+ this.embedWindow = newWindow;
+ },
+
+ _getIframeURL: function() {
+
+ 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?' +
+ 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)
+ {
+ var parts = classes[i].split('-');
+ courseId = parts[1];
+ }
+ }
+
+ return courseId;
+ },
+
+ _removeProtocolFromUrl: function(fullUrl) {
+ return fullUrl.replace(/^https?:\/\//,'');
+ },
+
+ embedItem: function(what, data) {
+ var sourceUrl = data.url;
+ var url = this._removeProtocolFromUrl(sourceUrl);
+ var parser = document.createElement('a');
+ parser.href = sourceUrl;
+ url += parser.search;
+
+ var content = 'tinymce-kalturamedia-embed||'+data.title+'||'+data.width+'||'+data.height+'';
+
+ host = this.get('host');
+ host.setSelection(this._currentSelection);
+ host.insertContentAtFocusPoint(content);
+ this.markUpdated();
+ this.embedWindow.close();
+ }
+
+ } , {
+ ATTRS: {
+ /**
+ * Whether the button should be active.
+ *
+ * @attribute active
+ * @type Boolean
+ */
+ active: {
+ value: false
+ },
+ /**
+ * 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
+ }
+ }}
+);
}, '@VERSION@', {"requires": ["moodle-editor_atto-plugin"]});
diff --git a/lib/editor/atto/plugins/kalturamedia/yui/src/button/js/button.js b/lib/editor/atto/plugins/kalturamedia/yui/src/button/js/button.js
index 146ce934..80fcdd7c 100644
--- a/lib/editor/atto/plugins/kalturamedia/yui/src/button/js/button.js
+++ b/lib/editor/atto/plugins/kalturamedia/yui/src/button/js/button.js
@@ -46,11 +46,13 @@ Y.namespace('M.atto_kalturamedia').Button = Y.Base.create('button', Y.M.editor_a
embedWindow: null,
initializer: function() {
- this.addButton({
- icon: 'icon',
- iconComponent: COMPONENTNAME,
- callback: this._kalturamedia
- });
+ if (this.get('active')) {
+ this.addButton({
+ icon: 'icon',
+ iconComponent: COMPONENTNAME,
+ callback: this._kalturamedia
+ });
+ }
},
_kalturamedia: function() {
this._currentSelection = this.get('host').getSelection();
@@ -130,6 +132,15 @@ Y.namespace('M.atto_kalturamedia').Button = Y.Base.create('button', Y.M.editor_a
} , {
ATTRS: {
+ /**
+ * Whether the button should be active.
+ *
+ * @attribute active
+ * @type Boolean
+ */
+ active: {
+ value: false
+ },
/**
* The contextid to use when generating this preview.
*