def resources(self):
     for r in super(MarkdownEdit, self).resources():
         yield r
     yield ew.JSLink('js/jquery.lightbox_me.js')
     yield ew.JSLink('js/jquery.textarea.js')
     yield ew.JSLink('js/sf_markitup.js')
     yield ew.CSSLink('css/markitup_sf.css')
Beispiel #2
0
 def resources(self):
     yield ew.JSLink('allura/js/jquery-ui.min.js', location='body_top_js')
     yield ew.JSLink('js/jquery.tagsinput.js')
     yield ew.CSSLink('css/jquery.tagsinput.css')
     yield onready('''
       $('input.label_edit').tagsInput({
           'height':'100%%',
           'width':'100%%',
           'autocomplete_url':'%(url)stags'
       });
       $('form').on('blur', '.ui-autocomplete-input', function() {
           setTimeout(function(){
               var clicked = $(document.activeElement); // This is the element that has focus
               if (clicked.is('#ui-active-menuitem')) {
                   return false;
               } else {
                   var value = $('div.tagsinput div input').val();
                   var exists = $('input.label_edit').tagExist(value);
                   var default_value = $('div.tagsinput div input').attr('data-default');
                   if ((value !== default_value) && (!exists) && value !== '') {
                       $('input.label_edit').addTag(value);
                   }
                   $('input[type=submit]', this).prop('disabled', true);
               }
             }, 1);
         });
     ''' % dict(url=c.app.url))
Beispiel #3
0
 def resources(self):
     yield ew.JSLink('tracker_js/jquery.multiselect.min.js')
     yield ew.CSSLink('allura/css/smoothness/jquery-ui-1.8.4.custom.css')
     yield ew.CSSLink('tracker_css/jquery.multiselect.css')
     yield ew.JSLink('tracker_js/ticket-list.js')
     yield ew.CSSLink('tracker_css/ticket-list.css')
     for r in super(TicketSearchResults, self).resources():
         yield r
Beispiel #4
0
 def resources(self):
     for r in super(MarkdownEdit, self).resources():
         yield r
     yield ew.JSLink('js/jquery.lightbox_me.js')
     yield ew.CSSLink('css/simplemde.min.css', compress=False)
     yield ew.CSSLink('css/markitup_sf.css')
     yield ew.JSLink('js/simplemde.min.js')
     yield ew.JSLink('js/sf_markitup.js')
Beispiel #5
0
 def resources(self):
     yield ew.JSLink('allura/js/jquery-ui.min.js', location='body_top_js')
     yield ew.JSLink('tracker_js/jquery.multiselect.min.js')
     yield ew.CSSLink('allura/css/smoothness/jquery-ui.min.css')
     yield ew.CSSLink('tracker_css/jquery.multiselect.css')
     yield ew.JSLink('tracker_js/ticket-list.js')
     yield ew.CSSLink('tracker_css/ticket-list.css')
     for r in super(TicketSearchResults, self).resources():
         yield r
Beispiel #6
0
 def resources(self):
     for r in super(ProjectUserCombo, self).resources():
         yield r
     yield ew.JSLink('allura/js/jquery-ui.min.js', location='body_top_js')
     yield ew.CSSLink('css/autocomplete.css')  # customized in [6b78ed] so we can't just use jquery-ui.min.css
     yield ew.CSSLink('css/combobox.css')
     yield ew.JSLink('js/combobox.js')
     yield onready('''
       $('select.project-user-combobox').combobox({
         source_url: "%susers"
       });''' % c.project.url())
Beispiel #7
0
 def resources(self):
     for r in super(MarkdownEdit, self).resources():
         yield r
     yield ew.JSLink('js/jquery.lightbox_me.js')
     yield ew.CSSLink('css/simplemde.min.css', compress=False)
     yield ew.CSSLink('css/markitup_sf.css')
     yield ew.CSSLink('css/show-hint.css')
     yield ew.JSLink('js/simplemde.min.js')
     yield ew.JSLink('js/sf_markitup.js')
     yield ew.JSLink('js/show-hint.js')
     yield ew.JSLink('js/usermentions-helper.js')
     yield onready('getProjectUsers(\'%s/users\')' % c.project.url())
Beispiel #8
0
 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):
        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
          });
        ''')
Beispiel #10
0
 def resources(self):
     for r in super(DateField, self).resources():
         yield r
     yield ew.JSLink('allura/js/jquery-ui.min.js', location='body_top_js')
     yield ew.CSSLink(
         'allura/css/smoothness/jquery-ui.min.css', compress=False
     )  # compress will also serve from a different location, breaking image refs
Beispiel #11
0
class SortableRepeatedMixin(JQueryMixin):
    js_widget_name = 'SortableRepeatedField'
    js_plugin_file = ew.JSLink('js/sortable_repeated_field.js')
    js_params = JQueryMixin.js_params + [
        'field_cls',
        'flist_cls',
        'stub_cls',
        'msg_cls',
        'append_to',
        'extra_field_on_focus_name',
    ]
    defaults = dict(container_cls='sortable-repeated-field',
                    field_cls='sortable-field',
                    flist_cls='sortable-field-list',
                    stub_cls='sortable-field-stub',
                    msg_cls='sortable-field-message',
                    append_to='top',
                    empty_msg='No fields have been defined',
                    nonempty_msg='Drag and drop the fields to reorder',
                    show_msg=True,
                    show_button=True,
                    extra_field_on_focus_name=None,
                    repetitions=0)

    button = ew.InputField(css_class='add',
                           field_type='button',
                           value='New Field')
Beispiel #12
0
 def resources(self):
     yield ew.JSLink('js/jquery.elastic.js')
     yield onready('''
         $('textarea.auto_resize').elastic().focus(function(){
             $(this).keyup();
         });
     ''')
 def resources(self):
     for r in super(FileChooser, self).resources():
         yield r
     yield ew.JSLink('js/jquery.file_chooser.js')
     yield onready('''
         var num_files = 0;
         var chooser = $('input.file_chooser').file();
         chooser.choose(function (e, input) {
             var holder = document.createElement('div');
             holder.style.clear = 'both';
             e.target.parentNode.appendChild(holder);
             $(holder).append(input.val());
             $(holder).append(input);
             input.attr('name', e.target.id + '-' + num_files);
             input.hide();
             ++num_files;
             var delete_link = document.createElement('a');
             delete_link.className = 'btn';
             var icon = document.createElement('b');
             icon.className = 'ico delete';
             delete_link.appendChild(icon);
             $(delete_link).click(function () {
                 this.parentNode.parentNode.removeChild(this.parentNode);
             });
             $(holder).append(delete_link);
         });''')
Beispiel #14
0
    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();
              });
            });
        ''')
Beispiel #15
0
 def resources(self):
     for r in super(ProjectUserCombo, self).resources():
         yield r
     yield ew.CSSLink('css/autocomplete.css')
     yield ew.CSSLink('css/combobox.css')
     yield ew.JSLink('js/combobox.js')
     yield onready('''
       $('select.project-user-combobox').combobox({
         source_url: "%susers"
       });''' % c.project.url())
Beispiel #16
0
 def resources(self):
     yield ew.JSLink('js/jquery.tagsinput.js')
     yield ew.CSSLink('css/jquery.tagsinput.css')
     yield onready('''
       $('input.label_edit').tagsInput({
           'height':'100%%',
           'width':'100%%',
           'autocomplete_url':'%(url)stags'
       });
     ''' % dict(url=c.app.url))
Beispiel #17
0
 def resources(self):
     for r in super(Thread, self).resources():
         yield r
     for w in self.widgets.itervalues():
         for r in w.resources():
             yield r
     yield ew.JSScript('''
     $(document).ready(function () {
         var thread_tag = $('a.thread_tag');
         var thread_spam = $('a.sidebar_thread_spam');
         var tag_thread_holder = $('#tag_thread_holder');
         var allow_moderate = $('#allow_moderate');
         var mod_thread_link = $('#mod_thread_link');
         var mod_thread_form = $('#mod_thread_form');
         if (mod_thread_link.length) {
             if (mod_thread_form.length) {
                 mod_thread_link.click(function (e) {
                     mod_thread_form.toggle();
                     return false;
                 });
             }
         }
         if (thread_tag.length) {
             if (tag_thread_holder.length) {
                 var submit_button = $('input[type="submit"]', tag_thread_holder);
                 var cancel_button = $('<a href="#" class="btn link">Cancel</a>').click(function(evt){
                     evt.preventDefault();
                     tag_thread_holder.hide();
                     thread_tag.removeClass('active');
                 });
                 submit_button.after(cancel_button);
                 thread_tag.click(function (e) {
                     tag_thread_holder.show();
                     thread_tag.addClass('active');
                     // focus the submit to scroll to the form, then focus the subject for them to start typing
                     submit_button.focus();
                     $('input[type="text"]', tag_thread_holder).focus();
                     return false;
                 });
             }
         }
         if (thread_spam.length) {
             if (allow_moderate.length) {
                 thread_spam[0].style.display='block';
             }
         }
     });
     ''')
     yield ew.JSScript('''
         var global_reactions = %s;
     ''' % utils.get_reactions_json())
     yield ew.JSLink('js/reactions.js')
Beispiel #18
0
 def resources(self):
     yield ew.JSLink('js/jquery.lightbox_me.js')
     yield onready('''
         var $lightbox = $('#lightbox_%s');
         $('body').on('click', '%s', function(e) {
             e.preventDefault();
             $lightbox.lightbox_me(%s);
         });
         $lightbox.on('click', '.close', function(e) {
             e.preventDefault();
             $lightbox.trigger('close');
         });
     ''' % (self.name, self.trigger, self.options))
 def resources(self):
     yield ew.JSLink('js/jquery.lightbox_me.js')
     yield onready('''
         var $lightbox = $('#lightbox_%s');
         var $trigger = $('%s');
         $trigger.bind('click', function(e) {
             $lightbox.lightbox_me();
             return false;
         });
         $($lightbox).delegate('.close', 'click', function(e) {
             $lightbox.trigger('close');
             return false;
         });
     ''' % (self.name, self.trigger))
 def resources(self):
     yield ew.JSLink('js/jquery.tools.min.js')
     yield ew.JSScript('''
     $(document).ready(function () {
         var badges = $('small.badge');
         var i = badges.length;
         while (i) {
             i--;
             var tipHolder = document.createElement('div');
             tipHolder.id = "tip" + i;
             tipHolder.className = "tip";
             document.body.appendChild(tipHolder);
             $(badges[i]).parent('a[title]').tooltip({
                 tip: '#tip' + i,
                 opacity: '.9',
                 offset: [-10, 0]
             });
         }
     });
     ''')
Beispiel #21
0
 def resources(self):
     for r in super(NeighborhoodProjectSelect, self).resources():
         yield r
     yield ew.JSLink('allura/js/jquery-ui.min.js', location='body_top_js')
     yield ew.CSSLink('css/autocomplete.css')  # customized in [6b78ed] so we can't just use jquery-ui.min.css
     yield onready('''
       $('input.neighborhood-project-select').autocomplete({
         source: function (request, response) {
           $.ajax({
             url: "%s",
             dataType: "json",
             data: {
               term: request.term
             },
             success: function (data) {
               response(data.projects);
             }
           });
         },
         minLength: 3
       });''' % self.url)
Beispiel #22
0
class StateField(JQueryMixin, ew.CompoundField):
    template = 'jinja:allura:templates/widgets/state_field.html'
    js_widget_name = 'StateField'
    js_plugin_file = ew.JSLink('js/state_field.js')
    js_params = JQueryMixin.js_params + [
        'selector_cls',
        'field_cls',
    ]
    defaults = dict(
        ew.CompoundField.defaults,
        js_params=js_params,
        container_cls='state-field-container',
        selector_cls='state-field-selector',
        field_cls='state-field',
        show_label=False,
        selector=None,
        states={},
    )

    @property
    def fields(self):
        return [self.selector] + list(self.states.values())
 def register_forge_js(self, href, **kw):
     self.resource_manager.register(ew.JSLink('allura/' + href, **kw))
 def resources(self):
     yield ew.JSLink('activity_js/follow.js')
Beispiel #25
0
    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 register_js(self, href, **kw):
     self.resource_manager.register(ew.JSLink(href, **kw))
 def register_app_js(self, href, **kw):
     app = kw.pop('app', c.app)
     self.resource_manager.register(
         ew.JSLink('tool/%s/%s' % (app.config.tool_name.lower(), href),
                   **kw))
Beispiel #28
0
 def resources(self):
     yield ew.JSLink('js/jquery.autosize-min.js')
     yield onready('''
         $('textarea.auto_resize').focus(function(){$(this).autosize();});
     ''')
Beispiel #29
0
 def resources(self):
     yield ew.JSLink('allura/js/hidpi-canvas.min.js')
     yield ew.JSLink('js/commit_browser.js')
     yield ew.CSSLink('css/commit_browser.css')
 def register_theme_js(self, href, **kw):
     self.resource_manager.register(ew.JSLink(self.theme_href(href), **kw))