Skip to content

Commit

Permalink
Moved to nicedit (nicedit.com) for HTML inputs and editors. Dropped a…
Browse files Browse the repository at this point in the history
…ll TinyMCE stuff
  • Loading branch information
tslocke committed May 19, 2008
1 parent 2822e33 commit 2d2d8d6
Show file tree
Hide file tree
Showing 7 changed files with 139 additions and 39 deletions.
12 changes: 7 additions & 5 deletions hobo/generators/hobo_rapid/hobo_rapid_generator.rb
Expand Up @@ -10,11 +10,13 @@ def manifest
end

record do |m|
m.file "hobo-rapid.js", "public/javascripts/hobo-rapid.js"
m.file "lowpro.js", "public/javascripts/lowpro.js"
m.file "IE7.js", "public/javascripts/IE7.js"
m.file "reset.css", "public/stylesheets/reset.css"
m.file "hobo-rapid.css", "public/stylesheets/hobo-rapid.css"
m.file "hobo-rapid.js", "public/javascripts/hobo-rapid.js"
m.file "lowpro.js", "public/javascripts/lowpro.js"
m.file "IE7.js", "public/javascripts/IE7.js"
m.file "nicEdit.js", "public/javascripts/nicEdit.js"
m.file "nicEditorIcons.gif", "public/images/nicEditorIcons.gif"
m.file "reset.css", "public/stylesheets/reset.css"
m.file "hobo-rapid.css", "public/stylesheets/hobo-rapid.css"
create_all(m, "themes/clean/public", "public/hobothemes/clean")
create_all(m, "themes/clean/views", "app/views/taglibs/themes/clean")
end
Expand Down
53 changes: 36 additions & 17 deletions hobo/generators/hobo_rapid/templates/hobo-rapid.js
Expand Up @@ -210,6 +210,21 @@ var Hobo = {
return new Ajax.InPlaceEditor(el, Hobo.putUrl(el), opts)
},

nicEditorOptions: { buttonList : ['bold','italic',
'left','center','right',
'ul',
'fontFormat',
'indent','outdent',
'link','unlink',
'image', 'removeLink']},

makeNicEditor: function(element) {
if (!Hobo.nicEditorOptions.iconsPath) { Hobo.nicEditorOptions.iconsPath = urlBase + '/images/nicEditorIcons.gif' }
var nic = new nicEditor(Hobo.nicEditorOptions)
nic.panelInstance(element.id, {hasPanel : true})
return nic.instanceById(element)
},

applyEvents: function(root) {
root = $(root)
function select(p) {
Expand All @@ -231,25 +246,22 @@ var Hobo = {
})

select(".in-place-html-textarea-bhv").each(function (el) {
var options = {rows: 2, handleLineBreaks: false}
if (typeof(tinyMCE) != "undefined") options["submitOnBlur"] = false
var nicEditPresent = typeof(nicEditor) != "undefined"
var options = { rows: 2, handleLineBreaks: false, okButton: true, cancelLink: true, okText: "Save" }
if (nicEditPresent) options["submitOnBlur"] = false
var ipe = Hobo._makeInPlaceEditor(el, options)
if (typeof(tinyMCE) != "undefined") {
if (nicEditPresent) {
ipe.afterEnterEditMode = function() {
var id = this._form.id = Hobo.uid()

// 'orrible 'ack
// What is the correct way to individually configure a tinyMCE instace?
var old = tinyMCE.settings.theme_advanced_buttons1
tinyMCE.settings.theme_advanced_buttons1 += ", separator, save"
tinyMCE.addMCEControl(this._controls.editor, id);
tinyMCE.settings.theme_advanced_buttons1 = old

this._form.onsubmit = function() {
tinyMCE.removeMCEControl(ipe.form.id)
setTimeout(ipe.onSubmit.bind(ipe), 10)
return false
}
var editor = this._controls.editor
var id = editor.id = Hobo.uid()
var nicInstance = Hobo.makeNicEditor(editor)
var panel = this._form.down(".nicEdit-panel")
panel.appendChild(this._controls.cancel)
panel.appendChild(this._controls.ok)
bkLib.addEvent(this._controls.ok,'click', function () {
nicInstance.saveContent()
setTimeout(function() {nicInstance.remove()}, 1)
})
}
}
})
Expand Down Expand Up @@ -573,6 +585,13 @@ SelectManyInput = Behavior.create({
})

Event.addBehavior({

'textarea.html' : function(e) {
if (typeof(nicEditors) != "undefined") {
Hobo.makeNicEditor(this)
}
},

'div.select-many.input' : SelectManyInput(),

'.association-count:click' : function(e) {
Expand Down

0 comments on commit 2d2d8d6

Please sign in to comment.