Joomla 2.5 内置控件
表单相关脚本
要使用joomla内置表单脚本有几个前提条件
- form名应该默认是adminForm
- form内必须有boxchecked,task这些hidden element
Joomla.isChecked(this.checked);
用于list中的checkbox,加到每个checkbox的onclick上
Joomla.submitbutton(task, form="adminForm");
提交表单到指定的task
Mootools
加载方法: JHtml::_('behavior.framework', true);
功能说明: mootools有core与more两部分,more包含很多额外的插件,如果需要使用,第二个参数需要为true。
tooltip(提示信息)
加载方法: JHtml::_('behavior.tooltip');
使用例子: <label title="Name::Enter the name of the user" class="hasTip">Name</label>
validation(表单验证)
加载方法: JHtml::_('behavior.formvalidation');
使用例子:
<form class="form-validate">
<input type="text" class="validate-username inputbox required" value="" name="jform[username]">
<button type="submit" class="validate"><?php echo JText::_('JREGISTER');?></button>
</form>
功能说明: 基本的客户端验证,验证失败时只会高亮无效的field,功能非常简单。
switcher
加载方法: JHtml::_('behavior.switcher');
功能说明: Add unobtrusive javascript support for submenu switcher support in Global Configuration and System Information.
JHtml::_('behavior.combobox');
keepalive
加载方法: JHtml::_('behavior.keepalive');
功能说明: 定时读取页面,用于保持登录状态
lightbox(弹出窗效果)
加载方法: JHtml::_('behavior.modal');
使用例子: <a rel="{handler: 'iframe', size: {x: 875, y: 550}}" href="/index.php" class="modal">
...
</a>flash upload (不推荐)
使用例子:
<?php
$doc = JFactory::getDocument();
$doc->addStyleSheet(JURI::root().'/media/media/css/mediamanager.css');
JHtml::_('behavior.uploader', 'upload-flash',
array(
'onBeforeStart' => 'function(){}',
'onComplete' => 'function(){}',
'targetURL' => JURI::base().'index.php?option=com_media&task=file.upload&tmpl=component&'.JSession::getFormToken().'=1&folder=phocadownload',
'fileSizeMax' => 1024 * 1024,
'typeFilter' => '{All: "*.*"}'
)
);
?>
<fieldset id="upload-noflash" class="actions">
<label for="upload-file" class="hidelabeltxt"><?php echo JText::_('COM_MEDIA_UPLOAD_FILE'); ?></label>
<input type="file" id="upload-file" name="Filedata" />
<label for="upload-submit" class="hidelabeltxt"><?php echo JText::_('COM_MEDIA_START_UPLOAD'); ?></label>
<input type="submit" id="upload-submit" value="<?php echo JText::_('COM_MEDIA_START_UPLOAD'); ?>"/>
</fieldset>
<div id="upload-flash" class="hide">
<button id="upload-browse">Browse files</button>
<button id="upload-clear">Clear List</button>
<button id="upload-start">Start Upload</button>
<div class="clr"> </div>
<p class="overall-title"></p>
<?php echo JHtml::_('image', 'media/bar.gif', JText::_('COM_MEDIA_OVERALL_PROGRESS'), array('class' => 'progress overall-progress'), true); ?>
<div class="clr"> </div>
<p class="current-title"></p>
<?php echo JHtml::_('image', 'media/bar.gif', JText::_('COM_MEDIA_CURRENT_PROGRESS'), array('class' => 'progress current-progress'), true); ?>
<p class="current-text"></p>
</div>
<ul class="upload-queue" id="upload-queue">
<li style="display:none;"></li>
</ul>
calendar(日历输入栏)
使用例子: JHTML::_('calendar', '2012-01-01', 'date', 'date', '%Y-%m-%d', array('class'=>'short', 'size'=>'25', 'maxlength'=>'19'));
higlight(单词高亮)
使用例子: highlighter(array $terms, $start = 'highlighter-start', $end = 'highlighter-end', $className = 'highlight', $tag = 'span')
功能说明: Highlight some words via Javascript.
在线编辑器
使用例子:
$editor = & JFactory::getEditor();
$editor->display(<post name>, <data>, '100%;', '350', '75', '20', array('pagebreak'));
获取内容代码:
WFEditor.getContent('jform_description');
AJAX时由于没有激活onsubmit,所以需要手动把editor内容放到input上:
function editorAllSave() {
if (typeof tinymce == "object") {
tinymce.editors.each(function (item, index) {
item.save();
});
}
}sliders
功能说明:dropdown tab效果,用于整理并归类param list,一般用于后台
使用例子:
<?php echo JHtml::_('sliders.start', 'item-slider'); ?>
<?php
$fieldSets = $this->form->getFieldsets('params');
foreach ($fieldSets as $name => $fieldSet) :
echo JHtml::_('sliders.panel',JText::_($fieldSet->label), $name.'-params');
if (isset($fieldSet->description) && trim($fieldSet->description)) :
echo '<p class="tip">'.$this->escape(JText::_($fieldSet->description)).'</p>';
endif;
?>
<fieldset class="panelform" >
<ul class="adminformlist">
<?php foreach ($this->form->getFieldset($name) as $field) : ?>
<li><?php echo $field->label; ?>
<?php echo $field->input; ?></li>
<?php endforeach; ?>
</ul>
</fieldset>
<?php endforeach; ?>
<?php echo JHtml::_('sliders.end'); ?>