PageRenderTime 72ms CodeModel.GetById 30ms app.highlight 1ms RepoModel.GetById 40ms app.codeStats 0ms

/kai/templates/snippets/add.mako

https://bitbucket.org/bbangert/kai/
Mako | 54 lines | 51 code | 3 blank | 0 comment | 3 complexity | ab9caed52b1e9bbe76ebc7eb4d80ccbe MD5 | raw file
 1<%!
 2from kai.model.forms import snippet_form
 3%>
 4<h1>${_('Add Snippet')}</h1>
 5<p>${_("""Pylons snippet repository is a place to share their code snippets with the community.
 6    Please only share fully functioning and tested snippets and include instructions so
 7    that novice and experienced Pylons users can benefit.""")}</p>
 8
 9${snippet_form.display(action=url('snippets')) | n}
10
11<div style="display: none; border: 2px solid #444; padding: 4px;" id="snippet_preview">&nbsp;</div>
12
13<%def name="title()">${parent.title()} - ${_('Add Snippet')}</%def>
14<%def name="javascript()">
15${parent.javascript()}
16<script src="http://yui.yahooapis.com/2.6.0/build/yuiloader/yuiloader-min.js" ></script>
17<script src="/javascripts/rst_helpers.js" charset="utf-8"></script>
18<script>
19$(document).ready(function() {
20    var loader = new YAHOO.util.YUILoader({
21        require: ["autocomplete"],
22        loadOptional: true,
23        onSuccess: function() {            
24            make_tagger = function(tag_field, tag_box, datafield) {
25                var data_source = new YAHOO.widget.DS_JSArray(datafield);
26                var myAutoComp = new YAHOO.widget.AutoComplete(tag_field, tag_box, data_source);
27                myAutoComp.typeAhead = true;
28                myAutoComp.queryDelay = 0;
29                myAutoComp.minQueryLength = 2;
30                myAutoComp.delimChar = [" ", ","];
31                return true;
32            };
33            var tags = [${','.join(["\"%s\"" % tag for tag in c.tags]) | n}];
34            make_tagger('snippet_form_tags', 'snippet_form_tags_autocomplete', tags);
35        }
36    });
37    loader.insert();
38    $('#preview').click(function() {
39        var content = $('#snippet_form_content')[0].value;
40        var preview_url = '${url('preview_snippet')}';
41        $.ajax({
42            data: {content:content},
43            type: "POST",
44            url: preview_url,
45            success: function(data, textStatus) {
46                $('#snippet_preview').html(data).slideDown();
47            }
48        });
49        return false;
50    });
51})
52</script>
53</%def>
54<%inherit file="layout.mako" />