Git Product home page Git Product logo

angular-gridster-1's Introduction

angular-gridster

An Angular directive for Gridster.

NOTE: I don't have any more projects which depend on this directive and as such I don't spend much time maintaining it. Unless you absolutely need Gridster, you may want to look at the Manifest Web Designs angular gridster module.

Installation

bower install https://github.com/tmrudick/angular-gridster.git

Basic Usage

<ul gridster="{ draggable: { enabled: true } }" gridster-changed="updated(serialized)">
  <li gridster-repeat="widget in widgets" layout="layout[$index]">{{ widget.title }}</li>
</ul>

gridster Directive

Holds grid-wide options and callbacks and instantiates Gridster. Also, it exposes a gridster function which can be used to access the Gridster API directly. The can be especially useful when resizing or removing widgets from subdirectives.

Parameters

All parameters are optional.

  • gridster - (String) JSON encoded Gridster options object.

  • gridster-changed - (Expression) function which takes a parameter named serialized which will be called whenever the serialized version of the grid changes due to resize or drag.

  • gridster-editable - (Expression) expression which evaluates to a boolean value indicating if the grid should be editable. If false, resizing and reordering is disabled.

gridsterRepeat Directive

Stripped down version of ngRepeat which will repeat DOM elements once and then hand off all DOM manipulation off to Gridster. Additional items can be added via the Gridster API.

This directive will NOT watch the collection for changes after elements have been added. I ran into many problems with using ngRepeat and Gridster. Specifically around removing elements from the grid.

Unlike ngRepeat, gridsterRepeat will only iterate over Arrays.

Similarly to ngRepeat, gridsterRepeat exposes all of the same $index, $last, etc scope variables.

Parameters

  • gridsterRepeat - (Expression) 'item in collection' expression where item is an identifier and collection is an Array on the scope.

  • gridster-layout - (Expression) expression which evaluates to an array of serialized positions (from the Gridster serialize method) or a single object from that array (using something like layout="grid[$index]").

Using the Gridster API directly

It is possible to use the underlying Gridster API from a sub-directive.

angular.module('directives', [])
  .directive('deletable', function() {
    return {
      template: '<button>Delete Me</button>',
      require: '^gridster',
      link: function(scope, element, attr, controller) {
        element.click(function() {
          controller.gridster().remove_widget(element.parent());
        });
      }
    };
  });

Contributing

File an issue and send a pull request!

Please report any issues using the Github issue tracker for this project.

angular-gridster-1's People

Contributors

bsmithgall avatar tmrudick avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.