本文整理汇总了PHP中Y::clientScript方法的典型用法代码示例。如果您正苦于以下问题:PHP Y::clientScript方法的具体用法?PHP Y::clientScript怎么用?PHP Y::clientScript使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Y
的用法示例。
在下文中一共展示了Y::clientScript方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
public function init()
{
if(Y::isGuest())
$this->redirect(Admin::url('login'));
if(!Y::checkAccess('moderator'))
Y::end($this->render('accessDenied'));
parent::init();
$folder = Y::asset('admin.assets');
Y::clientScript()
->registerCoreScript('jquery')
->registerCoreScript('jquery.ui');
Y::clientScript()->ajaxExclude(array(
'jquery.js',
'jquery-ui.min.js',
'jquery-ui.css',
//treeview
'jquery.treeview.js',
'jquery.cookie.js',
'jquery.treeview.edit.js',
'jquery.treeview.async.js',
));
}
示例2: actionUpdate
public function actionUpdate($dir, $fileName)
{
if (isset($_POST['fileContent'])) {
FileSystem::write('./'.$dir.'/'.$fileName, $_POST['fileContent'], 'w');
Y::end();
}
$content = '';
$info = FileSystem::getInfo('./'.$dir.'/'.$fileName, array('name', 'ext'));
if (in_array($info['ext'], array('js', 'css'))) {
if (substr($dir, 0, 2) == 'js' || substr($dir, 0, 3) == 'css') {
$content = FileSystem::read('./'.$dir.'/'.$fileName);
}
}
$output = $this->renderPartial('fileDetails', array(
'fileName' => $fileName,
'content' => $content,
'type' => $info['ext'] == 'css' ? 'css' : 'javascript',
'filePath' => './'.$dir.'/'.$fileName
), true);
Y::tab('Содержимое файла', $output);
$output = Y::getTabs('cssFileForm', true);
Y::clientScript()->render($output);
echo CHtml::tag('div', array(), $output);
}
示例3: init
public function init()
{
parent::init();
$this->setImport(array(
'admin.models.*',
'admin.components.*',
));
Y::clientScript()->registerScriptFile($this->scriptPath.'/js/cms/asc.js');
}
示例4: registerScritps
public function registerScritps()
{
$options = empty($this->options) ? '' : CJavaScript::encode($this->options);
Y::clientScript()
->registerScript($this->getId().'-form-submit', "
$(document).ready(function(){
$('#{$this->getId()}').tabs({$options});
});
")
->registerScriptFile('');
}
示例5: ajaxExclude
public function ajaxExclude($names)
{
if (Y::isAjaxRequest()) {
$files = array();
foreach ((array)$names as $name)
$files[$name] = false;
Y::clientScript()->scriptMap = CMap::mergeArray(
Y::clientScript()->scriptMap,
$files
);
}
}
示例6: init
public function init()
{
Y::clientScript()->
registerCoreScript('jquery')->
registerCssFile(Yii::app()->baseUrl.'/css/style.css');
if (Yii::app()->request->isAjaxRequest) {
Y::clientScript()->scriptMap = array(
'jquery.js' => false,
'style.css' => false,
);
}
parent::init();
}
示例7: init
public function init()
{
Y::clientScript()->registerScriptFile('/js/plugins/jquery.form.js');
$options = CJavaScript::encode($this->options);
Y::clientScript()->registerScript('save-button', "
$(document).ready(function() {
//form submit
$('#$this->id').closest('form').bind('submit', function(e) {
e.preventDefault(); // <-- important
$(this).ajaxSubmit($options);
});
});
");
parent::init();
}
示例8: run
public function run()
{
$id=$this->getId();
if (isset($this->htmlOptions['id']))
$id = $this->htmlOptions['id'];
else
$this->htmlOptions['id']=$id;
echo CHtml::openTag($this->tagName,$this->htmlOptions)."\n";
$tabsOut = "";
$contentOut = "";
$tabCount = 0;
foreach($this->tabs as $title=>$content)
{
$tabId = (is_array($content) && isset($content['id']))?$content['id']:$id.'_tab_'.$tabCount++;
if (!is_array($content))
{
$tabsOut .= strtr($this->headerTemplate, array('{title}'=>$title, '{url}'=>'#'.$tabId, '{id}'=>'#' . $tabId))."\n";
$contentOut .= strtr($this->contentTemplate, array('{content}'=>$content,'{id}'=>$tabId))."\n";
}
elseif (isset($content['ajax']))
{
$tabsOut .= strtr($this->headerTemplate, array('{title}'=>$title, '{url}'=>CHtml::normalizeUrl($content['ajax']), '{id}'=>'#' . $tabId))."\n";
}
else
{
$tabsOut .= strtr($this->headerTemplate, array('{title}'=>$title, '{url}'=>'#'.$tabId))."\n";
if(isset($content['content']))
$contentOut .= strtr($this->contentTemplate, array('{content}'=>$content['content'],'{id}'=>$tabId))."\n";
}
}
echo "<ul>\n" . $tabsOut . "</ul>\n";
echo $contentOut;
echo CHtml::closeTag($this->tagName)."\n";
$options=empty($this->options) ? '' : CJavaScript::encode($this->options);
Y::clientScript()->registerScript($id.'-form-submit', "
$(document).ready(function(){
$('#{$id}').tabs({$options});
});
");
}
示例9: registerScripts
public function registerScripts()
{
$id = $this->grid->id;
$url = Y::curUrl();
$js =<<< EOM
$('#$id').delegate('.checkbox-column input', 'change', function() {
$.get(
'$url',
{
model_id:$(this).val(),
published:true,
val:$(this).is(':checked')
}
);
});
EOM;
Y::clientScript()->registerScript(__CLASS__.'#'.$this->id, $js);
}
示例10: registerScripts
public function registerScripts()
{
$id = $this->grid->id;
$class = $this->htmlOptions["class"];
$url = Y::curUrl();
$js =<<< EOM
$('#$id').delegate('.$class div', 'click', function() {
$(this).toggleClass('yes');
$.get(
'$url',
{
model_id : parseInt($(this).attr('id').replace(/published-button-/ig, "")),
published : true,
val : $(this).attr('class') == "yes" ? true : false
}
);
return false;
});
EOM;
Y::clientScript()->registerScript(__CLASS__.'#'.$this->id, $js);
}
示例11: run
public function run()
{
if (!in_array($this->type, array('text/html', 'css', 'javascript', 'xml'))) {
throw new CException("type принемает значения: 'text/html', 'css', 'javascript', 'xml'");
}
if ($this->content === null) {
if (!($this->id && $this->form && $this->model && $this->attr))
throw new CException("Обязательные поля для CodeMirror: id, form, model, attr");
}
$folder = Y::asset('admin.assets');
Y::clientScript()
->registerScriptFile($folder.'/js/CodeMirror/lib/codemirror.js')
->registerCssFile($folder.'/js/CodeMirror/lib/codemirror.css')
->registerCssFile($folder.'/js/CodeMirror/theme/default.css')
->registerScriptFile($folder.'/js/CodeMirror/mode/javascript/javascript.js')
->registerCssFile($folder.'/js/CodeMirror/mode/javascript/javascript.css')
->registerScriptFile($folder.'/js/CodeMirror/mode/css/css.js')
->registerCssFile($folder.'/js/CodeMirror/mode/css/css.css')
->registerScriptFile($folder.'/js/CodeMirror/mode/xml/xml.js')
->registerCssFile($folder.'/js/CodeMirror/mode/xml/xml.css')
->registerScriptFile($folder.'/js/CodeMirror/mode/htmlmixed/htmlmixed.js')
->registerScriptFile($folder.'/js/CodeMirror/lib/overlay.js')
->registerScript('autocomplete_'.$this->id, '
$(document).ready(function() {
// autocomplite
function stopEvent() {
if (this.preventDefault) {this.preventDefault(); this.stopPropagation();}
else {this.returnValue = false; this.cancelBubble = true;}
}
function addStop(event) {
if (!event.stop) event.stop = stopEvent;
return event;
}
function connect(node, type, handler) {
function wrapHandler(event) {handler(addStop(event || window.event));}
if (typeof node.addEventListener == "function")
node.addEventListener(type, wrapHandler, false);
else
node.attachEvent("on" + type, wrapHandler);
}
function forEach(arr, f) {
for (var i = 0, e = arr.length; i < e; ++i) f(arr[i]);
}
var startComplete = function () {
// We want a single cursor position.
if ('.$this->id.'_CM_editor.somethingSelected()) return;
// Find the token at the cursor
var cur = '.$this->id.'_CM_editor.getCursor(false), token = '.$this->id.'_CM_editor.getTokenAt(cur), tprop = token;
if (!/^[\w$_]*$/.test(token.string)) {
token = tprop = {start: cur.ch, end: cur.ch, string: "", state: token.state,
className: token.string == "." ? "js-property" : null};
}
// If it is a property, find out what it is a property of.
while (tprop.className == "js-property") {
tprop = '.$this->id.'_CM_editor.getTokenAt({line: cur.line, ch: tprop.start});
if (tprop.string != ".") return;
tprop = '.$this->id.'_CM_editor.getTokenAt({line: cur.line, ch: tprop.start});
if (!context) var context = [];
context.push(tprop);
}
var completions = getCompletions(token, context);
if (!completions.length) return;
function insert(str) {
'.$this->id.'_CM_editor.replaceRange(str, {line: cur.line, ch: token.start}, {line: cur.line, ch: token.end});
}
// When there is only one completion, use it directly.
if (completions.length == 2) {insert(completions[0]); return true;}
// Build the select widget
var complete = document.createElement("div");
complete.className = "completions";
var sel = complete.appendChild(document.createElement("select"));
sel.multiple = true;
for (var i = 0; i < completions.length; ++i) {
var opt = sel.appendChild(document.createElement("option"));
opt.appendChild(document.createTextNode(completions[i]));
}
sel.firstChild.selected = true;
sel.size = Math.min(10, completions.length);
var pos = '.$this->id.'_CM_editor.cursorCoords();
complete.style.left = pos.x + "px";
complete.style.top = pos.yBot + "px";
document.body.appendChild(complete);
// Hack to hide the scrollbar.
if (completions.length <= 10)
complete.style.width = (sel.clientWidth - 2) + "px";
var done = false;
function close() {
if (done) return;
done = true;
complete.parentNode.removeChild(complete);
}
function pick() {
insert(sel.options[sel.selectedIndex].value);
close();
setTimeout(function(){'.$this->id.'_CM_editor.focus();}, 50);
//.........这里部分代码省略.........
示例12: registerScript
/**
* Register Script
*/
public function registerScript() {
$basePath=Yii::getPathOfAlias('application.modules.users.views.asset');
$baseUrl=Yii::app()->getAssetManager()->publish($basePath);
$cs = Y::clientScript()->registerCoreScript('jquery')
->registerCssFile($baseUrl.'/css/redmond/jquery-ui.css')
->registerCssFile($baseUrl.'/css/style.css')
->registerScriptFile($baseUrl.'/js/jquery-ui.min.js')
->registerScriptFile($baseUrl.'/js/form.js')
->registerScriptFile($baseUrl.'/js/jquery.json.js');
$widgets = self::getWidgets();
$wgByTypes = ProfileField::itemAlias('field_type');
foreach ($wgByTypes as $k=>$v) {
$wgByTypes[$k] = array();
}
foreach ($widgets[1] as $widget) {
if (isset($widget['fieldType'])&&count($widget['fieldType'])) {
foreach($widget['fieldType'] as $type) {
array_push($wgByTypes[$type],$widget['name']);
}
}
}
//echo '<pre>'; print_r($components[2]); die();
$js = "
var name = $('#name'),
value = $('#value'),
allFields = $([]).add(name).add(value),
tips = $('.validateTips');
var listWidgets = jQuery.parseJSON('".str_replace("'","\'",CJavaScript::jsonEncode($widgets[0]))."');
var components = jQuery.parseJSON('".str_replace("'","\'",CJavaScript::jsonEncode($widgets[1]))."');
var wgByType = jQuery.parseJSON('".str_replace("'","\'",CJavaScript::jsonEncode($wgByTypes))."');
var fieldType = {
'INTEGER':{
'hide':['match','other_validator','widgetparams'],
'val':{
'field_size':10,
'default':'0',
'range':'',
'widgetparams':''
}
},
'VARCHAR':{
'hide':['widgetparams'],
'val':{
'field_size':255,
'default':'',
'range':'',
'widgetparams':''
}
},
'TEXT':{
'hide':['field_size','range','widgetparams'],
'val':{
'field_size':0,
'default':'',
'range':'',
'widgetparams':''
}
},
'DATE':{
'hide':['field_size','field_size_min','match','range','widgetparams'],
'val':{
'field_size':0,
'default':'0000-00-00',
'range':'',
'widgetparams':''
}
},
'FLOAT':{
'hide':['match','other_validator','widgetparams'],
'val':{
'field_size':'10,2',
'default':'0.00',
'range':'',
'widgetparams':''
}
},
'BOOL':{
'hide':['field_size','field_size_min','match','widgetparams'],
'val':{
'field_size':0,
'default':0,
'range':'2==".Users::t('Yes').";0==".Users::t('No')."',
'widgetparams':''
}
},
'BLOB':{
'hide':['field_size','field_size_min','match','widgetparams'],
'val':{
'field_size':0,
'default':'',
'range':'',
//.........这里部分代码省略.........
示例13: run
/**
* Runs the widget.
* This registers the necessary javascript code and renders the form close tag.
*/
public function run()
{
echo CHtml::endForm();
if(!$this->enableAjaxValidation || empty($this->_attributes))
return;
$options=$this->clientOptions;
if(isset($this->clientOptions['validationUrl']) && is_array($this->clientOptions['validationUrl']))
$options['validationUrl']=CHtml::normalizeUrl($this->clientOptions['validationUrl']);
$options['attributes']=array();
foreach ($this->_attributes as $attr=>$item) {
if (in_array($attr,$this->disableAjaxValidationAttributes)===false) {
array_push($options['attributes'],$item);
}
}
if($this->_summary!==null)
$options['summaryID']=$this->_summary;
$options=CJavaScript::encode($options);
Y::clientScript()->registerCoreScript('yiiactiveform');
$id=$this->id;
Y::clientScript()->registerScript(__CLASS__.'#'.$id,"\$('#$id').yiiactiveform($options);");
}
示例14: renderTableFooter
public function renderTableFooter()
{
Y::clientScript()->registerScript("pageSize","
$('#".$this->getId()."').delegate('.pageSizer','change',function() {
$.fn.yiiGridView.update('".$this->getId()."',{data:{pageSize: $(this).val()}});
});
");
$options['pageSize'] = CHtml::dropDownList('pageSize', $this->dataProvider->pagination->pageSize, array(10=>10, 25=>25, 50=>50, 100=>100, 500=>500, 1000=>1000), array('class'=>'pageSizer'));
echo "<tfoot>\n";
echo "<tr>\n";
echo "<td>\n";
foreach ($options as $item)
echo $item;
echo "</td>\n";
echo "</tr>\n";
echo "</tfoot>\n";
}