From 6eda4b28a64b983d1cf1ff44b879c3fca5b30f91 Mon Sep 17 00:00:00 2001 From: dougbradbury Date: Mon, 10 Mar 2014 19:29:01 -0500 Subject: restore tag autocomplete --- app/assets/javascripts/refinery/blog/backend.js | 115 --------------------- .../javascripts/refinery/blog/backend.js.erb | 115 +++++++++++++++++++++ .../ui-lightness/jquery-ui-1.8.13.custom.css.scss | 2 + 3 files changed, 117 insertions(+), 115 deletions(-) delete mode 100644 app/assets/javascripts/refinery/blog/backend.js create mode 100644 app/assets/javascripts/refinery/blog/backend.js.erb diff --git a/app/assets/javascripts/refinery/blog/backend.js b/app/assets/javascripts/refinery/blog/backend.js deleted file mode 100644 index 77529c5..0000000 --- a/app/assets/javascripts/refinery/blog/backend.js +++ /dev/null @@ -1,115 +0,0 @@ -$(document).ready(function(){ - $('nav#actions.multilist > ul:not(.search_list) li a[href$="' + window.location.pathname + '"]') - .parent().addClass('selected'); - if($('nav#actions.multilist > ul:not(.search_list) li.selected').length == 0) { - $('nav#actions.multilist > ul:not(.search_list) li a:nth(1)').parent().addClass('selected'); - } - - $('nav#actions.multilist > ul:not(.search_list) li > a').each(function(i,a){ - if ($(this).data('dialog-title') == null) { - $(this).bind('click', function(){ - $(this).css('background-image', "url('/images/refinery/icons/ajax-loader.gif') !important"); - }); - } - }); - - $('ul.collapsible_menu').each(function(i, ul) { - (first_li = $(this).children('li:first')).after(div=$("
")); - - $(" ").appendTo(first_li) - - if (($(this).children('li.selected')).length == 0) { - div.hide(); - first_li.addClass("closed"); - } - $(this).children('li:not(:first)').appendTo(div); - - first_li.find('> a, > span.arrow').click(function(e){ - $(this).parent().toggleClass("closed"); - $(this).parent().toggleClass("open"); - - $(this).parent().next('div').animate({ - opacity: 'toggle' - , height: 'toggle' - }, 250, $.proxy(function(){ - $(this).css('background-image', null); - }, $(this)) - ); - e.preventDefault(); - }); - }); - - $('.success_icon, .failure_icon').bind('click', function(e) { - $.get($(this).attr('href'), $.proxy(function(data){ - $(this).css('background-image', null) - .removeClass('failure_icon').removeClass('success_icon') - .addClass(data.enabled ? 'success_icon' : 'failure_icon'); - }, $(this))); - 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')); - } - - event.preventDefault(); - }); - }); - - - function split( val ) { - return val.split( /,\s*/ ); - } - function extractLast( term ) { - return split( term ).pop(); - } - - page_options.init(false, '', '') - - $('<%= 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; - } - }) -}); diff --git a/app/assets/javascripts/refinery/blog/backend.js.erb b/app/assets/javascripts/refinery/blog/backend.js.erb new file mode 100644 index 0000000..5add3db --- /dev/null +++ b/app/assets/javascripts/refinery/blog/backend.js.erb @@ -0,0 +1,115 @@ +$(document).ready(function(){ + $('nav#actions.multilist > ul:not(.search_list) li a[href$="' + window.location.pathname + '"]') + .parent().addClass('selected'); + if($('nav#actions.multilist > ul:not(.search_list) li.selected').length == 0) { + $('nav#actions.multilist > ul:not(.search_list) li a:nth(1)').parent().addClass('selected'); + } + + $('nav#actions.multilist > ul:not(.search_list) li > a').each(function(i,a){ + if ($(this).data('dialog-title') == null) { + $(this).bind('click', function(){ + $(this).css('background-image', "url('/images/refinery/icons/ajax-loader.gif') !important"); + }); + } + }); + + $('ul.collapsible_menu').each(function(i, ul) { + (first_li = $(this).children('li:first')).after(div=$("
")); + + $(" ").appendTo(first_li) + + if (($(this).children('li.selected')).length == 0) { + div.hide(); + first_li.addClass("closed"); + } + $(this).children('li:not(:first)').appendTo(div); + + first_li.find('> a, > span.arrow').click(function(e){ + $(this).parent().toggleClass("closed"); + $(this).parent().toggleClass("open"); + + $(this).parent().next('div').animate({ + opacity: 'toggle' + , height: 'toggle' + }, 250, $.proxy(function(){ + $(this).css('background-image', null); + }, $(this)) + ); + e.preventDefault(); + }); + }); + + $('.success_icon, .failure_icon').bind('click', function(e) { + $.get($(this).attr('href'), $.proxy(function(data){ + $(this).css('background-image', null) + .removeClass('failure_icon').removeClass('success_icon') + .addClass(data.enabled ? 'success_icon' : 'failure_icon'); + }, $(this))); + 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')); + } + + event.preventDefault(); + }); + }); + + + function split( val ) { + return val.split( /,\s*/ ); + } + function extractLast( term ) { + return split( term ).pop(); + } + + page_options.init(false, '', '') + + $('#post_tag_list').bind( "keydown", function( event ) { + if ( event.keyCode === $.ui.keyCode.TAB && $( this ).data( "autocomplete" ).menu.active ) { + event.preventDefault() + } + }).autocomplete({ + source: function( request, response ) { + $.getJSON( "<%= Refinery::Core::Engine.routes.url_helpers.tags_blog_admin_posts_path %>", { + 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; + } + }) +}); diff --git a/app/assets/stylesheets/refinery/blog/ui-lightness/jquery-ui-1.8.13.custom.css.scss b/app/assets/stylesheets/refinery/blog/ui-lightness/jquery-ui-1.8.13.custom.css.scss index f9a1401..04ae033 100755 --- a/app/assets/stylesheets/refinery/blog/ui-lightness/jquery-ui-1.8.13.custom.css.scss +++ b/app/assets/stylesheets/refinery/blog/ui-lightness/jquery-ui-1.8.13.custom.css.scss @@ -25,6 +25,8 @@ /* Interaction Cues ----------------------------------*/ .ui-state-disabled { cursor: default !important; } +#ui-active-menuitem { background-color:#62bef2 } +.ui-menu-item:hover { background-color:#62bef2 } /* Icons -- cgit v1.2.3