From c5676211f51e528b20929bbb9a6e0702c6a4f2bf Mon Sep 17 00:00:00 2001 From: Alan Knowles Date: Thu, 29 Jul 2021 15:19:37 +0800 Subject: [PATCH] sync --- Roo/bootstrap/menu/Manager.js | 189 ++++++++++++++++++ Roo/bootstrap/menu/namespace.js | 6 + docs/src/Roo_LayoutDialog.js.html | 160 +++++++++++++++ docs/src/Roo_bootstrap_menu_Manager.js.html | 189 ++++++++++++++++++ docs/src/Roo_bootstrap_menu_namespace.js.html | 7 + docs/symbols/Roo.bootstrap.menu.Manager.json | 66 ++++++ 6 files changed, 617 insertions(+) create mode 100644 Roo/bootstrap/menu/Manager.js create mode 100644 Roo/bootstrap/menu/namespace.js create mode 100644 docs/src/Roo_LayoutDialog.js.html create mode 100644 docs/src/Roo_bootstrap_menu_Manager.js.html create mode 100644 docs/src/Roo_bootstrap_menu_namespace.js.html create mode 100644 docs/symbols/Roo.bootstrap.menu.Manager.json diff --git a/Roo/bootstrap/menu/Manager.js b/Roo/bootstrap/menu/Manager.js new file mode 100644 index 0000000000..4e1172fcec --- /dev/null +++ b/Roo/bootstrap/menu/Manager.js @@ -0,0 +1,189 @@ +/** + * @class Roo.bootstrap.MenuMgr + * @licence LGPL + * Provides a common registry of all menu items on a page so that they can be easily accessed by id. + * @singleton + */ +Roo.bootstrap.menu.Manager = function(){ + var menus, active, groups = {}, attached = false, lastShow = new Date(); + + // private - called when first menu is created + function init(){ + menus = {}; + active = new Roo.util.MixedCollection(); + Roo.get(document).addKeyListener(27, function(){ + if(active.length > 0){ + hideAll(); + } + }); + } + + // private + function hideAll(){ + if(active && active.length > 0){ + var c = active.clone(); + c.each(function(m){ + m.hide(); + }); + } + } + + // private + function onHide(m){ + active.remove(m); + if(active.length < 1){ + Roo.get(document).un("mouseup", onMouseDown); + + attached = false; + } + } + + // private + function onShow(m){ + var last = active.last(); + lastShow = new Date(); + active.add(m); + if(!attached){ + Roo.get(document).on("mouseup", onMouseDown); + + attached = true; + } + if(m.parentMenu){ + //m.getEl().setZIndex(parseInt(m.parentMenu.getEl().getStyle("z-index"), 10) + 3); + m.parentMenu.activeChild = m; + }else if(last && last.isVisible()){ + //m.getEl().setZIndex(parseInt(last.getEl().getStyle("z-index"), 10) + 3); + } + } + + // private + function onBeforeHide(m){ + if(m.activeChild){ + m.activeChild.hide(); + } + if(m.autoHideTimer){ + clearTimeout(m.autoHideTimer); + delete m.autoHideTimer; + } + } + + // private + function onBeforeShow(m){ + var pm = m.parentMenu; + if(!pm && !m.allowOtherMenus){ + hideAll(); + }else if(pm && pm.activeChild && active != m){ + pm.activeChild.hide(); + } + } + + // private this should really trigger on mouseup.. + function onMouseDown(e){ + Roo.log("on Mouse Up"); + + if(lastShow.getElapsed() > 50 && active.length > 0 && !e.getTarget(".dropdown-menu") && !e.getTarget('.user-menu')){ + Roo.log("MenuManager hideAll"); + hideAll(); + e.stopEvent(); + } + + + } + + // private + function onBeforeCheck(mi, state){ + if(state){ + var g = groups[mi.group]; + for(var i = 0, l = g.length; i < l; i++){ + if(g[i] != mi){ + g[i].setChecked(false); + } + } + } + } + + return { + + /** + * Hides all menus that are currently visible + */ + hideAll : function(){ + hideAll(); + }, + + // private + register : function(menu){ + if(!menus){ + init(); + } + menus[menu.id] = menu; + menu.on("beforehide", onBeforeHide); + menu.on("hide", onHide); + menu.on("beforeshow", onBeforeShow); + menu.on("show", onShow); + var g = menu.group; + if(g && menu.events["checkchange"]){ + if(!groups[g]){ + groups[g] = []; + } + groups[g].push(menu); + menu.on("checkchange", onCheck); + } + }, + + /** + * Returns a {@link Roo.menu.Menu} object + * @param {String/Object} menu The string menu id, an existing menu object reference, or a Menu config that will + * be used to generate and return a new Menu instance. + */ + get : function(menu){ + if(typeof menu == "string"){ // menu id + return menus[menu]; + }else if(menu.events){ // menu instance + return menu; + } + /*else if(typeof menu.length == 'number'){ // array of menu items? + return new Roo.bootstrap.Menu({items:menu}); + }else{ // otherwise, must be a config + return new Roo.bootstrap.Menu(menu); + } + */ + return false; + }, + + // private + unregister : function(menu){ + delete menus[menu.id]; + menu.un("beforehide", onBeforeHide); + menu.un("hide", onHide); + menu.un("beforeshow", onBeforeShow); + menu.un("show", onShow); + var g = menu.group; + if(g && menu.events["checkchange"]){ + groups[g].remove(menu); + menu.un("checkchange", onCheck); + } + }, + + // private + registerCheckable : function(menuItem){ + var g = menuItem.group; + if(g){ + if(!groups[g]){ + groups[g] = []; + } + groups[g].push(menuItem); + menuItem.on("beforecheckchange", onBeforeCheck); + } + }, + + // private + unregisterCheckable : function(menuItem){ + var g = menuItem.group; + if(g){ + groups[g].remove(menuItem); + menuItem.un("beforecheckchange", onBeforeCheck); + } + } + }; +}(); \ No newline at end of file diff --git a/Roo/bootstrap/menu/namespace.js b/Roo/bootstrap/menu/namespace.js new file mode 100644 index 0000000000..6587307ef0 --- /dev/null +++ b/Roo/bootstrap/menu/namespace.js @@ -0,0 +1,6 @@ +Roo.bootstrap.menu = Roo.bootstrap.menu || {}; +// deprciated +Roo.bootstrap.Menu = Roo.bootstrap.menu.Menu; +Roo.bootstrap.MenuItem = Roo.bootstrap.menu.Item; +Roo.bootstrap.MenuSeparator = Roo.bootstrap.menu.Separator + diff --git a/docs/src/Roo_LayoutDialog.js.html b/docs/src/Roo_LayoutDialog.js.html new file mode 100644 index 0000000000..254b968e35 --- /dev/null +++ b/docs/src/Roo_LayoutDialog.js.html @@ -0,0 +1,160 @@ +Roo/LayoutDialog.js +/** + * @class Roo.LayoutDialog + * @extends Roo.BasicDialog + * @children Roo.ContentPanel + * @builder-top + * Dialog which provides adjustments for working with a layout in a Dialog. + * Add your necessary layout config options to the dialog's config.<br> + * Example usage (including a nested layout): + * <pre><code> +if(!dialog){ + dialog = new Roo.LayoutDialog("download-dlg", { + modal: true, + width:600, + height:450, + shadow:true, + minWidth:500, + minHeight:350, + autoTabs:true, + proxyDrag:true, + // layout config merges with the dialog config + center:{ + tabPosition: "top", + alwaysShowTabs: true + } + }); + dialog.addKeyListener(27, dialog.hide, dialog); + dialog.setDefaultButton(dialog.addButton("Close", dialog.hide, dialog)); + dialog.addButton("Build It!", this.getDownload, this); + + // we can even add nested layouts + var innerLayout = new Roo.BorderLayout("dl-inner", { + east: { + initialSize: 200, + autoScroll:true, + split:true + }, + center: { + autoScroll:true + } + }); + innerLayout.beginUpdate(); + innerLayout.add("east", new Roo.ContentPanel("dl-details")); + innerLayout.add("center", new Roo.ContentPanel("selection-panel")); + innerLayout.endUpdate(true); + + var layout = dialog.getLayout(); + layout.beginUpdate(); + layout.add("center", new Roo.ContentPanel("standard-panel", + {title: "Download the Source", fitToFrame:true})); + layout.add("center", new Roo.NestedLayoutPanel(innerLayout, + {title: "Build your own roo.js"})); + layout.getRegion("center").showPanel(sp); + layout.endUpdate(); +} +</code></pre> + * @constructor + * @param {String/HTMLElement/Roo.Element} el The id of or container element, or config + * @param {Object} config configuration options + */ +Roo.LayoutDialog = function(el, cfg){ + + var config= cfg; + if (typeof(cfg) == 'undefined') { + config = Roo.apply({}, el); + // not sure why we use documentElement here.. - it should always be body. + // IE7 borks horribly if we use documentElement. + // webkit also does not like documentElement - it creates a body element... + el = Roo.get( document.body || document.documentElement ).createChild(); + //config.autoCreate = true; + } + + + config.autoTabs = false; + Roo.LayoutDialog.superclass.constructor.call(this, el, config); + this.body.setStyle({overflow:"hidden", position:"relative"}); + this.layout = new Roo.BorderLayout(this.body.dom, config); + this.layout.monitorWindowResize = false; + this.el.addClass("x-dlg-auto-layout"); + // fix case when center region overwrites center function + this.center = Roo.BasicDialog.prototype.center; + this.on("show", this.layout.layout, this.layout, true); + if (config.items) { + var xitems = config.items; + delete config.items; + Roo.each(xitems, this.addxtype, this); + } + + +}; +Roo.extend(Roo.LayoutDialog, Roo.BasicDialog, { + + + /** + * @cfg {Roo.LayoutRegion} east + */ + /** + * @cfg {Roo.LayoutRegion} west + */ + /** + * @cfg {Roo.LayoutRegion} south + */ + /** + * @cfg {Roo.LayoutRegion} north + */ + /** + * @cfg {Roo.LayoutRegion} center + */ + /** + * @cfg {Roo.Button} buttons[] Bottom buttons.. + */ + + + /** + * Ends update of the layout <strike>and resets display to none</strike>. Use standard beginUpdate/endUpdate on the layout. + * @deprecated + */ + endUpdate : function(){ + this.layout.endUpdate(); + }, + + /** + * Begins an update of the layout <strike>and sets display to block and visibility to hidden</strike>. Use standard beginUpdate/endUpdate on the layout. + * @deprecated + */ + beginUpdate : function(){ + this.layout.beginUpdate(); + }, + + /** + * Get the BorderLayout for this dialog + * @return {Roo.BorderLayout} + */ + getLayout : function(){ + return this.layout; + }, + + showEl : function(){ + Roo.LayoutDialog.superclass.showEl.apply(this, arguments); + if(Roo.isIE7){ + this.layout.layout(); + } + }, + + // private + // Use the syncHeightBeforeShow config option to control this automatically + syncBodyHeight : function(){ + Roo.LayoutDialog.superclass.syncBodyHeight.call(this); + if(this.layout){this.layout.layout();} + }, + + /** + * Add an xtype element (actually adds to the layout.) + * @return {Object} xdata xtype object data. + */ + + addxtype : function(c) { + return this.layout.addxtype(c); + } +}); \ No newline at end of file diff --git a/docs/src/Roo_bootstrap_menu_Manager.js.html b/docs/src/Roo_bootstrap_menu_Manager.js.html new file mode 100644 index 0000000000..b194799d9d --- /dev/null +++ b/docs/src/Roo_bootstrap_menu_Manager.js.html @@ -0,0 +1,189 @@ +Roo/bootstrap/menu/Manager.js/** + * @class Roo.bootstrap.MenuMgr + * @licence LGPL + * Provides a common registry of all menu items on a page so that they can be easily accessed by id. + * @singleton + */ +Roo.bootstrap.menu.Manager = function(){ + var menus, active, groups = {}, attached = false, lastShow = new Date(); + + // private - called when first menu is created + function init(){ + menus = {}; + active = new Roo.util.MixedCollection(); + Roo.get(document).addKeyListener(27, function(){ + if(active.length > 0){ + hideAll(); + } + }); + } + + // private + function hideAll(){ + if(active && active.length > 0){ + var c = active.clone(); + c.each(function(m){ + m.hide(); + }); + } + } + + // private + function onHide(m){ + active.remove(m); + if(active.length < 1){ + Roo.get(document).un("mouseup", onMouseDown); + + attached = false; + } + } + + // private + function onShow(m){ + var last = active.last(); + lastShow = new Date(); + active.add(m); + if(!attached){ + Roo.get(document).on("mouseup", onMouseDown); + + attached = true; + } + if(m.parentMenu){ + //m.getEl().setZIndex(parseInt(m.parentMenu.getEl().getStyle("z-index"), 10) + 3); + m.parentMenu.activeChild = m; + }else if(last && last.isVisible()){ + //m.getEl().setZIndex(parseInt(last.getEl().getStyle("z-index"), 10) + 3); + } + } + + // private + function onBeforeHide(m){ + if(m.activeChild){ + m.activeChild.hide(); + } + if(m.autoHideTimer){ + clearTimeout(m.autoHideTimer); + delete m.autoHideTimer; + } + } + + // private + function onBeforeShow(m){ + var pm = m.parentMenu; + if(!pm && !m.allowOtherMenus){ + hideAll(); + }else if(pm && pm.activeChild && active != m){ + pm.activeChild.hide(); + } + } + + // private this should really trigger on mouseup.. + function onMouseDown(e){ + Roo.log("on Mouse Up"); + + if(lastShow.getElapsed() > 50 && active.length > 0 && !e.getTarget(".dropdown-menu") && !e.getTarget('.user-menu')){ + Roo.log("MenuManager hideAll"); + hideAll(); + e.stopEvent(); + } + + + } + + // private + function onBeforeCheck(mi, state){ + if(state){ + var g = groups[mi.group]; + for(var i = 0, l = g.length; i < l; i++){ + if(g[i] != mi){ + g[i].setChecked(false); + } + } + } + } + + return { + + /** + * Hides all menus that are currently visible + */ + hideAll : function(){ + hideAll(); + }, + + // private + register : function(menu){ + if(!menus){ + init(); + } + menus[menu.id] = menu; + menu.on("beforehide", onBeforeHide); + menu.on("hide", onHide); + menu.on("beforeshow", onBeforeShow); + menu.on("show", onShow); + var g = menu.group; + if(g && menu.events["checkchange"]){ + if(!groups[g]){ + groups[g] = []; + } + groups[g].push(menu); + menu.on("checkchange", onCheck); + } + }, + + /** + * Returns a {@link Roo.menu.Menu} object + * @param {String/Object} menu The string menu id, an existing menu object reference, or a Menu config that will + * be used to generate and return a new Menu instance. + */ + get : function(menu){ + if(typeof menu == "string"){ // menu id + return menus[menu]; + }else if(menu.events){ // menu instance + return menu; + } + /*else if(typeof menu.length == 'number'){ // array of menu items? + return new Roo.bootstrap.Menu({items:menu}); + }else{ // otherwise, must be a config + return new Roo.bootstrap.Menu(menu); + } + */ + return false; + }, + + // private + unregister : function(menu){ + delete menus[menu.id]; + menu.un("beforehide", onBeforeHide); + menu.un("hide", onHide); + menu.un("beforeshow", onBeforeShow); + menu.un("show", onShow); + var g = menu.group; + if(g && menu.events["checkchange"]){ + groups[g].remove(menu); + menu.un("checkchange", onCheck); + } + }, + + // private + registerCheckable : function(menuItem){ + var g = menuItem.group; + if(g){ + if(!groups[g]){ + groups[g] = []; + } + groups[g].push(menuItem); + menuItem.on("beforecheckchange", onBeforeCheck); + } + }, + + // private + unregisterCheckable : function(menuItem){ + var g = menuItem.group; + if(g){ + groups[g].remove(menuItem); + menuItem.un("beforecheckchange", onBeforeCheck); + } + } + }; +}(); \ No newline at end of file diff --git a/docs/src/Roo_bootstrap_menu_namespace.js.html b/docs/src/Roo_bootstrap_menu_namespace.js.html new file mode 100644 index 0000000000..fc69cffbe1 --- /dev/null +++ b/docs/src/Roo_bootstrap_menu_namespace.js.html @@ -0,0 +1,7 @@ +Roo/bootstrap/menu/namespace.jsRoo.bootstrap.menu = Roo.bootstrap.menu || {}; +// deprciated +Roo.bootstrap.Menu = Roo.bootstrap.menu.Menu; +Roo.bootstrap.MenuItem = Roo.bootstrap.menu.Item; +Roo.bootstrap.MenuSeparator = Roo.bootstrap.menu.Separator + + \ No newline at end of file diff --git a/docs/symbols/Roo.bootstrap.menu.Manager.json b/docs/symbols/Roo.bootstrap.menu.Manager.json new file mode 100644 index 0000000000..244e226617 --- /dev/null +++ b/docs/symbols/Roo.bootstrap.menu.Manager.json @@ -0,0 +1,66 @@ +{ + "name" : "Roo.bootstrap.menu.Manager", + "augments" : [], + "desc" : "Provides a common registry of all menu items on a page so that they can be easily accessed by id.", + "isSingleton" : true, + "isStatic" : false, + "isBuiltin" : false, + "memberOf" : "Manager", + "example" : "", + "deprecated" : "", + "since" : "", + "see" : "", + "params" : [], + "returns" : [], + "throws" : "", + "requires" : "", + "config" : [], + "methods" : [ + { + "name" : "get", + "type" : "function", + "desc" : "Returns a {@link Roo.menu.Menu} object", + "sig" : "(menu)", + "static" : false, + "memberOf" : "", + "isStatic" : false, + "isConstructor" : false, + "isPrivate" : false, + "example" : "", + "deprecated" : "", + "since" : "", + "see" : "", + "exceptions" : "", + "requires" : "", + "params" : [ + { + "name" : "menu", + "type" : "String/Object", + "desc" : "The string menu id, an existing menu object reference, or a Menu config that will\nbe used to generate and return a new Menu instance.", + "isOptional" : false + } + ], + "returns" : [] + }, + { + "name" : "hideAll", + "type" : "function", + "desc" : "Hides all menus that are currently visible", + "sig" : "()\n{\n\n}", + "static" : false, + "memberOf" : "", + "isStatic" : false, + "isConstructor" : false, + "isPrivate" : false, + "example" : "", + "deprecated" : "", + "since" : "", + "see" : "", + "exceptions" : "", + "requires" : "", + "params" : [], + "returns" : [] + } + ], + "events" : [] +} \ No newline at end of file -- 2.39.2