Changeset 1084
- Timestamp:
- 03/11/08 07:39:17
- Files:
-
- qPloneTabs/branches/quintagroup.plonetabs/trunk/quintagroup/plonetabs/browser/kssactions.zcml (modified) (1 diff)
- qPloneTabs/branches/quintagroup.plonetabs/trunk/quintagroup/plonetabs/browser/plonetabs.py (modified) (6 diffs)
- qPloneTabs/branches/quintagroup.plonetabs/trunk/quintagroup/plonetabs/browser/resources/plonetabs.kss (modified) (4 diffs)
- qPloneTabs/branches/quintagroup.plonetabs/trunk/quintagroup/plonetabs/browser/templates/autogenerated.pt (modified) (1 diff)
- qPloneTabs/branches/quintagroup.plonetabs/trunk/quintagroup/plonetabs/plugins/plugin.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
qPloneTabs/branches/quintagroup.plonetabs/trunk/quintagroup/plonetabs/browser/kssactions.zcml
r1082 r1084 11 11 /> 12 12 13 <browser:page 14 for="plone.app.kss.interfaces.IPortalObject" 15 attribute="toggleActionsVisibility" 16 class=".plonetabs.PloneTabsControlPanel" 17 name="plonetabs-toggleActionsVisibility" 18 permission="cmf.ManagePortal" 19 /> 20 21 <browser:page 22 for="plone.app.kss.interfaces.IPortalObject" 23 attribute="toggleRootsVisibility" 24 class=".plonetabs.PloneTabsControlPanel" 25 name="plonetabs-toggleRootsVisibility" 26 permission="cmf.ManagePortal" 27 /> 28 13 29 </configure> qPloneTabs/branches/quintagroup.plonetabs/trunk/quintagroup/plonetabs/browser/plonetabs.py
r1082 r1084 1 from Acquisition import aq_inner 2 1 3 from zope.interface import implements 2 from zope.component import getUtility 4 from zope.component import getUtility, getMultiAdapter 3 5 from zope.i18n import translate 4 6 from zope.schema.interfaces import IVocabularyFactory … … 7 9 8 10 from Products.CMFCore.utils import getToolByName 11 from Products.CMFCore.interfaces import IAction 9 12 from Products.CMFEditions.setuphandlers import DEFAULT_POLICIES 10 13 from Products.CMFPlone import PloneMessageFactory as _ … … 19 22 from plone.app.workflow.remap import remap_workflow 20 23 from plone.memoize.instance import memoize 21 from kss.core import kssaction 24 from kss.core import kssaction, KSSExplicitError 22 25 23 26 from quintagroup.plonetabs.config import * … … 63 66 def getPortalActions(self, category="portal_tabs"): 64 67 """ See interface """ 65 return getToolByName(self.context, "portal_actions").listActions(categories=[category,]) 68 portal_actions = getToolByName(self.context, "portal_actions") 69 70 if category not in portal_actions.objectIds(): 71 return [] 72 73 actions = [] 74 for item in portal_actions[category].objectValues(): 75 if IAction.providedBy(item): 76 actions.append(item) 77 78 return actions 66 79 67 80 def isGeneratedTabs(self): … … 165 178 166 179 @kssaction 167 def toggleGeneratedTabs(self, field, checked= "0"):180 def toggleGeneratedTabs(self, field, checked='0'): 168 181 """ Toggle autogenaration setting on configlet """ 169 182 170 183 changeProperties = getToolByName(self.context, "portal_properties").site_properties.manage_changeProperties 171 if checked == "1":184 if checked == '1': 172 185 changeProperties(**{field : False}) 173 186 else: … … 180 193 ksscore.replaceInnerHTML(ksscore.getHtmlIdSelector(replace_id), content, withKssSetup="True") 181 194 182 195 # update global-sections viewlet 183 196 self.updateGlobalSections(ksscore) 184 197 185 186 198 @kssaction 199 def toggleActionsVisibility(self, id, checked='0', category=None): 200 """ Toggle visibility for portal actions """ 201 portal_actions = getToolByName(self.context, "portal_actions") 202 203 if category not in portal_actions.objectIds(): 204 raise KSSExplicitError, "Unexistent root portal actions category %s" % category 205 206 # remove prefix, added for making ids on configlet unique ("tabslist_") 207 act_id = id[len("tabslist_"):] 208 209 cat_container = portal_actions[category] 210 if act_id not in cat_container.objectIds(): 211 raise KSSExplicitError, "%s action does not exist in %s category" % (act_id, category) 212 213 if checked == '1': 214 checked = True 215 else: 216 checked = False 217 218 cat_container[act_id].visible = checked 219 220 ksscore = self.getCommandSet("core") 221 if checked: 222 ksscore.removeClass(ksscore.getHtmlIdSelector(id), value="invisible") 223 else: 224 ksscore.addClass(ksscore.getHtmlIdSelector(id), value="invisible") 225 226 # update global-sections viewlet 227 self.updateGlobalSections(ksscore) 228 229 @kssaction 230 def toggleRootsVisibility(self, id, checked='0'): 231 """ Toggle visibility for portal root objects (exclude_from_nav) """ 232 portal = getMultiAdapter((aq_inner(self.context), self.request), name='plone_portal_state').portal() 233 234 # remove prefix, added for making ids on configlet unique ("roottabs_") 235 obj_id = id[len("roottabs_"):] 236 237 if obj_id not in portal.objectIds(): 238 raise KSSExplicitError, "Object with %s id doesn't exist in portal root" % obj_id 239 240 if checked == '1': 241 checked = True 242 else: 243 checked = False 244 245 portal[obj_id].update(excludeFromNav=not checked) 246 247 ksscore = self.getCommandSet("core") 248 if checked: 249 ksscore.removeClass(ksscore.getHtmlIdSelector(id), value="invisible") 250 else: 251 ksscore.addClass(ksscore.getHtmlIdSelector(id), value="invisible") 252 253 # update global-sections viewlet 254 self.updateGlobalSections(ksscore) 255 256 257 258 259 qPloneTabs/branches/quintagroup.plonetabs/trunk/quintagroup/plonetabs/browser/resources/plonetabs.kss
r1083 r1084 11 11 /* Add class to body to allow conditional styling when kss is available */ 12 12 13 #actions_category:load { 14 action-client: setStateVar; 15 setStateVar-varname: plonetabs-category; 16 setStateVar-value: currentFormVar(); 17 } 18 13 19 #select_category:change { 14 20 action-client: plonetabs-redirectTo; … … 16 22 } 17 23 18 /* Hovering for IE especially */24 /* Hovering for IE especially 19 25 #app li:mouseover { 20 26 action-client: addClass; … … 26 32 removeClass-value: onHover; 27 33 } 28 } 34 */ 29 35 30 36 /* Automatically generated tabs */ … … 40 46 plonetabs-toggleGeneratedTabs-checked: currentFormVar(); 41 47 } 48 49 /* Visibility switching */ 50 #tabslist .visibility:click { 51 action-server: plonetabs-toggleActionsVisibility; 52 plonetabs-toggleActionsVisibility-id: nodeAttr(id, true); 53 plonetabs-toggleActionsVisibility-checked: currentFormVar(); 54 plonetabs-toggleActionsVisibility-category: stateVar(plonetabs-category); 55 } 56 57 #roottabs .visibility:click { 58 action-server: plonetabs-toggleRootsVisibility; 59 plonetabs-toggleRootsVisibility-id: nodeAttr(id, true); 60 plonetabs-toggleRootsVisibility-checked: currentFormVar(); 61 } qPloneTabs/branches/quintagroup.plonetabs/trunk/quintagroup/plonetabs/browser/templates/autogenerated.pt
r1082 r1084 12 12 <li tal:define="id tab/id; 13 13 visible python:not tab['exclude_from_nav']" 14 tal:attributes="id string: tabslist_${id};14 tal:attributes="id string:roottabs_${id}; 15 15 title tab/description|nothing; 16 16 class python:view.test(visible, '', 'invisible')"> 17 <div class="bridge"><input type="checkbox" class="visibility" value="1" id="id" name="rootvis" title="visibility" 18 tal:attributes="name string:i${repeat/tab/index}_${attrs/name}; 19 id id; 20 checked python:view.test(visible, 'checked', None)" /></div> 17 <div class="bridge"> 18 <input type="checkbox" class="visibility" value="1" name="rootvis" title="visibility" 19 tal:attributes="name string:i${repeat/tab/index}_${attrs/name}; 20 checked python:view.test(visible, 'checked', None)" /> 21 </div> 21 22 <span class="url-helper" tal:content="python:tab['url']">Tab Action</span> 22 23 <span class="tab-title" tal:content="tab/name">Tab Name</span> qPloneTabs/branches/quintagroup.plonetabs/trunk/quintagroup/plonetabs/plugins/plugin.js
r1082 r1084 1 2 /* Use onDOMLoad event to initialize kukit3 earlier then the document is fully loaded,4 but after the DOM is at its place already.5 6 This functionality is missing from Plone 2.1,7 the script is present in >=2.5, but it is not8 always added to RR - it needs to be added manually.9 10 If it's present we use it.11 */12 1 13 2 kukit.plonetabs = {};
