├── .gitignore
├── .jshintrc
├── CONTRIBUTING
├── COPYRIGHT
├── Gruntfile.js
├── LICENSE.md
├── NOTICE
├── README.md
├── demo
├── circle-outside.html
├── ellipse-outside.html
├── polygon-outside.html
├── reference-box.html
└── style.css
├── dist
├── CSSShapesEditor-min.js
└── CSSShapesEditor.js
├── package.json
├── src
├── CSSShapesEditor.js
├── CSSUtils.js
├── CircleEditor.js
├── Editor.js
├── EllipseEditor.js
├── PolygonEditor.js
├── ToolBar.js
├── fragments
│ ├── end.frag
│ └── start.frag
├── main.js
└── third-party
│ ├── almond
│ ├── LICENSE
│ ├── README.md
│ ├── almond.js
│ ├── package.json
│ └── shrinktest.sh
│ ├── eve
│ ├── LICENSE
│ ├── README.md
│ ├── component.json
│ ├── e.html
│ ├── eve.js
│ └── package.json
│ ├── jquery
│ └── jquery.min.js
│ ├── lodash
│ ├── LICENSE.txt
│ └── lodash.js
│ ├── requirejs
│ ├── require.js
│ └── text.js
│ ├── snap.freetransform
│ └── snap.freetransform.js
│ ├── snap.plugins
│ └── snap.plugins.js
│ └── snap
│ ├── LICENSE.txt
│ ├── snap.js
│ └── snap.svg-min.js
├── test
├── SpecRunner.html
├── main.js
├── spec
│ ├── CSSShapesEditorSpec.js
│ ├── CSSUtilsSpec.js
│ ├── CircleEditorSpec.js
│ ├── EllipseEditorSpec.js
│ ├── PolygonEditorSpec.js
│ └── test-files
│ │ ├── cssutils-markup.html
│ │ └── markup.html
└── third-party
│ └── jasmine
│ ├── MIT.LICENSE
│ ├── jasmine-html.js
│ ├── jasmine.css
│ └── jasmine.js
└── testem.json
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | node_modules
3 | dist/CSSShapesEditor.js
4 | dist/css-shapes-editor.js
5 | ./test/.DS_Store
6 | private
7 |
--------------------------------------------------------------------------------
/.jshintrc:
--------------------------------------------------------------------------------
1 | {
2 | "bitwise" : true,
3 | "curly" : true,
4 | "eqeqeq" : true,
5 | "forin" : true,
6 | "immed" : true,
7 | "latedef" : true,
8 | "newcap" : true,
9 | "noarg" : true,
10 | "noempty" : true,
11 | "nonew" : true,
12 | "plusplus" : true,
13 | "regexp" : true,
14 | "undef" : true,
15 | "strict" : true,
16 | "trailing" : false,
17 |
18 | "asi" : false,
19 | "boss" : false,
20 | "debug" : false,
21 | "eqnull" : false,
22 | "es5" : false,
23 | "esnext" : false,
24 | "evil" : false,
25 | "expr" : false,
26 | "funcscope" : false,
27 | "globalstrict" : false,
28 | "iterator" : false,
29 | "lastsemic" : false,
30 | "laxbreak" : false,
31 | "laxcomma" : false,
32 | "loopfunc" : false,
33 | "multistr" : false,
34 | "onecase" : false,
35 | "proto" : false,
36 | "regexdash" : false,
37 | "scripturl" : false,
38 | "smarttabs" : false,
39 | "shadow" : false,
40 | "sub" : false,
41 | "supernew" : false,
42 | "validthis" : false,
43 |
44 | "browser" : true,
45 | "couch" : false,
46 | "devel" : false,
47 | "dojo" : false,
48 | "jquery" : false,
49 | "mootools" : false,
50 | "node" : false,
51 | "nonstandard" : false,
52 | "prototypejs" : false,
53 | "rhino" : false,
54 | "wsh" : false,
55 |
56 | "nomen" : false,
57 | "onevar" : false,
58 | "passfail" : false,
59 | "white" : false,
60 |
61 | "maxerr" : 100,
62 | "predef" : [
63 | ],
64 | "indent" : 4,
65 | "globals" : [
66 | "require",
67 | "define",
68 | "brackets",
69 | "$",
70 | "PathUtils",
71 | "window",
72 | "navigator",
73 | "Mustache"
74 | ]
75 | }
--------------------------------------------------------------------------------
/CONTRIBUTING:
--------------------------------------------------------------------------------
1 | Contributions to this code are covered by the Adobe contributors license agreement.
2 |
3 | Developers must read, sign and submit the Adobe CLA before contributing to this project:
4 | https://adobe.echosign.com/public/hostedForm?formid=9H27ZS66W2S5CX
5 |
--------------------------------------------------------------------------------
/COPYRIGHT:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2014 Adobe Systems Incorporated. All rights reserved.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 | //
15 | // @NAME @VERSION
16 | //
17 | // @DESCRIPTION
18 | //
19 | // build: @DATE
20 |
--------------------------------------------------------------------------------
/Gruntfile.js:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2014 Adobe Systems Incorporated. All rights reserved.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | /*jslint vars: true, plusplus: true, devel: true, nomen: true, regexp: true, indent: 4, maxerr: 50 */
16 | /*global module, require */
17 |
18 | module.exports = function (grunt) {
19 |
20 | 'use strict';
21 |
22 | require('load-grunt-tasks')(grunt);
23 |
24 | grunt.initConfig({
25 |
26 | pkg: grunt.file.readJSON("package.json"),
27 |
28 | // configurable paths
29 | project: {
30 | out: 'dist/CSSShapesEditor.js',
31 | outmin: 'dist/CSSShapesEditor-min.js'
32 | },
33 |
34 | banner: grunt.file.read('./COPYRIGHT')
35 | .replace(/@NAME/, '<%= pkg.name %>')
36 | .replace(/@DESCRIPTION/, '<%= pkg.description %>')
37 | .replace(/@VERSION/, '<%= pkg.version %>')
38 | .replace(/@DATE/, grunt.template.today("yyyy-mm-dd")),
39 |
40 | watch: {
41 | files: ['src/{,*/}*.js'],
42 | tasks: ['jshint:src']
43 | },
44 |
45 | jshint: {
46 | options: {
47 | jshintrc: '.jshintrc'
48 | },
49 | src: [
50 | 'src/*.js',
51 | // 'test/spec/{,*/}*.js'
52 | ]
53 | },
54 |
55 | testem: {
56 | chrome: {
57 | options: JSON.parse(grunt.file.read('testem.json'))
58 | }
59 | },
60 |
61 | requirejs: {
62 | compile: {
63 | options: {
64 | baseUrl: 'src/',
65 | mainConfigFile: 'src/main.js',
66 | out: '<%= project.out %>',
67 | name: 'main',
68 | include: ['third-party/almond/almond'],
69 | wrap: {
70 | startFile: 'src/fragments/start.frag',
71 | endFile: 'src/fragments/end.frag'
72 | },
73 | optimize: 'none'
74 | }
75 | }
76 | },
77 |
78 | uglify: {
79 | options: {
80 | banner: "<%= banner %>",
81 | report: "min"
82 | },
83 | dist: {
84 | src: "<%= project.out %>",
85 | dest: "<%= project.outmin %>"
86 | }
87 | },
88 |
89 | // Used just to concat the copyright banner
90 | concat: {
91 | options: {
92 | banner: "<%= banner %>"
93 | },
94 | dist: {
95 | dest: "<%= project.out %>",
96 | src: ["<%= project.out %>"]
97 | }
98 | },
99 |
100 | /*
101 | Usage:
102 | grunt bump:minor
103 | grunt bump:build
104 | grunt bump:major
105 | grunt bump --setversion=2.0.1
106 |
107 | grunt bump-only:patch
108 | */
109 | bump: {
110 | options: {
111 | files: ['package.json'],
112 | updateConfigs: ['pkg'],
113 | commit: true,
114 | commitMessage: 'Release v%VERSION%',
115 | commitFiles: ['package.json','dist/'], // '-a' for all files
116 | createTag: true,
117 | tagName: 'v%VERSION%',
118 | tagMessage: 'Version %VERSION%',
119 | push: false,
120 | pushTo: 'origin',
121 | gitDescribeOptions: '--tags --always --abbrev=1 --dirty=-d' // options to use with '$ git describe'
122 | }
123 | }
124 | });
125 |
126 | grunt.registerTask('build', ['jshint:src', 'requirejs', 'concat', 'uglify']);
127 |
128 | grunt.registerTask('test', ['testem:run:chrome']);
129 |
130 | grunt.registerTask('lint', ['jshint:src']);
131 |
132 | grunt.registerTask('release', function (type) {
133 | type = type ? type : 'patch'; // Default release type
134 | grunt.task.run('bump:' + type); // Bump up the version
135 | grunt.task.run('build'); // Build the file
136 | });
137 | };
138 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | Copyright 2014 Adobe Systems Incorporated. All rights reserved.
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
15 | Apache License
16 | Version 2.0, January 2004
17 | http://www.apache.org/licenses/
18 |
19 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
20 |
21 | 1. Definitions.
22 |
23 | "License" shall mean the terms and conditions for use, reproduction,
24 | and distribution as defined by Sections 1 through 9 of this document.
25 |
26 | "Licensor" shall mean the copyright owner or entity authorized by
27 | the copyright owner that is granting the License.
28 |
29 | "Legal Entity" shall mean the union of the acting entity and all
30 | other entities that control, are controlled by, or are under common
31 | control with that entity. For the purposes of this definition,
32 | "control" means (i) the power, direct or indirect, to cause the
33 | direction or management of such entity, whether by contract or
34 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
35 | outstanding shares, or (iii) beneficial ownership of such entity.
36 |
37 | "You" (or "Your") shall mean an individual or Legal Entity
38 | exercising permissions granted by this License.
39 |
40 | "Source" form shall mean the preferred form for making modifications,
41 | including but not limited to software source code, documentation
42 | source, and configuration files.
43 |
44 | "Object" form shall mean any form resulting from mechanical
45 | transformation or translation of a Source form, including but
46 | not limited to compiled object code, generated documentation,
47 | and conversions to other media types.
48 |
49 | "Work" shall mean the work of authorship, whether in Source or
50 | Object form, made available under the License, as indicated by a
51 | copyright notice that is included in or attached to the work
52 | (an example is provided in the Appendix below).
53 |
54 | "Derivative Works" shall mean any work, whether in Source or Object
55 | form, that is based on (or derived from) the Work and for which the
56 | editorial revisions, annotations, elaborations, or other
57 | modifications
58 | represent, as a whole, an original work of authorship. For the
59 | purposes
60 | of this License, Derivative Works shall not include works that remain
61 | separable from, or merely link (or bind by name) to the interfaces
62 | of,
63 | the Work and Derivative Works thereof.
64 |
65 | "Contribution" shall mean any work of authorship, including
66 | the original version of the Work and any modifications or additions
67 | to that Work or Derivative Works thereof, that is intentionally
68 | submitted to Licensor for inclusion in the Work by the copyright
69 | owner
70 | or by an individual or Legal Entity authorized to submit on behalf of
71 | the copyright owner. For the purposes of this definition, "submitted"
72 | means any form of electronic, verbal, or written communication sent
73 | to the Licensor or its representatives, including but not limited to
74 | communication on electronic mailing lists, source code control
75 | systems,
76 | and issue tracking systems that are managed by, or on behalf of, the
77 | Licensor for the purpose of discussing and improving the Work, but
78 | excluding communication that is conspicuously marked or otherwise
79 | designated in writing by the copyright owner as "Not a Contribution."
80 |
81 | "Contributor" shall mean Licensor and any individual or Legal Entity
82 | on behalf of whom a Contribution has been received by Licensor and
83 | subsequently incorporated within the Work.
84 |
85 | 2. Grant of Copyright License. Subject to the terms and conditions of
86 | this License, each Contributor hereby grants to You a perpetual,
87 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
88 | copyright license to reproduce, prepare Derivative Works of,
89 | publicly display, publicly perform, sublicense, and distribute the
90 | Work and such Derivative Works in Source or Object form.
91 |
92 | 3. Grant of Patent License. Subject to the terms and conditions of
93 | this License, each Contributor hereby grants to You a perpetual,
94 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
95 | (except as stated in this section) patent license to make, have made,
96 | use, offer to sell, sell, import, and otherwise transfer the Work,
97 | where such license applies only to those patent claims licensable
98 | by such Contributor that are necessarily infringed by their
99 | Contribution(s) alone or by combination of their Contribution(s)
100 | with the Work to which such Contribution(s) was submitted. If You
101 | institute patent litigation against any entity (including a
102 | cross-claim or counterclaim in a lawsuit) alleging that the Work
103 | or a Contribution incorporated within the Work constitutes direct
104 | or contributory patent infringement, then any patent licenses
105 | granted to You under this License for that Work shall terminate
106 | as of the date such litigation is filed.
107 |
108 | 4. Redistribution. You may reproduce and distribute copies of the
109 | Work or Derivative Works thereof in any medium, with or without
110 | modifications, and in Source or Object form, provided that You
111 | meet the following conditions:
112 |
113 | (a) You must give any other recipients of the Work or
114 | Derivative Works a copy of this License; and
115 |
116 | (b) You must cause any modified files to carry prominent notices
117 | stating that You changed the files; and
118 |
119 | (c) You must retain, in the Source form of any Derivative Works
120 | that You distribute, all copyright, patent, trademark, and
121 | attribution notices from the Source form of the Work,
122 | excluding those notices that do not pertain to any part of
123 | the Derivative Works; and
124 |
125 | (d) If the Work includes a "NOTICE" text file as part of its
126 | distribution, then any Derivative Works that You distribute must
127 | include a readable copy of the attribution notices contained
128 | within such NOTICE file, excluding those notices that do not
129 | pertain to any part of the Derivative Works, in at least one
130 | of the following places: within a NOTICE text file distributed
131 | as part of the Derivative Works; within the Source form or
132 | documentation, if provided along with the Derivative Works; or,
133 | within a display generated by the Derivative Works, if and
134 | wherever such third-party notices normally appear. The contents
135 | of the NOTICE file are for informational purposes only and
136 | do not modify the License. You may add Your own attribution
137 | notices within Derivative Works that You distribute, alongside
138 | or as an addendum to the NOTICE text from the Work, provided
139 | that such additional attribution notices cannot be construed
140 | as modifying the License.
141 |
142 | You may add Your own copyright statement to Your modifications and
143 | may provide additional or different license terms and conditions
144 | for use, reproduction, or distribution of Your modifications, or
145 | for any such Derivative Works as a whole, provided Your use,
146 | reproduction, and distribution of the Work otherwise complies with
147 | the conditions stated in this License.
148 |
149 | 5. Submission of Contributions. Unless You explicitly state otherwise,
150 | any Contribution intentionally submitted for inclusion in the Work
151 | by You to the Licensor shall be under the terms and conditions of
152 | this License, without any additional terms or conditions.
153 | Notwithstanding the above, nothing herein shall supersede or modify
154 | the terms of any separate license agreement you may have executed
155 | with Licensor regarding such Contributions.
156 |
157 | 6. Trademarks. This License does not grant permission to use the trade
158 | names, trademarks, service marks, or product names of the Licensor,
159 | except as required for reasonable and customary use in describing the
160 | origin of the Work and reproducing the content of the NOTICE file.
161 |
162 | 7. Disclaimer of Warranty. Unless required by applicable law or
163 | agreed to in writing, Licensor provides the Work (and each
164 | Contributor provides its Contributions) on an "AS IS" BASIS,
165 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
166 | implied, including, without limitation, any warranties or conditions
167 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
168 | PARTICULAR PURPOSE. You are solely responsible for determining the
169 | appropriateness of using or redistributing the Work and assume any
170 | risks associated with Your exercise of permissions under this
171 | License.
172 |
173 | 8. Limitation of Liability. In no event and under no legal theory,
174 | whether in tort (including negligence), contract, or otherwise,
175 | unless required by applicable law (such as deliberate and grossly
176 | negligent acts) or agreed to in writing, shall any Contributor be
177 | liable to You for damages, including any direct, indirect, special,
178 | incidental, or consequential damages of any character arising as a
179 | result of this License or out of the use or inability to use the
180 | Work (including but not limited to damages for loss of goodwill,
181 | work stoppage, computer failure or malfunction, or any and all
182 | other commercial damages or losses), even if such Contributor
183 | has been advised of the possibility of such damages.
184 |
185 | 9. Accepting Warranty or Additional Liability. While redistributing
186 | the Work or Derivative Works thereof, You may choose to offer,
187 | and charge a fee for, acceptance of support, warranty, indemnity,
188 | or other liability obligations and/or rights consistent with this
189 | License. However, in accepting such obligations, You may act only
190 | on Your own behalf and on Your sole responsibility, not on behalf
191 | of any other Contributor, and only if You agree to indemnify,
192 | defend, and hold each Contributor harmless for any liability
193 | incurred by, or claims asserted against, such Contributor by reason
194 | of your accepting any such warranty or additional liability.
195 |
196 | END OF TERMS AND CONDITIONS
197 |
198 | APPENDIX: How to apply the Apache License to your work.
199 |
200 | To apply the Apache License to your work, attach the following
201 | boilerplate notice, with the fields enclosed by brackets "[]"
202 | replaced with your own identifying information. (Don't include
203 | the brackets!) The text should be enclosed in the appropriate
204 | comment syntax for the file format. We also recommend that a
205 | file or class name and description of purpose be included on the
206 | same "printed page" as the copyright notice for easier
207 | identification within third-party archives.
208 |
209 | Copyright [yyyy] [name of copyright owner]
210 |
211 | Licensed under the Apache License, Version 2.0 (the "License");
212 | you may not use this file except in compliance with the License.
213 | You may obtain a copy of the License at
214 |
215 | http://www.apache.org/licenses/LICENSE-2.0
216 |
217 | Unless required by applicable law or agreed to in writing, software
218 | distributed under the License is distributed on an "AS IS" BASIS,
219 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
220 | See the License for the specific language governing permissions and
221 | limitations under the License.
222 |
--------------------------------------------------------------------------------
/NOTICE:
--------------------------------------------------------------------------------
1 | The CSS Shapes Editor library
2 | Copyright 2014 Adobe Systems Incorporated
3 |
4 | This software is licensed under the Apache License, Version 2.0 (see LICENSE file).
5 |
6 | It uses the following third party libraries that may have licenses differing from that of CSS Shapes Editor itself.
7 |
8 | Third Party Software Notices:
9 | =============================
10 |
11 | almond (https://github.com/jrburke/almond)
12 | almond is released under two licenses: new BSD, and MIT. You may pick the
13 | license that best suits your development needs. The text of both licenses are
14 | provided below.
15 |
16 | The "New" BSD License:
17 | ----------------------
18 |
19 | Copyright (c) 2010-2011, The Dojo Foundation
20 | All rights reserved.
21 |
22 | Redistribution and use in source and binary forms, with or without
23 | modification, are permitted provided that the following conditions are met:
24 |
25 | * Redistributions of source code must retain the above copyright notice, this
26 | list of conditions and the following disclaimer.
27 | * Redistributions in binary form must reproduce the above copyright notice,
28 | this list of conditions and the following disclaimer in the documentation
29 | and/or other materials provided with the distribution.
30 | * Neither the name of the Dojo Foundation nor the names of its contributors
31 | may be used to endorse or promote products derived from this software
32 | without specific prior written permission.
33 |
34 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
35 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
36 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
37 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
38 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
39 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
40 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
41 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
42 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
43 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
44 |
45 |
46 |
47 | MIT License
48 | -----------
49 |
50 | Copyright (c) 2010-2014, The Dojo Foundation
51 |
52 | Permission is hereby granted, free of charge, to any person obtaining a copy
53 | of this software and associated documentation files (the "Software"), to deal
54 | in the Software without restriction, including without limitation the rights
55 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
56 | copies of the Software, and to permit persons to whom the Software is
57 | furnished to do so, subject to the following conditions:
58 |
59 | The above copyright notice and this permission notice shall be included in
60 | all copies or substantial portions of the Software.
61 |
62 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
63 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
64 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
65 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
66 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
67 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
68 | THE SOFTWARE.
69 |
70 | RequireJS (http://requirejs.org/)
71 | RequireJS is released under two licenses: new BSD, and MIT. You may pick the
72 | license that best suits your development needs. The text of both licenses are
73 | provided below.
74 |
75 | The "New" BSD License:
76 | ----------------------
77 |
78 | Copyright (c) 2010-2014, The Dojo Foundation
79 | All rights reserved.
80 |
81 | Redistribution and use in source and binary forms, with or without
82 | modification, are permitted provided that the following conditions are met:
83 |
84 | * Redistributions of source code must retain the above copyright notice, this
85 | list of conditions and the following disclaimer.
86 | * Redistributions in binary form must reproduce the above copyright notice,
87 | this list of conditions and the following disclaimer in the documentation
88 | and/or other materials provided with the distribution.
89 | * Neither the name of the Dojo Foundation nor the names of its contributors
90 | may be used to endorse or promote products derived from this software
91 | without specific prior written permission.
92 |
93 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
94 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
95 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
96 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
97 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
98 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
99 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
100 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
101 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
102 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
103 |
104 |
105 |
106 | MIT License
107 | -----------
108 |
109 | Copyright (c) 2010-2014, The Dojo Foundation
110 |
111 | Permission is hereby granted, free of charge, to any person obtaining a copy
112 | of this software and associated documentation files (the "Software"), to deal
113 | in the Software without restriction, including without limitation the rights
114 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
115 | copies of the Software, and to permit persons to whom the Software is
116 | furnished to do so, subject to the following conditions:
117 |
118 | The above copyright notice and this permission notice shall be included in
119 | all copies or substantial portions of the Software.
120 |
121 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
122 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
123 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
124 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
125 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
126 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
127 | THE SOFTWARE.
128 |
129 |
130 | MIT License
131 | -----------
132 |
133 | Copyright (c) 2010-2011, The Dojo Foundation
134 |
135 | Permission is hereby granted, free of charge, to any person obtaining a copy
136 | of this software and associated documentation files (the "Software"), to deal
137 | in the Software without restriction, including without limitation the rights
138 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
139 | copies of the Software, and to permit persons to whom the Software is
140 | furnished to do so, subject to the following conditions:
141 |
142 | The above copyright notice and this permission notice shall be included in
143 | all copies or substantial portions of the Software.
144 |
145 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
146 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
147 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
148 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
149 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
150 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
151 | THE SOFTWARE.
152 |
153 | lodash (https://github.com/lodash/lodash/)
154 | Copyright 2012-2013 The Dojo Foundation
155 | Based on Underscore.js 1.5.2, copyright 2009-2013 Jeremy Ashkenas,
156 | DocumentCloud and Investigative Reporters & Editors
157 |
158 | Permission is hereby granted, free of charge, to any person obtaining
159 | a copy of this software and associated documentation files (the
160 | "Software"), to deal in the Software without restriction, including
161 | without limitation the rights to use, copy, modify, merge, publish,
162 | distribute, sublicense, and/or sell copies of the Software, and to
163 | permit persons to whom the Software is furnished to do so, subject to
164 | the following conditions:
165 |
166 | The above copyright notice and this permission notice shall be
167 | included in all copies or substantial portions of the Software.
168 |
169 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
170 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
171 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
172 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
173 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
174 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
175 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
176 |
177 | jasmine (https://github.com/pivotal/jasmine)
178 | Copyright (c) 2008-2014 Pivotal Labs.
179 | This software is licensed under the MIT License.
180 |
181 | Permission is hereby granted, free of charge, to any person obtaining a copy
182 | of this software and associated documentation files (the "Software"), to deal
183 | in the Software without restriction, including without limitation the rights
184 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
185 | copies of the Software, and to permit persons to whom the Software is
186 | furnished to do so, subject to the following conditions:
187 |
188 | The above copyright notice and this permission notice shall be included in
189 | all copies or substantial portions of the Software.
190 |
191 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
192 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
193 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
194 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
195 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
196 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
197 | THE SOFTWARE.
198 |
199 | jQuery (https://jquery.org)
200 | (c) 2005, 2013 jQuery Foundation, Inc. | jquery.org/license
201 |
202 | Permission is hereby granted, free of charge, to any person obtaining
203 | a copy of this software and associated documentation files (the
204 | "Software"), to deal in the Software without restriction, including
205 | without limitation the rights to use, copy, modify, merge, publish,
206 | distribute, sublicense, and/or sell copies of the Software, and to
207 | permit persons to whom the Software is furnished to do so, subject to
208 | the following conditions:
209 |
210 | The above copyright notice and this permission notice shall be
211 | included in all copies or substantial portions of the Software.
212 |
213 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
214 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
215 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
216 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
217 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
218 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
219 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
220 |
221 | Snap.FreeTransform, adapted from Raphaël.FreeTransform (https://github.com/ElbertF/Raphael.FreeTransform)
222 | Copyright (c), Elbert Alias
223 | Permission is hereby granted, free of charge, to any person obtaining a copy
224 | of this software and associated documentation files (the "Software"), to deal
225 | in the Software without restriction, including without limitation the rights
226 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
227 | copies of the Software, and to permit persons to whom the Software is
228 | furnished to do so, subject to the following conditions:
229 |
230 | The above copyright notice and this permission notice shall be included in
231 | all copies or substantial portions of the Software.
232 |
233 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
234 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
235 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
236 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
237 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
238 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
239 | THE SOFTWARE.
240 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # CSS Shapes Editor
2 |
3 | JavaScript library for interactive editing of CSS Shapes values right in the browser. It works with functional values like `polygon()`, `circle()` and `ellipse()`.
4 |
5 | ## Demo
6 |
7 | See the `demo/` folder for examples.
8 |
9 | ## Basic usage
10 |
11 | Load `dist/CSSShapesEditor.js` into the page:
12 |
13 | ```js
14 |
15 | ```
16 |
17 | Setup the editor to edit a CSS shape value of an element. An interactive editor for the shape is drawn on top of the element.
18 |
19 | ```js
20 | var element = document.querySelector('#element');
21 | var shape = window.getComputedStyle(element)['shape-outside'];
22 | var editor = CSSShapesEditor(element, shape);
23 |
24 | editor.on('shapechange', function(){
25 | // update the CSS shape value on the element
26 | element.style['shape-outside'] = editor.getCSSValue();
27 | })
28 | ```
29 |
30 |
31 | Supported shape values:
32 |
33 | - `polygon()`
34 | - `circle()`
35 | - `ellipse()`
36 |
37 | Create a new shape from scratch by passing a shape declaration with no coordinates.
38 |
39 | ```js
40 | var editor = CSSShapesEditor(element, 'polygon()');
41 | ```
42 |
43 | ## Events
44 |
45 | The `"ready"` event is dispatched after the editor was initialized
46 |
47 | ```js
48 | editor.on('ready', function(){
49 | // editor is ready to work with
50 | })
51 | ```
52 |
53 | The `"shapechange"` event is dispatched after the shape was changed in the editor
54 |
55 | ```js
56 | editor.on('shapechange', function(){
57 | // update the CSS shape value on the element
58 | element.style['shape-outside'] = editor.getCSSValue();
59 | })
60 | ```
61 |
62 | The `"removed"` event is dispatched after the editor has been turned off and removed by using `editor.remove()`.
63 |
64 | ```js
65 | editor.on('removed', function(){
66 | // editor is gone; do other clean-up
67 | })
68 | ```
69 |
70 | ## API
71 |
72 | Get the CSS shape value as a string to use in a stylesheet:
73 |
74 | ```js
75 | editor.getCSSValue()
76 | ```
77 |
78 | Get the CSS shape value as a string with coordinates converted to a specific unit type:
79 |
80 | ```js
81 | editor.getCSSValue('%')
82 | // supported values: ["px", "in", "cm", "mm", "pt", "pc", "em", "rem", "vw", "vh", "%"]
83 |
84 | ```
85 |
86 | Programmatically update the shape editor with a new shape value:
87 |
88 | ```js
89 | editor.update("circle(50% at center)")
90 | ```
91 |
92 | Toggle the free-transform editor (scale, move, rotate) for the shape:
93 |
94 | ```js
95 | editor.toggleFreeTransform();
96 | ```
97 |
98 | Turn off editor and remove if from the page. **Unsaved changes will be lost.**
99 |
100 | ```js
101 | editor.remove()
102 | ```
103 |
104 | ## Contributing
105 |
106 | Your system needs:
107 |
108 | - [Node.JS](http://nodejs.org/)
109 | - [Grunt](http://gruntjs.com/)
110 |
111 | ### Setup dev environment
112 |
113 | Install dependencies:
114 |
115 | $ npm install
116 |
117 | ### Build
118 |
119 | Edit source in the `src/` directory. Build with Grunt:
120 |
121 | $ grunt build
122 |
123 | Build output goes into `dist/`. Do not edit source in `dist/`, it gets replaced automatically by the Grunt build process.
124 |
125 | ### Test
126 |
127 | Add tests to `test/spec/`. Run tests with [Testem](https://github.com/airportyh/testem):
128 |
129 | $ testem
130 |
131 | Testem uses the configuration found in `testem.json`
132 |
133 | ## License
134 |
135 | Apache 2.0. See [LICENSE.md](./LICENSE.md)
136 |
137 | ## Thanks
138 |
139 | The work of many people has contributed, both directly and indirectly, to building the CSS Shapes Editor library:
140 |
141 | - [Razvan Caliman](https://github.com/oslego)
142 | - [Bear Travis](https://github.com/betravis)
143 | - [François Remy](https://github.com/FremyCompany)
144 | - [Laurence Mclister](https://github.com/lmclister)
145 | - [Hans Muller](https://github.com/hansmuller)
146 | - [Lawrence Hsu](https://github.com/larz0)
147 | - [Dmitry Baranovskiy](https://github.com/DmitryBaranovskiy) for creating [Snap.svg](http://snapsvg.io/)
148 | - [Elbert Alias](https://github.com/elbertf) for creating [Raphael.FreeTransform ](https://github.com/ElbertF/Raphael.FreeTransform)
149 |
150 | and many, many others. Thank you!
151 |
--------------------------------------------------------------------------------
/demo/circle-outside.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
31 | This browser does not appear to support CSS Shapes. Find out how to get one which does.
32 |
33 |
34 |
35 |
36 |
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
37 |
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
31 | This browser does not appear to support CSS Shapes. Find out how to get one which does.
32 |
33 |
34 |
35 |
36 |
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
37 |
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
31 | This browser does not appear to support CSS Shapes. Find out how to get one which does.
32 |
33 |
34 |
35 |
36 |
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
37 |
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
34 | This browser does not appear to support CSS Shapes. Find out how to get one which does.
35 |
36 |
37 |
38 |
39 |
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
40 |
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
41 |
42 |
43 |
44 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/demo/style.css:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2014 Adobe Systems Incorporated. All rights reserved.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | .support-warning{
17 | padding: 1em;
18 | background: #fc5;
19 | color: #444;
20 | }
21 | @supports (shape-outside: circle(50% at 50% 50%)){
22 | .support-warning {
23 | display: none;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "css-shapes-editor",
3 | "main": "./dist/CSSShapesEditor.js",
4 | "description": "Editor for CSS Shapes in the browser.",
5 | "version": "0.10.0",
6 | "author": "Adobe Systems Inc.",
7 | "contributors": [
8 | "Razvan Caliman ",
9 | "François REMY ",
10 | "Bear Travis "
11 | ],
12 | "dependencies": {},
13 | "devDependencies": {
14 | "grunt": "~0.4.1",
15 | "grunt-bump": "0.0.13",
16 | "grunt-contrib-jshint": "~0.6.3",
17 | "grunt-contrib-requirejs": "~0.4.1",
18 | "grunt-contrib-watch": "~0.5.2",
19 | "grunt-contrib-uglify": "^0.5.1",
20 | "grunt-contrib-concat": "^0.5.0",
21 | "grunt-contrib-testem": "^0.5.16",
22 | "testem": "^0.6.15",
23 | "load-grunt-tasks": "~0.2.1"
24 | },
25 | "engines": {
26 | "node": ">=0.8.0"
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/CSSShapesEditor.js:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2014 Adobe Systems Incorporated. All rights reserved.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | /*jslint vars: true, plusplus: true, devel: true, nomen: true, regexp: true, indent: 4, maxerr: 50 */
16 | /*global define */
17 |
18 | define(['PolygonEditor', 'CircleEditor', 'EllipseEditor', 'lodash'], function(PolygonEditor, CircleEditor, EllipseEditor, _){
19 |
20 | 'use strict';
21 |
22 | function CSSShapesEditor(target, value, options){
23 |
24 | var _defaults = {
25 | // multiple objects with attributes are used into separate