当前位置: 首页>>代码示例>>PHP>>正文


PHP Requirements::customScript方法代码示例

本文整理汇总了PHP中Requirements::customScript方法的典型用法代码示例。如果您正苦于以下问题:PHP Requirements::customScript方法的具体用法?PHP Requirements::customScript怎么用?PHP Requirements::customScript使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Requirements的用法示例。


在下文中一共展示了Requirements::customScript方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: FieldHolder

	function FieldHolder() {
		
		
		Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/prototype/prototype.js');
		Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/behaviour/behaviour.js');
		Requirements::javascript(SAPPHIRE_DIR . '/javascript/prototype_improvements.js');
		Requirements::javascript(THIRDPARTY_DIR . '/scriptaculous/effects.js');
		Requirements::add_i18n_javascript(SAPPHIRE_DIR . '/javascript/lang');
		Requirements::javascript(SAPPHIRE_DIR . '/javascript/TableListField.js');
		
		// swap the js file
		Requirements::block(SAPPHIRE_DIR . '/javascript/TableField.js');
		Requirements::javascript('modifiedtablefield/javascript/ModifiedTableField.js');
		
		
		Requirements::css(SAPPHIRE_DIR . '/css/TableListField.css');
		

		$defaults = $this->fieldDefaults;
		if ($this->fieldDefaults == null && !is_array($this->fieldDefaults)) {
			$sourceClass = $this->sourceClass;
			
			$defaults = singleton($sourceClass)->stat('defaults');
		}
		
		if (count($defaults) > 0) {
			Requirements::customScript("var ".$this->name."_fieldDefaults = ".Convert::array2json($defaults));
		}
		
		
		return $this->renderWith($this->template);
	}
开发者ID:nathancox,项目名称:silverstripe-modifiedtablefield,代码行数:32,代码来源:ModifiedTableField.php

示例2: init

    public function init()
    {
        // Send default settings according to locale
        $locale = i18n::get_locale();
        $symbols = Zend_Locale_Data::getList($locale, 'symbols');
        $currency = Currency::config()->currency_symbol;
        $decimals = $symbols['decimal'];
        $thousands = $decimals == ',' ? ' ' : ',';
        // Accouting needs to be initialized globally
        FormExtraJquery::include_accounting();
        Requirements::customScript(<<<EOT
    window.accounting.settings = {
        currency: {
            symbol : "{$currency}",
            format: "%s%v",
            decimal : "{$decimals}",
            thousand: "{$thousands}",
            precision : 2
        },
        number: {
            precision : 0,
            thousand: "{$thousands}",
            decimal : "{$decimals}"
        }
    }
EOT
, 'accountingInit');
    }
开发者ID:helpfulrobot,项目名称:lekoala-silverstripe-form-extras,代码行数:28,代码来源:FormExtraLeftAndMainExtension.php

示例3: Field

    public function Field($properties = array())
    {
        Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery/jquery.min.js');
        Requirements::javascript('geoform/javascript/jquery.geocomplete.js');
        if (GoogleMaps::getApiKey()) {
            Requirements::javascript('//maps.googleapis.com/maps/api/js?sensor=false&libraries=places&language=' . i18n::get_tinymce_lang() . '&key=' . GoogleMaps::getApiKey());
        } else {
            Requirements::javascript('//maps.googleapis.com/maps/api/js?sensor=false&libraries=places&language=' . i18n::get_tinymce_lang());
        }
        $name = $this->getName();
        $this->fieldAddress->setPlaceholder(_t('GeoLocationField.ADDRESSPLACEHOLDER', 'Address'));
        // set caption if required
        $js = <<<JS
(function(\$){
    \$(function(){
        \$("#{$name}-Address").geocomplete().bind("geocode:result", function(event, result){
            \$("#{$name}-Latitude").val(result.geometry.location.lat());
            \$("#{$name}-Longditude").val(result.geometry.location.lng());
        });
    });
})(jQuery);
JS;
        Requirements::customScript($js, 'BootstrapGeoLocationField_Js_' . $this->ID());
        $css = <<<CSS
/* make the location suggest dropdown appear above dialog */
.pac-container {
    z-index: 2000 !important;
}
CSS;
        Requirements::customCSS($css, 'BootstrapGeoLocationField_Css_' . $this->ID());
        return $this->fieldLatitude->Field() . $this->fieldLongditude->Field() . '<div class="row">' . '<div class="col-sm-12">' . $this->fieldAddress->Field() . '</div>' . '</div>';
    }
开发者ID:EduardMa,项目名称:silverstripe-bootstrap_extra_fields,代码行数:32,代码来源:BootstrapGeoLocationField.php

示例4: jsValidation

    function jsValidation()
    {
        $formID = $this->form->FormName();
        $error = _t('DateField.VALIDATIONJS', 'Please enter a valid date format (DD/MM/YYYY).');
        $jsFunc = <<<JS
Behaviour.register({
\t"#{$formID}": {
\t\tvalidateDate: function(fieldName) {
\t\t\tvar el = _CURRENT_FORM.elements[fieldName];
\t\t\tvar value = \$F(el);
\t\t\t
\t\t\tif(value && value.length > 0 && !value.match(/^[0-9]{1,2}\\/[0-9]{1,2}\\/[0-90-9]{2,4}\$/)) {
\t\t\t\tvalidationError(el,"{$error}","validation",false);
\t\t\t\treturn false;
\t\t\t}
\t\t\treturn true;
\t\t}
\t}
});
JS;
        Requirements::customScript($jsFunc, 'func_validateDate_' . $formID);
        //		return "\$('$formID').validateDate('$this->name');";
        return <<<JS
if(\$('{$formID}')){
\tif(typeof fromAnOnBlur != 'undefined'){
\t\tif(fromAnOnBlur.name == '{$this->name}')
\t\t\t\$('{$formID}').validateDate('{$this->name}');
\t}else{
\t\t\$('{$formID}').validateDate('{$this->name}');
\t}
}
JS;
    }
开发者ID:racontemoi,项目名称:shibuichi,代码行数:33,代码来源:DateField.php

示例5: jsValidation

    function jsValidation()
    {
        $formID = $this->form->FormName();
        $error = _t('EmailField.VALIDATIONJS', 'Please enter an email address.');
        $jsFunc = <<<JS
Behaviour.register({
\t"#{$formID}": {
\t\tvalidateEmailField: function(fieldName) {
\t\t\tvar el = _CURRENT_FORM.elements[fieldName];
\t\t\tif(!el || !el.value) return true;

\t\t \tif(el.value.match(/^[a-z0-9!#\$%&'*+\\/=?^_`{|}~-]+(?:\\.[a-z0-9!#\$%&'*+\\/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\$/i)) {
\t\t \t\treturn true;
\t\t \t} else {
\t\t\t\tvalidationError(el, "{$error}","validation");
\t\t \t\treturn false;
\t\t \t} \t
\t\t}
\t}
});
JS;
        //fix for the problem with more than one form on a page.
        Requirements::customScript($jsFunc, 'func_validateEmailField' . '_' . $formID);
        //return "\$('$formID').validateEmailField('$this->name');";
        return <<<JS
if(typeof fromAnOnBlur != 'undefined'){
\tif(fromAnOnBlur.name == '{$this->name}')
\t\t\$('{$formID}').validateEmailField('{$this->name}');
}else{
\t\$('{$formID}').validateEmailField('{$this->name}');
}
JS;
    }
开发者ID:SustainableCoastlines,项目名称:loveyourwater,代码行数:33,代码来源:EmailField.php

示例6: init

 public function init()
 {
     parent::init();
     $themeDir = SSViewer::get_theme_folder();
     Requirements::javascript('framework/thirdparty/jquery/jquery.js');
     if (Locator::getLocations()) {
         Requirements::javascript('http://maps.google.com/maps/api/js?sensor=false');
         Requirements::javascript('locator/thirdparty/handlebars/handlebars-v1.3.0.js');
         Requirements::javascript('locator/thirdparty/jquery-store-locator/js/jquery.storelocator.js');
     }
     Requirements::css('locator/css/map.css');
     $featured = Locator::getLocations(array('Featured' => 1))->count() > 0 ? 'featuredLocations: true' : 'featuredLocations: false';
     // map config based on user input in Settings tab
     // AutoGeocode or Full Map
     $load = $this->data()->AutoGeocode ? 'autoGeocode: true, fullMapStart: false,' : 'autoGeocode: false, fullMapStart: true, storeLimit: 1000, maxDistance: true,';
     $base = Director::baseFolder();
     $themePath = $base . '/' . $themeDir;
     $listTemplatePath = file_exists($themePath . '/templates/location-list-description.html') ? $themeDir . '/templates/location-list-description.html' : 'locator/templates/location-list-description.html';
     $infowindowTemplatePath = file_exists($themePath . '/templates/infowindow-description.html') ? $themeDir . '/templates/infowindow-description.html' : 'locator/templates/infowindow-description.html';
     // in page or modal
     $modal = $this->data()->ModalWindow ? 'modalWindow: true' : 'modalWindow: false';
     $kilometer = $this->data()->Unit == 'km' ? 'lengthUnit: "km"' : 'lengthUnit: "m"';
     $link = $this->Link() . 'xml.xml';
     // init map
     if (Locator::getLocations()) {
         Requirements::customScript("\n                \$(function(\$) {\n                    \$('#map-container').storeLocator({\n                        " . $load . "\n                        dataLocation: '" . $link . "',\n                        listTemplatePath: '" . $listTemplatePath . "',\n                        infowindowTemplatePath: '" . $infowindowTemplatePath . "',\n                        originMarker: true,\n                        " . $modal . ',
                     ' . $featured . ",\n                        slideMap: false,\n                        zoomLevel: 0,\n                        distanceAlert: 120,\n                        formID: 'Form_LocationSearch',\n                        inputID: 'Form_LocationSearch_address',\n                        categoryID: 'Form_LocationSearch_category',\n                        distanceAlert: -1,\n                        " . $kilometer . '
                 });
             });
         ');
     }
 }
开发者ID:jeffwhitfield,项目名称:silverstripe-locator,代码行数:32,代码来源:Locator.php

示例7: init

    public function init()
    {
        parent::init();
        // Concatenate CSS
        Requirements::combine_files('style.css', array('mysite/css/layout.css', 'mysite/css/userstyles.css'));
        // Concatenate JavaScript
        Requirements::combine_files('scripts.js', array('mysite/javascript/lib/top-nav.js', 'mysite/javascript/vanilla.js'));
        // Google Analytics
        $config = SiteConfig::current_site_config();
        $google = $config->GACode;
        $gaJS = <<<JS
            (function(i, s, o, g, r, a, m) {
                i['GoogleAnalyticsObject'] = r;
                i[r] = i[r] || function() {
                    (i[r].q = i[r].q || []).push(arguments)
                }, i[r].l = 1 * new Date();
                a = s.createElement(o), m = s.getElementsByTagName(o)[0];
                a.async = 1;
                a.src = g;
                m.parentNode.insertBefore(a, m)
            })(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');
            ga('create', '{$google}', 'auto');
            ga('send', 'pageview');
JS;
        Requirements::customScript($gaJS);
    }
开发者ID:digi-brains,项目名称:Silver-Stream,代码行数:26,代码来源:Page.php

示例8: __construct

    /**
     * Constructor.
     *
     * @param Controller $controller
     * @param string $name method on the $controller
     * @param FieldList $fields
     * @param FieldList $actions
     * @param bool $checkCurrentUser - show logout button if logged in
     */
    public function __construct($controller, $name, $fields = null, $actions = null, $checkCurrentUser = true)
    {
        parent::__construct($controller, $name, $fields, $actions, $checkCurrentUser);
        // will be used to get correct Link()
        $this->ldapSecController = Injector::inst()->create('LDAPSecurityController');
        $usernameField = new TextField('Username', _t('Member.USERNAME', 'Username'), null, null, $this);
        $this->Fields()->replaceField('Email', $usernameField);
        $this->setValidator(new RequiredFields('Username', 'Password'));
        if (Security::config()->remember_username) {
            $usernameField->setValue(Session::get('SessionForms.MemberLoginForm.Email'));
        } else {
            // Some browsers won't respect this attribute unless it's added to the form
            $this->setAttribute('autocomplete', 'off');
            $usernameField->setAttribute('autocomplete', 'off');
        }
        // Users can't change passwords unless appropriate a LDAP user with write permissions is
        // configured the LDAP connection binding
        $this->Actions()->remove($this->Actions()->fieldByName('forgotPassword'));
        $allowPasswordChange = Config::inst()->get('LDAPService', 'allow_password_change');
        if ($allowPasswordChange && $name != 'LostPasswordForm' && !Member::currentUser()) {
            $forgotPasswordLink = sprintf('<p id="ForgotPassword"><a href="%s">%s</a></p>', $this->ldapSecController->Link('lostpassword'), _t('Member.BUTTONLOSTPASSWORD', "I've lost my password"));
            $forgotPassword = new LiteralField('forgotPassword', $forgotPasswordLink);
            $this->Actions()->add($forgotPassword);
        }
        // Focus on the Username field when the page is loaded
        Requirements::block('MemberLoginFormFieldFocus');
        $js = <<<JS
\t\t\t(function() {
\t\t\t\tvar el = document.getElementById("Username");
\t\t\t\tif(el && el.focus && (typeof jQuery == 'undefined' || jQuery(el).is(':visible'))) el.focus();
\t\t\t})();
JS;
        Requirements::customScript($js, 'LDAPLoginFormFieldFocus');
    }
开发者ID:andrewandante,项目名称:silverstripe-activedirectory,代码行数:43,代码来源:LDAPLoginForm.php

示例9: getGoogleSiteSearchForm

 /**
  * returns the form
  * @return Form
  */
 public function getGoogleSiteSearchForm($name = "GoogleSiteSearchForm")
 {
     $formIDinHTML = "Form_" . $name;
     if ($page = GoogleCustomSearchPage::get()->first()) {
         Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js');
         Requirements::javascript('googlecustomsearch/javascript/GoogleCustomSearch.js');
         $apiKey = Config::inst()->get("GoogleCustomSearchExt", "api_key");
         $cxKey = Config::inst()->get("GoogleCustomSearchExt", "cx_key");
         if ($apiKey && $cxKey) {
             Requirements::customScript("\n\t\t\t\t\t\tGoogleCustomSearch.apiKey = '" . $apiKey . "';\n\t\t\t\t\t\tGoogleCustomSearch.cxKey = '" . $cxKey . "';\n\t\t\t\t\t\tGoogleCustomSearch.formSelector = '#" . $formIDinHTML . "';\n\t\t\t\t\t\tGoogleCustomSearch.inputFieldSelector = '#" . $formIDinHTML . "_search';\n\t\t\t\t\t\tGoogleCustomSearch.resultsSelector = '#" . $formIDinHTML . "_Results';\n\t\t\t\t\t", "GoogleCustomSearchExt");
             $form = new Form($this->owner, 'GoogleSiteSearchForm', new FieldList($searchField = new TextField('search'), $resultField = new LiteralField($name . "_Results", "<div id=\"" . $formIDinHTML . "_Results\"></div>")), new FieldList(new FormAction('doSearch', _t("GoogleCustomSearchExt.GO", "Full Results"))));
             $form->setFormMethod('GET');
             if ($page = GoogleCustomSearchPage::get()->first()) {
                 $form->setFormAction($page->Link());
             }
             $form->disableSecurityToken();
             $form->loadDataFrom($_GET);
             $searchField->setAttribute("autocomplete", "off");
             $form->setAttribute("autocomplete", "off");
             return $form;
         } else {
             user_error("You must set an API Key and a CX key in your configs to use the Google Custom Search Form", E_USER_NOTICE);
         }
     } else {
         user_error("You must create a GoogleCustomSearchPage first.", E_USER_NOTICE);
     }
 }
开发者ID:helpfulrobot,项目名称:sunnysideup-googlecustomsearch,代码行数:31,代码来源:GoogleCustomSearchExt.php

示例10: init

 public function init()
 {
     parent::init();
     // Note: you should use SS template require tags inside your templates
     // instead of putting Requirements calls here.  However these are
     // included so that our older themes still work
     Requirements::css('themes/simple/css/homepage.css');
     Requirements::customScript('
             $("a.scroll-arrow").mousedown( function(e) {
                          e.preventDefault();              
           			var container = $(this).parent().attr("id");                              
                            var direction = $(this).is("#scroll-right") ? "+=" : "-=";
                            var totalWidth = -$(".row__inner").width();
                            $(".row__inner .tile").each(function() {
                                totalWidth += $(this).outerWidth(true);
                            });
                            
                            $("#"+ container + " .row__inner").animate({
                                scrollLeft: direction + Math.min(totalWidth, 3000)
                                
                            },{
                                duration: 2500,
                                easing: "swing", 
                                queue: false }
                            );
                        }).mouseup(function(e) {
                          $(".row__inner").stop();
            });');
 }
开发者ID:jareddreyer,项目名称:catalogue,代码行数:29,代码来源:Page.php

示例11: jsValidation

    function jsValidation()
    {
        $formID = $this->form->FormName();
        $error = _t('NumericField.VALIDATIONJS', 'is not a number, only numbers can be accepted for this field');
        $jsFunc = <<<JS
Behaviour.register({
\t"#{$formID}": {
\t\tvalidateNumericField: function(fieldName) {\t
\t\t\t\tel = _CURRENT_FORM.elements[fieldName];
\t\t\t\tif(!el || !el.value) return true;
\t\t\t\t
\t\t\t \tif(el.value.match(/^\\s*(\\-?[0-9]+(\\.[0-9]+)?\\s*\$)/)) { 
\t\t\t \t\treturn true;
\t\t\t \t} else {
\t\t\t\t\tvalidationError(el, "'" + el.value + "' {$error}","validation");
\t\t\t \t\treturn false;
\t\t\t \t}
\t\t\t}
\t}
});
JS;
        Requirements::customScript($jsFunc, 'func_validateNumericField');
        //return "\$('$formID').validateNumericField('$this->name');";
        return <<<JS
if(typeof fromAnOnBlur != 'undefined'){
\tif(fromAnOnBlur.name == '{$this->name}')
\t\t\$('{$formID}').validateNumericField('{$this->name}');
}else{
\t\$('{$formID}').validateNumericField('{$this->name}');
}
JS;
    }
开发者ID:Raiser,项目名称:Praktikum,代码行数:32,代码来源:NumericField.php

示例12: init

    public function init()
    {
        parent::init();
        // Page Specific Includes
        Requirements::customScript('
		 
		  //VITALSCRIPT!!!
		  jQuery("a.sendmessage").bind("click", function(){
			 var myval = $(this).attr("id");
			 jQuery("#SendForm_SendForm_CleanupID").attr("value", myval);
		  });


		  jQuery(".invite").fancybox({
			  "titleShow"		: "false",
			  "transitionIn"		: "elastic",
			  "transitionOut"		: "elastic"
			});

		  //VITALSCRIPT!!!
		  jQuery("a.invite").bind("click", function(){
			 var myval = $(this).attr("id");
			 jQuery("#InviteForm_InviteForm_CleanupID").attr("value", myval);
		  });

		  ');
    }
开发者ID:SustainableCoastlines,项目名称:loveyourwater,代码行数:27,代码来源:MyEvents.php

示例13: getPaymentFormFields

    function getPaymentFormFields()
    {
        $site_currency = Payment::site_currency();
        $paymentsList = '<div id="SecurePayTechCardsAvailable">';
        $count = 0;
        foreach (self::$credit_cards as $name => $image) {
            $count++;
            $class = '';
            if ($count == 1) {
                $class = "first";
            }
            if ($count % 2) {
                $class .= " even";
            } else {
                $class .= " odd";
            }
            $paymentsList .= '<img src="' . $image . '" alt="' . $name . '" class="SecurePayTechCardImage' . $count . '" />';
        }
        Requirements::customScript('
			function paymark_verify(merchant) {
				window.open ("http://www.paymark.co.nz/dart/darthttp.dll?etsl&tn=verify&merchantid=" + merchant, "verify", "scrollbars=yes, width=400, height=400");
			}
		', 'paymark_verify');
        $paymentsList .= '
			<img height="30" src="payment_securatech/images/paymark_small.png" alt="Paymark Certified" onclick="paymark_verify (' . "'" . self::get_spt_merchant_id() . "'" . ')" class="last" />
			</div>';
        $fieldSet = new FieldSet();
        $fieldSet->push(new LiteralField('SPTInfo', $paymentsList));
        return $fieldSet;
    }
开发者ID:helpfulrobot,项目名称:sunnysideup-payment-securatech,代码行数:30,代码来源:SecurePayTechPaymentHosted.php

示例14: jsValidation

	function jsValidation() {
		$formID = $this->form->FormName();
		$error = _t('NumericField.VALIDATIONJS', 'is not a number, only numbers can be accepted for this field');
		$jsFunc =<<<JS
Behaviour.register({
	"#$formID": {
		validateNumericField: function(fieldName) {	
				el = _CURRENT_FORM.elements[fieldName];
				if(!el || !el.value) return true;
				
			 	if(el.value.match(/^([0-9]+(\.[0-9]+)?$)/)) { 
			 		return true;
			 	} else {
					validationError(el, "'" + el.value + "' $error","validation");
			 		return false;
			 	}
			}
	}
});
JS;

		Requirements::customScript($jsFunc, 'func_validateNumericField');

		//return "\$('$formID').validateNumericField('$this->name');";
		return <<<JS
if(typeof fromAnOnBlur != 'undefined'){
	if(fromAnOnBlur.name == '$this->name')
		$('$formID').validateNumericField('$this->name');
}else{
	$('$formID').validateNumericField('$this->name');
}
JS;
	}
开发者ID:neopba,项目名称:silverstripe-book,代码行数:33,代码来源:NumericField.php

示例15: onAfterInit

 /**
  *
  */
 public function onAfterInit()
 {
     if ($code = PageProoferConfig::get_page_proofer()) {
         $data = ArrayData::create(array('Code' => $code->Code));
         Requirements::customScript($data->renderWith('PageProofer'));
     }
 }
开发者ID:muskie9,项目名称:silverstripe-pageproofer,代码行数:10,代码来源:PageProofer.php


注:本文中的Requirements::customScript方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。