fondant-rails 0.2.2
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/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +17 -0
- data/Rakefile +10 -0
- data/fondant-rails.gemspec +21 -0
- data/lib/fondant-rails.rb +8 -0
- data/lib/fondant-rails/source_file.rb +33 -0
- data/lib/fondant-rails/version.rb +5 -0
- data/vendor/assets/javascripts/fondant.coffee +441 -0
- data/vendor/assets/stylesheets/fondant.scss +37 -0
- metadata +88 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Oven Bits
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# Fondant for Rails' Asset Pipeline
|
2
|
+
|
3
|
+
Use [fondant](https://github.com/ovenbits-ingredients/fondant) in Rails' asset pipeline.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'fondant-rails', '~> 0.2.1', github: 'ovenbits-ingredients/fondant-rails'
|
10
|
+
|
11
|
+
## Contributing
|
12
|
+
|
13
|
+
1. Fork it
|
14
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
15
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
16
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
17
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'fondant-rails/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "fondant-rails"
|
8
|
+
gem.version = Fondant::Rails::VERSION
|
9
|
+
gem.authors = ["Phillip Ridlen"]
|
10
|
+
gem.email = ["phillip@ovenbits.com"]
|
11
|
+
gem.description = %q{Use fondant in Rails' asset pipeline}
|
12
|
+
gem.summary = gem.description
|
13
|
+
gem.homepage = "https://github.com/ovenbits-ingredients/fondant-rails"
|
14
|
+
|
15
|
+
gem.add_dependency 'railties', '>= 3.1'
|
16
|
+
|
17
|
+
gem.add_development_dependency 'thor', '~> 0.17'
|
18
|
+
|
19
|
+
gem.files = `git ls-files`.split($/)
|
20
|
+
gem.require_paths = ["lib"]
|
21
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'thor'
|
2
|
+
|
3
|
+
class SourceFile < Thor
|
4
|
+
include Thor::Actions
|
5
|
+
|
6
|
+
desc 'fetch source files', 'fetch source files from GitHub'
|
7
|
+
def fetch
|
8
|
+
self.destination_root = 'vendor/assets'
|
9
|
+
remote = 'https://raw.github.com/ovenbits-ingredients/fondant/master'
|
10
|
+
get "#{remote}/fondant.coffee", 'javascripts/fondant.coffee'
|
11
|
+
get "#{remote}/fondant.scss", 'stylesheets/fondant.scss'
|
12
|
+
get "#{remote}/VERSION", 'VERSION'
|
13
|
+
|
14
|
+
bump_version
|
15
|
+
end
|
16
|
+
|
17
|
+
desc 'clean up source files', 'remove source files no longer needed'
|
18
|
+
def cleanup
|
19
|
+
self.destination_root = 'vendor/assets'
|
20
|
+
remove_file 'VERSION'
|
21
|
+
end
|
22
|
+
|
23
|
+
protected
|
24
|
+
|
25
|
+
def bump_version
|
26
|
+
inside destination_root do
|
27
|
+
version = File.read('VERSION').sub("\n", '')
|
28
|
+
gsub_file '../../lib/fondant-rails/version.rb', /VERSION\s=\s'(\d|\.)+'$/ do |match|
|
29
|
+
%Q{VERSION = '#{version}'}
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,441 @@
|
|
1
|
+
# ## Fondant v0.2.2
|
2
|
+
#
|
3
|
+
# The icing on the cake for user input. A simple jQuery HTML5 WYSIWYG editor
|
4
|
+
# using `contenteditable`.
|
5
|
+
#
|
6
|
+
#
|
7
|
+
# © 2013 [Phillip Ridlen][1] & [Oven Bits, LLC][2]
|
8
|
+
#
|
9
|
+
# [1]: http://phillipridlen.com
|
10
|
+
# [2]: http://ovenbits.com
|
11
|
+
|
12
|
+
# ## Requirements
|
13
|
+
#
|
14
|
+
# * jQuery (tested with 1.9.1)
|
15
|
+
# * A modern-ish browser (IE9+)
|
16
|
+
#
|
17
|
+
# ## Usage
|
18
|
+
#
|
19
|
+
# ### Instantiation
|
20
|
+
#
|
21
|
+
# To launch the editor on a specific element:
|
22
|
+
#
|
23
|
+
# $('div.editable').fondant();
|
24
|
+
#
|
25
|
+
# You can also use it on a `<textarea>` and it will convert it to a `<div>`
|
26
|
+
# while the editor is on:
|
27
|
+
#
|
28
|
+
# $('form#content textarea.wysiwyg').fondant();
|
29
|
+
#
|
30
|
+
# ### Options Reference
|
31
|
+
#
|
32
|
+
# * `prefix` - prefix for all css classes and ids added to elements
|
33
|
+
# generated by Fondant (default: `fondant`)
|
34
|
+
#
|
35
|
+
# * `toolbar` - If set to `true`, Fondant will generate a toolbar. Otherwise you are responsible for
|
36
|
+
# hooking up all your toolbar buttons to call `$('selector').fondant('bold')`, etc.
|
37
|
+
# (default: `true`)
|
38
|
+
#
|
39
|
+
|
40
|
+
|
41
|
+
$ = jQuery
|
42
|
+
|
43
|
+
$ ->
|
44
|
+
|
45
|
+
# ## Class Definition
|
46
|
+
#
|
47
|
+
# Defines the `Fondant` class that will be instantiated when `$.fn.fondant`
|
48
|
+
# is called.
|
49
|
+
#
|
50
|
+
class Fondant
|
51
|
+
|
52
|
+
# ## Methods
|
53
|
+
|
54
|
+
constructor: (element, options) ->
|
55
|
+
@init('fondant', element, options)
|
56
|
+
|
57
|
+
# ### init( type, element, options )
|
58
|
+
#
|
59
|
+
# Initializes the Fondant editor.
|
60
|
+
#
|
61
|
+
# Parameters:
|
62
|
+
#
|
63
|
+
# * `type` - should always be 'fondant' (see constructor above)
|
64
|
+
# * `element` - enable the Fondant editor for this element
|
65
|
+
# * `options` - overrides for the default options
|
66
|
+
# * `toolbar` -
|
67
|
+
#
|
68
|
+
init: (type, element, options) ->
|
69
|
+
@id = new Date().getTime()
|
70
|
+
@type = type
|
71
|
+
@$element = $(element)
|
72
|
+
@options = @getOptions(options)
|
73
|
+
|
74
|
+
@templates.fondant = this
|
75
|
+
|
76
|
+
if ( @$element.prop('tagName').toLowerCase() == 'textarea' )
|
77
|
+
@textarea = @$element
|
78
|
+
@replaceTextareaWithDiv()
|
79
|
+
|
80
|
+
@makeEditable()
|
81
|
+
@insertToolbar()
|
82
|
+
@bindToolbar()
|
83
|
+
|
84
|
+
# ### destroy( save = true )
|
85
|
+
#
|
86
|
+
# Destroy the Fondant editor and any elements created by it
|
87
|
+
#
|
88
|
+
destroy: ( keep_changes = true ) ->
|
89
|
+
@unbindToolbar()
|
90
|
+
@removeToolbar()
|
91
|
+
@makeUneditable()
|
92
|
+
@replaceDivWithTextarea(keep_changes) if @textarea
|
93
|
+
@$element.removeData(@type)
|
94
|
+
|
95
|
+
# ### focus()
|
96
|
+
#
|
97
|
+
# Focus the editor
|
98
|
+
#
|
99
|
+
focus: ->
|
100
|
+
@$element.find('.' + @templates.editorContentClass()).focus()
|
101
|
+
|
102
|
+
# ### insertToolbar()
|
103
|
+
#
|
104
|
+
# Add the formatting toolbar and bind the editor functions
|
105
|
+
#
|
106
|
+
insertToolbar: ->
|
107
|
+
@$element.prepend(@templates.toolbar()) if @options.toolbar
|
108
|
+
|
109
|
+
# ### bindToolbar()
|
110
|
+
#
|
111
|
+
# Bind toolbar click events to their respective actions
|
112
|
+
#
|
113
|
+
bindToolbar: ->
|
114
|
+
for action in @actions
|
115
|
+
$("[data-action='#{ @type }-#{ action }']").on 'click.fondant',
|
116
|
+
$.proxy(@[action], this)
|
117
|
+
|
118
|
+
# ### unbindToolbar()
|
119
|
+
#
|
120
|
+
# Remove all toolbar events. If the default Fondant toolbar was generated,
|
121
|
+
# this is not needed since the DOM elements will be destroyed
|
122
|
+
#
|
123
|
+
unbindToolbar: ->
|
124
|
+
$("[data-action^='#{ @type }-']").off('.fondant') unless @options.toolbar
|
125
|
+
|
126
|
+
# ### removeToolbar()
|
127
|
+
#
|
128
|
+
# Remove the formatting toolbar and unbind the editor functions.
|
129
|
+
#
|
130
|
+
removeToolbar: ->
|
131
|
+
@$element.find(@options.prefix + "-toolbar").remove() if @options.toolbar
|
132
|
+
|
133
|
+
# ### getElement()
|
134
|
+
#
|
135
|
+
# Get the actual underlying DOM (not jQuery) element
|
136
|
+
#
|
137
|
+
getElement: ->
|
138
|
+
@$element.get(0)
|
139
|
+
|
140
|
+
# ### getOptions( options )
|
141
|
+
#
|
142
|
+
# Get the options from the defaults, options passed to the constructor, and
|
143
|
+
# the options set in the element's `data` attribute
|
144
|
+
#
|
145
|
+
getOptions: ( options ) ->
|
146
|
+
options = $.extend {},
|
147
|
+
$.fn[@type].defaults, # default options
|
148
|
+
options, # options passed in to the constructor
|
149
|
+
@$element.data() # options set in the element's `data` attribute
|
150
|
+
|
151
|
+
# ### value( html )
|
152
|
+
#
|
153
|
+
# Get the html from the editor, or if a value is passed in, set the html for the editor
|
154
|
+
#
|
155
|
+
value: ( html ) ->
|
156
|
+
if html == undefined
|
157
|
+
@$element.find('.' + @templates.editorContentClass()).html()
|
158
|
+
else
|
159
|
+
@$element.find('.' + @templates.editorContentClass()).html(html).html()
|
160
|
+
|
161
|
+
# ### makeEditable()
|
162
|
+
#
|
163
|
+
# Make the element editable. If it is a `<textarea>`, convert it to a
|
164
|
+
# `<div>` first.
|
165
|
+
#
|
166
|
+
makeEditable: ->
|
167
|
+
@$element.attr 'contenteditable', 'true'
|
168
|
+
@$element = @wrapEditorContent()
|
169
|
+
|
170
|
+
# ### makeUneditable()
|
171
|
+
#
|
172
|
+
# Turns off `contenteditable` for this editor. If this editor was
|
173
|
+
# originally a `<textarea>`, convert it back.
|
174
|
+
#
|
175
|
+
makeUneditable: ->
|
176
|
+
@$element = @unwrapEditorContent()
|
177
|
+
@$element.attr 'contenteditable', 'false'
|
178
|
+
|
179
|
+
# ### replaceElement( $old, fresh )
|
180
|
+
#
|
181
|
+
# Replace a jQuery element with a new one from a string. Returns the new
|
182
|
+
# jQuery element.
|
183
|
+
#
|
184
|
+
replaceElement: ( $old, fresh ) ->
|
185
|
+
$old.replaceWith($fresh = $(fresh))
|
186
|
+
$fresh
|
187
|
+
|
188
|
+
# ### replaceDivWithTextarea( keep_changes = true )
|
189
|
+
#
|
190
|
+
# Swaps out the the `<div>` for a `<textarea>`, returning the original's
|
191
|
+
# attributes. If keep_changes is false, put the original content back in.
|
192
|
+
# Essentially reverses the process of `replaceTextareaWithDiv`.
|
193
|
+
#
|
194
|
+
replaceDivWithTextarea: ( keep_changes = true ) ->
|
195
|
+
html = @$element.html()
|
196
|
+
|
197
|
+
@$element = @replaceElement(@$element, @textarea)
|
198
|
+
@$element.data(@type, this)
|
199
|
+
@$element.val(html) if keep_changes
|
200
|
+
|
201
|
+
@$element
|
202
|
+
|
203
|
+
# ### replaceTextareaWithDiv()
|
204
|
+
#
|
205
|
+
# Swaps out the `<textarea>` with a `<div>` so we can use contenteditable.
|
206
|
+
# Saves the `<textarea>`'s value and attributes so it can be restored when
|
207
|
+
# the editor gets canceled/destroyed.
|
208
|
+
#
|
209
|
+
replaceTextareaWithDiv: ->
|
210
|
+
if @textarea
|
211
|
+
@$element = @replaceElement @$element, @templates.editorContent()
|
212
|
+
@$element.data @type, this
|
213
|
+
@$element.addClass(@textarea.attr('class'))
|
214
|
+
@$element.html @textarea.val()
|
215
|
+
|
216
|
+
@$element
|
217
|
+
|
218
|
+
# ### unwrapEditorContent()
|
219
|
+
#
|
220
|
+
# Undoes what happens in `wrapEditorContent()`.
|
221
|
+
#
|
222
|
+
unwrapEditorContent: ->
|
223
|
+
$wrap = @$element
|
224
|
+
@$element = @replaceElement @$element, @$element.find(".#{ @templates.editorContentClass() }")
|
225
|
+
@$element.data @type, this
|
226
|
+
@$element.addClass @templates.editorClass()
|
227
|
+
$wrap.remove()
|
228
|
+
|
229
|
+
if @textarea
|
230
|
+
@$element.addClass(@textarea.attr 'class')
|
231
|
+
|
232
|
+
@$element
|
233
|
+
|
234
|
+
# ### wrapEditorContent()
|
235
|
+
#
|
236
|
+
# Wraps the current `@$element` with another, outer `<div>` so we can insert the toolbar
|
237
|
+
#
|
238
|
+
wrapEditorContent: ->
|
239
|
+
$original_element = @$element
|
240
|
+
@$element = @$element.wrap(@templates.editor()).parent()
|
241
|
+
@$element.data @type, this
|
242
|
+
@$element.addClass($original_element.attr 'class').removeClass(@templates.editorContentClass())
|
243
|
+
|
244
|
+
$original_element.removeClass @templates.editorClass()
|
245
|
+
$original_element.removeData @type
|
246
|
+
|
247
|
+
if @textarea
|
248
|
+
$original_element.removeClass(@textarea.attr 'class')
|
249
|
+
|
250
|
+
@$element
|
251
|
+
|
252
|
+
# ### applyFormat( command, value )
|
253
|
+
#
|
254
|
+
# Applies a rich text editor command to selection or block. Available
|
255
|
+
# commands are [listed on the MDN website][1].
|
256
|
+
#
|
257
|
+
# [1]: https://developer.mozilla.org/en-US/docs/Rich-Text_Editing_in_Mozilla
|
258
|
+
#
|
259
|
+
applyFormat: ( command, value ) ->
|
260
|
+
document.execCommand command, false, value
|
261
|
+
|
262
|
+
# ## Formatting Functions
|
263
|
+
#
|
264
|
+
# This is where the magic happens.
|
265
|
+
|
266
|
+
# ### actions
|
267
|
+
#
|
268
|
+
# Array of all the possible formatting actions to take
|
269
|
+
#
|
270
|
+
actions: [
|
271
|
+
'remove', 'custom', 'undo', 'redo',
|
272
|
+
'bold', 'italic',
|
273
|
+
'p', 'h1', 'h2', 'h3', 'h4', 'blockquote',
|
274
|
+
'ol', 'ul', 'indent', 'outdent',
|
275
|
+
'link', 'unlink'
|
276
|
+
]
|
277
|
+
|
278
|
+
# ### remove()
|
279
|
+
#
|
280
|
+
# Remove all formatting for selection
|
281
|
+
#
|
282
|
+
remove: -> @applyFormat 'removeFormat'
|
283
|
+
|
284
|
+
# ### custom( html )
|
285
|
+
#
|
286
|
+
# For hooking in custom actions.
|
287
|
+
#
|
288
|
+
custom: (html) ->
|
289
|
+
if navigator.appName == "Microsoft Internet Explorer"
|
290
|
+
console.log "Custom HTML not yet implemented"
|
291
|
+
else
|
292
|
+
@applyFormat 'insertHTML', html
|
293
|
+
|
294
|
+
# ### Text Styles
|
295
|
+
#
|
296
|
+
# * `bold()`
|
297
|
+
# * `italic()`
|
298
|
+
bold: -> @applyFormat 'bold'
|
299
|
+
italic: -> @applyFormat 'italic'
|
300
|
+
|
301
|
+
# ### Block Formats
|
302
|
+
#
|
303
|
+
# Wraps the selected element in a block element:
|
304
|
+
#
|
305
|
+
# * `p()`
|
306
|
+
# * `h1()`
|
307
|
+
# * `h2()`
|
308
|
+
# * `h3()`
|
309
|
+
# * `h4()`
|
310
|
+
# * `blockquote()`
|
311
|
+
#
|
312
|
+
p: -> @applyFormat 'formatBlock', '<p>'
|
313
|
+
h1: -> @applyFormat 'formatBlock', '<h1>'
|
314
|
+
h2: -> @applyFormat 'formatBlock', '<h2>'
|
315
|
+
h3: -> @applyFormat 'formatBlock', '<h3>'
|
316
|
+
h4: -> @applyFormat 'formatBlock', '<h4>'
|
317
|
+
blockquote: -> @applyFormat 'formatBlock', '<blockquote>'
|
318
|
+
|
319
|
+
# ### Lists and Indentation
|
320
|
+
#
|
321
|
+
# * `ol()`
|
322
|
+
# * `ul()`
|
323
|
+
# * `indent()`
|
324
|
+
# * `outdent()`
|
325
|
+
#
|
326
|
+
ol: -> @applyFormat 'insertOrderedList'
|
327
|
+
ul: -> @applyFormat 'insertUnorderedList'
|
328
|
+
indent: -> @applyFormat 'indent'
|
329
|
+
outdent: -> @applyFormat 'outdent'
|
330
|
+
|
331
|
+
# ### Links
|
332
|
+
#
|
333
|
+
# * `link( url )`
|
334
|
+
# * `unlink()`
|
335
|
+
link: (url) -> @applyFormat 'link', url
|
336
|
+
unlink: -> @applyFormat 'unlink'
|
337
|
+
|
338
|
+
# ## HTML Templates
|
339
|
+
#
|
340
|
+
# Templates for inserted html elements
|
341
|
+
templates:
|
342
|
+
|
343
|
+
editorClass: ->
|
344
|
+
"#{ @fondant.options.prefix }-editor"
|
345
|
+
editorContentClass: ->
|
346
|
+
"#{ @editorClass() }-content"
|
347
|
+
toolbarClass: ->
|
348
|
+
"#{ @fondant.options.prefix }-toolbar"
|
349
|
+
|
350
|
+
# ### templates.editor()
|
351
|
+
#
|
352
|
+
# Outer element to wrap the `contenteditable` region so we can insert the toolbar.
|
353
|
+
#
|
354
|
+
editor: ->
|
355
|
+
id = "#{ @fondant.options.prefix }-#{ @fondant.id }"
|
356
|
+
|
357
|
+
"""
|
358
|
+
<div class="#{ @editorClass() }" id="#{ id }">
|
359
|
+
</div>
|
360
|
+
"""
|
361
|
+
|
362
|
+
# ### templates.editorContent()
|
363
|
+
#
|
364
|
+
# If a `<textarea>` is being swapped out for a `<div>`, this is the
|
365
|
+
# function we'll use to generate the editor.
|
366
|
+
#
|
367
|
+
editorContent: ->
|
368
|
+
"""
|
369
|
+
<div class="#{ @editorClass()} #{ @editorContentClass() }">
|
370
|
+
</div>
|
371
|
+
"""
|
372
|
+
|
373
|
+
# ### templates.toolbar()
|
374
|
+
#
|
375
|
+
toolbar: ->
|
376
|
+
group = @toolbarClass() + '-button-group'
|
377
|
+
button = @toolbarClass() + '-button'
|
378
|
+
"""
|
379
|
+
<ul class="#{ @toolbarClass() }">
|
380
|
+
<li class="#{ group }-label">Text Styles</li>
|
381
|
+
<ul class="#{ group }">
|
382
|
+
<li class="#{ button } #{ button }-bold"><a href="#" data-action="#{ @fondant.type }-bold">B</a></li>
|
383
|
+
<li class="#{ button } #{ button }-italic"><a href="#" data-action="#{ @fondant.type }-italic">I</a></li>
|
384
|
+
</ul>
|
385
|
+
<li class="#{ group }-label">Block Styles</li>
|
386
|
+
<ul class="#{ group }">
|
387
|
+
<li class="#{ button } #{ button }-p"><a href="#" data-action="#{ @fondant.type }-p">P</a></li>
|
388
|
+
<li class="#{ button } #{ button }-h1"><a href="#" data-action="#{ @fondant.type }-h1">H1</a></li>
|
389
|
+
<li class="#{ button } #{ button }-h2"><a href="#" data-action="#{ @fondant.type }-h2">H2</a></li>
|
390
|
+
<li class="#{ button } #{ button }-h3"><a href="#" data-action="#{ @fondant.type }-h3">H3</a></li>
|
391
|
+
<li class="#{ button } #{ button }-h4"><a href="#" data-action="#{ @fondant.type }-h4">H4</a></li>
|
392
|
+
<li class="#{ button } #{ button }-blockquote"><a href="#" data-action="#{ @fondant.type }-blockquote">Quote</a></li>
|
393
|
+
</ul>
|
394
|
+
<li class="#{ group }-label">Lists</li>
|
395
|
+
<ul class="#{ group }">
|
396
|
+
<li class="#{ button } #{ button }-ol"><a href="#" data-action="#{ @fondant.type }-ol">Numbers</a></li>
|
397
|
+
<li class="#{ button } #{ button }-ul"><a href="#" data-action="#{ @fondant.type }-ul">Bullets</a></li>
|
398
|
+
<li class="#{ button } #{ button }-indent"><a href="#" data-action="#{ @fondant.type }-indent">Increase Indent</a></li>
|
399
|
+
<li class="#{ button } #{ button }-outdent"><a href="#" data-action="#{ @fondant.type }-outdent">Decrease Indent</a></li>
|
400
|
+
</ul>
|
401
|
+
</ul>
|
402
|
+
"""
|
403
|
+
|
404
|
+
|
405
|
+
# ## Plugin Setup
|
406
|
+
#
|
407
|
+
# ### jQuery function property
|
408
|
+
#
|
409
|
+
# Builds a fondant editor for each matched element.
|
410
|
+
#
|
411
|
+
$.fn.fondant = () ->
|
412
|
+
option = arguments[0]
|
413
|
+
args = Array.prototype.slice.call(arguments)[1..]
|
414
|
+
|
415
|
+
if (typeof option == 'string' && args.length < 1)
|
416
|
+
|
417
|
+
if option in ['getElement', 'value']
|
418
|
+
instance = $(this).data('fondant')
|
419
|
+
if instance
|
420
|
+
return instance[option].apply(instance, args)
|
421
|
+
|
422
|
+
@each ->
|
423
|
+
$this = $(this)
|
424
|
+
instance = $this.data('fondant')
|
425
|
+
options = typeof option == 'object' && option
|
426
|
+
|
427
|
+
if (!instance)
|
428
|
+
$this.data('fondant', (instance = new Fondant(this, options)))
|
429
|
+
|
430
|
+
if typeof option == 'string'
|
431
|
+
instance[option].apply(instance, args)
|
432
|
+
|
433
|
+
# ### Defaults
|
434
|
+
#
|
435
|
+
# Allows user to set their own defaults without having to pass in their
|
436
|
+
# overrides on every instantiation
|
437
|
+
#
|
438
|
+
$.fn.fondant.defaults =
|
439
|
+
prefix: 'fondant'
|
440
|
+
toolbar: true
|
441
|
+
|
@@ -0,0 +1,37 @@
|
|
1
|
+
// Fondant v0.2.2
|
2
|
+
// see http://github.com/ovenbits-ingredients/fondant for more information
|
3
|
+
//
|
4
|
+
.fondant-toolbar {
|
5
|
+
display: inline;
|
6
|
+
list-style: none;
|
7
|
+
margin: 0;
|
8
|
+
padding: 0;
|
9
|
+
|
10
|
+
li {
|
11
|
+
display: none;
|
12
|
+
}
|
13
|
+
|
14
|
+
ul {
|
15
|
+
display: inline;
|
16
|
+
margin: 0;
|
17
|
+
padding: 0;
|
18
|
+
|
19
|
+
li {
|
20
|
+
display: inline-block;
|
21
|
+
|
22
|
+
a {
|
23
|
+
background: #eee;
|
24
|
+
border: 1px solid #ddd;
|
25
|
+
border-radius: 0.3rem;
|
26
|
+
color: #777;
|
27
|
+
padding: 0.2rem 0.4rem;
|
28
|
+
&:hover {
|
29
|
+
background: #e0e0e0;
|
30
|
+
text-decoration: none;
|
31
|
+
}
|
32
|
+
}
|
33
|
+
|
34
|
+
}
|
35
|
+
}
|
36
|
+
}
|
37
|
+
|
metadata
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fondant-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.2
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Phillip Ridlen
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-02-12 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: railties
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '3.1'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '3.1'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: thor
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0.17'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0.17'
|
46
|
+
description: Use fondant in Rails' asset pipeline
|
47
|
+
email:
|
48
|
+
- phillip@ovenbits.com
|
49
|
+
executables: []
|
50
|
+
extensions: []
|
51
|
+
extra_rdoc_files: []
|
52
|
+
files:
|
53
|
+
- .gitignore
|
54
|
+
- Gemfile
|
55
|
+
- LICENSE.txt
|
56
|
+
- README.md
|
57
|
+
- Rakefile
|
58
|
+
- fondant-rails.gemspec
|
59
|
+
- lib/fondant-rails.rb
|
60
|
+
- lib/fondant-rails/source_file.rb
|
61
|
+
- lib/fondant-rails/version.rb
|
62
|
+
- vendor/assets/javascripts/fondant.coffee
|
63
|
+
- vendor/assets/stylesheets/fondant.scss
|
64
|
+
homepage: https://github.com/ovenbits-ingredients/fondant-rails
|
65
|
+
licenses: []
|
66
|
+
post_install_message:
|
67
|
+
rdoc_options: []
|
68
|
+
require_paths:
|
69
|
+
- lib
|
70
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
71
|
+
none: false
|
72
|
+
requirements:
|
73
|
+
- - ! '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
|
+
none: false
|
78
|
+
requirements:
|
79
|
+
- - ! '>='
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
requirements: []
|
83
|
+
rubyforge_project:
|
84
|
+
rubygems_version: 1.8.23
|
85
|
+
signing_key:
|
86
|
+
specification_version: 3
|
87
|
+
summary: Use fondant in Rails' asset pipeline
|
88
|
+
test_files: []
|