Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update faqfolder_view.pt #3

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Products/Faq/configure.zcml
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<configure xmlns="http://namespaces.zope.org/zope"
xmlns:five="http://namespaces.zope.org/five"
xmlns:i18n="http://namespaces.zope.org/i18n"
xmlns:browser="http://namespaces.zope.org/browser"
i18n_domain="faq">

<five:registerPackage package="." initialize=".initialize" />
Expand All @@ -10,4 +11,10 @@
<include file="skins.zcml" />
<include file="profiles.zcml" />

<!-- Resource directory for stylesheets -->
<browser:resourceDirectory
name="Products.Faq"
directory="static"
/>

</configure>
27 changes: 21 additions & 6 deletions Products/Faq/content/FaqFolder.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from interfaces import IFaqFolder
from zope.interface import implements
from Products.ATContentTypes.atct import ATFolder, ATFolderSchema
from Products.Archetypes.public import IntegerField, Schema, \
IntegerWidget, registerType
from Products.Archetypes.public import Schema, registerType
from Products.Archetypes.atapi import *

from Products.Faq import config
from Products.Faq import faqMessageFactory as _
Expand All @@ -13,18 +13,33 @@
schema = ATFolderSchema.copy() + Schema((

IntegerField('delay',
widget=IntegerWidget(description=_(u"desc_delay",
default=u"Delay for a new item."),
widget=IntegerWidget(description=_(u"desc_delay",
default=u"Delay for a new item."),
label=_(u"label_delay", default=u"Delay")
),
default=7,
default=0,
required=1,
searchable=0,
validators=('isInt',)),

TextField("text",
required=0,
searchable=1,
allowable_content_types=('text/plain', 'text/structured', 'text/html', 'application/msword',),
default_output_type='text/html',
validators=("isTidyHtmlWithCleanup",),
widget = RichWidget(
label='Anlesertext',
label_msgid='faqfolder_label_text',
i18n_domain='faqfolder',
description='',
rows=20,
allow_file_upload=False,),
)
))

schema['description'].widget.label = _(u"label_folder", default=u"Description")
schema['description'].widget.description = _(u"desc_folder",
schema['description'].widget.description = _(u"desc_folder",
default=u"The description of the FAQ category.")

class FaqFolder(ATFolder):
Expand Down
4 changes: 4 additions & 0 deletions Products/Faq/profiles/default/jsregistry.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0"?>
<object name="portal_javascripts" meta_type="JavaScripts Registry">
<javascript id="++resource++Products.Faq/faq.js" compression="none" expression="" />
</object>
1 change: 1 addition & 0 deletions Products/Faq/skins.zcml
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
<!-- File System Directory Views registration -->
<cmf:registerDirectory
name="faq"/>

</configure>
71 changes: 38 additions & 33 deletions Products/Faq/skins/faq/faqfolder_view.pt
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
lang="en-US"
metal:use-macro="here/main_template/macros/master"
i18n:domain="faq">

<metal:javascriptslot fill-slot="javascript_head_slot">
<script type="text/javascript" language="JavaScript">
<!--
Expand Down Expand Up @@ -85,60 +85,65 @@
</h1>
<div tal:replace="structure provider:plone.belowcontenttitle" />

<p metal:use-macro="here/kss_generic_macros/macros/generic_description_view">
<p tal:content="structure context/text">
Description
</p>

<div tal:replace="structure provider:plone.abovecontentbody" />

<tal:faq define="faqs python:context.getFolderContents(contentFilter={'portal_type' :['FaqEntry']});
<tal:faq define="faqs python:context.queryCatalog( {'portal_type' :['FaqEntry'], 'path': { 'query': '/'.join(context.getPhysicalPath()),'depth': 2, }, } );
items python:len(faqs);
DateTime python:modules['DateTime'].DateTime;
datenow python: DateTime();">
<button class="context" i18n:translate="toggle_all" onclick="toggle_all(items)" tal:attributes="onclick python:'toggle_all(%s)' % items">Show/Hide all</button>
<dl>
<tal:entries repeat="entry python:[brain.getObject() for brain in faqs]">

<button class="context" i18n:translate="toggle_all" onclick="toggle_all(items)" tal:attributes="onclick python:'toggle_all(%s)' % items">Show/Hide all</button>

<dl tal:define="entries python:context.getFolderContents(contentFilter={'portal_type' :['FaqEntry']});" tal:condition="entries">
<tal:entries repeat="entry python:[brain.getObject() for brain in entries]">
<dt tal:define="md python:DateTime(entry.ModificationDate());
delay here/delay;">
<img i18n:attributes="title showhide_answer;alt showhide_answer" title="Show or Hide answer"
alt="Show or Hide answer"
<img i18n:attributes="title showhide_answer;" title="Show or Hide answer" alt=""
tal:attributes="id string:icon_${repeat/entry/number};
onclick string:javascript:toggle('${repeat/entry/number}');
src string:${portal_url}/treeCollapsed.gif;
onmouseover string:javascript:overLinkStyle('icon_${repeat/entry/number}');
onmouseout string:javascript:outLinkStyle('icon_${repeat/entry/number}')" />
src string:${portal_url}/treeCollapsed.gif;
onmouseover string:javascript:overLinkStyle('icon_${repeat/entry/number}');
onmouseout string:javascript:outLinkStyle('icon_${repeat/entry/number}')" />
<img i18n:attributes="alt new; title new" class="new" alt="New" title="New" src="" tal:attributes="src string:$portal_url/new.gif"
tal:condition="python: (md + delay).toZone('GMT+2').greaterThan(datenow)"/>
<a href="#" tal:content="entry/Title" tal:attributes="href string:javascript:toggle('${repeat/entry/number}');">Title</a>
</dt>
<dd class="faq_question" tal:content="entry/Description">Question</dd>
<dd class="faq_answer" tal:attributes="id string:faq_${repeat/entry/number}" tal:content="structure entry/getAnswer">Answer</dd>

</tal:entries>
</dl>
</tal:entries>
</dl>

<div tal:repeat="folder python:[brain.getObject() for brain in here.getFolderContents(contentFilter={'portal_type' :['FaqFolder']})]">
<h2><a href="" tal:content="folder/Title"
tal:attributes="href string:${folder/absolute_url}">Folder title</a></h2>
<p tal:condition="folder/Description|nothing" tal:content="folder/Description" />
<div tal:repeat="folder python:[brain.getObject() for brain in here.getFolderContents(contentFilter={'portal_type' :['FaqFolder']})]">
<h2 tal:content="folder/Title">Folder title</h2>
<p tal:condition="folder/Description | nothing" tal:content="folder/Description" />
<p tal:condition="folder/text" tal:content="structure folder/text" />

<dl tal:define="subentries python:[brain.getObject() for brain in folder.getFolderContents(contentFilter={'portal_type' :['FaqEntry']})]" tal:condition="subentries">
<dl tal:define="subentries python:[brain.getObject() for brain in folder.getFolderContents(contentFilter={'portal_type' :['FaqEntry']})];
faq python:[brain.getObject() for brain in faqs];"
tal:condition="subentries">
<tal:entries repeat="subentry subentries">
<dt tal:define="md python:DateTime(subentry.ModificationDate());
delay here/delay">
<img i18n:attributes="title showhide_answer" title="Show or Hide answer"
tal:attributes="id string:icon_${item};
onclick string:javascript:toggle('${item}');
src string:${portal_url}/treeCollapsed.gif;
onmouseover string:javascript:overLinkStyle('icon_${item}');
onmouseout string:javascript:outLinkStyle('icon_${item}')" />
<img alt="Icon new" src="" tal:attributes="src string:$portal_url/new.gif"
tal:condition="python: (md + delay).toZone('GMT+2').greaterThan(datenow)"/>
<a href="#" tal:content="subentry/Title" tal:attributes="href string:javascript:toggle('${item}');">Title</a>
</dt>
<dd class="faq_question" tal:content="subentry/Description">Question</dd>
<dd class="faq_answer" tal:attributes="id string:faq_${item}" tal:content="structure subentry/getAnswer" tal:on-error="nothing">Answer</dd>

<span tal:define="num python:str(faq.index(subentry)+1)" tal:omit-tag="">
<dt tal:define="md python:DateTime(subentry.ModificationDate());
delay here/delay;"
tal:attributes="class string:faq_${num}">
<img i18n:attributes="title showhide_answer" title="Show or Hide answer" alt=""
tal:attributes="id string:icon_${num};
onclick string:javascript:toggle('${num}');
src string:${portal_url}/treeCollapsed.gif;
onmouseover string:javascript:overLinkStyle('icon_${num}');
onmouseout string:javascript:outLinkStyle('icon_${num}')" />
<img alt="Icon new" src="" tal:attributes="src string:$portal_url/new.gif"
tal:condition="python: (md + delay).toZone('GMT+2').greaterThan(datenow)"/>
<a href="#" tal:content="subentry/Title" tal:attributes="href string:javascript:toggle('${num}');">Title</a>
</dt>
<dd class="faq_question" tal:content="subentry/Description">Question</dd>
<dd class="faq_answer" tal:attributes="id string:faq_${num}" tal:content="structure subentry/getAnswer" tal:on-error="nothing">Answer</dd>
</span>
</tal:entries>
</dl>
</div>
Expand Down
44 changes: 44 additions & 0 deletions Products/Faq/static/faq.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/* ! FAQ Scripts */

displayAll = 0;
items = 0;

function toggle(id) {
el = document.getElementById("faq_" + id);
icon = document.getElementById("icon_" + id);

if (el) {
if (el.style.display == "block"){
el.style.display = "none";
icon.src = "treeCollapsed.gif";
} else {
el.style.display = "block";
icon.src = "treeExpanded.gif";
}
}
}

function toggle_all(items) {
for(var i = 1; i <= items; i++) {
el = document.getElementById("faq_" + i);
icon = document.getElementById("icon_" + i);
if (el) {
if (displayAll) {
el.style.display = "none";
icon.src = "treeCollapsed.gif";
} else {
el.style.display = "block";
icon.src = "treeExpanded.gif";
}
}
}
displayAll = (displayAll ? 0 : 1);
}

function overLinkStyle(link_id) {
document.getElementById(link_id).style.cursor = 'pointer';
}

function outLinkStyle(link_id) {
document.getElementById(link_id).style.cursor = 'default';
}
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from setuptools import setup, find_packages
import os

version = '1.3.dev0'
version = '1.3.iz1'

setup(name='Products.Faq',
version=version,
Expand Down