Commit ea19cfb0 authored by aaronwinborn's avatar aaronwinborn

by aaron: Wrap js with (function($) {})(jQuery); for library compatibility.

by aaron: Add settings to each js behavior.
by aaron: Convert js behavior selection to once().
by aaron: Add attach methods to js behaviors.
by aaron: Attach css & js to form using #attached element.
by aaron: Convert class #attributes to arrays.
by aaron: Fix php notices for $registration['callbacks']['resource'].
by aaron: Update parameters to theme('image') call for d7.
by aaron: Update parameters to theme('item_list') calls for d7.
by aaron: Set static cache in media_get_fields() and fix notices for isset.
by aaron: In media_get_registered_modules() fix notices for isset.
by aaron: In media_active_fields_for_node_type() grab field info for d7.
by aaron: Use file_get_field_list() to get a listing of node type's filefields.
parent d8fba41d
// $Id$
September 2009
-----------
* Use file_get_field_list() to get a listing of node type's filefields (aaron).
* $type is an object (aaron).
* Move menu settings to media config (aaron).
* Begin to fix content type settings page (aaron).
CHANGELOG for Media module.
===========================
July 2009
---------
* Drupal 7 compatability (jmstacey)
by aaron: Wrap js with (function($) {})(jQuery); for library compatibility.
by aaron: Add settings to each js behavior.
by aaron: Convert js behavior selection to once().
by aaron: Add attach methods to js behaviors.
by aaron: Attach css & js to form using #attached element.
by aaron: Convert class #attributes to arrays.
by aaron: Fix php notices for $registration['callbacks']['resource'].
by aaron: Update parameters to theme('image') call for d7.
by aaron: Update parameters to theme('item_list') calls for d7.
by aaron: Set static cache in media_get_fields() and fix notices for isset.
by aaron: In media_get_registered_modules() fix notices for isset.
by aaron: In media_active_fields_for_node_type() grab field info for d7.
by aaron: Use file_get_field_list() to get a listing of node type's filefields.
by aaron: $type is an object.
by aaron: Move menu settings to media config.
by aaron: Begin to fix content type settings page.
by jmstacey: Drupal 7 compatability.
* Update .info files.
* Added necessary files to new registry.
* Removed 'file' keys from hook_menu().
* Global media settings page fixed.
* Code styling cleanup (jmstacey).
* Untested rough sync up with D6 branch (jmstacey).
by jmstacey: Code styling cleanup.
by jmstacey: Untested rough sync up with D6 branch.
......@@ -2,99 +2,109 @@
/**
* @file
* This file handles the JS for Media Module functions
* This file handles the JS for Media Module functions.
*/
/**
* This handles the display, activation and
* hiding of drawers on the media browser form.
* This handles the display, activation
* and hiding of drawers on the media browser form.
*/
Drupal.behaviors.mediaDrawers = function (context) {
(function ($) {
Drupal.behaviors.mediaDrawers = {
attach: function (context, settings) {
// hide all the drawer display items on page load
$('.media.browser .ui-tabs-panel .drawer.display:not(.mediaDrawers-processed)', context).addClass('mediaDrawers-processed').each(function() {
$(this).hide();
});
// activate all the drawer data display that needs to be show when
// the page is loaded
$('.media.browser .ui-tabs-panel .drawer.display.active:not(.mediaDrawers-processed)', context).addClass('mediaDrawers-processed').each(function() {
$(this).show();
});
// --------------------------------------
// click actions
// Hide all the drawer display items on page load.
$('.media.browser .ui-tabs-panel .drawer.display', context).once('mediaDrawersHide', function() {
$(this).hide();
});
// now we need to bind click functionality on drawers to display
$('.media.browser .drawers .item-list ul li:not(.mediaDrawers-processed), .drawers li a:not(.mediaDrawers-processed)', context).addClass('mediaDrawers-processed').bind('click', function () {
// get the href id that we want to display
var display_id = $(this).attr('href');
// this handles the LI click
if (display_id == undefined) {
var display_id = $(this).children('a').attr('href');
}
// we need to get the tab page that this drawer is in
var parent = $(this).parents('.ui-tabs-panel').attr('id');
// hide current active drawer display
$('#'+parent+' .drawer.display.active').removeClass('active').hide();
// set any drawers to not active
$('#'+parent+' .drawers li.active').removeClass('active');
// make this drawer active
$(this).addClass('active');
// make the requested drawer display active
$(display_id).addClass('active').show();
// Activate all the drawer data display that needs to be shown when
// the page is loaded.
$('.media.browser .ui-tabs-panel .drawer.display.active', context).once('mediaDrawersActivate', function() {
$(this).show();
});
};
// --------------------------------------
// Click actions.
// Now we need to bind click functionality on drawers to display.
$('.media.browser .drawers .item-list ul li, .drawers li a', context).once('mediaDrawersBind').bind('click', function () {
// Get the href id that we want to display.
var display_id = $(this).attr('href');
// This handles the LI click.
if (display_id == undefined) {
var display_id = $(this).children('a').attr('href');
}
// We need to get the tab page that this drawer is in.
var parent = $(this).parents('.ui-tabs-panel').attr('id');
// Hide current active drawer display.
$('#'+parent+' .drawer.display.active').removeClass('active').hide();
// Set any drawers to not active.
$('#'+parent+' .drawers li.active').removeClass('active');
// Make this drawer active.
$(this).addClass('active');
// Make the requested drawer display active.
$(display_id).addClass('active').show();
});
}
}
/**
* We need to hide any form elements that were replaced by the media browser
* form, activate the add button, and hide the browser.
*/
Drupal.behaviors.mediaBrowserHide = function (context) {
// Hide our file progress indicators.
$('.media-browser-file-progress:not(.mediaBrowserHide-processed)', context).addClass('mediaBrowserHide-processed').attr('style', 'display:none');
$('.media-browser-metadata-wrapper:not(.mediaBrowserHide-processed)', context).addClass('mediaBroswerHide-processed').hide();
$('.media-browser-drawer-select:not(.mediaBrowserHide-processed)', context).addClass('mediaBroswerHide-processed').attr('style', 'display:none');
$('.media-browser-metadata-submit:not(.mediaBrowserHide-processed)', context).addClass('mediaBroswerHide-processed').attr('style', 'display:none').each(function() {
$(this).click(function() {
$(this).hide().siblings('.media-browser-metadata-wrapper').slideUp();
Drupal.behaviors.mediaBrowserHide = {
attach: function (context, settings) {
// Hide our file progress indicators.
$('.media-browser-file-progress', context).once('mediaBrowserHide').attr('style', 'display:none');
$('.media-browser-metadata-wrapper', context).once('mediaBroswerHide').hide();
$('.media-browser-drawer-select', context).once('mediaBroswerHide').attr('style', 'display:none');
$('.media-browser-metadata-submit', context).once('mediaBroswerHide', function() {
$(this).attr('style', 'display:none').click(function() {
$(this).hide().siblings('.media-browser-metadata-wrapper').slideUp();
});
});
});
// Add behavior to our big red activation button.
$('.media.browser.activation:not(.mediaBrowserHide-processed)', context).addClass('mediaBrowserHide-processed').each(function () {
// Hide the browser associated with this button.
$(this).next('.media.browser').hide();
$(this).click(function () {
// When clicking, show the browser and hide this button.
$(this).next('.media.browser').slideDown('slow');
$(this).slideUp();
// Add behavior to our big red activation button.
$('.media.browser.activation', context).once('mediaBrowserHide', function () {
// Hide the browser associated with this button.
$(this).next('.media.browser').hide();
$(this).click(function () {
// When clicking, show the browser and hide this button.
$(this).next('.media.browser').slideDown('slow');
$(this).slideUp();
});
});
});
};
}
}
/**
* Generate a MD5 hash of the file being uploaded
* Generate a MD5 hash of the file being uploaded.
*/
Drupal.behaviors.mediaGenerateMD5 = function (context) {
// Get the value from the file field.
$('#edit-field-file-media-media-tabs-tab-Addfiles-media-upload-resource-Newfile-resource-form-media-upload-upload:not(.mediaGenerateMD5-processed)', context).addClass('mediaGenerateMD5-processed').change(function () {
// Add the MD5 hash from the file name to the upload URL.
Drupal.settings['ahah']['edit-attach']['url'] += '/'+$.md5($(this).val());
// @TODO: Now add the MD5 value to the meta data form.
alert(Drupal.settings['ahah']['edit-attach']['url']);
});
};
Drupal.behaviors.mediaGenerateMD5 = {
attach: function (context, settings) {
// Get the value from the file field.
$('#edit-field-file-media-media-tabs-tab-Addfiles-media-upload-resource-Newfile-resource-form-media-upload-upload', context).once('mediaGenerateMD5').change(function () {
// Add the MD5 hash from the file name to the upload URL.
Drupal.settings['ahah']['edit-attach']['url'] += '/'+$.md5($(this).val());
// @TODO: Now add the MD5 value to the meta data form.
alert(Drupal.settings['ahah']['edit-attach']['url']);
});
}
}
Drupal.behaviors.mediaAhahHideBrowser = function (context) {
$('.media-browser-submit:not(.mediaAhahHideBrowser-processed)', context).addClass('mediaAhahHideBrowser-processed').each(function() {
$(this).bind('click', function() {
$(this).hide().siblings('.ui-tabs-panel, ul').slideUp();
$(this).siblings('.media-browser-file-progress').show();
$(this).siblings('.media-browser-metadata-wrapper').show();
$(this).siblings('.media-browser-metadata-submit').show();
/**
* Hide the browser and bind click behavior.
*/
Drupal.behaviors.mediaAhahHideBrowser ={
attach: function (context, settings) {
$('.media-browser-submit', context).once('mediaAhahHideBrowser', function() {
$(this).bind('click', function() {
$(this).hide().siblings('.ui-tabs-panel, ul').slideUp();
$(this).siblings('.media-browser-file-progress').show();
$(this).siblings('.media-browser-metadata-wrapper').show();
$(this).siblings('.media-browser-metadata-submit').show();
});
});
});
};
}
}
})(jQuery);
\ No newline at end of file
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment