//= require th-page-editor $(function() { var $simplePageForm = $(".simple-page-form"); if(!$simplePageForm.length) return; (function() { var $tagsmanager = $simplePageForm.find("[data-simple-routes-list]"); $tagsmanager.tagsManager({ prefilled: $tagsmanager.val().split(/,/g), preventSubmitOnEnter: true, typeahead: false, hiddenTagListName: $tagsmanager.prop("name"), validator: function(pathname) { return !pathname.match(/(?:^\/|\s|\/$)/); } }).prop("name", "").val("").blur(function() { if($(this).val().length) { $(this).trigger(jQuery.Event("keypress", { which: 44 })); } }); })(); var $htmlContainer = $simplePageForm.find(".content-html-container"); $htmlContainer.pageeditor({ iframeStylePath: $("[data-iframe-style-path]").data("iframe-style-path") }); $simplePageForm.submit(function() { $htmlContainer.pageeditor("destroy"); $simplePageForm.find("#simple_content_management_simple_page_content_html").val($htmlContainer.html().replace(/^\s+|\s+$/g, "")); }); });