MDL-14741: Removing the old moodleimage plugin - the TinyMCE builtin plugin does the same.

This commit is contained in:
scyrma
2008-07-31 03:18:40 +00:00
parent a4c36bdca6
commit ba44f12571
9 changed files with 1 additions and 994 deletions
+1 -1
View File
@@ -178,7 +178,7 @@ echo <<<EOF
entity_encoding: "raw",
language: "$editorlanguage",
directionality: "$directionality",
plugins: "safari,spellchecker,table,style,layer,advhr,advimage,advlink,emoticons,inlinepopups,media,searchreplace,paste,standardmenu,directionality,fullscreen,moodleimage,moodlelink,moodlenolink,dragmath,nonbreaking,contextmenu",
plugins: "safari,spellchecker,table,style,layer,advhr,advimage,advlink,emoticons,inlinepopups,media,searchreplace,paste,standardmenu,directionality,fullscreen,moodlelink,moodlenolink,dragmath,nonbreaking,contextmenu",
theme_advanced_layout_manager: "SimpleLayout",
theme_advanced_toolbar_align : "left",
theme_advanced_buttons1: "fontselect,fontsizeselect,formatselect,styleselect",
@@ -1 +0,0 @@
(function(){tinymce.create('tinymce.plugins.MoodleImagePlugin',{init:function(ed,url){course_id=tinyMCE.activeEditor.getParam('moodleimage_course_id');ed.addCommand('mceMoodleImage',function(){ed.windowManager.open({file:url+'/insert_image.php?id='+course_id,width:600+ed.getLang('example.delta_width',0),height:500+ed.getLang('example.delta_height',0),inline:1},{plugin_url:url,some_custom_arg:'custom arg'});});ed.addButton('moodleimage',{title:'Insert Image',cmd:'mceMoodleImage',image:url+'/img/image.gif'});ed.onNodeChange.add(function(ed,cm,n){cm.setActive('moodleimage',n.nodeName=='IMG');});},createControl:function(n,cm){return null;},getInfo:function(){return{longname:'Moodle Image plugin',author:'Glen Davies',authorurl:'http://www.canterbury.ac.nz',infourl:'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/example',version:"1.0"};}});tinymce.PluginManager.add('moodleimage',tinymce.plugins.MoodleImagePlugin);})();
@@ -1,78 +0,0 @@
(function() {
// Load plugin specific language pack
//tinymce.PluginManager.requireLangPack('example');
tinymce.create('tinymce.plugins.MoodleImagePlugin', {
/**
* Initializes the plugin, this will be executed after the plugin has been created.
* This call is done before the editor instance has finished it's initialization so use the onInit event
* of the editor instance to intercept that event.
*
* @param {tinymce.Editor} ed Editor instance that the plugin is initialized in.
* @param {string} url Absolute URL to where the plugin is located.
*/
init : function(ed, url) {
// Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('mceExample');
course_id = tinyMCE.activeEditor.getParam('moodleimage_course_id');
ed.addCommand('mceMoodleImage', function() {
ed.windowManager.open({
file : url + '/insert_image.php?id=' + course_id,
//file : '/moodle/lib/editor/htmlarea/popups/insert_image.php?id=' + course_id,
width : 600 + ed.getLang('example.delta_width', 0),
height : 500 + ed.getLang('example.delta_height', 0),
inline : 1
}, {
plugin_url : url, // Plugin absolute URL
some_custom_arg : 'custom arg' // Custom argument
});
});
// Register example button
ed.addButton('moodleimage', {
title : 'Insert Image',
cmd : 'mceMoodleImage',
image : url + '/img/image.gif'
});
// Add a node change handler, selects the button in the UI when a image is selected
ed.onNodeChange.add(function(ed, cm, n) {
cm.setActive('moodleimage', n.nodeName == 'IMG');
});
},
/**
* Creates control instances based in the incomming name. This method is normally not
* needed since the addButton method of the tinymce.Editor class is a more easy way of adding buttons
* but you sometimes need to create more complex controls like listboxes, split buttons etc then this
* method can be used to create those.
*
* @param {String} n Name of the control to create.
* @param {tinymce.ControlManager} cm Control manager to use inorder to create new control.
* @return {tinymce.ui.Control} New control instance or null if no control was created.
*/
createControl : function(n, cm) {
return null;
},
/**
* Returns information about the plugin as a name/value array.
* The current keys are longname, author, authorurl, infourl and version.
*
* @return {Object} Name/value array containing information about the plugin.
*/
getInfo : function() {
return {
longname : 'Moodle Image plugin',
author : 'Glen Davies',
authorurl : 'http://www.canterbury.ac.nz',
infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/example',
version : "1.0"
};
}
});
// Register plugin
tinymce.PluginManager.add('moodleimage', tinymce.plugins.MoodleImagePlugin);
})();
Binary file not shown.

Before

Width:  |  Height:  |  Size: 156 B

@@ -1,294 +0,0 @@
<?php // $Id$
require("../../../../../../../config.php");
if (!empty($_SESSION['id'])) {
$id = optional_param('id', $_SESSION['id'], PARAM_INT);
} else {
$id = optional_param('id', SITEID, PARAM_INT);
}
require_login($id);
require_capability('moodle/course:managefiles', get_context_instance(CONTEXT_COURSE, $id));
@header('Content-Type: text/html; charset=utf-8');
$upload_max_filesize = get_max_upload_file_size($CFG->maxbytes);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>{#moodleimage_dlg.title}</title>
<script type="text/javascript" src="../../tiny_mce_popup.js"></script>
<script type="text/javascript" src="../../utils/form_utils.js"></script>
<script type="text/javascript" src="js/moodleimage.js"></script>
<base target="_self" />
<script type="text/javascript">
//<![CDATA[
var preview_window = null;
function onPreview() {
var f_url = document.getElementById("f_url");
var url = f_url.value;
if (!url) {
alert("<?php print_string("enterurlfirst","editor");?>");
f_url.focus();
return false;
}
var img = new Image();
img.src = url;
var win = null;
if (!document.all) {
win = window.open("about:blank", "ha_imgpreview", "toolbar=no,menubar=no,personalbar=no,innerWidth=100,innerHeight=100,scrollbars=no,resizable=yes");
} else {
win = window.open("about:blank", "ha_imgpreview", "channelmode=no,directories=no,height=100,width=100,location=no,menubar=no,resizable=yes,scrollbars=no,toolbar=no");
}
preview_window = win;
var doc = win.document;
var body = doc.body;
if (body) {
body.innerHTML = "";
body.style.padding = "0px";
body.style.margin = "0px";
var el = doc.createElement("img");
el.src = url;
var table = doc.createElement("table");
body.appendChild(table);
table.style.width = "100%";
table.style.height = "100%";
var tbody = doc.createElement("tbody");
table.appendChild(tbody);
var tr = doc.createElement("tr");
tbody.appendChild(tr);
var td = doc.createElement("td");
tr.appendChild(td);
td.style.textAlign = "center";
td.appendChild(el);
win.resizeTo(el.offsetWidth + 30, el.offsetHeight + 30);
}
win.focus();
return false;
};
function checkvalue(elm,formname) {
var el = document.getElementById(elm);
if(!el.value) {
alert("Nothing to do!");
el.focus();
return false;
}
}
function submit_form(dothis) {
if(dothis == "delete") {
window.ibrowser.document.dirform.action.value = "delete";
}
if(dothis == "move") {
window.ibrowser.document.dirform.action.value = "move";
}
if(dothis == "zip") {
window.ibrowser.document.dirform.action.value = "zip";
}
window.ibrowser.document.dirform.submit();
return false;
}
//]]>
</script>
<style type="text/css">
html, body {
margin: 2px;
background-color: #F0F0EE;
font-size: 11px;
}
.title {
background-color: #ddddff;
padding: 5px;
border-bottom: 1px solid black;
font-family: Tahoma, sans-serif;
font-weight: bold;
font-size: 14px;
color: black;
}
td, input, select, button {
font-family: Tahoma, Verdana, sans-serif;
font-size: 11px;
}
button { width: 70px; }
.space { padding: 2px; }
form { margin-bottom: 0px; margin-top: 0px; }
</style>
</head>
<body>
<form action="" method="get" id="first">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="15%" align="right"><?php print_string("imageurl","editor");?>:</td>
<td width="60%"><input name="f_url" type="text" id="f_url" style="width: 100%;" /></td>
<td width="23%" align="center">
<button name="btnOK" type="button" id="btnOK" onclick="return MoodleImageDialog.insert();"><?php print_string("ok","editor") ?></button></td>
</tr>
<tr>
<td align="right"><?php print_string("alternatetext","editor");?>:</td>
<td><input name="f_alt" type="text" id="f_alt" style="width: 100%;" /></td>
<td align="center">
<button name="btnCancel" type="button" id="btnCancel" onclick="return tinyMCEPopup.close();"><?php print_string("cancel","editor") ?></button></td>
</tr>
</table>
<div class="space"></div>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="32%" valign="top">
<fieldset style="height:60px"><legend><?php print_string("layout","editor");?></legend>
<div class="space"></div>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="40%" align="right"><?php print_string("alignment","editor");?>:</td>
<td width="60%">
<select size="1" name="f_align" id="f_align"
title="Positioning of this image">
<option value="" ><?php print_string("notset","editor") ?></option>
<option value="left" ><?php print_string("left","editor") ?></option>
<option value="right" ><?php print_string("right","editor") ?></option>
<option value="texttop" ><?php print_string("texttop","editor") ?></option>
<option value="middle" ><?php print_string("middle","editor") ?></option>
<option value="baseline" selected="1" ><?php print_string("baseline","editor") ?></option>
<option value="absbottom" ><?php print_string("absbottom","editor") ?></option>
<option value="bottom" ><?php print_string("bottom","editor") ?></option>
<option value="middle" ><?php print_string("middle","editor") ?></option>
<option value="top" ><?php print_string("top","editor") ?></option>
</select></td>
</tr>
<tr>
<td width="40%" align="right"><?php print_string("borderthickness","editor") ?>:</td>
<td width="60%">
<input type="text" id="f_border" name="f_border" size="5" /></td>
</tr>
</table><div class="space"></div>
</fieldset>&nbsp;</td>
<td width="34%" valign="top">
<fieldset style="height:60px"><legend><?php print_string("spacing","editor");?></legend>
<div class="space"></div>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="40%" align="right"><?php print_string("horizontal","editor");?>: </td>
<td width="60%">
<input name="f_horiz" type="text" id="f_horiz" size="5" />
</td>
</tr>
<tr>
<td width="40%" align="right"><?php print_string("vertical","editor");?>:</td>
<td width="60%">
<input name="f_vert" type="text" id="f_vert" size="5" /></td>
</tr>
</table><div class="space"></div></fieldset></td>
<td width="34%" valign="top">
<fieldset style="height:60px"><legend><?php print_string("size","editor");?></legend>
<div class="space"></div>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="40%" align="right"><?php print_string("width","editor");?>:</td>
<td width="60%">
<input name="f_width" type="text" id="f_width" size="5" />
</td>
</tr>
<tr>
<td width="40%" align="right"><?php print_string("height","editor");?>:</td>
<td width="60%">
<input name="f_height" type="text" id="f_height" size="5" />
</td>
</tr>
</table><div class="space"></div>
</fieldset></td>
</tr>
</table></form>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="55%" valign="top"><?php
print_string("filebrowser","editor");
echo "<br />";
echo "<iframe id=\"ibrowser\" name=\"ibrowser\" src=\"{$CFG->httpswwwroot}/lib/editor/tinymce/coursefiles.php?usecheckboxes=1&id=$id\" style=\"width: 100%; height: 200px;\"></iframe>";
?>
</td>
<td width="45%" valign="top"><?php print_string("preview","editor");?>:<br />
<iframe id="ipreview" name="ipreview" src="about:blank" style="width: 100%; height: 200px;"></iframe>
</td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="55%"><div class="space"></div>
<?php if(has_capability('moodle/course:managefiles', get_context_instance(CONTEXT_COURSE, $id))) { ?>
<table border="0" cellpadding="2" cellspacing="0">
<tr><td><?php print_string("selection","editor");?>: </td>
<td><form id="idelete">
<input name="btnDelete" type="submit" id="btnDelete" value="<?php print_string("delete","editor");?>" onclick="return submit_form('delete');" /></form></td>
<td><form id="imove">
<input name="btnMove" type="submit" id="btnMove" value="<?php print_string("move","editor");?>" onclick="return submit_form('move');" /></td>
<td><form id="izip">
<input name="btnZip" type="submit" id="btnZip" value="<?php print_string("zip","editor");?>" onclick="return submit_form('zip');" /></form></td>
<td><form method="post" action="../../../coursefiles.php" target="ibrowser">
<input type="hidden" name="id" value="<?php print($id);?>" />
<input type="hidden" name="wdir" value="" />
<input type="hidden" id="irename" name="file" value="" />
<input type="hidden" name="action" value="rename" />
<input type="hidden" name="sesskey" value="<?php p($USER->sesskey) ?>" />
<input name="btnRename" type="submit" id="btnRename" value="<?php print_string("rename","editor");?>" /></form></td>
<tr></table>
<br />
<?php
} else {
print "";
} ?>
</td>
<td width="45%" rowspan="2" valign="top"><fieldset>
<legend><?php print_string("properties","editor");?></legend>
<div class="space"></div>
<div class="space"></div>
&nbsp;&nbsp;<?php print_string("size","editor");?>:
<input type="text" id="isize" name="isize" size="10" style="background: transparent; border: none;" />
<?php print_string("type","editor");?>: <input type="text" id="itype" name="itype" size="10" style="background: transparent; border: none;" />
<div class="space"></div>
<div class="space"></div>
</fieldset></td>
</tr>
<tr>
<td height="22">
<form id="cfolder" action="<?php echo $CFG->httpswwwroot;?>/lib/editor/tinymce/coursefiles.php" method="post" target="ibrowser">
<input type="hidden" name="id" value="<?php print($id);?>" />
<input type="hidden" name="wdir" value="" />
<input type="hidden" name="action" value="mkdir" />
<input type="hidden" name="sesskey" value="<?php p($USER->sesskey) ?>" />
<input name="name" type="text" id="foldername" size="35" />
<input name="btnCfolder" type="submit" id="btnCfolder" value="Create_folder" onclick="return checkvalue('foldername','cfolder');" />
</form>
<div class="space"></div>
<form action="<?php echo $CFG->httpswwwroot;?>/lib/editor/tinymce/coursefiles.php?id=<?php print($id);?>" method="post" enctype="multipart/form-data" target="ibrowser" id="uploader">
<input type="hidden" name="MAX_FILE_SIZE" value="<?php print($upload_max_filesize);?>" />
<input type="hidden" name="id" VALUE="<?php print($id);?>" />
<input type="hidden" name="wdir" value="" />
<input type="hidden" name="action" value="upload" />
<input type="hidden" name="sesskey" value="<?php p($USER->sesskey) ?>" />
<input type="file" name="userfile" id="userfile" size="35" />
<input name="save" type="submit" id="save" onclick="return checkvalue('userfile','uploader');" value="<?php print_string("upload","editor");?>" />
</form>
</td>
</tr>
</table>
<p>&nbsp;</p>
</body>
</html>
@@ -1,414 +0,0 @@
var ImageDialog = {
preInit : function() {
var url;
tinyMCEPopup.requireLangPack();
if (url = tinyMCEPopup.getParam("external_image_list_url"))
document.write('<script language="javascript" type="text/javascript" src="' + tinyMCEPopup.editor.documentBaseURI.toAbsolute(url) + '"></script>');
},
init : function(ed) {
var f = document.forms[0], nl = f.elements, ed = tinyMCEPopup.editor, dom = ed.dom, n = ed.selection.getNode();
tinyMCEPopup.resizeToInnerSize();
this.fillClassList('class_list');
this.fillFileList('src_list', 'tinyMCEImageList');
this.fillFileList('over_list', 'tinyMCEImageList');
this.fillFileList('out_list', 'tinyMCEImageList');
if (n.nodeName == 'IMG') {
nl.src.value = dom.getAttrib(n, 'src');
nl.width.value = dom.getAttrib(n, 'width');
nl.height.value = dom.getAttrib(n, 'height');
nl.alt.value = dom.getAttrib(n, 'alt');
nl.title.value = dom.getAttrib(n, 'title');
nl.vspace.value = this.getAttrib(n, 'vspace');
nl.hspace.value = this.getAttrib(n, 'hspace');
nl.border.value = this.getAttrib(n, 'border');
selectByValue(f, 'align', this.getAttrib(n, 'align'));
selectByValue(f, 'class_list', dom.getAttrib(n, 'class'));
nl.style.value = dom.getAttrib(n, 'style');
nl.id.value = dom.getAttrib(n, 'id');
nl.dir.value = dom.getAttrib(n, 'dir');
nl.lang.value = dom.getAttrib(n, 'lang');
nl.usemap.value = dom.getAttrib(n, 'usemap');
nl.longdesc.value = dom.getAttrib(n, 'longdesc');
nl.insert.value = ed.getLang('update');
if (/^\s*this.src\s*=\s*\'([^\']+)\';?\s*$/.test(dom.getAttrib(n, 'onmouseover')))
nl.onmouseoversrc.value = dom.getAttrib(n, 'onmouseover').replace(/^\s*this.src\s*=\s*\'([^\']+)\';?\s*$/, '$1');
if (/^\s*this.src\s*=\s*\'([^\']+)\';?\s*$/.test(dom.getAttrib(n, 'onmouseout')))
nl.onmouseoutsrc.value = dom.getAttrib(n, 'onmouseout').replace(/^\s*this.src\s*=\s*\'([^\']+)\';?\s*$/, '$1');
}
// Setup browse button
document.getElementById('srcbrowsercontainer').innerHTML = getBrowserHTML('srcbrowser','src','image','theme_advanced_image');
if (isVisible('srcbrowser'))
document.getElementById('src').style.width = '260px';
// Setup browse button
document.getElementById('onmouseoversrccontainer').innerHTML = getBrowserHTML('overbrowser','onmouseoversrc','image','theme_advanced_image');
if (isVisible('overbrowser'))
document.getElementById('onmouseoversrc').style.width = '260px';
// Setup browse button
document.getElementById('onmouseoutsrccontainer').innerHTML = getBrowserHTML('outbrowser','onmouseoutsrc','image','theme_advanced_image');
if (isVisible('outbrowser'))
document.getElementById('onmouseoutsrc').style.width = '260px';
// If option enabled default contrain proportions to checked
if (ed.getParam("advimage_constrain_proportions", true))
f.constrain.checked = true;
// Check swap image if valid data
if (nl.onmouseoversrc.value || nl.onmouseoutsrc.value)
this.setSwapImage(true);
else
this.setSwapImage(false);
this.changeAppearance();
this.updateStyle();
this.showPreviewImage(nl.src.value, 1);
},
insert : function(file, title) {
var ed = tinyMCEPopup.editor, t = this, f = document.forms[0];
if (f.src.value === '') {
ed.dom.remove(ed.selection.getNode());
ed.execCommand('mceRepaint');
tinyMCEPopup.close();
return;
}
if (tinyMCEPopup.getParam("accessibility_warnings", 1)) {
if (!f.alt.value) {
tinyMCEPopup.editor.windowManager.confirm(tinyMCEPopup.getLang('advimage_dlg.missing_alt'), function(s) {
if (s)
t.insertAndClose();
});
return;
}
}
t.insertAndClose();
},
insertAndClose : function() {
var ed = tinyMCEPopup.editor, f = document.forms[0], nl = f.elements, v, args = {}, el;
// Fixes crash in Safari
if (tinymce.isWebKit)
ed.getWin().focus();
if (!ed.settings.inline_styles) {
args = tinymce.extend(args, {
vspace : nl.vspace.value,
hspace : nl.hspace.value,
border : nl.border.value,
align : getSelectValue(f, 'align')
});
}
tinymce.extend(args, {
src : nl.src.value,
width : nl.width.value,
height : nl.height.value,
alt : nl.alt.value,
title : nl.title.value,
'class' : getSelectValue(f, 'class_list'),
style : nl.style.value,
id : nl.id.value,
dir : nl.dir.value,
lang : nl.lang.value,
usemap : nl.usemap.value,
longdesc : nl.longdesc.value
});
args.onmouseover = args.onmouseout = '';
if (f.onmousemovecheck.checked) {
if (nl.onmouseoversrc.value)
args.onmouseover = "this.src='" + nl.onmouseoversrc.value + "';";
if (nl.onmouseoutsrc.value)
args.onmouseout = "this.src='" + nl.onmouseoutsrc.value + "';";
}
el = ed.selection.getNode();
if (el && el.nodeName == 'IMG') {
ed.dom.setAttribs(el, args);
} else {
ed.execCommand('mceInsertContent', false, '<img id="__mce_tmp" src="javascript:;" />');
ed.dom.setAttribs('__mce_tmp', args);
ed.dom.setAttrib('__mce_tmp', 'id', '');
}
tinyMCEPopup.close();
},
getAttrib : function(e, at) {
var ed = tinyMCEPopup.editor, dom = ed.dom, v, v2;
if (ed.settings.inline_styles) {
switch (at) {
case 'align':
if (v = dom.getStyle(e, 'float'))
return v;
if (v = dom.getStyle(e, 'vertical-align'))
return v;
break;
case 'hspace':
v = dom.getStyle(e, 'margin-left')
v2 = dom.getStyle(e, 'margin-right');
if (v && v == v2)
return parseInt(v.replace(/[^0-9]/g, ''));
break;
case 'vspace':
v = dom.getStyle(e, 'margin-top')
v2 = dom.getStyle(e, 'margin-bottom');
if (v && v == v2)
return parseInt(v.replace(/[^0-9]/g, ''));
break;
case 'border':
v = 0;
tinymce.each(['top', 'right', 'bottom', 'left'], function(sv) {
sv = dom.getStyle(e, 'border-' + sv + '-width');
// False or not the same as prev
if (!sv || (sv != v && v !== 0)) {
v = 0;
return false;
}
if (sv)
v = sv;
});
if (v)
return parseInt(v.replace(/[^0-9]/g, ''));
break;
}
}
if (v = dom.getAttrib(e, at))
return v;
return '';
},
setSwapImage : function(st) {
var f = document.forms[0];
f.onmousemovecheck.checked = st;
setBrowserDisabled('overbrowser', !st);
setBrowserDisabled('outbrowser', !st);
if (f.over_list)
f.over_list.disabled = !st;
if (f.out_list)
f.out_list.disabled = !st;
f.onmouseoversrc.disabled = !st;
f.onmouseoutsrc.disabled = !st;
},
fillClassList : function(id) {
var dom = tinyMCEPopup.dom, lst = dom.get(id), v, cl;
if (v = tinyMCEPopup.getParam('theme_advanced_styles')) {
cl = [];
tinymce.each(v.split(';'), function(v) {
var p = v.split('=');
cl.push({'title' : p[0], 'class' : p[1]});
});
} else
cl = tinyMCEPopup.editor.dom.getClasses();
if (cl.length > 0) {
lst.options[lst.options.length] = new Option(tinyMCEPopup.getLang('not_set'), '');
tinymce.each(cl, function(o) {
lst.options[lst.options.length] = new Option(o.title || o['class'], o['class']);
});
} else
dom.remove(dom.getParent(id, 'tr'));
},
fillFileList : function(id, l) {
var dom = tinyMCEPopup.dom, lst = dom.get(id), v, cl;
l = window[l];
if (l && l.length > 0) {
lst.options[lst.options.length] = new Option('', '');
tinymce.each(l, function(o) {
lst.options[lst.options.length] = new Option(o[0], o[1]);
});
} else
dom.remove(dom.getParent(id, 'tr'));
},
resetImageData : function() {
var f = document.forms[0];
f.elements.width.value = f.elements.height.value = '';
},
updateImageData : function(img, st) {
var f = document.forms[0];
if (!st) {
f.elements.width.value = img.width;
f.elements.height.value = img.height;
}
this.preloadImg = img;
},
changeAppearance : function() {
var ed = tinyMCEPopup.editor, f = document.forms[0], img = document.getElementById('alignSampleImg');
if (img) {
if (ed.getParam('inline_styles')) {
ed.dom.setAttrib(img, 'style', f.style.value);
} else {
img.align = f.align.value;
img.border = f.border.value;
img.hspace = f.hspace.value;
img.vspace = f.vspace.value;
}
}
},
changeHeight : function() {
var f = document.forms[0], tp, t = this;
if (!f.constrain.checked || !t.preloadImg) {
t.updateStyle();
return;
}
if (f.width.value == "" || f.height.value == "")
return;
tp = (parseInt(f.width.value) / parseInt(t.preloadImg.width)) * t.preloadImg.height;
f.height.value = tp.toFixed(0);
t.updateStyle();
},
changeWidth : function() {
var f = document.forms[0], tp, t = this;
if (!f.constrain.checked || !t.preloadImg) {
t.updateStyle();
return;
}
if (f.width.value == "" || f.height.value == "")
return;
tp = (parseInt(f.height.value) / parseInt(t.preloadImg.height)) * t.preloadImg.width;
f.width.value = tp.toFixed(0);
t.updateStyle();
},
updateStyle : function() {
var dom = tinyMCEPopup.dom, st, v, f = document.forms[0];
if (tinyMCEPopup.editor.settings.inline_styles) {
st = tinyMCEPopup.dom.parseStyle(dom.get('style').value);
// Handle align
v = getSelectValue(f, 'align');
if (v) {
if (v == 'left' || v == 'right') {
st['float'] = v;
delete st['vertical-align'];
} else {
st['vertical-align'] = v;
delete st['float'];
}
} else {
delete st['float'];
delete st['vertical-align'];
}
// Handle border
v = f.border.value;
if (v || v == '0') {
if (v == '0')
st['border'] = '0';
else
st['border'] = v + 'px solid black';
} else
delete st['border'];
// Handle hspace
v = f.hspace.value;
if (v) {
delete st['margin'];
st['margin-left'] = v + 'px';
st['margin-right'] = v + 'px';
} else {
delete st['margin-left'];
delete st['margin-right'];
}
// Handle vspace
v = f.vspace.value;
if (v) {
delete st['margin'];
st['margin-top'] = v + 'px';
st['margin-bottom'] = v + 'px';
} else {
delete st['margin-top'];
delete st['margin-bottom'];
}
// Merge
st = tinyMCEPopup.dom.parseStyle(dom.serializeStyle(st));
dom.get('style').value = dom.serializeStyle(st);
}
},
changeMouseMove : function() {
},
showPreviewImage : function(u, st) {
if (!u) {
tinyMCEPopup.dom.setHTML('prev', '');
return;
}
if (!st && tinyMCEPopup.getParam("advimage_update_dimensions_onchange", true))
this.resetImageData();
u = tinyMCEPopup.editor.documentBaseURI.toAbsolute(u);
if (!st)
tinyMCEPopup.dom.setHTML('prev', '<img id="previewImg" src="' + u + '" border="0" onload="ImageDialog.updateImageData(this);" onerror="ImageDialog.resetImageData();" />');
else
tinyMCEPopup.dom.setHTML('prev', '<img id="previewImg" src="' + u + '" border="0" onload="ImageDialog.updateImageData(this, 1);" />');
}
};
ImageDialog.preInit();
tinyMCEPopup.onInit.add(ImageDialog.init, ImageDialog);
@@ -1,171 +0,0 @@
tinyMCEPopup.requireLangPack();
var MoodleImageDialog = {
init : function(ed) {
var f = document.forms[0], nl = f.elements, ed = tinyMCEPopup.editor, dom = ed.dom, n = ed.selection.getNode();
course_id = tinyMCEPopup.getParam('moodleimage_course_id');
tinyMCEPopup.resizeToInnerSize();
if (n.nodeName == 'IMG') {
nl.f_url.value = dom.getAttrib(n, 'src');
nl.f_width.value = dom.getAttrib(n, 'width');
nl.f_height.value = dom.getAttrib(n, 'height');
nl.f_alt.value = dom.getAttrib(n, 'alt');
nl.f_vert.value = this.getAttrib(n, 'vspace');
nl.f_horiz.value = this.getAttrib(n, 'hspace');
nl.f_border.value = this.getAttrib(n, 'border');
selectByValue(f, 'f_align', this.getAttrib(n, 'align'));
window.ipreview.location.replace('preview.php?id='+ course_id +'&imageurl='+ nl.f_url.value);
}
},
insert : function(file, title) {
var ed = tinyMCEPopup.editor, t = this, f = document.forms[0];
if (f.f_url.value === '') {
ed.dom.remove(ed.selection.getNode());
ed.execCommand('mceRepaint');
tinyMCEPopup.close();
return;
}
if (tinyMCEPopup.getParam("accessibility_warnings", 1)) {
if (!f.f_alt.value) {
tinyMCEPopup.editor.windowManager.confirm(tinyMCEPopup.getLang('moodleimage_dlg.missing_alt'), function(s) {
if (s)
t.insertAndClose();
});
return;
}
}
t.insertAndClose();
},
insertAndClose : function() {
var ed = tinyMCEPopup.editor, f = document.forms[0], nl = f.elements, v, args = {}, el;
// Fixes crash in Safari
if (tinymce.isWebKit)
ed.getWin().focus();
tinymce.extend(args, {
src : nl.f_url.value,
width : nl.f_width.value,
height : nl.f_height.value,
alt : nl.f_alt.value,
vspace : nl.f_vert.value,
hspace : nl.f_horiz.value,
border : nl.f_border.value,
align : getSelectValue(f, 'f_align')
});
el = ed.selection.getNode();
if (el && el.nodeName == 'IMG') {
ed.dom.setAttribs(el, args);
} else {
ed.execCommand('mceInsertContent', false, '<img id="__mce_tmp" src="javascript:;" />');
ed.dom.setAttribs('__mce_tmp', args);
ed.dom.setAttrib('__mce_tmp', 'id', '');
}
tinyMCEPopup.close();
},
changeHeight : function() {
var f = document.forms[0], tp, t = this;
//if (!f.constrain.checked || !t.preloadImg) {
//t.updateStyle();
//return;
//}
if (f.width.value == "" || f.height.value == "")
return;
tp = (parseInt(f.width.value) / parseInt(t.preloadImg.width)) * t.preloadImg.height;
f.height.value = tp.toFixed(0);
//t.updateStyle();
},
changeWidth : function() {
var f = document.forms[0], tp, t = this;
//if (!f.constrain.checked || !t.preloadImg) {
//t.updateStyle();
//return;
//}
if (f.f_width.value == "" || f.f_height.value == "")
return;
tp = (parseInt(f.f_height.value) / parseInt(t.preloadImg.height)) * t.preloadImg.width;
f.width.value = tp.toFixed(0);
//t.updateStyle();
},
getAttrib : function(e, at) {
var ed = tinyMCEPopup.editor, dom = ed.dom, v, v2;
if (ed.settings.inline_styles) {
switch (at) {
case 'align':
if (v = dom.getStyle(e, 'float'))
return v;
if (v = dom.getStyle(e, 'vertical-align'))
return v;
break;
case 'hspace':
v = dom.getStyle(e, 'margin-left')
v2 = dom.getStyle(e, 'margin-right');
if (v && v == v2)
return parseInt(v.replace(/[^0-9]/g, ''));
break;
case 'vspace':
v = dom.getStyle(e, 'margin-top')
v2 = dom.getStyle(e, 'margin-bottom');
if (v && v == v2)
return parseInt(v.replace(/[^0-9]/g, ''));
break;
case 'border':
v = 0;
tinymce.each(['top', 'right', 'bottom', 'left'], function(sv) {
sv = dom.getStyle(e, 'border-' + sv + '-width');
// False or not the same as prev
if (!sv || (sv != v && v !== 0)) {
v = 0;
return false;
}
if (sv)
v = sv;
});
if (v)
return parseInt(v.replace(/[^0-9]/g, ''));
break;
}
}
if (v = dom.getAttrib(e, at))
return v;
return '';
}
};
tinyMCEPopup.onInit.add(MoodleImageDialog.init, MoodleImageDialog);
@@ -1,4 +0,0 @@
tinyMCE.addI18n('en.moodleimage_dlg',{
title:"Insert Image",
missing_alt:"Are you sure you want to continue without including an Alternate Text? Without it the image may not be accessible to some users with disabilities, or to those using a text browser, or browsing the Web with images turned off."
});
@@ -1,31 +0,0 @@
<?php // $Id$ preview for insert image dialog
require("../../../../../../../config.php");
$id = optional_param('id', SITEID, PARAM_INT);
$imageurl = required_param('imageurl', PARAM_RAW);
require_login($id);
require_capability('moodle/course:managefiles', get_context_instance(CONTEXT_COURSE, $id));
@header('Content-Type: text/html; charset=utf-8');
$imagetag = clean_text('<img src="'.htmlSpecialChars($imageurl).'" alt="" />');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title><?php echo get_string('preview') ?></title>
<style type="text/css">
body { margin: 2px; }
</style>
</head>
<body bgcolor="#ffffff">
<?php echo $imagetag ?>
</body>
</html>