jquery-atwho-rails 0.5.1 → 0.5.2

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: 24d19f42cd98cc9e875d75ceecfc3a876aae8b62
4
- data.tar.gz: ff5e30310eb57d9c48645e646e1ad1f18f44ac7c
3
+ metadata.gz: fa2e92f75b0b7581ced18f8eaa51d4258f055f47
4
+ data.tar.gz: 04c3e54923cc76a80e8df334919e03e0fa985ed6
5
5
  SHA512:
6
- metadata.gz: 0aec51b126719a9242cde57c459518cc3a3dd44ade8dd455d3fb9d4c389313a8f80d68bf6e028473ac85d0f3405882f55c6faf363633f3fd04532157881848d7
7
- data.tar.gz: 2bb034a106b2d3a94911c24bf3aa36974eefc0becec36b03466c0de1ab22f39d417b76eb6daee5421ae338f9990c4fa7e7500bdafa45d30a839122f280641c4c
6
+ metadata.gz: 26541dbb4d524fcf01c31536a102f5da2e36cf05cf0aaf7b8a2a98afc8b7aa7ecf98693733dc8153bf2b918fe7a17f27644bf7db7368fbeb75cbaaa253dc54ba
7
+ data.tar.gz: 893b3c38c8bed239534725f3f1df1a710e5135967d14f6d36b3d09e028ec3d1e865d1e94260eb0389bca1ded8e598e0cef6643f74f1a4e03f14134a997ad199b
data/Rakefile CHANGED
@@ -27,7 +27,7 @@ task fresh: :sync do
27
27
  dist_dir = "lib/assets"
28
28
 
29
29
  js_dist_dir = "#{dist_dir}/javascripts/jquery.atwho/"
30
- FileUtils.copy "#{bower_dir}/Caret.js/src/jquery.caret.js", js_dist_dir
30
+ FileUtils.copy "#{bower_dir}/Caret.js/dist/jquery.caret.js", js_dist_dir
31
31
  FileUtils.copy "#{source_dir}/js/jquery.atwho.js", js_dist_dir
32
32
 
33
33
  FileUtils.copy "#{source_dir}/css/jquery.atwho.css", "#{dist_dir}/stylesheets/"
@@ -1,17 +1,23 @@
1
- /*! jquery.atwho - v0.5.1 - 2014-09-16
2
- * Copyright (c) 2014 chord.luo <chord.luo@gmail.com>;
3
- * homepage: http://ichord.github.com/At.js
1
+ /*! jquery.atwho - v0.5.2 %>
2
+ * Copyright (c) 2014 chord.luo <chord.luo@gmail.com>;
3
+ * homepage: http://ichord.github.com/At.js
4
4
  * Licensed MIT
5
5
  */
6
-
7
- (function() {
8
- (function(factory) {
9
- if (typeof define === 'function' && define.amd) {
10
- return define(['jquery'], factory);
11
- } else {
12
- return factory(window.jQuery);
13
- }
14
- })(function($) {
6
+ (function (root, factory) {
7
+ if (typeof define === 'function' && define.amd) {
8
+ // AMD. Register as an anonymous module.
9
+ define(["jquery"], function ($) {
10
+ return (root.returnExportsGlobal = factory($));
11
+ });
12
+ } else if (typeof exports === 'object') {
13
+ // Node. Does not work with strict CommonJS, but
14
+ // only CommonJS-like enviroments that support module.exports,
15
+ // like Node.
16
+ module.exports = factory(require("jquery"));
17
+ } else {
18
+ factory(jQuery);
19
+ }
20
+ }(this, function ($) {
15
21
 
16
22
  var Api, App, Controller, DEFAULT_CALLBACKS, KEY_CODE, Model, View,
17
23
  __slice = [].slice;
@@ -115,8 +121,7 @@ App = (function() {
115
121
  };
116
122
  })(this)).on('click.atwhoInner', (function(_this) {
117
123
  return function(e) {
118
- var _ref;
119
- return (_ref = _this.controller()) != null ? _ref.view.hide(e) : void 0;
124
+ return _this.dispatch();
120
125
  };
121
126
  })(this));
122
127
  };
@@ -300,10 +305,14 @@ Controller = (function() {
300
305
  };
301
306
 
302
307
  Controller.prototype.content = function() {
308
+ var range;
303
309
  if (this.$inputor.is('textarea, input')) {
304
310
  return this.$inputor.val();
305
311
  } else {
306
- return this.$inputor.text();
312
+ if (!(range = this.mark_range())) {
313
+ return;
314
+ }
315
+ return range.startContainer.parentNode.textContent || "";
307
316
  }
308
317
  };
309
318
 
@@ -344,7 +353,7 @@ Controller = (function() {
344
353
  c.left += iframe_offset.left;
345
354
  c.top += iframe_offset.top;
346
355
  }
347
- if (this.$inputor.attr('contentEditable') === 'true') {
356
+ if (this.$inputor.is('[contentEditable]')) {
348
357
  c = this.cur_rect || (this.cur_rect = c);
349
358
  }
350
359
  scale_bottom = this.app.document.selection ? 0 : 2;
@@ -356,19 +365,20 @@ Controller = (function() {
356
365
  };
357
366
 
358
367
  Controller.prototype.reset_rect = function() {
359
- if (this.$inputor.attr('contentEditable') === 'true') {
368
+ if (this.$inputor.is('[contentEditable]')) {
360
369
  return this.cur_rect = null;
361
370
  }
362
371
  };
363
372
 
364
373
  Controller.prototype.mark_range = function() {
365
- if (this.$inputor.attr('contentEditable') === 'true') {
366
- if (this.app.window.getSelection) {
367
- this.range = this.app.window.getSelection().getRangeAt(0);
368
- }
369
- if (this.app.document.selection) {
370
- return this.ie8_range = this.app.document.selection.createRange();
371
- }
374
+ var sel;
375
+ if (!this.$inputor.is('[contentEditable]')) {
376
+ return;
377
+ }
378
+ if (this.app.window.getSelection && (sel = this.app.window.getSelection()).rangeCount > 0) {
379
+ return this.range = sel.getRangeAt(0);
380
+ } else if (this.app.document.selection) {
381
+ return this.ie8_range = this.app.document.selection.createRange();
372
382
  }
373
383
  };
374
384
 
@@ -387,15 +397,15 @@ Controller = (function() {
387
397
  };
388
398
 
389
399
  Controller.prototype.insert = function(content, $li) {
390
- var $inputor, content_node, pos, range, sel, source, start_str, text, wrapped_content;
400
+ var $inputor, node, pos, range, sel, source, start_str, text, wrapped_contents, _i, _len, _ref;
391
401
  $inputor = this.$inputor;
392
- wrapped_content = this.callbacks('inserting_wrapper').call(this, $inputor, content, this.get_opt("suffix"));
402
+ wrapped_contents = this.callbacks('inserting_wrapper').call(this, $inputor, content, this.get_opt("suffix"));
393
403
  if ($inputor.is('textarea, input')) {
394
404
  source = $inputor.val();
395
405
  start_str = source.slice(0, Math.max(this.query.head_pos - this.at.length, 0));
396
- text = "" + start_str + wrapped_content + (source.slice(this.query['end_pos'] || 0));
406
+ text = "" + start_str + wrapped_contents + (source.slice(this.query['end_pos'] || 0));
397
407
  $inputor.val(text);
398
- $inputor.caret('pos', start_str.length + wrapped_content.length, {
408
+ $inputor.caret('pos', start_str.length + wrapped_contents.length, {
399
409
  iframe: this.app.iframe
400
410
  });
401
411
  } else if (range = this.range) {
@@ -403,16 +413,19 @@ Controller = (function() {
403
413
  range.setStart(range.endContainer, Math.max(pos, 0));
404
414
  range.setEnd(range.endContainer, range.endOffset);
405
415
  range.deleteContents();
406
- content_node = $(wrapped_content, this.app.document)[0];
407
- range.insertNode(content_node);
408
- range.setEndAfter(content_node);
409
- range.collapse(false);
416
+ _ref = $(wrapped_contents, this.app.document);
417
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
418
+ node = _ref[_i];
419
+ range.insertNode(node);
420
+ range.setEndAfter(node);
421
+ range.collapse(false);
422
+ }
410
423
  sel = this.app.window.getSelection();
411
424
  sel.removeAllRanges();
412
425
  sel.addRange(range);
413
426
  } else if (range = this.ie8_range) {
414
427
  range.moveStart('character', this.query.end_pos - this.query.head_pos - this.at.length);
415
- range.pasteHTML(wrapped_content);
428
+ range.pasteHTML(wrapped_contents);
416
429
  range.collapse(false);
417
430
  range.select();
418
431
  }
@@ -540,8 +553,10 @@ View = (function() {
540
553
  return $menu.on('mouseenter.atwho-view', 'li', function(e) {
541
554
  $menu.find('.cur').removeClass('cur');
542
555
  return $(e.currentTarget).addClass('cur');
543
- }).on('click', (function(_this) {
556
+ }).on('click.atwho-view', 'li', (function(_this) {
544
557
  return function(e) {
558
+ $menu.find('.cur').removeClass('cur');
559
+ $(e.currentTarget).addClass('cur');
545
560
  _this.choose(e);
546
561
  return e.preventDefault();
547
562
  };
@@ -592,7 +607,10 @@ View = (function() {
592
607
  if (!next.length) {
593
608
  next = this.$el.find('li:first');
594
609
  }
595
- return next.addClass('cur');
610
+ next.addClass('cur');
611
+ return this.$el.animate({
612
+ scrollTop: Math.max(0, cur.innerHeight() * (next.index() + 2) - this.$el.height())
613
+ }, 150);
596
614
  };
597
615
 
598
616
  View.prototype.prev = function() {
@@ -602,7 +620,10 @@ View = (function() {
602
620
  if (!prev.length) {
603
621
  prev = this.$el.find('li:last');
604
622
  }
605
- return prev.addClass('cur');
623
+ prev.addClass('cur');
624
+ return this.$el.animate({
625
+ scrollTop: Math.max(0, cur.innerHeight() * (prev.index() + 2) - this.$el.height())
626
+ }, 150);
606
627
  };
607
628
 
608
629
  View.prototype.show = function() {
@@ -614,6 +635,7 @@ View = (function() {
614
635
  this.context.mark_range();
615
636
  if (!this.visible()) {
616
637
  this.$el.show();
638
+ this.$el.scrollTop(0);
617
639
  this.context.trigger('shown');
618
640
  }
619
641
  if (rect = this.context.rect()) {
@@ -701,12 +723,14 @@ DEFAULT_CALLBACKS = {
701
723
  return _results;
702
724
  },
703
725
  matcher: function(flag, subtext, should_start_with_space) {
704
- var match, regexp;
726
+ var match, regexp, _a, _y;
705
727
  flag = flag.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
706
728
  if (should_start_with_space) {
707
729
  flag = '(?:^|\\s)' + flag;
708
730
  }
709
- regexp = new RegExp(flag + '([A-Za-zÀ-ÿ0-9_\+\-]*)$|' + flag + '([^\\x00-\\xff]*)$', 'gi');
731
+ _a = decodeURI("%C3%80");
732
+ _y = decodeURI("%C3%BF");
733
+ regexp = new RegExp("" + flag + "([A-Za-z" + _a + "-" + _y + "0-9_\+\-]*)$|" + flag + "([^\\x00-\\xff]*)$", 'gi');
710
734
  match = regexp.exec(subtext);
711
735
  if (match) {
712
736
  return match[2] || match[1];
@@ -768,22 +792,22 @@ DEFAULT_CALLBACKS = {
768
792
  return value;
769
793
  },
770
794
  inserting_wrapper: function($inputor, content, suffix) {
771
- var new_suffix, wrapped_content;
772
- new_suffix = suffix === "" ? suffix : suffix || " ";
795
+ var wrapped_content;
796
+ suffix = suffix === "" ? suffix : suffix || " ";
773
797
  if ($inputor.is('textarea, input')) {
774
- return '' + content + new_suffix;
798
+ return '' + content + suffix;
775
799
  } else if ($inputor.attr('contentEditable') === 'true') {
776
- new_suffix = suffix === "" ? suffix : suffix || "&nbsp;";
800
+ suffix = suffix === " " ? "&nbsp;" : suffix;
777
801
  if (/firefox/i.test(navigator.userAgent)) {
778
- wrapped_content = "<span>" + content + new_suffix + "</span>";
802
+ wrapped_content = "<span>" + content + suffix + "</span>";
779
803
  } else {
780
- suffix = "<span contenteditable='false'>" + new_suffix + "<span>";
804
+ suffix = "<span contenteditable='false'>" + suffix + "</span>";
781
805
  wrapped_content = "<span contenteditable='false'>" + content + suffix + "</span>";
782
806
  }
783
807
  if (this.app.document.selection) {
784
808
  wrapped_content = "<span contenteditable='true'>" + content + "</span>";
785
809
  }
786
- return wrapped_content;
810
+ return wrapped_content + "<span></span>";
787
811
  }
788
812
  }
789
813
  };
@@ -846,5 +870,6 @@ $.fn.atwho["default"] = {
846
870
  delay: null
847
871
  };
848
872
 
849
- });
850
- }).call(this);
873
+
874
+
875
+ }));
@@ -1,4 +1,3 @@
1
- //@ sourceMappingURL=jquery.caret.map
2
1
  /*
3
2
  Implement Github like autocomplete mentions
4
3
  http://ichord.github.com/At.js
@@ -10,6 +10,8 @@
10
10
  border-radius: 3px;
11
11
  box-shadow: 0 0 5px rgba(0,0,0,0.1);
12
12
  min-width: 120px;
13
+ max-height: 200px;
14
+ overflow: auto;
13
15
  z-index: 11110 !important;
14
16
  }
15
17
 
@@ -1,7 +1,7 @@
1
1
  module Jquery
2
2
  module Atwho
3
3
  module Rails
4
- VERSION = "0.5.1"
4
+ VERSION = "0.5.2"
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jquery-atwho-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - ichord
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-18 00:00:00.000000000 Z
11
+ date: 2014-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -85,7 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
85
85
  version: '0'
86
86
  requirements: []
87
87
  rubyforge_project: jquery-atwho-rails
88
- rubygems_version: 2.2.2
88
+ rubygems_version: 2.4.2
89
89
  signing_key:
90
90
  specification_version: 4
91
91
  summary: 'jquery plugin: @mentions'