123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441 |
- if(!dojo._hasResource["dojox.widget.Portlet"]){
- dojo._hasResource["dojox.widget.Portlet"] = true;
- dojo.experimental("dojox.widget.Portlet");
- dojo.provide("dojox.widget.Portlet");
- dojo.require("dijit.TitlePane");
- dojo.require("dojo.fx");
- dojo.declare("dojox.widget.Portlet", [dijit.TitlePane, dijit._Container],{
-
-
-
-
-
-
-
-
-
-
-
- resizeChildren: true,
-
-
-
-
- closable: true,
-
-
-
-
- _parents: null,
-
-
-
-
- _size: null,
-
-
- dragRestriction : false,
- buildRendering: function(){
- this.inherited(arguments);
-
- dojo.style(this.domNode, "visibility", "hidden");
- },
- postCreate: function(){
- this.inherited(arguments);
-
- dojo.addClass(this.domNode, "dojoxPortlet");
- dojo.removeClass(this.arrowNode, "dijitArrowNode");
- dojo.addClass(this.arrowNode, "dojoxPortletIcon dojoxArrowDown");
- dojo.addClass(this.titleBarNode, "dojoxPortletTitle");
- dojo.addClass(this.hideNode, "dojoxPortletContentOuter");
-
- dojo.addClass(this.domNode, "dojoxPortlet-" + (!this.dragRestriction ? "movable" : "nonmovable"));
- var _this = this;
- if(this.resizeChildren){
-
-
-
- this.subscribe("/dnd/drop", function(){_this._updateSize();});
- this.subscribe("/Portlet/sizechange", function(widget){_this.onSizeChange(widget);});
- this.connect(window, "onresize", function(){_this._updateSize();});
-
-
- var doSelectSubscribe = dojo.hitch(this, function(id, lastId){
- var widget = dijit.byId(id);
- if(widget.selectChild){
- var s = this.subscribe(id + "-selectChild", function(child){
- var n = _this.domNode.parentNode;
- while(n){
- if(n == child.domNode){
-
-
- _this.unsubscribe(s);
- _this._updateSize();
- break;
- }
- n = n.parentNode;
- }
- });
-
-
-
- var child = dijit.byId(lastId);
- if(widget && child){
- _this._parents.push({parent: widget, child: child});
- }
- }
- });
- var lastId;
- this._parents = [];
-
-
- for(var p = this.domNode.parentNode; p != null; p = p.parentNode){
- var id = p.getAttribute ? p.getAttribute("widgetId") : null;
- if(id){
- doSelectSubscribe(id, lastId);
- lastId = id;
- }
- }
- }
-
- this.connect(this.titleBarNode, "onmousedown", function(evt){
- if (dojo.hasClass(evt.target, "dojoxPortletIcon")) {
- dojo.stopEvent(evt);
- return false;
- }
- return true;
- });
-
-
- this.connect(this._wipeOut, "onEnd", function(){_this._publish();});
- this.connect(this._wipeIn, "onEnd", function(){_this._publish();});
- if(this.closable){
- this.closeIcon = this._createIcon("dojoxCloseNode", "dojoxCloseNodeHover", dojo.hitch(this, "onClose"));
- dojo.style(this.closeIcon, "display", "");
- }
- },
- startup: function(){
- if(this._started){return;}
- var children = this.getChildren();
- this._placeSettingsWidgets();
-
- dojo.forEach(children, function(child){
- try{
- if(!child.started && !child._started){
- child.startup()
- }
- }
- catch(e){
- console.log(this.id + ":" + this.declaredClass, e);
- }
- });
- this.inherited(arguments);
-
- dojo.style(this.domNode, "visibility", "visible");
- },
- _placeSettingsWidgets: function(){
-
-
-
-
- dojo.forEach(this.getChildren(), dojo.hitch(this, function(child){
- if(child.portletIconClass && child.toggle && !child.attr("portlet")){
- this._createIcon(child.portletIconClass, child.portletIconHoverClass, dojo.hitch(child, "toggle"));
- dojo.place(child.domNode, this.containerNode, "before");
- child.attr("portlet", this);
- this._settingsWidget = child;
- }
- }));
- },
- _createIcon: function(clazz, hoverClazz, fn){
-
-
- var icon = dojo.create("div",{
- "class": "dojoxPortletIcon " + clazz,
- "waiRole": "presentation"
- });
- dojo.place(icon, this.arrowNode, "before");
- this.connect(icon, "onclick", fn);
- if(hoverClazz){
- this.connect(icon, "onmouseover", function(){
- dojo.addClass(icon, hoverClazz);
- });
- this.connect(icon, "onmouseout", function(){
- dojo.removeClass(icon, hoverClazz);
- });
- }
- return icon;
- },
- onClose: function(evt){
-
-
-
-
-
- dojo.style(this.domNode, "display", "none");
- },
- onSizeChange: function(widget){
-
-
-
- if(widget == this){
- return;
- }
- this._updateSize();
- },
- _updateSize: function(){
-
-
- if(!this.open || !this._started || !this.resizeChildren){
- return;
- }
- if(this._timer){
- clearTimeout(this._timer);
- }
-
-
- this._timer = setTimeout(dojo.hitch(this, function(){
- var size ={
- w: dojo.style(this.domNode, "width"),
- h: dojo.style(this.domNode, "height")
- };
-
-
-
- for(var i = 0; i < this._parents.length; i++){
- var p = this._parents[i];
- var sel = p.parent.selectedChildWidget
- if(sel && sel != p.child){
- return;
- }
- }
- if(this._size){
-
-
- if(this._size.w == size.w && this._size.h == size.h){
- return;
- }
- }
- this._size = size;
- var fns = ["resize", "layout"];
- this._timer = null;
- var kids = this.getChildren();
- dojo.forEach(kids, function(child){
- for(var i = 0; i < fns.length; i++){
- if(dojo.isFunction(child[fns[i]])){
- try{
- child[fns[i]]();
- } catch(e){
- console.log(e);
- }
- break;
- }
- }
- });
- this.onUpdateSize();
- }), 100);
- },
- onUpdateSize: function(){
-
-
- },
- _publish: function(){
-
-
-
- dojo.publish("/Portlet/sizechange",[this]);
- },
- _onTitleClick: function(evt){
- if(evt.target == this.arrowNode){
- this.inherited(arguments);
- }
- },
- addChild: function(child){
-
-
- this._size = null;
- this.inherited(arguments);
- if(this._started){
- this._placeSettingsWidgets();
- this._updateSize();
- }
- if(this._started && !child.started && !child._started){
- child.startup();
- }
- },
- destroyDescendants: function(/*Boolean*/ preserveDom){
- this.inherited(arguments);
- if(this._settingsWidget){
- this._settingsWidget.destroyRecursive(preserveDom);
- }
- },
- destroy: function(){
- if(this._timer){
- clearTimeout(this._timer);
- }
- this.inherited(arguments);
- },
- _setCss: function(){
- this.inherited(arguments);
- dojo.style(this.arrowNode, "display", this.toggleable ? "":"none");
- }
- });
- dojo.declare("dojox.widget.PortletSettings", [dijit._Container, dijit.layout.ContentPane],{
-
-
-
-
-
-
-
-
-
-
- portletIconClass: "dojoxPortletSettingsIcon",
-
-
-
- portletIconHoverClass: "dojoxPortletSettingsIconHover",
- postCreate: function(){
-
-
-
- dojo.style(this.domNode, "display", "none");
- dojo.addClass(this.domNode, "dojoxPortletSettingsContainer");
-
- dojo.removeClass(this.domNode, "dijitContentPane");
- },
- _setPortletAttr: function(portlet){
-
-
- this.portlet = portlet;
- },
- toggle: function(){
-
-
- var n = this.domNode;
- if(dojo.style(n, "display") == "none"){
- dojo.style(n,{
- "display": "block",
- "height": "1px",
- "width": "auto"
- });
- dojo.fx.wipeIn({
- node: n
- }).play();
- }else{
- dojo.fx.wipeOut({
- node: n,
- onEnd: dojo.hitch(this, function(){
- dojo.style(n,{"display": "none", "height": "", "width":""});
- }
- )}).play();
- }
- }
- });
- dojo.declare("dojox.widget.PortletDialogSettings",
- dojox.widget.PortletSettings,{
-
-
-
-
-
- dimensions: null,
- constructor: function(props, node){
- this.dimensions = props.dimensions || [300, 100];
- },
- toggle: function(){
-
-
- if(!this.dialog){
- dojo["require"]("dijit.Dialog");
- this.dialog = new dijit.Dialog({title: this.title});
- dojo.body().appendChild(this.dialog.domNode);
-
- this.dialog.containerNode.appendChild(this.domNode);
- dojo.style(this.dialog.domNode,{
- "width" : this.dimensions[0] + "px",
- "height" : this.dimensions[1] + "px"
- });
- dojo.style(this.domNode, "display", "");
- }
- if(this.dialog.open){
- this.dialog.hide();
- }else{
- this.dialog.show(this.domNode);
- }
- }
- });
- }
|