Merge commit '4635b91554' into WebGUI8. Syntax clean up to 7.10.2

This commit is contained in:
Colin Kuskie 2010-10-27 15:59:33 -07:00
commit 87326192a3
46 changed files with 956 additions and 969 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

View file

@ -0,0 +1,63 @@
The UKPLayer is licensed under the terms of the GNU General Public License, version 2
http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
SWFObject 2, the code used to display the Slideshow, is licensed under the MIT License
http://www.opensource.org/licenses/mit-license.php
The UKPlayer makes use of three libraries that are compatible with GPL v.2. These are:
PureMVC (Creative Commons Attribution Licence 3.0)
http://puremvc.org/
Tweener (BSD Licence)
http://code.google.com/p/tweener/wiki/License
Hydrotik (licence see below)
http://blog.hydrotik.com/
/*
* Copyright 2007-2008 (c) Donovan Adams, http://blog.hydrotik.com/
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/

View file

@ -0,0 +1,290 @@
United Knowledge Slideshow Player - readme.txt
Copyright: United Knowledge, 2009
The Slideshow PLayer is licensed under the terms of the GNU General Public License, version 2
http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
SWFObject 2, the code used to display the Slideshow, is licensed under the MIT License
http://www.opensource.org/licenses/mit-license.php
Check out the latest source on:
http://git.st.unitedknowledge.org/git/ukplayer.git
git clone git://git.st.unitedknowledge.org/ukplayer.git
git clone http://git.st.unitedknowledge.org/git/ukplayer.git
More information about licences can be found in the file licences.txt in this directory.
**********************************************************************************************
* *
* The configuration XML *
* *
**********************************************************************************************
With the configuration .xml file you can customize the look and the behaviour of the
slideshow. It contains the following properties (the values are example values; there are
default values for most, but we recommend setting ALL properties yourself).
**********************************************************************************************
* Structure of the xml *
**********************************************************************************************
<config>
[properties go here]
</config>
**********************************************************************************************
* General properties *
**********************************************************************************************
<content_url>/someUrl/someXmlFile.xml</content_url>
The url to the .xml file that contains the content.
Value: an absolute or relative url to an xml file
<width>400</width>
<height>300</height>
The width and height of the player itself (this value is overwritten by the flashVars
but the tags need to be here).
Value: number in px
<default_duration>8</default_duration>
The duration of each slide. This can be overwritten by setting the duration per slide
in the content .xml file.
Value: number in seconds
<default_slidewidth>400</default_slidewidth>
<default_slideheight>300</default_slideheight>
If the width or height of a slide is larger than the values specified here, the slide
will be resized proportionally. Slides that are smaller than the slidshow will not be
resized.
Value: number in px
<background_color>0xeeeeee</background_color>
The background color for the slideshow. This will be visible during the transitions
and when a slide is smaller than the slideshow.
Value: 0x followed by hexadecimal color
<skin>rounded</skin>
The textarea, controls and thumbnails can be displayed with two different skins.
Value: simple or rounded
**********************************************************************************************
* Text properties *
**********************************************************************************************
<font>Verdana</font>
The font of the text in the slideshow.
Value: Verdana, Arial or TimesNewRoman
<font_size>12</font_size>
The font size of the text in the slideshow.
Value: number in px
<font_color>0xffffff</font_color>
The color of the text in the slideshow.
Value: 0x followed by hexadecimal color
<text_border_color>0xffffff</text_border_color>
The color of the border of the textarea.
Value: 0x followed by hexadecimal color
<text_bg_color>0x000000</text_bg_color>
The background color of the textarea.
Value: 0x followed by hexadecimal color
<text_autohide>false</text_autohide>
When set to true the textarea will hide after a few seconds.
Value: true or false
<text_display>over</text_display>
The textarea can be postioned over the slides, above the slides (the height of the player
should be the sum of the height of the slides and the height of the textarea) or can be
hidden.
Value: over, above or none
<text_height>50</text_height>
The minimum height of the textarea.
Value: number in px
**********************************************************************************************
* Controls properties *
**********************************************************************************************
<controls_color>0xffffff</controls_color>
The color of the buttons.
Value: 0x followed by hexadecimal color
<controls_border_color>0xffffff</controls_border_color>
The color of the border of the area with the buttons.
Value: 0x followed by hexadecimal color
<controls_bg_color>0x000000</controls_bg_color>
The background color of the area with the buttons.
Value: 0x followed by hexadecimal color
<controls_autohide>true</controls_autohide>
When set to true the controls will hide after a few seconds.
Value: true or false
<playbutton_percent_width>20</playbutton_percent_width>
The width of the big play button (which appears when auto_start is false and, if loop is
set to false, after the slideshow has finished) can be set in a percentage of the total
width of the movie.
Value: percentage of movie width
<playbutton_max_width>200</playbutton_max_width>
A maximum width for the play button to prevent it from becoming too large.
Value: number in px
**********************************************************************************************
* Thumbnail properties *
**********************************************************************************************
<thumbnail_width>40</thumbnail_width>
<thumbnail_height>30</thumbnail_height>
The height and width of each thumbnail image in the bar at the bottom of the
slideshow.
Value: number in px
<thumbnail_border_color>0x888888</thumbnail_border_color>
The color of the border of each thumbnail image.
Value: 0x followed by hexadecimal color
<menu_autohide>true</menu_autohide>
When set to true the thumbnail bar will hide after a few seconds.
Value: true or false
<menu_dead_zone_width>160</menu_dead_zone_width>
The width of the area in the center of the thumbnail bar in which the user can hover
the mouse, without the thumbnail bar moving to the left or to the right.
Value: number in px
<menu_gaps>6</menu_gaps>
The width of the gap between two thumbnail images.
Value: number in px
<thumbnails_hide>false</thumbnails_hide>
When set to true, the thumbnails are hidden.
Value: true or false
**********************************************************************************************
* Behaviour properties *
**********************************************************************************************
<mute_at_start>true</mute_at_start>
If true the slideshow will start with the sound muted.
Value: true or false
<sound>off</sound>
If the sound is turned off, the audio files will not be played and the mute and volume
controls will be hidden.
Value: on or off
<autostart>false</autostart>
If true the slideshow will start upon loading. If false a play button will be
displayed.
Value: true or false
<autopause>true</autopause>
If true the slideshow will pause when clicking on a thumbnail or clicking the
previous or next buttons.
Value: true or false
<loop>false</loop>
If true the slideshow will loop. If false, when the last slide has been displayed,
the slideshow will move back to the first slide and show a play button.
Value: true or false
**********************************************************************************************
* Error messages *
**********************************************************************************************
<error_message_content><![CDATA[Content Xml not found]]></error_message_content>
<error_message_image><![CDATA[Image not found]]></error_message_image>
Value: any text in CDATA tags: <![CDATA[ ... ]]>
**********************************************************************************************
* *
* The content XML *
* *
**********************************************************************************************
The content .xml file contains the properties for each slide.
**********************************************************************************************
* Structure of the xml *
**********************************************************************************************
<content>
<slides>
<slide>[properties go here]</slide>
<slide>[properties go here]</slide>
...
</slides>
</content>
**********************************************************************************************
* Properties in the slide tag *
**********************************************************************************************
<title><![CDATA[My first slide]]></title>
The title of the slide.
Value: any text in CDATA tags: <![CDATA[ ... ]]>
<description><![CDATA[This is my first slide!]]></description>
The description of the slide.
Value: any text in CDATA tags: <![CDATA[ ... ]]>
<image_source>/someUrl/someImg.jpg</image_source>
The url to the slide image.
Value: an absolute or relative url to a .jpg, .gif or .png file
<thumb_source>/someUrl/someImg_thumb.jpg</thumb_source>
The url to the thumbnail of the slide image.
Value: an absolute or relative url to a .jpg, .gif or .png file
<sound_source>/someUrl/someImg_thumb.jpg</sound_source>
The url to the sound file that will be played when the slide is displayed. It will be
played once for the duration of the slide (if the duration of the sound file is longer
than the set duration of the slide it will be cut off). This property is optional.
Value: an absolute or relative url to a .mp3 file
<duration>8</duration>
The duration for this specific slide. This value will overwrite the duration value set
in the configuration xml. This property is optional.
Value: number in seconds
<width>400</width>
<height>300</height>
The width and height of the slide. This will overwrite the default_slidewidth and
default_slideheight set in the configuration xml. The width and height properties are
optional.
Value: number in px
**********************************************************************************************
* eof *
**********************************************************************************************

View file

@ -0,0 +1,80 @@
<!DOCTYPE html PUBLIC "-/W3C/DTD XHTML 1.0 Strict/EN" "http:/www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http:/www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>UKplayer Slideshow Demo</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="swfobject.js"></script>
<script type="text/javascript">
swfobject.registerObject("myFlashContent","9.0.0","expressInstall.swf");
</script>
</head>
<body>
<!--
This is the United Knowledge Player for WebGUI.
It enables you to display photo's as a movie. The
configuration options can be found in the readme
file here:
/extras/ukplayer/readme.txt
There are three example files to show you how to
use this player:
/extras/ukplayer/slideshow.html
/extras/ukplayer/config.xml
/extras/ukplayer/content.xml
This player is Free Software under the GPL v2
Check out the latest source on:
http://git.st.unitedknowledge.org/git/ukplayer.git
git clone git://git.st.unitedknowledge.org/ukplayer.git
git clone http://git.st.unitedknowledge.org/git/ukplayer.git
Copyright 2008-2010 United Knowledge http:/www.unitedknowledge.nl/
-->
<div>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="400" height="300" id="myFlashContent">
<param name="movie" value="slideShow.swf" />
<param name="flashvars" value="config=config.xml" />
<!--[if !IE]>-->
<object type="application/x-shockwave-flash" data="slideShow.swf" width="400" height="300">
<param name="flashvars" value="config=config.xml" />
<!--<![endif]-->
<a href="http:/www.adobe.com/go/getflashplayer">
<img src="http:/www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />
</a>
<!--[if !IE]>-->
</object>
<!--<![endif]-->
</object>
</div>
<p>Code generated with the <a href="http://www.bobbyvandersluis.com/swfobject/generator/index.html">SWFObject 2 HTML and JavaScript generator</a>.</p>
<textarea rows="25" cols="130">
<script type="text/javascript" src="^Extras(ukplayer/swfobject.js);"></script>
<script type="text/javascript">
swfobject.registerObject("myFlashContent","9.0.0","^Extras(ukplayer/expressInstall.swf);");
</script>
<div>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="400" height="300" id="myFlashContent">
<param name="movie" value="^Extras(ukplayer/slideShow.swf);" />
<param name="flashvars" value="config=^Extras(ukplayer/config.xml);" />
<!--[if !IE]>-->
<object type="application/x-shockwave-flash" data="^Extras(ukplayer/slideShow.swf);" width="400" height="300">
<param name="flashvars" value="config=^Extras(ukplayer/config.xml);" />
<!--<![endif]-->
<a href="http:/www.adobe.com/go/getflashplayer">
<img src="http:/www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />
</a>
<!--[if !IE]>-->
</object>
<!--<![endif]-->
</object>
</div>
</textarea>
</body>
</html>

View file

@ -1,747 +0,0 @@
/*
* HTML Parser By John Resig (ejohn.org)
* Original code by Erik Arvidsson, Mozilla Public License
* http://erik.eae.net/simplehtmlparser/simplehtmlparser.js
*
* // Use like so:
* HTMLParser(htmlString, {
* start: function(tag, attrs, unary) {},
* end: function(tag) {},
* chars: function(text) {},
* comment: function(text) {}
* });
*
* // or to get an XML string:
* HTMLtoXML(htmlString);
*
* // or to get an XML DOM Document
* HTMLtoDOM(htmlString);
*
* // or to inject into an existing document/DOM node
* HTMLtoDOM(htmlString, document);
* HTMLtoDOM(htmlString, document.body);
*
*/
(function(){
// Regular Expressions for parsing tags and attributes
var startTag = /^<(\w+)((?:\s+\w+(?:\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|[^>\s]+))?)*)\s*(\/?)>/,
endTag = /^<\/(\w+)[^>]*>/,
attr = /(\w+)(?:\s*=\s*(?:(?:"((?:\\.|[^"])*)")|(?:'((?:\\.|[^'])*)')|([^>\s]+)))?/g;
// Empty Elements - HTML 4.01
var empty = makeMap("area,base,basefont,br,col,frame,hr,img,input,isindex,link,meta,param,embed");
// Block Elements - HTML 4.01
var block = makeMap("address,applet,blockquote,button,center,dd,del,dir,div,dl,dt,fieldset,form,frameset,hr,iframe,ins,isindex,li,map,menu,noframes,noscript,object,ol,p,pre,script,table,tbody,td,tfoot,th,thead,tr,ul");
// Inline Elements - HTML 4.01
var inline = makeMap("a,abbr,acronym,applet,b,basefont,bdo,big,br,button,cite,code,del,dfn,em,font,i,iframe,img,input,ins,kbd,label,map,object,q,s,samp,script,select,small,span,strike,strong,sub,sup,textarea,tt,u,var");
// Elements that you can, intentionally, leave open
// (and which close themselves)
var closeSelf = makeMap("colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr");
// Attributes that have their values filled in disabled="disabled"
var fillAttrs = makeMap("checked,compact,declare,defer,disabled,ismap,multiple,nohref,noresize,noshade,nowrap,readonly,selected");
// Special Elements (can contain anything)
var special = makeMap("script,style");
var HTMLParser = this.HTMLParser = function( html, handler ) {
var index, chars, match, stack = [], last = html;
stack.last = function(){
return this[ this.length - 1 ];
};
while ( html ) {
chars = true;
// Make sure we're not in a script or style element
if ( !stack.last() || !special[ stack.last() ] ) {
// Comment
if ( html.indexOf("<!--") == 0 ) {
index = html.indexOf("-->");
if ( index >= 0 ) {
if ( handler.comment )
handler.comment( html.substring( 4, index ) );
html = html.substring( index + 3 );
chars = false;
}
// end tag
} else if ( html.indexOf("</") == 0 ) {
match = html.match( endTag );
if ( match ) {
html = html.substring( match[0].length );
match[0].replace( endTag, parseEndTag );
chars = false;
}
// start tag
} else if ( html.indexOf("<") == 0 ) {
match = html.match( startTag );
if ( match ) {
html = html.substring( match[0].length );
match[0].replace( startTag, parseStartTag );
chars = false;
}
}
if ( chars ) {
index = html.indexOf("<");
var text = index < 0 ? html : html.substring( 0, index );
html = index < 0 ? "" : html.substring( index );
if ( handler.chars )
handler.chars( text );
}
} else {
html = html.replace(new RegExp("(.*)<\/" + stack.last() + "[^>]*>"), function(all, text){
text = text.replace(/<!--(.*?)-->/g, "$1")
.replace(/<!\[CDATA\[(.*?)]]>/g, "$1");
if ( handler.chars )
handler.chars( text );
return "";
});
parseEndTag( "", stack.last() );
}
if ( html == last )
throw "Parse Error: " + html;
last = html;
}
// Clean up any remaining tags
parseEndTag();
function parseStartTag( tag, tagName, rest, unary ) {
if ( block[ tagName ] ) {
while ( stack.last() && inline[ stack.last() ] ) {
parseEndTag( "", stack.last() );
}
}
if ( closeSelf[ tagName ] && stack.last() == tagName ) {
parseEndTag( "", tagName );
}
unary = empty[ tagName ] || !!unary;
if ( !unary )
stack.push( tagName );
if ( handler.start ) {
var attrs = [];
rest.replace(attr, function(match, name) {
var value = arguments[2] ? arguments[2] :
arguments[3] ? arguments[3] :
arguments[4] ? arguments[4] :
fillAttrs[name] ? name : "";
attrs.push({
name: name,
value: value,
escaped: value.replace(/(^|[^\\])"/g, '$1\\\"') //"
});
});
if ( handler.start )
handler.start( tagName, attrs, unary );
}
}
function parseEndTag( tag, tagName ) {
// If no tag name is provided, clean shop
if ( !tagName )
var pos = 0;
// Find the closest opened tag of the same type
else
for ( var pos = stack.length - 1; pos >= 0; pos-- )
if ( stack[ pos ] == tagName )
break;
if ( pos >= 0 ) {
// Close all the open elements, up the stack
for ( var i = stack.length - 1; i >= pos; i-- )
if ( handler.end )
handler.end( stack[ i ] );
// Remove the open elements from the stack
stack.length = pos;
}
}
};
this.HTMLtoXML = function( html ) {
var results = "";
HTMLParser(html, {
start: function( tag, attrs, unary ) {
results += "<" + tag;
for ( var i = 0; i < attrs.length; i++ )
results += " " + attrs[i].name + '="' + attrs[i].escaped + '"';
results += (unary ? "/" : "") + ">";
},
end: function( tag ) {
results += "</" + tag + ">";
},
chars: function( text ) {
results += text;
},
comment: function( text ) {
results += "<!--" + text + "-->";
}
});
return results;
};
this.HTMLtoDOM = function( html, doc ) {
// There can be only one of these elements
var one = makeMap("html,head,body,title");
// Enforce a structure for the document
var structure = {
link: "head",
base: "head"
};
if ( !doc ) {
if ( typeof DOMDocument != "undefined" )
doc = new DOMDocument();
else if ( typeof document != "undefined" && document.implementation && document.implementation.createDocument )
doc = document.implementation.createDocument("", "", null);
else if ( typeof ActiveX != "undefined" )
doc = new ActiveXObject("Msxml.DOMDocument");
} else
doc = doc.ownerDocument ||
doc.getOwnerDocument && doc.getOwnerDocument() ||
doc;
var elems = [],
documentElement = doc.documentElement ||
doc.getDocumentElement && doc.getDocumentElement();
// If we're dealing with an empty document then we
// need to pre-populate it with the HTML document structure
if ( !documentElement && doc.createElement ) (function(){
var html = doc.createElement("html");
var head = doc.createElement("head");
head.appendChild( doc.createElement("title") );
html.appendChild( head );
html.appendChild( doc.createElement("body") );
doc.appendChild( html );
})();
// Find all the unique elements
if ( doc.getElementsByTagName )
for ( var i in one )
one[ i ] = doc.getElementsByTagName( i )[0];
// If we're working with a document, inject contents into
// the body element
var curParentNode = one.body;
HTMLParser( html, {
start: function( tagName, attrs, unary ) {
// If it's a pre-built element, then we can ignore
// its construction
if ( one[ tagName ] ) {
curParentNode = one[ tagName ];
return;
}
var elem = doc.createElement( tagName );
for ( var attr in attrs )
elem.setAttribute( attrs[ attr ].name, attrs[ attr ].value );
if ( structure[ tagName ] && typeof one[ structure[ tagName ] ] != "boolean" )
one[ structure[ tagName ] ].appendChild( elem );
else if ( curParentNode && curParentNode.appendChild )
curParentNode.appendChild( elem );
if ( !unary ) {
elems.push( elem );
curParentNode = elem;
}
},
end: function( tag ) {
elems.length -= 1;
// Init the new parentNode
curParentNode = elems[ elems.length - 1 ];
},
chars: function( text ) {
curParentNode.appendChild( doc.createTextNode( text ) );
},
comment: function( text ) {
// create comment node
}
});
return doc;
};
function makeMap(str){
var obj = {}, items = str.split(",");
for ( var i = 0; i < items.length; i++ )
obj[ items[i] ] = true;
return obj;
}
})();
(function() {
var Dom = YAHOO.util.Dom,
Event = YAHOO.util.Event,
Lang = YAHOO.lang
;
YAHOO.widget.CodeEditor = function (id, cfg) {
// TODO: Make a cfg for off by default
this.editorState = "on";
// Disable Editor configs that don't apply
cfg["animate"] = false;
cfg["dompath"] = false;
cfg["focusAtStart"] = false;
// Default toolbar is different
cfg["toolbar"] = cfg["toolbar"] || {
titlebar : "Code Editor",
buttons : []
};
YAHOO.widget.CodeEditor.superclass.constructor.call(this, id, cfg);
// Allow us to have no buttons
// This will be fixed in a future version of YUI Editor
YAHOO.widget.Toolbar.prototype.disableAllButtons
= function () {
if (!this._buttonList) {
this._buttonList = [];
}
if (this.get('disabled')) {
return false;
}
var len = this._buttonList.length;
for (var i = 0; i < len; i++) {
this.disableButton(this._buttonList[i]);
}
};
// End allow us to have no buttons
this.on('editorContentLoaded', function() {
// Add the code stylesheet
var link = this._getDoc().createElement('link');
link.rel = "stylesheet";
link.type = "text/css";
link.href = this.get('css_url');
this._getDoc().getElementsByTagName('head')[0].appendChild(link);
// Highlight the initial value
if ( this.getEditorText() != this.old_text ) {
Lang.later(10, this, function () { this.highlight(true) } );
if ( this.status ) {
Lang.later(100, this, this._writeStatus);
}
this.old_text = this.getEditorText();
}
// Setup resize
if ( this.status ) {
this._setupResize();
}
}, this, true);
this.on('editorKeyUp', function(ev) {
// Highlight only if content has changed
if ( this.getEditorText() != this.old_text ) {
Lang.later(10, this, this.highlight);
if ( this.status ) {
Lang.later(100, this, this._writeStatus);
}
this.old_text = this.getEditorText();
}
}, this, true);
//Borrowed this from CodePress: http://codepress.sourceforge.net
this.cc = '\u2009'; // carret char
// TODO: Make this configurable based on a syntax definition
this.keywords = [
{ code: /(&lt;DOCTYPE.*?--&gt.)/g, tag: '<ins>$1</ins>' }, // comments
{ code: /(&lt;[^!]*?&gt;)/g, tag: '<b>$1</b>' }, // all tags
{ code: /(&lt;!--.*?--&gt.)/g, tag: '<ins>$1</ins>' }, // comments
{ code: /\b(YAHOO|widget|util|Dom|Event|lang)\b/g, tag: '<cite>$1</cite>' }, // reserved words
{ code: /\b(break|continue|do|for|new|this|void|case|default|else|function|return|typeof|while|if|label|switch|var|with|catch|boolean|int|try|false|throws|null|true|goto)\b/g, tag: '<b>$1</b>' }, // reserved words
{ code: /\"(.*?)(\"|<br>|<\/P>)/gi, tag: '<s>"$1$2</s>' }, // strings double quote
{ code: /\'(.*?)(\'|<br>|<\/P>)/gi, tag: '<s>\'$1$2</s>' }, // strings single quote
{ code: /\b(alert|isNaN|parent|Array|parseFloat|parseInt|blur|clearTimeout|prompt|prototype|close|confirm|length|Date|location|Math|document|element|name|self|elements|setTimeout|navigator|status|String|escape|Number|submit|eval|Object|event|onblur|focus|onerror|onfocus|onclick|top|onload|toString|onunload|unescape|open|valueOf|window|onmouseover|innerHTML)\b/g, tag: '<u>$1</u>' }, // special words
{ code: /([^:]|^)\/\/(.*?)(<br|<\/P)/gi, tag: '$1<i>//$2</i>$3' }, // comments //
{ code: /\/\*(.*?)\*\//g, tag: '<i>/*$1*/</i>' } // comments / * */
];
//End Borrowed Content
if ( cfg["toggleButton"] ) {
var editor = this;
// Add toggle button
var button = document.createElement("input");
button.type = "button";
button.value = "Toggle Editor";
Event.addListener( button, "click", function () {
if ( editor.editorState == "off" ) {
editor.editorState = "on";
var fc = editor.get('element').previousSibling,
el = editor.get('element');
Dom.setStyle(fc, 'position', 'static');
Dom.setStyle(fc, 'top', '0');
Dom.setStyle(fc, 'left', '0');
Dom.setStyle(el, 'visibility', 'hidden');
Dom.setStyle(el, 'top', '-9999px');
Dom.setStyle(el, 'left', '-9999px');
Dom.setStyle(el, 'position', 'absolute');
editor.get('element_cont').addClass('yui-editor-container');
YAHOO.log('Reset designMode on the Editor', 'info', 'example');
editor._setDesignMode('on');
YAHOO.log('Inject the HTML from the textarea into the editor', 'info', 'example');
// Escape HTML
var div = document.createElement("div");
var text = editor.get('textarea').value;
// IE truncates whitespace internally, so go line by line
var lines = text.split(/\n/);
for ( var i = 0; i < lines.length; i++ ) {
var line = lines[i];
YAHOO.log( i + ": " + line, "info", "CodeEditor" );
div.appendChild( document.createTextNode( line ) );
div.appendChild( document.createElement( "br" ) );
}
var html = div.innerHTML;
// We have <br>, not \n
html = html.replace(/\n/g,"");
YAHOO.log( html, "info", "CodeEditor" );
editor.setEditorHTML(html);
editor.highlight();
}
else {
editor.editorState = "off";
editor.saveHTML();
var fc = editor.get('element').previousSibling,
el = editor.get('element');
Dom.setStyle(fc, 'position', 'absolute');
Dom.setStyle(fc, 'top', '-9999px');
Dom.setStyle(fc, 'left', '-9999px');
editor.get('element_cont').removeClass('yui-editor-container');
Dom.setStyle(el, 'visibility', 'visible');
Dom.setStyle(el, 'top', '');
Dom.setStyle(el, 'left', '');
Dom.setStyle(el, 'position', 'static');
// Unescape HTML
var div = document.createElement("div");
var text = editor.getEditorText();
// IE truncates all whitespace internally, so add HTML for it
if ( editor.browser.ie && editor.browser.ie <= 8 ) {
text = text.replace(/\n/g, "&nbsp;<br>");
text = text.replace(/\t/g, "&nbsp;&nbsp;&nbsp;&nbsp;");
}
div.innerHTML = text;
editor.get('element').value = "";
for ( var i = 0; i < div.childNodes.length; i++ ) {
if ( div.childNodes[i].nodeName == "#text" ) {
editor.get('element').value = editor.get('element').value
+ div.childNodes[i].nodeValue
+ "\n"
;
}
}
YAHOO.log( editor.getEditorText(), "info", "CodeEditor" );
YAHOO.log( div.childNodes[0].nodeValue, "info", "CodeEditor" );
YAHOO.log( editor.get('element').value, "info", "CodeEditor" );
}
} );
// Put it right after the text area
var ta = document.getElementById( id );
if ( ta.nextSibling ) {
ta.parentNode.insertBefore( button, ta.nextSibling );
}
else {
ta.parentNode.appendChild( button );
}
}
};
Lang.extend( YAHOO.widget.CodeEditor, YAHOO.widget.SimpleEditor, {
/**
* @property _defaultCSS
* @description The default CSS used in the config for 'css'. This way you can add to the config like this: { css: YAHOO.widget.SimpleEditor.prototype._defaultCSS + 'ADD MYY CSS HERE' }
* @type String
*/
_defaultCSS: 'html { height: 95%; } body { background-color: #fff; font:13px/1.22 arial,helvetica,clean,sans-serif;*font-size:small;*font:x-small; } a, a:visited, a:hover { color: blue !important; text-decoration: underline !important; cursor: text !important; } .warning-localfile { border-bottom: 1px dashed red !important; } .yui-busy { cursor: wait !important; } img.selected { border: 2px dotted #808080; } img { cursor: pointer !important; border: none; } body.ptags.webkit div { margin: 11px 0; }'
});
/**
* @private
* @method _cleanIncomingHTML
* @description Clean up the HTML that the textarea starts with
*/
YAHOO.widget.CodeEditor.prototype._cleanIncomingHTML = function(str) {
// Workaround for bug in Lang.substitute
str = str.replace(/{/gi, 'RIGHT_BRACKET');
str = str.replace(/}/gi, 'LEFT_BRACKET');
// &nbsp; before <br> for IE8- so lines show up correctly
if ( this.browser.ie && this.browser.ie <= 8 ) {
str = str.replace(/\r?\n/g, "&nbsp;<br>");
}
// Fix tabs into softtabs
str = str.replace(/\t/g, '&nbsp;&nbsp;&nbsp;&nbsp;'); // TODO: Make softtabs configurable
return str;
};
/* Override to fix problem with the rest of what the normal _handleFormSubmit does
* ( it doesn't properly click the correct submit button )
*/
YAHOO.widget.CodeEditor.prototype._handleFormSubmit = function () {
if ( this.editorState == "on" ) {
this.saveHTML();
}
return;
};
/* End override to fix problem */
/**
* @private
* @method _writeStatus
* @description Write the number of Characters and Lines to the status line
*/
YAHOO.widget.CodeEditor.prototype._writeStatus = function () {
if ( this.status ) {
var text = this.getEditorText();
this.status.innerHTML
= 'C: ' + text.length
+ ' L: ' + text.split(/\r?\n/).length
;
}
};
/**
* @private
* @method _setupResize
* @description Creates the Resize instance and binds its events.
*/
YAHOO.widget.CodeEditor.prototype._setupResize
= function() {
if (!YAHOO.util.DD || !YAHOO.util.Resize) { return false; }
if (this.get('resize')) {
var config = {};
Lang.augmentObject(config, this._resizeConfig); //Break the config reference
this.resize = new YAHOO.util.Resize(this.get('element_cont').get('element'), config);
this.resize.on('resize', function(args) {
var anim = this.get('animate');
this.set('animate', false);
this.set('width', args.width + 'px');
var h = args.height,
th = (this.toolbar.get('element').clientHeight + 2),
dh = 0;
if (this.status) {
dh = (this.status.clientHeight + 1); //It has a 1px top border..
}
var newH = (h - th - dh);
this.set('height', newH + 'px');
this.get('element_cont').setStyle('height', '');
this.set('animate', anim);
}, this, true);
}
};
/*
* @method cleanHTML
* @description Reduce the HTML in the editor to plain text to be put back in the
* textarea. Called by saveHTML()
*/
YAHOO.widget.CodeEditor.prototype.cleanHTML = function (html) {
if (!html) {
html = this.getEditorHTML();
}
// Handle special-case HTML
html = html.replace(/(&nbsp;){4}/g,"\t"); // TODO: make softtabs configurable
html = html.replace(/&nbsp;/g," ");
// Remove spaces at end of lines
html = html.replace(/ ?<br>/gi,'\n');
// Parse the text out of the remaining HTML
text = "";
HTMLParser( html, {
chars : function (t) { text += t }
} );
// If, after all this, we are left with only a \n, user didn't add anything
// (editor adds a <br> if it starts blank)
if ( text == "\n" ) {
text = "";
}
return text;
};
/*
* @method focusCaret
* @description I don't actually know what this does, it was like this when I got here
*/
YAHOO.widget.CodeEditor.prototype.focusCaret = function() {
if (this.browser.gecko) {
if (this._getWindow().find(this.cc)) {
this._getSelection().getRangeAt(0).deleteContents();
}
} else if (this.browser.webkit || this.browser.ie || this.browser.opera) {
var cur = this._getDoc().getElementById('cur');
if ( cur ) {
cur.id = '';
cur.innerHTML = '';
this._selectNode(cur);
}
}
};
/**
* @method getEditorText
* @description Get the text inside the editor, removing any HTML used for highlighting
*/
YAHOO.widget.CodeEditor.prototype.getEditorText
= function () {
var html = this.getEditorHTML();
var text = this.cleanHTML( html );
return text;
};
/**
* @method highlight
* @description Apply the syntax highlighting to the content of the editor
* @param {Boolean} focus If true, editor currently has focus
*/
YAHOO.widget.CodeEditor.prototype.highlight = function(focus) {
// Opera support is not working yet
if ( this.browser.opera ) {
return;
}
// Firefox < 3 support is not working yet
if ( this.browser.gecko && this.browser.gecko <= 1.8 ) {
return;
}
// Keep track of where the cursor is right now
if (!focus) {
if (this.browser.gecko) {
this._getSelection().getRangeAt(0).insertNode(this._getDoc().createTextNode(this.cc));
} else if (this.browser.webkit || this.browser.ie || this.browser.opera) {
try {
this.execCommand('inserthtml', this.cc);
}
catch (e) {}
}
}
// Remove existing highlighting
var html = this.getEditorText();
// Fix line breaks
html = html.replace( /\t/g, "&nbsp;&nbsp;&nbsp;&nbsp;" );
if ( this.browser.ie ) {
html = html.replace( /\n/g, "&nbsp;<br>" );
}
else {
html = html.replace( /\n/g, "<br>");
}
// Apply new highlighting
for (var i = 0; i < this.keywords.length; i++) {
html = html.replace(this.keywords[i].code, this.keywords[i].tag);
}
// Replace cursor
if ( !this.browser.gecko ) {
html = html.replace(this.cc, '<span id="cur">|</span>');
}
this._getDoc().body.innerHTML = html;
if (!focus) {
this.focusCaret();
}
};
/**
* @method initAttributes
* @description Initializes all of the configuration attributes used to create
* the editor.
* @param {Object} attr Object literal specifying a set of
* configuration attributes used to create the editor.
*/
YAHOO.widget.CodeEditor.prototype.initAttributes
= function(attr) {
YAHOO.widget.CodeEditor.superclass.initAttributes.call(this, attr);
var self = this;
/**
* @attribute status
* @description Toggle the display of a status line below the editor
* @default false
* @type Boolean
*/
this.setAttributeConfig('status', {
value: attr.status || false,
method: function(status) {
if (status && !this.status) {
this.status = document.createElement('DIV');
this.status.id = this.get('id') + '_status';
Dom.addClass(this.status, 'dompath'); // Piggy-back on Editor's dompath
this.get('element_cont').get('firstChild').appendChild(this.status);
if (this.get('iframe')) {
this._writeStatus();
}
} else if (!status && this.status) {
this.status.parentNode.removeChild(this.status);
this.status = null;
}
}
});
/**
* @attribute css_url
* @description The URL to the CSS file for the inside of the code editor
* @default 'code.css'
* @type String
*/
this.setAttributeConfig('css_url', {
value: attr.css_url || 'code.css'
} );
};
})();

View file

@ -1,9 +0,0 @@
body { background:white url(line-numbers.png) repeat-y scroll 0pt -4px; font-family:monospace; font-size:13px; height:100%; line-height:16px; margin-left:32px; margin-top:8px; white-space:pre; }
b, i, s, u, a, em, tt, ins, big, cite, strong, var, dfn {text-decoration:none;font-weight:normal;font-style:normal;font-size:13px;}
b, cite {color:#7F0055;font-weight:bold;} /* reserved words */
u {color:darkblue;font-weight:bold;} /* special words */
i, i b, i s, i u {color:green;font-weight:normal;} /* comments */
s, s b, s u {color:#2A00FF;font-weight:normal;} /* strings */
ins, ins b, ins s, ins em {color:green;} /* comments */
a {color:blue; text-decoration: underline; } /* links */
body.ie { padding-left: 32px; margin-left: 0px; background-position: 0 -10px; margin-top: 0px;}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB