Quantcast
Channel: Yii Framework Forum
Viewing all articles
Browse latest Browse all 18717

灰显整个网站--------For雅安四川地震

$
0
0
不幸又发生在四川了 没办法 只能祈求这种天灾人祸少发生些!又有一些人为了出名捐钱捐物了 如果是出自真心最好 不然就老实呆着 不要帮倒忙 比如开着跑车到那里去送水 以为旅游呢 反而阻碍交通 :angry:

yii开发的网站 如果用了布局继承 那么要灰显整个网站 只需要把主布局 改动下就好:
 html {
            filter: progid:DXImageTransform.Microsoft.BasicImage(grayscale=1);
            -webkit-filter: grayscale(100%);
            filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#grayscale"); /* Firefox 10+, Firefox on Android */
        }

        img {
            _filter: progid:DXImageTransform.Microsoft.BasicImage(grayscale=0);
            -webkit-filter: grayscale(100%);
            filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#grayscale"); /* Firefox 10+, Firefox on Android */
        }

上面这段代码拷贝到<head>.. </head> 之间 ;

另一种方法, 扩展一个CWebApplication:
class MyWebApplication extends CWebApplication
{

    /**
     * The post-filter for controller actions.
     * This method is invoked after the currently requested controller action and all its filters
     * are executed. You may override this method with logic that needs to be done
     * after all controller actions.
     * @param CController $controller the controller
     * @param CAction $action the action
     */
    public function afterControllerAction($controller, $action)
    {

    }

    /**
     * The pre-filter for controller actions.
     * This method is invoked before the currently requested controller action and all its filters
     * are executed. You may override this method with logic that needs to be done
     * before all controller actions.
     * @param CController $controller the controller
     * @param CAction $action the action
     * @return boolean whether the action should be executed.
     */
    public function beforeControllerAction($controller,$action)
    {
        $forYaAn = <<<GRAY_PAGE
 html {
            filter: progid:DXImageTransform.Microsoft.BasicImage(grayscale=1);
            -webkit-filter: grayscale(100%);
            filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#grayscale"); /* Firefox 10+, Firefox on Android */
        }

        img {
            _filter: progid:DXImageTransform.Microsoft.BasicImage(grayscale=0);
            -webkit-filter: grayscale(100%);
            filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#grayscale"); /* Firefox 10+, Firefox on Android */
        }
GRAY_PAGE;

        $this->clientScript->registerCss('for_yaAn',$forYaAn);

        if (!empty($this->user->loginRequiredAjaxResponse)){
            Yii::app()->clientScript->registerScript('ajaxLoginRequired', '
            //jQuery("body").ajaxComplete(
            jQuery("body").ajaxSuccess(
                function(event, request, options) {
                    if (request.responseText == "'.Yii::app()->components['user']->loginRequiredAjaxResponse.'") {
                        window.location.href = "'. $this->createUrl(UserHelper::getLoginUrl()) .'";
                    }
                }
            );
        ');
        }
       return parent::beforeControllerAction($controller,$action);
    }



   
}




然后再主入口文件index.php 修改创建应用程序的地方:
$app = Yii::createApplication('MyWebApplication', $config);


css 样式来自:to gray, for Ya'An, Si Chuan earthquake

Viewing all articles
Browse latest Browse all 18717

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>