decidim-core 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (150) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/decidim.js.es6 +2 -4
  3. data/app/assets/javascripts/decidim/append_elements.js.es6 +1 -1
  4. data/app/assets/javascripts/decidim/editor.js.es6 +33 -35
  5. data/app/assets/javascripts/decidim/filters.js.es6 +9 -15
  6. data/app/assets/javascripts/decidim/form_filter.component.js.es6 +5 -5
  7. data/app/assets/javascripts/decidim/form_filter.component.test.js +1 -1
  8. data/app/assets/javascripts/decidim/foundation.js.es6 +17 -0
  9. data/app/assets/javascripts/decidim/user_registrations.js.es6 +2 -3
  10. data/app/assets/stylesheets/decidim/_decidim.scss +9 -0
  11. data/app/assets/stylesheets/decidim/_variables.scss +5 -11
  12. data/app/assets/stylesheets/decidim/application.scss.erb +6 -0
  13. data/app/assets/stylesheets/decidim/extras/_leaflet.scss +13 -0
  14. data/app/assets/stylesheets/decidim/modules/_buttons.scss +8 -2
  15. data/app/assets/stylesheets/decidim/modules/_cards.scss +0 -2
  16. data/app/assets/stylesheets/decidim/modules/_comments.scss +33 -8
  17. data/app/assets/stylesheets/decidim/modules/{_defintion-data.scss → _definition-data.scss} +0 -0
  18. data/app/assets/stylesheets/decidim/modules/_filter-tags.scss +24 -0
  19. data/app/assets/stylesheets/decidim/modules/_layout.scss +1 -9
  20. data/app/assets/stylesheets/decidim/modules/_list-docs.scss +1 -1
  21. data/app/assets/stylesheets/decidim/modules/_margins.scss +15 -0
  22. data/app/assets/stylesheets/decidim/modules/_modules.scss +56 -0
  23. data/app/assets/stylesheets/decidim/modules/_opinion-toggle.scss +25 -5
  24. data/app/assets/stylesheets/decidim/modules/_order-by.scss +1 -0
  25. data/app/assets/stylesheets/decidim/modules/_process-header.scss +2 -1
  26. data/app/assets/stylesheets/decidim/modules/_process-phase.scss +0 -4
  27. data/app/assets/stylesheets/decidim/modules/_status-labels.scss +7 -1
  28. data/app/assets/stylesheets/decidim/modules/_typography.scss +17 -0
  29. data/app/assets/stylesheets/decidim/utils/_fontface.scss +3 -3
  30. data/app/assets/stylesheets/decidim/utils/_settings.scss +10 -7
  31. data/app/commands/decidim/invite_user.rb +2 -2
  32. data/app/commands/decidim/update_account.rb +48 -0
  33. data/app/controllers/concerns/decidim/form_factory.rb +1 -1
  34. data/app/controllers/concerns/decidim/needs_authorization.rb +12 -1
  35. data/app/controllers/concerns/decidim/user_profile.rb +30 -0
  36. data/app/controllers/decidim/account_controller.rb +28 -10
  37. data/app/controllers/decidim/authorizations_controller.rb +21 -8
  38. data/app/controllers/decidim/devise/invitations_controller.rb +2 -0
  39. data/app/controllers/decidim/devise/sessions_controller.rb +1 -1
  40. data/app/controllers/decidim/own_user_groups_controller.rb +14 -0
  41. data/app/controllers/decidim/participatory_processes_controller.rb +1 -1
  42. data/app/forms/decidim/account_form.rb +41 -0
  43. data/app/helpers/decidim/aria_selected_link_to_helper.rb +26 -0
  44. data/app/helpers/decidim/attachments_helper.rb +15 -0
  45. data/app/helpers/decidim/filters_helper.rb +2 -3
  46. data/app/helpers/decidim/layout_helper.rb +29 -6
  47. data/app/helpers/decidim/resource_helper.rb +64 -0
  48. data/app/helpers/decidim/user_profile_helper.rb +23 -0
  49. data/app/mailers/decidim/decidim_devise_mailer.rb +1 -0
  50. data/app/models/decidim/abilities/everyone.rb +5 -1
  51. data/app/models/decidim/ability.rb +3 -4
  52. data/app/models/decidim/{participatory_process_attachment.rb → attachment.rb} +5 -5
  53. data/app/models/decidim/feature.rb +2 -0
  54. data/app/models/decidim/organization.rb +1 -0
  55. data/app/models/decidim/participatory_process.rb +2 -5
  56. data/app/models/decidim/resource_link.rb +28 -0
  57. data/app/models/decidim/user.rb +6 -0
  58. data/app/models/decidim/user_group.rb +10 -1
  59. data/app/services/decidim/resource_search.rb +1 -4
  60. data/app/types/decidim/session_type.rb +16 -0
  61. data/app/types/decidim/user_group_type.rb +20 -0
  62. data/app/types/decidim/user_type.rb +5 -1
  63. data/app/uploaders/decidim/attachment_uploader.rb +4 -1
  64. data/app/uploaders/decidim/avatar_uploader.rb +8 -0
  65. data/app/uploaders/decidim/banner_image_uploader.rb +1 -0
  66. data/app/uploaders/decidim/hero_image_uploader.rb +1 -0
  67. data/app/uploaders/decidim/homepage_image_uploader.rb +5 -1
  68. data/app/uploaders/decidim/image_uploader.rb +1 -1
  69. data/app/uploaders/decidim/organization_favicon_uploader.rb +17 -0
  70. data/app/uploaders/decidim/organization_logo_uploader.rb +2 -2
  71. data/app/validators/feature_validator.rb +23 -0
  72. data/app/views/decidim/account/_password_fields.html.erb +2 -0
  73. data/app/views/decidim/account/_user_groups.html.erb +0 -0
  74. data/app/views/decidim/account/show.html.erb +24 -29
  75. data/app/views/decidim/application/_attachments.html.erb +8 -0
  76. data/app/views/decidim/{participatory_processes → application}/_documents.html.erb +0 -0
  77. data/app/views/decidim/{participatory_processes → application}/_photos.html.erb +0 -0
  78. data/app/views/decidim/authorizations/first_login.html.erb +22 -0
  79. data/app/views/decidim/authorizations/index.html.erb +46 -19
  80. data/app/views/decidim/devise/omniauth_registrations/new.html.erb +1 -1
  81. data/app/views/decidim/devise/registrations/new.html.erb +1 -1
  82. data/app/views/decidim/own_user_groups/index.html.erb +24 -0
  83. data/app/views/decidim/participatory_process_steps/_participatory_process_step.html.erb +1 -1
  84. data/app/views/decidim/participatory_process_steps/index.html.erb +3 -1
  85. data/app/views/decidim/participatory_processes/_participatory_process.html.erb +2 -2
  86. data/app/views/decidim/participatory_processes/_promoted_process.html.erb +1 -1
  87. data/app/views/decidim/participatory_processes/index.html.erb +2 -0
  88. data/app/views/decidim/participatory_processes/show.html.erb +37 -8
  89. data/app/views/decidim/shared/_comments.html.erb +0 -0
  90. data/app/views/layouts/decidim/_application.html.erb +5 -3
  91. data/app/views/layouts/decidim/_header.html.erb +4 -4
  92. data/app/views/layouts/decidim/_logo.html.erb +29 -17
  93. data/app/views/layouts/decidim/_process_header.html.erb +15 -3
  94. data/app/views/layouts/decidim/_process_header_steps.html.erb +1 -1
  95. data/app/views/layouts/decidim/_user_menu.html.erb +3 -0
  96. data/app/views/layouts/decidim/mailer.html.erb +1 -1
  97. data/app/views/layouts/decidim/user_profile.html.erb +35 -0
  98. data/app/views/pages/home.html.erb +5 -139
  99. data/app/views/pages/home/_extended.html.erb +48 -0
  100. data/app/views/pages/home/_hero.html.erb +20 -0
  101. data/app/views/pages/home/_highlighted_processes.html.erb +37 -0
  102. data/app/views/pages/home/_statistics.html.erb +22 -0
  103. data/app/views/pages/home/_sub_hero.html.erb +11 -0
  104. data/config/i18n-tasks.yml +1 -0
  105. data/config/initializers/foundation_rails_helper.rb +2 -0
  106. data/config/locales/ca.yml +69 -33
  107. data/config/locales/en.yml +86 -29
  108. data/config/locales/es.yml +68 -32
  109. data/config/routes.rb +8 -3
  110. data/db/migrate/20161116115156_create_attachments.rb +0 -2
  111. data/db/migrate/20170113150627_create_resource_links.rb +10 -0
  112. data/db/migrate/20170123134023_make_attachments_polymorphic.rb +18 -0
  113. data/db/migrate/20170123140857_add_avatar_to_user_groups.rb +5 -0
  114. data/db/migrate/20170125135937_rename_attachable_to_attached_to.rb +11 -0
  115. data/db/migrate/20170125152026_add_weight_to_features.rb +5 -0
  116. data/db/migrate/20170126151123_add_extra_info_to_processes.rb +8 -0
  117. data/db/migrate/20170128140553_add_timestamps_to_identities.rb +5 -0
  118. data/db/migrate/20170130132833_add_favicon_to_decidim_organizations.rb +5 -0
  119. data/db/seeds.rb +38 -6
  120. data/lib/decidim/authorable.rb +32 -0
  121. data/lib/decidim/core.rb +37 -0
  122. data/lib/decidim/core/engine.rb +2 -3
  123. data/lib/decidim/core/test.rb +6 -0
  124. data/lib/decidim/core/test/factories.rb +24 -3
  125. data/lib/decidim/core/test/shared_examples/authorable.rb +31 -0
  126. data/lib/decidim/core/test/shared_examples/has_attachments.rb +29 -0
  127. data/lib/decidim/core/test/shared_examples/has_category.rb +10 -0
  128. data/lib/decidim/core/test/shared_examples/has_feature.rb +20 -0
  129. data/lib/decidim/core/test/shared_examples/has_scope.rb +10 -0
  130. data/lib/decidim/core/version.rb +1 -1
  131. data/lib/decidim/feature_manifest.rb +31 -1
  132. data/lib/decidim/features/base_controller.rb +10 -0
  133. data/lib/decidim/features/settings_manifest.rb +1 -0
  134. data/lib/decidim/has_attachment.rb +32 -0
  135. data/lib/decidim/has_attachments.rb +32 -0
  136. data/lib/decidim/has_category.rb +21 -0
  137. data/lib/decidim/has_feature.rb +20 -0
  138. data/lib/decidim/has_scope.rb +21 -0
  139. data/lib/decidim/query_extensions.rb +2 -2
  140. data/lib/decidim/resource_manifest.rb +80 -0
  141. data/lib/decidim/resourceable.rb +85 -0
  142. metadata +67 -40
  143. data/app/assets/javascripts/decidim/inline_svg.js.es6 +0 -12
  144. data/app/assets/stylesheets/decidim/application.sass +0 -12
  145. data/app/assets/stylesheets/decidim/extras/_turbolinks.scss +0 -3
  146. data/app/assets/stylesheets/decidim/modules/_popularity.scss +0 -74
  147. data/app/assets/stylesheets/decidim/utils/_variables.scss +0 -22
  148. data/app/views/decidim/account/_authorizations.html.erb +0 -52
  149. data/vendor/assets/javascripts/owl.carousel.min.js +0 -47
  150. data/vendor/assets/javascripts/svg-injector.js +0 -464
@@ -1,12 +0,0 @@
1
- // = require svg-injector
2
-
3
- (function() {
4
- let inlineSVG = function () {
5
- let $externalSvg = $("img.external-svg");
6
- SVGInjector($externalSvg, {
7
- each: (svg) => $(svg).show()
8
- });
9
- }
10
-
11
- $(document).on('turbolinks:load', inlineSVG);
12
- }(window));
@@ -1,12 +0,0 @@
1
- @import "utils/*"
2
-
3
- @import foundation
4
- @include foundation-everything
5
-
6
- @import "variables"
7
-
8
- @import "modules/*"
9
- @import "layouts/*"
10
- @import "extras/*"
11
-
12
- @import "editor"
@@ -1,3 +0,0 @@
1
- .turbolinks-progress-bar{
2
- background-color: $primary;
3
- }
@@ -1,74 +0,0 @@
1
- $popularity1: #53c9c8;
2
- $popularity2: #f9bc48;
3
- $popularity3: #f85a39;
4
-
5
- .popularity{
6
- min-width: 100px;
7
- margin-top: 5px;
8
- @include clearfix;
9
- &.extra__popularity{
10
- margin-top: 1.5rem;
11
- margin-bottom: 1.5rem;
12
- }
13
- }
14
-
15
- .popularity__desc{
16
- color: $muted;
17
- text-transform: uppercase;
18
- font-size: 90%;
19
- padding-top: .3rem;
20
- display: block;
21
- clear: both;
22
- }
23
-
24
- .popularity__item{
25
- float: left;
26
- width: 18.4%;
27
- height: 4px;
28
- background-color: lightgrey;
29
- margin-left: 2%;
30
- &:first-of-type{
31
- margin-left: 0;
32
- }
33
- }
34
-
35
- .popularity__item:first-of-type{
36
- .popularity--level1 &,
37
- .popularity--level2 &,
38
- .popularity--level3 &,
39
- .popularity--level4 &,
40
- .popularity--level5 &,
41
- .popularity--level6 &{
42
- background: $popularity1;
43
- }
44
- }
45
- .popularity__item:nth-of-type(2){
46
- .popularity--level2 &,
47
- .popularity--level3 &,
48
- .popularity--level4 &,
49
- .popularity--level5 &,
50
- .popularity--level6 &{
51
- background: linear-gradient(to right, $popularity1, $popularity2);
52
- }
53
- }
54
- .popularity__item:nth-of-type(3){
55
- .popularity--level3 &,
56
- .popularity--level4 &,
57
- .popularity--level5 &,
58
- .popularity--level6 &{
59
- background: $popularity2;
60
- }
61
- }
62
- .popularity__item:nth-of-type(4){
63
- .popularity--level4 &,
64
- .popularity--level5 &,
65
- .popularity--level6 &{
66
- background: linear-gradient(to right, $popularity2 50%, $popularity3);
67
- }
68
- }
69
- .popularity__item:nth-of-type(5){
70
- .popularity--level5 &,
71
- .popularity--level6 &{
72
- background: $popularity3;
73
- }
74
- }
@@ -1,22 +0,0 @@
1
- // Decidim Variables
2
-
3
- $primary: map-get($foundation-palette, primary) !default;
4
- $secondary: map-get($foundation-palette, secondary) !default;
5
- $success: map-get($foundation-palette, success) !default;
6
- $warning: map-get($foundation-palette, warning) !default;
7
- $alert: map-get($foundation-palette, alert) !default;
8
-
9
- $light-gray-dark: darken($light-gray, 2.5) !default;
10
-
11
- $proposals: #238FF7 !default;
12
- $actions: #57D685 !default;
13
- $debates: #FA6C96 !default;
14
- $meetings: #FABC6C !default;
15
-
16
- $twitter: #55acee !default;
17
- $facebook: #3b5998 !default;
18
- $google: #dd4b39 !default;
19
-
20
- $muted: lighten($body-font-color, 30) !default;
21
-
22
- $border: 1px solid $medium-gray !default;
@@ -1,52 +0,0 @@
1
- <div class="tabs-panel" id="authorizations">
2
- <div class="row column">
3
- <% if authorizations.any? %>
4
- <section class="section">
5
- <div class="card card--list">
6
- <% authorizations.each do |authorization| %>
7
- <div class="card--list__item">
8
- <div class="card--list__text">
9
- <%= icon "lock-unlocked", class: "card--list__icon" %>
10
- <div>
11
- <h5 class="card--list__heading">
12
- <%= t(authorization.name, scope: "decidim.authorization_handlers") %>
13
- </h5>
14
- <span class="text-small"><%= l(authorization.created_at, format: :long) %></span>
15
- </div>
16
- </div>
17
- <div class="card--list__data">
18
- <%= link_to authorization, method: :delete, class: "card--list__data__icon", data: { confirm: t(".authorization_confirm_destroy") } do %>
19
- <%= icon "circle-x" %>
20
- <% end %>
21
- </div>
22
- </div>
23
- <% end %>
24
- </div>
25
- <% end %>
26
- <% if handlers.any? %>
27
- <div class="card card--list">
28
- <% handlers.each do |handler| %>
29
- <div class="card--list__item">
30
- <div class="card--list__text">
31
- <a href="#">
32
- <%= icon "lock-locked", class: "card--list__icon" %>
33
- </a>
34
- <div>
35
- <h5 class="card--list__heading">
36
- <%= link_to t(handler.handler_name, scope: "decidim.authorization_handlers"), new_authorization_path(handler: handler.handler_name) %>
37
- </h5>
38
- </div>
39
- </div>
40
- <div class="card--list__data">
41
- <%= link_to new_authorization_path(handler: handler.handler_name), class: "card--list__data__icon" do %>
42
- <%= icon "chevron-right" %>
43
- <% end %>
44
- </div>
45
- </div>
46
- <% end %>
47
- </div>
48
- </section>
49
- <% end %>
50
- </div>
51
- </div>
52
-
@@ -1,47 +0,0 @@
1
- "function"!==typeof Object.create&&(Object.create=function(f){function g(){}g.prototype=f;return new g});
2
- (function(f,g,k){var l={init:function(a,b){this.$elem=f(b);this.options=f.extend({},f.fn.owlCarousel.options,this.$elem.data(),a);this.userOptions=a;this.loadContent()},loadContent:function(){function a(a){var d,e="";if("function"===typeof b.options.jsonSuccess)b.options.jsonSuccess.apply(this,[a]);else{for(d in a.owl)a.owl.hasOwnProperty(d)&&(e+=a.owl[d].item);b.$elem.html(e)}b.logIn()}var b=this,e;"function"===typeof b.options.beforeInit&&b.options.beforeInit.apply(this,[b.$elem]);"string"===typeof b.options.jsonPath?
3
- (e=b.options.jsonPath,f.getJSON(e,a)):b.logIn()},logIn:function(){this.$elem.data("owl-originalStyles",this.$elem.attr("style"));this.$elem.data("owl-originalClasses",this.$elem.attr("class"));this.$elem.css({opacity:0});this.orignalItems=this.options.items;this.checkBrowser();this.wrapperWidth=0;this.checkVisible=null;this.setVars()},setVars:function(){if(0===this.$elem.children().length)return!1;this.baseClass();this.eventTypes();this.$userItems=this.$elem.children();this.itemsAmount=this.$userItems.length;
4
- this.wrapItems();this.$owlItems=this.$elem.find(".owl-item");this.$owlWrapper=this.$elem.find(".owl-wrapper");this.playDirection="next";this.prevItem=0;this.prevArr=[0];this.currentItem=0;this.customEvents();this.onStartup()},onStartup:function(){this.updateItems();this.calculateAll();this.buildControls();this.updateControls();this.response();this.moveEvents();this.stopOnHover();this.owlStatus();!1!==this.options.transitionStyle&&this.transitionTypes(this.options.transitionStyle);!0===this.options.autoPlay&&
5
- (this.options.autoPlay=5E3);this.play();this.$elem.find(".owl-wrapper").css("display","block");this.$elem.is(":visible")?this.$elem.css("opacity",1):this.watchVisibility();this.onstartup=!1;this.eachMoveUpdate();"function"===typeof this.options.afterInit&&this.options.afterInit.apply(this,[this.$elem])},eachMoveUpdate:function(){!0===this.options.lazyLoad&&this.lazyLoad();!0===this.options.autoHeight&&this.autoHeight();this.onVisibleItems();"function"===typeof this.options.afterAction&&this.options.afterAction.apply(this,
6
- [this.$elem])},updateVars:function(){"function"===typeof this.options.beforeUpdate&&this.options.beforeUpdate.apply(this,[this.$elem]);this.watchVisibility();this.updateItems();this.calculateAll();this.updatePosition();this.updateControls();this.eachMoveUpdate();"function"===typeof this.options.afterUpdate&&this.options.afterUpdate.apply(this,[this.$elem])},reload:function(){var a=this;g.setTimeout(function(){a.updateVars()},0)},watchVisibility:function(){var a=this;if(!1===a.$elem.is(":visible"))a.$elem.css({opacity:0}),
7
- g.clearInterval(a.autoPlayInterval),g.clearInterval(a.checkVisible);else return!1;a.checkVisible=g.setInterval(function(){a.$elem.is(":visible")&&(a.reload(),a.$elem.animate({opacity:1},200),g.clearInterval(a.checkVisible))},500)},wrapItems:function(){this.$userItems.wrapAll('<div class="owl-wrapper">').wrap('<div class="owl-item"></div>');this.$elem.find(".owl-wrapper").wrap('<div class="owl-wrapper-outer">');this.wrapperOuter=this.$elem.find(".owl-wrapper-outer");this.$elem.css("display","block")},
8
- baseClass:function(){var a=this.$elem.hasClass(this.options.baseClass),b=this.$elem.hasClass(this.options.theme);a||this.$elem.addClass(this.options.baseClass);b||this.$elem.addClass(this.options.theme)},updateItems:function(){var a,b;if(!1===this.options.responsive)return!1;if(!0===this.options.singleItem)return this.options.items=this.orignalItems=1,this.options.itemsCustom=!1,this.options.itemsDesktop=!1,this.options.itemsDesktopSmall=!1,this.options.itemsTablet=!1,this.options.itemsTabletSmall=
9
- !1,this.options.itemsMobile=!1;a=f(this.options.responsiveBaseWidth).width();a>(this.options.itemsDesktop[0]||this.orignalItems)&&(this.options.items=this.orignalItems);if(!1!==this.options.itemsCustom)for(this.options.itemsCustom.sort(function(a,b){return a[0]-b[0]}),b=0;b<this.options.itemsCustom.length;b+=1)this.options.itemsCustom[b][0]<=a&&(this.options.items=this.options.itemsCustom[b][1]);else a<=this.options.itemsDesktop[0]&&!1!==this.options.itemsDesktop&&(this.options.items=this.options.itemsDesktop[1]),
10
- a<=this.options.itemsDesktopSmall[0]&&!1!==this.options.itemsDesktopSmall&&(this.options.items=this.options.itemsDesktopSmall[1]),a<=this.options.itemsTablet[0]&&!1!==this.options.itemsTablet&&(this.options.items=this.options.itemsTablet[1]),a<=this.options.itemsTabletSmall[0]&&!1!==this.options.itemsTabletSmall&&(this.options.items=this.options.itemsTabletSmall[1]),a<=this.options.itemsMobile[0]&&!1!==this.options.itemsMobile&&(this.options.items=this.options.itemsMobile[1]);this.options.items>this.itemsAmount&&
11
- !0===this.options.itemsScaleUp&&(this.options.items=this.itemsAmount)},response:function(){var a=this,b,e;if(!0!==a.options.responsive)return!1;e=f(g).width();a.resizer=function(){f(g).width()!==e&&(!1!==a.options.autoPlay&&g.clearInterval(a.autoPlayInterval),g.clearTimeout(b),b=g.setTimeout(function(){e=f(g).width();a.updateVars()},a.options.responsiveRefreshRate))};f(g).resize(a.resizer)},updatePosition:function(){this.jumpTo(this.currentItem);!1!==this.options.autoPlay&&this.checkAp()},appendItemsSizes:function(){var a=
12
- this,b=0,e=a.itemsAmount-a.options.items;a.$owlItems.each(function(c){var d=f(this);d.css({width:a.itemWidth}).data("owl-item",Number(c));if(0===c%a.options.items||c===e)c>e||(b+=1);d.data("owl-roundPages",b)})},appendWrapperSizes:function(){this.$owlWrapper.css({width:this.$owlItems.length*this.itemWidth*2,left:0});this.appendItemsSizes()},calculateAll:function(){this.calculateWidth();this.appendWrapperSizes();this.loops();this.max()},calculateWidth:function(){this.itemWidth=Math.round(this.$elem.width()/
13
- this.options.items)},max:function(){var a=-1*(this.itemsAmount*this.itemWidth-this.options.items*this.itemWidth);this.options.items>this.itemsAmount?this.maximumPixels=a=this.maximumItem=0:(this.maximumItem=this.itemsAmount-this.options.items,this.maximumPixels=a);return a},min:function(){return 0},loops:function(){var a=0,b=0,e,c;this.positionsInArray=[0];this.pagesInArray=[];for(e=0;e<this.itemsAmount;e+=1)b+=this.itemWidth,this.positionsInArray.push(-b),!0===this.options.scrollPerPage&&(c=f(this.$owlItems[e]),
14
- c=c.data("owl-roundPages"),c!==a&&(this.pagesInArray[a]=this.positionsInArray[e],a=c))},buildControls:function(){if(!0===this.options.navigation||!0===this.options.pagination)this.owlControls=f('<div class="owl-controls"/>').toggleClass("clickable",!this.browser.isTouch).appendTo(this.$elem);!0===this.options.pagination&&this.buildPagination();!0===this.options.navigation&&this.buildButtons()},buildButtons:function(){var a=this,b=f('<div class="owl-buttons"/>');a.owlControls.append(b);a.buttonPrev=
15
- f("<div/>",{"class":"owl-prev",html:a.options.navigationText[0]||""});a.buttonNext=f("<div/>",{"class":"owl-next",html:a.options.navigationText[1]||""});b.append(a.buttonPrev).append(a.buttonNext);b.on("touchstart.owlControls mousedown.owlControls",'div[class^="owl"]',function(a){a.preventDefault()});b.on("touchend.owlControls mouseup.owlControls",'div[class^="owl"]',function(b){b.preventDefault();f(this).hasClass("owl-next")?a.next():a.prev()})},buildPagination:function(){var a=this;a.paginationWrapper=
16
- f('<div class="owl-pagination"/>');a.owlControls.append(a.paginationWrapper);a.paginationWrapper.on("touchend.owlControls mouseup.owlControls",".owl-page",function(b){b.preventDefault();Number(f(this).data("owl-page"))!==a.currentItem&&a.goTo(Number(f(this).data("owl-page")),!0)})},updatePagination:function(){var a,b,e,c,d,g;if(!1===this.options.pagination)return!1;this.paginationWrapper.html("");a=0;b=this.itemsAmount-this.itemsAmount%this.options.items;for(c=0;c<this.itemsAmount;c+=1)0===c%this.options.items&&
17
- (a+=1,b===c&&(e=this.itemsAmount-this.options.items),d=f("<div/>",{"class":"owl-page"}),g=f("<span></span>",{text:!0===this.options.paginationNumbers?a:"","class":!0===this.options.paginationNumbers?"owl-numbers":""}),d.append(g),d.data("owl-page",b===c?e:c),d.data("owl-roundPages",a),this.paginationWrapper.append(d));this.checkPagination()},checkPagination:function(){var a=this;if(!1===a.options.pagination)return!1;a.paginationWrapper.find(".owl-page").each(function(){f(this).data("owl-roundPages")===
18
- f(a.$owlItems[a.currentItem]).data("owl-roundPages")&&(a.paginationWrapper.find(".owl-page").removeClass("active"),f(this).addClass("active"))})},checkNavigation:function(){if(!1===this.options.navigation)return!1;!1===this.options.rewindNav&&(0===this.currentItem&&0===this.maximumItem?(this.buttonPrev.addClass("disabled"),this.buttonNext.addClass("disabled")):0===this.currentItem&&0!==this.maximumItem?(this.buttonPrev.addClass("disabled"),this.buttonNext.removeClass("disabled")):this.currentItem===
19
- this.maximumItem?(this.buttonPrev.removeClass("disabled"),this.buttonNext.addClass("disabled")):0!==this.currentItem&&this.currentItem!==this.maximumItem&&(this.buttonPrev.removeClass("disabled"),this.buttonNext.removeClass("disabled")))},updateControls:function(){this.updatePagination();this.checkNavigation();this.owlControls&&(this.options.items>=this.itemsAmount?this.owlControls.hide():this.owlControls.show())},destroyControls:function(){this.owlControls&&this.owlControls.remove()},next:function(a){if(this.isTransition)return!1;
20
- this.currentItem+=!0===this.options.scrollPerPage?this.options.items:1;if(this.currentItem>this.maximumItem+(!0===this.options.scrollPerPage?this.options.items-1:0))if(!0===this.options.rewindNav)this.currentItem=0,a="rewind";else return this.currentItem=this.maximumItem,!1;this.goTo(this.currentItem,a)},prev:function(a){if(this.isTransition)return!1;this.currentItem=!0===this.options.scrollPerPage&&0<this.currentItem&&this.currentItem<this.options.items?0:this.currentItem-(!0===this.options.scrollPerPage?
21
- this.options.items:1);if(0>this.currentItem)if(!0===this.options.rewindNav)this.currentItem=this.maximumItem,a="rewind";else return this.currentItem=0,!1;this.goTo(this.currentItem,a)},goTo:function(a,b,e){var c=this;if(c.isTransition)return!1;"function"===typeof c.options.beforeMove&&c.options.beforeMove.apply(this,[c.$elem]);a>=c.maximumItem?a=c.maximumItem:0>=a&&(a=0);c.currentItem=c.owl.currentItem=a;if(!1!==c.options.transitionStyle&&"drag"!==e&&1===c.options.items&&!0===c.browser.support3d)return c.swapSpeed(0),
22
- !0===c.browser.support3d?c.transition3d(c.positionsInArray[a]):c.css2slide(c.positionsInArray[a],1),c.afterGo(),c.singleItemTransition(),!1;a=c.positionsInArray[a];!0===c.browser.support3d?(c.isCss3Finish=!1,!0===b?(c.swapSpeed("paginationSpeed"),g.setTimeout(function(){c.isCss3Finish=!0},c.options.paginationSpeed)):"rewind"===b?(c.swapSpeed(c.options.rewindSpeed),g.setTimeout(function(){c.isCss3Finish=!0},c.options.rewindSpeed)):(c.swapSpeed("slideSpeed"),g.setTimeout(function(){c.isCss3Finish=!0},
23
- c.options.slideSpeed)),c.transition3d(a)):!0===b?c.css2slide(a,c.options.paginationSpeed):"rewind"===b?c.css2slide(a,c.options.rewindSpeed):c.css2slide(a,c.options.slideSpeed);c.afterGo()},jumpTo:function(a){"function"===typeof this.options.beforeMove&&this.options.beforeMove.apply(this,[this.$elem]);a>=this.maximumItem||-1===a?a=this.maximumItem:0>=a&&(a=0);this.swapSpeed(0);!0===this.browser.support3d?this.transition3d(this.positionsInArray[a]):this.css2slide(this.positionsInArray[a],1);this.currentItem=
24
- this.owl.currentItem=a;this.afterGo()},afterGo:function(){this.prevArr.push(this.currentItem);this.prevItem=this.owl.prevItem=this.prevArr[this.prevArr.length-2];this.prevArr.shift(0);this.prevItem!==this.currentItem&&(this.checkPagination(),this.checkNavigation(),this.eachMoveUpdate(),!1!==this.options.autoPlay&&this.checkAp());"function"===typeof this.options.afterMove&&this.prevItem!==this.currentItem&&this.options.afterMove.apply(this,[this.$elem])},stop:function(){this.apStatus="stop";g.clearInterval(this.autoPlayInterval)},
25
- checkAp:function(){"stop"!==this.apStatus&&this.play()},play:function(){var a=this;a.apStatus="play";if(!1===a.options.autoPlay)return!1;g.clearInterval(a.autoPlayInterval);a.autoPlayInterval=g.setInterval(function(){a.next(!0)},a.options.autoPlay)},swapSpeed:function(a){"slideSpeed"===a?this.$owlWrapper.css(this.addCssSpeed(this.options.slideSpeed)):"paginationSpeed"===a?this.$owlWrapper.css(this.addCssSpeed(this.options.paginationSpeed)):"string"!==typeof a&&this.$owlWrapper.css(this.addCssSpeed(a))},
26
- addCssSpeed:function(a){return{"-webkit-transition":"all "+a+"ms ease","-moz-transition":"all "+a+"ms ease","-o-transition":"all "+a+"ms ease",transition:"all "+a+"ms ease"}},removeTransition:function(){return{"-webkit-transition":"","-moz-transition":"","-o-transition":"",transition:""}},doTranslate:function(a){return{"-webkit-transform":"translate3d("+a+"px, 0px, 0px)","-moz-transform":"translate3d("+a+"px, 0px, 0px)","-o-transform":"translate3d("+a+"px, 0px, 0px)","-ms-transform":"translate3d("+
27
- a+"px, 0px, 0px)",transform:"translate3d("+a+"px, 0px,0px)"}},transition3d:function(a){this.$owlWrapper.css(this.doTranslate(a))},css2move:function(a){this.$owlWrapper.css({left:a})},css2slide:function(a,b){var e=this;e.isCssFinish=!1;e.$owlWrapper.stop(!0,!0).animate({left:a},{duration:b||e.options.slideSpeed,complete:function(){e.isCssFinish=!0}})},checkBrowser:function(){var a=k.createElement("div");a.style.cssText=" -moz-transform:translate3d(0px, 0px, 0px); -ms-transform:translate3d(0px, 0px, 0px); -o-transform:translate3d(0px, 0px, 0px); -webkit-transform:translate3d(0px, 0px, 0px); transform:translate3d(0px, 0px, 0px)";
28
- a=a.style.cssText.match(/translate3d\(0px, 0px, 0px\)/g);this.browser={support3d:null!==a&&1===a.length,isTouch:"ontouchstart"in g||g.navigator.msMaxTouchPoints}},moveEvents:function(){if(!1!==this.options.mouseDrag||!1!==this.options.touchDrag)this.gestures(),this.disabledEvents()},eventTypes:function(){var a=["s","e","x"];this.ev_types={};!0===this.options.mouseDrag&&!0===this.options.touchDrag?a=["touchstart.owl mousedown.owl","touchmove.owl mousemove.owl","touchend.owl touchcancel.owl mouseup.owl"]:
29
- !1===this.options.mouseDrag&&!0===this.options.touchDrag?a=["touchstart.owl","touchmove.owl","touchend.owl touchcancel.owl"]:!0===this.options.mouseDrag&&!1===this.options.touchDrag&&(a=["mousedown.owl","mousemove.owl","mouseup.owl"]);this.ev_types.start=a[0];this.ev_types.move=a[1];this.ev_types.end=a[2]},disabledEvents:function(){this.$elem.on("dragstart.owl",function(a){a.preventDefault()});this.$elem.on("mousedown.disableTextSelect",function(a){return f(a.target).is("input, textarea, select, option")})},
30
- gestures:function(){function a(a){if(void 0!==a.touches)return{x:a.touches[0].pageX,y:a.touches[0].pageY};if(void 0===a.touches){if(void 0!==a.pageX)return{x:a.pageX,y:a.pageY};if(void 0===a.pageX)return{x:a.clientX,y:a.clientY}}}function b(a){"on"===a?(f(k).on(d.ev_types.move,e),f(k).on(d.ev_types.end,c)):"off"===a&&(f(k).off(d.ev_types.move),f(k).off(d.ev_types.end))}function e(b){b=b.originalEvent||b||g.event;d.newPosX=a(b).x-h.offsetX;d.newPosY=a(b).y-h.offsetY;d.newRelativeX=d.newPosX-h.relativePos;
31
- "function"===typeof d.options.startDragging&&!0!==h.dragging&&0!==d.newRelativeX&&(h.dragging=!0,d.options.startDragging.apply(d,[d.$elem]));(8<d.newRelativeX||-8>d.newRelativeX)&&!0===d.browser.isTouch&&(void 0!==b.preventDefault?b.preventDefault():b.returnValue=!1,h.sliding=!0);(10<d.newPosY||-10>d.newPosY)&&!1===h.sliding&&f(k).off("touchmove.owl");d.newPosX=Math.max(Math.min(d.newPosX,d.newRelativeX/5),d.maximumPixels+d.newRelativeX/5);!0===d.browser.support3d?d.transition3d(d.newPosX):d.css2move(d.newPosX)}
32
- function c(a){a=a.originalEvent||a||g.event;var c;a.target=a.target||a.srcElement;h.dragging=!1;!0!==d.browser.isTouch&&d.$owlWrapper.removeClass("grabbing");d.dragDirection=0>d.newRelativeX?d.owl.dragDirection="left":d.owl.dragDirection="right";0!==d.newRelativeX&&(c=d.getNewPosition(),d.goTo(c,!1,"drag"),h.targetElement===a.target&&!0!==d.browser.isTouch&&(f(a.target).on("click.disable",function(a){a.stopImmediatePropagation();a.stopPropagation();a.preventDefault();f(a.target).off("click.disable")}),
33
- a=f._data(a.target,"events").click,c=a.pop(),a.splice(0,0,c)));b("off")}var d=this,h={offsetX:0,offsetY:0,baseElWidth:0,relativePos:0,position:null,minSwipe:null,maxSwipe:null,sliding:null,dargging:null,targetElement:null};d.isCssFinish=!0;d.$elem.on(d.ev_types.start,".owl-wrapper",function(c){c=c.originalEvent||c||g.event;var e;if(3===c.which)return!1;if(!(d.itemsAmount<=d.options.items)){if(!1===d.isCssFinish&&!d.options.dragBeforeAnimFinish||!1===d.isCss3Finish&&!d.options.dragBeforeAnimFinish)return!1;
34
- !1!==d.options.autoPlay&&g.clearInterval(d.autoPlayInterval);!0===d.browser.isTouch||d.$owlWrapper.hasClass("grabbing")||d.$owlWrapper.addClass("grabbing");d.newPosX=0;d.newRelativeX=0;f(this).css(d.removeTransition());e=f(this).position();h.relativePos=e.left;h.offsetX=a(c).x-e.left;h.offsetY=a(c).y-e.top;b("on");h.sliding=!1;h.targetElement=c.target||c.srcElement}})},getNewPosition:function(){var a=this.closestItem();a>this.maximumItem?a=this.currentItem=this.maximumItem:0<=this.newPosX&&(this.currentItem=
35
- a=0);return a},closestItem:function(){var a=this,b=!0===a.options.scrollPerPage?a.pagesInArray:a.positionsInArray,e=a.newPosX,c=null;f.each(b,function(d,g){e-a.itemWidth/20>b[d+1]&&e-a.itemWidth/20<g&&"left"===a.moveDirection()?(c=g,a.currentItem=!0===a.options.scrollPerPage?f.inArray(c,a.positionsInArray):d):e+a.itemWidth/20<g&&e+a.itemWidth/20>(b[d+1]||b[d]-a.itemWidth)&&"right"===a.moveDirection()&&(!0===a.options.scrollPerPage?(c=b[d+1]||b[b.length-1],a.currentItem=f.inArray(c,a.positionsInArray)):
36
- (c=b[d+1],a.currentItem=d+1))});return a.currentItem},moveDirection:function(){var a;0>this.newRelativeX?(a="right",this.playDirection="next"):(a="left",this.playDirection="prev");return a},customEvents:function(){var a=this;a.$elem.on("owl.next",function(){a.next()});a.$elem.on("owl.prev",function(){a.prev()});a.$elem.on("owl.play",function(b,e){a.options.autoPlay=e;a.play();a.hoverStatus="play"});a.$elem.on("owl.stop",function(){a.stop();a.hoverStatus="stop"});a.$elem.on("owl.goTo",function(b,e){a.goTo(e)});
37
- a.$elem.on("owl.jumpTo",function(b,e){a.jumpTo(e)})},stopOnHover:function(){var a=this;!0===a.options.stopOnHover&&!0!==a.browser.isTouch&&!1!==a.options.autoPlay&&(a.$elem.on("mouseover",function(){a.stop()}),a.$elem.on("mouseout",function(){"stop"!==a.hoverStatus&&a.play()}))},lazyLoad:function(){var a,b,e,c,d;if(!1===this.options.lazyLoad)return!1;for(a=0;a<this.itemsAmount;a+=1)b=f(this.$owlItems[a]),"loaded"!==b.data("owl-loaded")&&(e=b.data("owl-item"),c=b.find(".lazyOwl"),"string"!==typeof c.data("src")?
38
- b.data("owl-loaded","loaded"):(void 0===b.data("owl-loaded")&&(c.hide(),b.addClass("loading").data("owl-loaded","checked")),(d=!0===this.options.lazyFollow?e>=this.currentItem:!0)&&e<this.currentItem+this.options.items&&c.length&&this.lazyPreload(b,c)))},lazyPreload:function(a,b){function e(){a.data("owl-loaded","loaded").removeClass("loading");b.removeAttr("data-src");"fade"===d.options.lazyEffect?b.fadeIn(400):b.show();"function"===typeof d.options.afterLazyLoad&&d.options.afterLazyLoad.apply(this,
39
- [d.$elem])}function c(){f+=1;d.completeImg(b.get(0))||!0===k?e():100>=f?g.setTimeout(c,100):e()}var d=this,f=0,k;"DIV"===b.prop("tagName")?(b.css("background-image","url("+b.data("src")+")"),k=!0):b[0].src=b.data("src");c()},autoHeight:function(){function a(){var a=f(e.$owlItems[e.currentItem]).height();e.wrapperOuter.css("height",a+"px");e.wrapperOuter.hasClass("autoHeight")||g.setTimeout(function(){e.wrapperOuter.addClass("autoHeight")},0)}function b(){d+=1;e.completeImg(c.get(0))?a():100>=d?g.setTimeout(b,
40
- 100):e.wrapperOuter.css("height","")}var e=this,c=f(e.$owlItems[e.currentItem]).find("img"),d;void 0!==c.get(0)?(d=0,b()):a()},completeImg:function(a){return!a.complete||"undefined"!==typeof a.naturalWidth&&0===a.naturalWidth?!1:!0},onVisibleItems:function(){var a;!0===this.options.addClassActive&&this.$owlItems.removeClass("active");this.visibleItems=[];for(a=this.currentItem;a<this.currentItem+this.options.items;a+=1)this.visibleItems.push(a),!0===this.options.addClassActive&&f(this.$owlItems[a]).addClass("active");
41
- this.owl.visibleItems=this.visibleItems},transitionTypes:function(a){this.outClass="owl-"+a+"-out";this.inClass="owl-"+a+"-in"},singleItemTransition:function(){var a=this,b=a.outClass,e=a.inClass,c=a.$owlItems.eq(a.currentItem),d=a.$owlItems.eq(a.prevItem),f=Math.abs(a.positionsInArray[a.currentItem])+a.positionsInArray[a.prevItem],g=Math.abs(a.positionsInArray[a.currentItem])+a.itemWidth/2;a.isTransition=!0;a.$owlWrapper.addClass("owl-origin").css({"-webkit-transform-origin":g+"px","-moz-perspective-origin":g+
42
- "px","perspective-origin":g+"px"});d.css({position:"relative",left:f+"px"}).addClass(b).on("webkitAnimationEnd oAnimationEnd MSAnimationEnd animationend",function(){a.endPrev=!0;d.off("webkitAnimationEnd oAnimationEnd MSAnimationEnd animationend");a.clearTransStyle(d,b)});c.addClass(e).on("webkitAnimationEnd oAnimationEnd MSAnimationEnd animationend",function(){a.endCurrent=!0;c.off("webkitAnimationEnd oAnimationEnd MSAnimationEnd animationend");a.clearTransStyle(c,e)})},clearTransStyle:function(a,
43
- b){a.css({position:"",left:""}).removeClass(b);this.endPrev&&this.endCurrent&&(this.$owlWrapper.removeClass("owl-origin"),this.isTransition=this.endCurrent=this.endPrev=!1)},owlStatus:function(){this.owl={userOptions:this.userOptions,baseElement:this.$elem,userItems:this.$userItems,owlItems:this.$owlItems,currentItem:this.currentItem,prevItem:this.prevItem,visibleItems:this.visibleItems,isTouch:this.browser.isTouch,browser:this.browser,dragDirection:this.dragDirection}},clearEvents:function(){this.$elem.off(".owl owl mousedown.disableTextSelect");
44
- f(k).off(".owl owl");f(g).off("resize",this.resizer)},unWrap:function(){0!==this.$elem.children().length&&(this.$owlWrapper.unwrap(),this.$userItems.unwrap().unwrap(),this.owlControls&&this.owlControls.remove());this.clearEvents();this.$elem.attr("style",this.$elem.data("owl-originalStyles")||"").attr("class",this.$elem.data("owl-originalClasses"))},destroy:function(){this.stop();g.clearInterval(this.checkVisible);this.unWrap();this.$elem.removeData()},reinit:function(a){a=f.extend({},this.userOptions,
45
- a);this.unWrap();this.init(a,this.$elem)},addItem:function(a,b){var e;if(!a)return!1;if(0===this.$elem.children().length)return this.$elem.append(a),this.setVars(),!1;this.unWrap();e=void 0===b||-1===b?-1:b;e>=this.$userItems.length||-1===e?this.$userItems.eq(-1).after(a):this.$userItems.eq(e).before(a);this.setVars()},removeItem:function(a){if(0===this.$elem.children().length)return!1;a=void 0===a||-1===a?-1:a;this.unWrap();this.$userItems.eq(a).remove();this.setVars()}};f.fn.owlCarousel=function(a){return this.each(function(){if(!0===
46
- f(this).data("owl-init"))return!1;f(this).data("owl-init",!0);var b=Object.create(l);b.init(a,this);f.data(this,"owlCarousel",b)})};f.fn.owlCarousel.options={items:5,itemsCustom:!1,itemsDesktop:[1199,4],itemsDesktopSmall:[979,3],itemsTablet:[768,2],itemsTabletSmall:!1,itemsMobile:[479,1],singleItem:!1,itemsScaleUp:!1,slideSpeed:200,paginationSpeed:800,rewindSpeed:1E3,autoPlay:!1,stopOnHover:!1,navigation:!1,navigationText:["prev","next"],rewindNav:!0,scrollPerPage:!1,pagination:!0,paginationNumbers:!1,
47
- responsive:!0,responsiveRefreshRate:200,responsiveBaseWidth:g,baseClass:"owl-carousel",theme:"owl-theme",lazyLoad:!1,lazyFollow:!0,lazyEffect:"fade",autoHeight:!1,jsonPath:!1,jsonSuccess:!1,dragBeforeAnimFinish:!0,mouseDrag:!0,touchDrag:!0,addClassActive:!1,transitionStyle:!1,beforeUpdate:!1,afterUpdate:!1,beforeInit:!1,afterInit:!1,beforeMove:!1,afterMove:!1,afterAction:!1,startDragging:!1,afterLazyLoad:!1}})(jQuery,window,document);
@@ -1,464 +0,0 @@
1
- /**
2
- * SVGInjector v1.1.3 - Fast, caching, dynamic inline SVG DOM injection library
3
- * https://github.com/iconic/SVGInjector
4
- *
5
- * Copyright (c) 2014-2015 Waybury <hello@waybury.com>
6
- * @license MIT
7
- */
8
-
9
- (function (window, document) {
10
-
11
- 'use strict';
12
-
13
- // Environment
14
- var isLocal = window.location.protocol === 'file:';
15
- var hasSvgSupport = document.implementation.hasFeature('http://www.w3.org/TR/SVG11/feature#BasicStructure', '1.1');
16
-
17
- function uniqueClasses(list) {
18
- list = list.split(' ');
19
-
20
- var hash = {};
21
- var i = list.length;
22
- var out = [];
23
-
24
- while (i--) {
25
- if (!hash.hasOwnProperty(list[i])) {
26
- hash[list[i]] = 1;
27
- out.unshift(list[i]);
28
- }
29
- }
30
-
31
- return out.join(' ');
32
- }
33
-
34
- /**
35
- * cache (or polyfill for <= IE8) Array.forEach()
36
- * source: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach
37
- */
38
- var forEach = Array.prototype.forEach || function (fn, scope) {
39
- if (this === void 0 || this === null || typeof fn !== 'function') {
40
- throw new TypeError();
41
- }
42
-
43
- /* jshint bitwise: false */
44
- var i, len = this.length >>> 0;
45
- /* jshint bitwise: true */
46
-
47
- for (i = 0; i < len; ++i) {
48
- if (i in this) {
49
- fn.call(scope, this[i], i, this);
50
- }
51
- }
52
- };
53
-
54
- // SVG Cache
55
- var svgCache = {};
56
-
57
- var injectCount = 0;
58
- var injectedElements = [];
59
-
60
- // Request Queue
61
- var requestQueue = [];
62
-
63
- // Script running status
64
- var ranScripts = {};
65
-
66
- var cloneSvg = function (sourceSvg) {
67
- return sourceSvg.cloneNode(true);
68
- };
69
-
70
- var queueRequest = function (url, callback) {
71
- requestQueue[url] = requestQueue[url] || [];
72
- requestQueue[url].push(callback);
73
- };
74
-
75
- var processRequestQueue = function (url) {
76
- for (var i = 0, len = requestQueue[url].length; i < len; i++) {
77
- // Make these calls async so we avoid blocking the page/renderer
78
- /* jshint loopfunc: true */
79
- (function (index) {
80
- setTimeout(function () {
81
- requestQueue[url][index](cloneSvg(svgCache[url]));
82
- }, 0);
83
- })(i);
84
- /* jshint loopfunc: false */
85
- }
86
- };
87
-
88
- var loadSvg = function (url, callback) {
89
- if (svgCache[url] !== undefined) {
90
- if (svgCache[url] instanceof SVGSVGElement) {
91
- // We already have it in cache, so use it
92
- callback(cloneSvg(svgCache[url]));
93
- }
94
- else {
95
- // We don't have it in cache yet, but we are loading it, so queue this request
96
- queueRequest(url, callback);
97
- }
98
- }
99
- else {
100
-
101
- if (!window.XMLHttpRequest) {
102
- callback('Browser does not support XMLHttpRequest');
103
- return false;
104
- }
105
-
106
- // Seed the cache to indicate we are loading this URL already
107
- svgCache[url] = {};
108
- queueRequest(url, callback);
109
-
110
- var httpRequest = new XMLHttpRequest();
111
-
112
- httpRequest.onreadystatechange = function () {
113
- // readyState 4 = complete
114
- if (httpRequest.readyState === 4) {
115
-
116
- // Handle status
117
- if (httpRequest.status === 404 || httpRequest.responseXML === null) {
118
- callback('Unable to load SVG file: ' + url);
119
-
120
- if (isLocal) callback('Note: SVG injection ajax calls do not work locally without adjusting security setting in your browser. Or consider using a local webserver.');
121
-
122
- callback();
123
- return false;
124
- }
125
-
126
- // 200 success from server, or 0 when using file:// protocol locally
127
- if (httpRequest.status === 200 || (isLocal && httpRequest.status === 0)) {
128
-
129
- /* globals Document */
130
- if (httpRequest.responseXML instanceof Document) {
131
- // Cache it
132
- svgCache[url] = httpRequest.responseXML.documentElement;
133
- }
134
- /* globals -Document */
135
-
136
- // IE9 doesn't create a responseXML Document object from loaded SVG,
137
- // and throws a "DOM Exception: HIERARCHY_REQUEST_ERR (3)" error when injected.
138
- //
139
- // So, we'll just create our own manually via the DOMParser using
140
- // the the raw XML responseText.
141
- //
142
- // :NOTE: IE8 and older doesn't have DOMParser, but they can't do SVG either, so...
143
- else if (DOMParser && (DOMParser instanceof Function)) {
144
- var xmlDoc;
145
- try {
146
- var parser = new DOMParser();
147
- xmlDoc = parser.parseFromString(httpRequest.responseText, 'text/xml');
148
- }
149
- catch (e) {
150
- xmlDoc = undefined;
151
- }
152
-
153
- if (!xmlDoc || xmlDoc.getElementsByTagName('parsererror').length) {
154
- callback('Unable to parse SVG file: ' + url);
155
- return false;
156
- }
157
- else {
158
- // Cache it
159
- svgCache[url] = xmlDoc.documentElement;
160
- }
161
- }
162
-
163
- // We've loaded a new asset, so process any requests waiting for it
164
- processRequestQueue(url);
165
- }
166
- else {
167
- callback('There was a problem injecting the SVG: ' + httpRequest.status + ' ' + httpRequest.statusText);
168
- return false;
169
- }
170
- }
171
- };
172
-
173
- httpRequest.open('GET', url);
174
-
175
- // Treat and parse the response as XML, even if the
176
- // server sends us a different mimetype
177
- if (httpRequest.overrideMimeType) httpRequest.overrideMimeType('text/xml');
178
-
179
- httpRequest.send();
180
- }
181
- };
182
-
183
- // Inject a single element
184
- var injectElement = function (el, evalScripts, pngFallback, callback) {
185
-
186
- // Grab the src or data-src attribute
187
- var imgUrl = el.getAttribute('data-src') || el.getAttribute('src');
188
-
189
- // We can only inject SVG
190
- if (!(/\.svg/i).test(imgUrl)) {
191
- callback('Attempted to inject a file with a non-svg extension: ' + imgUrl);
192
- return;
193
- }
194
-
195
- // If we don't have SVG support try to fall back to a png,
196
- // either defined per-element via data-fallback or data-png,
197
- // or globally via the pngFallback directory setting
198
- if (!hasSvgSupport) {
199
- var perElementFallback = el.getAttribute('data-fallback') || el.getAttribute('data-png');
200
-
201
- // Per-element specific PNG fallback defined, so use that
202
- if (perElementFallback) {
203
- el.setAttribute('src', perElementFallback);
204
- callback(null);
205
- }
206
- // Global PNG fallback directoriy defined, use the same-named PNG
207
- else if (pngFallback) {
208
- el.setAttribute('src', pngFallback + '/' + imgUrl.split('/').pop().replace('.svg', '.png'));
209
- callback(null);
210
- }
211
- // um...
212
- else {
213
- callback('This browser does not support SVG and no PNG fallback was defined.');
214
- }
215
-
216
- return;
217
- }
218
-
219
- // Make sure we aren't already in the process of injecting this element to
220
- // avoid a race condition if multiple injections for the same element are run.
221
- // :NOTE: Using indexOf() only _after_ we check for SVG support and bail,
222
- // so no need for IE8 indexOf() polyfill
223
- if (injectedElements.indexOf(el) !== -1) {
224
- return;
225
- }
226
-
227
- // Remember the request to inject this element, in case other injection
228
- // calls are also trying to replace this element before we finish
229
- injectedElements.push(el);
230
-
231
- // Try to avoid loading the orginal image src if possible.
232
- el.setAttribute('src', '');
233
-
234
- // Load it up
235
- loadSvg(imgUrl, function (svg) {
236
-
237
- if (typeof svg === 'undefined' || typeof svg === 'string') {
238
- callback(svg);
239
- return false;
240
- }
241
-
242
- var imgId = el.getAttribute('id');
243
- if (imgId) {
244
- svg.setAttribute('id', imgId);
245
- }
246
-
247
- var imgTitle = el.getAttribute('title');
248
- if (imgTitle) {
249
- svg.setAttribute('title', imgTitle);
250
- }
251
-
252
- // Concat the SVG classes + 'injected-svg' + the img classes
253
- var classMerge = [].concat(svg.getAttribute('class') || [], 'injected-svg', el.getAttribute('class') || []).join(' ');
254
- svg.setAttribute('class', uniqueClasses(classMerge));
255
-
256
- var imgStyle = el.getAttribute('style');
257
- if (imgStyle) {
258
- svg.setAttribute('style', imgStyle);
259
- }
260
-
261
- // Copy all the data elements to the svg
262
- var imgData = [].filter.call(el.attributes, function (at) {
263
- return (/^data-\w[\w\-]*$/).test(at.name);
264
- });
265
- forEach.call(imgData, function (dataAttr) {
266
- if (dataAttr.name && dataAttr.value) {
267
- svg.setAttribute(dataAttr.name, dataAttr.value);
268
- }
269
- });
270
-
271
- // Make sure any internally referenced clipPath ids and their
272
- // clip-path references are unique.
273
- //
274
- // This addresses the issue of having multiple instances of the
275
- // same SVG on a page and only the first clipPath id is referenced.
276
- //
277
- // Browsers often shortcut the SVG Spec and don't use clipPaths
278
- // contained in parent elements that are hidden, so if you hide the first
279
- // SVG instance on the page, then all other instances lose their clipping.
280
- // Reference: https://bugzilla.mozilla.org/show_bug.cgi?id=376027
281
-
282
- // Handle all defs elements that have iri capable attributes as defined by w3c: http://www.w3.org/TR/SVG/linking.html#processingIRI
283
- // Mapping IRI addressable elements to the properties that can reference them:
284
- var iriElementsAndProperties = {
285
- 'clipPath': ['clip-path'],
286
- 'color-profile': ['color-profile'],
287
- 'cursor': ['cursor'],
288
- 'filter': ['filter'],
289
- 'linearGradient': ['fill', 'stroke'],
290
- 'marker': ['marker', 'marker-start', 'marker-mid', 'marker-end'],
291
- 'mask': ['mask'],
292
- 'pattern': ['fill', 'stroke'],
293
- 'radialGradient': ['fill', 'stroke']
294
- };
295
-
296
- var element, elementDefs, properties, currentId, newId;
297
- Object.keys(iriElementsAndProperties).forEach(function (key) {
298
- element = key;
299
- properties = iriElementsAndProperties[key];
300
-
301
- elementDefs = svg.querySelectorAll('defs ' + element + '[id]');
302
- for (var i = 0, elementsLen = elementDefs.length; i < elementsLen; i++) {
303
- currentId = elementDefs[i].id;
304
- newId = currentId + '-' + injectCount;
305
-
306
- // All of the properties that can reference this element type
307
- var referencingElements;
308
- forEach.call(properties, function (property) {
309
- // :NOTE: using a substring match attr selector here to deal with IE "adding extra quotes in url() attrs"
310
- referencingElements = svg.querySelectorAll('[' + property + '*="' + currentId + '"]');
311
- for (var j = 0, referencingElementLen = referencingElements.length; j < referencingElementLen; j++) {
312
- referencingElements[j].setAttribute(property, 'url(#' + newId + ')');
313
- }
314
- });
315
-
316
- elementDefs[i].id = newId;
317
- }
318
- });
319
-
320
- // Remove any unwanted/invalid namespaces that might have been added by SVG editing tools
321
- svg.removeAttribute('xmlns:a');
322
-
323
- // Post page load injected SVGs don't automatically have their script
324
- // elements run, so we'll need to make that happen, if requested
325
-
326
- // Find then prune the scripts
327
- var scripts = svg.querySelectorAll('script');
328
- var scriptsToEval = [];
329
- var script, scriptType;
330
-
331
- for (var k = 0, scriptsLen = scripts.length; k < scriptsLen; k++) {
332
- scriptType = scripts[k].getAttribute('type');
333
-
334
- // Only process javascript types.
335
- // SVG defaults to 'application/ecmascript' for unset types
336
- if (!scriptType || scriptType === 'application/ecmascript' || scriptType === 'application/javascript') {
337
-
338
- // innerText for IE, textContent for other browsers
339
- script = scripts[k].innerText || scripts[k].textContent;
340
-
341
- // Stash
342
- scriptsToEval.push(script);
343
-
344
- // Tidy up and remove the script element since we don't need it anymore
345
- svg.removeChild(scripts[k]);
346
- }
347
- }
348
-
349
- // Run/Eval the scripts if needed
350
- if (scriptsToEval.length > 0 && (evalScripts === 'always' || (evalScripts === 'once' && !ranScripts[imgUrl]))) {
351
- for (var l = 0, scriptsToEvalLen = scriptsToEval.length; l < scriptsToEvalLen; l++) {
352
-
353
- // :NOTE: Yup, this is a form of eval, but it is being used to eval code
354
- // the caller has explictely asked to be loaded, and the code is in a caller
355
- // defined SVG file... not raw user input.
356
- //
357
- // Also, the code is evaluated in a closure and not in the global scope.
358
- // If you need to put something in global scope, use 'window'
359
- new Function(scriptsToEval[l])(window); // jshint ignore:line
360
- }
361
-
362
- // Remember we already ran scripts for this svg
363
- ranScripts[imgUrl] = true;
364
- }
365
-
366
- // :WORKAROUND:
367
- // IE doesn't evaluate <style> tags in SVGs that are dynamically added to the page.
368
- // This trick will trigger IE to read and use any existing SVG <style> tags.
369
- //
370
- // Reference: https://github.com/iconic/SVGInjector/issues/23
371
- var styleTags = svg.querySelectorAll('style');
372
- forEach.call(styleTags, function (styleTag) {
373
- styleTag.textContent += '';
374
- });
375
-
376
- // Replace the image with the svg
377
- el.parentNode.replaceChild(svg, el);
378
-
379
- // Now that we no longer need it, drop references
380
- // to the original element so it can be GC'd
381
- delete injectedElements[injectedElements.indexOf(el)];
382
- el = null;
383
-
384
- // Increment the injected count
385
- injectCount++;
386
-
387
- callback(svg);
388
- });
389
- };
390
-
391
- /**
392
- * SVGInjector
393
- *
394
- * Replace the given elements with their full inline SVG DOM elements.
395
- *
396
- * :NOTE: We are using get/setAttribute with SVG because the SVG DOM spec differs from HTML DOM and
397
- * can return other unexpected object types when trying to directly access svg properties.
398
- * ex: "className" returns a SVGAnimatedString with the class value found in the "baseVal" property,
399
- * instead of simple string like with HTML Elements.
400
- *
401
- * @param {mixes} Array of or single DOM element
402
- * @param {object} options
403
- * @param {function} callback
404
- * @return {object} Instance of SVGInjector
405
- */
406
- var SVGInjector = function (elements, options, done) {
407
-
408
- // Options & defaults
409
- options = options || {};
410
-
411
- // Should we run the scripts blocks found in the SVG
412
- // 'always' - Run them every time
413
- // 'once' - Only run scripts once for each SVG
414
- // [false|'never'] - Ignore scripts
415
- var evalScripts = options.evalScripts || 'always';
416
-
417
- // Location of fallback pngs, if desired
418
- var pngFallback = options.pngFallback || false;
419
-
420
- // Callback to run during each SVG injection, returning the SVG injected
421
- var eachCallback = options.each;
422
-
423
- // Do the injection...
424
- if (elements.length !== undefined) {
425
- var elementsLoaded = 0;
426
- forEach.call(elements, function (element) {
427
- injectElement(element, evalScripts, pngFallback, function (svg) {
428
- if (eachCallback && typeof eachCallback === 'function') eachCallback(svg);
429
- if (done && elements.length === ++elementsLoaded) done(elementsLoaded);
430
- });
431
- });
432
- }
433
- else {
434
- if (elements) {
435
- injectElement(elements, evalScripts, pngFallback, function (svg) {
436
- if (eachCallback && typeof eachCallback === 'function') eachCallback(svg);
437
- if (done) done(1);
438
- elements = null;
439
- });
440
- }
441
- else {
442
- if (done) done(0);
443
- }
444
- }
445
- };
446
-
447
- /* global module, exports: true, define */
448
- // Node.js or CommonJS
449
- if (typeof module === 'object' && typeof module.exports === 'object') {
450
- module.exports = exports = SVGInjector;
451
- }
452
- // AMD support
453
- else if (typeof define === 'function' && define.amd) {
454
- define(function () {
455
- return SVGInjector;
456
- });
457
- }
458
- // Otherwise, attach to window as global
459
- else if (typeof window === 'object') {
460
- window.SVGInjector = SVGInjector;
461
- }
462
- /* global -module, -exports, -define */
463
-
464
- }(window, document));