diff --git a/README.md b/README.md index 52768f0..e407bd0 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,14 @@ # decision-demo-carousel -一个全屏轮播的插件示例 \ No newline at end of file +一个全屏轮播的插件示例,用来演示对tabPane相关方法的使用 + +## 使用方法 +1. 先打开几个模板. +2. 然后按下组合键 *shift+alt+f*,设置好时间,是否全屏,是否刷新,确定 +3. 停止轮播,再按一次 *shift+alt+f* + +## 效果图 + +![示例](screenshorts/screenshort.gif) + + diff --git a/build.xml b/build.xml new file mode 100644 index 0000000..cafaa43 --- /dev/null +++ b/build.xml @@ -0,0 +1,130 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/lib/report/.gitkeep b/lib/report/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/plugin.xml b/plugin.xml new file mode 100644 index 0000000..b4d97bb --- /dev/null +++ b/plugin.xml @@ -0,0 +1,15 @@ + + + com.fr.plugin.carousel + + yes + 1.0 + 10.0 + 2018-07-31 + dailer + + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..7f59558 --- /dev/null +++ b/pom.xml @@ -0,0 +1,20 @@ + + + 4.0.0 + + + com.fr.plugin + starter + 10.0 + + jar + plugin-carousel + + + + + ${project.basedir}/../webroot/WEB-INF/plugins/plugin-com.fr.plugin.function.test-1.0/classes + + \ No newline at end of file diff --git a/screenshorts/screenshort.gif b/screenshorts/screenshort.gif new file mode 100644 index 0000000..0a9d77b Binary files /dev/null and b/screenshorts/screenshort.gif differ diff --git a/src/main/java/com/fr/plugin/Carousel.java b/src/main/java/com/fr/plugin/Carousel.java new file mode 100644 index 0000000..54afe02 --- /dev/null +++ b/src/main/java/com/fr/plugin/Carousel.java @@ -0,0 +1,27 @@ +package com.fr.plugin; + +import com.fr.decision.fun.impl.AbstractWebResourceProvider; +import com.fr.decision.web.MainComponent; +import com.fr.intelli.record.Focus; +import com.fr.intelli.record.Original; +import com.fr.record.analyzer.EnableMetrics; +import com.fr.web.struct.Atom; + +/** + * Created by dailer on 18/10/10. + */ +@EnableMetrics +public class Carousel extends AbstractWebResourceProvider { + + + @Override + public Atom attach() { + return MainComponent.KEY; + } + + @Override + @Focus(id = "com.fr.plugin.carousel", text = "轮播功能", source = Original.PLUGIN) + public Atom client() { + return CarouselComponent.KEY; + } +} \ No newline at end of file diff --git a/src/main/java/com/fr/plugin/CarouselComponent.java b/src/main/java/com/fr/plugin/CarouselComponent.java new file mode 100644 index 0000000..3b8d4b4 --- /dev/null +++ b/src/main/java/com/fr/plugin/CarouselComponent.java @@ -0,0 +1,29 @@ +package com.fr.plugin; + +import com.fr.decision.config.AppearanceConfig; +import com.fr.web.struct.Component; +import com.fr.web.struct.category.ScriptPath; +import com.fr.web.struct.category.StylePath; +import com.fr.web.struct.Filter; + +/** + * Created by Zed on 2018/10/12. + */ +public class CarouselComponent extends Component { + + public static final CarouselComponent KEY = new CarouselComponent(); + + private CarouselComponent() { + + } + + @Override + public ScriptPath script() { + return ScriptPath.build("com/fr/plugin/web/carousel.js"); + } + + @Override + public StylePath style() { + return StylePath.build("com/fr/plugin/web/carousel.css"); + } +} \ No newline at end of file diff --git a/src/main/resources/com/fr/plugin/web/carousel.css b/src/main/resources/com/fr/plugin/web/carousel.css new file mode 100644 index 0000000..851bf8b --- /dev/null +++ b/src/main/resources/com/fr/plugin/web/carousel.css @@ -0,0 +1,50 @@ +/* fine-decision-webui 19-01-03 12:02:26 */ +.demo-background { + background: #3d3780; +} +.dec-workbench-tabs { + border-radius: 8px; + overflow: hidden; +} +#wrapper.active { + transform: perspective(0.5em) rotateX(25deg); + transform-origin: bottom; +} + +.demo-header { + background: #494299; +} +.demo-header .demo-sidebar-trigger .b-font { + color: #FFFFFF; + font-size: 30px; +} +.demo-header .demo-search-button .b-font, +.demo-header .favorite-font .b-font { + color: #a1a1e5; +} +.demo-header .demo-title-text { + color: #FFFFFF; + font-size: 24px; +} + +.demo-sidebar { + background: #494299; + color: #a1a1e5; + font-size: 14px; + border-radius: 10px; +} +.demo-sidebar .platform-node-icon .b-font { + font-size: 35px; + color: #a1a1e5; +} +.demo-sidebar .demo-sidebar-item.active { + background-color: rgba(0, 255, 170, 0.25); + color: #fff; + border: 2px solid #00f9a6; + border-radius: 8px; + -webkit-box-shadow: 0 2px 12px 0 rgba(0, 255, 170, 0.25); + box-shadow: 0 2px 12px 0 rgba(0, 255, 170, 0.25); +} +.demo-sidebar .demo-sidebar-expander-popup { + background: #3d3780; +} diff --git a/src/main/resources/com/fr/plugin/web/carousel.js b/src/main/resources/com/fr/plugin/web/carousel.js new file mode 100644 index 0000000..4097b03 --- /dev/null +++ b/src/main/resources/com/fr/plugin/web/carousel.js @@ -0,0 +1,208 @@ +!(function () { + var timer = null; + Dec.Plugin = Dec.Plugin || {}; + Dec.Plugin.alternate = { + play: function () { + var pane = { + type: "dec.plugin.carousel.popup", + onClickConfirm: function (v) { + var service = BI.Services.getService("dec.service.tabs"); + v.fullscreen && service.fullScreen(); + timer = service.alternatePlay(v.time, v.refresh); + }, + listeners: [ + { + eventName: "EVENT_CLOSE", + action: function () { + BI.Popovers.remove("plugin-carousel-popup"); + } + } + ] + }; + + BI.Popovers.create("plugin-carousel-popup", { + type: "bi.popover", + header: "轮播设定", + body: pane, + width: 450, + height: 240, + listeners: [ + { + eventName: "EVENT_CLOSE", + action: function () { + BI.Popovers.remove("plugin-carousel-popup"); + } + } + ] + }).open("plugin-carousel-popup"); + }, + + stop: function () { + window.clearInterval(timer); + timer = null; + } + }; + + document.onkeydown = function (e) { + var keyCode = e.keyCode || e.which || e.charCode; + var shiftKey = e.shiftKey; + var altKey = e.altKey; + if (shiftKey && altKey && keyCode === 70) { + if (!timer) { + Dec.Plugin.alternate.play(); + } else { + Dec.Plugin.alternate.stop(); + } + e.preventDefault(); + } + }; +}()); + +!(function () { + + + var WIDTH = 80; + var HEIGHT = 50; + var EDITOR_Width = 300; + + var Popup = BI.inherit(BI.Widget, { + + props: { + baseCls: "dec-add-user-popup", + btns: [BI.i18nText(BI.i18nText("BI-Basic_Sure")), BI.i18nText(BI.i18nText("BI-Basic_Cancel"))], + onClickConfirm: BI.emptyFn, + info: {} + }, + + render: function () { + var self = this; + + return { + el: { + type: "bi.vtape", + tgap: -10, + items: [ + { + el: this.rebuildCenter() + }, { + el: this.rebuildSouth(), + height: 44 + } + ] + } + }; + }, + + + rebuildSouth: function () { + var self = this, o = this.options; + var sure = BI.createWidget({ + type: "bi.button", + ref: function (_ref) { + self.sure = _ref; + }, + text: this.options.btns[0], + warningTitle: o.warningTitle, + height: 24, + handler: function () { + self.end(); + } + }); + var cancel = BI.createWidget({ + type: "bi.button", + ref: function (_ref) { + self.cancel = _ref; + }, + text: this.options.btns[1], + height: 24, + level: "ignore", + handler: function () { + self.close(); + } + }); + return { + type: "bi.right_vertical_adapt", + lgap: 10, + items: [cancel, sure] + }; + }, + + rebuildCenter: function (center) { + var self = this, o = this.options; + + var time = BI.createWidget({ + type: "bi.editor", + ref: function (_ref) { + self.time = _ref; + }, + cls: "bi-border", + watermark: BI.i18nText("间隔时间(s)"), + width: EDITOR_Width, + height: 24 + }); + + var fullscrenn = BI.createWidget({ + type: "bi.multi_select_item", + ref: function (_ref) { + self.fullscreen = _ref; + }, + text: "是否全屏", + width: EDITOR_Width - 2, + height: 24, + value: o.info.description || "" + }); + + var refresh = BI.createWidget({ + type: "bi.multi_select_item", + ref: function (_ref) { + self.refresh = _ref; + }, + text: "切换前是否刷新模板", + width: EDITOR_Width - 2, + height: 24 + }); + + + return { + element: center, + type: "bi.vertical", + cls: "dec-add-user-popup", + items: [ + { + el: { + type: "bi.vertical_adapt", + height: HEIGHT, + items: [{ + type: "bi.label", + width: WIDTH, + textAlign: "left", + text: BI.i18nText("间隔时间(s)") + }, time] + }, + tgap: 10 + }, fullscrenn, refresh + ] + }; + }, + + + getValue: function () { + return { + time: this.time.getValue(), + fullscreen: this.fullscreen.isSelected(), + refresh: this.refresh.isSelected() + }; + }, + + close: function () { + this.fireEvent("EVENT_CLOSE"); + }, + end: function () { + this.options.onClickConfirm(this.getValue()); + this.close(); + } + }); + + Popup.EVENT_CLICK_CONFIRM = "EVENT_CONFIRM"; + BI.shortcut("dec.plugin.carousel.popup", Popup); +}()); \ No newline at end of file