fondant-rails 0.2.4 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# ## Fondant v0.
|
1
|
+
# ## Fondant v0.4.0
|
2
2
|
#
|
3
3
|
# The icing on the cake for user input. A simple jQuery HTML5 WYSIWYG editor
|
4
4
|
# using `contenteditable`.
|
@@ -112,8 +112,10 @@ $ ->
|
|
112
112
|
#
|
113
113
|
bindToolbar: ->
|
114
114
|
for action in @actions
|
115
|
-
$("[data-action='#{ @type }-#{ action }']")
|
116
|
-
|
115
|
+
$button = $("[data-action='#{ @type }-#{ action }']")
|
116
|
+
$button.on 'click.fondant', { action: action, editor: this }, (event) ->
|
117
|
+
event.preventDefault()
|
118
|
+
event.data.editor[event.data.action]()
|
117
119
|
|
118
120
|
# ### unbindToolbar()
|
119
121
|
#
|
@@ -148,6 +150,18 @@ $ ->
|
|
148
150
|
options, # options passed in to the constructor
|
149
151
|
@$element.data() # options set in the element's `data` attribute
|
150
152
|
|
153
|
+
# ### getSelection()
|
154
|
+
#
|
155
|
+
# Grab the currently selected HTML content
|
156
|
+
#
|
157
|
+
getSelection: ->
|
158
|
+
content = window
|
159
|
+
.getSelection()
|
160
|
+
.getRangeAt(0)
|
161
|
+
.cloneContents()
|
162
|
+
|
163
|
+
$('<span>').html(content).html()
|
164
|
+
|
151
165
|
# ### value( html )
|
152
166
|
#
|
153
167
|
# Get the html from the editor, or if a value is passed in, set the html for the editor
|
@@ -288,7 +302,8 @@ $ ->
|
|
288
302
|
#
|
289
303
|
custom: (html) ->
|
290
304
|
if navigator.appName == "Microsoft Internet Explorer"
|
291
|
-
|
305
|
+
range = document.selection.createRange()
|
306
|
+
range.pasteHTML(html)
|
292
307
|
else
|
293
308
|
@applyFormat 'insertHTML', html
|
294
309
|
|
@@ -415,7 +430,7 @@ $ ->
|
|
415
430
|
|
416
431
|
if (typeof option == 'string' && args.length < 1)
|
417
432
|
|
418
|
-
if option in ['getElement', 'value']
|
433
|
+
if option in ['getElement', 'getSelection', 'value']
|
419
434
|
instance = $(this).data('fondant')
|
420
435
|
if instance
|
421
436
|
return instance[option].apply(instance, args)
|