JavaScript API

Back
The methods below are all inside the label object literal, and they are used like this:
label.addDesignation(this, 'foo');

If the function signature contains a “label” parameter in its signature, you’re going to pretty much always pass this to that parameter.

abbr: function(label, selector)

Description: Splits the text of a selector into three parameters: abbr, prefix and suffix.
Parameters: (object) label - jQuery label object, (string) selector - the CSS selector from which you want to pull text
Return Values: (object) returns an object with the abbr, prefix and suffix to be used on the label.

addDesignation: function(label, text)

Description: Simply appends a designation class div to the label with a specific text value.
Parameters: (object) label - jQuery label object, (string) text - text string to append.
Return Values: null

asterisks: function(label, selector)

Description: If your label uses Code 39 barcodes, you will need to use this function to append asterisks to the barcode div. 
The barcode will not read without an asterisk at the beginning and end.
Parameters: (object) label - jQuery label object, (string) selector - div selector where the barcode is visible.
Return Values: null

code128: function(rawData)

Description: If your label uses Code 128 barcodes, this method will generate the checksum and return the value to print on the label.
Parameters: (string) rawData - text to be converted to a barcode
Return Values (string) barcode data

changeBg: function(label, selector, target)

Description: In many cases, color bars will need to change color to match the first letter in the string. This does that.
Parameters: (object) label - jQuery label object, (string) selector - element that has the color you want, (string) target - element you want to change
Return Values: null

check: function(data)

Description: Checks if an object or array is empty
Parameters: (object) data - object to check
Return Values: (bool)

doLettering: function(label, selector)

Description: Each letter in the label is placed inside its own span, allowing full control of text styling. This method performs that function.
Parameters: (object) label - jQuery label object, (string) selector - CSS selector [parameters are optional]
Return Values: null
Important: The parameters are optional. Most of the time, this method will be used with no parameter. If it's inside the labelWrap loop, pass this to the label parameter

initials: function(selector)

Description: This will create initials from a space delimited string, like John Robert Doe, will return "JRD".
Parameters: (string) selector - CSS selector
Return Values: (string) initials string

length: function(that, selector)

Description: Return the length of the characters in a selector. This function is useful create a class where you can style variable length text with limited horizontal space.
Parameters: (object) that - jQuery label object, (string) selector - CSS selector
Return Values: (string) class name with the number of characters, like "length4"

lightOrDark: function(color)

Description: Convert the hex value of a color to "light" or "dark". This is useful for dynamically coloring the text of a container.
Parameters: (string) color - hex value of a color
Return Values: (string) "light" for container that should have white text or "dark" for a container that should have black text.

mc: function(label)

Description: Some labels require the use of a separate character for names staring the Mc (e.g., McGlaughlin). This creates that.
Parameters: (object) label - jQuery label object
Return Values: null, but this method will append an Mc character to every place on your label where the name appears

parentheses: function(label, selector)

Description: Although not for barcodes, this function basically does what asterisks() does, just with parenthesis.
Parameters: (object) that - jQuery label object, (string) selector - CSS selector
Return Values: null

zeroFill: function(num)

Description: Fill a number to six characters with zeros (e.g., 1 becomes 000001).
Parameters: (int or string) number you need to zero-fill
Return Values: (string) zero-filled value