Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add Richtext option, closes josht/faqMan#3, update UI a tad, make sur…

…e windows are actually deleted and loaded again (needed for TinyMCE integration).
  • Loading branch information...
commit 9475d86d68555d326e1bb8bc9e168c5ac75eac26 1 parent 4b11cbe
@Mark-H authored
View
70 assets/components/faqman/js/mgr/widgets/items.grid.js
@@ -72,18 +72,15 @@ faqMan.grid.Items = function(config) {
text: _('faqman.item_create')
,handler: this.createItem
,scope: this
- }
- ,{
+ },'-',{
pressed: true
,enableToggle:true
- ,text: _('faqman.answers')
+ ,text: _('faqman.toggle_answers')
,scope:this
,toggleHandler: function(btn, pressed) {
this.togglePreview(pressed);
}
- }
- ,'->'
- ,{
+ },'->',{
xtype: 'textfield'
,name: 'search'
,id: 'faqman-tf-search'
@@ -101,7 +98,7 @@ faqMan.grid.Items = function(config) {
});
},scope:this}
}
- },{
+ },'-',{
xtype: 'button'
,id: 'modx-filter-clear'
,text: _('filter_clear')
@@ -161,7 +158,6 @@ Ext.extend(faqMan.grid.Items,MODx.grid.Grid,{
return true;
}
,togglePreview: function(show) {
- console.log(this);
this.config.viewConfig.showPreview = show;
this.refresh();
}
@@ -183,32 +179,26 @@ Ext.extend(faqMan.grid.Items,MODx.grid.Grid,{
if (!this.config || !this.config.setid) return false;
var s = this.config.setid;
- if (!this.windows.createItem) {
- this.windows.createItem = MODx.load({
- xtype: 'faqman-window-item-create'
- ,set: s
- ,listeners: {
- 'success': {fn:function() {this.refresh();},scope:this}
- }
- });
- }
- this.windows.createItem.fp.getForm().reset();
+ this.windows.createItem = MODx.load({
+ xtype: 'faqman-window-item-create'
+ ,set: s
+ ,listeners: {
+ 'success': {fn:function() {this.refresh();},scope:this}
+ }
+ });
this.windows.createItem.show(e.target);
}
,updateItem: function(btn,e) {
if (!this.menu.record || !this.menu.record.id) return false;
var r = this.menu.record;
- if (!this.windows.updateItem) {
- this.windows.updateItem = MODx.load({
- xtype: 'faqman-window-item-update'
- ,record: r
- ,listeners: {
- 'success': {fn:function() {this.refresh();},scope:this}
- }
- });
- }
- this.windows.updateItem.fp.getForm().reset();
+ this.windows.updateItem = MODx.load({
+ xtype: 'faqman-window-item-update'
+ ,record: r
+ ,listeners: {
+ 'success': {fn:function() {this.refresh();},scope:this}
+ }
+ });
this.windows.updateItem.fp.getForm().setValues(r);
this.windows.updateItem.show(e.target);
}
@@ -246,9 +236,10 @@ faqMan.window.CreateItem = function(config) {
Ext.applyIf(config,{
title: _('faqman.item_create')
,id: this.ident
- ,height: 150
- ,width: 475
+ ,autoHeight: true
+ ,width: 600
,url: faqMan.config.connector_url
+ ,closeAction: 'close'
,baseParams: {
action: 'mgr/item/create'
,set: config.set
@@ -258,16 +249,19 @@ faqMan.window.CreateItem = function(config) {
,fieldLabel: _('faqman.question')
,name: 'question'
,id: 'faqman-'+this.ident+'-question'
- ,width: 300
+ ,width: '94%'
},{
xtype: 'textarea'
,fieldLabel: _('faqman.answer')
,name: 'answer'
,id: 'faqman-'+this.ident+'-answer'
- ,width: 300
+ ,width: '94%'
}]
});
faqMan.window.CreateItem.superclass.constructor.call(this,config);
+ this.on('activate',function() {
+ if (typeof Tiny != 'undefined') { MODx.loadRTE('faqman-'+this.ident+'-answer'); }
+ });
};
Ext.extend(faqMan.window.CreateItem,MODx.Window);
Ext.reg('faqman-window-item-create',faqMan.window.CreateItem);
@@ -279,10 +273,11 @@ faqMan.window.UpdateItem = function(config) {
Ext.applyIf(config,{
title: _('faqman.item_update')
,id: this.ident
- ,height: 150
- ,width: 475
+ ,autoHeight: true
+ ,width: 600
,url: faqMan.config.connector_url
,action: 'mgr/item/update'
+ ,closeAction: 'close'
,fields: [{
xtype: 'hidden'
,name: 'id'
@@ -292,16 +287,19 @@ faqMan.window.UpdateItem = function(config) {
,fieldLabel: _('faqman.question')
,name: 'question'
,id: 'faqman-'+this.ident+'-question'
- ,width: 300
+ ,width: '94%'
},{
xtype: 'textarea'
,fieldLabel: _('faqman.answer')
,name: 'answer'
,id: 'faqman-'+this.ident+'-answer'
- ,width: 300
+ ,width: '94%'
}]
});
faqMan.window.UpdateItem.superclass.constructor.call(this,config);
+ this.on('activate',function() {
+ if (typeof Tiny != 'undefined') { MODx.loadRTE('faqman-'+this.ident+'-answer'); }
+ });
};
Ext.extend(faqMan.window.UpdateItem,MODx.Window);
Ext.reg('faqman-window-item-update',faqMan.window.UpdateItem);
View
4 core/components/faqman/controllers/index.php
@@ -24,5 +24,5 @@
* @subpackage controllers
*/
require_once dirname(dirname(__FILE__)).'/model/faqman/faqman.class.php';
-$faqman = new faqMan($modx);
-return $faqman->initialize('mgr');
+$faqMan = new faqMan($modx);
+return $faqMan->initialize('mgr');
View
41 core/components/faqman/controllers/mgr/set.php
@@ -30,4 +30,45 @@
$modx->regClientStartupScript($faqMan->config['jsUrl'].'mgr/sections/set.js');
$output = '<div id="faqman-panel-set-div"></div>';
+/* If we want to use Tiny, we'll need some extra files. */
+$useTiny = $modx->getOption('faqman.use_richtext',$faqMan->config,false);
+if ($useTiny) {
+ $tinyCorePath = $modx->getOption('tiny.core_path',null,$modx->getOption('core_path').'components/tinymce/');
+ /* Make sure Tiny is installed by checking the core class file */
+ if (file_exists($tinyCorePath.'tinymce.class.php')) {
+
+ /* First fetch the faqman+tiny specific settings */
+ $cb1 = $modx->getOption('faqman.tiny.buttons1',null,'undo,redo,selectall,pastetext,pasteword,charmap,separator,image,modxlink,unlink,media,separator,code,help');
+ $cb2 = $modx->getOption('faqman.tiny.buttons2',null,'bold,italic,underline,strikethrough,sub,sup,separator,bullist,numlist,outdent,indent,separator,justifyleft,justifycenter,justifyright,justifyfull');
+ $cb3 = $modx->getOption('faqman.tiny.buttons3',null,'styleselect,formatselect,separator,styleprops');
+ $cb4 = $modx->getOption('faqman.tiny.buttons4',null,'');
+ $cb5 = $modx->getOption('faqman.tiny.buttons5',null,'');
+ $plugins = $modx->getOption('faqman.tiny.custom_plugins',null,'');
+ $theme = $modx->getOption('faqman.tiny.theme',null,'');
+ $bfs = $modx->getOption('faqman.tiny.theme_advanced_blockformats',null,'');
+ $css = $modx->getOption('faqman.tiny.theme_advanced_css_selectors',null,'');
+
+ /* If the settings are empty, override them with the generic tinymce settings. */
+ $tinyProperties = array(
+ 'height' => $modx->getOption('faqman.tiny.height',null,200),
+ 'width' => $modx->getOption('faqman.tiny.width',null,'95%'),
+ 'tiny.custom_buttons1' => (!empty($cb1)) ? $cb1 : $modx->getOption('tiny.custom_buttons1',null,'undo,redo,selectall,separator,pastetext,pasteword,separator,search,replace,separator,nonbreaking,hr,charmap,separator,image,modxlink,unlink,anchor,media,separator,cleanup,removeformat,separator,fullscreen,print,code,help'),
+ 'tiny.custom_buttons2' => (!empty($cb2)) ? $cb2 : $modx->getOption('tiny.custom_buttons2',null,'bold,italic,underline,strikethrough,sub,sup,separator,bullist,numlist,outdent,indent,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,styleselect,formatselect,separator,styleprops'),
+ 'tiny.custom_buttons3' => (!empty($cb3)) ? $cb3 : $modx->getOption('tiny.custom_buttons3',null,''),
+ 'tiny.custom_buttons4' => (!empty($cb4)) ? $cb4 : $modx->getOption('tiny.custom_buttons4',null,''),
+ 'tiny.custom_buttons5' => (!empty($cb5)) ? $cb5 : $modx->getOption('tiny.custom_buttons5',null,''),
+ 'tiny.custom_plugins' => (!empty($plugins)) ? $plugins : $modx->getOption('tiny.custom_plugins',null,'style,advimage,advlink,modxlink,searchreplace,print,contextmenu,paste,fullscreen,noneditable,nonbreaking,xhtmlxtras,visualchars,media'),
+ 'tiny.editor_theme' => (!empty($theme)) ? $theme : $modx->getOption('tiny.editor_theme',null,'cirkuit'),
+ 'tiny.skin_variant' => $modx->getOption('tiny.skin_variant',null,''),
+ 'tiny.theme_advanced_blockformats' => (!empty($bfs)) ? $bfs : $modx->getOption('tiny.theme_advanced_blockformats',null,'p,h1,h2,h3,h4,h5,h6,div,blockquote,code,pre,address'),
+ 'tiny.css_selectors' => (!empty($css)) ? $css : $modx->getOption('tiny.css_selectors',null,''),
+ );
+ require_once $tinyCorePath.'tinymce.class.php';
+ $tiny = new TinyMCE($modx,$tinyProperties);
+ $tiny->setProperties($tinyProperties);
+ $html = $tiny->initialize();
+ $modx->regClientHTMLBlock($html);
+ }
+}
+
return $output;
View
2  core/components/faqman/lexicon/de/default.inc.php
@@ -59,4 +59,4 @@
$_lang['faqman.question'] = 'Frage';
$_lang['faqman.answer'] = 'Antwort';
-$_lang['faqman.answers'] = 'Antwort';
+$_lang['faqman.toggle_answers'] = 'Antwortvorschau ein- / ausblenden';
View
2  core/components/faqman/lexicon/en/default.inc.php
@@ -58,4 +58,4 @@
$_lang['faqman.question'] = 'Question';
$_lang['faqman.answer'] = 'Answer';
-$_lang['faqman.answers'] = 'Answers';
+$_lang['faqman.toggle_answers'] = 'Toggle Answer Previews';
Please sign in to comment.
Something went wrong with that request. Please try again.