Login

Tag "yui"

Snippet List

Django Drag and Drop Using YUI

I was trying to implement the django inline drag & drop, I cudn't understand. Then I have try with YUI library Copy the above code in the respective .py & download the YUI library and add the JS in your media folder. This will do..., Try this our , it's easy to use..,

  • django
  • yui
  • drag
  • drop
  • and
Read More

YUI Loader as Django middleware

This server-side middleware implements some of the functionality in the Yahoo User Interface Loader component. YUI JavaScript and CSS modules requirements can be declared anywhere in the base, inherited or included templates, and the resulting, optimized `<script>` and `<link rel="stylesheet">` tags are inserted at the specified position of the resulting page. Requirements may be specified in multiple locations. This is useful when zero or more components are included in the HTML head section, and inherited and/or included templates require possibly overlapping sets of YUI components in the body across inherited and included templates. All tags are collected in the head section, and duplicate tags are automatically eliminated. The middleware understands component dependencies and ensures that resources are loaded in the right order. It knows about built-in rollup files that ship with YUI. By automatically using rolled-up files, the number of HTTP requests is reduced. The default syntax looks like HTML comments. Markup for the insertion point is replaced with `<script>` and `<link>` tags: <!-- YUI_init --> Component requirements are indicated, possibly in multiple locations, with the `YUI_include` markup. It is removed from the resulting page by the middleware. Example: <!-- YUI_include fonts grids event dragdrop --> Non-minified and compressed versions are requested, respectively, by: <!-- YUI_version raw --> <!-- YUI_version debug --> Example: <html><head> <!-- YUI_init --> <!-- YUI_include dom event --> </head><body> <!-- YUI_include element selector reset fonts base --> </body></html> Renders: <html><head> <link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.5.1/build/reset-fonts/reset-fonts.css" /> <link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.5.1/build/base/base-min.css" /> <script type="text/javascript" src="http://yui.yahooapis.com/2.5.1/build/yahoo-dom-event/yahoo-dom-event.js"></script> <script type="text/javascript" src="http://yui.yahooapis.com/2.5.1/build/element/element-beta-min.js"></script> <script type="text/javascript" src="http://yui.yahooapis.com/2.5.1/build/selector/selector-beta-min.js"></script> </head><body> </body></html> The markup format can be customized with global Django settings. Example: YUI_INCLUDE_PREFIX_RE = r'{!' YUI_INCLUDE_SUFFIX_RE = r'!}' would change markup to e.g. `{! init !}` and `{! include dom event !}`. The base URL is customized with the `YUI_INCLUDE_BASE` setting, e.g.: YUI_INCLUDE_BASE = 'http://localhost:8000/yui/build/' To remove the XHTML trailing slash from the `<link>` tag, use: YUI_INCLUDE_CSS_TAG = '<link rel="stylesheet" type="text/css" href="%s">' See also the [home page for this module](http://trac.ambitone.com/ambidjangolib/wiki/YUI_include).

  • yui
  • loader
Read More

YUI Autocomplete

This snippet allows you to use YUI's autocomplete widget in a easy way. 1. Download YUI (http://developer.yahoo.com/yui/) library and put it into MEDIA folder (in my case I put YUI/build/ directory as base/yui/ in my MEDIA folder) 2. Create lookup view for your autocomplete field. See 'test_ajax_ac' function to see how this lookup view may be built. You have to define JsonResponse somewhere in your files. JsonResponse is taken from: http://www.djangosnippets.org/snippets/154/ 3. Define url for newly created view in urls.py (in usual way) 4. Include necessary .js and .css files in your page (see example in test_ajax.html) 5. Assign widget to a field - see form's __init__ at UserForm in the example. Additional (optional) parameters are: format_result_fname (name of javascript function for formatting results - see YUI docs for examples)), item_select_handler_fname (name of javascript function for handling item select event (see YUI docs)). When using YUI take care about proper skin - you'll possibly need to define wrapper like: `<div class="yui-skin-sam">....</div>` around your html code.

  • javascript
  • yui
  • autocomplete
  • widget
Read More

WTForm (What The Form)

WTForm is an extension to the django newforms library allowing the developer, in a very flexible way, to layout the form fields using fieldsets and columns WTForm was built with the well-documented [YUI Grid CSS](http://developer.yahoo.com/yui/grids/) in mind when rendering the columns and fields. This should make it easy to implement WTForm in your own applications. Here is an image of an [example form rendered with WTForm](http://www.gmta.info/files/wtform.png).

  • newforms
  • html
  • css
  • fieldset
  • form
  • yui
  • rendering
  • grid
  • columns
  • layout
Read More
Author: chrj
  • 23
  • 101

4 snippets posted so far.