Skip to content

Instantly share code, notes, and snippets.

View davglass's full-sized avatar
💭
Taking a much needed sabbatical from Open Source. Please fork and carry on.

Dav Glass davglass

💭
Taking a much needed sabbatical from Open Source. Please fork and carry on.
View GitHub Profile
//Regex to strip the HTML tags from a string
var stripHTML = /<\S[^><]*>/g;
//Get the HTML from the Editor, assuming myEditor is your Editor reference
var html = myEditor.saveHTML();
//Remove the HTML tags from the returned string
var text = html.replace(stripHTML, '');
//Get the word count from the text string
//Snippet from event-debug.js
_worker = function(delegateKey, e, el) {
var target = resolveTextNode((e.target || e.srcElement)),
tests = delegates[delegateKey],
spec,
ename,
elements,
nElements,
(function() {
var Dom = YAHOO.util.Dom,
Event = YAHOO.util.Event;
var myEditor = new YAHOO.widget.Editor('editor', {
height: '300px',
width: '600px',
dompath: true,
//Hide all the images in the document.
extracss: 'img { display: none; }',
YUI().use('node', function(Y) {
var node = Y.Node.create('<div id="hasalink"><a class="blah" href="#">my link!</a></div>');
node.query('.blah').on('click', function(e) {
//do domething
e.preventDefault();
});
Y.get('#parent').appendChild(node);
});
myEditor.on('windowRender', function() {
myEditor.get('panel').cfg.setProperty('fixedcenter', true);
});
//Get the HTML from the Editor
var html = myEditor.saveHTML(),
//Filter the URL
url = myEditor._baseHREF.replace(/\//gi, '\\/'),
//Create a RegEx object from the URL
re = new RegExp('href="' + url, 'gi');
//Replace the HTML
html = html.replace(re, 'href="');
YUI.add('my-examples', function(Y) {
Y.namespace('MyNamespace');
Y.MyNamespace.MyClass = function() {
Y.MyNamespace.MyClass.superclass.constructor.apply(this, arguments);
};
Y.MyNamespace.MyClass.NAME = "myClass";
Y.MyNamespace.MyClass.ATTRS = {
myAttribute: {
value: "defaultValue"
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Event Bubbling</title>
</head>
<body>
<script src="http://yui.yahooapis.com/3.0.0b1/build/yui/yui-min.js" type="text/javascript"></script>
<script>
YUI().use('event', 'base', function(Y) {
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Event Bubbling</title>
</head>
<body>
<script src="http://yui.yahooapis.com/3.0.0b1/build/yui/yui-min.js" type="text/javascript"></script>
<script>
YUI().use('event', 'base', function(Y) {
//Add this after you include simpleeditor.js but before you call new YAHOO.widget.SimpleEditor
YAHOO.widget.SimpleEditor.prototype._handleCreateLinkClink = function() {
if (this.get('limitCommands')) {
if (!this.toolbar.getButtonByValue('createlink')) {
YAHOO.log('Toolbar Button for (createlink) was not found, skipping exec.', 'info', 'SimpleEditor');
return false;
}
}