my_forum 0.0.1.beta60 → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.rdoc +1 -12
- data/Rakefile +3 -4
- data/app/assets/javascripts/my_forum/application.js +0 -6
- data/{spec/dummy/app/assets/stylesheets → app/assets/stylesheets/my_forum}/application.css +1 -1
- data/app/controllers/my_forum/application_controller.rb +0 -81
- data/app/helpers/my_forum/application_helper.rb +0 -43
- data/app/views/layouts/my_forum/application.html.erb +14 -0
- data/config/routes.rb +0 -48
- data/lib/my_forum/engine.rb +0 -31
- data/lib/my_forum/version.rb +1 -1
- data/lib/tasks/my_forum_tasks.rake +4 -155
- data/{spec → test}/dummy/README.rdoc +0 -0
- data/{spec → test}/dummy/Rakefile +0 -0
- data/{spec → test}/dummy/app/assets/javascripts/application.js +1 -1
- data/test/dummy/app/assets/stylesheets/application.css +15 -0
- data/{spec → test}/dummy/app/controllers/application_controller.rb +0 -0
- data/{spec → test}/dummy/app/helpers/application_helper.rb +0 -0
- data/{spec → test}/dummy/app/views/layouts/application.html.erb +0 -0
- data/{spec → test}/dummy/bin/bundle +0 -0
- data/{spec → test}/dummy/bin/rails +0 -0
- data/{spec → test}/dummy/bin/rake +0 -0
- data/{spec → test}/dummy/config/application.rb +0 -0
- data/{spec → test}/dummy/config/boot.rb +0 -0
- data/{spec → test}/dummy/config/database.yml +0 -0
- data/{spec → test}/dummy/config/environment.rb +0 -0
- data/{spec → test}/dummy/config/environments/development.rb +0 -0
- data/{spec → test}/dummy/config/environments/production.rb +1 -1
- data/{spec → test}/dummy/config/environments/test.rb +1 -1
- data/{spec → test}/dummy/config/initializers/assets.rb +0 -0
- data/{spec → test}/dummy/config/initializers/backtrace_silencers.rb +0 -0
- data/{spec → test}/dummy/config/initializers/cookies_serializer.rb +0 -0
- data/{spec → test}/dummy/config/initializers/filter_parameter_logging.rb +0 -0
- data/{spec → test}/dummy/config/initializers/inflections.rb +0 -0
- data/{spec → test}/dummy/config/initializers/mime_types.rb +0 -0
- data/{spec → test}/dummy/config/initializers/session_store.rb +0 -0
- data/{spec → test}/dummy/config/initializers/wrap_parameters.rb +0 -0
- data/{spec → test}/dummy/config/locales/en.yml +0 -0
- data/{spec → test}/dummy/config/routes.rb +0 -0
- data/{spec → test}/dummy/config/secrets.yml +0 -0
- data/{spec → test}/dummy/config.ru +0 -0
- data/{spec → test}/dummy/public/404.html +0 -0
- data/{spec → test}/dummy/public/422.html +0 -0
- data/{spec → test}/dummy/public/500.html +0 -0
- data/{spec → test}/dummy/public/favicon.ico +0 -0
- data/test/integration/navigation_test.rb +10 -0
- data/test/my_forum_test.rb +7 -0
- data/test/test_helper.rb +15 -0
- metadata +84 -355
- data/app/assets/javascripts/my_forum/admin/categories.js.coffee +0 -0
- data/app/assets/javascripts/my_forum/admin/dashboard.js.coffee +0 -0
- data/app/assets/javascripts/my_forum/admin/forums.js.coffee +0 -0
- data/app/assets/javascripts/my_forum/admin/roles.js +0 -2
- data/app/assets/javascripts/my_forum/admin/users.js +0 -2
- data/app/assets/javascripts/my_forum/forums.js.coffee +0 -0
- data/app/assets/javascripts/my_forum/jquery.scrollTo.min.js +0 -7
- data/app/assets/javascripts/my_forum/jquery.selection.js +0 -354
- data/app/assets/javascripts/my_forum/my_forum.js.coffee +0 -118
- data/app/assets/javascripts/my_forum/posts.js.coffee +0 -20
- data/app/assets/javascripts/my_forum/topics.js.coffee +0 -0
- data/app/assets/javascripts/my_forum/users.js.coffee +0 -0
- data/app/assets/javascripts/my_forum/welcome.js.coffee +0 -0
- data/app/assets/stylesheets/my_forum/admin/categories.css.scss +0 -0
- data/app/assets/stylesheets/my_forum/admin/dashboard.css.scss +0 -3
- data/app/assets/stylesheets/my_forum/admin/forums.css.scss +0 -7
- data/app/assets/stylesheets/my_forum/admin/roles.css +0 -4
- data/app/assets/stylesheets/my_forum/admin/users.css +0 -4
- data/app/assets/stylesheets/my_forum/application.css.scss +0 -80
- data/app/assets/stylesheets/my_forum/forums.css.scss +0 -31
- data/app/assets/stylesheets/my_forum/posts.css.scss +0 -138
- data/app/assets/stylesheets/my_forum/private_messages.css.scss +0 -11
- data/app/assets/stylesheets/my_forum/topics.css.scss +0 -16
- data/app/assets/stylesheets/my_forum/users.css.scss +0 -3
- data/app/assets/stylesheets/my_forum/welcome.css.scss +0 -73
- data/app/controllers/my_forum/admin/categories_controller.rb +0 -36
- data/app/controllers/my_forum/admin/dashboard_controller.rb +0 -13
- data/app/controllers/my_forum/admin/emoticons_controller.rb +0 -65
- data/app/controllers/my_forum/admin/forums_controller.rb +0 -35
- data/app/controllers/my_forum/admin/mail_controller.rb +0 -31
- data/app/controllers/my_forum/admin/roles_controller.rb +0 -38
- data/app/controllers/my_forum/admin/users_controller.rb +0 -14
- data/app/controllers/my_forum/attachments_controller.rb +0 -30
- data/app/controllers/my_forum/forums_controller.rb +0 -39
- data/app/controllers/my_forum/images_controller.rb +0 -7
- data/app/controllers/my_forum/posts_controller.rb +0 -81
- data/app/controllers/my_forum/private_messages_controller.rb +0 -73
- data/app/controllers/my_forum/topics_controller.rb +0 -96
- data/app/controllers/my_forum/users_controller.rb +0 -145
- data/app/controllers/my_forum/welcome_controller.rb +0 -30
- data/app/helpers/my_forum/admin/dashboard_helper.rb +0 -4
- data/app/helpers/my_forum/admin/forums_helper.rb +0 -4
- data/app/helpers/my_forum/admin/roles_helper.rb +0 -4
- data/app/helpers/my_forum/admin/users_helper.rb +0 -4
- data/app/helpers/my_forum/emoticons_helper.rb +0 -7
- data/app/helpers/my_forum/forums_helper.rb +0 -44
- data/app/helpers/my_forum/posts_helper.rb +0 -72
- data/app/helpers/my_forum/private_messages_helper.rb +0 -25
- data/app/helpers/my_forum/topics_helper.rb +0 -18
- data/app/helpers/my_forum/users_helper.rb +0 -33
- data/app/helpers/my_forum/welcome_helper.rb +0 -4
- data/app/mailers/application_mailer.rb +0 -4
- data/app/mailers/my_forum/user_mailer.rb +0 -24
- data/app/models/my_forum/attachment.rb +0 -12
- data/app/models/my_forum/avatar.rb +0 -11
- data/app/models/my_forum/category.rb +0 -7
- data/app/models/my_forum/category_permission.rb +0 -6
- data/app/models/my_forum/emoticon.rb +0 -6
- data/app/models/my_forum/forum.rb +0 -50
- data/app/models/my_forum/image.rb +0 -5
- data/app/models/my_forum/log_read_mark.rb +0 -4
- data/app/models/my_forum/post.rb +0 -26
- data/app/models/my_forum/private_message.rb +0 -8
- data/app/models/my_forum/role.rb +0 -6
- data/app/models/my_forum/topic.rb +0 -41
- data/app/models/my_forum/user.rb +0 -71
- data/app/models/my_forum/user_group.rb +0 -13
- data/app/models/my_forum/user_group_link.rb +0 -6
- data/app/models/my_forum/user_roles.rb +0 -6
- data/app/views/layouts/mailer.html.erb +0 -5
- data/app/views/layouts/mailer.text.erb +0 -1
- data/app/views/layouts/my_forum/_guest_navbar.html.haml +0 -4
- data/app/views/layouts/my_forum/_user_navbar.html.haml +0 -19
- data/app/views/layouts/my_forum/admin_application.haml +0 -29
- data/app/views/layouts/my_forum/application.haml +0 -23
- data/app/views/my_forum/admin/categories/edit.haml +0 -9
- data/app/views/my_forum/admin/categories/new.haml +0 -5
- data/app/views/my_forum/admin/dashboard/index.haml +0 -0
- data/app/views/my_forum/admin/emoticons/edit.haml +0 -4
- data/app/views/my_forum/admin/emoticons/index.haml +0 -15
- data/app/views/my_forum/admin/emoticons/new.haml +0 -5
- data/app/views/my_forum/admin/forums/index.haml +0 -47
- data/app/views/my_forum/admin/forums/new.haml +0 -6
- data/app/views/my_forum/admin/mail/index.haml +0 -9
- data/app/views/my_forum/admin/roles/index.haml +0 -12
- data/app/views/my_forum/admin/roles/new.haml +0 -22
- data/app/views/my_forum/admin/users/index.haml +0 -10
- data/app/views/my_forum/forums/_topic_subject.html.haml +0 -16
- data/app/views/my_forum/forums/show.haml +0 -29
- data/app/views/my_forum/posts/edit.html.haml +0 -31
- data/app/views/my_forum/private_messages/_sidebar.haml +0 -10
- data/app/views/my_forum/private_messages/inbox.haml +0 -26
- data/app/views/my_forum/private_messages/new.haml +0 -21
- data/app/views/my_forum/private_messages/show.haml +0 -10
- data/app/views/my_forum/shared/_post_preview.haml +0 -15
- data/app/views/my_forum/shared/_upload_photo.haml +0 -45
- data/app/views/my_forum/shared/post_preview.js.coffee +0 -4
- data/app/views/my_forum/topics/_post.haml +0 -29
- data/app/views/my_forum/topics/_profile_popover.haml +0 -47
- data/app/views/my_forum/topics/_quick_answer.haml +0 -34
- data/app/views/my_forum/topics/_topic_header.haml +0 -4
- data/app/views/my_forum/topics/_user_info.haml +0 -9
- data/app/views/my_forum/topics/new.haml +0 -38
- data/app/views/my_forum/topics/show.haml +0 -60
- data/app/views/my_forum/user_mailer/custom_email.text.erb +0 -1
- data/app/views/my_forum/user_mailer/pm_notification.text.erb +0 -6
- data/app/views/my_forum/user_mailer/reset_password_email.haml +0 -1
- data/app/views/my_forum/user_mailer/reset_password_email.text.erb +0 -1
- data/app/views/my_forum/users/edit.haml +0 -36
- data/app/views/my_forum/users/forgot_password.haml +0 -10
- data/app/views/my_forum/users/new.haml +0 -14
- data/app/views/my_forum/users/signin.haml +0 -14
- data/app/views/my_forum/users/signout.haml +0 -0
- data/app/views/my_forum/welcome/index.haml +0 -37
- data/config/initializers/will_paginate.rb +0 -24
- data/config/locales/en.yml +0 -68
- data/config/locales/ru.yml +0 -196
- data/db/migrate/20141117122725_create_my_forum_forums.rb +0 -12
- data/db/migrate/20141117122742_create_my_forum_topics.rb +0 -17
- data/db/migrate/20141117122751_create_my_forum_posts.rb +0 -11
- data/db/migrate/20141118081021_create_my_forum_categories.rb +0 -8
- data/db/migrate/20141118131215_create_my_forum_users.rb +0 -34
- data/db/migrate/20141222094522_create_my_forum_roles.rb +0 -10
- data/db/migrate/20141222094538_create_my_forum_user_roles.rb +0 -9
- data/db/migrate/20150202115250_create_my_forum_log_read_marks.rb +0 -10
- data/db/migrate/20150215200453_create_my_forum_user_groups.rb +0 -15
- data/db/migrate/20150215204852_create_my_forum_user_group_links.rb +0 -9
- data/db/migrate/20150215212443_create_my_forum_category_permissions.rb +0 -9
- data/db/migrate/20150227210814_create_my_forum_private_messages.rb +0 -16
- data/db/migrate/20151012095554_create_my_forum_images.rb +0 -12
- data/db/migrate/20151218135729_add_is_deleted.rb +0 -6
- data/db/migrate/20151220121140_create_my_forum_emoticons.rb +0 -10
- data/db/migrate/20151221203243_my_forum_rename_user_avatar.rb +0 -5
- data/db/migrate/20151221205045_my_forum_change_user_avatar.rb +0 -5
- data/db/migrate/20160122202142_add_latest_post_info_for_topic.rb +0 -24
- data/db/migrate/20160210130805_add_indexes_for_topics.rb +0 -7
- data/db/migrate/20160214085201_add_edited_by_for_post.rb +0 -5
- data/spec/controllers/my_forum/admin/emoticons_controller_spec.rb +0 -7
- data/spec/controllers/my_forum/admin/mail_controller_spec.rb +0 -7
- data/spec/controllers/my_forum/private_messages_controller_spec.rb +0 -7
- data/spec/controllers/my_forum/users_controller_spec.rb +0 -76
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/schema.rb +0 -159
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +0 -12
- data/spec/helpers/my_forum/posts_helper_spec.rb +0 -24
- data/spec/helpers/my_forum/private_messages_helper_spec.rb +0 -17
- data/spec/models/my_forum/emoticon_spec.rb +0 -7
- data/spec/models/my_forum/private_message_spec.rb +0 -7
- data/spec/models/my_forum/user_spec.rb +0 -13
- data/spec/rails_helper.rb +0 -52
- data/spec/spec_helper.rb +0 -87
@@ -1,354 +0,0 @@
|
|
1
|
-
/*!
|
2
|
-
* jQuery.selection - jQuery Plugin
|
3
|
-
*
|
4
|
-
* Copyright (c) 2010-2014 IWASAKI Koji (@madapaja).
|
5
|
-
* http://blog.madapaja.net/
|
6
|
-
* Under The MIT License
|
7
|
-
*
|
8
|
-
* Permission is hereby granted, free of charge, to any person obtaining
|
9
|
-
* a copy of this software and associated documentation files (the
|
10
|
-
* "Software"), to deal in the Software without restriction, including
|
11
|
-
* without limitation the rights to use, copy, modify, merge, publish,
|
12
|
-
* distribute, sublicense, and/or sell copies of the Software, and to
|
13
|
-
* permit persons to whom the Software is furnished to do so, subject to
|
14
|
-
* the following conditions:
|
15
|
-
*
|
16
|
-
* The above copyright notice and this permission notice shall be
|
17
|
-
* included in all copies or substantial portions of the Software.
|
18
|
-
*
|
19
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
20
|
-
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
21
|
-
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
22
|
-
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
23
|
-
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
24
|
-
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
25
|
-
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
26
|
-
*/
|
27
|
-
(function($, win, doc) {
|
28
|
-
/**
|
29
|
-
* get caret status of the selection of the element
|
30
|
-
*
|
31
|
-
* @param {Element} element target DOM element
|
32
|
-
* @return {Object} return
|
33
|
-
* @return {String} return.text selected text
|
34
|
-
* @return {Number} return.start start position of the selection
|
35
|
-
* @return {Number} return.end end position of the selection
|
36
|
-
*/
|
37
|
-
var _getCaretInfo = function(element){
|
38
|
-
var res = {
|
39
|
-
text: '',
|
40
|
-
start: 0,
|
41
|
-
end: 0
|
42
|
-
};
|
43
|
-
|
44
|
-
if (!element.value) {
|
45
|
-
/* no value or empty string */
|
46
|
-
return res;
|
47
|
-
}
|
48
|
-
|
49
|
-
try {
|
50
|
-
if (win.getSelection) {
|
51
|
-
/* except IE */
|
52
|
-
res.start = element.selectionStart;
|
53
|
-
res.end = element.selectionEnd;
|
54
|
-
res.text = element.value.slice(res.start, res.end);
|
55
|
-
} else if (doc.selection) {
|
56
|
-
/* for IE */
|
57
|
-
element.focus();
|
58
|
-
|
59
|
-
var range = doc.selection.createRange(),
|
60
|
-
range2 = doc.body.createTextRange();
|
61
|
-
|
62
|
-
res.text = range.text;
|
63
|
-
|
64
|
-
try {
|
65
|
-
range2.moveToElementText(element);
|
66
|
-
range2.setEndPoint('StartToStart', range);
|
67
|
-
} catch (e) {
|
68
|
-
range2 = element.createTextRange();
|
69
|
-
range2.setEndPoint('StartToStart', range);
|
70
|
-
}
|
71
|
-
|
72
|
-
res.start = element.value.length - range2.text.length;
|
73
|
-
res.end = res.start + range.text.length;
|
74
|
-
}
|
75
|
-
} catch (e) {
|
76
|
-
/* give up */
|
77
|
-
}
|
78
|
-
|
79
|
-
return res;
|
80
|
-
};
|
81
|
-
|
82
|
-
/**
|
83
|
-
* caret operation for the element
|
84
|
-
* @type {Object}
|
85
|
-
*/
|
86
|
-
var _CaretOperation = {
|
87
|
-
/**
|
88
|
-
* get caret position
|
89
|
-
*
|
90
|
-
* @param {Element} element target element
|
91
|
-
* @return {Object} return
|
92
|
-
* @return {Number} return.start start position for the selection
|
93
|
-
* @return {Number} return.end end position for the selection
|
94
|
-
*/
|
95
|
-
getPos: function(element) {
|
96
|
-
var tmp = _getCaretInfo(element);
|
97
|
-
return {start: tmp.start, end: tmp.end};
|
98
|
-
},
|
99
|
-
|
100
|
-
/**
|
101
|
-
* set caret position
|
102
|
-
*
|
103
|
-
* @param {Element} element target element
|
104
|
-
* @param {Object} toRange caret position
|
105
|
-
* @param {Number} toRange.start start position for the selection
|
106
|
-
* @param {Number} toRange.end end position for the selection
|
107
|
-
* @param {String} caret caret mode: any of the following: "keep" | "start" | "end"
|
108
|
-
*/
|
109
|
-
setPos: function(element, toRange, caret) {
|
110
|
-
caret = this._caretMode(caret);
|
111
|
-
|
112
|
-
if (caret === 'start') {
|
113
|
-
toRange.end = toRange.start;
|
114
|
-
} else if (caret === 'end') {
|
115
|
-
toRange.start = toRange.end;
|
116
|
-
}
|
117
|
-
|
118
|
-
element.focus();
|
119
|
-
try {
|
120
|
-
if (element.createTextRange) {
|
121
|
-
var range = element.createTextRange();
|
122
|
-
|
123
|
-
if (win.navigator.userAgent.toLowerCase().indexOf("msie") >= 0) {
|
124
|
-
toRange.start = element.value.substr(0, toRange.start).replace(/\r/g, '').length;
|
125
|
-
toRange.end = element.value.substr(0, toRange.end).replace(/\r/g, '').length;
|
126
|
-
}
|
127
|
-
|
128
|
-
range.collapse(true);
|
129
|
-
range.moveStart('character', toRange.start);
|
130
|
-
range.moveEnd('character', toRange.end - toRange.start);
|
131
|
-
|
132
|
-
range.select();
|
133
|
-
} else if (element.setSelectionRange) {
|
134
|
-
element.setSelectionRange(toRange.start, toRange.end);
|
135
|
-
}
|
136
|
-
} catch (e) {
|
137
|
-
/* give up */
|
138
|
-
}
|
139
|
-
},
|
140
|
-
|
141
|
-
/**
|
142
|
-
* get selected text
|
143
|
-
*
|
144
|
-
* @param {Element} element target element
|
145
|
-
* @return {String} return selected text
|
146
|
-
*/
|
147
|
-
getText: function(element) {
|
148
|
-
return _getCaretInfo(element).text;
|
149
|
-
},
|
150
|
-
|
151
|
-
/**
|
152
|
-
* get caret mode
|
153
|
-
*
|
154
|
-
* @param {String} caret caret mode
|
155
|
-
* @return {String} return any of the following: "keep" | "start" | "end"
|
156
|
-
*/
|
157
|
-
_caretMode: function(caret) {
|
158
|
-
caret = caret || "keep";
|
159
|
-
if (caret === false) {
|
160
|
-
caret = 'end';
|
161
|
-
}
|
162
|
-
|
163
|
-
switch (caret) {
|
164
|
-
case 'keep':
|
165
|
-
case 'start':
|
166
|
-
case 'end':
|
167
|
-
break;
|
168
|
-
|
169
|
-
default:
|
170
|
-
caret = 'keep';
|
171
|
-
}
|
172
|
-
|
173
|
-
return caret;
|
174
|
-
},
|
175
|
-
|
176
|
-
/**
|
177
|
-
* replace selected text
|
178
|
-
*
|
179
|
-
* @param {Element} element target element
|
180
|
-
* @param {String} text replacement text
|
181
|
-
* @param {String} caret caret mode: any of the following: "keep" | "start" | "end"
|
182
|
-
*/
|
183
|
-
replace: function(element, text, caret) {
|
184
|
-
var tmp = _getCaretInfo(element),
|
185
|
-
orig = element.value,
|
186
|
-
pos = $(element).scrollTop(),
|
187
|
-
range = {start: tmp.start, end: tmp.start + text.length};
|
188
|
-
|
189
|
-
element.value = orig.substr(0, tmp.start) + text + orig.substr(tmp.end);
|
190
|
-
|
191
|
-
$(element).scrollTop(pos);
|
192
|
-
this.setPos(element, range, caret);
|
193
|
-
},
|
194
|
-
|
195
|
-
/**
|
196
|
-
* insert before the selected text
|
197
|
-
*
|
198
|
-
* @param {Element} element target element
|
199
|
-
* @param {String} text insertion text
|
200
|
-
* @param {String} caret caret mode: any of the following: "keep" | "start" | "end"
|
201
|
-
*/
|
202
|
-
insertBefore: function(element, text, caret) {
|
203
|
-
var tmp = _getCaretInfo(element),
|
204
|
-
orig = element.value,
|
205
|
-
pos = $(element).scrollTop(),
|
206
|
-
range = {start: tmp.start + text.length, end: tmp.end + text.length};
|
207
|
-
|
208
|
-
element.value = orig.substr(0, tmp.start) + text + orig.substr(tmp.start);
|
209
|
-
|
210
|
-
$(element).scrollTop(pos);
|
211
|
-
this.setPos(element, range, caret);
|
212
|
-
},
|
213
|
-
|
214
|
-
/**
|
215
|
-
* insert after the selected text
|
216
|
-
*
|
217
|
-
* @param {Element} element target element
|
218
|
-
* @param {String} text insertion text
|
219
|
-
* @param {String} caret caret mode: any of the following: "keep" | "start" | "end"
|
220
|
-
*/
|
221
|
-
insertAfter: function(element, text, caret) {
|
222
|
-
var tmp = _getCaretInfo(element),
|
223
|
-
orig = element.value,
|
224
|
-
pos = $(element).scrollTop(),
|
225
|
-
range = {start: tmp.start, end: tmp.end};
|
226
|
-
|
227
|
-
element.value = orig.substr(0, tmp.end) + text + orig.substr(tmp.end);
|
228
|
-
|
229
|
-
$(element).scrollTop(pos);
|
230
|
-
this.setPos(element, range, caret);
|
231
|
-
}
|
232
|
-
};
|
233
|
-
|
234
|
-
/* add jQuery.selection */
|
235
|
-
$.extend({
|
236
|
-
/**
|
237
|
-
* get selected text on the window
|
238
|
-
*
|
239
|
-
* @param {String} mode selection mode: any of the following: "text" | "html"
|
240
|
-
* @return {String} return
|
241
|
-
*/
|
242
|
-
selection: function(mode) {
|
243
|
-
var getText = ((mode || 'text').toLowerCase() === 'text');
|
244
|
-
|
245
|
-
try {
|
246
|
-
if (win.getSelection) {
|
247
|
-
if (getText) {
|
248
|
-
// get text
|
249
|
-
return win.getSelection().toString();
|
250
|
-
} else {
|
251
|
-
// get html
|
252
|
-
var sel = win.getSelection(), range;
|
253
|
-
|
254
|
-
if (sel.getRangeAt) {
|
255
|
-
range = sel.getRangeAt(0);
|
256
|
-
} else {
|
257
|
-
range = doc.createRange();
|
258
|
-
range.setStart(sel.anchorNode, sel.anchorOffset);
|
259
|
-
range.setEnd(sel.focusNode, sel.focusOffset);
|
260
|
-
}
|
261
|
-
|
262
|
-
return $('<div></div>').append(range.cloneContents()).html();
|
263
|
-
}
|
264
|
-
} else if (doc.selection) {
|
265
|
-
if (getText) {
|
266
|
-
// get text
|
267
|
-
return doc.selection.createRange().text;
|
268
|
-
} else {
|
269
|
-
// get html
|
270
|
-
return doc.selection.createRange().htmlText;
|
271
|
-
}
|
272
|
-
}
|
273
|
-
} catch (e) {
|
274
|
-
/* give up */
|
275
|
-
}
|
276
|
-
|
277
|
-
return '';
|
278
|
-
}
|
279
|
-
});
|
280
|
-
|
281
|
-
/* add selection */
|
282
|
-
$.fn.extend({
|
283
|
-
selection: function(mode, opts) {
|
284
|
-
opts = opts || {};
|
285
|
-
|
286
|
-
switch (mode) {
|
287
|
-
/**
|
288
|
-
* selection('getPos')
|
289
|
-
* get caret position
|
290
|
-
*
|
291
|
-
* @return {Object} return
|
292
|
-
* @return {Number} return.start start position for the selection
|
293
|
-
* @return {Number} return.end end position for the selection
|
294
|
-
*/
|
295
|
-
case 'getPos':
|
296
|
-
return _CaretOperation.getPos(this[0]);
|
297
|
-
|
298
|
-
/**
|
299
|
-
* selection('setPos', opts)
|
300
|
-
* set caret position
|
301
|
-
*
|
302
|
-
* @param {Number} opts.start start position for the selection
|
303
|
-
* @param {Number} opts.end end position for the selection
|
304
|
-
*/
|
305
|
-
case 'setPos':
|
306
|
-
return this.each(function() {
|
307
|
-
_CaretOperation.setPos(this, opts);
|
308
|
-
});
|
309
|
-
|
310
|
-
/**
|
311
|
-
* selection('replace', opts)
|
312
|
-
* replace the selected text
|
313
|
-
*
|
314
|
-
* @param {String} opts.text replacement text
|
315
|
-
* @param {String} opts.caret caret mode: any of the following: "keep" | "start" | "end"
|
316
|
-
*/
|
317
|
-
case 'replace':
|
318
|
-
return this.each(function() {
|
319
|
-
_CaretOperation.replace(this, opts.text, opts.caret);
|
320
|
-
});
|
321
|
-
|
322
|
-
/**
|
323
|
-
* selection('insert', opts)
|
324
|
-
* insert before/after the selected text
|
325
|
-
*
|
326
|
-
* @param {String} opts.text insertion text
|
327
|
-
* @param {String} opts.caret caret mode: any of the following: "keep" | "start" | "end"
|
328
|
-
* @param {String} opts.mode insertion mode: any of the following: "before" | "after"
|
329
|
-
*/
|
330
|
-
case 'insert':
|
331
|
-
return this.each(function() {
|
332
|
-
if (opts.mode === 'before') {
|
333
|
-
_CaretOperation.insertBefore(this, opts.text, opts.caret);
|
334
|
-
} else {
|
335
|
-
_CaretOperation.insertAfter(this, opts.text, opts.caret);
|
336
|
-
}
|
337
|
-
});
|
338
|
-
|
339
|
-
/**
|
340
|
-
* selection('get')
|
341
|
-
* get selected text
|
342
|
-
*
|
343
|
-
* @return {String} return
|
344
|
-
*/
|
345
|
-
case 'get':
|
346
|
-
/* falls through */
|
347
|
-
default:
|
348
|
-
return _CaretOperation.getText(this[0]);
|
349
|
-
}
|
350
|
-
|
351
|
-
return this;
|
352
|
-
}
|
353
|
-
});
|
354
|
-
})(jQuery, window, window.document);
|
@@ -1,118 +0,0 @@
|
|
1
|
-
ready = ->
|
2
|
-
# Quote button
|
3
|
-
$('.quote-post').click (event) ->
|
4
|
-
quoute_post_id = $(event.target).data('post-id')
|
5
|
-
|
6
|
-
$.ajax
|
7
|
-
url: '/post/' + quoute_post_id
|
8
|
-
type: "GET"
|
9
|
-
dataType: "json"
|
10
|
-
success: (response) ->
|
11
|
-
quote = $('#quick_answer_textarea').val()
|
12
|
-
quote += '\n[quote author=' + response.author+ ']'
|
13
|
-
quote += response.text
|
14
|
-
quote += '[/quote]\n\n'
|
15
|
-
|
16
|
-
$('#quick_answer_textarea').val(quote)
|
17
|
-
$('body').scrollTo($('#quick_answer_textarea'))
|
18
|
-
|
19
|
-
|
20
|
-
# BBCode editor
|
21
|
-
$('.text-editor-buttons').click (event) ->
|
22
|
-
event.preventDefault()
|
23
|
-
|
24
|
-
apply_to = $('.text-editor-buttons').data('apply-to')
|
25
|
-
apply_to = $('#' + apply_to)
|
26
|
-
|
27
|
-
# Smiles
|
28
|
-
if $(event.target).attr('class').search('smile') >= 0
|
29
|
-
smile_code = $(event.target).data('code') || $(event.target).find('[data-code]').data('code')
|
30
|
-
|
31
|
-
if smile_code
|
32
|
-
text = apply_to.val()
|
33
|
-
apply_to.val(text + smile_code + ' ')
|
34
|
-
|
35
|
-
return false
|
36
|
-
|
37
|
-
|
38
|
-
# Text formatting
|
39
|
-
return false if !$(event.target).is('a') and !$(event.target).is('i')
|
40
|
-
|
41
|
-
button = if $(event.target).is('a') then $(event.target).find('i') else $(event.target)
|
42
|
-
html_class = button.attr('class')
|
43
|
-
|
44
|
-
action = if html_class then html_class.replace('fa fa-', '') else ''
|
45
|
-
text = apply_to.val()
|
46
|
-
|
47
|
-
switch action
|
48
|
-
when 'bold'
|
49
|
-
bbcode = '[b] [/b]'
|
50
|
-
when 'italic'
|
51
|
-
bbcode = '[i] [/i]'
|
52
|
-
when 'strikethrough'
|
53
|
-
bbcode = '[s] [/s]'
|
54
|
-
when 'underline'
|
55
|
-
bbcode = '[u] [/u]'
|
56
|
-
when 'link', 'video-camera', 'camera-retro'
|
57
|
-
$('#add_photo').modal()
|
58
|
-
else
|
59
|
-
bbcode = ''
|
60
|
-
console.log 'Unknown tag'
|
61
|
-
|
62
|
-
if bbcode
|
63
|
-
if (selected_text = apply_to.selection()).length > 0
|
64
|
-
open_tag = bbcode.split(' ')[0]
|
65
|
-
close_tag = bbcode.split(' ')[1]
|
66
|
-
apply_to.selection('replace', { text: open_tag + selected_text + close_tag })
|
67
|
-
else
|
68
|
-
apply_to.val(text + bbcode + ' ')
|
69
|
-
|
70
|
-
# Autocomplete
|
71
|
-
$('.autocomplete').keyup (elm) ->
|
72
|
-
ajax_url = $(@).data('autocomplete-path')
|
73
|
-
return unless ajax_url
|
74
|
-
|
75
|
-
$.ajax
|
76
|
-
url: ajax_url
|
77
|
-
type: "GET"
|
78
|
-
dataType: "json"
|
79
|
-
data: str: $(elm.target).val()
|
80
|
-
success: (response) ->
|
81
|
-
autocomplete_popup(response, elm.target)
|
82
|
-
|
83
|
-
autocomplete_popup = (autocomplete_list, object) ->
|
84
|
-
popup_id = 'autocomplete_popup'
|
85
|
-
|
86
|
-
# Create or use existing Popup Window
|
87
|
-
if $('#' + popup_id).length > 0
|
88
|
-
popup_container = $('#' + popup_id)
|
89
|
-
else
|
90
|
-
popup_container = $("<div id='#{popup_id}'></div>")
|
91
|
-
$(object).after(popup_container)
|
92
|
-
|
93
|
-
$('body').click ->
|
94
|
-
popup_container.remove()
|
95
|
-
|
96
|
-
# Show lists
|
97
|
-
html_list = $('<ul/>')
|
98
|
-
$.map autocomplete_list, (item) ->
|
99
|
-
li = $('<li/>')
|
100
|
-
.addClass('ui-menu-item')
|
101
|
-
.attr('role', 'menuitem')
|
102
|
-
.appendTo(html_list)
|
103
|
-
|
104
|
-
a = $('<a/>')
|
105
|
-
.addClass('ui-all')
|
106
|
-
.text(item)
|
107
|
-
.appendTo(li)
|
108
|
-
|
109
|
-
li.click ->
|
110
|
-
$(object).val(item)
|
111
|
-
|
112
|
-
# Destroy popup after select tag
|
113
|
-
popup_container.remove()
|
114
|
-
|
115
|
-
popup_container.html(html_list)
|
116
|
-
|
117
|
-
$(document).ready(ready)
|
118
|
-
$(document).on('page:load', ready)
|
@@ -1,20 +0,0 @@
|
|
1
|
-
ready = ->
|
2
|
-
$('#post_preview').click (event) ->
|
3
|
-
event.preventDefault()
|
4
|
-
|
5
|
-
elm_id = $(event.target).data('elm-preview')
|
6
|
-
elm = $('#' + elm_id)
|
7
|
-
|
8
|
-
return unless elm
|
9
|
-
|
10
|
-
data = elm.val()
|
11
|
-
|
12
|
-
$.ajax
|
13
|
-
url: '/post/preview'
|
14
|
-
type: 'POST'
|
15
|
-
dataType: 'script'
|
16
|
-
data:
|
17
|
-
text: data
|
18
|
-
|
19
|
-
$(document).ready(ready)
|
20
|
-
$(document).on('page:load', ready)
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,80 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
-
* listed below.
|
4
|
-
*
|
5
|
-
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
-
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
7
|
-
*
|
8
|
-
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
-
* compiled file so the styles you add here take precedence over styles defined in any styles
|
10
|
-
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
|
11
|
-
* file per style scope.
|
12
|
-
*
|
13
|
-
*= require_tree .
|
14
|
-
*= require_self
|
15
|
-
*/
|
16
|
-
|
17
|
-
@import "bootstrap-sprockets";
|
18
|
-
@import "bootstrap";
|
19
|
-
@import "font-awesome-sprockets";
|
20
|
-
@import "font-awesome";
|
21
|
-
|
22
|
-
.popover {
|
23
|
-
min-width: 540px !important;
|
24
|
-
}
|
25
|
-
|
26
|
-
.popover-title {
|
27
|
-
font-weight: bold;
|
28
|
-
color: #000;
|
29
|
-
}
|
30
|
-
|
31
|
-
.modal-dialog {
|
32
|
-
.post_attachment {
|
33
|
-
max-width: 200px;
|
34
|
-
}
|
35
|
-
}
|
36
|
-
|
37
|
-
.buttons_for_new_topic {
|
38
|
-
margin-top: 10px;
|
39
|
-
}
|
40
|
-
|
41
|
-
.errors_for {
|
42
|
-
color: red;
|
43
|
-
padding: 10px;
|
44
|
-
border: 1px solid red;
|
45
|
-
margin-bottom: 14px;
|
46
|
-
}
|
47
|
-
|
48
|
-
#autocomplete_popup {
|
49
|
-
position: absolute;
|
50
|
-
border: 1px solid grey;
|
51
|
-
padding: 0;
|
52
|
-
background-color: #fff;
|
53
|
-
|
54
|
-
ul {
|
55
|
-
list-style-type: none;
|
56
|
-
padding-left: 0;
|
57
|
-
width: 200px;
|
58
|
-
|
59
|
-
li {
|
60
|
-
padding: 4px;
|
61
|
-
width: 100%;
|
62
|
-
cursor: pointer;
|
63
|
-
}
|
64
|
-
|
65
|
-
li:hover {
|
66
|
-
background-color: cornflowerblue;
|
67
|
-
}
|
68
|
-
}
|
69
|
-
|
70
|
-
}
|
71
|
-
.text-editor-buttons {
|
72
|
-
margin-bottom: -1px;
|
73
|
-
|
74
|
-
.btn-group.smiles {
|
75
|
-
img {
|
76
|
-
max-width: 16px;
|
77
|
-
height: 16px;
|
78
|
-
}
|
79
|
-
}
|
80
|
-
}
|
@@ -1,31 +0,0 @@
|
|
1
|
-
.topic-list-container {
|
2
|
-
background-color: #f7f7f7;
|
3
|
-
padding: 6px;
|
4
|
-
|
5
|
-
a {
|
6
|
-
color: #000;
|
7
|
-
}
|
8
|
-
|
9
|
-
.box {
|
10
|
-
padding: 4px 6px;
|
11
|
-
border: 1px solid #DFDFDF;
|
12
|
-
background-color: #fff;
|
13
|
-
|
14
|
-
.topic-row {
|
15
|
-
margin-bottom: 10px;
|
16
|
-
|
17
|
-
.info {
|
18
|
-
font-size: 11px;
|
19
|
-
}
|
20
|
-
|
21
|
-
.topic_subject {
|
22
|
-
color: #4E6EE3;
|
23
|
-
}
|
24
|
-
|
25
|
-
.topic_description {
|
26
|
-
font-size: 11px;
|
27
|
-
}
|
28
|
-
}
|
29
|
-
|
30
|
-
}
|
31
|
-
}
|