-
-
Save Burick/080f406858a6029ddc8f86af1fec3894 to your computer and use it in GitHub Desktop.
MODX Rich Introtext w/ Toggle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
** richIntro | |
** Plugin checks if introtext is filled in yet, and hides it if not. Run 'onDocFormRender' | |
** http://g.recordit.co/VOYqBC3CnS.gif | |
*/ | |
$introtext = empty($resource->get('introtext')); | |
if($introtext){ | |
$modx->regClientStartupHTMLBlock('<script>Ext.onReady(function() { | |
var introtext = Ext.getCmp("modx-resource-introtext"); | |
introtext.hide();}); | |
</script>'); | |
}else{ | |
$modx->regClientStartupHTMLBlock('<script>Ext.onReady(function() { | |
if(MODx.loadRTE) MODx.loadRTE("modx-resource-introtext"); | |
});</script>'); | |
} | |
$modx->regClientStartupHTMLBlock('<style type="text/css">#x-form-el-modx-resource-introtext{width: 100%; overflow:hidden;}</style>'); | |
$modx->regClientStartupHTMLBlock('<script>Ext.onReady(function() { | |
var group = Ext.getCmp("modx-resource-main-right"); | |
var checkbox = new Ext.form.Checkbox({boxLabel:"Hide Introtext", id:"hide-introtext", hideLabel:true, checked: '.($introtext ? 'true':'false').', listeners:{ | |
\'check\': function(t,n,o){ | |
var introtext = Ext.getCmp("modx-resource-introtext"); | |
if(n){ | |
introtext.setValue(""); | |
introtext.hide(); | |
if(MODx.unloadRTE) MODx.unloadRTE("modx-resource-introtext"); | |
}else{ | |
introtext.show(); | |
if(MODx.loadRTE) MODx.loadRTE("modx-resource-introtext"); | |
} | |
} | |
} | |
}); | |
group.items.add(checkbox); | |
}); | |
</script>'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment