| | 8 | InsertSmiley._pluginInfo = { |
| | 9 | name : "InsertSmiley", |
| | 10 | version : "2.0", |
| | 11 | developer : "V 1.0 Ki Master George, V2.0 James Sleeman", |
| | 12 | developer_url : "http://www.gogo.co.nz/", |
| | 13 | c_owner : "Ki Master George, James Sleeman", |
| | 14 | sponsor : "Gogo Internet Services", |
| | 15 | sponsor_url : "http://www.gogo.co.nz/", |
| | 16 | license : "htmlArea" |
| | 17 | }; |
| | 18 | |
| | 19 | /** To configure the InsertSmiley plugin. |
| | 20 | * |
| | 21 | * Set xinha_config.InsertSmiley.smileys to EITHER |
| | 22 | * |
| | 23 | * * A URL to a file called smileys.js, which follows the format |
| | 24 | * you can view in smileys/smileys.js |
| | 25 | * |
| | 26 | * * A URL to a file called smileys.php (or whatever other language) |
| | 27 | * which outputs a file in the same way as smileys/smileys.php |
| | 28 | * |
| | 29 | * * A javascript the same as you will find in smileys/smileys.js |
| | 30 | * |
| | 31 | * By defaut the static smileys/smileys.js file is used, you may |
| | 32 | * wish to set this like so |
| | 33 | * |
| | 34 | * xinha_config.InsertSmiley.smileys = _editor_url+'/plugins/InsertSmiley/smileys/smileys.php'; |
| | 35 | * |
| | 36 | * And then you can add new smileys just by dumping all the images into the |
| | 37 | * /xinha/plugins/InsertSmiley/smileys/ |
| | 38 | * folder and they will automatically be made available. |
| | 39 | * |
| | 40 | */ |
| | 41 | |
| | 42 | Xinha.Config.prototype.InsertSmiley= { |
| | 43 | smileys : '' |
| | 44 | }; |
| | 45 | |
| | 46 | Xinha.loadStyle('dialog.css', 'InsertSmiley'); |
| | 47 | |
| 26 | | InsertSmiley._pluginInfo = { |
| 27 | | name : "InsertSmiley", |
| 28 | | version : "1.0", |
| 29 | | developer : "Ki Master George", |
| 30 | | developer_url : "http://kimastergeorge.i4host.com/", |
| 31 | | c_owner : "Ki Master George", |
| 32 | | sponsor : "Ki Master George", |
| 33 | | sponsor_url : "http://kimastergeorge.i4host.com/", |
| 34 | | license : "htmlArea" |
| | 70 | InsertSmiley.prototype.onGenerateOnce = function() |
| | 71 | { |
| | 72 | // Back compat for ray's smiley config in changeset:904 ( ticket:1093 ) |
| | 73 | if(this.editor.config.InsertSmiley.smileyURL) |
| | 74 | { |
| | 75 | var smileys = [ ]; |
| | 76 | var smileylist = Xinha._geturlcontent(Xinha.getPluginDir("InsertSmiley") + '/smileys.txt'); |
| | 77 | var smileyURL = this.editor.config.InsertSmiley.smileyURL; |
| | 78 | |
| | 79 | smileylist = smileylist.match(/^.+$/mg); |
| | 80 | for(var i = 0; i < smileylist.length; i++) |
| | 81 | { |
| | 82 | smileys[smileys.length] = { title: smileylist[i], src: smileyURL + encodeURIComponent(smileylist[i]) }; |
| | 83 | } |
| | 84 | this.editor.config.InsertSmiley.smileys = smileys; |
| | 85 | } |
| | 86 | |
| | 87 | |
| | 88 | this.loadAssets(); |
| 40 | | Xinha.Config.prototype.InsertSmiley= { |
| 41 | | smileyURL : "http://www.x-webservice.net/storage/xinha/plugins/InsertSmiley/" |
| | 94 | |
| | 95 | /** Load the dialog and js files. |
| | 96 | * |
| | 97 | */ |
| | 98 | |
| | 99 | InsertSmiley.prototype.loadAssets = function() |
| | 100 | { |
| | 101 | var self = this; |
| | 102 | if (self.loading) return; |
| | 103 | |
| | 104 | if(typeof this.editor.config.InsertSmiley.smileys != 'string') |
| | 105 | { |
| | 106 | // Must be a smiley definition itself |
| | 107 | this.smileys = this.editor.config.InsertSmiley.smileys; |
| | 108 | this.smiley_base = _editor_url; // Doesn't make a lot of sense, we assume the smileys will have absolute paths anyway |
| | 109 | } |
| | 110 | else |
| | 111 | { |
| | 112 | var smileys_def = |
| | 113 | this.editor.config.InsertSmiley.smileys |
| | 114 | ? this.editor.config.InsertSmiley.smileys // URL to the smileys.js file, or somethign that creates it |
| | 115 | : (Xinha.getPluginDir("InsertSmiley") + '/smileys/smileys.js'); // our own default one |
| | 116 | |
| | 117 | Xinha._getback( |
| | 118 | smileys_def, |
| | 119 | function(sm) { self.smileys = eval(sm); self.smileys_base = smileys_def.replace(/\/[^\/]+(\?.*)?$/, '/'); } |
| | 120 | ); |
| | 121 | } |
| | 122 | |
| | 123 | Xinha._getback( Xinha.getPluginDir("InsertSmiley") + '/dialog.html', function(html) { self.makeDialog(html); } ); |
| | 124 | } |
| | 125 | |
| | 126 | /** Make the dialog |
| | 127 | * |
| | 128 | * @note It is really important that this happens throuh the onGenerateOnce event |
| | 129 | * (in this case it goes onGenerateOnce -> loadAssets -> makeDialog) |
| | 130 | * because otherwise creating the dialog can fail in mysterious ways (silent |
| | 131 | * javascript exceptions in Gecko etc). |
| | 132 | */ |
| | 133 | |
| | 134 | InsertSmiley.prototype.makeDialog = function(html) |
| | 135 | { |
| | 136 | var self = this; |
| | 137 | |
| | 138 | // We can not make the dialog until the smileys are loaded, so wait a bit. |
| | 139 | if(!this.smileys) |
| | 140 | { |
| | 141 | window.setTimeout(function() { self.makeDialog(html); }, 1000); |
| | 142 | return; |
| | 143 | } |
| | 144 | |
| | 145 | var dialog = new Xinha.Dialog(this.editor, html, 'InsertSmiley', {width:155, height:100}, {modal:false}); |
| | 146 | |
| | 147 | var src; |
| | 148 | var s; |
| | 149 | var a; |
| | 150 | |
| | 151 | for(var i = 0; i < this.smileys.length; i++) |
| | 152 | { |
| | 153 | src = this.smileys[i].src.match(/^(([a-zA-Z]+:\/\/)|\/)/) ? |
| | 154 | this.smileys[i].src : this.smileys_base + this.smileys[i].src; |
| | 155 | s = document.createElement('img'); |
| | 156 | s.src = src; |
| | 157 | s.alt = dialog._lc(this.smileys[i].title); |
| | 158 | s.style.border = 'none'; |
| | 159 | |
| | 160 | a = document.createElement('a'); |
| | 161 | a.href= 'javascript:void(0);'; |
| | 162 | a.smiley_src = src; |
| | 163 | a.title = dialog._lc(this.smileys[i].title); |
| | 164 | |
| | 165 | // This is where we insert the smiley into the HTML |
| | 166 | Xinha.addDom0Event(a, 'click', function(ev) { self.editor.insertHTML('<img src="'+this.smiley_src+'" alt="'+this.title+'" />'); Xinha._stopEvent(window.event ? event : ev); return false; }); |
| | 167 | |
| | 168 | a.appendChild(s); |
| | 169 | dialog.getElementById('smileys').appendChild(a); |
| | 170 | |
| | 171 | a = null; s = null; src = null; |
| | 172 | } |
| | 173 | |
| | 174 | this.dialog = dialog; |
| | 175 | return true; |
| | 176 | } |
| | 177 | |
| | 178 | /** Show the dialog. |
| | 179 | */ |
| | 180 | |
| | 181 | InsertSmiley.prototype.buttonPress = function(editor) { |
| | 182 | if(this.dialog) |
| | 183 | { |
| | 184 | this.dialog.show(); |
| | 185 | } |
| | 186 | else |
| | 187 | { |
| | 188 | // Should put something here! |
| | 189 | } |
| | 190 | return; |