Ignore:
Timestamp:
Mar 26, 2011, 3:12:52 PM (13 years ago)
Author:
mistic100
Message:

[extensions] TypeTags

  • new administration
File:
1 edited

Legend:

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

    r9829 r9863  
     1{combine_script id="jquery.ui.draggable" require="jquery.ui"}
     2{combine_script id="jquery.ui.droppable"}
     3
    14{combine_script id="farbtastic" require="jquery" path=$ROOT_URL|@cat:"plugins/typetags/admin/farbtastic/farbtastic.js"}
    25{combine_css path=$ROOT_URL|@cat:"plugins/typetags/admin/farbtastic/farbtastic.css"}
     6{combine_css path=$ROOT_URL|@cat:"plugins/typetags/admin/typetags_style.css"}
    37
    48{footer_script}
    59{literal}
    6   $(document).ready(function(){
    7     $('#colorpicker').farbtastic('#hexval');
    8   });
     10        $(document).ready(function(){
     11                // colorpicker
     12                $('#colorpicker').farbtastic('#hexval');
     13
     14                // déplace chaque élément dans la bonne case
     15                jQuery('ul#tt-NULL li').each(function() {
     16                        var $target = jQuery('ul#' + jQuery(this).attr('title'));
     17                        jQuery(this).appendTo($target).css('float', 'left');
     18                });
     19               
     20                // initialise les déplacement
     21                jQuery("li").draggable({
     22                        revert: "invalid",
     23                        helper: "clone",
     24                        cursor: "move"
     25                });
     26
     27                // initialise le dépôt
     28                jQuery('.tt-container').droppable({
     29                        accept: "li",
     30                        hoverClass: "active",
     31                        drop: function(event, ui) {
     32                                var $gallery = this;
     33                                ui.draggable.fadeOut(function() {
     34                                        jQuery(this).appendTo($gallery).fadeIn();
     35                                        equilibrate(); // on rééquilibre les colonnes à chaque déplacement
     36                                });                     
     37                        }
     38                });
     39               
     40                // équilibrage des colonnes
     41                equilibrate();
     42        });
     43                       
     44        function equilibrate() {
     45                jQuery("#associations").each(function(){
     46                        var h=0;
     47                        jQuery("> ul", this).css('height', 'auto')
     48                                .each(function(){ h=Math.max(h,jQuery(this).height()); })
     49                                .css({'height': h+'px'});
     50                });
     51        }
     52       
     53        // génération des couples tag:typetag avant de valider le formulaire
     54        function save_datas(form) {
     55                var out = '';
     56               
     57                jQuery(".tt-container").each(function(){
     58                        var section = jQuery(this).attr('id');
     59                        jQuery("> li", this).each(function(){
     60                                out += jQuery(this).attr('id') + ':' + section + ';';
     61                        });
     62                });
     63               
     64                jQuery('#assoc-input').val(out);
     65                submit(form);
     66        }
    967{/literal}
    1068{/footer_script}
     
    1472</div>
    1573
    16 <form action="" method="post" name="form">
    17   {if isset($edit_tags)}
    18     <input type="hidden" name="edit_list" value="{$edit_tags}" />
    19   {/if}
     74<form action="{$typetags_ADMIN}" method="post" name="form">
     75        <fieldset>
     76        {if isset($edited_typetag)}
     77                <legend>{'Edit typetag'|@translate}</legend>
     78                <input type="hidden" name="edited_typetag" value="{$edited_typetag}" />
     79                <div class="edit-container">
     80                        <div id="colorpicker" style="float:right;"></div>
     81                        <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>
     82                        <p>&nbsp;</p>
     83                        <p>{'New name'|@translate} : <input type="text" size="18" name="typetag_name" value="{$typetag.NAME}"/></p>
     84                        <p>{'New color'|@translate} : <input type="text" id="hexval" name="typetag_color" size="7" maxlength="7" value="{$typetag.COLOR}"/></p>
     85                        <p>&nbsp;</p>
     86                        <p>
     87                                <input class="submit" type="submit" name="edittypetag" value="{'Modify'|@translate}"/>
     88                                <input class="submit" type="submit" name="cancel" value="{'Reset'|@translate}"/>
     89                        </p>
     90                </div>
     91        {else}
     92                <legend>{'Create a Typetag'|@translate}</legend>
     93                <div class="edit-container">
     94                        <div id="colorpicker" style="float:right;"></div>
     95                        <p>&nbsp;</p>
     96                        <p>{'New TypeTag'|@translate} : <input type="text" size="18" name="typetag_name" value="{if isset($typetag.NAME)}{$typetag.NAME}{/if}"/></p>
     97                        <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>
     98                        <p>&nbsp;</p>
     99                        <p>
     100                                <input class="submit" type="submit" name="addtypetag" value="{'Create a Typetag'|@translate}"/>
     101                        </p>
     102                </div>
     103        {/if}
     104        </fieldset>
     105</form>
    20106
    21 <fieldset>
    22 {if isset($edited_typetag)}
    23     <legend>{'Edit typetags'|translate}</legend>
    24     <input type="hidden" name="edited_typetag" value="{$edited_typetag}" />
    25    
    26     <div style="width: 500px; margin: auto;">
    27     <div id="colorpicker" style="float: right;"></div>
    28       <p><b>{'Edited TypeTag'|translate} : &nbsp;<input type="text" readonly="readonly"  size="20" style="background-color: {$typetag.OLD_COLOR}; color: {$typetag.COLOR_TEXT};" value="{$typetag.OLD_NAME}"></b>
    29       <p>&nbsp;</p>
    30       <p>{'New name'|translate}&nbsp;&nbsp;<input type="text" size="20" maxlength="15" name="typetag_name" value="{$typetag.NAME}"/></p>
    31                         <p>{'New color'|translate}&nbsp;&nbsp;<input type="text" id="hexval" name="typetag_color" size="9" maxlength="7" value="{$typetag.COLOR}"/></p>
    32       <p>&nbsp;</p>
    33       <p><input class="submit" type="submit" name="submit" value="{'Modify'|translate}"/>
    34          <input class="submit" type="submit" name="cancel" value="{'Reset'|translate}" /></p>
    35     </div>
    36 {else}
    37     <legend>{'Create a Typetag'|translate}</legend>
    38     <div style="width: 500px; margin: auto;">
    39     <div id="colorpicker" style="float: right;"></div>
    40       <p>&nbsp;</p>
    41       <p>{'New TypeTag'|translate}&nbsp;&nbsp;<input type="text" size="20" maxlength="15" name="add_typetag" value="{if isset($typetag.NAME)}{$typetag.NAME}{/if}"/></p>
    42                         <p>{'ColorTypeTag'|translate}&nbsp;&nbsp;<input type="text" id="hexval" name="hexval" size="9" value="{if isset($typetag.COLOR)}{$typetag.COLOR}{else}#444444{/if}"/></p>
    43       <p>&nbsp;</p>
    44       <p><input class="submit" type="submit" name="addtypetag" value="{'Create a Typetag'|translate}"/></p>
    45     </div>
    46 {/if}
    47 </fieldset>
     107        {if !empty($typetags_selection)}
     108        <fieldset>
     109                <legend>{'TypeTag selection'|@translate}</legend>
     110                <ul class="tagSelection">
     111                        {foreach from=$typetags_selection item=typetag}
     112                        <li>
     113                                <input type="text" readonly="readonly" size="18" style="background-color:{$typetag.color};color:{$typetag.color_text};margin:5px 0;" value="{$typetag.name}">
     114                                <a href="{$typetag.u_edit}" title="{'edit'|@translate}"><img src="{$themeconf.icon_dir}/edit.png" class="button" alt="{'edit'|@translate}"/></a>
     115                                <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>
     116                        </li>
     117                        {/foreach}
     118                </ul>
     119        </fieldset>
     120        {/if}
    48121
    49 {if !empty($typetags_selection)}
    50 <fieldset>
    51     <legend>{'TypeTag selection'|translate}</legend>
    52     <ul class="tagSelection">
    53     {foreach from=$typetags_selection item=typetag}
    54       <li>
    55         <label><input type="checkbox" name="typetags[]" value="{$typetag.id}" style="margin: 5px 0;"/>&nbsp;
    56           <input type="text" readonly="readonly" size="18" style="background-color: {$typetag.color}; color: {$typetag.color_text}; margin: 5px 0;" value="{$typetag.name}"></label></li>
    57     {/foreach}
    58     </ul>
    59     <p><br>
    60      <input class="submit" type="submit" name="edittypetag" value="{'Edit selected typetags'|translate}"/>
    61      <input class="submit" type="submit" name="deletetypetag" value="{'Delete selected typetags'|translate}" onclick="return confirm('{'Are you sure?'|translate}');"/>
    62     </p>
    63 </fieldset>
    64 {/if}
    65 
    66 {if !empty($typetags_association) and !empty($typetags_selection)}
    67 <fieldset>
    68     <legend>{'TypeTag association'|translate}</legend>
    69       <ul class="tagSelection">
    70       {foreach from=$typetags_association item=tag}
    71         <li style="margin: 10px 0;">
    72           <label><input type="checkbox" name="assoc_tags[]" value="{$tag.id}" /><span style="color: {$tag.color}; font-weight: bold;"> {$tag.name}</span></label></li>
    73       {/foreach}
    74       </ul>
    75             <p><br>{'existing_typetag_list'|translate}
    76                           <select class="categoryDropDown" name="typetaglist">
    77         <option value=""> {'choose_typetag'|@translate}</option>
    78                           {foreach from=$typetags_selection item=typetag}
    79                         <option value="{$typetag.id}"> {$typetag.name}</option>
    80                           {/foreach}
    81                           </select>
    82                           <input class="submit" type="submit" name="associate" value="{'associate'|translate}" onclick="return confirm('{'Are you sure?'|translate}');"/></p>
    83 </fieldset>
    84 {/if}
    85 
    86 {if !empty($typetags_dissociation)}
    87 <fieldset>
    88     <legend>{'TypeTag dissociation'|translate}</legend>
    89       <ul class="tagSelection">
    90       {foreach from=$typetags_dissociation item=tag}
    91         <li style="margin: 10px 0;">
    92           <label><input type="checkbox" name="dissoc_tags[]" value="{$tag.id}" /><span style="color: {$tag.color}; font-weight: bold;"> {$tag.name}</span></label></li>
    93       {/foreach}
    94       </ul>
    95       <p><br><input class="submit" type="submit" name="dissociate" value="{'dissociate'|translate}"onclick="return confirm('{'Are you sure?'|translate}');"/></p>
    96 </fieldset>
    97 {/if}
     122<form action="{$typetags_ADMIN}" method="post" name="form" onsubmit="save_datas(this);">
     123        {if !empty($typetags_association) and !empty($typetags_selection)}
     124        <fieldset>
     125                <legend>{'TypeTag association'|@translate}</legend>
     126               
     127                <ul id="tt-NULL" class="tt-container NULL">
     128                        <h5>Non associés</h5>
     129                        {foreach from=$typetags_association item=tag}
     130                        <li id="t-{$tag.tagid}" title="tt-{$tag.typetagid}">
     131                                {$tag.tagname}
     132                        </li>
     133                        {/foreach}
     134                </ul>
     135               
     136                <div id="associations">
     137                {foreach from=$typetags_selection item=typetag}
     138                        <ul id="tt-{$typetag.id}" class="tt-container" style="box-shadow:inset 0 0 5px {$typetag.color};">
     139                                <h5 style="background-color:{$typetag.color};color:{$typetag.color_text};">{$typetag.name}</h5>
     140                        </ul>
     141                {/foreach}
     142                </div>
     143               
     144                <p style="clear:both;">
     145                        <input type="hidden" name="associations" id="assoc-input"/>
     146                        <input class="submit" type="submit" name="associate" value="{'Validate'|@translate}"/>
     147                        <input class="submit" type="submit" name="delete_all_assoc" value="{'Delete all associations'|@translate}" onclick="return confirm('{'Are you sure?'|@translate}');"/>
     148                </p>
     149        </fieldset>
     150        {/if}
    98151</form>
Note: See TracChangeset for help on using the changeset viewer.