app/assets/javascripts/fullstack/ckeditor.js.coffee in fullstack-ckeditor-0.1.2 vs app/assets/javascripts/fullstack/ckeditor.js.coffee in fullstack-ckeditor-0.1.3

- old
+ new

@@ -1,66 +1,19 @@ +#= require jquery +#= require jquery_ujs + $(document).ready -> - if typeof CKEDITOR is "undefined" - + if typeof window.CKEDITOR is "undefined" window.CKEDITOR_BASEPATH = '/ckeditor/' $.getScript "/ckeditor/ckeditor.js", -> - - # Integrate Rails CSRF token into file upload dialogs (link, image, attachment and flash) - CKEDITOR.on "dialogDefinition", (ev) -> - - # Take the dialog name and its definition from the event data. - dialogName = ev.data.name - dialogDefinition = ev.data.definition - content = undefined - upload = undefined - if CKEDITOR.tools.indexOf(["link", "image", "attachment", "flash"], dialogName) > -1 - content = (dialogDefinition.getContents("Upload") or dialogDefinition.getContents("upload")) - upload = ((if not content? then null else content.get("upload"))) - if upload and not upload.filebrowser["params"]? - upload.filebrowser["params"] = config.filebrowserParams() - upload.action = config.addQueryString(upload.action, upload.filebrowser["params"]) - - $( 'textarea.markup, textarea.markup-ckeditor' ).each -> + textarea = $(@) id = textarea.attr('id') - + config = {} + console.log($.extend(config, CKEDITOR.config)) config.width = textarea.outerWidth() - config.filebrowserBrowseUrl = "/ckeditor/attachment_files" - config.filebrowserFlashBrowseUrl = "/ckeditor/attachment_files" - config.filebrowserFlashUploadUrl = "/ckeditor/attachment_files" - config.filebrowserImageBrowseLinkUrl = "/ckeditor/pictures" - config.filebrowserImageBrowseUrl = "/ckeditor/pictures" - config.filebrowserImageUploadUrl = "/ckeditor/pictures" - config.filebrowserUploadUrl = "/ckeditor/attachment_files" - - config.filebrowserParams = -> - csrf_token = undefined - csrf_param = undefined - meta = undefined - metas = document.getElementsByTagName("meta") - params = new Object() - i = 0 - - while i < metas.length - meta = metas[i] - switch meta.name - when "csrf-token" - csrf_token = meta.content - when "csrf-param" - csrf_param = meta.content - i++ - params[csrf_param] = csrf_token if csrf_param isnt `undefined` and csrf_token isnt `undefined` - params - - config.addQueryString = (url, params) -> - queryString = [] - unless params - return url - else - for i of params - queryString.push i + "=" + encodeURIComponent(params[i]) - url + ((if (url.indexOf("?") isnt -1) then "&" else "?")) + queryString.join("&") + config.filebrowserBrowseUrl = "/admin/ckeditor/pictures" CKEDITOR.replace( id , config ) \ No newline at end of file