* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
*/
RedactorPlugins.wutil = {
+ /**
+ * Initializes the RedactorPlugins.wutil plugin.
+ */
+ init: function() {
+ // convert HTML to BBCode upon submit
+ this.$source.parents('form').submit($.proxy(this.submit, this));
+ },
+
/**
* Allows inserting of text contents in Redactor's source area.
*
replaceRangesWith: function(range) {
getSelection().removeAllRanges();
getSelection().addRange(range);
+ },
+
+ /**
+ * Returns text using BBCodes.
+ *
+ * @return string
+ */
+ getText: function() {
+ if (this.inWysiwygMode()) {
+ this.sync();
+
+ this._convertFromHtml();
+ }
+
+ return this.$source.val();
+ },
+
+ /**
+ * Converts HTML to BBCode upon submit.
+ */
+ submit: function() {
+ if (this.inWysiwygMode()) {
+ this.sync();
+
+ this._convertFromHtml();
+ }
}
};
});
/**
- * Provides previews for ckEditor message fields.
+ * Provides previews for Redactor message fields.
*
* @param string className
* @param string messageFieldID
* @return string
*/
_getMessage: function() {
- if (!$.browser.ckeditor) {
+ if (!$.browser.redactor) {
return this._messageField.val();
}
- else if (this._messageField.data('ckeditorInstance')) {
- var $ckEditor = this._messageField.ckeditorGet();
- return $ckEditor.getData();
+ else if (this._messageField.data('redactor')) {
+ return this._messageField.redactor('getText');
}
return null;