1(function($, undefined) { 2 $.web2py.ajax_fields = function(target) { 3 /* 4 *this attaches something to a newly loaded fragment/page 5 * Ideally all events should be bound to the document, so we can avoid calling 6 * this over and over... all will be bound to the document 7 */ 8 /*adds btn class to buttons*/ 9 $('button', target).addClass('btn btn-default'); 10 $("p.w2p-autocomplete-widget input").addClass('form-control'); 11 $('form input[type="submit"], form input[type="button"]', target).addClass('btn btn-default'); 12 /* javascript for PasswordWidget*/ 13 $('input[type=password][data-w2p_entropy]', target).each(function() { 14 web2py.validate_entropy($(this)); 15 }); 16 /* javascript for ListWidget*/ 17 $('ul.w2p_list', target).each(function() { 18 function pe(ul, e) { 19 var new_line = ml(ul); 20 rel(ul); 21 if ($(e.target).parent().is(':visible')) { 22 /* make sure we didn't delete the element before we insert after */ 23 new_line.insertAfter($(e.target).parent()); 24 } else { 25 /* the line we clicked on was deleted, just add to end of list */ 26 new_line.appendTo(ul); 27 } 28 new_line.find(":text").focus(); 29 return false; 30 } 31 32 function rl(ul, e) { 33 if ($(ul).children().length > 1) { 34 /* only remove if we have more than 1 item so the list is never empty */ 35 $(e.target).parent().remove(); 36 } 37 } 38 39 function ml(ul) { 40 /* clone the first field */ 41 var line = $(ul).find("li:first").clone(true); 42 line.find(':text').val(''); 43 return line; 44 } 45 46 function rel(ul) { 47 /* keep only as many as needed*/ 48 $(ul).find("li").each(function() { 49 var trimmed = $.trim($(this.firstChild).val()); 50 if (trimmed == '') $(this).remove(); 51 else $(this.firstChild).val(trimmed); 52 }); 53 } 54 var ul = this; 55 $(ul).find(":text").after('<a class="btn btn-default" href="#">+</a> <a class="btn btn-default" href="#">-</a>').keypress(function(e) { 56 return (e.which == 13) ? pe(ul, e) : true; 57 }).next().click(function(e) { 58 pe(ul, e); 59 e.preventDefault(); 60 }).next().click(function(e) { 61 rl(ul, e); 62 e.preventDefault(); 63 }); 64 }); 65 } 66 67 $(function() { 68 $(".nav ul.dropdown-menu").each(function() { 69 var toggle = jQuery(this).parent(); 70 if (toggle.parent().hasClass("nav")) { 71 toggle.attr("data-w2pmenulevel", "l0"); 72 toggle.children("a") 73 .addClass("dropdown-toggle") 74 .append('<span class="caret"> </span>') 75 .attr("data-toggle", "dropdown"); 76 } else { 77 toggle.addClass("dropdown-submenu").removeClass("dropdown"); 78 }; 79 }); 80 }); 81 82})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.