Created
September 23, 2016 12:38
-
-
Save nzall/824a2a4f070f598719577b3ab321fdd0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <div data-dojo-type="js/widgets/ExpandableSearchComponent" | |
| id="machineSearchView.operatingSystemExpandableSearch" | |
| data-dojo-props="prefixTitle: '<s:property value="%{getText('label.machine.operatingSystem')}"/>: ', containedWidgetId: 'machineSearchView.operatingSystem', defaultValue: '-1'"> | |
| <div data-dojo-type="dojo/store/Memory" | |
| data-dojo-id="operatingSystemStore" | |
| data-dojo-props="<s:property value='%{getOperatingSystemTypeCodeJsonString()}'/>"></div> | |
| <s:set name="operatingSystem" value="machineSearchView.operatingSystem" | |
| scope="request"></s:set> | |
| <div data-dojo-type="dijit/form/Select" class="readOnlySelect" | |
| data-dojo-props="store:operatingSystemStore, labelAttr: 'label', sortByLabel: false, value:'${operatingSystem}'" | |
| name="machineSearchView.operatingSystem" | |
| id="machineSearchView.operatingSystem"></div> | |
| </div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <div class="expandableSearch"> | |
| <div data-dojo-type="dijit/TitlePane" data-dojo-props="title:'${prefixTitle}', open:false" id="${containedWidgetId}titleNodePane"> | |
| <div id="container" | |
| class="${baseClass}Container" | |
| data-dojo-attach-point="containerNode"></div> | |
| </div> | |
| </div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Javascript for ExpandableSearchComponent | |
| */ | |
| define([ "dojo/_base/declare", "dijit/_WidgetBase", "dijit/_TemplatedMixin", | |
| "dojo/text!./templates/ExpandableSearchComponent.html", | |
| "dijit/TitlePane", "dijit/_WidgetsInTemplateMixin", "dijit/registry", | |
| "dojo/on", "dojo/aspect", "dojo/_base/lang", "dojo/dom", | |
| "dojo/dom-attr", "js/utils/CommonUtils", "dijit/focus" ], function(declare, | |
| _WidgetBase, _TemplatedMixin, template, TitlePane, | |
| _WidgetsInTemplateMixin, registry, on, aspect, lang, dom, domAttr, | |
| CommonUtils, focusUtil) { | |
| return declare([ _WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin ], { | |
| templateString : template, | |
| prefixTitle : "", | |
| containedWidgetId : "", | |
| defaultValue : "", | |
| startup : function() { | |
| this.inherited(arguments); | |
| var containedWidgetId = this.containedWidgetId; | |
| var containedWidget = registry.byId(this.containedWidgetId); | |
| if (typeof containedWidget === "undefined") { | |
| containedWidget = dom.byId(this.containedWidgetId); | |
| } | |
| var titlePane = registry.byId(this.containedWidgetId | |
| + "titleNodePane"); | |
| this.own(on(titlePane, "Show", function() { | |
| if (typeof containedWidget.loadAndOpenDropDown === "function") { | |
| containedWidget._aroundNode = containedWidget.focusNode; | |
| containedWidget.loadAndOpenDropDown(); | |
| } | |
| focusUtil.focus(dom.byId(containedWidgetId)); | |
| })); | |
| this.own(on(titlePane, "Hide", function() { | |
| if (typeof containedWidget.closeDropDown === "function") { | |
| containedWidget.closeDropDown(); | |
| } | |
| })); | |
| this.own(on(containedWidget, "change", function(event) { | |
| var newVal = ""; | |
| if (typeof containedWidget.attr == "function" | |
| && containedWidget.attr("displayedValue") !== null) { | |
| newVal = containedWidget.attr("displayedValue"); | |
| } | |
| if (typeof event === "object") { | |
| newVal = containedWidget.value; | |
| } | |
| var newTitle = this.prefixTitle + newVal; | |
| if (newTitle.length > 35) { | |
| newTitle = newTitle.substring(0, 32) + "..."; | |
| } | |
| titlePane.set("title", newTitle); | |
| if (titlePane.open) { | |
| titlePane.toggle(); | |
| } | |
| }.bind(this))); | |
| }, | |
| reset : function() { | |
| var containedWidget = registry.byId(this.containedWidgetId); | |
| if (typeof containedWidget === "undefined") { | |
| containedWidget = dom.byId(this.containedWidgetId); | |
| } | |
| if (typeof containedWidget.set === "function" | |
| && containedWidget.attr("displayedValue") !== null) { | |
| containedWidget.set("value", this.defaultValue); | |
| } | |
| if (typeof containedWidget.set === "function" | |
| && containedWidget.attr("displayedValue") === null) { | |
| containedWidget.set("value", this.defaultValue); | |
| } | |
| if (typeof containedWidget.onChange !== "function") { | |
| domAttr.set(containedWidget, "value", this.defaultValue); | |
| if ("createEvent" in document) { | |
| var evt = document.createEvent("HTMLEvents"); | |
| evt.initEvent("change", false, true); | |
| containedWidget.dispatchEvent(evt); | |
| } else { | |
| containedWidget.fireEvent("onchange"); | |
| } | |
| } | |
| } | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment