Skip to content

Commit

Permalink
Merge 3bae35c into b63ff67
Browse files Browse the repository at this point in the history
  • Loading branch information
djowett committed Apr 28, 2015
2 parents b63ff67 + 3bae35c commit b43e938
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
35 changes: 35 additions & 0 deletions docs/developer.rst
Expand Up @@ -257,3 +257,38 @@ If you switch from the default 16-column Deco grid to another grid with a differ
these saved layouts will still contain a 16-column width and this can mock up your design in small ways.
In that case,
make sure you clear the default cover layouts and/or save your own layout with the correct number of columns.

Row and Column Classes
++++++++++++++++++++++

``collective.cover`` enables you to set CSS classes on rows and columns in its layouts.
These classes are those listed in the Styles field of the @@cover-settings view, which is
also used for Tile styles.
This does mean that rows, columns and tiles will have the same list of classes available for styling.
If this is not satisfactory then the vocabularies ``collective.cover.RowColumnStyles`` and/or
``collective.cover.TileStyles`` can be overridden in your own product as shown below:

In **overrides.zcml**:

<utility
factory=".vocabularies.RowColumnStylesVocabulary"
provides="zope.schema.interfaces.IVocabularyFactory"
name="collective.cover.RowColumnStyles"
/>

**vocabularies.py**

from zope.schema.vocabulary import SimpleTerm
from zope.schema.vocabulary import SimpleVocabulary

class RowColumnStylesVocabulary(object):

def __call__(self, context):
items = []
items.append(SimpleTerm(value=u'row-default', title='Row Default'))
items.append(SimpleTerm(value=u'row-alternative', title='Row Alternative'))
items.append(SimpleTerm(value=u'column-default', title='Column Default'))
items.append(SimpleTerm(value=u'column-alternative', title='Column Alternative'))

return SimpleVocabulary(items)

5 changes: 3 additions & 2 deletions src/collective/cover/browser/cover.py
Expand Up @@ -5,7 +5,6 @@
from collective.cover.interfaces import ICover
from collective.cover.interfaces import IGridSystem
from collective.cover.tiles.list import ListTile
from collective.cover.vocabularies import TileStylesVocabulary
from five import grok
from plone import api
from plone.dexterity.events import EditBegunEvent
Expand All @@ -17,6 +16,7 @@
from zope.annotation.interfaces import IAnnotations
from zope.component import getUtility
from zope.event import notify
from zope.schema.interfaces import IVocabularyFactory

import json

Expand Down Expand Up @@ -152,7 +152,8 @@ class LayoutEdit(grok.View):

def update(self):
self.context = aq_inner(self.context)
vocab = TileStylesVocabulary()
vocab = getUtility(IVocabularyFactory,
'collective.cover.RowColumnStyles')
self.css_classes = vocab(self.context)
# XXX: used to lock the object when someone is editing it
notify(EditBegunEvent(self.context))
Expand Down
3 changes: 3 additions & 0 deletions src/collective/cover/vocabularies.py
Expand Up @@ -132,4 +132,7 @@ def __call__(self, context):

return SimpleVocabulary(items)

# CSS classes for tiles and for "rows & columns". Separate declarations even
# though they are the same means they can be overridden separately
grok.global_utility(TileStylesVocabulary, name=u'collective.cover.TileStyles')
grok.global_utility(TileStylesVocabulary, name=u'collective.cover.RowColumnStyles')

3 comments on commit b43e938

@hvelarde
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@djowett I think this is not clear enough; could you please ask someone else to see if they understand what are you trying to describe here?

@hvelarde
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@djowett isn't just easier to rename the original vocabulary from collective.cover.TileStyles to collective.cover.Styles?

@djowett
Copy link
Contributor Author

@djowett djowett commented on b43e938 Apr 28, 2015 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.