Changeset 26650


Ignore:
Timestamp:
Jan 12, 2014, 1:16:46 PM (10 years ago)
Author:
mistic100
Message:

change behavior of reset/cancel button on tags manager + reorganize code

Location:
trunk/admin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/tags.php

    r26649 r26650  
    3939// +-----------------------------------------------------------------------+
    4040
    41 if (isset($_POST['submit']))
     41if (isset($_POST['edit_submit']))
    4242{
    4343  $query = '
     
    195195// +-----------------------------------------------------------------------+
    196196
    197 if (isset($_POST['confirm_merge']))
     197if (isset($_POST['merge_submit']))
    198198{
    199199  if (!isset($_POST['destination_tag']))
     
    429429  }
    430430
    431   $template->assign(
    432     array(
    433       $list_name => implode(',', $_POST['tags']),
    434       )
    435     );
     431  $template->assign($list_name, implode(',', $_POST['tags']));
    436432
    437433  $query = '
     
    442438  $result = pwg_query($query);
    443439  while ($row = pwg_db_fetch_assoc($result))
    444   {
    445     $name_of[ $row['id'] ] = $row['name'];
    446   }
    447 
    448   foreach ($_POST['tags'] as $tag_id)
    449440  {
    450441    $template->append(
    451442      'tags',
    452443      array(
    453         'ID' => $tag_id,
    454         'NAME' => $name_of[$tag_id],
     444        'ID' => $row['id'],
     445        'NAME' => $row['name'],
    455446        )
    456447      );
  • trunk/admin/themes/default/template/tags.tpl

    r26646 r26650  
    11{include file='include/tag_selection.inc.tpl'}
    22
    3 {footer_script}{literal}
    4 jQuery(document).ready(function(){
    5   function displayDeletionWarnings() {
    6     jQuery(".warningDeletion").show();
    7     jQuery("input[name=destination_tag]:checked").parent("label").children(".warningDeletion").hide();
     3{html_style}
     4.showInfo { text-indent:5px; }
     5{/html_style}
     6
     7{footer_script require='jquery'}
     8jQuery('.showInfo').tipTip({
     9  'delay' : 0,
     10  'fadeIn' : 200,
     11  'fadeOut' : 200,
     12  'maxWidth':'300px',
     13  'keepAlive':true,
     14  'activation':'click'
     15});
     16
     17function displayDeletionWarnings() {
     18  jQuery(".warningDeletion").show();
     19  jQuery("input[name=destination_tag]:checked").parent("label").children(".warningDeletion").hide();
     20}
     21
     22displayDeletionWarnings();
     23
     24jQuery("#mergeTags label").click(function() {
     25  displayDeletionWarnings();
     26});
     27
     28jQuery("input[name=merge]").click(function() {
     29  if (jQuery("ul.tagSelection input[type=checkbox]:checked").length < 2) {
     30    alert("{'Select at least two tags for merging'|@translate}");
     31    return false;
     32  }
     33});
     34
     35$("#searchInput").on("keydown", function(e) {
     36  var $this = $(this),
     37      timer = $this.data("timer");
     38
     39  if (timer) {
     40    clearTimeout(timer);
    841  }
    942
    10   displayDeletionWarnings();
     43  $this.data("timer", setTimeout(function() {
     44    var val = $this.val();
     45    if (!val) {
     46      $(".tagSelection>li").show();
     47      $("#filterIcon").css("visibility","hidden");
     48    }
     49    else {
     50      $("#filterIcon").css("visibility","visible");
     51      var regex = new RegExp( val.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&"), "i" );
     52      $(".tagSelection>li").each(function() {
     53        var $li = $(this),
     54            text = $.trim( $("label", $li).text() );
     55        $li.toggle(regex.test(text));
     56      });
     57    }
    1158
    12   jQuery("#mergeTags label").click(function() {
    13     displayDeletionWarnings();
    14   });
     59  }, 300) );
    1560
    16   jQuery("input[name=merge]").click(function() {
    17     if (jQuery("ul.tagSelection input[type=checkbox]:checked").length < 2) {
    18       alert("{/literal}{'Select at least two tags for merging'|@translate}{literal}");
    19       return false;
    20     }
    21   });
     61  if (e.keyCode == 13) { // Enter
     62    e.preventDefault();
     63  }
    2264});
    23 {/literal}{/footer_script}
     65{/footer_script}
    2466
    2567
     
    4789
    4890    <p>
    49       <input type="hidden" name="pwg_token" value="{$PWG_TOKEN}">
    50       <input class="submit" type="submit" name="submit" value="{'Submit'|@translate}">
    51       <input class="submit" type="reset" value="{'Reset'|@translate}">
     91      <input type="submit" name="edit_submit" value="{'Submit'|@translate}">
     92      <input type="submit" name="edit_cancel" value="{'Cancel'|@translate}">
    5293    </p>
    5394  </fieldset>
    5495  {/if}
     96
    5597  {if isset($DUPLIC_TAGS_LIST)}
    5698  <fieldset>
     
    71113
    72114    <p>
    73       <input type="hidden" name="pwg_token" value="{$PWG_TOKEN}">
    74       <input class="submit" type="submit" name="duplic_submit" value="{'Submit'|@translate}">
    75       <input class="submit" type="reset" value="{'Reset'|@translate}">
     115      <input type="submit" name="duplic_submit" value="{'Submit'|@translate}">
     116      <input type="submit" name="duplic_cancel" value="{'Cancel'|@translate}">
    76117    </p>
    77118  </fieldset>
     
    79120
    80121  {if isset($MERGE_TAGS_LIST)}
    81   <input type="hidden" name="merge_list" value="{$MERGE_TAGS_LIST}">
    82 
    83122  <fieldset id="mergeTags">
    84123    <legend>{'Merge tags'|@translate}</legend>
    85     {'Select the destination tag'|@translate}<br><br>
     124    {'Select the destination tag'|@translate}
     125
     126    <p>
    86127    {foreach from=$tags item=tag name=tagloop}
    87128    <label><input type="radio" name="destination_tag" value="{$tag.ID}"{if $smarty.foreach.tagloop.index == 0} checked="checked"{/if}> {$tag.NAME}<span class="warningDeletion"> {'(this tag will be deleted)'|@translate}</span></label><br>
    88129    {/foreach}
    89     <br><input type="submit" name="confirm_merge" value="{'Confirm merge'|@translate}">
     130    </p>
     131
     132    <p>
     133      <input type="hidden" name="merge_list" value="{$MERGE_TAGS_LIST}">
     134      <input type="submit" name="merge_submit" value="{'Confirm merge'|@translate}">
     135      <input type="submit" name="merge_cancel" value="{'Cancel'|@translate}">
     136    </p>
    90137  </fieldset>
    91138  {/if}
     
    104151  <fieldset>
    105152    <legend>{'Tag selection'|@translate}</legend>
    106 {html_style}
    107 .showInfo{ldelim}text-indent:5px}
    108 {/html_style}
    109 {footer_script}{literal}
    110 jQuery('.showInfo').tipTip({
    111     'delay' : 0,
    112     'fadeIn' : 200,
    113     'fadeOut' : 200,
    114     'maxWidth':'300px',
    115     'keepAlive':true,
    116     'activation':'click'
    117   });
    118 {/literal}{/footer_script}
    119 {if count($all_tags)}
    120 <div><label><span class="icon-filter" style="visibility:hidden" id="filterIcon"></span>{'Search'|@translate}: <input id="searchInput" type="text" size="12"></label></div>
    121 {footer_script}{literal}
    122 $("#searchInput").on( "keydown", function(e) {
    123         var $this = $(this),
    124                 timer = $this.data("timer");
    125         if (timer)
    126                 clearTimeout(timer);
    127153
    128         $this.data("timer", setTimeout( function() {
    129                 var val = $this.val();
    130                 if (!val) {
    131                         $(".tagSelection>li").show();
    132                         $("#filterIcon").css("visibility","hidden");
    133                 }
    134                 else {
    135                         $("#filterIcon").css("visibility","visible");
    136                         var regex = new RegExp( val.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&"), "i" );
    137                         $(".tagSelection>li").each( function(i, li) {
    138                                 var $li = $(li),
    139                                         text = $.trim( $("label", $li).text() );
    140                                 if (regex.test( text ))
    141                                         $li.show();
    142                                 else
    143                                         $li.hide();
    144                         });
    145                 }
     154    {if count($all_tags)}
     155    <div><label><span class="icon-filter" style="visibility:hidden" id="filterIcon"></span>{'Search'|@translate}: <input id="searchInput" type="text" size="12"></label></div>
     156    {/if}
    146157
    147         }, 300) );
    148  
    149   if (e.keyCode == 13) { // Enter
    150     e.preventDefault();
    151   }
    152 });
    153 {/literal}{/footer_script}
    154 {/if}
    155 <ul class="tagSelection">
    156 {foreach from=$all_tags item=tag}
    157         <li>{capture name='showInfo'}<b>{$tag.name}</b> ({$tag.counter|@translate_dec:'%d photo':'%d photos'}) <br> <a href="{$tag.U_VIEW}">{'View in gallery'|@translate}</a> | <a href="{$tag.U_EDIT}">{'Manage photos'|@translate}</a>{if !empty($tag.alt_names)}<br>{$tag.alt_names}{/if}{/capture}
    158                 <a class="icon-info-circled-1 showInfo" title="{$smarty.capture.showInfo|@htmlspecialchars}"></a>
    159                 <label>
    160                         <input type="checkbox" name="tags[]" value="{$tag.id}"> {$tag.name}
    161                 </label>
    162         </li>
    163 {/foreach}
    164 </ul>
     158    <ul class="tagSelection">
     159    {foreach from=$all_tags item=tag}
     160      <li>
     161        {capture name='showInfo'}{strip}
     162          <b>{$tag.name}</b> ({$tag.counter|@translate_dec:'%d photo':'%d photos'})<br>
     163          <a href="{$tag.U_VIEW}">{'View in gallery'|@translate}</a> |
     164          <a href="{$tag.U_EDIT}">{'Manage photos'|@translate}</a>
     165          {if !empty($tag.alt_names)}<br>{$tag.alt_names}{/if}
     166        {/strip}{/capture}
     167        <a class="icon-info-circled-1 showInfo" title="{$smarty.capture.showInfo|@htmlspecialchars}"></a>
     168        <label>
     169          <input type="checkbox" name="tags[]" value="{$tag.id}"> {$tag.name}
     170        </label>
     171      </li>
     172    {/foreach}
     173    </ul>
    165174
    166                 <p>
    167                         <input type="hidden" name="pwg_token" value="{$PWG_TOKEN}">
    168                         <input type="submit" name="edit" value="{'Edit selected tags'|@translate}">
    169                         <input type="submit" name="duplicate" value="{'Duplicate selected tags'|@translate}">
    170                         <input type="submit" name="merge" value="{'Merge selected tags'|@translate}">
    171                         <input type="submit" name="delete" value="{'Delete selected tags'|@translate}" onclick="return confirm('{'Are you sure?'|@translate}');">
    172                 </p>
     175    <p>
     176      <input type="hidden" name="pwg_token" value="{$PWG_TOKEN}">
     177      <input type="submit" name="edit" value="{'Edit selected tags'|@translate}">
     178      <input type="submit" name="duplicate" value="{'Duplicate selected tags'|@translate}">
     179      <input type="submit" name="merge" value="{'Merge selected tags'|@translate}">
     180      <input type="submit" name="delete" value="{'Delete selected tags'|@translate}" onclick="return confirm('{'Are you sure?'|@translate}');">
     181    </p>
    173182  </fieldset>
    174183
Note: See TracChangeset for help on using the changeset viewer.