可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
(Note: While I'm not entirely sure if this be better asked on SuperUser, I guess the fact that you probably will have to mess around in the xpi/jar file with the css settings, should make it suitable for SO.)
Mozilla Thunderbird's Calendar extension, Lightning, will use different colors for different calendars, and just use a narrow vertical bar for the category color: (Light blue as calendar color and red as category color)
What I would like to find out is how I could go about changing/"hacking" the css styles that - surely - must be associated with this, buried somewhere in the plugin directory, so that in the example above, the event would be fully colored red.
Anyone know how to achieve this?
回答1:
The category-overlay.png image is merely a gradient overlay to give the category bar the right looks.
Two options here. One more easy but not as reliable, the other a bit more difficult:
Option A: Easy
Create a userChrome.css in your $profile/chrome/ directory. It should contain the following:
.calendar-color-box[categories~="mycategory"],
.calendar-event-box-container[categories~="mycategory"] {
background-color: #abc123 !important;
}
You'll need to do this for each category you'd like to change the color for. Note that changing the color of the category in the Lightning options won't change the category color you set here.
Option B: More complete
You'll need to modify some files inside lightning.xpi here. This solution merely requires you to set the category colors in Lightning and will also work for newly added categories. Note that this way events without a category are transparent, if you want more you'll have to do it on your own.
- Open lightning.xpi with a zip program
- Enter the directory chrome/
- Open the containing calendar.jar with a zip program
- Descend into content/calendar/
- Open calendar-multiday-view.xml
- search "calendar-color-box" and remove it from the class attribute
- a few lines above there is a <content> tag, add class="category-color-box" to it
- Open calendar-month-view.xml and calendar-view-core.xml and do the same
- Save the files back to calendar.jar
- Save calendar.jar back to lightning.xpi
- Install the modified lightning.xpi
If you'd rather see a patch, this applies to the latest comm-central source:
diff --git a/calendar/base/content/calendar-month-view.xml b/calendar/base/content/calendar-month-view.xml
--- a/calendar/base/content/calendar-month-view.xml
+++ b/calendar/base/content/calendar-month-view.xml
@@ -52,21 +52,20 @@
<bindings id="calendar-month-view-bindings"
xmlns="http://www.mozilla.org/xbl"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:xbl="http://www.mozilla.org/xbl">
<binding id="calendar-month-day-box-item" extends="chrome://calendar/content/calendar-view-core.xml#calendar-editable-item">
- <content mousethrough="never" tooltip="itemTooltip">
+ <content mousethrough="never" tooltip="itemTooltip" class="category-color-box">
<xul:vbox flex="1">
<xul:hbox>
<xul:box anonid="event-container"
- class="calendar-color-box"
xbl:inherits="calendar-uri,calendar-id"
flex="1">
<xul:box class="calendar-event-selection" orient="horizontal" flex="1">
<xul:stack anonid="eventbox"
class="calendar-event-box-container"
xbl:inherits="readonly,flashing,alarm,allday,priority,progress,status,calendar,categories"
flex="1">
<xul:hbox class="calendar-event-details">
diff --git a/calendar/base/content/calendar-multiday-view.xml b/calendar/base/content/calendar-multiday-view.xml
--- a/calendar/base/content/calendar-multiday-view.xml
+++ b/calendar/base/content/calendar-multiday-view.xml
@@ -2119,20 +2119,19 @@
]]></handler>
</handlers>
</binding>
<!--
- An individual event box, to be inserted into a column.
-->
<binding id="calendar-event-box" extends="chrome://calendar/content/calendar-view-core.xml#calendar-editable-item">
- <content mousethrough="never" tooltip="itemTooltip">
+ <content mousethrough="never" tooltip="itemTooltip" class="category-color-box">
<xul:box xbl:inherits="orient,width,height" flex="1">
<xul:box anonid="event-container"
- class="calendar-color-box"
xbl:inherits="orient,readonly,flashing,alarm,allday,priority,progress,status,calendar,categories,calendar-uri,calendar-id"
flex="1">
<xul:box class="calendar-event-selection" orient="horizontal" flex="1">
<xul:stack anonid="eventbox"
align="stretch"
class="calendar-event-box-container"
flex="1"
xbl:inherits="context,parentorient=orient,readonly,flashing,alarm,allday,priority,progress,status,calendar,categories">
diff --git a/calendar/base/content/calendar-view-core.xml b/calendar/base/content/calendar-view-core.xml
--- a/calendar/base/content/calendar-view-core.xml
+++ b/calendar/base/content/calendar-view-core.xml
@@ -46,21 +46,21 @@
xmlns="http://www.mozilla.org/xbl"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:xbl="http://www.mozilla.org/xbl">
<binding id="calendar-editable-item">
<content mousethrough="never"
tooltip="itemTooltip"
- tabindex="-1">
+ tabindex="-1"
+ class="category-color-box">
<xul:vbox flex="1">
<xul:hbox>
<xul:box anonid="event-container"
- class="calendar-color-box"
xbl:inherits="calendar-uri,calendar-id"
flex="1">
<xul:box class="calendar-event-selection" orient="horizontal" flex="1">
<xul:stack anonid="eventbox"
class="calendar-event-box-container"
flex="1"
xbl:inherits="readonly,flashing,alarm,allday,priority,progress,status,calendar,categories">
<xul:hbox class="calendar-event-details">
Option C: Change Javascript
This would be the best working hack, although it requires javascript changes. Open calendar.jar as described in Option B and check out calendar-views.js, there are two functions: updateStyleSheetForViews()
and updateStyleSheetForCategory()
. I'll leave this to people that want to tinker with it themselves, but the idea would be to add a rule for .calendar-color-box[categories~=...]
that overrides the default rule in case there are categories. This way if there is no category set, the calendar color is used, otherwise the desired category color.
Have fun :)
回答2:
This extension looks perfect for the functionality you want.
https://addons.mozilla.org/en-us/thunderbird/addon/calendar-tweaks/
To have just this, uncheck all the options, and check these:
- apply category color to event backgruonds
- use calendar color if no category color
回答3:
You should install the DOM Inspector addon to understand the XUL structure of an event. Together with userChrome.css you should be able to style it the way you want it.
回答4:
Image of daily calendar
Image of weekly calendar
ALL CODE BY: TOUT SÉLECTIONNER
This is a several step process that I have translated from a french website. I am simply making a note of what worked for me. This is for thunderbird 3.1.9. for the lightning-1-1.0b2-tb-macosx.xpi plugin. These directions were written April 8th, 2011. These directions are specifically for Mac users, although you can probably use them for windows as well.
Anything in ALL CAPS, means that you need to swap out your own information. Example: YOUREMAIL@gmail.com
Part 1:
- Find your profile folder. Something similar to: MachintoshHD/Users/YOURUSERNAME/Library/Thunderbird/Profiles/RANDOMLETTERS.default
- Create a folder in here called "chrome"
- Create a file called userChrome.css and save it into the chrome folder. You can create a .css file with a regular text editor, as long as it has a .css extention. I used dreamweaver, and a free program called JEdit, and text edit - all worked fine for me.
- Inside of the CSS file you will paste the code below. (Note any text surrounded by
/* */
is not recognized as code by thunderbird (or anything that reads .css) It is only there as a notation by the person(s) that coded it. Example /*TEXT*/
The Code:
@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"); /* set default namespace to XUL */
.calendar-event-box-container[categories] { margin: 1px !important;} /* add margin to the category-box */
.calendar-color-box:not([categories]) { color: black !important; background-color: #A6A6A6 !important;} /* events without category will appear grey */
calendar-category-box:not([categories]) { display: block !important; } /* category-box always displayed even if event doesn't have a category */
/* 2- using the calendar uri (much better) */
.category-color-box[calendar-uri="http://my.caldav.server/path/to/file"]{ background-color: #FF0000 !important; display:block !important; float:right;}
/* display the category-box with the specified color (forced color of the calendar) */
/* for each category, assign a forced color
each category must be spelled lowercase in the css, spaces replaced with '_'
I didn't make any test with accents... but they may work (lowercase, spaces -> _) eg: "Appel Téléphonique" -> "appel_téléphonique"
*/
.calendar-color-box[categories="CATEGORY_NAME1"] { color: black !important; background-color: #CCCCFF !important;}
.calendar-color-box[categories="CATEGORY_NAME2"] { color: black !important; background-color: #FF99FF !important;}
.calendar-color-box[categories="CATEGORY_NAME3"] { color: black !important; background-color: #FF0000 !important;}
.calendar-color-box[categories="CATEGORY_NAME4"] { color: black !important; background-color: #CC33CC !important;}
.calendar-color-box[categories="CATEGORY_NAME5"] { color: black !important; background-color: #0000FF !important;}
Part 2: Now comes the complex part - taking apart the lightening plugin, one step at a time, putting it back together and loading it as a modified plugin into Thunderbird.
- Download the lightning plugin for thunderbird (lightning-1-1.0b2-tb-macosx.xpi). It will have a .xpi extension.
- An .xip file is the same thing as a zip file. Right-click the file, click on "get info" and change the extension to .zip instead of .xpi. It should look like this
lightning-1-1.0b2-tb-macosx.zip. Or you can rename it. Example: ORIGINALPLUGIN.zip
- Unzip the file by double-clicking on it. If this does not work, you may need to download an unzipping software (such as stuffit expander for mac).
- Inside the folder, find the calendar.jar file. You can find it here: ORIGINALPLUGIN FOLDER/chrome/calendar.jar
- Rename calendar.jar to calendar.zip, unzip this file.
- Now you need to find three more files (copy them into a new area.)
/content/calendar/calendar-month-view.xml
/content/calendar/calendar-multiday-view.xml
/content/calendar/calendar-view-core.xml
- Make the following edits in these files using a program such as JEdit.
The symbol "<" means remove this line
The symbol ">" means add this line in it's place
CODE BY: TOUT SÉLECTIONNER
-> calendar/content/calendar/calendar-month-view.xml
Line 64
< xbl:inherits="calendar-uri,calendar-id"
> xbl:inherits="calendar-uri,calendar-id,categories"
Line 95
< <xul:calendar-category-box anonid="category-box" xbl:inherits="categories" pack="end"/>
> <xul:calendar-category-box anonid="category-box" xbl:inherits="categories,calendar-uri" pack="end"/>
-> calendar/content/calendar/calendar-multiday-view.xml
Line 2135
< <xul:calendar-category-box anonid="category-box" xbl:inherits="categories" pack="end" />
> <xul:calendar-category-box anonid="category-box" xbl:inherits="categories,calendar-uri" pack="end" />
-> calendar/content/calendar/calendar-view-core.xml
Line 59
< xbl:inherits="calendar-uri,calendar-id"
> xbl:inherits="calendar-uri,calendar-id,categories"
Line 84
< xbl:inherits="categories"
> xbl:inherits="categories,calendar-uri"
Line 394
< xbl:inherits="categories">
> xbl:inherits="categories,calendar-uri">
Part 3:
- Once the changes are made save each file.
- Replace the original files in the unzipped calendar folder
- Select the "skin" and "content" folders. Right-click and select "compress 2 items". If you zip the folder and not the individual files, this may not work.
- Rename this file calendar.jar
- Replace the original calendar.jar file with the new one you just created. (see Part 2, step 4) ORIGINALPLUGIN FOLDER/chrome/calendar.jar
Select the contents of the ORIGINALPLUGIN FOLDER.
Calendar-js
chrome
chrome.manifest
components
defaults
install.rdf
modules
timezones.sqlite
Right-click the selected items and select "compress 8 items"
- Rename the zip file to ANYNAMEYOUWANT.xpi For instance you can name it modifiedLightningPlug.xpi
- Load the plug-in: Open thunderbird>Tools>Add-ons>Plugins>install
- Locate the ANYNAMEYOUWANT.xpi file, let it load, and restart Thunderbird.
. . . and that should be it. It worked for me. I will check back to see if anyone else had luck with this, if not, I will double check my notes.Thanks to TOUT SÉLECTIONNER for writing the oringial code.
回答5:
Just updated the way i've done things with the different ideas on this page...
I was the author of the "french post" and I just needed another way to inverse colors...
So there it is for your pleasure (and my users too !!)
This is a unified diff ouptut of the modifications made on the lightning xpi (more precisely the calendar.jar package inside of it)
You may find all the informations on the original post :
http://www.geckozone.org/forum/viewtopic.php?f=22&t=89384&start=15#p646027
For the non french speakers, here is some translation :
Hello everybody,
Here is a more correct version of the changes.
The big plus compared to my previous proposal is that we do not need anymore to define the colors of categories / calendars in the file userChrome.css that is also not used at all!
Overall:
Apply changes to XML files to allow the use of "calendar-id" and "categories" on the various elements of the DOM.
Update the file "calendar-views.js" to apply the parameterized color categories and calendars but by inverting them.
Finally, some css changes in "calendar-views.css" for:
- Always show the border and a margin of 1px (rendering is better I think ...)
- A gray color (# ACACAC ") to the uncategorized events
- Change only the color of the calendar (ie the right border) when selecting an element (by adding the property ".calendar-event-box-container")
Also, the image /skin/calendar/category-overlay.png has been expanded to increase the size of the border ...
Note: It only remains to put all this stuff as an option, but I did not have time to look over there at the moment ... But if one of you can give me some avenues of research, I will give it a try !
All the best :)
Vincent
回答6:
Thanks to speedballs answer I was able to locate the file that controls the Category Overlay: There is a PNG file under:
....\extensions\{e2fda1a4-762b-4020-b5ad-a41df1933103}\chrome\calendar.jar\
skin\calendar\category-overlay.png
The width of this file is 7px, and enlarging it's width will enlarge the Category Color Overlay in the calendar view. (I just used GIMP to scale it horizontally.)
So it would appear that it is not possible to use the category to fully color the whole event, as it's color is only mapped in via a "hardwired" pixel-width of the overlay png.
回答7:
I am not a programming person so I found a way around modifying codes.
You can go around that by creating several individual calendars (e.g. that you can call work, personal, birthdays, etc.). You can choose the background color of each calendar. If you make the calendars all visible at the same time (by checking the calendar boxes on the left side), what you enter in each calendar will have a different background color, not just a stripe to the right.
When you create a new event, instead of selecting a category, leave 'none' for category but select a calendar in the calendar dropdown menu and assign your event to a particular calendar (each have different background colors).
The only downside of that is that you need to export all individual calendars if you would like to export your calendars at some point. But otherwise it works.