Quellcode durchsuchen

Check TODOs in the code.

AntonLV vor 12 Jahren
Ursprung
Commit
83273dc931

+ 21 - 0
inc/js/functions.js

@@ -450,3 +450,24 @@ function bx_search (n, sFormSel, sResultsContSel, sLoadingContSel, bSortResults)
     return false;
 }
 
+function on_filter_apply(e, sInputId, sFilterName)
+{
+	var oRegExp = new RegExp("[&]{0,1}" + sFilterName + "=.*");
+    var s = ('' + document.location).replace(oRegExp, ''); // remove filter
+    s = s.replace(/page=\d+/, 'page=1'); // goto 1st page
+    if (e.checked && $('#' + sInputId).val().length > 2)
+        s += (-1 == s.indexOf('?') ? '?' : '&') + sFilterName + '=' + $('#' + sInputId).val(); // append filter
+    document.location = s;
+}
+
+function on_filter_key_up (e, sCheckboxId)
+{
+    if (13 == e.keyCode) {
+        $('#' + sCheckboxId).click();
+        return false;
+    }
+    else {
+        $('#' + sCheckboxId).removeAttr('checked');
+        return true;
+    }
+}

+ 6 - 13
template/adminActionsPanel.html

@@ -3,23 +3,16 @@
     <table>
         <tr>
             <bx_if:selectAll>
-                <td><input class="admin-actions-select-all" type="checkbox" onclick="$('#{wrapperId} input[name=\'{checkboxName}[]\']:enabled').attr('checked', this.checked)"  {checked} /></td>
+                <td><input class="admin-actions-select-all" type="checkbox" onclick="$('#__wrapper_id__ input[name=\'__checkbox_name__[]\']:enabled').attr('checked', this.checked)"  __checked__ /></td>
                 <td><bx_text:_Select_all /></td>
             </bx_if:selectAll>
             <td>&nbsp;</td>
             <bx_repeat:buttons>
-                <td>
-                    <div class="input_wrapper input_wrapper_submit">
-                    <div class="button_wrapper"><input class="form_input_submit" type="{type}" name="{name}" value="{value}" {onclick} />
-                        <div class="button_wrapper_close"></div>
-                    </div>
-                    <div class="input_close input_close_submit"/>
-                    </div>
-                </td>
+                <td><input class="bx-btn" type="__type__" name="__name__" value="__value__" __onclick__ /></td>
             </bx_repeat:buttons>
-            <bx_if:customHTML>
-                <td>{custom_HTML}</td>
-            </bx_if:customHTML>
+            <bx_if:custom_html>
+                <td>__custom_html__</td>
+            </bx_if:custom_html>
         </tr>
     </table>
-</div>
+</div>

+ 16 - 0
template/adminFilterPanel.html

@@ -0,0 +1,16 @@
+<!-- TODO: remake according to new design -->
+<div class="admin_filter_panel">
+	<table>
+	    <tr>
+		    <td><bx_text:_sys_admin_filter /></td>
+		    <td>
+			    <div class="input_wrapper input_wrapper_text">
+				    <input type="text" id="__input_id__" value="__filter_value__" class="form_input_text" onkeypress="return on_filter_key_up(event, '__checkbox_id__')" />
+				    <div class="input_close input_close_text">&nbsp;</div>
+			    </div>
+		    </td>
+			<td><input type="checkbox" id="__checkbox_id__" __is_checked__ onclick="__on_apply__" /></td>
+		    <td><label for="__checkbox_id__"><bx_text:_sys_admin_apply /></label></td>
+	    </tr>
+	</table>
+</div>

+ 17 - 55
template/scripts/BxBaseSearchResult.php

@@ -115,6 +115,7 @@ class BxBaseSearchResult extends BxDolSearchResult
                 $aBtns[] = $v;
                 continue;
             }
+
             $aBtns[] = array(
                 'type' => 'submit',
                 'name' => $k,
@@ -122,80 +123,41 @@ class BxBaseSearchResult extends BxDolSearchResult
                 'onclick' => '',
             );
         }
-        $aUnit = array(
+
+        return BxDolTemplate::getInstance()->parseHtmlByName('adminActionsPanel.html', array(
             'bx_repeat:buttons' => $aBtns,
-            'bx_if:customHTML' => array(
+            'bx_if:custom_html' => array(
                 'condition' => strlen($sCustomHtml) > 0,
                 'content' => array(
-                    'custom_HTML' => $sCustomHtml,
+                    'custom_html' => $sCustomHtml,
                 )
             ),
             'bx_if:selectAll' => array(
                 'condition' => $bSelectAll,
                 'content' => array(
-                    'wrapperId' => $sWrapperId,
-                    'checkboxName' => $sCheckboxName,
+                    'wrapper_id' => $sWrapperId,
+                    'checkbox_name' => $sCheckboxName,
                     'checked' => ($bSelectAll && $bSelectAllChecked ? 'checked="checked"' : '')
                 )
             ),
-        );
-        return BxDolTemplate::getInstance()->parseHtmlByName('adminActionsPanel.html', $aUnit, array('{','}'));
+        ));
     }
 
     function showAdminFilterPanel($sFilterValue, $sInputId = 'filter_input_id', $sCheckboxId = 'filter_checkbox_id', $sFilterName = 'filter', $sOnApply = '') 
     {
-        $sFilter = _t('_sys_admin_filter');
-        $sApply = _t('_sys_admin_apply');
-
         $sFilterValue = bx_html_attribute($sFilterValue);
         $isChecked = $sFilterValue ? ' checked="checked" ' : '';
 
-        $sJsContent = "";
-        if(empty($sOnApply)) {
-            $sOnApply = 'on_filter_apply(this)';
-            ob_start();
-?>
-    <script type="text/javascript">
-        function on_filter_apply (e) {
-            var s = ('' + document.location).replace (/[&]{0,1}<?php echo $sFilterName;?>=.*/, ''); // remove filter
-            s = s.replace(/page=\d+/, 'page=1'); // goto 1st page
-            if (e.checked && $('#<?php echo $sInputId;?>').val().length > 2)
-                s += (-1 == s.indexOf('?') ? '?' : '&') + '<?php echo $sFilterName;?>=' + $('#<?php echo $sInputId;?>').val(); // append filter
-            document.location = s;
-        }
-        function on_filter_key_up (e) {
-            if (13 == e.keyCode) {
-                $('#<?php echo $sCheckboxId; ?>').attr('checked', 'checked');
-                on_filter_apply($('#<?php echo $sCheckboxId; ?>').get(0));
-                return false;
-            } else {
-                $('#<?php echo $sCheckboxId; ?>').attr('checked', '');
-                return true;
-            }
-        }
-    </script>
-<?php
-            $sJsContent = ob_get_clean();
-        }
+        if(empty($sOnApply))
+            $sOnApply = "on_filter_apply(this, '" . $sInputId . "', '" . $sFilterName . "')";
 
-        return <<<EOF
-    {$sJsContent}
-    <div class="admin_filter_panel">
-        <table>
-            <tr>
-                <td>{$sFilter}</td>
-                <td>
-                    <div class="input_wrapper input_wrapper_text">
-                        <input type="text" id="{$sInputId}" value="{$sFilterValue}" class="form_input_text" onkeypress="return on_filter_key_up(event)" />
-                        <div class="input_close input_close_text">&nbsp;</div>
-                    </div>
-                </td>
-                <td><input type="checkbox" id="{$sCheckboxId}" $isChecked onclick="{$sOnApply}" /></td>
-                <td><label for="{$sCheckboxId}">{$sApply}</label></td>
-            </tr>
-        </table>
-    </div>
-EOF;
+		return BxDolTemplate::getInstance()->parseHtmlByName('adminFilterPanel.html', array(
+			'input_id' => $sInputId,
+			'filter_value' => $sFilterValue,
+			'checkbox_id' => $sCheckboxId,
+			'is_checked' => $isChecked,
+			'on_apply' => $sOnApply,
+		));
     }
 
     function showPagination($bAdmin = false, $bChangePage = true, $bPageReload = true)