Skip to content
This repository was archived by the owner on Aug 5, 2020. It is now read-only.
/ selector-utils Public archive

Selector utility functions that can be selectively included in your Adaptive.js builds.

Notifications You must be signed in to change notification settings

mobify/selector-utils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

90 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Selector Utils

Selector utility functions that can be selectively included in your Adaptive.js builds.

NPM Circle CI

Requirements

Zepto Support

Selector Utils support Zepto up until v1.1.0 but is not actively developed for it. While we don't actively support Zepto for Selector Utils, we welcome any and all issues and PRs to help us make it work.

Installation

Selector Utils can be installed to your Adaptive.js build using NPM:

npm install selector-utils --save

Usage with Require.js

To use with require.js, after installing through NPM you merely have to reference the desired utils in your require config file(s) (Note: If your project already has Velocity as an external dependency, and the versions are compatible, it's recommended that you use the one in your project to reduce duplication. Adaptive projects will automatically minify the util src code when building.):

{
    'paths': {
        '$': '$',
        'velocity': 'node_modules/velocity-animate/velocity',
        'isChildOf': 'node_modules/selector-utils/src/selector/isChildOf',
        'removeEmpty': 'node_modules/selector-utils/src/selector/removeEmpty',
        'scrollTo': 'node_modules/selector-utils/src/selector/scrollTo',
        'swap': 'node_modules/selector-utils/src/selector/swap',
        'traversals': 'node_modules/selector-utils/src/selector/traversals',
        'unwrapTables': 'node_modules/selector-utils/src/selector/unwrapTables',
        'any': 'node_modules/selector-utils/src/utils/any',
        'capitalize': 'node_modules/selector-utils/src/utils/capitalize',
        'format': 'node_modules/selector-utils/src/utils/format',
        'nestedValue': 'node_modules/selector-utils/src/utils/nestedValue'
    }
}

And then require in and use the util as needed:

define(
    ['$', 'isChildOf'],
    function($) {
        if ($('.childElement').isChildOf('.parentElement')) {
            // do something
        }
    }
);

Available Utilities

Utilities

  • $.any
  • $.capitalize
  • $.format
  • $.nestedValue

Selector Extensions

  • $('.element').removeEmpty()
  • $('.element').removeStyle(andDescendants)
  • $('.element').swap(tag)
  • $('.element').isChildOf(selector)
  • $('.element').prevUntil(selector)
  • $('.element').nextUntil(selector)
  • $('.element').prevAll()
  • $('.element').nextAll()
  • $('.element').unwrapTables(tag)

Static Selector Extensions

  • $.scrollTo($element, options) (Requires Velocity)

About

Selector utility functions that can be selectively included in your Adaptive.js builds.

Resources

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors 5