comparison dnd_test/dnd_test.module @ 12:a5b2b9fa2a1a

Cross browser compatibility changes -- winnowing the scope of possible configurations.
author David Eads <eads@chicagotech.org>
date Fri, 27 Feb 2009 11:50:59 -0600
parents 5d2ae5b8eae2
children ef7ad7b5baa4
comparison
equal deleted inserted replaced
11:99ba5941779c 12:a5b2b9fa2a1a
24 * Implementation of hook_form_alter(). 24 * Implementation of hook_form_alter().
25 * 25 *
26 * This demonstrates how to attach Drag and Drop to a given textarea. 26 * This demonstrates how to attach Drag and Drop to a given textarea.
27 */ 27 */
28 function dnd_test_form_alter(&$form, &$form_state) { 28 function dnd_test_form_alter(&$form, &$form_state) {
29
30 //global $_SERVER;
31 //dpm($_SERVER);
32
29 if ($form['#id'] == 'node-form' && $form['type']['#value'] == 'page') { 33 if ($form['#id'] == 'node-form' && $form['type']['#value'] == 'page') {
30 drupal_add_css(drupal_get_path('module', 'dnd_test') .'/dnd_test.css'); 34 drupal_add_css(drupal_get_path('module', 'dnd_test') .'/dnd_test.css');
31 $form['body_field']['body']['#dnd-enabled'] = TRUE; 35 $form['body_field']['body']['#dnd-enabled'] = TRUE;
32 $form['body_field']['body']['#dnd-settings'] = array( 36 $form['body_field']['body']['#dnd-settings'] = array(
33 'drop_selector' => '#edit-body-dnd-library .drop', 37 'drop_selector' => '#edit-body-dnd-library .drop',
92 * for multiple versions (i.e. different sizes) of a single item 96 * for multiple versions (i.e. different sizes) of a single item
93 */ 97 */
94 function dnd_editor_items($i) { 98 function dnd_editor_items($i) {
95 $item = array(); 99 $item = array();
96 foreach(array(t('S'), t('M'), t('L')) as $size) { 100 foreach(array(t('S'), t('M'), t('L')) as $size) {
97 $item['item-'. $i .'-'. $size] = theme('dnd_editor_item', $i, $size); 101 $item[$i .'-'. $size] = theme('dnd_editor_item', $i, $size);
98 } 102 }
99 return $item; 103 return $item;
100 } 104 }
101 105
102 /** 106 /**
103 * Completely contrived edit item theme function 107 * Completely contrived edit item theme function
104 */ 108 */
105 function template_preprocess_dnd_library_item(&$variables) { 109 function template_preprocess_dnd_library_item(&$variables) {
110 global $_SERVER;
111
106 $i = $variables['i']; 112 $i = $variables['i'];
107 113
108 if ($i % 3 == 0) { 114 if ($i % 3 == 0) {
109 $img = 3; 115 $img = 3;
110 } 116 }
113 } 119 }
114 else { 120 else {
115 $img = 1; 121 $img = 1;
116 } 122 }
117 123
118 $variables['image'] = theme('image', drupal_get_path('module', 'dnd_test') .'/img/item-'. $img .'-thumb.jpg'); 124 //$variables['image'] = theme('image', drupal_get_path('module', 'dnd_test') .'/img/item-'. $img .'-thumb.jpg');
125 $variables['image'] = '<img src="http://'. $_SERVER['SERVER_ADDR'] . base_path() . drupal_get_path('module', 'dnd_test') .'/img/item-'. $img .'-thumb.jpg?dnd_id='. $i .'-M" class="drop" />';
119 $variables['title'] = t('Lorem Ipsum @count', array('@count' => $i)); 126 $variables['title'] = t('Lorem Ipsum @count', array('@count' => $i));
120 $variables['date'] = 'Feb 18 2009'; 127 $variables['date'] = 'Feb 18 2009';
121 $variables['author'] = 'David Eads'; 128 $variables['author'] = 'David Eads';
122 foreach(array(t('S'), t('M'), t('L')) as $size) { 129 foreach(array(t('S'), t('M'), t('L')) as $size) {
123 $attributes = array( 130 $sizes[] = '<img src="http://'. $_SERVER['SERVER_ADDR'] . base_path() . drupal_get_path('module', 'dnd_test') .'/img/icon/'. $size .'.png?dnd_id='. $i .'-'. $size .'" class="drop" />';
124 'class' => 'drop size-'. $size,
125 'id' => 'item-'. $i .'-'. $size,
126 );
127 $sizes[] = theme('image', drupal_get_path('module', 'dnd_test') .'/img/icon/'. $size .'.png', $size, $size, $attributes);
128 } 131 }
129 $variables['sizes'] = '<ul><li>'. implode('</li><li>', $sizes) .'</li></ul>'; 132 $variables['sizes'] = '<ul><li>'. implode('</li><li>', $sizes) .'</li></ul>';
130 } 133 }
131 134
132 135