editable_components 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +64 -0
- data/Rakefile +34 -0
- data/app/assets/config/editable_components_manifest.js +2 -0
- data/app/assets/fonts/editable_components/icomoon.eot +0 -0
- data/app/assets/fonts/editable_components/icomoon.svg +24 -0
- data/app/assets/fonts/editable_components/icomoon.ttf +0 -0
- data/app/assets/fonts/editable_components/icomoon.woff +0 -0
- data/app/assets/javascripts/editable_components/application.js +13 -0
- data/app/assets/javascripts/editable_components/dragula/dragula.css +22 -0
- data/app/assets/javascripts/editable_components/dragula/dragula.js +908 -0
- data/app/assets/javascripts/editable_components/dragula/dragula.min.css +1 -0
- data/app/assets/javascripts/editable_components/dragula/dragula.min.js +1 -0
- data/app/assets/javascripts/editable_components/dropzone/CONTRIBUTING.md +78 -0
- data/app/assets/javascripts/editable_components/dropzone/LICENSE +12 -0
- data/app/assets/javascripts/editable_components/dropzone/README.md +134 -0
- data/app/assets/javascripts/editable_components/dropzone/basic.css +39 -0
- data/app/assets/javascripts/editable_components/dropzone/dropzone-amd-module.js +1782 -0
- data/app/assets/javascripts/editable_components/dropzone/dropzone.css +388 -0
- data/app/assets/javascripts/editable_components/dropzone/dropzone.js +1767 -0
- data/app/assets/javascripts/editable_components/dropzone/min/basic.min.css +1 -0
- data/app/assets/javascripts/editable_components/dropzone/min/dropzone-amd-module.min.js +2 -0
- data/app/assets/javascripts/editable_components/dropzone/min/dropzone.min.css +1 -0
- data/app/assets/javascripts/editable_components/dropzone/min/dropzone.min.js +2 -0
- data/app/assets/javascripts/editable_components/main.js +280 -0
- data/app/assets/javascripts/editable_components/medium-editor/API.md +520 -0
- data/app/assets/javascripts/editable_components/medium-editor/CHANGES.md +1043 -0
- data/app/assets/javascripts/editable_components/medium-editor/CODE_OF_CONDUCT.md +13 -0
- data/app/assets/javascripts/editable_components/medium-editor/CONTRIBUTING.md +56 -0
- data/app/assets/javascripts/editable_components/medium-editor/CUSTOM-EVENTS.md +223 -0
- data/app/assets/javascripts/editable_components/medium-editor/LICENSE +36 -0
- data/app/assets/javascripts/editable_components/medium-editor/MAINTAINERS.md +33 -0
- data/app/assets/javascripts/editable_components/medium-editor/OPTIONS.md +663 -0
- data/app/assets/javascripts/editable_components/medium-editor/README.md +725 -0
- data/app/assets/javascripts/editable_components/medium-editor/UPGRADE-5.md +146 -0
- data/app/assets/javascripts/editable_components/medium-editor/medium-editor.css +230 -0
- data/app/assets/javascripts/editable_components/medium-editor/medium-editor.js +7876 -0
- data/app/assets/javascripts/editable_components/medium-editor/medium-editor.min.css +1 -0
- data/app/assets/javascripts/editable_components/medium-editor/medium-editor.min.js +4 -0
- data/app/assets/javascripts/editable_components/medium-editor/themes/beagle.css +78 -0
- data/app/assets/javascripts/editable_components/medium-editor/themes/beagle.min.css +1 -0
- data/app/assets/javascripts/editable_components/medium-editor/themes/bootstrap.css +67 -0
- data/app/assets/javascripts/editable_components/medium-editor/themes/bootstrap.min.css +1 -0
- data/app/assets/javascripts/editable_components/medium-editor/themes/default.css +63 -0
- data/app/assets/javascripts/editable_components/medium-editor/themes/default.min.css +1 -0
- data/app/assets/javascripts/editable_components/medium-editor/themes/flat.css +58 -0
- data/app/assets/javascripts/editable_components/medium-editor/themes/flat.min.css +1 -0
- data/app/assets/javascripts/editable_components/medium-editor/themes/mani.css +57 -0
- data/app/assets/javascripts/editable_components/medium-editor/themes/mani.min.css +1 -0
- data/app/assets/javascripts/editable_components/medium-editor/themes/roman.css +58 -0
- data/app/assets/javascripts/editable_components/medium-editor/themes/roman.min.css +1 -0
- data/app/assets/javascripts/editable_components/medium-editor/themes/tim.css +67 -0
- data/app/assets/javascripts/editable_components/medium-editor/themes/tim.min.css +1 -0
- data/app/assets/javascripts/editable_components/sizzle/sizzle.js +2272 -0
- data/app/assets/javascripts/editable_components/sizzle/sizzle.min.js +3 -0
- data/app/assets/javascripts/editable_components/sizzle/sizzle.min.map +1 -0
- data/app/assets/javascripts/editable_components/vue/README.md +124 -0
- data/app/assets/javascripts/editable_components/vue/vue.common.js +9320 -0
- data/app/assets/javascripts/editable_components/vue/vue.common.min.js +7 -0
- data/app/assets/javascripts/editable_components/vue/vue.esm.js +9318 -0
- data/app/assets/javascripts/editable_components/vue/vue.js +9316 -0
- data/app/assets/javascripts/editable_components/vue/vue.min.js +8 -0
- data/app/assets/javascripts/editable_components/vue/vue.runtime.common.js +6831 -0
- data/app/assets/javascripts/editable_components/vue/vue.runtime.esm.js +6829 -0
- data/app/assets/javascripts/editable_components/vue/vue.runtime.js +6827 -0
- data/app/assets/javascripts/editable_components/vue/vue.runtime.min.js +7 -0
- data/app/assets/stylesheets/editable_components/application.sass +65 -0
- data/app/assets/stylesheets/editable_components/blaze/blaze.colors.min.css +1 -0
- data/app/assets/stylesheets/editable_components/blaze/blaze.min.css +1 -0
- data/app/assets/stylesheets/editable_components/blaze/components.addresses.min.css +1 -0
- data/app/assets/stylesheets/editable_components/blaze/components.alerts.min.css +1 -0
- data/app/assets/stylesheets/editable_components/blaze/components.avatars.min.css +1 -0
- data/app/assets/stylesheets/editable_components/blaze/components.badges.min.css +1 -0
- data/app/assets/stylesheets/editable_components/blaze/components.breadcrumbs.min.css +1 -0
- data/app/assets/stylesheets/editable_components/blaze/components.bubbles.min.css +1 -0
- data/app/assets/stylesheets/editable_components/blaze/components.buttons.min.css +1 -0
- data/app/assets/stylesheets/editable_components/blaze/components.calendars.min.css +1 -0
- data/app/assets/stylesheets/editable_components/blaze/components.cards.min.css +1 -0
- data/app/assets/stylesheets/editable_components/blaze/components.headings.min.css +1 -0
- data/app/assets/stylesheets/editable_components/blaze/components.hints.min.css +1 -0
- data/app/assets/stylesheets/editable_components/blaze/components.input-groups.min.css +1 -0
- data/app/assets/stylesheets/editable_components/blaze/components.inputs.min.css +1 -0
- data/app/assets/stylesheets/editable_components/blaze/components.links.min.css +1 -0
- data/app/assets/stylesheets/editable_components/blaze/components.lists.min.css +1 -0
- data/app/assets/stylesheets/editable_components/blaze/components.navs.min.css +1 -0
- data/app/assets/stylesheets/editable_components/blaze/components.overlays.min.css +1 -0
- data/app/assets/stylesheets/editable_components/blaze/components.pagination.min.css +1 -0
- data/app/assets/stylesheets/editable_components/blaze/components.progress.min.css +1 -0
- data/app/assets/stylesheets/editable_components/blaze/components.ranges.min.css +1 -0
- data/app/assets/stylesheets/editable_components/blaze/components.tables.min.css +1 -0
- data/app/assets/stylesheets/editable_components/blaze/components.tabs.min.css +1 -0
- data/app/assets/stylesheets/editable_components/blaze/components.tags.min.css +1 -0
- data/app/assets/stylesheets/editable_components/blaze/components.toggles.min.css +1 -0
- data/app/assets/stylesheets/editable_components/blaze/components.tooltips.min.css +1 -0
- data/app/assets/stylesheets/editable_components/blaze/components.trees.min.css +1 -0
- data/app/assets/stylesheets/editable_components/blaze/components.typography.min.css +1 -0
- data/app/assets/stylesheets/editable_components/blaze/generics.global.min.css +1 -0
- data/app/assets/stylesheets/editable_components/blaze/objects.containers.min.css +1 -0
- data/app/assets/stylesheets/editable_components/blaze/objects.drawers.min.css +1 -0
- data/app/assets/stylesheets/editable_components/blaze/objects.forms.min.css +1 -0
- data/app/assets/stylesheets/editable_components/blaze/objects.grid.min.css +1 -0
- data/app/assets/stylesheets/editable_components/blaze/objects.grid.responsive.min.css +1 -0
- data/app/assets/stylesheets/editable_components/blaze/objects.images.min.css +1 -0
- data/app/assets/stylesheets/editable_components/blaze/objects.media.min.css +1 -0
- data/app/assets/stylesheets/editable_components/blaze/objects.modals.min.css +1 -0
- data/app/assets/stylesheets/editable_components/blaze/objects.panels.min.css +1 -0
- data/app/assets/stylesheets/editable_components/blaze/themes/blaze.example.min.css +1 -0
- data/app/assets/stylesheets/editable_components/blaze/utilities.alignment.min.css +1 -0
- data/app/assets/stylesheets/editable_components/blaze/utilities.boxing.min.css +1 -0
- data/app/assets/stylesheets/editable_components/blaze/utilities.elevation.min.css +1 -0
- data/app/assets/stylesheets/editable_components/blaze/utilities.sizes.min.css +1 -0
- data/app/assets/stylesheets/editable_components/dragula/dragula.css +22 -0
- data/app/assets/stylesheets/editable_components/dragula/dragula.js +908 -0
- data/app/assets/stylesheets/editable_components/dragula/dragula.min.css +1 -0
- data/app/assets/stylesheets/editable_components/dragula/dragula.min.js +1 -0
- data/app/assets/stylesheets/editable_components/main.sass +225 -0
- data/app/assets/stylesheets/editable_components/medium-editor/API.md +520 -0
- data/app/assets/stylesheets/editable_components/medium-editor/CHANGES.md +1043 -0
- data/app/assets/stylesheets/editable_components/medium-editor/CODE_OF_CONDUCT.md +13 -0
- data/app/assets/stylesheets/editable_components/medium-editor/CONTRIBUTING.md +56 -0
- data/app/assets/stylesheets/editable_components/medium-editor/CUSTOM-EVENTS.md +223 -0
- data/app/assets/stylesheets/editable_components/medium-editor/LICENSE +36 -0
- data/app/assets/stylesheets/editable_components/medium-editor/MAINTAINERS.md +33 -0
- data/app/assets/stylesheets/editable_components/medium-editor/OPTIONS.md +663 -0
- data/app/assets/stylesheets/editable_components/medium-editor/README.md +725 -0
- data/app/assets/stylesheets/editable_components/medium-editor/UPGRADE-5.md +146 -0
- data/app/assets/stylesheets/editable_components/medium-editor/medium-editor.css +230 -0
- data/app/assets/stylesheets/editable_components/medium-editor/medium-editor.js +7876 -0
- data/app/assets/stylesheets/editable_components/medium-editor/medium-editor.min.css +1 -0
- data/app/assets/stylesheets/editable_components/medium-editor/medium-editor.min.js +4 -0
- data/app/assets/stylesheets/editable_components/medium-editor/themes/beagle.css +78 -0
- data/app/assets/stylesheets/editable_components/medium-editor/themes/beagle.min.css +1 -0
- data/app/assets/stylesheets/editable_components/medium-editor/themes/bootstrap.css +67 -0
- data/app/assets/stylesheets/editable_components/medium-editor/themes/bootstrap.min.css +1 -0
- data/app/assets/stylesheets/editable_components/medium-editor/themes/default.css +63 -0
- data/app/assets/stylesheets/editable_components/medium-editor/themes/default.min.css +1 -0
- data/app/assets/stylesheets/editable_components/medium-editor/themes/flat.css +58 -0
- data/app/assets/stylesheets/editable_components/medium-editor/themes/flat.min.css +1 -0
- data/app/assets/stylesheets/editable_components/medium-editor/themes/mani.css +57 -0
- data/app/assets/stylesheets/editable_components/medium-editor/themes/mani.min.css +1 -0
- data/app/assets/stylesheets/editable_components/medium-editor/themes/roman.css +58 -0
- data/app/assets/stylesheets/editable_components/medium-editor/themes/roman.min.css +1 -0
- data/app/assets/stylesheets/editable_components/medium-editor/themes/tim.css +67 -0
- data/app/assets/stylesheets/editable_components/medium-editor/themes/tim.min.css +1 -0
- data/app/controllers/editable_components/blocks_controller.rb +36 -0
- data/app/helpers/editable_components/application_helper.rb +4 -0
- data/app/jobs/editable_components/application_job.rb +4 -0
- data/app/mailers/editable_components/application_mailer.rb +6 -0
- data/app/models/editable_components/application_record.rb +5 -0
- data/app/models/editable_components/block.rb +176 -0
- data/app/models/editable_components/concerns/editable.rb +34 -0
- data/app/models/editable_components/item.rb +50 -0
- data/app/models/editable_components/item_boolean.rb +23 -0
- data/app/models/editable_components/item_datetime.rb +14 -0
- data/app/models/editable_components/item_file.rb +46 -0
- data/app/models/editable_components/item_float.rb +23 -0
- data/app/models/editable_components/item_hash.rb +16 -0
- data/app/models/editable_components/item_integer.rb +23 -0
- data/app/models/editable_components/item_string.rb +29 -0
- data/app/models/editable_components/item_text.rb +19 -0
- data/app/views/editable_components/_admin_toolbar.html.erb +105 -0
- data/app/views/editable_components/_block.html.erb +6 -0
- data/app/views/editable_components/_block_image.html.erb +6 -0
- data/app/views/editable_components/_block_multi_text.html.erb +7 -0
- data/app/views/editable_components/_block_slide.html.erb +6 -0
- data/app/views/editable_components/_block_slider.html.erb +7 -0
- data/app/views/editable_components/_block_text.html.erb +5 -0
- data/app/views/editable_components/_block_text_with_image.html.erb +12 -0
- data/app/views/editable_components/_blocks.html.erb +12 -0
- data/config/initializers/editable_components.rb +72 -0
- data/config/routes.rb +4 -0
- data/db/migrate/20170414173603_create_editable_components_blocks.rb +18 -0
- data/db/migrate/20170414173610_create_editable_components_items.rb +11 -0
- data/db/migrate/20170414173611_add_items_booleans.rb +5 -0
- data/db/migrate/20170414173612_add_items_datetimes.rb +5 -0
- data/db/migrate/20170414173613_add_items_files.rb +5 -0
- data/db/migrate/20170414173614_add_items_floats.rb +5 -0
- data/db/migrate/20170414173615_add_items_hashes.rb +5 -0
- data/db/migrate/20170414173616_add_items_integers.rb +5 -0
- data/db/migrate/20170414173617_add_items_strings.rb +5 -0
- data/db/migrate/20170414173618_add_items_texts.rb +5 -0
- data/lib/data/img1.jpg +0 -0
- data/lib/editable_components.rb +87 -0
- data/lib/editable_components/engine.rb +21 -0
- data/lib/editable_components/version.rb +3 -0
- data/lib/tasks/editable_components_tasks.rake +4 -0
- metadata +264 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ea50542043e609312e77f3da4c7d1fef363b3d3b
|
4
|
+
data.tar.gz: a6daa7a6b46dc31b510fb5c1eaa0887d876b5091
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 37ba95df0bd821832b80a655f112b2f925062c4042c8007ec7592f91349370d5e974485c79ffc4f32b9790b254655583d8dc9868e2e0e9a6c8de8f36d427fb67
|
7
|
+
data.tar.gz: 21ec42dd7e39b3e9aac0ad933b38c07d110a1d4562e22738dd2215a35187c2bc3d91ea8ed23773251978047428cc5c280025207641013a39afa6df504b0443b0
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2017
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
# EditableComponents for Rails
|
2
|
+
|
3
|
+
A Ruby on Rails plugin to manage UI components editable from the front-end.
|
4
|
+
|
5
|
+
_NOTE_: this is an **ALPHA** version, major changes could happens.
|
6
|
+
|
7
|
+
Goals:
|
8
|
+
|
9
|
+
- attach the necessary data to a model transparently
|
10
|
+
|
11
|
+
- edit the UI contents directly from the pages
|
12
|
+
|
13
|
+
- simplify the components development in views
|
14
|
+
|
15
|
+
![preview](preview.png)
|
16
|
+
|
17
|
+
### Instructions
|
18
|
+
|
19
|
+
1. Add to the Gemfile: `gem 'editable_components'`
|
20
|
+
|
21
|
+
2. Copy migrations (Rails 5.x syntax, in Rails 4.x use rake): `rails editable_components:install:migrations`
|
22
|
+
|
23
|
+
3. Apply them: `rake db:migrate`
|
24
|
+
|
25
|
+
4. Include the concern *Editable* to your model: `include EditableComponents::Concerns::Editable`
|
26
|
+
|
27
|
+
5. Add to your application layout (in head, ex. using ERB): `<%= stylesheet_link_tag( EditableComponents::Engine.css ) if EditableComponents::Engine.css %>`
|
28
|
+
|
29
|
+
6. Add to your application layout (before body closing): `<%= javascript_include_tag( EditableComponents::Engine.js ) if EditableComponents::Engine.js %>`
|
30
|
+
|
31
|
+
7. Add your blocks to the views (ex. in show):
|
32
|
+
```erb
|
33
|
+
<%= render layout: 'editable_components/blocks', locals: { container: @page } do |blocks| %>
|
34
|
+
<% blocks.each do |block| %>
|
35
|
+
<%= render partial: "editable_components/block", locals: { block: block } %>
|
36
|
+
<% end %>
|
37
|
+
<% end %>
|
38
|
+
```
|
39
|
+
|
40
|
+
8. Add some sample data (ex. Page model): `Page.first.create_block :text`
|
41
|
+
|
42
|
+
##### Images
|
43
|
+
|
44
|
+
To add support for images add CarrierWave gem to your Gemfile and execute: `rails generate uploader File`
|
45
|
+
|
46
|
+
### Notes
|
47
|
+
|
48
|
+
- This is not a complete replacement for an admin interface but it could improve the usability of a CMS software or content editor
|
49
|
+
|
50
|
+
### Dev Notes
|
51
|
+
|
52
|
+
##### Structure
|
53
|
+
|
54
|
+
- Including the Editable concern to a model will add `has_many :ec_blocks` relationship (the list of blocks attached to a container) and some utility methods
|
55
|
+
|
56
|
+
- Block: an editable UI component (ex. a text with a title, a slider, a 3 column text widgets, etc.); built with a list of sub blocks (for nested components) and a list of items
|
57
|
+
|
58
|
+
- Item: a single piece of information (ex. a string, a text, a boolean, an integer, a file, etc.)
|
59
|
+
|
60
|
+
- The live editing interface uses VueJS
|
61
|
+
|
62
|
+
## Contributors
|
63
|
+
|
64
|
+
- [Mattia Roccoberton](http://blocknot.es) - creator, maintainer
|
data/Rakefile
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'EditableComponents'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.md')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
load 'rails/tasks/statistics.rake'
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
require 'bundler/gem_tasks'
|
24
|
+
|
25
|
+
require 'rake/testtask'
|
26
|
+
|
27
|
+
Rake::TestTask.new(:test) do |t|
|
28
|
+
t.libs << 'test'
|
29
|
+
t.pattern = 'test/**/*_test.rb'
|
30
|
+
t.verbose = false
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
task default: :test
|
Binary file
|
@@ -0,0 +1,24 @@
|
|
1
|
+
<?xml version="1.0" standalone="no"?>
|
2
|
+
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
|
3
|
+
<svg xmlns="http://www.w3.org/2000/svg">
|
4
|
+
<metadata>Generated by IcoMoon</metadata>
|
5
|
+
<defs>
|
6
|
+
<font id="icomoon" horiz-adv-x="1024">
|
7
|
+
<font-face units-per-em="1024" ascent="960" descent="-64" />
|
8
|
+
<missing-glyph horiz-adv-x="1024" />
|
9
|
+
<glyph unicode=" " horiz-adv-x="512" d="" />
|
10
|
+
<glyph unicode="" glyph-name="pencil" d="M864 960c88.364 0 160-71.634 160-160 0-36.020-11.91-69.258-32-96l-64-64-224 224 64 64c26.742 20.090 59.978 32 96 32zM64 224l-64-288 288 64 592 592-224 224-592-592zM715.578 596.422l-448-448-55.156 55.156 448 448 55.156-55.156z" />
|
11
|
+
<glyph unicode="" glyph-name="image" d="M959.884 832c0.040-0.034 0.082-0.076 0.116-0.116v-767.77c-0.034-0.040-0.076-0.082-0.116-0.116h-895.77c-0.040 0.034-0.082 0.076-0.114 0.116v767.772c0.034 0.040 0.076 0.082 0.114 0.114h895.77zM960 896h-896c-35.2 0-64-28.8-64-64v-768c0-35.2 28.8-64 64-64h896c35.2 0 64 28.8 64 64v768c0 35.2-28.8 64-64 64v0zM832 672c0-53.020-42.98-96-96-96s-96 42.98-96 96 42.98 96 96 96 96-42.98 96-96zM896 128h-768v128l224 384 256-320h64l224 192z" />
|
12
|
+
<glyph unicode="" glyph-name="file-text2" d="M917.806 730.924c-22.212 30.292-53.174 65.7-87.178 99.704s-69.412 64.964-99.704 87.178c-51.574 37.82-76.592 42.194-90.924 42.194h-496c-44.112 0-80-35.888-80-80v-864c0-44.112 35.888-80 80-80h736c44.112 0 80 35.888 80 80v624c0 14.332-4.372 39.35-42.194 90.924zM785.374 785.374c30.7-30.7 54.8-58.398 72.58-81.374h-153.954v153.946c22.984-17.78 50.678-41.878 81.374-72.572zM896 16c0-8.672-7.328-16-16-16h-736c-8.672 0-16 7.328-16 16v864c0 8.672 7.328 16 16 16 0 0 495.956 0.002 496 0v-224c0-17.672 14.326-32 32-32h224v-624zM736 128h-448c-17.672 0-32 14.326-32 32s14.328 32 32 32h448c17.674 0 32-14.326 32-32s-14.326-32-32-32zM736 256h-448c-17.672 0-32 14.326-32 32s14.328 32 32 32h448c17.674 0 32-14.326 32-32s-14.326-32-32-32zM736 384h-448c-17.672 0-32 14.326-32 32s14.328 32 32 32h448c17.674 0 32-14.326 32-32s-14.326-32-32-32z" />
|
13
|
+
<glyph unicode="" glyph-name="mobile2" d="M768 960h-576c-35.2 0-64-28.798-64-64v-896c0-35.2 28.798-64 64-64h576c35.2 0 64 28.8 64 64v896c0 35.202-28.8 64-64 64zM480-17.782c-27.492 0-49.782 22.29-49.782 49.782s22.29 49.782 49.782 49.782 49.782-22.29 49.782-49.782-22.29-49.782-49.782-49.782zM768 128h-576v704h576v-704z" />
|
14
|
+
<glyph unicode="" glyph-name="upload" d="M448 384h128v256h192l-256 256-256-256h192zM640 528v-98.712l293.066-109.288-421.066-157.018-421.066 157.018 293.066 109.288v98.712l-384-144v-256l512-192 512 192v256z" />
|
15
|
+
<glyph unicode="" glyph-name="floppy-disk" d="M896 960h-896v-1024h1024v896l-128 128zM512 832h128v-256h-128v256zM896 64h-768v768h64v-320h576v320h74.978l53.022-53.018v-714.982z" />
|
16
|
+
<glyph unicode="" glyph-name="user" d="M576 253.388v52.78c70.498 39.728 128 138.772 128 237.832 0 159.058 0 288-192 288s-192-128.942-192-288c0-99.060 57.502-198.104 128-237.832v-52.78c-217.102-17.748-384-124.42-384-253.388h896c0 128.968-166.898 235.64-384 253.388z" />
|
17
|
+
<glyph unicode="" glyph-name="search" d="M992.262 88.604l-242.552 206.294c-25.074 22.566-51.89 32.926-73.552 31.926 57.256 67.068 91.842 154.078 91.842 249.176 0 212.078-171.922 384-384 384-212.076 0-384-171.922-384-384s171.922-384 384-384c95.098 0 182.108 34.586 249.176 91.844-1-21.662 9.36-48.478 31.926-73.552l206.294-242.552c35.322-39.246 93.022-42.554 128.22-7.356s31.892 92.898-7.354 128.22zM384 320c-141.384 0-256 114.616-256 256s114.616 256 256 256 256-114.616 256-256-114.614-256-256-256z" />
|
18
|
+
<glyph unicode="" glyph-name="cog" d="M933.79 349.75c-53.726 93.054-21.416 212.304 72.152 266.488l-100.626 174.292c-28.75-16.854-62.176-26.518-97.846-26.518-107.536 0-194.708 87.746-194.708 195.99h-201.258c0.266-33.41-8.074-67.282-25.958-98.252-53.724-93.056-173.156-124.702-266.862-70.758l-100.624-174.292c28.97-16.472 54.050-40.588 71.886-71.478 53.638-92.908 21.512-211.92-71.708-266.224l100.626-174.292c28.65 16.696 61.916 26.254 97.4 26.254 107.196 0 194.144-87.192 194.7-194.958h201.254c-0.086 33.074 8.272 66.57 25.966 97.218 53.636 92.906 172.776 124.594 266.414 71.012l100.626 174.29c-28.78 16.466-53.692 40.498-71.434 71.228zM512 240.668c-114.508 0-207.336 92.824-207.336 207.334 0 114.508 92.826 207.334 207.336 207.334 114.508 0 207.332-92.826 207.332-207.334-0.002-114.51-92.824-207.334-207.332-207.334z" />
|
19
|
+
<glyph unicode="" glyph-name="bin" d="M128 640v-640c0-35.2 28.8-64 64-64h576c35.2 0 64 28.8 64 64v640h-704zM320 64h-64v448h64v-448zM448 64h-64v448h64v-448zM576 64h-64v448h64v-448zM704 64h-64v448h64v-448zM848 832h-208v80c0 26.4-21.6 48-48 48h-224c-26.4 0-48-21.6-48-48v-80h-208c-26.4 0-48-21.6-48-48v-80h832v80c0 26.4-21.6 48-48 48zM576 832h-192v63.198h192v-63.198z" />
|
20
|
+
<glyph unicode="" glyph-name="eye" d="M512 768c-223.318 0-416.882-130.042-512-320 95.118-189.958 288.682-320 512-320 223.312 0 416.876 130.042 512 320-95.116 189.958-288.688 320-512 320zM764.45 598.296c60.162-38.374 111.142-89.774 149.434-150.296-38.292-60.522-89.274-111.922-149.436-150.296-75.594-48.218-162.89-73.704-252.448-73.704-89.56 0-176.858 25.486-252.452 73.704-60.158 38.372-111.138 89.772-149.432 150.296 38.292 60.524 89.274 111.924 149.434 150.296 3.918 2.5 7.876 4.922 11.86 7.3-9.96-27.328-15.41-56.822-15.41-87.596 0-141.382 114.616-256 256-256 141.382 0 256 114.618 256 256 0 30.774-5.452 60.268-15.408 87.598 3.978-2.378 7.938-4.802 11.858-7.302v0zM512 544c0-53.020-42.98-96-96-96s-96 42.98-96 96 42.98 96 96 96 96-42.982 96-96z" />
|
21
|
+
<glyph unicode="" glyph-name="eye-blocked" d="M945.942 945.942c-18.746 18.744-49.136 18.744-67.882 0l-202.164-202.164c-51.938 15.754-106.948 24.222-163.896 24.222-223.318 0-416.882-130.042-512-320 41.122-82.124 100.648-153.040 173.022-207.096l-158.962-158.962c-18.746-18.746-18.746-49.136 0-67.882 9.372-9.374 21.656-14.060 33.94-14.060s24.568 4.686 33.942 14.058l864 864c18.744 18.746 18.744 49.138 0 67.884zM416 640c42.24 0 78.082-27.294 90.92-65.196l-121.724-121.724c-37.902 12.838-65.196 48.68-65.196 90.92 0 53.020 42.98 96 96 96zM110.116 448c38.292 60.524 89.274 111.924 149.434 150.296 3.918 2.5 7.876 4.922 11.862 7.3-9.962-27.328-15.412-56.822-15.412-87.596 0-54.89 17.286-105.738 46.7-147.418l-60.924-60.924c-52.446 36.842-97.202 83.882-131.66 138.342zM768 518c0 27.166-4.256 53.334-12.102 77.898l-321.808-321.808c24.568-7.842 50.742-12.090 77.91-12.090 141.382 0 256 114.618 256 256zM830.026 670.026l-69.362-69.362c1.264-0.786 2.53-1.568 3.786-2.368 60.162-38.374 111.142-89.774 149.434-150.296-38.292-60.522-89.274-111.922-149.436-150.296-75.594-48.218-162.89-73.704-252.448-73.704-38.664 0-76.902 4.76-113.962 14.040l-76.894-76.894c59.718-21.462 123.95-33.146 190.856-33.146 223.31 0 416.876 130.042 512 320-45.022 89.916-112.118 166.396-193.974 222.026z" />
|
22
|
+
<glyph unicode="" glyph-name="plus" d="M992 576h-352v352c0 17.672-14.328 32-32 32h-192c-17.672 0-32-14.328-32-32v-352h-352c-17.672 0-32-14.328-32-32v-192c0-17.672 14.328-32 32-32h352v-352c0-17.672 14.328-32 32-32h192c17.672 0 32 14.328 32 32v352h352c17.672 0 32 14.328 32 32v192c0 17.672-14.328 32-32 32z" />
|
23
|
+
<glyph unicode="" glyph-name="move-down" d="M768 256v384h-64v-384h-160l192-192 192 192zM320 704v-192h-192v192h192zM384 768h-320v-320h320v320zM64 320h96v-64h-96v64zM192 320h96v-64h-96v64zM320 320h64v-96h-64v96zM64 96h64v-96h-64v96zM160 64h96v-64h-96v64zM288 64h96v-64h-96v64zM64 224h64v-96h-64v96zM320 192h64v-96h-64v96z" />
|
24
|
+
</font></defs></svg>
|
Binary file
|
Binary file
|
@@ -0,0 +1,13 @@
|
|
1
|
+
// OFF require_tree .
|
2
|
+
//
|
3
|
+
// OFF require editable_components/jquery/jquery
|
4
|
+
// OFF require editable_components/jquery-modal/jquery.modal
|
5
|
+
// OFF require editable_components/sortablejs/Sortable
|
6
|
+
//
|
7
|
+
//= require editable_components/sizzle/sizzle
|
8
|
+
//= require editable_components/vue/vue
|
9
|
+
//= require editable_components/dropzone/dropzone
|
10
|
+
//= require editable_components/dragula/dragula
|
11
|
+
//= require editable_components/medium-editor/medium-editor
|
12
|
+
//
|
13
|
+
//= require editable_components/main
|
@@ -0,0 +1,22 @@
|
|
1
|
+
.gu-mirror {
|
2
|
+
position: fixed !important;
|
3
|
+
margin: 0 !important;
|
4
|
+
z-index: 9999 !important;
|
5
|
+
opacity: 0.8;
|
6
|
+
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=80)";
|
7
|
+
filter: alpha(opacity=80);
|
8
|
+
}
|
9
|
+
.gu-hide {
|
10
|
+
display: none !important;
|
11
|
+
}
|
12
|
+
.gu-unselectable {
|
13
|
+
-webkit-user-select: none !important;
|
14
|
+
-moz-user-select: none !important;
|
15
|
+
-ms-user-select: none !important;
|
16
|
+
user-select: none !important;
|
17
|
+
}
|
18
|
+
.gu-transit {
|
19
|
+
opacity: 0.2;
|
20
|
+
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=20)";
|
21
|
+
filter: alpha(opacity=20);
|
22
|
+
}
|
@@ -0,0 +1,908 @@
|
|
1
|
+
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.dragula = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
|
2
|
+
'use strict';
|
3
|
+
|
4
|
+
var cache = {};
|
5
|
+
var start = '(?:^|\\s)';
|
6
|
+
var end = '(?:\\s|$)';
|
7
|
+
|
8
|
+
function lookupClass (className) {
|
9
|
+
var cached = cache[className];
|
10
|
+
if (cached) {
|
11
|
+
cached.lastIndex = 0;
|
12
|
+
} else {
|
13
|
+
cache[className] = cached = new RegExp(start + className + end, 'g');
|
14
|
+
}
|
15
|
+
return cached;
|
16
|
+
}
|
17
|
+
|
18
|
+
function addClass (el, className) {
|
19
|
+
var current = el.className;
|
20
|
+
if (!current.length) {
|
21
|
+
el.className = className;
|
22
|
+
} else if (!lookupClass(className).test(current)) {
|
23
|
+
el.className += ' ' + className;
|
24
|
+
}
|
25
|
+
}
|
26
|
+
|
27
|
+
function rmClass (el, className) {
|
28
|
+
el.className = el.className.replace(lookupClass(className), ' ').trim();
|
29
|
+
}
|
30
|
+
|
31
|
+
module.exports = {
|
32
|
+
add: addClass,
|
33
|
+
rm: rmClass
|
34
|
+
};
|
35
|
+
|
36
|
+
},{}],2:[function(require,module,exports){
|
37
|
+
(function (global){
|
38
|
+
'use strict';
|
39
|
+
|
40
|
+
var emitter = require('contra/emitter');
|
41
|
+
var crossvent = require('crossvent');
|
42
|
+
var classes = require('./classes');
|
43
|
+
var doc = document;
|
44
|
+
var documentElement = doc.documentElement;
|
45
|
+
|
46
|
+
function dragula (initialContainers, options) {
|
47
|
+
var len = arguments.length;
|
48
|
+
if (len === 1 && Array.isArray(initialContainers) === false) {
|
49
|
+
options = initialContainers;
|
50
|
+
initialContainers = [];
|
51
|
+
}
|
52
|
+
var _mirror; // mirror image
|
53
|
+
var _source; // source container
|
54
|
+
var _item; // item being dragged
|
55
|
+
var _offsetX; // reference x
|
56
|
+
var _offsetY; // reference y
|
57
|
+
var _moveX; // reference move x
|
58
|
+
var _moveY; // reference move y
|
59
|
+
var _initialSibling; // reference sibling when grabbed
|
60
|
+
var _currentSibling; // reference sibling now
|
61
|
+
var _copy; // item used for copying
|
62
|
+
var _renderTimer; // timer for setTimeout renderMirrorImage
|
63
|
+
var _lastDropTarget = null; // last container item was over
|
64
|
+
var _grabbed; // holds mousedown context until first mousemove
|
65
|
+
|
66
|
+
var o = options || {};
|
67
|
+
if (o.moves === void 0) { o.moves = always; }
|
68
|
+
if (o.accepts === void 0) { o.accepts = always; }
|
69
|
+
if (o.invalid === void 0) { o.invalid = invalidTarget; }
|
70
|
+
if (o.containers === void 0) { o.containers = initialContainers || []; }
|
71
|
+
if (o.isContainer === void 0) { o.isContainer = never; }
|
72
|
+
if (o.copy === void 0) { o.copy = false; }
|
73
|
+
if (o.copySortSource === void 0) { o.copySortSource = false; }
|
74
|
+
if (o.revertOnSpill === void 0) { o.revertOnSpill = false; }
|
75
|
+
if (o.removeOnSpill === void 0) { o.removeOnSpill = false; }
|
76
|
+
if (o.direction === void 0) { o.direction = 'vertical'; }
|
77
|
+
if (o.ignoreInputTextSelection === void 0) { o.ignoreInputTextSelection = true; }
|
78
|
+
if (o.mirrorContainer === void 0) { o.mirrorContainer = doc.body; }
|
79
|
+
|
80
|
+
var drake = emitter({
|
81
|
+
containers: o.containers,
|
82
|
+
start: manualStart,
|
83
|
+
end: end,
|
84
|
+
cancel: cancel,
|
85
|
+
remove: remove,
|
86
|
+
destroy: destroy,
|
87
|
+
canMove: canMove,
|
88
|
+
dragging: false
|
89
|
+
});
|
90
|
+
|
91
|
+
if (o.removeOnSpill === true) {
|
92
|
+
drake.on('over', spillOver).on('out', spillOut);
|
93
|
+
}
|
94
|
+
|
95
|
+
events();
|
96
|
+
|
97
|
+
return drake;
|
98
|
+
|
99
|
+
function isContainer (el) {
|
100
|
+
return drake.containers.indexOf(el) !== -1 || o.isContainer(el);
|
101
|
+
}
|
102
|
+
|
103
|
+
function events (remove) {
|
104
|
+
var op = remove ? 'remove' : 'add';
|
105
|
+
touchy(documentElement, op, 'mousedown', grab);
|
106
|
+
touchy(documentElement, op, 'mouseup', release);
|
107
|
+
}
|
108
|
+
|
109
|
+
function eventualMovements (remove) {
|
110
|
+
var op = remove ? 'remove' : 'add';
|
111
|
+
touchy(documentElement, op, 'mousemove', startBecauseMouseMoved);
|
112
|
+
}
|
113
|
+
|
114
|
+
function movements (remove) {
|
115
|
+
var op = remove ? 'remove' : 'add';
|
116
|
+
crossvent[op](documentElement, 'selectstart', preventGrabbed); // IE8
|
117
|
+
crossvent[op](documentElement, 'click', preventGrabbed);
|
118
|
+
}
|
119
|
+
|
120
|
+
function destroy () {
|
121
|
+
events(true);
|
122
|
+
release({});
|
123
|
+
}
|
124
|
+
|
125
|
+
function preventGrabbed (e) {
|
126
|
+
if (_grabbed) {
|
127
|
+
e.preventDefault();
|
128
|
+
}
|
129
|
+
}
|
130
|
+
|
131
|
+
function grab (e) {
|
132
|
+
_moveX = e.clientX;
|
133
|
+
_moveY = e.clientY;
|
134
|
+
|
135
|
+
var ignore = whichMouseButton(e) !== 1 || e.metaKey || e.ctrlKey;
|
136
|
+
if (ignore) {
|
137
|
+
return; // we only care about honest-to-god left clicks and touch events
|
138
|
+
}
|
139
|
+
var item = e.target;
|
140
|
+
var context = canStart(item);
|
141
|
+
if (!context) {
|
142
|
+
return;
|
143
|
+
}
|
144
|
+
_grabbed = context;
|
145
|
+
eventualMovements();
|
146
|
+
if (e.type === 'mousedown') {
|
147
|
+
if (isInput(item)) { // see also: https://github.com/bevacqua/dragula/issues/208
|
148
|
+
item.focus(); // fixes https://github.com/bevacqua/dragula/issues/176
|
149
|
+
} else {
|
150
|
+
e.preventDefault(); // fixes https://github.com/bevacqua/dragula/issues/155
|
151
|
+
}
|
152
|
+
}
|
153
|
+
}
|
154
|
+
|
155
|
+
function startBecauseMouseMoved (e) {
|
156
|
+
if (!_grabbed) {
|
157
|
+
return;
|
158
|
+
}
|
159
|
+
if (whichMouseButton(e) === 0) {
|
160
|
+
release({});
|
161
|
+
return; // when text is selected on an input and then dragged, mouseup doesn't fire. this is our only hope
|
162
|
+
}
|
163
|
+
// truthy check fixes #239, equality fixes #207
|
164
|
+
if (e.clientX !== void 0 && e.clientX === _moveX && e.clientY !== void 0 && e.clientY === _moveY) {
|
165
|
+
return;
|
166
|
+
}
|
167
|
+
if (o.ignoreInputTextSelection) {
|
168
|
+
var clientX = getCoord('clientX', e);
|
169
|
+
var clientY = getCoord('clientY', e);
|
170
|
+
var elementBehindCursor = doc.elementFromPoint(clientX, clientY);
|
171
|
+
if (isInput(elementBehindCursor)) {
|
172
|
+
return;
|
173
|
+
}
|
174
|
+
}
|
175
|
+
|
176
|
+
var grabbed = _grabbed; // call to end() unsets _grabbed
|
177
|
+
eventualMovements(true);
|
178
|
+
movements();
|
179
|
+
end();
|
180
|
+
start(grabbed);
|
181
|
+
|
182
|
+
var offset = getOffset(_item);
|
183
|
+
_offsetX = getCoord('pageX', e) - offset.left;
|
184
|
+
_offsetY = getCoord('pageY', e) - offset.top;
|
185
|
+
|
186
|
+
classes.add(_copy || _item, 'gu-transit');
|
187
|
+
renderMirrorImage();
|
188
|
+
drag(e);
|
189
|
+
}
|
190
|
+
|
191
|
+
function canStart (item) {
|
192
|
+
if (drake.dragging && _mirror) {
|
193
|
+
return;
|
194
|
+
}
|
195
|
+
if (isContainer(item)) {
|
196
|
+
return; // don't drag container itself
|
197
|
+
}
|
198
|
+
var handle = item;
|
199
|
+
while (getParent(item) && isContainer(getParent(item)) === false) {
|
200
|
+
if (o.invalid(item, handle)) {
|
201
|
+
return;
|
202
|
+
}
|
203
|
+
item = getParent(item); // drag target should be a top element
|
204
|
+
if (!item) {
|
205
|
+
return;
|
206
|
+
}
|
207
|
+
}
|
208
|
+
var source = getParent(item);
|
209
|
+
if (!source) {
|
210
|
+
return;
|
211
|
+
}
|
212
|
+
if (o.invalid(item, handle)) {
|
213
|
+
return;
|
214
|
+
}
|
215
|
+
|
216
|
+
var movable = o.moves(item, source, handle, nextEl(item));
|
217
|
+
if (!movable) {
|
218
|
+
return;
|
219
|
+
}
|
220
|
+
|
221
|
+
return {
|
222
|
+
item: item,
|
223
|
+
source: source
|
224
|
+
};
|
225
|
+
}
|
226
|
+
|
227
|
+
function canMove (item) {
|
228
|
+
return !!canStart(item);
|
229
|
+
}
|
230
|
+
|
231
|
+
function manualStart (item) {
|
232
|
+
var context = canStart(item);
|
233
|
+
if (context) {
|
234
|
+
start(context);
|
235
|
+
}
|
236
|
+
}
|
237
|
+
|
238
|
+
function start (context) {
|
239
|
+
if (isCopy(context.item, context.source)) {
|
240
|
+
_copy = context.item.cloneNode(true);
|
241
|
+
drake.emit('cloned', _copy, context.item, 'copy');
|
242
|
+
}
|
243
|
+
|
244
|
+
_source = context.source;
|
245
|
+
_item = context.item;
|
246
|
+
_initialSibling = _currentSibling = nextEl(context.item);
|
247
|
+
|
248
|
+
drake.dragging = true;
|
249
|
+
drake.emit('drag', _item, _source);
|
250
|
+
}
|
251
|
+
|
252
|
+
function invalidTarget () {
|
253
|
+
return false;
|
254
|
+
}
|
255
|
+
|
256
|
+
function end () {
|
257
|
+
if (!drake.dragging) {
|
258
|
+
return;
|
259
|
+
}
|
260
|
+
var item = _copy || _item;
|
261
|
+
drop(item, getParent(item));
|
262
|
+
}
|
263
|
+
|
264
|
+
function ungrab () {
|
265
|
+
_grabbed = false;
|
266
|
+
eventualMovements(true);
|
267
|
+
movements(true);
|
268
|
+
}
|
269
|
+
|
270
|
+
function release (e) {
|
271
|
+
ungrab();
|
272
|
+
|
273
|
+
if (!drake.dragging) {
|
274
|
+
return;
|
275
|
+
}
|
276
|
+
var item = _copy || _item;
|
277
|
+
var clientX = getCoord('clientX', e);
|
278
|
+
var clientY = getCoord('clientY', e);
|
279
|
+
var elementBehindCursor = getElementBehindPoint(_mirror, clientX, clientY);
|
280
|
+
var dropTarget = findDropTarget(elementBehindCursor, clientX, clientY);
|
281
|
+
if (dropTarget && ((_copy && o.copySortSource) || (!_copy || dropTarget !== _source))) {
|
282
|
+
drop(item, dropTarget);
|
283
|
+
} else if (o.removeOnSpill) {
|
284
|
+
remove();
|
285
|
+
} else {
|
286
|
+
cancel();
|
287
|
+
}
|
288
|
+
}
|
289
|
+
|
290
|
+
function drop (item, target) {
|
291
|
+
var parent = getParent(item);
|
292
|
+
if (_copy && o.copySortSource && target === _source) {
|
293
|
+
parent.removeChild(_item);
|
294
|
+
}
|
295
|
+
if (isInitialPlacement(target)) {
|
296
|
+
drake.emit('cancel', item, _source, _source);
|
297
|
+
} else {
|
298
|
+
drake.emit('drop', item, target, _source, _currentSibling);
|
299
|
+
}
|
300
|
+
cleanup();
|
301
|
+
}
|
302
|
+
|
303
|
+
function remove () {
|
304
|
+
if (!drake.dragging) {
|
305
|
+
return;
|
306
|
+
}
|
307
|
+
var item = _copy || _item;
|
308
|
+
var parent = getParent(item);
|
309
|
+
if (parent) {
|
310
|
+
parent.removeChild(item);
|
311
|
+
}
|
312
|
+
drake.emit(_copy ? 'cancel' : 'remove', item, parent, _source);
|
313
|
+
cleanup();
|
314
|
+
}
|
315
|
+
|
316
|
+
function cancel (revert) {
|
317
|
+
if (!drake.dragging) {
|
318
|
+
return;
|
319
|
+
}
|
320
|
+
var reverts = arguments.length > 0 ? revert : o.revertOnSpill;
|
321
|
+
var item = _copy || _item;
|
322
|
+
var parent = getParent(item);
|
323
|
+
var initial = isInitialPlacement(parent);
|
324
|
+
if (initial === false && reverts) {
|
325
|
+
if (_copy) {
|
326
|
+
if (parent) {
|
327
|
+
parent.removeChild(_copy);
|
328
|
+
}
|
329
|
+
} else {
|
330
|
+
_source.insertBefore(item, _initialSibling);
|
331
|
+
}
|
332
|
+
}
|
333
|
+
if (initial || reverts) {
|
334
|
+
drake.emit('cancel', item, _source, _source);
|
335
|
+
} else {
|
336
|
+
drake.emit('drop', item, parent, _source, _currentSibling);
|
337
|
+
}
|
338
|
+
cleanup();
|
339
|
+
}
|
340
|
+
|
341
|
+
function cleanup () {
|
342
|
+
var item = _copy || _item;
|
343
|
+
ungrab();
|
344
|
+
removeMirrorImage();
|
345
|
+
if (item) {
|
346
|
+
classes.rm(item, 'gu-transit');
|
347
|
+
}
|
348
|
+
if (_renderTimer) {
|
349
|
+
clearTimeout(_renderTimer);
|
350
|
+
}
|
351
|
+
drake.dragging = false;
|
352
|
+
if (_lastDropTarget) {
|
353
|
+
drake.emit('out', item, _lastDropTarget, _source);
|
354
|
+
}
|
355
|
+
drake.emit('dragend', item);
|
356
|
+
_source = _item = _copy = _initialSibling = _currentSibling = _renderTimer = _lastDropTarget = null;
|
357
|
+
}
|
358
|
+
|
359
|
+
function isInitialPlacement (target, s) {
|
360
|
+
var sibling;
|
361
|
+
if (s !== void 0) {
|
362
|
+
sibling = s;
|
363
|
+
} else if (_mirror) {
|
364
|
+
sibling = _currentSibling;
|
365
|
+
} else {
|
366
|
+
sibling = nextEl(_copy || _item);
|
367
|
+
}
|
368
|
+
return target === _source && sibling === _initialSibling;
|
369
|
+
}
|
370
|
+
|
371
|
+
function findDropTarget (elementBehindCursor, clientX, clientY) {
|
372
|
+
var target = elementBehindCursor;
|
373
|
+
while (target && !accepted()) {
|
374
|
+
target = getParent(target);
|
375
|
+
}
|
376
|
+
return target;
|
377
|
+
|
378
|
+
function accepted () {
|
379
|
+
var droppable = isContainer(target);
|
380
|
+
if (droppable === false) {
|
381
|
+
return false;
|
382
|
+
}
|
383
|
+
|
384
|
+
var immediate = getImmediateChild(target, elementBehindCursor);
|
385
|
+
var reference = getReference(target, immediate, clientX, clientY);
|
386
|
+
var initial = isInitialPlacement(target, reference);
|
387
|
+
if (initial) {
|
388
|
+
return true; // should always be able to drop it right back where it was
|
389
|
+
}
|
390
|
+
return o.accepts(_item, target, _source, reference);
|
391
|
+
}
|
392
|
+
}
|
393
|
+
|
394
|
+
function drag (e) {
|
395
|
+
if (!_mirror) {
|
396
|
+
return;
|
397
|
+
}
|
398
|
+
e.preventDefault();
|
399
|
+
|
400
|
+
var clientX = getCoord('clientX', e);
|
401
|
+
var clientY = getCoord('clientY', e);
|
402
|
+
var x = clientX - _offsetX;
|
403
|
+
var y = clientY - _offsetY;
|
404
|
+
|
405
|
+
_mirror.style.left = x + 'px';
|
406
|
+
_mirror.style.top = y + 'px';
|
407
|
+
|
408
|
+
var item = _copy || _item;
|
409
|
+
var elementBehindCursor = getElementBehindPoint(_mirror, clientX, clientY);
|
410
|
+
var dropTarget = findDropTarget(elementBehindCursor, clientX, clientY);
|
411
|
+
var changed = dropTarget !== null && dropTarget !== _lastDropTarget;
|
412
|
+
if (changed || dropTarget === null) {
|
413
|
+
out();
|
414
|
+
_lastDropTarget = dropTarget;
|
415
|
+
over();
|
416
|
+
}
|
417
|
+
var parent = getParent(item);
|
418
|
+
if (dropTarget === _source && _copy && !o.copySortSource) {
|
419
|
+
if (parent) {
|
420
|
+
parent.removeChild(item);
|
421
|
+
}
|
422
|
+
return;
|
423
|
+
}
|
424
|
+
var reference;
|
425
|
+
var immediate = getImmediateChild(dropTarget, elementBehindCursor);
|
426
|
+
if (immediate !== null) {
|
427
|
+
reference = getReference(dropTarget, immediate, clientX, clientY);
|
428
|
+
} else if (o.revertOnSpill === true && !_copy) {
|
429
|
+
reference = _initialSibling;
|
430
|
+
dropTarget = _source;
|
431
|
+
} else {
|
432
|
+
if (_copy && parent) {
|
433
|
+
parent.removeChild(item);
|
434
|
+
}
|
435
|
+
return;
|
436
|
+
}
|
437
|
+
if (
|
438
|
+
(reference === null && changed) ||
|
439
|
+
reference !== item &&
|
440
|
+
reference !== nextEl(item)
|
441
|
+
) {
|
442
|
+
_currentSibling = reference;
|
443
|
+
dropTarget.insertBefore(item, reference);
|
444
|
+
drake.emit('shadow', item, dropTarget, _source);
|
445
|
+
}
|
446
|
+
function moved (type) { drake.emit(type, item, _lastDropTarget, _source); }
|
447
|
+
function over () { if (changed) { moved('over'); } }
|
448
|
+
function out () { if (_lastDropTarget) { moved('out'); } }
|
449
|
+
}
|
450
|
+
|
451
|
+
function spillOver (el) {
|
452
|
+
classes.rm(el, 'gu-hide');
|
453
|
+
}
|
454
|
+
|
455
|
+
function spillOut (el) {
|
456
|
+
if (drake.dragging) { classes.add(el, 'gu-hide'); }
|
457
|
+
}
|
458
|
+
|
459
|
+
function renderMirrorImage () {
|
460
|
+
if (_mirror) {
|
461
|
+
return;
|
462
|
+
}
|
463
|
+
var rect = _item.getBoundingClientRect();
|
464
|
+
_mirror = _item.cloneNode(true);
|
465
|
+
_mirror.style.width = getRectWidth(rect) + 'px';
|
466
|
+
_mirror.style.height = getRectHeight(rect) + 'px';
|
467
|
+
classes.rm(_mirror, 'gu-transit');
|
468
|
+
classes.add(_mirror, 'gu-mirror');
|
469
|
+
o.mirrorContainer.appendChild(_mirror);
|
470
|
+
touchy(documentElement, 'add', 'mousemove', drag);
|
471
|
+
classes.add(o.mirrorContainer, 'gu-unselectable');
|
472
|
+
drake.emit('cloned', _mirror, _item, 'mirror');
|
473
|
+
}
|
474
|
+
|
475
|
+
function removeMirrorImage () {
|
476
|
+
if (_mirror) {
|
477
|
+
classes.rm(o.mirrorContainer, 'gu-unselectable');
|
478
|
+
touchy(documentElement, 'remove', 'mousemove', drag);
|
479
|
+
getParent(_mirror).removeChild(_mirror);
|
480
|
+
_mirror = null;
|
481
|
+
}
|
482
|
+
}
|
483
|
+
|
484
|
+
function getImmediateChild (dropTarget, target) {
|
485
|
+
var immediate = target;
|
486
|
+
while (immediate !== dropTarget && getParent(immediate) !== dropTarget) {
|
487
|
+
immediate = getParent(immediate);
|
488
|
+
}
|
489
|
+
if (immediate === documentElement) {
|
490
|
+
return null;
|
491
|
+
}
|
492
|
+
return immediate;
|
493
|
+
}
|
494
|
+
|
495
|
+
function getReference (dropTarget, target, x, y) {
|
496
|
+
var horizontal = o.direction === 'horizontal';
|
497
|
+
var reference = target !== dropTarget ? inside() : outside();
|
498
|
+
return reference;
|
499
|
+
|
500
|
+
function outside () { // slower, but able to figure out any position
|
501
|
+
var len = dropTarget.children.length;
|
502
|
+
var i;
|
503
|
+
var el;
|
504
|
+
var rect;
|
505
|
+
for (i = 0; i < len; i++) {
|
506
|
+
el = dropTarget.children[i];
|
507
|
+
rect = el.getBoundingClientRect();
|
508
|
+
if (horizontal && (rect.left + rect.width / 2) > x) { return el; }
|
509
|
+
if (!horizontal && (rect.top + rect.height / 2) > y) { return el; }
|
510
|
+
}
|
511
|
+
return null;
|
512
|
+
}
|
513
|
+
|
514
|
+
function inside () { // faster, but only available if dropped inside a child element
|
515
|
+
var rect = target.getBoundingClientRect();
|
516
|
+
if (horizontal) {
|
517
|
+
return resolve(x > rect.left + getRectWidth(rect) / 2);
|
518
|
+
}
|
519
|
+
return resolve(y > rect.top + getRectHeight(rect) / 2);
|
520
|
+
}
|
521
|
+
|
522
|
+
function resolve (after) {
|
523
|
+
return after ? nextEl(target) : target;
|
524
|
+
}
|
525
|
+
}
|
526
|
+
|
527
|
+
function isCopy (item, container) {
|
528
|
+
return typeof o.copy === 'boolean' ? o.copy : o.copy(item, container);
|
529
|
+
}
|
530
|
+
}
|
531
|
+
|
532
|
+
function touchy (el, op, type, fn) {
|
533
|
+
var touch = {
|
534
|
+
mouseup: 'touchend',
|
535
|
+
mousedown: 'touchstart',
|
536
|
+
mousemove: 'touchmove'
|
537
|
+
};
|
538
|
+
var pointers = {
|
539
|
+
mouseup: 'pointerup',
|
540
|
+
mousedown: 'pointerdown',
|
541
|
+
mousemove: 'pointermove'
|
542
|
+
};
|
543
|
+
var microsoft = {
|
544
|
+
mouseup: 'MSPointerUp',
|
545
|
+
mousedown: 'MSPointerDown',
|
546
|
+
mousemove: 'MSPointerMove'
|
547
|
+
};
|
548
|
+
if (global.navigator.pointerEnabled) {
|
549
|
+
crossvent[op](el, pointers[type], fn);
|
550
|
+
} else if (global.navigator.msPointerEnabled) {
|
551
|
+
crossvent[op](el, microsoft[type], fn);
|
552
|
+
} else {
|
553
|
+
crossvent[op](el, touch[type], fn);
|
554
|
+
crossvent[op](el, type, fn);
|
555
|
+
}
|
556
|
+
}
|
557
|
+
|
558
|
+
function whichMouseButton (e) {
|
559
|
+
if (e.touches !== void 0) { return e.touches.length; }
|
560
|
+
if (e.which !== void 0 && e.which !== 0) { return e.which; } // see https://github.com/bevacqua/dragula/issues/261
|
561
|
+
if (e.buttons !== void 0) { return e.buttons; }
|
562
|
+
var button = e.button;
|
563
|
+
if (button !== void 0) { // see https://github.com/jquery/jquery/blob/99e8ff1baa7ae341e94bb89c3e84570c7c3ad9ea/src/event.js#L573-L575
|
564
|
+
return button & 1 ? 1 : button & 2 ? 3 : (button & 4 ? 2 : 0);
|
565
|
+
}
|
566
|
+
}
|
567
|
+
|
568
|
+
function getOffset (el) {
|
569
|
+
var rect = el.getBoundingClientRect();
|
570
|
+
return {
|
571
|
+
left: rect.left + getScroll('scrollLeft', 'pageXOffset'),
|
572
|
+
top: rect.top + getScroll('scrollTop', 'pageYOffset')
|
573
|
+
};
|
574
|
+
}
|
575
|
+
|
576
|
+
function getScroll (scrollProp, offsetProp) {
|
577
|
+
if (typeof global[offsetProp] !== 'undefined') {
|
578
|
+
return global[offsetProp];
|
579
|
+
}
|
580
|
+
if (documentElement.clientHeight) {
|
581
|
+
return documentElement[scrollProp];
|
582
|
+
}
|
583
|
+
return doc.body[scrollProp];
|
584
|
+
}
|
585
|
+
|
586
|
+
function getElementBehindPoint (point, x, y) {
|
587
|
+
var p = point || {};
|
588
|
+
var state = p.className;
|
589
|
+
var el;
|
590
|
+
p.className += ' gu-hide';
|
591
|
+
el = doc.elementFromPoint(x, y);
|
592
|
+
p.className = state;
|
593
|
+
return el;
|
594
|
+
}
|
595
|
+
|
596
|
+
function never () { return false; }
|
597
|
+
function always () { return true; }
|
598
|
+
function getRectWidth (rect) { return rect.width || (rect.right - rect.left); }
|
599
|
+
function getRectHeight (rect) { return rect.height || (rect.bottom - rect.top); }
|
600
|
+
function getParent (el) { return el.parentNode === doc ? null : el.parentNode; }
|
601
|
+
function isInput (el) { return el.tagName === 'INPUT' || el.tagName === 'TEXTAREA' || el.tagName === 'SELECT' || isEditable(el); }
|
602
|
+
function isEditable (el) {
|
603
|
+
if (!el) { return false; } // no parents were editable
|
604
|
+
if (el.contentEditable === 'false') { return false; } // stop the lookup
|
605
|
+
if (el.contentEditable === 'true') { return true; } // found a contentEditable element in the chain
|
606
|
+
return isEditable(getParent(el)); // contentEditable is set to 'inherit'
|
607
|
+
}
|
608
|
+
|
609
|
+
function nextEl (el) {
|
610
|
+
return el.nextElementSibling || manually();
|
611
|
+
function manually () {
|
612
|
+
var sibling = el;
|
613
|
+
do {
|
614
|
+
sibling = sibling.nextSibling;
|
615
|
+
} while (sibling && sibling.nodeType !== 1);
|
616
|
+
return sibling;
|
617
|
+
}
|
618
|
+
}
|
619
|
+
|
620
|
+
function getEventHost (e) {
|
621
|
+
// on touchend event, we have to use `e.changedTouches`
|
622
|
+
// see http://stackoverflow.com/questions/7192563/touchend-event-properties
|
623
|
+
// see https://github.com/bevacqua/dragula/issues/34
|
624
|
+
if (e.targetTouches && e.targetTouches.length) {
|
625
|
+
return e.targetTouches[0];
|
626
|
+
}
|
627
|
+
if (e.changedTouches && e.changedTouches.length) {
|
628
|
+
return e.changedTouches[0];
|
629
|
+
}
|
630
|
+
return e;
|
631
|
+
}
|
632
|
+
|
633
|
+
function getCoord (coord, e) {
|
634
|
+
var host = getEventHost(e);
|
635
|
+
var missMap = {
|
636
|
+
pageX: 'clientX', // IE8
|
637
|
+
pageY: 'clientY' // IE8
|
638
|
+
};
|
639
|
+
if (coord in missMap && !(coord in host) && missMap[coord] in host) {
|
640
|
+
coord = missMap[coord];
|
641
|
+
}
|
642
|
+
return host[coord];
|
643
|
+
}
|
644
|
+
|
645
|
+
module.exports = dragula;
|
646
|
+
|
647
|
+
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
648
|
+
|
649
|
+
},{"./classes":1,"contra/emitter":5,"crossvent":6}],3:[function(require,module,exports){
|
650
|
+
module.exports = function atoa (a, n) { return Array.prototype.slice.call(a, n); }
|
651
|
+
|
652
|
+
},{}],4:[function(require,module,exports){
|
653
|
+
'use strict';
|
654
|
+
|
655
|
+
var ticky = require('ticky');
|
656
|
+
|
657
|
+
module.exports = function debounce (fn, args, ctx) {
|
658
|
+
if (!fn) { return; }
|
659
|
+
ticky(function run () {
|
660
|
+
fn.apply(ctx || null, args || []);
|
661
|
+
});
|
662
|
+
};
|
663
|
+
|
664
|
+
},{"ticky":9}],5:[function(require,module,exports){
|
665
|
+
'use strict';
|
666
|
+
|
667
|
+
var atoa = require('atoa');
|
668
|
+
var debounce = require('./debounce');
|
669
|
+
|
670
|
+
module.exports = function emitter (thing, options) {
|
671
|
+
var opts = options || {};
|
672
|
+
var evt = {};
|
673
|
+
if (thing === undefined) { thing = {}; }
|
674
|
+
thing.on = function (type, fn) {
|
675
|
+
if (!evt[type]) {
|
676
|
+
evt[type] = [fn];
|
677
|
+
} else {
|
678
|
+
evt[type].push(fn);
|
679
|
+
}
|
680
|
+
return thing;
|
681
|
+
};
|
682
|
+
thing.once = function (type, fn) {
|
683
|
+
fn._once = true; // thing.off(fn) still works!
|
684
|
+
thing.on(type, fn);
|
685
|
+
return thing;
|
686
|
+
};
|
687
|
+
thing.off = function (type, fn) {
|
688
|
+
var c = arguments.length;
|
689
|
+
if (c === 1) {
|
690
|
+
delete evt[type];
|
691
|
+
} else if (c === 0) {
|
692
|
+
evt = {};
|
693
|
+
} else {
|
694
|
+
var et = evt[type];
|
695
|
+
if (!et) { return thing; }
|
696
|
+
et.splice(et.indexOf(fn), 1);
|
697
|
+
}
|
698
|
+
return thing;
|
699
|
+
};
|
700
|
+
thing.emit = function () {
|
701
|
+
var args = atoa(arguments);
|
702
|
+
return thing.emitterSnapshot(args.shift()).apply(this, args);
|
703
|
+
};
|
704
|
+
thing.emitterSnapshot = function (type) {
|
705
|
+
var et = (evt[type] || []).slice(0);
|
706
|
+
return function () {
|
707
|
+
var args = atoa(arguments);
|
708
|
+
var ctx = this || thing;
|
709
|
+
if (type === 'error' && opts.throws !== false && !et.length) { throw args.length === 1 ? args[0] : args; }
|
710
|
+
et.forEach(function emitter (listen) {
|
711
|
+
if (opts.async) { debounce(listen, args, ctx); } else { listen.apply(ctx, args); }
|
712
|
+
if (listen._once) { thing.off(type, listen); }
|
713
|
+
});
|
714
|
+
return thing;
|
715
|
+
};
|
716
|
+
};
|
717
|
+
return thing;
|
718
|
+
};
|
719
|
+
|
720
|
+
},{"./debounce":4,"atoa":3}],6:[function(require,module,exports){
|
721
|
+
(function (global){
|
722
|
+
'use strict';
|
723
|
+
|
724
|
+
var customEvent = require('custom-event');
|
725
|
+
var eventmap = require('./eventmap');
|
726
|
+
var doc = global.document;
|
727
|
+
var addEvent = addEventEasy;
|
728
|
+
var removeEvent = removeEventEasy;
|
729
|
+
var hardCache = [];
|
730
|
+
|
731
|
+
if (!global.addEventListener) {
|
732
|
+
addEvent = addEventHard;
|
733
|
+
removeEvent = removeEventHard;
|
734
|
+
}
|
735
|
+
|
736
|
+
module.exports = {
|
737
|
+
add: addEvent,
|
738
|
+
remove: removeEvent,
|
739
|
+
fabricate: fabricateEvent
|
740
|
+
};
|
741
|
+
|
742
|
+
function addEventEasy (el, type, fn, capturing) {
|
743
|
+
return el.addEventListener(type, fn, capturing);
|
744
|
+
}
|
745
|
+
|
746
|
+
function addEventHard (el, type, fn) {
|
747
|
+
return el.attachEvent('on' + type, wrap(el, type, fn));
|
748
|
+
}
|
749
|
+
|
750
|
+
function removeEventEasy (el, type, fn, capturing) {
|
751
|
+
return el.removeEventListener(type, fn, capturing);
|
752
|
+
}
|
753
|
+
|
754
|
+
function removeEventHard (el, type, fn) {
|
755
|
+
var listener = unwrap(el, type, fn);
|
756
|
+
if (listener) {
|
757
|
+
return el.detachEvent('on' + type, listener);
|
758
|
+
}
|
759
|
+
}
|
760
|
+
|
761
|
+
function fabricateEvent (el, type, model) {
|
762
|
+
var e = eventmap.indexOf(type) === -1 ? makeCustomEvent() : makeClassicEvent();
|
763
|
+
if (el.dispatchEvent) {
|
764
|
+
el.dispatchEvent(e);
|
765
|
+
} else {
|
766
|
+
el.fireEvent('on' + type, e);
|
767
|
+
}
|
768
|
+
function makeClassicEvent () {
|
769
|
+
var e;
|
770
|
+
if (doc.createEvent) {
|
771
|
+
e = doc.createEvent('Event');
|
772
|
+
e.initEvent(type, true, true);
|
773
|
+
} else if (doc.createEventObject) {
|
774
|
+
e = doc.createEventObject();
|
775
|
+
}
|
776
|
+
return e;
|
777
|
+
}
|
778
|
+
function makeCustomEvent () {
|
779
|
+
return new customEvent(type, { detail: model });
|
780
|
+
}
|
781
|
+
}
|
782
|
+
|
783
|
+
function wrapperFactory (el, type, fn) {
|
784
|
+
return function wrapper (originalEvent) {
|
785
|
+
var e = originalEvent || global.event;
|
786
|
+
e.target = e.target || e.srcElement;
|
787
|
+
e.preventDefault = e.preventDefault || function preventDefault () { e.returnValue = false; };
|
788
|
+
e.stopPropagation = e.stopPropagation || function stopPropagation () { e.cancelBubble = true; };
|
789
|
+
e.which = e.which || e.keyCode;
|
790
|
+
fn.call(el, e);
|
791
|
+
};
|
792
|
+
}
|
793
|
+
|
794
|
+
function wrap (el, type, fn) {
|
795
|
+
var wrapper = unwrap(el, type, fn) || wrapperFactory(el, type, fn);
|
796
|
+
hardCache.push({
|
797
|
+
wrapper: wrapper,
|
798
|
+
element: el,
|
799
|
+
type: type,
|
800
|
+
fn: fn
|
801
|
+
});
|
802
|
+
return wrapper;
|
803
|
+
}
|
804
|
+
|
805
|
+
function unwrap (el, type, fn) {
|
806
|
+
var i = find(el, type, fn);
|
807
|
+
if (i) {
|
808
|
+
var wrapper = hardCache[i].wrapper;
|
809
|
+
hardCache.splice(i, 1); // free up a tad of memory
|
810
|
+
return wrapper;
|
811
|
+
}
|
812
|
+
}
|
813
|
+
|
814
|
+
function find (el, type, fn) {
|
815
|
+
var i, item;
|
816
|
+
for (i = 0; i < hardCache.length; i++) {
|
817
|
+
item = hardCache[i];
|
818
|
+
if (item.element === el && item.type === type && item.fn === fn) {
|
819
|
+
return i;
|
820
|
+
}
|
821
|
+
}
|
822
|
+
}
|
823
|
+
|
824
|
+
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
825
|
+
|
826
|
+
},{"./eventmap":7,"custom-event":8}],7:[function(require,module,exports){
|
827
|
+
(function (global){
|
828
|
+
'use strict';
|
829
|
+
|
830
|
+
var eventmap = [];
|
831
|
+
var eventname = '';
|
832
|
+
var ron = /^on/;
|
833
|
+
|
834
|
+
for (eventname in global) {
|
835
|
+
if (ron.test(eventname)) {
|
836
|
+
eventmap.push(eventname.slice(2));
|
837
|
+
}
|
838
|
+
}
|
839
|
+
|
840
|
+
module.exports = eventmap;
|
841
|
+
|
842
|
+
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
843
|
+
|
844
|
+
},{}],8:[function(require,module,exports){
|
845
|
+
(function (global){
|
846
|
+
|
847
|
+
var NativeCustomEvent = global.CustomEvent;
|
848
|
+
|
849
|
+
function useNative () {
|
850
|
+
try {
|
851
|
+
var p = new NativeCustomEvent('cat', { detail: { foo: 'bar' } });
|
852
|
+
return 'cat' === p.type && 'bar' === p.detail.foo;
|
853
|
+
} catch (e) {
|
854
|
+
}
|
855
|
+
return false;
|
856
|
+
}
|
857
|
+
|
858
|
+
/**
|
859
|
+
* Cross-browser `CustomEvent` constructor.
|
860
|
+
*
|
861
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent.CustomEvent
|
862
|
+
*
|
863
|
+
* @public
|
864
|
+
*/
|
865
|
+
|
866
|
+
module.exports = useNative() ? NativeCustomEvent :
|
867
|
+
|
868
|
+
// IE >= 9
|
869
|
+
'function' === typeof document.createEvent ? function CustomEvent (type, params) {
|
870
|
+
var e = document.createEvent('CustomEvent');
|
871
|
+
if (params) {
|
872
|
+
e.initCustomEvent(type, params.bubbles, params.cancelable, params.detail);
|
873
|
+
} else {
|
874
|
+
e.initCustomEvent(type, false, false, void 0);
|
875
|
+
}
|
876
|
+
return e;
|
877
|
+
} :
|
878
|
+
|
879
|
+
// IE <= 8
|
880
|
+
function CustomEvent (type, params) {
|
881
|
+
var e = document.createEventObject();
|
882
|
+
e.type = type;
|
883
|
+
if (params) {
|
884
|
+
e.bubbles = Boolean(params.bubbles);
|
885
|
+
e.cancelable = Boolean(params.cancelable);
|
886
|
+
e.detail = params.detail;
|
887
|
+
} else {
|
888
|
+
e.bubbles = false;
|
889
|
+
e.cancelable = false;
|
890
|
+
e.detail = void 0;
|
891
|
+
}
|
892
|
+
return e;
|
893
|
+
}
|
894
|
+
|
895
|
+
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
896
|
+
|
897
|
+
},{}],9:[function(require,module,exports){
|
898
|
+
var si = typeof setImmediate === 'function', tick;
|
899
|
+
if (si) {
|
900
|
+
tick = function (fn) { setImmediate(fn); };
|
901
|
+
} else {
|
902
|
+
tick = function (fn) { setTimeout(fn, 0); };
|
903
|
+
}
|
904
|
+
|
905
|
+
module.exports = tick;
|
906
|
+
},{}]},{},[2])(2)
|
907
|
+
});
|
908
|
+
//# sourceMappingURL=data:application/json;charset:utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9icm93c2VyLXBhY2svX3ByZWx1ZGUuanMiLCJjbGFzc2VzLmpzIiwiZHJhZ3VsYS5qcyIsIm5vZGVfbW9kdWxlcy9hdG9hL2F0b2EuanMiLCJub2RlX21vZHVsZXMvY29udHJhL2RlYm91bmNlLmpzIiwibm9kZV9tb2R1bGVzL2NvbnRyYS9lbWl0dGVyLmpzIiwibm9kZV9tb2R1bGVzL2Nyb3NzdmVudC9zcmMvY3Jvc3N2ZW50LmpzIiwibm9kZV9tb2R1bGVzL2Nyb3NzdmVudC9zcmMvZXZlbnRtYXAuanMiLCJub2RlX21vZHVsZXMvY3VzdG9tLWV2ZW50L2luZGV4LmpzIiwibm9kZV9tb2R1bGVzL3RpY2t5L3RpY2t5LWJyb3dzZXIuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7QUNBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E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