Commits

Ralph Bean committed aa7fc93

Added utility method.

Comments (0)

Files changed (2)

 
 setup(
     name='tw2.jqplugins.gritter',
-    version='2.0b2',
+    version='2.0b3',
     description='toscawidgets2 wrapper for jquery gritter plugin.',
     long_description=long_description,
     author='Ralph Bean',
     license='MIT',
     url='http://github.com/ralphbean/tw2.jqplugins.gritter',
     install_requires=[
+        "simplejson",
         "tw2.core>=2.0b2",
         "tw2.jquery",
         "tw2.jqplugins.ui>=2.0b7",

tw2/jqplugins/gritter/base.py

 # TW2 proper imports
 import tw2.core as twc
 
+import simplejson
+
 jquery_gritter_js = twc.JSLink(
     modname='tw2.jqplugins.gritter',
     filename='static/jquery/gritter/js/jquery.gritter.min.js'
     jquery_gritter_css,
     jquery_gritter_dir,
 ]
+
+def gritter_callback(**kw):
+    """ Return js_callbacks that create gritter popups.
+
+    >>> gritter_callback(title="Some Title", text="A message...")
+
+    """
+    json = simplejson.dumps(kw)
+    return twc.js_callback('function() { $.gritter.add(%s); }' % json)