Author: thorsten
Date: Sat Oct 29 09:40:57 2005
New Revision: 329441
URL: http://svn.apache.org/viewcvs?rev=329441&view=rev
Log:
> El lun, 17-10-2005 a las 22:31 +0100, Kevin escribió:
> > Thought I'd post my work in progress in trying to do switchable
> > alternate css stylesheets. I call it theme switching though not
> > sure if that is the correct terminology.
The following branding-theme-switcher.ft is based on Kevin's mail and code. I
used his code examples partly (more the idea of it) because it did not
needed the cookie part.
FIXME: thorsten -> create a function that reads all possible themes and create
dynamic examples. Use the helper-prototype for do it.
Added:
forrest/trunk/main/template-sites/v2/src/documentation/resources/themes/default/html/branding-theme-switcher.ft
forrest/trunk/main/template-sites/v2/src/documentation/resources/themes/default/js/cssStyleSwitcher.js
(with props)
Added:
forrest/trunk/main/template-sites/v2/src/documentation/resources/themes/default/html/branding-theme-switcher.ft
URL:
http://svn.apache.org/viewcvs/forrest/trunk/main/template-sites/v2/src/documentation/resources/themes/default/html/branding-theme-switcher.ft?rev=329441&view=auto
==============================================================================
---
forrest/trunk/main/template-sites/v2/src/documentation/resources/themes/default/html/branding-theme-switcher.ft
(added)
+++
forrest/trunk/main/template-sites/v2/src/documentation/resources/themes/default/html/branding-theme-switcher.ft
Sat Oct 29 09:40:57 2005
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright 2002-2005 The Apache Software Foundation or its licensors,
+ as applicable.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<forrest:contract
+ xmlns:i18n="http://apache.org/cocoon/i18n/2.1"
+ xmlns:forrest="http://apache.org/forrest/templates/1.0"
+ name="branding-theme-switcher" type="nugget">
+
+ <description>
+ <p> <strong>branding-theme-switcher</strong> provides a way to switch the
+ underlying stylesheets (it not a "real" theme switcher). </p>
+ <pre class="code"><![CDATA[A theme is a presentation layer that provides
an aggregation of
+a) theme structure information (*.fv)
+b) theme style information (*.css & *.png|jpg|gif|...)
+c) theme functionality (*.js & *.ft)]]> </pre>
+ <p> A "real" theme switcher would change a/b/c. </p>
+ <p> A "real" color-theme switcher should also provide a possibility to
+ change each color with a WEB-GUI. </p>
+ </description>
+ <usage><![CDATA[<forrest:contract name="branding-theme-switcher"/>]]></usage>
+ <forrest:template xmlns:forrest="http://apache.org/forrest/templates/1.0"
+ format="html" name="branding-theme-switcher" inputFormat="xsl" body="true"
head="true">
+ <xsl:stylesheet version="1.1"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+ <xsl:template name="branding-theme-switcher-head">
+ <!--<xsl:param name="branding-theme-switcher"/>
+ <xsl:param name="branding-theme-switcher-theme"/>-->
+ <script type="text/javascript" language="javascript"
+ src="{$root}themes/cssStyleSwitcher.js"> </script>
+ </xsl:template>
+ <xsl:template name="branding-theme-switcher-body">
+ <!--<xsl:param name="branding-theme-switcher"/>
+ <xsl:param name="branding-theme-switcher-theme"/>-->
+ Theme-switcher:<br/>
+ <div id="theme-switcher-static">static:<br/>
+ as links: <a href="javascript:switchTheme('default')">default</a>|<a
href="javascript:switchTheme('Pelt')">pelt</a>
+ <form action="">
+ <select name="themeChanger" onchange="switchThemeSelect(this);">
+ <option value="-1">Select a theme</option>
+ <option value="default">Default</option>
+ <option value="Pelt">Pelt</option>
+ </select>
+ </form>
+ </div>
+ </xsl:template>
+ </xsl:stylesheet>
+ </forrest:template>
+</forrest:contract>
\ No newline at end of file
Added:
forrest/trunk/main/template-sites/v2/src/documentation/resources/themes/default/js/cssStyleSwitcher.js
URL:
http://svn.apache.org/viewcvs/forrest/trunk/main/template-sites/v2/src/documentation/resources/themes/default/js/cssStyleSwitcher.js?rev=329441&view=auto
==============================================================================
---
forrest/trunk/main/template-sites/v2/src/documentation/resources/themes/default/js/cssStyleSwitcher.js
(added)
+++
forrest/trunk/main/template-sites/v2/src/documentation/resources/themes/default/js/cssStyleSwitcher.js
Sat Oct 29 09:40:57 2005
@@ -0,0 +1,45 @@
+/*
+* Copyright 2002-2005 The Apache Software Foundation or its licensors,
+* as applicable.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+/*
+* Note: this script depends on prototype.js
+*
+* cssStyleSwitcher.js
+*/
+function switchTheme(title){
+ for(var i = 0; i <document.getElementsByTagName("link").length; i++) {
+ var a = document.getElementsByTagName("link")[i];
+ //deactivate all screen css
+ if (a.getAttribute("media") == "screen") {
+ a.disabled=true;
+ }
+ }
+ //activate the selected theme
+ for(var i = 0; i <document.getElementsByTagName("link").length; i++) {
+ var a = document.getElementsByTagName("link")[i];
+ if (a.getAttribute("media") == "screen" ) {
+ a.disabled = (a.getAttribute("title") == title)?false:true;
+ }
+ }
+}
+/* change the active (preferred) stylesheet to the selected one and save it */
+function switchThemeSelect(selBox){
+ var selIndex= selBox.selectedIndex; // get the selected index
+ var title= selBox.options[selIndex].value; // get the value of this index
+ if (title == "-1") return false;
+ switchTheme(title); // do the actual switch
+} // end method switchThemeSelect()
\ No newline at end of file
Propchange:
forrest/trunk/main/template-sites/v2/src/documentation/resources/themes/default/js/cssStyleSwitcher.js
------------------------------------------------------------------------------
svn:eol-style = native