-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
web_widget_darkroom: Add o2m DarkroomJS widget
- Loading branch information
Showing
45 changed files
with
3,621 additions
and
0 deletions.
There are no files selected for viewing
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,95 @@ | ||
.. image:: https://img.shields.io/badge/license-AGPL--3-blue.svg | ||
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html | ||
:alt: License: LGPL-3 | ||
|
||
====================== | ||
Odoo DarkroomJS Widget | ||
====================== | ||
|
||
This module provides a `DarkroomJS`_ web widget for use with images fields. | ||
|
||
.. _DarkroomJS: https://github.com/MattKetmo/darkroomjs | ||
|
||
This widget will allow you to perform the following actions on images: | ||
|
||
* Zoom | ||
* Rotate | ||
* Crop | ||
* Step back in history client-side (before save) | ||
|
||
|
||
Usage | ||
===== | ||
|
||
To use this module, you need to: | ||
|
||
* Install web_widget_darkroom | ||
* Add the to any One2many image relation by using the `darkroom` widget. Options can be passed through to Darkroom using the `options` key:: | ||
|
||
<field name="image_id" widget="darkroom" | ||
options="{'minWidth': 100}" /> | ||
|
||
The Odoo DarkroomJS widget passes options directly through to Darkroom, which are copied from the source below:: | ||
|
||
// Default options | ||
defaults: { | ||
// Canvas properties (dimension, ratio, color) | ||
minWidth: null, | ||
minHeight: null, | ||
maxWidth: null, | ||
maxHeight: null, | ||
ratio: null, | ||
backgroundColor: '#fff', | ||
|
||
// Plugins options | ||
plugins: {}, | ||
|
||
// Post-initialisation callback | ||
initialize: function() { /* noop */ } | ||
}, | ||
|
||
|
||
|
||
Known Issues/Roadmap | ||
==================== | ||
|
||
* Plugins are not able to be added without inheriting, then redefining the widget in the registry due to JS inheritance. | ||
** This is not scalable because there would need to be an explicit dependency chain in order to avoid registry overwrite. | ||
|
||
|
||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues | ||
<https://github.com/OCA/{project_repo}/issues>`_. In case of trouble, please | ||
check there if your issue has already been reported. If you spotted it first, | ||
help us smashing it by providing a detailed and welcomed feedback. | ||
|
||
Credits | ||
======= | ||
|
||
Images | ||
------ | ||
|
||
* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_. | ||
|
||
Contributors | ||
------------ | ||
|
||
* Dave Lasley <[email protected]> | ||
|
||
Maintainer | ||
---------- | ||
|
||
.. image:: https://odoo-community.org/logo.png | ||
:alt: Odoo Community Association | ||
:target: https://odoo-community.org | ||
|
||
This module is maintained by the OCA. | ||
|
||
OCA, or the Odoo Community Association, is a nonprofit organization whose | ||
mission is to support the collaborative development of Odoo features and | ||
promote its widespread use. | ||
|
||
To contribute to this module, please visit https://odoo-community.org. |
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,3 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2016 LasLabs Inc. | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). |
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,28 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2016 LasLabs Inc. | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). | ||
|
||
{ | ||
"name": "Web Darkroom Image Widget", | ||
"summary": "Widget provides a dynamic, editable canvas for use on any" | ||
" One2many image field in backend form views.", | ||
"version": "9.0.1.0.1", | ||
"category": "Web", | ||
"website": "https://laslabs.com/", | ||
"author": "LasLabs, Odoo Community Association (OCA)", | ||
"license": "LGPL-3", | ||
"application": False, | ||
"installable": True, | ||
"depends": [ | ||
"web", | ||
], | ||
"data": [ | ||
'views/assets.xml', | ||
], | ||
'qweb': [ | ||
"static/src/xml/field_templates.xml", | ||
], | ||
'demo': [ | ||
'demo/res_users.xml', | ||
] | ||
} |
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 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
|
||
<!-- | ||
Copyright 2016 LasLabs Inc. | ||
License LGPL-3 or later (http://www.gnu.org/licenses/lgpl.html). | ||
--> | ||
|
||
<openerp> | ||
<data> | ||
<record id="view_users_form" model="ir.ui.view"> | ||
<field name="name">res.users.form.darkroom</field> | ||
<field name="model">res.users</field> | ||
<field name="inherit_id" ref="base.view_users_form" /> | ||
<field name="arch" type="xml"> | ||
<xpath expr="//notebook" position="inside"> | ||
<page string="Darkroom"> | ||
<field name="image" widget="darkroom" /> | ||
</page> | ||
</xpath> | ||
</field> | ||
</record> | ||
</data> | ||
</openerp> | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = LF | ||
indent_style = space | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
indent_size = 2 |
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 @@ | ||
/.sass-cache/ | ||
/bower_components/ | ||
/build/ | ||
/node_modules/ | ||
/docs/ |
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,23 @@ | ||
# Change Log | ||
|
||
All notable changes to this project will be documented in this file. | ||
|
||
## Unreleased | ||
|
||
- Add type "button" to avoid html5 submit validation (#24) | ||
|
||
## 2.0.0 (2015-08-01) | ||
|
||
- Use of **Gulp** for the build process | ||
- Replace the webfont by **SVG symbols** (which are direclty included in the compiled javascript) | ||
- Ability to change **canvas ratio** | ||
- Original image is kept and changes are done on a clone | ||
|
||
## 1.0.x (2014) | ||
|
||
Initial release. | ||
|
||
- Create canvas with FabricJS from an image element | ||
- Plugins: Crop, History, Rotate, Save | ||
- Build process via Grunt | ||
- Build webfont from SVG files to display the icons |
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,18 @@ | ||
Copyright (c) 2013 Matthieu Moquet | ||
|
||
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,88 @@ | ||
# DarkroomJS | ||
|
||
DarkroomJS is a JavaScript library which provides basic image editing tools in | ||
your browser, such as **rotation** or **cropping**. It is based on the awesome | ||
[FabricJS](http://fabricjs.com/) library to handle images in HTML5 canvas. | ||
|
||
## Demo | ||
|
||
Try the online demo at [http://mattketmo.github.io/darkroomjs](http://mattketmo.github.io/darkroomjs/) | ||
|
||
The library is currently *work in progress*. | ||
I know there is some bug especially when resizing the crop zone. | ||
Feel free to fork the project or report issues on GitHub. | ||
All ideas are also welcome. | ||
|
||
## Building | ||
|
||
- Install [Node](http://nodejs.org/) & `npm`. | ||
- Run `npm install` to build dependencies. | ||
- Run `npm start` to build the assets and start the demo webserver. | ||
|
||
## Usage | ||
|
||
Simply instanciate a new Darkroom object with a reference to the image element: | ||
|
||
```html | ||
<img src="some-image.jpg" id="target"> | ||
<script> | ||
new Darkroom('#target'); | ||
</script> | ||
``` | ||
|
||
You can also pass some options: | ||
|
||
```javascript | ||
new Darkroom('#target', { | ||
// Canvas initialization size | ||
minWidth: 100, | ||
minHeight: 100, | ||
maxWidth: 500, | ||
maxHeight: 500, | ||
|
||
// Plugins options | ||
plugins: { | ||
crop: { | ||
minHeight: 50, | ||
minWidth: 50, | ||
ratio: 1 | ||
}, | ||
save: false // disable plugin | ||
}, | ||
|
||
// Post initialization method | ||
initialize: function() { | ||
// Active crop selection | ||
this.plugins['crop'].requireFocus(); | ||
|
||
// Add custom listener | ||
this.addEventListener('core:transformation', function() { /* ... */ }); | ||
} | ||
}); | ||
``` | ||
|
||
## Why? | ||
|
||
It's easy to get a javascript script to crop an image in a web page. | ||
But if your want more features like rotation or brightness adjustment, then you | ||
will have to do it yourself. No more jQuery plugins here. | ||
It only uses the power of HTML5 canvas to make what ever you want with your image. | ||
|
||
## The concept | ||
|
||
The library is designed to be easily extendable. The core script only transforms | ||
the target image to a canvas with a FabricJS instance, and creates an empty toolbar. | ||
All the features are then implemented in separate plugins. | ||
|
||
Each plugin is responsible for creating its own functionality. | ||
Buttons can easily be added to the toolbar and binded with those features. | ||
|
||
## Contributing | ||
|
||
Run `npm develop` to build and watch the files while developing. | ||
|
||
## License | ||
|
||
DarkroomJS is released under the MIT License. See the [bundled LICENSE file](LICENSE) | ||
for details. | ||
|
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,31 @@ | ||
{ | ||
"name": "darkroom", | ||
"description": "Extensible image editing tool via HTML canvas", | ||
"version": "2.0.0", | ||
"homepage": "http://mattketmo.github.io/darkroomjs/", | ||
"authors": [ | ||
"Matthieu Moquet <[email protected]>" | ||
], | ||
"license": "MIT", | ||
"dependencies": { | ||
"fabric": "~1.4.*" | ||
}, | ||
"main": [ | ||
"build/darkroom.css", | ||
"build/darkroom.js" | ||
], | ||
"moduleType": [ | ||
"globals" | ||
], | ||
"keywords": [ | ||
"image", | ||
"canvas", | ||
"crop" | ||
], | ||
"ignore": [ | ||
"node_modules", | ||
"bower_components", | ||
"test", | ||
"tests" | ||
] | ||
} |
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 @@ | ||
#!/bin/bash | ||
|
||
# Update gh-pages branch | ||
git branch -D gh-pages | ||
git checkout -b gh-pages HEAD | ||
|
||
# Build assets | ||
rm -rf build | ||
gulp build --prod | ||
|
||
# Put build into demo folder | ||
rm demo/build | ||
cp -r build demo/build | ||
|
||
# Commit | ||
git add -f demo | ||
git commit -m "Build GH pages" | ||
|
||
# Push & reset | ||
git push origin `git subtree split --prefix demo HEAD`:gh-pages --force | ||
git checkout - |
Oops, something went wrong.