Created
April 2, 2012 17:06
-
-
Save Neener54/2285181 to your computer and use it in GitHub Desktop.
handlebars template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wysiwyg = { | |
wysihtml5 : function(){ | |
// Global array of editor instances, necessary for being able to do custom functions later | |
editors = new Array(); | |
$('textarea.wysihtml5').each(function(){ | |
var currTextArea = $(this); | |
var currId = currTextArea.attr('id'); | |
wysiwyg.toolbar(currTextArea); | |
editors[currId] = new wysihtml5.Editor(currId.toString(), { | |
name: 'wysihtml5_ed_'+currId, | |
// Whether the editor should look like the textarea (by adopting styles) | |
style: true, | |
// Whether urls, entered by the user should automatically become clickable-links | |
autoLink: true, | |
// Id of the toolbar element, pass falsey value if you don't want any toolbar logic | |
toolbar: "toolbar_"+currId, | |
// Object which includes parser rules (set this to examples/rules/spec.json or your own spec, otherwise only span tags are allowed!) | |
parserRules: wysihtml5ParserRules, | |
// Class name which should be set on the contentEditable element in the created sandbox iframe, can be styled via the 'stylesheets' option | |
composerClassName: "wysihtml5-editor", | |
// Array (or single string) of stylesheet urls to be loaded in the editor's iframe | |
stylesheets: ['/assets/wysihtml5.css'], | |
// Class name to add to the body when the wysihtml5 editor is supported | |
bodyClassName: "wysihtml5-supported", | |
// Whether the composer should allow the user to manually resize images, tables etc. | |
allowObjectResizing: true, | |
// Whether the rich text editor should be rendered on touch devices (wysihtml5 >= 0.3.0 comes with basic support for iOS 5) | |
supportTouchDevices: true | |
}); | |
console.log(editors[currId]); | |
}); | |
$('a.btnImageSelector').on('click', function(){ | |
console.log('btn clicked'); | |
var seltarget = $(this).data('origin'); | |
var seltype = $(this).data('type'); | |
newImageSelector.popup({target: seltarget, type: seltype}); | |
}); | |
}, | |
toolbar : function(el){ | |
var template = HandlebarsTemplates['shared/editor_toolbar']; | |
var id = {id : el.attr('id')}; | |
var html = template(id); | |
el.before(html); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment