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 }); 52 53 // Show available link 54 $element.on('click', '.ShowTags a', function () { 55 $element.find('.ShowTags a').hide(); 56 $element.find('.AvailableTags').show(); 57 return false; 58 }); 59 60 // Use available tags 61 $element.on('click', '.AvailableTag', function () { 62 //$(this).hide(); 63 var tag = $(this).attr('data-id'); 64 $tagsInput.tokenInput('add', {id: tag, name: $(this).text()}); 65 return false; 66 }); 67 } 68 } 69} 70 71$(document).on('contentLoad', function(e) { 72 if (e.target.id === 'DiscussionForm') { 73 discussionTagging.start($('.FormWrapper', e.target)); 74 } else { 75 var elementID = '#DiscussionForm'; 76 if ($(e.target).find('#DiscussionAddTagForm').length) { 77 elementID = '#DiscussionAddTagForm'; 78 } 79 discussionTagging.start($(elementID, e.target)); 80 } 81});
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.