/**
  * Registers necessary client scripts. 
  * Automaticlly prepend user's beforeajaxUpdate with needed code that will modify GET params when navigating and sorting
  */
 public function registerClientScript()
 {
     parent::registerClientScript();
     if ($this->selectableRows > 0) {
         $id = $this->getId();
         $options = array('selVar' => $this->selVar);
         $options = CJavaScript::encode($options);
         $cs = Yii::app()->getClientScript();
         $cs->registerScriptFile($this->selBaseScriptUrl . '/jquery.selgridview.js', CClientScript::POS_END);
         $cs->registerScript(__CLASS__ . '#' . $id . '-sel', "jQuery('#{$id}').selGridView({$options});");
     }
 }
Пример #2
0
    /**
     * Registers necessary client scripts.
     */
    public function registerClientScript()
    {
        parent::registerClientScript();
        $cs = Yii::app()->getClientScript();
        $cs->registerScriptFile($this->baseTreeTableUrl . '/javascripts/jquery.treeTable.js', CClientScript::POS_END);
        $cs->registerScriptFile($this->baseJuiUrl . '/jquery.ui.core.min.js', CClientScript::POS_END);
        $cs->registerScriptFile($this->baseJuiUrl . '/jquery.ui.widget.min.js', CClientScript::POS_END);
        $cs->registerScriptFile($this->baseJuiUrl . '/jquery.ui.mouse.min.js', CClientScript::POS_END);
        $cs->registerScriptFile($this->baseJuiUrl . '/jquery.ui.droppable.min.js', CClientScript::POS_END);
        $cs->registerScriptFile($this->baseJuiUrl . '/jquery.ui.draggable.min.js', CClientScript::POS_END);
        $cs->registerCssFile($this->baseTreeTableUrl . '/stylesheets/jquery.treeTable.css');
        $cs->registerScript('treeTable', '
            $(document).ready(function()  {
              $("#' . $this->getId() . ' .items").treeTable();
            });
            ');
        $cs->registerScript('draganddrop', '
            $(document).ready(function()  {
               $("#' . $this->getId() . ' .items tr.initialized").draggable({
                  helper: "clone",
                  opacity: .75,
                  refreshPositions: true, // Performance?
                  revert: "invalid",
                  revertDuration: 300,
                  scroll: true
                });

                $("#' . $this->getId() . ' .items tr.initialized, #' . $this->getId() . ' .items tr.before, #' . $this->getId() . ' .items tr.after").droppable({
                    accept: ".initialized",
                    drop: function(e, ui) {
                      // Call jQuery treeTable plugin to move the branch
                      //$(ui.draggable).appendBranchTo(this);
                      if($(this).hasClass("initialized")) {
                        window.location.href = "moveNode/action/child/to/"+$(this).attr("id")+"/id/"+$(ui.draggable).attr("id");
                      }
                      if($(this).hasClass("before")) {
                        window.location.href = "moveNode/action/before/to/"+$(this).attr("id").replace("before-", "")+"/id/"+$(ui.draggable).attr("id");
                      }
                      if($(this).hasClass("after")) {
                        window.location.href = "moveNode/action/before/to/"+$(this).attr("id").replace("after-", "")+"/id/"+$(ui.draggable).attr("id");
                      }
                    },
                    hoverClass: "accept",
                    over: function(e, ui) {
                      // Make the droppable branch expand when a draggable node is moved over it.
                      if(this.id != $(ui.draggable.parents("tr")[0]).id && !$(this).is(".expanded")) {
                        $(this).expand();
                      }
                    },
                    activate: function(e, ui) {
                      $(".after").css("display", "table-row");
                      $(".before").css("display", "table-row");
                    },
                    deactivate: function(e, ui) {
                      $(".after").css("display", "none");
                      $(".before").css("display", "none");
                    },
                  });
            });

            ');
    }
Пример #3
0
    /**
     * Изначально регистрируются 2 плагина gridBase и grid
     * Если установить значение свойства jsPlugin, то подключится так же плагин /css/admin/gridview/grid.js
     * И на сам grid будет инициализироват плагин с названием из jsPlugin
     */
    public function registerClientScript()
    {
        parent::registerClientScript();
        $cs = Yii::app()->clientScript;
        $cs->registerCoreScript('jquery.ui');
        $cs->registerScriptFile("/js/plugins/gridview/gridBase.js");
        $cs->registerScriptFile("/js/plugins/gridview/grid.js");

        $options = CJavaScript::encode(array(
            'mass_removal' => $this->mass_removal,
            'filter_hint'  => $this->filter_hint
        ));
        $cs->registerScript($this->getId() . '.grid', "
            $('#{$this->getId()}').grid({$options});
        ");

        $this->onRegisterScript(new CEvent);
    }