move label boxes inside a <div> (#979)
This commit is contained in:
parent
46bf42acfe
commit
421b7c357a
|
@ -176,7 +176,7 @@
|
|||
|
||||
<div tal:replace="structure provider:plone.belowcontentbody" />
|
||||
|
||||
<script type="text/javascript" tal:content="string: var PORTAL_URL='${view/portal_url}';"/>
|
||||
<script type="text/javascript" tal:content="string: var PORTAL_URL='${view/portal_url}';"></script>
|
||||
<script metal:use-macro="view/js_macros/macros/labelboxes"></script>
|
||||
|
||||
</tal:block>
|
||||
|
|
|
@ -102,7 +102,7 @@
|
|||
|
||||
<div tal:replace="structure provider:plone.belowcontentbody" />
|
||||
|
||||
<script type="text/javascript" tal:content="string: var PORTAL_URL='${view/portal_url}';"/>
|
||||
<script type="text/javascript" tal:content="string: var PORTAL_URL='${view/portal_url}';"></script>
|
||||
<script metal:use-macro="view/js_macros/macros/labelboxes"></script>
|
||||
|
||||
</tal:block>
|
||||
|
|
|
@ -477,6 +477,13 @@ class IDocumentPfbSearch(interface.Interface):
|
|||
values=[_(u'Session'), _(u'Type'), _(u'Number')])
|
||||
|
||||
|
||||
print 'PLOP', plone.directives.form.default_value
|
||||
@plone.directives.form.default_value(field=IDocumentPfbSearch['session'])
|
||||
def sessionDefaultValue(data):
|
||||
print 'session defualt value'
|
||||
print ' -->', tabellio.config.utils.get_legisl_and_sessions()[0]
|
||||
return tabellio.config.utils.get_legisl_and_sessions()[0]
|
||||
|
||||
class DocumentPfbSearchForm(form.Form):
|
||||
method = 'get'
|
||||
prefix = 'document'
|
||||
|
|
|
@ -0,0 +1,105 @@
|
|||
<html xmlns="http://www.w3.org/1999/xhtml"
|
||||
xmlns:tal="http://xml.zope.org/namespaces/tal"
|
||||
xmlns:metal="http://xml.zope.org/namespaces/metal"
|
||||
xmlns:i18n="http://xml.zope.org/namespaces/i18n"
|
||||
i18n:domain="plone">
|
||||
<body>
|
||||
|
||||
<script tppe="text/javascript" metal:define-macro="labelboxes">
|
||||
function update_input(input) {
|
||||
var s = '';
|
||||
jq(input).nextAll('span.labelbox').each(function() {
|
||||
s = s + ' ' + jq(this).attr('class').split(' ')[1];
|
||||
});
|
||||
jq(input).attr('value', s);
|
||||
}
|
||||
|
||||
function create_labelbox(input_box, id, value)
|
||||
{
|
||||
labelbox = $('<span class="labelbox ' + id + '">' + value + '<' + '/span>');
|
||||
$(labelbox).click(function() {
|
||||
$(this).remove();
|
||||
update_input(jq(input_box).prevAll('input')[0]);
|
||||
});
|
||||
return labelbox;
|
||||
}
|
||||
|
||||
function autocomplete_ready(event, data, formatted) {
|
||||
(function($) {
|
||||
var input_box = $(event.target);
|
||||
// XXX: don't insert item if it's already present
|
||||
labelbox = create_labelbox(input_box, data[1], data[0]);
|
||||
$(input_box).before(labelbox);
|
||||
update_input(jq(input_box).prevAll('input')[0]);
|
||||
$(input_box).attr('value', '');
|
||||
}(jQuery));
|
||||
}
|
||||
|
||||
function sync_elements(index, elem, url)
|
||||
{
|
||||
$(elem).parent().find('input').wrapAll('<div class="labelboxes">');
|
||||
hidden = $(elem).prev();
|
||||
values = $(hidden).attr('value').trim().split(' ');
|
||||
for (i=0; i < values.length; i++) {
|
||||
if (values[i]) {
|
||||
labelbox = create_labelbox(elem, values[i], '...');
|
||||
$(hidden).after(labelbox);
|
||||
$(labelbox).load(url + '?id=' + values[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function sync_authors(index, elem) { sync_elements(index, elem, PORTAL_URL+'/listAuthors'); }
|
||||
function sync_polgroups(index, elem) { sync_elements(index, elem, PORTAL_URL+'/listPolgroups'); }
|
||||
function sync_topics(index, elem) { sync_elements(index, elem, PORTAL_URL+'/listTopics'); }
|
||||
|
||||
if(typeof(String.prototype.trim) === "undefined") {
|
||||
String.prototype.trim = function()
|
||||
{
|
||||
return String(this).replace(/^\s+|\s+$/g, '');
|
||||
};
|
||||
}
|
||||
|
||||
(function($) {
|
||||
$().ready(function() {
|
||||
$('.author-autocomplete').each(sync_authors).autocomplete(PORTAL_URL+'/listAuthors', {
|
||||
}).result(autocomplete_ready);
|
||||
$('.polgroup-autocomplete').each(sync_polgroups).autocomplete(PORTAL_URL+'/listPolgroups', {
|
||||
}).result(autocomplete_ready);
|
||||
$('.topic-autocomplete').each(sync_topics).autocomplete(PORTAL_URL+'/listTopics', {
|
||||
}).result(autocomplete_ready);
|
||||
});
|
||||
})(jQuery);
|
||||
</script>
|
||||
|
||||
<script type="text/javascript" metal:define-macro="livereload">
|
||||
function load_results(elem)
|
||||
{
|
||||
var base = $(elem).parents('.results-var');
|
||||
var base_spec = ' #' + $(elem).parents('.results-var').parent()[0].id + ' .results-var > div';
|
||||
jQuery.get($(elem).attr('href'), null, function(data, textStatus, jqXHR) {
|
||||
if (textStatus == 'notmodified')
|
||||
return;
|
||||
if (textStatus == 'success') {
|
||||
$(base).html($(data).find(base_spec));
|
||||
console.log('ici:', $(base).find('.listingBar a'));
|
||||
$(base).find('.listingBar a').click(function() { return load_results($(this)); });
|
||||
}
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
(function($) {
|
||||
$().ready(function() {
|
||||
$('.results-var .listingBar a').click(function() { return load_results($(this)); });
|
||||
});
|
||||
})(jQuery);
|
||||
</script>
|
||||
|
||||
<!-- TODO -->
|
||||
<script tppe="text/javascript" metal:define-macro="droppedradios">
|
||||
</script>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
Reference in New Issue