From a8b5bce609089af8795768230c7dd3a9b87cd5e0 Mon Sep 17 00:00:00 2001 From: Philip Arndt Date: Sat, 14 Sep 2013 10:00:42 +1200 Subject: Supported Rails 4 and Refinery 3.0.0.dev --- app/assets/javascripts/refinery/blog/backend.js | 73 +++++-------------------- 1 file changed, 14 insertions(+), 59 deletions(-) (limited to 'app/assets/javascripts/refinery/blog/backend.js') diff --git a/app/assets/javascripts/refinery/blog/backend.js b/app/assets/javascripts/refinery/blog/backend.js index 77529c5..d4869c1 100644 --- a/app/assets/javascripts/refinery/blog/backend.js +++ b/app/assets/javascripts/refinery/blog/backend.js @@ -48,68 +48,23 @@ $(document).ready(function(){ e.preventDefault(); }); - - $(function() { - $('#page-tabs').tabs(); - $('#copy_body_link').click(function(event) { - // Find the WYMEditor that maps to the custom_teaser field - var teaserTextArea = $('#post_custom_teaser')[0]; - var teaserEditor = null; - $.each(WYMeditor.INSTANCES, function(index, editor) { - if (editor._element[0] == teaserTextArea) { - teaserEditor = editor; - } - }); - - if (teaserEditor) { - teaserEditor.html($('#post_body').attr('value')); + $('#page-tabs').tabs(); + $('#copy_body_link').click(function(event) { + // Find the WYMEditor that maps to the custom_teaser field + var teaserTextArea = $('#post_custom_teaser')[0]; + var teaserEditor = null; + $.each(WYMeditor.INSTANCES, function(index, editor) { + if (editor._element[0] == teaserTextArea) { + teaserEditor = editor; } - - event.preventDefault(); }); - }); - - function split( val ) { - return val.split( /,\s*/ ); - } - function extractLast( term ) { - return split( term ).pop(); - } + if (teaserEditor) { + teaserEditor.html($('#post_body').attr('value')); + } - page_options.init(false, '', '') + event.preventDefault(); + }); - $('<%= dom_id %>').bind( "keydown", function( event ) { - if ( event.keyCode === $.ui.keyCode.TAB && $( this ).data( "autocomplete" ).menu.active ) { - event.preventDefault() - } - }).autocomplete({ - source: function( request, response ) { - $.getJSON( "<%= url %>", { - term: extractLast( request.term ) - }, response ); - }, - search: function() { - // custom minLength - var term = extractLast( this.value ); - if ( term.length < 2 ) { - return false; - } - }, - focus: function() { - // prevent value inserted on focus - return false; - }, - select: function( event, ui ) { - var terms = split( this.value ); - // remove the current input - terms.pop(); - // add the selected item - terms.push( ui.item.value ); - // add placeholder to get the comma-and-space at the end - terms.push( "" ); - this.value = terms.join( ", " ); - return false; - } - }) + page_options.init(false, '', ''); }); -- cgit v1.2.3