Ignore:
Timestamp:
May 20, 2012, 12:38:07 PM (12 years ago)
Author:
mistic100
Message:
  • display typetags everywhere (not only tags page)
  • little redesign of admin page + code cleaning
File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/typetags/admin/typetags_admin.tpl

    r10987 r15149  
    55{combine_css path=$ROOT_URL|@cat:"plugins/typetags/admin/typetags_style.css"}
    66
    7 {footer_script}
    8 {literal}
    9   $(document).ready(function(){
    10     // colorpicker
    11     $('#colorpicker').farbtastic('#hexval');
    12 
    13     // déplace chaque élément dans la bonne case
    14     jQuery('ul#tt-NULL li').each(function() {
    15       var $target = jQuery('ul#' + jQuery(this).attr('title'));
    16       jQuery(this).appendTo($target).css('float', 'left');
     7{footer_script}{literal}
     8// set all containers the same size
     9function equilibrate() {
     10  var h=0;
     11  jQuery("#associations ul")
     12    .css('height', 'auto')
     13    .each(function() {
     14      h = Math.max(h, jQuery(this).height());
     15    })
     16    .promise().done(function() {
     17      jQuery("#associations ul").css({'height': h+'px'});
    1718    });
    1819   
    19     // initialise les déplacement
    20     jQuery("li").draggable({
    21       revert: "invalid",
    22       helper: "clone",
    23       cursor: "move"
     20  //jQuery("#tt-NULL").css('height', 'auto');
     21}
     22
     23// generate tag:typetag couples before submit the form
     24function save_datas(form) {
     25  var out = '';
     26 
     27  jQuery(".tt-container").each(function() {
     28    var section = jQuery(this).attr('id');
     29    jQuery("> li", this).each(function() {
     30      out += jQuery(this).attr('id') + ':' + section + ';';
    2431    });
     32  });
     33 
     34  jQuery('#assoc-input').val(out);
     35  submit(form);
     36}
    2537
    26     // initialise le dépôt
    27     jQuery('.tt-container').droppable({
    28       accept: "li",
    29       hoverClass: "active",
    30       drop: function(event, ui) {
    31         var $gallery = this;
    32         ui.draggable.fadeOut(function() {
    33           jQuery(this).appendTo($gallery).fadeIn();
    34           equilibrate(); // on rééquilibre les colonnes à chaque déplacement
    35         });     
    36       }
    37     });
    38    
    39     // équilibrage des colonnes
    40     equilibrate();
    41   });
    42      
    43   function equilibrate() {
    44     jQuery("#associations").each(function(){
    45       var h=0;
    46       jQuery("> ul", this).css('height', 'auto')
    47         .each(function(){ h=Math.max(h,jQuery(this).height()); })
    48         .css({'height': h+'px'});
    49     });
     38// colorpicker
     39jQuery('#colorpicker').farbtastic('#hexval');
     40
     41// move each tag in it's typetag container
     42jQuery('ul#tt-NULL li').each(function() {
     43  var $target = jQuery('ul#' + jQuery(this).attr('data'));
     44  jQuery(this).appendTo($target).css('float', 'left');
     45  if ($($target).attr('id') == 'tt-NULL') jQuery(this).css({'display':'inline-block','float':'none'});
     46});
     47equilibrate();
     48
     49// init drag
     50jQuery("li").draggable({
     51  revert: "invalid",
     52  helper: "clone",
     53  cursor: "move"
     54});
     55
     56// init drop
     57jQuery('.tt-container').droppable({
     58  accept: "li",
     59  hoverClass: "active",
     60  drop: function(event, ui) {
     61    var $gallery = this;
     62    ui.draggable.fadeOut(function() {
     63      jQuery(this).appendTo($gallery).css('float', 'left').css('display','').fadeIn();
     64      if ($($gallery).attr('id') == 'tt-NULL') jQuery(this).css({'display':'inline-block','float':'none'});
     65      equilibrate();
     66    });     
    5067  }
    51  
    52   // génération des couples tag:typetag avant de valider le formulaire
    53   function save_datas(form) {
    54     var out = '';
    55    
    56     jQuery(".tt-container").each(function(){
    57       var section = jQuery(this).attr('id');
    58       jQuery("> li", this).each(function(){
    59         out += jQuery(this).attr('id') + ':' + section + ';';
    60       });
    61     });
    62    
    63     jQuery('#assoc-input').val(out);
    64     submit(form);
    65   }
    66 {/literal}
    67 {/footer_script}
     68});
     69{/literal}{/footer_script}
    6870
    6971<div class="titrePage">
     
    7274
    7375<form action="{$typetags_ADMIN}" method="post" name="form">
     76<fieldset>
     77  <legend>{'Configuration'|@translate}</legend>
     78  <b>{'Display colored tags'|@translate}</b>
     79  <label><input type="radio" name="show_all" value="false" {if not $SHOW_ALL}checked="checked"{/if}> {'Only on tags page'|@translate}</label>
     80  <label><input type="radio" name="show_all" value="true" {if $SHOW_ALL}checked="checked"{/if}> {'Everywhere'|@translate}</label>
     81  <p><input class="submit" type="submit" name="save_config" value="{'Submit'|@translate}"></p>
     82</fieldset>
     83</form>
     84 
     85<form action="{$typetags_ADMIN}" method="post" name="form">
    7486  <fieldset>
    7587  {if isset($edited_typetag)}
    7688    <legend>{'Edit typetag'|@translate}</legend>
    77     <input type="hidden" name="edited_typetag" value="{$edited_typetag}" />
    7889    <div class="edit-container">
    7990      <div id="colorpicker" style="float:right;"></div>
    8091      <p><b>{'Edited TypeTag'|@translate} : <input type="text" readonly="readonly" size="18" style="background-color:{$typetag.OLD_COLOR};color:{$typetag.COLOR_TEXT};" value="{$typetag.OLD_NAME}"></b></p>
    8192      <p>&nbsp;</p>
    82       <p>{'New name'|@translate} : <input type="text" size="18" name="typetag_name" value="{$typetag.NAME}"/></p>
    83       <p>{'New color'|@translate} : <input type="text" id="hexval" name="typetag_color" size="7" maxlength="7" value="{$typetag.COLOR}"/></p>
     93      <p>{'New name'|@translate} : <input type="text" size="18" name="typetag_name" value="{$typetag.NAME}"></p>
     94      <p>{'New color'|@translate} : <input type="text" id="hexval" name="typetag_color" size="7" maxlength="7" value="{$typetag.COLOR}"></p>
    8495      <p>&nbsp;</p>
    8596      <p>
    86         <input class="submit" type="submit" name="edittypetag" value="{'Modify'|@translate}"/>
    87         <input class="submit" type="submit" name="cancel" value="{'Reset'|@translate}"/>
     97        <input type="hidden" name="edited_typetag" value="{$edited_typetag}">
     98        <input class="submit" type="submit" name="edittypetag" value="{'Modify'|@translate}">
     99        <input class="submit" type="submit" name="cancel" value="{'Reset'|@translate}">
    88100      </p>
    89101    </div>
     
    93105      <div id="colorpicker" style="float:right;"></div>
    94106      <p>&nbsp;</p>
    95       <p>{'New TypeTag'|@translate} : <input type="text" size="18" name="typetag_name" value="{if isset($typetag.NAME)}{$typetag.NAME}{/if}"/></p>
    96       <p>{'Color TypeTag'|@translate} : <input type="text" id="hexval" name="typetag_color" size="7" maxlength="7" value="{if isset($typetag.COLOR)}{$typetag.COLOR}{else}#444444{/if}"/></p>
     107      <p>{'New TypeTag'|@translate} : <input type="text" size="18" name="typetag_name" value="{if isset($typetag.NAME)}{$typetag.NAME}{/if}"></p>
     108      <p>{'Color TypeTag'|@translate} : <input type="text" id="hexval" name="typetag_color" size="7" maxlength="7" value="{if isset($typetag.COLOR)}{$typetag.COLOR}{else}#444444{/if}"></p>
    97109      <p>&nbsp;</p>
    98110      <p>
    99         <input class="submit" type="submit" name="addtypetag" value="{'Create a Typetag'|@translate}"/>
     111        <input class="submit" type="submit" name="addtypetag" value="{'Create a Typetag'|@translate}">
    100112      </p>
    101113    </div>
     
    104116</form>
    105117
    106   {if !empty($typetags_selection)}
     118{if !empty($typetags_selection)}
     119<form action="{$typetags_ADMIN}" method="post" name="form" onsubmit="save_datas(this);">
    107120  <fieldset>
    108     <legend>{'TypeTag selection'|@translate}</legend>
    109     <ul class="tagSelection">
    110       {foreach from=$typetags_selection item=typetag}
    111       <li>
    112         <input type="text" readonly="readonly" style="background-color:{$typetag.color};color:{$typetag.color_text};margin:5px 0;" value="{$typetag.name}">
    113         <a href="{$typetag.u_edit}" title="{'edit'|@translate}"><img src="{$themeconf.icon_dir}/edit.png" class="button" alt="{'edit'|@translate}"/></a>
    114         <a href="{$typetag.u_delete}" title="{'delete'|@translate}" onclick="return confirm('{'Are you sure?'|@translate}');"><img src="{$themeconf.admin_icon_dir}/plug_delete.png" class="button" alt="{'delete'|@translate}"/></a>
    115       </li>
    116       {/foreach}
    117     </ul>
    118   </fieldset>
    119   {/if}
    120 
    121 <form action="{$typetags_ADMIN}" method="post" name="form" onsubmit="save_datas(this);">
    122   {if !empty($typetags_association) and !empty($typetags_selection)}
    123   <fieldset>
    124     <legend>{'TypeTag association'|@translate}</legend>
     121    <legend>{'Edit and associate TypeTags'|@translate}</legend>
    125122   
    126123    <ul id="tt-NULL" class="tt-container NULL">
    127       <h5>Non associés</h5>
     124      <h5>{'Not associated'|@translate}</h5>
    128125      {foreach from=$typetags_association item=tag}
    129       <li id="t-{$tag.tagid}" title="tt-{$tag.typetagid}">
     126      <li id="t-{$tag.tagid}" data="tt-{$tag.typetagid}">
    130127        {$tag.tagname}
    131128      </li>
     
    136133    {foreach from=$typetags_selection item=typetag}
    137134      <ul id="tt-{$typetag.id}" class="tt-container" style="box-shadow:inset 0 0 5px {$typetag.color};">
     135        <span class="buttons">
     136          <a href="{$typetag.u_edit}" title="{'edit'|@translate}"><img src="{$themeconf.icon_dir}/edit.png" class="button" alt="{'edit'|@translate}"></a>
     137          <a href="{$typetag.u_delete}" title="{'delete'|@translate}" onclick="return confirm('{'Are you sure?'|@translate}');"><img src="{$themeconf.icon_dir}/delete.png" class="button" alt="{'delete'|@translate}"></a>
     138        </span>
    138139        <h5 style="background-color:{$typetag.color};color:{$typetag.color_text};">{$typetag.name}</h5>
    139140      </ul>
     
    141142    </div>
    142143   
    143     <p style="clear:both;">
    144       <input type="hidden" name="associations" id="assoc-input"/>
    145       <input class="submit" type="submit" name="associate" value="{'Validate'|@translate}"/>
    146       <input class="submit" type="submit" name="delete_all_assoc" value="{'Delete all associations'|@translate}" onclick="return confirm('{'Are you sure?'|@translate}');"/>
     144    <div style="clear:both;"></div>
     145    <p style="margin-top:20px;">
     146      <input type="hidden" name="associations" id="assoc-input">
     147      <input class="submit" type="submit" name="associate" value="{'Validate'|@translate}">
     148      <input class="submit" type="submit" name="delete_all_assoc" value="{'Delete all associations'|@translate}" onclick="return confirm('{'Are you sure?'|@translate}');">
    147149    </p>
    148150  </fieldset>
    149   {/if}
    150151</form>
     152{/if}
Note: See TracChangeset for help on using the changeset viewer.