本文整理汇总了PHP中Y::asset方法的典型用法代码示例。如果您正苦于以下问题:PHP Y::asset方法的具体用法?PHP Y::asset怎么用?PHP Y::asset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Y
的用法示例。
在下文中一共展示了Y::asset方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: ascLink
public static function ascLink($text, $url, $urlParams = array(), $htmlOptions = array(), $pluginOptions = array())
{
if (isset($htmlOptions['id']))
$selector = '#'.$htmlOptions['id'];
elseif (isset($htmlOptions['class']))
$selector = '.'.$htmlOptions['class'];
else
throw new Exception('Параметр id обязателен, для ascLink');
$params = CJavaScript::encode($pluginOptions);
$folder = Y::asset('admin.assets');
Yii::app()->clientScript
->registerScriptFile($folder.'/js/cms/asc.js')
->registerScript('ascLink_'.$selector, "$('$selector').asc($params)");
return CHtml::link($text, self::url($url, $urlParams), $htmlOptions);
}
示例3: 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);
//.........这里部分代码省略.........