-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(init): pull out the basic angular code from grid core
- Loading branch information
0 parents
commit e641a67
Showing
28 changed files
with
1,618 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
.idea | ||
.sass-cache | ||
**/node_modules/** | ||
!**/node_modules/@grid | ||
bower_components/ | ||
build | ||
node_modules | ||
tmp | ||
test-assets | ||
/coverage | ||
release | ||
release/bundle*.css |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
{ | ||
// JSHint Default Configuration File (as on JSHint website) | ||
// See http://jshint.com/docs/ for more details | ||
|
||
"maxerr": 50, | ||
// {int} Maximum error before stopping | ||
|
||
// Enforcing | ||
"bitwise": true, | ||
// true: Prohibit bitwise operators (&, |, ^, etc.) | ||
"camelcase": true, | ||
// true: Identifiers must be in camelCase | ||
"curly": true, | ||
// true: Require {} for every new block or scope | ||
"eqeqeq": true, | ||
// true: Require triple equals (===) for comparison | ||
"forin": true, | ||
// true: Require filtering for..in loops with obj.hasOwnProperty() | ||
"immed": true, | ||
// true: Require immediate invocations to be wrapped in parens e.g. `(function () { } ());` | ||
"indent": 4, | ||
// {int} Number of spaces to use for indentation | ||
"latedef": "nofunc", | ||
// true: Require variables/functions to be defined before being used | ||
"newcap": true, | ||
// true: Require capitalization of all constructor functions e.g. `new F()` | ||
"noarg": true, | ||
// true: Prohibit use of `arguments.caller` and `arguments.callee` | ||
"noempty": true, | ||
// true: Prohibit use of empty blocks | ||
"nonew": false, | ||
// true: Prohibit use of constructors for side-effects (without assignment) | ||
"plusplus": false, | ||
// true: Prohibit use of `++` & `--` | ||
"quotmark": "single", | ||
// Quotation mark consistency: | ||
"smarttabs": true, | ||
"trailing": true, | ||
"undef": true, | ||
// true: Require all non-global variables to be declared (prevents global leaks) | ||
"unused": "vars", | ||
// true: Require all defined variables be used | ||
"strict": false, | ||
// true: Requires all functions run in ES5 Strict Mode | ||
"maxparams": false, | ||
// {int} Max number of formal params allowed per function | ||
"maxdepth": false, | ||
// {int} Max depth of nested blocks (within functions) | ||
"maxstatements": false, | ||
// {int} Max number statements per function | ||
"maxcomplexity": false, | ||
// {int} Max cyclomatic complexity per function | ||
"maxlen": false, | ||
// {int} Max number of characters per line | ||
|
||
// Relaxing | ||
"asi": false, | ||
// true: Tolerate Automatic Semicolon Insertion (no semicolons) | ||
"boss": false, | ||
// true: Tolerate assignments where comparisons would be expected | ||
"debug": false, | ||
// true: Allow debugger statements e.g. browser breakpoints. | ||
"eqnull": false, | ||
// true: Tolerate use of `== null` | ||
"esnext": true, | ||
// true: Allow ES.next (ES6) syntax (ex: `const`) | ||
"moz": false, | ||
// true: Allow Mozilla specific syntax (extends and overrides esnext features) | ||
// (ex: `for each`, multiple try/catch, function expression…) | ||
"evil": false, | ||
// true: Tolerate use of `eval` and `new Function()` | ||
"expr": true, | ||
// true: Tolerate `ExpressionStatement` as Programs | ||
"funcscope": false, | ||
// true: Tolerate defining variables inside control statements" | ||
"globalstrict": false, | ||
// true: Allow global "use strict" (also enables 'strict') | ||
"iterator": false, | ||
// true: Tolerate using the `__iterator__` property | ||
"lastsemic": false, | ||
// true: Tolerate omitting a semicolon for the last statement of a 1-line block | ||
"laxbreak": false, | ||
// true: Tolerate possibly unsafe line breakings | ||
"laxcomma": false, | ||
// true: Tolerate comma-first style coding | ||
"loopfunc": false, | ||
// true: Tolerate functions being defined in loops | ||
"multistr": true, | ||
// true: Tolerate multi-line strings | ||
"proto": false, | ||
// true: Tolerate using the `__proto__` property | ||
"scripturl": false, | ||
// true: Tolerate script-targeted URLs | ||
"shadow": false, | ||
// true: Allows re-define variables later in code e.g. `var x=1; x=2;` | ||
"sub": false, | ||
// true: Tolerate using `[]` notation when it can still be expressed in dot notation | ||
"supernew": false, | ||
// true: Tolerate `new function () { ... };` and `new Object;` | ||
"validthis": false, | ||
// true: Tolerate using this in a non-constructor function | ||
|
||
// Environments | ||
"browser": true, | ||
// Web Browser (window, document, etc) | ||
"couch": false, | ||
// CouchDB | ||
"devel": true, | ||
// Development/debugging (alert, confirm, etc) | ||
"dojo": false, | ||
// Dojo Toolkit | ||
"jquery": true, | ||
// jQuery | ||
"mootools": false, | ||
// MooTools | ||
"node": true, | ||
// Node.js | ||
"nonstandard": false, | ||
// Widely adopted globals (escape, unescape, etc) | ||
"prototypejs": false, | ||
// Prototype and Scriptaculous | ||
"rhino": false, | ||
// Rhino | ||
"worker": false, | ||
// Web Workers | ||
"wsh": false, | ||
// Windows Scripting Host | ||
"yui": false, | ||
// Yahoo User Interface | ||
|
||
"globals": { | ||
"angular": false, | ||
"describe": false, | ||
"it": false, | ||
"afterEach": false, | ||
"beforeEach": false, | ||
"confirm": false, | ||
"context": false, | ||
"expect": false, | ||
"jasmine": false, | ||
"JSHINT": false, | ||
"mostRecentAjaxRequest": false, | ||
"qq": false, | ||
"spyOn": false, | ||
"spyOnEvent": false, | ||
"xdescribe": false | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.idea | ||
.sass-cache | ||
**/node_modules/** | ||
!**/node_modules/@grid | ||
/bower_components/**/node_modules | ||
build | ||
tmp | ||
test-assets | ||
/coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
save-prefix=~ | ||
ca= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// Place your settings in this file to overwrite default and user settings. | ||
{ | ||
"editor.tabSize": 4, | ||
"editor.formatOnSave": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"generator-angulpify": { | ||
"projectName": "uiq", | ||
"coffee": false, | ||
"jade": false, | ||
"sass": true, | ||
"bootstrap": false, | ||
"uiBootstrap": false, | ||
"uiRouter": false | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
We use semantic release so if you don't already have it: | ||
|
||
`npm i -g commitizen` | ||
|
||
to commit run `git cz` (or if you're a really good commitizen just alias your favorite commit alias to that) | ||
|
||
see [semantic release](https://github.com/semantic-release/semantic-release) for guidelines on how to make commits. we use the standard conventional changelog format. | ||
|
||
there is an automagic circle ci build setup on the master branch which will publish based on your commits as described in the doc above so there's no need to manage npm access or even think about which version to bump. | ||
|
||
please first submit prs if you are an org member. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2014 RelateIQ | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
[![npm](https://img.shields.io/npm/v/grid.svg)]( https://www.npmjs.com/package/grid-angular-adapter) [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/) | ||
|
||
Grid Angular Adapter | ||
=== | ||
|
||
Tools for using Grid with angular (1.0 currently) | ||
|
||
Installation | ||
=== | ||
`npm install --save grid-angular-adapter` | ||
|
||
|
||
the three srvcs currently exposed can be injected | ||
|
||
`function(GridSrvc, GridBuilderSrvc, GridDecoratorSrvc){}` | ||
|
||
|
||
if not using angular | ||
|
||
`var core = require('grid/src/modules/core')` | ||
|
||
|
||
**angular directive decorator** | ||
``` javascript | ||
angular.module('myCoolGrid', [require('grid')]) | ||
|
||
.controller('MyGridCtrl', function($scope, GridSrvc, GridDecoratorSrvc) { | ||
var grid = GridSrvc.core(); | ||
|
||
// do row col and datamodel setup... | ||
|
||
var top = 20, | ||
left = 10, | ||
height = 2, | ||
width = 2, | ||
unit = 'cell', | ||
space = 'virtual'; | ||
var d = grid.decorators.create(top, left, height, width, unit, space); | ||
|
||
// return some element | ||
d.render = function() { | ||
var scope = $scope.$new(); | ||
scope.interestingData = 'INTERESTING DATA!!!'; | ||
return GridDecoratorSrvc.render({ | ||
$scope: scope, | ||
template: '<my-directive data="interestingData"></my-directive>', | ||
events: true | ||
}); | ||
}; | ||
grid.decorators.add(d); | ||
}); | ||
``` | ||
|
||
This will put your compiled directive in a box that spans from `row 20-22` and `col 10-12`, and moves appropriately with the scroll. The `events` flag lets the grid know that this decorator is interactable and should receive mouse events. (Otherwise pointer events are set to none.) The GridDecoratorSrvc takes care of destroying the scope and properly removing elements to avoid memory leaks with angular. You definitely should use it for any angular decorators. | ||
|
||
|
||
## Builders | ||
Builders help you to get html into the actual cells of a given row or column instead of the text that would have been rendered. | ||
|
||
|
||
**basic builders** | ||
``` javascript | ||
var builder = grid.colModel.createBuilder(function render() { | ||
return angular.element('<a href="#"></a>')[0]; | ||
}, function update(elem, ctx) { | ||
grid.viewLayer.setTextContent(elem, ctx.data.formatted); | ||
return elem; | ||
}); | ||
var colDescriptor = grid.colModel.create(builder); | ||
``` | ||
|
||
have `<a>` tags in your cells for all the rows in that column | ||
|
||
**angular cell builder** | ||
|
||
``` javascript | ||
angular.module('myCoolGrid', [require('grid')]) | ||
|
||
.controller('MyGridCtrl', function($scope, GridSrvc, GridBuilderSrvc) { | ||
var grid = GridSrvc.core(); | ||
|
||
// do row col and datamodel setup... | ||
|
||
grid.colModel.create(grid.colModel.createBuilder(function render(ctx) { | ||
return GridBuilderSrvc.render($scope, '<my-directive data="interestingData"></my-directive>'); | ||
}, function update(elem, ctx) { | ||
var scope = angular.element(elem).scope(); | ||
scope.interestingData = ctx.data.formatted; | ||
scope.$digest(); | ||
return elem; | ||
})); | ||
}); | ||
``` | ||
|
||
The GridBuilderSrvc handles destroying the scope and properly removing the elements to prevent memory leaks. | ||
|
||
Note: it's important for the update function of a builder to be extremely fast. Call `scope.$digest` not `scope.$apply`, and use `grid.viewLayer.setTextContent` not `elem.innerHTML` where possible | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<!DOCTYPE html> | ||
<html ng-app="gridApp"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<title></title> | ||
<script> | ||
window.onerror = function (errorMsg, url, lineNumber, columnNumber, errorObject) { | ||
if (errorObject && /<omitted>/.test(errorMsg)) { | ||
console.error('Full exception message: ' + errorObject.message); | ||
} | ||
} | ||
</script> | ||
<!--styles--> | ||
<link rel="stylesheet" type="text/css" href="grid.css" /> | ||
</head> | ||
<body> | ||
<grid-app></grid-app> | ||
|
||
</div> | ||
<!--scripts--> | ||
<script src="app.js"></script> | ||
</body> | ||
</html> |
Oops, something went wrong.