ballonizer 0.7.2 → 0.7.3

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: 52d2c968649c91a1265268bba794bbdc898070d7
4
- data.tar.gz: bbce6945bdceae4d0f52424f484f8be85059ec4c
3
+ metadata.gz: 967c8a0ccad88064316e33f61b350e0be330d66c
4
+ data.tar.gz: 0b417a9f8ec71ffe3be883245f68f4d71f9cf578
5
5
  SHA512:
6
- metadata.gz: 22b110740fb92fa3f0676bae93a4d1a64e807c8f68a9ff8856fa6f3410c2bd91e10edc72822b877224b162b30f18af69b10434a79956a07f5491689d649ee3b8
7
- data.tar.gz: 21a67f66b77c393dce3e026fc864c59de831653f70fffdf64ac7632a01f2c7713f5cb13856e665607924d9e4103a2c92e822964471930da1e10eeed1318c4d98
6
+ metadata.gz: 4c59c4dabec9977df98437ad2e594d8310cc41e776b4e32a7ffa6e3908f31c17271464e4db24b93c1667735e39486eeecafdc8d9e2d12e546a467137c008662e
7
+ data.tar.gz: 8c549d6bfb363b8cd3558de6f5de7a8b25b5ee038215c91ff1ea15780f523ab5b9d30ce05594dfcd118976522c4903f20154f28cc1b77e60271507b1044c25b6
@@ -455,6 +455,24 @@
455
455
  this.editionNode = editionBallon;
456
456
  imageForm.prepend(this.editionNode);
457
457
 
458
+ // Some webcomics allows the reader to navigate using the
459
+ // arrow keys. This can be very annoying when editing a
460
+ // balloon ("edition mode"/textarea) because you normally
461
+ // use the arrows to edit the ballon you are writing. The
462
+ // result is you losing all your work every time you make
463
+ // the mistake of pressing an arrow key. This guarantee that
464
+ // any other scripts on the page that trigger by key events
465
+ // will not trigger while the user is typing a balloon text.
466
+ this.editionNode.keydown($.proxy(function (event) {
467
+ event.stopPropagation();
468
+ }, this));
469
+ this.editionNode.keyup($.proxy(function (event) {
470
+ event.stopPropagation();
471
+ }, this));
472
+ this.editionNode.keypress($.proxy(function (event) {
473
+ event.stopPropagation();
474
+ }, this));
475
+
458
476
  this.node.click($.proxy(function (event) {
459
477
  this.click(event);
460
478
  }, this));
data/lib/ballonizer.rb CHANGED
@@ -55,7 +55,18 @@ require 'sprockets'
55
55
  # ballonized_image_ballons.
56
56
  #
57
57
  # Changelog:
58
- # v0.6.1
58
+ # v0.7.3
59
+ # * Solve the annoying arrow key problem. Stop the propagation of
60
+ # the key events while editing a balloon. This is meant to solve
61
+ # the problem with some sites that use the arrow keys to navigate
62
+ # between pages. If you used one of these keys while editing a
63
+ # ballon you would lose all work.
64
+ # v0.7.2
65
+ # * Little CSS fix (normalize line-height for ballons)
66
+ # v0.7.1
67
+ # * Fix the big submit button problem and the hidden behind other
68
+ # element submit button problem.
69
+ # v0.7.0
59
70
  # * Add the jquery_no_conflict option. If this option is true the
60
71
  # js_load_snippet will restore any previous loaded version of
61
72
  # jQuery after the ballonizer javascript client code already
@@ -524,6 +524,47 @@ describe("Ballonizer", function () {
524
524
  ]
525
525
  });
526
526
  });
527
+ // avoid the arrow keys to previous/next comic while typing problem
528
+ it("any key{press,down,up} triggers on the page don't trigger", function () {
529
+ var firstBallon = getBallons()[0];
530
+
531
+ $('body').keydown(function (event) {
532
+ /* jshint unused: false */
533
+ console.log("this body.keydown wasn't meant to execute");
534
+ });
535
+ $('body').keyup(function (event) {
536
+ /* jshint unused: false */
537
+ console.log("this body.keyup wasn't meant to execute");
538
+ });
539
+ $('body').keypress(function (event) {
540
+ /* jshint unused: false */
541
+ console.log("this body.keypress wasn't meant to execute");
542
+ });
543
+
544
+ var spyDown = spyOnEvent("body", "keydown");
545
+ var spyUp = spyOnEvent("body", "keyup");
546
+ var spyPress = spyOnEvent("body", "keypress");
547
+
548
+ // alternate to the edition mode
549
+ realWorldEvent("dblclick", firstBallon.getNormalNode());
550
+
551
+ // trigger all three events while the textarea has focus
552
+ var textarea = firstBallon.editionNode();
553
+ textarea.trigger(jQuery.Event(
554
+ 'keydown', { which: $.ui.keyCode.LEFT }
555
+ ));
556
+ textarea.trigger(jQuery.Event(
557
+ 'keyup', { which: $.ui.keyCode.LEFT }
558
+ ));
559
+ textarea.trigger(jQuery.Event(
560
+ 'keypress', { which: $.ui.keyCode.LEFT }
561
+ ));
562
+
563
+ // verify if the body events have been triggered
564
+ expect(spyDown).not.toHaveBeenTriggered();
565
+ expect(spyUp).not.toHaveBeenTriggered();
566
+ expect(spyPress).not.toHaveBeenTriggered();
567
+ });
527
568
  });
528
569
  });
529
570
  describe("when a ballon is added", function () {
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.7.2
4
+ version: 0.7.3
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-08-09 00:00:00.000000000 Z
11
+ date: 2013-09-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri