{combine_css path='themes/default/js/plugins/jquery.tokeninput.css'} {combine_script id='jquery.tokeninput' load='footer' path='themes/default/js/plugins/jquery.tokeninput.js'} {combine_css path=$SMILIES_PATH|cat:'template/style.css'} {footer_script} (function(){ var data = {ldelim}}, edit = false, edited = false; // set changed jQuery('select[name="folder"]').change(function() { if (edited) { var ok = confirm('{'If you change current set you will lost every shortcuts changes.'|translate|escape:javascript}'); if (!ok) { jQuery(this).val(jQuery(this).data('selected')); return false; } } var image = jQuery(this).find(':selected').css('background-image'); jQuery(this).css('background-image', image); jQuery(this).data('selected', jQuery(this).val()); fetch(); }); // size changed jQuery('input[name="cols"]').change(function() { update(); }); // switch preview/edit jQuery('.edit').click(function() { if (edit) { $(this).html('{'Edit shorcuts'|translate|escape:javascript}'); } else { $(this).html('{'Preview'|translate|escape:javascript}'); } edit = !edit; update(); return false; }); // reset defaults jQuery('.reset').click(function() { if (!confirm('{'Are you sure?'|translate|escape:javascript}')) { return false; } jQuery.ajax({ url: 'admin.php', type: 'GET', dataType: 'json', data: { action: 'ss_reset', folder: jQuery('select[name="folder"]').val(), }, success: function(result) { data = result; edited = false; update(); } }); return false; }); // display edit form before submit jQuery('#smiliesupport').submit(function() { if (!edit) { jQuery('.edit').click(); } return true; }); /* get smilies list */ function fetch() { jQuery.ajax({ url: 'admin.php', type: 'GET', dataType: 'json', data: { action: 'ss_list', folder: jQuery('select[name="folder"]').val(), }, success: function(result) { data = result; edited = false; update(); } }); } /* update preview/edit table */ function update() { var html = '', i=0; if (!edit) { html+= ''; var cols = parseInt(jQuery('input[name="cols"]').val()); for (var file in data.smilies) { var smiley = data.smilies[file]; html+= ''; html+= (i+1)%cols==0 ? '' : ''; i++; } html+= ''; jQuery('.reset').hide(); } else { html+= '' +'' +'{'Name'|translate}' +'{'Shortcuts'|translate}' +'' +'' +'{'Name'|translate}' +'{'Shortcuts'|translate}' +'' +''; for (var file in data.smilies) { var smiley = data.smilies[file]; html+= '' +''+ smiley.title +'' +'' +'' +''; html+= (i+1)%2==0 ? '' : ''; i++; } html+= ''; jQuery('.reset').show(); } jQuery('#preview').html(html); // init tokeninput jQuery('.shortcuts').tokenInput([], { hintText: '{'Type in a new shortcut'|translate|escape:javascript}', newText: '', animateDropdown: false, preventDuplicates: true, allowFreeTagging: true, minChars: 2, searchDelay: 10, onAdd: function(item) { edited = true; var file = $(this).parent('td').data("file"); if (data.smilies[file].short == null) { data.smilies[file].short = [item.name]; } else { data.smilies[file].short.push(item.name); } }, onDelete: function(item) { edited = true; var file = $(this).parent('td').data("file"); for (var i in data.smilies[file].short) { if (data.smilies[file].short[i] == item.name) { data.smilies[file].short.splice(i, 1); } } }, }); // prevent spaces jQuery('.token-input-input-token input').keydown(function(e) { if (e.keyCode == 32) { return false; } }); } // init fetch(); }());{/footer_script}

Smilies Support

{'Configuration'|translate}
{'Preview'|translate} {'Edit shortcuts'|translate}