From e8c2bdabe57dc7fe9dafdba960755ceb535f70eb Mon Sep 17 00:00:00 2001 From: John Bintz Date: Mon, 2 Nov 2009 22:32:31 -0500 Subject: [PATCH] switch media uploader to prototype --- addons/Core/Core.inc | 2 +- js/MediaUpload.js | 30 +++++++++++++++++------------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/addons/Core/Core.inc b/addons/Core/Core.inc index 9509c34..f35ce3b 100644 --- a/addons/Core/Core.inc +++ b/addons/Core/Core.inc @@ -208,7 +208,7 @@ class ComicPressAddonCore extends ComicPressAddon { } if (strpos($pagenow, "media-upload") === 0) { - wp_enqueue_script('cp-media', get_stylesheet_directory_uri() . '/js/MediaUpload.js', array('jquery')); + wp_enqueue_script('cp-media', get_stylesheet_directory_uri() . '/js/MediaUpload.js', array('prototype')); } } diff --git a/js/MediaUpload.js b/js/MediaUpload.js index 1e2d1ce..127f3df 100644 --- a/js/MediaUpload.js +++ b/js/MediaUpload.js @@ -1,19 +1,23 @@ -jQuery(function() { - jQuery('.media-item').each(function() { - var item = this; - jQuery('.savesend', item).each(function() { - jQuery(this).prepend(jQuery('').addClass('button')); +Event.observe(window, 'load', function() { + $$('.media-item').each(function(item) { + item.select('.savesend').each(function(savesend) { + var button = new Element('input', { type: 'submit', name: 'save', value: 'Save changes' }).addClassName('button'); + savesend.insert({top: button}); + }); + + var show_insert = function(t) { + var b = item.select('input[name*=send]').pop(); + if (b) { b[(t.value == 'none') ? 'show' : 'hide'](); } + } + + item.select('input[name*=comic_image_type]').each(function(radio) { + radio.observe('click', function(e) { show_insert(radio); }); }); - var show_insert = function(t) { - jQuery('input[name*=send]', item)[(t.value == 'none') ? 'show' : 'hide'](); - }; - - jQuery('input[name*=comic_image_type]', item).bind('click', function() { show_insert(this); }); - var type = jQuery('input[name*=comic_image_type][checked]', item).get(0); + var type = item.select('input[name*=comic_image_type][checked]').pop(); if (type) { - jQuery('.filename.new', item).append(jQuery('').text(' (' + jQuery.trim(jQuery(type).parent().text()) + ')')); + item.select('.filename.new').pop().insert({bottom: new Element('strong').update(type.parentNode.innerHTML.stripTags())}); show_insert(type); } }); -}); \ No newline at end of file +});