# mootools-plus mootools-plus provides helpers and Ruby-like methods to Javascript MooTools core classes and plus. ## Installation Add the gem in your `Gemfile`: ```ruby group :assets do gem 'mootools-plus', '~> 0.2.0' end ``` Then `bundle install` it. Add mootools-plus to the asset pipeline: ```javascript //= require mootools-plus ``` Enjoy! ## Documentation ### Array #### `compact() → array` Alias of Array#clean #### `deleteIf(function) → array` Deletes every element of the array for which function evaluates to true. * Example ```javascript [1, 2, 3, 4].deleteIf(function(){ return this < 3 }) // => [1, 2] ``` * [Source](https://github.com/caedes/mootools-plus/blob/stable/vendor/assets/javascripts/mootools-plus/array.js#L12) #### `filterOne(fn, bind) → other` Returns only the first element of the array for which function evaluates to true. * Example ```javascript [1, 2, 3, 4, 3, 4].filterOne(function(){ return this == 3 }) // => 3 ``` * [Source](https://github.com/caedes/mootools-plus/blob/stable/vendor/assets/javascripts/mootools-plus/array.js#L20) #### `first(int) → array|other` Alias of Array#getFirst #### `getFirst(int) → array|other` Returns the first element(s) of an array. * Example ```javascript [1, 2, 3, 4].getFirst() // => 1 [1, 2, 3, 4].getFirst(3) // => [1, 2, 3] ``` * [Source](https://github.com/caedes/mootools-plus/blob/stable/vendor/assets/javascripts/mootools-plus/array.js#L3) #### `getLast(int) → array|other` Returns the last element(s) of an array. * Example ```javascript [1, 2, 3, 4].getLast() // => 1 [1, 2, 3, 4].getLast(2) // => [1, 2] ``` * [Source](https://github.com/caedes/mootools-plus/blob/stable/vendor/assets/javascripts/mootools-plus/array.js#L7) #### `hasAny() → boolean` Returns true if the array contains at least one element. * Example ```javascript [1, 2, 3, 4].hasAny() // => true [].hasAny() // => false ``` * [Source](https://github.com/caedes/mootools-plus/blob/stable/vendor/assets/javascripts/mootools-plus/array.js#L28) #### `isBlank() → boolean` Returns true if the array contains no elements. * Example ```javascript [1, 2, 3, 4].isBlank() // => false [].isBlank() // => true ``` * [Source](https://github.com/caedes/mootools-plus/blob/stable/vendor/assets/javascripts/mootools-plus/array.js#L24) #### `isEmpty() → boolean` Alias of Array#isBlank #### `last(int) → array|other` Alias of Array#getLast #### `select(fn, bind) → array` Alias of Array#filter #### `selectOne(fn, bind) → other` Alias of Array#filterOne ### ui.Dropdown #### Use ```haml %div %header %a= 'Pipo' %ol %li %a= 'item 1' %li %a= 'item 2' %li %a= 'item 3' %li %a= 'item 4' %li %a= 'item 5' %li %a= 'item 6' ``` ```javascript new ui.Dropdown($$('div')[0]) ``` [Example](http://jsfiddle.net/9BZw9/) #### Options ```javascript { panel: { openAtStart: false // Set to true to open the dropdown at initialization } } ``` ## Changelog View [CHANGELOG](https://github.com/caedes/mootools-plus/blob/stable/CHANGELOG.md) of the latest stable version. ## License This project uses MIT-LICENSE.