Changeset 13663
- Timestamp:
- 11/27/07 16:51:21 (1 year ago)
- Files:
-
- trunk/midcom/midcom.helper.datamanager2/locale/default.en.txt (modified) (1 diff)
- trunk/midcom/midcom.helper.datamanager2/locale/default.fi.txt (modified) (2 diffs)
- trunk/midcom/midcom.helper.datamanager2/static/jquery.widget_sortable.js (modified) (1 diff)
- trunk/midcom/midcom.helper.datamanager2/widget/select.php (modified) (2 diffs)
- trunk/midcom/midcom.helper.datamanager2/widget/sortable.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/midcom/midcom.helper.datamanager2/locale/default.en.txt
r5325 r13663 205 205 ---STRINGEND 206 206 207 ---STRING write the order, lower numbers are placed first 208 Write the order, lower numbers are placed first 209 ---STRINGEND 210 211 ---STRING drag and drop to sort 212 Drag and drop to sort 213 ---STRINGEND 214 trunk/midcom/midcom.helper.datamanager2/locale/default.fi.txt
r5325 r13663 92 92 ---STRINGEND 93 93 94 ---STRING rotate left 95 KierrÀ vasemmalle 96 ---STRINGEND 97 98 ---STRING rotate right 99 KierrÀ oikealle 100 ---STRINGEND 101 94 102 ---STRING type blobs: file size 95 103 Tiedoston koko 96 104 ---STRINGEND 97 105 106 ---STRING type image: actions 107 Kuvan toiminnot 108 ---STRINGEND 109 98 110 ---STRING type image: available sizes 99 111 Saatavilla olevat koot … … 192 204 ---STRINGEND 193 205 194 ---STRING rotate left 195 KierrÀ vasemmalle 196 ---STRINGEND 197 198 ---STRING rotate right 199 KierrÀ oikealle 200 ---STRINGEND 201 202 ---STRING type image: actions 203 Kuvan toiminnot 204 ---STRINGEND 205 206 ---STRING write the order, lower numbers are placed first 207 Kirjoita jÀrjestys, pienet numerot nÀytetÀÀn ensimmÀisenÀ 208 ---STRINGEND 209 210 ---STRING drag and drop to sort 211 JÀrjestele hiirellÀ raahaamalla 212 ---STRINGEND 213 trunk/midcom/midcom.helper.datamanager2/static/jquery.widget_sortable.js
r13591 r13663 1 1 jQuery.fn.create_sortable = function() 2 2 { 3 // Hide the inputs 4 $j(this).find('input[@type="text"]').css({display: 'none'}); 5 3 6 $j(this).each(function(i) 4 7 { 5 8 $j(this).sortable({ 6 containment: $j(this).attr('id') 9 containment: 'parent', 10 change: function(e, ui) 11 { 12 // Update all the text inputs to keep track on the changes 13 $j(this.parentNode).find('input[@type="text"]').each(function(i) 14 { 15 $j(this).attr('value', i + 1); 16 }); 17 } 7 18 }); 8 19 }); 9 20 } 21 22 $j(document).ready(function() 23 { 24 $j('body p.sortable-help').css({display: 'none !important'}); 25 $j('body p.sortable-help-jquery').css({display: 'block !important'}); 26 }); trunk/midcom/midcom.helper.datamanager2/widget/select.php
r13568 r13663 49 49 50 50 /** 51 * The select element in use. This need s pearate tracking due to the potential51 * The select element in use. This need separate tracking due to the potential 52 52 * group code. This makes tracking of empty return values much easier. It is 53 53 * populated during add_elements_to_form(). … … 255 255 256 256 } 257 258 257 } 259 260 258 ?> trunk/midcom/midcom.helper.datamanager2/widget/sortable.php
r13582 r13663 35 35 36 36 /** 37 * Select automatically every object. This is for using the widget only to sort, not to select what 38 * has been sorted. 39 * 40 * @access public 41 * @var boolean 42 */ 43 var $select_all = false; 44 45 /** 37 46 * The initialization event handler post-processes the maxlength setting. 38 47 * … … 91 100 function _create_select_element() 92 101 { 93 $this->_elements['s_header'] =& HTML_QuickForm::createElement('static', 's_header', '', "<ul id=\"{$this->name}_sortable\" class=\"sortable\">\n");94 95 102 $readonly = $this->_field['readonly']; 96 103 … … 117 124 } 118 125 126 // Show the help text 127 // jQuery help text, hide for now 128 $html = "<p style=\"display: none;\" class=\"sortable-help-jquery\">\n"; 129 $html .= $this->_l10n->get('drag and drop to sort') . '.'; 130 $html .= "</p>\n"; 131 132 // Non-jQuery help, show on default, but hide with jQuery 133 $html .= "<p class=\"sortable-help\">\n"; 134 $html .= $this->_l10n->get('write the order, lower numbers are placed first') . '.'; 135 $html .= "</p>\n"; 136 $html .= "<ul id=\"{$this->name}_sortable\" class=\"midcom_helper_datamanager2_widget_sortable\">\n"; 137 138 $this->_elements['s_header'] =& HTML_QuickForm::createElement('static', 's_header', '', $html); 139 140 $i = 1; 141 142 // Temporary array for the selection set 143 $temp = array(); 144 145 $all = $this->_type->list_all(); 146 147 foreach ($this->_type->selection as $key => $value) 148 { 149 if (isset($all[$value])) 150 { 151 $temp[$value] = $all[$value]; 152 } 153 else 154 { 155 $temp[$value] = $value; 156 } 157 } 158 159 foreach ($this->_type->list_all() as $key => $value) 160 { 161 if (array_key_exists($key, $temp)) 162 { 163 continue; 164 } 165 166 $temp[$key] = $value; 167 } 168 169 // Reset the form data 119 170 $html = ''; 120 $i = 1; 121 122 foreach ($this->_type->list_all() as $key => $value) 123 { 171 172 foreach ($temp as $key => $value) 173 { 174 if ( array_key_exists($key, $this->_type->selection) 175 || $this->select_all) 176 { 177 $checked = ' checked="checked"'; 178 } 179 else 180 { 181 $checked = ''; 182 } 183 124 184 $html .= " <li>\n"; 125 $html .= " <input type=\"{$input_type}\" name=\"{$this->name}{$name_suffix}\" value=\"{$key}\" />\n"; 126 $html .= " <input type=\"text\" name=\"{$this->name}_order[{$key}]\" value=\"{$i}\" />\n"; 127 $html .= " {$this->_translate($value)}\n"; 185 186 if ($this->select_all) 187 { 188 $html .= " <input type=\"{$input_type}\" name=\"{$this->name}{$name_suffix}\" id=\"midcom_helper_datamanager2_widget_sortable_{$this->name}_{$i}\" value=\"{$key}\" checked=\"checked\" style=\"display: none !important;\" />\n"; 189 } 190 else 191 { 192 $html .= " <label for=\"midcom_helper_datamanager2_widget_sortable_{$this->name}_{$i}\">\n"; 193 $html .= " <input type=\"{$input_type}\" name=\"{$this->name}{$name_suffix}\" id=\"midcom_helper_datamanager2_widget_sortable_{$this->name}_{$i}\" value=\"{$key}\"{$checked} />\n"; 194 } 195 196 $html .= " <input type=\"text\" name=\"{$this->name}_order[{$key}]\" value=\"{$i}\" />\n"; 197 $html .= " {$this->_translate($value)}\n"; 198 199 if (!$this->select_all) 200 { 201 $html .= " </label>\n"; 202 } 128 203 $html .= " </li>\n"; 129 204 $i++; … … 153 228 function sync_type_with_widget($results) 154 229 { 155 echo "<pre>\n"; 156 echo "Make me work\n"; 157 print_r($_POST); 158 echo "</pre>\n"; 159 die(); 230 $temp = array(); 231 232 asort($results["{$this->name}_order"]); 233 $name = $this->name; 234 235 foreach ($results["{$this->name}_order"] as $key => $value) 236 { 237 if ( !isset($results[$this->name]) 238 || !in_array($key, $results[$this->name])) 239 { 240 continue; 241 } 242 243 $temp[] = $key; 244 } 245 246 $this->_type->selection = $temp; 160 247 } 161 248 }
