message_train 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.document +5 -0
- data/.rspec +1 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +7 -0
- data/Gemfile +51 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +83 -0
- data/Rakefile +71 -0
- data/VERSION +1 -0
- data/app/assets/javascripts/message_train.js +138 -0
- data/app/assets/stylesheets/message_train.scss +107 -0
- data/app/controllers/message_train/application_controller.rb +64 -0
- data/app/controllers/message_train/boxes_controller.rb +37 -0
- data/app/controllers/message_train/conversations_controller.rb +38 -0
- data/app/controllers/message_train/messages_controller.rb +74 -0
- data/app/controllers/message_train/participants_controller.rb +36 -0
- data/app/helpers/message_train/application_helper.rb +4 -0
- data/app/helpers/message_train/boxes_helper.rb +30 -0
- data/app/helpers/message_train/conversations_helper.rb +73 -0
- data/app/helpers/message_train/messages_helper.rb +58 -0
- data/app/models/message_train/attachment.rb +17 -0
- data/app/models/message_train/box.rb +268 -0
- data/app/models/message_train/conversation.rb +101 -0
- data/app/models/message_train/ignore.rb +18 -0
- data/app/models/message_train/message.rb +146 -0
- data/app/models/message_train/receipt.rb +70 -0
- data/app/views/application/404.html.haml +3 -0
- data/app/views/message_train/application/results.json.jbuilder +8 -0
- data/app/views/message_train/boxes/_dropdown_list.html.haml +5 -0
- data/app/views/message_train/boxes/_list_item.html.haml +5 -0
- data/app/views/message_train/boxes/_widget.html.haml +6 -0
- data/app/views/message_train/boxes/show.html.haml +47 -0
- data/app/views/message_train/conversations/_conversation.html.haml +9 -0
- data/app/views/message_train/conversations/_deleted_toggle.html.haml +1 -0
- data/app/views/message_train/conversations/_ignored_toggle.html.haml +4 -0
- data/app/views/message_train/conversations/_read_toggle.html.haml +4 -0
- data/app/views/message_train/conversations/_toggle.html.haml +1 -0
- data/app/views/message_train/conversations/_trashed_toggle.html.haml +4 -0
- data/app/views/message_train/conversations/show.html.haml +11 -0
- data/app/views/message_train/conversations/show.json.jbuilder +2 -0
- data/app/views/message_train/messages/_deleted_toggle.html.haml +1 -0
- data/app/views/message_train/messages/_form.html.haml +8 -0
- data/app/views/message_train/messages/_message.html.haml +35 -0
- data/app/views/message_train/messages/_read_toggle.html.haml +4 -0
- data/app/views/message_train/messages/_toggle.html.haml +1 -0
- data/app/views/message_train/messages/_trashed_toggle.html.haml +4 -0
- data/app/views/message_train/messages/edit.html.haml +2 -0
- data/app/views/message_train/messages/new.html.haml +2 -0
- data/app/views/message_train/messages/show.json.jbuilder +2 -0
- data/app/views/message_train/participants/_field.html.haml +4 -0
- data/app/views/message_train/participants/_participant.json.jbuilder +5 -0
- data/app/views/message_train/participants/index.json.jbuilder +3 -0
- data/app/views/message_train/participants/show.json.jbuilder +1 -0
- data/bin/rails +12 -0
- data/config/initializers/bootstrap_pager_config.rb +10 -0
- data/config/initializers/date_time.rb +5 -0
- data/config/locales/en.yml +50 -0
- data/config/routes.rb +11 -0
- data/db/migrate/20150721145319_create_message_train_conversations.rb +9 -0
- data/db/migrate/20150721160322_create_message_train_messages.rb +14 -0
- data/db/migrate/20150721161144_create_message_train_attachments.rb +10 -0
- data/db/migrate/20150721161940_create_message_train_receipts.rb +16 -0
- data/db/migrate/20150721163838_create_message_train_ignores.rb +11 -0
- data/lib/generators/message_train/install/install_generator.rb +30 -0
- data/lib/generators/message_train/install/templates/initializer.rb +10 -0
- data/lib/generators/message_train/utils.rb +16 -0
- data/lib/message_train/configuration.rb +35 -0
- data/lib/message_train/engine.rb +19 -0
- data/lib/message_train/localization.rb +31 -0
- data/lib/message_train/mixin.rb +83 -0
- data/lib/message_train/version.rb +7 -0
- data/lib/message_train.rb +20 -0
- data/lib/tasks/message_train_tasks.rake +0 -0
- data/message_train.gemspec +325 -0
- data/night_train.gemspec +274 -0
- data/spec/controllers/message_train/boxes_controller_spec.rb +82 -0
- data/spec/controllers/message_train/conversations_controller_spec.rb +86 -0
- data/spec/controllers/message_train/messages_controller_spec.rb +210 -0
- data/spec/controllers/message_train/participants_controller_spec.rb +35 -0
- data/spec/dummy/.rspec +2 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/files/message_train/attachments/1917-Boys_Race_Above-Wiki.jpg +0 -0
- data/spec/dummy/app/assets/files/message_train/attachments/ACD_Silverbarn's_Mayumi.jpg +0 -0
- data/spec/dummy/app/assets/files/message_train/attachments/ACD_obedience.jpg +0 -0
- data/spec/dummy/app/assets/files/message_train/attachments/A_Man_and_His_Dog.jpg +0 -0
- data/spec/dummy/app/assets/files/message_train/attachments/Alaskan_Malamute_agility_a-frame.jpg +0 -0
- data/spec/dummy/app/assets/files/message_train/attachments/American_water_spaniel_02.jpg +0 -0
- data/spec/dummy/app/assets/files/message_train/attachments/Aport_konkurs_rybnik.jpg +0 -0
- data/spec/dummy/app/assets/files/message_train/attachments/Askerhytta.jpg +0 -0
- data/spec/dummy/app/assets/files/message_train/attachments/Bambisj.jpg +0 -0
- data/spec/dummy/app/assets/files/message_train/attachments/Cattle_dog_skating.jpg +0 -0
- data/spec/dummy/app/assets/files/message_train/attachments/Dog's_Olympics_training_ground_-_geograph.org.uk_-_660324.jpg +0 -0
- data/spec/dummy/app/assets/files/message_train/attachments/DogShowHierarchy.png +0 -0
- data/spec/dummy/app/assets/files/message_train/attachments/Dog_weight_pull.jpg +0 -0
- data/spec/dummy/app/assets/files/message_train/attachments/Draghuntpostcard.jpg +0 -0
- data/spec/dummy/app/assets/files/message_train/attachments/Esham_51.JPG +0 -0
- data/spec/dummy/app/assets/files/message_train/attachments/FastCourseExample.jpg +0 -0
- data/spec/dummy/app/assets/files/message_train/attachments/Fotos_joel_141.JPG +0 -0
- data/spec/dummy/app/assets/files/message_train/attachments/Galgo_Spanish_male_brindle.jpg +0 -0
- data/spec/dummy/app/assets/files/message_train/attachments/Golden-retriever-carlos-bei-der-dummyarbeit.jpg +0 -0
- data/spec/dummy/app/assets/files/message_train/attachments/Habavk.jpg +0 -0
- data/spec/dummy/app/assets/files/message_train/attachments/Haie_rci.svg +1714 -0
- data/spec/dummy/app/assets/files/message_train/attachments/Hanging_18.jpg +0 -0
- data/spec/dummy/app/assets/files/message_train/attachments/Hundewa.jpg +0 -0
- data/spec/dummy/app/assets/files/message_train/attachments/K9ProSports_AttackOnHandler.jpg +0 -0
- data/spec/dummy/app/assets/files/message_train/attachments/K9ProSports_heel.jpg +0 -0
- data/spec/dummy/app/assets/files/message_train/attachments/K9Pro_Civil_agitation.JPG +0 -0
- data/spec/dummy/app/assets/files/message_train/attachments/TrainingSchutzhundRetrieveOverWall.jpg +0 -0
- data/spec/dummy/app/assets/files/message_train/attachments/example.pdf +0 -0
- data/spec/dummy/app/assets/files/message_train/attachments/letterlegal5.doc +0 -0
- data/spec/dummy/app/assets/files/message_train/attachments/pdf-sample.pdf +0 -0
- data/spec/dummy/app/assets/files/message_train/attachments/sample.pdf +0 -0
- data/spec/dummy/app/assets/files/message_train/attachments/tips.doc +0 -0
- data/spec/dummy/app/assets/files/message_train/attachments/wd-spectools-word-sample-04.doc +0 -0
- data/spec/dummy/app/assets/images/logo.svg +140 -0
- data/spec/dummy/app/assets/javascripts/application.js +17 -0
- data/spec/dummy/app/assets/stylesheets/application.css.scss +35 -0
- data/spec/dummy/app/controllers/application_controller.rb +14 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/mailers/.keep +0 -0
- data/spec/dummy/app/models/.keep +0 -0
- data/spec/dummy/app/models/group.rb +19 -0
- data/spec/dummy/app/models/role.rb +10 -0
- data/spec/dummy/app/models/user.rb +23 -0
- data/spec/dummy/app/views/layouts/_top_navigation.html.haml +5 -0
- data/spec/dummy/app/views/layouts/application.html.haml +29 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/bin/setup +29 -0
- data/spec/dummy/config/application.rb +40 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +41 -0
- data/spec/dummy/config/environments/production.rb +79 -0
- data/spec/dummy/config/environments/test.rb +42 -0
- data/spec/dummy/config/initializers/assets.rb +11 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/bootstrap_leather.rb +7 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/spec/dummy/config/initializers/devise.rb +265 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/message_train.rb +10 -0
- data/spec/dummy/config/initializers/mime_types.rb +4 -0
- data/spec/dummy/config/initializers/paperclip.rb +2 -0
- data/spec/dummy/config/initializers/rolify.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/devise.en.yml +60 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/routes.rb +5 -0
- data/spec/dummy/config/secrets.yml +22 -0
- data/spec/dummy/config/unused/temporary_i18n_debugging.rb +12 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/db/migrate/20150721140013_devise_create_users.rb +42 -0
- data/spec/dummy/db/migrate/20150721141009_rolify_create_roles.rb +19 -0
- data/spec/dummy/db/migrate/20150721141128_create_groups.rb +11 -0
- data/spec/dummy/db/migrate/20150721150307_add_display_name_column_to_users.rb +6 -0
- data/spec/dummy/db/migrate/20150724142846_create_message_train_conversations.night_train.rb +10 -0
- data/spec/dummy/db/migrate/20150724142847_create_message_train_messages.night_train.rb +15 -0
- data/spec/dummy/db/migrate/20150724142848_create_message_train_attachments.night_train.rb +11 -0
- data/spec/dummy/db/migrate/20150724142849_create_message_train_receipts.night_train.rb +17 -0
- data/spec/dummy/db/migrate/20150724142850_create_message_train_ignores.night_train.rb +12 -0
- data/spec/dummy/db/schema.rb +121 -0
- data/spec/dummy/db/seeds/conversations.seeds.rb +86 -0
- data/spec/dummy/db/seeds/development/conversations.seeds.rb +9 -0
- data/spec/dummy/db/seeds/groups.seeds.rb +9 -0
- data/spec/dummy/db/seeds/test/conversations.seeds.rb +9 -0
- data/spec/dummy/db/seeds/users.seeds.rb +15 -0
- data/spec/dummy/db/seeds.rb +0 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/lib/assets/.keep +0 -0
- data/spec/dummy/log/.keep +0 -0
- data/spec/dummy/public/404.html +67 -0
- data/spec/dummy/public/422.html +67 -0
- data/spec/dummy/public/500.html +66 -0
- data/spec/dummy/public/capybara.html +193 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/factories/attachment.rb +6 -0
- data/spec/factories/group.rb +20 -0
- data/spec/factories/message.rb +68 -0
- data/spec/factories/user.rb +8 -0
- data/spec/features/boxes_spec.rb +50 -0
- data/spec/features/conversations_spec.rb +36 -0
- data/spec/features/messages_spec.rb +53 -0
- data/spec/helpers/message_train/boxes_helper_spec.rb +44 -0
- data/spec/message_train_spec.rb +7 -0
- data/spec/models/group_spec.rb +23 -0
- data/spec/models/message_train/attachment_spec.rb +12 -0
- data/spec/models/message_train/box_spec.rb +195 -0
- data/spec/models/message_train/conversation_spec.rb +98 -0
- data/spec/models/message_train/ignore_spec.rb +27 -0
- data/spec/models/message_train/message_spec.rb +83 -0
- data/spec/models/message_train/receipt_spec.rb +73 -0
- data/spec/models/user_spec.rb +68 -0
- data/spec/rails_helper.rb +83 -0
- data/spec/spec_helper.rb +92 -0
- data/spec/support/controller_behaviors.rb +88 -0
- data/spec/support/controller_macros.rb +13 -0
- data/spec/support/conversations.rb +10 -0
- data/spec/support/factory_girl.rb +3 -0
- data/spec/support/feature_behaviors.rb +62 -0
- data/spec/support/groups.rb +3 -0
- data/spec/support/loaded_site.rb +5 -0
- data/spec/support/shared_connection.rb +13 -0
- data/spec/support/users.rb +6 -0
- data/spec/support/utilities.rb +8 -0
- data/vendor/assets/javascripts/bootstrap-tags.js +623 -0
- data/vendor/assets/stylesheets/bootstrap-tags.css +78 -0
- metadata +608 -0
@@ -0,0 +1,623 @@
|
|
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);
|