# HG changeset patch # User Dan Fuhry # Date 1289603561 18000 # Node ID 28ef73d2e7e815cf6dcfbb93d7a95218f20fc029 # Parent f8d8b3ef32e051b31534ff55678f0863d06d3986 Sprites, also floodlight search support diff -r f8d8b3ef32e0 -r 28ef73d2e7e8 guieditor/editor.js --- a/guieditor/editor.js Wed Nov 10 13:55:24 2010 -0500 +++ b/guieditor/editor.js Fri Nov 12 18:12:41 2010 -0500 @@ -16,6 +16,8 @@ toolbar += head.run(); var buttons = ['heading', '|', 'bold*', 'italic*', 'underline*', '|', 'intlink', 'extlink', 'image*', 'table*', '|', 'ulist*', 'olist*', '|', 'signature']; + // if new images are to be added, run sprite.sh under icons/ and update this array + var spritelist = ['add', 'bold', 'extlink', 'image', 'intlink', 'italic', 'olist', 'signature', 'table', 'ulist', 'underline', 'separator']; // Button: Bold var i; @@ -25,7 +27,7 @@ if ( buttons[i] == '|' ) { label.assign_vars({ - TITLE: '|' + TITLE: gen_sprite_html(cdnPath + '/plugins/guieditor/icons/sprite.png', 8, 16, 0, (spritelist.length - 1) * 16), }); toolbar += label.run(); } @@ -53,7 +55,8 @@ } button.assign_vars({ TITLE: $lang.get('guied_btn_' + buttons[i]), - IMAGE: cdnPath + '/plugins/guieditor/icons/' + buttons[i] + '.png', + // FIXME: indexOf is error prone here + SPRITE: gen_sprite_html(cdnPath + '/plugins/guieditor/icons/sprite.png', 16, 16, 0, spritelist.indexOf(buttons[i]) * 16), FLAGS: 'href="#" onclick="guied_act(\'' + buttons[i] + '\'); return false;"' }); toolbar += button.run(); @@ -76,6 +79,7 @@ function guied_act(action) { var textarea = document.getElementById('ajaxEditArea'); + var af_class = typeof(autofill_schemas.floodlight) == 'object' ? 'guied_floodlight' : 'page'; switch(action) { case 'bold': @@ -99,7 +103,7 @@ ' + $lang.get('guied_intlink_lbl_page') + ' \ \ \ -
\ +
\ ' + $lang.get('guied_intlink_af_hint') + ' \ \ \ @@ -573,3 +577,31 @@ } }; + +// This is only used if floodlight is available +autofill_schemas.guied_floodlight = { + init: function(element, fillclass, params) + { + params = params || {}; + $(element).autocomplete(makeUrlNS('Special', 'Autofill', 'type=floodlight') + '&userinput=', { + minChars: 3, + formatItem: function(row, _, __) + { + var type = ( typeof(row.type) == 'string' ) ? row.type : ''; + var html = '' + row.title + ' ' + type + ''; + html += '
' + $lang.get('floodlight_lbl_score') + row.score + '% | ' + row.size + ''; + row[0] = row[0].replace(/^go:/, ''); + return html; + }, + tableHeader: '' + $lang.get('floodlight_table_heading') + '', + showWhenNoResults: true, + onItemSelect: function(li) + { + $(element).val(li.selectValue.replace(/^go:/, '')); + }, + width: 180, + noResultsHTML: '' + $lang.get('floodlight_msg_no_results') + '', + }); + } +}; + diff -r f8d8b3ef32e0 -r 28ef73d2e7e8 guieditor/icons/sprite.png Binary file guieditor/icons/sprite.png has changed diff -r f8d8b3ef32e0 -r 28ef73d2e7e8 guieditor/icons/sprite.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/guieditor/icons/sprite.sh Fri Nov 12 18:12:41 2010 -0500 @@ -0,0 +1,22 @@ +#!/bin/bash +# separator is special (only 8px wide) so ensure it goes last +images=(`ls *.png | grep -v sprite | grep -v separator` separator.png) + +echo "Creating sprite.png. Update spritelist in ../editor.js with:" +echo -ne "\t[" +for img in ${images[@]}; do + echo -n "'${img%.png}'" + if [ $img != "separator.png" ]; then + echo -n ", " + fi +done +echo "]" + +montage=`which montage` +if [ -z "$montage" ]; then + echo "Could not find montage, please install imagemagick" + exit 1 +fi + +montage -background transparent -tile ${#images[@]}x1 -geometry +0+0 ${images[@]} sprite.png +