To allow scrolling in Safari mobile, we set the content of text_view_comments frame in a jQuery UI layout.
So the automated scrolling operations in c_sync.js must be adjustable to the right part to scroll.
Also, if a comment have to be shown outside of the current viewport, we scroll the correct part to that viewport
and then set the comment top Y offset to juste what it needs to avoid the "Add comment" button after scrolling
operation.
If not in Safari mobile, we add an offset here to avoid comment to display under the "Add comment" button.
# This is the denormalisation engine
# his goal is to leverage on django's signal to update
# denormalized fields
# this should be used with beanstalk or starling
# python client (there is 2) http://github.com/earl/beanstalkc/tree/master
import logging
from django.db.models import signals
from cm.models import TextVersion, Text
# Text denormalisation
def update_text_from_last_version(sender, **kwargs):
"""
Update text's last version
"""
text_version = kwargs['instance']
try:
text = text_version.text
text.update_denorm_fields()
except Text.DoesNotExist:
pass
#logging.warning('No text found for text_version: %i' %text_version.id)
# GIB when deleting last revision, do not delete related text
def delete_last_version (sender, instance, signal, *args, **kwargs):
if instance.id == instance.text.last_text_version_id:
previous = instance.get_previous_version()
if previous:
instance.text.last_text_version_id = previous.id
instance.text.save()
def connect_all():
# text updated by text_version
signals.pre_delete.connect(delete_last_version, sender=TextVersion)
signals.post_save.connect(update_text_from_last_version, sender=TextVersion)
signals.post_delete.connect(update_text_from_last_version, sender=TextVersion)
connect_all()