cowtech-js-rails 1.0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README +6 -0
- data/lib/cowtech_js.rb +14 -0
- data/lib/cowtech_js/version.rb +20 -0
- data/vendor/assets/javascripts/cowtech/accesskeys.coffee +92 -0
- data/vendor/assets/javascripts/cowtech/autocomplete.coffee +49 -0
- data/vendor/assets/javascripts/cowtech/bulk.coffee +71 -0
- data/vendor/assets/javascripts/cowtech/calculator.coffee +110 -0
- data/vendor/assets/javascripts/cowtech/clipboard.coffee +46 -0
- data/vendor/assets/javascripts/cowtech/combobox.coffee +101 -0
- data/vendor/assets/javascripts/cowtech/document.coffee +252 -0
- data/vendor/assets/javascripts/cowtech/dynamic-table.coffee +184 -0
- data/vendor/assets/javascripts/cowtech/form.coffee +383 -0
- data/vendor/assets/javascripts/cowtech/google-analytics.coffee +22 -0
- data/vendor/assets/javascripts/cowtech/keepalive.coffee +57 -0
- data/vendor/assets/javascripts/cowtech/messages.coffee +258 -0
- data/vendor/assets/javascripts/cowtech/modal.coffee +175 -0
- data/vendor/assets/javascripts/cowtech/numeric.coffee +77 -0
- data/vendor/assets/javascripts/cowtech/scroll.coffee +34 -0
- data/vendor/assets/javascripts/cowtech/search.coffee +43 -0
- data/vendor/assets/javascripts/cowtech/share.coffee +59 -0
- data/vendor/assets/javascripts/cowtech/utils.coffee +110 -0
- data/vendor/assets/javascripts/cowtech/wysiwyg.coffee +155 -0
- metadata +101 -0
@@ -0,0 +1,77 @@
|
|
1
|
+
###
|
2
|
+
#
|
3
|
+
# This file is part of the cowtech-js-rails gem. Copyright (C) 2012 and above Shogun <shogun_panda@me.com>.
|
4
|
+
# Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.
|
5
|
+
#
|
6
|
+
###
|
7
|
+
|
8
|
+
(($) ->
|
9
|
+
$.cowtech = $.cowtech || {}
|
10
|
+
|
11
|
+
$.cowtech.numeric =
|
12
|
+
precision: 3
|
13
|
+
autoload: (->
|
14
|
+
$("[type=numeric], [validate=numeric]").cowtech_numeric()
|
15
|
+
)
|
16
|
+
|
17
|
+
handle: ((input) ->
|
18
|
+
regex =
|
19
|
+
float: /^(-?)(\d+)([,.]\d+)?$/
|
20
|
+
integer: /^(-?)\d+$/
|
21
|
+
|
22
|
+
is_float = (input.attr("data-numeric-float") == "true")
|
23
|
+
positive = (input.attr("data-numeric-positive") == "true")
|
24
|
+
not_zero = (input.attr("data-numeric-not-zero") == "true")
|
25
|
+
precision = parseInt(input.attr("data-numeric-precision"))
|
26
|
+
val = input.val().trim().replace(",", ".")
|
27
|
+
|
28
|
+
# Set precision
|
29
|
+
precision = $.cowtech.numeric.precision if isNaN(precision) || precision < 1
|
30
|
+
|
31
|
+
# Check if valid
|
32
|
+
val = "0" if val.length == 0 || !regex["float"].test(val)
|
33
|
+
|
34
|
+
# Round to n decimal digit
|
35
|
+
val = $.cowtech.utils.parse_float(val)
|
36
|
+
input.data("numeric-value", val)
|
37
|
+
|
38
|
+
# Set value
|
39
|
+
input.val(val.toFixed((if (is_float) then precision else 0)).replace(".", ","))
|
40
|
+
|
41
|
+
# Set classes
|
42
|
+
input.removeClass("numeric-positive numeric-negative numeric-zero numeric-unset")
|
43
|
+
if val == 0
|
44
|
+
input.addClass("numeric-zero")
|
45
|
+
input.addClass("numeric-unset") if not_zero == true
|
46
|
+
else
|
47
|
+
input.addClass((if (val > 0) then "numeric-positive" else "numeric-negative")) if input.attr("data-numeric-add-classes") == "true"
|
48
|
+
|
49
|
+
!(positive && val < 0) || input.is("[required].numeric-unset") || input.is(".required.numeric-unset")
|
50
|
+
)
|
51
|
+
|
52
|
+
$.fn.cowtech_numeric = (->
|
53
|
+
@each ->
|
54
|
+
el = $(this)
|
55
|
+
el.on("change", ->
|
56
|
+
$.cowtech.numeric.handle(el)
|
57
|
+
).on("focus", ->
|
58
|
+
val = el.val().trim().replace(",", ".")
|
59
|
+
el.val("") if parseFloat(val) == 0
|
60
|
+
el.css(
|
61
|
+
color: "black"
|
62
|
+
fontStyle: "normal"
|
63
|
+
).removeClass("positive negative zero unset")
|
64
|
+
).on("blur", ->
|
65
|
+
$(el).css(
|
66
|
+
color: null
|
67
|
+
fontStyle: null
|
68
|
+
)
|
69
|
+
|
70
|
+
$.cowtech.numeric.handle(el)
|
71
|
+
).addClass("numeric").change()
|
72
|
+
)
|
73
|
+
|
74
|
+
$.fn.numberize = (->
|
75
|
+
$.cowtech.numeric.handle(this) if @is(".numeric")
|
76
|
+
)
|
77
|
+
)(jQuery)
|
@@ -0,0 +1,34 @@
|
|
1
|
+
###
|
2
|
+
#
|
3
|
+
# This file is part of the cowtech-js-rails gem. Copyright (C) 2012 and above Shogun <shogun_panda@me.com>.
|
4
|
+
# Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.
|
5
|
+
#
|
6
|
+
###
|
7
|
+
|
8
|
+
(($) ->
|
9
|
+
$.cowtech = $.cowtech || {}
|
10
|
+
|
11
|
+
$.cowtech.scroll =
|
12
|
+
trigger: null
|
13
|
+
|
14
|
+
autoload: (->
|
15
|
+
$.cowtech.scroll.trigger = $("[data-scroll-role=trigger]")
|
16
|
+
|
17
|
+
$.cowtech.scroll.trigger.hide().on("click", (ev) ->
|
18
|
+
$("body").animate({
|
19
|
+
scrollTop: 0
|
20
|
+
},
|
21
|
+
"fast"
|
22
|
+
)
|
23
|
+
|
24
|
+
false
|
25
|
+
)
|
26
|
+
|
27
|
+
$(window).on("scroll", ->
|
28
|
+
if $(window).scrollTop() > 0
|
29
|
+
$.cowtech.scroll.trigger.fadeIn()
|
30
|
+
else
|
31
|
+
$.cowtech.scroll.trigger.fadeOut()
|
32
|
+
)
|
33
|
+
)
|
34
|
+
)(jQuery)
|
@@ -0,0 +1,43 @@
|
|
1
|
+
###
|
2
|
+
#
|
3
|
+
# This file is part of the cowtech-js-rails gem. Copyright (C) 2012 and above Shogun <shogun_panda@me.com>.
|
4
|
+
# Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.
|
5
|
+
#
|
6
|
+
###
|
7
|
+
|
8
|
+
(($) ->
|
9
|
+
$.cowtech = $.cowtech || {}
|
10
|
+
$.cowtech.search =
|
11
|
+
execute: (->
|
12
|
+
nv = $.extend($.cowtech.data.params.params, {
|
13
|
+
page: 1
|
14
|
+
})
|
15
|
+
fnv = {}
|
16
|
+
|
17
|
+
$("[data-search-field]").each(->
|
18
|
+
key = $(this).attr("data-search-field")
|
19
|
+
|
20
|
+
if !key.match(/^period-(month|year)$/)
|
21
|
+
if $(this).is("[type=checkbox]")
|
22
|
+
nv[key] = $(this).is(":checked")
|
23
|
+
else
|
24
|
+
nv[key] = $(this).val()
|
25
|
+
)
|
26
|
+
|
27
|
+
nv["period"] = "#{$("[data-search-field=period-year]").val()}-#{$("[data-search-field=period-month]").val()}" if $("[data-search-field|=\"period\"]").size() == 2
|
28
|
+
|
29
|
+
for key of nv
|
30
|
+
fnv[key] = nv[key] if !$.cowtech.utils.is_blank(nv[key])
|
31
|
+
location.href = "#{$.cowtech.data.params.current_location.replace(/#$/, "")}?#{$.param(fnv)}"
|
32
|
+
)
|
33
|
+
|
34
|
+
autoload: (->
|
35
|
+
$("[data-search-field]:not([data-search-disabled=true])").on("change", $.cowtech.search.execute)
|
36
|
+
$("[data-search-role=search]").on("click", $.cowtech.search.execute)
|
37
|
+
$("[data-search-role=clear]").on("click", (ev) ->
|
38
|
+
$("[data-search-field=search]").val("")
|
39
|
+
$.cowtech.search.execute()
|
40
|
+
false
|
41
|
+
)
|
42
|
+
)
|
43
|
+
)(jQuery)
|
@@ -0,0 +1,59 @@
|
|
1
|
+
###
|
2
|
+
#
|
3
|
+
# This file is part of the cowtech-js-rails gem. Copyright (C) 2012 and above Shogun <shogun_panda@me.com>.
|
4
|
+
# Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.
|
5
|
+
#
|
6
|
+
###
|
7
|
+
|
8
|
+
(($) ->
|
9
|
+
$.cowtech = $.cowtech || {}
|
10
|
+
$.cowtech.share =
|
11
|
+
autoload: ((config) ->
|
12
|
+
$("div.share").cowtech_share(config)
|
13
|
+
hide_tips = ->
|
14
|
+
$(".qtip").qtip("hide")
|
15
|
+
|
16
|
+
$(window).on("scroll", hide_tips)
|
17
|
+
|
18
|
+
$("div, section").each(->
|
19
|
+
$(this).on("scroll", hide_tips) if $(this).css("overflow-y") == "scroll"
|
20
|
+
)
|
21
|
+
)
|
22
|
+
|
23
|
+
$.fn.cowtech_share = ((config) ->
|
24
|
+
@each(->
|
25
|
+
body = $(this).hide()
|
26
|
+
config = $.cowtech.utils.initialize(config, {
|
27
|
+
yadjust: yadjust_def
|
28
|
+
})
|
29
|
+
|
30
|
+
yadjust_def = -2
|
31
|
+
yadjust = $.cowtech.utils.initialize(config.yadjust, yadjust_def)
|
32
|
+
|
33
|
+
body.parent().find("h2").qtip(
|
34
|
+
content:
|
35
|
+
text: body
|
36
|
+
position:
|
37
|
+
my: "top left"
|
38
|
+
at: "bottom left"
|
39
|
+
viewport: $(window)
|
40
|
+
adjust:
|
41
|
+
x: 10
|
42
|
+
y: yadjust
|
43
|
+
style:
|
44
|
+
classes: "ui-tooltip-share ui-tooltip-shadow"
|
45
|
+
tip:
|
46
|
+
corner: "top left"
|
47
|
+
mimic: "center"
|
48
|
+
border: 1
|
49
|
+
width: 22
|
50
|
+
height: 11
|
51
|
+
offset: 10
|
52
|
+
show:
|
53
|
+
delay: 500
|
54
|
+
hide:
|
55
|
+
event: "unfocus"
|
56
|
+
)
|
57
|
+
)
|
58
|
+
)
|
59
|
+
)(jQuery)
|
@@ -0,0 +1,110 @@
|
|
1
|
+
###
|
2
|
+
#
|
3
|
+
# This file is part of the cowtech-js-rails gem. Copyright (C) 2012 and above Shogun <shogun_panda@me.com>.
|
4
|
+
# Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.
|
5
|
+
#
|
6
|
+
###
|
7
|
+
|
8
|
+
if !String::trim?
|
9
|
+
String::trim = (->
|
10
|
+
@replace /(^\s+)|(\s+$)/g, ""
|
11
|
+
)
|
12
|
+
|
13
|
+
Date.labels =
|
14
|
+
months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]
|
15
|
+
monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
|
16
|
+
days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
|
17
|
+
daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]
|
18
|
+
daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]
|
19
|
+
Date.localized_labels = Date.labels
|
20
|
+
|
21
|
+
String::toDateTime = (->
|
22
|
+
rv = new Date()
|
23
|
+
mo = @match(/([a-z]{3}) ([a-z]{3}) (\d{2}) (\d{2}):(\d{2}):(\d{2}) (\+[0-9]{4}) ([0-9]{4})$/i)
|
24
|
+
rv.setUTCFullYear(parseInt(mo[8]), Date.labels.shortMonths.indexOf(mo[2]), parseInt(mo[3]))
|
25
|
+
rv.setUTCHours(parseInt(mo[4]), parseInt(mo[5]), parseInt(mo[6]))
|
26
|
+
rv
|
27
|
+
)
|
28
|
+
|
29
|
+
Date::toShortString = (->
|
30
|
+
days = @getDate()
|
31
|
+
hours = @getHours()
|
32
|
+
minutes = @getMinutes()
|
33
|
+
day = "0#{days}" if days < 10
|
34
|
+
hours = "0#{hours}" if hours < 10
|
35
|
+
minutes = "0#{minutes}" if minutes < 10
|
36
|
+
"{day} {Date.localized_labels.months[@getMonth()]} {@getFullYear()}, {hours}:{minutes}"
|
37
|
+
)
|
38
|
+
|
39
|
+
(($) ->
|
40
|
+
$.cowtech = $.cowtech || {}
|
41
|
+
$.cowtech.data = {}
|
42
|
+
|
43
|
+
$.cowtech.utils =
|
44
|
+
initialize: ((obj, def) ->
|
45
|
+
if $.cowtech.utils.is_blank(obj) then def else obj
|
46
|
+
)
|
47
|
+
|
48
|
+
module_active: ((module) ->
|
49
|
+
eval("!$.cowtech.utils.is_null($.fn.cowtech_" + module + ") || !$.cowtech.utils.is_null($.cowtech." + module + ");")
|
50
|
+
)
|
51
|
+
|
52
|
+
is_null: ((obj) ->
|
53
|
+
!obj? || $.cowtech.utils.is_of_type(obj, "undefined")
|
54
|
+
)
|
55
|
+
|
56
|
+
is_blank: ((obj) ->
|
57
|
+
$.cowtech.utils.is_null(obj) || obj.toString().match(/^\s*$/)?
|
58
|
+
)
|
59
|
+
|
60
|
+
is_of_type: ((obj, type) ->
|
61
|
+
typeof(obj) == type
|
62
|
+
)
|
63
|
+
|
64
|
+
is_object: ((obj) ->
|
65
|
+
$.cowtech.utils.is_of_type(obj, "object")
|
66
|
+
)
|
67
|
+
|
68
|
+
length: ((obj) ->
|
69
|
+
rv = 0
|
70
|
+
(rv++) for i of obj
|
71
|
+
rv
|
72
|
+
)
|
73
|
+
|
74
|
+
format_currency: ((number, currency, precision) ->
|
75
|
+
precision = $.cowtech.utils.initialize(precision, $.cowtech.numeric.precision)
|
76
|
+
rv = number.toFixed(precision).toString().replace(".", ",")
|
77
|
+
rv += " #{currency}" if !$.cowtech.utils.is_blank(currency)
|
78
|
+
rv
|
79
|
+
)
|
80
|
+
|
81
|
+
parse_float: ((number, precision) ->
|
82
|
+
rv = $.cowtech.utils.round_number(parseFloat(number.replace(",", ".")), precision)
|
83
|
+
if isNaN(rv) then 0 else rv
|
84
|
+
)
|
85
|
+
|
86
|
+
round_number: ((number, precision) ->
|
87
|
+
prec = Math.pow(10, $.cowtech.utils.initialize(precision, $.cowtech.numeric.precision))
|
88
|
+
Math.round(parseFloat(number) * prec) / prec
|
89
|
+
)
|
90
|
+
|
91
|
+
detect_browser: ((not_add) ->
|
92
|
+
rv = null
|
93
|
+
|
94
|
+
$.ajax(
|
95
|
+
async: false
|
96
|
+
url: "http://#{document.domain.replace(/^forum\./, "")}/detect-browser"
|
97
|
+
dataType: "jsonp"
|
98
|
+
success: (data, textStatus, xhr) ->
|
99
|
+
if data.success
|
100
|
+
rv = data.data
|
101
|
+
$("body").addClass rv.classes if !not_add == true
|
102
|
+
)
|
103
|
+
|
104
|
+
rv
|
105
|
+
)
|
106
|
+
|
107
|
+
is_mobile: (->
|
108
|
+
!$.cowtech.utils.is_null($.mobile)
|
109
|
+
)
|
110
|
+
)(jQuery)
|
@@ -0,0 +1,155 @@
|
|
1
|
+
###
|
2
|
+
#
|
3
|
+
# This file is part of the cowtech-js-rails gem. Copyright (C) 2012 and above Shogun <shogun_panda@me.com>.
|
4
|
+
# Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.
|
5
|
+
#
|
6
|
+
###
|
7
|
+
|
8
|
+
(($) ->
|
9
|
+
$.cowtech = $.cowtech || {}
|
10
|
+
$.cowtech.wysiwyg =
|
11
|
+
cols: 5
|
12
|
+
colors: ["FCE94F", "EDD400", "C4A000", "FCAF3E", "F57900", "CE5C00", "E9B96E", "C17D11", "8F5902", "8AE234", "73D216", "4E9A06", "729FCF", "3465A4", "204A87", "AD7FA8", "75507B", "5C3566", "EF2929", "CC0000", "A40000", "FFFFFF", "D3D7CF", "BABDB6", "888A85", "555753", "000000"]
|
13
|
+
emotes: ["angel", "angry", "aww", "aww_2", "blushing", "childish", "confused", "creepy", "crying", "cthulhu", "cute", "cute_winking", "devil", "gah", "gah_2", "gasping", "greedy", "grinning", "grinning_winking", "happy", "happy_2", "happy_3", "heart", "huh", "huh_2", "kissing", "laughing", "lips_sealed", "madness", "malicious", "sick", "smiling", "speechless", "spiteful", "stupid", "sunglasses", "terrified", "thumb_down", "thumb_up", "tired", "tongue_out", "tongue_out_laughing", "tongue_out_left", "tongue_out_up", "tongue_out_up_left", "tongue_out_winking", "uncertain", "uncertain_2", "unhappy", "winking"]
|
14
|
+
labels:
|
15
|
+
preview: "Preview"
|
16
|
+
remove: "Remove"
|
17
|
+
url: "URL (Address)"
|
18
|
+
alt: "Alternative text"
|
19
|
+
title: "Title"
|
20
|
+
placeholder: "Placeholder"
|
21
|
+
bold: "Bold"
|
22
|
+
italic: "Italic"
|
23
|
+
underline: "Underline"
|
24
|
+
strike_through: "Strikethrough"
|
25
|
+
image: "Image"
|
26
|
+
link: "Link"
|
27
|
+
size: "Size"
|
28
|
+
color: "Color"
|
29
|
+
emote: "Emoticon"
|
30
|
+
header_1: "Header 1"
|
31
|
+
header_2: "Header 2"
|
32
|
+
header_3: "Header 3"
|
33
|
+
header_4: "Header 4"
|
34
|
+
header_5: "Header 5"
|
35
|
+
header_6: "Header 6"
|
36
|
+
center: "Center"
|
37
|
+
list: "List"
|
38
|
+
ordered_list: "Ordered list"
|
39
|
+
quote: "Quote"
|
40
|
+
loader:
|
41
|
+
message: "Loading ..."
|
42
|
+
image: "/images/loading.gif"
|
43
|
+
|
44
|
+
autoload: (->
|
45
|
+
$("[data-wysiwyg-role=editor]").each(->
|
46
|
+
$(this).closest("tr").removeClass("mandatory")
|
47
|
+
$.cowtech.wysiwyg.setup $(this)
|
48
|
+
)
|
49
|
+
)
|
50
|
+
|
51
|
+
show_preview: (->
|
52
|
+
$("[data-wysiwyg-role=preview]").removeClass("loading")
|
53
|
+
$("[data-wysiwyg-role=body]").slideDown("fast")
|
54
|
+
$("[data-wysiwyg-role=loader]").remove()
|
55
|
+
)
|
56
|
+
|
57
|
+
preview: ((obj) ->
|
58
|
+
area = $(obj.textarea)
|
59
|
+
content = area.val()
|
60
|
+
|
61
|
+
$("[data-wysiwyg-role=remove]").click()
|
62
|
+
$("[data-wysiwyg-role=preview]").remove()
|
63
|
+
|
64
|
+
prev = $("<div data-wysiwyg-role=\"preview\" class=\"loading\"><h2>#{$.cowtech.wysiwyg.labels.preview}<a href=\"#\" data-wysiwyg-role=\"remove\" class=\"btn btn-secondary\">#{$.cowtech.wysiwyg.labels.remove}</a></h2></div>")
|
65
|
+
area.after(prev)
|
66
|
+
$("<img data-wysiwyg-role=\"loader\" src=\"#{$.cowtech.wysiwyg.image}\" alt=\"#{$.cowtech.wysiwyg.loader.message}\"/>").appendTo(prev)
|
67
|
+
$("[data-wysiwyg-role=remove]").on("click", ->
|
68
|
+
$("[data-wysiwyg-role=preview]").remove()
|
69
|
+
false
|
70
|
+
)
|
71
|
+
|
72
|
+
body = $("<iframe src=\"#\" data-wysiwyg-role=\"body\" id=\"wysiwyg-preview-body\"></iframe>").appendTo(prev).hide()
|
73
|
+
form = $("<form action=\"#{$.cowtech.data.urls.preview}\" method=\"POST\" target=\"wysiwyg-preview-body\"><input type=\"hidden\" name=\"content\" value=\"\"/></form>")
|
74
|
+
form.find("input").val(content)
|
75
|
+
form.submit()
|
76
|
+
)
|
77
|
+
|
78
|
+
get_cell_info: ((cell, count, cols) ->
|
79
|
+
cols = $.cowtech.utils.initialize(cols, $.cowtech.wysiwyg.cols)
|
80
|
+
row_index = Math.floor(cell / cols) + 1
|
81
|
+
col_index = Math.floor(cell % cols) + 1
|
82
|
+
|
83
|
+
rv = ["row-#{row_index}", "col-#{col_index}"]
|
84
|
+
rv.push("row-first") if row_index == 1
|
85
|
+
rv.push("row-last") if row_index == Math.ceil(count / cols)
|
86
|
+
rv.push("col-first") if col_index == 1
|
87
|
+
rv.push("col-last") if col_index == cols
|
88
|
+
rv
|
89
|
+
)
|
90
|
+
|
91
|
+
setup: ((el) ->
|
92
|
+
wysiwyg_fonts = []
|
93
|
+
i = 10
|
94
|
+
|
95
|
+
# Add sizes
|
96
|
+
while i < 40
|
97
|
+
wysiwyg_fonts.push(name: "#{i}pt", openWith: "$", closeWith: "${: style=\"font-size: #{i}pt\"}", className: "font-cell wysiwyg-icon dimension")
|
98
|
+
i += 2
|
99
|
+
|
100
|
+
# Add colors
|
101
|
+
wysiwyg_colors_buttons = []
|
102
|
+
count = $.cowtech.wysiwyg.colors.length
|
103
|
+
i = 0
|
104
|
+
while i < count
|
105
|
+
color = $.cowtech.wysiwyg.colors[i]
|
106
|
+
wysiwyg_colors_buttons.push(openWith: "$", closeWith: "${: style=\"color: ##{color}\"}", className: "#{$.cowtech.wysiwyg.get_cell_info(i, count).join(" ")} color-cell color-#{color}")
|
107
|
+
i++
|
108
|
+
|
109
|
+
# Add buttons
|
110
|
+
wysiwyg_emotes_buttons = []
|
111
|
+
count = $.cowtech.wysiwyg.emotes.length
|
112
|
+
i = 0
|
113
|
+
while i < count
|
114
|
+
emote = $.cowtech.wysiwyg.emotes[i]
|
115
|
+
wysiwyg_emotes_buttons.push(replaceWith: "@#{emote}@", className: "#{$.cowtech.wysiwyg.get_cell_info(i, count).join(" ")} emotes-cell color-#{emote}")
|
116
|
+
i++
|
117
|
+
|
118
|
+
# Settings
|
119
|
+
wysiwyg_settings =
|
120
|
+
resizeHandle: false
|
121
|
+
previewParserPath: ""
|
122
|
+
onShiftEnter:
|
123
|
+
keepDefault: false
|
124
|
+
openWith: "\n\n"
|
125
|
+
markupSet: [
|
126
|
+
{name: $.cowtech.wysiwyg.labels.bold, key: "B", openWith: "**", closeWith: "**", className: "wysiwyg-icon bold"},
|
127
|
+
{name: $.cowtech.wysiwyg.labels.italic, key: "I", openWith: "_", closeWith: "_", className: "wysiwyg-icon italic"},
|
128
|
+
{name: $.cowtech.wysiwyg.labels.underline, key: "U", openWith: "=", closeWith: "=", className: "wysiwyg-icon u"},
|
129
|
+
{name: $.cowtech.wysiwyg.labels.strike_through, key: "S", openWith: "~", closeWith: "~", className: "wysiwyg-icon s"},
|
130
|
+
{separator: "---------------"},
|
131
|
+
{name: $.cowtech.wysiwyg.labels.image, key: "P", replaceWith: "![[![#{$.cowtech.wysiwyg.labels.alt}]!]]([![#{$.cowtech.wysiwyg.labels.url}: !: http: //]!] \"[![#{$.cowtech.wysiwyg.labels.title}]!]\")", className: "wysiwyg-icon img"},
|
132
|
+
{name: $.cowtech.wysiwyg.labels.link, key: "L", openWith: "[", closeWith: "]([![#{$.cowtech.wysiwyg.labels.url}: !: http: //]!] \"[![#{$.cowtech.wysiwyg.labels.title}]!]\")", placeHolder: $.cowtech.wysiwyg.labels.placeholder, className: "wysiwyg-icon link"},
|
133
|
+
{separator: "---------------"},
|
134
|
+
{name: $.cowtech.wysiwyg.labels.size, key: "D", className: "wysiwyg-icon dimension", dropMenu: wysiwyg_fonts},
|
135
|
+
{name: $.cowtech.wysiwyg.labels.color, key: "T", className: "wysiwyg-icon color", dropMenu: wysiwyg_colors_buttons},
|
136
|
+
{name: $.cowtech.wysiwyg.labels.emote, key: "E", className: "wysiwyg-icon emotes", dropMenu: wysiwyg_emotes_buttons},
|
137
|
+
{separator: "---------------"},
|
138
|
+
{name: $.cowtech.wysiwyg.labels.header_1, key: "1", openWith: "# ", className: "wysiwyg-icon h1"},
|
139
|
+
{name: $.cowtech.wysiwyg.labels.header_2, key: "2", openWith: "## ", className: "wysiwyg-icon h2"},
|
140
|
+
{name: $.cowtech.wysiwyg.labels.header_3, key: "3", openWith: "### ", className: "wysiwyg-icon h3"},
|
141
|
+
{name: $.cowtech.wysiwyg.labels.header_4, key: "4", openWith: "#### ", className: "wysiwyg-icon h4"},
|
142
|
+
{name: $.cowtech.wysiwyg.labels.header_5, key: "5", openWith: "##### ", className: "wysiwyg-icon h5"},
|
143
|
+
{name: $.cowtech.wysiwyg.labels.header_6, key: "6", openWith: "###### ", className: "wysiwyg-icon h6"},
|
144
|
+
{separator: "---------------"},
|
145
|
+
{name: $.cowtech.wysiwyg.labels.center, key: "H", openWith: "%%%\n", closeWith: "\n%%%", className: "wysiwyg-icon center"},
|
146
|
+
{name: $.cowtech.wysiwyg.labels.list, openWith: "- ", className: "wysiwyg-icon ul"},
|
147
|
+
{name: $.cowtech.wysiwyg.labels.ordered_list, openWith: ((markItUp) -> "#{markItUp.line}. "), className: "wysiwyg-icon ol"},
|
148
|
+
{name: $.cowtech.wysiwyg.labels.quote, openWith: "> ", className: "wysiwyg-icon quote"},
|
149
|
+
{separator: "---------------"},
|
150
|
+
{name: $.cowtech.wysiwyg.labels.preview, beforeInsert: $.cowtech.wysiwyg.preview, className: "wysiwyg-icon preview"}
|
151
|
+
]
|
152
|
+
|
153
|
+
el.markItUp(wysiwyg_settings)
|
154
|
+
)
|
155
|
+
)(jQuery)
|