ballonizer 0.6.0 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Rakefile +1 -1
- data/lib/assets/javascripts/ballonizer.js +104 -29
- data/lib/assets/stylesheets/ballonizer.css +3 -0
- data/lib/ballonizer.rb +23 -3
- data/spec/javascripts/ballonizer_spec.js +12 -12
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b3aa463bc872474ad1a3c7026aed2dc957f52814
|
4
|
+
data.tar.gz: a698fdd12b78996403a37dc938bd72f9ecfde3c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c242c148ec73d9d41e0ce702e7af3f288e85027920d00b9395361a5325a5ce8560bbddce6213b0ed4000ebf3fafe90023cd9660f316be7fe1e4a60d44b8c222
|
7
|
+
data.tar.gz: c2a5b76cabc58123e2778df531f4747e927607fbddd5ee30cfa02b8fe78c1c2bb92984ca63643482c2234e06b438bc0f8615bb07bd9290b72a18139e0058371f
|
data/Rakefile
CHANGED
@@ -13,7 +13,7 @@ end
|
|
13
13
|
RSpec::Core::RakeTask.new :spec
|
14
14
|
|
15
15
|
Jshintrb::JshintTask.new :jshint do |t|
|
16
|
-
t.pattern = '{lib/
|
16
|
+
t.pattern = '{lib/assets/javascripts/*.js,spec/javascripts/*.js}'
|
17
17
|
t.options = {
|
18
18
|
bitwise: true,
|
19
19
|
camelcase: true,
|
@@ -1,6 +1,12 @@
|
|
1
1
|
// Module pattern
|
2
2
|
(function (global) {
|
3
3
|
"use strict";
|
4
|
+
// We define these two variables as null to cause an error when the
|
5
|
+
// global version of these variables is accessed. This is used to enforce
|
6
|
+
// the use of the jQueryObject parameter of the ballonizer constructor.
|
7
|
+
var jQuery = null;
|
8
|
+
var $ = null;
|
9
|
+
|
4
10
|
var Ballonizer = (function () {
|
5
11
|
|
6
12
|
var htmlEscape = function (str) {
|
@@ -37,6 +43,10 @@
|
|
37
43
|
* match the container wrapped around each image to be ballonized.
|
38
44
|
* @param context A node or JQuery object. The Ballonizer will
|
39
45
|
* affect and see only inside of this node.
|
46
|
+
* @param jQueryObject The '$' or 'jQuery' variables defined by jQuery
|
47
|
+
* library. The object will use this object instead the global one.
|
48
|
+
* The main utility of this is allow the use of a different jQuery
|
49
|
+
* version that the used in the rest of the page scripts.
|
40
50
|
* @param config A hash with the config to be used in some
|
41
51
|
* situations:
|
42
52
|
* ballonInitialText: ballon text when the ballon is created (do
|
@@ -44,11 +54,15 @@
|
|
44
54
|
* to "double click to edit ballon text";
|
45
55
|
* submitButtonValue: text of the button who submits the changes
|
46
56
|
* in the ballons. Defaults to "Submit ballon changes";
|
57
|
+
* jQueryObject: a jQuery object to use instead of the global one,
|
58
|
+
* the main utility of this configuration is use multiple jQuery
|
59
|
+
* versions in the page.
|
47
60
|
* @return Ballonizer object
|
48
61
|
*/
|
49
62
|
Ballonizer = function (actionFormURL,
|
50
63
|
ballonizerContainerSelector,
|
51
64
|
context,
|
65
|
+
jQueryObject,
|
52
66
|
config) {
|
53
67
|
|
54
68
|
// Implicit constructor pattern
|
@@ -56,16 +70,28 @@
|
|
56
70
|
return new Ballonizer(actionFormURL,
|
57
71
|
ballonizerContainerSelector,
|
58
72
|
context,
|
73
|
+
jQueryObject,
|
59
74
|
config);
|
60
75
|
}
|
61
76
|
|
77
|
+
var defaultConfig = {
|
78
|
+
ballonInitialText: "double click to edit ballon text",
|
79
|
+
submitButtonValue: "Submit ballon changes"
|
80
|
+
};
|
81
|
+
|
82
|
+
if (jQueryObject) {
|
83
|
+
this.jQuery = jQueryObject;
|
84
|
+
} else {
|
85
|
+
throw new Ballonizer.Error(
|
86
|
+
"the parameter jQueryObject is null or undefined"
|
87
|
+
);
|
88
|
+
}
|
89
|
+
var $ = this.jQuery;
|
90
|
+
|
62
91
|
if (null == config) {
|
63
|
-
this.config =
|
64
|
-
ballonInitialText: "double click to edit ballon text",
|
65
|
-
submitButtonValue: "Submit ballon changes"
|
66
|
-
};
|
92
|
+
this.config = defaultConfig;
|
67
93
|
} else {
|
68
|
-
this.config = config;
|
94
|
+
this.config = $.extend({}, defaultConfig, config);
|
69
95
|
}
|
70
96
|
|
71
97
|
this.actionFormURL = actionFormURL;
|
@@ -76,7 +102,9 @@
|
|
76
102
|
var imageContainers = $(ballonizerContainerSelector, this.context);
|
77
103
|
imageContainers.each($.proxy(function (ix, element) {
|
78
104
|
var container = $(element);
|
79
|
-
var ballonizedContainer = new BallonizedImageContainer(
|
105
|
+
var ballonizedContainer = new BallonizedImageContainer(
|
106
|
+
this, container, jQueryObject
|
107
|
+
);
|
80
108
|
var imgSrc = $("img", container).prop("src");
|
81
109
|
|
82
110
|
this.ballonizedImages[imgSrc] = ballonizedContainer;
|
@@ -116,6 +144,8 @@
|
|
116
144
|
};
|
117
145
|
|
118
146
|
Ballonizer.prototype.generateBallonizerFormNode = function () {
|
147
|
+
var $ = this.jQuery;
|
148
|
+
var jQuery = this.jQuery;
|
119
149
|
var form = $("<form class='ballonizer_page_form' method='post' >" +
|
120
150
|
"<div><input name='ballonizer_data' type='hidden'>" +
|
121
151
|
"</input><input name='ballonizer_submit'" +
|
@@ -125,10 +155,32 @@
|
|
125
155
|
|
126
156
|
form.attr("action", this.actionFormURL);
|
127
157
|
|
158
|
+
// We find the greater z-index of a body direct child and
|
159
|
+
// increment this value by one (this way the form will not
|
160
|
+
// be hiiden behind another element)
|
161
|
+
var zIndexes = [];
|
162
|
+
$("body > *").each(function (ix, el) {
|
163
|
+
var zIndexCSS = $(el).css('z-index');
|
164
|
+
// the inherit is made numeric by the jQuery, we are
|
165
|
+
// filtering here only the "auto" string value
|
166
|
+
if (jQuery.isNumeric(zIndexCSS)) {
|
167
|
+
zIndexes.push(parseInt(zIndexCSS, 10));
|
168
|
+
}
|
169
|
+
});
|
170
|
+
var zIndex = null;
|
171
|
+
if (zIndexes.length > 0) {
|
172
|
+
zIndex = Math.max.apply(null, zIndexes) + 1;
|
173
|
+
} else {
|
174
|
+
zIndex = 1;
|
175
|
+
}
|
176
|
+
$("input[name='ballonizer_submit']", form).css("z-index", zIndex);
|
177
|
+
|
128
178
|
return form;
|
129
179
|
};
|
130
180
|
|
131
181
|
Ballonizer.prototype.notifyBallonChange = function () {
|
182
|
+
var $ = this.jQuery;
|
183
|
+
var jQuery = this.jQuery;
|
132
184
|
var submitButton = $("input[type='submit']", this.formNode);
|
133
185
|
var dataInput = $("input[type='hidden']", this.formNode);
|
134
186
|
|
@@ -142,6 +194,7 @@
|
|
142
194
|
};
|
143
195
|
|
144
196
|
Ballonizer.prototype.serialize = function () {
|
197
|
+
var jQuery = this.jQuery;
|
145
198
|
var serialization = {};
|
146
199
|
|
147
200
|
jQuery.each(this.ballonizedImages, function (ix, el) {
|
@@ -154,14 +207,19 @@
|
|
154
207
|
|
155
208
|
BallonizedImageContainer = (function () {
|
156
209
|
var BallonizedImageContainer = function (ballonizerInstance,
|
157
|
-
containerNode
|
210
|
+
containerNode,
|
211
|
+
jQueryObject) {
|
158
212
|
|
159
213
|
// Implicit constructor pattern
|
160
214
|
if (!(this instanceof BallonizedImageContainer)) {
|
161
215
|
return new BallonizedImageContainer(ballonizerInstance,
|
162
|
-
containerNode
|
216
|
+
containerNode,
|
217
|
+
jQueryObject);
|
163
218
|
}
|
164
219
|
|
220
|
+
this.jQuery = jQueryObject;
|
221
|
+
var $ = this.jQuery;
|
222
|
+
|
165
223
|
// See notifyBallonChange for this flag explanation
|
166
224
|
this.userAlreadyInteracted = false;
|
167
225
|
|
@@ -187,7 +245,9 @@
|
|
187
245
|
var ballons = $(".ballonizer_ballon", this.containerNode);
|
188
246
|
|
189
247
|
ballons.each($.proxy(function (ix, element) {
|
190
|
-
this.ballons.push(new InterfaceBallon(
|
248
|
+
this.ballons.push(new InterfaceBallon(
|
249
|
+
this, $(element), this.jQuery
|
250
|
+
));
|
191
251
|
}, this));
|
192
252
|
|
193
253
|
var img = $("img", this.containerNode);
|
@@ -217,6 +277,7 @@
|
|
217
277
|
// preserve the semantics of the ballon change be always from a user
|
218
278
|
// interaction.
|
219
279
|
BallonizedImageContainer.prototype.notifyBallonChange = function () {
|
280
|
+
var jQuery = this.jQuery;
|
220
281
|
// This flag is necessary to work around the load of the image.
|
221
282
|
// The ready callback don't wait for images to load and the
|
222
283
|
// load callback has several caveats with using images (see
|
@@ -242,7 +303,7 @@
|
|
242
303
|
};
|
243
304
|
|
244
305
|
BallonizedImageContainer.prototype.removeBallonFromList = function (ballon) {
|
245
|
-
var ix = jQuery.inArray(ballon, this.ballons);
|
306
|
+
var ix = this.jQuery.inArray(ballon, this.ballons);
|
246
307
|
this.ballons.splice(ix, 1);
|
247
308
|
|
248
309
|
this.notifyBallonChange();
|
@@ -274,7 +335,8 @@
|
|
274
335
|
var ballonWidth = 129, ballonHeight = 41;
|
275
336
|
var ballon = new InterfaceBallon(this, ballonX, ballonY,
|
276
337
|
ballonWidth, ballonHeight,
|
277
|
-
this.ballonizerInstance.getBallonInitialText()
|
338
|
+
this.ballonizerInstance.getBallonInitialText(),
|
339
|
+
this.jQuery);
|
278
340
|
|
279
341
|
this.ballons.push(ballon);
|
280
342
|
|
@@ -282,6 +344,8 @@
|
|
282
344
|
};
|
283
345
|
|
284
346
|
BallonizedImageContainer.prototype.serialize = function () {
|
347
|
+
var $ = this.jQuery;
|
348
|
+
var jQuery = this.jQuery;
|
285
349
|
/* jshint camelcase: false */
|
286
350
|
var serialization = {
|
287
351
|
// The img_src is out of style (not in camel case) because
|
@@ -302,28 +366,30 @@
|
|
302
366
|
})();
|
303
367
|
|
304
368
|
InterfaceBallon = (function () {
|
305
|
-
var InterfaceBallon = function (imgContainer, xOrNode,
|
306
|
-
height, initialText) {
|
369
|
+
var InterfaceBallon = function (imgContainer, xOrNode, yOrJQueryObject,
|
370
|
+
width, height, initialText, jQueryObject) {
|
307
371
|
|
308
372
|
// Implicit constructor pattern
|
309
373
|
if (!(this instanceof InterfaceBallon)) {
|
310
|
-
return new InterfaceBallon(imgContainer, xOrNode,
|
311
|
-
height, initialText);
|
374
|
+
return new InterfaceBallon(imgContainer, xOrNode, yOrJQueryObject, width,
|
375
|
+
height, initialText, jQueryObject);
|
312
376
|
}
|
313
377
|
|
314
378
|
this.imgContainer = imgContainer;
|
315
379
|
this.state = "initial";
|
316
380
|
|
317
|
-
if (
|
381
|
+
if (3 === arguments.length) {
|
318
382
|
this.node = xOrNode;
|
383
|
+
this.jQuery = yOrJQueryObject;
|
319
384
|
this.updatePositionAndSize();
|
320
385
|
this.fontSize = parseInt(this.node.css('font-size'), 10);
|
321
386
|
this.text = this.node.text();
|
322
387
|
} else {
|
323
388
|
this.left = xOrNode;
|
324
|
-
this.top =
|
389
|
+
this.top = yOrJQueryObject;
|
325
390
|
this.width = width;
|
326
391
|
this.height = height;
|
392
|
+
this.jQuery = jQueryObject;
|
327
393
|
var containerNode = this.imgContainer.getContainerNode();
|
328
394
|
|
329
395
|
// The ifs purpose are avoid the ballon of being created
|
@@ -352,6 +418,8 @@
|
|
352
418
|
this.changeFontSizeToBestFitBallon();
|
353
419
|
}
|
354
420
|
|
421
|
+
var $ = this.jQuery;
|
422
|
+
|
355
423
|
this.node.draggable({
|
356
424
|
containment: "parent",
|
357
425
|
opacity: 0.5,
|
@@ -403,6 +471,7 @@
|
|
403
471
|
};
|
404
472
|
|
405
473
|
InterfaceBallon.prototype.generateBallonNode = function () {
|
474
|
+
var $ = this.jQuery;
|
406
475
|
var nodeStyle = ["left: ", this.left, "px; ", "top: ",
|
407
476
|
this.top, "px; ", "width: ", this.width, "px; ",
|
408
477
|
"height: ", this.height, "px;"].join("");
|
@@ -426,17 +495,17 @@
|
|
426
495
|
};
|
427
496
|
};
|
428
497
|
InterfaceBallon.prototype.changeFontSizeToBestFitBallon = function () {
|
429
|
-
var
|
430
|
-
var
|
498
|
+
var oldHeight = this.node.css('height');
|
499
|
+
var desiredCalcHeight = this.node.height();
|
431
500
|
this.node.css('height', 'auto');
|
432
|
-
var
|
433
|
-
this.node.css('font-size',
|
434
|
-
while (this.node.height() <
|
435
|
-
this.node.css('font-size', ++
|
501
|
+
var actualFontSize = 1;
|
502
|
+
this.node.css('font-size', actualFontSize);
|
503
|
+
while (this.node.height() < desiredCalcHeight) {
|
504
|
+
this.node.css('font-size', ++actualFontSize + 'px');
|
436
505
|
}
|
437
|
-
this.node.css('font-size', --
|
438
|
-
this.node.css('height',
|
439
|
-
this.fontSize =
|
506
|
+
this.node.css('font-size', --actualFontSize + 'px');
|
507
|
+
this.node.css('height', oldHeight);
|
508
|
+
this.fontSize = actualFontSize;
|
440
509
|
};
|
441
510
|
InterfaceBallon.prototype.updatePositionAndSize = function () {
|
442
511
|
var newX = this.node.position().left;
|
@@ -512,6 +581,8 @@
|
|
512
581
|
};
|
513
582
|
|
514
583
|
InterfaceBallon.prototype.dblclick = function () {
|
584
|
+
var $ = this.jQuery;
|
585
|
+
var jQuery = this.jQuery;
|
515
586
|
this.state = this.state.replace("initial", "edit");
|
516
587
|
|
517
588
|
var context = this.imgContainer.getBallonizerInstance().getContext();
|
@@ -528,7 +599,7 @@
|
|
528
599
|
// the inherit is made numeric by the jQuery, we are
|
529
600
|
// filtering here only the "auto" string value
|
530
601
|
if (jQuery.isNumeric(zIndexCSS)) {
|
531
|
-
zIndexes.push(parseInt(zIndexCSS));
|
602
|
+
zIndexes.push(parseInt(zIndexCSS, 10));
|
532
603
|
}
|
533
604
|
});
|
534
605
|
var zIndex = null;
|
@@ -575,8 +646,12 @@
|
|
575
646
|
top: this.top / containerHeight,
|
576
647
|
width: this.width / containerWidth,
|
577
648
|
height: this.height / containerHeight,
|
578
|
-
|
579
|
-
|
649
|
+
text: this.text,
|
650
|
+
/* jshint camelcase: false */
|
651
|
+
// The fontSize is out of style (not in camel case) because
|
652
|
+
// it will be submitted to the ruby, and i'm giving
|
653
|
+
// preference to the ruby convention when in conflict
|
654
|
+
font_size: this.fontSize
|
580
655
|
};
|
581
656
|
};
|
582
657
|
|
@@ -17,6 +17,7 @@
|
|
17
17
|
display: block;
|
18
18
|
word-wrap: break-word;
|
19
19
|
overflow: hidden;
|
20
|
+
border-radius: 50% 50%;
|
20
21
|
}
|
21
22
|
|
22
23
|
.ballonizer_ballon_hidden_for_edition
|
@@ -79,5 +80,7 @@
|
|
79
80
|
position: fixed;
|
80
81
|
top: 0;
|
81
82
|
right: 0;
|
83
|
+
width: auto;
|
84
|
+
height: auto;
|
82
85
|
}
|
83
86
|
|
data/lib/ballonizer.rb
CHANGED
@@ -55,6 +55,16 @@ require 'sprockets'
|
|
55
55
|
# ballonized_image_ballons.
|
56
56
|
#
|
57
57
|
# Changelog:
|
58
|
+
# v0.6.1
|
59
|
+
# * Add the jquery_no_conflict option. If this option is true the
|
60
|
+
# js_load_snippet will restore any previous loaded version of
|
61
|
+
# jQuery after the ballonizer javascript client code already
|
62
|
+
# referenced the latest loaded version (use this option if the page
|
63
|
+
# already use a jQuery version that's different from the used by
|
64
|
+
# the gem, and you use the add_required_js_libs_for_edition and
|
65
|
+
# add_js_for_edition options).
|
66
|
+
# v0.6.0
|
67
|
+
# * Change the jQuery version provided by the gem to the 1.10.2
|
58
68
|
# v0.5.1:
|
59
69
|
# * js_load_snippet can take a settings arg too. Fixed ballonize_page to
|
60
70
|
# use the :form_handler_url from the settings argument.
|
@@ -193,7 +203,11 @@ class Ballonizer
|
|
193
203
|
# If true and the database argument don't have any of the tables used by
|
194
204
|
# the class call create_tables over the database argument. If false or the
|
195
205
|
# database has at leat one of the tables does nothing.
|
196
|
-
create_tables_if_none: false
|
206
|
+
create_tables_if_none: false,
|
207
|
+
# Use the jQuery.noConflict to restore any previous loaded version of the
|
208
|
+
# jQuery in a ballonized page. Only works with add_js_for_edition, and
|
209
|
+
# probably only makes sense with add_required_js_libs_for_edition.
|
210
|
+
jquery_no_conflict: false
|
197
211
|
}.freeze.each { | _, v| v.freeze }
|
198
212
|
|
199
213
|
USED_TABLES = [ :images, :ballons, :ballonized_image_ballons,
|
@@ -497,13 +511,19 @@ class Ballonizer
|
|
497
511
|
# @return [String] The added snippet. Already with the <script/> tag around it.
|
498
512
|
def js_load_snippet(settings = {})
|
499
513
|
settings = @settings.merge(settings)
|
514
|
+
# We create a reference to the jQuery because the global variable can be
|
515
|
+
# cleaned by the jQuery.noConflict(true), if the jquery_no_conflict
|
516
|
+
# setting is defined
|
500
517
|
<<-EOF
|
501
518
|
<script type="text/javascript">
|
502
|
-
|
519
|
+
var jQueryReference = jQuery;
|
520
|
+
jQueryReference(document).ready(function() {
|
503
521
|
Ballonizer('#{settings[:form_handler_url]}',
|
504
522
|
'.ballonizer_image_container',
|
505
|
-
|
523
|
+
jQueryReference('body'),
|
524
|
+
jQueryReference);
|
506
525
|
})
|
526
|
+
#{ 'jQuery.noConflict(true); ' if settings[:jquery_no_conflict] }
|
507
527
|
</script>
|
508
528
|
EOF
|
509
529
|
end
|
@@ -65,24 +65,24 @@ describe("Ballonizer", function () {
|
|
65
65
|
describe("but none in the context", function () {
|
66
66
|
it("doesn't create a form", function () {
|
67
67
|
loadFixtures("ballonized-xkcd-without-ballons.html");
|
68
|
-
Ballonizer(actionFormURL, imageToBallonizeCSSSelector, $("#bottom"));
|
68
|
+
Ballonizer(actionFormURL, imageToBallonizeCSSSelector, $("#bottom"), $);
|
69
69
|
expect($("form.ballonizer_page_form")).not.toExist();
|
70
70
|
});
|
71
71
|
it(".getForm return null", function () {
|
72
|
-
instance = Ballonizer(actionFormURL, imageToBallonizeCSSSelector, $("#bottom"));
|
72
|
+
instance = Ballonizer(actionFormURL, imageToBallonizeCSSSelector, $("#bottom"), $);
|
73
73
|
expect(instance.getForm()).toEqual(null);
|
74
74
|
});
|
75
75
|
});
|
76
76
|
describe("and they are in the context", function () {
|
77
77
|
it("create a hidden form as the last child of the context", function () {
|
78
78
|
loadFixtures("ballonized-xkcd-without-ballons.html");
|
79
|
-
Ballonizer(actionFormURL, imageToBallonizeCSSSelector, $("#jasmine-fixtures"));
|
79
|
+
Ballonizer(actionFormURL, imageToBallonizeCSSSelector, $("#jasmine-fixtures"), $);
|
80
80
|
expect($("#jasmine-fixtures")).toHaveBallonizerForm(actionFormURL);
|
81
81
|
expect($("form.ballonizer_page_form")).toBeHidden();
|
82
82
|
});
|
83
83
|
it("changes in .getForm result affect the node in the DOM", function () {
|
84
84
|
loadFixtures("ballonized-xkcd-without-ballons.html");
|
85
|
-
instance = Ballonizer(actionFormURL, imageToBallonizeCSSSelector, $("#jasmine-fixtures"));
|
85
|
+
instance = Ballonizer(actionFormURL, imageToBallonizeCSSSelector, $("#jasmine-fixtures"), $);
|
86
86
|
instance.getForm().attr("method", "get");
|
87
87
|
expect($("form.ballonizer_page_form")).toHaveAttr("method", "get");
|
88
88
|
});
|
@@ -90,7 +90,7 @@ describe("Ballonizer", function () {
|
|
90
90
|
describe("when the ballonized image is double clicked", function () {
|
91
91
|
it("a new ballon will be created", function () {
|
92
92
|
loadFixtures("ballonized-xkcd-without-ballons.html");
|
93
|
-
instance = Ballonizer(actionFormURL, imageToBallonizeCSSSelector, $("#jasmine-fixtures"));
|
93
|
+
instance = Ballonizer(actionFormURL, imageToBallonizeCSSSelector, $("#jasmine-fixtures"), $);
|
94
94
|
|
95
95
|
var ballonizedImg = $(".ballonizer_image_container img");
|
96
96
|
ballonizedImg.trigger("dblclick");
|
@@ -98,7 +98,7 @@ describe("Ballonizer", function () {
|
|
98
98
|
});
|
99
99
|
it("the default action of clicking the image (if any) will not trigger", function () {
|
100
100
|
loadFixtures("ballonized-xkcd-with-anchor-in-image.html");
|
101
|
-
instance = Ballonizer(actionFormURL, imageToBallonizeCSSSelector, $("#jasmine-fixtures"));
|
101
|
+
instance = Ballonizer(actionFormURL, imageToBallonizeCSSSelector, $("#jasmine-fixtures"), $);
|
102
102
|
var spyAnchor = spyOnEvent("#comic a", "click");
|
103
103
|
var ballonizedImg = $(".ballonizer_image_container img");
|
104
104
|
// In a real browser the dblclick event will be generated with one or
|
@@ -112,7 +112,7 @@ describe("Ballonizer", function () {
|
|
112
112
|
describe(".getBallonizedImageContainers", function () {
|
113
113
|
describe("when there's no image to ballonize", function () {
|
114
114
|
it("return an object without any keys", function () {
|
115
|
-
instance = Ballonizer(actionFormURL, imageToBallonizeCSSSelector, $("#jasmine-fixtures"));
|
115
|
+
instance = Ballonizer(actionFormURL, imageToBallonizeCSSSelector, $("#jasmine-fixtures"), $);
|
116
116
|
var ballonizedImageContainers = instance.getBallonizedImageContainers();
|
117
117
|
expect(ballonizedImageContainers).toBeAnEmptyObject();
|
118
118
|
});
|
@@ -120,7 +120,7 @@ describe("Ballonizer", function () {
|
|
120
120
|
describe("when there's a image to ballonize", function () {
|
121
121
|
it("return an object with the img src as key and the object as value", function () {
|
122
122
|
loadFixtures("ballonized-xkcd-without-ballons.html");
|
123
|
-
instance = Ballonizer(actionFormURL, imageToBallonizeCSSSelector, $("#jasmine-fixtures"));
|
123
|
+
instance = Ballonizer(actionFormURL, imageToBallonizeCSSSelector, $("#jasmine-fixtures"), $);
|
124
124
|
var ballonizedImageContainers = instance.getBallonizedImageContainers();
|
125
125
|
expect(ballonizedImageContainers.hasOwnProperty("http://imgs.xkcd.com/comics/cells.png")).toBeTruthy();
|
126
126
|
});
|
@@ -129,7 +129,7 @@ describe("Ballonizer", function () {
|
|
129
129
|
describe("BallonizedImageContainer", function () {
|
130
130
|
it("adds a hidden form for the ballon edition in the body", function () {
|
131
131
|
loadFixtures("ballonized-xkcd-without-ballons.html");
|
132
|
-
instance = Ballonizer(actionFormURL, imageToBallonizeCSSSelector, $("#jasmine-fixtures"));
|
132
|
+
instance = Ballonizer(actionFormURL, imageToBallonizeCSSSelector, $("#jasmine-fixtures"), $);
|
133
133
|
expect($("body")).toContain("form.ballonizer_image_form");
|
134
134
|
// What the value of action is not important, but the action attribute
|
135
135
|
// is required (http://www.w3.org/TR/html401/interact/forms.html#h-17.3)
|
@@ -139,7 +139,7 @@ describe("Ballonizer", function () {
|
|
139
139
|
describe("when there's a image with ballons", function () {
|
140
140
|
it("getBallons return they", function () {
|
141
141
|
loadFixtures("ballonized-xkcd-with-ballons.html");
|
142
|
-
instance = Ballonizer(actionFormURL, imageToBallonizeCSSSelector, $("#jasmine-fixtures"));
|
142
|
+
instance = Ballonizer(actionFormURL, imageToBallonizeCSSSelector, $("#jasmine-fixtures"), $);
|
143
143
|
var ballonizedImageContainers = instance.getBallonizedImageContainers();
|
144
144
|
var ballons = ballonizedImageContainers["http://imgs.xkcd.com/comics/cells.png"].getBallons();
|
145
145
|
|
@@ -168,7 +168,7 @@ describe("Ballonizer", function () {
|
|
168
168
|
var containerWidth, containerHeight;
|
169
169
|
var getBallons = function () {
|
170
170
|
loadFixtures("ballonized-xkcd-with-ballons.html");
|
171
|
-
instance = Ballonizer(actionFormURL, imageToBallonizeCSSSelector, $("#jasmine-fixtures"));
|
171
|
+
instance = Ballonizer(actionFormURL, imageToBallonizeCSSSelector, $("#jasmine-fixtures"), $);
|
172
172
|
var imageContainer = instance.getBallonizedImageContainers()["http://imgs.xkcd.com/comics/cells.png"],
|
173
173
|
ballons = imageContainer.getBallons(),
|
174
174
|
containerNode = imageContainer.getContainerNode();
|
@@ -288,7 +288,7 @@ describe("Ballonizer", function () {
|
|
288
288
|
it("prevent the default action of changing the page", function () {
|
289
289
|
// first create a ballon
|
290
290
|
loadFixtures("ballonized-xkcd-with-anchor-in-image.html");
|
291
|
-
instance = Ballonizer(actionFormURL, imageToBallonizeCSSSelector, $("#jasmine-fixtures"));
|
291
|
+
instance = Ballonizer(actionFormURL, imageToBallonizeCSSSelector, $("#jasmine-fixtures"), $);
|
292
292
|
var ballonizedImg = $(".ballonizer_image_container img");
|
293
293
|
realWorldEvent("dblclick", ballonizedImg);
|
294
294
|
var ballon = $(".ballonizer_ballon");
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ballonizer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Henrique Becker
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-07-
|
11
|
+
date: 2013-07-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|