- Timestamp:
- Jun 15, 2013, 6:52:37 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/SmiliesSupport/template/smiliessupport_admin.tpl
r15110 r23234 1 {combine_script id='jquery. cluetip' require='jquery' path='themes/default/js/plugins/jquery.cluetip.js'}2 { include file='include/autosize.inc.tpl'}1 {combine_script id='jquery.tokeninput' load='footer' path='themes/default/js/plugins/jquery.tokeninput.js'} 2 {combine_css path=$SMILIES_PATH|cat:'template/style.css'} 3 3 4 {footer_script require="jquery.cluetip"}{literal} 5 jQuery('.cluetip').cluetip({ 6 width: 550, 7 splitTitle: '|' 8 }); 4 5 {footer_script}{literal} 6 var data = {}; 7 var edit = false; 8 var edited = false; 9 10 // set changed 11 jQuery("select[name='folder']").change(function() { 12 if (edited) { 13 var ok = confirm("{/literal}{'If you change current set you will lost every shortcuts changes.'|@translate}{literal}"); 14 if (!ok) { 15 jQuery(this).val(jQuery(this).data("selected")); 16 return false; 17 } 18 } 19 20 var image = jQuery(this).find(":selected").css("background-image"); 21 jQuery(this).css("background-image", image); 22 jQuery(this).data("selected", jQuery(this).val()); 23 24 fetch(); 25 }); 26 27 // size changed 28 jQuery("input[name='cols']").change(function() { 29 update(); 30 }); 31 32 // switch preview/edit 33 jQuery(".edit").click(function() { 34 if (edit) { 35 $(this).html("{/literal}{'Edit shorcuts'|@translate}{literal}"); 36 } 37 else { 38 $(this).html("{/literal}{'Preview'|@translate}{literal}"); 39 } 40 41 edit = !edit; 42 update(); 43 return false; 44 }); 45 46 // display edit form before submit 47 jQuery("#smiliesupport").submit(function() { 48 if (!edit) jQuery(".edit").click(); 49 return true; 50 }); 51 52 /* get smilies list */ 53 function fetch() { 54 jQuery.ajax({ 55 url: 'admin.php', 56 type: 'GET', 57 dataType: 'json', 58 data: { 59 action: 'ss_preview', 60 folder: jQuery("select[name='folder']").val(), 61 }, 62 success: function(result) { 63 data = result; 64 edited = false; 65 update(); 66 } 67 }); 68 } 69 70 /* update preview/edit table */ 71 function update() { 72 var html = ''; 73 74 if (!edit) { 75 html+= '<tr>'; 76 var cols = parseInt(jQuery("input[name='cols']").val()); 77 var i=0; 78 79 for (var file in data.smilies) { 80 var smiley = data.smilies[file]; 81 html+= '<td><a href="#" title="'+ smiley.title +'"><img src="'+ data.path + smiley.file +'"/></a></td>'; 82 if ((parseInt(i)+1)%cols == 0) html+= '</tr><tr>'; 83 i++; 84 } 85 86 html+= '</tr>'; 87 } 88 else { 89 {/literal} 90 html+= '<tr>' 91 +'<th>{'Smiley'|@translate}</th>' 92 +'<th>{'Name'|@translate}</th>' 93 +'<th>{'Shortcuts'|@translate}</th>' 94 +'</tr>'; 95 {literal} 96 97 for (var file in data.smilies) { 98 var smiley = data.smilies[file]; 99 html+= '<tr data-file="'+ smiley.file +'">' 100 +'<td><img src="'+ data.path + smiley.file +'"/></td>' 101 +'<td>'+ smiley.title +'</td>' 102 +'<td>' 103 +'<select name="shortcuts['+ smiley.file +']" class="shortcuts">'; 104 105 for (var j in smiley.short) { 106 html+= '<option value="'+ smiley.short[j] +'" selected>'+ smiley.short[j] +'</option>'; 107 } 108 109 html+= '</select>' 110 +'</td>' 111 +'</tr>'; 112 } 113 } 114 115 jQuery("#preview").html(html); 116 117 // init tokeninput 118 jQuery(".shortcuts").tokenInput([], { 119 hintText: '{/literal}{'Type in a new shortcut'|@translate}{literal}', 120 newText: '', 121 animateDropdown: false, 122 preventDuplicates: true, 123 caseSensitive: true, 124 allowCreation: true, 125 minChars: 2, 126 searchDelay: 10, 127 128 onAdd: function(item) { 129 edited = true; 130 var file = $(this).parents("tr").data("file"); 131 132 if (data.smilies[file].short == null) { 133 data.smilies[file].short = [item.name]; 134 } 135 else { 136 data.smilies[file].short.push(item.name); 137 } 138 }, 139 onDelete: function(item) { 140 edited = true; 141 var file = $(this).parents("tr").data("file"); 142 143 for (var i in data.smilies[file].short) { 144 if (data.smilies[file].short[i] == item.name) { 145 data.smilies[file].short.splice(i, 1); 146 } 147 } 148 }, 149 }); 150 151 // prevent spaces 152 jQuery(".token-input-input-token input").keydown(function(e) { 153 if (e.keyCode == 32) { 154 return false; 155 } 156 }); 157 } 158 159 // init 160 fetch(); 9 161 {/literal}{/footer_script} 10 162 11 {html_head}12 <style type="text/css">13 legend .cluetip {ldelim}14 text-align:center;15 margin:20px 0 -10px 0;16 font-size:1.2em;17 }18 .cluetip:after {ldelim}19 margin-left:5px;20 vertical-align:top;21 content:url('{$themeconf.admin_icon_dir}/help.png');22 }23 .properties textarea {ldelim}24 width:60%;25 margin:0 20%;26 }27 </style>28 {/html_head}29 163 30 164 <div class="titrePage"> … … 32 166 </div> 33 167 34 <form method="post" action="" class="properties"> 35 <fieldset> 36 <legend>{'Configuration'|@translate}</legend> 37 <ul> 168 <form method="post" action="" class="properties" id="smiliesupport"> 169 170 <fieldset> 171 <legend>{'Configuration'|@translate}</legend> 172 173 <ul> 38 174 <li> 39 <span class="property">{'Smileys\' folder'|@translate}</span> 40 <select name="folder"> 41 {html_options options=$sets selected=$FOLDER} 175 <b>{'Smilies set'|@translate}</b> 176 <select name="folder" style="background-image:url('{$SMILIES_PATH}smilies/{$FOLDER}/{$SETS[$FOLDER]}');" data-selected="{$FOLDER}"> 177 {foreach from=$SETS item=rep key=set} 178 <option value="{$set}" style="background-image:url('{$SMILIES_PATH}smilies/{$set}/{$rep}');" {if $set==$FOLDER}selected{/if}>{$set}</option> 179 {/foreach} 42 180 </select> 43 181 </li> 44 182 <li> 45 <span class="property">{'Nb. columns'|@translate}</span> 46 <input type="text" size="3" name="cols" value="{$COLS}" /> 47 </li> 48 <li> 49 <span class="property">{'Representative'|@translate}</span> 50 <select name="representant"> 51 {html_options options=$smilies selected=$REPRESENTANT} 52 </select> 183 <b>{'Columns'|@translate}</b> 184 <input type="text" size="2" name="cols" value="{$COLS}"> 53 185 </li> 54 <li> 55 <table><tr> 56 {foreach from=$smiliesfiles item=smileyfile} 57 <td><a href="#" title="{$smileyfile.TITLE}"><img src="{$smileyfile.PATH}"/></a></td> 58 {$smileyfile.TR} 59 {/foreach} 60 </tr></table> 61 </li> 62 </ul> 63 </fieldset> 186 </ul> 187 </fieldset> 188 189 <fieldset> 190 <legend>{'Preview'|@translate}</legend> 191 <a href="#" class="edit buttonLike">{'Edit shorcuts'|@translate}</a> 192 <table id="preview"></table> 193 </fieldset> 64 194 65 <fieldset> 66 <legend><span class="cluetip" title="smilies.txt|{'smilies_file_help'|@translate}">smilies.txt</legend> 67 <textarea rows="5" name="text">{$CONTENT_FILE}</textarea> 68 </fieldset> 69 70 <p><input class="submit" type="submit" value="{'Submit'|@translate}" name="submit" /></p> 195 <p class="formButtons"><input class="submit" type="submit" value="{'Submit'|@translate}" name="submit" /></p> 196 71 197 </form>
Note: See TracChangeset
for help on using the changeset viewer.