redcloth-rails 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ # See http://help.github.com/ignore-files/ for more about ignoring files.
2
+ #
3
+ # If you find yourself ignoring temporary files generated by your text editor
4
+ # or operating system, you probably want to add a global ignore instead:
5
+ # git config --global core.excludesfile ~/.gitignore_global
6
+
7
+ # Ignore bundler config
8
+ /.bundle
9
+
10
+ # Ignore all gem builds
11
+ *.gem
data/CHANGELOG.textile ADDED
@@ -0,0 +1,7 @@
1
+ h2. redcloth-rails 0.1.1
2
+
3
+ * [FIX] Fixed coffeescript conversion errors in textile_editor.js.coffee, firefox/chrome/... browsers are supported again.
4
+
5
+ h2. redcloth-rails 0.1.0
6
+
7
+ * Initial release.
@@ -22,7 +22,7 @@
22
22
  # - doesn't need to be in the body onload tag
23
23
  # - can supply your own, custom IDs for the editor to be drawn around
24
24
  #
25
- #todo:
25
+ # TODO:
26
26
  # - a clean way of providing image and link inserts
27
27
  # - get the selection to properly show in IE
28
28
  #
@@ -43,7 +43,6 @@ class TextileEditorButton
43
43
  @sve = sve # sve = simple vs. extended. add an 's' to make it show up in the simple toolbar
44
44
  @open = open # set to -1 if tag does not need to be closed
45
45
  @standard = true # this is a standard button
46
- # this.framework = 'prototype'; // the JS framework used
47
46
 
48
47
  window.TextileEditorButton = TextileEditorButton
49
48
 
@@ -52,7 +51,7 @@ class TextileEditorButtonSeparator
52
51
 
53
52
  constructor: (sve) ->
54
53
  @separator = true
55
- @sve = sve
54
+ @sve = sve
56
55
 
57
56
  window.TextileEditorButtonSeparator = TextileEditorButtonSeparator
58
57
 
@@ -68,20 +67,19 @@ class TextileEditor
68
67
  TextileEditor.buttons || new Array()
69
68
 
70
69
  constructor: (canvas, view) ->
71
-
72
- toolbar = document.createElement("div")
73
- toolbar.id = "textile-toolbar-" + canvas
70
+ toolbar = document.createElement("div")
71
+ toolbar.id = "textile-toolbar-" + canvas
74
72
  toolbar.className = "textile-toolbar"
73
+
75
74
  @canvas = document.getElementById(canvas)
76
- @canvas.parentNode.insertBefore toolbar, @canvas
75
+ @canvas.parentNode.insertBefore(toolbar, @canvas)
77
76
  @openTags = new Array()
78
77
 
79
78
  # Create the local Button array by assigning theButtons array to edButtons
80
- edButtons = new Array()
81
- edButtons = TextileEditor.getButtons()
79
+ edButtons = TextileEditor.getButtons()
82
80
  standardButtons = new Array()
83
- i = 0
84
81
 
82
+ i = 0
85
83
  while i < edButtons.length
86
84
  thisButton = @prepareButton(edButtons[i])
87
85
  if view is "s"
@@ -95,72 +93,73 @@ class TextileEditor
95
93
  toolbar.appendChild thisButton
96
94
  standardButtons.push thisButton
97
95
  i++
98
- # end for
96
+
99
97
  te = this
100
98
  buttons = toolbar.getElementsByTagName("button")
101
- i = 0
102
99
 
100
+ i = 0
103
101
  while i < buttons.length
104
-
105
- #$A(toolbar.getElementsByTagName('button')).each(function(button) {
106
102
  unless buttons[i].onclick
107
103
  buttons[i].onclick = ->
108
104
  te.insertTag this
109
- false
110
- # end if
111
- buttons[i].tagStart = buttons[i].getAttribute("tagStart")
112
- buttons[i].tagEnd = buttons[i].getAttribute("tagEnd")
113
- buttons[i].open = buttons[i].getAttribute("open")
105
+ return false
106
+
107
+ buttons[i].tagStart = buttons[i].getAttribute("tagStart")
108
+ buttons[i].tagEnd = buttons[i].getAttribute("tagEnd")
109
+ buttons[i].open = buttons[i].getAttribute("open")
114
110
  buttons[i].textile_editor = te
115
- buttons[i].canvas = te.canvas
111
+ buttons[i].canvas = te.canvas
116
112
  i++
117
113
 
118
114
  # draw individual buttons (edShowButton)
119
115
  prepareButton: (button) ->
120
116
  if button.separator
121
- theButton = document.createElement("span")
117
+ theButton = document.createElement("span")
122
118
  theButton.className = "ed_sep"
123
119
  return theButton
120
+
124
121
  if button.standard
125
- theButton = document.createElement("button")
122
+ theButton = document.createElement("button")
126
123
  theButton.id = button.id
127
- theButton.setAttribute "class", "standard"
128
- theButton.setAttribute "tagStart", button.tagStart
129
- theButton.setAttribute "tagEnd", button.tagEnd
130
- theButton.setAttribute "open", button.open
131
- img = document.createElement("img")
124
+ theButton.setAttribute("class", "standard")
125
+ theButton.setAttribute("tagStart", button.tagStart)
126
+ theButton.setAttribute("tagEnd", button.tagEnd)
127
+ theButton.setAttribute("open", button.open)
128
+
129
+ img = document.createElement("img")
132
130
  img.src = button.display
133
- theButton.appendChild img
131
+ theButton.appendChild(img)
134
132
  else
135
133
  return button
136
- # end if !custom
134
+
137
135
  theButton.accessKey = button.access
138
- theButton.title = button.title
139
- theButton
136
+ theButton.title = button.title
137
+ return theButton
140
138
 
141
139
  # if clicked, no selected text, tag not open highlight button
142
140
  # (edAddTag)
143
141
  addTag: (button) ->
144
142
  unless button.tagEnd is ""
145
143
  @openTags[@openTags.length] = button
146
-
147
- #var el = document.getElementById(button.id);
148
- #el.className = 'selected';
149
144
  button.className = "selected"
150
145
 
146
+ return button
147
+
151
148
  # if clicked, no selected text, tag open lowlight button
152
149
  # (edRemoveTag)
153
150
  removeTag: (button) ->
154
151
  i = 0
155
152
  while i < @openTags.length
156
153
  if @openTags[i] is button
157
- @openTags.splice button, 1
154
+ @openTags.splice(button, 1)
158
155
 
159
156
  #var el = document.getElementById(button.id);
160
157
  #el.className = 'unselected';
161
158
  button.className = "unselected"
162
159
  i++
163
160
 
161
+ return undefined
162
+
164
163
  # see if there are open tags. for the remove tag bit...
165
164
  # (edCheckOpenTags)
166
165
  checkOpenTags: (button) ->
@@ -169,16 +168,12 @@ class TextileEditor
169
168
  while i < @openTags.length
170
169
  tag++ if @openTags[i] is button
171
170
  i++
172
- if tag > 0
173
- true # tag found
174
- else
175
- false # tag not found
171
+
172
+ return (tag > 0) # tag found / not found
176
173
 
177
174
  # insert the tag. this is the bulk of the code.
178
175
  # (edInsertTag)
179
176
  insertTag: (button, tagStart, tagEnd) ->
180
-
181
- #console.log(button);
182
177
  myField = button.canvas
183
178
  myField.focus()
184
179
  if tagStart
@@ -204,8 +199,7 @@ class TextileEditor
204
199
  newlineReplaceRegexClean = /\r\n\s\n/g
205
200
  newlineReplaceRegexDirty = "\\r\\n\\s\\n"
206
201
  newlineReplaceClean = "\r\n\n"
207
- else if myField.selectionStart or myField.selectionStart is "0" # MOZ/FF/NS/S support
208
-
202
+ else if myField.selectionStart or myField.selectionStart == 0 or myField.selectionStart == '0' # MOZ/FF/NS/S support
209
203
  # figure out cursor and selection positions
210
204
  startPos = myField.selectionStart
211
205
  endPos = myField.selectionEnd
@@ -299,19 +293,20 @@ class TextileEditor
299
293
 
300
294
  # now lets look and see if the user is trying to muck with a block or block modifier
301
295
  else if button.tagStart.match(/^(h1|h2|h3|h4|h5|h6|bq|p|\>|\<\>|\<|\=|\(|\))/g)
302
- insertTag = ""
303
- insertModifier = ""
304
- tagPartBlock = ""
305
- tagPartModifier = ""
296
+ insertTag = ""
297
+ insertModifier = ""
298
+ tagPartBlock = ""
299
+ tagPartModifier = ""
306
300
  tagPartModifierOrig = "" # ugly hack but it's late
307
- drawSwitch = ""
308
- captureIndentStart = false
309
- captureListStart = false
310
- periodAddition = "\\. "
301
+ drawSwitch = ""
302
+ captureIndentStart = false
303
+ captureListStart = false
304
+ periodAddition = "\\. "
311
305
  periodAdditionClean = ". "
312
- listItemsAddition = 0
313
- re_list_items = new RegExp("(\\*+|\\#+)", "g") # need this regex later on when checking indentation of lists
314
- re_block_modifier = new RegExp("^(h1|h2|h3|h4|h5|h6|bq|p| [\\*]{1,} | [\\#]{1,} |)(\\>|\\<\\>|\\<|\\=|[\\(]{1,}|[\\)]{1,6}|)", "g")
306
+ listItemsAddition = 0
307
+ re_list_items = new RegExp("(\\*+|\\#+)", "g") # need this regex later on when checking indentation of lists
308
+ re_block_modifier = new RegExp("^(h1|h2|h3|h4|h5|h6|bq|p| [\\*]{1,} | [\\#]{1,} |)(\\>|\\<\\>|\\<|\\=|[\\(]{1,}|[\\)]{1,6}|)", "g")
309
+
315
310
  if tagPartMatches = re_block_modifier.exec(selectedText)
316
311
  tagPartBlock = tagPartMatches[1]
317
312
  tagPartModifier = tagPartMatches[2]
@@ -503,19 +498,18 @@ class TextileEditor
503
498
 
504
499
  # set the appropriate DOM value with the final text
505
500
  if FF is true
506
- myField.value = finalText
501
+ myField.value = finalText
507
502
  myField.scrollTop = scrollTop
508
503
  else
509
504
  sel.text = finalText
510
505
 
511
- # build up the selection capture, doesn't work in IE
512
506
  if textSelected
507
+ # build up the selection capture, doesn't work in IE
513
508
  myField.selectionStart = startPos + newlineStartPos
514
509
  myField.selectionEnd = endPos + posDiffPos - posDiffNeg - newlineEndPos
515
510
 
516
- #alert('s: ' + myField.selectionStart + ' e: ' + myField.selectionEnd + ' sp: ' + startPos + ' ep: ' + endPos + ' pdp: ' + posDiffPos + ' pdn: ' + posDiffNeg)
517
511
  else
518
512
  myField.selectionStart = cursorPos
519
- myField.selectionEnd = cursorPos
513
+ myField.selectionEnd = cursorPos
520
514
 
521
515
  window.TextileEditor = TextileEditor
@@ -1,5 +1,5 @@
1
1
  module RedCloth
2
2
  module Rails
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redcloth-rails
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 0
10
- version: 0.1.0
9
+ - 1
10
+ version: 0.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - emjot
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2013-03-04 00:00:00 +01:00
18
+ date: 2013-03-08 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -60,6 +60,8 @@ extensions: []
60
60
  extra_rdoc_files: []
61
61
 
62
62
  files:
63
+ - .gitignore
64
+ - CHANGELOG.textile
63
65
  - Gemfile
64
66
  - LICENSE
65
67
  - README.textile