سازنده جعبه جستجو از سازنده استفاده کنید و مستقیماً با سازنده جعبه جستجو تماس نگیرید.
سازنده
سازنده
new Builder()
مثال
// Builds a search box.functiononload(){gapi.client.init({'apiKey':'<your api key>','clientId':'<your client id>',// Add additional scopes if needed'scope':'https://www.googleapis.com/auth/cloud_search.query','hosted_domain':'<your G Suite domain>',});constsearchBox = newgapi.cloudsearch.widget.searchbox.Builder().setInput(document.getElementById('input')).setAnchor(document.getElementById('input').parentElement).build();}gapi.load('client:cloudsearch-widget',onload);
روش ها
ساختن
build() SearchBox را برمی گرداند
برمی گرداند
non-null SearchBox
تنظیم آداپتور
setAdapter(adapter) Builder را برمی گرداند
مورد نیاز . تجربه جستجوی کاربر را با این آداپتور سفارشی کنید.
constadapter = {interceptSuggestRequest:function(request){// Change the request}}builder.setAdapter(adapter).build();
setAnchor
setAnchor(anchor) Builder را برمی گرداند
مورد نیاز . باید یک HTMLElement معتبر باشد که می تواند شامل گره های فرزند باشد. لنگر پوشش جستجو. روکش به عنوان آخرین فرزند در لنگر اضافه می شود. موقعیت روکش پایین لنگر است.
پارامتر
لنگر
HTMLElement
مقدار نباید صفر باشد.
منسوخ شده است
به جای آن از «setAnchorElement» استفاده کنید
برمی گرداند
این non-null Builder
setAnchorElement
setAnchorElement(anchorElement) Builder را برمی گرداند
مورد نیاز . باید یک HTMLElement معتبر باشد که می تواند شامل گره های فرزند باشد. لنگر پوشش جستجو. روکش به عنوان آخرین فرزند در لنگر اضافه می شود. موقعیت روکش پایین لنگر است.
پارامتر
AnchorElement
HTMLElement
مقدار نباید صفر باشد.
برمی گرداند
این non-null Builder
setHints
setHints(hints) Builder را برمی گرداند
اختیاری هنگام خالی بودن ورودی، نکات مربوط به کادر جستجو. هنگامی که ورودی خالی است، یک اشاره تصادفی از آرایه انتخاب می شود.
پارامتر
نکات
آرایه رشته
مقدار نباید صفر باشد.
برمی گرداند
این non-null Builder
setInput
setInput(input) Builder را برمی گرداند
مورد نیاز . یک HTMLElement که کاربر پرس و جو را وارد می کند. باید <input> یا <textarea> باشد
پارامتر
ورودی
HTMLElement
مقدار نباید صفر باشد.
منسوخ شده است
به جای آن از «setInputElement» استفاده کنید
برمی گرداند
این non-null Builder
setInputElement
setInputElement(inputElement) Builder را برمی گرداند
مورد نیاز . یک HTMLElement که کاربر پرس و جو را وارد می کند. باید <input> یا <textarea> باشد
پارامتر
عنصر ورودی
HTMLElement
مقدار نباید صفر باشد.
برمی گرداند
این non-null Builder
setResultsContainer
setResultsContainer(resultsContainer) Builder را برمی گرداند
اختیاری ظرفی برای نمایش نتایج جستجو در صورت تنظیم، نتایج در ظرف نتایج جستجو ارائه می شود. اگر تنظیم نشود، نتایج در cloudsearch.google.com نشان داده می شود.
setSearchApplicationId(searchApplicationId) Builder را برمی گرداند
اختیاری شناسه برنامه جستجو را برای استفاده برای درخواست ها تنظیم می کند. باید با پیشوند "جستجو برنامه ها/" باشد.
پارامتر
SearchApplicationId
رشته
برمی گرداند
این non-null Builder
setThrottleInterval
setThrottleInterval(throttleInterval) Builder را برمی گرداند
اختیاری فاصله دریچه گاز بر حسب میلی ثانیه در درخواست شلیک. کادر جستجو در هر throttleInterval میلی ثانیه کمتر از یک درخواست ارسال می کند. اگر throttleInternal کمتر از 200 باشد، کادر جستجو مقدار را نادیده می گیرد و به جای آن از 200 به عنوان فاصله استفاده می کند.
تاریخ آخرین بهروزرسانی 2025-07-24 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-07-24 بهوقت ساعت هماهنگ جهانی."],[],[],null,["# Class: Builder\n\ngapi.cloudsearch.widget.[searchbox](/workspace/cloud-search/docs/reference/widget/js/gapi.cloudsearch.widget.searchbox).Builder\n===============================================================================================================================\n\nclass static\n\nBuilder of a search box. Use a builder and do not directly call\nthe searchbox constructor.\n\nConstructor\n-----------\n\n### Builder\n\nnew\nBuilder()\n\n#### Example\n\n // Builds a search box.\n function onload() {\n gapi.client.init({\n 'apiKey': '\u003cyour api key\u003e',\n 'clientId': '\u003cyour client id\u003e',\n // Add additional scopes if needed\n 'scope': 'https://www.googleapis.com/auth/cloud_search.query',\n 'hosted_domain': '\u003cyour G Suite domain\u003e',\n });\n\n const searchBox = new gapi.cloudsearch.widget.searchbox.Builder()\n .setInput(document.getElementById('input'))\n .setAnchor(document.getElementById('input').parentElement)\n .build();\n }\n gapi.load('client:cloudsearch-widget', onload);\n\nMethods\n-------\n\n### build\n\nbuild() returns SearchBox\n\nReturns\n\n: `non-null SearchBox`\n\n### setAdapter\n\nsetAdapter(adapter) returns Builder\n\n**Required**. Customize the user's search experience with this adapter.\n\n| #### Parameter ||\n|---------|-----------------------------------------------------------------------------------------------------------------------------------------------------|\n| adapter | [SearchBoxAdapter](/workspace/cloud-search/docs/reference/widget/js/SearchBoxAdapter) You can override part of the methods. Value must not be null. |\n\nReturns\n\n: `non-null Builder` this\n\n#### Example\n\n const adapter = {\n interceptSuggestRequest: function(request) {\n // Change the request\n }\n }\n\n builder.setAdapter(adapter).build();\n\n### setAnchor\n\nsetAnchor(anchor) returns Builder\n\n**Required**. Must to be a valid HTMLElement that can contain child\nnodes.\nAnchor of the search overlay. The overlay is added\nas the last child in anchor. The position of the overlay is the\nbottom of anchor.\n\n| #### Parameter ||\n|--------|-------------------------------------|\n| anchor | HTMLElement Value must not be null. |\n\nDeprecated\n: Use \\`setAnchorElement\\` instead\n\nReturns\n\n: `non-null Builder` this\n\n### setAnchorElement\n\nsetAnchorElement(anchorElement) returns Builder\n\n**Required**. Must to be a valid HTMLElement that can contain child\nnodes.\nAnchor of the search overlay. The overlay is added\nas the last child in anchor. The position of the overlay is the\nbottom of anchor.\n\n| #### Parameter ||\n|---------------|-------------------------------------|\n| anchorElement | HTMLElement Value must not be null. |\n\nReturns\n\n: `non-null Builder` this\n\n### setHints\n\nsetHints(hints) returns Builder\n\n**Optional**. The hints on the search box when input is empty.\nWhen the input is empty, a random hint is picked from the array.\n\n| #### Parameter ||\n|-------|-----------------------------------------|\n| hints | Array of string Value must not be null. |\n\nReturns\n\n: `non-null Builder` this\n\n### setInput\n\nsetInput(input) returns Builder\n\n**Required**. An HTMLElement that the user inputs the query.\nMust be \\\u003cinput\\\u003e or \\\u003ctextarea\\\u003e\n\n| #### Parameter ||\n|-------|-------------------------------------|\n| input | HTMLElement Value must not be null. |\n\nDeprecated\n: Use \\`setInputElement\\` instead\n\nReturns\n\n: `non-null Builder` this\n\n### setInputElement\n\nsetInputElement(inputElement) returns Builder\n\n**Required**. An HTMLElement that the user inputs the query.\nMust be \\\u003cinput\\\u003e or \\\u003ctextarea\\\u003e\n\n| #### Parameter ||\n|--------------|-------------------------------------|\n| inputElement | HTMLElement Value must not be null. |\n\nReturns\n\n: `non-null Builder` this\n\n### setResultsContainer\n\nsetResultsContainer(resultsContainer) returns Builder\n\n**Optional**. Container for displaying search results.\nIf set, the results are rendered in the search results container.\nIf not set, the results are shown in cloudsearch.google.com.\n\n| #### Parameter ||\n|------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| resultsContainer | [gapi.cloudsearch.widget.resultscontainer.ResultsContainer](/workspace/cloud-search/docs/reference/widget/js/gapi.cloudsearch.widget.resultscontainer.ResultsContainer) Value must not be null. |\n\nSee also\n: [ResultsContainer](/workspace/cloud-search/docs/reference/widget/js/gapi.cloudsearch.widget.resultscontainer.ResultsContainer)\n\nReturns\n\n: `non-null Builder` this\n\n### setSearchApplicationId\n\nsetSearchApplicationId(searchApplicationId) returns Builder\n\n**Optional**. Sets the search application ID to use for requests. Must\nbe prefixed with 'searchapplications/'.\n\n| #### Parameter ||\n|---------------------|--------|\n| searchApplicationId | string |\n\nReturns\n\n: `non-null Builder` this\n\n### setThrottleInterval\n\nsetThrottleInterval(throttleInterval) returns Builder\n\n**Optional**. The throttle interval in ms on firing request.\nThe search box sends less than one request every throttleInterval\nmilliseconds. If throttleInternal is less than 200, search box ignores\nthe value and uses 200 as interval instead.\n\n| #### Parameter ||\n|------------------|--------|\n| throttleInterval | number |\n\nReturns\n\n: `non-null Builder` this"]]