1var discussionTagging = { 2 start: function($element) { 3 var $button = $element.find('form :submit'); 4 if ($button) { 5 var $form = $element.find('form'); 6 var $tagsInput = $element.find("#Form_Tags"); 7 8 $form.bind('BeforeDiscussionSubmit', function (e, $form, $button) { 9 $tagsInput.triggerHandler('BeforeSubmit', [$form]); 10 }); 11 12 var tags; 13 var dataTags = $tagsInput.data('tags'); 14 if (dataTags) { 15 tags = []; 16 if ($.isPlainObject(dataTags)) { 17 for (var tagID in dataTags) { 18 tags.push({name: dataTags[tagID], id: tagID}); 19 } 20 } 21 } else { 22 tags = $tagsInput.val(); 23 if (tags && tags.length) { 24 tags = tags.split(","); 25 26 for (i = 0; i < tags.length; i++) { 27 tags[i] = {id: tags[i], name: tags[i]}; 28 } 29 } else { 30 tags = []; 31 } 32 } 33 34 var tagSearch = gdn.definition('TaggingSearchUrl', gdn.url('tags/search')); 35 var tagAdd = gdn.definition('TaggingAdd', false); 36 var maxTags = gdn.definition('MaxTagsAllowed', false); 37 38 $tagsInput.tokenInput(tagSearch, { 39 hintText: gdn.definition("TagHint", "Start to type..."), 40 searchingText: '', // search text gives flickery ux, don't like 41 searchDelay: 300, 42 animateDropdown: false, 43 minChars: 1, 44 maxLength: 25, 45 prePopulate: tags, 46 dataFields: ["#Form_CategoryID"], 47 allowFreeTagging: tagAdd, 48 tokenLimit: maxTags, 49 zindex: 3000, 50 allowTabOut: true, 51 ariaLabel: gdn.translate("Tag"), 52 }); 53 54 // Show available link 55 $element.on('click', '.ShowTags a', function () { 56 $element.find('.ShowTags a').hide(); 57 $element.find('.AvailableTags').show(); 58 return false; 59 }); 60 61 // Use available tags 62 $element.on('click', '.AvailableTag', function () { 63 //$(this).hide(); 64 var tag = $(this).attr('data-id'); 65 $tagsInput.tokenInput('add', {id: tag, name: $(this).text()}); 66 return false; 67 }); 68 } 69 } 70} 71 72$(document).on('contentLoad', function(e) { 73 if (e.target.id === 'DiscussionForm') { 74 discussionTagging.start($('.FormWrapper', e.target)); 75 } else { 76 var elementID = '#DiscussionForm'; 77 if ($(e.target).find('#DiscussionAddTagForm').length) { 78 elementID = '#DiscussionAddTagForm'; 79 } 80 discussionTagging.start($(elementID, e.target)); 81 } 82});
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.