Register js for ajax notifications
1780
protected function registerJs()
    {
        $config['options'] = $this->options;
        $config['layerOptions'] = $this->layerOptions;
        $config['layerOptions']['layerId'] = $this->layer->getLayerId();

        $config = Json::encode($config);
        $layerClass = Json::encode($this->layerClass);

        $this->view->registerJs("
            $.ajaxSetup({
                showNoty: true // default for all ajax calls
            });
            $(document).ajaxComplete(function (event, xhr, settings) {
                if (settings.showNoty && (settings.type=='POST' || settings.container)) {
                    $.ajax({
                        url: '$this->url',
                        method: 'POST',
                        cache: false,
                        showNoty: false,
                        global: false,
                        data: {
                            layerClass: '$layerClass',
                            config: '$config'
                        },
                        success: function(data) {
                           $('#" . $this->layer->getLayerId() . "').html(data);
                        }
                    });
                }
            });
        ", View::POS_END);
    }
475308
protected function registerJs()
	{
		if (static::$JS_REGISTERED) return;

		JqueryAsset::register($this->getView());
		BootstrapAsset::register($this->getView());

		$js = new JsExpression(<<<JS
			var widgetClass = 'widget-memory-tabs';
			var storageName = 'widget-memory-tabs';

			var hasStorage = function() {
				var test = 'test';
				try {
					{$this->storageType}.setItem(test, test);
					{$this->storageType}.removeItem(test);
					return true;
				} catch(e) {
					return false;
				}
			};

			if (hasStorage) {

				var loadData = function() {
					var dataStr = {$this->storageType}.getItem(storageName);
					if (dataStr == null) return {};
					return JSON.parse(dataStr);
				};

				var saveData = function(dataObj) {
					dataStr = JSON.stringify(dataObj);
					{$this->storageType}.setItem(storageName, dataStr);
				};

				var activateIndex = function(tabId, index) {
					var tab = $('#' + tabId);
					var items = tab.children('li');
					if (items.length <= index) return;

					$('#' + tabId + ' li:eq(' + index + ') a').tab('show');
				};
				
				var getBaseUrlByAnchor = function(url) {
					var hashTagIndex = url.indexOf('#',0);
					if (hashTagIndex === -1) return null;
					return url.substring(0, hashTagIndex);
				};

				var initIndexes = function() {
					var data = loadData();
					var curUrl = window.location.href;
					if (data[curUrl] == null) {
						var baseUrl = getBaseUrlByAnchor(curUrl);
						if (baseUrl === null) {
							return;
						} else if (data[baseUrl] == null) {
							return;
						}
						curUrl = baseUrl;
					}
					var tabs = $('.' + widgetClass);
					tabs.each(function(i, el) {
						var tabId = $(this).attr('id');
						if (tabId != null) {
							var index = data[curUrl][tabId];
							activateIndex(tabId, index);
						}
					});
				};

				var setIndex = function(tabId, index) {
					var curUrl = window.location.href;
					var baseUrl = getBaseUrlByAnchor(curUrl);

					var data = loadData();
					
					if(data[curUrl] == null) {
						if (baseUrl !== null && data[baseUrl] == null) {
							data[baseUrl] = {};
						} else if (baseUrl === null) {
							data[curUrl] = {};
						} else {
							curUrl = baseUrl;
						}
					}

					data[curUrl][tabId] = index;

					saveData(data);
				};

				$('.widget-memory-tabs > li > a').mouseup(function(event) {
					var tabs = $(this).closest('.' + widgetClass);
					var selectedIndex = $(this).parent().prevAll().length;

					setIndex(tabs.attr('id'), selectedIndex);
				});

				initIndexes();
			}
JS
);
		$this->view->registerJs($js);

		static::$JS_REGISTERED = true;
	}
923636
function show_notification(msg, type, reload_page, timeout){
    // defaults to false
    reload_page = reload_page || false;
    timeout = timeout || 3000;

    $('#notify_message').removeClass();
    $('#notify_message').addClass('notify_message-' + type);
    $('#notify_message').html(msg);
    $('#notify_message').slideDown(600).delay(timeout).slideUp(600, function(){
        if(reload_page === true){
            location.reload();
        }
    });
}
786946
protected function registerClientScript()
	{
		$view = $this->getView();
		UMeditorAsset::register($view);
		$id = $this->options['id'];
		$options = Json::encode($this->clientOptions);
		$js = "window.um = UM.getEditor('$id', $options);";
		$view->registerJs($js, $view::POS_READY);
	}
1147628
protected function renderJs() {
        $id = $this->options['id'];
        $options = $this->getOptionsObject();

        $this->getView()->registerJs("$('#$id').remainingCharacters($options);");
    }
222941
def register_event(self, event):
        """"""

        self.log('Registering event hook:', event.cmd, event.thing,
                 pretty=True, lvl=verbose)
        self.hooks[event.cmd] = event.thing
1292141
public function registerClientScript() {
        $view = $this->getView();
        $assetBundle = $this->assetBundle instanceof AssetBundle ? $this->assetBundle : Asset::register($view);

        if (array_key_exists('language', $this->options) && $this->options['language'] !== null) {
            $assetBundle->language = $this->options['language'];
        }

        $selector = $this->selector === null ? '#' . $this->htmlOptions['id'] : $this->selector;
        $options = Json::encode($this->options);

        $view->registerJs("jQuery('$selector').gtreetable($options);");
    }
1304983
public function registerClientScript()
	{
		$view = $this->getView();
		TwbsMaxlengthAsset::register($view);

		$options = empty($this->clientOptions) ? "{}" : Json::encode($this->clientOptions);
		if( isset($this->selector)) {
			$js = "jQuery(\"{$this->selector}\").maxlength(" . $options . ")";
		} else {
			$js = "jQuery(\"#{$this->options['id']}\").maxlength(" . $options . ")";
		}
		$view->registerJs($js);
	}
1279885
protected function registerClientScript()
    {
        /* publish assets dir */
        $path = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'assets';
        $assetsUrl = $this->getAssetsUrl($path);

        /* @var $cs CClientScript */
        $cs = Yii::app()->getClientScript();

        $cs->registerScriptFile($assetsUrl . '/js/highcharts.js');

        /* register required files */
        $defaultOptions = array('exporting' => array('enabled' => true));

        $this->pluginOptions = CMap::mergeArray($defaultOptions, $this->pluginOptions);

        if (isset($this->pluginOptions['exporting']) && @$this->pluginOptions['exporting']['enabled']) {
            $cs->registerScriptFile($assetsUrl . '/js/modules/exporting.js');
        }

        if ($theme = TbArray::getValue('theme', $this->pluginOptions)) {
            $cs->registerScriptFile($assetsUrl . '/js/themes/' . $theme . '.js');
        }

        $options = CJavaScript::encode($this->pluginOptions);

        $cs->registerScript(
            __CLASS__ . '#' . $this->getId(),
            "var highchart{$this->getId()} = new Highcharts.Chart({$options});"
        );
    }
29507
def register_event(id, info = EMPTY_HASH)
      Notifications.events[id] = Event.new(id, info)
    end
882549
public function registerClientScript()
    {
        $this->options['element'] = new JsExpression("jQuery('#{$this->options['id']}')[0]");
        $mdeOptions = Json::encode($this->mdeOptions);
        $mdeName = Inflector::classify('editor' . $this->options['id']);
        $js = "var {$mdeName} = new SimpleMDE({$mdeOptions});";
        $this->getView()->registerJs($js);
    }
300850
protected function registerAssets()
    {

        if (\is_array($this->ajaxSettings)) {
            $this->ajaxSettings = explode(',', $this->ajaxSettings);
        }

        $this->view->registerJs(<<<JS
$(document).on('click','button[data-ajax-button-id]', 'click', function() {
    var button = $(this);
    $.ajax({
        url : button.data('ajax-button-url'),
        type : button.data('ajax-button-method'),
        data : button.data('ajax-button-params'),
        {$this->jsCallback($this->errorExpression, 'error')}
        {$this->jsCallback($this->successExpression, 'success')}
        {$this->ajaxSettings}
    });
});
JS
        );
    }
426937
protected function registerClientScript()
    {
        $id = $this->options['id'];
        $view = $this->getView();
        $option = !empty($this->pluginOptions['option']) ? Json::encode($this->pluginOptions['option']) : '{}';

        if ($this->theme) {
            $js = "var {$this->clientId} = echarts.init(document.getElementById('{$id}'), " . $this->quote($this->theme) . ");";
        } else {
            $js = "var {$this->clientId} = echarts.init(document.getElementById('{$id}'));";
        }
        $js .= "{$this->clientId}.setOption({$option});";
        if (isset($this->pluginOptions['group'])) {
            $js .= "{$this->clientId}.group = " . $this->quote($this->pluginOptions['group']) . ";";
        }
        if ($this->responsive) {
            $js .= "$(window).resize(function () {{$this->clientId}.resize()});";
        }
        foreach ($this->pluginEvents as $name => $handlers) {
            $handlers = (array) $handlers;
            foreach ($handlers as $handler) {
                $js .= "{$this->clientId}.on(" . $this->quote($name) . ", $handler);";
            }
        }

        EChartsAsset::register($view);
        $view->registerJs($js);
    }
789600
public function registerJSVariables()
    {
        $object = json_encode($this->localizationData());

        $this->app['hook.factory']->action('wp_head', function () use ($object) {
            echo "<script>var Assely = {$object};</script>";
        })->dispatch();
    }
1294099
private function register_event_listener() {

		$cron_array = _get_cron_array();
		if ( ! $cron_array ) {
			return;
		}

		$hooks = array_reduce(
			$cron_array,
			function ( $hooks, $crons ) {

				return array_merge( $hooks, array_keys( $crons ) );
			},
			[]
		);

		$profile_cb = function () {

			$this->cron_action_profile();
		};

		array_walk(
			$hooks,
			function ( $hook ) use ( $profile_cb ) {

				// Please note that "(int) ( PHP_INT_MAX + 1 )" is the lowest possible integer.
				add_action( $hook, $profile_cb, (int) ( PHP_INT_MAX + 1 ) );
				add_action( $hook, $profile_cb, PHP_INT_MAX );
			}
		);

		self::$ran = TRUE;
	}
1374032
function ajaxBeforeSend(xhr, settings) {
        var context = settings.context;
        if (settings.beforeSend.call(context, xhr, settings) === false || triggerGlobal(settings, context, 'ajaxBeforeSend', [
                xhr,
                settings
            ]) === false)
            return false;

        triggerGlobal(settings, context, 'ajaxSend', [
            xhr,
            settings
        ]);
    }
563454
public function registerClientScript()
	{
		$id=$this->getId();

		if($this->ajaxUpdate===false)
			$ajaxUpdate=false;
		else
			$ajaxUpdate=array_unique(preg_split('/\s*,\s*/',$this->ajaxUpdate.','.$id,-1,PREG_SPLIT_NO_EMPTY));
		$options=array(
			'ajaxUpdate'=>$ajaxUpdate,
			'ajaxVar'=>$this->ajaxVar,
			'pagerClass'=>$this->pagerCssClass,
			'loadingClass'=>$this->loadingCssClass,
			'filterClass'=>$this->filterCssClass,
			'tableClass'=>$this->itemsCssClass,
			'selectableRows'=>$this->selectableRows,
			'enableHistory'=>$this->enableHistory,
			'updateSelector'=>$this->updateSelector,
			'filterSelector'=>$this->filterSelector
		);
		if($this->ajaxUrl!==null)
			$options['url']=CHtml::normalizeUrl($this->ajaxUrl);
		if($this->ajaxType!==null) {
			$options['ajaxType']=strtoupper($this->ajaxType);
			$request=Yii::app()->getRequest();
			if ($options['ajaxType']=='POST' && $request->enableCsrfValidation) {
				$options['csrfTokenName']=$request->csrfTokenName;
				$options['csrfToken']=$request->getCsrfToken();
			}
		}
		if($this->enablePagination)
			$options['pageVar']=$this->dataProvider->getPagination()->pageVar;
		foreach(array('beforeAjaxUpdate', 'afterAjaxUpdate', 'ajaxUpdateError', 'selectionChanged') as $event)
		{
			if($this->$event!==null)
			{
				if($this->$event instanceof CJavaScriptExpression)
					$options[$event]=$this->$event;
				else
					$options[$event]=new CJavaScriptExpression($this->$event);
			}
		}

		$options=CJavaScript::encode($options);
		$cs=Yii::app()->getClientScript();
		$cs->registerCoreScript('jquery');
		$cs->registerCoreScript('bbq');
		if($this->enableHistory)
			$cs->registerCoreScript('history');
		$cs->registerScriptFile($this->baseScriptUrl.'/jquery.yiigridview.js',CClientScript::POS_END);
		$cs->registerScript(__CLASS__.'#'.$id,"jQuery('#$id').yiiGridView($options);");
	}