/** * Publishes and registers the necessary script files. */ protected function registerClientScript() { $assets = Booster::getBooster()->cs; $assets->registerPackage('highcharts'); $baseUrl = $assets->packages['highcharts']['baseUrl']; $this->options = CMap::mergeArray(array('exporting' => array('enabled' => true)), $this->options); if (isset($this->options['exporting']) && @$this->options['exporting']['enabled']) { $assets->registerScriptFile($baseUrl . '/modules/exporting.js'); } if (isset($this->options['theme'])) { $assets->registerScriptFile($baseUrl . '/themes/' . $this->options['theme'] . '.js'); } $options = CJavaScript::encode($this->options); $assets->registerScript(__CLASS__ . '#' . $this->getId(), "var highchart{$this->getId()} = new Highcharts.Chart({$options});"); }
/** *### .init() * * Initializes the widget. */ public function init() { parent::init(); $booster = Booster::getBooster(); $popover = $booster->popoverSelector; $tooltip = $booster->tooltipSelector; $afterAjaxUpdate = "js:function() {\n\t\t\tjQuery('.popover').remove();\n\t\t\tjQuery('{$popover}').popover();\n\t\t\tjQuery('.tooltip').remove();\n\t\t\tjQuery('{$tooltip}').tooltip();\n\t\t}"; if (!isset($this->afterAjaxUpdate)) { $this->afterAjaxUpdate = $afterAjaxUpdate; } }
/** *### .init() * * Initializes the widget. */ public function init() { parent::init(); $classes = array('table'); if (isset($this->type)) { if (is_string($this->type)) { $this->type = explode(' ', $this->type); } if (!empty($this->type)) { $validTypes = array(self::TYPE_STRIPED, self::TYPE_BORDERED, self::TYPE_CONDENSED, self::TYPE_HOVER); foreach ($this->type as $type) { if (in_array($type, $validTypes)) { $classes[] = 'table-' . $type; } } } } if (!empty($classes)) { $classes = implode(' ', $classes); if (isset($this->itemsCssClass)) { $this->itemsCssClass .= ' ' . $classes; } else { $this->itemsCssClass = $classes; } } $booster = Booster::getBooster(); $popover = $booster->popoverSelector; $tooltip = $booster->tooltipSelector; $afterAjaxUpdate = "js:function() {\n\t\t\tjQuery('.popover').remove();\n\t\t\tjQuery('{$popover}').popover();\n\t\t\tjQuery('.tooltip').remove();\n\t\t\tjQuery('{$tooltip}').tooltip();\n\t\t}"; if (!isset($this->afterAjaxUpdate)) { $this->afterAjaxUpdate = $afterAjaxUpdate; } }
/** *### .renderHeaderCellContent() * * Renders the header cell content. * This method will render a link that can trigger the sorting if the column is sortable. */ protected function renderHeaderCellContent() { if ($this->grid->enableSorting && $this->sortable && $this->name !== null) { $sort = $this->grid->dataProvider->getSort(); $label = isset($this->header) ? $this->header : $sort->resolveLabel($this->name); $booster = Booster::getBooster(); if ($sort->resolveAttribute($this->name) !== false) { $label .= ' <span class="caret"></span>'; } /* { if($sort->getDirection($this->name) === CSort::SORT_ASC){ $label .= ' <span class="'.($booster->fontAwesomeCss ? 'fa fa-sort-asc' : 'icon-chevron-down').'"></span>'; } elseif($sort->getDirection($this->name) === CSort::SORT_DESC){ $label .= ' <span class="'.($booster->fontAwesomeCss ? 'fa fa-sort-desc' : 'icon-chevron-up').'"></span>'; } else { $label .= ' '; } } */ echo $sort->link($this->name, $label, array('class' => 'sort-link')); } else { if ($this->name !== null && $this->header === null) { if ($this->grid->dataProvider instanceof CActiveDataProvider) { echo CHtml::encode($this->grid->dataProvider->model->getAttributeLabel($this->name)); } else { echo CHtml::encode($this->name); } } else { parent::renderHeaderCellContent(); } } }
/** * Register required script files */ public function registerClientScript() { $booster = Booster::getBooster(); $booster->registerPackage('markdown'); $id = $this->htmlOptions['id']; $options = CJSON::encode($this->options); Yii::app()->clientScript->registerScript(__CLASS__ . '#' . $id, "\n\t\t\t\$('#{$id}').markdown({$options})\n\t\t\t", CClientScript::POS_END); }
/** *### .registerClientScript() * * Registers required client script for chosen. It is not used through bootstrap->registerPlugin * in order to attach events if any */ public function registerClientScript($id) { Booster::getBooster()->registerPackage('chosen'); $options = !empty($this->options) ? CJavaScript::encode($this->options) : ''; ob_start(); echo "\$('#{$id}').chosen({$options})"; Yii::app()->getClientScript()->registerScript(__CLASS__ . '#' . $this->getId(), ob_get_clean() . ';'); }
/** * Register required script files * * @param integer $id */ public function registerClientScript($id) { $booster = Booster::getBooster(); $booster->registerAssetCss('markdown.editor.css'); $booster->registerAssetJs('markdown.converter.js', CClientScript::POS_HEAD); $booster->registerAssetJs('markdown.sanitizer.js', CClientScript::POS_HEAD); $booster->registerAssetJs('markdown.editor.js', CClientScript::POS_HEAD); Yii::app()->clientScript->registerScript($id, "var converter = Markdown.getSanitizingConverter();\n\t\t\tvar editor = new Markdown.Editor(converter, '" . $id . "');\n\t\t\teditor.run();", CClientScript::POS_END); }
/** * */ public function init() { Booster::getBooster()->registerPackage('ui-layout'); if (!is_array($this->options)) { $this->options = array(); } if (!is_array($this->htmlOptions)) { $this->htmlOptions = array(); } }
/** *### .registerClientScript() * * Registers required * * @param string $id */ public function registerClientScript($id) { Booster::getBooster()->cs->registerPackage('colorpicker'); $options = !empty($this->format) ? CJavaScript::encode(array('format' => $this->format)) : ''; ob_start(); echo "jQuery('#{$id}').colorpicker({$options})"; foreach ($this->events as $event => $handler) { echo ".on('{$event}', " . CJavaScript::encode($handler) . ")"; } Yii::app()->getClientScript()->registerScript(__CLASS__ . '#' . $this->getId(), ob_get_clean() . ';'); }
/** * Registers required client script for bootstrap select2. It is not used through bootstrap->registerPlugin * in order to attach events if any * @param $id * @throws CException */ public function registerClientScript($id) { Booster::getBooster()->registerPackage('select2'); if (empty($this->options['language']) && empty($this->htmlOptions['lang'])) { $this->options['language'] = Yii::app()->language; } if (!empty($this->value) || $this->value === 0 || $this->value === '0') { if (is_array($this->value)) { $value = CJSON::encode($this->value); } else { $value = '"' . $this->value . '"'; } //trigger maybe removed $defValue = ".val({$value}).trigger('change')"; } else { $defValue = ''; } if ($this->disabled) { $defValue .= ".prop('disabled', true)"; } $options = CJavaScript::encode($this->options); ob_start(); echo "jQuery('select#{$id}').select2({$options});"; if (!empty($defValue)) { echo "jQuery('select#{$id}')" . $defValue . ';'; } if (count($this->events) > 0) { echo "jQuery('select#{$id}')"; foreach ($this->events as $event => $handler) { echo ".on('{$event}', " . CJavaScript::encode($handler) . ")"; } echo ';'; } if (!empty($this->initialData)) { $data = CJavaScript::encode($this->initialData); $js = <<<JS var data = {$data}; if(!\$.isArray(data)) { \tdata = [data]; } \$.each(data, function(index, value){ \tvar option = \$("<option selected></option>").val(value.id).data('data',value); \t\$('select#{$id}').append(option); }); \$('select#{$id}').trigger('change'); JS; echo $js; } Yii::app()->getClientScript()->registerScript(__CLASS__ . '#' . $this->getId(), ob_get_clean()); }
public function registerLanguageScript() { $booster = Booster::getBooster(); if (isset($this->options['language']) && $this->options['language'] != 'en') { $filename = '/bootstrap-datepicker/js/locales/bootstrap-datepicker.' . $this->options['language'] . '.js'; if (file_exists(Yii::getPathOfAlias('booster.assets') . $filename)) { if ($booster->enableCdn) { Yii::app()->clientScript->registerScriptFile('//cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.2.0/js/locales/bootstrap-datepicker.' . $this->options['language'] . '.js', CClientScript::POS_HEAD); } else { $booster->cs->registerScriptFile($booster->getAssetsUrl() . $filename, CClientScript::POS_HEAD); } } } }
/** * Registers required css and js files * * @param integer $id the id of the toggle button */ protected function registerClientScript($id) { $booster = Booster::getBooster(); $booster->registerPackage('switch'); $config = CJavaScript::encode($this->options); ob_start(); echo "\$('#{$id}').bootstrapSwitch({$config})"; foreach ($this->events as $event => $handler) { $event = $event . '.bootstrapSwitch'; if (!$handler instanceof CJavaScriptExpression && strpos($handler, 'js:') === 0) { $handler = new CJavaScriptExpression($handler); } echo ".on('{$event}', " . $handler . ")"; } Yii::app()->clientScript->registerScript(__CLASS__ . '#' . $this->getId(), ob_get_clean() . ';'); }
/** * Registers required * * @param integer $id */ public function registerClientScript($id) { $booster = Booster::getBooster(); $booster->registerAssetJs('bootstrap-modalmanager.js', CClientScript::POS_HEAD); $booster->registerAssetCss('bootstrap-modalmanager.css'); $options = !empty($this->format) ? CJavaScript::encode(array('format' => $this->format)) : ''; ob_start(); echo "jQuery('#{$id}').modalmanager({$options})"; foreach ($this->events as $event => $handler) { echo ".on('{$event}', " . CJavaScript::encode($handler) . ")"; } Yii::app()->getClientScript()->registerScript(__CLASS__ . '#' . $this->getId(), ob_get_clean() . ';'); foreach ($this->events as $name => $handler) { $handler = CJavaScript::encode($handler); Yii::app()->getClientScript()->registerScript(__CLASS__ . '#' . $id . '_' . $name, "jQuery('#{$id}').on('{$name}', {$handler});"); } }
public function init() { $booster = Booster::getBooster(); $booster->registerAssetCss('bootstrap-image-gallery' . (!YII_DEBUG ? '.min' : '') . '.css'); $booster->registerAssetJs('fileupload/load-image.min.js'); $booster->registerAssetJs('bootstrap-image-gallery' . (!YII_DEBUG ? '.min' : '') . '.js'); if ($this->fullScreen) { Yii::app()->clientScript->registerScript($this->id, 'jQuery("#' . $this->id . '").addClass("modal-fullscreen");', CClientScript::POS_READY); } if (!$this->eventListener) { Yii::app()->clientScript->registerScript($this->id, '$(document.body).off(".modal-gallery.data-api");'); } if (!isset($this->htmlOptions['id'])) { $this->htmlOptions['id'] = $this->id; } echo CHtml::openTag('div', CMap::mergeArray(self::$defaultHtmlOptions, $this->htmlOptions)); }
/** * Publishes and registers the necessary script files. */ protected function registerClientScript() { $assets = Booster::getBooster()->cs; $assets->registerCss(__CLASS__ . '#sidebar-toggle', ' #' . $this->wrapper . '.toggled #' . $this->sidebar . ' { width: 0px; } #' . $this->wrapper . '.toggled #' . $this->content . ' { width: 100%; margin-left: 0px; } '); $assets->registerScript(__CLASS__ . '#sidebar-toggle', ' $("#sidebar-toggle").click(function(){ $("#' . $this->wrapper . '").toggleClass("toggled"); }); ', CClientScript::POS_LOAD); }
function registerClientScript() { $booster = Booster::getBooster(); $booster->registerPackage('typeahead'); if (empty($this->datasets) || !isset($this->datasets['source']) || !is_array($this->datasets['source'])) { return; } Yii::app()->clientScript->registerScript(__CLASS__ . '#substringMatcher', ' var substringMatcher = function(strs) { return function findMatches(q, cb) { var matches, substringRegex; // an array that will be populated with substring matches matches = []; // regex used to determine if a string contains the substring `q` substrRegex = new RegExp(q, "i"); // iterate through the pool of strings and for any string that // contains the substring `q`, add it to the `matches` array $.each(strs, function(i, str) { if (substrRegex.test(str)) { // the typeahead jQuery plugin expects suggestions to a // JavaScript object, refer to typeahead docs for more info matches.push({ value: str }); } }); cb(matches); }; }; ', CClientScript::POS_HEAD); $source_list = !empty($this->options) ? CJavaScript::encode($this->datasets['source']) : ''; Yii::app()->clientScript->registerScript(__CLASS__ . '#source_list#' . $this->id, ' var _' . $this->id . '_source_list = ' . $source_list . '; ', CClientScript::POS_HEAD); }
/** * Register required script files */ public function registerClientScript() { $assets = Booster::getBooster()->cs; $assets->registerPackage('redactor'); $baseUrl = $assets->packages['redactor']['baseUrl']; // Prepend language file to scripts package. if ($this->editorOptions['lang'] != 'en') { $assets->registerScriptFile($baseUrl . '/lang/' . $this->editorOptions['lang'] . '.js'); } if (isset($this->editorOptions['plugins'])) { foreach ($this->editorOptions['plugins'] as $name) { $filepath = Yii::getPathOfAlias('booster.assets.redactor.plugins') . '/' . $name . '/' . $name; $url = $baseUrl . '/plugins/' . $name . '/' . $name; if (file_exists($filepath . '.css')) { $assets->registerCssFile($url . '.css'); } if (file_exists($filepath . '.js')) { $assets->registerScriptFile($url . '.js'); } } } $options = $this->editorOptions ? CJavaScript::encode($this->editorOptions) : ''; $assets->registerScript(uniqid(__CLASS__ . '#', true), "jQuery('{$this->selector}').redactor({$options});"); }
border-width: 14px; float: right; } .process-middle{ background-color: #5bc0de; } .process-item{ height:28px; position: relative; line-height: 28px; } </style> <?php Booster::getBooster()->registerPackage('datetimepicker'); Booster::getBooster()->registerPackage('select2'); $box = $this->beginWidget('booster.widgets.TbPanel', array('title' => Yii::app()->user->name, 'context' => 'info', 'padContent' => false, 'headerIcon' => 'user', 'headerButtons' => array(array('class' => 'booster.widgets.TbButton', 'label' => '导出', 'buttonType' => 'submitLink', 'url' => '', 'visible' => in_array(Yii::app()->user->isAdmin(), [1, 3]), 'htmlOptions' => array('href' => $this->createUrl('recruitmentProcessFile')), 'context' => 'info', 'size' => 'small'), array('class' => 'booster.widgets.TbButton', 'label' => '只看自己', 'buttonType' => 'submitLink', 'url' => '', 'visible' => in_array(Yii::app()->user->isAdmin(), [1, 3]), 'htmlOptions' => array('href' => $this->createUrl('recruitmentProcess', array('onlyself' => $onlyself * -1)), 'style' => 'margin-right: 20px;' . ($onlyself == -1 ? '' : 'background:gainsboro;')), 'context' => 'info', 'size' => 'small')), 'headerHtmlOptions' => array(), 'contentHtmlOptions' => array('align' => 'center', 'style' => ' overflow:auto; '), 'htmlOptions' => array('class' => 'bootstrap-widget-table', 'style' => ' overflow:auto; '))); $this->widget('booster.widgets.TbGridView', array('enableSorting' => false, 'id' => 'user-info-grid', 'dataProvider' => $model->inProcess(30, $onlyself), 'htmlOptions' => array('style' => ''), 'filter' => $model, 'afterAjaxUpdate' => ' function() { jQuery(\'.popover\').remove(); jQuery(\'[data-toggle=popover]\').popover(); jQuery(\'.tooltip\').remove(); jQuery(\'[data-toggle=tooltip]\').tooltip(); jQuery(\'.TalentStatus_setup_datetime\').datetimepicker({\'language\':\'zh-CN\',\'format\':\'yyyy-mm-dd hh:ii\',\'startDate\':\'-0d -2w\',\'endDate\':\'+1m\',\'todayHighlight\':true,\'minuteStep\':30,\'startView\':2,\'minViewMode\':1,\'autoclose\':true}); jQuery(\'.s2id_TalentStatus_middleman\').select2({\'maximumSelectionSize\':1,\'placeholder\':\'面试人\',\'width\':\'resolve\'}); jQuery(\'.s2id_OptionsDetails_middleman\').select2({\'maximumSelectionSize\':1,\'placeholder\':\'拒绝缘由\',\'width\':\'resolve\'}); jQuery(\'.carousel-invite-form\').carousel(\'pause\'); } ', 'columns' => array(array('name' => 'departments.department', 'htmlOptions' => array('style' => 'vertical-align: middle;width:6%')), array('name' => 'position', 'htmlOptions' => array('style' => 'vertical-align: middle;'), 'headerHtmlOptions' => array('style' => 'width:7%', 'class' => 'col-sm-1')), array('name' => 'name', 'type' => 'raw', 'htmlOptions' => array('style' => 'vertical-align: middle;'), 'headerHtmlOptions' => array('style' => 'width:5%', 'class' => 'col-sm-1'), 'value' => array($this, 'getUserUrl')), array('name' => 'create_datetime', 'filter' => ' ', 'type' => 'raw', 'htmlOptions' => array('style' => 'vertical-align: middle;'), 'headerHtmlOptions' => array('style' => 'width:95px;', 'class' => ''), 'value' => 'date("m-d H:i",strtotime($data->update_time))'), array('header' => '', 'type' => 'raw', 'headerHtmlOptions' => array('style' => 'width=20px;', 'class' => ''), 'htmlOptions' => array('style' => 'vertical-align: middle;'), 'value' => array($this, 'getResumeDownloadUrl')), array('header' => '招聘进度', 'filter' => ' ', 'name' => 'recruitmentProcess', 'value' => array($this, 'getRecruitmentProcess'), 'htmlOptions' => array('style' => 'vertical-align: middle;'), 'headerHtmlOptions' => array('style' => '', 'class' => 'col-sm-5')), array('header' => '下一操作', 'type' => 'raw', 'headerHtmlOptions' => array('style' => '', 'class' => ''), 'value' => array($this, 'getRecruitmentNextProcess'))))); $this->endWidget(); ?>
public function registerLanguageScript() { if (isset($this->options['language']) && $this->options['language'] != 'en') { $file = 'locales/bootstrap-datetimepicker.' . $this->options['language'] . '.js'; $booster = Booster::getBooster(); if (@file_exists(Yii::getPathOfAlias('booster.assets.bootstrap-datetimepicker') . '/js/' . $file)) { if ($booster->enableCdn) { // Not in CDN yet $booster->registerAssetJs('../bootstrap-datetimepicker/' . '/js/' . $file); } else { $booster->registerAssetJs('../bootstrap-datetimepicker/' . '/js/' . $file); } } } }
private function insertDefaultStylesheetIfColorsEnabled() { if (empty($this->editorOptions['color'])) { return; } $defaultStyleSheetUrl = Booster::getBooster()->getAssetsUrl() . '/css/wysiwyg-color.css'; array_unshift($this->editorOptions['stylesheets'], $defaultStyleSheetUrl); // we want default css to be first }
public function registerAssets() { $booster = Booster::getBooster(); if ($this->type == 'date' || $this->type == 'combodate') { /** * @var $widget TbDatePicker */ $widget = Yii::app()->widgetFactory->createWidget($this->getOwner(), 'booster.widgets.TbDatePicker', array('options' => isset($this->options['datepicker']) ? $this->options['datepicker'] : array())); $widget->registerLanguageScript(); } elseif ($this->type == 'datetime') { $booster->registerPackage('datetimepicker'); /** * @var $widget TbDateTimePicker */ $widget = Yii::app()->widgetFactory->createWidget($this->getOwner(), 'booster.widgets.TbDateTimePicker', array('options' => $this->options['datetimepicker'])); $widget->registerLanguageScript(); } if ($this->type == 'combodate') { // include moment.js if needed $booster->registerPackage('moment'); } elseif ($this->type == 'select2') { // include select2 if needed $booster->registerPackage('select2'); } $booster->registerPackage('x-editable'); return; /* TODO original */ $am = Yii::app()->getAssetManager(); $cs = Yii::app()->getClientScript(); $form = yii::app()->editable->form; $mode = $this->mode ? $this->mode : yii::app()->editable->defaults['mode']; // bootstrap if ($form === EditableConfig::FORM_BOOTSTRAP) { if ($bootstrap = yii::app()->getComponent('bootstrap')) { $bootstrap->registerCoreCss(); $bootstrap->registerCoreScripts(); } else { throw new CException('You need to setup Yii-bootstrap extension first.'); } $assetsUrl = $am->publish(Yii::getPathOfAlias('editable.assets.bootstrap-editable')); $js = 'bootstrap-editable.js'; $css = 'bootstrap-editable.css'; // jqueryui } elseif ($form === EditableConfig::FORM_JQUERYUI) { if ($mode === EditableConfig::POPUP && Yii::getVersion() < '1.1.13') { throw new CException('jQuery UI editable popup supported from Yii 1.1.13+'); } // register jquery ui $this->registerJQueryUI(); $assetsUrl = $am->publish(Yii::getPathOfAlias('editable.assets.jqueryui-editable')); $js = 'jqueryui-editable.js'; $css = 'jqueryui-editable.css'; // plain jQuery } else { $assetsUrl = $am->publish(Yii::getPathOfAlias('editable.assets.jquery-editable')); $js = 'jquery-editable-poshytip.js'; $css = 'jquery-editable.css'; // publish & register poshytip for popup version if ($mode === EditableConfig::POPUP) { $poshytipUrl = $am->publish(Yii::getPathOfAlias('editable.assets.poshytip')); $cs->registerScriptFile($poshytipUrl . '/jquery.poshytip.js'); $cs->registerCssFile($poshytipUrl . '/tip-yellowsimple/tip-yellowsimple.css'); } // register jquery ui for datepicker if ($this->type == 'date' || $this->type == 'dateui') { $this->registerJQueryUI(); } } // register assets $cs->registerCssFile($assetsUrl . '/css/' . $css); $cs->registerScriptFile($assetsUrl . '/js/' . $js, CClientScript::POS_END); // include moment.js for combodate if ($this->type == 'combodate') { $momentUrl = $am->publish(Yii::getPathOfAlias('editable.assets.moment')); $cs->registerScriptFile($momentUrl . '/moment.min.js'); } // include select2 lib for select2 type if ($this->type == 'select2') { $select2Url = $am->publish(Yii::getPathOfAlias('editable.assets.select2')); $cs->registerScriptFile($select2Url . '/select2.min.js'); $cs->registerCssFile($select2Url . '/select2.css'); } // include bootstrap-datetimepicker if ($this->type == 'datetime') { $url = $am->publish(Yii::getPathOfAlias('editable.assets.bootstrap-datetimepicker')); $cs->registerScriptFile($url . '/js/bootstrap-datetimepicker.js'); $cs->registerCssFile($url . '/css/datetimepicker.css'); } // TODO: include locale for datepicker // may be do it manually? /* * if ($this->type == 'date' && $this->language && substr($this->language, 0, 2) != 'en') { * //todo: check compare dp locale name with yii's * $localesUrl = Yii::app()->getAssetManager()->publish(Yii::getPathOfAlias('ext.editable.assets.js.locales')); * Yii::app()->clientScript->registerScriptFile($localesUrl . '/bootstrap-datepicker.'. str_replace('_', '-', $this->language).'.js', CClientScript::POS_END); * } */ }
/** * Registers and publishes required scripts * * @param string $id */ public function registerClientScript($id) { $booster = Booster::getBooster(); $booster->registerAssetCss('fileupload/jquery.fileupload-ui.css'); // Upgrade widget factory // @todo remove when jquery.ui 1.9+ is fully integrated into stable Yii versions $booster->registerAssetJs('fileupload/vendor/jquery.ui.widget.js'); //The Templates plugin is included to render the upload/download listings $booster->registerAssetJs("fileupload/tmpl.min.js", CClientScript::POS_END); if ($this->previewImages || $this->imageProcessing) { $booster->registerAssetJs("fileupload/load-image.min.js", CClientScript::POS_END); $booster->registerAssetJs("fileupload/canvas-to-blob.min.js", CClientScript::POS_END); // gallery :) and one smile from me ;) $booster->registerAssetCss("bootstrap-image-gallery.min.css"); $booster->registerAssetJs("bootstrap-image-gallery.min.js", CClientScript::POS_END); } //The Iframe Transport is required for browsers without support for XHR file uploads $booster->registerAssetJs('fileupload/jquery.iframe-transport.js'); $booster->registerAssetJs('fileupload/jquery.fileupload.js'); // The File Upload image processing plugin if ($this->imageProcessing) { $booster->registerAssetJs('fileupload/jquery.fileupload-ip.js'); } // The File Upload file processing plugin if ($this->previewImages) { $booster->registerAssetJs('fileupload/jquery.fileupload-fp.js'); } // locale $booster->registerAssetJs('fileupload/jquery.fileupload-locale.js'); //The File Upload user interface plugin $booster->registerAssetJs('fileupload/jquery.fileupload-ui.js'); $options = CJavaScript::encode($this->options); Yii::app()->clientScript->registerScript(__CLASS__ . '#' . $id, "jQuery('#{$id}').fileupload({$options}){$this->generateCallbackBindJSString()};"); }
<?php /* @var $this CardsController */ /* @var $model Cards */ $this->breadcrumbs = array(Yii::t('app', 'History of the card #') . $model->number); Booster::getBooster()->registerPackage('datepicker'); $cs = Yii::app()->clientScript; $cs->registerScript(__CLASS__ . __LINE__, 'jQuery("#CardsHistory_action_date").datepicker({"language":"' . Yii::app()->language . '", format:"dd.mm.yyyy"}); jQuery("#CardsHistory_action_date").on("changeDate", function(ev){ jQuery(this).datepicker("hide"); });', CClientScript::POS_READY); ?> <h1><?php echo Yii::t('app', 'History of the card #') . CHtml::encode($model->number); ?> </h1> <div class="row"> <div class="col-sm-6"> <?php $this->widget('booster.widgets.TbDetailView', array('data' => $model, 'type' => array('striped', 'bordered'), 'attributes' => array(array('name' => 'series', 'type' => 'raw', 'value' => function ($data) { return Cards::getSeriesList($data->series); }), 'number', array('name' => 'created_at', 'type' => 'raw', 'value' => function ($data) { return date("d.m.Y H:i:s", strtotime($data->created_at)); }), array('name' => 'expired_at', 'type' => 'raw', 'value' => function ($data) { return date("d.m.Y H:i:s", $data->expired_at); }), array('name' => 'status', 'type' => 'raw', 'value' => function ($data) { return $data->cardStatus; })))); ?> </div> <div class="col-sm-6">
/** *### .registerClientScript() * * Registers required client script for bootstrap select2. * It is not used through bootstrap->registerPlugin * in order to attach events if any * * @param string $id */ public function registerClientScript($id) { $booster = Booster::getBooster(); $booster->registerPackage('bootstrap-tags'); $options = !empty($this->options) ? CJavaScript::encode($this->options) : ''; Yii::app()->getClientScript()->registerScript(__CLASS__ . '#' . $this->getId(), "jQuery('#tags_{$id}').tags({$options});"); }
/** * Register required scripts */ protected function registerClientScripts() { $booster = Booster::getBooster(); $booster->registerAssetCss('easy-pie-chart.css'); $booster->registerAssetJs('jquery.easy.pie.chart.js'); $options = CJavaScript::encode($this->chartOptions); Yii::app()->getClientScript()->registerScript(__CLASS__ . '#percent-of-type-operation-simple-pie', ' $("#' . $this->column->grid->id . ' .' . $this->column->grid->extendedSummaryCssClass . ' .' . $this->chartCssClass . '") .easyPieChart(' . $options . '); '); $this->column->grid->componentsReadyScripts[__CLASS__] = $this->column->grid->componentsAfterAjaxUpdate[__CLASS__] = '$("#' . $this->column->grid->id . ' .' . $this->column->grid->extendedSummaryCssClass . ' .' . $this->chartCssClass . '") .easyPieChart(' . $options . ');'; }
/** *### .registerClientScript() * * Registers required css js files */ public function registerClientScript() { $booster = Booster::getBooster(); $booster->registerAssetCss('bootstrap-daterangepicker.css'); $booster->registerAssetJs('bootstrap.daterangepicker.js'); $booster->registerPackage('moment'); }
/** *### .registerClientScript() * * Registers required client script for bootstrap select2. It is not used through bootstrap->registerPlugin * in order to attach events if any */ public function registerClientScript($id) { Booster::getBooster()->registerPackage('select2'); $options = !empty($this->options) ? CJavaScript::encode($this->options) : ''; if (!empty($this->val)) { if (is_array($this->val)) { $data = CJSON::encode($this->val); } else { $data = $this->val; } $defValue = ".select2('val', {$data})"; } else { $defValue = ''; } if ($this->readonly) { $defValue .= ".select2('readonly', true)"; } elseif ($this->disabled) { $defValue .= ".select2('enable', false)"; } ob_start(); echo "jQuery('#{$id}').select2({$options})"; foreach ($this->events as $event => $handler) { echo ".on('{$event}', " . CJavaScript::encode($handler) . ")"; } echo $defValue; Yii::app()->getClientScript()->registerScript(__CLASS__ . '#' . $this->getId(), ob_get_clean() . ';'); }
/** * */ public function renderBulkActions() { \Booster::getBooster()->registerAssetJs('jquery.saveselection.gridview.js'); $this->componentsAfterAjaxUpdate[] = "\$.fn.yiiGridView.afterUpdateGrid('" . $this->id . "');"; echo '<tr><td colspan="' . count($this->columns) . '" class="grid-toolbar">'; if (!empty($this->bulk)) { $this->bulk->renderButtons(); } echo $this->renderSorter(); if (!empty($this->actionsButtons)) { if (is_array($this->actionsButtons)) { foreach ($this->actionsButtons as $button) { echo $button; } } else { echo CHtml::link(Yii::t('YupeModule.yupe', 'Add'), ['/' . $this->getController()->getModule()->getId() . '/' . lcfirst($this->_modelName) . 'Backend/create'], ['class' => 'btn btn-success pull-right btn-sm']); } } echo '</td></tr>'; }
/** *### .registerClientScript() * * Registers required javascript * * @param string $id */ public function registerClientScript($id) { Booster::getBooster()->cs->registerPackage('ckeditor'); $options = !empty($this->editorOptions) ? CJavaScript::encode($this->editorOptions) : '{}'; Yii::app()->clientScript->registerScript(__CLASS__ . '#' . $this->getId(), "CKEDITOR.replace( '{$id}', {$options});"); }
/** * Register script that will handle its behavior */ public function registerClientScript() { Booster::getBooster()->registerAssetCss('bootstrap-relational.css'); /** * @var $cs CClientScript */ $cs = Yii::app()->getClientScript(); if ($this->afterAjaxUpdate !== null) { if (!$this->afterAjaxUpdate instanceof CJavaScriptExpression && strpos($this->afterAjaxUpdate, 'js:') !== 0) { $this->afterAjaxUpdate = new CJavaScriptExpression($this->afterAjaxUpdate); } } else { $this->afterAjaxUpdate = 'js:$.noop'; } $this->ajaxErrorMessage = CHtml::encode($this->ajaxErrorMessage); $afterAjaxUpdate = CJavaScript::encode($this->afterAjaxUpdate); $span = count($this->grid->columns); $loadingPic = CHtml::image(Booster::getBooster()->getAssetsUrl() . '/img/loading.gif'); $cache = $this->cacheData ? 'true' : 'false'; $data = !empty($this->submitData) && is_array($this->submitData) ? $this->submitData : 'js:{}'; $data = CJavascript::encode($data); list($parentId) = explode('_', $this->id); $js = <<<EOD \$(document).on('click','#{$parentId} .{$this->cssClass}', function(){ \tvar span = {$span}; \tvar that = \$(this); \tvar status = that.data('status'); \tvar rowid = that.data('rowid'); \tvar tr = \$('#relatedinfo'+rowid); \tvar parent = that.parents('tr').eq(0); \tvar afterAjaxUpdate = {$afterAjaxUpdate}; \tif (status && status=='on'){return} \tthat.data('status','on'); \tif (tr.length && !tr.is(':visible') && {$cache}) \t{ \t\ttr.slideDown(); \t\tthat.data('status','off'); \t\treturn; \t}else if (tr.length && tr.is(':visible')) \t{ \t\ttr.slideUp(); \t\tthat.data('status','off'); \t\treturn; \t} \tif (tr.length) \t{ \t\ttr.find('td').html('{$loadingPic}'); \t\tif (!tr.is(':visible')){ \t\t\ttr.slideDown(); \t\t} \t} \telse \t{ \t\tvar td = \$('<td/>').html('{$loadingPic}').attr({'colspan':{$span}}); \t\ttr = \$('<tr/>').prop({'id':'relatedinfo'+rowid}).append(td); \t\t/* we need to maintain zebra styles :) */ \t\tvar fake = \$('<tr class="hide"/>').append(\$('<td/>').attr({'colspan':{$span}})); \t\tparent.after(tr); \t\ttr.after(fake); \t} \tvar data = \$.extend({$data}, {id:rowid}); \t\$.ajax({ \t\turl: '{$this->url}', \t\tdata: data, \t\tsuccess: function(data){ \t\t\ttr.find('td').html(data); \t\t\tthat.data('status','off'); \t\t\tif (\$.isFunction(afterAjaxUpdate)) \t\t\t{ \t\t\t\tafterAjaxUpdate(tr,rowid,data); \t\t\t} \t\t}, \t\terror: function() \t\t{ \t\t\ttr.find('td').html('{$this->ajaxErrorMessage}'); \t\t\tthat.data('status','off'); \t\t} \t}); }); EOD; $cs->registerScript(__CLASS__ . '#' . $this->id, $js); }