def resources(self): yield ew.CSSScript('''.deck li input, .deck li select { margin: 2px 0 2px 3px; width: 148px; }''') yield ew.JSScript('''$(function() { $('.active-card').each(function() { var newitem = $('.new-item', this); var adder = $('.adder', this); var deleters = $('.deleter', this); newitem.remove(); newitem.removeClass('new-item'); deleters.click(function(evt) { evt.stopPropagation(); evt.preventDefault(); var $this = $(this); $this.closest('li').remove(); }); adder.click(function(evt) { evt.stopPropagation(); evt.preventDefault(); newitem.clone().insertBefore(adder.closest('li')); }); }); });''')
def resources(self): yield ew.JSLink('js/jquery.tag.editor.js') yield ew.CSSScript(''' input.label_edit{ float: left; } .tagEditor{ margin: 4px 0; padding: 0; float: left; } .tagEditor li, .removable{ display: inline; background-image: url('%s'); background-color: #eef; background-position: right center; background-repeat: no-repeat; list-style-type: none; padding: 0 18px 0 6px; margin: 0 4px; cursor: pointer; -moz-border-radius: 5px; -webkit-border-radius: 5px; } .tagEditor li:hover{ background-color: #ebebeb; }''' % g.forge_static('images/minus_small.png')) yield onready(''' $('input.label_edit').tagEditor({ confirmRemoval: false, completeOnSeparator: true, completeOnBlur: true }); ''')
def resources(self): for r in super(Post, self).resources(): yield r for w in six.itervalues(self.widgets): for r in w.resources(): yield r yield ew.CSSScript(''' div.moderate { color:grey; } ''') yield ew.JSLink('js/jquery.lightbox_me.js') yield ew.JSLink('js/post.js')
def resources(self): for r in super(NeighborhoodOverviewForm, self).resources(): yield r yield ew.CSSLink('css/colorPicker.css') yield ew.CSSLink('css/jqfontselector.css') yield ew.CSSScript(''' table.table_class, table.input_inner{ margin: 0; padding: 0; width: 99%; } table.table_class .left{ text-align: left; } table.table_class .right{ text-align: right; width: 50%;} table.table_class tbody tr td { border: none; } table.table_class select.add_opt {width: 5em; margin:0; padding: 0;} ''') yield ew.JSLink('js/jquery.colorPicker.js') yield ew.JSLink('js/jqfontselector.js') yield ew.JSScript(''' $(function(){ $('.table_class').find('input[type="checkbox"]').each(function(index, element) { var cb_name = $(this).attr('name'); var inp_name = cb_name.substr(0, cb_name.length-4); var inp_el = $('div[class="'+inp_name+'-inp"]'); if ($(this).prop('checked')) { inp_el.hide(); } $(element).click(function(e) { if ($(this).prop('checked')) { inp_el.hide(); } else { inp_el.show(); } }); }); $('.table_class').find('input.color').each(function(index, element) { $(element).colorPicker(); }); $('.table_class').find('input.font').each(function(index, element) { $(element).fontSelector(); }); }); ''')
def resources(self): for r in super(Post, self).resources(): yield r for w in self.widgets.itervalues(): for r in w.resources(): yield r yield ew.CSSScript(''' div.moderate { color:grey; } ''') yield ew.JSLink('js/jquery.lightbox_me.js') yield ew.JSScript(''' (function () { $('div.discussion-post').each(function () { var post = this; $('.submit', post).button(); $('.moderate_post', post).click(function(e){ e.preventDefault(); var mod = $(this).text(); if ($(this).hasClass('delete')) mod = 'Delete'; else if ($(this).hasClass('approve')) mod = 'Approve'; else if ($(this).hasClass('spam')) mod = 'Spam'; else if ($(this).hasClass('undo')) mod = 'Undo'; if (mod === 'Delete' && !confirm('Really delete this post?')) { return; } $.ajax({ type: 'POST', url: this.parentNode.action, data: jQuery(this.parentNode).serialize(), success: function() { if (mod === 'Delete'){ $(post).remove(); } else if (mod === 'Approve'){ $('a.shortlink, form.moderate_spam, form.moderate_approve', post).toggle(); $('div.moderate', post).removeClass('moderate'); } else if (mod == 'Spam'){ spam_block_display($(post), 'show_spam'); } else if (mod == 'Undo'){ spam_block_display($(post), 'hide_spam'); } } }); }); function spam_block_display($post, display_type) { var spam_block = $post.find('.info.grid-15.spam-present'); var row = $post.find('.row').eq(0); if (display_type == 'show_spam') { spam_block.show(); row.hide(); } else if (display_type == 'hide_spam') { spam_block.hide(); row.show(); } } function get_cm($elem) { return $('.CodeMirror', $elem)[0].CodeMirror; } if($('a.edit_post', post)){ $('a.edit_post', post).click(function (evt) { evt.preventDefault(); $('.display_post', post).hide(); // remove the options column, but have to adjust the width of the middle section which is // already hard-coded var $opts = $('.options:first', post); var opts_width = $opts.outerWidth(true); $opts.hide(); var $post_middle = $('div.grid-14:first', post); $post_middle.data('original-width', $post_middle.width()); $post_middle.width($post_middle.width() + opts_width); var $edit_post_form = $('.edit_post_form', post); var cm = get_cm($edit_post_form); $edit_post_form.show(); cm.refresh(); cm.focus(); }); $("a.cancel_edit_post", post).click(function(evt){ $('.display_post', post).show(); $('.options', post).show(); $('.edit_post_form', post).hide(); var $post_middle = $('div.grid-14:first', post); $post_middle.width($post_middle.data('original-width')); }); } if($('.reply_post', post)){ $('.reply_post', post).click(function (evt) { evt.preventDefault(); var $reply_post_form = $('.reply_post_form', post); var cm = get_cm($reply_post_form); $reply_post_form.show(); cm.focus(); }); $('.reply_post', post).button(); } if($('.add_attachment', post)){ $('.add_attachment', post).click(function (evt) { evt.preventDefault(); $('.add_attachment_form', post).show(); }); } if($('.shortlink', post)){ var popup = $('.shortlink_popup', post); $('.shortlink', post).click(function(evt){ evt.preventDefault(); popup.lightbox_me({ onLoad: function() { $('input', popup).select(); } }); }); $('.close', popup).bind('click', function() { popup.hide(); }); } }); //lightbox_me script to create lightbox of attached images $('.lightbox').click(function(e) { var image_source = $(this).data("src"); var image = $('#lightbox').find('img:first'); image.attr("src", image_source); $('#lightbox').lightbox_me({ centered: true }); e.preventDefault(); }); }()); ''')
def resources(self): for r in super(MilestonesAdmin, self).resources(): yield r yield ew.CSSScript('''div.state-field table{ width: 700px; }''')