textext-rails 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9bf427f9b010f127657982b974ba154a7f8f7046
4
+ data.tar.gz: 52c147ab5b6cc38ea7b966bfe3b9e5c3f89df628
5
+ SHA512:
6
+ metadata.gz: 8c287ae462ef33b98dda7b4924dcea22767676a9f94e85c183e46b9412d370ba833a96d42bdffd22e07029cbfdd3eca59f6c792634867581871bc3cda187dc60
7
+ data.tar.gz: b2af79ea006a889282bd5bfabcbe57770444ed372add48ee24537aa4d0367c8edbc5bb0b7e480982f7741fae302da3d57e9f090110a5709765ef9a1a3ad7b81c
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Textext Rails
2
2
 
3
- Brings the [jQuery TextExt plugin](http://textextjs.com/) into the Rails asset pipeline. The TextExt asset files are from the TextExt [1.2.0 release](https://github.com/alexgorbatchev/jquery-textext/tree/1.2.0).
3
+ Brings the [jQuery TextExt plugin](http://textextjs.com/) into the Rails asset pipeline. The TextExt asset files are from the TextExt [1.3.1 release](https://github.com/alexgorbatchev/jquery-textext/tree/1.3.1).
4
4
 
5
5
  ## Installation
6
6
 
@@ -28,4 +28,4 @@ That's it! Please see the [TextExt manual](http://textextjs.com/manual/index.ht
28
28
 
29
29
  ## License
30
30
 
31
- MIT licensed. Please see the LICENSE file for more information.
31
+ MIT licensed. Please see the LICENSE file for more information.
data/Rakefile CHANGED
@@ -1,21 +1,20 @@
1
1
  require "bundler/gem_tasks"
2
2
 
3
- DOWNLOAD_FOLDER = 'https://nodeload.github.com/alexgorbatchev/jquery-textext/tarball/'
4
- LATEST_VERSION = '1.2.0'
5
- DOWNLOAD_URL = DOWNLOAD_FOLDER + LATEST_VERSION
3
+ LATEST_VERSION = '1.3.1'
4
+ DOWNLOAD_URL = "https://github.com/alexgorbatchev/jquery-textext/archive/#{LATEST_VERSION}.tar.gz"
6
5
 
7
6
  desc "Sync the files from the upstream release"
8
7
  task :sync do
9
8
  sh 'mkdir -p sync'
10
9
  sh 'mkdir -p vendor/assets'
11
- sh "curl -0 #{DOWNLOAD_URL} > sync/latest.tar.gz"
12
- sh 'cd sync && tar -xzvf latest.tar.gz'
10
+ sh "curl -0 -L #{DOWNLOAD_URL} > sync/latest.tar.gz"
11
+ sh 'cd sync && tar -xzf latest.tar.gz'
13
12
 
14
- release_folder = `ls sync | grep alex`.chomp
13
+ release_folder = `ls sync | grep jquery-textext`.chomp
15
14
 
16
15
  sh 'rm -rf vendor/assets/stylesheets'
17
16
  sh 'rm -rf vendor/assets/javascripts'
18
17
  sh "mv sync/#{release_folder}/src/css vendor/assets/stylesheets"
19
18
  sh "mv sync/#{release_folder}/src/js vendor/assets/javascripts"
20
19
  sh 'rm -rf sync'
21
- end
20
+ end
@@ -1,5 +1,5 @@
1
1
  module Textext
2
2
  module Rails
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
@@ -7,18 +7,15 @@ Gem::Specification.new do |s|
7
7
  s.version = Textext::Rails::VERSION
8
8
  s.authors = ["Jeff Pollard"]
9
9
  s.email = ["jeff.pollard@gmail.com"]
10
- s.homepage = ""
10
+ s.homepage = "https://github.com/Fluxx/textext-rails"
11
11
  s.summary = %q{Adds the jQuery TextExt plugin to the Rails 3.1 asset pipeline}
12
12
  s.description = %q{Adds the jQuery TextExt plugin to the Rails 3.1 asset pipeline}
13
13
 
14
14
  s.rubyforge_project = "textext-rails"
15
15
 
16
16
  s.files = `git ls-files`.split("\n")
17
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
17
  s.require_paths = ["lib"]
20
18
 
21
- # specify any dependencies here; for example:
22
- # s.add_development_dependency "rspec"
23
- # s.add_runtime_dependency "rest-client"
19
+ # specify any dependencies here
20
+ s.add_development_dependency "rake"
24
21
  end
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * jQuery TextExt Plugin
3
- * http://alexgorbatchev.com/textext
3
+ * http://textextjs.com
4
4
  *
5
- * @version 1.2.0
5
+ * @version 1.3.1
6
6
  * @copyright Copyright (C) 2011 Alex Gorbatchev. All rights reserved.
7
7
  * @license MIT License
8
8
  */
@@ -71,7 +71,7 @@
71
71
 
72
72
  var stringify = (JSON || {}).stringify,
73
73
  slice = Array.prototype.slice,
74
-
74
+ p,
75
75
  UNDEFINED = 'undefined',
76
76
 
77
77
  /**
@@ -802,7 +802,9 @@
802
802
  if(plugin)
803
803
  {
804
804
  self._plugins[name] = plugin = new plugin();
805
- self[name] = function() { return plugin; };
805
+ self[name] = (function(plugin) {
806
+ return function(){ return plugin; }
807
+ })(plugin);
806
808
  initList.push(plugin);
807
809
  $.extend(true, plugin, self.opts(OPT_EXT + '.*'), self.opts(OPT_EXT + '.' + name));
808
810
  }
@@ -968,17 +970,19 @@
968
970
  input = self.input(),
969
971
  wrap = self.wrapElement(),
970
972
  container = wrap.parent(),
971
- width = self.originalWidth,
973
+ width = self.originalWidth + 'px',
972
974
  height
973
975
  ;
974
976
 
975
977
  self.trigger(EVENT_PRE_INVALIDATE);
976
978
 
977
- height = input.outerHeight();
979
+ height = input.outerHeight() + 'px';
978
980
 
979
- input.width(width);
980
- wrap.width(width).height(height);
981
- container.height(height);
981
+ // using css() method instead of width() and height() here because they don't seem to do the right thing in jQuery 1.8.x
982
+ // https://github.com/alexgorbatchev/jquery-textext/issues/74
983
+ input.css({ 'width' : width });
984
+ wrap.css({ 'width' : width, 'height' : height });
985
+ container.css({ 'height' : height });
982
986
 
983
987
  self.trigger(EVENT_POST_INVALIDATE);
984
988
  };
@@ -1076,7 +1080,7 @@
1076
1080
  p.getFormData = function(keyCode)
1077
1081
  {
1078
1082
  var self = this,
1079
- data = self.getWeightedEventResponse(EVENT_GET_FORM_DATA, keyCode)
1083
+ data = self.getWeightedEventResponse(EVENT_GET_FORM_DATA, keyCode || 0)
1080
1084
  ;
1081
1085
 
1082
1086
  self.trigger(EVENT_SET_FORM_DATA , data['form']);
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * jQuery TextExt Plugin
3
- * http://alexgorbatchev.com/textext
3
+ * http://textextjs.com
4
4
  *
5
- * @version 1.2.0
5
+ * @version 1.3.1
6
6
  * @copyright Copyright (C) 2011 Alex Gorbatchev. All rights reserved.
7
7
  * @license MIT License
8
8
  */
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * jQuery TextExt Plugin
3
- * http://alexgorbatchev.com/textext
3
+ * http://textextjs.com
4
4
  *
5
- * @version 1.2.0
5
+ * @version 1.3.1
6
6
  * @copyright Copyright (C) 2011 Alex Gorbatchev. All rights reserved.
7
7
  * @license MIT License
8
8
  */
@@ -1,15 +1,15 @@
1
1
  /**
2
2
  * jQuery TextExt Plugin
3
- * http://alexgorbatchev.com/textext
3
+ * http://textextjs.com
4
4
  *
5
- * @version 1.2.0
5
+ * @version 1.3.1
6
6
  * @copyright Copyright (C) 2011 Alex Gorbatchev. All rights reserved.
7
7
  * @license MIT License
8
8
  */
9
9
  (function($)
10
10
  {
11
11
  /**
12
- * Autocomplete plugin brings the classic autocomplete functionality to the TextExt echosystem.
12
+ * Autocomplete plugin brings the classic autocomplete functionality to the TextExt ecosystem.
13
13
  * The gist of functionality is when user starts typing in, for example a term or a tag, a
14
14
  * dropdown would be presented with possible suggestions to complete the input quicker.
15
15
  *
@@ -29,6 +29,8 @@
29
29
  CSS_DOT_SELECTED = CSS_DOT + CSS_SELECTED,
30
30
  CSS_SUGGESTION = 'text-suggestion',
31
31
  CSS_DOT_SUGGESTION = CSS_DOT + CSS_SUGGESTION,
32
+ CSS_LABEL = 'text-label',
33
+ CSS_DOT_LABEL = CSS_DOT + CSS_LABEL,
32
34
 
33
35
  /**
34
36
  * Autocomplete plugin options are grouped under `autocomplete` when passed to the
@@ -226,6 +228,8 @@
226
228
 
227
229
  POSITION_ABOVE = 'above',
228
230
  POSITION_BELOW = 'below',
231
+
232
+ DATA_MOUSEDOWN_ON_AUTOCOMPLETE = 'mousedownOnAutocomplete',
229
233
 
230
234
  DEFAULT_OPTS = {
231
235
  autocomplete : {
@@ -291,6 +295,7 @@
291
295
 
292
296
  self.on(container, {
293
297
  mouseover : self.onMouseOver,
298
+ mousedown : self.onMouseDown,
294
299
  click : self.onClick
295
300
  });
296
301
 
@@ -300,6 +305,12 @@
300
305
  ;
301
306
 
302
307
  $(self).data('container', container);
308
+
309
+ $(document.body).click(function(e)
310
+ {
311
+ if (self.isDropdownVisible() && !self.withinWrapElement(e.target))
312
+ self.trigger(EVENT_HIDE_DROPDOWN);
313
+ });
303
314
 
304
315
  self.positionDropdown();
305
316
  }
@@ -345,7 +356,23 @@
345
356
  target.addClass(CSS_SELECTED);
346
357
  }
347
358
  };
348
-
359
+
360
+ /**
361
+ * Reacts to the `mouseDown` event triggered by the TextExt core.
362
+ *
363
+ * @signature TextExtAutocomplete.onMouseDown(e)
364
+ *
365
+ * @param e {Object} jQuery event.
366
+ *
367
+ * @author adamayres
368
+ * @date 2012/01/13
369
+ * @id TextExtAutocomplete.onMouseDown
370
+ */
371
+ p.onMouseDown = function(e)
372
+ {
373
+ this.containerElement().data(DATA_MOUSEDOWN_ON_AUTOCOMPLETE, true);
374
+ };
375
+
349
376
  /**
350
377
  * Reacts to the `click` event triggered by the TextExt core.
351
378
  *
@@ -363,8 +390,11 @@
363
390
  target = $(e.target)
364
391
  ;
365
392
 
366
- if(target.is(CSS_DOT_SUGGESTION))
367
- self.selectFromDropdown();
393
+ if(target.is(CSS_DOT_SUGGESTION) || target.is(CSS_DOT_LABEL))
394
+ self.trigger('enterKeyPress');
395
+
396
+ if (self.core().hasPlugin('tags'))
397
+ self.val('');
368
398
  };
369
399
 
370
400
  /**
@@ -380,12 +410,18 @@
380
410
  */
381
411
  p.onBlur = function(e)
382
412
  {
383
- var self = this;
413
+ var self = this,
414
+ container = self.containerElement(),
415
+ isBlurByMousedown = container.data(DATA_MOUSEDOWN_ON_AUTOCOMPLETE) === true
416
+ ;
384
417
 
385
- // use timeout here so that onClick has a chance to fire because if
386
- // dropdown is hidden when clicked, onClick doesn't fire
418
+ // only trigger a close event if the blur event was
419
+ // not triggered by a mousedown event on the autocomplete
420
+ // otherwise set focus back back on the input
387
421
  if(self.isDropdownVisible())
388
- setTimeout(function() { self.trigger(EVENT_HIDE_DROPDOWN) }, 100);
422
+ isBlurByMousedown ? self.core().focusInput() : self.trigger(EVENT_HIDE_DROPDOWN);
423
+
424
+ container.removeData(DATA_MOUSEDOWN_ON_AUTOCOMPLETE);
389
425
  };
390
426
 
391
427
  /**
@@ -684,7 +720,7 @@
684
720
  * @author agorbatchev
685
721
  * @date 2011/12/27
686
722
  * @id TextExtAutocomplete.onToggleDropdown
687
- * @version 1.1
723
+ * @version 1.1.0
688
724
  */
689
725
  p.onToggleDropdown = function(e)
690
726
  {
@@ -1049,9 +1085,26 @@
1049
1085
  if(suggestion)
1050
1086
  {
1051
1087
  self.val(self.itemManager().itemToString(suggestion));
1052
- self.core().getFormData();
1088
+ self.core().getFormData();
1053
1089
  }
1054
1090
 
1055
1091
  self.trigger(EVENT_HIDE_DROPDOWN);
1056
1092
  };
1093
+
1094
+ /**
1095
+ * Determines if the specified HTML element is within the TextExt core wrap HTML element.
1096
+ *
1097
+ * @signature TextExtAutocomplete.withinWrapElement(element)
1098
+ *
1099
+ * @param element {HTMLElement} element to check if contained by wrap element
1100
+ *
1101
+ * @author adamayres
1102
+ * @version 1.3.0
1103
+ * @date 2012/01/15
1104
+ * @id TextExtAutocomplete.withinWrapElement
1105
+ */
1106
+ p.withinWrapElement = function(element)
1107
+ {
1108
+ return this.core().wrapElement().find(element).size() > 0;
1109
+ }
1057
1110
  })(jQuery);
@@ -0,0 +1,116 @@
1
+ /**
2
+ * jQuery TextExt Plugin
3
+ * http://alexgorbatchev.com/textext
4
+ *
5
+ * @version 1.3.1
6
+ * @copyright Copyright (C) 2011 Alex Gorbatchev. All rights reserved.
7
+ * @license MIT License
8
+ */
9
+ (function($)
10
+ {
11
+ /**
12
+ * Displays a clear search button.
13
+ *
14
+ * @author mreinstein
15
+ * @date 2012/02/19
16
+ * @id TextExtClear
17
+ */
18
+ function TextExtClear() {};
19
+
20
+ $.fn.textext.TextExtClear = TextExtClear;
21
+ $.fn.textext.addPlugin('clear', TextExtClear);
22
+
23
+ var p = TextExtClear.prototype,
24
+ /**
25
+ * Clear plugin only has one option and that is its HTML template. It could be
26
+ * changed when passed to the `$().textext()` function. For example:
27
+ *
28
+ * $('textarea').textext({
29
+ * plugins: 'clear',
30
+ * html: {
31
+ * clear: "<span/>"
32
+ * }
33
+ * })
34
+ *
35
+ * @author mreinstein
36
+ * @date 2012/02/19
37
+ * @id TextExtClear.options
38
+ */
39
+
40
+ /**
41
+ * HTML source that is used to generate markup required for the clear.
42
+ *
43
+ * @name html.clear
44
+ * @default '<div class="text-clear"/>'
45
+ * @author mreinstein
46
+ * @date 2012/02/19
47
+ * @id TextExtClear.options.html.clear
48
+ */
49
+ OPT_HTML_CLEAR = 'html.clear',
50
+
51
+ DEFAULT_OPTS = {
52
+ html : {
53
+ clear : '<div class="text-clear"/>'
54
+ }
55
+ };
56
+
57
+ /**
58
+ * Initialization method called by the core during plugin instantiation.
59
+ *
60
+ * @signature TextExtClear.init(core)
61
+ *
62
+ * @param core {TextExt} Instance of the TextExt core class.
63
+ *
64
+ * @author agorbatchev
65
+ * @date 2011/12/27
66
+ * @id TextExtClear.init
67
+ */
68
+ p.init = function(core)
69
+ {
70
+ var self = this,
71
+ clear
72
+ ;
73
+
74
+ self.baseInit(core, DEFAULT_OPTS);
75
+
76
+ self._clear = clear = $(self.opts(OPT_HTML_CLEAR));
77
+ self.core().wrapElement().append(clear);
78
+ clear.bind('click', function(e) { self.onClearClick(e); });
79
+ };
80
+
81
+ //--------------------------------------------------------------------------------
82
+ // Event handlers
83
+
84
+ /**
85
+ * Reacts to the `click` event whenever user clicks the clear.
86
+ *
87
+ * @signature TextExtClear.onClearClick(e)
88
+ *
89
+ * @param e {Object} jQuery event.
90
+ * @author agorbatchev
91
+ * @date 2011/12/27
92
+ * @id TextExtClear.onClearClick
93
+ */
94
+ p.onClearClick = function(e)
95
+ {
96
+ var self = this;
97
+
98
+ // check if the tags plugin is present
99
+ if(typeof self.core()._plugins.tags != 'undefined')
100
+ {
101
+ // it is! remove all tags
102
+ var elems = self.core()._plugins.tags.tagElements();
103
+ for(var i =0; i < elems.length;i++)
104
+ {
105
+ self.core()._plugins.tags.removeTag($(elems[i]));
106
+ }
107
+ }
108
+ // clear the text from the search area
109
+ self.val('');
110
+ self.core().getFormData();
111
+ };
112
+
113
+ //--------------------------------------------------------------------------------
114
+ // Core functionality
115
+
116
+ })(jQuery);
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * jQuery TextExt Plugin
3
- * http://alexgorbatchev.com/textext
3
+ * http://textextjs.com
4
4
  *
5
- * @version 1.2.0
5
+ * @version 1.3.1
6
6
  * @copyright Copyright (C) 2011 Alex Gorbatchev. All rights reserved.
7
7
  * @license MIT License
8
8
  */
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * jQuery TextExt Plugin
3
- * http://alexgorbatchev.com/textext
3
+ * http://textextjs.com
4
4
  *
5
- * @version 1.2.0
5
+ * @version 1.3.1
6
6
  * @copyright Copyright (C) 2011 Alex Gorbatchev. All rights reserved.
7
7
  * @license MIT License
8
8
  */
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * jQuery TextExt Plugin
3
- * http://alexgorbatchev.com/textext
3
+ * http://textextjs.com
4
4
  *
5
- * @version 1.2.0
5
+ * @version 1.3.1
6
6
  * @copyright Copyright (C) 2011 Alex Gorbatchev. All rights reserved.
7
7
  * @license MIT License
8
8
  */
@@ -109,8 +109,10 @@
109
109
  */
110
110
  p.init = function(core)
111
111
  {
112
- var self = this,
113
- container
112
+ var self = this,
113
+ placeholderKey = 'placeholder',
114
+ container,
115
+ prompt
114
116
  ;
115
117
 
116
118
  self.baseInit(core, DEFAULT_OPTS);
@@ -121,7 +123,18 @@
121
123
  self.core().wrapElement().append(container);
122
124
  self.setPrompt(self.opts(OPT_PROMPT));
123
125
 
124
- if(self.val().length > 0)
126
+ prompt = core.input().attr(placeholderKey);
127
+
128
+ if(!prompt)
129
+ prompt = self.opts(OPT_PROMPT);
130
+
131
+ // clear placeholder attribute if set
132
+ core.input().attr(placeholderKey, '');
133
+
134
+ if(prompt)
135
+ self.setPrompt(prompt);
136
+
137
+ if($.trim(self.val()).length > 0)
125
138
  self.hidePrompt();
126
139
 
127
140
  self.on({
@@ -208,8 +221,7 @@
208
221
 
209
222
  self.startTimer('prompt', 0.1, function()
210
223
  {
211
- if(self.val().length === 0)
212
- self.showPrompt();
224
+ self.showPrompt();
213
225
  });
214
226
  };
215
227
 
@@ -224,7 +236,12 @@
224
236
  */
225
237
  p.showPrompt = function()
226
238
  {
227
- this.containerElement().removeClass(CSS_HIDE_PROMPT);
239
+ var self = this,
240
+ input = self.input()
241
+ ;
242
+
243
+ if($.trim(self.val()).length === 0 && !input.is(':focus'))
244
+ self.containerElement().removeClass(CSS_HIDE_PROMPT);
228
245
  };
229
246
 
230
247
  /**
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * jQuery TextExt Plugin
3
- * http://alexgorbatchev.com/textext
3
+ * http://textextjs.com
4
4
  *
5
- * @version 1.2.0
5
+ * @version 1.3.1
6
6
  * @copyright Copyright (C) 2011 Alex Gorbatchev. All rights reserved.
7
7
  * @license MIT License
8
8
  */
@@ -1,17 +1,17 @@
1
1
  /**
2
2
  * jQuery TextExt Plugin
3
- * http://alexgorbatchev.com/textext
3
+ * http://textextjs.com
4
4
  *
5
- * @version 1.2.0
5
+ * @version 1.3.1
6
6
  * @copyright Copyright (C) 2011 Alex Gorbatchev. All rights reserved.
7
7
  * @license MIT License
8
8
  */
9
9
  (function($)
10
10
  {
11
11
  /**
12
- * Tags plugin brings in the traditional tag functionality where user can assemble and
12
+ * Tags plugin brings in the traditional tag functionality where user can assemble and
13
13
  * edit list of tags. Tags plugin works especially well together with Autocomplete, Filter,
14
- * Suggestions and Ajax plugins to provide full spectrum of features. It can also work on
14
+ * Suggestions and Ajax plugins to provide full spectrum of features. It can also work on
15
15
  * its own and just do one thing -- tags.
16
16
  *
17
17
  * @author agorbatchev
@@ -32,9 +32,13 @@
32
32
  CSS_DOT_TAG = CSS_DOT + CSS_TAG,
33
33
  CSS_TAGS = 'text-tags',
34
34
  CSS_DOT_TAGS = CSS_DOT + CSS_TAGS,
35
+ CSS_LABEL = 'text-label',
36
+ CSS_DOT_LABEL = CSS_DOT + CSS_LABEL,
37
+ CSS_REMOVE = 'text-remove',
38
+ CSS_DOT_REMOVE = CSS_DOT + CSS_REMOVE,
35
39
 
36
40
  /**
37
- * Tags plugin options are grouped under `tags` when passed to the
41
+ * Tags plugin options are grouped under `tags` when passed to the
38
42
  * `$().textext()` function. For example:
39
43
  *
40
44
  * $('textarea').textext({
@@ -73,7 +77,7 @@
73
77
  * @id TextExtTags.options.tags.items
74
78
  */
75
79
  OPT_ITEMS = 'tags.items',
76
-
80
+
77
81
  /**
78
82
  * HTML source that is used to generate a single tag.
79
83
  *
@@ -84,7 +88,7 @@
84
88
  * @id TextExtTags.options.html.tag
85
89
  */
86
90
  OPT_HTML_TAG = 'html.tag',
87
-
91
+
88
92
  /**
89
93
  * HTML source that is used to generate container for the tags.
90
94
  *
@@ -124,6 +128,35 @@
124
128
  */
125
129
  EVENT_IS_TAG_ALLOWED = 'isTagAllowed',
126
130
 
131
+ /**
132
+ * Tags plugin triggers the `tagClick` event when user clicks on one of the tags. This allows to process
133
+ * the click and potentially change the value of the tag (for example in case of user feedback).
134
+ *
135
+ * $('textarea').textext({...}).bind('tagClick', function(e, tag, value, callback)
136
+ * {
137
+ * var newValue = window.prompt('New value', value);
138
+
139
+ * if(newValue)
140
+ * callback(newValue, true);
141
+ * })
142
+ *
143
+ * Callback argument has the following signature:
144
+ *
145
+ * function(newValue, refocus)
146
+ * {
147
+ * ...
148
+ * }
149
+ *
150
+ * Please check out [example](/manual/examples/tags-changing.html).
151
+ *
152
+ * @name tagClick
153
+ * @version 1.3.0
154
+ * @author s.stok
155
+ * @date 2011/01/23
156
+ * @id TextExtTags.events.tagClick
157
+ */
158
+ EVENT_TAG_CLICK = 'tagClick',
159
+
127
160
  DEFAULT_OPTS = {
128
161
  tags : {
129
162
  enabled : true,
@@ -151,7 +184,6 @@
151
184
  p.init = function(core)
152
185
  {
153
186
  this.baseInit(core, DEFAULT_OPTS);
154
-
155
187
  var self = this,
156
188
  input = self.input(),
157
189
  container
@@ -182,7 +214,7 @@
182
214
  });
183
215
  }
184
216
 
185
- self._originalPadding = {
217
+ self._originalPadding = {
186
218
  left : parseInt(input.css('paddingLeft') || 0),
187
219
  top : parseInt(input.css('paddingTop') || 0)
188
220
  };
@@ -211,7 +243,7 @@
211
243
 
212
244
  //--------------------------------------------------------------------------------
213
245
  // Event handlers
214
-
246
+
215
247
  /**
216
248
  * Reacts to the `postInit` event triggered by the core and sets default tags
217
249
  * if any were specified.
@@ -232,7 +264,7 @@
232
264
 
233
265
  /**
234
266
  * Reacts to the [`getFormData`][1] event triggered by the core. Returns data with the
235
- * weight of 200 to be *greater than the Autocomplete plugin* data weight. The weights
267
+ * weight of 200 to be *greater than the Autocomplete plugin* data weight. The weights
236
268
  * system is covered in greater detail in the [`getFormData`][1] event documentation.
237
269
  *
238
270
  * [1]: /manual/textext.html#getformdata
@@ -312,7 +344,7 @@
312
344
  };
313
345
 
314
346
  /**
315
- * Reacts to the `backspaceKeyDown` event. When backspace key is pressed in an empty text field,
347
+ * Reacts to the `backspaceKeyDown` event. When backspace key is pressed in an empty text field,
316
348
  * deletes last tag from the list.
317
349
  *
318
350
  * @signature TextExtTags.onBackspaceKeyDown(e)
@@ -336,7 +368,7 @@
336
368
  /**
337
369
  * Reacts to the `preInvalidate` event and updates the input box to look like the tags are
338
370
  * positioned inside it.
339
- *
371
+ *
340
372
  * @signature TextExtTags.onPreInvalidate(e)
341
373
  *
342
374
  * @param e {Object} jQuery event.
@@ -351,7 +383,7 @@
351
383
  lastTag = self.tagElements().last(),
352
384
  pos = lastTag.position()
353
385
  ;
354
-
386
+
355
387
  if(lastTag.length > 0)
356
388
  pos.left += lastTag.innerWidth();
357
389
  else
@@ -379,22 +411,42 @@
379
411
  p.onClick = function(e)
380
412
  {
381
413
  var self = this,
414
+ core = self.core(),
382
415
  source = $(e.target),
383
- focus = 0
416
+ focus = 0,
417
+ tag
384
418
  ;
385
419
 
386
420
  if(source.is(CSS_DOT_TAGS))
387
421
  {
388
422
  focus = 1;
389
423
  }
390
- else if(source.is('.text-remove'))
424
+ else if(source.is(CSS_DOT_REMOVE))
391
425
  {
392
426
  self.removeTag(source.parents(CSS_DOT_TAG + ':first'));
393
427
  focus = 1;
394
428
  }
429
+ else if(source.is(CSS_DOT_LABEL))
430
+ {
431
+ tag = source.parents(CSS_DOT_TAG + ':first');
432
+ self.trigger(EVENT_TAG_CLICK, tag, tag.data(CSS_TAG), tagClickCallback);
433
+ }
434
+
435
+ function tagClickCallback(newValue, refocus)
436
+ {
437
+ tag.data(CSS_TAG, newValue);
438
+ tag.find(CSS_DOT_LABEL).text(self.itemManager().itemToString(newValue));
439
+
440
+ self.updateFormCache();
441
+ core.getFormData();
442
+ core.invalidateBounds();
443
+
444
+ if(refocus)
445
+ core.focusInput();
446
+ }
395
447
 
396
448
  if(focus)
397
- self.core().focusInput();
449
+ core.focusInput();
398
450
  };
399
451
 
400
452
  /**
@@ -458,7 +510,7 @@
458
510
  * any of the tags, the tags container is sent under the text area. If cursor
459
511
  * is over any of the tags, the tag container is brought to be over the text
460
512
  * area.
461
- *
513
+ *
462
514
  * @signature TextExtTags.toggleZIndex(e)
463
515
  *
464
516
  * @param e {Object} jQuery event.
@@ -559,7 +611,7 @@
559
611
  *
560
612
  * @signature TextExtTags.getTagElement(tag)
561
613
  *
562
- * @param tag {Object} Tag object in the format that current `ItemManager` can understand.
614
+ * @param tag {Object} Tag object in the format that current `ItemManager` can understand.
563
615
  * Default is `String`.
564
616
 
565
617
  * @author agorbatchev
@@ -583,7 +635,7 @@
583
635
  *
584
636
  * @signature TextExtTags.removeTag(tag)
585
637
  *
586
- * @param tag {Object} Tag object in the format that current `ItemManager` can understand.
638
+ * @param tag {Object} Tag object in the format that current `ItemManager` can understand.
587
639
  * Default is `String`.
588
640
  *
589
641
  * @author agorbatchev
@@ -618,7 +670,7 @@
618
670
  *
619
671
  * @signature TextExtTags.renderTag(tag)
620
672
  *
621
- * @param tag {Object} Tag object in the format that current `ItemManager` can understand.
673
+ * @param tag {Object} Tag object in the format that current `ItemManager` can understand.
622
674
  * Default is `String`.
623
675
  *
624
676
  * @author agorbatchev
@@ -1,8 +1,8 @@
1
1
  .text-core {
2
2
  position: relative;
3
- background: #fff;
4
3
  }
5
4
  .text-core .text-wrap {
5
+ background: #fff;
6
6
  position: absolute;
7
7
  }
8
8
  .text-core .text-wrap textarea,
@@ -0,0 +1,13 @@
1
+ .text-core .text-wrap .text-clear {
2
+ -webkit-box-sizing: border-box;
3
+ -moz-box-sizing: border-box;
4
+ box-sizing: border-box;
5
+ position: absolute;
6
+ top: 0;
7
+ right: 14px;
8
+ width: 22px;
9
+ height: 22px;
10
+ background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAYUlEQVR42mP4////P1IwA5RBNIBr+Pj5+/9Tlx78v373OYoCkBgIY2gACWr7tP63CO8BanoBlmyfuQssBsIYGtAVLNpwEsMADA0gAFMIw+hOpEwDSU4i2dMkByvJEUcsAABHaALCQIZDrAAAAABJRU5ErkJggg==") 50% 50% no-repeat;
11
+ cursor: pointer;
12
+ z-index: 2;
13
+ }
metadata CHANGED
@@ -1,16 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: textext-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
5
- prerelease:
4
+ version: 0.2.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Jeff Pollard
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-02-05 00:00:00.000000000 Z
13
- dependencies: []
11
+ date: 2014-01-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
14
27
  description: Adds the jQuery TextExt plugin to the Rails 3.1 asset pipeline
15
28
  email:
16
29
  - jeff.pollard@gmail.com
@@ -23,7 +36,6 @@ files:
23
36
  - LICENSE
24
37
  - README.md
25
38
  - Rakefile
26
- - latest.tar.gz
27
39
  - lib/textext-rails.rb
28
40
  - lib/textext/rails.rb
29
41
  - lib/textext/rails/engine.rb
@@ -33,6 +45,7 @@ files:
33
45
  - vendor/assets/javascripts/textext.plugin.ajax.js
34
46
  - vendor/assets/javascripts/textext.plugin.arrow.js
35
47
  - vendor/assets/javascripts/textext.plugin.autocomplete.js
48
+ - vendor/assets/javascripts/textext.plugin.clear.js
36
49
  - vendor/assets/javascripts/textext.plugin.filter.js
37
50
  - vendor/assets/javascripts/textext.plugin.focus.js
38
51
  - vendor/assets/javascripts/textext.plugin.prompt.js
@@ -43,31 +56,31 @@ files:
43
56
  - vendor/assets/stylesheets/textext.core.css
44
57
  - vendor/assets/stylesheets/textext.plugin.arrow.css
45
58
  - vendor/assets/stylesheets/textext.plugin.autocomplete.css
59
+ - vendor/assets/stylesheets/textext.plugin.clear.css
46
60
  - vendor/assets/stylesheets/textext.plugin.focus.css
47
61
  - vendor/assets/stylesheets/textext.plugin.prompt.css
48
62
  - vendor/assets/stylesheets/textext.plugin.tags.css
49
- homepage: ''
63
+ homepage: https://github.com/Fluxx/textext-rails
50
64
  licenses: []
65
+ metadata: {}
51
66
  post_install_message:
52
67
  rdoc_options: []
53
68
  require_paths:
54
69
  - lib
55
70
  required_ruby_version: !ruby/object:Gem::Requirement
56
- none: false
57
71
  requirements:
58
- - - ! '>='
72
+ - - '>='
59
73
  - !ruby/object:Gem::Version
60
74
  version: '0'
61
75
  required_rubygems_version: !ruby/object:Gem::Requirement
62
- none: false
63
76
  requirements:
64
- - - ! '>='
77
+ - - '>='
65
78
  - !ruby/object:Gem::Version
66
79
  version: '0'
67
80
  requirements: []
68
81
  rubyforge_project: textext-rails
69
- rubygems_version: 1.8.11
82
+ rubygems_version: 2.0.3
70
83
  signing_key:
71
- specification_version: 3
84
+ specification_version: 4
72
85
  summary: Adds the jQuery TextExt plugin to the Rails 3.1 asset pipeline
73
86
  test_files: []
Binary file