rmails 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +20 -0
- data/Gemfile +24 -0
- data/Gemfile.lock +167 -0
- data/LICENSE.txt +20 -0
- data/README.markdown +9 -0
- data/Rakefile +31 -0
- data/Rakefile1 +9 -0
- data/Vagrantfile +51 -0
- data/app/assets/images/arrow_bottom.gif +0 -0
- data/app/assets/images/arrow_right.gif +0 -0
- data/app/assets/images/at-sign.png +0 -0
- data/app/assets/images/checkerboard.gif +0 -0
- data/app/assets/images/glyphicons-halflings-white.png +0 -0
- data/app/assets/images/glyphicons-halflings.png +0 -0
- data/app/assets/images/icon_draft.gif +0 -0
- data/app/assets/images/icon_layout.gif +0 -0
- data/app/assets/images/icon_move.gif +0 -0
- data/app/assets/images/icon_regular.gif +0 -0
- data/app/assets/images/icon_snippet.gif +0 -0
- data/app/assets/images/nav_arrow.png +0 -0
- data/app/assets/images/x.png +0 -0
- data/app/assets/javascripts/application.coffee.erb +27 -0
- data/app/assets/javascripts/canjs/can.construct.proxy.js +60 -0
- data/app/assets/javascripts/canjs/can.construct.super.js +44 -0
- data/app/assets/javascripts/canjs/can.control.plugin.js +245 -0
- data/app/assets/javascripts/canjs/can.control.view.js +88 -0
- data/app/assets/javascripts/canjs/can.dojo.js +3669 -0
- data/app/assets/javascripts/canjs/can.dojo.min.js +66 -0
- data/app/assets/javascripts/canjs/can.fixture.js +1020 -0
- data/app/assets/javascripts/canjs/can.jquery.js +2995 -0
- data/app/assets/javascripts/canjs/can.jquery.min.js +52 -0
- data/app/assets/javascripts/canjs/can.mootools.js +3462 -0
- data/app/assets/javascripts/canjs/can.mootools.min.js +63 -0
- data/app/assets/javascripts/canjs/can.observe.attributes.js +293 -0
- data/app/assets/javascripts/canjs/can.observe.backup.js +368 -0
- data/app/assets/javascripts/canjs/can.observe.delegate.js +359 -0
- data/app/assets/javascripts/canjs/can.observe.setter.js +58 -0
- data/app/assets/javascripts/canjs/can.observe.validations.js +374 -0
- data/app/assets/javascripts/canjs/can.view.modifiers.js +292 -0
- data/app/assets/javascripts/canjs/can.yui.js +3530 -0
- data/app/assets/javascripts/canjs/can.yui.min.js +65 -0
- data/app/assets/javascripts/canjs/can.zepto.js +3426 -0
- data/app/assets/javascripts/canjs/can.zepto.min.js +62 -0
- data/app/assets/javascripts/controls/admins.coffee.erb +105 -0
- data/app/assets/javascripts/controls/aliases.coffee.erb +91 -0
- data/app/assets/javascripts/controls/domains.coffee.erb +115 -0
- data/app/assets/javascripts/controls/settings.coffee.erb +47 -0
- data/app/assets/javascripts/controls/users.coffee.erb +94 -0
- data/app/assets/javascripts/lib/facebox.js +311 -0
- data/app/assets/javascripts/lib/html5.js +2 -0
- data/app/assets/javascripts/lib/jquery.js +9301 -0
- data/app/assets/javascripts/lib/jquery_formparams.js +108 -0
- data/app/assets/javascripts/lib/jquery_input_hint.js +20 -0
- data/app/assets/javascripts/lib/jquery_paginate.js +120 -0
- data/app/assets/javascripts/lib/jquery_ui_custom.js +6 -0
- data/app/assets/javascripts/lib/json2.js +487 -0
- data/app/assets/javascripts/lib/utils.coffee.erb +48 -0
- data/app/assets/javascripts/models/admin.coffee.erb +42 -0
- data/app/assets/javascripts/models/alias.coffee.erb +28 -0
- data/app/assets/javascripts/models/domain.coffee.erb +39 -0
- data/app/assets/javascripts/models/property.coffee.erb +18 -0
- data/app/assets/javascripts/models/user.coffee.erb +29 -0
- data/app/assets/stylesheets/application.sass +156 -0
- data/app/assets/stylesheets/base.css.sass +243 -0
- data/app/assets/stylesheets/facebox.css +80 -0
- data/app/assets/stylesheets/lib/bootstrap.css +9 -0
- data/app/assets/stylesheets/twitter/bootstrap-responsive.scss +1 -0
- data/app/assets/stylesheets/twitter/bootstrap.scss +63 -0
- data/app/assets/stylesheets/twitter/bootstrap/_accordion.scss +34 -0
- data/app/assets/stylesheets/twitter/bootstrap/_alerts.scss +79 -0
- data/app/assets/stylesheets/twitter/bootstrap/_breadcrumbs.scss +24 -0
- data/app/assets/stylesheets/twitter/bootstrap/_button-groups.scss +229 -0
- data/app/assets/stylesheets/twitter/bootstrap/_buttons.scss +228 -0
- data/app/assets/stylesheets/twitter/bootstrap/_carousel.scss +158 -0
- data/app/assets/stylesheets/twitter/bootstrap/_close.scss +32 -0
- data/app/assets/stylesheets/twitter/bootstrap/_code.scss +61 -0
- data/app/assets/stylesheets/twitter/bootstrap/_component-animations.scss +22 -0
- data/app/assets/stylesheets/twitter/bootstrap/_dropdowns.scss +237 -0
- data/app/assets/stylesheets/twitter/bootstrap/_forms.scss +689 -0
- data/app/assets/stylesheets/twitter/bootstrap/_grid.scss +21 -0
- data/app/assets/stylesheets/twitter/bootstrap/_hero-unit.scss +25 -0
- data/app/assets/stylesheets/twitter/bootstrap/_labels-badges.scss +83 -0
- data/app/assets/stylesheets/twitter/bootstrap/_layouts.scss +16 -0
- data/app/assets/stylesheets/twitter/bootstrap/_media.scss +55 -0
- data/app/assets/stylesheets/twitter/bootstrap/_mixins.scss +690 -0
- data/app/assets/stylesheets/twitter/bootstrap/_modals.scss +95 -0
- data/app/assets/stylesheets/twitter/bootstrap/_navbar.scss +497 -0
- data/app/assets/stylesheets/twitter/bootstrap/_navs.scss +409 -0
- data/app/assets/stylesheets/twitter/bootstrap/_pager.scss +43 -0
- data/app/assets/stylesheets/twitter/bootstrap/_pagination.scss +123 -0
- data/app/assets/stylesheets/twitter/bootstrap/_popovers.scss +133 -0
- data/app/assets/stylesheets/twitter/bootstrap/_progress-bars.scss +122 -0
- data/app/assets/stylesheets/twitter/bootstrap/_reset.scss +216 -0
- data/app/assets/stylesheets/twitter/bootstrap/_responsive-1200px-min.scss +28 -0
- data/app/assets/stylesheets/twitter/bootstrap/_responsive-767px-max.scss +193 -0
- data/app/assets/stylesheets/twitter/bootstrap/_responsive-768px-979px.scss +19 -0
- data/app/assets/stylesheets/twitter/bootstrap/_responsive-navbar.scss +189 -0
- data/app/assets/stylesheets/twitter/bootstrap/_responsive-utilities.scss +74 -0
- data/app/assets/stylesheets/twitter/bootstrap/_scaffolding.scss +53 -0
- data/app/assets/stylesheets/twitter/bootstrap/_sprites.scss +197 -0
- data/app/assets/stylesheets/twitter/bootstrap/_tables.scss +235 -0
- data/app/assets/stylesheets/twitter/bootstrap/_thumbnails.scss +53 -0
- data/app/assets/stylesheets/twitter/bootstrap/_tooltip.scss +70 -0
- data/app/assets/stylesheets/twitter/bootstrap/_type.scss +247 -0
- data/app/assets/stylesheets/twitter/bootstrap/_utilities.scss +45 -0
- data/app/assets/stylesheets/twitter/bootstrap/_variables.scss +301 -0
- data/app/assets/stylesheets/twitter/bootstrap/_wells.scss +29 -0
- data/app/assets/stylesheets/twitter/bootstrap/responsive.scss +48 -0
- data/app/controllers/admin_users_controller.rb +62 -0
- data/app/controllers/aliases_controller.rb +35 -0
- data/app/controllers/application_controller.rb +20 -0
- data/app/controllers/domains_controller.rb +48 -0
- data/app/controllers/server_controller.rb +28 -0
- data/app/controllers/users_controller.rb +35 -0
- data/app/helpers/admin_users_helper.rb +11 -0
- data/app/helpers/application_helper.rb +2 -0
- data/app/helpers/domains_helper.rb +25 -0
- data/app/helpers/server_helper.rb +30 -0
- data/app/mailers/.gitkeep +0 -0
- data/app/models/.gitkeep +0 -0
- data/app/models/admin_user.rb +54 -0
- data/app/models/certificate_manager.rb +46 -0
- data/app/models/property.rb +103 -0
- data/app/models/property/awstats.rb +15 -0
- data/app/models/property/dovecot.rb +61 -0
- data/app/models/property/dspam.rb +45 -0
- data/app/models/property/nginx.rb +47 -0
- data/app/models/property/postfix.rb +64 -0
- data/app/models/property_value_validator.rb +41 -0
- data/app/models/system_manager.rb +88 -0
- data/app/models/virtual_alias.rb +13 -0
- data/app/models/virtual_domain.rb +15 -0
- data/app/models/virtual_user.rb +51 -0
- data/app/views/admin_users/_form.html.haml +21 -0
- data/app/views/admin_users/first.html.haml +12 -0
- data/app/views/admin_users/index.html.haml +61 -0
- data/app/views/aliases/_form.html.haml +11 -0
- data/app/views/aliases/_list.html.haml +0 -0
- data/app/views/devise/confirmations/new.html.haml +9 -0
- data/app/views/devise/mailer/confirmation_instructions.html.haml +4 -0
- data/app/views/devise/mailer/reset_password_instructions.html.haml +6 -0
- data/app/views/devise/mailer/unlock_instructions.html.haml +5 -0
- data/app/views/devise/passwords/edit.html.haml +14 -0
- data/app/views/devise/passwords/new.html.haml +12 -0
- data/app/views/devise/registrations/edit.html.haml +18 -0
- data/app/views/devise/registrations/new.html.haml +10 -0
- data/app/views/devise/sessions/new.html.haml +16 -0
- data/app/views/devise/shared/_links.haml +17 -0
- data/app/views/devise/unlocks/new.html.haml +11 -0
- data/app/views/domains/_fields.html.haml +0 -0
- data/app/views/domains/_form.html.haml +7 -0
- data/app/views/domains/index.html.haml +133 -0
- data/app/views/domains/show.html.haml +1 -0
- data/app/views/layouts/_nav.html.haml +3 -0
- data/app/views/layouts/application.html.haml +29 -0
- data/app/views/server/_certificates.html.haml +10 -0
- data/app/views/server/_dovecot.html.haml +27 -0
- data/app/views/server/_dspam.html.haml +9 -0
- data/app/views/server/_postfix_info.html.haml +5 -0
- data/app/views/server/_postfix_test.html.haml +5 -0
- data/app/views/server/_status.html.haml +11 -0
- data/app/views/server/index.html.haml +36 -0
- data/app/views/users/_form.html.haml +11 -0
- data/app/views/users/_list.html.haml +0 -0
- data/bin/rmails +43 -0
- data/config.ru +4 -0
- data/config/application.rb +62 -0
- data/config/boot.rb +6 -0
- data/config/environment.rb +5 -0
- data/config/environments/development.rb +37 -0
- data/config/environments/production.rb +67 -0
- data/config/environments/test.rb +37 -0
- data/config/initializers/backtrace_silencers.rb +7 -0
- data/config/initializers/devise.rb +240 -0
- data/config/initializers/devise_encryptable.rb +37 -0
- data/config/initializers/devise_models.rb +86 -0
- data/config/initializers/inflections.rb +15 -0
- data/config/initializers/mime_types.rb +5 -0
- data/config/initializers/secret_token.rb +7 -0
- data/config/initializers/session_store.rb +8 -0
- data/config/initializers/simple_form.rb +142 -0
- data/config/initializers/simple_form_bootstrap.rb +45 -0
- data/config/initializers/wrap_parameters.rb +14 -0
- data/config/locales/cz.yml +45 -0
- data/config/locales/devise.cz.yml +47 -0
- data/config/locales/devise.en.yml +60 -0
- data/config/locales/en.yml +5 -0
- data/config/locales/server/cz.yml +14 -0
- data/config/locales/server/en.yml +7 -0
- data/config/locales/server/help/dovecot/cz.yml +21 -0
- data/config/locales/server/help/dovecot/en.yml +18 -0
- data/config/locales/server/help/dspam/cz.yml +10 -0
- data/config/locales/server/help/dspam/en.yml +4 -0
- data/config/locales/server/key/dovecot/cz.yml +23 -0
- data/config/locales/server/key/dovecot/en.yml +20 -0
- data/config/locales/server/key/dspam/cz.yml +10 -0
- data/config/locales/server/key/dspam/en.yml +4 -0
- data/config/locales/simple_form.en.yml +26 -0
- data/config/locales/views/admin_users/cz.yml +25 -0
- data/config/locales/views/admin_users/en.yml +5 -0
- data/config/locales/views/aliases/cz.yml +17 -0
- data/config/locales/views/aliases/en.yml +1 -0
- data/config/locales/views/devise/cz.yml +26 -0
- data/config/locales/views/devise/en.yml +13 -0
- data/config/locales/views/domains/cz.yml +15 -0
- data/config/locales/views/domains/en.yml +15 -0
- data/config/locales/views/server/cz.yml +19 -0
- data/config/locales/views/server/en.yml +3 -0
- data/config/locales/views/users/cz.yml +18 -0
- data/config/locales/views/users/en.yml +1 -0
- data/config/routes.rb +80 -0
- data/db/migrate/20121112201233_virtual_domain.rb +11 -0
- data/db/migrate/20121112201247_virtual_alias.rb +10 -0
- data/db/migrate/20121112201341_virtual_user.rb +34 -0
- data/db/migrate/20121112201359_create_admin_user.rb +30 -0
- data/db/migrate/20121112201411_server_configuration.rb +13 -0
- data/db/migrate/20130304083938_join_domains_users.rb +12 -0
- data/db/migrate/20130311214040_create_versions.rb +18 -0
- data/db/seeds.rb +45 -0
- data/lib/devise-encryptable.rb +1 -0
- data/lib/rmails.rb +5 -0
- data/lib/rmails/installer.rb +37 -0
- data/lib/rmails/version.rb +3 -0
- data/lib/tasks/.gitkeep +0 -0
- data/lib/templates/haml/scaffold/_form.html.haml +10 -0
- data/locals +0 -0
- data/log/.gitkeep +0 -0
- data/public/404.html +26 -0
- data/public/422.html +26 -0
- data/public/500.html +25 -0
- data/public/favicon.ico +0 -0
- data/public/fonts/London.eot +0 -0
- data/public/fonts/London.otf +0 -0
- data/public/fonts/London.woff +0 -0
- data/public/fonts/LondonBold.otf +0 -0
- data/public/robots.txt +5 -0
- data/rmails.gemspec +35 -0
- data/script/prepflog.pl +576 -0
- data/script/rails +6 -0
- data/system/config/automateit_env.rb +16 -0
- data/system/config/fields.yml +48 -0
- data/system/config/tags.yml +39 -0
- data/system/dist/README_AutomateIt_dist.txt +20 -0
- data/system/dist/amavis/spamassassin.cf.erb +85 -0
- data/system/dist/amavis/user.erb +33 -0
- data/system/dist/awstats/awstats.mail.conf.erb +41 -0
- data/system/dist/awstats/prepflog.pl +576 -0
- data/system/dist/dovecot/dovecot-sql.conf.ext.erb +14 -0
- data/system/dist/dovecot/dovecot.conf.erb +297 -0
- data/system/dist/dovecot/old_dovecot.conf.erb +63 -0
- data/system/dist/dspam/conf.erb +96 -0
- data/system/dist/dspam/pgsql.conf +33 -0
- data/system/dist/nginx/awstats.erb +17 -0
- data/system/dist/nginx/rmails.erb +40 -0
- data/system/dist/postfix/email2email.cf.erb +5 -0
- data/system/dist/postfix/main.cf.erb +118 -0
- data/system/dist/postfix/master.cf.erb +74 -0
- data/system/dist/postfix/sasl.conf.erb +3 -0
- data/system/dist/postfix/sender_login_maps.cf.erb +5 -0
- data/system/dist/postfix/virtual_alias_maps.cf.erb +5 -0
- data/system/dist/postfix/virtual_mailbox_domains.cf.erb +5 -0
- data/system/dist/postfix/virtual_mailbox_maps.cf.erb +5 -0
- data/system/dist/postgresql/postgresql.conf.erb +54 -0
- data/system/dist/rmails/Gemfile.1 +8 -0
- data/system/dist/rmails/Gemfile.2 +24 -0
- data/system/dist/rmails/database.yml.erb +15 -0
- data/system/dist/sudoers +37 -0
- data/system/lib/README_AutomateIt_lib.txt +22 -0
- data/system/lib/dkim_key.rb +9 -0
- data/system/lib/smtpd_key.rb +39 -0
- data/system/lib/ssl.rb +23 -0
- data/system/recipes/01_prepare_server.rb +84 -0
- data/system/recipes/02_setup_database.rb +65 -0
- data/system/recipes/03_setup_postfix.rb +124 -0
- data/system/recipes/04_setup_dovecot.rb +78 -0
- data/system/recipes/05_setup_nginx.rb +29 -0
- data/system/recipes/06_setup_dspam.rb +24 -0
- data/system/recipes/07_setup_amavis.rb +16 -0
- data/system/recipes/08_setup_spamassassin.rb +22 -0
- data/system/recipes/09_setup_awstats.rb +49 -0
- data/system/recipes/XX_start_services.rb +5 -0
- data/test/fixtures/.gitkeep +0 -0
- data/test/functional/.gitkeep +0 -0
- data/test/functional/aliases_controller_test.rb +7 -0
- data/test/functional/domains_controller_test.rb +7 -0
- data/test/functional/users_controller_test.rb +7 -0
- data/test/integration/.gitkeep +0 -0
- data/test/performance/browsing_test.rb +12 -0
- data/test/test_helper.rb +13 -0
- data/test/unit/.gitkeep +0 -0
- data/test/unit/helpers/aliases_helper_test.rb +4 -0
- data/test/unit/helpers/domains_helper_test.rb +4 -0
- data/test/unit/helpers/users_helper_test.rb +4 -0
- data/vendor/assets/javascripts/.gitkeep +0 -0
- data/vendor/assets/javascripts/canjs/can.construct.proxy.js +60 -0
- data/vendor/assets/javascripts/canjs/can.construct.super.js +44 -0
- data/vendor/assets/javascripts/canjs/can.control.plugin.js +245 -0
- data/vendor/assets/javascripts/canjs/can.control.view.js +88 -0
- data/vendor/assets/javascripts/canjs/can.dojo.js +3669 -0
- data/vendor/assets/javascripts/canjs/can.dojo.min.js +66 -0
- data/vendor/assets/javascripts/canjs/can.fixture.js +1020 -0
- data/vendor/assets/javascripts/canjs/can.jquery.js +2995 -0
- data/vendor/assets/javascripts/canjs/can.jquery.min.js +52 -0
- data/vendor/assets/javascripts/canjs/can.mootools.js +3462 -0
- data/vendor/assets/javascripts/canjs/can.mootools.min.js +63 -0
- data/vendor/assets/javascripts/canjs/can.observe.attributes.js +293 -0
- data/vendor/assets/javascripts/canjs/can.observe.backup.js +368 -0
- data/vendor/assets/javascripts/canjs/can.observe.delegate.js +359 -0
- data/vendor/assets/javascripts/canjs/can.observe.setter.js +58 -0
- data/vendor/assets/javascripts/canjs/can.observe.validations.js +374 -0
- data/vendor/assets/javascripts/canjs/can.view.modifiers.js +292 -0
- data/vendor/assets/javascripts/canjs/can.yui.js +3530 -0
- data/vendor/assets/javascripts/canjs/can.yui.min.js +65 -0
- data/vendor/assets/javascripts/canjs/can.zepto.js +3426 -0
- data/vendor/assets/javascripts/canjs/can.zepto.min.js +62 -0
- data/vendor/assets/javascripts/twitter/bootstrap-affix.js +104 -0
- data/vendor/assets/javascripts/twitter/bootstrap-alert.js +90 -0
- data/vendor/assets/javascripts/twitter/bootstrap-button.js +96 -0
- data/vendor/assets/javascripts/twitter/bootstrap-carousel.js +176 -0
- data/vendor/assets/javascripts/twitter/bootstrap-collapse.js +158 -0
- data/vendor/assets/javascripts/twitter/bootstrap-dropdown.js +150 -0
- data/vendor/assets/javascripts/twitter/bootstrap-modal.js +239 -0
- data/vendor/assets/javascripts/twitter/bootstrap-popover.js +103 -0
- data/vendor/assets/javascripts/twitter/bootstrap-scrollspy.js +151 -0
- data/vendor/assets/javascripts/twitter/bootstrap-tab.js +135 -0
- data/vendor/assets/javascripts/twitter/bootstrap-tooltip.js +275 -0
- data/vendor/assets/javascripts/twitter/bootstrap-transition.js +60 -0
- data/vendor/assets/javascripts/twitter/bootstrap-typeahead.js +300 -0
- data/vendor/assets/javascripts/twitter/my/bootstrap-typeahead.js +311 -0
- data/vendor/assets/stylesheets/.gitkeep +0 -0
- metadata +470 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
(function(c,o,j){c.addEvent=function(a,b){this.__bindEvents||(this.__bindEvents={});var d=a.split(".")[0];this.__bindEvents[d]||(this.__bindEvents[d]=[]);this.__bindEvents[d].push({handler:b,name:a});return this};c.removeEvent=function(a,b){if(this.__bindEvents){for(var d=0,c=this.__bindEvents[a.split(".")[0]],e;d<c.length;)e=c[d],b&&e.handler===b||!b&&e.name===a?c.splice(d,1):d++;return this}};c.dispatch=function(a){if(this.__bindEvents){var b=(this.__bindEvents[a.type.split(".")[0]]||[]).slice(0),
|
|
2
|
+
d=this,f=[a].concat(a.data||[]);c.each(b,function(b){a.data=f.slice(1);b.handler.apply(d,f)})}};var t=document.createElement("table"),n=document.createElement("tr"),S={tr:document.createElement("tbody"),tbody:t,thead:t,tfoot:t,td:n,th:n,"*":document.createElement("div")},sa=/^\s*<(\w+)[^>]*>/,ta=function(a,b){b===j&&(b=sa.test(a)&&RegExp.$1);b in S||(b="*");var d=S[b];if("tr"===b){var c=document.createElement("div");c.innerHTML="<table><tbody>"+a+"</tbody></table>";d=c.firstChild.firstChild}else d.innerHTML=
|
|
3
|
+
""+a;c={};d=d.childNodes;c.length=d.length;for(var e=0;e<d.length;e++)c[e]=d[e];return[].slice.call(c)};c.buildFragment=function(a){var a=ta(a),b=document.createDocumentFragment();a.forEach(function(a){b.appendChild(a)});return b};c.each=function(a,b,d){var c=0,e;if(a)if("number"==typeof a.length&&a.pop){a.attr&&a.attr("length");for(e=a.length;c<e&&!1!==b.call(d||a[c],a[c],c,a);c++);}else for(e in a)if(!1===b.call(d||a[c],a[e],e,a))break;return a};c.trim=function(a){return a&&a.trim()};c.makeArray=
|
|
4
|
+
Array.from;c.isArray=function(a){return"array"===typeOf(a)};c.inArray=function(a,b){return b.indexOf(a)};c.map=function(a,b){return Array.from(a||[]).map(b)};c.extend=function(a){if(!0===a){var b=c.makeArray(arguments);b.shift();return Object.merge.apply(Object,b)}return Object.append.apply(Object,arguments)};c.param=function(a){return Object.toQueryString(a)};c.isEmptyObject=function(a){return 0===Object.keys(a).length};c.proxy=function(a){var b=c.makeArray(arguments),a=b.shift();return a.bind.apply(a,
|
|
5
|
+
b)};c.isFunction=function(a){return"function"==typeOf(a)};c.bind=function(a,b){this.bind&&this.bind!==c.bind?this.bind(a,b):this.addEvent?this.addEvent(a,b):c.addEvent.call(this,a,b);return this};c.unbind=function(a,b){this.unbind&&this.unbind!==c.unbind?this.unbind(a,b):this.removeEvent?this.removeEvent(a,b):c.removeEvent.call(this,a,b);return this};c.trigger=function(a,b,d,f){f=f===j?!0:f;d=d||[];if(a.fireEvent)for(a=a[0]||a;a;){b.type||(b={type:b,target:a});var e=a!==o?c.$(a).retrieve("events")[0]:
|
|
6
|
+
a.retrieve("events");e&&e[b.type]&&e[b.type].keys.each(function(a){a.apply(this,[b].concat(d))},this);a=f&&a.parentNode?a.parentNode:null}else"string"===typeof b&&(b={type:b}),b.target=b.target||a,b.data=d,c.dispatch.call(a,b)};c.delegate=function(a,b,d){this.delegate?this.delegate(a,b,d):this.addEvent&&this.addEvent(b+":relay("+a+")",d);return this};c.undelegate=function(a,b,d){this.undelegate?this.undelegate(a,b,d):this.removeEvent&&this.removeEvent(b+":relay("+a+")",d);return this};var T={type:"method",
|
|
7
|
+
success:j,error:j},H=function(a,b){for(var d in a)b[d]="function"==typeof b[d]?function(){a[d].apply(a,arguments)}:d[a]};c.ajax=function(a){var b=c.Deferred(),d=c.extend({},a),f;for(f in T)d[f]!==j&&(d[T[f]]=d[f],delete d[f]);d.method=d.method||"get";var e=a.success,g=a.error;d.onSuccess=function(d){"json"===a.dataType&&(d=eval("("+d+")"));H(h.xhr,b);b.resolve(d,"success",h.xhr);e&&e(d,"success",h.xhr)};d.onError=function(){H(h.xhr,b);b.reject(h.xhr,"error");g(h.xhr,"error")};var h=new Request(d);
|
|
8
|
+
h.send();H(h.xhr,b);return b};c.$=function(a){return a===o?o:$$(a)};var ua=document.id;document.id=function(a){return a&&11===a.nodeType?a:ua.apply(document,arguments)};c.append=function(a,b){"string"===typeof b&&(b=c.buildFragment(b));return a.grab(b)};c.filter=function(a,b){return a.filter(b)};c.data=function(a,b,d){return d===j?a[0].retrieve(b):a.store(b,d)};c.addClass=function(a,b){return a.addClass(b)};c.remove=function(a){a=a.filter(function(a){if(1!==a.nodeType)a.parentNode.removeChild(a);
|
|
9
|
+
else return!0});a.destroy();return a};var va=Element.prototype.destroy;Element.implement({destroy:function(){c.trigger(this,"destroyed",[],!1);for(var a=this.getElementsByTagName("*"),b=0,d;(d=a[b])!==j;b++)c.trigger(d,"destroyed",[],!1);va.apply(this,arguments)}});c.get=function(a,b){return a[b]};var wa=Slick.uidOf;Slick.uidOf=function(a){return 1===a.nodeType||a===o?wa(a):Math.random()};var w=function(a){if(!(this instanceof w))return new w;this._doneFuncs=[];this._failFuncs=[];this._resultArgs=
|
|
10
|
+
null;this._status="";a&&a.call(this,this)};c.Deferred=w;c.when=w.when=function(){var a=c.makeArray(arguments);if(2>a.length){var b=a[0];return b&&c.isFunction(b.isResolved)&&c.isFunction(b.isRejected)?b:w().resolve(b)}var d=w(),f=0,e=[];c.each(a,function(b,c){b.done(function(){e[c]=2>arguments.length?arguments[0]:arguments;++f==a.length&&d.resolve.apply(d,e)}).fail(function(){d.reject(arguments)})});return d};t=function(a,b){return function(d){var c=this._resultArgs=1<arguments.length?arguments[1]:
|
|
11
|
+
[];return this.exec(d,this[a],c,b)}};n=function(a,b){return function(){var d=this;c.each(Array.prototype.slice.call(arguments),function(c,e,g){c&&(c.constructor===Array?g.callee.apply(d,c):(d._status===b&&c.apply(d,d._resultArgs||[]),d[a].push(c)))});return this}};c.extend(w.prototype,{pipe:function(a,b){var d=c.Deferred();this.done(function(){d.resolve(a.apply(this,arguments))});this.fail(function(){b?d.reject(b.apply(this,arguments)):d.reject.apply(d,arguments)});return d},resolveWith:t("_doneFuncs",
|
|
12
|
+
"rs"),rejectWith:t("_failFuncs","rj"),done:n("_doneFuncs","rs"),fail:n("_failFuncs","rj"),always:function(){var a=c.makeArray(arguments);a.length&&a[0]&&this.done(a[0]).fail(a[0]);return this},then:function(){var a=c.makeArray(arguments);1<a.length&&a[1]&&this.fail(a[1]);a.length&&a[0]&&this.done(a[0]);return this},isResolved:function(){return"rs"===this._status},isRejected:function(){return"rj"===this._status},reject:function(){return this.rejectWith(this,arguments)},resolve:function(){return this.resolveWith(this,
|
|
13
|
+
arguments)},exec:function(a,b,d,f){if(""!==this._status)return this;this._status=f;c.each(b,function(b){b.apply(a,d)});return this}});var xa=/==/,ya=/([A-Z]+)([A-Z][a-z])/g,za=/([a-z\d])([A-Z])/g,Aa=/([a-z\d])([A-Z])/g,U=/\{([^\}]+)\}/g,s=/"/g,Ba=/'/g;c.extend(c,{esc:function(a){return(""+a).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(s,""").replace(Ba,"'")},getObject:function(a,b,d){var a=a?a.split("."):[],f=a.length,e,g=0,h,i,b=c.isArray(b)?b:[b||o];if(!f)return b[0];
|
|
14
|
+
for(;e=b[g++];){for(i=0;i<f-1&&/^f|^o/.test(typeof e);i++)e=a[i]in e?e[a[i]]:d&&(e[a[i]]={});if(/^f|^o/.test(typeof e)&&(h=a[i]in e?e[a[i]]:d&&(e[a[i]]={}),h!==j))return!1===d&&delete e[a[i]],h}},capitalize:function(a){return a.charAt(0).toUpperCase()+a.slice(1)},underscore:function(a){return a.replace(xa,"/").replace(ya,"$1_$2").replace(za,"$1_$2").replace(Aa,"_").toLowerCase()},sub:function(a,b,d){var f=[];f.push(a.replace(U,function(a,g){var h=c.getObject(g,b,d===j?d:!d);return/^f|^o/.test(typeof h)?
|
|
15
|
+
(f.push(h),""):""+h}));return 1>=f.length?f[0]:f},replacer:U,undHash:/_|-/});var I=0;c.Construct=function(){if(arguments.length)return c.Construct.extend.apply(c.Construct,arguments)};c.extend(c.Construct,{newInstance:function(){var a=this.instance(),b;a.setup&&(b=a.setup.apply(a,arguments));a.init&&a.init.apply(a,b||arguments);return a},_inherit:function(a,b,d){c.extend(d||a,a||{})},_overwrite:function(a,b,d,c){a[d]=c},setup:function(a){this.defaults=c.extend(!0,{},a.defaults,this.defaults)},instance:function(){I=
|
|
16
|
+
1;var a=new this;I=0;return a},extend:function(a,b,d){function f(){if(!I)return this.constructor!==f&&arguments.length?arguments.callee.extend.apply(arguments.callee,arguments):this.constructor.newInstance.apply(this.constructor,arguments)}"string"!=typeof a&&(d=b,b=a,a=null);d||(d=b,b=null);var d=d||{},e=this.prototype,g,h,i,k;k=this.instance();c.Construct._inherit(d,e,k);for(g in this)this.hasOwnProperty(g)&&(f[g]=this[g]);c.Construct._inherit(b,this,f);if(a){i=a.split(".");h=i.pop();i=e=c.getObject(i.join("."),
|
|
17
|
+
o,!0);var p=c.underscore(a.replace(/\./g,"_")),C=c.underscore(h);e[h]=f}c.extend(f,{constructor:f,prototype:k,namespace:i,shortName:h,_shortName:C,fullName:a,_fullName:p});f.prototype.constructor=f;h=[this].concat(c.makeArray(arguments));k=f.setup.apply(f,h);f.init&&f.init.apply(f,k||h);return f}});var u=function(a){return a&&"object"===typeof a&&!(a instanceof Date)},J=function(a,b){return c.each(a,function(a){a&&a.unbind&&a.unbind("change"+b)})},K=function(a,b,d){a instanceof x?J([a],d._namespace):
|
|
18
|
+
a=c.isArray(a)?new x.List(a):new x(a);a.bind("change"+d._namespace,function(f,e){var g=c.makeArray(arguments),f=g.shift();g[0]="*"===b?d.indexOf(a)+"."+g[0]:b+"."+g[0];f.triggeredNS=f.triggeredNS||{};f.triggeredNS[d._namespace]||(f.triggeredNS[d._namespace]=!0,c.trigger(d,f,g),c.trigger(d,g[0],g))});return a},V=0,y=j,W=function(){if(!y)return y=[],!0},m=function(a,b,d){if(!a._init)if(y)y.push([a,{type:b,batchNum:X},d]);else return c.trigger(a,b,d)},X=1,Y=function(){var a=y.slice(0);y=j;X++;c.each(a,
|
|
19
|
+
function(a){c.trigger.apply(c,a)})},E=function(a,b,d){a.each(function(a,e){d[e]=u(a)&&c.isFunction(a[b])?a[b]():a});return d},n=function(a){return function(){return c[a].apply(this,arguments)}},t=n("addEvent"),n=n("removeEvent"),L=function(a){return c.isArray(a)?a:(""+a).split(".")},x=c.Construct("can.Observe",{setup:function(){c.Construct.setup.apply(this,arguments)},bind:t,unbind:n,id:"id"},{setup:function(a){this._data={};this._namespace=".observe"+ ++V;this._init=1;this.attr(a);delete this._init},
|
|
20
|
+
attr:function(a,b){if(~"ns".indexOf((typeof a).charAt(0))){if(b===j)return x.__reading&&x.__reading(this,a),this._get(a);this._set(a,b);return this}return this._attrs(a,b)},each:function(){return c.each.apply(j,[this.__get()].concat(c.makeArray(arguments)))},removeAttr:function(a){var a=L(a),b=a.shift(),c=this._data[b];if(a.length)return c.removeAttr(a);delete this._data[b];b in this.constructor.prototype||delete this[b];m(this,"change",[b,"remove",j,c]);m(this,b,[j,c]);return c},_get:function(a){var a=
|
|
21
|
+
L(a),b=this.__get(a.shift());return a.length?b?b._get(a):j:b},__get:function(a){return a?this._data[a]:this._data},_set:function(a,b){var c=L(a),f=c.shift(),e=this.__get(f);if(u(e)&&c.length)e._set(c,b);else{if(c.length)throw"can.Observe: Object does not exist";this.__convert&&(b=this.__convert(f,b));this.__set(f,b,e)}},__set:function(a,b,c){if(b!==c){var f=this.__get().hasOwnProperty(a)?"set":"add";this.___set(a,u(b)?K(b,a,this):b);m(this,"change",[a,f,b,c]);m(this,a,[b,c]);c&&J([c],this._namespace)}},
|
|
22
|
+
___set:function(a,b){this._data[a]=b;a in this.constructor.prototype||(this[a]=b)},bind:t,unbind:n,serialize:function(){return E(this,"serialize",{})},_attrs:function(a,b){if(a===j)return E(this,"attr",{});var a=c.extend(!0,{},a),d,f=W(),e=this,g;this.each(function(c,d){g=a[d];g===j?b&&e.removeAttr(d):(u(c)&&u(g)?c.attr(g,b):c!=g&&e._set(d,g),delete a[d])});for(d in a)g=a[d],this._set(d,g);f&&Y();return this}}),Ca=[].splice,M=x("can.Observe.List",{setup:function(a,b){this.length=0;this._namespace=
|
|
23
|
+
".observe"+ ++V;this._init=1;this.bind("change",c.proxy(this._changes,this));this.push.apply(this,c.makeArray(a||[]));c.extend(this,b);delete this._init},_changes:function(a,b,c,f,e){~b.indexOf(".")||("add"===c?(m(this,c,[f,+b]),m(this,"length",[this.length])):"remove"===c?(m(this,c,[e,+b]),m(this,"length",[this.length])):m(this,c,[f,+b]))},__get:function(a){return a?this[a]:this},___set:function(a,b){this[a]=b;+a>=this.length&&(this.length=+a+1)},serialize:function(){return E(this,"serialize",[])},
|
|
24
|
+
splice:function(a,b){var d=c.makeArray(arguments),f;for(f=2;f<d.length;f++){var e=d[f];u(e)&&(d[f]=K(e,"*",this))}b===j&&(b=d[1]=this.length-a);f=Ca.apply(this,d);0<b&&(m(this,"change",[""+a,"remove",j,f]),J(f,this._namespace));2<d.length&&m(this,"change",[""+a,"add",d.slice(2),f]);return f},_attrs:function(a,b){if(a===j)return E(this,"attr",[]);var a=a.slice(0),c=Math.min(a.length,this.length),f=W(),e;for(e=0;e<c;e++){var g=this[e],h=a[e];u(g)&&u(h)?g.attr(h,b):g!=h&&this._set(e,h)}a.length>this.length?
|
|
25
|
+
this.push(a.slice(this.length)):a.length<this.length&&b&&this.splice(a.length);f&&Y()}});c.each({push:"length",unshift:0},function(a,b){M.prototype[b]=function(){for(var d=arguments[0]&&c.isArray(arguments[0])?arguments[0]:c.makeArray(arguments),f=a?this.length:0,e=0;e<d.length;e++){var g=d[e];u(g)&&(d[e]=K(g,"*",this))}e=[][b].apply(this,d);(!this.comparator||!d.length)&&m(this,"change",[""+f,"add",d,j]);return e}});c.each({pop:"length",shift:0},function(a,b){M.prototype[b]=function(){var d=arguments[0]&&
|
|
26
|
+
c.isArray(arguments[0])?arguments[0]:c.makeArray(arguments),f=a&&this.length?this.length-1:0,d=[][b].apply(this,d);m(this,"change",[""+f,"remove",j,[d]]);d&&d.unbind&&d.unbind("change"+this._namespace);return d}});M.prototype.indexOf=[].indexOf||function(a){return c.inArray(a,this)};var Da=function(a,b,d){var f=new c.Deferred;a.then(function(){arguments[0]=b[d](arguments[0]);f.resolve.apply(f,arguments)},function(){f.rejectWith.apply(this,arguments)});return f},Ea=0,Z=/change.observe\d+/,$=function(a,
|
|
27
|
+
b,c,f,e){var g;g=[a.serialize()];var h=a.constructor,i;"destroy"==b&&g.shift();"create"!==b&&g.unshift(a[a.constructor.id]);i=h[b].apply(h,g);g=i.pipe(function(c){a[e||b+"d"](c,i);return a});i.abort&&(g.abort=function(){i.abort()});return g.then(c,f)},Fa={create:{url:"_shortName",type:"post"},update:{data:function(a,b){var b=b||{},d=this.id;b[d]&&b[d]!==a&&(b["new"+c.capitalize(a)]=b[d],delete b[d]);b[d]=a;return b},type:"put"},destroy:{type:"delete",data:function(a){var b={};b[this.id]=a;return b}},
|
|
28
|
+
findAll:{url:"_shortName"},findOne:{}},aa=function(a,b){return function(d){var d=a.data?a.data.apply(this,arguments):d,f=b||this[a.url||"_url"],e=d,g=a.type||"get";if("string"==typeof f){var h=f.split(" "),f={url:h.pop()};h.length&&(f.type=h.pop())}f.data="object"==typeof e&&!c.isArray(e)?c.extend(f.data||{},e):e;f.url=c.sub(f.url,f.data,!0);return c.ajax(c.extend({type:g||"post",dataType:"json",success:void 0,error:void 0},f))}};c.Observe("can.Model",{setup:function(a){c.Observe.apply(this,arguments);
|
|
29
|
+
if(this!==c.Model){var b=this,d=c.proxy(this._clean,b);c.each(Fa,function(f,e){c.isFunction(b[e])||(b[e]=aa(f,b[e]));if(b["make"+c.capitalize(e)]){var g=b["make"+c.capitalize(e)](b[e]);c.Construct._overwrite(b,a,e,function(){this._super;this._reqs++;return g.apply(this,arguments).then(d,d)})}});if(!b.fullName||b.fullName==a.fullName)b.fullName=b._shortName="Model"+ ++Ea;this.store={};this._reqs=0;this._url=this._shortName+"/{"+this.id+"}"}},_ajax:aa,_clean:function(){this._reqs--;if(!this._reqs)for(var a in this.store)this.store[a]._bindings||
|
|
30
|
+
delete this.store[a]},models:function(a){if(a){if(a instanceof this.List)return a;var b=this,d=new (b.List||ba),f=c.isArray(a),e=a instanceof ba,e=f?a:e?a.serialize():a.data;c.each(e,function(a){d.push(b.model(a))});f||c.each(a,function(a,b){"data"!==b&&(d[b]=a)});return d}},model:function(a){if(a){a instanceof this&&(a=a.serialize());var b=this.store[a[this.id]]?this.store[a[this.id]].attr(a):new this(a);this._reqs&&(this.store[a[this.id]]=b);return b}}},{isNew:function(){var a=this[this.constructor.id];
|
|
31
|
+
return!(a||0===a)},save:function(a,b){return $(this,this.isNew()?"create":"update",a,b)},destroy:function(a,b){return $(this,"destroy",a,b,"destroyed")},bind:function(a){Z.test(a)||(this._bindings||(this.constructor.store[this[this.constructor.id]]=this,this._bindings=0),this._bindings++);return c.Observe.prototype.bind.apply(this,arguments)},unbind:function(a){Z.test(a)||(this._bindings--,this._bindings||delete this.constructor.store[this[this.constructor.id]]);return c.Observe.prototype.unbind.apply(this,
|
|
32
|
+
arguments)},___set:function(a,b){c.Observe.prototype.___set.call(this,a,b);a===this.constructor.id&&this._bindings&&(this.constructor.store[this[this.constructor.id]]=this)}});c.each({makeFindAll:"models",makeFindOne:"model"},function(a,b){c.Model[b]=function(b){return function(c,e,g){return Da(b.call(this,c),this,a).then(e,g)}}});c.each(["created","updated","destroyed"],function(a){c.Model.prototype[a]=function(b){var d=this.constructor;b&&"object"==typeof b&&this.attr(b.attr?b.attr():b);c.trigger(this,
|
|
33
|
+
a);c.trigger(this,"change",a);c.trigger(d,a,this)}});var ba=c.Observe.List("can.Model.List",{setup:function(){c.Observe.List.prototype.setup.apply(this,arguments);var a=this;this.bind("change",function(b,c){/\w+\.destroyed/.test(c)&&a.splice(a.indexOf(b.target),1)})}}),Ga=/^\d+$/,Ha=/([^\[\]]+)|(\[\])/g,Ia=/([^?#]*)(#.*)?$/,ca=function(a){return decodeURIComponent(a.replace(/\+/g," "))};c.extend(c,{deparam:function(a){var b={},d;a&&Ia.test(a)&&(a=a.split("&"),c.each(a,function(a){var a=a.split("="),
|
|
34
|
+
c=ca(a.shift()),g=ca(a.join("="));current=b;for(var a=c.match(Ha),c=0,h=a.length-1;c<h;c++)current[a[c]]||(current[a[c]]=Ga.test(a[c+1])||"[]"==a[c+1]?[]:{}),current=current[a[c]];d=a.pop();"[]"==d?current.push(g):current[d]=g}));return b}});var da=/\:([\w\.]+)/g,ea=/^(?:&[^=]+=[^&]*)+/,Ja=function(a){var b=[];c.each(a,function(a,f){b.push(("className"===f?"class":f)+'="'+("href"===f?a:c.esc(a))+'"')});return b.join(" ")},fa=function(a,b){var c=0,f=0,e={},g;for(g in a.defaults)a.defaults[g]===b[g]&&
|
|
35
|
+
(e[g]=1,c++);for(;f<a.names.length;f++){if(!b.hasOwnProperty(a.names[f]))return-1;e[a.names[f]]||c++}return c},ga=!0,N=o.location,z=c.each,v=c.extend;c.route=function(a,b){var b=b||{},d=[],f=a.replace(da,function(c,f,h){d.push(f);return"([^\\"+(a.substr(h+c.length,1)||"&")+"]"+(b[f]?"*":"+")+")"});c.route.routes[a]={test:RegExp("^"+f+"($|&)"),route:a,names:d,defaults:b,length:a.split("/").length};return c.route};v(c.route,{param:function(a,b){var d,f=0,e,g=a.route,h=0;delete a.route;z(a,function(){h++});
|
|
36
|
+
z(c.route.routes,function(b){e=fa(b,a);e>f&&(d=b,f=e);if(e>=h)return!1});c.route.routes[g]&&fa(c.route.routes[g],a)===f&&(d=c.route.routes[g]);if(d){var i=v({},a),g=d.route.replace(da,function(b,c){delete i[c];return a[c]===d.defaults[c]?"":encodeURIComponent(a[c])}),k;z(d.defaults,function(a,b){i[b]===a&&delete i[b]});k=c.param(i);b&&c.route.attr("route",d.route);return g+(k?"&"+k:"")}return c.isEmptyObject(a)?"":"&"+c.param(a)},deparam:function(a){var b={length:-1};z(c.route.routes,function(c){c.test.test(a)&&
|
|
37
|
+
c.length>b.length&&(b=c)});if(-1<b.length){var d=a.match(b.test),f=d.shift(),e=(f=a.substr(f.length-("&"===d[d.length-1]?1:0)))&&ea.test(f)?c.deparam(f.slice(1)):{},e=v(!0,{},b.defaults,e);z(d,function(a,c){a&&"&"!==a&&(e[b.names[c]]=decodeURIComponent(a))});e.route=b.route;return e}"&"!==a.charAt(0)&&(a="&"+a);return ea.test(a)?c.deparam(a.slice(1)):{}},data:new c.Observe({}),routes:{},ready:function(a){!1===a&&(ga=a);(!0===a||!0===ga)&&ha();return c.route},url:function(a,b){b&&(a=v({},O,a));return"#!"+
|
|
38
|
+
c.route.param(a)},link:function(a,b,d,f){return"<a "+Ja(v({href:c.route.url(b,f)},d))+">"+a+"</a>"},current:function(a){return N.hash=="#!"+c.route.param(a)}});z("bind unbind delegate undelegate attr removeAttr".split(" "),function(a){c.route[a]=function(){return c.route.data[a].apply(c.route.data,arguments)}});var ia,O,ha=function(){var a=N.href.split(/#!?/)[1]||"";O=c.route.deparam(a);(!P||a!==ja)&&c.route.attr(O,!0)},ja,P;c.bind.call(o,"hashchange",ha);c.route.bind("change",function(){P=1;clearTimeout(ia);
|
|
39
|
+
ia=setTimeout(function(){P=0;var a=c.route.data.serialize();N.hash="#!"+(ja=c.route.param(a,!0))},1)});c.bind.call(document,"ready",c.route.ready);(function(){var a=function(a,b,d){c.bind.call(a,b,d);return function(){c.unbind.call(a,b,d)}},b=c.isFunction,d=c.extend,f=c.each,e=[].slice,g=/\{([^\}]+)\}/g,h=c.getObject("$.event.special")||{},i=function(a,b,d,f){c.delegate.call(a,b,d,f);return function(){c.undelegate.call(a,b,d,f)}},k=function(a,d){var f="string"==typeof d?a[d]:d;b(f)||(f=a[f]);return function(){a.called=
|
|
40
|
+
d;return f.apply(a,[this.nodeName?c.$(this):this].concat(e.call(arguments,0)))}},p;c.Construct("can.Control",{setup:function(){c.Construct.setup.apply(this,arguments);if(this!==c.Control){var a;this.actions={};for(a in this.prototype)this._isAction(a)&&(this.actions[a]=this._action(a))}},_isAction:function(a){var c=this.prototype[a],d=typeof c;return"constructor"!==a&&("function"==d||"string"==d&&b(this.prototype[c]))&&!(!h[a]&&!C[a]&&!/[^\w]/.test(a))},_action:function(a,b){g.lastIndex=0;if(b||!g.test(a)){var d=
|
|
41
|
+
b?c.sub(a,[b,o]):a,f=c.isArray(d),e=(f?d[1]:d).match(/^(?:(.*?)\s)?([\w\.\:>]+)$/);return{processor:C[e[2]]||p,parts:e,delegate:f?d[0]:j}}},processors:{},defaults:{}},{setup:function(a,b){var f=this.constructor,e=f.pluginName||f._fullName;this.element=c.$(a);e&&"can_control"!==e&&this.element.addClass(e);(e=c.data(this.element,"controls"))||c.data(this.element,"controls",e=[]);e.push(this);this.options=d({},f.defaults,b);this.on();return[this.element,this.options]},on:function(b,d,f,e){if(!b){this.off();
|
|
42
|
+
var b=this.constructor,d=this._bindings,f=b.actions,e=this.element,g=k(this,"destroy"),h,p;for(h in f)f.hasOwnProperty(h)&&(p=f[h]||b._action(h,this.options),d.push(p.processor(p.delegate||e,p.parts[2],p.parts[1],h,this)));c.bind.call(e,"destroyed",g);d.push(function(a){c.unbind.call(a,"destroyed",g)});return d.length}"string"==typeof b&&(e=f,f=d,d=b,b=this.element);"string"==typeof e&&(e=k(this,e));this._bindings.push(d?i(b,c.trim(d),f,e):a(b,f,e));return this._bindings.length},off:function(){var a=
|
|
43
|
+
this.element[0];f(this._bindings||[],function(b){b(a)});this._bindings=[]},destroy:function(){var a=this.constructor,a=a.pluginName||a._fullName;this.off();a&&"can_control"!==a&&this.element.removeClass(a);a=c.data(this.element,"controls");a.splice(c.inArray(this,a),1);c.trigger(this,"destroyed");this.element=null}});var C=c.Control.processors;p=function(b,d,f,e,g){e=k(g,e);return f?i(b,c.trim(f),d,e):a(b,d,e)};f("change click contextmenu dblclick keydown keyup keypress mousedown mousemove mouseout mouseover mouseup reset resize scroll select submit focusin focusout mouseenter mouseleave".split(" "),
|
|
44
|
+
function(a){C[a]=p})})();c.Control.processors.route=function(a,b,d,f,e){c.route(d||"");var g,h=function(a){if(c.route.attr("route")===(d||"")&&(a.batchNum===j||a.batchNum!==g))if(g=a.batchNum,a=c.route.attr(),delete a.route,c.isFunction(e[f]))e[f](a);else e[e[f]](a)};c.route.bind("change",h);return function(){c.route.unbind("change",h)}};var F=c.isFunction,Ka=c.makeArray,ka=1,l=c.view=function(a,b,d,f){a=l.render(a,b,d,f);return c.isDeferred(a)?a.pipe(function(a){return l.frag(a)}):l.frag(a)};c.extend(l,
|
|
45
|
+
{frag:function(a,b){return l.hookup(l.fragment(a),b)},fragment:function(a){a=c.buildFragment(a,document.body);a.childNodes.length||a.appendChild(document.createTextNode(""));return a},toId:function(a){return c.map(a.toString().split(/\/|\./g),function(a){if(a)return a}).join("_")},hookup:function(a,b){var d=[],f,e,g,h=0;for(c.each(a.childNodes?c.makeArray(a.childNodes):a,function(a){1===a.nodeType&&(d.push(a),d.push.apply(d,c.makeArray(a.getElementsByTagName("*"))))});g=d[h++];)if(g.getAttribute&&
|
|
46
|
+
(f=g.getAttribute("data-view-id"))&&(e=l.hookups[f]))e(g,b,f),delete l.hookups[f],g.removeAttribute("data-view-id");return a},hookups:{},hook:function(a){l.hookups[++ka]=a;return" data-view-id='"+ka+"'"},cached:{},cache:!0,register:function(a){this.types["."+a.suffix]=a},types:{},ext:".ejs",registerScript:function(){},preload:function(){},render:function(a,b,d,f){F(d)&&(f=d,d=j);var e=La(b);if(e.length){var g=new c.Deferred;e.push(la(a,!0));c.when.apply(c,e).then(function(a){var e=Ka(arguments),h=
|
|
47
|
+
e.pop();if(c.isDeferred(b))b=ma(a);else for(var j in b)c.isDeferred(b[j])&&(b[j]=ma(e.shift()));e=h(b,d);g.resolve(e);f&&f(e)});return g}var h,e=F(f),g=la(a,e);e?(h=g,g.then(function(a){f(a(b,d))})):g.then(function(a){h=a(b,d)});return h}});c.isDeferred=function(a){return a&&F(a.then)&&F(a.pipe)};var na=function(a,b){if(!a.length)throw"can.view: No template or empty template:"+b;},la=function(a,b){var d=a.match(/\.[\w\d]+$/),f,e,g,h=function(a){var a=f.renderer(g,a),b=new c.Deferred;b.resolve(a);
|
|
48
|
+
l.cache&&(l.cached[g]=b);return b};a.match(/^#/)&&(a=a.substr(1));if(e=document.getElementById(a))d="."+e.type.match(/\/(x\-)?(.+)/)[2];!d&&!l.cached[a]&&(a+=d=l.ext);c.isArray(d)&&(d=d[0]);g=c.view.toId(a);if(a.match(/^\/\//))var i=a.substr(2),a=!o.steal?"/"+i:steal.root.mapJoin(i);f=l.types[d];if(l.cached[g])return l.cached[g];if(e)return h(e.innerHTML);var k=new c.Deferred;c.ajax({async:b,url:a,dataType:"text",error:function(b){na("",a);k.reject(b)},success:function(b){na(b,a);k.resolve(f.renderer(g,
|
|
49
|
+
b));l.cache&&(l.cached[g]=k)}});return k},La=function(a){var b=[];if(c.isDeferred(a))return[a];for(var d in a)c.isDeferred(a[d])&&b.push(a[d]);return b},ma=function(a){return c.isArray(a)&&"success"===a[1]?a[0]:a};o.steal&&steal.type("view js",function(a,b){var d=c.view.types["."+a.type],f=c.view.toId(a.rootSrc);a.text="steal('"+(d.plugin||"can/view/"+a.type)+"').then(function($){can.view.preload('"+f+"',"+a.text+");\n})";b()});c.extend(c.view,{register:function(a){this.types["."+a.suffix]=a;o.steal&&
|
|
50
|
+
steal.type(a.suffix+" view js",function(a,d){var f=c.view.types["."+a.type],e=c.view.toId(a.rootSrc+"");a.text=f.script(e,a.text);d()});c.view[a.suffix]=function(b,c){l.preload(b,a.renderer(b,c))}},registerScript:function(a,b,c){return"can.view.preload('"+b+"',"+l.types["."+a].script(b,c)+");"},preload:function(a,b){c.view.cached[a]=(new c.Deferred).resolve(function(a,c){return b.call(a,a,c)})}});var Ma=function(a,b){var d;c.Observe&&(d=c.Observe.__reading,c.Observe.__reading=function(a,b){f.push({obj:a,
|
|
51
|
+
attr:b})});var f=[],e=a.call(b);c.Observe&&(c.Observe.__reading=d);return{value:e,observed:f}},oa=function(a,b,d){var f={},e=!0,g={value:j,teardown:function(){for(var a in f){var b=f[a];b.observe.obj.unbind(b.observe.attr,h);delete f[a]}}},h=function(){var a=g.value,b=i();g.value=b;b!==a&&d(b,a)},i=function(){var d=Ma(a,b),g=d.observed,d=d.value;e=!e;c.each(g,function(a){f[a.obj._namespace+"|"+a.attr]?f[a.obj._namespace+"|"+a.attr].matched=e:(f[a.obj._namespace+"|"+a.attr]={matched:e,observe:a},a.obj.bind(a.attr,
|
|
52
|
+
h))});for(var i in f)g=f[i],g.matched!==e&&(g.observe.obj.unbind(g.observe.attr,h),delete f[i]);return d};g.value=i();g.isListening=!c.isEmptyObject(f);return g};c.compute=function(a,b){if(a.isComputed)return a;var d,f=0,e,g=!0;"function"===typeof a?e=function(c){return c===j?d?d.value:a.call(b||this):a.apply(b||this,arguments)}:(e=function(b){if(b===j)return a;var d=a;a=b;d!==b&&c.trigger(e,"change",[b,d]);return b},g=!1);e.isComputed=!0;e.bind=function(h,i){c.addEvent.apply(e,arguments);f===0&&
|
|
53
|
+
g&&(d=oa(a,b||this,function(a,b){c.trigger(e,"change",[a,b])}));f++};e.unbind=function(a,b){c.removeEvent.apply(e,arguments);f--;f===0&&g&&d.teardown()};return e};c.compute.binder=oa;var Na=function(a){eval(a)},v=c.extend,pa=/\s*\(([\$\w]+)\)\s*->([^\n]*)/,qa=/([^\s]+)=$/,Oa=/(\r|\n)+/g,Pa=/__!!__/g,Qa={"":"span",table:"tr",tr:"td",ol:"li",ul:"li",tbody:"tr",thead:"tr",tfoot:"tr"},D={"class":"className"},ra=c.each(["checked","disabled","readonly","required"],function(a){D[a]=a}),Q=function(a,b,d){D[b]?
|
|
54
|
+
a[D[b]]=-1<c.inArray(b,ra)?!0:d:a.setAttribute(b,d)},Ra=function(a){return"string"==typeof a||"number"==typeof a?c.esc(a):R(a)},R=function(a){if("string"==typeof a)return a;if(!a&&0!=a)return"";var b=a.hookup&&function(b,c){a.hookup.call(a,b,c)}||"function"==typeof a&&a;return b?(A.push(b),""):""+a},q=function(a){if(this.constructor!=q){var b=new q(a);return function(a,c){return b.render(a,c)}}"function"==typeof a?this.template={fn:a}:(v(this,a),this.template=Sa(this.text,this.name))};c.EJS=q;q.prototype.render=
|
|
55
|
+
function(a,b){a=a||{};return this.template.fn.call(a,a,new q.Helpers(a,b||{}))};v(q,{txt:function(a,b,d,f,e){var g=c.compute.binder(e,f,function(a,b){p(a,b)});if(!g.isListening)return(a||0!==d?Ra:R)(g.value);var h,i=function(a){c.bind.call(a,"destroyed",g.teardown);h=a},k=function(a){a||(g.teardown(),c.unbind.call(h,"destroyed",g.teardown))},b=Qa[b]||"span",p;if(0==d)return"<"+b+c.view.hook(a?function(a,b){p=function(a){d.nodeValue=""+a;k(d.parentNode)};var c=b&&11===a.parentNode.nodeType?b:a.parentNode,
|
|
56
|
+
d=document.createTextNode(g.value);c.insertBefore(d,a);c.removeChild(a);i(c)}:function(a,b){p=function(a){e[0].parentNode&&(e=d(a,e));k(e[0].parentNode)};var b=b&&11===a.parentNode.nodeType?b:a.parentNode,d=function(a,d){var e=c.view.frag(a,b),f=c.map(e.childNodes,function(a){return a}),g=d[d.length-1];g.nextSibling?g.parentNode.insertBefore(e,g.nextSibling):g.parentNode.appendChild(e);c.remove(c.$(d));return f},e=d(g.value,[a]);i(b)})+"></"+b+">";if(1===d){var l=g.value.replace(/['"]/g,"").split("=")[0];
|
|
57
|
+
A.push(function(a){p=function(b){var b=(b||"").replace(/['"]/g,"").split("="),d=b[0];if(d!=l&&l){var e=l;-1<c.inArray(e,ra)?a[e]=!1:a.removeAttribute(e)}d&&(Q(a,d,b[1]),l=d)};i(a)});return g.value}A.push(function(a){p=function(){Q(a,d,h.render())};var b=c.$(a),e;(e=c.data(b,"hooks"))||c.data(b,"hooks",e={});var f=D[d]?a[D[d]]:a.getAttribute(d),b=f.split("__!!__"),h;e[d]?e[d].bindings.push(g):e[d]={render:function(){var a=0;return f.replace(Pa,function(){return R(h.bindings[a++].value)})},bindings:[g],
|
|
58
|
+
batchNum:j};h=e[d];b.splice(1,0,g.value);Q(a,d,b.join(""));i(a)});return"__!!__"},pending:function(){if(A.length){var a=A.slice(0);A=[];return c.view.hook(function(b){c.each(a,function(a){a(b)})})}return""}});var Ta=RegExp("(<%%|%%>|<%==|<%=|<%#|<%|%>|<|>|\"|')","g"),B=null,G=s=null,A=[],Sa=function(a,b){var c=[],f=0,a=a.replace(Oa,"\n");a.replace(Ta,function(b,e,g){g>f&&c.push(a.substring(f,g));c.push(e);f=g+e.length});f<a.length&&c.push(a.substr(f));var e="",g=["var ___v1ew = [];"],h=function(a,
|
|
59
|
+
b){g.push("___v1ew.push(",'"',a.split("\\").join("\\\\").split("\n").join("\\n").split('"').join('\\"').split("\t").join("\\t"),'"'+(b||"")+");")},i=[],k,l=null,o=!1,m="",n=[],q=0,r;for(B=s=G=null;(r=c[q++])!==j;){if(null===l)switch(r){case "<%":case "<%=":case "<%==":o=1;case "<%#":l=r;e.length&&h(e);e="";break;case "<%%":e+="<%";break;case "<":0!==c[q].indexOf("!--")&&(B=1,o=0);e+=r;break;case ">":B=0;o?(h(e,',can.EJS.pending(),">"'),e=""):e+=r;"/"==k.substr(-1)&&(n.pop(),m=n[n.length-1]);break;
|
|
60
|
+
case "'":case '"':B&&(s&&s===r?s=null:null===s&&(s=r,G=k));default:"<"===k&&(m=r.split(" ")[0],0===m.indexOf("/")&&n.pop()===m.substr(1)?m=n[n.length-1]||m.substr(1):n.push(m)),e+=r}else switch(r){case "%>":switch(l){case "<%":k=--e.split("{").length- --e.split("}").length;1==k?(g.push("___v1ew.push(","can.EJS.txt(0,'"+m+"',"+(s?"'"+G.match(qa)[1]+"'":B?1:0)+",this,function(){","var ___v1ew = [];",e),i.push({before:"",after:"return ___v1ew.join('')}));\n"})):(f=i.length&&-1==k?i.pop():{after:";"},
|
|
61
|
+
f.before&&g.push(f.before),g.push(e,";",f.after));break;case "<%=":case "<%==":(k=--e.split("{").length- --e.split("}").length)&&i.push({before:"return ___v1ew.join('')",after:"}));"}),pa.test(e)&&(e=e.match(pa),e="function(__){var "+e[1]+"=can.$(__);"+e[2]+"}"),g.push("___v1ew.push(","can.EJS.txt("+("<%="===l?1:0)+",'"+m+"',"+(s?"'"+G.match(qa)[1]+"'":B?1:0)+",this,function(){ return ",e,k?"var ___v1ew = [];":"}));")}l=null;e="";break;case "<%%":e+="<%";break;default:e+=r}k=r}e.length&&h(e);g.push(";");
|
|
62
|
+
h={out:"with(_VIEW) { with (_CONTEXT) {"+g.join("")+" return ___v1ew.join('')}}"};Na.call(h,"this.fn = (function(_CONTEXT,_VIEW){"+h.out+"});\r\n//@ sourceURL="+b+".js");return h};q.Helpers=function(a,b){this._data=a;this._extras=b;v(this,b)};q.Helpers.prototype={list:function(a,b){c.each(a,function(c,f){b(c,f,a)})}};c.view.register({suffix:"ejs",script:function(a,b){return"can.EJS(function(_CONTEXT,_VIEW) { "+(new q({text:b,name:a})).template.out+" })"},renderer:function(a,b){return q({text:b,name:a})}});
|
|
63
|
+
"function"===typeof define&&define.amd?define("can",[],function(){return c}):o.can=c})(can={},this);
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
(function(can, window, undefined){
|
|
2
|
+
|
|
3
|
+
can.each([ can.Observe, can.Model ], function(clss){
|
|
4
|
+
// in some cases model might not be defined quite yet.
|
|
5
|
+
if(clss === undefined){
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
can.extend(clss, {
|
|
10
|
+
/**
|
|
11
|
+
* @attribute can.Observe.static.attributes
|
|
12
|
+
* @parent can.Observe.attributes
|
|
13
|
+
*
|
|
14
|
+
* `can.Observe.attributes` is a property that contains key/value pair(s) of an attribute's name and its
|
|
15
|
+
* respective type for using in [can.Observe.static.convert convert] and [can.Observe.prototype.serialize serialize].
|
|
16
|
+
*
|
|
17
|
+
* var Contact = can.Observe({
|
|
18
|
+
* attributes : {
|
|
19
|
+
* birthday : 'date',
|
|
20
|
+
* age: 'number',
|
|
21
|
+
* name: 'string'
|
|
22
|
+
* }
|
|
23
|
+
* });
|
|
24
|
+
*
|
|
25
|
+
*/
|
|
26
|
+
attributes : {},
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @attribute can.Observe.static.convert
|
|
30
|
+
* @parent can.Observe.attributes
|
|
31
|
+
*
|
|
32
|
+
* You often want to convert from what the observe sends you to a form more useful to JavaScript.
|
|
33
|
+
* For example, contacts might be returned from the server with dates that look like: "1982-10-20".
|
|
34
|
+
* We can observe to convert it to something closer to `new Date(1982,10,20)`.
|
|
35
|
+
*
|
|
36
|
+
* Convert comes with the following types:
|
|
37
|
+
*
|
|
38
|
+
* - __date__ Converts to a JS date. Accepts integers or strings that work with Date.parse
|
|
39
|
+
* - __number__ An integer or number that can be passed to parseFloat
|
|
40
|
+
* - __boolean__ Converts "false" to false, and puts everything else through Boolean()
|
|
41
|
+
*
|
|
42
|
+
* The following sets the birthday attribute to "date" and provides a date conversion function:
|
|
43
|
+
*
|
|
44
|
+
* var Contact = can.Observe({
|
|
45
|
+
* attributes : {
|
|
46
|
+
* birthday : 'date'
|
|
47
|
+
* },
|
|
48
|
+
* convert : {
|
|
49
|
+
* date : function(raw){
|
|
50
|
+
* if(typeof raw == 'string'){
|
|
51
|
+
* //- Extracts dates formated 'YYYY-DD-MM'
|
|
52
|
+
* var matches = raw.match(/(\d+)-(\d+)-(\d+)/);
|
|
53
|
+
*
|
|
54
|
+
* //- Parses to date object and returns
|
|
55
|
+
* return new Date(matches[1],
|
|
56
|
+
* (+matches[2])-1,
|
|
57
|
+
* matches[3]);
|
|
58
|
+
*
|
|
59
|
+
* }else if(raw instanceof Date){
|
|
60
|
+
* return raw;
|
|
61
|
+
* }
|
|
62
|
+
* }
|
|
63
|
+
* }
|
|
64
|
+
* },{});
|
|
65
|
+
*
|
|
66
|
+
* var contact = new Contact();
|
|
67
|
+
*
|
|
68
|
+
* //- calls convert on attribute set
|
|
69
|
+
* contact.attr('birthday', '4-26-2012')
|
|
70
|
+
*
|
|
71
|
+
* contact.attr('birthday'); //-> Date
|
|
72
|
+
*
|
|
73
|
+
* ## Assocations and Convert
|
|
74
|
+
*
|
|
75
|
+
* If you have assocations defined within your model(s), you can use convert to automatically
|
|
76
|
+
* call seralize on those models.
|
|
77
|
+
*
|
|
78
|
+
* can.Model("Contact",{
|
|
79
|
+
* attributes : {
|
|
80
|
+
* tasks: "Task.models"
|
|
81
|
+
* }
|
|
82
|
+
* }, {});
|
|
83
|
+
*
|
|
84
|
+
* can.Model("Task",{
|
|
85
|
+
* attributes : {
|
|
86
|
+
* due : 'date'
|
|
87
|
+
* }
|
|
88
|
+
* },{});
|
|
89
|
+
*
|
|
90
|
+
* var contact = new Contact({
|
|
91
|
+
* tasks: [ new Task({
|
|
92
|
+
* due: new Date()
|
|
93
|
+
* }) ]
|
|
94
|
+
* });
|
|
95
|
+
*
|
|
96
|
+
* contact.seralize();
|
|
97
|
+
* //-> { tasks: [ { due: 1333219754627 } ] }
|
|
98
|
+
*
|
|
99
|
+
*/
|
|
100
|
+
convert: {
|
|
101
|
+
"date": function( str ) {
|
|
102
|
+
var type = typeof str;
|
|
103
|
+
if ( type === "string" ) {
|
|
104
|
+
return isNaN(Date.parse(str)) ? null : Date.parse(str)
|
|
105
|
+
} else if ( type === 'number' ) {
|
|
106
|
+
return new Date(str)
|
|
107
|
+
} else {
|
|
108
|
+
return str
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
"number": function( val ) {
|
|
112
|
+
return parseFloat(val);
|
|
113
|
+
},
|
|
114
|
+
"boolean": function( val ) {
|
|
115
|
+
return Boolean(val === "false" ? 0 : val);
|
|
116
|
+
},
|
|
117
|
+
"default": function( val, error, type ) {
|
|
118
|
+
var construct = can.getObject(type),
|
|
119
|
+
context = window,
|
|
120
|
+
realType;
|
|
121
|
+
// if type has a . we need to look it up
|
|
122
|
+
if ( type.indexOf(".") >= 0 ) {
|
|
123
|
+
// get everything before the last .
|
|
124
|
+
realType = type.substring(0, type.lastIndexOf("."));
|
|
125
|
+
// get the object before the last .
|
|
126
|
+
context = can.getObject(realType);
|
|
127
|
+
}
|
|
128
|
+
return typeof construct == "function" ? construct.call(context, val) : val;
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
/**
|
|
132
|
+
* @attribute can.Observe.static.serialize
|
|
133
|
+
* @parent can.Observe.attributes
|
|
134
|
+
*
|
|
135
|
+
* `can.Observe.static.seralize` is object of name-function pairs that are used to
|
|
136
|
+
* serialize attributes.
|
|
137
|
+
*
|
|
138
|
+
* Similar to [can.Observe.convert], in that the keys of this object correspond to
|
|
139
|
+
* the types specified in [can.Observe.attributes].
|
|
140
|
+
*
|
|
141
|
+
* By default every attribute will be passed through the 'default' serialization method
|
|
142
|
+
* that will return the value if the property holds a primitive value (string, number, ...),
|
|
143
|
+
* or it will call the "serialize" method if the property holds an object with the "serialize" method set.
|
|
144
|
+
*
|
|
145
|
+
* For example, to serialize all dates to ISO format:
|
|
146
|
+
*
|
|
147
|
+
* var Contact = can.Observe({
|
|
148
|
+
* attributes : {
|
|
149
|
+
* birthday : 'date'
|
|
150
|
+
* },
|
|
151
|
+
* serialize : {
|
|
152
|
+
* date : function(val, type){
|
|
153
|
+
* return new Date(val).toISOString();
|
|
154
|
+
* }
|
|
155
|
+
* }
|
|
156
|
+
* },{});
|
|
157
|
+
*
|
|
158
|
+
* var contact = new Contact({
|
|
159
|
+
* birthday: new Date("Oct 25, 1973")
|
|
160
|
+
* }).serialize();
|
|
161
|
+
* //-> { "birthday" : "1973-10-25T05:00:00.000Z" }
|
|
162
|
+
*
|
|
163
|
+
*/
|
|
164
|
+
serialize: {
|
|
165
|
+
"default": function( val, type ) {
|
|
166
|
+
return isObject(val) && val.serialize ? val.serialize() : val;
|
|
167
|
+
},
|
|
168
|
+
"date": function( val ) {
|
|
169
|
+
return val && val.getTime()
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
// overwrite setup to do this stuff
|
|
175
|
+
var oldSetup = clss.setup;
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* @hide
|
|
179
|
+
* @attribute can.Observe.static.setup
|
|
180
|
+
* @parent can.Observe.attributes
|
|
181
|
+
*
|
|
182
|
+
* `can.Observe.static.setup` overrides default `can.Observe` setup to provide
|
|
183
|
+
* functionality for attributes.
|
|
184
|
+
*
|
|
185
|
+
*/
|
|
186
|
+
clss.setup = function(superClass, stat, proto){
|
|
187
|
+
var self = this;
|
|
188
|
+
oldSetup.call(self, superClass, stat, proto);
|
|
189
|
+
|
|
190
|
+
can.each(["attributes", "validations"], function( name ) {
|
|
191
|
+
if (!self[name] || superClass[name] === self[name] ) {
|
|
192
|
+
self[name] = {};
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
can.each(["convert", "serialize"], function( name ) {
|
|
197
|
+
if ( superClass[name] != self[name] ) {
|
|
198
|
+
self[name] = can.extend({}, superClass[name], self[name]);
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
};
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* @hide
|
|
206
|
+
* @function can.Observe.prototype.convert
|
|
207
|
+
* @parent can.Observe.attributes
|
|
208
|
+
*/
|
|
209
|
+
can.Observe.prototype.__convert = function(prop, value){
|
|
210
|
+
// check if there is a
|
|
211
|
+
|
|
212
|
+
var Class = this.constructor,
|
|
213
|
+
val, type, converter;
|
|
214
|
+
|
|
215
|
+
if(Class.attributes){
|
|
216
|
+
// the type of the attribute
|
|
217
|
+
type = Class.attributes[prop];
|
|
218
|
+
converter = Class.convert[type] || Class.convert['default'];
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
return value === null || !type ?
|
|
222
|
+
// just use the value
|
|
223
|
+
value :
|
|
224
|
+
// otherwise, pass to the converter
|
|
225
|
+
converter.call(Class, value, function() {}, type);
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* @function can.Observe.prototype.serialize
|
|
230
|
+
* @parent can.Observe.attributes
|
|
231
|
+
*
|
|
232
|
+
* `can.Observe.prototype.serialize` serializes an object for the object.
|
|
233
|
+
* Serialized data is typically used to send back to a server.
|
|
234
|
+
*
|
|
235
|
+
* You can set the serialization methods similar to the convert methods:
|
|
236
|
+
*
|
|
237
|
+
* var Contact = can.Observe({
|
|
238
|
+
* attributes : {
|
|
239
|
+
* birthday : 'date'
|
|
240
|
+
* },
|
|
241
|
+
* serialize : {
|
|
242
|
+
* date : function( val, type ){
|
|
243
|
+
* return val.getYear() +
|
|
244
|
+
* "-" + (val.getMonth() + 1) +
|
|
245
|
+
* "-" + val.getDate();
|
|
246
|
+
* }
|
|
247
|
+
* }
|
|
248
|
+
* },{})
|
|
249
|
+
*
|
|
250
|
+
* var contact = new Contact();
|
|
251
|
+
* contact.attr('birthday', new Date());
|
|
252
|
+
* contact.serialize()
|
|
253
|
+
* //-> { birthday: 'YYYY-MM-DD' }
|
|
254
|
+
*
|
|
255
|
+
* You can also get and serialize an individual property by passing the attribute
|
|
256
|
+
* name to the `serialize` function. Building on the above demo, we can serialize
|
|
257
|
+
* the `birthday` attribute only.
|
|
258
|
+
*
|
|
259
|
+
* contact.serialize('birthday') //-> 'YYYY-MM-DD'
|
|
260
|
+
*
|
|
261
|
+
* @param {Object} attrName (optional) when passed returns only that attribute name
|
|
262
|
+
*/
|
|
263
|
+
can.Observe.prototype.serialize = function(attrName){
|
|
264
|
+
var where = {},
|
|
265
|
+
Class = this.constructor,
|
|
266
|
+
attrs = {};
|
|
267
|
+
|
|
268
|
+
if(attrName != undefined){
|
|
269
|
+
attrs[attrName] = this[attrName];
|
|
270
|
+
} else {
|
|
271
|
+
attrs = this.__get();
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
can.each(attrs, function( val, name ) {
|
|
275
|
+
var type = Class.attributes[name],
|
|
276
|
+
converter= Class.serialize[type];
|
|
277
|
+
|
|
278
|
+
// if the value is an object, and has a attrs or serialize function
|
|
279
|
+
where[name] = val && typeof val.serialize == 'function' ?
|
|
280
|
+
// call attrs or serialize to get the original data back
|
|
281
|
+
val.serialize() :
|
|
282
|
+
// otherwise if we have a converter
|
|
283
|
+
converter ?
|
|
284
|
+
// use the converter
|
|
285
|
+
converter(val, type) :
|
|
286
|
+
// or return the val
|
|
287
|
+
val
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
return attrName != undefined ? where[attrName] : where;
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
})(this.can, this )
|
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
(function(can, window, undefined){
|
|
2
|
+
|
|
3
|
+
var isArray = can.isArray,
|
|
4
|
+
// essentially returns an object that has all the must have comparisons ...
|
|
5
|
+
// must haves, do not return true when provided undefined
|
|
6
|
+
cleanSet = function(obj, compares){
|
|
7
|
+
var copy = can.extend({}, obj);
|
|
8
|
+
for(var prop in copy) {
|
|
9
|
+
var compare = compares[prop] === undefined ? compares["*"] : compares[prop];
|
|
10
|
+
if( same(copy[prop], undefined, compare ) ) {
|
|
11
|
+
delete copy[prop]
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return copy;
|
|
15
|
+
},
|
|
16
|
+
propCount = function(obj){
|
|
17
|
+
var count = 0;
|
|
18
|
+
for(var prop in obj) count++;
|
|
19
|
+
return count;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @class can.Object
|
|
24
|
+
* @parent can.util
|
|
25
|
+
*
|
|
26
|
+
* Object contains several helper methods that
|
|
27
|
+
* help compare objects.
|
|
28
|
+
*
|
|
29
|
+
* ## same
|
|
30
|
+
*
|
|
31
|
+
* Returns true if two objects are similar.
|
|
32
|
+
*
|
|
33
|
+
* can.Object.same({foo: "bar"} , {bar: "foo"}) //-> false
|
|
34
|
+
*
|
|
35
|
+
* ## subset
|
|
36
|
+
*
|
|
37
|
+
* Returns true if an object is a set of another set.
|
|
38
|
+
*
|
|
39
|
+
* can.Object.subset({}, {foo: "bar"} ) //-> true
|
|
40
|
+
*
|
|
41
|
+
* ## subsets
|
|
42
|
+
*
|
|
43
|
+
* Returns the subsets of an object
|
|
44
|
+
*
|
|
45
|
+
* can.Object.subsets({userId: 20},
|
|
46
|
+
* [
|
|
47
|
+
* {userId: 20, limit: 30},
|
|
48
|
+
* {userId: 5},
|
|
49
|
+
* {}
|
|
50
|
+
* ])
|
|
51
|
+
* //-> [{userId: 20, limit: 30}]
|
|
52
|
+
*/
|
|
53
|
+
can.Object = {};
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* @function same
|
|
57
|
+
* Returns if two objects are the same. It takes an optional compares object that
|
|
58
|
+
* can be used to make comparisons.
|
|
59
|
+
*
|
|
60
|
+
* This function does not work with objects that create circular references.
|
|
61
|
+
*
|
|
62
|
+
* ## Examples
|
|
63
|
+
*
|
|
64
|
+
* can.Object.same({name: "Justin"},
|
|
65
|
+
* {name: "JUSTIN"}) //-> false
|
|
66
|
+
*
|
|
67
|
+
* // ignore the name property
|
|
68
|
+
* can.Object.same({name: "Brian"},
|
|
69
|
+
* {name: "JUSTIN"},
|
|
70
|
+
* {name: null}) //-> true
|
|
71
|
+
*
|
|
72
|
+
* // ignore case
|
|
73
|
+
* can.Object.same({name: "Justin"},
|
|
74
|
+
* {name: "JUSTIN"},
|
|
75
|
+
* {name: "i"}) //-> true
|
|
76
|
+
*
|
|
77
|
+
* // deep rule
|
|
78
|
+
* can.Object.same({ person : { name: "Justin" } },
|
|
79
|
+
* { person : { name: "JUSTIN" } },
|
|
80
|
+
* { person : { name: "i" } }) //-> true
|
|
81
|
+
*
|
|
82
|
+
* // supplied compare function
|
|
83
|
+
* can.Object.same({age: "Thirty"},
|
|
84
|
+
* {age: 30},
|
|
85
|
+
* {age: function( a, b ){
|
|
86
|
+
* if( a == "Thirty" ) {
|
|
87
|
+
* a = 30
|
|
88
|
+
* }
|
|
89
|
+
* if( b == "Thirty" ) {
|
|
90
|
+
* b = 30
|
|
91
|
+
* }
|
|
92
|
+
* return a === b;
|
|
93
|
+
* }}) //-> true
|
|
94
|
+
*
|
|
95
|
+
* @param {Object} a an object to compare
|
|
96
|
+
* @param {Object} b an object to compare
|
|
97
|
+
* @param {Object} [compares] an object that indicates how to
|
|
98
|
+
* compare specific properties.
|
|
99
|
+
* Typically this is a name / value pair
|
|
100
|
+
*
|
|
101
|
+
* can.Object.same({name: "Justin"},{name: "JUSTIN"},{name: "i"})
|
|
102
|
+
*
|
|
103
|
+
* There are two compare functions that you can specify with a string:
|
|
104
|
+
*
|
|
105
|
+
* - 'i' - ignores case
|
|
106
|
+
* - null - ignores this property
|
|
107
|
+
*
|
|
108
|
+
* @param {Object} [deep] used internally
|
|
109
|
+
*/
|
|
110
|
+
var same = can.Object.same = function(a, b, compares, aParent, bParent, deep){
|
|
111
|
+
var aType = typeof a,
|
|
112
|
+
aArray = isArray(a),
|
|
113
|
+
comparesType = typeof compares,
|
|
114
|
+
compare;
|
|
115
|
+
|
|
116
|
+
if(comparesType == 'string' || compares === null ){
|
|
117
|
+
compares = compareMethods[compares];
|
|
118
|
+
comparesType = 'function'
|
|
119
|
+
}
|
|
120
|
+
if(comparesType == 'function'){
|
|
121
|
+
return compares(a, b, aParent, bParent)
|
|
122
|
+
}
|
|
123
|
+
compares = compares || {};
|
|
124
|
+
|
|
125
|
+
if(a instanceof Date){
|
|
126
|
+
return a === b;
|
|
127
|
+
}
|
|
128
|
+
if(deep === -1){
|
|
129
|
+
return aType === 'object' || a === b;
|
|
130
|
+
}
|
|
131
|
+
if(aType !== typeof b || aArray !== isArray(b)){
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
if(a === b){
|
|
135
|
+
return true;
|
|
136
|
+
}
|
|
137
|
+
if(aArray){
|
|
138
|
+
if(a.length !== b.length){
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
for(var i =0; i < a.length; i ++){
|
|
142
|
+
compare = compares[i] === undefined ? compares["*"] : compares[i]
|
|
143
|
+
if(!same(a[i],b[i], a, b, compare )){
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
return true;
|
|
148
|
+
} else if(aType === "object" || aType === 'function'){
|
|
149
|
+
var bCopy = can.extend({}, b);
|
|
150
|
+
for(var prop in a){
|
|
151
|
+
compare = compares[prop] === undefined ? compares["*"] : compares[prop];
|
|
152
|
+
if(! same( a[prop], b[prop], compare , a, b, deep === false ? -1 : undefined )){
|
|
153
|
+
return false;
|
|
154
|
+
}
|
|
155
|
+
delete bCopy[prop];
|
|
156
|
+
}
|
|
157
|
+
// go through bCopy props ... if there is no compare .. return false
|
|
158
|
+
for(prop in bCopy){
|
|
159
|
+
if( compares[prop] === undefined ||
|
|
160
|
+
! same( undefined, b[prop], compares[prop] , a, b, deep === false ? -1 : undefined )){
|
|
161
|
+
return false;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return true;
|
|
165
|
+
}
|
|
166
|
+
return false;
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* @function subsets
|
|
171
|
+
* Returns the sets in 'sets' that are a subset of checkSet
|
|
172
|
+
* @param {Object} checkSet
|
|
173
|
+
* @param {Object} sets
|
|
174
|
+
*/
|
|
175
|
+
can.Object.subsets = function(checkSet, sets, compares){
|
|
176
|
+
var len = sets.length,
|
|
177
|
+
subsets = [],
|
|
178
|
+
checkPropCount = propCount(checkSet),
|
|
179
|
+
setLength;
|
|
180
|
+
|
|
181
|
+
for(var i =0; i < len; i++){
|
|
182
|
+
//check this subset
|
|
183
|
+
var set = sets[i];
|
|
184
|
+
if( can.Object.subset(checkSet, set, compares) ){
|
|
185
|
+
subsets.push(set)
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
return subsets;
|
|
189
|
+
};
|
|
190
|
+
/**
|
|
191
|
+
* @function subset
|
|
192
|
+
* Compares if checkSet is a subset of set
|
|
193
|
+
* @param {Object} checkSet
|
|
194
|
+
* @param {Object} set
|
|
195
|
+
* @param {Object} [compares]
|
|
196
|
+
* @param {Object} [checkPropCount]
|
|
197
|
+
*/
|
|
198
|
+
can.Object.subset = function(subset, set, compares){
|
|
199
|
+
// go through set {type: 'folder'} and make sure every property
|
|
200
|
+
// is in subset {type: 'folder', parentId :5}
|
|
201
|
+
// then make sure that set has fewer properties
|
|
202
|
+
// make sure we are only checking 'important' properties
|
|
203
|
+
// in subset (ones that have to have a value)
|
|
204
|
+
|
|
205
|
+
var setPropCount =0,
|
|
206
|
+
compares = compares || {};
|
|
207
|
+
|
|
208
|
+
for(var prop in set){
|
|
209
|
+
|
|
210
|
+
if(! same(subset[prop], set[prop], compares[prop], subset, set ) ){
|
|
211
|
+
return false;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
return true;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
var compareMethods = {
|
|
219
|
+
"null" : function(){
|
|
220
|
+
return true;
|
|
221
|
+
},
|
|
222
|
+
i : function(a, b){
|
|
223
|
+
return (""+a).toLowerCase() == (""+b).toLowerCase()
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
;
|
|
229
|
+
|
|
230
|
+
var flatProps = function(a){
|
|
231
|
+
var obj = {};
|
|
232
|
+
for(var prop in a){
|
|
233
|
+
if(typeof a[prop] !== 'object' || a[prop] === null || a[prop] instanceof Date){
|
|
234
|
+
obj[prop] = a[prop]
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
return obj;
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
can.extend(can.Observe.prototype, {
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* @function can.Observe.prototype.backup
|
|
244
|
+
* @plugin can/observe/backup
|
|
245
|
+
* @parent can.Observe.backup
|
|
246
|
+
*
|
|
247
|
+
* `observe.backup()` backs up a [can.Observe] instance, so it can be restored later
|
|
248
|
+
* by calling [can.Observe.prototype.restore] or checked if it
|
|
249
|
+
* has changed with [can.Observe.prototype.isDirty]:
|
|
250
|
+
*
|
|
251
|
+
* var recipe = new can.Observe({
|
|
252
|
+
* name : 'Pancakes',
|
|
253
|
+
* ingredients : [{
|
|
254
|
+
* name : "eggs",
|
|
255
|
+
* amount : '1'
|
|
256
|
+
* }, {
|
|
257
|
+
* name : "flour",
|
|
258
|
+
* amount : '1 cup'
|
|
259
|
+
* }, {
|
|
260
|
+
* name : "milk",
|
|
261
|
+
* amount : '1 1/4 cup'
|
|
262
|
+
* }]
|
|
263
|
+
* });
|
|
264
|
+
*
|
|
265
|
+
* recipe.backup();
|
|
266
|
+
*
|
|
267
|
+
* @return {can.Observe} The observe instance
|
|
268
|
+
*/
|
|
269
|
+
backup: function() {
|
|
270
|
+
this._backupStore = this._attrs();
|
|
271
|
+
return this;
|
|
272
|
+
},
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* @function can.Observe.prototype.isDirty
|
|
276
|
+
* @plugin can/observe/backup
|
|
277
|
+
* @parent can.Observe.backup
|
|
278
|
+
*
|
|
279
|
+
* `observe.isDirty([checkAssociations])` returns if the observe has changed since the last
|
|
280
|
+
* [can.Observe.prototype.backup] call. If there is no backup it will return false. If you pass
|
|
281
|
+
* true, _isDirty_ also checks if any child properties or [can.Model] associations have changed.
|
|
282
|
+
*
|
|
283
|
+
* var recipe = new can.Observe({
|
|
284
|
+
* name : 'Pancakes',
|
|
285
|
+
* ingredients : [{
|
|
286
|
+
* name : "eggs",
|
|
287
|
+
* amount : '1'
|
|
288
|
+
* }, {
|
|
289
|
+
* name : "flour",
|
|
290
|
+
* amount : '1 cup'
|
|
291
|
+
* }, {
|
|
292
|
+
* name : "milk",
|
|
293
|
+
* amount : '1 1/4 cup'
|
|
294
|
+
* }]
|
|
295
|
+
* });
|
|
296
|
+
*
|
|
297
|
+
* recipe.backup();
|
|
298
|
+
* // Change the attribute of a nested property
|
|
299
|
+
* recipe.attr('ingredients.0.amount', '2');
|
|
300
|
+
* recipe.isDirty() // -> false
|
|
301
|
+
* recipe.isDirty(true) // -> true
|
|
302
|
+
* recipe.attr('name', 'Eggcakes');
|
|
303
|
+
* recipe.isDirty() // -> true
|
|
304
|
+
*
|
|
305
|
+
* @param {Boolean} [checkAssociations] Whether nested objects should be checked or
|
|
306
|
+
* not. Defaults to false.
|
|
307
|
+
* @return {Boolean} true if there are changes,
|
|
308
|
+
* false if not or there is no backup
|
|
309
|
+
*/
|
|
310
|
+
isDirty: function(checkAssociations) {
|
|
311
|
+
return this._backupStore &&
|
|
312
|
+
!can.Object.same(this._attrs(),
|
|
313
|
+
this._backupStore,
|
|
314
|
+
undefined,
|
|
315
|
+
undefined,
|
|
316
|
+
undefined,
|
|
317
|
+
!!checkAssociations);
|
|
318
|
+
},
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* @function can.Observe.prototype.restore
|
|
322
|
+
* @parent can.Observe.backup
|
|
323
|
+
*
|
|
324
|
+
* `observe.restore([restoreAssociations])` restores the observe to the state of the last time
|
|
325
|
+
* [can.Observe.prototype.backup] was called if [can.Observe.prototype.isDirty]
|
|
326
|
+
* returns true. If you pass true, _restore_ will also check and restore all nested properties
|
|
327
|
+
* and [can.Model] associations.
|
|
328
|
+
*
|
|
329
|
+
* var recipe = new can.Observe({
|
|
330
|
+
* name : 'Pancakes',
|
|
331
|
+
* ingredients : [{
|
|
332
|
+
* name : "eggs",
|
|
333
|
+
* amount : '1'
|
|
334
|
+
* }, {
|
|
335
|
+
* name : "flour",
|
|
336
|
+
* amount : '1 cup'
|
|
337
|
+
* }, {
|
|
338
|
+
* name : "milk",
|
|
339
|
+
* amount : '1 1/4 cup'
|
|
340
|
+
* }]});
|
|
341
|
+
*
|
|
342
|
+
* recipe.backup();
|
|
343
|
+
*
|
|
344
|
+
* // Change the attribute of a nested observe
|
|
345
|
+
* recipe.attr('ingredients.0.amount', '2');
|
|
346
|
+
* recipe.attr('name', 'Eggcakes');
|
|
347
|
+
* recipe.attr('name') // -> Eggcakes
|
|
348
|
+
* recipe.attr('ingredients.0.amount') // -> 2
|
|
349
|
+
* recipe.restore(true);
|
|
350
|
+
* recipe.attr('name') // -> Pancakes
|
|
351
|
+
* recipe.attr('ingredients.0.amount') // -> 1
|
|
352
|
+
*
|
|
353
|
+
* @param {Boolean} [restoreAssociations] Whether nested objects should also
|
|
354
|
+
* be restored or not. Defaults to false.
|
|
355
|
+
* @return {can.Observe} The observe instance
|
|
356
|
+
*/
|
|
357
|
+
restore: function(restoreAssociations) {
|
|
358
|
+
var props = restoreAssociations ? this._backupStore : flatProps(this._backupStore)
|
|
359
|
+
|
|
360
|
+
if(this.isDirty(restoreAssociations)){
|
|
361
|
+
this._attrs(props);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
return this;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
})
|
|
368
|
+
})(this.can, this )
|