Commit 5a085810 authored by Frank Bergmann's avatar Frank Bergmann

- OpenACS 5.9 import

parent 01a59427
// Simple CSS (className) plugin for the editor
// Sponsored by http://www.miro.com.au
// Implementation by Mihai Bazon, http://dynarch.com/mishoo.
//
// (c) dynarch.com 2003
// Distributed under the same terms as HTMLArea itself.
// This notice MUST stay intact for use (see license.txt).
//
// $Id$
// @TODO This is the default and won't be very useful to others.
// We should make this better.
Xinha.Config.prototype.cssPluginConfig =
{
combos : [
{ label: "Syntax",
// menu text // CSS class
options: { "None" : "",
"Code" : "code",
"String" : "string",
"Comment" : "comment",
"Variable name" : "variable-name",
"Type" : "type",
"Reference" : "reference",
"Preprocessor" : "preprocessor",
"Keyword" : "keyword",
"Function name" : "function-name",
"Html tag" : "html-tag",
"Html italic" : "html-helper-italic",
"Warning" : "warning",
"Html bold" : "html-helper-bold"
},
context: "pre"
},
{ label: "Info",
options: { "None" : "",
"Quote" : "quote",
"Highlight" : "highlight",
"Deprecated" : "deprecated"
}
}
]
};
function CSSDropdowns(editor, params) {
this.editor = editor;
var cfg = editor.config;
var self = this;
var plugin_config;
if(params && params.length)
{
plugin_config = params[0];
}
else
{
plugin_config = editor.config.cssPluginConfig;
}
var combos = plugin_config.combos;
for (var i = 0; i < combos.length; i++) {
var combo = combos[i];
var id = "CSS-class" + i;
var css_class = {
id : id,
options : combo.options,
action : function(editor) { self.onSelect(editor, this, combo.context, combo.updatecontextclass); },
refresh : function(editor) { self.updateValue(editor, this); },
context : combo.context
};
cfg.registerDropdown(css_class);
cfg.addToolbarElement(["T[" + combo.label + "]", id, "separator"] , "formatblock", -1);
}
}
CSSDropdowns._pluginInfo = {
name : "CSSDropdowns",
version : "1.0",
developer : "Mihai Bazon",
developer_url : "http://dynarch.com/mishoo/",
c_owner : "Mihai Bazon",
sponsor : "Miro International",
sponsor_url : "http://www.miro.com.au",
license : "htmlArea"
};
CSSDropdowns.prototype.onSelect = function(editor, obj, context, updatecontextclass) {
var tbobj = editor._toolbarObjects[obj.id];
var index = tbobj.element.selectedIndex;
var className = tbobj.element.value;
// retrieve parent element of the selection
var parent = editor.getParentElement();
var surround = true;
var is_span = (parent && parent.tagName.toLowerCase() == "span");
var update_parent = (context && updatecontextclass && parent && parent.tagName.toLowerCase() == context);
if (update_parent) {
parent.className = className;
editor.updateToolbar();
return;
}
if (is_span && index == 0 && !/\S/.test(parent.style.cssText)) {
while (parent.firstChild) {
parent.parentNode.insertBefore(parent.firstChild, parent);
}
parent.parentNode.removeChild(parent);
editor.updateToolbar();
return;
}
if (is_span) {
// maybe we could simply change the class of the parent node?
if (parent.childNodes.length == 1) {
parent.className = className;
surround = false;
// in this case we should handle the toolbar updation
// ourselves.
editor.updateToolbar();
}
}
// Other possibilities could be checked but require a lot of code. We
// can't afford to do that now.
if (surround) {
// shit happens ;-) most of the time. this method works, but
// it's dangerous when selection spans multiple block-level
// elements.
editor.surroundHTML("<span class='" + className + "'>", "</span>");
}
};
CSSDropdowns.prototype.updateValue = function(editor, obj) {
var select = editor._toolbarObjects[obj.id].element;
var parent = editor.getParentElement();
if (typeof parent.className != "undefined" && /\S/.test(parent.className)) {
var options = select.options;
var value = parent.className;
for (var i = options.length; --i >= 0;) {
var option = options[i];
if (value == option.value) {
select.selectedIndex = i;
return;
}
}
}
select.selectedIndex = 0;
};
/** CSS Picker Plugin by Justin Rovang
*
* For full documentation, please see
* http://bitbucket.org/rovangju/xinha_csspicker/wiki/Home
*
* SAMPLE CONFIG:
*
* You can configure the appearance of the item/style list using the following CSS classes:
* .CSSPickerOption (Normal state)
* .CSSPickerOptionOver (Mouse-over state, typically border change)
* .CSSPickerOptionActive (Indicator for active classes under the selection/carat)
*
* Keys are CSS Class names
* wrapper: tag to wrap selected text with
* name: friendly name to display in panel with that class style applied to it.
*
* Sample config:
* CSSPicker.cssList = {
* 'xinhaDashedBox' : { 'wrapper':'div', 'name':'Breakout box' }
* 'xinhaMiniHeadline' : { 'wrapper':'div', 'name':'Sub-headline' }
* }
*
*/
function CSSPicker(editor, args) {
this.editor = editor;
var CSSPicker = this;
}
CSSPicker._pluginInfo = {
name : "CSSPicker",
version : "2008-12-01",
author : "Justin Rovang"
}
CSSPicker.prototype.onGenerateOnce = function() {
var editor = this.editor;
var CSSPicker = this;
editor._cssPicker = editor.addPanel("right");
this.main = document.createElement("div");
editor._cssPicker.style.backgroundColor='#dee5f8';
editor._cssPicker.appendChild(this.main);
Xinha.freeLater(this,"main");
editor.showPanel(editor._cssPicker);
}
CSSPicker.prototype.onUpdateToolbar = function() {
if(this.editor._cssPicker) {
if(this._timeoutID) window.clearTimeout(this._timeoutID);
var e = this.editor;
this._timeoutID = window.setTimeout(function() { e._gen(); }, 250); //1000 = 1sec / 500=.5sec / 250=.25sec
}
}
Xinha.prototype.listStyles = function(s) {
var editor = this;
var mySel = this.getSelection();
var myRange;
if(Xinha.is_ie) {
myRange = this.saveSelection();//mySel;
mySel = this.createRange(mySel).text;
}
var d = document.createElement("div");
d.className='CSSPickerOption';
/* If our carat is within an active class, highlight it */
var toggleState = editor.getStyleInfo(s);
if(toggleState) Xinha._addClass(d, 'CSSPickerOptionActive');
d.align='center';
d.innerHTML='<div class="'+s+'">'+CSSPicker.cssList[s].name+'</div>';
d.onclick = function() {
editor.wrapStyle(s, mySel, myRange, CSSPicker.cssList[s].wrapper);
return false;
};
Xinha._addEvent(d, 'mouseover', function(ev) {
Xinha._addClass(d, 'CSSPickerOptionOver');
});
Xinha._addEvent(d, 'mouseout', function(ev) {
Xinha._removeClass(d, 'CSSPickerOptionOver');
});
return d;
}
Xinha.prototype._gen = function() {
this.plugins.CSSPicker.instance.main.innerHTML='';
for(var s in CSSPicker.cssList) {
this.plugins.CSSPicker.instance.main.appendChild(this.listStyles(s));
}
return true;
}
/*
(string) s: style name
(string) sel: selection text
(object) myRange: selection object
(string) sWrapper: wrapper tag (e.g.: div, span)
*/
Xinha.prototype.wrapStyle = function(s, sel, myRange, sWrapper) {
if(!sWrapper) sWrapper="div";
sWrapper=sWrapper.toLowerCase();
/* The reason for these next lines is that we want the user to be able to place
* their cursor below the new div element. Otherwise they can't which makes
* placing anything after a div wrapper difficult/almost impossible. */
var divBreak='';
if(sWrapper=="div") divBreak='<br/>';
var editor=this;
this.focusEditor();
if(Xinha.is_ie) this.restoreSelection(myRange);
/*
* First - Get parent elements and see if the style is already applied.
*/
var toggleState = editor.getStyleInfo(s);
if(!toggleState) {
/* Create a new wrapper when:
* 1. Selected text has no 'snug' wrapper around it already.
* 2. If it does have a 'snug' wrapper, only append to the className if it's of the same type (span or div)
*/
if(sel == '') sel = '&nbsp;'; //We insert this if the selection is empty, making it easier for carat placement via click
this.insertHTML("<"+sWrapper+" class='"+s+"'>"+sel+"</"+sWrapper+">"+divBreak);
/* Modify the 'snug' wrapper if the above conditions are not met for a new element: */
}
else {
/* 1. If the current ancestor has -just- this classname. It should be removed.
* 2. If it has more than one class, it should be removed from the list of the parents
*/
Xinha._removeClass(toggleState, s);
}
return true;
}
Xinha.prototype.getStyleInfo = function(sClassToProbe) {
var editor = this;
var aList = this.getAllAncestors();
var a,s;
if(aList) aList.pop(); //We don't want the body element to show up in this list.
if(aList.length > 0) {
for(var o in aList){
a = aList[o];
/* Instead of break down and rebuild the array for this search, we're going
* to do some string trickery...
* // NOTE: THIS MAY BE PRONE TO PARTIAL MATCHES. SOLUTION IS TO ADD A SPACE PREPEND
*/
if(a.className) {
s = a.className.trim()+' ';
if(s.toLowerCase().match(sClassToProbe.toLowerCase()+' ')) {
return a;
}
}
}
}
return false;
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!-- saved from url=(0014)about:internet -->
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>SWFObject embed by Geoff Stearns (express install) @ deconcept</title>
<!-- SWFObject embed by Geoff Stearns geoff@deconcept.com http://blog.deconcept.com/swfobject/ -->
<script type="text/javascript" src="swfobject.js"></script>
<style type="text/css">
body {
background-color: #eeeeee;
font: .8em/1.3em verdana,arial,helvetica,sans-serif;
}
#info {
width: 300px;
overflow: auto;
}
#flashcontent {
border: solid 1px #000;
width: 300px;
height: 300px;
float: left;
margin: 15px 20px;
}
</style>
</head>
<body>
<div id="flashcontent">
<strong>You need to upgrade your Flash Player</strong>
This is replaced by the Flash content.
Place your alternate content here and users without the Flash plugin or with
Javascript turned off will see this. Content here allows you to leave out <code>noscript</code>
tags. Include a link to <a href="expressinstall.html?detectflash=false">bypass the detection</a> if you wish.
</div>
<script type="text/javascript">
// <![CDATA[
var so = new SWFObject("so_tester.swf", "sotester", "300", "300", "9", "#FF6600");
so.addVariable("flashVarText", "this is passed in via FlashVars"); // this line is optional, but this example uses the variable and displays this text inside the flash movie
so.useExpressInstall('expressinstall.swf');
so.write("flashcontent");
// ]]>
</script>
<div id="info">
<p>
This Flash movie was embedded using the <a href="http://blog.deconcept.com/swfobject/">SWFObject</a> embed method by <a href="http://blog.deconcept.com/">Geoff Stearns</a>.
</p>
<p>Other sample embeds:</p>
<ul>
<li><a href="swfobject.html">Basic Flash Embed with alternate content</a></li>
<li><a href="fullpage.html">Full page Flash embed</a></li>
<li>Basic Flash Embed with Express Install allowed</li>
</ul>
<p>You can also <a href="flashversion.html">view your installed Flash version</a>.</p>
<p>
<a href="view-source:http://blog.deconcept.com/swfobject/expressinstall.html">View source</a> (in mozilla, firefox) | <a href="swfobject_source.js">View Javascript</a>.
</p>
<p>
<a href="http://blog.deconcept.com/swfobject/swfobject1-4.zip">Download Source</a>.
</p>
</div>
<p style="clear: both;margin-left: 20px"><a href="http://validator.w3.org/check?uri=referer">Validate XHTML</a> and <a href="http://jigsaw.w3.org/css-validator/check/referer">CSS</a></p>
</body>
</html>
/**
* SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
*
* SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
* http://www.opensource.org/licenses/mit-license.php
*
*/
if(typeof deconcept=="undefined"){var deconcept=new Object();}if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a){if(!document.getElementById){return;}this.DETECT_KEY=_a?_a:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(_1){this.setAttribute("swf",_1);}if(id){this.setAttribute("id",id);}if(w){this.setAttribute("width",w);}if(h){this.setAttribute("height",h);}if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7){deconcept.SWFObject.doPrepUnload=true;}if(c){this.addParam("bgcolor",c);}var q=_7?_7:"high";this.addParam("quality",q);this.setAttribute("useExpressInstall",false);this.setAttribute("doExpressInstall",false);var _c=(_8)?_8:window.location;this.setAttribute("xiRedirectUrl",_c);this.setAttribute("redirectUrl","");if(_9){this.setAttribute("redirectUrl",_9);}};deconcept.SWFObject.prototype={useExpressInstall:function(_d){this.xiSWFPath=!_d?"expressinstall.swf":_d;this.setAttribute("useExpressInstall",true);},setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10];},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15];},getVariables:function(){return this.variables;},getVariablePairs:function(){var _16=new Array();var key;var _18=this.getVariables();for(key in _18){_16[_16.length]=key+"="+_18[key];}return _16;},getSWFHTML:function(){var _19="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");this.setAttribute("swf",this.xiSWFPath);}_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\"";_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";var _1a=this.getParams();for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}var _1c=this.getVariablePairs().join("&");if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");this.setAttribute("swf",this.xiSWFPath);}_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\">";_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";var _1d=this.getParams();for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}var _1f=this.getVariablePairs().join("&");if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}return _19;},write:function(_20){if(this.getAttribute("useExpressInstall")){var _21=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var n=(typeof _20=="string")?document.getElementById(_20):_20;n.innerHTML=this.getSWFHTML();return true;}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}return false;}};deconcept.SWFObjectUtil.getPlayerVersion=function(){var _23=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}}else{if(navigator.userAgent&&navigator.userAgent.indexOf("Windows CE")>=0){var axo=1;var _26=3;while(axo){try{_26++;axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+_26);_23=new deconcept.PlayerVersion([_26,0,0]);}catch(e){axo=null;}}}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}}return _23;};deconcept.PlayerVersion=function(_29){this.major=_29[0]!=null?parseInt(_29[0]):0;this.minor=_29[1]!=null?parseInt(_29[1]):0;this.rev=_29[2]!=null?parseInt(_29[2]):0;};deconcept.PlayerVersion.prototype.versionIsValid=function(fv){if(this.major<fv.major){return false;}if(this.major>fv.major){return true;}if(this.minor<fv.minor){return false;}if(this.minor>fv.minor){return true;}if(this.rev<fv.rev){return false;}return true;};deconcept.util={getRequestParameter:function(_2b){var q=document.location.search||document.location.hash;if(_2b==null){return q;}if(q){var _2d=q.substring(1).split("&");for(var i=0;i<_2d.length;i++){if(_2d[i].substring(0,_2d[i].indexOf("="))==_2b){return _2d[i].substring((_2d[i].indexOf("=")+1));}}}return "";}};deconcept.SWFObjectUtil.cleanupSWFs=function(){var _2f=document.getElementsByTagName("OBJECT");for(var i=_2f.length-1;i>=0;i--){_2f[i].style.display="none";for(var x in _2f[i]){if(typeof _2f[i][x]=="function"){_2f[i][x]=function(){};}}}};if(deconcept.SWFObject.doPrepUnload){if(!deconcept.unloadSet){deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};window.attachEvent("onunload",deconcept.SWFObjectUtil.cleanupSWFs);};window.attachEvent("onbeforeunload",deconcept.SWFObjectUtil.prepUnload);deconcept.unloadSet=true;}}if(!document.getElementById&&document.all){document.getElementById=function(id){return document.all[id];};}var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject;
\ No newline at end of file
/**
* SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
*
* SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
* http://www.opensource.org/licenses/mit-license.php
*
*/
if(typeof deconcept == "undefined") var deconcept = new Object();
if(typeof deconcept.util == "undefined") deconcept.util = new Object();
if(typeof deconcept.SWFObjectUtil == "undefined") deconcept.SWFObjectUtil = new Object();
deconcept.SWFObject = function(swf, id, w, h, ver, c, quality, xiRedirectUrl, redirectUrl, detectKey) {
if (!document.getElementById) { return; }
this.DETECT_KEY = detectKey ? detectKey : 'detectflash';
this.skipDetect = deconcept.util.getRequestParameter(this.DETECT_KEY);
this.params = new Object();
this.variables = new Object();
this.attributes = new Array();
if(swf) { this.setAttribute('swf', swf); }
if(id) { this.setAttribute('id', id); }
if(w) { this.setAttribute('width', w); }
if(h) { this.setAttribute('height', h); }
if(ver) { this.setAttribute('version', new deconcept.PlayerVersion(ver.toString().split("."))); }
this.installedVer = deconcept.SWFObjectUtil.getPlayerVersion();
if (!window.opera && document.all && this.installedVer.major > 7) {
// only add the onunload cleanup if the Flash Player version supports External Interface and we are in IE
deconcept.SWFObject.doPrepUnload = true;
}
if(c) { this.addParam('bgcolor', c); }
var q = quality ? quality : 'high';
this.addParam('quality', q);
this.setAttribute('useExpressInstall', false);
this.setAttribute('doExpressInstall', false);
var xir = (xiRedirectUrl) ? xiRedirectUrl : window.location;
this.setAttribute('xiRedirectUrl', xir);
this.setAttribute('redirectUrl', '');
if(redirectUrl) { this.setAttribute('redirectUrl', redirectUrl); }
}
deconcept.SWFObject.prototype = {
useExpressInstall: function(path) {
this.xiSWFPath = !path ? "expressinstall.swf" : path;
this.setAttribute('useExpressInstall', true);
},
setAttribute: function(name, value){
this.attributes[name] = value;
},
getAttribute: function(name){
return this.attributes[name];
},
addParam: function(name, value){
this.params[name] = value;
},
getParams: function(){
return this.params;
},
addVariable: function(name, value){
this.variables[name] = value;
},
getVariable: function(name){
return this.variables[name];
},
getVariables: function(){
return this.variables;
},
getVariablePairs: function(){
var variablePairs = new Array();
var key;
var variables = this.getVariables();
for(key in variables){
variablePairs[variablePairs.length] = key +"="+ variables[key];
}
return variablePairs;
},
getSWFHTML: function() {
var swfNode = "";
if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) { // netscape plugin architecture
if (this.getAttribute("doExpressInstall")) {
this.addVariable("MMplayerType", "PlugIn");
this.setAttribute('swf', this.xiSWFPath);
}
swfNode = '<embed type="application/x-shockwave-flash" src="'+ this.getAttribute('swf') +'" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'" style="'+ this.getAttribute('style') +'"';
swfNode += ' id="'+ this.getAttribute('id') +'" name="'+ this.getAttribute('id') +'" ';
var params = this.getParams();
for(var key in params){ swfNode += [key] +'="'+ params[key] +'" '; }
var pairs = this.getVariablePairs().join("&");
if (pairs.length > 0){ swfNode += 'flashvars="'+ pairs +'"'; }
swfNode += '/>';
} else { // PC IE
if (this.getAttribute("doExpressInstall")) {
this.addVariable("MMplayerType", "ActiveX");
this.setAttribute('swf', this.xiSWFPath);
}
swfNode = '<object id="'+ this.getAttribute('id') +'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'" style="'+ this.getAttribute('style') +'">';
swfNode += '<param name="movie" value="'+ this.getAttribute('swf') +'" />';
var params = this.getParams();
for(var key in params) {
swfNode += '<param name="'+ key +'" value="'+ params[key] +'" />';
}
var pairs = this.getVariablePairs().join("&");
if(pairs.length > 0) {swfNode += '<param name="flashvars" value="'+ pairs +'" />';}
swfNode += "</object>";
}
return swfNode;
},
write: function(elementId){
if(this.getAttribute('useExpressInstall')) {
// check to see if we need to do an express install
var expressInstallReqVer = new deconcept.PlayerVersion([6,0,65]);
if (this.installedVer.versionIsValid(expressInstallReqVer) && !this.installedVer.versionIsValid(this.getAttribute('version'))) {
this.setAttribute('doExpressInstall', true);
this.addVariable("MMredirectURL", escape(this.getAttribute('xiRedirectUrl')));
document.title = document.title.slice(0, 47) + " - Flash Player Installation";
this.addVariable("MMdoctitle", document.title);
}
}
if(this.skipDetect || this.getAttribute('doExpressInstall') || this.installedVer.versionIsValid(this.getAttribute('version'))){
var n = (typeof elementId == 'string') ? document.getElementById(elementId) : elementId;
n.innerHTML = this.getSWFHTML();
return true;
}else{
if(this.getAttribute('redirectUrl') != "") {
document.location.replace(this.getAttribute('redirectUrl'));
}
}
return false;
}
}
/* ---- detection functions ---- */
deconcept.SWFObjectUtil.getPlayerVersion = function(){
var PlayerVersion = new deconcept.PlayerVersion([0,0,0]);
if(navigator.plugins && navigator.mimeTypes.length){
var x = navigator.plugins["Shockwave Flash"];
if(x && x.description) {
PlayerVersion = new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split("."));
}
}else if (navigator.userAgent && navigator.userAgent.indexOf("Windows CE") >= 0){ // if Windows CE
var axo = 1;
var counter = 3;
while(axo) {
try {
counter++;
axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+ counter);
// document.write("player v: "+ counter);
PlayerVersion = new deconcept.PlayerVersion([counter,0,0]);
} catch (e) {
axo = null;
}
}
} else { // Win IE (non mobile)
// do minor version lookup in IE, but avoid fp6 crashing issues
// see http://blog.deconcept.com/2006/01/11/getvariable-setvariable-crash-internet-explorer-flash-6/
try{
var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
}catch(e){
try {
var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
PlayerVersion = new deconcept.PlayerVersion([6,0,21]);
axo.AllowScriptAccess = "always"; // error if player version < 6.0.47 (thanks to Michael Williams @ Adobe for this code)
} catch(e) {
if (PlayerVersion.major == 6) {
return PlayerVersion;
}
}
try {
axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
} catch(e) {}
}
if (axo != null) {
PlayerVersion = new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));
}
}
return PlayerVersion;
}
deconcept.PlayerVersion = function(arrVersion){
this.major = arrVersion[0] != null ? parseInt(arrVersion[0]) : 0;
this.minor = arrVersion[1] != null ? parseInt(arrVersion[1]) : 0;
this.rev = arrVersion[2] != null ? parseInt(arrVersion[2]) : 0;
}
deconcept.PlayerVersion.prototype.versionIsValid = function(fv){
if(this.major < fv.major) return false;
if(this.major > fv.major) return true;
if(this.minor < fv.minor) return false;
if(this.minor > fv.minor) return true;
if(this.rev < fv.rev) return false;
return true;
}
/* ---- get value of query string param ---- */
deconcept.util = {
getRequestParameter: function(param) {
var q = document.location.search || document.location.hash;
if (param == null) { return q; }
if(q) {
var pairs = q.substring(1).split("&");
for (var i=0; i < pairs.length; i++) {
if (pairs[i].substring(0, pairs[i].indexOf("=")) == param) {
return pairs[i].substring((pairs[i].indexOf("=")+1));
}
}
}
return "";
}
}
/* fix for video streaming bug */
deconcept.SWFObjectUtil.cleanupSWFs = function() {
var objects = document.getElementsByTagName("OBJECT");
for (var i = objects.length - 1; i >= 0; i--) {
objects[i].style.display = 'none';
for (var x in objects[i]) {
if (typeof objects[i][x] == 'function') {
objects[i][x] = function(){};
}
}
}
}
// fixes bug in some fp9 versions see http://blog.deconcept.com/2006/07/28/swfobject-143-released/
if (deconcept.SWFObject.doPrepUnload) {
if (!deconcept.unloadSet) {
deconcept.SWFObjectUtil.prepUnload = function() {
__flash_unloadHandler = function(){};
__flash_savedUnloadHandler = function(){};
window.attachEvent("onunload", deconcept.SWFObjectUtil.cleanupSWFs);
}
window.attachEvent("onbeforeunload", deconcept.SWFObjectUtil.prepUnload);
deconcept.unloadSet = true;
}
}
/* add document.getElementById if needed (mobile IE < 5) */
if (!document.getElementById && document.all) { document.getElementById = function(id) { return document.all[id]; }}
/* add some aliases for ease of use/backwards compatibility */
var getQueryParamValue = deconcept.util.getRequestParameter;
var FlashObject = deconcept.SWFObject; // for legacy support
var SWFObject = deconcept.SWFObject;
.filemanager-container .filemanager { overflow:visible; }
.filemanager-info-area { width:50%; float:left; clear:left; }
.filemanager-preview-area { width:50%; float:left; clear:right; }
div.filemanager-info-area dt, div.filemanager-preview-area dt { width:25%; margin-left:5px; }
div.filemanager-info-area dd, div.filemanager-preview-area dd { width:auto; }
div.filemanager-preview-area dt { float:left; }
div.filemanager-preview-area h2 { display:none; }
div.filemanager-preview-area img.preview { margin-left:5px; margin-right:5px; margin-top:0px; float:right; clear:right; max-width:140px; }
div.filemanager-preview-area dl { float:left; clear:left; width:auto; }
div.filemanager-preview div.object { margin-left:15%; margin-right:15%; margin-top:0px; float:right; clear:right; }
div.filemanager td, div.filemanager th, div.filemanager input[type=text] {
line-height: 20px;
font-size: 11px;
}
div.filemanager th
{
font-weight:bold;
text-align:left;
padding-left:0px;
}
div.filemanager td.filemanager-f_alt input {width:100%;}
div.filemanager table.filemanager-extended-options { width:550px; margin-left:5px; margin-right:5px; border-collapse:collapse; }
table.filemanager-extended-options .buttonColor {
width :1em;
margin-left: 2px;
cursor: default;
}
table.filemanager-extended-options .buttonColor .chooser, table.filemanager-extended-options .buttonColor .nocolor {
height: 0.6em;
border: 1px solid;
padding: 0px 1em;
border-color: ButtonHighlight ButtonShadow ButtonShadow ButtonHighlight;
}
table.filemanager-extended-options .buttonColor .buttonClick {
border-color: ButtonShadow ButtonHighlight ButtonHighlight ButtonShadow;
}
table.filemanager-extended-options .buttonColor .buttonColor-hilite {
border-color: ButtonShadow ButtonHighlight ButtonHighlight ButtonShadow;
}
table.filemanager-extended-options .buttonColor .nocolor { padding: 0px; }
table.filemanager-extended-options .buttonColor .nocolor-hilite { background-color: #fff; color: #f00; }
div.filemanager-uploader-area { clear:both; }
\ No newline at end of file
/**
= Mootools File Manager =
The MootoolsFileManager plugin allows for the management, selection and
insertion of links to files and inline images to the edited HTML.
It requires the use of Mootools. If you do not use mootools plugins,
then mootools is not loaded. If mootools is already loaded, it will
not be reloaded (so if you want to use your own version of Mootools
then load it first).
== Usage ==
Instruct Xinha to load the MootoolsFileManager plugin (follow the NewbieGuide).
Configure the plugin as per the directions in the config.php file.
* @author $Author$
* @version $Id$
* @package MootoolsFileManager
*/
MootoolsFileManager._pluginInfo = {
name : "Mootols File Manager",
version : "1.0",
developer : "James Sleeman (Xinha), Christoph Pojer (FileManager)",
license : "MIT"
};
// All the configuration is done through PHP, please read config.php to learn how (or if you're in a real
// hurry, just edit config.php)
Xinha.Config.prototype.MootoolsFileManager =
{
'backend' : Xinha.getPluginDir("MootoolsFileManager") + '/backend.php?__plugin=MootoolsFileManager&',
'backend_data' : { }
};
MootoolsFileManager.AssetLoader = Xinha.includeAssets();
// In case you want to use your own version of Mootools, you can load it first.
if(typeof MooTools == 'undefined')
{
MootoolsFileManager.AssetLoader
.loadScript('mootools-filemanager/Demos/mootools-core.js', 'MootoolsFileManager')
.loadScript('mootools-filemanager/Demos/mootools-more.js', 'MootoolsFileManager');
}
// In case you want to use your own version of FileManager, you can load it first.
// You better look at the changes we had to do to the standard one though.
if(typeof FileManager == 'undefined')
{
MootoolsFileManager.AssetLoader
.loadStyle('mootools-filemanager/Css/FileManager.css', 'MootoolsFileManager')
.loadStyle('mootools-filemanager/Css/Additions.css', 'MootoolsFileManager')
.loadScript('mootools-filemanager/Source/Additions.js', 'MootoolsFileManager')
.loadScript('mootools-filemanager/Source/Uploader/Fx.ProgressBar.js', 'MootoolsFileManager')
.loadScript('mootools-filemanager/Source/Uploader/Swiff.Uploader.js', 'MootoolsFileManager')
.loadScript('mootools-filemanager/Source/FileManager.js', 'MootoolsFileManager')
.loadScript('mootools-filemanager/Source/Uploader.js', 'MootoolsFileManager')
.loadScript('mootools-filemanager/Language/Language.en.js', 'MootoolsFileManager');
}
MootoolsFileManager.AssetLoader.loadStyle('MootoolsFileManager.css', 'MootoolsFileManager');
function MootoolsFileManager(editor)
{
this.editor = editor;
var self = this;
var cfg = editor.config;
// Do a callback to the PHP backend and get it to "decode" the configuration for us into a
// javascript object.
// IMPORTANT: we need to do this synchronously to ensure that the buttons are added to the toolbar
// before the toolbar is drawn.
var phpcfg = Xinha._posturlcontent(editor.config.MootoolsFileManager.backend+'__function=read-config', editor.config.MootoolsFileManager.backend_data);
eval ('var f = '+phpcfg+';');
self.phpcfg = f;
self.hookUpButtons();
return;
};
/** Connect up/insert the appropriate buttons and load in the auxillary files.
*
* The different "modes" of this plugin have been split into several auxilliary files
* as it's likely you may not want them all (esp if we add more modes later).
*
* Each mode's "include" is loaded as soon as we know it could be needed by the
* editor, we don't wait until the button is pressed as that would be slow for
* the user to respond.
*
*/
MootoolsFileManager.prototype.hookUpButtons = function()
{
var self = this;
var phpcfg = self.phpcfg;
if (phpcfg.files_dir)
{
MootoolsFileManager.AssetLoader.loadScriptOnce('MootoolsFileManager.FileManager.js', 'MootoolsFileManager');
this.editor.config.registerButton({
id : "linkfile",
tooltip : Xinha._lc("Insert File Link",'ExtendedFileManager'),
image : Xinha.getPluginDir('ExtendedFileManager') + '/img/ed_linkfile.gif',
textMode : false,
action : function(editor) { MootoolsFileManager.AssetLoader.whenReady(function() { self.OpenFileManager(); }); }
});
this.editor.config.addToolbarElement("linkfile", "createlink", 1);
};
if(phpcfg.images_dir)
{
MootoolsFileManager.AssetLoader.loadScriptOnce('MootoolsFileManager.ImageManager.js', 'MootoolsFileManager');
// Override our Editors insert image button action.
self.editor._insertImage = function(image)
{
MootoolsFileManager.AssetLoader.whenReady(function() { self.OpenImageManager(image); });
}
}
};
/** Helper method to scale (an image typically) to a new constraint.
*
* @param origdim object { width: 123,height: 456 } The original dimensions.
* @param newdim object { width: 456, height: 123 } The new (maximum) dimensions.
* @param flexside 'width'|'height' (optional) the side which can be "flexible"
* Defaults to the "short" side.
* @return { width: 789, height: 987 } The scaled dimensions which should be used.
*/
MootoolsFileManager.prototype.ScaleImage = function( origdim, newdim, flexside )
{
if(!origdim.height || !origdim.width) return newdim; // No old size, stays new.
if(!newdim.height && !newdim.width) return origdim; // No new size, stays the same.
if(!flexside)
{
if(origdim.width > origdim.height)
{
flexside = 'height'; // Landscape image, allow the height to flex.
}
else
{
flexside = 'width'; // Portrait image, allow the width to flex
}
}
var knownside = null;
switch(flexside)
{
case 'height': knownside = 'width'; break;
case 'width' : knownside = 'height'; break;
}
// If we DON'T know the known side, we need to flip it.
if(!newdim[knownside])
{
var t = knownside;
knownside = flexside;
flexside = t;
}
var ratio = 0;
switch(flexside)
{
case 'width': ratio = origdim.width / origdim.height; break;
case 'height': ratio = origdim.height / origdim.width; break;
}
var rdim = {};
rdim[knownside] = newdim[knownside];
rdim[flexside] = Math.floor(newdim[knownside] * ratio);
if(isNaN(rdim[knownside])) rdim[knownside] = null;
if(isNaN(rdim[flexside])) rdim[flexside] = null;
return rdim;
}
/** Take a multi-part CSS size specification (eg sizes for 4 borders) and
* shrink it into one if possible.
*/
MootoolsFileManager.prototype.shortSize = function(cssSize)
{
if(/ /.test(cssSize))
{
var sizes = cssSize.split(' ');
var useFirstSize = true;
for(var i = 1; i < sizes.length; i++)
{
if(sizes[0] != sizes[i])
{
useFirstSize = false;
break;
}
}
if(useFirstSize) cssSize = sizes[0];
}
return cssSize;
};
/** Take a colour in rgb(a,b) format and convert to HEX
* handles multiple colours in same string as well.
*/
MootoolsFileManager.prototype.convertToHex = function(color)
{
if (typeof color == "string" && /, /.test.color)
color = color.replace(/, /, ','); // rgb(a, b) => rgb(a,b)
if (typeof color == "string" && / /.test.color) { // multiple values
var colors = color.split(' ');
var colorstring = '';
for (var i = 0; i < colors.length; i++) {
colorstring += Xinha._colorToRgb(colors[i]);
if (i + 1 < colors.length)
colorstring += " ";
}
return colorstring;
}
return Xinha._colorToRgb(color);
}
The mootools-filemanager is a git repository which (probably) contains local modifications to work better with Xinha. Therefore, we want to keep it as a git repo so we can easily update.
The upstream git repository is (from http://github.com/cpojer/mootools-filemanager)
git://github.com/cpojer/mootools-filemanager.git
Simply CD'ing into the mootools-filemanager directory and performing
git pull
should be sufficient to update.
The mootools-filemanager/.git/ directory should be stripped prior to shipping for space concerns.
<?php
/**
* Unified backend for ImageManager
*
* Image Manager was originally developed by:
* Xiang Wei Zhuo, email: xiangweizhuo(at)hotmail.com Wei Shou.
*
* Unified backend sponsored by DTLink Software, http://www.dtlink.com
* Implementation by Yermo Lamers, http://www.formvista.com
*
* (c) DTLink, LLC 2005.
* Distributed under the same terms as HTMLArea itself.
* This notice MUST stay intact for use (see license.txt).
*
* DESCRIPTION:
*
* Instead of using separate URL's for each function, ImageManager now
* routes all requests to the server through this single, replaceable,
* entry point. backend.php expects at least two URL variable parameters:
*
* __plugin=ImageManager for future expansion; identify the plugin being requested.
* __function=thumbs|images|editorFrame|editor|manager function being called.
*
* Having a single entry point that strictly adheres to a defined interface will
* make the backend code much easier to maintain and expand. It will make it easier
* on integrators, not to mention it'll make it easier to have separate
* implementations of the backend in different languages (Perl, Python, ASP, etc.)
*
* @see config.inc.php
*/
// Strip slashes if MQGPC is on
if(function_exists('set_magic_quotes_runtime')) @set_magic_quotes_runtime(0);
if(function_exists('get_magic_quotes_gpc') && @get_magic_quotes_gpc())
{
$to_clean = array(&$_GET, &$_POST, &$_REQUEST, &$_COOKIE);
while(count($to_clean))
{
$cleaning =& $to_clean[array_pop($junk = array_keys($to_clean))];
unset($to_clean[array_pop($junk = array_keys($to_clean))]);
foreach(array_keys($cleaning) as $k)
{
if(is_array($cleaning[$k]))
{
$to_clean[] =& $cleaning[$k];
}
else
{
$cleaning[$k] = stripslashes($cleaning[$k]);
}
}
}
}
function size_to_bytes($s)
{
if(preg_match('/([0-9\.])+([a-zA-Z]+)/', $s, $M))
{
switch(strtolower($M[2]))
{
case 'm':
return floor(floatval($M[1]) * 1024 * 1024);
case 'b':
return intval($M[1]);
case 'kb':
return floor(floatval($M[1]) * 1024);
}
}
if(floatval($s) < 10) return floor(floatval($s) * 1024 * 1024);
if(floatval($s) < 1024) return floor(floatval($s) * 1024); // Kilobytes
return intval($s); // Bytes
}
require_once('config.php');
switch ( @$_REQUEST[ "__function" ] )
{
case 'read-config':
// This is used so that the javascript can read the config
// so we don't have to have a js config and a php config duplicating
// settings
echo xinha_to_js($IMConfig);
break;
case 'image-manager':
include('mootools-filemanager/Backend/FileManager.php');
$browser = new FileManager(array(
'directory' => $IMConfig['images_dir'],
'baseURL' => $IMConfig['images_url'],
'assetBasePath' => $IMConfig['base_url'] .'/mootools-filemanager/Assets',
'upload' => $IMConfig['allow_images_upload'],
'maxUploadSize' => size_to_bytes($IMConfig['max_images_upload_size']),
'suggestedMaxImageDimension' => $IMConfig['suggested_images_image_dimension'],
'destroy' => $IMConfig['allow_images_delete'],
'filter' => 'image/',
));
$browser->fireEvent(!empty($_REQUEST['event']) ? $_REQUEST['event'] : null);
break;
case 'file-manager':
include('mootools-filemanager/Backend/FileManager.php');
$browser = new FileManager(array(
'directory' => $IMConfig['files_dir'],
'baseURL' => $IMConfig['files_url'],
'assetBasePath' => $IMConfig['base_url'] .'/mootools-filemanager/Assets',
'upload' => $IMConfig['allow_files_upload'],
'maxUploadSize' => size_to_bytes($IMConfig['max_files_upload_size']),
'suggestedMaxImageDimension' => $IMConfig['suggested_files_image_dimension'],
'destroy' => $IMConfig['allow_files_delete'],
// 'filter' => $IMConfig['files_filter'],
));
$browser->fireEvent(!empty($_REQUEST['event']) ? $_REQUEST['event'] : null);
break;
}
?>
<?php
/**
= MootoolsFileManager Configuration File =
Configure either by directly editing the config.php file (not recommended) or
as follows...
1. You need to be able to put PHP in your XinhaConfig.js, so
you may want to call it XinhaConfig.php instead, or whatever other
method you choose (eg put the config as an inline script in your
main php page).
2. In step 3 of your XinhaConfig write something like...
{{{
with (xinha_config.MootoolsFileManager)
{
<?php
require_once('/path/to/xinha/contrib/php-xinha.php');
xinha_pass_to_php_backend
(
array
(
'images_dir' => '/home/your/directory',
'images_url' => '/directory',
'allow_images_upload' => true,
)
)
?>
}
}}}
This will work provided you are using normal file-based PHP sessions
(most likely), if not, you may need to modify the php-xinha.php
file to suit your setup.
* @author $Author$
* @version $Id$
* @package MootoolsFileManager
*
*/
/**
== File Paths REQUIRED ==
This plugin operates (optionally) in two modes.
1. As a File Manager where people are inserting a link to a file
(eg a doc or pdf commonly), we call this "files" mode.
2. As an Image Manager where people are inserting an inline image,
we call this "images" mode.
You may provide one of, or both of, files_dir and images_dir. If you do not
provide one, that mode of MootoolsFileManager will be disabled.
# `files_dir` -- Directory path to the location where ordinary files are stored
(eg /home/you/public_html/downloads/ )
# `files_url` -- The URL path to the files_dir
(eg /downloads/)
# `images_dir` -- Directory path to the location where inline images are stored
(eg /home/you/public_html/images/)
# `images_url` -- The URL path to the images_dir
=== Security Caution ===
You should ensure that the paths you specify are protected against having PHP and
other scripts from being executed. The following .htaccess file is a good idea
{{{
<IfModule mod_php.c>
php_flag engine off
</IfModule>
AddType text/html .html .htm .shtml .php .php3 .php4 .php5 .php6 .php7 .php8 .phtml .phtm .pl .py .cgi
RemoveHandler .php
RemoveHandler .php8
RemoveHandler .php7
RemoveHandler .php6
RemoveHandler .php5
RemoveHandler .php4
RemoveHandler .php3
}}}
*/
$IMConfig['files_dir'] = FALSE; // No trailing slash
$IMConfig['files_url'] = FALSE; // No trailing slash
$IMConfig['images_dir'] = FALSE; // No trailing slash
$IMConfig['images_url'] = FALSE; // No trailing slash
/**
== Turning On Uploads ==
We have two sets of settings for turning on uploads, one controls the files mode
of the plugin, the other is for images mode.
Note that allowing upload also permits the user to create subdirectories to better
organise the files.
=== Maximum File Sizes ===
Each mode can have a different maximum file size that can be uploaded, this
size is a number followed by one of M, KB or B.
=== Suggested Image Dimensions ===
Each mode can have a different "suggested maximum image dimension", when the
user uses the Mootools File Manager to upload a file, they are able to choose
to "resize large images" on upload. This defines what "large" means.
*/
$IMConfig['allow_files_upload'] = false;
$IMConfig['allow_files_delete'] = false;
$IMConfig['max_files_upload_size'] = '3M';
$IMConfig['suggested_files_image_dimension'] = array('width' => 2048, 'height' => 1536);
$IMConfig['allow_images_upload'] = false;
$IMConfig['allow_images_delete'] = false;
$IMConfig['max_images_upload_size'] = '3M';
$IMConfig['suggested_images_image_dimension'] = array('width' => 1024, 'height' => 768);
// -------------------------------------------------------------------------
// OPTIONAL SETTINGS
// -------------------------------------------------------------------------
/**
== Plugin Path ==
For most people the defaults will work fine, but if you have trouble, you can set
`base_dir` to be the directory path to xinha/plugins/MootoolsFileManager
`base_url` to be the url path to xinha/plugins/MootoolsFileManager
*/
$IMConfig['base_dir'] = getcwd();
$IMConfig['base_url'] = preg_replace('/\/backend\.php.*/', '', $_SERVER['REQUEST_URI']);
/**
== HTML Compatability ==
For most people the default of using CSS will be fine, but if the HTML you are editing
in Xinha is destined for an email you will probably want to use hspace and vspace
instead of CSS margins because of poor Email support for CSS.
*/
$IMConfig['UseHSpaceVSpace'] = TRUE;
/**
// Future use, not yet required.
== ImageMagick Path ==
Certain operations require that ImageMagick is available on your server,
mogrify, convert and identify executables are required.
If these executables are not in your executable path, you'll want to
set the path to them here, for Linux/Unix etc this will be something like
{{{
/usr/bin
}}}
for Windows servers, something like
{{{
C:/"Program Files"/ImageMagick-5.5.7-Q16/
}}}
$IMConfig['IMAGE_TRANSFORM_LIB_PATH'] = '';
*/
////////////////////////////////////////////////////////////////////////////////
// ================== END OF CONFIGURATION ======================= //
////////////////////////////////////////////////////////////////////////////////
// Standard PHP Backend Data Passing
// if data was passed using xinha_pass_to_php_backend() we merge the items
// provided into the Config
require_once(realpath(dirname(__FILE__) . '/../../contrib/php-xinha.php'));
if($passed_data = xinha_read_passed_data())
{
$IMConfig = array_merge($IMConfig, $passed_data);
}
@session_write_close(); // Close session now so we don't lock.
?>
/** Save the content of the editor to the text area when blurring (losing focus).
*
* @author Peter Siewert
* @see Ticket #1433
*/
SaveOnBlur._pluginInfo = {
name:"SaveOnBlur",
version:"1.0",
developer:"Peter Siewert",
developer_url:"http://xinha.org",
sponsor:"",
sponsor_url:"",
license:"htmlArea"
};
function SaveOnBlur(editor){
this.editor=editor;
}
SaveOnBlur.prototype.onKeyPress=function(){
this.queue_xinha_update_textarea();
return false;
};
SaveOnBlur.prototype.onMouseDown=function(){
this.queue_xinha_update_textarea();
return false;
};
SaveOnBlur.prototype.queue_xinha_update_textarea = function()
{
var blurry = this;
if(!this._attach_blur)
{
Xinha._addEvent(this.editor._iframe, 'blur', function(){ blurry.xinha_update_textarea(); }); // IE
Xinha._addEvent(this.editor._doc, 'blur', function(){ blurry.xinha_update_textarea(); }); // GECKO
this._attach_blur = 1;
}
}
SaveOnBlur.prototype.xinha_update_textarea = function()
{
this.editor._textArea.value=this.editor.outwardHtml(this.editor.getHTML());
}
/**
* WYSIWYG Wrap Plugin
*
* The purpose of this plugin is to wrap the content being edited in Xinha
* with certain elements of given ID and/or class when in the WYSIWYG view.
*
* The reason for this is to assist when styling content.
*
*/
WysiwygWrap._pluginInfo = {
name : "WYSIWYG Wrap",
version : "1.0",
developer : "James Sleeman",
developer_url : "http://www.gogo.co.nz/",
c_owner : "James Sleeman",
license : "htmlArea"
};
Xinha.Config.prototype.WysiwygWrap =
{
'elements' : [ ]
// 'elements' : [ 'div.class#id', 'ul', 'li' ]
};
function WysiwygWrap(editor) {
this.editor = editor;
}
/** Take HTML and wrap it with the elements.
*
* @param string
* @return string
*/
WysiwygWrap.prototype.inwardHtml = function(html)
{
for(var x = this.editor.config.WysiwygWrap.elements.length - 1; x >= 0; x--)
{
var e = { tagName: this.editor.config.WysiwygWrap.elements[x], className: '', id: '' };
if(e.tagName.match(/#(.+)$/))
{
e.id = RegExp.$1;
e.tagName = e.tagName.replace(/#(.+)$/,'');
}
if(e.tagName.match(/[^.]*\.(.+)$/))
{
e.className = RegExp.$1.replace('.', ' ');
e.tagName = e.tagName.replace(/\..+$/, '');
}
if(!e.tagName.length)
{
e.tagName = 'div';
}
html = '<'+e.tagName+' id="'+e.id+'" class="'+e.className+'">'+html+'</'+e.tagName+'>';
}
return html;
}
/** Take HTML and strip it from the elements.
*
* @param string
* @return string
*/
WysiwygWrap.prototype.outwardHtml = function(html)
{
for(var x = 0; x < this.editor.config.WysiwygWrap.elements.length; x++)
{
var e = { tagName: this.editor.config.WysiwygWrap.elements[x], className: '', id: '' };
if(e.tagName.match(/#(.+)$/))
{
e.id = RegExp.$1;
e.tagName = e.tagName.replace(/#(.+)$/,'');
}
if(e.tagName.match(/[^.]*\.(.+)$/))
{
e.className = RegExp.$1.replace('.', ' ');
e.tagName = e.tagName.replace(/\..+$/, '');
}
if(!e.tagName.length)
{
e.tagName = 'div';
}
var r1 = new RegExp('^(\\s|\\n|\\r)*<'+e.tagName+'[^>]*>(\\s|\\n|\\r)*', 'i');
var r2 = new RegExp('(\\s|\\n|\\r)*</'+e.tagName+'[^>]*>(\\s|\\n|\\r)*$', 'i');
html = html.replace(r1, '');
html = html.replace(r2, '');
}
return html;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment