fluentd-ui 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of fluentd-ui might be problematic. Click here for more details.
- checksums.yaml +7 -0
- data/.bowerrc +3 -0
- data/.gitignore +31 -0
- data/.rspec +1 -0
- data/ChangeLog +3 -0
- data/Gemfile +21 -0
- data/Gemfile.lock +247 -0
- data/Gemfile.production +3 -0
- data/README.md +53 -0
- data/Rakefile +8 -0
- data/app/assets/images/.keep +0 -0
- data/app/assets/javascripts/alert.js +51 -0
- data/app/assets/javascripts/application.js +22 -0
- data/app/assets/javascripts/nested_setting.js +41 -0
- data/app/assets/javascripts/setting_format.js +15 -0
- data/app/assets/javascripts/tutorial.js +58 -0
- data/app/assets/javascripts/vue/fluent_log.js +64 -0
- data/app/assets/javascripts/vue/in_tail_format.js +153 -0
- data/app/assets/javascripts/vue/treeview.js +97 -0
- data/app/assets/javascripts/vue_common.js +4 -0
- data/app/assets/stylesheets/application.css +18 -0
- data/app/assets/stylesheets/common.css.scss +152 -0
- data/app/controllers/api_controller.rb +37 -0
- data/app/controllers/application_controller.rb +110 -0
- data/app/controllers/concerns/.keep +0 -0
- data/app/controllers/fluentd/agents_controller.rb +35 -0
- data/app/controllers/fluentd/settings/in_syslog_controller.rb +34 -0
- data/app/controllers/fluentd/settings/in_tail_controller.rb +57 -0
- data/app/controllers/fluentd/settings/out_forward_controller.rb +42 -0
- data/app/controllers/fluentd/settings/out_mongo_controller.rb +36 -0
- data/app/controllers/fluentd/settings/out_s3_controller.rb +36 -0
- data/app/controllers/fluentd/settings/out_td_controller.rb +36 -0
- data/app/controllers/fluentd/settings_controller.rb +18 -0
- data/app/controllers/fluentd_controller.rb +62 -0
- data/app/controllers/misc_controller.rb +69 -0
- data/app/controllers/plugins_controller.rb +44 -0
- data/app/controllers/polling_controller.rb +20 -0
- data/app/controllers/sessions_controller.rb +45 -0
- data/app/controllers/tutorials_controller.rb +40 -0
- data/app/controllers/users_controller.rb +28 -0
- data/app/controllers/welcome_controller.rb +5 -0
- data/app/helpers/application_helper.rb +55 -0
- data/app/helpers/fluentd/settings_helper.rb +2 -0
- data/app/helpers/miscs_helper.rb +2 -0
- data/app/helpers/settings_helper.rb +43 -0
- data/app/mailers/.keep +0 -0
- data/app/models/.keep +0 -0
- data/app/models/concerns/.keep +0 -0
- data/app/models/fluentd.rb +178 -0
- data/app/models/fluentd/agent.rb +28 -0
- data/app/models/fluentd/agent/common.rb +76 -0
- data/app/models/fluentd/agent/configuration.rb +35 -0
- data/app/models/fluentd/agent/fluentd_gem.rb +104 -0
- data/app/models/fluentd/agent/local_common.rb +101 -0
- data/app/models/fluentd/agent/remote.rb +7 -0
- data/app/models/fluentd/agent/td_agent.rb +44 -0
- data/app/models/fluentd/api.rb +6 -0
- data/app/models/fluentd/api/http.rb +26 -0
- data/app/models/fluentd/setting.rb +4 -0
- data/app/models/fluentd/setting/common.rb +185 -0
- data/app/models/fluentd/setting/in_syslog.rb +16 -0
- data/app/models/fluentd/setting/in_tail.rb +107 -0
- data/app/models/fluentd/setting/out_forward.rb +70 -0
- data/app/models/fluentd/setting/out_mongo.rb +35 -0
- data/app/models/fluentd/setting/out_s3.rb +29 -0
- data/app/models/fluentd/setting/out_td.rb +26 -0
- data/app/models/plugin.rb +193 -0
- data/app/models/settings.rb +4 -0
- data/app/models/user.rb +52 -0
- data/app/views/fluentd/_form.html.haml +31 -0
- data/app/views/fluentd/edit.html.haml +3 -0
- data/app/views/fluentd/errors.html.haml +19 -0
- data/app/views/fluentd/log.html.haml +9 -0
- data/app/views/fluentd/new.html.haml +3 -0
- data/app/views/fluentd/settings/_form.html.haml +43 -0
- data/app/views/fluentd/settings/edit.html.haml +7 -0
- data/app/views/fluentd/settings/in_syslog/_form.html.haml +9 -0
- data/app/views/fluentd/settings/in_syslog/show.html.haml +6 -0
- data/app/views/fluentd/settings/in_tail/_form.html.haml +42 -0
- data/app/views/fluentd/settings/in_tail/after_file_choose.html.haml +19 -0
- data/app/views/fluentd/settings/in_tail/after_format.html.haml +10 -0
- data/app/views/fluentd/settings/in_tail/confirm.html.haml +13 -0
- data/app/views/fluentd/settings/in_tail/show.html.haml +5 -0
- data/app/views/fluentd/settings/out_forward/_form.html.haml +22 -0
- data/app/views/fluentd/settings/out_forward/show.html.haml +6 -0
- data/app/views/fluentd/settings/out_mongo/_form.html.haml +30 -0
- data/app/views/fluentd/settings/out_mongo/finish.html.haml +4 -0
- data/app/views/fluentd/settings/out_mongo/show.html.haml +6 -0
- data/app/views/fluentd/settings/out_s3/_form.html.haml +39 -0
- data/app/views/fluentd/settings/out_s3/show.html.haml +6 -0
- data/app/views/fluentd/settings/out_td/_form.html.haml +18 -0
- data/app/views/fluentd/settings/out_td/show.html.haml +6 -0
- data/app/views/fluentd/settings/show.html.haml +10 -0
- data/app/views/fluentd/settings/source_and_output.html.haml +45 -0
- data/app/views/fluentd/show.html.haml +60 -0
- data/app/views/layouts/application.html.erb +102 -0
- data/app/views/layouts/sign_in.html.erb +28 -0
- data/app/views/misc/information.html.haml +75 -0
- data/app/views/misc/update_fluentd_ui.html.haml +45 -0
- data/app/views/plugins/installed.html.haml +67 -0
- data/app/views/plugins/recommended.html.haml +59 -0
- data/app/views/plugins/updated.html.haml +29 -0
- data/app/views/sessions/new.html.haml +13 -0
- data/app/views/shared/_error.html.haml +3 -0
- data/app/views/shared/_flash.html.haml +10 -0
- data/app/views/shared/_fluentd_nav.html.haml +12 -0
- data/app/views/shared/_global_nav.html.erb +80 -0
- data/app/views/shared/_initial_setup.html.haml +13 -0
- data/app/views/shared/_modal.html.erb +25 -0
- data/app/views/shared/_setting_errors.html.haml +5 -0
- data/app/views/shared/vue/_fluent_log.html.erb +25 -0
- data/app/views/shared/vue/_in_tail_format.html.erb +53 -0
- data/app/views/shared/vue/_treeview.html.erb +30 -0
- data/app/views/tutorials/chapter1.html.erb +31 -0
- data/app/views/tutorials/chapter2.html.haml +12 -0
- data/app/views/tutorials/chapter3.html.haml +12 -0
- data/app/views/tutorials/chapter4.html.haml +12 -0
- data/app/views/tutorials/chapter5.html.haml +10 -0
- data/app/views/tutorials/index.html.haml +26 -0
- data/app/views/users/show.html.haml +22 -0
- data/app/workers/all_plugin_check_update.rb +14 -0
- data/app/workers/fluentd_ui_restart.rb +41 -0
- data/app/workers/fluentd_ui_update_check.rb +15 -0
- data/app/workers/gem_installer.rb +17 -0
- data/app/workers/gem_uninstaller.rb +15 -0
- data/app/workers/gem_update_check.rb +10 -0
- data/bin/bundle +3 -0
- data/bin/fluentd-ui +13 -0
- data/bin/fluentd-ui-restart +12 -0
- data/bin/rails +8 -0
- data/bin/rake +8 -0
- data/bin/spring +18 -0
- data/bower.json +10 -0
- data/circle.yml +8 -0
- data/config.ru +4 -0
- data/config/application.rb +48 -0
- data/config/application.yml +211 -0
- data/config/boot.rb +4 -0
- data/config/environment.rb +5 -0
- data/config/environments/development.rb +36 -0
- data/config/environments/production.rb +69 -0
- data/config/environments/test.rb +40 -0
- data/config/initializers/backtrace_silencers.rb +7 -0
- data/config/initializers/cookies_serializer.rb +3 -0
- data/config/initializers/filter_parameter_logging.rb +4 -0
- data/config/initializers/inflections.rb +16 -0
- data/config/initializers/mime_types.rb +4 -0
- data/config/initializers/prefetch_gem_updates.rb +1 -0
- data/config/initializers/session_store.rb +3 -0
- data/config/initializers/wrap_parameters.rb +14 -0
- data/config/locales/en.yml +204 -0
- data/config/locales/ja.yml +194 -0
- data/config/locales/translation_en.yml +255 -0
- data/config/locales/translation_ja.yml +255 -0
- data/config/locales/tutorial_en.yml +117 -0
- data/config/locales/tutorial_ja.yml +120 -0
- data/config/routes.rb +93 -0
- data/config/secrets.yml +22 -0
- data/db/schema.rb +0 -0
- data/db/seeds.rb +11 -0
- data/fluentd-ui-ss01.png +0 -0
- data/fluentd-ui-ss02.png +0 -0
- data/fluentd-ui-ss03.png +0 -0
- data/fluentd-ui-ss04.png +0 -0
- data/fluentd-ui-ss05.png +0 -0
- data/fluentd-ui.gemspec +46 -0
- data/lib/assets/.keep +0 -0
- data/lib/file_reverse_reader.rb +56 -0
- data/lib/fluentd-ui.rb +22 -0
- data/lib/fluentd-ui/command.rb +52 -0
- data/lib/fluentd-ui/version.rb +3 -0
- data/lib/grok_converter.rb +39 -0
- data/lib/regexp_preview.rb +48 -0
- data/lib/tasks/.keep +0 -0
- data/lib/treeview.rb +45 -0
- data/log/.keep +0 -0
- data/public/404.html +67 -0
- data/public/422.html +67 -0
- data/public/500.html +66 -0
- data/public/favicon.ico +0 -0
- data/public/fluentd-logo-right-text.png +0 -0
- data/public/fluentd-logo.png +0 -0
- data/public/fluentd.png +0 -0
- data/public/robots.txt +5 -0
- data/spec/controllers/plugins_controller_spec.rb +5 -0
- data/spec/controllers/polling_controller_spec.rb +5 -0
- data/spec/controllers/sessions_controller_spec.rb +5 -0
- data/spec/controllers/tutorials_controller_spec.rb +5 -0
- data/spec/factories/fluentd.rb +11 -0
- data/spec/factories/plugins.rb +8 -0
- data/spec/factories/user.rb +6 -0
- data/spec/features/fluentd/setting/out_forward_spec.rb +45 -0
- data/spec/features/fluentd/setting/out_td_spec.rb +35 -0
- data/spec/features/sessions_spec.rb +55 -0
- data/spec/features/shared_examples/login_required.rb +4 -0
- data/spec/features/users_spec.rb +9 -0
- data/spec/grok_converter_spec.rb +50 -0
- data/spec/lib/file_reverse_reader_spec.rb +73 -0
- data/spec/lib/fluentd-ui_spec.rb +35 -0
- data/spec/models/fluentd/agent_spec.rb +91 -0
- data/spec/models/fluentd/setting/common_spec.rb +178 -0
- data/spec/models/fluentd/setting/in_syslog_spec.rb +35 -0
- data/spec/models/fluentd/setting/out_mongo_spec.rb +40 -0
- data/spec/models/fluentd/setting/out_td_spec.rb +38 -0
- data/spec/models/fluentd_spec.rb +166 -0
- data/spec/models/plugin_spec.rb +191 -0
- data/spec/models/user_spec.rb +15 -0
- data/spec/spec_helper.rb +58 -0
- data/spec/support/fixtures/error0.log +12 -0
- data/spec/support/fixtures/error2.log +130 -0
- data/spec/support/fluentd_agent_common_behavior.rb +114 -0
- data/spec/support/fluentd_agent_restart_strategy.rb +94 -0
- data/tmp/.gitkeep +0 -0
- data/vendor/assets/javascripts/.keep +0 -0
- data/vendor/assets/javascripts/bower/es6-promise/.bower.json +15 -0
- data/vendor/assets/javascripts/bower/es6-promise/bower.json +5 -0
- data/vendor/assets/javascripts/bower/es6-promise/promise.js +684 -0
- data/vendor/assets/javascripts/bower/es6-promise/promise.min.js +1 -0
- data/vendor/assets/javascripts/bower/lodash/.bower.json +33 -0
- data/vendor/assets/javascripts/bower/lodash/LICENSE.txt +22 -0
- data/vendor/assets/javascripts/bower/lodash/bower.json +23 -0
- data/vendor/assets/javascripts/bower/lodash/dist/lodash.compat.js +7157 -0
- data/vendor/assets/javascripts/bower/lodash/dist/lodash.compat.min.js +61 -0
- data/vendor/assets/javascripts/bower/lodash/dist/lodash.js +6785 -0
- data/vendor/assets/javascripts/bower/lodash/dist/lodash.min.js +56 -0
- data/vendor/assets/javascripts/bower/lodash/dist/lodash.underscore.js +4979 -0
- data/vendor/assets/javascripts/bower/lodash/dist/lodash.underscore.min.js +39 -0
- data/vendor/assets/javascripts/bower/vue/.bower.json +29 -0
- data/vendor/assets/javascripts/bower/vue/LICENSE +21 -0
- data/vendor/assets/javascripts/bower/vue/dist/vue.js +4713 -0
- data/vendor/assets/javascripts/bower/vue/dist/vue.min.js +7 -0
- data/vendor/assets/javascripts/bower/vue/src/batcher.js +45 -0
- data/vendor/assets/javascripts/bower/vue/src/binding.js +103 -0
- data/vendor/assets/javascripts/bower/vue/src/compiler.js +1037 -0
- data/vendor/assets/javascripts/bower/vue/src/config.js +19 -0
- data/vendor/assets/javascripts/bower/vue/src/deps-parser.js +65 -0
- data/vendor/assets/javascripts/bower/vue/src/directive.js +258 -0
- data/vendor/assets/javascripts/bower/vue/src/directives/html.js +41 -0
- data/vendor/assets/javascripts/bower/vue/src/directives/if.js +56 -0
- data/vendor/assets/javascripts/bower/vue/src/directives/index.js +129 -0
- data/vendor/assets/javascripts/bower/vue/src/directives/model.js +174 -0
- data/vendor/assets/javascripts/bower/vue/src/directives/on.js +56 -0
- data/vendor/assets/javascripts/bower/vue/src/directives/partial.js +50 -0
- data/vendor/assets/javascripts/bower/vue/src/directives/repeat.js +246 -0
- data/vendor/assets/javascripts/bower/vue/src/directives/style.js +40 -0
- data/vendor/assets/javascripts/bower/vue/src/directives/view.js +56 -0
- data/vendor/assets/javascripts/bower/vue/src/directives/with.js +50 -0
- data/vendor/assets/javascripts/bower/vue/src/emitter.js +97 -0
- data/vendor/assets/javascripts/bower/vue/src/exp-parser.js +190 -0
- data/vendor/assets/javascripts/bower/vue/src/filters.js +190 -0
- data/vendor/assets/javascripts/bower/vue/src/fragment.js +84 -0
- data/vendor/assets/javascripts/bower/vue/src/main.js +186 -0
- data/vendor/assets/javascripts/bower/vue/src/observer.js +446 -0
- data/vendor/assets/javascripts/bower/vue/src/text-parser.js +96 -0
- data/vendor/assets/javascripts/bower/vue/src/transition.js +228 -0
- data/vendor/assets/javascripts/bower/vue/src/utils.js +321 -0
- data/vendor/assets/javascripts/bower/vue/src/viewmodel.js +180 -0
- data/vendor/assets/javascripts/sb-admin-v2/bootstrap.js +1951 -0
- data/vendor/assets/javascripts/sb-admin-v2/bootstrap.min.js +6 -0
- data/vendor/assets/javascripts/sb-admin-v2/demo/dashboard-demo.js +117 -0
- data/vendor/assets/javascripts/sb-admin-v2/demo/flot-demo.js +1242 -0
- data/vendor/assets/javascripts/sb-admin-v2/demo/morris-demo.js +155 -0
- data/vendor/assets/javascripts/sb-admin-v2/jquery-1.10.2.js +6 -0
- data/vendor/assets/javascripts/sb-admin-v2/plugins/dataTables/dataTables.bootstrap.js +245 -0
- data/vendor/assets/javascripts/sb-admin-v2/plugins/dataTables/jquery.dataTables.js +14013 -0
- data/vendor/assets/javascripts/sb-admin-v2/plugins/flot/excanvas.min.js +1 -0
- data/vendor/assets/javascripts/sb-admin-v2/plugins/flot/jquery.flot.js +2599 -0
- data/vendor/assets/javascripts/sb-admin-v2/plugins/flot/jquery.flot.pie.js +750 -0
- data/vendor/assets/javascripts/sb-admin-v2/plugins/flot/jquery.flot.resize.js +60 -0
- data/vendor/assets/javascripts/sb-admin-v2/plugins/flot/jquery.flot.tooltip.min.js +12 -0
- data/vendor/assets/javascripts/sb-admin-v2/plugins/metisMenu/jquery.metisMenu.js +45 -0
- data/vendor/assets/javascripts/sb-admin-v2/plugins/morris/morris.js +1888 -0
- data/vendor/assets/javascripts/sb-admin-v2/plugins/morris/raphael-2.1.0.min.js +10 -0
- data/vendor/assets/javascripts/sb-admin-v2/sb-admin.js +18 -0
- data/vendor/assets/stylesheets/.keep +0 -0
- data/vendor/assets/stylesheets/sb-admin-v2/bootstrap.css +5830 -0
- data/vendor/assets/stylesheets/sb-admin-v2/bootstrap.min.css +7 -0
- data/vendor/assets/stylesheets/sb-admin-v2/font-awesome/css/font-awesome.css +1338 -0
- data/vendor/assets/stylesheets/sb-admin-v2/font-awesome/css/font-awesome.min.css +4 -0
- data/vendor/assets/stylesheets/sb-admin-v2/font-awesome/fonts/FontAwesome.otf +0 -0
- data/vendor/assets/stylesheets/sb-admin-v2/font-awesome/fonts/fontawesome-webfont.eot +0 -0
- data/vendor/assets/stylesheets/sb-admin-v2/font-awesome/fonts/fontawesome-webfont.svg +414 -0
- data/vendor/assets/stylesheets/sb-admin-v2/font-awesome/fonts/fontawesome-webfont.ttf +0 -0
- data/vendor/assets/stylesheets/sb-admin-v2/font-awesome/fonts/fontawesome-webfont.woff +0 -0
- data/vendor/assets/stylesheets/sb-admin-v2/font-awesome/scss/_bordered-pulled.scss +16 -0
- data/vendor/assets/stylesheets/sb-admin-v2/font-awesome/scss/_core.scss +12 -0
- data/vendor/assets/stylesheets/sb-admin-v2/font-awesome/scss/_fixed-width.scss +6 -0
- data/vendor/assets/stylesheets/sb-admin-v2/font-awesome/scss/_icons.scss +412 -0
- data/vendor/assets/stylesheets/sb-admin-v2/font-awesome/scss/_larger.scss +13 -0
- data/vendor/assets/stylesheets/sb-admin-v2/font-awesome/scss/_list.scss +19 -0
- data/vendor/assets/stylesheets/sb-admin-v2/font-awesome/scss/_mixins.scss +20 -0
- data/vendor/assets/stylesheets/sb-admin-v2/font-awesome/scss/_path.scss +14 -0
- data/vendor/assets/stylesheets/sb-admin-v2/font-awesome/scss/_rotated-flipped.scss +9 -0
- data/vendor/assets/stylesheets/sb-admin-v2/font-awesome/scss/_spinning.scss +30 -0
- data/vendor/assets/stylesheets/sb-admin-v2/font-awesome/scss/_stacked.scss +20 -0
- data/vendor/assets/stylesheets/sb-admin-v2/font-awesome/scss/_variables.scss +381 -0
- data/vendor/assets/stylesheets/sb-admin-v2/font-awesome/scss/font-awesome.scss +17 -0
- data/vendor/assets/stylesheets/sb-admin-v2/fonts/glyphicons-halflings-regular.eot +0 -0
- data/vendor/assets/stylesheets/sb-admin-v2/fonts/glyphicons-halflings-regular.svg +229 -0
- data/vendor/assets/stylesheets/sb-admin-v2/fonts/glyphicons-halflings-regular.ttf +0 -0
- data/vendor/assets/stylesheets/sb-admin-v2/fonts/glyphicons-halflings-regular.woff +0 -0
- data/vendor/assets/stylesheets/sb-admin-v2/plugins/dataTables/dataTables.bootstrap.css +233 -0
- data/vendor/assets/stylesheets/sb-admin-v2/plugins/morris/morris-0.4.3.min.css +2 -0
- data/vendor/assets/stylesheets/sb-admin-v2/plugins/social-buttons/social-buttons.css +68 -0
- data/vendor/assets/stylesheets/sb-admin-v2/plugins/timeline/timeline.css +144 -0
- data/vendor/assets/stylesheets/sb-admin-v2/sb-admin.css +329 -0
- data/vendor/patterns/firewalls +60 -0
- data/vendor/patterns/grok-patterns +94 -0
- data/vendor/patterns/haproxy +37 -0
- data/vendor/patterns/java +3 -0
- data/vendor/patterns/junos +9 -0
- data/vendor/patterns/linux-syslog +16 -0
- data/vendor/patterns/mcollective +1 -0
- data/vendor/patterns/mcollective-patterns +4 -0
- data/vendor/patterns/mongodb +4 -0
- data/vendor/patterns/nagios +108 -0
- data/vendor/patterns/postgresql +3 -0
- data/vendor/patterns/redis +3 -0
- data/vendor/patterns/ruby +2 -0
- metadata +659 -0
@@ -0,0 +1,39 @@
|
|
1
|
+
/**
|
2
|
+
* @license
|
3
|
+
* Lo-Dash 2.4.1 (Custom Build) lodash.com/license | Underscore.js 1.5.2 underscorejs.org/LICENSE
|
4
|
+
* Build: `lodash underscore exports="amd,commonjs,global,node" -o ./dist/lodash.underscore.js`
|
5
|
+
*/
|
6
|
+
;(function(){function n(n,r,t){t=(t||0)-1;for(var e=n?n.length:0;++t<e;)if(n[t]===r)return t;return-1}function r(n,r){for(var t=n.m,e=r.m,u=-1,o=t.length;++u<o;){var i=t[u],f=e[u];if(i!==f){if(i>f||typeof i=="undefined")return 1;if(i<f||typeof f=="undefined")return-1}}return n.n-r.n}function t(n){return"\\"+yr[n]}function e(n,r,t){r||(r=0),typeof t=="undefined"&&(t=n?n.length:0);var e=-1;t=t-r||0;for(var u=Array(0>t?0:t);++e<t;)u[e]=n[r+e];return u}function u(n){return n instanceof u?n:new o(n)}function o(n,r){this.__chain__=!!r,this.__wrapped__=n
|
7
|
+
}function i(n){function r(){if(u){var n=e(u);Rr.apply(n,arguments)}if(this instanceof r){var i=f(t.prototype),n=t.apply(i,n||arguments);return O(n)?n:i}return t.apply(o,n||arguments)}var t=n[0],u=n[2],o=n[4];return r}function f(n){return O(n)?Br(n):{}}function a(n,r,t){if(typeof n!="function")return Y;if(typeof r=="undefined"||!("prototype"in n))return n;switch(t){case 1:return function(t){return n.call(r,t)};case 2:return function(t,e){return n.call(r,t,e)};case 3:return function(t,e,u){return n.call(r,t,e,u)
|
8
|
+
};case 4:return function(t,e,u,o){return n.call(r,t,e,u,o)}}return L(n,r)}function l(n){function r(){var n=p?a:this;if(o){var y=e(o);Rr.apply(y,arguments)}return(i||g)&&(y||(y=e(arguments)),i&&Rr.apply(y,i),g&&y.length<c)?(u|=16,l([t,h?u:-4&u,y,null,a,c])):(y||(y=arguments),s&&(t=n[v]),this instanceof r?(n=f(t.prototype),y=t.apply(n,y),O(y)?y:n):t.apply(n,y))}var t=n[0],u=n[1],o=n[2],i=n[3],a=n[4],c=n[5],p=1&u,s=2&u,g=4&u,h=8&u,v=t;return r}function c(n,r){for(var t=-1,e=m(),u=n?n.length:0,o=[];++t<u;){var i=n[t];
|
9
|
+
0>e(r,i)&&o.push(i)}return o}function p(n,r,t,e){e=(e||0)-1;for(var u=n?n.length:0,o=[];++e<u;){var i=n[e];if(i&&typeof i=="object"&&typeof i.length=="number"&&(Cr(i)||b(i))){r||(i=p(i,r,t));var f=-1,a=i.length,l=o.length;for(o.length+=a;++f<a;)o[l++]=i[f]}else t||o.push(i)}return o}function s(n,r,t,e){if(n===r)return 0!==n||1/n==1/r;if(n===n&&!(n&&vr[typeof n]||r&&vr[typeof r]))return false;if(null==n||null==r)return n===r;var o=Er.call(n),i=Er.call(r);if(o!=i)return false;switch(o){case lr:case cr:return+n==+r;
|
10
|
+
case pr:return n!=+n?r!=+r:0==n?1/n==1/r:n==+r;case gr:case hr:return n==r+""}if(i=o==ar,!i){var f=n instanceof u,a=r instanceof u;if(f||a)return s(f?n.__wrapped__:n,a?r.__wrapped__:r,t,e);if(o!=sr)return false;if(o=n.constructor,f=r.constructor,o!=f&&!(A(o)&&o instanceof o&&A(f)&&f instanceof f)&&"constructor"in n&&"constructor"in r)return false}for(t||(t=[]),e||(e=[]),o=t.length;o--;)if(t[o]==n)return e[o]==r;var l=true,c=0;if(t.push(n),e.push(r),i){if(c=r.length,l=c==n.length)for(;c--&&(l=s(n[c],r[c],t,e)););}else Kr(r,function(r,u,o){return Nr.call(o,u)?(c++,!(l=Nr.call(n,u)&&s(n[u],r,t,e))&&er):void 0
|
11
|
+
}),l&&Kr(n,function(n,r,t){return Nr.call(t,r)?!(l=-1<--c)&&er:void 0});return t.pop(),e.pop(),l}function g(n,r,t){for(var e=-1,u=m(),o=n?n.length:0,i=[],f=t?[]:i;++e<o;){var a=n[e],l=t?t(a,e,n):a;(r?!e||f[f.length-1]!==l:0>u(f,l))&&(t&&f.push(l),i.push(a))}return i}function h(n){return function(r,t,e){var u={};t=X(t,e,3),e=-1;var o=r?r.length:0;if(typeof o=="number")for(;++e<o;){var i=r[e];n(u,i,t(i,e,r),r)}else Lr(r,function(r,e,o){n(u,r,t(r,e,o),o)});return u}}function v(n,r,t,e,u,o){var f=16&r,a=32&r;
|
12
|
+
if(!(2&r||A(n)))throw new TypeError;return f&&!t.length&&(r&=-17,t=false),a&&!e.length&&(r&=-33,e=false),(1==r||17===r?i:l)([n,r,t,e,u,o])}function y(n){return Vr[n]}function m(){var r=(r=u.indexOf)===G?n:r;return r}function _(n){return typeof n=="function"&&Ar.test(n)}function d(n){return Gr[n]}function b(n){return n&&typeof n=="object"&&typeof n.length=="number"&&Er.call(n)==fr||false}function w(n){if(!n)return n;for(var r=1,t=arguments.length;r<t;r++){var e=arguments[r];if(e)for(var u in e)n[u]=e[u]}return n
|
13
|
+
}function j(n){if(!n)return n;for(var r=1,t=arguments.length;r<t;r++){var e=arguments[r];if(e)for(var u in e)"undefined"==typeof n[u]&&(n[u]=e[u])}return n}function x(n){var r=[];return Kr(n,function(n,t){A(n)&&r.push(t)}),r.sort()}function T(n){for(var r=-1,t=Ur(n),e=t.length,u={};++r<e;){var o=t[r];u[n[o]]=o}return u}function E(n){if(!n)return true;if(Cr(n)||N(n))return!n.length;for(var r in n)if(Nr.call(n,r))return false;return true}function A(n){return typeof n=="function"}function O(n){return!(!n||!vr[typeof n])
|
14
|
+
}function S(n){return typeof n=="number"||n&&typeof n=="object"&&Er.call(n)==pr||false}function N(n){return typeof n=="string"||n&&typeof n=="object"&&Er.call(n)==hr||false}function R(n){for(var r=-1,t=Ur(n),e=t.length,u=Array(e);++r<e;)u[r]=n[t[r]];return u}function k(n,r){var t=m(),e=n?n.length:0,u=false;return e&&typeof e=="number"?u=-1<t(n,r):Lr(n,function(n){return(u=n===r)&&er}),u}function B(n,r,t){var e=true;r=X(r,t,3),t=-1;var u=n?n.length:0;if(typeof u=="number")for(;++t<u&&(e=!!r(n[t],t,n)););else Lr(n,function(n,t,u){return!(e=!!r(n,t,u))&&er
|
15
|
+
});return e}function F(n,r,t){var e=[];r=X(r,t,3),t=-1;var u=n?n.length:0;if(typeof u=="number")for(;++t<u;){var o=n[t];r(o,t,n)&&e.push(o)}else Lr(n,function(n,t,u){r(n,t,u)&&e.push(n)});return e}function q(n,r,t){r=X(r,t,3),t=-1;var e=n?n.length:0;if(typeof e!="number"){var u;return Lr(n,function(n,t,e){return r(n,t,e)?(u=n,er):void 0}),u}for(;++t<e;){var o=n[t];if(r(o,t,n))return o}}function D(n,r,t){var e=-1,u=n?n.length:0;if(r=r&&typeof t=="undefined"?r:a(r,t,3),typeof u=="number")for(;++e<u&&r(n[e],e,n)!==er;);else Lr(n,r)
|
16
|
+
}function I(n,r){var t=n?n.length:0;if(typeof t=="number")for(;t--&&false!==r(n[t],t,n););else{var e=Ur(n),t=e.length;Lr(n,function(n,u,o){return u=e?e[--t]:--t,false===r(o[u],u,o)&&er})}}function M(n,r,t){var e=-1,u=n?n.length:0;if(r=X(r,t,3),typeof u=="number")for(var o=Array(u);++e<u;)o[e]=r(n[e],e,n);else o=[],Lr(n,function(n,t,u){o[++e]=r(n,t,u)});return o}function $(n,r,t){var e=-1/0,u=e;typeof r!="function"&&t&&t[r]===n&&(r=null);var o=-1,i=n?n.length:0;if(null==r&&typeof i=="number")for(;++o<i;)t=n[o],t>u&&(u=t);
|
17
|
+
else r=X(r,t,3),D(n,function(n,t,o){t=r(n,t,o),t>e&&(e=t,u=n)});return u}function W(n,r,t,e){if(!n)return t;var u=3>arguments.length;r=X(r,e,4);var o=-1,i=n.length;if(typeof i=="number")for(u&&(t=n[++o]);++o<i;)t=r(t,n[o],o,n);else Lr(n,function(n,e,o){t=u?(u=false,n):r(t,n,e,o)});return t}function z(n,r,t,e){var u=3>arguments.length;return r=X(r,e,4),I(n,function(n,e,o){t=u?(u=false,n):r(t,n,e,o)}),t}function C(n){var r=-1,t=n?n.length:0,e=Array(typeof t=="number"?t:0);return D(n,function(n){var t;t=++r,t=0+Sr(Wr()*(t-0+1)),e[r]=e[t],e[t]=n
|
18
|
+
}),e}function P(n,r,t){var e;r=X(r,t,3),t=-1;var u=n?n.length:0;if(typeof u=="number")for(;++t<u&&!(e=r(n[t],t,n)););else Lr(n,function(n,t,u){return(e=r(n,t,u))&&er});return!!e}function U(n,r,t){return t&&E(r)?rr:(t?q:F)(n,r)}function V(n,r,t){var u=0,o=n?n.length:0;if(typeof r!="number"&&null!=r){var i=-1;for(r=X(r,t,3);++i<o&&r(n[i],i,n);)u++}else if(u=r,null==u||t)return n?n[0]:rr;return e(n,0,$r(Mr(0,u),o))}function G(r,t,e){if(typeof e=="number"){var u=r?r.length:0;e=0>e?Mr(0,u+e):e||0}else if(e)return e=J(r,t),r[e]===t?e:-1;
|
19
|
+
return n(r,t,e)}function H(n,r,t){if(typeof r!="number"&&null!=r){var u=0,o=-1,i=n?n.length:0;for(r=X(r,t,3);++o<i&&r(n[o],o,n);)u++}else u=null==r||t?1:Mr(0,r);return e(n,u)}function J(n,r,t,e){var u=0,o=n?n.length:u;for(t=t?X(t,e,1):Y,r=t(r);u<o;)e=u+o>>>1,t(n[e])<r?u=e+1:o=e;return u}function K(n,r,t,e){return typeof r!="boolean"&&null!=r&&(e=t,t=typeof r!="function"&&e&&e[r]===n?null:r,r=false),null!=t&&(t=X(t,e,3)),g(n,r,t)}function L(n,r){return 2<arguments.length?v(n,17,e(arguments,2),null,r):v(n,1,null,null,r)
|
20
|
+
}function Q(n,r,t){var e,u,o,i,f,a,l,c=0,p=false,s=true;if(!A(n))throw new TypeError;if(r=Mr(0,r)||0,true===t)var g=true,s=false;else O(t)&&(g=t.leading,p="maxWait"in t&&(Mr(r,t.maxWait)||0),s="trailing"in t?t.trailing:s);var h=function(){var t=r-(nt()-i);0<t?a=setTimeout(h,t):(u&&clearTimeout(u),t=l,u=a=l=rr,t&&(c=nt(),o=n.apply(f,e),a||u||(e=f=null)))},v=function(){a&&clearTimeout(a),u=a=l=rr,(s||p!==r)&&(c=nt(),o=n.apply(f,e),a||u||(e=f=null))};return function(){if(e=arguments,i=nt(),f=this,l=s&&(a||!g),false===p)var t=g&&!a;
|
21
|
+
else{u||g||(c=i);var y=p-(i-c),m=0>=y;m?(u&&(u=clearTimeout(u)),c=i,o=n.apply(f,e)):u||(u=setTimeout(v,y))}return m&&a?a=clearTimeout(a):a||r===p||(a=setTimeout(h,r)),t&&(m=true,o=n.apply(f,e)),!m||a||u||(e=f=null),o}}function X(n,r,t){var e=typeof n;if(null==n||"function"==e)return a(n,r,t);if("object"!=e)return nr(n);var u=Ur(n);return function(r){for(var t=u.length,e=false;t--&&(e=r[u[t]]===n[u[t]]););return e}}function Y(n){return n}function Z(n){D(x(n),function(r){var t=u[r]=n[r];u.prototype[r]=function(){var n=[this.__wrapped__];
|
22
|
+
return Rr.apply(n,arguments),n=t.apply(u,n),this.__chain__?new o(n,true):n}})}function nr(n){return function(r){return r[n]}}var rr,tr=0,er={},ur=+new Date+"",or=/($^)/,ir=/['\n\r\t\u2028\u2029\\]/g,fr="[object Arguments]",ar="[object Array]",lr="[object Boolean]",cr="[object Date]",pr="[object Number]",sr="[object Object]",gr="[object RegExp]",hr="[object String]",vr={"boolean":false,"function":true,object:true,number:false,string:false,undefined:false},yr={"\\":"\\","'":"'","\n":"n","\r":"r","\t":"t","\u2028":"u2028","\u2029":"u2029"},mr=vr[typeof window]&&window||this,_r=vr[typeof exports]&&exports&&!exports.nodeType&&exports,dr=vr[typeof module]&&module&&!module.nodeType&&module,br=dr&&dr.exports===_r&&_r,wr=vr[typeof global]&&global;
|
23
|
+
!wr||wr.global!==wr&&wr.window!==wr||(mr=wr);var jr=[],xr=Object.prototype,Tr=mr._,Er=xr.toString,Ar=RegExp("^"+(Er+"").replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/toString| for [^\]]+/g,".*?")+"$"),Or=Math.ceil,Sr=Math.floor,Nr=xr.hasOwnProperty,Rr=jr.push,kr=xr.propertyIsEnumerable,Br=_(Br=Object.create)&&Br,Fr=_(Fr=Array.isArray)&&Fr,qr=mr.isFinite,Dr=mr.isNaN,Ir=_(Ir=Object.keys)&&Ir,Mr=Math.max,$r=Math.min,Wr=Math.random;o.prototype=u.prototype;var zr={};!function(){var n={0:1,length:1};zr.spliceObjects=(jr.splice.call(n,0,1),!n[0])
|
24
|
+
}(1),u.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""},Br||(f=function(){function n(){}return function(r){if(O(r)){n.prototype=r;var t=new n;n.prototype=null}return t||mr.Object()}}()),b(arguments)||(b=function(n){return n&&typeof n=="object"&&typeof n.length=="number"&&Nr.call(n,"callee")&&!kr.call(n,"callee")||false});var Cr=Fr||function(n){return n&&typeof n=="object"&&typeof n.length=="number"&&Er.call(n)==ar||false},Pr=function(n){var r,t=[];
|
25
|
+
if(!n||!vr[typeof n])return t;for(r in n)Nr.call(n,r)&&t.push(r);return t},Ur=Ir?function(n){return O(n)?Ir(n):[]}:Pr,Vr={"&":"&","<":"<",">":">",'"':""","'":"'"},Gr=T(Vr),Hr=RegExp("("+Ur(Gr).join("|")+")","g"),Jr=RegExp("["+Ur(Vr).join("")+"]","g"),Kr=function(n,r){var t;if(!n||!vr[typeof n])return n;for(t in n)if(r(n[t],t,n)===er)break;return n},Lr=function(n,r){var t;if(!n||!vr[typeof n])return n;for(t in n)if(Nr.call(n,t)&&r(n[t],t,n)===er)break;return n};A(/x/)&&(A=function(n){return typeof n=="function"&&"[object Function]"==Er.call(n)
|
26
|
+
});var Qr=h(function(n,r,t){Nr.call(n,t)?n[t]++:n[t]=1}),Xr=h(function(n,r,t){(Nr.call(n,t)?n[t]:n[t]=[]).push(r)}),Yr=h(function(n,r,t){n[t]=r}),Zr=M,nt=_(nt=Date.now)&&nt||function(){return(new Date).getTime()};u.after=function(n,r){if(!A(r))throw new TypeError;return function(){return 1>--n?r.apply(this,arguments):void 0}},u.bind=L,u.bindAll=function(n){for(var r=1<arguments.length?p(arguments,true,false,1):x(n),t=-1,e=r.length;++t<e;){var u=r[t];n[u]=v(n[u],1,null,null,n)}return n},u.chain=function(n){return n=new o(n),n.__chain__=true,n
|
27
|
+
},u.compact=function(n){for(var r=-1,t=n?n.length:0,e=[];++r<t;){var u=n[r];u&&e.push(u)}return e},u.compose=function(){for(var n=arguments,r=n.length;r--;)if(!A(n[r]))throw new TypeError;return function(){for(var r=arguments,t=n.length;t--;)r=[n[t].apply(this,r)];return r[0]}},u.countBy=Qr,u.debounce=Q,u.defaults=j,u.defer=function(n){if(!A(n))throw new TypeError;var r=e(arguments,1);return setTimeout(function(){n.apply(rr,r)},1)},u.delay=function(n,r){if(!A(n))throw new TypeError;var t=e(arguments,2);
|
28
|
+
return setTimeout(function(){n.apply(rr,t)},r)},u.difference=function(n){return c(n,p(arguments,true,true,1))},u.filter=F,u.flatten=function(n,r){return p(n,r)},u.forEach=D,u.functions=x,u.groupBy=Xr,u.indexBy=Yr,u.initial=function(n,r,t){var u=0,o=n?n.length:0;if(typeof r!="number"&&null!=r){var i=o;for(r=X(r,t,3);i--&&r(n[i],i,n);)u++}else u=null==r||t?1:r||u;return e(n,0,$r(Mr(0,o-u),o))},u.intersection=function(){for(var n=[],r=-1,t=arguments.length;++r<t;){var e=arguments[r];(Cr(e)||b(e))&&n.push(e)
|
29
|
+
}var u=n[0],o=-1,i=m(),f=u?u.length:0,a=[];n:for(;++o<f;)if(e=u[o],0>i(a,e)){for(r=t;--r;)if(0>i(n[r],e))continue n;a.push(e)}return a},u.invert=T,u.invoke=function(n,r){var t=e(arguments,2),u=-1,o=typeof r=="function",i=n?n.length:0,f=Array(typeof i=="number"?i:0);return D(n,function(n){f[++u]=(o?r:n[r]).apply(n,t)}),f},u.keys=Ur,u.map=M,u.max=$,u.memoize=function(n,r){var t={};return function(){var e=r?r.apply(this,arguments):ur+arguments[0];return Nr.call(t,e)?t[e]:t[e]=n.apply(this,arguments)
|
30
|
+
}},u.min=function(n,r,t){var e=1/0,u=e;typeof r!="function"&&t&&t[r]===n&&(r=null);var o=-1,i=n?n.length:0;if(null==r&&typeof i=="number")for(;++o<i;)t=n[o],t<u&&(u=t);else r=X(r,t,3),D(n,function(n,t,o){t=r(n,t,o),t<e&&(e=t,u=n)});return u},u.omit=function(n){var r=[];Kr(n,function(n,t){r.push(t)});for(var r=c(r,p(arguments,true,false,1)),t=-1,e=r.length,u={};++t<e;){var o=r[t];u[o]=n[o]}return u},u.once=function(n){var r,t;if(!A(n))throw new TypeError;return function(){return r?t:(r=true,t=n.apply(this,arguments),n=null,t)
|
31
|
+
}},u.pairs=function(n){for(var r=-1,t=Ur(n),e=t.length,u=Array(e);++r<e;){var o=t[r];u[r]=[o,n[o]]}return u},u.partial=function(n){return v(n,16,e(arguments,1))},u.pick=function(n){for(var r=-1,t=p(arguments,true,false,1),e=t.length,u={};++r<e;){var o=t[r];o in n&&(u[o]=n[o])}return u},u.pluck=Zr,u.range=function(n,r,t){n=+n||0,t=+t||1,null==r&&(r=n,n=0);var e=-1;r=Mr(0,Or((r-n)/t));for(var u=Array(r);++e<r;)u[e]=n,n+=t;return u},u.reject=function(n,r,t){return r=X(r,t,3),F(n,function(n,t,e){return!r(n,t,e)
|
32
|
+
})},u.rest=H,u.shuffle=C,u.sortBy=function(n,t,e){var u=-1,o=n?n.length:0,i=Array(typeof o=="number"?o:0);for(t=X(t,e,3),D(n,function(n,r,e){i[++u]={m:[t(n,r,e)],n:u,o:n}}),o=i.length,i.sort(r);o--;)i[o]=i[o].o;return i},u.tap=function(n,r){return r(n),n},u.throttle=function(n,r,t){var e=true,u=true;if(!A(n))throw new TypeError;return false===t?e=false:O(t)&&(e="leading"in t?t.leading:e,u="trailing"in t?t.trailing:u),t={},t.leading=e,t.maxWait=r,t.trailing=u,Q(n,r,t)},u.times=function(n,r,t){n=-1<(n=+n)?n:0;
|
33
|
+
var e=-1,u=Array(n);for(r=a(r,t,1);++e<n;)u[e]=r(e);return u},u.toArray=function(n){return Cr(n)?e(n):n&&typeof n.length=="number"?M(n):R(n)},u.union=function(){return g(p(arguments,true,true))},u.uniq=K,u.values=R,u.where=U,u.without=function(n){return c(n,e(arguments,1))},u.wrap=function(n,r){return v(r,16,[n])},u.zip=function(){for(var n=-1,r=$(Zr(arguments,"length")),t=Array(0>r?0:r);++n<r;)t[n]=Zr(arguments,n);return t},u.collect=M,u.drop=H,u.each=D,u.extend=w,u.methods=x,u.object=function(n,r){var t=-1,e=n?n.length:0,u={};
|
34
|
+
for(r||!e||Cr(n[0])||(r=[]);++t<e;){var o=n[t];r?u[o]=r[t]:o&&(u[o[0]]=o[1])}return u},u.select=F,u.tail=H,u.unique=K,u.clone=function(n){return O(n)?Cr(n)?e(n):w({},n):n},u.contains=k,u.escape=function(n){return null==n?"":(n+"").replace(Jr,y)},u.every=B,u.find=q,u.has=function(n,r){return n?Nr.call(n,r):false},u.identity=Y,u.indexOf=G,u.isArguments=b,u.isArray=Cr,u.isBoolean=function(n){return true===n||false===n||n&&typeof n=="object"&&Er.call(n)==lr||false},u.isDate=function(n){return n&&typeof n=="object"&&Er.call(n)==cr||false
|
35
|
+
},u.isElement=function(n){return n&&1===n.nodeType||false},u.isEmpty=E,u.isEqual=function(n,r){return s(n,r)},u.isFinite=function(n){return qr(n)&&!Dr(parseFloat(n))},u.isFunction=A,u.isNaN=function(n){return S(n)&&n!=+n},u.isNull=function(n){return null===n},u.isNumber=S,u.isObject=O,u.isRegExp=function(n){return n&&vr[typeof n]&&Er.call(n)==gr||false},u.isString=N,u.isUndefined=function(n){return typeof n=="undefined"},u.lastIndexOf=function(n,r,t){var e=n?n.length:0;for(typeof t=="number"&&(e=(0>t?Mr(0,e+t):$r(t,e-1))+1);e--;)if(n[e]===r)return e;
|
36
|
+
return-1},u.mixin=Z,u.noConflict=function(){return mr._=Tr,this},u.random=function(n,r){return null==n&&null==r&&(r=1),n=+n||0,null==r?(r=n,n=0):r=+r||0,n+Sr(Wr()*(r-n+1))},u.reduce=W,u.reduceRight=z,u.result=function(n,r){if(n){var t=n[r];return A(t)?n[r]():t}},u.size=function(n){var r=n?n.length:0;return typeof r=="number"?r:Ur(n).length},u.some=P,u.sortedIndex=J,u.template=function(n,r,e){var o=u,i=o.templateSettings;n=(n||"")+"",e=j({},e,i);var f=0,a="__p+='",i=e.variable;n.replace(RegExp((e.escape||or).source+"|"+(e.interpolate||or).source+"|"+(e.evaluate||or).source+"|$","g"),function(r,e,u,o,i){return a+=n.slice(f,i).replace(ir,t),e&&(a+="'+_.escape("+e+")+'"),o&&(a+="';"+o+";\n__p+='"),u&&(a+="'+((__t=("+u+"))==null?'':__t)+'"),f=i+r.length,r
|
37
|
+
}),a+="';",i||(i="obj",a="with("+i+"||{}){"+a+"}"),a="function("+i+"){var __t,__p='',__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+a+"return __p}";try{var l=Function("_","return "+a)(o)}catch(c){throw c.source=a,c}return r?l(r):(l.source=a,l)},u.unescape=function(n){return null==n?"":(n+"").replace(Hr,d)},u.uniqueId=function(n){var r=++tr+"";return n?n+r:r},u.all=B,u.any=P,u.detect=q,u.findWhere=function(n,r){return U(n,r,true)},u.foldl=W,u.foldr=z,u.include=k,u.inject=W,u.first=V,u.last=function(n,r,t){var u=0,o=n?n.length:0;
|
38
|
+
if(typeof r!="number"&&null!=r){var i=o;for(r=X(r,t,3);i--&&r(n[i],i,n);)u++}else if(u=r,null==u||t)return n?n[o-1]:rr;return e(n,Mr(0,o-u))},u.sample=function(n,r,t){return n&&typeof n.length!="number"&&(n=R(n)),null==r||t?n?n[0+Sr(Wr()*(n.length-1-0+1))]:rr:(n=C(n),n.length=$r(Mr(0,r),n.length),n)},u.take=V,u.head=V,Z(u),u.VERSION="2.4.1",u.prototype.chain=function(){return this.__chain__=true,this},u.prototype.value=function(){return this.__wrapped__},D("pop push reverse shift sort splice unshift".split(" "),function(n){var r=jr[n];
|
39
|
+
u.prototype[n]=function(){var n=this.__wrapped__;return r.apply(n,arguments),zr.spliceObjects||0!==n.length||delete n[0],this}}),D(["concat","join","slice"],function(n){var r=jr[n];u.prototype[n]=function(){var n=r.apply(this.__wrapped__,arguments);return this.__chain__&&(n=new o(n),n.__chain__=true),n}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(mr._=u, define(function(){return u})):_r&&dr?br?(dr.exports=u)._=u:_r._=u:mr._=u}).call(this);
|
@@ -0,0 +1,29 @@
|
|
1
|
+
{
|
2
|
+
"name": "vue",
|
3
|
+
"version": "0.10.5",
|
4
|
+
"main": "dist/vue.js",
|
5
|
+
"description": "Simple, Fast & Composable MVVM for building interative interfaces",
|
6
|
+
"authors": [
|
7
|
+
"Evan You <yyx990803@gmail.com>"
|
8
|
+
],
|
9
|
+
"license": "MIT",
|
10
|
+
"ignore": [
|
11
|
+
".*",
|
12
|
+
"examples",
|
13
|
+
"test",
|
14
|
+
"tasks",
|
15
|
+
"Gruntfile.js",
|
16
|
+
"*.json",
|
17
|
+
"*.md"
|
18
|
+
],
|
19
|
+
"homepage": "https://github.com/yyx990803/vue",
|
20
|
+
"_release": "0.10.5",
|
21
|
+
"_resolution": {
|
22
|
+
"type": "version",
|
23
|
+
"tag": "v0.10.5",
|
24
|
+
"commit": "fe996b388971b014279b1f90df26ef95d8b00f05"
|
25
|
+
},
|
26
|
+
"_source": "git://github.com/yyx990803/vue.git",
|
27
|
+
"_target": "~0.10.0",
|
28
|
+
"_originalSource": "vue"
|
29
|
+
}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2013 Yuxi Evan You
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
@@ -0,0 +1,4713 @@
|
|
1
|
+
/*
|
2
|
+
Vue.js v0.10.5
|
3
|
+
(c) 2014 Evan You
|
4
|
+
License: MIT
|
5
|
+
*/
|
6
|
+
;(function(){
|
7
|
+
'use strict';
|
8
|
+
|
9
|
+
/**
|
10
|
+
* Require the given path.
|
11
|
+
*
|
12
|
+
* @param {String} path
|
13
|
+
* @return {Object} exports
|
14
|
+
* @api public
|
15
|
+
*/
|
16
|
+
|
17
|
+
function require(path, parent, orig) {
|
18
|
+
var resolved = require.resolve(path);
|
19
|
+
|
20
|
+
// lookup failed
|
21
|
+
if (null == resolved) {
|
22
|
+
throwError()
|
23
|
+
return
|
24
|
+
}
|
25
|
+
|
26
|
+
var module = require.modules[resolved];
|
27
|
+
|
28
|
+
// perform real require()
|
29
|
+
// by invoking the module's
|
30
|
+
// registered function
|
31
|
+
if (!module._resolving && !module.exports) {
|
32
|
+
var mod = {};
|
33
|
+
mod.exports = {};
|
34
|
+
mod.client = mod.component = true;
|
35
|
+
module._resolving = true;
|
36
|
+
module.call(this, mod.exports, require.relative(resolved), mod);
|
37
|
+
delete module._resolving;
|
38
|
+
module.exports = mod.exports;
|
39
|
+
}
|
40
|
+
|
41
|
+
function throwError () {
|
42
|
+
orig = orig || path;
|
43
|
+
parent = parent || 'root';
|
44
|
+
var err = new Error('Failed to require "' + orig + '" from "' + parent + '"');
|
45
|
+
err.path = orig;
|
46
|
+
err.parent = parent;
|
47
|
+
err.require = true;
|
48
|
+
throw err;
|
49
|
+
}
|
50
|
+
|
51
|
+
return module.exports;
|
52
|
+
}
|
53
|
+
|
54
|
+
/**
|
55
|
+
* Registered modules.
|
56
|
+
*/
|
57
|
+
|
58
|
+
require.modules = {};
|
59
|
+
|
60
|
+
/**
|
61
|
+
* Registered aliases.
|
62
|
+
*/
|
63
|
+
|
64
|
+
require.aliases = {};
|
65
|
+
|
66
|
+
/**
|
67
|
+
* Resolve `path`.
|
68
|
+
*
|
69
|
+
* Lookup:
|
70
|
+
*
|
71
|
+
* - PATH/index.js
|
72
|
+
* - PATH.js
|
73
|
+
* - PATH
|
74
|
+
*
|
75
|
+
* @param {String} path
|
76
|
+
* @return {String} path or null
|
77
|
+
* @api private
|
78
|
+
*/
|
79
|
+
|
80
|
+
require.exts = [
|
81
|
+
'',
|
82
|
+
'.js',
|
83
|
+
'.json',
|
84
|
+
'/index.js',
|
85
|
+
'/index.json'
|
86
|
+
];
|
87
|
+
|
88
|
+
require.resolve = function(path) {
|
89
|
+
if (path.charAt(0) === '/') path = path.slice(1);
|
90
|
+
|
91
|
+
for (var i = 0; i < 5; i++) {
|
92
|
+
var fullPath = path + require.exts[i];
|
93
|
+
if (require.modules.hasOwnProperty(fullPath)) return fullPath;
|
94
|
+
if (require.aliases.hasOwnProperty(fullPath)) return require.aliases[fullPath];
|
95
|
+
}
|
96
|
+
};
|
97
|
+
|
98
|
+
/**
|
99
|
+
* Normalize `path` relative to the current path.
|
100
|
+
*
|
101
|
+
* @param {String} curr
|
102
|
+
* @param {String} path
|
103
|
+
* @return {String}
|
104
|
+
* @api private
|
105
|
+
*/
|
106
|
+
|
107
|
+
require.normalize = function(curr, path) {
|
108
|
+
|
109
|
+
var segs = [];
|
110
|
+
|
111
|
+
if ('.' != path.charAt(0)) return path;
|
112
|
+
|
113
|
+
curr = curr.split('/');
|
114
|
+
path = path.split('/');
|
115
|
+
|
116
|
+
for (var i = 0; i < path.length; ++i) {
|
117
|
+
if ('..' === path[i]) {
|
118
|
+
curr.pop();
|
119
|
+
} else if ('.' != path[i] && '' != path[i]) {
|
120
|
+
segs.push(path[i]);
|
121
|
+
}
|
122
|
+
}
|
123
|
+
return curr.concat(segs).join('/');
|
124
|
+
};
|
125
|
+
|
126
|
+
/**
|
127
|
+
* Register module at `path` with callback `definition`.
|
128
|
+
*
|
129
|
+
* @param {String} path
|
130
|
+
* @param {Function} definition
|
131
|
+
* @api private
|
132
|
+
*/
|
133
|
+
|
134
|
+
require.register = function(path, definition) {
|
135
|
+
require.modules[path] = definition;
|
136
|
+
};
|
137
|
+
|
138
|
+
/**
|
139
|
+
* Alias a module definition.
|
140
|
+
*
|
141
|
+
* @param {String} from
|
142
|
+
* @param {String} to
|
143
|
+
* @api private
|
144
|
+
*/
|
145
|
+
|
146
|
+
require.alias = function(from, to) {
|
147
|
+
if (!require.modules.hasOwnProperty(from)) {
|
148
|
+
throwError()
|
149
|
+
return
|
150
|
+
}
|
151
|
+
require.aliases[to] = from;
|
152
|
+
|
153
|
+
function throwError () {
|
154
|
+
throw new Error('Failed to alias "' + from + '", it does not exist');
|
155
|
+
}
|
156
|
+
};
|
157
|
+
|
158
|
+
/**
|
159
|
+
* Return a require function relative to the `parent` path.
|
160
|
+
*
|
161
|
+
* @param {String} parent
|
162
|
+
* @return {Function}
|
163
|
+
* @api private
|
164
|
+
*/
|
165
|
+
|
166
|
+
require.relative = function(parent) {
|
167
|
+
var p = require.normalize(parent, '..');
|
168
|
+
|
169
|
+
/**
|
170
|
+
* The relative require() itself.
|
171
|
+
*/
|
172
|
+
|
173
|
+
function localRequire(path) {
|
174
|
+
var resolved = localRequire.resolve(path);
|
175
|
+
return require(resolved, parent, path);
|
176
|
+
}
|
177
|
+
|
178
|
+
/**
|
179
|
+
* Resolve relative to the parent.
|
180
|
+
*/
|
181
|
+
|
182
|
+
localRequire.resolve = function(path) {
|
183
|
+
var c = path.charAt(0);
|
184
|
+
if ('/' === c) return path.slice(1);
|
185
|
+
if ('.' === c) return require.normalize(p, path);
|
186
|
+
|
187
|
+
// resolve deps by returning
|
188
|
+
// the dep in the nearest "deps"
|
189
|
+
// directory
|
190
|
+
var segs = parent.split('/');
|
191
|
+
var i = segs.length;
|
192
|
+
while (i--) {
|
193
|
+
if (segs[i] === 'deps') {
|
194
|
+
break;
|
195
|
+
}
|
196
|
+
}
|
197
|
+
path = segs.slice(0, i + 2).join('/') + '/deps/' + path;
|
198
|
+
return path;
|
199
|
+
};
|
200
|
+
|
201
|
+
/**
|
202
|
+
* Check if module is defined at `path`.
|
203
|
+
*/
|
204
|
+
|
205
|
+
localRequire.exists = function(path) {
|
206
|
+
return require.modules.hasOwnProperty(localRequire.resolve(path));
|
207
|
+
};
|
208
|
+
|
209
|
+
return localRequire;
|
210
|
+
};
|
211
|
+
require.register("vue/src/main.js", function(exports, require, module){
|
212
|
+
var config = require('./config'),
|
213
|
+
ViewModel = require('./viewmodel'),
|
214
|
+
utils = require('./utils'),
|
215
|
+
makeHash = utils.hash,
|
216
|
+
assetTypes = ['directive', 'filter', 'partial', 'effect', 'component']
|
217
|
+
|
218
|
+
// require these so Browserify can catch them
|
219
|
+
// so they can be used in Vue.require
|
220
|
+
require('./observer')
|
221
|
+
require('./transition')
|
222
|
+
|
223
|
+
ViewModel.options = config.globalAssets = {
|
224
|
+
directives : require('./directives'),
|
225
|
+
filters : require('./filters'),
|
226
|
+
partials : makeHash(),
|
227
|
+
effects : makeHash(),
|
228
|
+
components : makeHash()
|
229
|
+
}
|
230
|
+
|
231
|
+
/**
|
232
|
+
* Expose asset registration methods
|
233
|
+
*/
|
234
|
+
assetTypes.forEach(function (type) {
|
235
|
+
ViewModel[type] = function (id, value) {
|
236
|
+
var hash = this.options[type + 's']
|
237
|
+
if (!hash) {
|
238
|
+
hash = this.options[type + 's'] = makeHash()
|
239
|
+
}
|
240
|
+
if (!value) return hash[id]
|
241
|
+
if (type === 'partial') {
|
242
|
+
value = utils.toFragment(value)
|
243
|
+
} else if (type === 'component') {
|
244
|
+
value = utils.toConstructor(value)
|
245
|
+
} else if (type === 'filter') {
|
246
|
+
utils.checkFilter(value)
|
247
|
+
}
|
248
|
+
hash[id] = value
|
249
|
+
return this
|
250
|
+
}
|
251
|
+
})
|
252
|
+
|
253
|
+
/**
|
254
|
+
* Set config options
|
255
|
+
*/
|
256
|
+
ViewModel.config = function (opts, val) {
|
257
|
+
if (typeof opts === 'string') {
|
258
|
+
if (val === undefined) {
|
259
|
+
return config[opts]
|
260
|
+
} else {
|
261
|
+
config[opts] = val
|
262
|
+
}
|
263
|
+
} else {
|
264
|
+
utils.extend(config, opts)
|
265
|
+
}
|
266
|
+
return this
|
267
|
+
}
|
268
|
+
|
269
|
+
/**
|
270
|
+
* Expose an interface for plugins
|
271
|
+
*/
|
272
|
+
ViewModel.use = function (plugin) {
|
273
|
+
if (typeof plugin === 'string') {
|
274
|
+
try {
|
275
|
+
plugin = require(plugin)
|
276
|
+
} catch (e) {
|
277
|
+
utils.warn('Cannot find plugin: ' + plugin)
|
278
|
+
return
|
279
|
+
}
|
280
|
+
}
|
281
|
+
|
282
|
+
// additional parameters
|
283
|
+
var args = [].slice.call(arguments, 1)
|
284
|
+
args.unshift(this)
|
285
|
+
|
286
|
+
if (typeof plugin.install === 'function') {
|
287
|
+
plugin.install.apply(plugin, args)
|
288
|
+
} else {
|
289
|
+
plugin.apply(null, args)
|
290
|
+
}
|
291
|
+
return this
|
292
|
+
}
|
293
|
+
|
294
|
+
/**
|
295
|
+
* Expose internal modules for plugins
|
296
|
+
*/
|
297
|
+
ViewModel.require = function (path) {
|
298
|
+
return require('./' + path)
|
299
|
+
}
|
300
|
+
|
301
|
+
ViewModel.extend = extend
|
302
|
+
ViewModel.nextTick = utils.nextTick
|
303
|
+
|
304
|
+
/**
|
305
|
+
* Expose the main ViewModel class
|
306
|
+
* and add extend method
|
307
|
+
*/
|
308
|
+
function extend (options) {
|
309
|
+
|
310
|
+
var ParentVM = this
|
311
|
+
|
312
|
+
// extend data options need to be copied
|
313
|
+
// on instantiation
|
314
|
+
if (options.data) {
|
315
|
+
options.defaultData = options.data
|
316
|
+
delete options.data
|
317
|
+
}
|
318
|
+
|
319
|
+
// inherit options
|
320
|
+
// but only when the super class is not the native Vue.
|
321
|
+
if (ParentVM !== ViewModel) {
|
322
|
+
options = inheritOptions(options, ParentVM.options, true)
|
323
|
+
}
|
324
|
+
utils.processOptions(options)
|
325
|
+
|
326
|
+
var ExtendedVM = function (opts, asParent) {
|
327
|
+
if (!asParent) {
|
328
|
+
opts = inheritOptions(opts, options, true)
|
329
|
+
}
|
330
|
+
ParentVM.call(this, opts, true)
|
331
|
+
}
|
332
|
+
|
333
|
+
// inherit prototype props
|
334
|
+
var proto = ExtendedVM.prototype = Object.create(ParentVM.prototype)
|
335
|
+
utils.defProtected(proto, 'constructor', ExtendedVM)
|
336
|
+
|
337
|
+
// allow extended VM to be further extended
|
338
|
+
ExtendedVM.extend = extend
|
339
|
+
ExtendedVM.super = ParentVM
|
340
|
+
ExtendedVM.options = options
|
341
|
+
|
342
|
+
// allow extended VM to add its own assets
|
343
|
+
assetTypes.forEach(function (type) {
|
344
|
+
ExtendedVM[type] = ViewModel[type]
|
345
|
+
})
|
346
|
+
|
347
|
+
// allow extended VM to use plugins
|
348
|
+
ExtendedVM.use = ViewModel.use
|
349
|
+
ExtendedVM.require = ViewModel.require
|
350
|
+
|
351
|
+
return ExtendedVM
|
352
|
+
}
|
353
|
+
|
354
|
+
/**
|
355
|
+
* Inherit options
|
356
|
+
*
|
357
|
+
* For options such as `data`, `vms`, `directives`, 'partials',
|
358
|
+
* they should be further extended. However extending should only
|
359
|
+
* be done at top level.
|
360
|
+
*
|
361
|
+
* `proto` is an exception because it's handled directly on the
|
362
|
+
* prototype.
|
363
|
+
*
|
364
|
+
* `el` is an exception because it's not allowed as an
|
365
|
+
* extension option, but only as an instance option.
|
366
|
+
*/
|
367
|
+
function inheritOptions (child, parent, topLevel) {
|
368
|
+
child = child || {}
|
369
|
+
if (!parent) return child
|
370
|
+
for (var key in parent) {
|
371
|
+
if (key === 'el') continue
|
372
|
+
var val = child[key],
|
373
|
+
parentVal = parent[key]
|
374
|
+
if (topLevel && typeof val === 'function' && parentVal) {
|
375
|
+
// merge hook functions into an array
|
376
|
+
child[key] = [val]
|
377
|
+
if (Array.isArray(parentVal)) {
|
378
|
+
child[key] = child[key].concat(parentVal)
|
379
|
+
} else {
|
380
|
+
child[key].push(parentVal)
|
381
|
+
}
|
382
|
+
} else if (
|
383
|
+
topLevel &&
|
384
|
+
(utils.isTrueObject(val) || utils.isTrueObject(parentVal))
|
385
|
+
&& !(parentVal instanceof ViewModel)
|
386
|
+
) {
|
387
|
+
// merge toplevel object options
|
388
|
+
child[key] = inheritOptions(val, parentVal)
|
389
|
+
} else if (val === undefined) {
|
390
|
+
// inherit if child doesn't override
|
391
|
+
child[key] = parentVal
|
392
|
+
}
|
393
|
+
}
|
394
|
+
return child
|
395
|
+
}
|
396
|
+
|
397
|
+
module.exports = ViewModel
|
398
|
+
});
|
399
|
+
require.register("vue/src/emitter.js", function(exports, require, module){
|
400
|
+
var slice = [].slice
|
401
|
+
|
402
|
+
function Emitter (ctx) {
|
403
|
+
this._ctx = ctx || this
|
404
|
+
}
|
405
|
+
|
406
|
+
var EmitterProto = Emitter.prototype
|
407
|
+
|
408
|
+
EmitterProto.on = function (event, fn) {
|
409
|
+
this._cbs = this._cbs || {}
|
410
|
+
;(this._cbs[event] = this._cbs[event] || [])
|
411
|
+
.push(fn)
|
412
|
+
return this
|
413
|
+
}
|
414
|
+
|
415
|
+
EmitterProto.once = function (event, fn) {
|
416
|
+
var self = this
|
417
|
+
this._cbs = this._cbs || {}
|
418
|
+
|
419
|
+
function on () {
|
420
|
+
self.off(event, on)
|
421
|
+
fn.apply(this, arguments)
|
422
|
+
}
|
423
|
+
|
424
|
+
on.fn = fn
|
425
|
+
this.on(event, on)
|
426
|
+
return this
|
427
|
+
}
|
428
|
+
|
429
|
+
EmitterProto.off = function (event, fn) {
|
430
|
+
this._cbs = this._cbs || {}
|
431
|
+
|
432
|
+
// all
|
433
|
+
if (!arguments.length) {
|
434
|
+
this._cbs = {}
|
435
|
+
return this
|
436
|
+
}
|
437
|
+
|
438
|
+
// specific event
|
439
|
+
var callbacks = this._cbs[event]
|
440
|
+
if (!callbacks) return this
|
441
|
+
|
442
|
+
// remove all handlers
|
443
|
+
if (arguments.length === 1) {
|
444
|
+
delete this._cbs[event]
|
445
|
+
return this
|
446
|
+
}
|
447
|
+
|
448
|
+
// remove specific handler
|
449
|
+
var cb
|
450
|
+
for (var i = 0; i < callbacks.length; i++) {
|
451
|
+
cb = callbacks[i]
|
452
|
+
if (cb === fn || cb.fn === fn) {
|
453
|
+
callbacks.splice(i, 1)
|
454
|
+
break
|
455
|
+
}
|
456
|
+
}
|
457
|
+
return this
|
458
|
+
}
|
459
|
+
|
460
|
+
/**
|
461
|
+
* The internal, faster emit with fixed amount of arguments
|
462
|
+
* using Function.call
|
463
|
+
*/
|
464
|
+
EmitterProto.emit = function (event, a, b, c) {
|
465
|
+
this._cbs = this._cbs || {}
|
466
|
+
var callbacks = this._cbs[event]
|
467
|
+
|
468
|
+
if (callbacks) {
|
469
|
+
callbacks = callbacks.slice(0)
|
470
|
+
for (var i = 0, len = callbacks.length; i < len; i++) {
|
471
|
+
callbacks[i].call(this._ctx, a, b, c)
|
472
|
+
}
|
473
|
+
}
|
474
|
+
|
475
|
+
return this
|
476
|
+
}
|
477
|
+
|
478
|
+
/**
|
479
|
+
* The external emit using Function.apply
|
480
|
+
*/
|
481
|
+
EmitterProto.applyEmit = function (event) {
|
482
|
+
this._cbs = this._cbs || {}
|
483
|
+
var callbacks = this._cbs[event], args
|
484
|
+
|
485
|
+
if (callbacks) {
|
486
|
+
callbacks = callbacks.slice(0)
|
487
|
+
args = slice.call(arguments, 1)
|
488
|
+
for (var i = 0, len = callbacks.length; i < len; i++) {
|
489
|
+
callbacks[i].apply(this._ctx, args)
|
490
|
+
}
|
491
|
+
}
|
492
|
+
|
493
|
+
return this
|
494
|
+
}
|
495
|
+
|
496
|
+
module.exports = Emitter
|
497
|
+
});
|
498
|
+
require.register("vue/src/config.js", function(exports, require, module){
|
499
|
+
var TextParser = require('./text-parser')
|
500
|
+
|
501
|
+
module.exports = {
|
502
|
+
prefix : 'v',
|
503
|
+
debug : false,
|
504
|
+
silent : false,
|
505
|
+
enterClass : 'v-enter',
|
506
|
+
leaveClass : 'v-leave',
|
507
|
+
interpolate : true
|
508
|
+
}
|
509
|
+
|
510
|
+
Object.defineProperty(module.exports, 'delimiters', {
|
511
|
+
get: function () {
|
512
|
+
return TextParser.delimiters
|
513
|
+
},
|
514
|
+
set: function (delimiters) {
|
515
|
+
TextParser.setDelimiters(delimiters)
|
516
|
+
}
|
517
|
+
})
|
518
|
+
});
|
519
|
+
require.register("vue/src/utils.js", function(exports, require, module){
|
520
|
+
var config = require('./config'),
|
521
|
+
toString = ({}).toString,
|
522
|
+
win = window,
|
523
|
+
console = win.console,
|
524
|
+
def = Object.defineProperty,
|
525
|
+
OBJECT = 'object',
|
526
|
+
THIS_RE = /[^\w]this[^\w]/,
|
527
|
+
BRACKET_RE_S = /\['([^']+)'\]/g,
|
528
|
+
BRACKET_RE_D = /\["([^"]+)"\]/g,
|
529
|
+
hasClassList = 'classList' in document.documentElement,
|
530
|
+
ViewModel // late def
|
531
|
+
|
532
|
+
var defer =
|
533
|
+
win.requestAnimationFrame ||
|
534
|
+
win.webkitRequestAnimationFrame ||
|
535
|
+
win.setTimeout
|
536
|
+
|
537
|
+
/**
|
538
|
+
* Normalize keypath with possible brackets into dot notations
|
539
|
+
*/
|
540
|
+
function normalizeKeypath (key) {
|
541
|
+
return key.indexOf('[') < 0
|
542
|
+
? key
|
543
|
+
: key.replace(BRACKET_RE_S, '.$1')
|
544
|
+
.replace(BRACKET_RE_D, '.$1')
|
545
|
+
}
|
546
|
+
|
547
|
+
var utils = module.exports = {
|
548
|
+
|
549
|
+
/**
|
550
|
+
* Convert a string template to a dom fragment
|
551
|
+
*/
|
552
|
+
toFragment: require('./fragment'),
|
553
|
+
|
554
|
+
/**
|
555
|
+
* get a value from an object keypath
|
556
|
+
*/
|
557
|
+
get: function (obj, key) {
|
558
|
+
/* jshint eqeqeq: false */
|
559
|
+
key = normalizeKeypath(key)
|
560
|
+
if (key.indexOf('.') < 0) {
|
561
|
+
return obj[key]
|
562
|
+
}
|
563
|
+
var path = key.split('.'),
|
564
|
+
d = -1, l = path.length
|
565
|
+
while (++d < l && obj != null) {
|
566
|
+
obj = obj[path[d]]
|
567
|
+
}
|
568
|
+
return obj
|
569
|
+
},
|
570
|
+
|
571
|
+
/**
|
572
|
+
* set a value to an object keypath
|
573
|
+
*/
|
574
|
+
set: function (obj, key, val) {
|
575
|
+
/* jshint eqeqeq: false */
|
576
|
+
key = normalizeKeypath(key)
|
577
|
+
if (key.indexOf('.') < 0) {
|
578
|
+
obj[key] = val
|
579
|
+
return
|
580
|
+
}
|
581
|
+
var path = key.split('.'),
|
582
|
+
d = -1, l = path.length - 1
|
583
|
+
while (++d < l) {
|
584
|
+
if (obj[path[d]] == null) {
|
585
|
+
obj[path[d]] = {}
|
586
|
+
}
|
587
|
+
obj = obj[path[d]]
|
588
|
+
}
|
589
|
+
obj[path[d]] = val
|
590
|
+
},
|
591
|
+
|
592
|
+
/**
|
593
|
+
* return the base segment of a keypath
|
594
|
+
*/
|
595
|
+
baseKey: function (key) {
|
596
|
+
return key.indexOf('.') > 0
|
597
|
+
? key.split('.')[0]
|
598
|
+
: key
|
599
|
+
},
|
600
|
+
|
601
|
+
/**
|
602
|
+
* Create a prototype-less object
|
603
|
+
* which is a better hash/map
|
604
|
+
*/
|
605
|
+
hash: function () {
|
606
|
+
return Object.create(null)
|
607
|
+
},
|
608
|
+
|
609
|
+
/**
|
610
|
+
* get an attribute and remove it.
|
611
|
+
*/
|
612
|
+
attr: function (el, type) {
|
613
|
+
var attr = config.prefix + '-' + type,
|
614
|
+
val = el.getAttribute(attr)
|
615
|
+
if (val !== null) {
|
616
|
+
el.removeAttribute(attr)
|
617
|
+
}
|
618
|
+
return val
|
619
|
+
},
|
620
|
+
|
621
|
+
/**
|
622
|
+
* Define an ienumerable property
|
623
|
+
* This avoids it being included in JSON.stringify
|
624
|
+
* or for...in loops.
|
625
|
+
*/
|
626
|
+
defProtected: function (obj, key, val, enumerable, writable) {
|
627
|
+
def(obj, key, {
|
628
|
+
value : val,
|
629
|
+
enumerable : enumerable,
|
630
|
+
writable : writable,
|
631
|
+
configurable : true
|
632
|
+
})
|
633
|
+
},
|
634
|
+
|
635
|
+
/**
|
636
|
+
* A less bullet-proof but more efficient type check
|
637
|
+
* than Object.prototype.toString
|
638
|
+
*/
|
639
|
+
isObject: function (obj) {
|
640
|
+
return typeof obj === OBJECT && obj && !Array.isArray(obj)
|
641
|
+
},
|
642
|
+
|
643
|
+
/**
|
644
|
+
* A more accurate but less efficient type check
|
645
|
+
*/
|
646
|
+
isTrueObject: function (obj) {
|
647
|
+
return toString.call(obj) === '[object Object]'
|
648
|
+
},
|
649
|
+
|
650
|
+
/**
|
651
|
+
* Most simple bind
|
652
|
+
* enough for the usecase and fast than native bind()
|
653
|
+
*/
|
654
|
+
bind: function (fn, ctx) {
|
655
|
+
return function (arg) {
|
656
|
+
return fn.call(ctx, arg)
|
657
|
+
}
|
658
|
+
},
|
659
|
+
|
660
|
+
/**
|
661
|
+
* Make sure null and undefined output empty string
|
662
|
+
*/
|
663
|
+
guard: function (value) {
|
664
|
+
/* jshint eqeqeq: false, eqnull: true */
|
665
|
+
return value == null
|
666
|
+
? ''
|
667
|
+
: (typeof value == 'object')
|
668
|
+
? JSON.stringify(value)
|
669
|
+
: value
|
670
|
+
},
|
671
|
+
|
672
|
+
/**
|
673
|
+
* When setting value on the VM, parse possible numbers
|
674
|
+
*/
|
675
|
+
checkNumber: function (value) {
|
676
|
+
return (isNaN(value) || value === null || typeof value === 'boolean')
|
677
|
+
? value
|
678
|
+
: Number(value)
|
679
|
+
},
|
680
|
+
|
681
|
+
/**
|
682
|
+
* simple extend
|
683
|
+
*/
|
684
|
+
extend: function (obj, ext) {
|
685
|
+
for (var key in ext) {
|
686
|
+
if (obj[key] !== ext[key]) {
|
687
|
+
obj[key] = ext[key]
|
688
|
+
}
|
689
|
+
}
|
690
|
+
return obj
|
691
|
+
},
|
692
|
+
|
693
|
+
/**
|
694
|
+
* filter an array with duplicates into uniques
|
695
|
+
*/
|
696
|
+
unique: function (arr) {
|
697
|
+
var hash = utils.hash(),
|
698
|
+
i = arr.length,
|
699
|
+
key, res = []
|
700
|
+
while (i--) {
|
701
|
+
key = arr[i]
|
702
|
+
if (hash[key]) continue
|
703
|
+
hash[key] = 1
|
704
|
+
res.push(key)
|
705
|
+
}
|
706
|
+
return res
|
707
|
+
},
|
708
|
+
|
709
|
+
/**
|
710
|
+
* Convert the object to a ViewModel constructor
|
711
|
+
* if it is not already one
|
712
|
+
*/
|
713
|
+
toConstructor: function (obj) {
|
714
|
+
ViewModel = ViewModel || require('./viewmodel')
|
715
|
+
return utils.isObject(obj)
|
716
|
+
? ViewModel.extend(obj)
|
717
|
+
: typeof obj === 'function'
|
718
|
+
? obj
|
719
|
+
: null
|
720
|
+
},
|
721
|
+
|
722
|
+
/**
|
723
|
+
* Check if a filter function contains references to `this`
|
724
|
+
* If yes, mark it as a computed filter.
|
725
|
+
*/
|
726
|
+
checkFilter: function (filter) {
|
727
|
+
if (THIS_RE.test(filter.toString())) {
|
728
|
+
filter.computed = true
|
729
|
+
}
|
730
|
+
},
|
731
|
+
|
732
|
+
/**
|
733
|
+
* convert certain option values to the desired format.
|
734
|
+
*/
|
735
|
+
processOptions: function (options) {
|
736
|
+
var components = options.components,
|
737
|
+
partials = options.partials,
|
738
|
+
template = options.template,
|
739
|
+
filters = options.filters,
|
740
|
+
key
|
741
|
+
if (components) {
|
742
|
+
for (key in components) {
|
743
|
+
components[key] = utils.toConstructor(components[key])
|
744
|
+
}
|
745
|
+
}
|
746
|
+
if (partials) {
|
747
|
+
for (key in partials) {
|
748
|
+
partials[key] = utils.toFragment(partials[key])
|
749
|
+
}
|
750
|
+
}
|
751
|
+
if (filters) {
|
752
|
+
for (key in filters) {
|
753
|
+
utils.checkFilter(filters[key])
|
754
|
+
}
|
755
|
+
}
|
756
|
+
if (template) {
|
757
|
+
options.template = utils.toFragment(template)
|
758
|
+
}
|
759
|
+
},
|
760
|
+
|
761
|
+
/**
|
762
|
+
* used to defer batch updates
|
763
|
+
*/
|
764
|
+
nextTick: function (cb) {
|
765
|
+
defer(cb, 0)
|
766
|
+
},
|
767
|
+
|
768
|
+
/**
|
769
|
+
* add class for IE9
|
770
|
+
* uses classList if available
|
771
|
+
*/
|
772
|
+
addClass: function (el, cls) {
|
773
|
+
if (hasClassList) {
|
774
|
+
el.classList.add(cls)
|
775
|
+
} else {
|
776
|
+
var cur = ' ' + el.className + ' '
|
777
|
+
if (cur.indexOf(' ' + cls + ' ') < 0) {
|
778
|
+
el.className = (cur + cls).trim()
|
779
|
+
}
|
780
|
+
}
|
781
|
+
},
|
782
|
+
|
783
|
+
/**
|
784
|
+
* remove class for IE9
|
785
|
+
*/
|
786
|
+
removeClass: function (el, cls) {
|
787
|
+
if (hasClassList) {
|
788
|
+
el.classList.remove(cls)
|
789
|
+
} else {
|
790
|
+
var cur = ' ' + el.className + ' ',
|
791
|
+
tar = ' ' + cls + ' '
|
792
|
+
while (cur.indexOf(tar) >= 0) {
|
793
|
+
cur = cur.replace(tar, ' ')
|
794
|
+
}
|
795
|
+
el.className = cur.trim()
|
796
|
+
}
|
797
|
+
},
|
798
|
+
|
799
|
+
/**
|
800
|
+
* Convert an object to Array
|
801
|
+
* used in v-repeat and array filters
|
802
|
+
*/
|
803
|
+
objectToArray: function (obj) {
|
804
|
+
var res = [], val, data
|
805
|
+
for (var key in obj) {
|
806
|
+
val = obj[key]
|
807
|
+
data = utils.isObject(val)
|
808
|
+
? val
|
809
|
+
: { $value: val }
|
810
|
+
data.$key = key
|
811
|
+
res.push(data)
|
812
|
+
}
|
813
|
+
return res
|
814
|
+
}
|
815
|
+
}
|
816
|
+
|
817
|
+
enableDebug()
|
818
|
+
function enableDebug () {
|
819
|
+
/**
|
820
|
+
* log for debugging
|
821
|
+
*/
|
822
|
+
utils.log = function (msg) {
|
823
|
+
if (config.debug && console) {
|
824
|
+
console.log(msg)
|
825
|
+
}
|
826
|
+
}
|
827
|
+
|
828
|
+
/**
|
829
|
+
* warnings, traces by default
|
830
|
+
* can be suppressed by `silent` option.
|
831
|
+
*/
|
832
|
+
utils.warn = function (msg) {
|
833
|
+
if (!config.silent && console) {
|
834
|
+
console.warn(msg)
|
835
|
+
if (config.debug && console.trace) {
|
836
|
+
console.trace()
|
837
|
+
}
|
838
|
+
}
|
839
|
+
}
|
840
|
+
}
|
841
|
+
});
|
842
|
+
require.register("vue/src/fragment.js", function(exports, require, module){
|
843
|
+
// string -> DOM conversion
|
844
|
+
// wrappers originally from jQuery, scooped from component/domify
|
845
|
+
var map = {
|
846
|
+
legend : [1, '<fieldset>', '</fieldset>'],
|
847
|
+
tr : [2, '<table><tbody>', '</tbody></table>'],
|
848
|
+
col : [2, '<table><tbody></tbody><colgroup>', '</colgroup></table>'],
|
849
|
+
_default : [0, '', '']
|
850
|
+
}
|
851
|
+
|
852
|
+
map.td =
|
853
|
+
map.th = [3, '<table><tbody><tr>', '</tr></tbody></table>']
|
854
|
+
|
855
|
+
map.option =
|
856
|
+
map.optgroup = [1, '<select multiple="multiple">', '</select>']
|
857
|
+
|
858
|
+
map.thead =
|
859
|
+
map.tbody =
|
860
|
+
map.colgroup =
|
861
|
+
map.caption =
|
862
|
+
map.tfoot = [1, '<table>', '</table>']
|
863
|
+
|
864
|
+
map.text =
|
865
|
+
map.circle =
|
866
|
+
map.ellipse =
|
867
|
+
map.line =
|
868
|
+
map.path =
|
869
|
+
map.polygon =
|
870
|
+
map.polyline =
|
871
|
+
map.rect = [1, '<svg xmlns="http://www.w3.org/2000/svg" version="1.1">','</svg>']
|
872
|
+
|
873
|
+
var TAG_RE = /<([\w:]+)/
|
874
|
+
|
875
|
+
module.exports = function (template) {
|
876
|
+
|
877
|
+
if (typeof template !== 'string') {
|
878
|
+
return template
|
879
|
+
}
|
880
|
+
|
881
|
+
// template by ID
|
882
|
+
if (template.charAt(0) === '#') {
|
883
|
+
var templateNode = document.getElementById(template.slice(1))
|
884
|
+
if (!templateNode) return
|
885
|
+
// if its a template tag and the browser supports it,
|
886
|
+
// its content is already a document fragment!
|
887
|
+
if (templateNode.tagName === 'TEMPLATE' && templateNode.content) {
|
888
|
+
return templateNode.content
|
889
|
+
}
|
890
|
+
template = templateNode.innerHTML
|
891
|
+
}
|
892
|
+
|
893
|
+
var frag = document.createDocumentFragment(),
|
894
|
+
m = TAG_RE.exec(template)
|
895
|
+
// text only
|
896
|
+
if (!m) {
|
897
|
+
frag.appendChild(document.createTextNode(template))
|
898
|
+
return frag
|
899
|
+
}
|
900
|
+
|
901
|
+
var tag = m[1],
|
902
|
+
wrap = map[tag] || map._default,
|
903
|
+
depth = wrap[0],
|
904
|
+
prefix = wrap[1],
|
905
|
+
suffix = wrap[2],
|
906
|
+
node = document.createElement('div')
|
907
|
+
|
908
|
+
node.innerHTML = prefix + template.trim() + suffix
|
909
|
+
while (depth--) node = node.lastChild
|
910
|
+
|
911
|
+
// one element
|
912
|
+
if (node.firstChild === node.lastChild) {
|
913
|
+
frag.appendChild(node.firstChild)
|
914
|
+
return frag
|
915
|
+
}
|
916
|
+
|
917
|
+
// multiple nodes, return a fragment
|
918
|
+
var child
|
919
|
+
/* jshint boss: true */
|
920
|
+
while (child = node.firstChild) {
|
921
|
+
if (node.nodeType === 1) {
|
922
|
+
frag.appendChild(child)
|
923
|
+
}
|
924
|
+
}
|
925
|
+
return frag
|
926
|
+
}
|
927
|
+
});
|
928
|
+
require.register("vue/src/compiler.js", function(exports, require, module){
|
929
|
+
var Emitter = require('./emitter'),
|
930
|
+
Observer = require('./observer'),
|
931
|
+
config = require('./config'),
|
932
|
+
utils = require('./utils'),
|
933
|
+
Binding = require('./binding'),
|
934
|
+
Directive = require('./directive'),
|
935
|
+
TextParser = require('./text-parser'),
|
936
|
+
DepsParser = require('./deps-parser'),
|
937
|
+
ExpParser = require('./exp-parser'),
|
938
|
+
ViewModel,
|
939
|
+
|
940
|
+
// cache methods
|
941
|
+
slice = [].slice,
|
942
|
+
extend = utils.extend,
|
943
|
+
hasOwn = ({}).hasOwnProperty,
|
944
|
+
def = Object.defineProperty,
|
945
|
+
|
946
|
+
// hooks to register
|
947
|
+
hooks = [
|
948
|
+
'created', 'ready',
|
949
|
+
'beforeDestroy', 'afterDestroy',
|
950
|
+
'attached', 'detached'
|
951
|
+
],
|
952
|
+
|
953
|
+
// list of priority directives
|
954
|
+
// that needs to be checked in specific order
|
955
|
+
priorityDirectives = [
|
956
|
+
'if',
|
957
|
+
'repeat',
|
958
|
+
'view',
|
959
|
+
'component'
|
960
|
+
]
|
961
|
+
|
962
|
+
/**
|
963
|
+
* The DOM compiler
|
964
|
+
* scans a DOM node and compile bindings for a ViewModel
|
965
|
+
*/
|
966
|
+
function Compiler (vm, options) {
|
967
|
+
|
968
|
+
var compiler = this,
|
969
|
+
key, i
|
970
|
+
|
971
|
+
// default state
|
972
|
+
compiler.init = true
|
973
|
+
compiler.destroyed = false
|
974
|
+
|
975
|
+
// process and extend options
|
976
|
+
options = compiler.options = options || {}
|
977
|
+
utils.processOptions(options)
|
978
|
+
|
979
|
+
// copy compiler options
|
980
|
+
extend(compiler, options.compilerOptions)
|
981
|
+
// repeat indicates this is a v-repeat instance
|
982
|
+
compiler.repeat = compiler.repeat || false
|
983
|
+
// expCache will be shared between v-repeat instances
|
984
|
+
compiler.expCache = compiler.expCache || {}
|
985
|
+
|
986
|
+
// initialize element
|
987
|
+
var el = compiler.el = compiler.setupElement(options)
|
988
|
+
utils.log('\nnew VM instance: ' + el.tagName + '\n')
|
989
|
+
|
990
|
+
// set other compiler properties
|
991
|
+
compiler.vm = el.vue_vm = vm
|
992
|
+
compiler.bindings = utils.hash()
|
993
|
+
compiler.dirs = []
|
994
|
+
compiler.deferred = []
|
995
|
+
compiler.computed = []
|
996
|
+
compiler.children = []
|
997
|
+
compiler.emitter = new Emitter(vm)
|
998
|
+
|
999
|
+
// VM ---------------------------------------------------------------------
|
1000
|
+
|
1001
|
+
// set VM properties
|
1002
|
+
vm.$ = {}
|
1003
|
+
vm.$el = el
|
1004
|
+
vm.$options = options
|
1005
|
+
vm.$compiler = compiler
|
1006
|
+
vm.$event = null
|
1007
|
+
|
1008
|
+
// set parent & root
|
1009
|
+
var parentVM = options.parent
|
1010
|
+
if (parentVM) {
|
1011
|
+
compiler.parent = parentVM.$compiler
|
1012
|
+
parentVM.$compiler.children.push(compiler)
|
1013
|
+
vm.$parent = parentVM
|
1014
|
+
// inherit lazy option
|
1015
|
+
if (!('lazy' in options)) {
|
1016
|
+
options.lazy = compiler.parent.options.lazy
|
1017
|
+
}
|
1018
|
+
}
|
1019
|
+
vm.$root = getRoot(compiler).vm
|
1020
|
+
|
1021
|
+
// DATA -------------------------------------------------------------------
|
1022
|
+
|
1023
|
+
// setup observer
|
1024
|
+
// this is necesarry for all hooks and data observation events
|
1025
|
+
compiler.setupObserver()
|
1026
|
+
|
1027
|
+
// create bindings for computed properties
|
1028
|
+
if (options.methods) {
|
1029
|
+
for (key in options.methods) {
|
1030
|
+
compiler.createBinding(key)
|
1031
|
+
}
|
1032
|
+
}
|
1033
|
+
|
1034
|
+
// create bindings for methods
|
1035
|
+
if (options.computed) {
|
1036
|
+
for (key in options.computed) {
|
1037
|
+
compiler.createBinding(key)
|
1038
|
+
}
|
1039
|
+
}
|
1040
|
+
|
1041
|
+
// initialize data
|
1042
|
+
var data = compiler.data = options.data || {},
|
1043
|
+
defaultData = options.defaultData
|
1044
|
+
if (defaultData) {
|
1045
|
+
for (key in defaultData) {
|
1046
|
+
if (!hasOwn.call(data, key)) {
|
1047
|
+
data[key] = defaultData[key]
|
1048
|
+
}
|
1049
|
+
}
|
1050
|
+
}
|
1051
|
+
|
1052
|
+
// copy paramAttributes
|
1053
|
+
var params = options.paramAttributes
|
1054
|
+
if (params) {
|
1055
|
+
i = params.length
|
1056
|
+
while (i--) {
|
1057
|
+
data[params[i]] = utils.checkNumber(
|
1058
|
+
compiler.eval(
|
1059
|
+
el.getAttribute(params[i])
|
1060
|
+
)
|
1061
|
+
)
|
1062
|
+
}
|
1063
|
+
}
|
1064
|
+
|
1065
|
+
// copy data properties to vm
|
1066
|
+
// so user can access them in the created hook
|
1067
|
+
extend(vm, data)
|
1068
|
+
vm.$data = data
|
1069
|
+
|
1070
|
+
// beforeCompile hook
|
1071
|
+
compiler.execHook('created')
|
1072
|
+
|
1073
|
+
// the user might have swapped the data ...
|
1074
|
+
data = compiler.data = vm.$data
|
1075
|
+
|
1076
|
+
// user might also set some properties on the vm
|
1077
|
+
// in which case we should copy back to $data
|
1078
|
+
var vmProp
|
1079
|
+
for (key in vm) {
|
1080
|
+
vmProp = vm[key]
|
1081
|
+
if (
|
1082
|
+
key.charAt(0) !== '$' &&
|
1083
|
+
data[key] !== vmProp &&
|
1084
|
+
typeof vmProp !== 'function'
|
1085
|
+
) {
|
1086
|
+
data[key] = vmProp
|
1087
|
+
}
|
1088
|
+
}
|
1089
|
+
|
1090
|
+
// now we can observe the data.
|
1091
|
+
// this will convert data properties to getter/setters
|
1092
|
+
// and emit the first batch of set events, which will
|
1093
|
+
// in turn create the corresponding bindings.
|
1094
|
+
compiler.observeData(data)
|
1095
|
+
|
1096
|
+
// COMPILE ----------------------------------------------------------------
|
1097
|
+
|
1098
|
+
// before compiling, resolve content insertion points
|
1099
|
+
if (options.template) {
|
1100
|
+
this.resolveContent()
|
1101
|
+
}
|
1102
|
+
|
1103
|
+
// now parse the DOM and bind directives.
|
1104
|
+
// During this stage, we will also create bindings for
|
1105
|
+
// encountered keypaths that don't have a binding yet.
|
1106
|
+
compiler.compile(el, true)
|
1107
|
+
|
1108
|
+
// Any directive that creates child VMs are deferred
|
1109
|
+
// so that when they are compiled, all bindings on the
|
1110
|
+
// parent VM have been created.
|
1111
|
+
i = compiler.deferred.length
|
1112
|
+
while (i--) {
|
1113
|
+
compiler.bindDirective(compiler.deferred[i])
|
1114
|
+
}
|
1115
|
+
compiler.deferred = null
|
1116
|
+
|
1117
|
+
// extract dependencies for computed properties.
|
1118
|
+
// this will evaluated all collected computed bindings
|
1119
|
+
// and collect get events that are emitted.
|
1120
|
+
if (this.computed.length) {
|
1121
|
+
DepsParser.parse(this.computed)
|
1122
|
+
}
|
1123
|
+
|
1124
|
+
// done!
|
1125
|
+
compiler.init = false
|
1126
|
+
|
1127
|
+
// post compile / ready hook
|
1128
|
+
compiler.execHook('ready')
|
1129
|
+
}
|
1130
|
+
|
1131
|
+
var CompilerProto = Compiler.prototype
|
1132
|
+
|
1133
|
+
/**
|
1134
|
+
* Initialize the VM/Compiler's element.
|
1135
|
+
* Fill it in with the template if necessary.
|
1136
|
+
*/
|
1137
|
+
CompilerProto.setupElement = function (options) {
|
1138
|
+
// create the node first
|
1139
|
+
var el = typeof options.el === 'string'
|
1140
|
+
? document.querySelector(options.el)
|
1141
|
+
: options.el || document.createElement(options.tagName || 'div')
|
1142
|
+
|
1143
|
+
var template = options.template,
|
1144
|
+
child, replacer, i, attr, attrs
|
1145
|
+
|
1146
|
+
if (template) {
|
1147
|
+
// collect anything already in there
|
1148
|
+
if (el.hasChildNodes()) {
|
1149
|
+
this.rawContent = document.createElement('div')
|
1150
|
+
/* jshint boss: true */
|
1151
|
+
while (child = el.firstChild) {
|
1152
|
+
this.rawContent.appendChild(child)
|
1153
|
+
}
|
1154
|
+
}
|
1155
|
+
// replace option: use the first node in
|
1156
|
+
// the template directly
|
1157
|
+
if (options.replace && template.firstChild === template.lastChild) {
|
1158
|
+
replacer = template.firstChild.cloneNode(true)
|
1159
|
+
if (el.parentNode) {
|
1160
|
+
el.parentNode.insertBefore(replacer, el)
|
1161
|
+
el.parentNode.removeChild(el)
|
1162
|
+
}
|
1163
|
+
// copy over attributes
|
1164
|
+
if (el.hasAttributes()) {
|
1165
|
+
i = el.attributes.length
|
1166
|
+
while (i--) {
|
1167
|
+
attr = el.attributes[i]
|
1168
|
+
replacer.setAttribute(attr.name, attr.value)
|
1169
|
+
}
|
1170
|
+
}
|
1171
|
+
// replace
|
1172
|
+
el = replacer
|
1173
|
+
} else {
|
1174
|
+
el.appendChild(template.cloneNode(true))
|
1175
|
+
}
|
1176
|
+
|
1177
|
+
}
|
1178
|
+
|
1179
|
+
// apply element options
|
1180
|
+
if (options.id) el.id = options.id
|
1181
|
+
if (options.className) el.className = options.className
|
1182
|
+
attrs = options.attributes
|
1183
|
+
if (attrs) {
|
1184
|
+
for (attr in attrs) {
|
1185
|
+
el.setAttribute(attr, attrs[attr])
|
1186
|
+
}
|
1187
|
+
}
|
1188
|
+
|
1189
|
+
return el
|
1190
|
+
}
|
1191
|
+
|
1192
|
+
/**
|
1193
|
+
* Deal with <content> insertion points
|
1194
|
+
* per the Web Components spec
|
1195
|
+
*/
|
1196
|
+
CompilerProto.resolveContent = function () {
|
1197
|
+
|
1198
|
+
var outlets = slice.call(this.el.getElementsByTagName('content')),
|
1199
|
+
raw = this.rawContent,
|
1200
|
+
outlet, select, i, j, main
|
1201
|
+
|
1202
|
+
i = outlets.length
|
1203
|
+
if (i) {
|
1204
|
+
// first pass, collect corresponding content
|
1205
|
+
// for each outlet.
|
1206
|
+
while (i--) {
|
1207
|
+
outlet = outlets[i]
|
1208
|
+
if (raw) {
|
1209
|
+
select = outlet.getAttribute('select')
|
1210
|
+
if (select) { // select content
|
1211
|
+
outlet.content =
|
1212
|
+
slice.call(raw.querySelectorAll(select))
|
1213
|
+
} else { // default content
|
1214
|
+
main = outlet
|
1215
|
+
}
|
1216
|
+
} else { // fallback content
|
1217
|
+
outlet.content =
|
1218
|
+
slice.call(outlet.childNodes)
|
1219
|
+
}
|
1220
|
+
}
|
1221
|
+
// second pass, actually insert the contents
|
1222
|
+
for (i = 0, j = outlets.length; i < j; i++) {
|
1223
|
+
outlet = outlets[i]
|
1224
|
+
if (outlet === main) continue
|
1225
|
+
insert(outlet, outlet.content)
|
1226
|
+
}
|
1227
|
+
// finally insert the main content
|
1228
|
+
if (raw && main) {
|
1229
|
+
insert(main, slice.call(raw.childNodes))
|
1230
|
+
}
|
1231
|
+
}
|
1232
|
+
|
1233
|
+
function insert (outlet, contents) {
|
1234
|
+
var parent = outlet.parentNode,
|
1235
|
+
i = 0, j = contents.length
|
1236
|
+
for (; i < j; i++) {
|
1237
|
+
parent.insertBefore(contents[i], outlet)
|
1238
|
+
}
|
1239
|
+
parent.removeChild(outlet)
|
1240
|
+
}
|
1241
|
+
|
1242
|
+
this.rawContent = null
|
1243
|
+
}
|
1244
|
+
|
1245
|
+
/**
|
1246
|
+
* Setup observer.
|
1247
|
+
* The observer listens for get/set/mutate events on all VM
|
1248
|
+
* values/objects and trigger corresponding binding updates.
|
1249
|
+
* It also listens for lifecycle hooks.
|
1250
|
+
*/
|
1251
|
+
CompilerProto.setupObserver = function () {
|
1252
|
+
|
1253
|
+
var compiler = this,
|
1254
|
+
bindings = compiler.bindings,
|
1255
|
+
options = compiler.options,
|
1256
|
+
observer = compiler.observer = new Emitter(compiler.vm)
|
1257
|
+
|
1258
|
+
// a hash to hold event proxies for each root level key
|
1259
|
+
// so they can be referenced and removed later
|
1260
|
+
observer.proxies = {}
|
1261
|
+
|
1262
|
+
// add own listeners which trigger binding updates
|
1263
|
+
observer
|
1264
|
+
.on('get', onGet)
|
1265
|
+
.on('set', onSet)
|
1266
|
+
.on('mutate', onSet)
|
1267
|
+
|
1268
|
+
// register hooks
|
1269
|
+
var i = hooks.length, j, hook, fns
|
1270
|
+
while (i--) {
|
1271
|
+
hook = hooks[i]
|
1272
|
+
fns = options[hook]
|
1273
|
+
if (Array.isArray(fns)) {
|
1274
|
+
j = fns.length
|
1275
|
+
// since hooks were merged with child at head,
|
1276
|
+
// we loop reversely.
|
1277
|
+
while (j--) {
|
1278
|
+
registerHook(hook, fns[j])
|
1279
|
+
}
|
1280
|
+
} else if (fns) {
|
1281
|
+
registerHook(hook, fns)
|
1282
|
+
}
|
1283
|
+
}
|
1284
|
+
|
1285
|
+
// broadcast attached/detached hooks
|
1286
|
+
observer
|
1287
|
+
.on('hook:attached', function () {
|
1288
|
+
broadcast(1)
|
1289
|
+
})
|
1290
|
+
.on('hook:detached', function () {
|
1291
|
+
broadcast(0)
|
1292
|
+
})
|
1293
|
+
|
1294
|
+
function onGet (key) {
|
1295
|
+
check(key)
|
1296
|
+
DepsParser.catcher.emit('get', bindings[key])
|
1297
|
+
}
|
1298
|
+
|
1299
|
+
function onSet (key, val, mutation) {
|
1300
|
+
observer.emit('change:' + key, val, mutation)
|
1301
|
+
check(key)
|
1302
|
+
bindings[key].update(val)
|
1303
|
+
}
|
1304
|
+
|
1305
|
+
function registerHook (hook, fn) {
|
1306
|
+
observer.on('hook:' + hook, function () {
|
1307
|
+
fn.call(compiler.vm)
|
1308
|
+
})
|
1309
|
+
}
|
1310
|
+
|
1311
|
+
function broadcast (event) {
|
1312
|
+
var children = compiler.children
|
1313
|
+
if (children) {
|
1314
|
+
var child, i = children.length
|
1315
|
+
while (i--) {
|
1316
|
+
child = children[i]
|
1317
|
+
if (child.el.parentNode) {
|
1318
|
+
event = 'hook:' + (event ? 'attached' : 'detached')
|
1319
|
+
child.observer.emit(event)
|
1320
|
+
child.emitter.emit(event)
|
1321
|
+
}
|
1322
|
+
}
|
1323
|
+
}
|
1324
|
+
}
|
1325
|
+
|
1326
|
+
function check (key) {
|
1327
|
+
if (!bindings[key]) {
|
1328
|
+
compiler.createBinding(key)
|
1329
|
+
}
|
1330
|
+
}
|
1331
|
+
}
|
1332
|
+
|
1333
|
+
CompilerProto.observeData = function (data) {
|
1334
|
+
|
1335
|
+
var compiler = this,
|
1336
|
+
observer = compiler.observer
|
1337
|
+
|
1338
|
+
// recursively observe nested properties
|
1339
|
+
Observer.observe(data, '', observer)
|
1340
|
+
|
1341
|
+
// also create binding for top level $data
|
1342
|
+
// so it can be used in templates too
|
1343
|
+
var $dataBinding = compiler.bindings['$data'] = new Binding(compiler, '$data')
|
1344
|
+
$dataBinding.update(data)
|
1345
|
+
|
1346
|
+
// allow $data to be swapped
|
1347
|
+
def(compiler.vm, '$data', {
|
1348
|
+
get: function () {
|
1349
|
+
compiler.observer.emit('get', '$data')
|
1350
|
+
return compiler.data
|
1351
|
+
},
|
1352
|
+
set: function (newData) {
|
1353
|
+
var oldData = compiler.data
|
1354
|
+
Observer.unobserve(oldData, '', observer)
|
1355
|
+
compiler.data = newData
|
1356
|
+
Observer.copyPaths(newData, oldData)
|
1357
|
+
Observer.observe(newData, '', observer)
|
1358
|
+
update()
|
1359
|
+
}
|
1360
|
+
})
|
1361
|
+
|
1362
|
+
// emit $data change on all changes
|
1363
|
+
observer
|
1364
|
+
.on('set', onSet)
|
1365
|
+
.on('mutate', onSet)
|
1366
|
+
|
1367
|
+
function onSet (key) {
|
1368
|
+
if (key !== '$data') update()
|
1369
|
+
}
|
1370
|
+
|
1371
|
+
function update () {
|
1372
|
+
$dataBinding.update(compiler.data)
|
1373
|
+
observer.emit('change:$data', compiler.data)
|
1374
|
+
}
|
1375
|
+
}
|
1376
|
+
|
1377
|
+
/**
|
1378
|
+
* Compile a DOM node (recursive)
|
1379
|
+
*/
|
1380
|
+
CompilerProto.compile = function (node, root) {
|
1381
|
+
var nodeType = node.nodeType
|
1382
|
+
if (nodeType === 1 && node.tagName !== 'SCRIPT') { // a normal node
|
1383
|
+
this.compileElement(node, root)
|
1384
|
+
} else if (nodeType === 3 && config.interpolate) {
|
1385
|
+
this.compileTextNode(node)
|
1386
|
+
}
|
1387
|
+
}
|
1388
|
+
|
1389
|
+
/**
|
1390
|
+
* Check for a priority directive
|
1391
|
+
* If it is present and valid, return true to skip the rest
|
1392
|
+
*/
|
1393
|
+
CompilerProto.checkPriorityDir = function (dirname, node, root) {
|
1394
|
+
var expression, directive, Ctor
|
1395
|
+
if (
|
1396
|
+
dirname === 'component' &&
|
1397
|
+
root !== true &&
|
1398
|
+
(Ctor = this.resolveComponent(node, undefined, true))
|
1399
|
+
) {
|
1400
|
+
directive = this.parseDirective(dirname, '', node)
|
1401
|
+
directive.Ctor = Ctor
|
1402
|
+
} else {
|
1403
|
+
expression = utils.attr(node, dirname)
|
1404
|
+
directive = expression && this.parseDirective(dirname, expression, node)
|
1405
|
+
}
|
1406
|
+
if (directive) {
|
1407
|
+
if (root === true) {
|
1408
|
+
utils.warn(
|
1409
|
+
'Directive v-' + dirname + ' cannot be used on an already instantiated ' +
|
1410
|
+
'VM\'s root node. Use it from the parent\'s template instead.'
|
1411
|
+
)
|
1412
|
+
return
|
1413
|
+
}
|
1414
|
+
this.deferred.push(directive)
|
1415
|
+
return true
|
1416
|
+
}
|
1417
|
+
}
|
1418
|
+
|
1419
|
+
/**
|
1420
|
+
* Compile normal directives on a node
|
1421
|
+
*/
|
1422
|
+
CompilerProto.compileElement = function (node, root) {
|
1423
|
+
|
1424
|
+
// textarea is pretty annoying
|
1425
|
+
// because its value creates childNodes which
|
1426
|
+
// we don't want to compile.
|
1427
|
+
if (node.tagName === 'TEXTAREA' && node.value) {
|
1428
|
+
node.value = this.eval(node.value)
|
1429
|
+
}
|
1430
|
+
|
1431
|
+
// only compile if this element has attributes
|
1432
|
+
// or its tagName contains a hyphen (which means it could
|
1433
|
+
// potentially be a custom element)
|
1434
|
+
if (node.hasAttributes() || node.tagName.indexOf('-') > -1) {
|
1435
|
+
|
1436
|
+
// skip anything with v-pre
|
1437
|
+
if (utils.attr(node, 'pre') !== null) {
|
1438
|
+
return
|
1439
|
+
}
|
1440
|
+
|
1441
|
+
var i, l, j, k
|
1442
|
+
|
1443
|
+
// check priority directives.
|
1444
|
+
// if any of them are present, it will take over the node with a childVM
|
1445
|
+
// so we can skip the rest
|
1446
|
+
for (i = 0, l = priorityDirectives.length; i < l; i++) {
|
1447
|
+
if (this.checkPriorityDir(priorityDirectives[i], node, root)) {
|
1448
|
+
return
|
1449
|
+
}
|
1450
|
+
}
|
1451
|
+
|
1452
|
+
// check transition & animation properties
|
1453
|
+
node.vue_trans = utils.attr(node, 'transition')
|
1454
|
+
node.vue_anim = utils.attr(node, 'animation')
|
1455
|
+
node.vue_effect = this.eval(utils.attr(node, 'effect'))
|
1456
|
+
|
1457
|
+
var prefix = config.prefix + '-',
|
1458
|
+
params = this.options.paramAttributes,
|
1459
|
+
attr, attrname, isDirective, exp, directives, directive, dirname
|
1460
|
+
|
1461
|
+
// v-with has special priority among the rest
|
1462
|
+
// it needs to pull in the value from the parent before
|
1463
|
+
// computed properties are evaluated, because at this stage
|
1464
|
+
// the computed properties have not set up their dependencies yet.
|
1465
|
+
if (root) {
|
1466
|
+
var withExp = utils.attr(node, 'with')
|
1467
|
+
if (withExp) {
|
1468
|
+
directives = this.parseDirective('with', withExp, node, true)
|
1469
|
+
for (j = 0, k = directives.length; j < k; j++) {
|
1470
|
+
this.bindDirective(directives[j], this.parent)
|
1471
|
+
}
|
1472
|
+
}
|
1473
|
+
}
|
1474
|
+
|
1475
|
+
var attrs = slice.call(node.attributes)
|
1476
|
+
for (i = 0, l = attrs.length; i < l; i++) {
|
1477
|
+
|
1478
|
+
attr = attrs[i]
|
1479
|
+
attrname = attr.name
|
1480
|
+
isDirective = false
|
1481
|
+
|
1482
|
+
if (attrname.indexOf(prefix) === 0) {
|
1483
|
+
// a directive - split, parse and bind it.
|
1484
|
+
isDirective = true
|
1485
|
+
dirname = attrname.slice(prefix.length)
|
1486
|
+
// build with multiple: true
|
1487
|
+
directives = this.parseDirective(dirname, attr.value, node, true)
|
1488
|
+
// loop through clauses (separated by ",")
|
1489
|
+
// inside each attribute
|
1490
|
+
for (j = 0, k = directives.length; j < k; j++) {
|
1491
|
+
this.bindDirective(directives[j])
|
1492
|
+
}
|
1493
|
+
} else if (config.interpolate) {
|
1494
|
+
// non directive attribute, check interpolation tags
|
1495
|
+
exp = TextParser.parseAttr(attr.value)
|
1496
|
+
if (exp) {
|
1497
|
+
directive = this.parseDirective('attr', exp, node)
|
1498
|
+
directive.arg = attrname
|
1499
|
+
if (params && params.indexOf(attrname) > -1) {
|
1500
|
+
// a param attribute... we should use the parent binding
|
1501
|
+
// to avoid circular updates like size={{size}}
|
1502
|
+
this.bindDirective(directive, this.parent)
|
1503
|
+
} else {
|
1504
|
+
this.bindDirective(directive)
|
1505
|
+
}
|
1506
|
+
}
|
1507
|
+
}
|
1508
|
+
|
1509
|
+
if (isDirective && dirname !== 'cloak') {
|
1510
|
+
node.removeAttribute(attrname)
|
1511
|
+
}
|
1512
|
+
}
|
1513
|
+
|
1514
|
+
}
|
1515
|
+
|
1516
|
+
// recursively compile childNodes
|
1517
|
+
if (node.hasChildNodes()) {
|
1518
|
+
slice.call(node.childNodes).forEach(this.compile, this)
|
1519
|
+
}
|
1520
|
+
}
|
1521
|
+
|
1522
|
+
/**
|
1523
|
+
* Compile a text node
|
1524
|
+
*/
|
1525
|
+
CompilerProto.compileTextNode = function (node) {
|
1526
|
+
|
1527
|
+
var tokens = TextParser.parse(node.nodeValue)
|
1528
|
+
if (!tokens) return
|
1529
|
+
var el, token, directive
|
1530
|
+
|
1531
|
+
for (var i = 0, l = tokens.length; i < l; i++) {
|
1532
|
+
|
1533
|
+
token = tokens[i]
|
1534
|
+
directive = null
|
1535
|
+
|
1536
|
+
if (token.key) { // a binding
|
1537
|
+
if (token.key.charAt(0) === '>') { // a partial
|
1538
|
+
el = document.createComment('ref')
|
1539
|
+
directive = this.parseDirective('partial', token.key.slice(1), el)
|
1540
|
+
} else {
|
1541
|
+
if (!token.html) { // text binding
|
1542
|
+
el = document.createTextNode('')
|
1543
|
+
directive = this.parseDirective('text', token.key, el)
|
1544
|
+
} else { // html binding
|
1545
|
+
el = document.createComment(config.prefix + '-html')
|
1546
|
+
directive = this.parseDirective('html', token.key, el)
|
1547
|
+
}
|
1548
|
+
}
|
1549
|
+
} else { // a plain string
|
1550
|
+
el = document.createTextNode(token)
|
1551
|
+
}
|
1552
|
+
|
1553
|
+
// insert node
|
1554
|
+
node.parentNode.insertBefore(el, node)
|
1555
|
+
// bind directive
|
1556
|
+
this.bindDirective(directive)
|
1557
|
+
|
1558
|
+
}
|
1559
|
+
node.parentNode.removeChild(node)
|
1560
|
+
}
|
1561
|
+
|
1562
|
+
/**
|
1563
|
+
* Parse a directive name/value pair into one or more
|
1564
|
+
* directive instances
|
1565
|
+
*/
|
1566
|
+
CompilerProto.parseDirective = function (name, value, el, multiple) {
|
1567
|
+
var compiler = this,
|
1568
|
+
definition = compiler.getOption('directives', name)
|
1569
|
+
if (definition) {
|
1570
|
+
// parse into AST-like objects
|
1571
|
+
var asts = Directive.parse(value)
|
1572
|
+
return multiple
|
1573
|
+
? asts.map(build)
|
1574
|
+
: build(asts[0])
|
1575
|
+
}
|
1576
|
+
function build (ast) {
|
1577
|
+
return new Directive(name, ast, definition, compiler, el)
|
1578
|
+
}
|
1579
|
+
}
|
1580
|
+
|
1581
|
+
/**
|
1582
|
+
* Add a directive instance to the correct binding & viewmodel
|
1583
|
+
*/
|
1584
|
+
CompilerProto.bindDirective = function (directive, bindingOwner) {
|
1585
|
+
|
1586
|
+
if (!directive) return
|
1587
|
+
|
1588
|
+
// keep track of it so we can unbind() later
|
1589
|
+
this.dirs.push(directive)
|
1590
|
+
|
1591
|
+
// for empty or literal directives, simply call its bind()
|
1592
|
+
// and we're done.
|
1593
|
+
if (directive.isEmpty || directive.isLiteral) {
|
1594
|
+
if (directive.bind) directive.bind()
|
1595
|
+
return
|
1596
|
+
}
|
1597
|
+
|
1598
|
+
// otherwise, we got more work to do...
|
1599
|
+
var binding,
|
1600
|
+
compiler = bindingOwner || this,
|
1601
|
+
key = directive.key
|
1602
|
+
|
1603
|
+
if (directive.isExp) {
|
1604
|
+
// expression bindings are always created on current compiler
|
1605
|
+
binding = compiler.createBinding(key, directive)
|
1606
|
+
} else {
|
1607
|
+
// recursively locate which compiler owns the binding
|
1608
|
+
while (compiler) {
|
1609
|
+
if (compiler.hasKey(key)) {
|
1610
|
+
break
|
1611
|
+
} else {
|
1612
|
+
compiler = compiler.parent
|
1613
|
+
}
|
1614
|
+
}
|
1615
|
+
compiler = compiler || this
|
1616
|
+
binding = compiler.bindings[key] || compiler.createBinding(key)
|
1617
|
+
}
|
1618
|
+
binding.dirs.push(directive)
|
1619
|
+
directive.binding = binding
|
1620
|
+
|
1621
|
+
var value = binding.val()
|
1622
|
+
// invoke bind hook if exists
|
1623
|
+
if (directive.bind) {
|
1624
|
+
directive.bind(value)
|
1625
|
+
}
|
1626
|
+
// set initial value
|
1627
|
+
directive.$update(value, true)
|
1628
|
+
}
|
1629
|
+
|
1630
|
+
/**
|
1631
|
+
* Create binding and attach getter/setter for a key to the viewmodel object
|
1632
|
+
*/
|
1633
|
+
CompilerProto.createBinding = function (key, directive) {
|
1634
|
+
|
1635
|
+
utils.log(' created binding: ' + key)
|
1636
|
+
|
1637
|
+
var compiler = this,
|
1638
|
+
methods = compiler.options.methods,
|
1639
|
+
isExp = directive && directive.isExp,
|
1640
|
+
isFn = (directive && directive.isFn) || (methods && methods[key]),
|
1641
|
+
bindings = compiler.bindings,
|
1642
|
+
computed = compiler.options.computed,
|
1643
|
+
binding = new Binding(compiler, key, isExp, isFn)
|
1644
|
+
|
1645
|
+
if (isExp) {
|
1646
|
+
// expression bindings are anonymous
|
1647
|
+
compiler.defineExp(key, binding, directive)
|
1648
|
+
} else if (isFn) {
|
1649
|
+
bindings[key] = binding
|
1650
|
+
compiler.defineVmProp(key, binding, methods[key])
|
1651
|
+
} else {
|
1652
|
+
bindings[key] = binding
|
1653
|
+
if (binding.root) {
|
1654
|
+
// this is a root level binding. we need to define getter/setters for it.
|
1655
|
+
if (computed && computed[key]) {
|
1656
|
+
// computed property
|
1657
|
+
compiler.defineComputed(key, binding, computed[key])
|
1658
|
+
} else if (key.charAt(0) !== '$') {
|
1659
|
+
// normal property
|
1660
|
+
compiler.defineDataProp(key, binding)
|
1661
|
+
} else {
|
1662
|
+
// properties that start with $ are meta properties
|
1663
|
+
// they should be kept on the vm but not in the data object.
|
1664
|
+
compiler.defineVmProp(key, binding, compiler.data[key])
|
1665
|
+
delete compiler.data[key]
|
1666
|
+
}
|
1667
|
+
} else if (computed && computed[utils.baseKey(key)]) {
|
1668
|
+
// nested path on computed property
|
1669
|
+
compiler.defineExp(key, binding)
|
1670
|
+
} else {
|
1671
|
+
// ensure path in data so that computed properties that
|
1672
|
+
// access the path don't throw an error and can collect
|
1673
|
+
// dependencies
|
1674
|
+
Observer.ensurePath(compiler.data, key)
|
1675
|
+
var parentKey = key.slice(0, key.lastIndexOf('.'))
|
1676
|
+
if (!bindings[parentKey]) {
|
1677
|
+
// this is a nested value binding, but the binding for its parent
|
1678
|
+
// has not been created yet. We better create that one too.
|
1679
|
+
compiler.createBinding(parentKey)
|
1680
|
+
}
|
1681
|
+
}
|
1682
|
+
}
|
1683
|
+
return binding
|
1684
|
+
}
|
1685
|
+
|
1686
|
+
/**
|
1687
|
+
* Define the getter/setter to proxy a root-level
|
1688
|
+
* data property on the VM
|
1689
|
+
*/
|
1690
|
+
CompilerProto.defineDataProp = function (key, binding) {
|
1691
|
+
var compiler = this,
|
1692
|
+
data = compiler.data,
|
1693
|
+
ob = data.__emitter__
|
1694
|
+
|
1695
|
+
// make sure the key is present in data
|
1696
|
+
// so it can be observed
|
1697
|
+
if (!(hasOwn.call(data, key))) {
|
1698
|
+
data[key] = undefined
|
1699
|
+
}
|
1700
|
+
|
1701
|
+
// if the data object is already observed, but the key
|
1702
|
+
// is not observed, we need to add it to the observed keys.
|
1703
|
+
if (ob && !(hasOwn.call(ob.values, key))) {
|
1704
|
+
Observer.convertKey(data, key)
|
1705
|
+
}
|
1706
|
+
|
1707
|
+
binding.value = data[key]
|
1708
|
+
|
1709
|
+
def(compiler.vm, key, {
|
1710
|
+
get: function () {
|
1711
|
+
return compiler.data[key]
|
1712
|
+
},
|
1713
|
+
set: function (val) {
|
1714
|
+
compiler.data[key] = val
|
1715
|
+
}
|
1716
|
+
})
|
1717
|
+
}
|
1718
|
+
|
1719
|
+
/**
|
1720
|
+
* Define a vm property, e.g. $index, $key, or mixin methods
|
1721
|
+
* which are bindable but only accessible on the VM,
|
1722
|
+
* not in the data.
|
1723
|
+
*/
|
1724
|
+
CompilerProto.defineVmProp = function (key, binding, value) {
|
1725
|
+
var ob = this.observer
|
1726
|
+
binding.value = value
|
1727
|
+
def(this.vm, key, {
|
1728
|
+
get: function () {
|
1729
|
+
if (Observer.shouldGet) ob.emit('get', key)
|
1730
|
+
return binding.value
|
1731
|
+
},
|
1732
|
+
set: function (val) {
|
1733
|
+
ob.emit('set', key, val)
|
1734
|
+
}
|
1735
|
+
})
|
1736
|
+
}
|
1737
|
+
|
1738
|
+
/**
|
1739
|
+
* Define an expression binding, which is essentially
|
1740
|
+
* an anonymous computed property
|
1741
|
+
*/
|
1742
|
+
CompilerProto.defineExp = function (key, binding, directive) {
|
1743
|
+
var computedKey = directive && directive.computedKey,
|
1744
|
+
exp = computedKey ? directive.expression : key,
|
1745
|
+
getter = this.expCache[exp]
|
1746
|
+
if (!getter) {
|
1747
|
+
getter = this.expCache[exp] = ExpParser.parse(computedKey || key, this)
|
1748
|
+
}
|
1749
|
+
if (getter) {
|
1750
|
+
this.markComputed(binding, getter)
|
1751
|
+
}
|
1752
|
+
}
|
1753
|
+
|
1754
|
+
/**
|
1755
|
+
* Define a computed property on the VM
|
1756
|
+
*/
|
1757
|
+
CompilerProto.defineComputed = function (key, binding, value) {
|
1758
|
+
this.markComputed(binding, value)
|
1759
|
+
def(this.vm, key, {
|
1760
|
+
get: binding.value.$get,
|
1761
|
+
set: binding.value.$set
|
1762
|
+
})
|
1763
|
+
}
|
1764
|
+
|
1765
|
+
/**
|
1766
|
+
* Process a computed property binding
|
1767
|
+
* so its getter/setter are bound to proper context
|
1768
|
+
*/
|
1769
|
+
CompilerProto.markComputed = function (binding, value) {
|
1770
|
+
binding.isComputed = true
|
1771
|
+
// bind the accessors to the vm
|
1772
|
+
if (binding.isFn) {
|
1773
|
+
binding.value = value
|
1774
|
+
} else {
|
1775
|
+
if (typeof value === 'function') {
|
1776
|
+
value = { $get: value }
|
1777
|
+
}
|
1778
|
+
binding.value = {
|
1779
|
+
$get: utils.bind(value.$get, this.vm),
|
1780
|
+
$set: value.$set
|
1781
|
+
? utils.bind(value.$set, this.vm)
|
1782
|
+
: undefined
|
1783
|
+
}
|
1784
|
+
}
|
1785
|
+
// keep track for dep parsing later
|
1786
|
+
this.computed.push(binding)
|
1787
|
+
}
|
1788
|
+
|
1789
|
+
/**
|
1790
|
+
* Retrive an option from the compiler
|
1791
|
+
*/
|
1792
|
+
CompilerProto.getOption = function (type, id, silent) {
|
1793
|
+
var opts = this.options,
|
1794
|
+
parent = this.parent,
|
1795
|
+
globalAssets = config.globalAssets,
|
1796
|
+
res = (opts[type] && opts[type][id]) || (
|
1797
|
+
parent
|
1798
|
+
? parent.getOption(type, id, silent)
|
1799
|
+
: globalAssets[type] && globalAssets[type][id]
|
1800
|
+
)
|
1801
|
+
if (!res && !silent && typeof id === 'string') {
|
1802
|
+
utils.warn('Unknown ' + type.slice(0, -1) + ': ' + id)
|
1803
|
+
}
|
1804
|
+
return res
|
1805
|
+
}
|
1806
|
+
|
1807
|
+
/**
|
1808
|
+
* Emit lifecycle events to trigger hooks
|
1809
|
+
*/
|
1810
|
+
CompilerProto.execHook = function (event) {
|
1811
|
+
event = 'hook:' + event
|
1812
|
+
this.observer.emit(event)
|
1813
|
+
this.emitter.emit(event)
|
1814
|
+
}
|
1815
|
+
|
1816
|
+
/**
|
1817
|
+
* Check if a compiler's data contains a keypath
|
1818
|
+
*/
|
1819
|
+
CompilerProto.hasKey = function (key) {
|
1820
|
+
var baseKey = utils.baseKey(key)
|
1821
|
+
return hasOwn.call(this.data, baseKey) ||
|
1822
|
+
hasOwn.call(this.vm, baseKey)
|
1823
|
+
}
|
1824
|
+
|
1825
|
+
/**
|
1826
|
+
* Do a one-time eval of a string that potentially
|
1827
|
+
* includes bindings. It accepts additional raw data
|
1828
|
+
* because we need to dynamically resolve v-component
|
1829
|
+
* before a childVM is even compiled...
|
1830
|
+
*/
|
1831
|
+
CompilerProto.eval = function (exp, data) {
|
1832
|
+
var parsed = TextParser.parseAttr(exp)
|
1833
|
+
return parsed
|
1834
|
+
? ExpParser.eval(parsed, this, data)
|
1835
|
+
: exp
|
1836
|
+
}
|
1837
|
+
|
1838
|
+
/**
|
1839
|
+
* Resolve a Component constructor for an element
|
1840
|
+
* with the data to be used
|
1841
|
+
*/
|
1842
|
+
CompilerProto.resolveComponent = function (node, data, test) {
|
1843
|
+
|
1844
|
+
// late require to avoid circular deps
|
1845
|
+
ViewModel = ViewModel || require('./viewmodel')
|
1846
|
+
|
1847
|
+
var exp = utils.attr(node, 'component'),
|
1848
|
+
tagName = node.tagName,
|
1849
|
+
id = this.eval(exp, data),
|
1850
|
+
tagId = (tagName.indexOf('-') > 0 && tagName.toLowerCase()),
|
1851
|
+
Ctor = this.getOption('components', id || tagId, true)
|
1852
|
+
|
1853
|
+
if (id && !Ctor) {
|
1854
|
+
utils.warn('Unknown component: ' + id)
|
1855
|
+
}
|
1856
|
+
|
1857
|
+
return test
|
1858
|
+
? exp === ''
|
1859
|
+
? ViewModel
|
1860
|
+
: Ctor
|
1861
|
+
: Ctor || ViewModel
|
1862
|
+
}
|
1863
|
+
|
1864
|
+
/**
|
1865
|
+
* Unbind and remove element
|
1866
|
+
*/
|
1867
|
+
CompilerProto.destroy = function (noRemove) {
|
1868
|
+
|
1869
|
+
// avoid being called more than once
|
1870
|
+
// this is irreversible!
|
1871
|
+
if (this.destroyed) return
|
1872
|
+
|
1873
|
+
var compiler = this,
|
1874
|
+
i, j, key, dir, dirs, binding,
|
1875
|
+
vm = compiler.vm,
|
1876
|
+
el = compiler.el,
|
1877
|
+
directives = compiler.dirs,
|
1878
|
+
computed = compiler.computed,
|
1879
|
+
bindings = compiler.bindings,
|
1880
|
+
children = compiler.children,
|
1881
|
+
parent = compiler.parent
|
1882
|
+
|
1883
|
+
compiler.execHook('beforeDestroy')
|
1884
|
+
|
1885
|
+
// unobserve data
|
1886
|
+
Observer.unobserve(compiler.data, '', compiler.observer)
|
1887
|
+
|
1888
|
+
// destroy all children
|
1889
|
+
// do not remove their elements since the parent
|
1890
|
+
// may have transitions and the children may not
|
1891
|
+
i = children.length
|
1892
|
+
while (i--) {
|
1893
|
+
children[i].destroy(true)
|
1894
|
+
}
|
1895
|
+
|
1896
|
+
// unbind all direcitves
|
1897
|
+
i = directives.length
|
1898
|
+
while (i--) {
|
1899
|
+
dir = directives[i]
|
1900
|
+
// if this directive is an instance of an external binding
|
1901
|
+
// e.g. a directive that refers to a variable on the parent VM
|
1902
|
+
// we need to remove it from that binding's directives
|
1903
|
+
// * empty and literal bindings do not have binding.
|
1904
|
+
if (dir.binding && dir.binding.compiler !== compiler) {
|
1905
|
+
dirs = dir.binding.dirs
|
1906
|
+
if (dirs) {
|
1907
|
+
j = dirs.indexOf(dir)
|
1908
|
+
if (j > -1) dirs.splice(j, 1)
|
1909
|
+
}
|
1910
|
+
}
|
1911
|
+
dir.$unbind()
|
1912
|
+
}
|
1913
|
+
|
1914
|
+
// unbind all computed, anonymous bindings
|
1915
|
+
i = computed.length
|
1916
|
+
while (i--) {
|
1917
|
+
computed[i].unbind()
|
1918
|
+
}
|
1919
|
+
|
1920
|
+
// unbind all keypath bindings
|
1921
|
+
for (key in bindings) {
|
1922
|
+
binding = bindings[key]
|
1923
|
+
if (binding) {
|
1924
|
+
binding.unbind()
|
1925
|
+
}
|
1926
|
+
}
|
1927
|
+
|
1928
|
+
// remove self from parent
|
1929
|
+
if (parent) {
|
1930
|
+
j = parent.children.indexOf(compiler)
|
1931
|
+
if (j > -1) parent.children.splice(j, 1)
|
1932
|
+
}
|
1933
|
+
|
1934
|
+
// finally remove dom element
|
1935
|
+
if (!noRemove) {
|
1936
|
+
if (el === document.body) {
|
1937
|
+
el.innerHTML = ''
|
1938
|
+
} else {
|
1939
|
+
vm.$remove()
|
1940
|
+
}
|
1941
|
+
}
|
1942
|
+
el.vue_vm = null
|
1943
|
+
|
1944
|
+
compiler.destroyed = true
|
1945
|
+
// emit destroy hook
|
1946
|
+
compiler.execHook('afterDestroy')
|
1947
|
+
|
1948
|
+
// finally, unregister all listeners
|
1949
|
+
compiler.observer.off()
|
1950
|
+
compiler.emitter.off()
|
1951
|
+
}
|
1952
|
+
|
1953
|
+
// Helpers --------------------------------------------------------------------
|
1954
|
+
|
1955
|
+
/**
|
1956
|
+
* shorthand for getting root compiler
|
1957
|
+
*/
|
1958
|
+
function getRoot (compiler) {
|
1959
|
+
while (compiler.parent) {
|
1960
|
+
compiler = compiler.parent
|
1961
|
+
}
|
1962
|
+
return compiler
|
1963
|
+
}
|
1964
|
+
|
1965
|
+
module.exports = Compiler
|
1966
|
+
});
|
1967
|
+
require.register("vue/src/viewmodel.js", function(exports, require, module){
|
1968
|
+
var Compiler = require('./compiler'),
|
1969
|
+
utils = require('./utils'),
|
1970
|
+
transition = require('./transition'),
|
1971
|
+
Batcher = require('./batcher'),
|
1972
|
+
slice = [].slice,
|
1973
|
+
def = utils.defProtected,
|
1974
|
+
nextTick = utils.nextTick,
|
1975
|
+
|
1976
|
+
// batch $watch callbacks
|
1977
|
+
watcherBatcher = new Batcher(),
|
1978
|
+
watcherId = 1
|
1979
|
+
|
1980
|
+
/**
|
1981
|
+
* ViewModel exposed to the user that holds data,
|
1982
|
+
* computed properties, event handlers
|
1983
|
+
* and a few reserved methods
|
1984
|
+
*/
|
1985
|
+
function ViewModel (options) {
|
1986
|
+
// just compile. options are passed directly to compiler
|
1987
|
+
new Compiler(this, options)
|
1988
|
+
}
|
1989
|
+
|
1990
|
+
// All VM prototype methods are inenumerable
|
1991
|
+
// so it can be stringified/looped through as raw data
|
1992
|
+
var VMProto = ViewModel.prototype
|
1993
|
+
|
1994
|
+
/**
|
1995
|
+
* Convenience function to get a value from
|
1996
|
+
* a keypath
|
1997
|
+
*/
|
1998
|
+
def(VMProto, '$get', function (key) {
|
1999
|
+
var val = utils.get(this, key)
|
2000
|
+
return val === undefined && this.$parent
|
2001
|
+
? this.$parent.$get(key)
|
2002
|
+
: val
|
2003
|
+
})
|
2004
|
+
|
2005
|
+
/**
|
2006
|
+
* Convenience function to set an actual nested value
|
2007
|
+
* from a flat key string. Used in directives.
|
2008
|
+
*/
|
2009
|
+
def(VMProto, '$set', function (key, value) {
|
2010
|
+
utils.set(this, key, value)
|
2011
|
+
})
|
2012
|
+
|
2013
|
+
/**
|
2014
|
+
* watch a key on the viewmodel for changes
|
2015
|
+
* fire callback with new value
|
2016
|
+
*/
|
2017
|
+
def(VMProto, '$watch', function (key, callback) {
|
2018
|
+
// save a unique id for each watcher
|
2019
|
+
var id = watcherId++,
|
2020
|
+
self = this
|
2021
|
+
function on () {
|
2022
|
+
var args = slice.call(arguments)
|
2023
|
+
watcherBatcher.push({
|
2024
|
+
id: id,
|
2025
|
+
override: true,
|
2026
|
+
execute: function () {
|
2027
|
+
callback.apply(self, args)
|
2028
|
+
}
|
2029
|
+
})
|
2030
|
+
}
|
2031
|
+
callback._fn = on
|
2032
|
+
self.$compiler.observer.on('change:' + key, on)
|
2033
|
+
})
|
2034
|
+
|
2035
|
+
/**
|
2036
|
+
* unwatch a key
|
2037
|
+
*/
|
2038
|
+
def(VMProto, '$unwatch', function (key, callback) {
|
2039
|
+
// workaround here
|
2040
|
+
// since the emitter module checks callback existence
|
2041
|
+
// by checking the length of arguments
|
2042
|
+
var args = ['change:' + key],
|
2043
|
+
ob = this.$compiler.observer
|
2044
|
+
if (callback) args.push(callback._fn)
|
2045
|
+
ob.off.apply(ob, args)
|
2046
|
+
})
|
2047
|
+
|
2048
|
+
/**
|
2049
|
+
* unbind everything, remove everything
|
2050
|
+
*/
|
2051
|
+
def(VMProto, '$destroy', function () {
|
2052
|
+
this.$compiler.destroy()
|
2053
|
+
})
|
2054
|
+
|
2055
|
+
/**
|
2056
|
+
* broadcast an event to all child VMs recursively.
|
2057
|
+
*/
|
2058
|
+
def(VMProto, '$broadcast', function () {
|
2059
|
+
var children = this.$compiler.children,
|
2060
|
+
i = children.length,
|
2061
|
+
child
|
2062
|
+
while (i--) {
|
2063
|
+
child = children[i]
|
2064
|
+
child.emitter.applyEmit.apply(child.emitter, arguments)
|
2065
|
+
child.vm.$broadcast.apply(child.vm, arguments)
|
2066
|
+
}
|
2067
|
+
})
|
2068
|
+
|
2069
|
+
/**
|
2070
|
+
* emit an event that propagates all the way up to parent VMs.
|
2071
|
+
*/
|
2072
|
+
def(VMProto, '$dispatch', function () {
|
2073
|
+
var compiler = this.$compiler,
|
2074
|
+
emitter = compiler.emitter,
|
2075
|
+
parent = compiler.parent
|
2076
|
+
emitter.applyEmit.apply(emitter, arguments)
|
2077
|
+
if (parent) {
|
2078
|
+
parent.vm.$dispatch.apply(parent.vm, arguments)
|
2079
|
+
}
|
2080
|
+
})
|
2081
|
+
|
2082
|
+
/**
|
2083
|
+
* delegate on/off/once to the compiler's emitter
|
2084
|
+
*/
|
2085
|
+
;['emit', 'on', 'off', 'once'].forEach(function (method) {
|
2086
|
+
// internal emit has fixed number of arguments.
|
2087
|
+
// exposed emit uses the external version
|
2088
|
+
// with fn.apply.
|
2089
|
+
var realMethod = method === 'emit'
|
2090
|
+
? 'applyEmit'
|
2091
|
+
: method
|
2092
|
+
def(VMProto, '$' + method, function () {
|
2093
|
+
var emitter = this.$compiler.emitter
|
2094
|
+
emitter[realMethod].apply(emitter, arguments)
|
2095
|
+
})
|
2096
|
+
})
|
2097
|
+
|
2098
|
+
// DOM convenience methods
|
2099
|
+
|
2100
|
+
def(VMProto, '$appendTo', function (target, cb) {
|
2101
|
+
target = query(target)
|
2102
|
+
var el = this.$el
|
2103
|
+
transition(el, 1, function () {
|
2104
|
+
target.appendChild(el)
|
2105
|
+
if (cb) nextTick(cb)
|
2106
|
+
}, this.$compiler)
|
2107
|
+
})
|
2108
|
+
|
2109
|
+
def(VMProto, '$remove', function (cb) {
|
2110
|
+
var el = this.$el
|
2111
|
+
transition(el, -1, function () {
|
2112
|
+
if (el.parentNode) {
|
2113
|
+
el.parentNode.removeChild(el)
|
2114
|
+
}
|
2115
|
+
if (cb) nextTick(cb)
|
2116
|
+
}, this.$compiler)
|
2117
|
+
})
|
2118
|
+
|
2119
|
+
def(VMProto, '$before', function (target, cb) {
|
2120
|
+
target = query(target)
|
2121
|
+
var el = this.$el
|
2122
|
+
transition(el, 1, function () {
|
2123
|
+
target.parentNode.insertBefore(el, target)
|
2124
|
+
if (cb) nextTick(cb)
|
2125
|
+
}, this.$compiler)
|
2126
|
+
})
|
2127
|
+
|
2128
|
+
def(VMProto, '$after', function (target, cb) {
|
2129
|
+
target = query(target)
|
2130
|
+
var el = this.$el
|
2131
|
+
transition(el, 1, function () {
|
2132
|
+
if (target.nextSibling) {
|
2133
|
+
target.parentNode.insertBefore(el, target.nextSibling)
|
2134
|
+
} else {
|
2135
|
+
target.parentNode.appendChild(el)
|
2136
|
+
}
|
2137
|
+
if (cb) nextTick(cb)
|
2138
|
+
}, this.$compiler)
|
2139
|
+
})
|
2140
|
+
|
2141
|
+
function query (el) {
|
2142
|
+
return typeof el === 'string'
|
2143
|
+
? document.querySelector(el)
|
2144
|
+
: el
|
2145
|
+
}
|
2146
|
+
|
2147
|
+
module.exports = ViewModel
|
2148
|
+
});
|
2149
|
+
require.register("vue/src/binding.js", function(exports, require, module){
|
2150
|
+
var Batcher = require('./batcher'),
|
2151
|
+
bindingBatcher = new Batcher(),
|
2152
|
+
bindingId = 1
|
2153
|
+
|
2154
|
+
/**
|
2155
|
+
* Binding class.
|
2156
|
+
*
|
2157
|
+
* each property on the viewmodel has one corresponding Binding object
|
2158
|
+
* which has multiple directive instances on the DOM
|
2159
|
+
* and multiple computed property dependents
|
2160
|
+
*/
|
2161
|
+
function Binding (compiler, key, isExp, isFn) {
|
2162
|
+
this.id = bindingId++
|
2163
|
+
this.value = undefined
|
2164
|
+
this.isExp = !!isExp
|
2165
|
+
this.isFn = isFn
|
2166
|
+
this.root = !this.isExp && key.indexOf('.') === -1
|
2167
|
+
this.compiler = compiler
|
2168
|
+
this.key = key
|
2169
|
+
this.dirs = []
|
2170
|
+
this.subs = []
|
2171
|
+
this.deps = []
|
2172
|
+
this.unbound = false
|
2173
|
+
}
|
2174
|
+
|
2175
|
+
var BindingProto = Binding.prototype
|
2176
|
+
|
2177
|
+
/**
|
2178
|
+
* Update value and queue instance updates.
|
2179
|
+
*/
|
2180
|
+
BindingProto.update = function (value) {
|
2181
|
+
if (!this.isComputed || this.isFn) {
|
2182
|
+
this.value = value
|
2183
|
+
}
|
2184
|
+
if (this.dirs.length || this.subs.length) {
|
2185
|
+
var self = this
|
2186
|
+
bindingBatcher.push({
|
2187
|
+
id: this.id,
|
2188
|
+
execute: function () {
|
2189
|
+
if (!self.unbound) {
|
2190
|
+
self._update()
|
2191
|
+
}
|
2192
|
+
}
|
2193
|
+
})
|
2194
|
+
}
|
2195
|
+
}
|
2196
|
+
|
2197
|
+
/**
|
2198
|
+
* Actually update the directives.
|
2199
|
+
*/
|
2200
|
+
BindingProto._update = function () {
|
2201
|
+
var i = this.dirs.length,
|
2202
|
+
value = this.val()
|
2203
|
+
while (i--) {
|
2204
|
+
this.dirs[i].$update(value)
|
2205
|
+
}
|
2206
|
+
this.pub()
|
2207
|
+
}
|
2208
|
+
|
2209
|
+
/**
|
2210
|
+
* Return the valuated value regardless
|
2211
|
+
* of whether it is computed or not
|
2212
|
+
*/
|
2213
|
+
BindingProto.val = function () {
|
2214
|
+
return this.isComputed && !this.isFn
|
2215
|
+
? this.value.$get()
|
2216
|
+
: this.value
|
2217
|
+
}
|
2218
|
+
|
2219
|
+
/**
|
2220
|
+
* Notify computed properties that depend on this binding
|
2221
|
+
* to update themselves
|
2222
|
+
*/
|
2223
|
+
BindingProto.pub = function () {
|
2224
|
+
var i = this.subs.length
|
2225
|
+
while (i--) {
|
2226
|
+
this.subs[i].update()
|
2227
|
+
}
|
2228
|
+
}
|
2229
|
+
|
2230
|
+
/**
|
2231
|
+
* Unbind the binding, remove itself from all of its dependencies
|
2232
|
+
*/
|
2233
|
+
BindingProto.unbind = function () {
|
2234
|
+
// Indicate this has been unbound.
|
2235
|
+
// It's possible this binding will be in
|
2236
|
+
// the batcher's flush queue when its owner
|
2237
|
+
// compiler has already been destroyed.
|
2238
|
+
this.unbound = true
|
2239
|
+
var i = this.dirs.length
|
2240
|
+
while (i--) {
|
2241
|
+
this.dirs[i].$unbind()
|
2242
|
+
}
|
2243
|
+
i = this.deps.length
|
2244
|
+
var subs
|
2245
|
+
while (i--) {
|
2246
|
+
subs = this.deps[i].subs
|
2247
|
+
var j = subs.indexOf(this)
|
2248
|
+
if (j > -1) subs.splice(j, 1)
|
2249
|
+
}
|
2250
|
+
}
|
2251
|
+
|
2252
|
+
module.exports = Binding
|
2253
|
+
});
|
2254
|
+
require.register("vue/src/observer.js", function(exports, require, module){
|
2255
|
+
/* jshint proto:true */
|
2256
|
+
|
2257
|
+
var Emitter = require('./emitter'),
|
2258
|
+
utils = require('./utils'),
|
2259
|
+
// cache methods
|
2260
|
+
def = utils.defProtected,
|
2261
|
+
isObject = utils.isObject,
|
2262
|
+
isArray = Array.isArray,
|
2263
|
+
hasOwn = ({}).hasOwnProperty,
|
2264
|
+
oDef = Object.defineProperty,
|
2265
|
+
slice = [].slice,
|
2266
|
+
// fix for IE + __proto__ problem
|
2267
|
+
// define methods as inenumerable if __proto__ is present,
|
2268
|
+
// otherwise enumerable so we can loop through and manually
|
2269
|
+
// attach to array instances
|
2270
|
+
hasProto = ({}).__proto__
|
2271
|
+
|
2272
|
+
// Array Mutation Handlers & Augmentations ------------------------------------
|
2273
|
+
|
2274
|
+
// The proxy prototype to replace the __proto__ of
|
2275
|
+
// an observed array
|
2276
|
+
var ArrayProxy = Object.create(Array.prototype)
|
2277
|
+
|
2278
|
+
// intercept mutation methods
|
2279
|
+
;[
|
2280
|
+
'push',
|
2281
|
+
'pop',
|
2282
|
+
'shift',
|
2283
|
+
'unshift',
|
2284
|
+
'splice',
|
2285
|
+
'sort',
|
2286
|
+
'reverse'
|
2287
|
+
].forEach(watchMutation)
|
2288
|
+
|
2289
|
+
// Augment the ArrayProxy with convenience methods
|
2290
|
+
def(ArrayProxy, '$set', function (index, data) {
|
2291
|
+
return this.splice(index, 1, data)[0]
|
2292
|
+
}, !hasProto)
|
2293
|
+
|
2294
|
+
def(ArrayProxy, '$remove', function (index) {
|
2295
|
+
if (typeof index !== 'number') {
|
2296
|
+
index = this.indexOf(index)
|
2297
|
+
}
|
2298
|
+
if (index > -1) {
|
2299
|
+
return this.splice(index, 1)[0]
|
2300
|
+
}
|
2301
|
+
}, !hasProto)
|
2302
|
+
|
2303
|
+
/**
|
2304
|
+
* Intercep a mutation event so we can emit the mutation info.
|
2305
|
+
* we also analyze what elements are added/removed and link/unlink
|
2306
|
+
* them with the parent Array.
|
2307
|
+
*/
|
2308
|
+
function watchMutation (method) {
|
2309
|
+
def(ArrayProxy, method, function () {
|
2310
|
+
|
2311
|
+
var args = slice.call(arguments),
|
2312
|
+
result = Array.prototype[method].apply(this, args),
|
2313
|
+
inserted, removed
|
2314
|
+
|
2315
|
+
// determine new / removed elements
|
2316
|
+
if (method === 'push' || method === 'unshift') {
|
2317
|
+
inserted = args
|
2318
|
+
} else if (method === 'pop' || method === 'shift') {
|
2319
|
+
removed = [result]
|
2320
|
+
} else if (method === 'splice') {
|
2321
|
+
inserted = args.slice(2)
|
2322
|
+
removed = result
|
2323
|
+
}
|
2324
|
+
|
2325
|
+
// link & unlink
|
2326
|
+
linkArrayElements(this, inserted)
|
2327
|
+
unlinkArrayElements(this, removed)
|
2328
|
+
|
2329
|
+
// emit the mutation event
|
2330
|
+
this.__emitter__.emit('mutate', '', this, {
|
2331
|
+
method : method,
|
2332
|
+
args : args,
|
2333
|
+
result : result,
|
2334
|
+
inserted : inserted,
|
2335
|
+
removed : removed
|
2336
|
+
})
|
2337
|
+
|
2338
|
+
return result
|
2339
|
+
|
2340
|
+
}, !hasProto)
|
2341
|
+
}
|
2342
|
+
|
2343
|
+
/**
|
2344
|
+
* Link new elements to an Array, so when they change
|
2345
|
+
* and emit events, the owner Array can be notified.
|
2346
|
+
*/
|
2347
|
+
function linkArrayElements (arr, items) {
|
2348
|
+
if (items) {
|
2349
|
+
var i = items.length, item, owners
|
2350
|
+
while (i--) {
|
2351
|
+
item = items[i]
|
2352
|
+
if (isWatchable(item)) {
|
2353
|
+
// if object is not converted for observing
|
2354
|
+
// convert it...
|
2355
|
+
if (!item.__emitter__) {
|
2356
|
+
convert(item)
|
2357
|
+
watch(item)
|
2358
|
+
}
|
2359
|
+
owners = item.__emitter__.owners
|
2360
|
+
if (owners.indexOf(arr) < 0) {
|
2361
|
+
owners.push(arr)
|
2362
|
+
}
|
2363
|
+
}
|
2364
|
+
}
|
2365
|
+
}
|
2366
|
+
}
|
2367
|
+
|
2368
|
+
/**
|
2369
|
+
* Unlink removed elements from the ex-owner Array.
|
2370
|
+
*/
|
2371
|
+
function unlinkArrayElements (arr, items) {
|
2372
|
+
if (items) {
|
2373
|
+
var i = items.length, item
|
2374
|
+
while (i--) {
|
2375
|
+
item = items[i]
|
2376
|
+
if (item && item.__emitter__) {
|
2377
|
+
var owners = item.__emitter__.owners
|
2378
|
+
if (owners) owners.splice(owners.indexOf(arr))
|
2379
|
+
}
|
2380
|
+
}
|
2381
|
+
}
|
2382
|
+
}
|
2383
|
+
|
2384
|
+
// Object add/delete key augmentation -----------------------------------------
|
2385
|
+
|
2386
|
+
var ObjProxy = Object.create(Object.prototype)
|
2387
|
+
|
2388
|
+
def(ObjProxy, '$add', function (key, val) {
|
2389
|
+
if (hasOwn.call(this, key)) return
|
2390
|
+
this[key] = val
|
2391
|
+
convertKey(this, key, true)
|
2392
|
+
}, !hasProto)
|
2393
|
+
|
2394
|
+
def(ObjProxy, '$delete', function (key) {
|
2395
|
+
if (!(hasOwn.call(this, key))) return
|
2396
|
+
// trigger set events
|
2397
|
+
this[key] = undefined
|
2398
|
+
delete this[key]
|
2399
|
+
this.__emitter__.emit('delete', key)
|
2400
|
+
}, !hasProto)
|
2401
|
+
|
2402
|
+
// Watch Helpers --------------------------------------------------------------
|
2403
|
+
|
2404
|
+
/**
|
2405
|
+
* Check if a value is watchable
|
2406
|
+
*/
|
2407
|
+
function isWatchable (obj) {
|
2408
|
+
return typeof obj === 'object' && obj && !obj.$compiler
|
2409
|
+
}
|
2410
|
+
|
2411
|
+
/**
|
2412
|
+
* Convert an Object/Array to give it a change emitter.
|
2413
|
+
*/
|
2414
|
+
function convert (obj) {
|
2415
|
+
if (obj.__emitter__) return true
|
2416
|
+
var emitter = new Emitter()
|
2417
|
+
def(obj, '__emitter__', emitter)
|
2418
|
+
emitter
|
2419
|
+
.on('set', function (key, val, propagate) {
|
2420
|
+
if (propagate) propagateChange(obj)
|
2421
|
+
})
|
2422
|
+
.on('mutate', function () {
|
2423
|
+
propagateChange(obj)
|
2424
|
+
})
|
2425
|
+
emitter.values = utils.hash()
|
2426
|
+
emitter.owners = []
|
2427
|
+
return false
|
2428
|
+
}
|
2429
|
+
|
2430
|
+
/**
|
2431
|
+
* Propagate an array element's change to its owner arrays
|
2432
|
+
*/
|
2433
|
+
function propagateChange (obj) {
|
2434
|
+
var owners = obj.__emitter__.owners,
|
2435
|
+
i = owners.length
|
2436
|
+
while (i--) {
|
2437
|
+
owners[i].__emitter__.emit('set', '', '', true)
|
2438
|
+
}
|
2439
|
+
}
|
2440
|
+
|
2441
|
+
/**
|
2442
|
+
* Watch target based on its type
|
2443
|
+
*/
|
2444
|
+
function watch (obj) {
|
2445
|
+
if (isArray(obj)) {
|
2446
|
+
watchArray(obj)
|
2447
|
+
} else {
|
2448
|
+
watchObject(obj)
|
2449
|
+
}
|
2450
|
+
}
|
2451
|
+
|
2452
|
+
/**
|
2453
|
+
* Augment target objects with modified
|
2454
|
+
* methods
|
2455
|
+
*/
|
2456
|
+
function augment (target, src) {
|
2457
|
+
if (hasProto) {
|
2458
|
+
target.__proto__ = src
|
2459
|
+
} else {
|
2460
|
+
for (var key in src) {
|
2461
|
+
def(target, key, src[key])
|
2462
|
+
}
|
2463
|
+
}
|
2464
|
+
}
|
2465
|
+
|
2466
|
+
/**
|
2467
|
+
* Watch an Object, recursive.
|
2468
|
+
*/
|
2469
|
+
function watchObject (obj) {
|
2470
|
+
augment(obj, ObjProxy)
|
2471
|
+
for (var key in obj) {
|
2472
|
+
convertKey(obj, key)
|
2473
|
+
}
|
2474
|
+
}
|
2475
|
+
|
2476
|
+
/**
|
2477
|
+
* Watch an Array, overload mutation methods
|
2478
|
+
* and add augmentations by intercepting the prototype chain
|
2479
|
+
*/
|
2480
|
+
function watchArray (arr) {
|
2481
|
+
augment(arr, ArrayProxy)
|
2482
|
+
linkArrayElements(arr, arr)
|
2483
|
+
}
|
2484
|
+
|
2485
|
+
/**
|
2486
|
+
* Define accessors for a property on an Object
|
2487
|
+
* so it emits get/set events.
|
2488
|
+
* Then watch the value itself.
|
2489
|
+
*/
|
2490
|
+
function convertKey (obj, key, propagate) {
|
2491
|
+
var keyPrefix = key.charAt(0)
|
2492
|
+
if (keyPrefix === '$' || keyPrefix === '_') {
|
2493
|
+
return
|
2494
|
+
}
|
2495
|
+
// emit set on bind
|
2496
|
+
// this means when an object is observed it will emit
|
2497
|
+
// a first batch of set events.
|
2498
|
+
var emitter = obj.__emitter__,
|
2499
|
+
values = emitter.values
|
2500
|
+
|
2501
|
+
init(obj[key], propagate)
|
2502
|
+
|
2503
|
+
oDef(obj, key, {
|
2504
|
+
enumerable: true,
|
2505
|
+
configurable: true,
|
2506
|
+
get: function () {
|
2507
|
+
var value = values[key]
|
2508
|
+
// only emit get on tip values
|
2509
|
+
if (pub.shouldGet) {
|
2510
|
+
emitter.emit('get', key)
|
2511
|
+
}
|
2512
|
+
return value
|
2513
|
+
},
|
2514
|
+
set: function (newVal) {
|
2515
|
+
var oldVal = values[key]
|
2516
|
+
unobserve(oldVal, key, emitter)
|
2517
|
+
copyPaths(newVal, oldVal)
|
2518
|
+
// an immediate property should notify its parent
|
2519
|
+
// to emit set for itself too
|
2520
|
+
init(newVal, true)
|
2521
|
+
}
|
2522
|
+
})
|
2523
|
+
|
2524
|
+
function init (val, propagate) {
|
2525
|
+
values[key] = val
|
2526
|
+
emitter.emit('set', key, val, propagate)
|
2527
|
+
if (isArray(val)) {
|
2528
|
+
emitter.emit('set', key + '.length', val.length, propagate)
|
2529
|
+
}
|
2530
|
+
observe(val, key, emitter)
|
2531
|
+
}
|
2532
|
+
}
|
2533
|
+
|
2534
|
+
/**
|
2535
|
+
* When a value that is already converted is
|
2536
|
+
* observed again by another observer, we can skip
|
2537
|
+
* the watch conversion and simply emit set event for
|
2538
|
+
* all of its properties.
|
2539
|
+
*/
|
2540
|
+
function emitSet (obj) {
|
2541
|
+
var emitter = obj && obj.__emitter__
|
2542
|
+
if (!emitter) return
|
2543
|
+
if (isArray(obj)) {
|
2544
|
+
emitter.emit('set', 'length', obj.length)
|
2545
|
+
} else {
|
2546
|
+
var key, val
|
2547
|
+
for (key in obj) {
|
2548
|
+
val = obj[key]
|
2549
|
+
emitter.emit('set', key, val)
|
2550
|
+
emitSet(val)
|
2551
|
+
}
|
2552
|
+
}
|
2553
|
+
}
|
2554
|
+
|
2555
|
+
/**
|
2556
|
+
* Make sure all the paths in an old object exists
|
2557
|
+
* in a new object.
|
2558
|
+
* So when an object changes, all missing keys will
|
2559
|
+
* emit a set event with undefined value.
|
2560
|
+
*/
|
2561
|
+
function copyPaths (newObj, oldObj) {
|
2562
|
+
if (!isObject(newObj) || !isObject(oldObj)) {
|
2563
|
+
return
|
2564
|
+
}
|
2565
|
+
var path, oldVal, newVal
|
2566
|
+
for (path in oldObj) {
|
2567
|
+
if (!(hasOwn.call(newObj, path))) {
|
2568
|
+
oldVal = oldObj[path]
|
2569
|
+
if (isArray(oldVal)) {
|
2570
|
+
newObj[path] = []
|
2571
|
+
} else if (isObject(oldVal)) {
|
2572
|
+
newVal = newObj[path] = {}
|
2573
|
+
copyPaths(newVal, oldVal)
|
2574
|
+
} else {
|
2575
|
+
newObj[path] = undefined
|
2576
|
+
}
|
2577
|
+
}
|
2578
|
+
}
|
2579
|
+
}
|
2580
|
+
|
2581
|
+
/**
|
2582
|
+
* walk along a path and make sure it can be accessed
|
2583
|
+
* and enumerated in that object
|
2584
|
+
*/
|
2585
|
+
function ensurePath (obj, key) {
|
2586
|
+
var path = key.split('.'), sec
|
2587
|
+
for (var i = 0, d = path.length - 1; i < d; i++) {
|
2588
|
+
sec = path[i]
|
2589
|
+
if (!obj[sec]) {
|
2590
|
+
obj[sec] = {}
|
2591
|
+
if (obj.__emitter__) convertKey(obj, sec)
|
2592
|
+
}
|
2593
|
+
obj = obj[sec]
|
2594
|
+
}
|
2595
|
+
if (isObject(obj)) {
|
2596
|
+
sec = path[i]
|
2597
|
+
if (!(hasOwn.call(obj, sec))) {
|
2598
|
+
obj[sec] = undefined
|
2599
|
+
if (obj.__emitter__) convertKey(obj, sec)
|
2600
|
+
}
|
2601
|
+
}
|
2602
|
+
}
|
2603
|
+
|
2604
|
+
// Main API Methods -----------------------------------------------------------
|
2605
|
+
|
2606
|
+
/**
|
2607
|
+
* Observe an object with a given path,
|
2608
|
+
* and proxy get/set/mutate events to the provided observer.
|
2609
|
+
*/
|
2610
|
+
function observe (obj, rawPath, observer) {
|
2611
|
+
|
2612
|
+
if (!isWatchable(obj)) return
|
2613
|
+
|
2614
|
+
var path = rawPath ? rawPath + '.' : '',
|
2615
|
+
alreadyConverted = convert(obj),
|
2616
|
+
emitter = obj.__emitter__
|
2617
|
+
|
2618
|
+
// setup proxy listeners on the parent observer.
|
2619
|
+
// we need to keep reference to them so that they
|
2620
|
+
// can be removed when the object is un-observed.
|
2621
|
+
observer.proxies = observer.proxies || {}
|
2622
|
+
var proxies = observer.proxies[path] = {
|
2623
|
+
get: function (key) {
|
2624
|
+
observer.emit('get', path + key)
|
2625
|
+
},
|
2626
|
+
set: function (key, val, propagate) {
|
2627
|
+
if (key) observer.emit('set', path + key, val)
|
2628
|
+
// also notify observer that the object itself changed
|
2629
|
+
// but only do so when it's a immediate property. this
|
2630
|
+
// avoids duplicate event firing.
|
2631
|
+
if (rawPath && propagate) {
|
2632
|
+
observer.emit('set', rawPath, obj, true)
|
2633
|
+
}
|
2634
|
+
},
|
2635
|
+
mutate: function (key, val, mutation) {
|
2636
|
+
// if the Array is a root value
|
2637
|
+
// the key will be null
|
2638
|
+
var fixedPath = key ? path + key : rawPath
|
2639
|
+
observer.emit('mutate', fixedPath, val, mutation)
|
2640
|
+
// also emit set for Array's length when it mutates
|
2641
|
+
var m = mutation.method
|
2642
|
+
if (m !== 'sort' && m !== 'reverse') {
|
2643
|
+
observer.emit('set', fixedPath + '.length', val.length)
|
2644
|
+
}
|
2645
|
+
}
|
2646
|
+
}
|
2647
|
+
|
2648
|
+
// attach the listeners to the child observer.
|
2649
|
+
// now all the events will propagate upwards.
|
2650
|
+
emitter
|
2651
|
+
.on('get', proxies.get)
|
2652
|
+
.on('set', proxies.set)
|
2653
|
+
.on('mutate', proxies.mutate)
|
2654
|
+
|
2655
|
+
if (alreadyConverted) {
|
2656
|
+
// for objects that have already been converted,
|
2657
|
+
// emit set events for everything inside
|
2658
|
+
emitSet(obj)
|
2659
|
+
} else {
|
2660
|
+
watch(obj)
|
2661
|
+
}
|
2662
|
+
}
|
2663
|
+
|
2664
|
+
/**
|
2665
|
+
* Cancel observation, turn off the listeners.
|
2666
|
+
*/
|
2667
|
+
function unobserve (obj, path, observer) {
|
2668
|
+
|
2669
|
+
if (!obj || !obj.__emitter__) return
|
2670
|
+
|
2671
|
+
path = path ? path + '.' : ''
|
2672
|
+
var proxies = observer.proxies[path]
|
2673
|
+
if (!proxies) return
|
2674
|
+
|
2675
|
+
// turn off listeners
|
2676
|
+
obj.__emitter__
|
2677
|
+
.off('get', proxies.get)
|
2678
|
+
.off('set', proxies.set)
|
2679
|
+
.off('mutate', proxies.mutate)
|
2680
|
+
|
2681
|
+
// remove reference
|
2682
|
+
observer.proxies[path] = null
|
2683
|
+
}
|
2684
|
+
|
2685
|
+
// Expose API -----------------------------------------------------------------
|
2686
|
+
|
2687
|
+
var pub = module.exports = {
|
2688
|
+
|
2689
|
+
// whether to emit get events
|
2690
|
+
// only enabled during dependency parsing
|
2691
|
+
shouldGet : false,
|
2692
|
+
|
2693
|
+
observe : observe,
|
2694
|
+
unobserve : unobserve,
|
2695
|
+
ensurePath : ensurePath,
|
2696
|
+
copyPaths : copyPaths,
|
2697
|
+
watch : watch,
|
2698
|
+
convert : convert,
|
2699
|
+
convertKey : convertKey
|
2700
|
+
}
|
2701
|
+
});
|
2702
|
+
require.register("vue/src/directive.js", function(exports, require, module){
|
2703
|
+
var dirId = 1,
|
2704
|
+
ARG_RE = /^[\w\$-]+$/,
|
2705
|
+
FILTER_TOKEN_RE = /[^\s'"]+|'[^']+'|"[^"]+"/g,
|
2706
|
+
NESTING_RE = /^\$(parent|root)\./,
|
2707
|
+
SINGLE_VAR_RE = /^[\w\.$]+$/,
|
2708
|
+
QUOTE_RE = /"/g,
|
2709
|
+
TextParser = require('./text-parser')
|
2710
|
+
|
2711
|
+
/**
|
2712
|
+
* Directive class
|
2713
|
+
* represents a single directive instance in the DOM
|
2714
|
+
*/
|
2715
|
+
function Directive (name, ast, definition, compiler, el) {
|
2716
|
+
|
2717
|
+
this.id = dirId++
|
2718
|
+
this.name = name
|
2719
|
+
this.compiler = compiler
|
2720
|
+
this.vm = compiler.vm
|
2721
|
+
this.el = el
|
2722
|
+
this.computeFilters = false
|
2723
|
+
this.key = ast.key
|
2724
|
+
this.arg = ast.arg
|
2725
|
+
this.expression = ast.expression
|
2726
|
+
|
2727
|
+
var isEmpty = this.expression === ''
|
2728
|
+
|
2729
|
+
// mix in properties from the directive definition
|
2730
|
+
if (typeof definition === 'function') {
|
2731
|
+
this[isEmpty ? 'bind' : 'update'] = definition
|
2732
|
+
} else {
|
2733
|
+
for (var prop in definition) {
|
2734
|
+
this[prop] = definition[prop]
|
2735
|
+
}
|
2736
|
+
}
|
2737
|
+
|
2738
|
+
// empty expression, we're done.
|
2739
|
+
if (isEmpty || this.isEmpty) {
|
2740
|
+
this.isEmpty = true
|
2741
|
+
return
|
2742
|
+
}
|
2743
|
+
|
2744
|
+
if (TextParser.Regex.test(this.key)) {
|
2745
|
+
this.key = compiler.eval(this.key)
|
2746
|
+
if (this.isLiteral) {
|
2747
|
+
this.expression = this.key
|
2748
|
+
}
|
2749
|
+
}
|
2750
|
+
|
2751
|
+
var filters = ast.filters,
|
2752
|
+
filter, fn, i, l, computed
|
2753
|
+
if (filters) {
|
2754
|
+
this.filters = []
|
2755
|
+
for (i = 0, l = filters.length; i < l; i++) {
|
2756
|
+
filter = filters[i]
|
2757
|
+
fn = this.compiler.getOption('filters', filter.name)
|
2758
|
+
if (fn) {
|
2759
|
+
filter.apply = fn
|
2760
|
+
this.filters.push(filter)
|
2761
|
+
if (fn.computed) {
|
2762
|
+
computed = true
|
2763
|
+
}
|
2764
|
+
}
|
2765
|
+
}
|
2766
|
+
}
|
2767
|
+
|
2768
|
+
if (!this.filters || !this.filters.length) {
|
2769
|
+
this.filters = null
|
2770
|
+
}
|
2771
|
+
|
2772
|
+
if (computed) {
|
2773
|
+
this.computedKey = Directive.inlineFilters(this.key, this.filters)
|
2774
|
+
this.filters = null
|
2775
|
+
}
|
2776
|
+
|
2777
|
+
this.isExp =
|
2778
|
+
computed ||
|
2779
|
+
!SINGLE_VAR_RE.test(this.key) ||
|
2780
|
+
NESTING_RE.test(this.key)
|
2781
|
+
|
2782
|
+
}
|
2783
|
+
|
2784
|
+
var DirProto = Directive.prototype
|
2785
|
+
|
2786
|
+
/**
|
2787
|
+
* called when a new value is set
|
2788
|
+
* for computed properties, this will only be called once
|
2789
|
+
* during initialization.
|
2790
|
+
*/
|
2791
|
+
DirProto.$update = function (value, init) {
|
2792
|
+
if (this.$lock) return
|
2793
|
+
if (init || value !== this.value || (value && typeof value === 'object')) {
|
2794
|
+
this.value = value
|
2795
|
+
if (this.update) {
|
2796
|
+
this.update(
|
2797
|
+
this.filters && !this.computeFilters
|
2798
|
+
? this.$applyFilters(value)
|
2799
|
+
: value,
|
2800
|
+
init
|
2801
|
+
)
|
2802
|
+
}
|
2803
|
+
}
|
2804
|
+
}
|
2805
|
+
|
2806
|
+
/**
|
2807
|
+
* pipe the value through filters
|
2808
|
+
*/
|
2809
|
+
DirProto.$applyFilters = function (value) {
|
2810
|
+
var filtered = value, filter
|
2811
|
+
for (var i = 0, l = this.filters.length; i < l; i++) {
|
2812
|
+
filter = this.filters[i]
|
2813
|
+
filtered = filter.apply.apply(this.vm, [filtered].concat(filter.args))
|
2814
|
+
}
|
2815
|
+
return filtered
|
2816
|
+
}
|
2817
|
+
|
2818
|
+
/**
|
2819
|
+
* Unbind diretive
|
2820
|
+
*/
|
2821
|
+
DirProto.$unbind = function () {
|
2822
|
+
// this can be called before the el is even assigned...
|
2823
|
+
if (!this.el || !this.vm) return
|
2824
|
+
if (this.unbind) this.unbind()
|
2825
|
+
this.vm = this.el = this.binding = this.compiler = null
|
2826
|
+
}
|
2827
|
+
|
2828
|
+
// Exposed static methods -----------------------------------------------------
|
2829
|
+
|
2830
|
+
/**
|
2831
|
+
* Parse a directive string into an Array of
|
2832
|
+
* AST-like objects representing directives
|
2833
|
+
*/
|
2834
|
+
Directive.parse = function (str) {
|
2835
|
+
|
2836
|
+
var inSingle = false,
|
2837
|
+
inDouble = false,
|
2838
|
+
curly = 0,
|
2839
|
+
square = 0,
|
2840
|
+
paren = 0,
|
2841
|
+
begin = 0,
|
2842
|
+
argIndex = 0,
|
2843
|
+
dirs = [],
|
2844
|
+
dir = {},
|
2845
|
+
lastFilterIndex = 0,
|
2846
|
+
arg
|
2847
|
+
|
2848
|
+
for (var c, i = 0, l = str.length; i < l; i++) {
|
2849
|
+
c = str.charAt(i)
|
2850
|
+
if (inSingle) {
|
2851
|
+
// check single quote
|
2852
|
+
if (c === "'") inSingle = !inSingle
|
2853
|
+
} else if (inDouble) {
|
2854
|
+
// check double quote
|
2855
|
+
if (c === '"') inDouble = !inDouble
|
2856
|
+
} else if (c === ',' && !paren && !curly && !square) {
|
2857
|
+
// reached the end of a directive
|
2858
|
+
pushDir()
|
2859
|
+
// reset & skip the comma
|
2860
|
+
dir = {}
|
2861
|
+
begin = argIndex = lastFilterIndex = i + 1
|
2862
|
+
} else if (c === ':' && !dir.key && !dir.arg) {
|
2863
|
+
// argument
|
2864
|
+
arg = str.slice(begin, i).trim()
|
2865
|
+
if (ARG_RE.test(arg)) {
|
2866
|
+
argIndex = i + 1
|
2867
|
+
dir.arg = arg
|
2868
|
+
}
|
2869
|
+
} else if (c === '|' && str.charAt(i + 1) !== '|' && str.charAt(i - 1) !== '|') {
|
2870
|
+
if (dir.key === undefined) {
|
2871
|
+
// first filter, end of key
|
2872
|
+
lastFilterIndex = i + 1
|
2873
|
+
dir.key = str.slice(argIndex, i).trim()
|
2874
|
+
} else {
|
2875
|
+
// already has filter
|
2876
|
+
pushFilter()
|
2877
|
+
}
|
2878
|
+
} else if (c === '"') {
|
2879
|
+
inDouble = true
|
2880
|
+
} else if (c === "'") {
|
2881
|
+
inSingle = true
|
2882
|
+
} else if (c === '(') {
|
2883
|
+
paren++
|
2884
|
+
} else if (c === ')') {
|
2885
|
+
paren--
|
2886
|
+
} else if (c === '[') {
|
2887
|
+
square++
|
2888
|
+
} else if (c === ']') {
|
2889
|
+
square--
|
2890
|
+
} else if (c === '{') {
|
2891
|
+
curly++
|
2892
|
+
} else if (c === '}') {
|
2893
|
+
curly--
|
2894
|
+
}
|
2895
|
+
}
|
2896
|
+
if (i === 0 || begin !== i) {
|
2897
|
+
pushDir()
|
2898
|
+
}
|
2899
|
+
|
2900
|
+
function pushDir () {
|
2901
|
+
dir.expression = str.slice(begin, i).trim()
|
2902
|
+
if (dir.key === undefined) {
|
2903
|
+
dir.key = str.slice(argIndex, i).trim()
|
2904
|
+
} else if (lastFilterIndex !== begin) {
|
2905
|
+
pushFilter()
|
2906
|
+
}
|
2907
|
+
if (i === 0 || dir.key) {
|
2908
|
+
dirs.push(dir)
|
2909
|
+
}
|
2910
|
+
}
|
2911
|
+
|
2912
|
+
function pushFilter () {
|
2913
|
+
var exp = str.slice(lastFilterIndex, i).trim(),
|
2914
|
+
filter
|
2915
|
+
if (exp) {
|
2916
|
+
filter = {}
|
2917
|
+
var tokens = exp.match(FILTER_TOKEN_RE)
|
2918
|
+
filter.name = tokens[0]
|
2919
|
+
filter.args = tokens.length > 1 ? tokens.slice(1) : null
|
2920
|
+
}
|
2921
|
+
if (filter) {
|
2922
|
+
(dir.filters = dir.filters || []).push(filter)
|
2923
|
+
}
|
2924
|
+
lastFilterIndex = i + 1
|
2925
|
+
}
|
2926
|
+
|
2927
|
+
return dirs
|
2928
|
+
}
|
2929
|
+
|
2930
|
+
/**
|
2931
|
+
* Inline computed filters so they become part
|
2932
|
+
* of the expression
|
2933
|
+
*/
|
2934
|
+
Directive.inlineFilters = function (key, filters) {
|
2935
|
+
var args, filter
|
2936
|
+
for (var i = 0, l = filters.length; i < l; i++) {
|
2937
|
+
filter = filters[i]
|
2938
|
+
args = filter.args
|
2939
|
+
? ',"' + filter.args.map(escapeQuote).join('","') + '"'
|
2940
|
+
: ''
|
2941
|
+
key = 'this.$compiler.getOption("filters", "' +
|
2942
|
+
filter.name +
|
2943
|
+
'").call(this,' +
|
2944
|
+
key + args +
|
2945
|
+
')'
|
2946
|
+
}
|
2947
|
+
return key
|
2948
|
+
}
|
2949
|
+
|
2950
|
+
/**
|
2951
|
+
* Convert double quotes to single quotes
|
2952
|
+
* so they don't mess up the generated function body
|
2953
|
+
*/
|
2954
|
+
function escapeQuote (v) {
|
2955
|
+
return v.indexOf('"') > -1
|
2956
|
+
? v.replace(QUOTE_RE, '\'')
|
2957
|
+
: v
|
2958
|
+
}
|
2959
|
+
|
2960
|
+
module.exports = Directive
|
2961
|
+
});
|
2962
|
+
require.register("vue/src/exp-parser.js", function(exports, require, module){
|
2963
|
+
var utils = require('./utils'),
|
2964
|
+
STR_SAVE_RE = /"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'/g,
|
2965
|
+
STR_RESTORE_RE = /"(\d+)"/g,
|
2966
|
+
NEWLINE_RE = /\n/g,
|
2967
|
+
CTOR_RE = new RegExp('constructor'.split('').join('[\'"+, ]*')),
|
2968
|
+
UNICODE_RE = /\\u\d\d\d\d/
|
2969
|
+
|
2970
|
+
// Variable extraction scooped from https://github.com/RubyLouvre/avalon
|
2971
|
+
|
2972
|
+
var KEYWORDS =
|
2973
|
+
// keywords
|
2974
|
+
'break,case,catch,continue,debugger,default,delete,do,else,false' +
|
2975
|
+
',finally,for,function,if,in,instanceof,new,null,return,switch,this' +
|
2976
|
+
',throw,true,try,typeof,var,void,while,with,undefined' +
|
2977
|
+
// reserved
|
2978
|
+
',abstract,boolean,byte,char,class,const,double,enum,export,extends' +
|
2979
|
+
',final,float,goto,implements,import,int,interface,long,native' +
|
2980
|
+
',package,private,protected,public,short,static,super,synchronized' +
|
2981
|
+
',throws,transient,volatile' +
|
2982
|
+
// ECMA 5 - use strict
|
2983
|
+
',arguments,let,yield' +
|
2984
|
+
// allow using Math in expressions
|
2985
|
+
',Math',
|
2986
|
+
|
2987
|
+
KEYWORDS_RE = new RegExp(["\\b" + KEYWORDS.replace(/,/g, '\\b|\\b') + "\\b"].join('|'), 'g'),
|
2988
|
+
REMOVE_RE = /\/\*(?:.|\n)*?\*\/|\/\/[^\n]*\n|\/\/[^\n]*$|'[^']*'|"[^"]*"|[\s\t\n]*\.[\s\t\n]*[$\w\.]+|[\{,]\s*[\w\$_]+\s*:/g,
|
2989
|
+
SPLIT_RE = /[^\w$]+/g,
|
2990
|
+
NUMBER_RE = /\b\d[^,]*/g,
|
2991
|
+
BOUNDARY_RE = /^,+|,+$/g
|
2992
|
+
|
2993
|
+
/**
|
2994
|
+
* Strip top level variable names from a snippet of JS expression
|
2995
|
+
*/
|
2996
|
+
function getVariables (code) {
|
2997
|
+
code = code
|
2998
|
+
.replace(REMOVE_RE, '')
|
2999
|
+
.replace(SPLIT_RE, ',')
|
3000
|
+
.replace(KEYWORDS_RE, '')
|
3001
|
+
.replace(NUMBER_RE, '')
|
3002
|
+
.replace(BOUNDARY_RE, '')
|
3003
|
+
return code
|
3004
|
+
? code.split(/,+/)
|
3005
|
+
: []
|
3006
|
+
}
|
3007
|
+
|
3008
|
+
/**
|
3009
|
+
* A given path could potentially exist not on the
|
3010
|
+
* current compiler, but up in the parent chain somewhere.
|
3011
|
+
* This function generates an access relationship string
|
3012
|
+
* that can be used in the getter function by walking up
|
3013
|
+
* the parent chain to check for key existence.
|
3014
|
+
*
|
3015
|
+
* It stops at top parent if no vm in the chain has the
|
3016
|
+
* key. It then creates any missing bindings on the
|
3017
|
+
* final resolved vm.
|
3018
|
+
*/
|
3019
|
+
function traceScope (path, compiler, data) {
|
3020
|
+
var rel = '',
|
3021
|
+
dist = 0,
|
3022
|
+
self = compiler
|
3023
|
+
|
3024
|
+
if (data && utils.get(data, path) !== undefined) {
|
3025
|
+
// hack: temporarily attached data
|
3026
|
+
return '$temp.'
|
3027
|
+
}
|
3028
|
+
|
3029
|
+
while (compiler) {
|
3030
|
+
if (compiler.hasKey(path)) {
|
3031
|
+
break
|
3032
|
+
} else {
|
3033
|
+
compiler = compiler.parent
|
3034
|
+
dist++
|
3035
|
+
}
|
3036
|
+
}
|
3037
|
+
if (compiler) {
|
3038
|
+
while (dist--) {
|
3039
|
+
rel += '$parent.'
|
3040
|
+
}
|
3041
|
+
if (!compiler.bindings[path] && path.charAt(0) !== '$') {
|
3042
|
+
compiler.createBinding(path)
|
3043
|
+
}
|
3044
|
+
} else {
|
3045
|
+
self.createBinding(path)
|
3046
|
+
}
|
3047
|
+
return rel
|
3048
|
+
}
|
3049
|
+
|
3050
|
+
/**
|
3051
|
+
* Create a function from a string...
|
3052
|
+
* this looks like evil magic but since all variables are limited
|
3053
|
+
* to the VM's data it's actually properly sandboxed
|
3054
|
+
*/
|
3055
|
+
function makeGetter (exp, raw) {
|
3056
|
+
var fn
|
3057
|
+
try {
|
3058
|
+
fn = new Function(exp)
|
3059
|
+
} catch (e) {
|
3060
|
+
utils.warn('Error parsing expression: ' + raw)
|
3061
|
+
}
|
3062
|
+
return fn
|
3063
|
+
}
|
3064
|
+
|
3065
|
+
/**
|
3066
|
+
* Escape a leading dollar sign for regex construction
|
3067
|
+
*/
|
3068
|
+
function escapeDollar (v) {
|
3069
|
+
return v.charAt(0) === '$'
|
3070
|
+
? '\\' + v
|
3071
|
+
: v
|
3072
|
+
}
|
3073
|
+
|
3074
|
+
/**
|
3075
|
+
* Parse and return an anonymous computed property getter function
|
3076
|
+
* from an arbitrary expression, together with a list of paths to be
|
3077
|
+
* created as bindings.
|
3078
|
+
*/
|
3079
|
+
exports.parse = function (exp, compiler, data) {
|
3080
|
+
// unicode and 'constructor' are not allowed for XSS security.
|
3081
|
+
if (UNICODE_RE.test(exp) || CTOR_RE.test(exp)) {
|
3082
|
+
utils.warn('Unsafe expression: ' + exp)
|
3083
|
+
return
|
3084
|
+
}
|
3085
|
+
// extract variable names
|
3086
|
+
var vars = getVariables(exp)
|
3087
|
+
if (!vars.length) {
|
3088
|
+
return makeGetter('return ' + exp, exp)
|
3089
|
+
}
|
3090
|
+
vars = utils.unique(vars)
|
3091
|
+
|
3092
|
+
var accessors = '',
|
3093
|
+
has = utils.hash(),
|
3094
|
+
strings = [],
|
3095
|
+
// construct a regex to extract all valid variable paths
|
3096
|
+
// ones that begin with "$" are particularly tricky
|
3097
|
+
// because we can't use \b for them
|
3098
|
+
pathRE = new RegExp(
|
3099
|
+
"[^$\\w\\.](" +
|
3100
|
+
vars.map(escapeDollar).join('|') +
|
3101
|
+
")[$\\w\\.]*\\b", 'g'
|
3102
|
+
),
|
3103
|
+
body = (' ' + exp)
|
3104
|
+
.replace(STR_SAVE_RE, saveStrings)
|
3105
|
+
.replace(pathRE, replacePath)
|
3106
|
+
.replace(STR_RESTORE_RE, restoreStrings)
|
3107
|
+
|
3108
|
+
body = accessors + 'return ' + body
|
3109
|
+
|
3110
|
+
function saveStrings (str) {
|
3111
|
+
var i = strings.length
|
3112
|
+
// escape newlines in strings so the expression
|
3113
|
+
// can be correctly evaluated
|
3114
|
+
strings[i] = str.replace(NEWLINE_RE, '\\n')
|
3115
|
+
return '"' + i + '"'
|
3116
|
+
}
|
3117
|
+
|
3118
|
+
function replacePath (path) {
|
3119
|
+
// keep track of the first char
|
3120
|
+
var c = path.charAt(0)
|
3121
|
+
path = path.slice(1)
|
3122
|
+
var val = 'this.' + traceScope(path, compiler, data) + path
|
3123
|
+
if (!has[path]) {
|
3124
|
+
accessors += val + ';'
|
3125
|
+
has[path] = 1
|
3126
|
+
}
|
3127
|
+
// don't forget to put that first char back
|
3128
|
+
return c + val
|
3129
|
+
}
|
3130
|
+
|
3131
|
+
function restoreStrings (str, i) {
|
3132
|
+
return strings[i]
|
3133
|
+
}
|
3134
|
+
|
3135
|
+
return makeGetter(body, exp)
|
3136
|
+
}
|
3137
|
+
|
3138
|
+
/**
|
3139
|
+
* Evaluate an expression in the context of a compiler.
|
3140
|
+
* Accepts additional data.
|
3141
|
+
*/
|
3142
|
+
exports.eval = function (exp, compiler, data) {
|
3143
|
+
var getter = exports.parse(exp, compiler, data), res
|
3144
|
+
if (getter) {
|
3145
|
+
// hack: temporarily attach the additional data so
|
3146
|
+
// it can be accessed in the getter
|
3147
|
+
compiler.vm.$temp = data
|
3148
|
+
res = getter.call(compiler.vm)
|
3149
|
+
delete compiler.vm.$temp
|
3150
|
+
}
|
3151
|
+
return res
|
3152
|
+
}
|
3153
|
+
});
|
3154
|
+
require.register("vue/src/text-parser.js", function(exports, require, module){
|
3155
|
+
var openChar = '{',
|
3156
|
+
endChar = '}',
|
3157
|
+
ESCAPE_RE = /[-.*+?^${}()|[\]\/\\]/g,
|
3158
|
+
// lazy require
|
3159
|
+
Directive
|
3160
|
+
|
3161
|
+
exports.Regex = buildInterpolationRegex()
|
3162
|
+
|
3163
|
+
function buildInterpolationRegex () {
|
3164
|
+
var open = escapeRegex(openChar),
|
3165
|
+
end = escapeRegex(endChar)
|
3166
|
+
return new RegExp(open + open + open + '?(.+?)' + end + '?' + end + end)
|
3167
|
+
}
|
3168
|
+
|
3169
|
+
function escapeRegex (str) {
|
3170
|
+
return str.replace(ESCAPE_RE, '\\$&')
|
3171
|
+
}
|
3172
|
+
|
3173
|
+
function setDelimiters (delimiters) {
|
3174
|
+
openChar = delimiters[0]
|
3175
|
+
endChar = delimiters[1]
|
3176
|
+
exports.delimiters = delimiters
|
3177
|
+
exports.Regex = buildInterpolationRegex()
|
3178
|
+
}
|
3179
|
+
|
3180
|
+
/**
|
3181
|
+
* Parse a piece of text, return an array of tokens
|
3182
|
+
* token types:
|
3183
|
+
* 1. plain string
|
3184
|
+
* 2. object with key = binding key
|
3185
|
+
* 3. object with key & html = true
|
3186
|
+
*/
|
3187
|
+
function parse (text) {
|
3188
|
+
if (!exports.Regex.test(text)) return null
|
3189
|
+
var m, i, token, match, tokens = []
|
3190
|
+
/* jshint boss: true */
|
3191
|
+
while (m = text.match(exports.Regex)) {
|
3192
|
+
i = m.index
|
3193
|
+
if (i > 0) tokens.push(text.slice(0, i))
|
3194
|
+
token = { key: m[1].trim() }
|
3195
|
+
match = m[0]
|
3196
|
+
token.html =
|
3197
|
+
match.charAt(2) === openChar &&
|
3198
|
+
match.charAt(match.length - 3) === endChar
|
3199
|
+
tokens.push(token)
|
3200
|
+
text = text.slice(i + m[0].length)
|
3201
|
+
}
|
3202
|
+
if (text.length) tokens.push(text)
|
3203
|
+
return tokens
|
3204
|
+
}
|
3205
|
+
|
3206
|
+
/**
|
3207
|
+
* Parse an attribute value with possible interpolation tags
|
3208
|
+
* return a Directive-friendly expression
|
3209
|
+
*
|
3210
|
+
* e.g. a {{b}} c => "a " + b + " c"
|
3211
|
+
*/
|
3212
|
+
function parseAttr (attr) {
|
3213
|
+
Directive = Directive || require('./directive')
|
3214
|
+
var tokens = parse(attr)
|
3215
|
+
if (!tokens) return null
|
3216
|
+
if (tokens.length === 1) return tokens[0].key
|
3217
|
+
var res = [], token
|
3218
|
+
for (var i = 0, l = tokens.length; i < l; i++) {
|
3219
|
+
token = tokens[i]
|
3220
|
+
res.push(
|
3221
|
+
token.key
|
3222
|
+
? inlineFilters(token.key)
|
3223
|
+
: ('"' + token + '"')
|
3224
|
+
)
|
3225
|
+
}
|
3226
|
+
return res.join('+')
|
3227
|
+
}
|
3228
|
+
|
3229
|
+
/**
|
3230
|
+
* Inlines any possible filters in a binding
|
3231
|
+
* so that we can combine everything into a huge expression
|
3232
|
+
*/
|
3233
|
+
function inlineFilters (key) {
|
3234
|
+
if (key.indexOf('|') > -1) {
|
3235
|
+
var dirs = Directive.parse(key),
|
3236
|
+
dir = dirs && dirs[0]
|
3237
|
+
if (dir && dir.filters) {
|
3238
|
+
key = Directive.inlineFilters(
|
3239
|
+
dir.key,
|
3240
|
+
dir.filters
|
3241
|
+
)
|
3242
|
+
}
|
3243
|
+
}
|
3244
|
+
return '(' + key + ')'
|
3245
|
+
}
|
3246
|
+
|
3247
|
+
exports.parse = parse
|
3248
|
+
exports.parseAttr = parseAttr
|
3249
|
+
exports.setDelimiters = setDelimiters
|
3250
|
+
exports.delimiters = [openChar, endChar]
|
3251
|
+
});
|
3252
|
+
require.register("vue/src/deps-parser.js", function(exports, require, module){
|
3253
|
+
var Emitter = require('./emitter'),
|
3254
|
+
utils = require('./utils'),
|
3255
|
+
Observer = require('./observer'),
|
3256
|
+
catcher = new Emitter()
|
3257
|
+
|
3258
|
+
/**
|
3259
|
+
* Auto-extract the dependencies of a computed property
|
3260
|
+
* by recording the getters triggered when evaluating it.
|
3261
|
+
*/
|
3262
|
+
function catchDeps (binding) {
|
3263
|
+
if (binding.isFn) return
|
3264
|
+
utils.log('\n- ' + binding.key)
|
3265
|
+
var got = utils.hash()
|
3266
|
+
binding.deps = []
|
3267
|
+
catcher.on('get', function (dep) {
|
3268
|
+
var has = got[dep.key]
|
3269
|
+
if (
|
3270
|
+
// avoid duplicate bindings
|
3271
|
+
(has && has.compiler === dep.compiler) ||
|
3272
|
+
// avoid repeated items as dependency
|
3273
|
+
// only when the binding is from self or the parent chain
|
3274
|
+
(dep.compiler.repeat && !isParentOf(dep.compiler, binding.compiler))
|
3275
|
+
) {
|
3276
|
+
return
|
3277
|
+
}
|
3278
|
+
got[dep.key] = dep
|
3279
|
+
utils.log(' - ' + dep.key)
|
3280
|
+
binding.deps.push(dep)
|
3281
|
+
dep.subs.push(binding)
|
3282
|
+
})
|
3283
|
+
binding.value.$get()
|
3284
|
+
catcher.off('get')
|
3285
|
+
}
|
3286
|
+
|
3287
|
+
/**
|
3288
|
+
* Test if A is a parent of or equals B
|
3289
|
+
*/
|
3290
|
+
function isParentOf (a, b) {
|
3291
|
+
while (b) {
|
3292
|
+
if (a === b) {
|
3293
|
+
return true
|
3294
|
+
}
|
3295
|
+
b = b.parent
|
3296
|
+
}
|
3297
|
+
}
|
3298
|
+
|
3299
|
+
module.exports = {
|
3300
|
+
|
3301
|
+
/**
|
3302
|
+
* the observer that catches events triggered by getters
|
3303
|
+
*/
|
3304
|
+
catcher: catcher,
|
3305
|
+
|
3306
|
+
/**
|
3307
|
+
* parse a list of computed property bindings
|
3308
|
+
*/
|
3309
|
+
parse: function (bindings) {
|
3310
|
+
utils.log('\nparsing dependencies...')
|
3311
|
+
Observer.shouldGet = true
|
3312
|
+
bindings.forEach(catchDeps)
|
3313
|
+
Observer.shouldGet = false
|
3314
|
+
utils.log('\ndone.')
|
3315
|
+
}
|
3316
|
+
|
3317
|
+
}
|
3318
|
+
});
|
3319
|
+
require.register("vue/src/filters.js", function(exports, require, module){
|
3320
|
+
var utils = require('./utils'),
|
3321
|
+
get = utils.get,
|
3322
|
+
slice = [].slice,
|
3323
|
+
QUOTE_RE = /^'.*'$/,
|
3324
|
+
filters = module.exports = utils.hash()
|
3325
|
+
|
3326
|
+
/**
|
3327
|
+
* 'abc' => 'Abc'
|
3328
|
+
*/
|
3329
|
+
filters.capitalize = function (value) {
|
3330
|
+
if (!value && value !== 0) return ''
|
3331
|
+
value = value.toString()
|
3332
|
+
return value.charAt(0).toUpperCase() + value.slice(1)
|
3333
|
+
}
|
3334
|
+
|
3335
|
+
/**
|
3336
|
+
* 'abc' => 'ABC'
|
3337
|
+
*/
|
3338
|
+
filters.uppercase = function (value) {
|
3339
|
+
return (value || value === 0)
|
3340
|
+
? value.toString().toUpperCase()
|
3341
|
+
: ''
|
3342
|
+
}
|
3343
|
+
|
3344
|
+
/**
|
3345
|
+
* 'AbC' => 'abc'
|
3346
|
+
*/
|
3347
|
+
filters.lowercase = function (value) {
|
3348
|
+
return (value || value === 0)
|
3349
|
+
? value.toString().toLowerCase()
|
3350
|
+
: ''
|
3351
|
+
}
|
3352
|
+
|
3353
|
+
/**
|
3354
|
+
* 12345 => $12,345.00
|
3355
|
+
*/
|
3356
|
+
filters.currency = function (value, sign) {
|
3357
|
+
if (!value && value !== 0) return ''
|
3358
|
+
sign = sign || '$'
|
3359
|
+
var s = Math.floor(value).toString(),
|
3360
|
+
i = s.length % 3,
|
3361
|
+
h = i > 0 ? (s.slice(0, i) + (s.length > 3 ? ',' : '')) : '',
|
3362
|
+
f = '.' + value.toFixed(2).slice(-2)
|
3363
|
+
return sign + h + s.slice(i).replace(/(\d{3})(?=\d)/g, '$1,') + f
|
3364
|
+
}
|
3365
|
+
|
3366
|
+
/**
|
3367
|
+
* args: an array of strings corresponding to
|
3368
|
+
* the single, double, triple ... forms of the word to
|
3369
|
+
* be pluralized. When the number to be pluralized
|
3370
|
+
* exceeds the length of the args, it will use the last
|
3371
|
+
* entry in the array.
|
3372
|
+
*
|
3373
|
+
* e.g. ['single', 'double', 'triple', 'multiple']
|
3374
|
+
*/
|
3375
|
+
filters.pluralize = function (value) {
|
3376
|
+
var args = slice.call(arguments, 1)
|
3377
|
+
return args.length > 1
|
3378
|
+
? (args[value - 1] || args[args.length - 1])
|
3379
|
+
: (args[value - 1] || args[0] + 's')
|
3380
|
+
}
|
3381
|
+
|
3382
|
+
/**
|
3383
|
+
* A special filter that takes a handler function,
|
3384
|
+
* wraps it so it only gets triggered on specific keypresses.
|
3385
|
+
*
|
3386
|
+
* v-on only
|
3387
|
+
*/
|
3388
|
+
|
3389
|
+
var keyCodes = {
|
3390
|
+
enter : 13,
|
3391
|
+
tab : 9,
|
3392
|
+
'delete' : 46,
|
3393
|
+
up : 38,
|
3394
|
+
left : 37,
|
3395
|
+
right : 39,
|
3396
|
+
down : 40,
|
3397
|
+
esc : 27
|
3398
|
+
}
|
3399
|
+
|
3400
|
+
filters.key = function (handler, key) {
|
3401
|
+
if (!handler) return
|
3402
|
+
var code = keyCodes[key]
|
3403
|
+
if (!code) {
|
3404
|
+
code = parseInt(key, 10)
|
3405
|
+
}
|
3406
|
+
return function (e) {
|
3407
|
+
if (e.keyCode === code) {
|
3408
|
+
return handler.call(this, e)
|
3409
|
+
}
|
3410
|
+
}
|
3411
|
+
}
|
3412
|
+
|
3413
|
+
/**
|
3414
|
+
* Filter filter for v-repeat
|
3415
|
+
*/
|
3416
|
+
filters.filterBy = function (arr, searchKey, delimiter, dataKey) {
|
3417
|
+
|
3418
|
+
// allow optional `in` delimiter
|
3419
|
+
// because why not
|
3420
|
+
if (delimiter && delimiter !== 'in') {
|
3421
|
+
dataKey = delimiter
|
3422
|
+
}
|
3423
|
+
|
3424
|
+
// get the search string
|
3425
|
+
var search = stripQuotes(searchKey) || this.$get(searchKey)
|
3426
|
+
if (!search) return arr
|
3427
|
+
search = search.toLowerCase()
|
3428
|
+
|
3429
|
+
// get the optional dataKey
|
3430
|
+
dataKey = dataKey && (stripQuotes(dataKey) || this.$get(dataKey))
|
3431
|
+
|
3432
|
+
// convert object to array
|
3433
|
+
if (!Array.isArray(arr)) {
|
3434
|
+
arr = utils.objectToArray(arr)
|
3435
|
+
}
|
3436
|
+
|
3437
|
+
return arr.filter(function (item) {
|
3438
|
+
return dataKey
|
3439
|
+
? contains(get(item, dataKey), search)
|
3440
|
+
: contains(item, search)
|
3441
|
+
})
|
3442
|
+
|
3443
|
+
}
|
3444
|
+
|
3445
|
+
filters.filterBy.computed = true
|
3446
|
+
|
3447
|
+
/**
|
3448
|
+
* Sort fitler for v-repeat
|
3449
|
+
*/
|
3450
|
+
filters.orderBy = function (arr, sortKey, reverseKey) {
|
3451
|
+
|
3452
|
+
var key = stripQuotes(sortKey) || this.$get(sortKey)
|
3453
|
+
if (!key) return arr
|
3454
|
+
|
3455
|
+
// convert object to array
|
3456
|
+
if (!Array.isArray(arr)) {
|
3457
|
+
arr = utils.objectToArray(arr)
|
3458
|
+
}
|
3459
|
+
|
3460
|
+
var order = 1
|
3461
|
+
if (reverseKey) {
|
3462
|
+
if (reverseKey === '-1') {
|
3463
|
+
order = -1
|
3464
|
+
} else if (reverseKey.charAt(0) === '!') {
|
3465
|
+
reverseKey = reverseKey.slice(1)
|
3466
|
+
order = this.$get(reverseKey) ? 1 : -1
|
3467
|
+
} else {
|
3468
|
+
order = this.$get(reverseKey) ? -1 : 1
|
3469
|
+
}
|
3470
|
+
}
|
3471
|
+
|
3472
|
+
// sort on a copy to avoid mutating original array
|
3473
|
+
return arr.slice().sort(function (a, b) {
|
3474
|
+
a = get(a, key)
|
3475
|
+
b = get(b, key)
|
3476
|
+
return a === b ? 0 : a > b ? order : -order
|
3477
|
+
})
|
3478
|
+
|
3479
|
+
}
|
3480
|
+
|
3481
|
+
filters.orderBy.computed = true
|
3482
|
+
|
3483
|
+
// Array filter helpers -------------------------------------------------------
|
3484
|
+
|
3485
|
+
/**
|
3486
|
+
* String contain helper
|
3487
|
+
*/
|
3488
|
+
function contains (val, search) {
|
3489
|
+
/* jshint eqeqeq: false */
|
3490
|
+
if (utils.isObject(val)) {
|
3491
|
+
for (var key in val) {
|
3492
|
+
if (contains(val[key], search)) {
|
3493
|
+
return true
|
3494
|
+
}
|
3495
|
+
}
|
3496
|
+
} else if (val != null) {
|
3497
|
+
return val.toString().toLowerCase().indexOf(search) > -1
|
3498
|
+
}
|
3499
|
+
}
|
3500
|
+
|
3501
|
+
/**
|
3502
|
+
* Test whether a string is in quotes,
|
3503
|
+
* if yes return stripped string
|
3504
|
+
*/
|
3505
|
+
function stripQuotes (str) {
|
3506
|
+
if (QUOTE_RE.test(str)) {
|
3507
|
+
return str.slice(1, -1)
|
3508
|
+
}
|
3509
|
+
}
|
3510
|
+
});
|
3511
|
+
require.register("vue/src/transition.js", function(exports, require, module){
|
3512
|
+
var endEvents = sniffEndEvents(),
|
3513
|
+
config = require('./config'),
|
3514
|
+
// batch enter animations so we only force the layout once
|
3515
|
+
Batcher = require('./batcher'),
|
3516
|
+
batcher = new Batcher(),
|
3517
|
+
// cache timer functions
|
3518
|
+
setTO = window.setTimeout,
|
3519
|
+
clearTO = window.clearTimeout,
|
3520
|
+
// exit codes for testing
|
3521
|
+
codes = {
|
3522
|
+
CSS_E : 1,
|
3523
|
+
CSS_L : 2,
|
3524
|
+
JS_E : 3,
|
3525
|
+
JS_L : 4,
|
3526
|
+
CSS_SKIP : -1,
|
3527
|
+
JS_SKIP : -2,
|
3528
|
+
JS_SKIP_E : -3,
|
3529
|
+
JS_SKIP_L : -4,
|
3530
|
+
INIT : -5,
|
3531
|
+
SKIP : -6
|
3532
|
+
}
|
3533
|
+
|
3534
|
+
// force layout before triggering transitions/animations
|
3535
|
+
batcher._preFlush = function () {
|
3536
|
+
/* jshint unused: false */
|
3537
|
+
var f = document.body.offsetHeight
|
3538
|
+
}
|
3539
|
+
|
3540
|
+
/**
|
3541
|
+
* stage:
|
3542
|
+
* 1 = enter
|
3543
|
+
* 2 = leave
|
3544
|
+
*/
|
3545
|
+
var transition = module.exports = function (el, stage, cb, compiler) {
|
3546
|
+
|
3547
|
+
var changeState = function () {
|
3548
|
+
cb()
|
3549
|
+
compiler.execHook(stage > 0 ? 'attached' : 'detached')
|
3550
|
+
}
|
3551
|
+
|
3552
|
+
if (compiler.init) {
|
3553
|
+
changeState()
|
3554
|
+
return codes.INIT
|
3555
|
+
}
|
3556
|
+
|
3557
|
+
var hasTransition = el.vue_trans === '',
|
3558
|
+
hasAnimation = el.vue_anim === '',
|
3559
|
+
effectId = el.vue_effect
|
3560
|
+
|
3561
|
+
if (effectId) {
|
3562
|
+
return applyTransitionFunctions(
|
3563
|
+
el,
|
3564
|
+
stage,
|
3565
|
+
changeState,
|
3566
|
+
effectId,
|
3567
|
+
compiler
|
3568
|
+
)
|
3569
|
+
} else if (hasTransition || hasAnimation) {
|
3570
|
+
return applyTransitionClass(
|
3571
|
+
el,
|
3572
|
+
stage,
|
3573
|
+
changeState,
|
3574
|
+
hasAnimation
|
3575
|
+
)
|
3576
|
+
} else {
|
3577
|
+
changeState()
|
3578
|
+
return codes.SKIP
|
3579
|
+
}
|
3580
|
+
|
3581
|
+
}
|
3582
|
+
|
3583
|
+
/**
|
3584
|
+
* Togggle a CSS class to trigger transition
|
3585
|
+
*/
|
3586
|
+
function applyTransitionClass (el, stage, changeState, hasAnimation) {
|
3587
|
+
|
3588
|
+
if (!endEvents.trans) {
|
3589
|
+
changeState()
|
3590
|
+
return codes.CSS_SKIP
|
3591
|
+
}
|
3592
|
+
|
3593
|
+
// if the browser supports transition,
|
3594
|
+
// it must have classList...
|
3595
|
+
var onEnd,
|
3596
|
+
classList = el.classList,
|
3597
|
+
existingCallback = el.vue_trans_cb,
|
3598
|
+
enterClass = config.enterClass,
|
3599
|
+
leaveClass = config.leaveClass,
|
3600
|
+
endEvent = hasAnimation ? endEvents.anim : endEvents.trans
|
3601
|
+
|
3602
|
+
// cancel unfinished callbacks and jobs
|
3603
|
+
if (existingCallback) {
|
3604
|
+
el.removeEventListener(endEvent, existingCallback)
|
3605
|
+
classList.remove(enterClass)
|
3606
|
+
classList.remove(leaveClass)
|
3607
|
+
el.vue_trans_cb = null
|
3608
|
+
}
|
3609
|
+
|
3610
|
+
if (stage > 0) { // enter
|
3611
|
+
|
3612
|
+
// set to enter state before appending
|
3613
|
+
classList.add(enterClass)
|
3614
|
+
// append
|
3615
|
+
changeState()
|
3616
|
+
// trigger transition
|
3617
|
+
if (!hasAnimation) {
|
3618
|
+
batcher.push({
|
3619
|
+
execute: function () {
|
3620
|
+
classList.remove(enterClass)
|
3621
|
+
}
|
3622
|
+
})
|
3623
|
+
} else {
|
3624
|
+
onEnd = function (e) {
|
3625
|
+
if (e.target === el) {
|
3626
|
+
el.removeEventListener(endEvent, onEnd)
|
3627
|
+
el.vue_trans_cb = null
|
3628
|
+
classList.remove(enterClass)
|
3629
|
+
}
|
3630
|
+
}
|
3631
|
+
el.addEventListener(endEvent, onEnd)
|
3632
|
+
el.vue_trans_cb = onEnd
|
3633
|
+
}
|
3634
|
+
return codes.CSS_E
|
3635
|
+
|
3636
|
+
} else { // leave
|
3637
|
+
|
3638
|
+
if (el.offsetWidth || el.offsetHeight) {
|
3639
|
+
// trigger hide transition
|
3640
|
+
classList.add(leaveClass)
|
3641
|
+
onEnd = function (e) {
|
3642
|
+
if (e.target === el) {
|
3643
|
+
el.removeEventListener(endEvent, onEnd)
|
3644
|
+
el.vue_trans_cb = null
|
3645
|
+
// actually remove node here
|
3646
|
+
changeState()
|
3647
|
+
classList.remove(leaveClass)
|
3648
|
+
}
|
3649
|
+
}
|
3650
|
+
// attach transition end listener
|
3651
|
+
el.addEventListener(endEvent, onEnd)
|
3652
|
+
el.vue_trans_cb = onEnd
|
3653
|
+
} else {
|
3654
|
+
// directly remove invisible elements
|
3655
|
+
changeState()
|
3656
|
+
}
|
3657
|
+
return codes.CSS_L
|
3658
|
+
|
3659
|
+
}
|
3660
|
+
|
3661
|
+
}
|
3662
|
+
|
3663
|
+
function applyTransitionFunctions (el, stage, changeState, effectId, compiler) {
|
3664
|
+
|
3665
|
+
var funcs = compiler.getOption('effects', effectId)
|
3666
|
+
if (!funcs) {
|
3667
|
+
changeState()
|
3668
|
+
return codes.JS_SKIP
|
3669
|
+
}
|
3670
|
+
|
3671
|
+
var enter = funcs.enter,
|
3672
|
+
leave = funcs.leave,
|
3673
|
+
timeouts = el.vue_timeouts
|
3674
|
+
|
3675
|
+
// clear previous timeouts
|
3676
|
+
if (timeouts) {
|
3677
|
+
var i = timeouts.length
|
3678
|
+
while (i--) {
|
3679
|
+
clearTO(timeouts[i])
|
3680
|
+
}
|
3681
|
+
}
|
3682
|
+
|
3683
|
+
timeouts = el.vue_timeouts = []
|
3684
|
+
function timeout (cb, delay) {
|
3685
|
+
var id = setTO(function () {
|
3686
|
+
cb()
|
3687
|
+
timeouts.splice(timeouts.indexOf(id), 1)
|
3688
|
+
if (!timeouts.length) {
|
3689
|
+
el.vue_timeouts = null
|
3690
|
+
}
|
3691
|
+
}, delay)
|
3692
|
+
timeouts.push(id)
|
3693
|
+
}
|
3694
|
+
|
3695
|
+
if (stage > 0) { // enter
|
3696
|
+
if (typeof enter !== 'function') {
|
3697
|
+
changeState()
|
3698
|
+
return codes.JS_SKIP_E
|
3699
|
+
}
|
3700
|
+
enter(el, changeState, timeout)
|
3701
|
+
return codes.JS_E
|
3702
|
+
} else { // leave
|
3703
|
+
if (typeof leave !== 'function') {
|
3704
|
+
changeState()
|
3705
|
+
return codes.JS_SKIP_L
|
3706
|
+
}
|
3707
|
+
leave(el, changeState, timeout)
|
3708
|
+
return codes.JS_L
|
3709
|
+
}
|
3710
|
+
|
3711
|
+
}
|
3712
|
+
|
3713
|
+
/**
|
3714
|
+
* Sniff proper transition end event name
|
3715
|
+
*/
|
3716
|
+
function sniffEndEvents () {
|
3717
|
+
var el = document.createElement('vue'),
|
3718
|
+
defaultEvent = 'transitionend',
|
3719
|
+
events = {
|
3720
|
+
'webkitTransition' : 'webkitTransitionEnd',
|
3721
|
+
'transition' : defaultEvent,
|
3722
|
+
'mozTransition' : defaultEvent
|
3723
|
+
},
|
3724
|
+
ret = {}
|
3725
|
+
for (var name in events) {
|
3726
|
+
if (el.style[name] !== undefined) {
|
3727
|
+
ret.trans = events[name]
|
3728
|
+
break
|
3729
|
+
}
|
3730
|
+
}
|
3731
|
+
ret.anim = el.style.animation === ''
|
3732
|
+
? 'animationend'
|
3733
|
+
: 'webkitAnimationEnd'
|
3734
|
+
return ret
|
3735
|
+
}
|
3736
|
+
|
3737
|
+
// Expose some stuff for testing purposes
|
3738
|
+
transition.codes = codes
|
3739
|
+
transition.sniff = sniffEndEvents
|
3740
|
+
});
|
3741
|
+
require.register("vue/src/batcher.js", function(exports, require, module){
|
3742
|
+
var utils = require('./utils')
|
3743
|
+
|
3744
|
+
function Batcher () {
|
3745
|
+
this.reset()
|
3746
|
+
}
|
3747
|
+
|
3748
|
+
var BatcherProto = Batcher.prototype
|
3749
|
+
|
3750
|
+
BatcherProto.push = function (job) {
|
3751
|
+
if (!job.id || !this.has[job.id]) {
|
3752
|
+
this.queue.push(job)
|
3753
|
+
this.has[job.id] = job
|
3754
|
+
if (!this.waiting) {
|
3755
|
+
this.waiting = true
|
3756
|
+
utils.nextTick(utils.bind(this.flush, this))
|
3757
|
+
}
|
3758
|
+
} else if (job.override) {
|
3759
|
+
var oldJob = this.has[job.id]
|
3760
|
+
oldJob.cancelled = true
|
3761
|
+
this.queue.push(job)
|
3762
|
+
this.has[job.id] = job
|
3763
|
+
}
|
3764
|
+
}
|
3765
|
+
|
3766
|
+
BatcherProto.flush = function () {
|
3767
|
+
// before flush hook
|
3768
|
+
if (this._preFlush) this._preFlush()
|
3769
|
+
// do not cache length because more jobs might be pushed
|
3770
|
+
// as we execute existing jobs
|
3771
|
+
for (var i = 0; i < this.queue.length; i++) {
|
3772
|
+
var job = this.queue[i]
|
3773
|
+
if (!job.cancelled) {
|
3774
|
+
job.execute()
|
3775
|
+
}
|
3776
|
+
}
|
3777
|
+
this.reset()
|
3778
|
+
}
|
3779
|
+
|
3780
|
+
BatcherProto.reset = function () {
|
3781
|
+
this.has = utils.hash()
|
3782
|
+
this.queue = []
|
3783
|
+
this.waiting = false
|
3784
|
+
}
|
3785
|
+
|
3786
|
+
module.exports = Batcher
|
3787
|
+
});
|
3788
|
+
require.register("vue/src/directives/index.js", function(exports, require, module){
|
3789
|
+
var utils = require('../utils'),
|
3790
|
+
config = require('../config'),
|
3791
|
+
transition = require('../transition'),
|
3792
|
+
directives = module.exports = utils.hash()
|
3793
|
+
|
3794
|
+
/**
|
3795
|
+
* Nest and manage a Child VM
|
3796
|
+
*/
|
3797
|
+
directives.component = {
|
3798
|
+
isLiteral: true,
|
3799
|
+
bind: function () {
|
3800
|
+
if (!this.el.vue_vm) {
|
3801
|
+
this.childVM = new this.Ctor({
|
3802
|
+
el: this.el,
|
3803
|
+
parent: this.vm
|
3804
|
+
})
|
3805
|
+
}
|
3806
|
+
},
|
3807
|
+
unbind: function () {
|
3808
|
+
if (this.childVM) {
|
3809
|
+
this.childVM.$destroy()
|
3810
|
+
}
|
3811
|
+
}
|
3812
|
+
}
|
3813
|
+
|
3814
|
+
/**
|
3815
|
+
* Binding HTML attributes
|
3816
|
+
*/
|
3817
|
+
directives.attr = {
|
3818
|
+
bind: function () {
|
3819
|
+
var params = this.vm.$options.paramAttributes
|
3820
|
+
this.isParam = params && params.indexOf(this.arg) > -1
|
3821
|
+
},
|
3822
|
+
update: function (value) {
|
3823
|
+
if (value || value === 0) {
|
3824
|
+
this.el.setAttribute(this.arg, value)
|
3825
|
+
} else {
|
3826
|
+
this.el.removeAttribute(this.arg)
|
3827
|
+
}
|
3828
|
+
if (this.isParam) {
|
3829
|
+
this.vm[this.arg] = utils.checkNumber(value)
|
3830
|
+
}
|
3831
|
+
}
|
3832
|
+
}
|
3833
|
+
|
3834
|
+
/**
|
3835
|
+
* Binding textContent
|
3836
|
+
*/
|
3837
|
+
directives.text = {
|
3838
|
+
bind: function () {
|
3839
|
+
this.attr = this.el.nodeType === 3
|
3840
|
+
? 'nodeValue'
|
3841
|
+
: 'textContent'
|
3842
|
+
},
|
3843
|
+
update: function (value) {
|
3844
|
+
this.el[this.attr] = utils.guard(value)
|
3845
|
+
}
|
3846
|
+
}
|
3847
|
+
|
3848
|
+
/**
|
3849
|
+
* Binding CSS display property
|
3850
|
+
*/
|
3851
|
+
directives.show = function (value) {
|
3852
|
+
var el = this.el,
|
3853
|
+
target = value ? '' : 'none',
|
3854
|
+
change = function () {
|
3855
|
+
el.style.display = target
|
3856
|
+
}
|
3857
|
+
transition(el, value ? 1 : -1, change, this.compiler)
|
3858
|
+
}
|
3859
|
+
|
3860
|
+
/**
|
3861
|
+
* Binding CSS classes
|
3862
|
+
*/
|
3863
|
+
directives['class'] = function (value) {
|
3864
|
+
if (this.arg) {
|
3865
|
+
utils[value ? 'addClass' : 'removeClass'](this.el, this.arg)
|
3866
|
+
} else {
|
3867
|
+
if (this.lastVal) {
|
3868
|
+
utils.removeClass(this.el, this.lastVal)
|
3869
|
+
}
|
3870
|
+
if (value) {
|
3871
|
+
utils.addClass(this.el, value)
|
3872
|
+
this.lastVal = value
|
3873
|
+
}
|
3874
|
+
}
|
3875
|
+
}
|
3876
|
+
|
3877
|
+
/**
|
3878
|
+
* Only removed after the owner VM is ready
|
3879
|
+
*/
|
3880
|
+
directives.cloak = {
|
3881
|
+
isEmpty: true,
|
3882
|
+
bind: function () {
|
3883
|
+
var el = this.el
|
3884
|
+
this.compiler.observer.once('hook:ready', function () {
|
3885
|
+
el.removeAttribute(config.prefix + '-cloak')
|
3886
|
+
})
|
3887
|
+
}
|
3888
|
+
}
|
3889
|
+
|
3890
|
+
/**
|
3891
|
+
* Store a reference to self in parent VM's $
|
3892
|
+
*/
|
3893
|
+
directives.ref = {
|
3894
|
+
isLiteral: true,
|
3895
|
+
bind: function () {
|
3896
|
+
var id = this.expression
|
3897
|
+
if (id) {
|
3898
|
+
this.vm.$parent.$[id] = this.vm
|
3899
|
+
}
|
3900
|
+
},
|
3901
|
+
unbind: function () {
|
3902
|
+
var id = this.expression
|
3903
|
+
if (id) {
|
3904
|
+
delete this.vm.$parent.$[id]
|
3905
|
+
}
|
3906
|
+
}
|
3907
|
+
}
|
3908
|
+
|
3909
|
+
directives.on = require('./on')
|
3910
|
+
directives.repeat = require('./repeat')
|
3911
|
+
directives.model = require('./model')
|
3912
|
+
directives['if'] = require('./if')
|
3913
|
+
directives['with'] = require('./with')
|
3914
|
+
directives.html = require('./html')
|
3915
|
+
directives.style = require('./style')
|
3916
|
+
directives.partial = require('./partial')
|
3917
|
+
directives.view = require('./view')
|
3918
|
+
});
|
3919
|
+
require.register("vue/src/directives/if.js", function(exports, require, module){
|
3920
|
+
var utils = require('../utils')
|
3921
|
+
|
3922
|
+
/**
|
3923
|
+
* Manages a conditional child VM
|
3924
|
+
*/
|
3925
|
+
module.exports = {
|
3926
|
+
|
3927
|
+
bind: function () {
|
3928
|
+
|
3929
|
+
this.parent = this.el.parentNode
|
3930
|
+
this.ref = document.createComment('vue-if')
|
3931
|
+
this.Ctor = this.compiler.resolveComponent(this.el)
|
3932
|
+
|
3933
|
+
// insert ref
|
3934
|
+
this.parent.insertBefore(this.ref, this.el)
|
3935
|
+
this.parent.removeChild(this.el)
|
3936
|
+
|
3937
|
+
if (utils.attr(this.el, 'view')) {
|
3938
|
+
utils.warn(
|
3939
|
+
'Conflict: v-if cannot be used together with v-view. ' +
|
3940
|
+
'Just set v-view\'s binding value to empty string to empty it.'
|
3941
|
+
)
|
3942
|
+
}
|
3943
|
+
if (utils.attr(this.el, 'repeat')) {
|
3944
|
+
utils.warn(
|
3945
|
+
'Conflict: v-if cannot be used together with v-repeat. ' +
|
3946
|
+
'Use `v-show` or the `filterBy` filter instead.'
|
3947
|
+
)
|
3948
|
+
}
|
3949
|
+
},
|
3950
|
+
|
3951
|
+
update: function (value) {
|
3952
|
+
|
3953
|
+
if (!value) {
|
3954
|
+
this.unbind()
|
3955
|
+
} else if (!this.childVM) {
|
3956
|
+
this.childVM = new this.Ctor({
|
3957
|
+
el: this.el.cloneNode(true),
|
3958
|
+
parent: this.vm
|
3959
|
+
})
|
3960
|
+
if (this.compiler.init) {
|
3961
|
+
this.parent.insertBefore(this.childVM.$el, this.ref)
|
3962
|
+
} else {
|
3963
|
+
this.childVM.$before(this.ref)
|
3964
|
+
}
|
3965
|
+
}
|
3966
|
+
|
3967
|
+
},
|
3968
|
+
|
3969
|
+
unbind: function () {
|
3970
|
+
if (this.childVM) {
|
3971
|
+
this.childVM.$destroy()
|
3972
|
+
this.childVM = null
|
3973
|
+
}
|
3974
|
+
}
|
3975
|
+
}
|
3976
|
+
});
|
3977
|
+
require.register("vue/src/directives/repeat.js", function(exports, require, module){
|
3978
|
+
var utils = require('../utils'),
|
3979
|
+
config = require('../config')
|
3980
|
+
|
3981
|
+
/**
|
3982
|
+
* Binding that manages VMs based on an Array
|
3983
|
+
*/
|
3984
|
+
module.exports = {
|
3985
|
+
|
3986
|
+
bind: function () {
|
3987
|
+
|
3988
|
+
this.identifier = '$r' + this.id
|
3989
|
+
|
3990
|
+
// a hash to cache the same expressions on repeated instances
|
3991
|
+
// so they don't have to be compiled for every single instance
|
3992
|
+
this.expCache = utils.hash()
|
3993
|
+
|
3994
|
+
var el = this.el,
|
3995
|
+
ctn = this.container = el.parentNode
|
3996
|
+
|
3997
|
+
// extract child Id, if any
|
3998
|
+
this.childId = this.compiler.eval(utils.attr(el, 'ref'))
|
3999
|
+
|
4000
|
+
// create a comment node as a reference node for DOM insertions
|
4001
|
+
this.ref = document.createComment(config.prefix + '-repeat-' + this.key)
|
4002
|
+
ctn.insertBefore(this.ref, el)
|
4003
|
+
ctn.removeChild(el)
|
4004
|
+
|
4005
|
+
this.collection = null
|
4006
|
+
this.vms = null
|
4007
|
+
|
4008
|
+
},
|
4009
|
+
|
4010
|
+
update: function (collection) {
|
4011
|
+
|
4012
|
+
if (!Array.isArray(collection)) {
|
4013
|
+
if (utils.isObject(collection)) {
|
4014
|
+
collection = utils.objectToArray(collection)
|
4015
|
+
} else {
|
4016
|
+
utils.warn('v-repeat only accepts Array or Object values.')
|
4017
|
+
}
|
4018
|
+
}
|
4019
|
+
|
4020
|
+
// keep reference of old data and VMs
|
4021
|
+
// so we can reuse them if possible
|
4022
|
+
this.oldVMs = this.vms
|
4023
|
+
this.oldCollection = this.collection
|
4024
|
+
collection = this.collection = collection || []
|
4025
|
+
|
4026
|
+
var isObject = collection[0] && utils.isObject(collection[0])
|
4027
|
+
this.vms = this.oldCollection
|
4028
|
+
? this.diff(collection, isObject)
|
4029
|
+
: this.init(collection, isObject)
|
4030
|
+
|
4031
|
+
if (this.childId) {
|
4032
|
+
this.vm.$[this.childId] = this.vms
|
4033
|
+
}
|
4034
|
+
|
4035
|
+
},
|
4036
|
+
|
4037
|
+
init: function (collection, isObject) {
|
4038
|
+
var vm, vms = []
|
4039
|
+
for (var i = 0, l = collection.length; i < l; i++) {
|
4040
|
+
vm = this.build(collection[i], i, isObject)
|
4041
|
+
vms.push(vm)
|
4042
|
+
if (this.compiler.init) {
|
4043
|
+
this.container.insertBefore(vm.$el, this.ref)
|
4044
|
+
} else {
|
4045
|
+
vm.$before(this.ref)
|
4046
|
+
}
|
4047
|
+
}
|
4048
|
+
return vms
|
4049
|
+
},
|
4050
|
+
|
4051
|
+
/**
|
4052
|
+
* Diff the new array with the old
|
4053
|
+
* and determine the minimum amount of DOM manipulations.
|
4054
|
+
*/
|
4055
|
+
diff: function (newCollection, isObject) {
|
4056
|
+
|
4057
|
+
var i, l, item, vm,
|
4058
|
+
oldIndex,
|
4059
|
+
targetNext,
|
4060
|
+
currentNext,
|
4061
|
+
nextEl,
|
4062
|
+
ctn = this.container,
|
4063
|
+
oldVMs = this.oldVMs,
|
4064
|
+
vms = []
|
4065
|
+
|
4066
|
+
vms.length = newCollection.length
|
4067
|
+
|
4068
|
+
// first pass, collect new reused and new created
|
4069
|
+
for (i = 0, l = newCollection.length; i < l; i++) {
|
4070
|
+
item = newCollection[i]
|
4071
|
+
if (isObject) {
|
4072
|
+
item.$index = i
|
4073
|
+
if (item.__emitter__ && item.__emitter__[this.identifier]) {
|
4074
|
+
// this piece of data is being reused.
|
4075
|
+
// record its final position in reused vms
|
4076
|
+
item.$reused = true
|
4077
|
+
} else {
|
4078
|
+
vms[i] = this.build(item, i, isObject)
|
4079
|
+
}
|
4080
|
+
} else {
|
4081
|
+
// we can't attach an identifier to primitive values
|
4082
|
+
// so have to do an indexOf...
|
4083
|
+
oldIndex = indexOf(oldVMs, item)
|
4084
|
+
if (oldIndex > -1) {
|
4085
|
+
// record the position on the existing vm
|
4086
|
+
oldVMs[oldIndex].$reused = true
|
4087
|
+
oldVMs[oldIndex].$data.$index = i
|
4088
|
+
} else {
|
4089
|
+
vms[i] = this.build(item, i, isObject)
|
4090
|
+
}
|
4091
|
+
}
|
4092
|
+
}
|
4093
|
+
|
4094
|
+
// second pass, collect old reused and destroy unused
|
4095
|
+
for (i = 0, l = oldVMs.length; i < l; i++) {
|
4096
|
+
vm = oldVMs[i]
|
4097
|
+
item = this.arg
|
4098
|
+
? vm.$data[this.arg]
|
4099
|
+
: vm.$data
|
4100
|
+
if (item.$reused) {
|
4101
|
+
vm.$reused = true
|
4102
|
+
delete item.$reused
|
4103
|
+
}
|
4104
|
+
if (vm.$reused) {
|
4105
|
+
// update the index to latest
|
4106
|
+
vm.$index = item.$index
|
4107
|
+
// the item could have had a new key
|
4108
|
+
if (item.$key && item.$key !== vm.$key) {
|
4109
|
+
vm.$key = item.$key
|
4110
|
+
}
|
4111
|
+
vms[vm.$index] = vm
|
4112
|
+
} else {
|
4113
|
+
// this one can be destroyed.
|
4114
|
+
if (item.__emitter__) {
|
4115
|
+
delete item.__emitter__[this.identifier]
|
4116
|
+
}
|
4117
|
+
vm.$destroy()
|
4118
|
+
}
|
4119
|
+
}
|
4120
|
+
|
4121
|
+
// final pass, move/insert DOM elements
|
4122
|
+
i = vms.length
|
4123
|
+
while (i--) {
|
4124
|
+
vm = vms[i]
|
4125
|
+
item = vm.$data
|
4126
|
+
targetNext = vms[i + 1]
|
4127
|
+
if (vm.$reused) {
|
4128
|
+
nextEl = vm.$el.nextSibling
|
4129
|
+
// destroyed VMs' element might still be in the DOM
|
4130
|
+
// due to transitions
|
4131
|
+
while (!nextEl.vue_vm && nextEl !== this.ref) {
|
4132
|
+
nextEl = nextEl.nextSibling
|
4133
|
+
}
|
4134
|
+
currentNext = nextEl.vue_vm
|
4135
|
+
if (currentNext !== targetNext) {
|
4136
|
+
if (!targetNext) {
|
4137
|
+
ctn.insertBefore(vm.$el, this.ref)
|
4138
|
+
} else {
|
4139
|
+
nextEl = targetNext.$el
|
4140
|
+
// new VMs' element might not be in the DOM yet
|
4141
|
+
// due to transitions
|
4142
|
+
while (!nextEl.parentNode) {
|
4143
|
+
targetNext = vms[nextEl.vue_vm.$index + 1]
|
4144
|
+
nextEl = targetNext
|
4145
|
+
? targetNext.$el
|
4146
|
+
: this.ref
|
4147
|
+
}
|
4148
|
+
ctn.insertBefore(vm.$el, nextEl)
|
4149
|
+
}
|
4150
|
+
}
|
4151
|
+
delete vm.$reused
|
4152
|
+
delete item.$index
|
4153
|
+
delete item.$key
|
4154
|
+
} else { // a new vm
|
4155
|
+
vm.$before(targetNext ? targetNext.$el : this.ref)
|
4156
|
+
}
|
4157
|
+
}
|
4158
|
+
|
4159
|
+
return vms
|
4160
|
+
},
|
4161
|
+
|
4162
|
+
build: function (data, index, isObject) {
|
4163
|
+
|
4164
|
+
// wrap non-object values
|
4165
|
+
var raw, alias,
|
4166
|
+
wrap = !isObject || this.arg
|
4167
|
+
if (wrap) {
|
4168
|
+
raw = data
|
4169
|
+
alias = this.arg || '$value'
|
4170
|
+
data = {}
|
4171
|
+
data[alias] = raw
|
4172
|
+
}
|
4173
|
+
data.$index = index
|
4174
|
+
|
4175
|
+
var el = this.el.cloneNode(true),
|
4176
|
+
Ctor = this.compiler.resolveComponent(el, data),
|
4177
|
+
vm = new Ctor({
|
4178
|
+
el: el,
|
4179
|
+
data: data,
|
4180
|
+
parent: this.vm,
|
4181
|
+
compilerOptions: {
|
4182
|
+
repeat: true,
|
4183
|
+
expCache: this.expCache
|
4184
|
+
}
|
4185
|
+
})
|
4186
|
+
|
4187
|
+
if (isObject) {
|
4188
|
+
// attach an ienumerable identifier to the raw data
|
4189
|
+
(raw || data).__emitter__[this.identifier] = true
|
4190
|
+
}
|
4191
|
+
|
4192
|
+
return vm
|
4193
|
+
|
4194
|
+
},
|
4195
|
+
|
4196
|
+
unbind: function () {
|
4197
|
+
if (this.childId) {
|
4198
|
+
delete this.vm.$[this.childId]
|
4199
|
+
}
|
4200
|
+
if (this.vms) {
|
4201
|
+
var i = this.vms.length
|
4202
|
+
while (i--) {
|
4203
|
+
this.vms[i].$destroy()
|
4204
|
+
}
|
4205
|
+
}
|
4206
|
+
}
|
4207
|
+
}
|
4208
|
+
|
4209
|
+
// Helpers --------------------------------------------------------------------
|
4210
|
+
|
4211
|
+
/**
|
4212
|
+
* Find an object or a wrapped data object
|
4213
|
+
* from an Array
|
4214
|
+
*/
|
4215
|
+
function indexOf (vms, obj) {
|
4216
|
+
for (var vm, i = 0, l = vms.length; i < l; i++) {
|
4217
|
+
vm = vms[i]
|
4218
|
+
if (!vm.$reused && vm.$value === obj) {
|
4219
|
+
return i
|
4220
|
+
}
|
4221
|
+
}
|
4222
|
+
return -1
|
4223
|
+
}
|
4224
|
+
});
|
4225
|
+
require.register("vue/src/directives/on.js", function(exports, require, module){
|
4226
|
+
var utils = require('../utils')
|
4227
|
+
|
4228
|
+
/**
|
4229
|
+
* Binding for event listeners
|
4230
|
+
*/
|
4231
|
+
module.exports = {
|
4232
|
+
|
4233
|
+
isFn: true,
|
4234
|
+
|
4235
|
+
bind: function () {
|
4236
|
+
this.context = this.binding.isExp
|
4237
|
+
? this.vm
|
4238
|
+
: this.binding.compiler.vm
|
4239
|
+
if (this.el.tagName === 'IFRAME' && this.arg !== 'load') {
|
4240
|
+
var self = this
|
4241
|
+
this.iframeBind = function () {
|
4242
|
+
self.el.contentWindow.addEventListener(self.arg, self.handler)
|
4243
|
+
}
|
4244
|
+
this.el.addEventListener('load', this.iframeBind)
|
4245
|
+
}
|
4246
|
+
},
|
4247
|
+
|
4248
|
+
update: function (handler) {
|
4249
|
+
if (typeof handler !== 'function') {
|
4250
|
+
utils.warn('Directive "v-on:' + this.expression + '" expects a method.')
|
4251
|
+
return
|
4252
|
+
}
|
4253
|
+
this.reset()
|
4254
|
+
var vm = this.vm,
|
4255
|
+
context = this.context
|
4256
|
+
this.handler = function (e) {
|
4257
|
+
e.targetVM = vm
|
4258
|
+
context.$event = e
|
4259
|
+
var res = handler.call(context, e)
|
4260
|
+
context.$event = null
|
4261
|
+
return res
|
4262
|
+
}
|
4263
|
+
if (this.iframeBind) {
|
4264
|
+
this.iframeBind()
|
4265
|
+
} else {
|
4266
|
+
this.el.addEventListener(this.arg, this.handler)
|
4267
|
+
}
|
4268
|
+
},
|
4269
|
+
|
4270
|
+
reset: function () {
|
4271
|
+
var el = this.iframeBind
|
4272
|
+
? this.el.contentWindow
|
4273
|
+
: this.el
|
4274
|
+
el.removeEventListener(this.arg, this.handler)
|
4275
|
+
},
|
4276
|
+
|
4277
|
+
unbind: function () {
|
4278
|
+
this.reset()
|
4279
|
+
this.el.removeEventListener('load', this.iframeBind)
|
4280
|
+
}
|
4281
|
+
}
|
4282
|
+
});
|
4283
|
+
require.register("vue/src/directives/model.js", function(exports, require, module){
|
4284
|
+
var utils = require('../utils'),
|
4285
|
+
isIE9 = navigator.userAgent.indexOf('MSIE 9.0') > 0,
|
4286
|
+
filter = [].filter
|
4287
|
+
|
4288
|
+
/**
|
4289
|
+
* Returns an array of values from a multiple select
|
4290
|
+
*/
|
4291
|
+
function getMultipleSelectOptions (select) {
|
4292
|
+
return filter
|
4293
|
+
.call(select.options, function (option) {
|
4294
|
+
return option.selected
|
4295
|
+
})
|
4296
|
+
.map(function (option) {
|
4297
|
+
return option.value || option.text
|
4298
|
+
})
|
4299
|
+
}
|
4300
|
+
|
4301
|
+
/**
|
4302
|
+
* Two-way binding for form input elements
|
4303
|
+
*/
|
4304
|
+
module.exports = {
|
4305
|
+
|
4306
|
+
bind: function () {
|
4307
|
+
|
4308
|
+
var self = this,
|
4309
|
+
el = self.el,
|
4310
|
+
type = el.type,
|
4311
|
+
tag = el.tagName
|
4312
|
+
|
4313
|
+
self.lock = false
|
4314
|
+
self.ownerVM = self.binding.compiler.vm
|
4315
|
+
|
4316
|
+
// determine what event to listen to
|
4317
|
+
self.event =
|
4318
|
+
(self.compiler.options.lazy ||
|
4319
|
+
tag === 'SELECT' ||
|
4320
|
+
type === 'checkbox' || type === 'radio')
|
4321
|
+
? 'change'
|
4322
|
+
: 'input'
|
4323
|
+
|
4324
|
+
// determine the attribute to change when updating
|
4325
|
+
self.attr = type === 'checkbox'
|
4326
|
+
? 'checked'
|
4327
|
+
: (tag === 'INPUT' || tag === 'SELECT' || tag === 'TEXTAREA')
|
4328
|
+
? 'value'
|
4329
|
+
: 'innerHTML'
|
4330
|
+
|
4331
|
+
// select[multiple] support
|
4332
|
+
if(tag === 'SELECT' && el.hasAttribute('multiple')) {
|
4333
|
+
this.multi = true
|
4334
|
+
}
|
4335
|
+
|
4336
|
+
var compositionLock = false
|
4337
|
+
self.cLock = function () {
|
4338
|
+
compositionLock = true
|
4339
|
+
}
|
4340
|
+
self.cUnlock = function () {
|
4341
|
+
compositionLock = false
|
4342
|
+
}
|
4343
|
+
el.addEventListener('compositionstart', this.cLock)
|
4344
|
+
el.addEventListener('compositionend', this.cUnlock)
|
4345
|
+
|
4346
|
+
// attach listener
|
4347
|
+
self.set = self.filters
|
4348
|
+
? function () {
|
4349
|
+
if (compositionLock) return
|
4350
|
+
// if this directive has filters
|
4351
|
+
// we need to let the vm.$set trigger
|
4352
|
+
// update() so filters are applied.
|
4353
|
+
// therefore we have to record cursor position
|
4354
|
+
// so that after vm.$set changes the input
|
4355
|
+
// value we can put the cursor back at where it is
|
4356
|
+
var cursorPos
|
4357
|
+
try { cursorPos = el.selectionStart } catch (e) {}
|
4358
|
+
|
4359
|
+
self._set()
|
4360
|
+
|
4361
|
+
// since updates are async
|
4362
|
+
// we need to reset cursor position async too
|
4363
|
+
utils.nextTick(function () {
|
4364
|
+
if (cursorPos !== undefined) {
|
4365
|
+
el.setSelectionRange(cursorPos, cursorPos)
|
4366
|
+
}
|
4367
|
+
})
|
4368
|
+
}
|
4369
|
+
: function () {
|
4370
|
+
if (compositionLock) return
|
4371
|
+
// no filters, don't let it trigger update()
|
4372
|
+
self.lock = true
|
4373
|
+
|
4374
|
+
self._set()
|
4375
|
+
|
4376
|
+
utils.nextTick(function () {
|
4377
|
+
self.lock = false
|
4378
|
+
})
|
4379
|
+
}
|
4380
|
+
el.addEventListener(self.event, self.set)
|
4381
|
+
|
4382
|
+
// fix shit for IE9
|
4383
|
+
// since it doesn't fire input on backspace / del / cut
|
4384
|
+
if (isIE9) {
|
4385
|
+
self.onCut = function () {
|
4386
|
+
// cut event fires before the value actually changes
|
4387
|
+
utils.nextTick(function () {
|
4388
|
+
self.set()
|
4389
|
+
})
|
4390
|
+
}
|
4391
|
+
self.onDel = function (e) {
|
4392
|
+
if (e.keyCode === 46 || e.keyCode === 8) {
|
4393
|
+
self.set()
|
4394
|
+
}
|
4395
|
+
}
|
4396
|
+
el.addEventListener('cut', self.onCut)
|
4397
|
+
el.addEventListener('keyup', self.onDel)
|
4398
|
+
}
|
4399
|
+
},
|
4400
|
+
|
4401
|
+
_set: function () {
|
4402
|
+
this.ownerVM.$set(
|
4403
|
+
this.key, this.multi
|
4404
|
+
? getMultipleSelectOptions(this.el)
|
4405
|
+
: this.el[this.attr]
|
4406
|
+
)
|
4407
|
+
},
|
4408
|
+
|
4409
|
+
update: function (value, init) {
|
4410
|
+
/* jshint eqeqeq: false */
|
4411
|
+
// sync back inline value if initial data is undefined
|
4412
|
+
if (init && value === undefined) {
|
4413
|
+
return this._set()
|
4414
|
+
}
|
4415
|
+
if (this.lock) return
|
4416
|
+
var el = this.el
|
4417
|
+
if (el.tagName === 'SELECT') { // select dropdown
|
4418
|
+
el.selectedIndex = -1
|
4419
|
+
if(this.multi && Array.isArray(value)) {
|
4420
|
+
value.forEach(this.updateSelect, this)
|
4421
|
+
} else {
|
4422
|
+
this.updateSelect(value)
|
4423
|
+
}
|
4424
|
+
} else if (el.type === 'radio') { // radio button
|
4425
|
+
el.checked = value == el.value
|
4426
|
+
} else if (el.type === 'checkbox') { // checkbox
|
4427
|
+
el.checked = !!value
|
4428
|
+
} else {
|
4429
|
+
el[this.attr] = utils.guard(value)
|
4430
|
+
}
|
4431
|
+
},
|
4432
|
+
|
4433
|
+
updateSelect: function (value) {
|
4434
|
+
/* jshint eqeqeq: false */
|
4435
|
+
// setting <select>'s value in IE9 doesn't work
|
4436
|
+
// we have to manually loop through the options
|
4437
|
+
var options = this.el.options,
|
4438
|
+
i = options.length
|
4439
|
+
while (i--) {
|
4440
|
+
if (options[i].value == value) {
|
4441
|
+
options[i].selected = true
|
4442
|
+
break
|
4443
|
+
}
|
4444
|
+
}
|
4445
|
+
},
|
4446
|
+
|
4447
|
+
unbind: function () {
|
4448
|
+
var el = this.el
|
4449
|
+
el.removeEventListener(this.event, this.set)
|
4450
|
+
el.removeEventListener('compositionstart', this.cLock)
|
4451
|
+
el.removeEventListener('compositionend', this.cUnlock)
|
4452
|
+
if (isIE9) {
|
4453
|
+
el.removeEventListener('cut', this.onCut)
|
4454
|
+
el.removeEventListener('keyup', this.onDel)
|
4455
|
+
}
|
4456
|
+
}
|
4457
|
+
}
|
4458
|
+
});
|
4459
|
+
require.register("vue/src/directives/with.js", function(exports, require, module){
|
4460
|
+
var utils = require('../utils')
|
4461
|
+
|
4462
|
+
/**
|
4463
|
+
* Binding for inheriting data from parent VMs.
|
4464
|
+
*/
|
4465
|
+
module.exports = {
|
4466
|
+
|
4467
|
+
bind: function () {
|
4468
|
+
|
4469
|
+
var self = this,
|
4470
|
+
childKey = self.arg,
|
4471
|
+
parentKey = self.key,
|
4472
|
+
compiler = self.compiler,
|
4473
|
+
owner = self.binding.compiler
|
4474
|
+
|
4475
|
+
if (compiler === owner) {
|
4476
|
+
this.alone = true
|
4477
|
+
return
|
4478
|
+
}
|
4479
|
+
|
4480
|
+
if (childKey) {
|
4481
|
+
if (!compiler.bindings[childKey]) {
|
4482
|
+
compiler.createBinding(childKey)
|
4483
|
+
}
|
4484
|
+
// sync changes on child back to parent
|
4485
|
+
compiler.observer.on('change:' + childKey, function (val) {
|
4486
|
+
if (compiler.init) return
|
4487
|
+
if (!self.lock) {
|
4488
|
+
self.lock = true
|
4489
|
+
utils.nextTick(function () {
|
4490
|
+
self.lock = false
|
4491
|
+
})
|
4492
|
+
}
|
4493
|
+
owner.vm.$set(parentKey, val)
|
4494
|
+
})
|
4495
|
+
}
|
4496
|
+
},
|
4497
|
+
|
4498
|
+
update: function (value) {
|
4499
|
+
// sync from parent
|
4500
|
+
if (!this.alone && !this.lock) {
|
4501
|
+
if (this.arg) {
|
4502
|
+
this.vm.$set(this.arg, value)
|
4503
|
+
} else if (this.vm.$data !== value) {
|
4504
|
+
this.vm.$data = value
|
4505
|
+
}
|
4506
|
+
}
|
4507
|
+
}
|
4508
|
+
|
4509
|
+
}
|
4510
|
+
});
|
4511
|
+
require.register("vue/src/directives/html.js", function(exports, require, module){
|
4512
|
+
var utils = require('../utils'),
|
4513
|
+
slice = [].slice
|
4514
|
+
|
4515
|
+
/**
|
4516
|
+
* Binding for innerHTML
|
4517
|
+
*/
|
4518
|
+
module.exports = {
|
4519
|
+
|
4520
|
+
bind: function () {
|
4521
|
+
// a comment node means this is a binding for
|
4522
|
+
// {{{ inline unescaped html }}}
|
4523
|
+
if (this.el.nodeType === 8) {
|
4524
|
+
// hold nodes
|
4525
|
+
this.nodes = []
|
4526
|
+
}
|
4527
|
+
},
|
4528
|
+
|
4529
|
+
update: function (value) {
|
4530
|
+
value = utils.guard(value)
|
4531
|
+
if (this.nodes) {
|
4532
|
+
this.swap(value)
|
4533
|
+
} else {
|
4534
|
+
this.el.innerHTML = value
|
4535
|
+
}
|
4536
|
+
},
|
4537
|
+
|
4538
|
+
swap: function (value) {
|
4539
|
+
var parent = this.el.parentNode,
|
4540
|
+
nodes = this.nodes,
|
4541
|
+
i = nodes.length
|
4542
|
+
// remove old nodes
|
4543
|
+
while (i--) {
|
4544
|
+
parent.removeChild(nodes[i])
|
4545
|
+
}
|
4546
|
+
// convert new value to a fragment
|
4547
|
+
var frag = utils.toFragment(value)
|
4548
|
+
// save a reference to these nodes so we can remove later
|
4549
|
+
this.nodes = slice.call(frag.childNodes)
|
4550
|
+
parent.insertBefore(frag, this.el)
|
4551
|
+
}
|
4552
|
+
}
|
4553
|
+
});
|
4554
|
+
require.register("vue/src/directives/style.js", function(exports, require, module){
|
4555
|
+
var prefixes = ['-webkit-', '-moz-', '-ms-']
|
4556
|
+
|
4557
|
+
/**
|
4558
|
+
* Binding for CSS styles
|
4559
|
+
*/
|
4560
|
+
module.exports = {
|
4561
|
+
|
4562
|
+
bind: function () {
|
4563
|
+
var prop = this.arg
|
4564
|
+
if (!prop) return
|
4565
|
+
if (prop.charAt(0) === '$') {
|
4566
|
+
// properties that start with $ will be auto-prefixed
|
4567
|
+
prop = prop.slice(1)
|
4568
|
+
this.prefixed = true
|
4569
|
+
}
|
4570
|
+
this.prop = prop
|
4571
|
+
},
|
4572
|
+
|
4573
|
+
update: function (value) {
|
4574
|
+
var prop = this.prop
|
4575
|
+
if (prop) {
|
4576
|
+
var isImportant = value.slice(-10) === '!important'
|
4577
|
+
? 'important'
|
4578
|
+
: ''
|
4579
|
+
if (isImportant) {
|
4580
|
+
value = value.slice(0, -10).trim()
|
4581
|
+
}
|
4582
|
+
this.el.style.setProperty(prop, value, isImportant)
|
4583
|
+
if (this.prefixed) {
|
4584
|
+
var i = prefixes.length
|
4585
|
+
while (i--) {
|
4586
|
+
this.el.style.setProperty(prefixes[i] + prop, value, isImportant)
|
4587
|
+
}
|
4588
|
+
}
|
4589
|
+
} else {
|
4590
|
+
this.el.style.cssText = value
|
4591
|
+
}
|
4592
|
+
}
|
4593
|
+
|
4594
|
+
}
|
4595
|
+
});
|
4596
|
+
require.register("vue/src/directives/partial.js", function(exports, require, module){
|
4597
|
+
var utils = require('../utils')
|
4598
|
+
|
4599
|
+
/**
|
4600
|
+
* Binding for partials
|
4601
|
+
*/
|
4602
|
+
module.exports = {
|
4603
|
+
|
4604
|
+
isLiteral: true,
|
4605
|
+
|
4606
|
+
bind: function () {
|
4607
|
+
|
4608
|
+
var id = this.expression
|
4609
|
+
if (!id) return
|
4610
|
+
|
4611
|
+
var el = this.el,
|
4612
|
+
compiler = this.compiler,
|
4613
|
+
partial = compiler.getOption('partials', id)
|
4614
|
+
|
4615
|
+
if (!partial) {
|
4616
|
+
if (id === 'yield') {
|
4617
|
+
utils.warn('{{>yield}} syntax has been deprecated. Use <content> tag instead.')
|
4618
|
+
}
|
4619
|
+
return
|
4620
|
+
}
|
4621
|
+
|
4622
|
+
partial = partial.cloneNode(true)
|
4623
|
+
|
4624
|
+
// comment ref node means inline partial
|
4625
|
+
if (el.nodeType === 8) {
|
4626
|
+
|
4627
|
+
// keep a ref for the partial's content nodes
|
4628
|
+
var nodes = [].slice.call(partial.childNodes),
|
4629
|
+
parent = el.parentNode
|
4630
|
+
parent.insertBefore(partial, el)
|
4631
|
+
parent.removeChild(el)
|
4632
|
+
// compile partial after appending, because its children's parentNode
|
4633
|
+
// will change from the fragment to the correct parentNode.
|
4634
|
+
// This could affect directives that need access to its element's parentNode.
|
4635
|
+
nodes.forEach(compiler.compile, compiler)
|
4636
|
+
|
4637
|
+
} else {
|
4638
|
+
|
4639
|
+
// just set innerHTML...
|
4640
|
+
el.innerHTML = ''
|
4641
|
+
el.appendChild(partial)
|
4642
|
+
|
4643
|
+
}
|
4644
|
+
}
|
4645
|
+
|
4646
|
+
}
|
4647
|
+
});
|
4648
|
+
require.register("vue/src/directives/view.js", function(exports, require, module){
|
4649
|
+
/**
|
4650
|
+
* Manages a conditional child VM using the
|
4651
|
+
* binding's value as the component ID.
|
4652
|
+
*/
|
4653
|
+
module.exports = {
|
4654
|
+
|
4655
|
+
bind: function () {
|
4656
|
+
|
4657
|
+
// track position in DOM with a ref node
|
4658
|
+
var el = this.raw = this.el,
|
4659
|
+
parent = el.parentNode,
|
4660
|
+
ref = this.ref = document.createComment('v-view')
|
4661
|
+
parent.insertBefore(ref, el)
|
4662
|
+
parent.removeChild(el)
|
4663
|
+
|
4664
|
+
// cache original content
|
4665
|
+
/* jshint boss: true */
|
4666
|
+
var node,
|
4667
|
+
frag = this.inner = document.createElement('div')
|
4668
|
+
while (node = el.firstChild) {
|
4669
|
+
frag.appendChild(node)
|
4670
|
+
}
|
4671
|
+
|
4672
|
+
},
|
4673
|
+
|
4674
|
+
update: function(value) {
|
4675
|
+
|
4676
|
+
this.unbind()
|
4677
|
+
|
4678
|
+
var Ctor = this.compiler.getOption('components', value)
|
4679
|
+
if (!Ctor) return
|
4680
|
+
|
4681
|
+
this.childVM = new Ctor({
|
4682
|
+
el: this.raw.cloneNode(true),
|
4683
|
+
parent: this.vm,
|
4684
|
+
compilerOptions: {
|
4685
|
+
rawContent: this.inner.cloneNode(true)
|
4686
|
+
}
|
4687
|
+
})
|
4688
|
+
|
4689
|
+
this.el = this.childVM.$el
|
4690
|
+
if (this.compiler.init) {
|
4691
|
+
this.ref.parentNode.insertBefore(this.el, this.ref)
|
4692
|
+
} else {
|
4693
|
+
this.childVM.$before(this.ref)
|
4694
|
+
}
|
4695
|
+
|
4696
|
+
},
|
4697
|
+
|
4698
|
+
unbind: function() {
|
4699
|
+
if (this.childVM) {
|
4700
|
+
this.childVM.$destroy()
|
4701
|
+
}
|
4702
|
+
}
|
4703
|
+
|
4704
|
+
}
|
4705
|
+
});
|
4706
|
+
require.alias("vue/src/main.js", "vue/index.js");
|
4707
|
+
if (typeof exports == 'object') {
|
4708
|
+
module.exports = require('vue');
|
4709
|
+
} else if (typeof define == 'function' && define.amd) {
|
4710
|
+
define(function(){ return require('vue'); });
|
4711
|
+
} else {
|
4712
|
+
window['Vue'] = require('vue');
|
4713
|
+
}})();
|