• This repository has been archived on 08/Sep/2020
  • Stars
    star
    410
  • Rank 102,038 (Top 3 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created almost 11 years ago
  • Updated about 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

This directive allows you to split !

UI.Layout directive Build Status

This directive allows you to split stuff ! Holy grail demo

Requirements

  • AngularJS

NOTE : if you use IE<=9, iOS<7 or Android<4 please include the requestAnimationFrame polyfill in your application.

NOTE : version 1.x is only compatible with IE>=10. If you use IE<=9 you need to use version 0.x

Installing

Browserify/WebPack

npm install --save angular-ui-layout

module.exports of index.js is the string 'ui.layout' so you can include it as such:

angular.module('myApp', [require('angular-ui-layout')]);

Bower

bower install angular-ui-layout\#bower
# or
bower install angular-ui-layout\#v0.0.0
# or
bower install angular-ui-layout\#src0.0.0

This will copy the UI.Layout files into a bower_components folder, along with its dependencies. Load the script files in your application:

<link rel="stylesheet" type="text/css" href="bower_components/angular-ui-layout/ui-layout.css"/>
<!-- ... -->
<script type="text/javascript" src="bower_components/raf/index.js"></script>
<script type="text/javascript" src="bower_components/angular-ui-layout/ui-layout.js"></script>

Add the UI.Layout module as a dependency to your application module:

var myAppModule = angular.module('MyApp', ['ui.layout']);

Usage

Add the directive like so:

<div ui-layout="{ flow : 'row' }"></div>
or
<ui-layout options="{ flow : 'row' }"></ui-layout>

If using a layout-container with ng-repeat, make sure to include a track by clause to the repeat, typically with $index:

<div ui-layout="{flow : 'column'}" class="maincontainer" >
  <div ui-layout-container ng-repeat="item in items track by $index"></div>
</div>

Options

flow

Type: String Default: 'row' flow: row | column

A fake flex-direction property. It specifies how the child elements are placed in the layout container, by setting the direction of the flex container's main axis. This determines the direction that child elements are laid out in.

dividerSize

Type: Integer Default: 10

The size in pixels that you want the divider/splitbar to be. Set to 0 to hide the splitbar, which in turn prevents user resizing the surrounding containers.

disableToggle

Type: Boolean Default: false

Set to true if you don't want the toggle arrows appearing in the splitbar.

disableMobileToggle

Type: Boolean Default: false

Like disableToggle above but only removes the arrows on mobile devices (max-device-width: 480px).

Child Attributes

uiLayoutContainer

Required on all child elements of the ui-layout element.

<div ui-layout>
    <div ui-layout-container></div>    
    <div ui-layout-container></div>    
</div>

Options

A string value 'central' can be passed to the directive:

<div ui-layout>
    <div ui-layout-container></div>    
    <div ui-layout-container="central"></div>    
    <div ui-layout-container></div>    
</div>

The 'central' container takes up all the remaining space during resizing, regardless of previous state, e.g. after splitbar drag.

collapsed [collapsed]

Type: boolean

<div ui-layout>
    <div ui-layout-container collapsed="true"></div>    
    <div ui-layout-container collapsed="layout.mycontainer"></div>    
</div>

Controls collapsed state of the container. Application can store the state of the layout e.g. like so:

$scope.layout {
  toolbar: true,
  leftSidebar: false,
  mycontainer: false
}

Changing those values will toggle container. See also [ui.layout.toggle][event-toggle].

size

Type: String

Sets the default placement of the splitbar.

pixels
<div ui-layout>
    <div ui-layout-container size="100px"></div>
</div>

percentage
<div ui-layout>
    <div ui-layout-container size="10%"></div>
</div>

minSize

Type: String Default: '8px'

Specifices the minimum size the child element can be set to. Defaults to the width of the splitbar if no value is provided.

pixels
<div ui-layout>
    <div ui-layout-container min-size="100px"></div>
</div>

percentage
<div ui-layout>
    <div ui-layout-container min-size="10%"></div>
</div>

maxSize

Type: String

Specifices the maxium size the child element can be set to.

pixels
<div ui-layout>
    <div ui-layout-container max-size="100px"></div>
</div>

percentage
<div ui-layout>
    <div ui-layout-container max-size="10%"></div>
</div>

Events

Events are broadcast on the scope where ui-layout is attached. This means they are available to any controller inside of a ui-layout container.

ui.layout.loaded

Returns: string or null

Dispatched when the layout container finished loading. It returns the value of the attribute, e.g. ui-layout-loaded="my-loaded-message", or null. The null also means that the layout has finished collapsing all the containers that should be collapsed (per application request when setting the [collapsed][collapsed] attribute).

Collapsing container on application load currently goes through these steps:

  1. layout is first loaded with all containers uncollapsed (disregarding user set values), then
  2. containers are collapsed either:
  • automatically: application has not set a string return value for the ui.layout.loaded event.
  • manually: application sets collapsed flags in the callback passed to ui.layout.loaded

All this means that the user will notice a flicker. If the flicker is not desirable, hide the layout behind an overlay, wait for the ui.layout.loaded event. In the "automatic" mode, all is done and the layout should be presentable. In the "manual" mode it is up to the application to count the ui.layout.toggle events.

<div id="main-container" ui-layout ui-layout-loaded>
    <div ui-layout-container>
      <div ui-layout ui-layout-loaded="child-container">
          <div ui-layout-container>
          
          </div>
      </div>
    </div>
</div>
$scope.$on('ui.layout.loaded', function(evt, id) => {
  switch (id) {
    case 'main-container':
      ...
      break;
    case 'child-container':
      ...
      break;
    default:
      break;
  }
});

Note: the value of the attribute is not evaluated, so:

$scope.layout = {
  mySidebar: {someKey: 'some value'}
}

<div id='my-sidebar' ui-layout ui-layout-loaded="layout.mySidebar.someKey"></div>
// $scope.$on will receive the string 'layout.mySidebar.someKey'

ui.layout.toggle [event-toggle]

Dispatched when a container is opened or closed. Element can be identified container.id, which is the same as element.id if provided, otherwise it is null.

$scope.$on('ui.layout.toggle', function(e, container){
  if ( container.size > 0 ){
     console.log('container is open!');
  }
});

Manually toggling (clicking the arrow button on the splitbar) will not update the collapsed attribute. If the application is using the collapsed attribute of ui-layout-container to programmatically control the collapsed state, the application should update it's state when this event occurs to stay in sync with the UI.

ui.layout.resize

Dispatched as a splitbar is dragged, debounced to occur only every 50ms.

$scope.$on('ui.layout.resize', function(e, beforeContainer, afterContainer){});

Testing

We use Karma and jshint to ensure the quality of the code. The easiest way to run these checks is to use grunt:

npm install -g gulp
npm install && bower install
gulp

The karma task will try to open Firefox and Chrome as browser in which to run the tests. Make sure this is available or change the configuration in test\karma-jqlite.conf.js and test\karma-jquery.conf.js

Some test tasks :

  • gulp karma : Will run jqlite and jquery tests in simple run mode,
  • gulp karma:jqlite:unit : Will run jqlite tests in simple run mode,
  • gulp karma:jquery:unit : Will run jquery tests in simple run mode,
  • gulp karma:jqlite:watch : Will run jqlite tests and watch for changes,
  • gulp karma:jquery:watch : Will run jquery tests and watch for changes,

** gulp serve runs and watches all**

More Repositories

1

bootstrap

PLEASE READ THE PROJECT STATUS BELOW. Native AngularJS (Angular) directives for Bootstrap. Smaller footprint (20kB gzipped), no 3rd party JS dependencies (jQuery, bootstrap JS) required. Please read the README.md file before submitting an issue!
JavaScript
14,347
star
2

ui-router

The de-facto solution to flexible routing with nested views in AngularJS
TypeScript
13,611
star
3

ui-grid

UI Grid: an Angular Data Grid
JavaScript
5,386
star
4

ui-select

AngularJS-native version of Select2 and Selectize
JavaScript
3,278
star
5

angular-google-maps

AngularJS directives for the Google Maps Javascript API
CoffeeScript
2,530
star
6

angular-ui-OLDREPO

DISCONTINUED REPO: This project has been restructured ->
JavaScript
2,210
star
7

ui-calendar

A complete AngularJS directive for the Arshaw FullCalendar.
JavaScript
1,494
star
8

ui-utils

Deprecated collection of modules for angular
JavaScript
1,443
star
9

AngularJS-sublime-package

AngularJS code completion, snippets, go to definition, quick panel search, and more.
JavaScript
1,422
star
10

ui-sortable

jQuery UI Sortable for AngularJS
JavaScript
1,265
star
11

ui-select2

AngularJS wrapper for select2 (deprecated, use angular-ui/ui-select)
JavaScript
594
star
12

ui-ace

This directive allows you to add ACE editor elements.
JavaScript
580
star
13

ui-tinymce

AngularUI wrapper for TinyMCE
JavaScript
490
star
14

ui-mask

Mask on an input field so the user can only type pre-determined pattern
JavaScript
393
star
15

ui-codemirror

This directive allows you to add CodeMirror to your textarea elements.
JavaScript
383
star
16

ui-grid.info

Website for ui-grid
377
star
17

ui-scroll

Unlimited bidirectional scrolling over a limited element buffer for AngularJS applications
JavaScript
324
star
18

ui-leaflet

AngularJS directive to embed an interact with maps managed by Leaflet library
JavaScript
316
star
19

AngularJS-StyleGuide

Example of scalable architecture for my NG-Conf 2014 talk
JavaScript
287
star
20

ui-map

Google Maps
JavaScript
285
star
21

AngularJS-Atom

An AngularJS package for Github's Atom editor
CoffeeScript
285
star
22

ui-date

jQuery UI Datepicker for AngularJS
JavaScript
266
star
23

ui-slider

jQuery UI Slider for AngularJS
HTML
265
star
24

AngularJS-brackets

AngularJS plugin for Brackets (booya)
JavaScript
217
star
25

bootstrap-bower

This is a bower repository to hold Angular UI Bootstrap releases.
JavaScript
158
star
26

alias

Create concise aliases for third-party directives and templates
JavaScript
115
star
27

ui-mention

Facebook-like @mentions for text inputs built around composability
JavaScript
115
star
28

ui-validate

General-purpose validator for ngModel
JavaScript
111
star
29

ui-chart

This directive lets you use jqPlot with Angular
JavaScript
111
star
30

ui-uploader

Customizable file uploader
JavaScript
108
star
31

ui-tour

A native tour-type directive that will lace easily-controllable tooltips throughout your app
HTML
94
star
32

AngularJs.tmbundle

AngularJs Textmate Bundle
87
star
33

angular-ui.github.com

Angular UI homepage
HTML
80
star
34

bower-ui-grid

Bower package for UI Grid
JavaScript
39
star
35

ui-scrollpoint

Add a 'ui-scrollpoint' class to elements when the page scrolls past them.
JavaScript
29
star
36

ui-event

Bind a callback to any event not natively supported by Angular
JavaScript
28
star
37

AngularJS-tern-plugin

A, slow'ish moving, WIP plugin for Tern that enables it to understand AngularJS dependency injection.
JavaScript
26
star
38

community

Placeholder repo for discussion
24
star
39

angular-ui-publisher

Helper component for building and publishing your angular modules as bower components
JavaScript
20
star
40

ui-leaflet-draw

angular directive for ui-leaflet to utilize Leaflet.Draw
CoffeeScript
16
star
41

ui-indeterminate

Toggle a checkbox input's special 'indeterminate' property
JavaScript
14
star
42

angular-ui-router-bower

Bower publishing for Angular UI-Router for ng1
14
star
43

ui-calendar2

Angular Native Calendar, inspired by ui-calendar
JavaScript
13
star
44

angular-ui-docs

Helper component for building your angular modules as bower components
JavaScript
10
star
45

ng-grid-legacy

ng-grid 2.x
JavaScript
5
star
46

builder

Build server for angular-ui
JavaScript
3
star
47

ui-position

Helper class used by a lot of angular projects on the web
1
star