HEX
Server: Apache
System: Linux msm5694.mjhst.com 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
User: camjab_ssh (1000)
PHP: 5.3.29
Disabled: NONE
Upload Files
File: /home/httpd/html/camrub.com/public_html/includes/trumbowyg/plugins/ruby/trumbowyg.ruby.js
/* ===========================================================
 * trumbowyg.ruby.js v1.0
 * Ruby text plugin for Trumbowyg
 * http://alex-d.github.com/Trumbowyg
 * ===========================================================
 * Author	: Fathi Anshory (0x00000F5C)
 * Twitter	: @fscchannl
 * Comment	: Since I use trumbowyg in my project and required it to insert ruby text, so I thought I can contribute a little. :D
 */

(function($) {
	'use strict';

	$.extend(true, $.trumbowyg, {
		langs: {
			en: {
				ruby: 'Add ruby text',
				rubyModal: 'Ruby modal',
				rubyText: 'Ruby text'
			},
			id: {
				ruby: 'Sisipkan teks ruby',
				rubyModal: 'Modal teks ruby',
				rubyText: 'Teks ruby'
			}
		},
		plugins: {
			ruby: {
				init: function(trumbowyg) {
					var btnDef = {
						fn: function() {
							trumbowyg.saveRange();
							trumbowyg.openModalInsert(
								trumbowyg.lang.ruby,
								{
									rubyText: {
										label: trumbowyg.lang.rubyText,
										required: false,
									},
									modal: {
										label: trumbowyg.lang.rubyModal,
										value: trumbowyg.getRangeText(),
										required: true
									}
								}, 
								function(v) {
									var node = $('<ruby title="' + v.rubyText + '">' + v.modal + '<rp> (</rp><rt>' + v.rubyText + '</rt><rp>)</rp></ruby>')[0];
									trumbowyg.range.deleteContents();
									trumbowyg.range.insertNode(node);
                                    trumbowyg.syncCode();
                                    trumbowyg.$c.trigger('tbwchange');
									return true;
								}
							);
						}
					};
					trumbowyg.addBtnDef('ruby', btnDef);
				}
			}
		}
	});
})(jQuery);