jquery-atwho-rails 1.0.1 → 1.1.0

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: 726bba9a4b37da246176b51d74f556349d9dd42f
4
- data.tar.gz: 6bc804d4df04719726219ac5892711c26a07cf4d
3
+ metadata.gz: f147f6dc894847559d1f5c240cbdb7a46fe14409
4
+ data.tar.gz: eabd2f00d29fe2e8480e251848aea0a2041c00f1
5
5
  SHA512:
6
- metadata.gz: 40bbe73676becc9c1d442e2625861af9a0743cd6a16e7cb54458de81a6ad3205b14e9646ceefcd8ac77d42ada47f28d38b0f8b4e06bbdf5a70d6e0727d52756a
7
- data.tar.gz: a22a4418a9536ef532cc5d60c9420fbb3c3e12198ab203824b028677f798f8e82304dc5fe2a8f45f94ef81415d263456abd6f3e79fb345f77e98534b9b954718
6
+ metadata.gz: c0bc1c81a508bab44cfbc9c927a504e61e7b3410918082b1512a72b0eb9c31b037f955d6cbe2e5f7e583354d5a2cdd7a94c3ef9e65d7af83e6f189dde49f5487
7
+ data.tar.gz: 820e7b345bb800961e39a45a6f6f8a877b3579e706758b928a9733b2b927f0bebbfd7f00ecffd93272466b5907c191602148702a2b0bf8025e6e2553e27432b6
data/.gitignore CHANGED
@@ -5,3 +5,4 @@ pkg/*
5
5
  *.swp
6
6
  tmp/*
7
7
  build/*
8
+ bower_components/
data/Rakefile CHANGED
@@ -2,28 +2,18 @@ require 'rubygems'
2
2
  require 'bundler/setup'
3
3
  require "bundler/gem_tasks"
4
4
 
5
- at_dir = "tmp/At.js"
6
- bower_dir = "#{at_dir}/bower_components/"
5
+ bower_dir = "bower_components/"
7
6
 
8
7
  desc "sync from At.js"
9
8
  task :sync do
10
- puts " * syncing..."
11
- FileUtils.mkdir_p("tmp") unless Dir.exist? "tmp"
12
- unless Dir.exist? at_dir
13
- system "git clone git://github.com/ichord/At.js.git #{at_dir}"
14
- else
15
- Dir.chdir(at_dir) { puts %x{git pull -X theirs} }
16
- end
17
- Dir.chdir(at_dir) {
18
- puts "* bower install..."
19
- puts %x{bower install}
20
- }
9
+ puts "* bower install..."
10
+ puts %x{bower install}
21
11
  end
22
12
 
23
13
  desc "copy assets"
24
- task fresh: :sync do
14
+ task refresh: :sync do
25
15
  puts " * Copying..."
26
- source_dir = "tmp/At.js/dist"
16
+ source_dir = "bower_components/At.js/dist"
27
17
  dist_dir = "lib/assets"
28
18
 
29
19
  js_dist_dir = "#{dist_dir}/javascripts/jquery.atwho/"
@@ -1,4 +1,4 @@
1
- /*! jquery.atwho - v1.0.1 %>
1
+ /*! jquery.atwho - v1.1.0 %>
2
2
  * Copyright (c) 2015 chord.luo <chord.luo@gmail.com>;
3
3
  * homepage: http://ichord.github.com/At.js
4
4
  * Licensed MIT
@@ -6,8 +6,8 @@
6
6
  (function (root, factory) {
7
7
  if (typeof define === 'function' && define.amd) {
8
8
  // AMD. Register as an anonymous module.
9
- define(["jquery"], function ($) {
10
- return (root.returnExportsGlobal = factory($));
9
+ define(["jquery"], function (jquery) {
10
+ return (root.returnExportsGlobal = factory(jquery));
11
11
  });
12
12
  } else if (typeof exports === 'object') {
13
13
  // Node. Does not work with strict CommonJS, but
@@ -17,7 +17,7 @@
17
17
  } else {
18
18
  factory(jQuery);
19
19
  }
20
- }(this, function ($) {
20
+ }(this, function (jquery) {
21
21
 
22
22
  var Api, App, Controller, DEFAULT_CALLBACKS, EditableController, KEY_CODE, Model, TextareaController, View,
23
23
  __slice = [].slice,
@@ -35,13 +35,15 @@ App = (function() {
35
35
  }
36
36
 
37
37
  App.prototype.createContainer = function(doc) {
38
- if ((this.$el = $("#atwho-container", doc)).length === 0) {
39
- return $(doc.body).append(this.$el = $("<div id='atwho-container'></div>"));
38
+ var _ref;
39
+ if ((_ref = this.$el) != null) {
40
+ _ref.remove();
40
41
  }
42
+ return $(doc.body).append(this.$el = $("<div class='atwho-container'></div>"));
41
43
  };
42
44
 
43
45
  App.prototype.setupRootElement = function(iframe, asRoot) {
44
- var error, _ref;
46
+ var error;
45
47
  if (asRoot == null) {
46
48
  asRoot = false;
47
49
  }
@@ -57,17 +59,10 @@ App = (function() {
57
59
  } catch (_error) {
58
60
  error = _error;
59
61
  this.iframe = null;
60
- throw new Error("iframe auto-discovery is failed.\nPlease use `serIframe` to set the target iframe manually.");
61
- }
62
- }
63
- if (this.iframeAsRoot = asRoot) {
64
- if ((_ref = this.$el) != null) {
65
- _ref.remove();
62
+ throw new Error("iframe auto-discovery is failed.\nPlease use `setIframe` to set the target iframe manually.");
66
63
  }
67
- return this.createContainer(this.document);
68
- } else {
69
- return this.createContainer(document);
70
64
  }
65
+ return this.createContainer((this.iframeAsRoot = asRoot) ? this.document : document);
71
66
  };
72
67
 
73
68
  App.prototype.controller = function(at) {
@@ -107,7 +102,19 @@ App = (function() {
107
102
  };
108
103
 
109
104
  App.prototype.listen = function() {
110
- return this.$inputor.on('keyup.atwhoInner', (function(_this) {
105
+ return this.$inputor.on('compositionstart', (function(_this) {
106
+ return function(e) {
107
+ var _ref;
108
+ if ((_ref = _this.controller()) != null) {
109
+ _ref.view.hide();
110
+ }
111
+ return _this.isComposing = true;
112
+ };
113
+ })(this)).on('compositionend', (function(_this) {
114
+ return function(e) {
115
+ return _this.isComposing = false;
116
+ };
117
+ })(this)).on('keyup.atwhoInner', (function(_this) {
111
118
  return function(e) {
112
119
  return _this.onKeyup(e);
113
120
  };
@@ -226,9 +233,13 @@ App = (function() {
226
233
  break;
227
234
  case KEY_CODE.TAB:
228
235
  case KEY_CODE.ENTER:
236
+ case KEY_CODE.SPACE:
229
237
  if (!view.visible()) {
230
238
  return;
231
239
  }
240
+ if (!this.controller().getOpt('spaceSelectsMatch') && e.keyCode === KEY_CODE.SPACE) {
241
+ return;
242
+ }
232
243
  e.preventDefault();
233
244
  view.choose(e);
234
245
  break;
@@ -501,6 +512,9 @@ EditableController = (function(_super) {
501
512
 
502
513
  EditableController.prototype.catchQuery = function(e) {
503
514
  var $inserted, $query, index, inserted, lastNode, matched, offset, query, range, _range;
515
+ if (this.app.isComposing) {
516
+ return;
517
+ }
504
518
  if (!(range = this._getRange())) {
505
519
  return;
506
520
  }
@@ -544,7 +558,8 @@ EditableController = (function(_super) {
544
558
  matched = this.callbacks("matcher").call(this, this.at, _range.toString(), this.getOpt('startWithSpace'));
545
559
  if ($query.length === 0 && typeof matched === 'string' && (index = range.startOffset - this.at.length - matched.length) >= 0) {
546
560
  range.setStart(range.startContainer, index);
547
- range.surroundContents(($query = $("<span class='atwho-query'/>", this.app.document))[0]);
561
+ $query = $("<span/>", this.app.document).attr(this.getOpt("editableAtwhoQueryAttrs")).addClass('atwho-query');
562
+ range.surroundContents($query.get(0));
548
563
  lastNode = $query.contents().last().get(0);
549
564
  if (/firefox/i.test(navigator.userAgent)) {
550
565
  range.setStart(lastNode, lastNode.length);
@@ -560,9 +575,12 @@ EditableController = (function(_super) {
560
575
  el: $query
561
576
  };
562
577
  this.trigger("matched", [this.at, query.text]);
578
+ return this.query = query;
563
579
  } else {
564
580
  this.view.hide();
565
- query = null;
581
+ this.query = {
582
+ el: $query
583
+ };
566
584
  if ($query.text().indexOf(this.at) >= 0) {
567
585
  if (this._movingEvent(e) && $query.hasClass('atwho-inserted')) {
568
586
  $query.removeClass('atwho-query');
@@ -570,8 +588,8 @@ EditableController = (function(_super) {
570
588
  this._setRange("after", this._unwrap($query.text($query.text()).contents().first()));
571
589
  }
572
590
  }
591
+ return null;
573
592
  }
574
- return this.query = query;
575
593
  };
576
594
 
577
595
  EditableController.prototype.rect = function() {
@@ -847,7 +865,8 @@ KEY_CODE = {
847
865
  UP: 38,
848
866
  RIGHT: 39,
849
867
  DOWN: 40,
850
- BACKSPACE: 8
868
+ BACKSPACE: 8,
869
+ SPACE: 32
851
870
  };
852
871
 
853
872
  DEFAULT_CALLBACKS = {
@@ -862,7 +881,7 @@ DEFAULT_CALLBACKS = {
862
881
  }
863
882
  _a = decodeURI("%C3%80");
864
883
  _y = decodeURI("%C3%BF");
865
- regexp = new RegExp("" + flag + "([A-Za-z" + _a + "-" + _y + "0-9_\+\-]*)$|" + flag + "([^\\x00-\\xff]*)$", 'gi');
884
+ regexp = new RegExp("" + flag + "([A-Za-z" + _a + "-" + _y + "0-9_\.\+\-]*)$|" + flag + "([^\\x00-\\xff]*)$", 'gi');
866
885
  match = regexp.exec(subtext);
867
886
  if (match) {
868
887
  return match[2] || match[1];
@@ -900,9 +919,13 @@ DEFAULT_CALLBACKS = {
900
919
  });
901
920
  },
902
921
  tplEval: function(tpl, map) {
903
- var error;
922
+ var error, template;
923
+ template = tpl;
904
924
  try {
905
- return tpl.replace(/\$\{([^\}]*)\}/g, function(tag, key, pos) {
925
+ if (typeof tpl !== 'string') {
926
+ template = tpl(map);
927
+ }
928
+ return template.replace(/\$\{([^\}]*)\}/g, function(tag, key, pos) {
906
929
  return map[key];
907
930
  });
908
931
  } catch (_error) {
@@ -988,7 +1011,9 @@ $.fn.atwho["default"] = {
988
1011
  limit: 5,
989
1012
  maxLen: 20,
990
1013
  displayTimeout: 300,
991
- delay: null
1014
+ delay: null,
1015
+ spaceSelectsMatch: false,
1016
+ editableAtwhoQueryAttrs: {}
992
1017
  };
993
1018
 
994
1019
 
@@ -1,7 +1,7 @@
1
1
  module Jquery
2
2
  module Atwho
3
3
  module Rails
4
- VERSION = '1.0.1'
4
+ VERSION = '1.1.0'
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: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ichord
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-04 00:00:00.000000000 Z
11
+ date: 2015-05-03 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.4.2
88
+ rubygems_version: 2.4.6
89
89
  signing_key:
90
90
  specification_version: 4
91
91
  summary: 'jquery plugin: @mentions'