コード例 #1
0
ファイル: X2ClientScript.php プロジェクト: tymiles003/X2CRM
 /**
  * Performs all the necessary JavaScript/CSS initializations for most parts of the app.
  */
 public function registerMain()
 {
     $fullscreen = $this->fullscreen;
     $profile = $this->profile;
     $baseUrl = $this->baseUrl;
     $themeUrl = $this->themeUrl;
     $scriptUrl = $this->scriptUrl;
     $admin = $this->admin;
     $isGuest = $this->isGuest;
     // jQuery and jQuery UI libraries
     $this->registerCoreScript('jquery')->registerCoreScript('jquery.ui')->registerCoreScript('jquery.migrate')->registerCoreScript('bbq');
     $this->registerPackages($this->getDefaultPackages());
     $cldScript = $this->getCurrencyConfigScript();
     AuxLib::registerPassVarsToClientScriptScript('auxlib', array('saveMiscLayoutSettingUrl' => "'" . addslashes(Yii::app()->createUrl('/profile/saveMiscLayoutSetting')) . "'"), 'passAuxLibVars');
     $this->registerX2ModelMappingsScript();
     $this->registerX2Forms();
     $this->registerX2QuickCRUD();
     $this->registerX2Flashes();
     Yii::app()->clientScript->registerScript('csrfTokenScript', "\n            x2.csrfToken = '" . Yii::app()->request->getCsrfToken() . "';\n        ", CClientScript::POS_HEAD);
     $this->registerAttachments();
     $this->registerDateFormats();
     if (YII_DEBUG) {
         $this->registerScriptFile($baseUrl . '/js/Timer.js');
     }
     Yii::app()->clientScript->registerPackage('spectrum');
     // custom scripts
     $this->registerScriptFile($baseUrl . '/js/json2.js')->registerScriptFile($baseUrl . '/js/lib/lodash/lodash.js', self::POS_END)->registerScriptFile($baseUrl . '/js/webtoolkit.sha256.js')->registerScriptFile($baseUrl . '/js/main.js', CCLientScript::POS_HEAD)->registerScriptFile($baseUrl . '/js/auxlib.js', CClientScript::POS_HEAD)->registerScriptFile($baseUrl . '/js/IframeFixOverlay.js', CClientScript::POS_HEAD)->registerScriptFile($baseUrl . '/js/LayoutManager.js')->registerScriptFile($baseUrl . '/js/media.js')->registerScript('formatCurrency-locales', $cldScript, CCLientScript::POS_HEAD)->registerScriptFile($baseUrl . '/js/modernizr.custom.66175.js')->registerScriptFile($baseUrl . '/js/widgets.js')->registerScriptFile($baseUrl . '/js/qtip/jquery.qtip.js')->registerScriptFile($baseUrl . '/js/ActionFrames.js')->registerScriptFile($baseUrl . '/js/ColorPicker.js', CCLientScript::POS_END)->registerScriptFile($baseUrl . '/js/PopupDropdownMenu.js', CCLientScript::POS_END)->registerScriptFile($baseUrl . '/js/jQueryOverrides.js', CCLientScript::POS_END)->registerScriptFile($baseUrl . '/js/checklistDropdown/jquery.multiselect.js');
     $this->registerTestingScripts();
     $this->registerDebuggingScripts();
     if (AuxLib::isIPad()) {
         $this->registerScriptFile($baseUrl . '/js/jquery.mobile.custom.js');
     }
     $this->registerInitScript();
     $this->registerAuxLibTranslationsScript();
     if (Yii::app()->session['translate']) {
         $this->registerScriptFile($baseUrl . '/js/translator.js');
     }
     $this->registerScriptFile($baseUrl . '/js/backgroundFade.js');
     $this->registerScript('datepickerLanguage', "\n            \$.datepicker.setDefaults(\$.datepicker.regional['']);\n        ");
     $mmPath = Yii::getPathOfAlias('application.extensions.moneymask.assets');
     $aMmPath = Yii::app()->getAssetManager()->publish($mmPath);
     $this->registerScriptFile("{$aMmPath}/jquery.maskMoney.js");
     $this->registerCssFile($baseUrl . '/css/normalize.css', 'all')->registerCssFile($themeUrl . '/css/print.css', 'print')->registerCoreScript('cookie');
     $this->registerCombinedCss();
     if (AuxLib::getLayoutType() !== 'responsive' && AuxLib::isAndroid()) {
         $this->registerCssFile($themeUrl . '/css/androidLayout.css', 'screen, projection');
     } elseif (AuxLib::isIPad()) {
         $this->registerCssFile($themeUrl . '/css/ipadLayout.css', 'screen, projection');
     }
     $this->registerScript('fullscreenToggle', '
         window.enableFullWidth = ' . (!Yii::app()->user->isGuest ? $profile->enableFullWidth ? 'true' : 'false' : 'true') . ';
         window.fullscreen = ' . ($fullscreen ? 'true' : 'false') . ';
     ', CClientScript::POS_HEAD);
     if (is_object(Yii::app()->controller->module)) {
         $this->registerScript('saveCurrModule', "\n                x2.currModule = '" . Yii::app()->controller->module->name . "';\n            ", CClientScript::POS_HEAD);
     }
     if (!$isGuest) {
         $this->registerScript('notificationsParams', "\n                x2.notifications = new x2.Notifs ({\n                    disablePopup: " . ($profile->disableNotifPopup ? 'true' : 'false') . ",\n                    translations: {\n                        clearAll: '" . addslashes(Yii::t('app', 'Permanently delete all notifications?')) . "'\n                    }\n                });\n            ", CClientScript::POS_READY);
         $this->registerScriptFile($baseUrl . '/js/jstorage.min.js')->registerScriptFile($baseUrl . '/js/notifications.js', CClientScript::POS_BEGIN);
     }
     if (!$isGuest && ($profile->language == 'he' || $profile->language == 'fa')) {
         $this->registerCss('rtl-language', 'body{text-align:right;}');
     }
     $this->registerCoreScript('rating');
 }
コード例 #2
0
 /**
  * Returns a JS string which declares two global JS dictionaries if they haven't already been 
  * declared. Additional properties of the yii global are declared if the user has a profile.
  * The globals would already have been decalared in the case that this is an AJAX request in 
  * which registered scripts are being sent back in response to the client.
  *
  * @param object if set, additional profile specific properties are declared
  * @returns string A JS string
  */
 public function getJSGlobalsSetupScript($profile = null)
 {
     if ($profile) {
         $notificationSound = '';
         if (!empty($profile->notificationSound) && is_numeric($profile->notificationSound)) {
             $notificationSound = Yii::app()->createExternalUrl('/media/media/getFile', array('id' => $profile->notificationSound));
         }
     }
     $yii = array('baseUrl' => $this->owner->baseUrl, 'absoluteBaseUrl' => $this->owner->absoluteBaseUrl, 'scriptUrl' => $this->owner->request->scriptUrl, 'themeBaseUrl' => $this->owner->theme->baseUrl, 'language' => $this->owner->language == 'en' ? '' : $this->owner->getLanguage(), 'datePickerFormat' => Formatter::formatDatePicker('medium'), 'timePickerFormat' => Formatter::formatTimePicker());
     if ($profile) {
         $yii['profile'] = $profile->getAttributes();
         $yii['notificationSoundPath'] = $notificationSound;
     }
     $x2 = array('DEBUG' => YII_DEBUG, 'DEV_MODE' => X2_DEV_MODE, 'UNIT_TESTING' => YII_UNIT_TESTING, 'isGuest' => !$this->owner->params->noSession && $this->owner->user->getIsGuest(), 'notifUpdateInterval' => $this->settings->chatPollTime, 'isAndroid' => AuxLib::isAndroid(), 'isIPad' => AuxLib::isIPad(), 'isMobileApp' => $this->isMobileApp(), 'isPhoneGap' => $this->isPhoneGap());
     $setX2 = '';
     foreach ($x2 as $key => $val) {
         $setX2 .= "x2.{$key} = " . CJSON::encode($val) . ";\n";
     }
     return '
         ;(function () {
             if (typeof yii === "undefined") {
                 yii = ' . CJSON::encode($yii) . ';
             }
             if (typeof x2 === "undefined") {
                 x2 = {};
             }
             ' . $setX2 . '
         }) ();
     ';
 }
コード例 #3
0
 /**
  * Returns a JS string which declares two global JS dictionaries if they haven't already been 
  * declared. Additional properties of the yii global are declared if the user has a profile.
  * The globals would already have been decalared in the case that this is an AJAX request in 
  * which registered scripts are being sent back in response to the client.
  *
  * @param object if set, additional profile specific properties are declared
  * @returns string A JS string
  */
 public function getJSGlobalsSetupScript($profile = null)
 {
     if ($profile) {
         $notificationSound = '';
         if (!empty($profile->notificationSound) && is_numeric($profile->notificationSound)) {
             $notificationSound = Yii::app()->createExternalUrl('/media/media/getFile', array('id' => $profile->notificationSound));
         }
     }
     return '
         ;(function () {
             if (typeof yii === "undefined") {
                 yii = {
                     baseUrl: "' . $this->owner->baseUrl . '",
                     scriptUrl: "' . $this->owner->request->scriptUrl . '",
                     themeBaseUrl: "' . $this->owner->theme->baseUrl . '",
                     language: "' . ($this->owner->language == 'en' ? '' : $this->owner->getLanguage()) . '",
                     datePickerFormat: "' . Formatter::formatDatePicker('medium') . '",
                     timePickerFormat: "' . Formatter::formatTimePicker() . '"
                     ' . ($profile ? '
                         , profile: ' . CJSON::encode($profile->getAttributes()) . ',
                           notificationSoundPath: "' . $notificationSound . '"' : '') . '};
             }
             if (typeof x2 === "undefined") {
                 x2 = {};
             }
             x2.DEBUG = ' . (YII_DEBUG ? 'true' : 'false') . ';
             x2.UNIT_TESTING = ' . (YII_UNIT_TESTING ? 'true' : 'false') . ';
             x2.notifUpdateInterval = ' . $this->settings->chatPollTime . ';
             x2.isAndroid = ' . (AuxLib::isAndroid() ? 'true' : 'false') . ';
             x2.isIPad = ' . (AuxLib::isIPad() ? 'true' : 'false') . ';
         }) ();
     ';
 }