Commits

Ralph Bean committed 212c2b3

Tests and a lot of cleanup.

Comments (0)

Files changed (11)

 tags
 dist
 build
+htmlcov
         'genshi': _extra_genshi,
         'mako': _extra_mako,
     },
-    tests_require = ['BeautifulSoup', 'nose', 'FormEncode'],
+    tests_require = ['BeautifulSoup', 'nose', 'FormEncode', 'mako'],
     packages=find_packages(exclude=['ez_setup', 'tests']),
     namespace_packages = ['tw2', 'tw2.jqplugins'],
     zip_safe=False,
     twc.core.request_local()['middleware'] = twc.make_middleware()
 
 
-def test_jquery():
+def test_jquery_resource():
     from tw2.jquery import jquery_js
     the_link = '/resources/tw2.jquery/static/jquery/1.6.0/jquery.js'
     assert(jquery_js.req().link == the_link)
+
+def test_jquery_js_function():
+    from tw2.jquery import jQuery
+    assert(str(jQuery('foo')) == 'jQuery("foo")')
+

tw2/jquery/__init__.py

-from widgets import *
+from base import jquery_js, jQuery
     subdir = 'css'
     extension = 'css'
 
+jquery_js = jQueryJSLink()
 jQuery = js_function('jQuery')

tw2/jquery/plugins/__init__.py

-__import__('pkg_resources').declare_namespace(__name__)

tw2/jquery/samples.py

-"""
-Here you can create samples of your widgets by providing default parameters,
-inserting them in a container widget, mixing them with other widgets, etc...
-These samples will appear in the WidgetBrowser
-
-See http://toscawidgets.org/documentation/WidgetBrowser for more information
-"""
-
-import widgets

tw2/jquery/templates/__init__.py

Empty file removed.

tw2/jquery/templates/jqgrid.html

-<table xmlns:py="http://genshi.edgewall.org/" py:attrs="w.attrs" >
-    <tbody>
-    <tr py:for="row in w.options_rows">
-        <td py:for="attrs, desc in row">
-            <input py:attrs="attrs" />
-            <label for="${attrs['id']}" py:content="desc" />
-        </td>
-        <td py:for="j in xrange(w.cols - len(row))" />
-    </tr>
-    </tbody>
-</table>

tw2/jquery/templates/jqgrid.mak

-<%namespace name="tw" module="tw2.core.mako_util"/>\
-<table ${tw.attrs(attrs=w.attrs)}>
-</table>
-% if w.paginate:
-<div id=${w._pager}></div>
-% endif
-<script type="text/javascript">
-    //Code to gridify the above table and paginator
-    var ${w.attrs['id']}_options = { url: ${w._url}, pager: ${w._pager} };
-    jQuery.extend(${w.attrs['id']}_options, ${w._options});
-    jQuery(document).ready(
-      function(){ 
-        jQuery("#${w.attrs['id']}").jqGrid(${w.attrs['id']}_options);
-    % if w._pager_options:
-        jQuery("#${w.attrs['id']}").jqGrid('navGrid', '#' + ${w._pager},
-            ${w._pager_options.get('options', "null")},
-            ${w._pager_options.get('pEdit', "null")},
-            ${w._pager_options.get('pAdd', "null")},
-            ${w._pager_options.get('pSearch', "null")});
-    % endif
-      }); 
-</script>

tw2/jquery/widgets.py

-from base import jQueryJSLink, jQueryCSSLink, jQueryPluginJSLink, jQueryPluginCSSLink
-from tw2.core.resources import encoder
-import defaults
-
-jquery_js = jQueryJSLink()
-
-####
-####
-#### JQuery plugins
-####
-####
-
-# SwitchView
-jswitchview_js = jQueryPluginJSLink(name=defaults._switchview_name_, version=defaults._switchview_version_)
-jswitchview_css = jQueryPluginCSSLink(name=defaults._switchview_name_, version=defaults._switchview_version_)
-jswitchview = jQueryJSLink(resources=[jswitchview_js, jswitchview_css])
-
-#Jcrop
-jcrop_css = jQueryPluginCSSLink(name=defaults._jcrop_name_, version=defaults._jcrop_version_)
-jcrop_js = jQueryPluginJSLink(name=defaults._jcrop_name_, version=defaults._jcrop_version_)
-
-# The usable piece, I couldn't figure out a better way to do dependencies
-jcrop = jQueryJSLink(resources = [jcrop_js, jcrop_css])
-
-####
-####
-#### Jquery enabled widgets
-####
-####
-
-jnullable_js = jQueryPluginJSLink(name=defaults._nullable_name_, version=defaults._nullable_version_)
-
-import tw2.forms.widgets
-import tw2.core as twc
-
-class NullableSelectionField(tw2.forms.widgets.SelectionField):
-    input_class = 'nullable'
-    title_text = twc.Param("Text to use as the tool tip for each radio button", default="Select an option, or click a selected option to deselect it.")
-    resources = [jquery_js, jnullable_js]
-
-    def prepare(self):
-        super(NullableSelectionField, self).prepare()
-        #Add the input_class value to the class list
-        for opt in self.options:
-            opt[0]['class'] = self.input_class
-            opt[0]['title'] = self.title_text
-
-class NullableRadioButtonList(NullableSelectionField, tw2.forms.widgets.RadioButtonList): pass
-
-class NullableRadioButtonTable(NullableSelectionField, tw2.forms.widgets.RadioButtonTable):
-    """TODO: Fix the prepare path"""
-    pass