openseadragon 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 49ded4f5934b0c28ce5849b7f3e63cc287180e27
|
4
|
+
data.tar.gz: 866a1293d8bb5d330c76d6616cebeb4d1e17fdb5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ead6ec905ddcd5f12020b4233f2a4be9c5d66239cf378d88cd396b650b3ce30606a94f7a97fcc2aec07a8a09cdf7c58d6c7aff334575f0bf24a1a4a969365027
|
7
|
+
data.tar.gz: cb08cc979a049b35dc0edab0c00cd7e5f445d1c87df60e502feccc1ad574e01bfeccf312b68e16762a12b1fe0322aa692433a21ea1b94e868dd528fe9649a3d8
|
@@ -51,7 +51,7 @@ module Openseadragon
|
|
51
51
|
tile_sources = sources.map { |thing| extract_openseadragon_picture_tilesource(thing) }
|
52
52
|
|
53
53
|
picture_options[:data] ||= {}
|
54
|
-
picture_options[:data][:openseadragon]
|
54
|
+
picture_options[:data][:openseadragon] = osd_asset_defaults.merge(picture_options[:data][:openseadragon] || {}).to_json
|
55
55
|
|
56
56
|
picture_tag [tile_sources], { media: 'openseadragon' }.merge(source_options), picture_options
|
57
57
|
end
|
@@ -97,7 +97,7 @@ module Openseadragon
|
|
97
97
|
html_options.merge! src_options.fetch(:html, {})
|
98
98
|
html_options[:data] ||= {}
|
99
99
|
|
100
|
-
osd_options =
|
100
|
+
osd_options = html_options[:data][:openseadragon] || {}
|
101
101
|
osd_options.merge!(src_options.except(:html))
|
102
102
|
|
103
103
|
if src.respond_to? :to_tilesource
|
@@ -114,7 +114,7 @@ module Openseadragon
|
|
114
114
|
html_options[:data][:openseadragon] = osd_options.to_json
|
115
115
|
|
116
116
|
[ html_options.fetch(:src, src) => html_options ]
|
117
|
-
else
|
117
|
+
else # string
|
118
118
|
thing
|
119
119
|
end
|
120
120
|
end
|
@@ -44,63 +44,74 @@ describe Openseadragon::OpenseadragonHelper do
|
|
44
44
|
end
|
45
45
|
|
46
46
|
describe "#openseadragon_picture_tag" do
|
47
|
-
|
48
|
-
|
47
|
+
before { allow(helper).to receive(:osd_asset_defaults).and_return({b: 6}) }
|
48
|
+
|
49
|
+
context "with no args" do
|
50
|
+
subject { helper.openseadragon_picture_tag }
|
51
|
+
it "should mark the <picture> as an openseadragon tag" do
|
52
|
+
expect(subject).to match /picture data-openseadragon="#{helper.escape_once({b: 6}.to_json)}"/
|
53
|
+
end
|
49
54
|
end
|
50
55
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
56
|
+
context "with simple strings" do
|
57
|
+
subject { helper.openseadragon_picture_tag('image1.jpg', 'image2.jpg') }
|
58
|
+
|
59
|
+
it "should pass simple strings through" do
|
60
|
+
expect(subject).to have_selector 'picture source[src="image1.jpg"][media="openseadragon"]'
|
61
|
+
expect(subject).to have_selector 'picture source[src="image2.jpg"][media="openseadragon"]'
|
62
|
+
expect(subject).to match /picture data-openseadragon="#{helper.escape_once({b: 6}.to_json)}"/
|
63
|
+
end
|
55
64
|
end
|
56
65
|
|
57
66
|
context "with tilesource objects" do
|
67
|
+
subject { helper.openseadragon_picture_tag(double(to_tilesource: { a: 1})) }
|
58
68
|
it "should convert sources to tilesources" do
|
59
|
-
|
60
|
-
|
61
|
-
expect(
|
62
|
-
expect(response).to match /data-openseadragon="#{helper.escape_once({a: 1}.to_json)}"/
|
69
|
+
expect(subject).to have_selector 'picture source[src="openseadragon-tilesource"]'
|
70
|
+
expect(subject).to match /data-openseadragon="#{helper.escape_once({a: 1}.to_json)}"/
|
71
|
+
expect(subject).to match /picture data-openseadragon="#{helper.escape_once({b: 6}.to_json)}"/
|
63
72
|
end
|
64
73
|
end
|
65
74
|
|
66
75
|
context "with a source given as a hash" do
|
67
|
-
|
68
|
-
|
76
|
+
subject { helper.openseadragon_picture_tag(['image1.jpg' => { html: { id: 'xyz' }}]) }
|
69
77
|
it "should extract html options" do
|
70
|
-
|
71
|
-
expect(
|
78
|
+
expect(subject).to have_selector 'picture source[src="image1.jpg"][id="xyz"]'
|
79
|
+
expect(subject).to match /picture data-openseadragon="#{helper.escape_once({b: 6}.to_json)}"/
|
72
80
|
end
|
73
81
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
82
|
+
context "and extra options" do
|
83
|
+
subject { helper.openseadragon_picture_tag(['image1.jpg' => { a: 1}]) }
|
84
|
+
it "should pass the remaining options as encoded openseadragon options" do
|
85
|
+
expect(subject).to have_selector 'picture source[src="image1.jpg"]'
|
86
|
+
expect(subject).to have_selector 'picture source[src="image1.jpg"][data-openseadragon]'
|
87
|
+
expect(subject).to match /data-openseadragon="#{helper.escape_once({a: 1}.to_json)}"/
|
88
|
+
end
|
79
89
|
end
|
80
90
|
|
81
|
-
|
82
|
-
source
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
91
|
+
context "tielsource key and options" do
|
92
|
+
let(:source) { double(to_tilesource: { a: 1, b: 1}) }
|
93
|
+
subject { helper.openseadragon_picture_tag([source => { html: { id: 'xyz' }, b: 2, c: 3}]) }
|
94
|
+
it "should merge a tilesource key with the options provided" do
|
95
|
+
expect(subject).to have_selector 'picture source[src="openseadragon-tilesource"]'
|
96
|
+
expect(subject).to have_selector 'picture source[src="openseadragon-tilesource"][id="xyz"]'
|
97
|
+
expect(subject).to match /data-openseadragon="#{helper.escape_once({b: 2, c: 3, a: 1}.to_json)}"/
|
98
|
+
end
|
87
99
|
end
|
88
100
|
end
|
101
|
+
end
|
89
102
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
end
|
103
|
+
describe "#osd_asset_defaults" do
|
104
|
+
subject { helper.send(:osd_asset_defaults) }
|
105
|
+
its(['prefixUrl']) { should eq ''}
|
106
|
+
its(['navImages']) { should eq(
|
107
|
+
"zoomIn"=>{"REST"=>"/assets/openseadragon/zoomin_rest.png", "GROUP"=>"/assets/openseadragon/zoomin_grouphover.png", "HOVER"=>"/assets/openseadragon/zoomin_hover.png", "DOWN"=>"/assets/openseadragon/zoomin_pressed.png"},
|
108
|
+
"zoomOut"=>{"REST"=>"/assets/openseadragon/zoomout_rest.png", "GROUP"=>"/assets/openseadragon/zoomout_grouphover.png", "HOVER"=>"/assets/openseadragon/zoomout_hover.png", "DOWN"=>"/assets/openseadragon/zoomout_pressed.png"},
|
109
|
+
"home"=>{"REST"=>"/assets/openseadragon/home_rest.png", "GROUP"=>"/assets/openseadragon/home_grouphover.png", "HOVER"=>"/assets/openseadragon/home_hover.png", "DOWN"=>"/assets/openseadragon/home_pressed.png"},
|
110
|
+
"fullpage"=>{"REST"=>"/assets/openseadragon/fullpage_rest.png", "GROUP"=>"/assets/openseadragon/fullpage_grouphover.png", "HOVER"=>"/assets/openseadragon/fullpage_hover.png", "DOWN"=>"/assets/openseadragon/fullpage_pressed.png"},
|
111
|
+
"rotateleft"=>{"REST"=>"/assets/openseadragon/rotateleft_rest.png", "GROUP"=>"/assets/openseadragon/rotateleft_grouphover.png", "HOVER"=>"/assets/openseadragon/rotateleft_hover.png", "DOWN"=>"/assets/openseadragon/rotateleft_pressed.png"},
|
112
|
+
"rotateright"=>{"REST"=>"/assets/openseadragon/rotateright_rest.png", "GROUP"=>"/assets/openseadragon/rotateright_grouphover.png", "HOVER"=>"/assets/openseadragon/rotateright_hover.png", "DOWN"=>"/assets/openseadragon/rotateright_pressed.png"},
|
113
|
+
"previous"=>{"REST"=>"/assets/openseadragon/previous_rest.png", "GROUP"=>"/assets/openseadragon/previous_grouphover.png", "HOVER"=>"/assets/openseadragon/previous_hover.png", "DOWN"=>"/assets/openseadragon/previous_pressed.png"},
|
114
|
+
"next"=>{"REST"=>"/assets/openseadragon/next_rest.png", "GROUP"=>"/assets/openseadragon/next_grouphover.png", "HOVER"=>"/assets/openseadragon/next_hover.png", "DOWN"=>"/assets/openseadragon/next_pressed.png"}
|
115
|
+
)}
|
105
116
|
end
|
106
117
|
end
|