ckc-angularjs-utility

An Angularjs module that has some common helper functions

Added by: Sam Deering

GitHub

Repository

ckelsey/ckc-angularjs-utility

Stats

Stars: 0

Watchers: 0

Forks: 0

Module Description

ckc-angularjs-utility

An Angularjs module that has some common helper functions

###Example ####Javascript

angular.module('st4rtApp',[
    'utility_module'
]).controller('AppCtlr', ['Sendgrid', function (Sendgrid){
    var self = this;
    this.Sendgrid = Sendgrid;
}]);

###Methods

  • .debug(anything)

    • Print a javascript expression, object, string, etc. in the console. It will also write the into the html as a return
  • .domain()

    • Returns the current domain
  • .scroll_to(string)

    • Scrolls the page to a specific element id(Angular has issues with anchor tags using hashtags)
  • .trim_text(string, limit)

    • Trims the passed text to the passed length. If it is longer than specified, adds an ellipses
  • .parse_json(json)

    • Safely returns an object from JSON. If error, returns the supplied json
  • .stringify(object)

    • Safely returns a string from an object. If error, returns the supplied object
  • .parse_commas(string)

    • Returns an array of a string split by commas
  • .object_length(object)

    • Returns the number of properties in an object
  • .color_luminance(color(string), adjustment(float))

    • Adjusts a given color(hex, rgb, rgba, hsl) up or down where 1 is 16 bits. Note 1, 0, -1 equals no change. Returns rgb()
  • .convert_color(color(string), target_type(string))

    • Converts a color from one standard to another (hls, rgb, hex)
  • .is_it(start(object), expression(string), equals(boolean))

    • Returns true or false. The first argument is either the starting object, array, string, number. The second argument is the object/array property path if it applies. Lastly, the third argument is what it should equal
  • .to_text(HTML)

    • Takes html and converts it to text
  • .validate_email(string)

    • Checks to see if the passed string is a valid email in that it contains '@' and a domain name
  • .get_time(object{timestamp, hours, minutes, seconds, miliseconds, am_pm, delimiter})

    • Returns a formatted time as hour:minute:second:miliseconds AM/PM
  • .format_date(object{date, display(string)})

    • Returns a formatted date using these keys:
      • year_short
      • year_long
      • month_number
      • month_name_short
      • month_name_long
      • day_number
      • day_name_short
      • day_name_long
      • hours
      • minutes
      • seconds
      • miliseconds
      • am_pm
  • .merge(object, object)

    • Merges object2 properties and values into object1
  • .math(method(string), expression(number/string))

    • Will perform javascript math functions in a template
  • .is_past(then(date))

    • Will compare the current date and time with a supplied date and time to see if it is in the past or not
  • .trust_url(string)

    • An angular helper to that declares a safe url to bind to. Only use if you know the source of the url
  • .trust_html(anything)

    • An angular helper to that declares safe html to bind to. Only use if you know the source of the html

###Directives

  • ellipsis-bind
    • Limits a body of text by a specified number of lines

    • Attributes

      • ellipsis-symbol
        • Defaults to "...", can be whatever you want
      • ellipsis-lines
        • Defaults to "...", can be whatever you want
      • ellipsis-watch
        • Makes Angular specifically watch the text, in case it's going to change
      • ellipsis-bind
        • What calls the directive as well as defines what is the text

###Use

  • Bower - ckc-angularjs-utility
  • Add "utility_module" to your app's dependencies
  • Add "utility.min.js" to your scripts

Module stats last updated: 2015-04-19 12:38:32

Disclaimer: Some data on this page may have been gathered from the authors GitHub respository. If you see any mistakes or outdated information please let us know. Thanks!