spree_product_hover_zoom 1.0.2
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 +15 -0
- data/.rspec +1 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/Gemfile +3 -0
- data/LICENSE +26 -0
- data/README.md +54 -0
- data/Rakefile +29 -0
- data/Versionfile +1 -0
- data/app/assets/images/zoom.gif +0 -0
- data/app/assets/javascripts/spree/backend/spree_product_hover_zoom.js +2 -0
- data/app/assets/javascripts/spree/frontend/spree_product_hover_zoom.js.coffee.erb +52 -0
- data/app/assets/stylesheets/spree/backend/spree_product_hover_zoom.css +4 -0
- data/app/assets/stylesheets/spree/frontend/spree_product_hover_zoom.css +25 -0
- data/app/models/spree/product_zoom_configuration.rb +3 -0
- data/app/overrides/spree/products/_thumbnails/add_lightbox_to_thumbnails.html.erb.deface +3 -0
- data/app/overrides/spree/products/_thumbnails/add_lightbox_to_thumbnails.html.erb.deface~HEAD +2 -0
- data/app/overrides/spree/products/_thumbnails/swap_product_variant_images.deface +3 -0
- data/app/overrides/spree/products/show.rb +6 -0
- data/app/views/spree/products/_hover_zoom.html.erb +1 -0
- data/app/views/spree/products/_image.html.erb +7 -0
- data/app/views/spree/products/_image0.html.erb +40 -0
- data/config/locales/en.yml +5 -0
- data/config/routes.rb +3 -0
- data/lib/generators/spree_product_hover_zoom/install/install_generator.rb +17 -0
- data/lib/spree_product_hover_zoom.rb +2 -0
- data/lib/spree_product_hover_zoom/engine.rb +34 -0
- data/lib/spree_product_hover_zoom/factories.rb +47 -0
- data/script/rails +7 -0
- data/spec/features/zoom_spec.rb +144 -0
- data/spec/products_images/1/mini/product1.jpg +0 -0
- data/spec/products_images/1/product/product1.jpg +0 -0
- data/spec/products_images/2/mini/product2.jpg +0 -0
- data/spec/products_images/2/product/product2.jpg +0 -0
- data/spec/products_images/3/mini/product1.jpg +0 -0
- data/spec/products_images/3/product/product1.jpg +0 -0
- data/spec/products_images/4/mini/product2.jpg +0 -0
- data/spec/products_images/4/product/product2.jpg +0 -0
- data/spec/products_images/info.txt +3 -0
- data/spec/spec_helper.rb +77 -0
- data/spree-zoom-on-hover.gif +0 -0
- data/spree_product_hover_zoom.gemspec +29 -0
- data/vendor/assets/images/store/blank.gif +0 -0
- data/vendor/assets/javascripts/drift.min.js +1 -0
- data/vendor/assets/javascripts/luminous.js +697 -0
- data/vendor/assets/stylesheets/drift-basic.css +151 -0
- data/vendor/assets/stylesheets/luminous-basic.css +195 -0
- metadata +245 -0
data/script/rails
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
2
|
+
|
3
|
+
ENGINE_ROOT = File.expand_path('../..', __FILE__)
|
4
|
+
ENGINE_PATH = File.expand_path('../../lib/spree_product_hover_zoom/engine', __FILE__)
|
5
|
+
|
6
|
+
require 'rails/all'
|
7
|
+
require 'rails/engine/commands'
|
@@ -0,0 +1,144 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
feature "gallery", :js => true do
|
4
|
+
|
5
|
+
before(:each) {
|
6
|
+
Capybara.default_selector = :css
|
7
|
+
|
8
|
+
products = Spree::Product.all
|
9
|
+
if (products.size == 0)
|
10
|
+
@product = create(:product1)
|
11
|
+
@opt_type = create(:option_type1)
|
12
|
+
end
|
13
|
+
}
|
14
|
+
|
15
|
+
scenario "product without options, two images" do
|
16
|
+
attach_images(@product.master)
|
17
|
+
|
18
|
+
visit "/products/#{@product.id}"
|
19
|
+
|
20
|
+
expect(page.evaluate_script 'typeof $.fancybox').to eq('function')
|
21
|
+
|
22
|
+
within("div#main-image") do
|
23
|
+
# ERROR zoom.gif is being overwritten here:
|
24
|
+
# javascript product.js.coffee
|
25
|
+
# showVariantImages ($('#main-image img')).attr('src', newImg);
|
26
|
+
page.should have_selector("img", count: 2)
|
27
|
+
# workaround is here:
|
28
|
+
# javascript zoom.js.coffee show_variant_images
|
29
|
+
# ($ 'img.click-to-zoom').attr 'src', "<%= asset_path('zoom.gif') %>"
|
30
|
+
page.should have_css("img.zoom-click", count: 1)
|
31
|
+
page.should have_css("img.click-to-zoom", count: 1)
|
32
|
+
|
33
|
+
show_gallery
|
34
|
+
|
35
|
+
page.should have_css("#gallery a.productid-#{@product.master.id}.fancybox", count: 2)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
scenario "product with option and one variant with two product master images" do
|
41
|
+
@product.option_types << @opt_type
|
42
|
+
variant1 = get_variant(1)
|
43
|
+
|
44
|
+
attach_images(@product.master)
|
45
|
+
expect(@product.images.length).to be(2)
|
46
|
+
|
47
|
+
visit "/products/#{@product.id}"
|
48
|
+
|
49
|
+
within("div#main-image") do
|
50
|
+
page.should have_css("img.click-to-zoom", count: 1)
|
51
|
+
|
52
|
+
show_gallery
|
53
|
+
|
54
|
+
page.should have_css("#gallery a", count: 2)
|
55
|
+
page.should have_css("#gallery a.productid-#{@product.master.id}.fancybox", count: 2)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
|
60
|
+
scenario "product with 2 variants and 2 attached images to the master and second variant" do
|
61
|
+
@product.option_types << @opt_type
|
62
|
+
|
63
|
+
variant1 = get_variant(1)
|
64
|
+
variant2 = get_variant(2)
|
65
|
+
|
66
|
+
attach_images(@product.master)
|
67
|
+
attach_images(variant2)
|
68
|
+
expect(@product.images.length).to eq(2)
|
69
|
+
expect(@product.variant_images.length).to eq(4)
|
70
|
+
|
71
|
+
visit "/products/#{@product.id}"
|
72
|
+
|
73
|
+
page.should have_css("img.click-to-zoom", count: 1)
|
74
|
+
|
75
|
+
show_gallery
|
76
|
+
|
77
|
+
# 2 from master, 2 from variant
|
78
|
+
page.should have_css("#gallery a", count: 4)
|
79
|
+
page.should have_css("#gallery a.master", count: 2)
|
80
|
+
page.should have_css("#gallery a.fancybox", count: 2)
|
81
|
+
page.should have_css("#gallery a.productid-#{@product.master.id}", count: 2)
|
82
|
+
page.should have_css("#gallery a.productid-#{variant2.id}", count: 2)
|
83
|
+
|
84
|
+
page.choose("variant_id_#{variant2.id}")
|
85
|
+
page.should have_css("#gallery a.fancybox", count: 4)
|
86
|
+
end
|
87
|
+
|
88
|
+
scenario "product with 2 variants and 2 attached images to each variant" do
|
89
|
+
@product.option_types << @opt_type
|
90
|
+
|
91
|
+
variant1 = get_variant(1)
|
92
|
+
variant2 = get_variant(2)
|
93
|
+
|
94
|
+
attach_images(variant1)
|
95
|
+
attach_images(variant2)
|
96
|
+
expect(@product.images.length).to eq(0)
|
97
|
+
expect(@product.variant_images.length).to eq(4)
|
98
|
+
|
99
|
+
visit "/products/#{@product.id}"
|
100
|
+
page.should have_css("img.click-to-zoom", count: 1)
|
101
|
+
|
102
|
+
show_gallery
|
103
|
+
|
104
|
+
page.should have_css("#gallery a", count: 4)
|
105
|
+
page.should have_css("#gallery a.master", count: 0)
|
106
|
+
page.should have_css("#gallery a.fancybox", count: 2)
|
107
|
+
page.should have_css("#gallery a.productid-#{variant1.id}.fancybox", count: 2)
|
108
|
+
page.should have_css("#gallery a.productid-#{variant2.id}", count: 2)
|
109
|
+
|
110
|
+
page.choose("variant_id_#{variant2.id}")
|
111
|
+
page.should have_css("#gallery a.fancybox", count: 2)
|
112
|
+
page.should have_css("#gallery a.productid-#{variant2.id}.fancybox", count: 2)
|
113
|
+
end
|
114
|
+
|
115
|
+
|
116
|
+
def show_gallery
|
117
|
+
# gallery is hidden, selenium-webdriver only knows visible elements
|
118
|
+
page.execute_script '$("#gallery").show()'
|
119
|
+
end
|
120
|
+
|
121
|
+
def get_variant(nr)
|
122
|
+
optnme = "option_value#{nr}"
|
123
|
+
opt_vlue = build(optnme.to_sym)
|
124
|
+
opt_vlue.option_type = @opt_type
|
125
|
+
opt_vlue.save
|
126
|
+
|
127
|
+
varnme = "variant#{nr}"
|
128
|
+
variant = build(varnme.to_sym)
|
129
|
+
variant.product = @product
|
130
|
+
variant.option_values << opt_vlue
|
131
|
+
variant.save
|
132
|
+
variant
|
133
|
+
end
|
134
|
+
|
135
|
+
def attach_images(product)
|
136
|
+
img = build(:image1)
|
137
|
+
img.viewable = product
|
138
|
+
img.save
|
139
|
+
|
140
|
+
img = build(:image2)
|
141
|
+
img.viewable = product
|
142
|
+
img.save
|
143
|
+
end
|
144
|
+
end
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
# Configure Rails Environment
|
2
|
+
ENV['RAILS_ENV'] = 'test'
|
3
|
+
|
4
|
+
require File.expand_path('../dummy/config/environment.rb', __FILE__)
|
5
|
+
|
6
|
+
require 'rspec/rails'
|
7
|
+
require 'database_cleaner'
|
8
|
+
require 'ffaker'
|
9
|
+
|
10
|
+
# Requires supporting ruby files with custom matchers and macros, etc,
|
11
|
+
# in spec/support/ and its subdirectories.
|
12
|
+
Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].each { |f| require f }
|
13
|
+
|
14
|
+
# Requires factories and other useful helpers defined in spree_core.
|
15
|
+
require 'spree/testing_support/authorization_helpers'
|
16
|
+
require 'spree/testing_support/capybara_ext'
|
17
|
+
require 'spree/testing_support/controller_requests'
|
18
|
+
require 'spree/testing_support/factories'
|
19
|
+
require 'spree/testing_support/url_helpers'
|
20
|
+
|
21
|
+
# Requires factories defined in lib/spree_product_hover_zoom/factories.rb
|
22
|
+
require 'spree_product_hover_zoom/factories'
|
23
|
+
|
24
|
+
RSpec.configure do |config|
|
25
|
+
config.include FactoryGirl::Syntax::Methods
|
26
|
+
|
27
|
+
# Infer an example group's spec type from the file location.
|
28
|
+
config.infer_spec_type_from_file_location!
|
29
|
+
|
30
|
+
# == URL Helpers
|
31
|
+
#
|
32
|
+
# Allows access to Spree's routes in specs:
|
33
|
+
#
|
34
|
+
# visit spree.admin_path
|
35
|
+
# current_path.should eql(spree.products_path)
|
36
|
+
config.include Spree::TestingSupport::UrlHelpers
|
37
|
+
|
38
|
+
# == Mock Framework
|
39
|
+
#
|
40
|
+
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
|
41
|
+
#
|
42
|
+
# config.mock_with :mocha
|
43
|
+
# config.mock_with :flexmock
|
44
|
+
# config.mock_with :rr
|
45
|
+
config.mock_with :rspec
|
46
|
+
config.color = true
|
47
|
+
|
48
|
+
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
49
|
+
config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
50
|
+
|
51
|
+
# Capybara javascript drivers require transactional fixtures set to false,
|
52
|
+
# and we use DatabaseCleaner to cleanup after each test instead.
|
53
|
+
# Without transactional fixtures set to false the records created
|
54
|
+
# to setup a test will be unavailable to the browser, which runs under
|
55
|
+
# a separate server instance.
|
56
|
+
config.use_transactional_fixtures = false
|
57
|
+
|
58
|
+
# Ensure Suite is set to use transactions for speed.
|
59
|
+
config.before :suite do
|
60
|
+
DatabaseCleaner.strategy = :transaction
|
61
|
+
DatabaseCleaner.clean_with :truncation
|
62
|
+
end
|
63
|
+
|
64
|
+
# Before each spec check if it is a Javascript test and switch between using database transactions or not where necessary.
|
65
|
+
config.before :each do
|
66
|
+
DatabaseCleaner.strategy = RSpec.current_example.metadata[:js] ? :truncation : :transaction
|
67
|
+
DatabaseCleaner.start
|
68
|
+
end
|
69
|
+
|
70
|
+
# After each spec clean the database.
|
71
|
+
config.after :each do
|
72
|
+
DatabaseCleaner.clean
|
73
|
+
end
|
74
|
+
|
75
|
+
config.fail_fast = ENV['FAIL_FAST'] || false
|
76
|
+
config.order = "random"
|
77
|
+
end
|
Binary file
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
Gem::Specification.new do |s|
|
3
|
+
s.platform = Gem::Platform::RUBY
|
4
|
+
s.name = 'spree_product_hover_zoom'
|
5
|
+
s.version = '1.0.2'
|
6
|
+
s.summary = 'A Spree extension that adds gallery view and zoom-on-hover functionality for product images.'
|
7
|
+
s.required_ruby_version = '>= 1.8.7'
|
8
|
+
|
9
|
+
s.author = 'Vinz Loh'
|
10
|
+
s.email = 'vincent.ml@gmail.com'
|
11
|
+
s.homepage = 'http://cloudcoder.com.my'
|
12
|
+
|
13
|
+
s.files = `git ls-files`.split("\n")
|
14
|
+
s.require_path = 'lib'
|
15
|
+
s.requirements << 'none'
|
16
|
+
|
17
|
+
s.add_dependency 'spree_core', '~> 3.2'
|
18
|
+
s.add_dependency 'spree_frontend', '~> 3.2'
|
19
|
+
|
20
|
+
s.add_development_dependency 'capybara', '~> 2.4'
|
21
|
+
s.add_development_dependency 'database_cleaner'
|
22
|
+
s.add_development_dependency 'factory_girl', '~> 4.5'
|
23
|
+
s.add_development_dependency 'ffaker'
|
24
|
+
s.add_development_dependency 'rspec-rails', '~> 3.1'
|
25
|
+
s.add_development_dependency 'sass-rails', '~> 5.0'
|
26
|
+
s.add_development_dependency 'coffee-rails', '4.2'
|
27
|
+
s.add_development_dependency 'selenium-webdriver'
|
28
|
+
s.add_development_dependency 'sqlite3'
|
29
|
+
end
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.Drift=e()}}(function(){return function e(t,n,i){function s(l,a){if(!n[l]){if(!t[l]){var r="function"==typeof require&&require;if(!a&&r)return r(l,!0);if(o)return o(l,!0);var h=new Error("Cannot find module '"+l+"'");throw h.code="MODULE_NOT_FOUND",h}var d=n[l]={exports:{}};t[l][0].call(d.exports,function(e){var n=t[l][1][e];return s(n?n:e)},d,d.exports,e,t,n,i)}return n[l].exports}for(var o="function"==typeof require&&require,l=0;l<i.length;l++)s(i[l]);return s}({1:[function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{"default":e}}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(n,"__esModule",{value:!0});var o=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),l=e("./util/throwIfMissing"),a=i(l),r=e("./util/dom"),h=function(){function e(t){s(this,e),this.isShowing=!1;var n=t.namespace,i=void 0===n?null:n,o=t.zoomFactor,l=void 0===o?(0,a["default"])():o,r=t.containerEl,h=void 0===r?(0,a["default"])():r;this.settings={namespace:i,zoomFactor:l,containerEl:h},this.openClasses=this._buildClasses("open"),this._buildElement()}return o(e,[{key:"_buildClasses",value:function(e){var t=["drift-"+e],n=this.settings.namespace;return n&&t.push(n+"-"+e),t}},{key:"_buildElement",value:function(){this.el=document.createElement("div"),(0,r.addClasses)(this.el,this._buildClasses("bounding-box"))}},{key:"show",value:function(e,t){this.isShowing=!0,this.settings.containerEl.appendChild(this.el);var n=this.el.style;n.width=Math.round(e/this.settings.zoomFactor)+"px",n.height=Math.round(t/this.settings.zoomFactor)+"px",(0,r.addClasses)(this.el,this.openClasses)}},{key:"hide",value:function(){this.isShowing&&this.settings.containerEl.removeChild(this.el),this.isShowing=!1,(0,r.removeClasses)(this.el,this.openClasses)}},{key:"setPosition",value:function(e,t,n){var i=window.pageXOffset,s=window.pageYOffset,o=n.left+e*n.width-this.el.clientWidth/2+i,l=n.top+t*n.height-this.el.clientHeight/2+s;this.el.getBoundingClientRect();o<n.left+i?o=n.left+i:o+this.el.clientWidth>n.left+n.width+i&&(o=n.left+n.width-this.el.clientWidth+i),l<n.top+s?l=n.top+s:l+this.el.clientHeight>n.top+n.height+s&&(l=n.top+n.height-this.el.clientHeight+s),this.el.style.left=o+"px",this.el.style.top=l+"px"}}]),e}();n["default"]=h},{"./util/dom":6,"./util/throwIfMissing":7}],2:[function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{"default":e}}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),l=e("./util/dom"),a=e("./injectBaseStylesheet"),r=i(a),h=e("./Trigger"),d=i(h),u=e("./ZoomPane"),c=i(u);t.exports=function(){function e(t){var n=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(s(this,e),this.VERSION="1.1.0",this.destroy=function(){n.trigger._unbindEvents()},this.triggerEl=t,!(0,l.isDOMElement)(this.triggerEl))throw new TypeError("`new Drift` requires a DOM element as its first argument.");var o=i.namespace,a=void 0===o?null:o,h=i.showWhitespaceAtEdges,d=void 0!==h&&h,u=i.containInline,c=void 0!==u&&u,f=i.inlineOffsetX,m=void 0===f?0:f,g=i.inlineOffsetY,v=void 0===g?0:g,p=i.inlineContainer,y=void 0===p?document.body:p,b=i.sourceAttribute,w=void 0===b?"data-zoom":b,_=i.zoomFactor,E=void 0===_?3:_,C=i.paneContainer,B=void 0===C?document.body:C,x=i.inlinePane,z=void 0===x?375:x,k=i.handleTouch,S=void 0===k||k,L=i.onShow,M=void 0===L?null:L,O=i.onHide,P=void 0===O?null:O,T=i.injectBaseStyles,D=void 0===T||T,H=i.hoverDelay,A=void 0===H?0:H,I=i.touchDelay,F=void 0===I?0:I,W=i.hoverBoundingBox,j=void 0!==W&&W,R=i.touchBoundingBox,X=void 0!==R&&R;if(z!==!0&&!(0,l.isDOMElement)(B))throw new TypeError("`paneContainer` must be a DOM element when `inlinePane !== true`");if(!(0,l.isDOMElement)(y))throw new TypeError("`inlineContainer` must be a DOM element");this.settings={namespace:a,showWhitespaceAtEdges:d,containInline:c,inlineOffsetX:m,inlineOffsetY:v,inlineContainer:y,sourceAttribute:w,zoomFactor:E,paneContainer:B,inlinePane:z,handleTouch:S,onShow:M,onHide:P,injectBaseStyles:D,hoverDelay:A,touchDelay:F,hoverBoundingBox:j,touchBoundingBox:X},this.settings.injectBaseStyles&&(0,r["default"])(),this._buildZoomPane(),this._buildTrigger()}return o(e,[{key:"_buildZoomPane",value:function(){this.zoomPane=new c["default"]({container:this.settings.paneContainer,zoomFactor:this.settings.zoomFactor,showWhitespaceAtEdges:this.settings.showWhitespaceAtEdges,containInline:this.settings.containInline,inline:this.settings.inlinePane,namespace:this.settings.namespace,inlineOffsetX:this.settings.inlineOffsetX,inlineOffsetY:this.settings.inlineOffsetY,inlineContainer:this.settings.inlineContainer})}},{key:"_buildTrigger",value:function(){this.trigger=new d["default"]({el:this.triggerEl,zoomPane:this.zoomPane,handleTouch:this.settings.handleTouch,onShow:this.settings.onShow,onHide:this.settings.onHide,sourceAttribute:this.settings.sourceAttribute,hoverDelay:this.settings.hoverDelay,touchDelay:this.settings.touchDelay,hoverBoundingBox:this.settings.hoverBoundingBox,touchBoundingBox:this.settings.touchBoundingBox,namespace:this.settings.namespace,zoomFactor:this.settings.zoomFactor})}},{key:"setZoomImageURL",value:function(e){this.zoomPane._setImageURL(e)}},{key:"disable",value:function(){this.trigger.enabled=!1}},{key:"enable",value:function(){this.trigger.enabled=!0}},{key:"isShowing",get:function(){return this.zoomPane.isShowing}},{key:"zoomFactor",get:function(){return this.settings.zoomFactor},set:function(e){this.settings.zoomFactor=e,this.zoomPane.settings.zoomFactor=e}}]),e}()},{"./Trigger":3,"./ZoomPane":4,"./injectBaseStylesheet":5,"./util/dom":6}],3:[function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{"default":e}}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(n,"__esModule",{value:!0});var o=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),l=e("./util/throwIfMissing"),a=i(l),r=e("./BoundingBox"),h=i(r),d=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};s(this,e),u.call(this);var n=t.el,i=void 0===n?(0,a["default"])():n,o=t.zoomPane,l=void 0===o?(0,a["default"])():o,r=t.sourceAttribute,d=void 0===r?(0,a["default"])():r,c=t.handleTouch,f=void 0===c?(0,a["default"])():c,m=t.onShow,g=void 0===m?null:m,v=t.onHide,p=void 0===v?null:v,y=t.hoverDelay,b=void 0===y?0:y,w=t.touchDelay,_=void 0===w?0:w,E=t.hoverBoundingBox,C=void 0===E?(0,a["default"])():E,B=t.touchBoundingBox,x=void 0===B?(0,a["default"])():B,z=t.namespace,k=void 0===z?null:z,S=t.zoomFactor,L=void 0===S?(0,a["default"])():S;this.settings={el:i,zoomPane:l,sourceAttribute:d,handleTouch:f,onShow:g,onHide:p,hoverDelay:b,touchDelay:_,hoverBoundingBox:C,touchBoundingBox:x,namespace:k,zoomFactor:L},(this.settings.hoverBoundingBox||this.settings.touchBoundingBox)&&(this.boundingBox=new h["default"]({namespace:this.settings.namespace,zoomFactor:this.settings.zoomFactor,containerEl:this.settings.el.offsetParent})),this.enabled=!0,this._bindEvents()}return o(e,[{key:"_bindEvents",value:function(){this.settings.el.addEventListener("mouseenter",this._handleEntry,!1),this.settings.el.addEventListener("mouseleave",this._hide,!1),this.settings.el.addEventListener("mousemove",this._handleMovement,!1),this.settings.handleTouch&&(this.settings.el.addEventListener("touchstart",this._handleEntry,!1),this.settings.el.addEventListener("touchend",this._hide,!1),this.settings.el.addEventListener("touchmove",this._handleMovement,!1))}},{key:"_unbindEvents",value:function(){this.settings.el.removeEventListener("mouseenter",this._handleEntry,!1),this.settings.el.removeEventListener("mouseleave",this._hide,!1),this.settings.el.removeEventListener("mousemove",this._handleMovement,!1),this.settings.handleTouch&&(this.settings.el.removeEventListener("touchstart",this._handleEntry,!1),this.settings.el.removeEventListener("touchend",this._hide,!1),this.settings.el.removeEventListener("touchmove",this._handleMovement,!1))}},{key:"isShowing",get:function(){return this.settings.zoomPane.isShowing}}]),e}(),u=function(){var e=this;this._handleEntry=function(t){t.preventDefault(),e._lastMovement=t,"mouseenter"==t.type&&e.settings.hoverDelay?e.entryTimeout=setTimeout(e._show,e.settings.hoverDelay):e.settings.touchDelay?e.entryTimeout=setTimeout(e._show,e.settings.touchDelay):e._show()},this._show=function(){if(e.enabled){var t=e.settings.onShow;if(t&&"function"==typeof t&&t(),e.settings.zoomPane.show(e.settings.el.getAttribute(e.settings.sourceAttribute),e.settings.el.clientWidth,e.settings.el.clientHeight),e._lastMovement){var n=e._lastMovement.touches;(n&&e.settings.touchBoundingBox||!n&&e.settings.hoverBoundingBox)&&e.boundingBox.show(e.settings.zoomPane.el.clientWidth,e.settings.zoomPane.el.clientHeight)}e._handleMovement()}},this._hide=function(t){t.preventDefault(),e._lastMovement=null,e.entryTimeout&&clearTimeout(e.entryTimeout),e.boundingBox&&e.boundingBox.hide();var n=e.settings.onHide;n&&"function"==typeof n&&n(),e.settings.zoomPane.hide()},this._handleMovement=function(t){if(t)t.preventDefault(),e._lastMovement=t;else{if(!e._lastMovement)return;t=e._lastMovement}var n=void 0,i=void 0;if(t.touches){var s=t.touches[0];n=s.clientX,i=s.clientY}else n=t.clientX,i=t.clientY;var o=e.settings.el,l=o.getBoundingClientRect(),a=n-l.left,r=i-l.top,h=a/e.settings.el.clientWidth,d=r/e.settings.el.clientHeight;e.boundingBox&&e.boundingBox.setPosition(h,d,l),e.settings.zoomPane.setPosition(h,d,l)}};n["default"]=d},{"./BoundingBox":1,"./util/throwIfMissing":7}],4:[function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{"default":e}}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(n,"__esModule",{value:!0});var o=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),l=e("./util/throwIfMissing"),a=i(l),r=e("./util/dom"),h=document.createElement("div").style,d="undefined"!=typeof document&&("animation"in h||"webkitAnimation"in h),u=function(){function e(){var t=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};s(this,e),this._completeShow=function(){t.el.removeEventListener("animationend",t._completeShow,!1),t.el.removeEventListener("webkitAnimationEnd",t._completeShow,!1),(0,r.removeClasses)(t.el,t.openingClasses)},this._completeHide=function(){t.el.removeEventListener("animationend",t._completeHide,!1),t.el.removeEventListener("webkitAnimationEnd",t._completeHide,!1),(0,r.removeClasses)(t.el,t.openClasses),(0,r.removeClasses)(t.el,t.closingClasses),(0,r.removeClasses)(t.el,t.inlineClasses),t.el.setAttribute("style",""),t.el.parentElement===t.settings.container?t.settings.container.removeChild(t.el):t.el.parentElement===t.settings.inlineContainer&&t.settings.inlineContainer.removeChild(t.el)},this._handleLoad=function(){t.imgEl.removeEventListener("load",t._handleLoad,!1),(0,r.removeClasses)(t.el,t.loadingClasses)},this.isShowing=!1;var i=n.container,o=void 0===i?null:i,l=n.zoomFactor,h=void 0===l?(0,a["default"])():l,d=n.inline,u=void 0===d?(0,a["default"])():d,c=n.namespace,f=void 0===c?null:c,m=n.showWhitespaceAtEdges,g=void 0===m?(0,a["default"])():m,v=n.containInline,p=void 0===v?(0,a["default"])():v,y=n.inlineOffsetX,b=void 0===y?0:y,w=n.inlineOffsetY,_=void 0===w?0:w,E=n.inlineContainer,C=void 0===E?document.body:E;this.settings={container:o,zoomFactor:h,inline:u,namespace:f,showWhitespaceAtEdges:g,containInline:p,inlineOffsetX:b,inlineOffsetY:_,inlineContainer:C},this.openClasses=this._buildClasses("open"),this.openingClasses=this._buildClasses("opening"),this.closingClasses=this._buildClasses("closing"),this.inlineClasses=this._buildClasses("inline"),this.loadingClasses=this._buildClasses("loading"),this._buildElement()}return o(e,[{key:"_buildClasses",value:function(e){var t=["drift-"+e],n=this.settings.namespace;return n&&t.push(n+"-"+e),t}},{key:"_buildElement",value:function(){this.el=document.createElement("div"),(0,r.addClasses)(this.el,this._buildClasses("zoom-pane"));var e=document.createElement("div");(0,r.addClasses)(e,this._buildClasses("zoom-pane-loader")),this.el.appendChild(e),this.imgEl=document.createElement("img"),this.el.appendChild(this.imgEl)}},{key:"_setImageURL",value:function(e){this.imgEl.setAttribute("src",e)}},{key:"_setImageSize",value:function(e,t){this.imgEl.style.width=e*this.settings.zoomFactor+"px",this.imgEl.style.height=t*this.settings.zoomFactor+"px"}},{key:"setPosition",value:function(e,t,n){var i=-(this.imgEl.clientWidth*e-this.el.clientWidth/2),s=-(this.imgEl.clientHeight*t-this.el.clientHeight/2),o=-(this.imgEl.clientWidth-this.el.clientWidth),l=-(this.imgEl.clientHeight-this.el.clientHeight);if(this.el.parentElement===this.settings.inlineContainer){var a=window.pageXOffset,r=window.pageYOffset,h=n.left+e*n.width-this.el.clientWidth/2+this.settings.inlineOffsetX+a,d=n.top+t*n.height-this.el.clientHeight/2+this.settings.inlineOffsetY+r;if(this.settings.containInline){this.el.getBoundingClientRect();h<n.left+a?h=n.left+a:h+this.el.clientWidth>n.left+n.width+a&&(h=n.left+n.width-this.el.clientWidth+a),d<n.top+r?d=n.top+r:d+this.el.clientHeight>n.top+n.height+r&&(d=n.top+n.height-this.el.clientHeight+r)}this.el.style.left=h+"px",this.el.style.top=d+"px"}this.settings.showWhitespaceAtEdges||(i>0?i=0:i<o&&(i=o),s>0?s=0:s<l&&(s=l)),this.imgEl.style.transform="translate("+i+"px, "+s+"px)",this.imgEl.style.webkitTransform="translate("+i+"px, "+s+"px)"}},{key:"_removeListenersAndResetClasses",value:function(){this.el.removeEventListener("animationend",this._completeShow,!1),this.el.removeEventListener("animationend",this._completeHide,!1),this.el.removeEventListener("webkitAnimationEnd",this._completeShow,!1),this.el.removeEventListener("webkitAnimationEnd",this._completeHide,!1),(0,r.removeClasses)(this.el,this.openClasses),(0,r.removeClasses)(this.el,this.closingClasses)}},{key:"show",value:function(e,t,n){this._removeListenersAndResetClasses(),this.isShowing=!0,(0,r.addClasses)(this.el,this.openClasses),(0,r.addClasses)(this.el,this.loadingClasses),this.imgEl.addEventListener("load",this._handleLoad,!1),this._setImageURL(e),this._setImageSize(t,n),this._isInline?this._showInline():this._showInContainer(),d&&(this.el.addEventListener("animationend",this._completeShow,!1),this.el.addEventListener("webkitAnimationEnd",this._completeShow,!1),(0,r.addClasses)(this.el,this.openingClasses))}},{key:"_showInline",value:function(){this.settings.inlineContainer.appendChild(this.el),(0,r.addClasses)(this.el,this.inlineClasses)}},{key:"_showInContainer",value:function(){this.settings.container.appendChild(this.el)}},{key:"hide",value:function(){this._removeListenersAndResetClasses(),this.isShowing=!1,d?(this.el.addEventListener("animationend",this._completeHide,!1),this.el.addEventListener("webkitAnimationEnd",this._completeHide,!1),(0,r.addClasses)(this.el,this.closingClasses)):((0,r.removeClasses)(this.el,this.openClasses),(0,r.removeClasses)(this.el,this.inlineClasses))}},{key:"_isInline",get:function(){var e=this.settings.inline;return e===!0||"number"==typeof e&&window.innerWidth<=e}}]),e}();n["default"]=u},{"./util/dom":6,"./util/throwIfMissing":7}],5:[function(e,t,n){"use strict";function i(){if(!document.querySelector(".drift-base-styles")){var e=document.createElement("style");e.type="text/css",e.classList.add("drift-base-styles"),e.appendChild(document.createTextNode(s));var t=document.head;t.insertBefore(e,t.firstChild)}}Object.defineProperty(n,"__esModule",{value:!0}),n["default"]=i;var s="\n@keyframes noop {\n 0% { zoom: 1; }\n}\n\n@-webkit-keyframes noop {\n 0% { zoom: 1; }\n}\n\n.drift-zoom-pane.drift-open {\n display: block;\n}\n\n.drift-zoom-pane.drift-opening, .drift-zoom-pane.drift-closing {\n animation: noop 1ms;\n -webkit-animation: noop 1ms;\n}\n\n.drift-zoom-pane {\n position: absolute;\n overflow: hidden;\n width: 100%;\n height: 100%;\n top: 0;\n left: 0;\n pointer-events: none;\n}\n\n.drift-zoom-pane-loader {\n display: none;\n}\n\n.drift-zoom-pane img {\n position: absolute;\n display: block;\n max-width: none;\n max-height: none;\n}\n\n.drift-bounding-box {\n position: absolute;\n pointer-events: none;\n}\n"},{}],6:[function(e,t,n){"use strict";function i(e){return r?e instanceof HTMLElement:e&&"object"===("undefined"==typeof e?"undefined":a(e))&&null!==e&&1===e.nodeType&&"string"==typeof e.nodeName}function s(e,t){t.forEach(function(t){e.classList.add(t)})}function o(e,t){t.forEach(function(t){e.classList.remove(t)})}var l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};Object.defineProperty(n,"__esModule",{value:!0});var a="function"==typeof Symbol&&"symbol"===l(Symbol.iterator)?function(e){return"undefined"==typeof e?"undefined":l(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":"undefined"==typeof e?"undefined":l(e)};n.isDOMElement=i,n.addClasses=s,n.removeClasses=o;var r="object"===("undefined"==typeof HTMLElement?"undefined":a(HTMLElement))},{}],7:[function(e,t,n){"use strict";function i(){throw new Error("Missing parameter")}Object.defineProperty(n,"__esModule",{value:!0}),n["default"]=i},{}]},{},[2])(2)});
|
@@ -0,0 +1,697 @@
|
|
1
|
+
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
|
2
|
+
'use strict';
|
3
|
+
|
4
|
+
var _typeof2 = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
5
|
+
|
6
|
+
Object.defineProperty(exports, "__esModule", {
|
7
|
+
value: true
|
8
|
+
});
|
9
|
+
|
10
|
+
var _typeof = typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol" ? function (obj) {
|
11
|
+
return typeof obj === "undefined" ? "undefined" : _typeof2(obj);
|
12
|
+
} : function (obj) {
|
13
|
+
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj === "undefined" ? "undefined" : _typeof2(obj);
|
14
|
+
};
|
15
|
+
|
16
|
+
var _createClass = function () {
|
17
|
+
function defineProperties(target, props) {
|
18
|
+
for (var i = 0; i < props.length; i++) {
|
19
|
+
var descriptor = props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if ("value" in descriptor) descriptor.writable = true;Object.defineProperty(target, descriptor.key, descriptor);
|
20
|
+
}
|
21
|
+
}return function (Constructor, protoProps, staticProps) {
|
22
|
+
if (protoProps) defineProperties(Constructor.prototype, protoProps);if (staticProps) defineProperties(Constructor, staticProps);return Constructor;
|
23
|
+
};
|
24
|
+
}();
|
25
|
+
|
26
|
+
var _dom = require('./util/dom');
|
27
|
+
|
28
|
+
var _throwIfMissing = require('./util/throwIfMissing');
|
29
|
+
|
30
|
+
var _throwIfMissing2 = _interopRequireDefault(_throwIfMissing);
|
31
|
+
|
32
|
+
function _interopRequireDefault(obj) {
|
33
|
+
return obj && obj.__esModule ? obj : { default: obj };
|
34
|
+
}
|
35
|
+
|
36
|
+
function _classCallCheck(instance, Constructor) {
|
37
|
+
if (!(instance instanceof Constructor)) {
|
38
|
+
throw new TypeError("Cannot call a class as a function");
|
39
|
+
}
|
40
|
+
}
|
41
|
+
|
42
|
+
var LEFT_ARROW = 37;
|
43
|
+
var RIGHT_ARROW = 39;
|
44
|
+
|
45
|
+
// All officially-supported browsers have this, but it's easy to
|
46
|
+
// account for, just in case.
|
47
|
+
var HAS_ANIMATION = typeof document === 'undefined' ? false : 'animation' in document.createElement('div').style;
|
48
|
+
|
49
|
+
var Lightbox = function () {
|
50
|
+
function Lightbox() {
|
51
|
+
var _this = this;
|
52
|
+
|
53
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
54
|
+
|
55
|
+
_classCallCheck(this, Lightbox);
|
56
|
+
|
57
|
+
this._sizeImgWrapperEl = function () {
|
58
|
+
var style = _this.imgWrapperEl.style;
|
59
|
+
style.width = _this.innerEl.clientWidth + 'px';
|
60
|
+
style.maxWidth = _this.innerEl.clientWidth + 'px';
|
61
|
+
style.height = _this.innerEl.clientHeight - _this.captionEl.clientHeight + 'px';
|
62
|
+
style.maxHeight = _this.innerEl.clientHeight - _this.captionEl.clientHeight + 'px';
|
63
|
+
};
|
64
|
+
|
65
|
+
this._handleKeydown = function (e) {
|
66
|
+
if (e.keyCode == LEFT_ARROW) {
|
67
|
+
_this.showPrevious();
|
68
|
+
} else if (e.keyCode == RIGHT_ARROW) {
|
69
|
+
_this.showNext();
|
70
|
+
}
|
71
|
+
};
|
72
|
+
|
73
|
+
this.showNext = function () {
|
74
|
+
if (!_this.settings._gallery) {
|
75
|
+
return;
|
76
|
+
}
|
77
|
+
|
78
|
+
_this.currentTrigger = _this.settings._gallery.nextTrigger(_this.currentTrigger);
|
79
|
+
_this._updateImgSrc();
|
80
|
+
_this._updateCaption();
|
81
|
+
_this._sizeImgWrapperEl();
|
82
|
+
};
|
83
|
+
|
84
|
+
this.showPrevious = function () {
|
85
|
+
if (!_this.settings._gallery) {
|
86
|
+
return;
|
87
|
+
}
|
88
|
+
|
89
|
+
_this.currentTrigger = _this.settings._gallery.previousTrigger(_this.currentTrigger);
|
90
|
+
_this._updateImgSrc();
|
91
|
+
_this._updateCaption();
|
92
|
+
_this._sizeImgWrapperEl();
|
93
|
+
};
|
94
|
+
|
95
|
+
this._completeOpen = function () {
|
96
|
+
_this.el.removeEventListener('animationend', _this._completeOpen, false);
|
97
|
+
|
98
|
+
(0, _dom.removeClasses)(_this.el, _this.openingClasses);
|
99
|
+
};
|
100
|
+
|
101
|
+
this._completeClose = function () {
|
102
|
+
_this.el.removeEventListener('animationend', _this._completeClose, false);
|
103
|
+
|
104
|
+
(0, _dom.removeClasses)(_this.el, _this.openClasses);
|
105
|
+
(0, _dom.removeClasses)(_this.el, _this.closingClasses);
|
106
|
+
};
|
107
|
+
|
108
|
+
var _options$namespace = options.namespace;
|
109
|
+
var namespace = _options$namespace === undefined ? null : _options$namespace;
|
110
|
+
var _options$parentEl = options.parentEl;
|
111
|
+
var parentEl = _options$parentEl === undefined ? (0, _throwIfMissing2.default)() : _options$parentEl;
|
112
|
+
var _options$triggerEl = options.triggerEl;
|
113
|
+
var triggerEl = _options$triggerEl === undefined ? (0, _throwIfMissing2.default)() : _options$triggerEl;
|
114
|
+
var _options$sourceAttrib = options.sourceAttribute;
|
115
|
+
var sourceAttribute = _options$sourceAttrib === undefined ? (0, _throwIfMissing2.default)() : _options$sourceAttrib;
|
116
|
+
var _options$caption = options.caption;
|
117
|
+
var caption = _options$caption === undefined ? null : _options$caption;
|
118
|
+
var _options$includeImgix = options.includeImgixJSClass;
|
119
|
+
var includeImgixJSClass = _options$includeImgix === undefined ? false : _options$includeImgix;
|
120
|
+
var _options$_gallery = options._gallery;
|
121
|
+
|
122
|
+
var _gallery = _options$_gallery === undefined ? null : _options$_gallery;
|
123
|
+
|
124
|
+
var _options$_arrowNaviga = options._arrowNavigation;
|
125
|
+
|
126
|
+
var _arrowNavigation = _options$_arrowNaviga === undefined ? null : _options$_arrowNaviga;
|
127
|
+
|
128
|
+
this.settings = { namespace: namespace, parentEl: parentEl, triggerEl: triggerEl, sourceAttribute: sourceAttribute, caption: caption, includeImgixJSClass: includeImgixJSClass, _gallery: _gallery, _arrowNavigation: _arrowNavigation };
|
129
|
+
|
130
|
+
if (!(0, _dom.isDOMElement)(this.settings.parentEl)) {
|
131
|
+
throw new TypeError('`new Lightbox` requires a DOM element passed as `parentEl`.');
|
132
|
+
}
|
133
|
+
|
134
|
+
this.currentTrigger = this.settings.triggerEl;
|
135
|
+
|
136
|
+
this.openClasses = this._buildClasses('open');
|
137
|
+
this.openingClasses = this._buildClasses('opening');
|
138
|
+
this.closingClasses = this._buildClasses('closing');
|
139
|
+
|
140
|
+
this.elementBuilt = false;
|
141
|
+
}
|
142
|
+
|
143
|
+
_createClass(Lightbox, [{
|
144
|
+
key: '_buildClasses',
|
145
|
+
value: function _buildClasses(suffix) {
|
146
|
+
var classes = ['lum-' + suffix];
|
147
|
+
|
148
|
+
var ns = this.settings.namespace;
|
149
|
+
if (ns) {
|
150
|
+
classes.push(ns + '-' + suffix);
|
151
|
+
}
|
152
|
+
|
153
|
+
return classes;
|
154
|
+
}
|
155
|
+
}, {
|
156
|
+
key: '_buildElement',
|
157
|
+
value: function _buildElement() {
|
158
|
+
this.el = document.createElement('div');
|
159
|
+
(0, _dom.addClasses)(this.el, this._buildClasses('lightbox'));
|
160
|
+
|
161
|
+
this.innerEl = document.createElement('div');
|
162
|
+
(0, _dom.addClasses)(this.innerEl, this._buildClasses('lightbox-inner'));
|
163
|
+
this.el.appendChild(this.innerEl);
|
164
|
+
|
165
|
+
var loaderEl = document.createElement('div');
|
166
|
+
(0, _dom.addClasses)(loaderEl, this._buildClasses('lightbox-loader'));
|
167
|
+
this.innerEl.appendChild(loaderEl);
|
168
|
+
|
169
|
+
this.imgWrapperEl = document.createElement('div');
|
170
|
+
(0, _dom.addClasses)(this.imgWrapperEl, this._buildClasses('lightbox-image-wrapper'));
|
171
|
+
this.innerEl.appendChild(this.imgWrapperEl);
|
172
|
+
|
173
|
+
var positionHelperEl = document.createElement('span');
|
174
|
+
(0, _dom.addClasses)(positionHelperEl, this._buildClasses('lightbox-position-helper'));
|
175
|
+
this.imgWrapperEl.appendChild(positionHelperEl);
|
176
|
+
|
177
|
+
this.imgEl = document.createElement('img');
|
178
|
+
(0, _dom.addClasses)(this.imgEl, this._buildClasses('img'));
|
179
|
+
positionHelperEl.appendChild(this.imgEl);
|
180
|
+
|
181
|
+
this.captionEl = document.createElement('p');
|
182
|
+
(0, _dom.addClasses)(this.captionEl, this._buildClasses('lightbox-caption'));
|
183
|
+
positionHelperEl.appendChild(this.captionEl);
|
184
|
+
|
185
|
+
if (this.settings._gallery) {
|
186
|
+
this._setUpGalleryElements();
|
187
|
+
}
|
188
|
+
|
189
|
+
this.settings.parentEl.appendChild(this.el);
|
190
|
+
|
191
|
+
this._updateImgSrc();
|
192
|
+
this._updateCaption();
|
193
|
+
|
194
|
+
if (this.settings.includeImgixJSClass) {
|
195
|
+
this.imgEl.classList.add('imgix-fluid');
|
196
|
+
}
|
197
|
+
}
|
198
|
+
}, {
|
199
|
+
key: '_setUpGalleryElements',
|
200
|
+
value: function _setUpGalleryElements() {
|
201
|
+
this._buildGalleryButton('previous', this.showPrevious);
|
202
|
+
this._buildGalleryButton('next', this.showNext);
|
203
|
+
}
|
204
|
+
}, {
|
205
|
+
key: '_buildGalleryButton',
|
206
|
+
value: function _buildGalleryButton(name, fn) {
|
207
|
+
var btn = document.createElement('button');
|
208
|
+
this[name + 'Button'] = btn;
|
209
|
+
|
210
|
+
btn.innerText = name;
|
211
|
+
(0, _dom.addClasses)(btn, this._buildClasses(name + '-button'));
|
212
|
+
(0, _dom.addClasses)(btn, this._buildClasses('gallery-button'));
|
213
|
+
this.innerEl.appendChild(btn);
|
214
|
+
|
215
|
+
btn.addEventListener('click', function (e) {
|
216
|
+
e.stopPropagation();
|
217
|
+
|
218
|
+
fn();
|
219
|
+
}, false);
|
220
|
+
}
|
221
|
+
}, {
|
222
|
+
key: '_updateCaption',
|
223
|
+
value: function _updateCaption() {
|
224
|
+
var captionType = _typeof(this.settings.caption);
|
225
|
+
var caption = '';
|
226
|
+
|
227
|
+
if (captionType === 'string') {
|
228
|
+
caption = this.settings.caption;
|
229
|
+
} else if (captionType === 'function') {
|
230
|
+
caption = this.settings.caption(this.currentTrigger);
|
231
|
+
}
|
232
|
+
|
233
|
+
this.captionEl.innerHTML = caption;
|
234
|
+
}
|
235
|
+
}, {
|
236
|
+
key: '_updateImgSrc',
|
237
|
+
value: function _updateImgSrc() {
|
238
|
+
var _this2 = this;
|
239
|
+
|
240
|
+
var imageURL = this.currentTrigger.getAttribute(this.settings.sourceAttribute);
|
241
|
+
|
242
|
+
if (!imageURL) {
|
243
|
+
throw new Error('No image URL was found in the ' + this.settings.sourceAttribute + ' attribute of the trigger.');
|
244
|
+
}
|
245
|
+
|
246
|
+
var loadingClasses = this._buildClasses('loading');
|
247
|
+
(0, _dom.addClasses)(this.el, loadingClasses);
|
248
|
+
this.imgEl.onload = function () {
|
249
|
+
(0, _dom.removeClasses)(_this2.el, loadingClasses);
|
250
|
+
};
|
251
|
+
|
252
|
+
this.imgEl.setAttribute('src', imageURL);
|
253
|
+
}
|
254
|
+
}, {
|
255
|
+
key: 'open',
|
256
|
+
value: function open() {
|
257
|
+
if (!this.elementBuilt) {
|
258
|
+
this._buildElement();
|
259
|
+
this.elementBuilt = true;
|
260
|
+
}
|
261
|
+
|
262
|
+
// When opening, always reset to the trigger we were passed
|
263
|
+
this.currentTrigger = this.settings.triggerEl;
|
264
|
+
|
265
|
+
// Make sure to re-set the `img` `src`, in case it's been changed
|
266
|
+
// by someone/something else.
|
267
|
+
this._updateImgSrc();
|
268
|
+
this._updateCaption();
|
269
|
+
|
270
|
+
(0, _dom.addClasses)(this.el, this.openClasses);
|
271
|
+
|
272
|
+
this._sizeImgWrapperEl();
|
273
|
+
window.addEventListener('resize', this._sizeImgWrapperEl, false);
|
274
|
+
|
275
|
+
if (this.settings._arrowNavigation) {
|
276
|
+
window.addEventListener('keydown', this._handleKeydown, false);
|
277
|
+
}
|
278
|
+
|
279
|
+
if (HAS_ANIMATION) {
|
280
|
+
this.el.addEventListener('animationend', this._completeOpen, false);
|
281
|
+
(0, _dom.addClasses)(this.el, this.openingClasses);
|
282
|
+
}
|
283
|
+
}
|
284
|
+
}, {
|
285
|
+
key: 'close',
|
286
|
+
value: function close() {
|
287
|
+
window.removeEventListener('resize', this._sizeImgWrapperEl, false);
|
288
|
+
|
289
|
+
if (this.settings._arrowNavigation) {
|
290
|
+
window.removeEventListener('keydown', this._handleKeydown, false);
|
291
|
+
}
|
292
|
+
|
293
|
+
if (HAS_ANIMATION) {
|
294
|
+
this.el.addEventListener('animationend', this._completeClose, false);
|
295
|
+
(0, _dom.addClasses)(this.el, this.closingClasses);
|
296
|
+
} else {
|
297
|
+
(0, _dom.removeClasses)(this.el, this.openClasses);
|
298
|
+
}
|
299
|
+
}
|
300
|
+
}, {
|
301
|
+
key: 'destroy',
|
302
|
+
value: function destroy() {
|
303
|
+
if (this.el) {
|
304
|
+
this.settings.parentEl.removeChild(this.el);
|
305
|
+
}
|
306
|
+
}
|
307
|
+
}]);
|
308
|
+
|
309
|
+
return Lightbox;
|
310
|
+
}();
|
311
|
+
|
312
|
+
exports.default = Lightbox;
|
313
|
+
|
314
|
+
},{"./util/dom":6,"./util/throwIfMissing":7}],2:[function(require,module,exports){
|
315
|
+
'use strict';
|
316
|
+
|
317
|
+
var _createClass = function () {
|
318
|
+
function defineProperties(target, props) {
|
319
|
+
for (var i = 0; i < props.length; i++) {
|
320
|
+
var descriptor = props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if ("value" in descriptor) descriptor.writable = true;Object.defineProperty(target, descriptor.key, descriptor);
|
321
|
+
}
|
322
|
+
}return function (Constructor, protoProps, staticProps) {
|
323
|
+
if (protoProps) defineProperties(Constructor.prototype, protoProps);if (staticProps) defineProperties(Constructor, staticProps);return Constructor;
|
324
|
+
};
|
325
|
+
}();
|
326
|
+
|
327
|
+
var _class, _temp, _initialiseProps;
|
328
|
+
|
329
|
+
var _dom = require('./util/dom');
|
330
|
+
|
331
|
+
var _injectBaseStylesheet = require('./injectBaseStylesheet');
|
332
|
+
|
333
|
+
var _injectBaseStylesheet2 = _interopRequireDefault(_injectBaseStylesheet);
|
334
|
+
|
335
|
+
var _Lightbox = require('./Lightbox');
|
336
|
+
|
337
|
+
var _Lightbox2 = _interopRequireDefault(_Lightbox);
|
338
|
+
|
339
|
+
function _interopRequireDefault(obj) {
|
340
|
+
return obj && obj.__esModule ? obj : { default: obj };
|
341
|
+
}
|
342
|
+
|
343
|
+
function _classCallCheck(instance, Constructor) {
|
344
|
+
if (!(instance instanceof Constructor)) {
|
345
|
+
throw new TypeError("Cannot call a class as a function");
|
346
|
+
}
|
347
|
+
}
|
348
|
+
|
349
|
+
module.exports = (_temp = _class = function () {
|
350
|
+
function Luminous(trigger) {
|
351
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
352
|
+
|
353
|
+
_classCallCheck(this, Luminous);
|
354
|
+
|
355
|
+
_initialiseProps.call(this);
|
356
|
+
|
357
|
+
this.isOpen = false;
|
358
|
+
|
359
|
+
this.trigger = trigger;
|
360
|
+
|
361
|
+
if (!(0, _dom.isDOMElement)(this.trigger)) {
|
362
|
+
throw new TypeError('`new Luminous` requires a DOM element as its first argument.');
|
363
|
+
}
|
364
|
+
|
365
|
+
// A bit unexpected if you haven't seen this pattern before.
|
366
|
+
// Based on the pattern here:
|
367
|
+
// https://github.com/getify/You-Dont-Know-JS/blob/master/es6%20&%20beyond/ch2.md#nested-defaults-destructured-and-restructured
|
368
|
+
var _options$namespace = options.namespace;
|
369
|
+
var namespace = _options$namespace === undefined ? null : _options$namespace;
|
370
|
+
var _options$sourceAttrib = options.sourceAttribute;
|
371
|
+
var sourceAttribute = _options$sourceAttrib === undefined ? 'href' : _options$sourceAttrib;
|
372
|
+
var _options$caption = options.caption;
|
373
|
+
var caption = _options$caption === undefined ? null : _options$caption;
|
374
|
+
var _options$openTrigger = options.openTrigger;
|
375
|
+
var openTrigger = _options$openTrigger === undefined ? 'click' : _options$openTrigger;
|
376
|
+
var _options$closeTrigger = options.closeTrigger;
|
377
|
+
var closeTrigger = _options$closeTrigger === undefined ? 'click' : _options$closeTrigger;
|
378
|
+
var _options$closeWithEsc = options.closeWithEscape;
|
379
|
+
var closeWithEscape = _options$closeWithEsc === undefined ? true : _options$closeWithEsc;
|
380
|
+
var _options$closeOnScrol = options.closeOnScroll;
|
381
|
+
var closeOnScroll = _options$closeOnScrol === undefined ? false : _options$closeOnScrol;
|
382
|
+
var _options$appendToSele = options.appendToSelector;
|
383
|
+
var appendToSelector = _options$appendToSele === undefined ? 'body' : _options$appendToSele;
|
384
|
+
var _options$onOpen = options.onOpen;
|
385
|
+
var onOpen = _options$onOpen === undefined ? null : _options$onOpen;
|
386
|
+
var _options$onClose = options.onClose;
|
387
|
+
var onClose = _options$onClose === undefined ? null : _options$onClose;
|
388
|
+
var _options$includeImgix = options.includeImgixJSClass;
|
389
|
+
var includeImgixJSClass = _options$includeImgix === undefined ? false : _options$includeImgix;
|
390
|
+
var _options$injectBaseSt = options.injectBaseStyles;
|
391
|
+
var injectBaseStyles = _options$injectBaseSt === undefined ? true : _options$injectBaseSt;
|
392
|
+
var _options$_gallery = options._gallery;
|
393
|
+
|
394
|
+
var _gallery = _options$_gallery === undefined ? null : _options$_gallery;
|
395
|
+
|
396
|
+
var _options$_arrowNaviga = options._arrowNavigation;
|
397
|
+
|
398
|
+
var _arrowNavigation = _options$_arrowNaviga === undefined ? null : _options$_arrowNaviga;
|
399
|
+
|
400
|
+
this.settings = { namespace: namespace, sourceAttribute: sourceAttribute, caption: caption, openTrigger: openTrigger, closeTrigger: closeTrigger, closeWithEscape: closeWithEscape, closeOnScroll: closeOnScroll, appendToSelector: appendToSelector, onOpen: onOpen, onClose: onClose, includeImgixJSClass: includeImgixJSClass, injectBaseStyles: injectBaseStyles, _gallery: _gallery, _arrowNavigation: _arrowNavigation };
|
401
|
+
|
402
|
+
if (this.settings.injectBaseStyles) {
|
403
|
+
(0, _injectBaseStylesheet2.default)();
|
404
|
+
}
|
405
|
+
|
406
|
+
this._buildLightbox();
|
407
|
+
this._bindEvents();
|
408
|
+
}
|
409
|
+
|
410
|
+
_createClass(Luminous, [{
|
411
|
+
key: '_buildLightbox',
|
412
|
+
value: function _buildLightbox() {
|
413
|
+
this.lightbox = new _Lightbox2.default({
|
414
|
+
namespace: this.settings.namespace,
|
415
|
+
parentEl: document.querySelector(this.settings.appendToSelector),
|
416
|
+
triggerEl: this.trigger,
|
417
|
+
sourceAttribute: this.settings.sourceAttribute,
|
418
|
+
caption: this.settings.caption,
|
419
|
+
includeImgixJSClass: this.settings.includeImgixJSClass,
|
420
|
+
_gallery: this.settings._gallery,
|
421
|
+
_arrowNavigation: this.settings._arrowNavigation
|
422
|
+
});
|
423
|
+
}
|
424
|
+
}, {
|
425
|
+
key: '_bindEvents',
|
426
|
+
value: function _bindEvents() {
|
427
|
+
this.trigger.addEventListener(this.settings.openTrigger, this.open, false);
|
428
|
+
|
429
|
+
if (this.settings.closeWithEscape) {
|
430
|
+
window.addEventListener('keyup', this._handleKeyup, false);
|
431
|
+
}
|
432
|
+
}
|
433
|
+
}, {
|
434
|
+
key: '_bindCloseEvent',
|
435
|
+
value: function _bindCloseEvent() {
|
436
|
+
this.lightbox.el.addEventListener(this.settings.closeTrigger, this.close, false);
|
437
|
+
}
|
438
|
+
}, {
|
439
|
+
key: '_unbindEvents',
|
440
|
+
value: function _unbindEvents() {
|
441
|
+
this.trigger.removeEventListener(this.settings.openTrigger, this.open, false);
|
442
|
+
if (this.lightbox.el) {
|
443
|
+
this.lightbox.el.removeEventListener(this.settings.closeTrigger, this.close, false);
|
444
|
+
}
|
445
|
+
|
446
|
+
if (this.settings.closeWithEscape) {
|
447
|
+
window.removeEventListener('keyup', this._handleKeyup, false);
|
448
|
+
}
|
449
|
+
}
|
450
|
+
}]);
|
451
|
+
|
452
|
+
return Luminous;
|
453
|
+
}(), _initialiseProps = function _initialiseProps() {
|
454
|
+
var _this = this;
|
455
|
+
|
456
|
+
this.VERSION = '1.0.1';
|
457
|
+
|
458
|
+
this.open = function (e) {
|
459
|
+
if (e && typeof e.preventDefault === 'function') {
|
460
|
+
e.preventDefault();
|
461
|
+
}
|
462
|
+
|
463
|
+
var previouslyBuilt = _this.lightbox.elementBuilt;
|
464
|
+
|
465
|
+
_this.lightbox.open();
|
466
|
+
|
467
|
+
if (!previouslyBuilt) {
|
468
|
+
_this._bindCloseEvent();
|
469
|
+
}
|
470
|
+
|
471
|
+
if (_this.settings.closeOnScroll) {
|
472
|
+
window.addEventListener('scroll', _this.close, false);
|
473
|
+
}
|
474
|
+
|
475
|
+
var onOpen = _this.settings.onOpen;
|
476
|
+
if (onOpen && typeof onOpen === 'function') {
|
477
|
+
onOpen();
|
478
|
+
}
|
479
|
+
|
480
|
+
_this.isOpen = true;
|
481
|
+
};
|
482
|
+
|
483
|
+
this.close = function (e) {
|
484
|
+
if (e && typeof e.preventDefault === 'function') {
|
485
|
+
e.preventDefault();
|
486
|
+
}
|
487
|
+
|
488
|
+
if (_this.settings.closeOnScroll) {
|
489
|
+
window.removeEventListener('scroll', _this.close, false);
|
490
|
+
}
|
491
|
+
|
492
|
+
_this.lightbox.close();
|
493
|
+
|
494
|
+
var onClose = _this.settings.onClose;
|
495
|
+
if (onClose && typeof onClose === 'function') {
|
496
|
+
onClose();
|
497
|
+
}
|
498
|
+
|
499
|
+
_this.isOpen = false;
|
500
|
+
};
|
501
|
+
|
502
|
+
this._handleKeyup = function (e) {
|
503
|
+
if (_this.isOpen && e.keyCode === 27) {
|
504
|
+
_this.close();
|
505
|
+
}
|
506
|
+
};
|
507
|
+
|
508
|
+
this.destroy = function () {
|
509
|
+
_this._unbindEvents();
|
510
|
+
_this.lightbox.destroy();
|
511
|
+
};
|
512
|
+
}, _temp);
|
513
|
+
|
514
|
+
},{"./Lightbox":1,"./injectBaseStylesheet":4,"./util/dom":6}],3:[function(require,module,exports){
|
515
|
+
'use strict';
|
516
|
+
|
517
|
+
Object.defineProperty(exports, "__esModule", {
|
518
|
+
value: true
|
519
|
+
});
|
520
|
+
|
521
|
+
var _createClass = function () {
|
522
|
+
function defineProperties(target, props) {
|
523
|
+
for (var i = 0; i < props.length; i++) {
|
524
|
+
var descriptor = props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if ("value" in descriptor) descriptor.writable = true;Object.defineProperty(target, descriptor.key, descriptor);
|
525
|
+
}
|
526
|
+
}return function (Constructor, protoProps, staticProps) {
|
527
|
+
if (protoProps) defineProperties(Constructor.prototype, protoProps);if (staticProps) defineProperties(Constructor, staticProps);return Constructor;
|
528
|
+
};
|
529
|
+
}();
|
530
|
+
|
531
|
+
var _dom = require('./util/dom');
|
532
|
+
|
533
|
+
var _Luminous = require('./Luminous');
|
534
|
+
|
535
|
+
var _Luminous2 = _interopRequireDefault(_Luminous);
|
536
|
+
|
537
|
+
function _interopRequireDefault(obj) {
|
538
|
+
return obj && obj.__esModule ? obj : { default: obj };
|
539
|
+
}
|
540
|
+
|
541
|
+
function _classCallCheck(instance, Constructor) {
|
542
|
+
if (!(instance instanceof Constructor)) {
|
543
|
+
throw new TypeError("Cannot call a class as a function");
|
544
|
+
}
|
545
|
+
}
|
546
|
+
|
547
|
+
var LuminousGallery = function () {
|
548
|
+
function LuminousGallery(triggers) {
|
549
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
550
|
+
var luminousOpts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
551
|
+
|
552
|
+
_classCallCheck(this, LuminousGallery);
|
553
|
+
|
554
|
+
this.boundMethod = function () {};
|
555
|
+
|
556
|
+
var _options$arrowNavigat = options.arrowNavigation;
|
557
|
+
var arrowNavigation = _options$arrowNavigat === undefined ? true : _options$arrowNavigat;
|
558
|
+
|
559
|
+
this.settings = { arrowNavigation: arrowNavigation };
|
560
|
+
|
561
|
+
this.triggers = triggers;
|
562
|
+
this.luminousOpts = luminousOpts;
|
563
|
+
this.luminousOpts._gallery = this;
|
564
|
+
this.luminousOpts._arrowNavigation = this.settings.arrowNavigation;
|
565
|
+
this._constructLuminousInstances();
|
566
|
+
}
|
567
|
+
|
568
|
+
_createClass(LuminousGallery, [{
|
569
|
+
key: '_constructLuminousInstances',
|
570
|
+
value: function _constructLuminousInstances() {
|
571
|
+
this.luminousInstances = [];
|
572
|
+
|
573
|
+
var triggerLen = this.triggers.length;
|
574
|
+
for (var i = 0; i < triggerLen; i++) {
|
575
|
+
var trigger = this.triggers[i];
|
576
|
+
var lum = new _Luminous2.default(trigger, this.luminousOpts);
|
577
|
+
this.luminousInstances.push(lum);
|
578
|
+
}
|
579
|
+
}
|
580
|
+
}, {
|
581
|
+
key: 'nextTrigger',
|
582
|
+
value: function nextTrigger(trigger) {
|
583
|
+
var nextTriggerIndex = Array.prototype.indexOf.call(this.triggers, trigger) + 1;
|
584
|
+
|
585
|
+
return nextTriggerIndex >= this.triggers.length ? this.triggers[0] : this.triggers[nextTriggerIndex];
|
586
|
+
}
|
587
|
+
}, {
|
588
|
+
key: 'previousTrigger',
|
589
|
+
value: function previousTrigger(trigger) {
|
590
|
+
var prevTriggerIndex = Array.prototype.indexOf.call(this.triggers, trigger) - 1;
|
591
|
+
|
592
|
+
return prevTriggerIndex < 0 ? this.triggers[this.triggers.length - 1] : this.triggers[prevTriggerIndex];
|
593
|
+
}
|
594
|
+
}, {
|
595
|
+
key: 'destroy',
|
596
|
+
value: function destroy() {}
|
597
|
+
}]);
|
598
|
+
|
599
|
+
return LuminousGallery;
|
600
|
+
}();
|
601
|
+
|
602
|
+
exports.default = LuminousGallery;
|
603
|
+
|
604
|
+
},{"./Luminous":2,"./util/dom":6}],4:[function(require,module,exports){
|
605
|
+
'use strict';
|
606
|
+
|
607
|
+
Object.defineProperty(exports, "__esModule", {
|
608
|
+
value: true
|
609
|
+
});
|
610
|
+
exports.default = injectBaseStylesheet;
|
611
|
+
var RULES = '\n@keyframes lum-noop {\n 0% { zoom: 1; }\n}\n\n.lum-lightbox {\n position: fixed;\n display: none;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n}\n\n.lum-lightbox.lum-open {\n display: block;\n}\n\n.lum-lightbox.lum-opening, .lum-lightbox.lum-closing {\n animation: lum-noop 1ms;\n}\n\n.lum-lightbox-inner {\n position: absolute;\n top: 0%;\n right: 0%;\n bottom: 0%;\n left: 0%;\n\n overflow: hidden;\n}\n\n.lum-lightbox-loader {\n display: none;\n}\n\n.lum-lightbox-inner img {\n max-width: 100%;\n max-height: 100%;\n}\n\n.lum-lightbox-image-wrapper {\n vertical-align: middle;\n display: table-cell;\n text-align: center;\n}\n';
|
612
|
+
|
613
|
+
function injectBaseStylesheet() {
|
614
|
+
if (document.querySelector('.lum-base-styles')) {
|
615
|
+
return;
|
616
|
+
}
|
617
|
+
|
618
|
+
var styleEl = document.createElement('style');
|
619
|
+
styleEl.type = 'text/css';
|
620
|
+
styleEl.classList.add('lum-base-styles');
|
621
|
+
|
622
|
+
styleEl.appendChild(document.createTextNode(RULES));
|
623
|
+
|
624
|
+
var head = document.head;
|
625
|
+
head.insertBefore(styleEl, head.firstChild);
|
626
|
+
}
|
627
|
+
|
628
|
+
},{}],5:[function(require,module,exports){
|
629
|
+
(function (global){
|
630
|
+
'use strict';
|
631
|
+
|
632
|
+
var _Luminous = require('./Luminous');
|
633
|
+
|
634
|
+
var _Luminous2 = _interopRequireDefault(_Luminous);
|
635
|
+
|
636
|
+
var _LuminousGallery = require('./LuminousGallery');
|
637
|
+
|
638
|
+
var _LuminousGallery2 = _interopRequireDefault(_LuminousGallery);
|
639
|
+
|
640
|
+
function _interopRequireDefault(obj) {
|
641
|
+
return obj && obj.__esModule ? obj : { default: obj };
|
642
|
+
}
|
643
|
+
|
644
|
+
global.Luminous = _Luminous2.default;
|
645
|
+
global.LuminousGallery = _LuminousGallery2.default;
|
646
|
+
|
647
|
+
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
648
|
+
},{"./Luminous":2,"./LuminousGallery":3}],6:[function(require,module,exports){
|
649
|
+
'use strict';
|
650
|
+
|
651
|
+
var _typeof2 = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
652
|
+
|
653
|
+
Object.defineProperty(exports, "__esModule", {
|
654
|
+
value: true
|
655
|
+
});
|
656
|
+
|
657
|
+
var _typeof = typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol" ? function (obj) {
|
658
|
+
return typeof obj === "undefined" ? "undefined" : _typeof2(obj);
|
659
|
+
} : function (obj) {
|
660
|
+
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj === "undefined" ? "undefined" : _typeof2(obj);
|
661
|
+
};
|
662
|
+
|
663
|
+
exports.isDOMElement = isDOMElement;
|
664
|
+
exports.addClasses = addClasses;
|
665
|
+
exports.removeClasses = removeClasses;
|
666
|
+
// This is not really a perfect check, but works fine.
|
667
|
+
// From http://stackoverflow.com/questions/384286
|
668
|
+
var HAS_DOM_2 = (typeof HTMLElement === 'undefined' ? 'undefined' : _typeof(HTMLElement)) === 'object';
|
669
|
+
|
670
|
+
function isDOMElement(obj) {
|
671
|
+
return HAS_DOM_2 ? obj instanceof HTMLElement : obj && (typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) === 'object' && obj !== null && obj.nodeType === 1 && typeof obj.nodeName === 'string';
|
672
|
+
}
|
673
|
+
|
674
|
+
function addClasses(el, classNames) {
|
675
|
+
classNames.forEach(function (className) {
|
676
|
+
el.classList.add(className);
|
677
|
+
});
|
678
|
+
}
|
679
|
+
|
680
|
+
function removeClasses(el, classNames) {
|
681
|
+
classNames.forEach(function (className) {
|
682
|
+
el.classList.remove(className);
|
683
|
+
});
|
684
|
+
}
|
685
|
+
|
686
|
+
},{}],7:[function(require,module,exports){
|
687
|
+
'use strict';
|
688
|
+
|
689
|
+
Object.defineProperty(exports, "__esModule", {
|
690
|
+
value: true
|
691
|
+
});
|
692
|
+
exports.default = throwIfMissing;
|
693
|
+
function throwIfMissing() {
|
694
|
+
throw new Error('Missing parameter');
|
695
|
+
}
|
696
|
+
|
697
|
+
},{}]},{},[5]);
|