/** * */ public function init() { parent::init(); Yii::app()->clientScript->registerCssFile(YiiEmbed::assetsUrl() . '/css/detail-view.css'); }
/** * */ public function registerClientScript() { parent::registerClientScript(); Yii::app()->clientScript->registerCssFile(YiiEmbed::assetsUrl() . '/css/grid-view.css'); if ($this->multiActions || $this->gridActions || $this->gridButtons) { Yii::app()->clientScript->registerScriptFile(YiiEmbed::assetsUrl() . '/js/jquery.form.js'); // put the url from the button into the form action // handle submit form to capture the response into a modal Yii::app()->controller->beginWidget('YiiEmbedJavaScriptWidget', array('position' => CClientScript::POS_END)); ?> <script type="text/javascript"> var modalRemote = $('#modal-remote'); // handle multiActions $('#<?php echo $this->id; ?> -form').on('change', '.multi-actions', function () { var checked = false; var action = $('#<?php echo $this->id; ?> -form').attr('action'); var url = $(this).val(); $(this).val(''); if (url) { $('.select-on-check').each(function () { if ($(this).is(':checked')) checked = true; }); if (checked) { setupGridViewAjaxForm(); $('#<?php echo $this->id; ?> -form').attr('action', url).submit(); } else { alert('<?php echo Yii::t('dressing', 'No rows selected.'); ?> '); } } }); // handle gridActions $('#<?php echo $this->id; ?> -form').on('change', '.grid-actions', function () { var action = $('#<?php echo $this->id; ?> -form').attr('action'); var url = $(this).val(); $(this).val(''); if (url) { setupGridViewAjaxForm(); $('#<?php echo $this->id; ?> -form').attr('action', url).submit(); } }); // handle gridButtons $('#<?php echo $this->id; ?> -form').on('click', '.gridButton', function () { var action = $('#<?php echo $this->id; ?> -form').attr('action'); var url = $(this).val(); $(this).val(''); if (url) { $('#<?php echo $this->id; ?> -form').attr('action', url).submit(); } }); // handle form submission function setupGridViewAjaxForm() { $('#<?php echo $this->id; ?> -form').ajaxForm({ beforeSubmit: function (response) { if (!modalRemote.length) modalRemote = $('<div class="modal hide fade" id="modal-remote"></div>'); modalRemote.modalResponsiveFix(); modalRemote.touchScroll(); modalRemote.html('<div class="modal-header"><h3><?php echo Yii::t('dressing', 'Loading...'); ?> </h3></div><div class="modal-body"><div class="modal-remote-indicator"></div>').modal(); }, success: function (response) { modalRemote.html(response); $(window).resize(); $('#modal-remote input:text:visible:first').focus(); }, error: function (response) { modalRemote.children('.modal-header').html('<button type="button" class="close" data-dismiss="modal"><i class="icon-remove"></i></button><h3><?php echo Yii::t('dressing', 'Error!'); ?> </h3>'); modalRemote.children('.modal-body').html(response); } }); } </script> <?php Yii::app()->controller->endWidget(); } }