CaScadeS
|
* Does everyone here understand the word "chrome"?
CaScadeS will live under Tools > CSS Editor menu
From
editor.xul:<!-- tasks menu filled from tasksOverlay --> <menu id="tasksMenu"> <menupopup id="taskPopup"> <menuitem id="menu_validate" observes="cmd_validate"/> <menuseparator id="sep_validate"/> </menupopup> </menu>A new overlay will create the new menu item
<overlay id="cascadesToolbar"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/x-javascript" src="chrome://cascades/content/cascadesOverlay.js"/>
<menupopup id="taskPopup">
<menuitem label="&cascadesMenuItem.label;"
accesskey="&cascadesMenuItem.accesskey;"
oncommand="openCascadesDialog();"
insertafter="menu_validate"/>
</menupopup>
</overlay>
function openCascadesDialog()
{
window.openDialog("chrome://cascades/content/EdCssProps.xul",
"_blank",
"chrome,close,modal,titlebar");
window._content.focus();
}
contents.rdf<?xml version="1.0"?>
<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:chrome="http://www.mozilla.org/rdf/chrome#">
<RDF:Seq about="urn:mozilla:package:root">
<RDF:li resource="urn:mozilla:package:cascades"/>
</RDF:Seq>
<RDF:Description about="urn:mozilla:package:cascades"
chrome:displayName="CaScadeS, the stylesheet editor"
chrome:author="Daniel Glazman"
chrome:name="cascades">
</RDF:Description>
<RDF:Seq about="urn:mozilla:overlays">
<RDF:li resource="chrome://editor/content/editor.xul"/>
</RDF:Seq>
<RDF:Seq about="chrome://editor/content/editor.xul">
<RDF:li>chrome://cascades/content/cascadesOverlay.xul</RDF:li>
</RDF:Seq>
</RDF:RDF>
Make it clean, make it localizable!!!
<?xml version="1.0"?>
<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:chrome="http://www.mozilla.org/rdf/chrome#">
<!-- list all the skins being supplied by this package -->
<RDF:Seq about="urn:mozilla:locale:root">
<RDF:li resource="urn:mozilla:locale:en-US"/>
</RDF:Seq>
<!-- locale information -->
<RDF:Description about="urn:mozilla:locale:en-US">
<chrome:packages>
<RDF:Seq about="urn:mozilla:locale:en-US:packages">
<RDF:li resource="urn:mozilla:locale:en-US:cascades"/>
</RDF:Seq>
</chrome:packages>
</RDF:Description>
<RDF:Description about="urn:mozilla:locale:en-US:cascades"
chrome:localeVersion="1.3b"/>
</RDF:RDF>
An install JS script registers the content and the locale parts.
The XPI file is a zip of the tree:
cascades03.xpi
cascades/
cascades/content/
cascades/content/contents.rdf
cascades/content/cascadesOverlay.js
cascades/content/cascadesOverlay.xul
cascades/content/commonCssProps.js
cascades/content/compatibility.js
cascades/content/EdCssProps-utils.js
cascades/content/EdCssProps.css
cascades/content/EdCssProps.js
cascades/content/EdCssProps.xul
cascades/content/tabsOverlay.xul
cascades/locale/
cascades/locale/en-US/
cascades/locale/en-US/contents.rdf
cascades/locale/en-US/cascadesOverlay.dtd
cascades/locale/en-US/EdCssProps.dtd
install.js
Make an install page:
function doneFn (name, result)
{
if (result != 0 && result != 999)
alert("The install didn't seem to work, you could maybe try " +
"a manual install instead.\nFailure code was " + result + ".");
else
alert("Installation complete, please restart your browser.");
}
function install(packageName, fileName)
{
var xpi = new Object();
xpi[packageName] = fileName;
InstallTrigger.install(xpi, doneFn);
}
<a href="javascript:install('cascades', 'cascades03.xpi');">Install CaScadeS</a>
http://xulplanet.com/
http://xulplanet.com/
#mozilla are very helpfulOverall, making such a CSS editor add-on was surprisingly easy and Mozilla is an incredible platform for extensible applications.