artfully_ose 1.2.0.pre.15 → 1.2.0.pre.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/app/assets/javascripts/application.js +22 -1
- data/app/assets/javascripts/bootstrap-wysihtml5.js +511 -0
- data/app/assets/javascripts/custom/prices.js +1 -0
- data/app/assets/javascripts/wysihtml5-0.3.0.min.js +261 -0
- data/app/assets/stylesheets/application.sass +25 -1
- data/app/assets/stylesheets/bootstrap-wysihtml5.css +102 -0
- data/app/assets/stylesheets/bootstrap.css +1 -0
- data/app/assets/stylesheets/sass/store.sass +22 -0
- data/app/assets/stylesheets/wysiwyg-color.css +67 -0
- data/app/controllers/exchanges_controller.rb +7 -1
- data/app/controllers/membership_kits_controller.rb +25 -0
- data/app/controllers/mobile/dashboard_controller.rb +17 -0
- data/app/controllers/mobile/events_controller.rb +16 -0
- data/app/controllers/mobile/orders_controller.rb +60 -0
- data/app/controllers/mobile/shows_controller.rb +33 -0
- data/app/controllers/mobile/tickets_controller.rb +85 -0
- data/app/controllers/mobile/users_controller.rb +32 -0
- data/app/controllers/people_controller.rb +8 -6
- data/app/controllers/refunds_controller.rb +7 -7
- data/app/controllers/searches_controller.rb +3 -4
- data/app/controllers/store/checkouts_controller.rb +4 -4
- data/app/controllers/store/events_controller.rb +14 -2
- data/app/controllers/store/memberships_controller.rb +2 -0
- data/app/controllers/store/orders_controller.rb +1 -1
- data/app/controllers/tickets_controller.rb +2 -2
- data/app/helpers/artfully_ose_helper.rb +21 -0
- data/app/mailers/order_mailer.rb +28 -1
- data/app/models/address.rb +1 -1
- data/app/models/checkout.rb +8 -14
- data/app/models/contribution.rb +1 -0
- data/app/models/event.rb +17 -6
- data/app/models/exchange.rb +7 -5
- data/app/models/ext/integrations.rb +8 -3
- data/app/models/item.rb +4 -0
- data/app/models/job/checkout_processor.rb +41 -0
- data/app/models/job/order_mailer_job.rb +8 -0
- data/app/models/job/order_processor.rb +50 -9
- data/app/models/kit.rb +1 -1
- data/app/models/kits/membership_kit.rb +55 -0
- data/app/models/member.rb +16 -4
- data/app/models/membership_type.rb +7 -0
- data/app/models/order_handler.rb +4 -3
- data/app/models/orders/imported_order.rb +4 -0
- data/app/models/orders/order.rb +16 -5
- data/app/models/orders/pdf_generation.rb +75 -0
- data/app/models/organization.rb +7 -0
- data/app/models/person.rb +15 -0
- data/app/models/refund.rb +5 -2
- data/app/models/section.rb +16 -2
- data/app/models/show.rb +2 -8
- data/app/models/show_stats_view.rb +10 -0
- data/app/models/ticket.rb +38 -15
- data/app/models/ticket/qr_code.rb +21 -0
- data/app/models/ticket/template.rb +1 -0
- data/app/models/ticket/transfers.rb +5 -1
- data/app/models/ticket_summary.rb +5 -2
- data/app/models/ticket_type.rb +42 -7
- data/app/models/user.rb +3 -0
- data/app/models/user_membership.rb +1 -0
- data/app/views/actions/get/_show.html.haml +1 -12
- data/app/views/contributions/_form.html.haml +1 -1
- data/app/views/events/_ticket_type_fields.html.haml +21 -0
- data/app/views/events/image.html.haml +1 -1
- data/app/views/exchanges/new.html.haml +51 -28
- data/app/views/layouts/_google_analytics.html.haml +5 -2
- data/app/views/layouts/members.html.haml +1 -1
- data/app/views/layouts/storefront.html.haml +1 -1
- data/app/views/members/invitations/edit.html.erb +14 -0
- data/app/views/members/invitations/new.html.erb +14 -0
- data/app/views/members/mailer/invitation_instructions.html.haml +11 -0
- data/app/views/membership_kits/edit.html.haml +68 -0
- data/app/views/membership_types/index.html.haml +7 -3
- data/app/views/order_mailer/confirmation_for_exchange.html.haml +34 -0
- data/app/views/order_mailer/confirmation_for_exchange.text.haml +26 -0
- data/app/views/order_mailer/confirmation_for_refund.html.haml +29 -0
- data/app/views/order_mailer/confirmation_for_refund.text.haml +22 -0
- data/app/views/organizations/_form.html.haml +1 -1
- data/app/views/people/_header.html.haml +4 -4
- data/app/views/people/index.html.haml +18 -6
- data/app/views/refunds/new.html.haml +41 -27
- data/app/views/store/checkouts/_membership_info.html.haml +11 -0
- data/app/views/store/checkouts/thanks.html.haml +2 -10
- data/app/views/store/events/_calendar.html.haml +1 -4
- data/app/views/store/events/calendar.html.haml +49 -0
- data/app/views/store/events/show.html.haml +3 -8
- data/app/views/store/events/single_show.html.haml +2 -2
- data/app/views/store/memberships/index.html.haml +3 -11
- data/app/views/store/shows/_show.html.haml +6 -6
- data/config/initializers/paperclip.rb +14 -0
- data/config/routes.rb +35 -0
- data/db/migrate/20130722153731_add_autentication_token_to_users.rb +5 -0
- data/db/migrate/20130723212712_add_qr_code_to_tickets.rb +9 -0
- data/db/migrate/20130820011240_add_uuid_to_tickets.rb +13 -0
- data/db/migrate/20130820025134_make_ticket_uuid_not_null.rb +11 -0
- data/db/migrate/20130823191625_add_pdf_to_orders.rb +5 -0
- data/db/migrate/20131127162818_add_buyer_id_index_to_tickets.rb +5 -0
- data/db/migrate/20131127164000_member_tickets.rb +9 -0
- data/lib/artfully_ose.rb +3 -1
- data/lib/artfully_ose/engine.rb +5 -4
- data/lib/artfully_ose/version.rb +1 -1
- metadata +51 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MGRiNjgzNjkzMjA2MjgwY2RkZjM3OTM4MDEyZjQ3Y2JjNGRmYTIyYg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
Y2NkZDMxNzUwYjE3ZWU1N2FjMWEyYTc4MWFiOGM3MjU2Zjc5ZDNiZg==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
M2QyYzBhYjAwNGVkZDZlNGZmZDlhM2I1OTU5MjI2MmEyYzkwOWQyNDA1NzQz
|
10
|
+
OWZjNmI4MzFhMDFhMWM1NjE2ZGYwMDM2NDRmN2U3ODcwN2FiOGZiNjRhNTdj
|
11
|
+
ZmI1OGNlYThhYTVkMWIzOWEyY2I0MGIzNjlhMDZmNGEyNTEwMjI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MjRiZWE2Yjk4NGJiODAxM2U1NjEwM2RhYmU3ZDRhMjc1NDg3ODIxNjcyZGVm
|
14
|
+
YmZjNzIxMTAwYzE0YWQwMjBiMDViZWU1ZDdhNzQ5ZmRiNzgzZWUxOTNlMDAx
|
15
|
+
NGY5ZjQwZjc0YjM1Y2RiNTQyZWIwYTBhY2I0Y2JjODkzZmVjODk=
|
@@ -7,6 +7,8 @@
|
|
7
7
|
//= require locationselector
|
8
8
|
//= require_directory ./custom
|
9
9
|
//= require bootstrap
|
10
|
+
//= require wysihtml5-0.3.0.min.js
|
11
|
+
//= require bootstrap-wysihtml5.js
|
10
12
|
//= require_self
|
11
13
|
|
12
14
|
var artfully = angular.module("artfully", ['ngResource']);
|
@@ -158,6 +160,20 @@ var clearFA = function() {
|
|
158
160
|
}
|
159
161
|
}
|
160
162
|
|
163
|
+
|
164
|
+
function bindMemberTickets() {
|
165
|
+
$('.member-ticket-yes').on('click', function(e) { $('.membership-fields', $(this).parent().parent().parent().parent()).show() })
|
166
|
+
$('.member-ticket-no').on('click', function(e) { $('.membership-fields', $(this).parent().parent().parent().parent()).hide() })
|
167
|
+
|
168
|
+
jQuery.each($('.member-ticket-yes'), function() {
|
169
|
+
if ($(this).prop("checked")) {
|
170
|
+
$('.membership-fields', $(this).parent().parent().parent().parent()).show()
|
171
|
+
} else {
|
172
|
+
$('.membership-fields', $(this).parent().parent().parent().parent()).hide()
|
173
|
+
}
|
174
|
+
})
|
175
|
+
}
|
176
|
+
|
161
177
|
$(document).ready(function() {
|
162
178
|
|
163
179
|
/*********** NEW BOOTSTRAP JS ***********/
|
@@ -179,6 +195,8 @@ $(document).ready(function() {
|
|
179
195
|
$('.dropdown .dropdown-menu .disabled').on('click', function(e) {
|
180
196
|
e.preventDefault();
|
181
197
|
});
|
198
|
+
|
199
|
+
$('.wysihtml5').wysihtml5()
|
182
200
|
|
183
201
|
/*********** NEW ARTFULLY JS ************/
|
184
202
|
|
@@ -186,7 +204,9 @@ $(document).ready(function() {
|
|
186
204
|
$('.no-fa').popover({trigger:'manual', title: "That's us not you!", content: "You cannot name your organization \"Fractured Atlas\". Use the name of your company, group, or business here. Fiscally sponsored projects of Fractured Atlas should use their project name here."})
|
187
205
|
$('.no-fa').on('keyup', checkForFA);
|
188
206
|
$('.no-fa').on('change', clearFA);
|
189
|
-
|
207
|
+
|
208
|
+
bindMemberTickets()
|
209
|
+
|
190
210
|
/*********** EXISTING ARTFUL.LY JS ******/
|
191
211
|
|
192
212
|
singleShot();
|
@@ -278,6 +298,7 @@ $(document).ready(function() {
|
|
278
298
|
$(".add-new-ticket-type-link").bind("ajax:complete", function(et, e){
|
279
299
|
$("#newTicketType").html(e.responseText);
|
280
300
|
$("#newTicketType").modal( "show" );
|
301
|
+
bindMemberTickets();
|
281
302
|
return false;
|
282
303
|
});
|
283
304
|
|
@@ -0,0 +1,511 @@
|
|
1
|
+
!function($, wysi) {
|
2
|
+
"use strict";
|
3
|
+
|
4
|
+
var tpl = {
|
5
|
+
"font-styles": function(locale, options) {
|
6
|
+
var size = (options && options.size) ? ' btn-'+options.size : '';
|
7
|
+
return "<li class='dropdown'>" +
|
8
|
+
"<a class='btn dropdown-toggle" + size + "' data-toggle='dropdown' href='#'>" +
|
9
|
+
"<i class='icon-font'></i> <span class='current-font'>" + locale.font_styles.normal + "</span> <b class='caret'></b>" +
|
10
|
+
"</a>" +
|
11
|
+
"<ul class='dropdown-menu'>" +
|
12
|
+
"<li><a data-wysihtml5-command='formatBlock' data-wysihtml5-command-value='div' tabindex='-1'>" + locale.font_styles.normal + "</a></li>" +
|
13
|
+
"<li><a data-wysihtml5-command='formatBlock' data-wysihtml5-command-value='h1' tabindex='-1'>" + locale.font_styles.h1 + "</a></li>" +
|
14
|
+
"<li><a data-wysihtml5-command='formatBlock' data-wysihtml5-command-value='h2' tabindex='-1'>" + locale.font_styles.h2 + "</a></li>" +
|
15
|
+
"<li><a data-wysihtml5-command='formatBlock' data-wysihtml5-command-value='h3' tabindex='-1'>" + locale.font_styles.h3 + "</a></li>" +
|
16
|
+
"<li><a data-wysihtml5-command='formatBlock' data-wysihtml5-command-value='h4'>" + locale.font_styles.h4 + "</a></li>" +
|
17
|
+
"<li><a data-wysihtml5-command='formatBlock' data-wysihtml5-command-value='h5'>" + locale.font_styles.h5 + "</a></li>" +
|
18
|
+
"<li><a data-wysihtml5-command='formatBlock' data-wysihtml5-command-value='h6'>" + locale.font_styles.h6 + "</a></li>" +
|
19
|
+
"</ul>" +
|
20
|
+
"</li>";
|
21
|
+
},
|
22
|
+
|
23
|
+
"emphasis": function(locale, options) {
|
24
|
+
var size = (options && options.size) ? ' btn-'+options.size : '';
|
25
|
+
return "<li>" +
|
26
|
+
"<div class='btn-group'>" +
|
27
|
+
"<a class='btn" + size + "' data-wysihtml5-command='bold' title='CTRL+B' tabindex='-1'>" + locale.emphasis.bold + "</a>" +
|
28
|
+
"<a class='btn" + size + "' data-wysihtml5-command='italic' title='CTRL+I' tabindex='-1'>" + locale.emphasis.italic + "</a>" +
|
29
|
+
"<a class='btn" + size + "' data-wysihtml5-command='underline' title='CTRL+U' tabindex='-1'>" + locale.emphasis.underline + "</a>" +
|
30
|
+
"</div>" +
|
31
|
+
"</li>";
|
32
|
+
},
|
33
|
+
|
34
|
+
"lists": function(locale, options) {
|
35
|
+
var size = (options && options.size) ? ' btn-'+options.size : '';
|
36
|
+
return "<li>" +
|
37
|
+
"<div class='btn-group'>" +
|
38
|
+
"<a class='btn" + size + "' data-wysihtml5-command='insertUnorderedList' title='" + locale.lists.unordered + "' tabindex='-1'><i class='icon-list'></i></a>" +
|
39
|
+
"<a class='btn" + size + "' data-wysihtml5-command='insertOrderedList' title='" + locale.lists.ordered + "' tabindex='-1'><i class='icon-th-list'></i></a>" +
|
40
|
+
"<a class='btn" + size + "' data-wysihtml5-command='Outdent' title='" + locale.lists.outdent + "' tabindex='-1'><i class='icon-indent-right'></i></a>" +
|
41
|
+
"<a class='btn" + size + "' data-wysihtml5-command='Indent' title='" + locale.lists.indent + "' tabindex='-1'><i class='icon-indent-left'></i></a>" +
|
42
|
+
"</div>" +
|
43
|
+
"</li>";
|
44
|
+
},
|
45
|
+
|
46
|
+
"link": function(locale, options) {
|
47
|
+
var size = (options && options.size) ? ' btn-'+options.size : '';
|
48
|
+
return "<li>" +
|
49
|
+
"<div class='bootstrap-wysihtml5-insert-link-modal modal hide fade'>" +
|
50
|
+
"<div class='modal-header'>" +
|
51
|
+
"<a class='close' data-dismiss='modal'>×</a>" +
|
52
|
+
"<h3>" + locale.link.insert + "</h3>" +
|
53
|
+
"</div>" +
|
54
|
+
"<div class='modal-body'>" +
|
55
|
+
"<input value='http://' class='bootstrap-wysihtml5-insert-link-url input-xlarge'>" +
|
56
|
+
"<label class='checkbox'> <input type='checkbox' class='bootstrap-wysihtml5-insert-link-target' checked>" + locale.link.target + "</label>" +
|
57
|
+
"</div>" +
|
58
|
+
"<div class='modal-footer'>" +
|
59
|
+
"<a href='#' class='btn' data-dismiss='modal'>" + locale.link.cancel + "</a>" +
|
60
|
+
"<a href='#' class='btn btn-primary' data-dismiss='modal'>" + locale.link.insert + "</a>" +
|
61
|
+
"</div>" +
|
62
|
+
"</div>" +
|
63
|
+
"<a class='btn" + size + "' data-wysihtml5-command='createLink' title='" + locale.link.insert + "' tabindex='-1'><i class='icon-share'></i></a>" +
|
64
|
+
"</li>";
|
65
|
+
},
|
66
|
+
|
67
|
+
"image": function(locale, options) {
|
68
|
+
var size = (options && options.size) ? ' btn-'+options.size : '';
|
69
|
+
return "<li>" +
|
70
|
+
"<div class='bootstrap-wysihtml5-insert-image-modal modal hide fade'>" +
|
71
|
+
"<div class='modal-header'>" +
|
72
|
+
"<a class='close' data-dismiss='modal'>×</a>" +
|
73
|
+
"<h3>" + locale.image.insert + "</h3>" +
|
74
|
+
"</div>" +
|
75
|
+
"<div class='modal-body'>" +
|
76
|
+
"<input value='http://' class='bootstrap-wysihtml5-insert-image-url input-xlarge'>" +
|
77
|
+
"</div>" +
|
78
|
+
"<div class='modal-footer'>" +
|
79
|
+
"<a href='#' class='btn' data-dismiss='modal'>" + locale.image.cancel + "</a>" +
|
80
|
+
"<a href='#' class='btn btn-primary' data-dismiss='modal'>" + locale.image.insert + "</a>" +
|
81
|
+
"</div>" +
|
82
|
+
"</div>" +
|
83
|
+
"<a class='btn" + size + "' data-wysihtml5-command='insertImage' title='" + locale.image.insert + "' tabindex='-1'><i class='icon-picture'></i></a>" +
|
84
|
+
"</li>";
|
85
|
+
},
|
86
|
+
|
87
|
+
"html": function(locale, options) {
|
88
|
+
var size = (options && options.size) ? ' btn-'+options.size : '';
|
89
|
+
return "<li>" +
|
90
|
+
"<div class='btn-group'>" +
|
91
|
+
"<a class='btn" + size + "' data-wysihtml5-action='change_view' title='" + locale.html.edit + "' tabindex='-1'><i class='icon-pencil'></i></a>" +
|
92
|
+
"</div>" +
|
93
|
+
"</li>";
|
94
|
+
},
|
95
|
+
|
96
|
+
"color": function(locale, options) {
|
97
|
+
var size = (options && options.size) ? ' btn-'+options.size : '';
|
98
|
+
return "<li class='dropdown'>" +
|
99
|
+
"<a class='btn dropdown-toggle" + size + "' data-toggle='dropdown' href='#' tabindex='-1'>" +
|
100
|
+
"<span class='current-color'>" + locale.colours.black + "</span> <b class='caret'></b>" +
|
101
|
+
"</a>" +
|
102
|
+
"<ul class='dropdown-menu'>" +
|
103
|
+
"<li><div class='wysihtml5-colors' data-wysihtml5-command-value='black'></div><a class='wysihtml5-colors-title' data-wysihtml5-command='foreColor' data-wysihtml5-command-value='black'>" + locale.colours.black + "</a></li>" +
|
104
|
+
"<li><div class='wysihtml5-colors' data-wysihtml5-command-value='silver'></div><a class='wysihtml5-colors-title' data-wysihtml5-command='foreColor' data-wysihtml5-command-value='silver'>" + locale.colours.silver + "</a></li>" +
|
105
|
+
"<li><div class='wysihtml5-colors' data-wysihtml5-command-value='gray'></div><a class='wysihtml5-colors-title' data-wysihtml5-command='foreColor' data-wysihtml5-command-value='gray'>" + locale.colours.gray + "</a></li>" +
|
106
|
+
"<li><div class='wysihtml5-colors' data-wysihtml5-command-value='maroon'></div><a class='wysihtml5-colors-title' data-wysihtml5-command='foreColor' data-wysihtml5-command-value='maroon'>" + locale.colours.maroon + "</a></li>" +
|
107
|
+
"<li><div class='wysihtml5-colors' data-wysihtml5-command-value='red'></div><a class='wysihtml5-colors-title' data-wysihtml5-command='foreColor' data-wysihtml5-command-value='red'>" + locale.colours.red + "</a></li>" +
|
108
|
+
"<li><div class='wysihtml5-colors' data-wysihtml5-command-value='purple'></div><a class='wysihtml5-colors-title' data-wysihtml5-command='foreColor' data-wysihtml5-command-value='purple'>" + locale.colours.purple + "</a></li>" +
|
109
|
+
"<li><div class='wysihtml5-colors' data-wysihtml5-command-value='green'></div><a class='wysihtml5-colors-title' data-wysihtml5-command='foreColor' data-wysihtml5-command-value='green'>" + locale.colours.green + "</a></li>" +
|
110
|
+
"<li><div class='wysihtml5-colors' data-wysihtml5-command-value='olive'></div><a class='wysihtml5-colors-title' data-wysihtml5-command='foreColor' data-wysihtml5-command-value='olive'>" + locale.colours.olive + "</a></li>" +
|
111
|
+
"<li><div class='wysihtml5-colors' data-wysihtml5-command-value='navy'></div><a class='wysihtml5-colors-title' data-wysihtml5-command='foreColor' data-wysihtml5-command-value='navy'>" + locale.colours.navy + "</a></li>" +
|
112
|
+
"<li><div class='wysihtml5-colors' data-wysihtml5-command-value='blue'></div><a class='wysihtml5-colors-title' data-wysihtml5-command='foreColor' data-wysihtml5-command-value='blue'>" + locale.colours.blue + "</a></li>" +
|
113
|
+
"<li><div class='wysihtml5-colors' data-wysihtml5-command-value='orange'></div><a class='wysihtml5-colors-title' data-wysihtml5-command='foreColor' data-wysihtml5-command-value='orange'>" + locale.colours.orange + "</a></li>" +
|
114
|
+
"</ul>" +
|
115
|
+
"</li>";
|
116
|
+
}
|
117
|
+
};
|
118
|
+
|
119
|
+
var templates = function(key, locale, options) {
|
120
|
+
return tpl[key](locale, options);
|
121
|
+
};
|
122
|
+
|
123
|
+
|
124
|
+
var Wysihtml5 = function(el, options) {
|
125
|
+
this.el = el;
|
126
|
+
var toolbarOpts = options || defaultOptions;
|
127
|
+
for(var t in toolbarOpts.customTemplates) {
|
128
|
+
tpl[t] = toolbarOpts.customTemplates[t];
|
129
|
+
}
|
130
|
+
this.toolbar = this.createToolbar(el, toolbarOpts);
|
131
|
+
this.editor = this.createEditor(options);
|
132
|
+
|
133
|
+
window.editor = this.editor;
|
134
|
+
|
135
|
+
$('iframe.wysihtml5-sandbox').each(function(i, el){
|
136
|
+
$(el.contentWindow).off('focus.wysihtml5').on({
|
137
|
+
'focus.wysihtml5' : function(){
|
138
|
+
$('li.dropdown').removeClass('open');
|
139
|
+
}
|
140
|
+
});
|
141
|
+
});
|
142
|
+
};
|
143
|
+
|
144
|
+
Wysihtml5.prototype = {
|
145
|
+
|
146
|
+
constructor: Wysihtml5,
|
147
|
+
|
148
|
+
createEditor: function(options) {
|
149
|
+
options = options || {};
|
150
|
+
|
151
|
+
// Add the toolbar to a clone of the options object so multiple instances
|
152
|
+
// of the WYISYWG don't break because "toolbar" is already defined
|
153
|
+
options = $.extend(true, {}, options);
|
154
|
+
options.toolbar = this.toolbar[0];
|
155
|
+
|
156
|
+
var editor = new wysi.Editor(this.el[0], options);
|
157
|
+
|
158
|
+
if(options && options.events) {
|
159
|
+
for(var eventName in options.events) {
|
160
|
+
editor.on(eventName, options.events[eventName]);
|
161
|
+
}
|
162
|
+
}
|
163
|
+
return editor;
|
164
|
+
},
|
165
|
+
|
166
|
+
createToolbar: function(el, options) {
|
167
|
+
var self = this;
|
168
|
+
var toolbar = $("<ul/>", {
|
169
|
+
'class' : "wysihtml5-toolbar",
|
170
|
+
'style': "display:none"
|
171
|
+
});
|
172
|
+
var culture = options.locale || defaultOptions.locale || "en";
|
173
|
+
for(var key in defaultOptions) {
|
174
|
+
var value = false;
|
175
|
+
|
176
|
+
if(options[key] !== undefined) {
|
177
|
+
if(options[key] === true) {
|
178
|
+
value = true;
|
179
|
+
}
|
180
|
+
} else {
|
181
|
+
value = defaultOptions[key];
|
182
|
+
}
|
183
|
+
|
184
|
+
if(value === true) {
|
185
|
+
toolbar.append(templates(key, locale[culture], options));
|
186
|
+
|
187
|
+
if(key === "html") {
|
188
|
+
this.initHtml(toolbar);
|
189
|
+
}
|
190
|
+
|
191
|
+
if(key === "link") {
|
192
|
+
this.initInsertLink(toolbar);
|
193
|
+
}
|
194
|
+
|
195
|
+
if(key === "image") {
|
196
|
+
this.initInsertImage(toolbar);
|
197
|
+
}
|
198
|
+
}
|
199
|
+
}
|
200
|
+
|
201
|
+
if(options.toolbar) {
|
202
|
+
for(key in options.toolbar) {
|
203
|
+
toolbar.append(options.toolbar[key]);
|
204
|
+
}
|
205
|
+
}
|
206
|
+
|
207
|
+
toolbar.find("a[data-wysihtml5-command='formatBlock']").click(function(e) {
|
208
|
+
var target = e.target || e.srcElement;
|
209
|
+
var el = $(target);
|
210
|
+
self.toolbar.find('.current-font').text(el.html());
|
211
|
+
});
|
212
|
+
|
213
|
+
toolbar.find("a[data-wysihtml5-command='foreColor']").click(function(e) {
|
214
|
+
var target = e.target || e.srcElement;
|
215
|
+
var el = $(target);
|
216
|
+
self.toolbar.find('.current-color').text(el.html());
|
217
|
+
});
|
218
|
+
|
219
|
+
this.el.before(toolbar);
|
220
|
+
|
221
|
+
return toolbar;
|
222
|
+
},
|
223
|
+
|
224
|
+
initHtml: function(toolbar) {
|
225
|
+
var changeViewSelector = "a[data-wysihtml5-action='change_view']";
|
226
|
+
toolbar.find(changeViewSelector).click(function(e) {
|
227
|
+
toolbar.find('a.btn').not(changeViewSelector).toggleClass('disabled');
|
228
|
+
});
|
229
|
+
},
|
230
|
+
|
231
|
+
initInsertImage: function(toolbar) {
|
232
|
+
var self = this;
|
233
|
+
var insertImageModal = toolbar.find('.bootstrap-wysihtml5-insert-image-modal');
|
234
|
+
var urlInput = insertImageModal.find('.bootstrap-wysihtml5-insert-image-url');
|
235
|
+
var insertButton = insertImageModal.find('a.btn-primary');
|
236
|
+
var initialValue = urlInput.val();
|
237
|
+
var caretBookmark;
|
238
|
+
|
239
|
+
var insertImage = function() {
|
240
|
+
var url = urlInput.val();
|
241
|
+
urlInput.val(initialValue);
|
242
|
+
self.editor.currentView.element.focus();
|
243
|
+
if (caretBookmark) {
|
244
|
+
self.editor.composer.selection.setBookmark(caretBookmark);
|
245
|
+
caretBookmark = null;
|
246
|
+
}
|
247
|
+
self.editor.composer.commands.exec("insertImage", url);
|
248
|
+
};
|
249
|
+
|
250
|
+
urlInput.keypress(function(e) {
|
251
|
+
if(e.which == 13) {
|
252
|
+
insertImage();
|
253
|
+
insertImageModal.modal('hide');
|
254
|
+
}
|
255
|
+
});
|
256
|
+
|
257
|
+
insertButton.click(insertImage);
|
258
|
+
|
259
|
+
insertImageModal.on('shown', function() {
|
260
|
+
urlInput.focus();
|
261
|
+
});
|
262
|
+
|
263
|
+
insertImageModal.on('hide', function() {
|
264
|
+
self.editor.currentView.element.focus();
|
265
|
+
});
|
266
|
+
|
267
|
+
toolbar.find('a[data-wysihtml5-command=insertImage]').click(function() {
|
268
|
+
var activeButton = $(this).hasClass("wysihtml5-command-active");
|
269
|
+
|
270
|
+
if (!activeButton) {
|
271
|
+
self.editor.currentView.element.focus(false);
|
272
|
+
caretBookmark = self.editor.composer.selection.getBookmark();
|
273
|
+
insertImageModal.appendTo('body').modal('show');
|
274
|
+
insertImageModal.on('click.dismiss.modal', '[data-dismiss="modal"]', function(e) {
|
275
|
+
e.stopPropagation();
|
276
|
+
});
|
277
|
+
return false;
|
278
|
+
}
|
279
|
+
else {
|
280
|
+
return true;
|
281
|
+
}
|
282
|
+
});
|
283
|
+
},
|
284
|
+
|
285
|
+
initInsertLink: function(toolbar) {
|
286
|
+
var self = this;
|
287
|
+
var insertLinkModal = toolbar.find('.bootstrap-wysihtml5-insert-link-modal');
|
288
|
+
var urlInput = insertLinkModal.find('.bootstrap-wysihtml5-insert-link-url');
|
289
|
+
var targetInput = insertLinkModal.find('.bootstrap-wysihtml5-insert-link-target');
|
290
|
+
var insertButton = insertLinkModal.find('a.btn-primary');
|
291
|
+
var initialValue = urlInput.val();
|
292
|
+
var caretBookmark;
|
293
|
+
|
294
|
+
var insertLink = function() {
|
295
|
+
var url = urlInput.val();
|
296
|
+
urlInput.val(initialValue);
|
297
|
+
self.editor.currentView.element.focus();
|
298
|
+
if (caretBookmark) {
|
299
|
+
self.editor.composer.selection.setBookmark(caretBookmark);
|
300
|
+
caretBookmark = null;
|
301
|
+
}
|
302
|
+
|
303
|
+
var newWindow = targetInput.prop("checked");
|
304
|
+
self.editor.composer.commands.exec("createLink", {
|
305
|
+
'href' : url,
|
306
|
+
'target' : (newWindow ? '_blank' : '_self'),
|
307
|
+
'rel' : (newWindow ? 'nofollow' : '')
|
308
|
+
});
|
309
|
+
};
|
310
|
+
var pressedEnter = false;
|
311
|
+
|
312
|
+
urlInput.keypress(function(e) {
|
313
|
+
if(e.which == 13) {
|
314
|
+
insertLink();
|
315
|
+
insertLinkModal.modal('hide');
|
316
|
+
}
|
317
|
+
});
|
318
|
+
|
319
|
+
insertButton.click(insertLink);
|
320
|
+
|
321
|
+
insertLinkModal.on('shown', function() {
|
322
|
+
urlInput.focus();
|
323
|
+
});
|
324
|
+
|
325
|
+
insertLinkModal.on('hide', function() {
|
326
|
+
self.editor.currentView.element.focus();
|
327
|
+
});
|
328
|
+
|
329
|
+
toolbar.find('a[data-wysihtml5-command=createLink]').click(function() {
|
330
|
+
var activeButton = $(this).hasClass("wysihtml5-command-active");
|
331
|
+
|
332
|
+
if (!activeButton) {
|
333
|
+
self.editor.currentView.element.focus(false);
|
334
|
+
caretBookmark = self.editor.composer.selection.getBookmark();
|
335
|
+
insertLinkModal.appendTo('body').modal('show');
|
336
|
+
insertLinkModal.on('click.dismiss.modal', '[data-dismiss="modal"]', function(e) {
|
337
|
+
e.stopPropagation();
|
338
|
+
});
|
339
|
+
return false;
|
340
|
+
}
|
341
|
+
else {
|
342
|
+
return true;
|
343
|
+
}
|
344
|
+
});
|
345
|
+
}
|
346
|
+
};
|
347
|
+
|
348
|
+
// these define our public api
|
349
|
+
var methods = {
|
350
|
+
resetDefaults: function() {
|
351
|
+
$.fn.wysihtml5.defaultOptions = $.extend(true, {}, $.fn.wysihtml5.defaultOptionsCache);
|
352
|
+
},
|
353
|
+
bypassDefaults: function(options) {
|
354
|
+
return this.each(function () {
|
355
|
+
var $this = $(this);
|
356
|
+
$this.data('wysihtml5', new Wysihtml5($this, options));
|
357
|
+
});
|
358
|
+
},
|
359
|
+
shallowExtend: function (options) {
|
360
|
+
var settings = $.extend({}, $.fn.wysihtml5.defaultOptions, options || {}, $(this).data());
|
361
|
+
var that = this;
|
362
|
+
return methods.bypassDefaults.apply(that, [settings]);
|
363
|
+
},
|
364
|
+
deepExtend: function(options) {
|
365
|
+
var settings = $.extend(true, {}, $.fn.wysihtml5.defaultOptions, options || {});
|
366
|
+
var that = this;
|
367
|
+
return methods.bypassDefaults.apply(that, [settings]);
|
368
|
+
},
|
369
|
+
init: function(options) {
|
370
|
+
var that = this;
|
371
|
+
return methods.shallowExtend.apply(that, [options]);
|
372
|
+
}
|
373
|
+
};
|
374
|
+
|
375
|
+
$.fn.wysihtml5 = function ( method ) {
|
376
|
+
if ( methods[method] ) {
|
377
|
+
return methods[method].apply( this, Array.prototype.slice.call( arguments, 1 ));
|
378
|
+
} else if ( typeof method === 'object' || ! method ) {
|
379
|
+
return methods.init.apply( this, arguments );
|
380
|
+
} else {
|
381
|
+
$.error( 'Method ' + method + ' does not exist on jQuery.wysihtml5' );
|
382
|
+
}
|
383
|
+
};
|
384
|
+
|
385
|
+
$.fn.wysihtml5.Constructor = Wysihtml5;
|
386
|
+
|
387
|
+
var defaultOptions = $.fn.wysihtml5.defaultOptions = {
|
388
|
+
"font-styles": true,
|
389
|
+
"color": false,
|
390
|
+
"emphasis": true,
|
391
|
+
"lists": true,
|
392
|
+
"html": false,
|
393
|
+
"link": true,
|
394
|
+
"image": true,
|
395
|
+
events: {},
|
396
|
+
parserRules: {
|
397
|
+
classes: {
|
398
|
+
// (path_to_project/lib/css/wysiwyg-color.css)
|
399
|
+
"wysiwyg-color-silver" : 1,
|
400
|
+
"wysiwyg-color-gray" : 1,
|
401
|
+
"wysiwyg-color-white" : 1,
|
402
|
+
"wysiwyg-color-maroon" : 1,
|
403
|
+
"wysiwyg-color-red" : 1,
|
404
|
+
"wysiwyg-color-purple" : 1,
|
405
|
+
"wysiwyg-color-fuchsia" : 1,
|
406
|
+
"wysiwyg-color-green" : 1,
|
407
|
+
"wysiwyg-color-lime" : 1,
|
408
|
+
"wysiwyg-color-olive" : 1,
|
409
|
+
"wysiwyg-color-yellow" : 1,
|
410
|
+
"wysiwyg-color-navy" : 1,
|
411
|
+
"wysiwyg-color-blue" : 1,
|
412
|
+
"wysiwyg-color-teal" : 1,
|
413
|
+
"wysiwyg-color-aqua" : 1,
|
414
|
+
"wysiwyg-color-orange" : 1
|
415
|
+
},
|
416
|
+
tags: {
|
417
|
+
"b": {},
|
418
|
+
"i": {},
|
419
|
+
"br": {},
|
420
|
+
"ol": {},
|
421
|
+
"ul": {},
|
422
|
+
"li": {},
|
423
|
+
"h1": {},
|
424
|
+
"h2": {},
|
425
|
+
"h3": {},
|
426
|
+
"h4": {},
|
427
|
+
"h5": {},
|
428
|
+
"h6": {},
|
429
|
+
"blockquote": {},
|
430
|
+
"u": 1,
|
431
|
+
"img": {
|
432
|
+
"check_attributes": {
|
433
|
+
"width": "numbers",
|
434
|
+
"alt": "alt",
|
435
|
+
"src": "url",
|
436
|
+
"height": "numbers"
|
437
|
+
}
|
438
|
+
},
|
439
|
+
"a": {
|
440
|
+
check_attributes: {
|
441
|
+
'href': "url", // important to avoid XSS
|
442
|
+
'target': 'alt',
|
443
|
+
'rel': 'alt'
|
444
|
+
}
|
445
|
+
},
|
446
|
+
"span": 1,
|
447
|
+
"div": 1,
|
448
|
+
// to allow save and edit files with code tag hacks
|
449
|
+
"code": 1,
|
450
|
+
"pre": 1
|
451
|
+
}
|
452
|
+
},
|
453
|
+
stylesheets: ["/assets/wysiwyg-color.css"], // (path_to_project/lib/css/wysiwyg-color.css)
|
454
|
+
locale: "en"
|
455
|
+
};
|
456
|
+
|
457
|
+
if (typeof $.fn.wysihtml5.defaultOptionsCache === 'undefined') {
|
458
|
+
$.fn.wysihtml5.defaultOptionsCache = $.extend(true, {}, $.fn.wysihtml5.defaultOptions);
|
459
|
+
}
|
460
|
+
|
461
|
+
var locale = $.fn.wysihtml5.locale = {
|
462
|
+
en: {
|
463
|
+
font_styles: {
|
464
|
+
normal: "Normal text",
|
465
|
+
h1: "Heading 1",
|
466
|
+
h2: "Heading 2",
|
467
|
+
h3: "Heading 3",
|
468
|
+
h4: "Heading 4",
|
469
|
+
h5: "Heading 5",
|
470
|
+
h6: "Heading 6"
|
471
|
+
},
|
472
|
+
emphasis: {
|
473
|
+
bold: "Bold",
|
474
|
+
italic: "Italic",
|
475
|
+
underline: "Underline"
|
476
|
+
},
|
477
|
+
lists: {
|
478
|
+
unordered: "Unordered list",
|
479
|
+
ordered: "Ordered list",
|
480
|
+
outdent: "Outdent",
|
481
|
+
indent: "Indent"
|
482
|
+
},
|
483
|
+
link: {
|
484
|
+
insert: "Insert link",
|
485
|
+
cancel: "Cancel",
|
486
|
+
target: "Open link in new window"
|
487
|
+
},
|
488
|
+
image: {
|
489
|
+
insert: "Insert image",
|
490
|
+
cancel: "Cancel"
|
491
|
+
},
|
492
|
+
html: {
|
493
|
+
edit: "Edit HTML"
|
494
|
+
},
|
495
|
+
colours: {
|
496
|
+
black: "Black",
|
497
|
+
silver: "Silver",
|
498
|
+
gray: "Grey",
|
499
|
+
maroon: "Maroon",
|
500
|
+
red: "Red",
|
501
|
+
purple: "Purple",
|
502
|
+
green: "Green",
|
503
|
+
olive: "Olive",
|
504
|
+
navy: "Navy",
|
505
|
+
blue: "Blue",
|
506
|
+
orange: "Orange"
|
507
|
+
}
|
508
|
+
}
|
509
|
+
};
|
510
|
+
|
511
|
+
}(window.jQuery, window.wysihtml5);
|