statixite 1.0.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.rdoc +145 -0
- data/Rakefile +26 -0
- data/app/assets/images/statixite/STATIXITE-logo.png +0 -0
- data/app/assets/images/statixite/favicon.ico +0 -0
- data/app/assets/images/statixite/jekyll.png +0 -0
- data/app/assets/images/statixite/md-editor.png +0 -0
- data/app/assets/images/statixite/ring-alt.gif +0 -0
- data/app/assets/javascripts/controllers/statixite/deployments_create.js +13 -0
- data/app/assets/javascripts/controllers/statixite/deployments_index.js +13 -0
- data/app/assets/javascripts/controllers/statixite/sites_create.js +27 -0
- data/app/assets/javascripts/controllers/statixite/sites_new.js +27 -0
- data/app/assets/javascripts/controllers/statixite/templates_edit.js +208 -0
- data/app/assets/javascripts/statixite/application.js +8 -0
- data/app/assets/javascripts/statixite/array-helpers.js +13 -0
- data/app/assets/javascripts/statixite/editor.js +244 -0
- data/app/assets/javascripts/statixite/loader.js +14 -0
- data/app/assets/javascripts/statixite/notify-defaults.js +5 -0
- data/app/assets/stylesheets/statixite/application.less +271 -0
- data/app/assets/stylesheets/statixite/bootstrap-glyphicons.less +305 -0
- data/app/assets/stylesheets/statixite/bootstrap.less +58 -0
- data/app/assets/stylesheets/statixite/bootstrap_and_overrides.less +2 -0
- data/app/assets/stylesheets/statixite/landing-page.less +156 -0
- data/app/controllers/statixite/application_controller.rb +22 -0
- data/app/controllers/statixite/deployments_controller.rb +61 -0
- data/app/controllers/statixite/media_controller.rb +61 -0
- data/app/controllers/statixite/posts_controller.rb +68 -0
- data/app/controllers/statixite/sites_controller.rb +141 -0
- data/app/controllers/statixite/templates_controller.rb +233 -0
- data/app/helpers/statixite/application_helper.rb +63 -0
- data/app/models/statixite/deployment.rb +5 -0
- data/app/models/statixite/media.rb +7 -0
- data/app/models/statixite/post.rb +76 -0
- data/app/models/statixite/site.rb +76 -0
- data/app/services/statixite/deployment_service.rb +73 -0
- data/app/services/statixite/git_service.rb +102 -0
- data/app/services/statixite/site_deactivation_service.rb +52 -0
- data/app/services/statixite/site_operation_service.rb +251 -0
- data/app/uploaders/statixite/file_uploader.rb +14 -0
- data/app/validators/statixite/jekyll_template_validator.rb +16 -0
- data/app/validators/statixite/liquid_validator.rb +11 -0
- data/app/views/layouts/statixite/_dash_nav.html.haml +20 -0
- data/app/views/layouts/statixite/_flash.html.haml +13 -0
- data/app/views/layouts/statixite/_head.html.haml +12 -0
- data/app/views/layouts/statixite/_header.html.haml +30 -0
- data/app/views/layouts/statixite/_site_sub_items.html.haml +38 -0
- data/app/views/layouts/statixite/dashboard.html.haml +27 -0
- data/app/views/statixite/deployments/_modal.html.haml +18 -0
- data/app/views/statixite/deployments/index.html.haml +39 -0
- data/app/views/statixite/kaminari/_first_page.html.haml +2 -0
- data/app/views/statixite/kaminari/_gap.html.haml +2 -0
- data/app/views/statixite/kaminari/_last_page.html.haml +2 -0
- data/app/views/statixite/kaminari/_next_page.html.haml +2 -0
- data/app/views/statixite/kaminari/_page.html.haml +6 -0
- data/app/views/statixite/kaminari/_paginator.html.haml +11 -0
- data/app/views/statixite/kaminari/_prev_page.html.haml +2 -0
- data/app/views/statixite/media/_index.html.haml +13 -0
- data/app/views/statixite/media/_paginate.html.haml +1 -0
- data/app/views/statixite/media/index.html.haml +39 -0
- data/app/views/statixite/media/index.js.haml +2 -0
- data/app/views/statixite/posts/_form.html.haml +65 -0
- data/app/views/statixite/posts/_image_modal.html.haml +21 -0
- data/app/views/statixite/posts/_modals.html.haml +111 -0
- data/app/views/statixite/posts/_posts.html.haml +15 -0
- data/app/views/statixite/posts/edit.html.haml +6 -0
- data/app/views/statixite/posts/index.html.haml +4 -0
- data/app/views/statixite/posts/index.js.haml +1 -0
- data/app/views/statixite/posts/new.html.haml +5 -0
- data/app/views/statixite/sites/_sites.html.haml +27 -0
- data/app/views/statixite/sites/_templates.html.haml +26 -0
- data/app/views/statixite/sites/build_and_preview.html.haml +24 -0
- data/app/views/statixite/sites/index.html.haml +4 -0
- data/app/views/statixite/sites/index.js.haml +1 -0
- data/app/views/statixite/sites/new.html.haml +45 -0
- data/app/views/statixite/sites/settings.html.haml +77 -0
- data/app/views/statixite/templates/edit.html.haml +93 -0
- data/app/views/statixite/templates/upload_files.js.haml +2 -0
- data/config/routes.rb +24 -0
- data/db/migrate/20150525171543_create_statixite_sites.rb +15 -0
- data/db/migrate/20150530041055_create_statixite_posts.rb +14 -0
- data/db/migrate/20150610024047_create_statixite_deployments.rb +11 -0
- data/db/migrate/20151013131224_create_statixite_media.rb +10 -0
- data/lib/assets/templates.yaml +734 -0
- data/lib/generators/statixite/statixite_generator.rb +49 -0
- data/lib/statixite.rb +14 -0
- data/lib/statixite/cloud_sync.rb +104 -0
- data/lib/statixite/engine.rb +49 -0
- data/lib/statixite/version.rb +3 -0
- data/lib/tasks/statixite_tasks.rake +4 -0
- data/vendor/assets/bower_components/bootstrap/CHANGELOG.md +5 -0
- data/vendor/assets/bower_components/bootstrap/Gruntfile.js +533 -0
- data/vendor/assets/bower_components/bootstrap/LICENSE +21 -0
- data/vendor/assets/bower_components/bootstrap/README.md +139 -0
- data/vendor/assets/bower_components/bootstrap/bower.json +34 -0
- data/vendor/assets/bower_components/bootstrap/dist/css/bootstrap-theme.css +587 -0
- data/vendor/assets/bower_components/bootstrap/dist/css/bootstrap-theme.css.map +1 -0
- data/vendor/assets/bower_components/bootstrap/dist/css/bootstrap-theme.min.css +6 -0
- data/vendor/assets/bower_components/bootstrap/dist/css/bootstrap-theme.min.css.map +1 -0
- data/vendor/assets/bower_components/bootstrap/dist/css/bootstrap.css +6760 -0
- data/vendor/assets/bower_components/bootstrap/dist/css/bootstrap.css.map +1 -0
- data/vendor/assets/bower_components/bootstrap/dist/css/bootstrap.min.css +6 -0
- data/vendor/assets/bower_components/bootstrap/dist/css/bootstrap.min.css.map +1 -0
- data/vendor/assets/bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.eot +0 -0
- data/vendor/assets/bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.svg +288 -0
- data/vendor/assets/bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.ttf +0 -0
- data/vendor/assets/bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.woff +0 -0
- data/vendor/assets/bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.woff2 +0 -0
- data/vendor/assets/bower_components/bootstrap/dist/js/bootstrap.js +2363 -0
- data/vendor/assets/bower_components/bootstrap/dist/js/bootstrap.min.js +7 -0
- data/vendor/assets/bower_components/bootstrap/dist/js/npm.js +13 -0
- data/vendor/assets/bower_components/bootstrap/fonts/glyphicons-halflings-regular.eot +0 -0
- data/vendor/assets/bower_components/bootstrap/fonts/glyphicons-halflings-regular.svg +288 -0
- data/vendor/assets/bower_components/bootstrap/fonts/glyphicons-halflings-regular.ttf +0 -0
- data/vendor/assets/bower_components/bootstrap/fonts/glyphicons-halflings-regular.woff +0 -0
- data/vendor/assets/bower_components/bootstrap/fonts/glyphicons-halflings-regular.woff2 +0 -0
- data/vendor/assets/bower_components/bootstrap/grunt/bs-commonjs-generator.js +30 -0
- data/vendor/assets/bower_components/bootstrap/grunt/bs-glyphicons-data-generator.js +42 -0
- data/vendor/assets/bower_components/bootstrap/grunt/bs-lessdoc-parser.js +237 -0
- data/vendor/assets/bower_components/bootstrap/grunt/bs-raw-files-generator.js +44 -0
- data/vendor/assets/bower_components/bootstrap/grunt/configBridge.json +46 -0
- data/vendor/assets/bower_components/bootstrap/grunt/sauce_browsers.yml +82 -0
- data/vendor/assets/bower_components/bootstrap/js/affix.js +162 -0
- data/vendor/assets/bower_components/bootstrap/js/alert.js +94 -0
- data/vendor/assets/bower_components/bootstrap/js/button.js +120 -0
- data/vendor/assets/bower_components/bootstrap/js/carousel.js +237 -0
- data/vendor/assets/bower_components/bootstrap/js/collapse.js +211 -0
- data/vendor/assets/bower_components/bootstrap/js/dropdown.js +165 -0
- data/vendor/assets/bower_components/bootstrap/js/modal.js +337 -0
- data/vendor/assets/bower_components/bootstrap/js/popover.js +108 -0
- data/vendor/assets/bower_components/bootstrap/js/scrollspy.js +172 -0
- data/vendor/assets/bower_components/bootstrap/js/tab.js +155 -0
- data/vendor/assets/bower_components/bootstrap/js/tooltip.js +514 -0
- data/vendor/assets/bower_components/bootstrap/js/transition.js +59 -0
- data/vendor/assets/bower_components/bootstrap/less/alerts.less +73 -0
- data/vendor/assets/bower_components/bootstrap/less/badges.less +66 -0
- data/vendor/assets/bower_components/bootstrap/less/bootstrap.less +56 -0
- data/vendor/assets/bower_components/bootstrap/less/breadcrumbs.less +26 -0
- data/vendor/assets/bower_components/bootstrap/less/button-groups.less +244 -0
- data/vendor/assets/bower_components/bootstrap/less/buttons.less +166 -0
- data/vendor/assets/bower_components/bootstrap/less/carousel.less +270 -0
- data/vendor/assets/bower_components/bootstrap/less/close.less +34 -0
- data/vendor/assets/bower_components/bootstrap/less/code.less +69 -0
- data/vendor/assets/bower_components/bootstrap/less/component-animations.less +33 -0
- data/vendor/assets/bower_components/bootstrap/less/dropdowns.less +216 -0
- data/vendor/assets/bower_components/bootstrap/less/forms.less +613 -0
- data/vendor/assets/bower_components/bootstrap/less/glyphicons.less +305 -0
- data/vendor/assets/bower_components/bootstrap/less/grid.less +84 -0
- data/vendor/assets/bower_components/bootstrap/less/input-groups.less +171 -0
- data/vendor/assets/bower_components/bootstrap/less/jumbotron.less +54 -0
- data/vendor/assets/bower_components/bootstrap/less/labels.less +64 -0
- data/vendor/assets/bower_components/bootstrap/less/list-group.less +130 -0
- data/vendor/assets/bower_components/bootstrap/less/media.less +66 -0
- data/vendor/assets/bower_components/bootstrap/less/mixins.less +40 -0
- data/vendor/assets/bower_components/bootstrap/less/mixins/alerts.less +14 -0
- data/vendor/assets/bower_components/bootstrap/less/mixins/background-variant.less +9 -0
- data/vendor/assets/bower_components/bootstrap/less/mixins/border-radius.less +18 -0
- data/vendor/assets/bower_components/bootstrap/less/mixins/buttons.less +65 -0
- data/vendor/assets/bower_components/bootstrap/less/mixins/center-block.less +7 -0
- data/vendor/assets/bower_components/bootstrap/less/mixins/clearfix.less +22 -0
- data/vendor/assets/bower_components/bootstrap/less/mixins/forms.less +85 -0
- data/vendor/assets/bower_components/bootstrap/less/mixins/gradients.less +59 -0
- data/vendor/assets/bower_components/bootstrap/less/mixins/grid-framework.less +91 -0
- data/vendor/assets/bower_components/bootstrap/less/mixins/grid.less +122 -0
- data/vendor/assets/bower_components/bootstrap/less/mixins/hide-text.less +21 -0
- data/vendor/assets/bower_components/bootstrap/less/mixins/image.less +33 -0
- data/vendor/assets/bower_components/bootstrap/less/mixins/labels.less +12 -0
- data/vendor/assets/bower_components/bootstrap/less/mixins/list-group.less +30 -0
- data/vendor/assets/bower_components/bootstrap/less/mixins/nav-divider.less +10 -0
- data/vendor/assets/bower_components/bootstrap/less/mixins/nav-vertical-align.less +9 -0
- data/vendor/assets/bower_components/bootstrap/less/mixins/opacity.less +8 -0
- data/vendor/assets/bower_components/bootstrap/less/mixins/pagination.less +24 -0
- data/vendor/assets/bower_components/bootstrap/less/mixins/panels.less +24 -0
- data/vendor/assets/bower_components/bootstrap/less/mixins/progress-bar.less +10 -0
- data/vendor/assets/bower_components/bootstrap/less/mixins/reset-filter.less +8 -0
- data/vendor/assets/bower_components/bootstrap/less/mixins/reset-text.less +18 -0
- data/vendor/assets/bower_components/bootstrap/less/mixins/resize.less +6 -0
- data/vendor/assets/bower_components/bootstrap/less/mixins/responsive-visibility.less +15 -0
- data/vendor/assets/bower_components/bootstrap/less/mixins/size.less +10 -0
- data/vendor/assets/bower_components/bootstrap/less/mixins/tab-focus.less +9 -0
- data/vendor/assets/bower_components/bootstrap/less/mixins/table-row.less +28 -0
- data/vendor/assets/bower_components/bootstrap/less/mixins/text-emphasis.less +9 -0
- data/vendor/assets/bower_components/bootstrap/less/mixins/text-overflow.less +8 -0
- data/vendor/assets/bower_components/bootstrap/less/mixins/vendor-prefixes.less +227 -0
- data/vendor/assets/bower_components/bootstrap/less/modals.less +150 -0
- data/vendor/assets/bower_components/bootstrap/less/navbar.less +660 -0
- data/vendor/assets/bower_components/bootstrap/less/navs.less +242 -0
- data/vendor/assets/bower_components/bootstrap/less/normalize.less +424 -0
- data/vendor/assets/bower_components/bootstrap/less/pager.less +54 -0
- data/vendor/assets/bower_components/bootstrap/less/pagination.less +89 -0
- data/vendor/assets/bower_components/bootstrap/less/panels.less +271 -0
- data/vendor/assets/bower_components/bootstrap/less/popovers.less +131 -0
- data/vendor/assets/bower_components/bootstrap/less/print.less +101 -0
- data/vendor/assets/bower_components/bootstrap/less/progress-bars.less +87 -0
- data/vendor/assets/bower_components/bootstrap/less/responsive-embed.less +35 -0
- data/vendor/assets/bower_components/bootstrap/less/responsive-utilities.less +194 -0
- data/vendor/assets/bower_components/bootstrap/less/scaffolding.less +161 -0
- data/vendor/assets/bower_components/bootstrap/less/tables.less +234 -0
- data/vendor/assets/bower_components/bootstrap/less/theme.less +291 -0
- data/vendor/assets/bower_components/bootstrap/less/thumbnails.less +36 -0
- data/vendor/assets/bower_components/bootstrap/less/tooltip.less +101 -0
- data/vendor/assets/bower_components/bootstrap/less/type.less +302 -0
- data/vendor/assets/bower_components/bootstrap/less/utilities.less +55 -0
- data/vendor/assets/bower_components/bootstrap/less/variables.less +869 -0
- data/vendor/assets/bower_components/bootstrap/less/wells.less +29 -0
- data/vendor/assets/bower_components/bootstrap/nuget/MyGet.ps1 +8 -0
- data/vendor/assets/bower_components/bootstrap/nuget/bootstrap.less.nuspec +28 -0
- data/vendor/assets/bower_components/bootstrap/nuget/bootstrap.nuspec +28 -0
- data/vendor/assets/bower_components/bootstrap/package.js +32 -0
- data/vendor/assets/bower_components/bootstrap/package.json +87 -0
- data/vendor/assets/bower_components/jquery/AUTHORS.txt +275 -0
- data/vendor/assets/bower_components/jquery/LICENSE.txt +36 -0
- data/vendor/assets/bower_components/jquery/README.md +5 -0
- data/vendor/assets/bower_components/jquery/bower.json +14 -0
- data/vendor/assets/bower_components/jquery/dist/jquery.js +9831 -0
- data/vendor/assets/bower_components/jquery/dist/jquery.min.js +4 -0
- data/vendor/assets/bower_components/jquery/dist/jquery.min.map +1 -0
- data/vendor/assets/bower_components/jquery/src/ajax.js +845 -0
- data/vendor/assets/bower_components/jquery/src/ajax/jsonp.js +100 -0
- data/vendor/assets/bower_components/jquery/src/ajax/load.js +83 -0
- data/vendor/assets/bower_components/jquery/src/ajax/parseJSON.js +13 -0
- data/vendor/assets/bower_components/jquery/src/ajax/parseXML.js +27 -0
- data/vendor/assets/bower_components/jquery/src/ajax/script.js +68 -0
- data/vendor/assets/bower_components/jquery/src/ajax/var/location.js +3 -0
- data/vendor/assets/bower_components/jquery/src/ajax/var/nonce.js +5 -0
- data/vendor/assets/bower_components/jquery/src/ajax/var/rquery.js +3 -0
- data/vendor/assets/bower_components/jquery/src/ajax/xhr.js +167 -0
- data/vendor/assets/bower_components/jquery/src/attributes.js +11 -0
- data/vendor/assets/bower_components/jquery/src/attributes/attr.js +142 -0
- data/vendor/assets/bower_components/jquery/src/attributes/classes.js +177 -0
- data/vendor/assets/bower_components/jquery/src/attributes/prop.js +109 -0
- data/vendor/assets/bower_components/jquery/src/attributes/support.js +36 -0
- data/vendor/assets/bower_components/jquery/src/attributes/val.js +170 -0
- data/vendor/assets/bower_components/jquery/src/callbacks.js +232 -0
- data/vendor/assets/bower_components/jquery/src/core.js +489 -0
- data/vendor/assets/bower_components/jquery/src/core/access.js +65 -0
- data/vendor/assets/bower_components/jquery/src/core/init.js +134 -0
- data/vendor/assets/bower_components/jquery/src/core/parseHTML.js +49 -0
- data/vendor/assets/bower_components/jquery/src/core/ready.js +103 -0
- data/vendor/assets/bower_components/jquery/src/core/support.js +18 -0
- data/vendor/assets/bower_components/jquery/src/core/var/rsingleTag.js +5 -0
- data/vendor/assets/bower_components/jquery/src/css.js +515 -0
- data/vendor/assets/bower_components/jquery/src/css/addGetHookIf.js +24 -0
- data/vendor/assets/bower_components/jquery/src/css/adjustCSS.js +65 -0
- data/vendor/assets/bower_components/jquery/src/css/curCSS.js +57 -0
- data/vendor/assets/bower_components/jquery/src/css/defaultDisplay.js +72 -0
- data/vendor/assets/bower_components/jquery/src/css/hiddenVisibleSelectors.js +18 -0
- data/vendor/assets/bower_components/jquery/src/css/showHide.js +48 -0
- data/vendor/assets/bower_components/jquery/src/css/support.js +121 -0
- data/vendor/assets/bower_components/jquery/src/css/var/cssExpand.js +3 -0
- data/vendor/assets/bower_components/jquery/src/css/var/getStyles.js +15 -0
- data/vendor/assets/bower_components/jquery/src/css/var/isHidden.js +16 -0
- data/vendor/assets/bower_components/jquery/src/css/var/rmargin.js +3 -0
- data/vendor/assets/bower_components/jquery/src/css/var/rnumnonpx.js +5 -0
- data/vendor/assets/bower_components/jquery/src/css/var/swap.js +24 -0
- data/vendor/assets/bower_components/jquery/src/data.js +187 -0
- data/vendor/assets/bower_components/jquery/src/data/Data.js +200 -0
- data/vendor/assets/bower_components/jquery/src/data/accepts.js +20 -0
- data/vendor/assets/bower_components/jquery/src/data/support.js +23 -0
- data/vendor/assets/bower_components/jquery/src/data/var/acceptData.js +18 -0
- data/vendor/assets/bower_components/jquery/src/data/var/dataPriv.js +5 -0
- data/vendor/assets/bower_components/jquery/src/data/var/dataUser.js +5 -0
- data/vendor/assets/bower_components/jquery/src/deferred.js +158 -0
- data/vendor/assets/bower_components/jquery/src/deprecated.js +32 -0
- data/vendor/assets/bower_components/jquery/src/dimensions.js +54 -0
- data/vendor/assets/bower_components/jquery/src/effects.js +629 -0
- data/vendor/assets/bower_components/jquery/src/effects/Tween.js +121 -0
- data/vendor/assets/bower_components/jquery/src/effects/animatedSelector.js +13 -0
- data/vendor/assets/bower_components/jquery/src/effects/support.js +58 -0
- data/vendor/assets/bower_components/jquery/src/event.js +710 -0
- data/vendor/assets/bower_components/jquery/src/event/ajax.js +20 -0
- data/vendor/assets/bower_components/jquery/src/event/alias.js +27 -0
- data/vendor/assets/bower_components/jquery/src/event/focusin.js +53 -0
- data/vendor/assets/bower_components/jquery/src/event/support.js +9 -0
- data/vendor/assets/bower_components/jquery/src/event/trigger.js +199 -0
- data/vendor/assets/bower_components/jquery/src/exports/amd.js +24 -0
- data/vendor/assets/bower_components/jquery/src/exports/global.js +26 -0
- data/vendor/assets/bower_components/jquery/src/intro.js +44 -0
- data/vendor/assets/bower_components/jquery/src/jquery.js +37 -0
- data/vendor/assets/bower_components/jquery/src/manipulation.js +481 -0
- data/vendor/assets/bower_components/jquery/src/manipulation/_evalUrl.js +20 -0
- data/vendor/assets/bower_components/jquery/src/manipulation/buildFragment.js +102 -0
- data/vendor/assets/bower_components/jquery/src/manipulation/createSafeFragment.js +20 -0
- data/vendor/assets/bower_components/jquery/src/manipulation/getAll.js +21 -0
- data/vendor/assets/bower_components/jquery/src/manipulation/setGlobalEval.js +20 -0
- data/vendor/assets/bower_components/jquery/src/manipulation/support.js +33 -0
- data/vendor/assets/bower_components/jquery/src/manipulation/var/nodeNames.js +5 -0
- data/vendor/assets/bower_components/jquery/src/manipulation/var/rcheckableType.js +3 -0
- data/vendor/assets/bower_components/jquery/src/manipulation/var/rleadingWhitespace.js +3 -0
- data/vendor/assets/bower_components/jquery/src/manipulation/var/rscriptType.js +3 -0
- data/vendor/assets/bower_components/jquery/src/manipulation/var/rtagName.js +3 -0
- data/vendor/assets/bower_components/jquery/src/manipulation/wrapMap.js +27 -0
- data/vendor/assets/bower_components/jquery/src/offset.js +221 -0
- data/vendor/assets/bower_components/jquery/src/outro.js +2 -0
- data/vendor/assets/bower_components/jquery/src/queue.js +143 -0
- data/vendor/assets/bower_components/jquery/src/queue/delay.js +22 -0
- data/vendor/assets/bower_components/jquery/src/selector-native.js +211 -0
- data/vendor/assets/bower_components/jquery/src/selector-sizzle.js +14 -0
- data/vendor/assets/bower_components/jquery/src/selector.js +1 -0
- data/vendor/assets/bower_components/jquery/src/serialize.js +125 -0
- data/vendor/assets/bower_components/jquery/src/support.js +63 -0
- data/vendor/assets/bower_components/jquery/src/traversing.js +175 -0
- data/vendor/assets/bower_components/jquery/src/traversing/findFilter.js +100 -0
- data/vendor/assets/bower_components/jquery/src/traversing/var/dir.js +20 -0
- data/vendor/assets/bower_components/jquery/src/traversing/var/rneedsContext.js +6 -0
- data/vendor/assets/bower_components/jquery/src/traversing/var/siblings.js +15 -0
- data/vendor/assets/bower_components/jquery/src/var/arr.js +3 -0
- data/vendor/assets/bower_components/jquery/src/var/class2type.js +5 -0
- data/vendor/assets/bower_components/jquery/src/var/concat.js +5 -0
- data/vendor/assets/bower_components/jquery/src/var/deletedIds.js +3 -0
- data/vendor/assets/bower_components/jquery/src/var/document.js +3 -0
- data/vendor/assets/bower_components/jquery/src/var/documentElement.js +5 -0
- data/vendor/assets/bower_components/jquery/src/var/hasOwn.js +5 -0
- data/vendor/assets/bower_components/jquery/src/var/indexOf.js +5 -0
- data/vendor/assets/bower_components/jquery/src/var/pnum.js +3 -0
- data/vendor/assets/bower_components/jquery/src/var/push.js +5 -0
- data/vendor/assets/bower_components/jquery/src/var/rcssNum.js +7 -0
- data/vendor/assets/bower_components/jquery/src/var/rnotwhite.js +3 -0
- data/vendor/assets/bower_components/jquery/src/var/slice.js +5 -0
- data/vendor/assets/bower_components/jquery/src/var/support.js +5 -0
- data/vendor/assets/bower_components/jquery/src/var/toString.js +5 -0
- data/vendor/assets/bower_components/jquery/src/wrap.js +79 -0
- data/vendor/assets/bower_components/jsoneditor/CONTRIBUTING.md +15 -0
- data/vendor/assets/bower_components/jsoneditor/HISTORY.md +457 -0
- data/vendor/assets/bower_components/jsoneditor/LICENSE +176 -0
- data/vendor/assets/bower_components/jsoneditor/NOTICE +17 -0
- data/vendor/assets/bower_components/jsoneditor/README.md +155 -0
- data/vendor/assets/bower_components/jsoneditor/bower.json +32 -0
- data/vendor/assets/bower_components/jsoneditor/dist/img/jsoneditor-icons.svg +893 -0
- data/vendor/assets/bower_components/jsoneditor/dist/jsoneditor-minimalist.js +9418 -0
- data/vendor/assets/bower_components/jsoneditor/dist/jsoneditor-minimalist.map +1 -0
- data/vendor/assets/bower_components/jsoneditor/dist/jsoneditor-minimalist.min.js +35 -0
- data/vendor/assets/bower_components/jsoneditor/dist/jsoneditor.css.less +879 -0
- data/vendor/assets/bower_components/jsoneditor/dist/jsoneditor.js +35095 -0
- data/vendor/assets/bower_components/jsoneditor/dist/jsoneditor.map +1 -0
- data/vendor/assets/bower_components/jsoneditor/dist/jsoneditor.min.css +1 -0
- data/vendor/assets/bower_components/jsoneditor/dist/jsoneditor.min.js +48 -0
- data/vendor/assets/bower_components/jsoneditor/dist/which files do I need.md +41 -0
- data/vendor/assets/bower_components/jsoneditor/docs/api.md +286 -0
- data/vendor/assets/bower_components/jsoneditor/docs/shortcut_keys.md +38 -0
- data/vendor/assets/bower_components/jsoneditor/docs/usage.md +117 -0
- data/vendor/assets/bower_components/jsoneditor/examples/01_basic_usage.html +49 -0
- data/vendor/assets/bower_components/jsoneditor/examples/02_viewer.html +44 -0
- data/vendor/assets/bower_components/jsoneditor/examples/03_switch_mode.html +66 -0
- data/vendor/assets/bower_components/jsoneditor/examples/04_load_and_save.html +62 -0
- data/vendor/assets/bower_components/jsoneditor/examples/05_custom_fields_editable.html +63 -0
- data/vendor/assets/bower_components/jsoneditor/examples/06_custom_styling.html +51 -0
- data/vendor/assets/bower_components/jsoneditor/examples/07_json_schema_validation.html +71 -0
- data/vendor/assets/bower_components/jsoneditor/examples/css/darktheme.css +76 -0
- data/vendor/assets/bower_components/jsoneditor/examples/requirejs_demo/requirejs_demo.html +21 -0
- data/vendor/assets/bower_components/jsoneditor/examples/requirejs_demo/scripts/main.js +25 -0
- data/vendor/assets/bower_components/jsoneditor/examples/requirejs_demo/scripts/require.js +36 -0
- data/vendor/assets/bower_components/jsoneditor/index.js +1 -0
- data/vendor/assets/bower_components/jsoneditor/package.json +41 -0
- data/vendor/assets/bower_components/jsoneditor/src/css/contextmenu.css +233 -0
- data/vendor/assets/bower_components/jsoneditor/src/css/img/description.txt +14 -0
- data/vendor/assets/bower_components/jsoneditor/src/css/img/jsoneditor-icons.svg +893 -0
- data/vendor/assets/bower_components/jsoneditor/src/css/jsoneditor.css +433 -0
- data/vendor/assets/bower_components/jsoneditor/src/css/menu.css +110 -0
- data/vendor/assets/bower_components/jsoneditor/src/css/searchbox.css +75 -0
- data/vendor/assets/bower_components/jsoneditor/src/docs/which files do I need.md +41 -0
- data/vendor/assets/bower_components/jsoneditor/src/js/ContextMenu.js +455 -0
- data/vendor/assets/bower_components/jsoneditor/src/js/Highlighter.js +84 -0
- data/vendor/assets/bower_components/jsoneditor/src/js/History.js +252 -0
- data/vendor/assets/bower_components/jsoneditor/src/js/JSONEditor.js +371 -0
- data/vendor/assets/bower_components/jsoneditor/src/js/Node.js +3400 -0
- data/vendor/assets/bower_components/jsoneditor/src/js/SearchBox.js +295 -0
- data/vendor/assets/bower_components/jsoneditor/src/js/ace/index.js +9 -0
- data/vendor/assets/bower_components/jsoneditor/src/js/ace/theme-jsoneditor.js +144 -0
- data/vendor/assets/bower_components/jsoneditor/src/js/appendNodeFactory.js +226 -0
- data/vendor/assets/bower_components/jsoneditor/src/js/assets/jsonlint/README.md +15 -0
- data/vendor/assets/bower_components/jsoneditor/src/js/assets/jsonlint/jsonlint.js +418 -0
- data/vendor/assets/bower_components/jsoneditor/src/js/header.js +29 -0
- data/vendor/assets/bower_components/jsoneditor/src/js/modeswitcher.js +105 -0
- data/vendor/assets/bower_components/jsoneditor/src/js/textmode.js +474 -0
- data/vendor/assets/bower_components/jsoneditor/src/js/treemode.js +1150 -0
- data/vendor/assets/bower_components/jsoneditor/src/js/util.js +765 -0
- data/vendor/assets/bower_components/notifyjs/CHANGES.md +7 -0
- data/vendor/assets/bower_components/notifyjs/README.md +31 -0
- data/vendor/assets/bower_components/notifyjs/bower.json +14 -0
- data/vendor/assets/bower_components/notifyjs/dist/notify.js +586 -0
- data/vendor/assets/bower_components/notifyjs/dist/styles/metro/notify-metro.css +40 -0
- data/vendor/assets/bower_components/notifyjs/dist/styles/metro/notify-metro.js +39 -0
- data/vendor/assets/bower_components/notifyjs/examples/classes.html +49 -0
- data/vendor/assets/bower_components/notifyjs/examples/images/Mail.png +0 -0
- data/vendor/assets/bower_components/notifyjs/examples/inlines.html +111 -0
- data/vendor/assets/bower_components/notifyjs/examples/metro.html +37 -0
- data/vendor/assets/bower_components/notifyjs/examples/multi-text.html +55 -0
- data/vendor/assets/bower_components/notifyjs/examples/position.html +42 -0
- data/vendor/assets/bower_components/notifyjs/notify.jquery.json +28 -0
- data/vendor/assets/bower_components/notifyjs/package.json +18 -0
- data/vendor/assets/bower_components/vue/LICENSE +21 -0
- data/vendor/assets/bower_components/vue/bower.json +19 -0
- data/vendor/assets/bower_components/vue/dist/vue.js +10198 -0
- data/vendor/assets/bower_components/vue/dist/vue.min.js +8 -0
- data/vendor/assets/bower_components/vue/src/api/child.js +49 -0
- data/vendor/assets/bower_components/vue/src/api/data.js +159 -0
- data/vendor/assets/bower_components/vue/src/api/dom.js +226 -0
- data/vendor/assets/bower_components/vue/src/api/events.js +174 -0
- data/vendor/assets/bower_components/vue/src/api/global.js +129 -0
- data/vendor/assets/bower_components/vue/src/api/lifecycle.js +68 -0
- data/vendor/assets/bower_components/vue/src/batcher.js +98 -0
- data/vendor/assets/bower_components/vue/src/cache.js +112 -0
- data/vendor/assets/bower_components/vue/src/compiler/compile-props.js +183 -0
- data/vendor/assets/bower_components/vue/src/compiler/compile.js +630 -0
- data/vendor/assets/bower_components/vue/src/compiler/index.js +4 -0
- data/vendor/assets/bower_components/vue/src/compiler/transclude.js +144 -0
- data/vendor/assets/bower_components/vue/src/config.js +124 -0
- data/vendor/assets/bower_components/vue/src/directive.js +254 -0
- data/vendor/assets/bower_components/vue/src/directives/attr.js +59 -0
- data/vendor/assets/bower_components/vue/src/directives/class.js +70 -0
- data/vendor/assets/bower_components/vue/src/directives/cloak.js +10 -0
- data/vendor/assets/bower_components/vue/src/directives/component.js +344 -0
- data/vendor/assets/bower_components/vue/src/directives/el.js +12 -0
- data/vendor/assets/bower_components/vue/src/directives/html.js +40 -0
- data/vendor/assets/bower_components/vue/src/directives/if.js +125 -0
- data/vendor/assets/bower_components/vue/src/directives/index.js +24 -0
- data/vendor/assets/bower_components/vue/src/directives/model/checkbox.js +42 -0
- data/vendor/assets/bower_components/vue/src/directives/model/index.js +82 -0
- data/vendor/assets/bower_components/vue/src/directives/model/radio.js +33 -0
- data/vendor/assets/bower_components/vue/src/directives/model/select.js +236 -0
- data/vendor/assets/bower_components/vue/src/directives/model/text.js +132 -0
- data/vendor/assets/bower_components/vue/src/directives/on.js +59 -0
- data/vendor/assets/bower_components/vue/src/directives/prop.js +62 -0
- data/vendor/assets/bower_components/vue/src/directives/ref.js +22 -0
- data/vendor/assets/bower_components/vue/src/directives/repeat.js +770 -0
- data/vendor/assets/bower_components/vue/src/directives/show.js +8 -0
- data/vendor/assets/bower_components/vue/src/directives/style.js +110 -0
- data/vendor/assets/bower_components/vue/src/directives/text.js +14 -0
- data/vendor/assets/bower_components/vue/src/directives/transition.js +26 -0
- data/vendor/assets/bower_components/vue/src/element-directives/content.js +111 -0
- data/vendor/assets/bower_components/vue/src/element-directives/index.js +2 -0
- data/vendor/assets/bower_components/vue/src/element-directives/partial.js +73 -0
- data/vendor/assets/bower_components/vue/src/filters/array-filters.js +97 -0
- data/vendor/assets/bower_components/vue/src/filters/index.js +146 -0
- data/vendor/assets/bower_components/vue/src/instance/compile.js +200 -0
- data/vendor/assets/bower_components/vue/src/instance/events.js +139 -0
- data/vendor/assets/bower_components/vue/src/instance/init.js +89 -0
- data/vendor/assets/bower_components/vue/src/instance/misc.js +93 -0
- data/vendor/assets/bower_components/vue/src/instance/scope.js +282 -0
- data/vendor/assets/bower_components/vue/src/observer/array.js +98 -0
- data/vendor/assets/bower_components/vue/src/observer/dep.js +61 -0
- data/vendor/assets/bower_components/vue/src/observer/index.js +234 -0
- data/vendor/assets/bower_components/vue/src/observer/object.js +82 -0
- data/vendor/assets/bower_components/vue/src/parsers/directive.js +180 -0
- data/vendor/assets/bower_components/vue/src/parsers/expression.js +264 -0
- data/vendor/assets/bower_components/vue/src/parsers/path.js +348 -0
- data/vendor/assets/bower_components/vue/src/parsers/template.js +288 -0
- data/vendor/assets/bower_components/vue/src/parsers/text.js +178 -0
- data/vendor/assets/bower_components/vue/src/transition/index.js +128 -0
- data/vendor/assets/bower_components/vue/src/transition/queue.js +35 -0
- data/vendor/assets/bower_components/vue/src/transition/transition.js +357 -0
- data/vendor/assets/bower_components/vue/src/util/component.js +124 -0
- data/vendor/assets/bower_components/vue/src/util/debug.js +64 -0
- data/vendor/assets/bower_components/vue/src/util/dom.js +272 -0
- data/vendor/assets/bower_components/vue/src/util/env.js +85 -0
- data/vendor/assets/bower_components/vue/src/util/index.js +9 -0
- data/vendor/assets/bower_components/vue/src/util/lang.js +310 -0
- data/vendor/assets/bower_components/vue/src/util/options.js +357 -0
- data/vendor/assets/bower_components/vue/src/vue.js +89 -0
- data/vendor/assets/bower_components/vue/src/watcher.js +312 -0
- metadata +870 -0
@@ -0,0 +1,132 @@
|
|
1
|
+
var _ = require('../../util')
|
2
|
+
|
3
|
+
module.exports = {
|
4
|
+
|
5
|
+
bind: function () {
|
6
|
+
var self = this
|
7
|
+
var el = this.el
|
8
|
+
var isRange = el.type === 'range'
|
9
|
+
|
10
|
+
// check params
|
11
|
+
// - lazy: update model on "change" instead of "input"
|
12
|
+
var lazy = this._checkParam('lazy') != null
|
13
|
+
// - number: cast value into number when updating model.
|
14
|
+
var number = this._checkParam('number') != null
|
15
|
+
// - debounce: debounce the input listener
|
16
|
+
var debounce = parseInt(this._checkParam('debounce'), 10)
|
17
|
+
|
18
|
+
// handle composition events.
|
19
|
+
// http://blog.evanyou.me/2014/01/03/composition-event/
|
20
|
+
// skip this for Android because it handles composition
|
21
|
+
// events quite differently. Android doesn't trigger
|
22
|
+
// composition events for language input methods e.g.
|
23
|
+
// Chinese, but instead triggers them for spelling
|
24
|
+
// suggestions... (see Discussion/#162)
|
25
|
+
var composing = false
|
26
|
+
if (!_.isAndroid && !isRange) {
|
27
|
+
this.on('compositionstart', function () {
|
28
|
+
composing = true
|
29
|
+
})
|
30
|
+
this.on('compositionend', function () {
|
31
|
+
composing = false
|
32
|
+
// in IE11 the "compositionend" event fires AFTER
|
33
|
+
// the "input" event, so the input handler is blocked
|
34
|
+
// at the end... have to call it here.
|
35
|
+
//
|
36
|
+
// #1327: in lazy mode this is unecessary.
|
37
|
+
if (!lazy) {
|
38
|
+
self.listener()
|
39
|
+
}
|
40
|
+
})
|
41
|
+
}
|
42
|
+
|
43
|
+
// prevent messing with the input when user is typing,
|
44
|
+
// and force update on blur.
|
45
|
+
this.focused = false
|
46
|
+
if (!isRange) {
|
47
|
+
this.on('focus', function () {
|
48
|
+
self.focused = true
|
49
|
+
})
|
50
|
+
this.on('blur', function () {
|
51
|
+
self.focused = false
|
52
|
+
self.listener()
|
53
|
+
})
|
54
|
+
}
|
55
|
+
|
56
|
+
// Now attach the main listener
|
57
|
+
this.listener = function () {
|
58
|
+
if (composing) return
|
59
|
+
var val = number || isRange
|
60
|
+
? _.toNumber(el.value)
|
61
|
+
: el.value
|
62
|
+
self.set(val)
|
63
|
+
// force update on next tick to avoid lock & same value
|
64
|
+
// also only update when user is not typing
|
65
|
+
_.nextTick(function () {
|
66
|
+
if (self._bound && !self.focused) {
|
67
|
+
self.update(self._watcher.value)
|
68
|
+
}
|
69
|
+
})
|
70
|
+
}
|
71
|
+
if (debounce) {
|
72
|
+
this.listener = _.debounce(this.listener, debounce)
|
73
|
+
}
|
74
|
+
|
75
|
+
// Support jQuery events, since jQuery.trigger() doesn't
|
76
|
+
// trigger native events in some cases and some plugins
|
77
|
+
// rely on $.trigger()
|
78
|
+
//
|
79
|
+
// We want to make sure if a listener is attached using
|
80
|
+
// jQuery, it is also removed with jQuery, that's why
|
81
|
+
// we do the check for each directive instance and
|
82
|
+
// store that check result on itself. This also allows
|
83
|
+
// easier test coverage control by unsetting the global
|
84
|
+
// jQuery variable in tests.
|
85
|
+
this.hasjQuery = typeof jQuery === 'function'
|
86
|
+
if (this.hasjQuery) {
|
87
|
+
jQuery(el).on('change', this.listener)
|
88
|
+
if (!lazy) {
|
89
|
+
jQuery(el).on('input', this.listener)
|
90
|
+
}
|
91
|
+
} else {
|
92
|
+
this.on('change', this.listener)
|
93
|
+
if (!lazy) {
|
94
|
+
this.on('input', this.listener)
|
95
|
+
}
|
96
|
+
}
|
97
|
+
|
98
|
+
// IE9 doesn't fire input event on backspace/del/cut
|
99
|
+
if (!lazy && _.isIE9) {
|
100
|
+
this.on('cut', function () {
|
101
|
+
_.nextTick(self.listener)
|
102
|
+
})
|
103
|
+
this.on('keyup', function (e) {
|
104
|
+
if (e.keyCode === 46 || e.keyCode === 8) {
|
105
|
+
self.listener()
|
106
|
+
}
|
107
|
+
})
|
108
|
+
}
|
109
|
+
|
110
|
+
// set initial value if present
|
111
|
+
if (
|
112
|
+
el.hasAttribute('value') ||
|
113
|
+
(el.tagName === 'TEXTAREA' && el.value.trim())
|
114
|
+
) {
|
115
|
+
this._initValue = number
|
116
|
+
? _.toNumber(el.value)
|
117
|
+
: el.value
|
118
|
+
}
|
119
|
+
},
|
120
|
+
|
121
|
+
update: function (value) {
|
122
|
+
this.el.value = _.toString(value)
|
123
|
+
},
|
124
|
+
|
125
|
+
unbind: function () {
|
126
|
+
var el = this.el
|
127
|
+
if (this.hasjQuery) {
|
128
|
+
jQuery(el).off('change', this.listener)
|
129
|
+
jQuery(el).off('input', this.listener)
|
130
|
+
}
|
131
|
+
}
|
132
|
+
}
|
@@ -0,0 +1,59 @@
|
|
1
|
+
var _ = require('../util')
|
2
|
+
|
3
|
+
module.exports = {
|
4
|
+
|
5
|
+
acceptStatement: true,
|
6
|
+
priority: 700,
|
7
|
+
|
8
|
+
bind: function () {
|
9
|
+
// deal with iframes
|
10
|
+
if (
|
11
|
+
this.el.tagName === 'IFRAME' &&
|
12
|
+
this.arg !== 'load'
|
13
|
+
) {
|
14
|
+
var self = this
|
15
|
+
this.iframeBind = function () {
|
16
|
+
_.on(self.el.contentWindow, self.arg, self.handler)
|
17
|
+
}
|
18
|
+
this.on('load', this.iframeBind)
|
19
|
+
}
|
20
|
+
},
|
21
|
+
|
22
|
+
update: function (handler) {
|
23
|
+
if (typeof handler !== 'function') {
|
24
|
+
process.env.NODE_ENV !== 'production' && _.warn(
|
25
|
+
'Directive v-on="' + this.arg + ': ' +
|
26
|
+
this.expression + '" expects a function value, ' +
|
27
|
+
'got ' + handler
|
28
|
+
)
|
29
|
+
return
|
30
|
+
}
|
31
|
+
this.reset()
|
32
|
+
var vm = this.vm
|
33
|
+
this.handler = function (e) {
|
34
|
+
e.targetVM = vm
|
35
|
+
vm.$event = e
|
36
|
+
var res = handler(e)
|
37
|
+
vm.$event = null
|
38
|
+
return res
|
39
|
+
}
|
40
|
+
if (this.iframeBind) {
|
41
|
+
this.iframeBind()
|
42
|
+
} else {
|
43
|
+
_.on(this.el, this.arg, this.handler)
|
44
|
+
}
|
45
|
+
},
|
46
|
+
|
47
|
+
reset: function () {
|
48
|
+
var el = this.iframeBind
|
49
|
+
? this.el.contentWindow
|
50
|
+
: this.el
|
51
|
+
if (this.handler) {
|
52
|
+
_.off(el, this.arg, this.handler)
|
53
|
+
}
|
54
|
+
},
|
55
|
+
|
56
|
+
unbind: function () {
|
57
|
+
this.reset()
|
58
|
+
}
|
59
|
+
}
|
@@ -0,0 +1,62 @@
|
|
1
|
+
// NOTE: the prop internal directive is compiled and linked
|
2
|
+
// during _initScope(), before the created hook is called.
|
3
|
+
// The purpose is to make the initial prop values available
|
4
|
+
// inside `created` hooks and `data` functions.
|
5
|
+
|
6
|
+
var _ = require('../util')
|
7
|
+
var Watcher = require('../watcher')
|
8
|
+
var bindingModes = require('../config')._propBindingModes
|
9
|
+
|
10
|
+
module.exports = {
|
11
|
+
|
12
|
+
bind: function () {
|
13
|
+
|
14
|
+
var child = this.vm
|
15
|
+
var parent = child._context
|
16
|
+
// passed in from compiler directly
|
17
|
+
var prop = this._descriptor
|
18
|
+
var childKey = prop.path
|
19
|
+
var parentKey = prop.parentPath
|
20
|
+
|
21
|
+
this.parentWatcher = new Watcher(
|
22
|
+
parent,
|
23
|
+
parentKey,
|
24
|
+
function (val) {
|
25
|
+
if (_.assertProp(prop, val)) {
|
26
|
+
child[childKey] = val
|
27
|
+
}
|
28
|
+
}, { sync: true }
|
29
|
+
)
|
30
|
+
|
31
|
+
// set the child initial value.
|
32
|
+
var value = this.parentWatcher.value
|
33
|
+
if (childKey === '$data') {
|
34
|
+
child._data = value
|
35
|
+
} else {
|
36
|
+
_.initProp(child, prop, value)
|
37
|
+
}
|
38
|
+
|
39
|
+
// setup two-way binding
|
40
|
+
if (prop.mode === bindingModes.TWO_WAY) {
|
41
|
+
// important: defer the child watcher creation until
|
42
|
+
// the created hook (after data observation)
|
43
|
+
var self = this
|
44
|
+
child.$once('hook:created', function () {
|
45
|
+
self.childWatcher = new Watcher(
|
46
|
+
child,
|
47
|
+
childKey,
|
48
|
+
function (val) {
|
49
|
+
parent.$set(parentKey, val)
|
50
|
+
}, { sync: true }
|
51
|
+
)
|
52
|
+
})
|
53
|
+
}
|
54
|
+
},
|
55
|
+
|
56
|
+
unbind: function () {
|
57
|
+
this.parentWatcher.teardown()
|
58
|
+
if (this.childWatcher) {
|
59
|
+
this.childWatcher.teardown()
|
60
|
+
}
|
61
|
+
}
|
62
|
+
}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
var _ = require('../util')
|
2
|
+
|
3
|
+
module.exports = {
|
4
|
+
|
5
|
+
isLiteral: true,
|
6
|
+
|
7
|
+
bind: function () {
|
8
|
+
var vm = this.el.__vue__
|
9
|
+
if (!vm) {
|
10
|
+
process.env.NODE_ENV !== 'production' && _.warn(
|
11
|
+
'v-ref should only be used on a component root element.'
|
12
|
+
)
|
13
|
+
return
|
14
|
+
}
|
15
|
+
// If we get here, it means this is a `v-ref` on a
|
16
|
+
// child, because parent scope `v-ref` is stripped in
|
17
|
+
// `v-component` already. So we just record our own ref
|
18
|
+
// here - it will overwrite parent ref in `v-component`,
|
19
|
+
// if any.
|
20
|
+
vm._refID = this.expression
|
21
|
+
}
|
22
|
+
}
|
@@ -0,0 +1,770 @@
|
|
1
|
+
var _ = require('../util')
|
2
|
+
var config = require('../config')
|
3
|
+
var isObject = _.isObject
|
4
|
+
var isPlainObject = _.isPlainObject
|
5
|
+
var textParser = require('../parsers/text')
|
6
|
+
var expParser = require('../parsers/expression')
|
7
|
+
var templateParser = require('../parsers/template')
|
8
|
+
var compiler = require('../compiler')
|
9
|
+
var uid = 0
|
10
|
+
|
11
|
+
// async component resolution states
|
12
|
+
var UNRESOLVED = 0
|
13
|
+
var PENDING = 1
|
14
|
+
var RESOLVED = 2
|
15
|
+
var ABORTED = 3
|
16
|
+
|
17
|
+
module.exports = {
|
18
|
+
|
19
|
+
/**
|
20
|
+
* Setup.
|
21
|
+
*/
|
22
|
+
|
23
|
+
bind: function () {
|
24
|
+
|
25
|
+
// some helpful tips...
|
26
|
+
/* istanbul ignore if */
|
27
|
+
if (
|
28
|
+
process.env.NODE_ENV !== 'production' &&
|
29
|
+
this.el.tagName === 'OPTION' &&
|
30
|
+
this.el.parentNode && this.el.parentNode.__v_model
|
31
|
+
) {
|
32
|
+
_.warn(
|
33
|
+
'Don\'t use v-repeat for v-model options; ' +
|
34
|
+
'use the `options` param instead: ' +
|
35
|
+
'http://vuejs.org/guide/forms.html#Dynamic_Select_Options'
|
36
|
+
)
|
37
|
+
}
|
38
|
+
|
39
|
+
// support for item in array syntax
|
40
|
+
var inMatch = this.expression.match(/(.*) in (.*)/)
|
41
|
+
if (inMatch) {
|
42
|
+
this.arg = inMatch[1]
|
43
|
+
this._watcherExp = inMatch[2]
|
44
|
+
}
|
45
|
+
// uid as a cache identifier
|
46
|
+
this.id = '__v_repeat_' + (++uid)
|
47
|
+
|
48
|
+
// setup anchor nodes
|
49
|
+
this.start = _.createAnchor('v-repeat-start')
|
50
|
+
this.end = _.createAnchor('v-repeat-end')
|
51
|
+
_.replace(this.el, this.end)
|
52
|
+
_.before(this.start, this.end)
|
53
|
+
|
54
|
+
// check if this is a block repeat
|
55
|
+
this.template = _.isTemplate(this.el)
|
56
|
+
? templateParser.parse(this.el, true)
|
57
|
+
: this.el
|
58
|
+
|
59
|
+
// check for trackby param
|
60
|
+
this.idKey = this._checkParam('track-by')
|
61
|
+
// check for transition stagger
|
62
|
+
var stagger = +this._checkParam('stagger')
|
63
|
+
this.enterStagger = +this._checkParam('enter-stagger') || stagger
|
64
|
+
this.leaveStagger = +this._checkParam('leave-stagger') || stagger
|
65
|
+
|
66
|
+
// check for v-ref/v-el
|
67
|
+
this.refID = this._checkParam(config.prefix + 'ref')
|
68
|
+
this.elID = this._checkParam(config.prefix + 'el')
|
69
|
+
|
70
|
+
// check other directives that need to be handled
|
71
|
+
// at v-repeat level
|
72
|
+
this.checkIf()
|
73
|
+
this.checkComponent()
|
74
|
+
|
75
|
+
// create cache object
|
76
|
+
this.cache = Object.create(null)
|
77
|
+
},
|
78
|
+
|
79
|
+
/**
|
80
|
+
* Warn against v-if usage.
|
81
|
+
*/
|
82
|
+
|
83
|
+
checkIf: function () {
|
84
|
+
if (_.attr(this.el, 'if') !== null) {
|
85
|
+
process.env.NODE_ENV !== 'production' && _.warn(
|
86
|
+
'Don\'t use v-if with v-repeat. ' +
|
87
|
+
'Use v-show or the "filterBy" filter instead.'
|
88
|
+
)
|
89
|
+
}
|
90
|
+
},
|
91
|
+
|
92
|
+
/**
|
93
|
+
* Check the component constructor to use for repeated
|
94
|
+
* instances. If static we resolve it now, otherwise it
|
95
|
+
* needs to be resolved at build time with actual data.
|
96
|
+
*/
|
97
|
+
|
98
|
+
checkComponent: function () {
|
99
|
+
this.componentState = UNRESOLVED
|
100
|
+
var options = this.vm.$options
|
101
|
+
var id = _.checkComponent(this.el, options)
|
102
|
+
if (!id) {
|
103
|
+
// default constructor
|
104
|
+
this.Component = _.Vue
|
105
|
+
// inline repeats should inherit
|
106
|
+
this.inline = true
|
107
|
+
// important: transclude with no options, just
|
108
|
+
// to ensure block start and block end
|
109
|
+
this.template = compiler.transclude(this.template)
|
110
|
+
var copy = _.extend({}, options)
|
111
|
+
copy._asComponent = false
|
112
|
+
this._linkFn = compiler.compile(this.template, copy)
|
113
|
+
} else {
|
114
|
+
this.Component = null
|
115
|
+
this.asComponent = true
|
116
|
+
// check inline-template
|
117
|
+
if (this._checkParam('inline-template') !== null) {
|
118
|
+
// extract inline template as a DocumentFragment
|
119
|
+
this.inlineTemplate = _.extractContent(this.el, true)
|
120
|
+
}
|
121
|
+
var tokens = textParser.parse(id)
|
122
|
+
if (tokens) {
|
123
|
+
// dynamic component to be resolved later
|
124
|
+
var componentExp = textParser.tokensToExp(tokens)
|
125
|
+
this.componentGetter = expParser.parse(componentExp).get
|
126
|
+
} else {
|
127
|
+
// static
|
128
|
+
this.componentId = id
|
129
|
+
this.pendingData = null
|
130
|
+
}
|
131
|
+
}
|
132
|
+
},
|
133
|
+
|
134
|
+
resolveComponent: function () {
|
135
|
+
this.componentState = PENDING
|
136
|
+
this.vm._resolveComponent(this.componentId, _.bind(function (Component) {
|
137
|
+
if (this.componentState === ABORTED) {
|
138
|
+
return
|
139
|
+
}
|
140
|
+
this.Component = Component
|
141
|
+
this.componentState = RESOLVED
|
142
|
+
this.realUpdate(this.pendingData)
|
143
|
+
this.pendingData = null
|
144
|
+
}, this))
|
145
|
+
},
|
146
|
+
|
147
|
+
/**
|
148
|
+
* Resolve a dynamic component to use for an instance.
|
149
|
+
* The tricky part here is that there could be dynamic
|
150
|
+
* components depending on instance data.
|
151
|
+
*
|
152
|
+
* @param {Object} data
|
153
|
+
* @param {Object} meta
|
154
|
+
* @return {Function}
|
155
|
+
*/
|
156
|
+
|
157
|
+
resolveDynamicComponent: function (data, meta) {
|
158
|
+
// create a temporary context object and copy data
|
159
|
+
// and meta properties onto it.
|
160
|
+
// use _.define to avoid accidentally overwriting scope
|
161
|
+
// properties.
|
162
|
+
var context = Object.create(this.vm)
|
163
|
+
var key
|
164
|
+
for (key in data) {
|
165
|
+
_.define(context, key, data[key])
|
166
|
+
}
|
167
|
+
for (key in meta) {
|
168
|
+
_.define(context, key, meta[key])
|
169
|
+
}
|
170
|
+
var id = this.componentGetter.call(context, context)
|
171
|
+
var Component = _.resolveAsset(this.vm.$options, 'components', id)
|
172
|
+
if (process.env.NODE_ENV !== 'production') {
|
173
|
+
_.assertAsset(Component, 'component', id)
|
174
|
+
}
|
175
|
+
if (!Component.options) {
|
176
|
+
process.env.NODE_ENV !== 'production' && _.warn(
|
177
|
+
'Async resolution is not supported for v-repeat ' +
|
178
|
+
'+ dynamic component. (component: ' + id + ')'
|
179
|
+
)
|
180
|
+
return _.Vue
|
181
|
+
}
|
182
|
+
return Component
|
183
|
+
},
|
184
|
+
|
185
|
+
/**
|
186
|
+
* Update.
|
187
|
+
* This is called whenever the Array mutates. If we have
|
188
|
+
* a component, we might need to wait for it to resolve
|
189
|
+
* asynchronously.
|
190
|
+
*
|
191
|
+
* @param {Array|Number|String} data
|
192
|
+
*/
|
193
|
+
|
194
|
+
update: function (data) {
|
195
|
+
if (process.env.NODE_ENV !== 'production' && !_.isArray(data)) {
|
196
|
+
_.warn(
|
197
|
+
'v-repeat pre-converts Objects into Arrays, and ' +
|
198
|
+
'v-repeat filters should always return Arrays.'
|
199
|
+
)
|
200
|
+
}
|
201
|
+
if (this.componentId) {
|
202
|
+
var state = this.componentState
|
203
|
+
if (state === UNRESOLVED) {
|
204
|
+
this.pendingData = data
|
205
|
+
// once resolved, it will call realUpdate
|
206
|
+
this.resolveComponent()
|
207
|
+
} else if (state === PENDING) {
|
208
|
+
this.pendingData = data
|
209
|
+
} else if (state === RESOLVED) {
|
210
|
+
this.realUpdate(data)
|
211
|
+
}
|
212
|
+
} else {
|
213
|
+
this.realUpdate(data)
|
214
|
+
}
|
215
|
+
},
|
216
|
+
|
217
|
+
/**
|
218
|
+
* The real update that actually modifies the DOM.
|
219
|
+
*
|
220
|
+
* @param {Array|Number|String} data
|
221
|
+
*/
|
222
|
+
|
223
|
+
realUpdate: function (data) {
|
224
|
+
this.vms = this.diff(data, this.vms)
|
225
|
+
// update v-ref
|
226
|
+
if (this.refID) {
|
227
|
+
this.vm.$[this.refID] = this.converted
|
228
|
+
? toRefObject(this.vms)
|
229
|
+
: this.vms
|
230
|
+
}
|
231
|
+
if (this.elID) {
|
232
|
+
this.vm.$$[this.elID] = this.vms.map(function (vm) {
|
233
|
+
return vm.$el
|
234
|
+
})
|
235
|
+
}
|
236
|
+
},
|
237
|
+
|
238
|
+
/**
|
239
|
+
* Diff, based on new data and old data, determine the
|
240
|
+
* minimum amount of DOM manipulations needed to make the
|
241
|
+
* DOM reflect the new data Array.
|
242
|
+
*
|
243
|
+
* The algorithm diffs the new data Array by storing a
|
244
|
+
* hidden reference to an owner vm instance on previously
|
245
|
+
* seen data. This allows us to achieve O(n) which is
|
246
|
+
* better than a levenshtein distance based algorithm,
|
247
|
+
* which is O(m * n).
|
248
|
+
*
|
249
|
+
* @param {Array} data
|
250
|
+
* @param {Array} oldVms
|
251
|
+
* @return {Array}
|
252
|
+
*/
|
253
|
+
|
254
|
+
diff: function (data, oldVms) {
|
255
|
+
var idKey = this.idKey
|
256
|
+
var converted = this.converted
|
257
|
+
var start = this.start
|
258
|
+
var end = this.end
|
259
|
+
var inDoc = _.inDoc(start)
|
260
|
+
var alias = this.arg
|
261
|
+
var init = !oldVms
|
262
|
+
var vms = new Array(data.length)
|
263
|
+
var obj, raw, vm, i, l, primitive
|
264
|
+
// First pass, go through the new Array and fill up
|
265
|
+
// the new vms array. If a piece of data has a cached
|
266
|
+
// instance for it, we reuse it. Otherwise build a new
|
267
|
+
// instance.
|
268
|
+
for (i = 0, l = data.length; i < l; i++) {
|
269
|
+
obj = data[i]
|
270
|
+
raw = converted ? obj.$value : obj
|
271
|
+
primitive = !isObject(raw)
|
272
|
+
vm = !init && this.getVm(raw, i, converted ? obj.$key : null)
|
273
|
+
if (vm) { // reusable instance
|
274
|
+
|
275
|
+
if (process.env.NODE_ENV !== 'production' && vm._reused) {
|
276
|
+
_.warn(
|
277
|
+
'Duplicate objects found in v-repeat="' + this.expression + '": ' +
|
278
|
+
JSON.stringify(raw)
|
279
|
+
)
|
280
|
+
}
|
281
|
+
|
282
|
+
vm._reused = true
|
283
|
+
vm.$index = i // update $index
|
284
|
+
// update data for track-by or object repeat,
|
285
|
+
// since in these two cases the data is replaced
|
286
|
+
// rather than mutated.
|
287
|
+
if (idKey || converted || primitive) {
|
288
|
+
if (alias) {
|
289
|
+
vm[alias] = raw
|
290
|
+
} else if (_.isPlainObject(raw)) {
|
291
|
+
vm.$data = raw
|
292
|
+
} else {
|
293
|
+
vm.$value = raw
|
294
|
+
}
|
295
|
+
}
|
296
|
+
} else { // new instance
|
297
|
+
vm = this.build(obj, i, true)
|
298
|
+
vm._reused = false
|
299
|
+
}
|
300
|
+
vms[i] = vm
|
301
|
+
// insert if this is first run
|
302
|
+
if (init) {
|
303
|
+
vm.$before(end)
|
304
|
+
}
|
305
|
+
}
|
306
|
+
// if this is the first run, we're done.
|
307
|
+
if (init) {
|
308
|
+
return vms
|
309
|
+
}
|
310
|
+
// Second pass, go through the old vm instances and
|
311
|
+
// destroy those who are not reused (and remove them
|
312
|
+
// from cache)
|
313
|
+
var removalIndex = 0
|
314
|
+
var totalRemoved = oldVms.length - vms.length
|
315
|
+
for (i = 0, l = oldVms.length; i < l; i++) {
|
316
|
+
vm = oldVms[i]
|
317
|
+
if (!vm._reused) {
|
318
|
+
this.uncacheVm(vm)
|
319
|
+
vm.$destroy(false, true) // defer cleanup until removal
|
320
|
+
this.remove(vm, removalIndex++, totalRemoved, inDoc)
|
321
|
+
}
|
322
|
+
}
|
323
|
+
// final pass, move/insert new instances into the
|
324
|
+
// right place.
|
325
|
+
var targetPrev, prevEl, currentPrev
|
326
|
+
var insertionIndex = 0
|
327
|
+
for (i = 0, l = vms.length; i < l; i++) {
|
328
|
+
vm = vms[i]
|
329
|
+
// this is the vm that we should be after
|
330
|
+
targetPrev = vms[i - 1]
|
331
|
+
prevEl = targetPrev
|
332
|
+
? targetPrev._staggerCb
|
333
|
+
? targetPrev._staggerAnchor
|
334
|
+
: targetPrev._fragmentEnd || targetPrev.$el
|
335
|
+
: start
|
336
|
+
if (vm._reused && !vm._staggerCb) {
|
337
|
+
currentPrev = findPrevVm(vm, start, this.id)
|
338
|
+
if (currentPrev !== targetPrev) {
|
339
|
+
this.move(vm, prevEl)
|
340
|
+
}
|
341
|
+
} else {
|
342
|
+
// new instance, or still in stagger.
|
343
|
+
// insert with updated stagger index.
|
344
|
+
this.insert(vm, insertionIndex++, prevEl, inDoc)
|
345
|
+
}
|
346
|
+
vm._reused = false
|
347
|
+
}
|
348
|
+
return vms
|
349
|
+
},
|
350
|
+
|
351
|
+
/**
|
352
|
+
* Build a new instance and cache it.
|
353
|
+
*
|
354
|
+
* @param {Object} data
|
355
|
+
* @param {Number} index
|
356
|
+
* @param {Boolean} needCache
|
357
|
+
*/
|
358
|
+
|
359
|
+
build: function (data, index, needCache) {
|
360
|
+
var meta = { $index: index }
|
361
|
+
if (this.converted) {
|
362
|
+
meta.$key = data.$key
|
363
|
+
}
|
364
|
+
var raw = this.converted ? data.$value : data
|
365
|
+
var alias = this.arg
|
366
|
+
if (alias) {
|
367
|
+
data = {}
|
368
|
+
data[alias] = raw
|
369
|
+
} else if (!isPlainObject(raw)) {
|
370
|
+
// non-object values
|
371
|
+
data = {}
|
372
|
+
meta.$value = raw
|
373
|
+
} else {
|
374
|
+
// default
|
375
|
+
data = raw
|
376
|
+
}
|
377
|
+
// resolve constructor
|
378
|
+
var Component = this.Component || this.resolveDynamicComponent(data, meta)
|
379
|
+
var parent = this._host || this.vm
|
380
|
+
var vm = parent.$addChild({
|
381
|
+
el: templateParser.clone(this.template),
|
382
|
+
data: data,
|
383
|
+
inherit: this.inline,
|
384
|
+
template: this.inlineTemplate,
|
385
|
+
// repeater meta, e.g. $index, $key
|
386
|
+
_meta: meta,
|
387
|
+
// mark this as an inline-repeat instance
|
388
|
+
_repeat: this.inline,
|
389
|
+
// is this a component?
|
390
|
+
_asComponent: this.asComponent,
|
391
|
+
// linker cachable if no inline-template
|
392
|
+
_linkerCachable: !this.inlineTemplate && Component !== _.Vue,
|
393
|
+
// pre-compiled linker for simple repeats
|
394
|
+
_linkFn: this._linkFn,
|
395
|
+
// identifier, shows that this vm belongs to this collection
|
396
|
+
_repeatId: this.id,
|
397
|
+
// transclusion content owner
|
398
|
+
_context: this.vm
|
399
|
+
}, Component)
|
400
|
+
// cache instance
|
401
|
+
if (needCache) {
|
402
|
+
this.cacheVm(raw, vm, index, this.converted ? meta.$key : null)
|
403
|
+
}
|
404
|
+
// sync back changes for two-way bindings of primitive values
|
405
|
+
var dir = this
|
406
|
+
if (this.rawType === 'object' && isPrimitive(raw)) {
|
407
|
+
vm.$watch(alias || '$value', function (val) {
|
408
|
+
if (dir.filters) {
|
409
|
+
process.env.NODE_ENV !== 'production' && _.warn(
|
410
|
+
'You seem to be mutating the $value reference of ' +
|
411
|
+
'a v-repeat instance (likely through v-model) ' +
|
412
|
+
'and filtering the v-repeat at the same time. ' +
|
413
|
+
'This will not work properly with an Array of ' +
|
414
|
+
'primitive values. Please use an Array of ' +
|
415
|
+
'Objects instead.'
|
416
|
+
)
|
417
|
+
}
|
418
|
+
dir._withLock(function () {
|
419
|
+
if (dir.converted) {
|
420
|
+
dir.rawValue[vm.$key] = val
|
421
|
+
} else {
|
422
|
+
dir.rawValue.$set(vm.$index, val)
|
423
|
+
}
|
424
|
+
})
|
425
|
+
})
|
426
|
+
}
|
427
|
+
return vm
|
428
|
+
},
|
429
|
+
|
430
|
+
/**
|
431
|
+
* Unbind, teardown everything
|
432
|
+
*/
|
433
|
+
|
434
|
+
unbind: function () {
|
435
|
+
this.componentState = ABORTED
|
436
|
+
if (this.refID) {
|
437
|
+
this.vm.$[this.refID] = null
|
438
|
+
}
|
439
|
+
if (this.vms) {
|
440
|
+
var i = this.vms.length
|
441
|
+
var vm
|
442
|
+
while (i--) {
|
443
|
+
vm = this.vms[i]
|
444
|
+
this.uncacheVm(vm)
|
445
|
+
vm.$destroy()
|
446
|
+
}
|
447
|
+
}
|
448
|
+
},
|
449
|
+
|
450
|
+
/**
|
451
|
+
* Cache a vm instance based on its data.
|
452
|
+
*
|
453
|
+
* If the data is an object, we save the vm's reference on
|
454
|
+
* the data object as a hidden property. Otherwise we
|
455
|
+
* cache them in an object and for each primitive value
|
456
|
+
* there is an array in case there are duplicates.
|
457
|
+
*
|
458
|
+
* @param {Object} data
|
459
|
+
* @param {Vue} vm
|
460
|
+
* @param {Number} index
|
461
|
+
* @param {String} [key]
|
462
|
+
*/
|
463
|
+
|
464
|
+
cacheVm: function (data, vm, index, key) {
|
465
|
+
var idKey = this.idKey
|
466
|
+
var cache = this.cache
|
467
|
+
var primitive = !isObject(data)
|
468
|
+
var id
|
469
|
+
if (key || idKey || primitive) {
|
470
|
+
id = idKey
|
471
|
+
? idKey === '$index'
|
472
|
+
? index
|
473
|
+
: data[idKey]
|
474
|
+
: (key || index)
|
475
|
+
if (!cache[id]) {
|
476
|
+
cache[id] = vm
|
477
|
+
} else if (!primitive && idKey !== '$index') {
|
478
|
+
process.env.NODE_ENV !== 'production' && _.warn(
|
479
|
+
'Duplicate objects with the same track-by key in v-repeat: ' + id
|
480
|
+
)
|
481
|
+
}
|
482
|
+
} else {
|
483
|
+
id = this.id
|
484
|
+
if (data.hasOwnProperty(id)) {
|
485
|
+
if (data[id] === null) {
|
486
|
+
data[id] = vm
|
487
|
+
} else {
|
488
|
+
process.env.NODE_ENV !== 'production' && _.warn(
|
489
|
+
'Duplicate objects found in v-repeat="' + this.expression + '": ' +
|
490
|
+
JSON.stringify(data)
|
491
|
+
)
|
492
|
+
}
|
493
|
+
} else {
|
494
|
+
_.define(data, id, vm)
|
495
|
+
}
|
496
|
+
}
|
497
|
+
vm._raw = data
|
498
|
+
},
|
499
|
+
|
500
|
+
/**
|
501
|
+
* Try to get a cached instance from a piece of data.
|
502
|
+
*
|
503
|
+
* @param {Object} data
|
504
|
+
* @param {Number} index
|
505
|
+
* @param {String} [key]
|
506
|
+
* @return {Vue|undefined}
|
507
|
+
*/
|
508
|
+
|
509
|
+
getVm: function (data, index, key) {
|
510
|
+
var idKey = this.idKey
|
511
|
+
var primitive = !isObject(data)
|
512
|
+
if (key || idKey || primitive) {
|
513
|
+
var id = idKey
|
514
|
+
? idKey === '$index'
|
515
|
+
? index
|
516
|
+
: data[idKey]
|
517
|
+
: (key || index)
|
518
|
+
return this.cache[id]
|
519
|
+
} else {
|
520
|
+
return data[this.id]
|
521
|
+
}
|
522
|
+
},
|
523
|
+
|
524
|
+
/**
|
525
|
+
* Delete a cached vm instance.
|
526
|
+
*
|
527
|
+
* @param {Vue} vm
|
528
|
+
*/
|
529
|
+
|
530
|
+
uncacheVm: function (vm) {
|
531
|
+
var data = vm._raw
|
532
|
+
var idKey = this.idKey
|
533
|
+
var index = vm.$index
|
534
|
+
// fix #948: avoid accidentally fall through to
|
535
|
+
// a parent repeater which happens to have $key.
|
536
|
+
var key = vm.hasOwnProperty('$key') && vm.$key
|
537
|
+
var primitive = !isObject(data)
|
538
|
+
if (idKey || key || primitive) {
|
539
|
+
var id = idKey
|
540
|
+
? idKey === '$index'
|
541
|
+
? index
|
542
|
+
: data[idKey]
|
543
|
+
: (key || index)
|
544
|
+
this.cache[id] = null
|
545
|
+
} else {
|
546
|
+
data[this.id] = null
|
547
|
+
vm._raw = null
|
548
|
+
}
|
549
|
+
},
|
550
|
+
|
551
|
+
/**
|
552
|
+
* Insert an instance.
|
553
|
+
*
|
554
|
+
* @param {Vue} vm
|
555
|
+
* @param {Number} index
|
556
|
+
* @param {Node} prevEl
|
557
|
+
* @param {Boolean} inDoc
|
558
|
+
*/
|
559
|
+
|
560
|
+
insert: function (vm, index, prevEl, inDoc) {
|
561
|
+
if (vm._staggerCb) {
|
562
|
+
vm._staggerCb.cancel()
|
563
|
+
vm._staggerCb = null
|
564
|
+
}
|
565
|
+
var staggerAmount = this.getStagger(vm, index, null, 'enter')
|
566
|
+
if (inDoc && staggerAmount) {
|
567
|
+
// create an anchor and insert it synchronously,
|
568
|
+
// so that we can resolve the correct order without
|
569
|
+
// worrying about some elements not inserted yet
|
570
|
+
var anchor = vm._staggerAnchor
|
571
|
+
if (!anchor) {
|
572
|
+
anchor = vm._staggerAnchor = _.createAnchor('stagger-anchor')
|
573
|
+
anchor.__vue__ = vm
|
574
|
+
}
|
575
|
+
_.after(anchor, prevEl)
|
576
|
+
var op = vm._staggerCb = _.cancellable(function () {
|
577
|
+
vm._staggerCb = null
|
578
|
+
vm.$before(anchor)
|
579
|
+
_.remove(anchor)
|
580
|
+
})
|
581
|
+
setTimeout(op, staggerAmount)
|
582
|
+
} else {
|
583
|
+
vm.$after(prevEl)
|
584
|
+
}
|
585
|
+
},
|
586
|
+
|
587
|
+
/**
|
588
|
+
* Move an already inserted instance.
|
589
|
+
*
|
590
|
+
* @param {Vue} vm
|
591
|
+
* @param {Node} prevEl
|
592
|
+
*/
|
593
|
+
|
594
|
+
move: function (vm, prevEl) {
|
595
|
+
vm.$after(prevEl, null, false)
|
596
|
+
},
|
597
|
+
|
598
|
+
/**
|
599
|
+
* Remove an instance.
|
600
|
+
*
|
601
|
+
* @param {Vue} vm
|
602
|
+
* @param {Number} index
|
603
|
+
* @param {Boolean} inDoc
|
604
|
+
*/
|
605
|
+
|
606
|
+
remove: function (vm, index, total, inDoc) {
|
607
|
+
if (vm._staggerCb) {
|
608
|
+
vm._staggerCb.cancel()
|
609
|
+
vm._staggerCb = null
|
610
|
+
// it's not possible for the same vm to be removed
|
611
|
+
// twice, so if we have a pending stagger callback,
|
612
|
+
// it means this vm is queued for enter but removed
|
613
|
+
// before its transition started. Since it is already
|
614
|
+
// destroyed, we can just leave it in detached state.
|
615
|
+
return
|
616
|
+
}
|
617
|
+
var staggerAmount = this.getStagger(vm, index, total, 'leave')
|
618
|
+
if (inDoc && staggerAmount) {
|
619
|
+
var op = vm._staggerCb = _.cancellable(function () {
|
620
|
+
vm._staggerCb = null
|
621
|
+
remove()
|
622
|
+
})
|
623
|
+
setTimeout(op, staggerAmount)
|
624
|
+
} else {
|
625
|
+
remove()
|
626
|
+
}
|
627
|
+
function remove () {
|
628
|
+
vm.$remove(function () {
|
629
|
+
vm._cleanup()
|
630
|
+
})
|
631
|
+
}
|
632
|
+
},
|
633
|
+
|
634
|
+
/**
|
635
|
+
* Get the stagger amount for an insertion/removal.
|
636
|
+
*
|
637
|
+
* @param {Vue} vm
|
638
|
+
* @param {Number} index
|
639
|
+
* @param {String} type
|
640
|
+
* @param {Number} total
|
641
|
+
*/
|
642
|
+
|
643
|
+
getStagger: function (vm, index, total, type) {
|
644
|
+
type = type + 'Stagger'
|
645
|
+
var transition = vm.$el.__v_trans
|
646
|
+
var hooks = transition && transition.hooks
|
647
|
+
var hook = hooks && (hooks[type] || hooks.stagger)
|
648
|
+
return hook
|
649
|
+
? hook.call(vm, index, total)
|
650
|
+
: index * this[type]
|
651
|
+
},
|
652
|
+
|
653
|
+
/**
|
654
|
+
* Pre-process the value before piping it through the
|
655
|
+
* filters, and convert non-Array objects to arrays.
|
656
|
+
*
|
657
|
+
* This function will be bound to this directive instance
|
658
|
+
* and passed into the watcher.
|
659
|
+
*
|
660
|
+
* @param {*} value
|
661
|
+
* @return {Array}
|
662
|
+
* @private
|
663
|
+
*/
|
664
|
+
|
665
|
+
_preProcess: function (value) {
|
666
|
+
// regardless of type, store the un-filtered raw value.
|
667
|
+
this.rawValue = value
|
668
|
+
var type = this.rawType = typeof value
|
669
|
+
if (!isPlainObject(value)) {
|
670
|
+
this.converted = false
|
671
|
+
if (type === 'number') {
|
672
|
+
value = range(value)
|
673
|
+
} else if (type === 'string') {
|
674
|
+
value = _.toArray(value)
|
675
|
+
}
|
676
|
+
return value || []
|
677
|
+
} else {
|
678
|
+
// convert plain object to array.
|
679
|
+
var keys = Object.keys(value)
|
680
|
+
var i = keys.length
|
681
|
+
var res = new Array(i)
|
682
|
+
var key
|
683
|
+
while (i--) {
|
684
|
+
key = keys[i]
|
685
|
+
res[i] = {
|
686
|
+
$key: key,
|
687
|
+
$value: value[key]
|
688
|
+
}
|
689
|
+
}
|
690
|
+
this.converted = true
|
691
|
+
return res
|
692
|
+
}
|
693
|
+
}
|
694
|
+
}
|
695
|
+
|
696
|
+
/**
|
697
|
+
* Helper to find the previous element that is an instance
|
698
|
+
* root node. This is necessary because a destroyed vm's
|
699
|
+
* element could still be lingering in the DOM before its
|
700
|
+
* leaving transition finishes, but its __vue__ reference
|
701
|
+
* should have been removed so we can skip them.
|
702
|
+
*
|
703
|
+
* If this is a block repeat, we want to make sure we only
|
704
|
+
* return vm that is bound to this v-repeat. (see #929)
|
705
|
+
*
|
706
|
+
* @param {Vue} vm
|
707
|
+
* @param {Comment|Text} anchor
|
708
|
+
* @return {Vue}
|
709
|
+
*/
|
710
|
+
|
711
|
+
function findPrevVm (vm, anchor, id) {
|
712
|
+
var el = vm.$el.previousSibling
|
713
|
+
/* istanbul ignore if */
|
714
|
+
if (!el) return
|
715
|
+
while (
|
716
|
+
(!el.__vue__ || el.__vue__.$options._repeatId !== id) &&
|
717
|
+
el !== anchor
|
718
|
+
) {
|
719
|
+
el = el.previousSibling
|
720
|
+
}
|
721
|
+
return el.__vue__
|
722
|
+
}
|
723
|
+
|
724
|
+
/**
|
725
|
+
* Create a range array from given number.
|
726
|
+
*
|
727
|
+
* @param {Number} n
|
728
|
+
* @return {Array}
|
729
|
+
*/
|
730
|
+
|
731
|
+
function range (n) {
|
732
|
+
var i = -1
|
733
|
+
var ret = new Array(n)
|
734
|
+
while (++i < n) {
|
735
|
+
ret[i] = i
|
736
|
+
}
|
737
|
+
return ret
|
738
|
+
}
|
739
|
+
|
740
|
+
/**
|
741
|
+
* Convert a vms array to an object ref for v-ref on an
|
742
|
+
* Object value.
|
743
|
+
*
|
744
|
+
* @param {Array} vms
|
745
|
+
* @return {Object}
|
746
|
+
*/
|
747
|
+
|
748
|
+
function toRefObject (vms) {
|
749
|
+
var ref = {}
|
750
|
+
for (var i = 0, l = vms.length; i < l; i++) {
|
751
|
+
ref[vms[i].$key] = vms[i]
|
752
|
+
}
|
753
|
+
return ref
|
754
|
+
}
|
755
|
+
|
756
|
+
/**
|
757
|
+
* Check if a value is a primitive one:
|
758
|
+
* String, Number, Boolean, null or undefined.
|
759
|
+
*
|
760
|
+
* @param {*} value
|
761
|
+
* @return {Boolean}
|
762
|
+
*/
|
763
|
+
|
764
|
+
function isPrimitive (value) {
|
765
|
+
var type = typeof value
|
766
|
+
return value == null ||
|
767
|
+
type === 'string' ||
|
768
|
+
type === 'number' ||
|
769
|
+
type === 'boolean'
|
770
|
+
}
|