message_train 0.4.6 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +7 -1
- data/README.rdoc +1 -1
- data/VERSION +1 -1
- data/app/assets/javascripts/ckeditor/config.js.coffee +48 -0
- data/app/assets/javascripts/message_train.js +25 -50
- data/app/assets/stylesheets/message_train.scss +6 -5
- data/app/controllers/message_train/messages_controller.rb +1 -1
- data/app/controllers/message_train/participants_controller.rb +4 -0
- data/app/views/message_train/messages/_form.html.haml +25 -4
- data/message_train.gemspec +20 -11
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/features/messages_spec.rb +9 -17
- data/spec/support/shared_connection.rb +0 -1
- data/spec/support/utilities.rb +51 -0
- metadata +62 -9
- data/app/views/message_train/participants/_field.html.haml +0 -4
- data/spec/support/wysihtml5_helper.rb +0 -8
- data/vendor/assets/javascripts/bootstrap-tags.js +0 -623
- data/vendor/assets/stylesheets/bootstrap-tags.css +0 -78
@@ -1,623 +0,0 @@
|
|
1
|
-
/*!
|
2
|
-
* bootstrap-tags 1.1.5
|
3
|
-
* https://github.com/maxwells/bootstrap-tags
|
4
|
-
* Copyright 2013 Max Lahey; Licensed MIT
|
5
|
-
*/
|
6
|
-
|
7
|
-
(function($) {
|
8
|
-
(function() {
|
9
|
-
window.Tags || (window.Tags = {});
|
10
|
-
jQuery(function() {
|
11
|
-
$.tags = function(element, options) {
|
12
|
-
var key, tag, tagData, value, _i, _len, _ref, _this = this;
|
13
|
-
if (options == null) {
|
14
|
-
options = {};
|
15
|
-
}
|
16
|
-
for (key in options) {
|
17
|
-
value = options[key];
|
18
|
-
this[key] = value;
|
19
|
-
}
|
20
|
-
this.bootstrapVersion || (this.bootstrapVersion = "3");
|
21
|
-
this.readOnly || (this.readOnly = false);
|
22
|
-
this.suggestOnClick || (this.suggestOnClick = false);
|
23
|
-
this.suggestions || (this.suggestions = []);
|
24
|
-
this.restrictTo = options.restrictTo != null ? options.restrictTo.concat(this.suggestions) : false;
|
25
|
-
this.exclude || (this.exclude = false);
|
26
|
-
this.displayPopovers = options.popovers != null ? true : options.popoverData != null;
|
27
|
-
this.popoverTrigger || (this.popoverTrigger = "hover");
|
28
|
-
this.tagClass || (this.tagClass = "btn-info");
|
29
|
-
this.tagSize || (this.tagSize = "md");
|
30
|
-
this.promptText || (this.promptText = "Enter tags...");
|
31
|
-
this.caseInsensitive || (this.caseInsensitive = false);
|
32
|
-
this.readOnlyEmptyMessage || (this.readOnlyEmptyMessage = "No tags to display...");
|
33
|
-
this.maxNumTags || (this.maxNumTags = -1);
|
34
|
-
this.beforeAddingTag || (this.beforeAddingTag = function(tag) {});
|
35
|
-
this.afterAddingTag || (this.afterAddingTag = function(tag) {});
|
36
|
-
this.beforeDeletingTag || (this.beforeDeletingTag = function(tag) {});
|
37
|
-
this.afterDeletingTag || (this.afterDeletingTag = function(tag) {});
|
38
|
-
this.definePopover || (this.definePopover = function(tag) {
|
39
|
-
return 'associated content for "' + tag + '"';
|
40
|
-
});
|
41
|
-
this.excludes || (this.excludes = function() {
|
42
|
-
return false;
|
43
|
-
});
|
44
|
-
this.tagRemoved || (this.tagRemoved = function(tag) {});
|
45
|
-
this.pressedReturn || (this.pressedReturn = function(e) {});
|
46
|
-
this.pressedDelete || (this.pressedDelete = function(e) {});
|
47
|
-
this.pressedDown || (this.pressedDown = function(e) {});
|
48
|
-
this.pressedUp || (this.pressedUp = function(e) {});
|
49
|
-
this.$element = $(element);
|
50
|
-
if (options.tagData != null) {
|
51
|
-
this.tagsArray = options.tagData;
|
52
|
-
} else {
|
53
|
-
tagData = $(".tag-data", this.$element).html();
|
54
|
-
this.tagsArray = tagData != null ? tagData.split(",") : [];
|
55
|
-
}
|
56
|
-
if (options.popoverData) {
|
57
|
-
this.popoverArray = options.popoverData;
|
58
|
-
} else {
|
59
|
-
this.popoverArray = [];
|
60
|
-
_ref = this.tagsArray;
|
61
|
-
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
62
|
-
tag = _ref[_i];
|
63
|
-
this.popoverArray.push(null);
|
64
|
-
}
|
65
|
-
}
|
66
|
-
this.getTags = function() {
|
67
|
-
return _this.tagsArray;
|
68
|
-
};
|
69
|
-
this.getTagsContent = function() {
|
70
|
-
return _this.popoverArray;
|
71
|
-
};
|
72
|
-
this.getTagsWithContent = function() {
|
73
|
-
var combined, i, _j, _ref1;
|
74
|
-
combined = [];
|
75
|
-
for (i = _j = 0, _ref1 = _this.tagsArray.length - 1; 0 <= _ref1 ? _j <= _ref1 : _j >= _ref1; i = 0 <= _ref1 ? ++_j : --_j) {
|
76
|
-
combined.push({
|
77
|
-
tag: _this.tagsArray[i],
|
78
|
-
content: _this.popoverArray[i]
|
79
|
-
});
|
80
|
-
}
|
81
|
-
return combined;
|
82
|
-
};
|
83
|
-
this.getTag = function(tag) {
|
84
|
-
var index;
|
85
|
-
index = _this.tagsArray.indexOf(tag);
|
86
|
-
if (index > -1) {
|
87
|
-
return _this.tagsArray[index];
|
88
|
-
} else {
|
89
|
-
return null;
|
90
|
-
}
|
91
|
-
};
|
92
|
-
this.getTagWithContent = function(tag) {
|
93
|
-
var index;
|
94
|
-
index = _this.tagsArray.indexOf(tag);
|
95
|
-
return {
|
96
|
-
tag: _this.tagsArray[index],
|
97
|
-
content: _this.popoverArray[index]
|
98
|
-
};
|
99
|
-
};
|
100
|
-
this.hasTag = function(tag) {
|
101
|
-
return _this.tagsArray.indexOf(tag) > -1;
|
102
|
-
};
|
103
|
-
this.removeTagClicked = function(e) {
|
104
|
-
if (e.currentTarget.tagName === "A") {
|
105
|
-
_this.removeTag($("span", e.currentTarget.parentElement).html());
|
106
|
-
$(e.currentTarget.parentNode).remove();
|
107
|
-
}
|
108
|
-
return _this;
|
109
|
-
};
|
110
|
-
this.removeLastTag = function() {
|
111
|
-
if (_this.tagsArray.length > 0) {
|
112
|
-
_this.removeTag(_this.tagsArray[_this.tagsArray.length - 1]);
|
113
|
-
if (_this.canAddByMaxNum()) {
|
114
|
-
_this.enableInput();
|
115
|
-
}
|
116
|
-
}
|
117
|
-
return _this;
|
118
|
-
};
|
119
|
-
this.removeTag = function(tag) {
|
120
|
-
if (_this.tagsArray.indexOf(tag) > -1) {
|
121
|
-
if (_this.beforeDeletingTag(tag) === false) {
|
122
|
-
return;
|
123
|
-
}
|
124
|
-
_this.popoverArray.splice(_this.tagsArray.indexOf(tag), 1);
|
125
|
-
_this.tagsArray.splice(_this.tagsArray.indexOf(tag), 1);
|
126
|
-
_this.renderTags();
|
127
|
-
_this.afterDeletingTag(tag);
|
128
|
-
if (_this.canAddByMaxNum()) {
|
129
|
-
_this.enableInput();
|
130
|
-
}
|
131
|
-
}
|
132
|
-
return _this;
|
133
|
-
};
|
134
|
-
this.canAddByRestriction = function(tag) {
|
135
|
-
return this.restrictTo === false || this.restrictTo.indexOf(tag) !== -1;
|
136
|
-
};
|
137
|
-
this.canAddByExclusion = function(tag) {
|
138
|
-
return (this.exclude === false || this.exclude.indexOf(tag) === -1) && !this.excludes(tag);
|
139
|
-
};
|
140
|
-
this.canAddByMaxNum = function() {
|
141
|
-
return this.maxNumTags === -1 || this.tagsArray.length < this.maxNumTags;
|
142
|
-
};
|
143
|
-
this.addTag = function(tag) {
|
144
|
-
var associatedContent;
|
145
|
-
if (_this.canAddByRestriction(tag) && !_this.hasTag(tag) && tag.length > 0 && _this.canAddByExclusion(tag) && _this.canAddByMaxNum()) {
|
146
|
-
if (_this.beforeAddingTag(tag) === false) {
|
147
|
-
return;
|
148
|
-
}
|
149
|
-
associatedContent = _this.definePopover(tag);
|
150
|
-
_this.popoverArray.push(associatedContent || null);
|
151
|
-
_this.tagsArray.push(tag);
|
152
|
-
_this.afterAddingTag(tag);
|
153
|
-
_this.renderTags();
|
154
|
-
if (!_this.canAddByMaxNum()) {
|
155
|
-
_this.disableInput();
|
156
|
-
}
|
157
|
-
}
|
158
|
-
return _this;
|
159
|
-
};
|
160
|
-
this.addTagWithContent = function(tag, content) {
|
161
|
-
if (_this.canAddByRestriction(tag) && !_this.hasTag(tag) && tag.length > 0) {
|
162
|
-
if (_this.beforeAddingTag(tag) === false) {
|
163
|
-
return;
|
164
|
-
}
|
165
|
-
_this.tagsArray.push(tag);
|
166
|
-
_this.popoverArray.push(content);
|
167
|
-
_this.afterAddingTag(tag);
|
168
|
-
_this.renderTags();
|
169
|
-
}
|
170
|
-
return _this;
|
171
|
-
};
|
172
|
-
this.renameTag = function(name, newName) {
|
173
|
-
_this.tagsArray[_this.tagsArray.indexOf(name)] = newName;
|
174
|
-
_this.renderTags();
|
175
|
-
return _this;
|
176
|
-
};
|
177
|
-
this.setPopover = function(tag, popoverContent) {
|
178
|
-
_this.popoverArray[_this.tagsArray.indexOf(tag)] = popoverContent;
|
179
|
-
_this.renderTags();
|
180
|
-
return _this;
|
181
|
-
};
|
182
|
-
this.clickHandler = function(e) {
|
183
|
-
return _this.makeSuggestions(e, true);
|
184
|
-
};
|
185
|
-
this.keyDownHandler = function(e) {
|
186
|
-
var k, numSuggestions;
|
187
|
-
k = e.keyCode != null ? e.keyCode : e.which;
|
188
|
-
switch (k) {
|
189
|
-
case 13:
|
190
|
-
e.preventDefault();
|
191
|
-
_this.pressedReturn(e);
|
192
|
-
tag = e.target.value;
|
193
|
-
if (_this.suggestedIndex !== -1) {
|
194
|
-
tag = _this.suggestionList[_this.suggestedIndex];
|
195
|
-
}
|
196
|
-
_this.addTag(tag);
|
197
|
-
e.target.value = "";
|
198
|
-
_this.renderTags();
|
199
|
-
return _this.hideSuggestions();
|
200
|
-
|
201
|
-
case 46:
|
202
|
-
case 8:
|
203
|
-
_this.pressedDelete(e);
|
204
|
-
if (e.target.value === "") {
|
205
|
-
_this.removeLastTag();
|
206
|
-
}
|
207
|
-
if (e.target.value.length === 1) {
|
208
|
-
return _this.hideSuggestions();
|
209
|
-
}
|
210
|
-
break;
|
211
|
-
|
212
|
-
case 40:
|
213
|
-
_this.pressedDown(e);
|
214
|
-
if (_this.input.val() === "" && (_this.suggestedIndex === -1 || _this.suggestedIndex == null)) {
|
215
|
-
_this.makeSuggestions(e, true);
|
216
|
-
}
|
217
|
-
numSuggestions = _this.suggestionList.length;
|
218
|
-
_this.suggestedIndex = _this.suggestedIndex < numSuggestions - 1 ? _this.suggestedIndex + 1 : numSuggestions - 1;
|
219
|
-
_this.selectSuggested(_this.suggestedIndex);
|
220
|
-
if (_this.suggestedIndex >= 0) {
|
221
|
-
return _this.scrollSuggested(_this.suggestedIndex);
|
222
|
-
}
|
223
|
-
break;
|
224
|
-
|
225
|
-
case 38:
|
226
|
-
_this.pressedUp(e);
|
227
|
-
_this.suggestedIndex = _this.suggestedIndex > 0 ? _this.suggestedIndex - 1 : 0;
|
228
|
-
_this.selectSuggested(_this.suggestedIndex);
|
229
|
-
if (_this.suggestedIndex >= 0) {
|
230
|
-
return _this.scrollSuggested(_this.suggestedIndex);
|
231
|
-
}
|
232
|
-
break;
|
233
|
-
|
234
|
-
case 9:
|
235
|
-
case 27:
|
236
|
-
_this.hideSuggestions();
|
237
|
-
return _this.suggestedIndex = -1;
|
238
|
-
}
|
239
|
-
};
|
240
|
-
this.keyUpHandler = function(e) {
|
241
|
-
var k;
|
242
|
-
k = e.keyCode != null ? e.keyCode : e.which;
|
243
|
-
if (k !== 40 && k !== 38 && k !== 27) {
|
244
|
-
return _this.makeSuggestions(e, false);
|
245
|
-
}
|
246
|
-
};
|
247
|
-
this.getSuggestions = function(str, overrideLengthCheck) {
|
248
|
-
var _this = this;
|
249
|
-
this.suggestionList = [];
|
250
|
-
if (this.caseInsensitive) {
|
251
|
-
str = str.toLowerCase();
|
252
|
-
}
|
253
|
-
$.each(this.suggestions, function(i, suggestion) {
|
254
|
-
var suggestionVal;
|
255
|
-
suggestionVal = _this.caseInsensitive ? suggestion.substring(0, str.length).toLowerCase() : suggestion.substring(0, str.length);
|
256
|
-
if (_this.tagsArray.indexOf(suggestion) < 0 && suggestionVal === str && (str.length > 0 || overrideLengthCheck)) {
|
257
|
-
return _this.suggestionList.push(suggestion);
|
258
|
-
}
|
259
|
-
});
|
260
|
-
return this.suggestionList;
|
261
|
-
};
|
262
|
-
this.makeSuggestions = function(e, overrideLengthCheck, val) {
|
263
|
-
if (val == null) {
|
264
|
-
val = e.target.value != null ? e.target.value : e.target.textContent;
|
265
|
-
}
|
266
|
-
_this.suggestedIndex = -1;
|
267
|
-
_this.$suggestionList.html("");
|
268
|
-
$.each(_this.getSuggestions(val, overrideLengthCheck), function(i, suggestion) {
|
269
|
-
return _this.$suggestionList.append(_this.template("tags_suggestion", {
|
270
|
-
suggestion: suggestion
|
271
|
-
}));
|
272
|
-
});
|
273
|
-
_this.$(".tags-suggestion").mouseover(_this.selectSuggestedMouseOver);
|
274
|
-
_this.$(".tags-suggestion").click(_this.suggestedClicked);
|
275
|
-
if (_this.suggestionList.length > 0) {
|
276
|
-
return _this.showSuggestions();
|
277
|
-
} else {
|
278
|
-
return _this.hideSuggestions();
|
279
|
-
}
|
280
|
-
};
|
281
|
-
this.suggestedClicked = function(e) {
|
282
|
-
tag = e.target.textContent;
|
283
|
-
if (_this.suggestedIndex !== -1) {
|
284
|
-
tag = _this.suggestionList[_this.suggestedIndex];
|
285
|
-
}
|
286
|
-
_this.addTag(tag);
|
287
|
-
_this.input.val("");
|
288
|
-
_this.makeSuggestions(e, false, "");
|
289
|
-
_this.input.focus();
|
290
|
-
return _this.hideSuggestions();
|
291
|
-
};
|
292
|
-
this.hideSuggestions = function() {
|
293
|
-
return _this.$(".tags-suggestion-list").css({
|
294
|
-
display: "none"
|
295
|
-
});
|
296
|
-
};
|
297
|
-
this.showSuggestions = function() {
|
298
|
-
return _this.$(".tags-suggestion-list").css({
|
299
|
-
display: "block"
|
300
|
-
});
|
301
|
-
};
|
302
|
-
this.selectSuggestedMouseOver = function(e) {
|
303
|
-
$(".tags-suggestion").removeClass("tags-suggestion-highlighted");
|
304
|
-
$(e.target).addClass("tags-suggestion-highlighted");
|
305
|
-
$(e.target).mouseout(_this.selectSuggestedMousedOut);
|
306
|
-
return _this.suggestedIndex = _this.$(".tags-suggestion").index($(e.target));
|
307
|
-
};
|
308
|
-
this.selectSuggestedMousedOut = function(e) {
|
309
|
-
return $(e.target).removeClass("tags-suggestion-highlighted");
|
310
|
-
};
|
311
|
-
this.selectSuggested = function(i) {
|
312
|
-
var tagElement;
|
313
|
-
$(".tags-suggestion").removeClass("tags-suggestion-highlighted");
|
314
|
-
tagElement = _this.$(".tags-suggestion").eq(i);
|
315
|
-
return tagElement.addClass("tags-suggestion-highlighted");
|
316
|
-
};
|
317
|
-
this.scrollSuggested = function(i) {
|
318
|
-
var pos, tagElement, topElement, topPos;
|
319
|
-
tagElement = _this.$(".tags-suggestion").eq(i);
|
320
|
-
topElement = _this.$(".tags-suggestion").eq(0);
|
321
|
-
pos = tagElement.position();
|
322
|
-
topPos = topElement.position();
|
323
|
-
if (pos != null) {
|
324
|
-
return _this.$(".tags-suggestion-list").scrollTop(pos.top - topPos.top);
|
325
|
-
}
|
326
|
-
};
|
327
|
-
this.adjustInputPosition = function() {
|
328
|
-
var pBottom, pLeft, pTop, pWidth, tagElement, tagPosition;
|
329
|
-
tagElement = _this.$(".tag").last();
|
330
|
-
tagPosition = tagElement.position();
|
331
|
-
pLeft = tagPosition != null ? tagPosition.left + tagElement.outerWidth(true) : 12;
|
332
|
-
pTop = tagPosition != null ? tagPosition.top : 0;
|
333
|
-
pWidth = _this.$element.width() - pLeft;
|
334
|
-
$(".tags-input", _this.$element).css({
|
335
|
-
paddingLeft: Math.max(pLeft, 0),
|
336
|
-
paddingTop: Math.max(pTop, 0),
|
337
|
-
width: pWidth
|
338
|
-
});
|
339
|
-
pBottom = tagPosition != null ? tagPosition.top + tagElement.outerHeight(true) : 22;
|
340
|
-
return _this.$element.css({
|
341
|
-
paddingBottom: pBottom - _this.$element.height()
|
342
|
-
});
|
343
|
-
};
|
344
|
-
this.renderTags = function() {
|
345
|
-
var tagList;
|
346
|
-
tagList = _this.$(".tags");
|
347
|
-
tagList.html("");
|
348
|
-
_this.input.attr("placeholder", _this.tagsArray.length === 0 ? _this.promptText : "");
|
349
|
-
$.each(_this.tagsArray, function(i, tag) {
|
350
|
-
tag = $(_this.formatTag(i, tag));
|
351
|
-
$("a", tag).click(_this.removeTagClicked);
|
352
|
-
$("a", tag).mouseover(_this.toggleCloseColor);
|
353
|
-
$("a", tag).mouseout(_this.toggleCloseColor);
|
354
|
-
if (_this.displayPopovers) {
|
355
|
-
_this.initializePopoverFor(tag, _this.tagsArray[i], _this.popoverArray[i]);
|
356
|
-
}
|
357
|
-
return tagList.append(tag);
|
358
|
-
});
|
359
|
-
return _this.adjustInputPosition();
|
360
|
-
};
|
361
|
-
this.renderReadOnly = function() {
|
362
|
-
var tagList;
|
363
|
-
tagList = _this.$(".tags");
|
364
|
-
tagList.html(_this.tagsArray.length === 0 ? _this.readOnlyEmptyMessage : "");
|
365
|
-
return $.each(_this.tagsArray, function(i, tag) {
|
366
|
-
tag = $(_this.formatTag(i, tag, true));
|
367
|
-
if (_this.displayPopovers) {
|
368
|
-
_this.initializePopoverFor(tag, _this.tagsArray[i], _this.popoverArray[i]);
|
369
|
-
}
|
370
|
-
return tagList.append(tag);
|
371
|
-
});
|
372
|
-
};
|
373
|
-
this.disableInput = function() {
|
374
|
-
return this.$("input").prop("disabled", true);
|
375
|
-
};
|
376
|
-
this.enableInput = function() {
|
377
|
-
return this.$("input").prop("disabled", false);
|
378
|
-
};
|
379
|
-
this.initializePopoverFor = function(tag, title, content) {
|
380
|
-
options = {
|
381
|
-
title: title,
|
382
|
-
content: content,
|
383
|
-
placement: "bottom"
|
384
|
-
};
|
385
|
-
if (_this.popoverTrigger === "hoverShowClickHide") {
|
386
|
-
$(tag).mouseover(function() {
|
387
|
-
$(tag).popover("show");
|
388
|
-
return $(".tag").not(tag).popover("hide");
|
389
|
-
});
|
390
|
-
$(document).click(function() {
|
391
|
-
return $(tag).popover("hide");
|
392
|
-
});
|
393
|
-
} else {
|
394
|
-
options.trigger = _this.popoverTrigger;
|
395
|
-
}
|
396
|
-
return $(tag).popover(options);
|
397
|
-
};
|
398
|
-
this.toggleCloseColor = function(e) {
|
399
|
-
var opacity, tagAnchor;
|
400
|
-
tagAnchor = $(e.currentTarget);
|
401
|
-
opacity = tagAnchor.css("opacity");
|
402
|
-
opacity = opacity < .8 ? 1 : .6;
|
403
|
-
return tagAnchor.css({
|
404
|
-
opacity: opacity
|
405
|
-
});
|
406
|
-
};
|
407
|
-
this.formatTag = function(i, tag, isReadOnly) {
|
408
|
-
var escapedTag;
|
409
|
-
if (isReadOnly == null) {
|
410
|
-
isReadOnly = false;
|
411
|
-
}
|
412
|
-
escapedTag = tag.replace("<", "<").replace(">", ">");
|
413
|
-
return _this.template("tag", {
|
414
|
-
tag: escapedTag,
|
415
|
-
tagClass: _this.tagClass,
|
416
|
-
isPopover: _this.displayPopovers,
|
417
|
-
isReadOnly: isReadOnly,
|
418
|
-
tagSize: _this.tagSize
|
419
|
-
});
|
420
|
-
};
|
421
|
-
this.addDocumentListeners = function() {
|
422
|
-
return $(document).mouseup(function(e) {
|
423
|
-
var container;
|
424
|
-
container = _this.$(".tags-suggestion-list");
|
425
|
-
if (container.has(e.target).length === 0) {
|
426
|
-
return _this.hideSuggestions();
|
427
|
-
}
|
428
|
-
});
|
429
|
-
};
|
430
|
-
this.template = function(name, options) {
|
431
|
-
return Tags.Templates.Template(this.getBootstrapVersion(), name, options);
|
432
|
-
};
|
433
|
-
this.$ = function(selector) {
|
434
|
-
return $(selector, this.$element);
|
435
|
-
};
|
436
|
-
this.getBootstrapVersion = function() {
|
437
|
-
return Tags.bootstrapVersion || this.bootstrapVersion;
|
438
|
-
};
|
439
|
-
this.initializeDom = function() {
|
440
|
-
return this.$element.append(this.template("tags_container"));
|
441
|
-
};
|
442
|
-
this.init = function() {
|
443
|
-
this.$element.addClass("bootstrap-tags").addClass("bootstrap-" + this.getBootstrapVersion());
|
444
|
-
this.initializeDom();
|
445
|
-
if (this.readOnly) {
|
446
|
-
this.renderReadOnly();
|
447
|
-
this.removeTag = function() {};
|
448
|
-
this.removeTagClicked = function() {};
|
449
|
-
this.removeLastTag = function() {};
|
450
|
-
this.addTag = function() {};
|
451
|
-
this.addTagWithContent = function() {};
|
452
|
-
this.renameTag = function() {};
|
453
|
-
return this.setPopover = function() {};
|
454
|
-
} else {
|
455
|
-
this.input = $(this.template("input", {
|
456
|
-
tagSize: this.tagSize
|
457
|
-
}));
|
458
|
-
if (this.suggestOnClick) {
|
459
|
-
this.input.click(this.clickHandler);
|
460
|
-
}
|
461
|
-
this.input.keydown(this.keyDownHandler);
|
462
|
-
this.input.keyup(this.keyUpHandler);
|
463
|
-
this.$element.append(this.input);
|
464
|
-
this.$suggestionList = $(this.template("suggestion_list"));
|
465
|
-
this.$element.append(this.$suggestionList);
|
466
|
-
this.renderTags();
|
467
|
-
this.removeTag(''); // This hack added by Karen to remove blank tags
|
468
|
-
if (!this.canAddByMaxNum()) {
|
469
|
-
this.disableInput();
|
470
|
-
}
|
471
|
-
return this.addDocumentListeners();
|
472
|
-
}
|
473
|
-
};
|
474
|
-
this.init();
|
475
|
-
return this;
|
476
|
-
};
|
477
|
-
return $.fn.tags = function(options) {
|
478
|
-
var stopOn, tagsObject;
|
479
|
-
tagsObject = {};
|
480
|
-
stopOn = typeof options === "number" ? options : -1;
|
481
|
-
this.each(function(i, el) {
|
482
|
-
var $el;
|
483
|
-
$el = $(el);
|
484
|
-
if ($el.data("tags") == null) {
|
485
|
-
$el.data("tags", new $.tags(this, options));
|
486
|
-
}
|
487
|
-
if (stopOn === i || i === 0) {
|
488
|
-
return tagsObject = $el.data("tags");
|
489
|
-
}
|
490
|
-
});
|
491
|
-
return tagsObject;
|
492
|
-
};
|
493
|
-
});
|
494
|
-
}).call(this);
|
495
|
-
(function() {
|
496
|
-
window.Tags || (window.Tags = {});
|
497
|
-
Tags.Helpers || (Tags.Helpers = {});
|
498
|
-
Tags.Helpers.addPadding = function(string, amount, doPadding) {
|
499
|
-
if (amount == null) {
|
500
|
-
amount = 1;
|
501
|
-
}
|
502
|
-
if (doPadding == null) {
|
503
|
-
doPadding = true;
|
504
|
-
}
|
505
|
-
if (!doPadding) {
|
506
|
-
return string;
|
507
|
-
}
|
508
|
-
if (amount === 0) {
|
509
|
-
return string;
|
510
|
-
}
|
511
|
-
return Tags.Helpers.addPadding(" " + string + " ", amount - 1);
|
512
|
-
};
|
513
|
-
}).call(this);
|
514
|
-
(function() {
|
515
|
-
var _base;
|
516
|
-
window.Tags || (window.Tags = {});
|
517
|
-
Tags.Templates || (Tags.Templates = {});
|
518
|
-
(_base = Tags.Templates)["2"] || (_base["2"] = {});
|
519
|
-
Tags.Templates["2"].input = function(options) {
|
520
|
-
var tagSize;
|
521
|
-
if (options == null) {
|
522
|
-
options = {};
|
523
|
-
}
|
524
|
-
tagSize = function() {
|
525
|
-
switch (options.tagSize) {
|
526
|
-
case "sm":
|
527
|
-
return "small";
|
528
|
-
|
529
|
-
case "md":
|
530
|
-
return "medium";
|
531
|
-
|
532
|
-
case "lg":
|
533
|
-
return "large";
|
534
|
-
}
|
535
|
-
}();
|
536
|
-
return "<input type='text' class='tags-input input-" + tagSize + "' />";
|
537
|
-
};
|
538
|
-
}).call(this);
|
539
|
-
(function() {
|
540
|
-
var _base;
|
541
|
-
window.Tags || (window.Tags = {});
|
542
|
-
Tags.Templates || (Tags.Templates = {});
|
543
|
-
(_base = Tags.Templates)["2"] || (_base["2"] = {});
|
544
|
-
Tags.Templates["2"].tag = function(options) {
|
545
|
-
if (options == null) {
|
546
|
-
options = {};
|
547
|
-
}
|
548
|
-
return "<div class='tag label " + options.tagClass + " " + options.tagSize + "' " + (options.isPopover ? "rel='popover'" : "") + "> <span>" + Tags.Helpers.addPadding(options.tag, 2, options.isReadOnly) + "</span> " + (options.isReadOnly ? "" : "<a><i class='remove icon-remove-sign icon-white' /></a>") + " </div>";
|
549
|
-
};
|
550
|
-
}).call(this);
|
551
|
-
(function() {
|
552
|
-
var _base;
|
553
|
-
window.Tags || (window.Tags = {});
|
554
|
-
Tags.Templates || (Tags.Templates = {});
|
555
|
-
(_base = Tags.Templates)["3"] || (_base["3"] = {});
|
556
|
-
Tags.Templates["3"].input = function(options) {
|
557
|
-
if (options == null) {
|
558
|
-
options = {};
|
559
|
-
}
|
560
|
-
return "<input type='text' class='form-control tags-input input-" + options.tagSize + "' />";
|
561
|
-
};
|
562
|
-
}).call(this);
|
563
|
-
(function() {
|
564
|
-
var _base;
|
565
|
-
window.Tags || (window.Tags = {});
|
566
|
-
Tags.Templates || (Tags.Templates = {});
|
567
|
-
(_base = Tags.Templates)["3"] || (_base["3"] = {});
|
568
|
-
Tags.Templates["3"].tag = function(options) {
|
569
|
-
if (options == null) {
|
570
|
-
options = {};
|
571
|
-
}
|
572
|
-
return "<div class='tag label " + options.tagClass + " " + options.tagSize + "' " + (options.isPopover ? "rel='popover'" : "") + "> <span>" + Tags.Helpers.addPadding(options.tag, 2, options.isReadOnly) + "</span> " + (options.isReadOnly ? "" : "<a><i class='remove glyphicon glyphicon-remove-sign glyphicon-white' /></a>") + " </div>";
|
573
|
-
};
|
574
|
-
}).call(this);
|
575
|
-
(function() {
|
576
|
-
var _base;
|
577
|
-
window.Tags || (window.Tags = {});
|
578
|
-
Tags.Templates || (Tags.Templates = {});
|
579
|
-
(_base = Tags.Templates).shared || (_base.shared = {});
|
580
|
-
Tags.Templates.shared.suggestion_list = function(options) {
|
581
|
-
if (options == null) {
|
582
|
-
options = {};
|
583
|
-
}
|
584
|
-
return '<ul class="tags-suggestion-list dropdown-menu"></ul>';
|
585
|
-
};
|
586
|
-
}).call(this);
|
587
|
-
(function() {
|
588
|
-
var _base;
|
589
|
-
window.Tags || (window.Tags = {});
|
590
|
-
Tags.Templates || (Tags.Templates = {});
|
591
|
-
(_base = Tags.Templates).shared || (_base.shared = {});
|
592
|
-
Tags.Templates.shared.tags_container = function(options) {
|
593
|
-
if (options == null) {
|
594
|
-
options = {};
|
595
|
-
}
|
596
|
-
return '<div class="tags"></div>';
|
597
|
-
};
|
598
|
-
}).call(this);
|
599
|
-
(function() {
|
600
|
-
var _base;
|
601
|
-
window.Tags || (window.Tags = {});
|
602
|
-
Tags.Templates || (Tags.Templates = {});
|
603
|
-
(_base = Tags.Templates).shared || (_base.shared = {});
|
604
|
-
Tags.Templates.shared.tags_suggestion = function(options) {
|
605
|
-
if (options == null) {
|
606
|
-
options = {};
|
607
|
-
}
|
608
|
-
return "<li class='tags-suggestion'>" + options.suggestion + "</li>";
|
609
|
-
};
|
610
|
-
}).call(this);
|
611
|
-
(function() {
|
612
|
-
window.Tags || (window.Tags = {});
|
613
|
-
Tags.Templates || (Tags.Templates = {});
|
614
|
-
Tags.Templates.Template = function(version, templateName, options) {
|
615
|
-
if (Tags.Templates[version] != null) {
|
616
|
-
if (Tags.Templates[version][templateName] != null) {
|
617
|
-
return Tags.Templates[version][templateName](options);
|
618
|
-
}
|
619
|
-
}
|
620
|
-
return Tags.Templates.shared[templateName](options);
|
621
|
-
};
|
622
|
-
}).call(this);
|
623
|
-
})(window.jQuery);
|