1/** 2 * @file nutrition-facts-vitamins.js 3 * 4 * Style for Nutrition Facts Vitamins Plugin 5 * 6 * Copyright (c) 2014, Dandelion Web Design Inc. <http://dandelionwebdesign.com> 7 */ 8 9jQuery(document).ready(function($) { 10 11 /** 12 * Script to generate new vitamin label 13 */ 14 $('.addNewVitamin').click(function(e) { 15 e.preventDefault(); 16 17 var id = 1, 18 length = $('.dynamic').length; 19 20 if( length > 0 ) { 21 id = $('.dynamic:last').data('id') + 1; 22 } 23 24 var html = '<div class="nutritionField dynamic" data-id=' + id + '>' + 25 '<div class="label editable" title="Click to edit">' + 26 '<label>Add Label' + id + ' Here</label>' + 27 '</div>' + 28 '<input type="hidden" value="Add Label' + id + ' Here" class="extraVitaminLabel" name="extra_vitamin_label[]">' + 29 '<input type="text" value="" name="extra_vitamin[]">' + 30 '<a class="remove" href="#" title="Remove this label"></a>' + 31 '<div class="clear"></div>' + 32 '</div>'; 33 34 $('.nutritionField:last').after(html); 35 36 }); 37 38 /** 39 * Make the label editable. 40 */ 41 $('.nutritionFieldsWrap').on('click', '.editable > label', function() { 42 var value = $(this).html(), 43 parent = $(this).parent(), 44 input = '<input type="text" value="' + value + '" class="editableTextField" title="Click outside to save">'; 45 46 $(this).parent().html(input); 47 parent.find('.editableTextField').focus().select(); 48 }); 49 50 /** 51 * Change textbox to labe on focus out. 52 */ 53 $('.nutritionFieldsWrap').on('blur', '.editableTextField', function() { 54 var value = $(this).val(); 55 if( !value ) { 56 value = "Add Label Here"; 57 } 58 59 var vitaminLabel = $(this).closest('.nutritionField').find('.extraVitaminLabel'); 60 $(this).parent().html("<label>" + value + "</label>"); 61 vitaminLabel.val( value ); 62 }); 63 64 /** 65 * Remove label. 66 */ 67 $('.nutritionFieldsWrap').on('click', '.remove', function(e) { 68 e.preventDefault(); 69 70 var sure = confirm('Are you sure?'); 71 if( sure ) { 72 $(this).parent().fadeOut(300, function() { 73 $(this).remove(); 74 }); 75 } 76 }); 77 78});
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.