示例#1
0
 /**
  * Initialize widget
  */
 public function init()
 {
     $assetsUrl = Yii::app()->getAssetManager()->publish(Yii::getPathOfAlias('ext.jstree.assets'), false, -1, YII_DEBUG);
     Yii::app()->getClientScript()->registerPackage('cookie');
     $this->cs = Yii::app()->getClientScript();
     $this->cs->registerScriptFile($assetsUrl . '/jquery.jstree.js');
 }
示例#2
0
 /**
  * Init widget
  */
 public function init()
 {
     $assetsUrl = Yii::app()->assetManager->publish(dirname(__FILE__) . '/assets', false, -1, YII_DEBUG);
     $this->cs = Yii::app()->getClientScript();
     $this->cs->registerCoreScript('cookie');
     $this->cs->registerScriptFile($assetsUrl . '/jstree.js');
     $this->cs->registerCssFile($assetsUrl . '/themes/default/style.css');
 }
示例#3
0
 /**
  * Init widget
  */
 public function init()
 {
     $this->assetsUrl = Yii::app()->assetManager->publish(dirname(__FILE__) . '/assets', false, -1, YII_DEBUG);
     $this->cs = Yii::app()->getClientScript();
     $this->cs->registerCoreScript('cookie');
     if (Yii::app()->request->isAjaxRequest) {
         Yii::app()->clientScript->scriptMap['jquery.js'] = false;
         Yii::app()->clientScript->scriptMap['cookie.js'] = false;
     }
     $this->cs->registerScriptFile($this->assetsUrl . '/jquery.jstree.js');
     $this->cs->registerCssFile($this->assetsUrl . "/themes/{$this->theme}/style.css");
 }
示例#4
0
 /**
  * @depends testRegisterScriptFile
  * @depends testRegisterScriptFileWithHtmlOptions
  * 
  * @dataProvider providerRenderScriptFiles
  *
  * @param string $url
  * @param integer $position
  * @param array $htmlOptions
  * @param string $assertion
  */
 public function testRenderScriptFiles($url, $position, $htmlOptions, $assertion)
 {
     $returnedClientScript = $this->_clientScript->registerScriptFile($url, $position, $htmlOptions);
     $output = '<head></head>';
     $returnedClientScript->render($output);
     $this->assertContains($assertion, $output);
 }
 public function registerScriptFile($name, $position = null, array $htmlOptions = array())
 {
     if (in_array($name, $this->bannedJsFiles)) {
         return $this;
     }
     parent::registerScriptFile($name, $position, $htmlOptions);
 }
示例#6
0
 /**
  * @param bool $registerLocaleJs
  * @return JTimeAgo
  */
 public function handleLocale($registerLocaleJs = true)
 {
     //  $localeId = Yii::app()->getLocale()->getCanonicalID($localeId) ;
     $localeId = Yii::app()->getLocale()->getId();
     if (isset($this->localeIdMap[$localeId])) {
         $localeId = $this->localeIdMap[$localeId];
     }
     $localeJsPath = $this->assetsPath . DIRECTORY_SEPARATOR . 'locales' . DIRECTORY_SEPARATOR . "jquery.timeago.{$localeId}.js";
     // echo $localeJsPath ; die(__FILE__);
     if (!is_file($localeJsPath)) {
         /**
          * try  another locale form :
          */
         $localeId = str_replace('_', '-', $localeId);
         $localeJsPath = $this->assetsPath . DIRECTORY_SEPARATOR . 'locales' . DIRECTORY_SEPARATOR . "jquery.timeago.{$localeId}.js";
         if (!is_file($localeJsPath)) {
             return $this;
         }
     }
     if ($registerLocaleJs == true) {
         $localeJsUrl = $this->baseUrl . '/locales/' . "jquery.timeago.{$localeId}.js";
         $this->cs->registerScriptFile($localeJsUrl);
     } else {
         $localeJsCode = file_get_contents($localeJsPath);
         $this->cs->registerScript(__CLASS__ . '_locale_' . $this->getId(), $localeJsCode, CClientScript::POS_HEAD);
     }
 }
示例#7
0
 /**
  * Change default of script position to CClinetScript::POS_END
  */
 public function registerScriptFile($url, $position = self::POS_END, array $htmlOptions = array())
 {
     if (substr($url, 0, 1) !== '/' && strpos($url, '://') === false) {
         $url = $this->_baseUrl . '/' . $url;
     }
     return parent::registerScriptFile($url, $position, $htmlOptions);
 }
 /**
  * {@inheritDoc}
  */
 public function registerScriptFile($url, $position = null, array $htmlOptions = array())
 {
     if ($this->isBundled($url)) {
         return $this;
     }
     return parent::registerScriptFile($url, $position, $htmlOptions);
 }
示例#9
0
 public function registerScriptFile($url, $position = self::POS_HEAD)
 {
     if (!Yii::app()->request->isAjaxRequest) {
         return parent::registerScriptFile($url, $position);
     } else {
         echo '<script type="text/javascript" src="' . CHtml::encode($url) . '"></script>';
         return $this;
     }
 }
示例#10
0
 /**
  * Registers a script file
  *
  * @param String $src
  * @param String $position
  */
 public function registerScriptFile($src, $position = NULL)
 {
     #    if(Yii::app()->getRequest()->getIsAjaxRequest()) {
     #         Yii::app()->clientScript->registerScript('loadScript_'.$src, "loadJavaScript(\"".$src."\");", CClientScript::POS_BEGIN);
     #      } else {
     return parent::registerScriptFile($src, $position);
     #        }
     #registerScriptFile
 }
示例#11
0
    public function run()
    {
        $this->clientScript = Yii::app()->clientScript;
        $this->clientScript->registerPackage('aes-common');
        if (defined('TEST_APP_INSTANCE') && TEST_APP_INSTANCE) {
            $this->clientScript->registerScript('urlMangerInit', 'UrlManager.setBaseUrl("/index-test.php");', CClientScript::POS_HEAD);
        }
        //Registering backbone + marionete
        $this->clientScript->registerPackage('marionette');
        $this->clientScript->registerScriptFile('/js/libs/aes/i18n.js');
        $this->clientScript->registerScriptFile('/js/libs/jquery.dateFormat-1.0.js');
        /**
         * Resolving conflict with jquery.ui.button and bootstrap.button plugins
         * Bootstrap.button will be available by $().bButton
         * 
         * NOTE: You should update js/libs/bootstrap.button.js with the same version
         * of bootstrap if you are updating bootstrap.js
         */
        $this->clientScript->registerScriptFile('/js/libs/bootstrap.button.js', CClientScript::POS_END);
        $this->clientScript->registerScript('resolveBtnConflict', '$(function(){ var btn = $.fn.button.noConflict();
            $.fn.bButton = btn; });', CClientScript::POS_END);
        $this->clientScript->registerScriptFile('/js/libs/bootstrap.tooltip.js', CClientScript::POS_END);
        $this->clientScript->registerScript('resolveTooltipConflict', '$(function(){
               var bTooltip = $.fn.tooltip;

               $.fn.tooltip.noConflict();
               $.fn.jqTooltip = $.fn.tooltip;

               $.fn.tooltip = bTooltip;
            });', CClientScript::POS_END);
        $user = Yii::app()->user;
        /**
         * Initializing webUser for client-side
         */
        $this->clientScript->registerScriptFile('/js/libs/aes/WebUser.js');
        $this->clientScript->registerScript('webUserInit', 'WebUser.initialize({' . (!$user->isGuest ? 'id: ' . $user->id . ', displayName: "' . $user->username . '"' : '') . '});', CClientScript::POS_HEAD);
        if ($this->isolated) {
            $appMain = 'dev/app.dev.js';
            $this->clientScript->registerScriptFile('/js/libs/backbone-faux-server.js');
        } else {
            $appMain = 'app.js';
        }
        $this->requires['basePath'] = 'application.views.' . $this->controller->id . '.assets.' . $this->controller->action->id . '.js.' . $this->appName;
        $fullAppName = ucfirst($this->appName) . 'App';
        $this->requires['js'] = array_merge(array($fullAppName . '.js'), $this->requires['js']);
        $this->requires['js'][] = $appMain;
        $this->requires = $this->filterCommonScripts($this->requires);
        $this->clientScript->packages = array_merge($this->clientScript->packages, array($this->appName => $this->requires));
        $this->clientScript->registerPackage($this->appName);
        foreach ($this->initializers as $index => $initializer) {
            $this->clientScript->registerScript('intlzr' . $index, 'App.addInitializer(function(){ ' . $initializer . ' });');
        }
    }
 /**
  * Registers a javascript file.
  * @param string $url URL of the javascript file
  * @param int|null $position the position of the JavaScript code. Valid values include the following:
  * <ul>
  * <li>CClientScript::POS_HEAD : the script is inserted in the head section right before the title element.</li>
  * <li>CClientScript::POS_BEGIN : the script is inserted at the beginning of the body section.</li>
  * <li>CClientScript::POS_END : the script is inserted at the end of the body section.</li>
  * </ul>
  * @param array $htmlOptions
  * @return YdClientScript the CClientScript object itself (to support method chaining, available since version 1.1.5).
  */
 public function registerScriptFile($url, $position = null, array $htmlOptions = array())
 {
     // do not load these scripts on ajax
     $ignoreAjax = array('jquery-ui.min.js', 'jquery-ui.js', 'jquery-ui-i18n.min.js', 'jquery-ui-i18n.js', 'bootstrap.min.js', 'bootstrap.js');
     if (Yii::app()->request->isAjaxRequest) {
         foreach ($ignoreAjax as $ignore) {
             if ($this->endsWith($url, $ignore)) {
                 return $this;
             }
         }
     }
     return parent::registerScriptFile($url, $position, $htmlOptions);
 }
示例#13
0
 /**
  * Registers a javascript file.
  * @param string $url URL of the javascript file
  * @param integer $position the position of the JavaScript code. Valid values include the following:
  * <ul>
  * <li>CClientScript::POS_HEAD : the script is inserted in the head section right before the title element.</li>
  * <li>CClientScript::POS_BEGIN : the script is inserted at the beginning of the body section.</li>
  * <li>CClientScript::POS_END : the script is inserted at the end of the body section.</li>
  * </ul>
  * @param array $htmlOptions additional HTML attributes
  * @return CClientScript the CClientScript object itself (to support method chaining, available since version 1.1.5).
  */
 public function registerScriptFile($url, $position = null, array $htmlOptions = array(), $level = 1)
 {
     $this->scriptFileLevels[$url] = $level;
     return parent::registerScriptFile($url, $position, $htmlOptions);
 }
示例#14
0
 public function registerScriptFile($url, $position = self::POS_HEAD, array $htmlOptions = array())
 {
     $url = strpos($url, '?') === false ? $url . '?v=' . $this->scriptVersion : $url . '&v=' . $this->scriptVersion;
     return parent::registerScriptFile($url, $position, $htmlOptions);
 }
示例#15
0
 public function registerScriptFile($url, $position = null, array $htmlOptions = array())
 {
     $url = $this->addAppVersion($url);
     //\Yii::log('URL regged:' . $url, 'info');
     return parent::registerScriptFile($url, $position, $htmlOptions);
 }
示例#16
0
 /**
  * Register JS file  and add revision to url
  *
  * @param string $url
  * @param string $position
  * @param array $htmlOptions
  * @param bool $isRevision
  * @return CClientScript
  */
 public function registerScriptFile($url, $position = null, array $htmlOptions = array(), $isRevision = true)
 {
     if ($isRevision) {
         $url = $url . $this->getRevision();
     }
     return parent::registerScriptFile($url, $position, $htmlOptions);
 }
示例#17
0
 /**
  * Registers a javascript file.
  * @param string $url URL of the javascript file
  * @param int|null $position the position of the JavaScript code. Valid values include the following:
  * <ul>
  * <li>CClientScript::POS_HEAD : the script is inserted in the head section right before the title element.</li>
  * <li>CClientScript::POS_BEGIN : the script is inserted at the beginning of the body section.</li>
  * <li>CClientScript::POS_END : the script is inserted at the end of the body section.</li>
  * </ul>
  * @param array $htmlOptions
  * @return YdClientScript the CClientScript object itself (to support method chaining, available since version 1.1.5).
  */
 public function registerScriptFile($url, $position = null, array $htmlOptions = array())
 {
     // do not load these scripts on ajax
     if (Yii::app()->request->isAjaxRequest) {
         foreach ($this->ignoreAjaxScriptFile as $ignore) {
             if ($this->endsWith($url, $ignore)) {
                 return $this;
             }
         }
     } else {
         foreach ($this->ignoreScriptFile as $ignore) {
             if ($this->endsWith($url, $ignore)) {
                 return $this;
             }
         }
     }
     return parent::registerScriptFile($url, $position, $htmlOptions);
 }
示例#18
0
 public function registerScriptFile($url, $position = null, array $options = array())
 {
     if (isset($options['order'])) {
         $order = $options['order'];
         unset($options['order']);
     } else {
         $order = null;
     }
     $order = CPropertyValue::ensureInteger($order);
     if ($order) {
         $this->orderScriptFiles[$position][$url] = $order;
     }
     return parent::registerScriptFile($url, $position, $options);
 }
示例#19
0
 public function registerScriptFile($url, $position = null, array $htmlOptions = array())
 {
     $url .= '?v=' . Yii::app()->params['version'];
     parent::registerScriptFile($url, $position, $htmlOptions);
     return $this;
 }
示例#20
0
 public function registerScriptFile($url, $position = self::POS_HEAD)
 {
     parent::registerScriptFile($this->absolutizeURL($url), $position);
 }
 /**
  * Registers the external javascript files
  */
 public function registerClientScripts()
 {
     if ($this->baseUrl === '') {
         throw new CException(Yii::t('EJqueryUiWidget', 'baseUrl must be set. This is done automatically by calling publishAssets()'));
     }
     $this->clientScript = Yii::app()->getClientScript();
     $this->clientScript->registerCoreScript('jquery');
     switch ($this->getCompression()) {
         case 'none':
             $this->clientScript->registerScriptFile($this->baseUrl . '/js/jquery-ui-1.7.1.custom.js');
             break;
         case 'packed':
             $this->clientScript->registerScriptFile($this->baseUrl . '/js/jquery-ui-1.7.1.custom.packed.js');
             break;
         default:
             $this->clientScript->registerScriptFile($this->baseUrl . '/js/jquery-ui-1.7.1.custom.min.js');
             break;
     }
     if ($this->getUseBundledStyleSheet()) {
         $this->clientScript->registerCssFile($this->baseUrl . '/css/' . $this->getTheme() . '/jquery-ui-1.7.1.custom.css');
     }
 }
 /**
  * @param string $path
  * @param int $position
  * @param string $defaultAssetUrl
  */
 public function registerScriptFile($path, $position = 0, array $htmlOptions = array())
 {
     $parsedPath = $this->_parseAssetsPath($path);
     if ($parsedPath) {
         return parent::registerScriptFile($this->_getFileUrl($parsedPath['assetsUrl'], $parsedPath['path']), $position, $htmlOptions);
     } else {
         return parent::registerScriptFile($path, $position, $htmlOptions);
     }
 }