定制 somardesignstudios/silverstripe-sft-embed 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

somardesignstudios/silverstripe-sft-embed

最新稳定版本:1.0.2

Composer 安装命令:

composer require somardesignstudios/silverstripe-sft-embed

包简介

Enables embedding the MSD Service Finder Tool in Silverstripe projects

README 文档

README

This module facilitates the inclusion of the Service Finder Tool in a Silverstripe website.

About minified js file and its source code

In order to make updating the embed javascript doable, a source code file embed_source.js is added to the code repo, and the embed.js file is re-minified and compressed by online JS minify tool from https://www.toptal.com/developers/javascript-minifier.

The embed.js is then fully tested and behave as exactly as before.

Usage

Include the module code with composer require somardesignstudios/silverstripe-sft-embed.

You can then bind buttons to the Service Finder Tool by adding the default trigger class (.js-service-finder-tool-trigger) to relevant elements via the template helper $ServiceFinderToolTrigger:

<button class="$ServiceFinderToolTrigger">Open Service Finder Tool</button>

The SomarDesignStudios\ServiceFinderTool\ControllerExtension will inject the necessary Javascript into the page when the trigger is used.

Cached content

The normal method will not work correctly if the element is wrapped with partial caching, in which case you will need to follow the steps below to trigger the injection manually.

Via configuration

To force the JavaScript to load on every page; add a configuration file service-finder-tool.yml with the following

---
Name: servicefindertool
Only:
  moduleexists: 'somardesignstudios/silverstripe-sft-embed'
---
SomarDesignStudios\ServiceFinderTool:
  always_load_script: true

Via manual implementation

If you want to attach the trigger to an element manually (for example, if the target element does not exist in the DOM during page load):

  • Call SomarDesignStudios\ServiceFinderTool\ControllerExtension::requireCoreJS() from your controller to inject the necessary Javascript
  • Bind the tool to a button element by calling window.initServiceFinderTool('<element-css-selector>')

If you need to open the tool from your own Javascript, you can call window.openServiceFinderTool() directly, and you can close it by calling window.closeServiceFinderTool().

Security

This module can allow Javascript from a third-party source, and as such should be treated with a level of caution. Theoretically, this could change at any time. As a result, a copy of the Javascript has been included in the module, which will be periodically updated when the remote script is.

By default, the module will use the baked-in version of the Javascript. To shift to using the remote version, add the following to your config:

SomarDesignStudios\ServiceFinderTool\ControllerExtension:
  use_remote_js: true

Special Thanks

统计信息

  • 总下载量: 671
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 7
  • Forks: 2
  • 开发语言: JavaScript

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2022-10-02

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固