From 2b33573f81a301e8ee55ba2bbb872b7edd18f4f6 Mon Sep 17 00:00:00 2001 From: Alan Knowles Date: Wed, 25 Nov 2020 18:03:25 +0800 Subject: [PATCH] fix view source on dashbard4 --- docs/Roo.docs.ViewSource.bjs | 4 ++-- docs/Roo.docs.ViewSource.js | 25 ++++++++++++++++++++++--- examples/bootstrap/dashboard4.bjs | 7 ++++++- examples/bootstrap/dashboard4.js | 11 +++++++++++ examples/bootstrap4/dashboard4.html | 3 ++- 5 files changed, 43 insertions(+), 7 deletions(-) diff --git a/docs/Roo.docs.ViewSource.bjs b/docs/Roo.docs.ViewSource.bjs index 082956335e..08da87d01e 100644 --- a/docs/Roo.docs.ViewSource.bjs +++ b/docs/Roo.docs.ViewSource.bjs @@ -2,7 +2,7 @@ "name" : "Roo.docs.ViewSource", "parent" : "", "title" : "", - "path" : "/home/alan/gitlive/roojs1/docs2/Roo.docs.ViewSource.bjs", + "path" : "/home/alan/gitlive/roojs1/docs/Roo.docs.ViewSource.bjs", "permname" : "", "modOrder" : "001", "strings" : { @@ -12,7 +12,7 @@ "items" : [ { "listeners" : { - "show" : "function (_self)\n{\n // if(_this.data.buttonText){\n // _this.acceptBtn.setText(_this.data.buttonText);\n // }\n \n _this.body_ctr.el.dom.innerHTML = _this.data.source;\n _this.body_ctr.el.dom.scrollTop = 0;\n _this.dialog.setTitle(\"View Source: \" + _this.data.fname);\n _this.dialog.el.setStyle('zIndex', '10002');\n \n}" + "show" : "function (_self)\n{\n // if(_this.data.buttonText){\n // _this.acceptBtn.setText(_this.data.buttonText);\n // }\n \n if (typeof( _this.data.source) == 'undefined') {\n Roo.Ajax.request({\n url : _this.data.src,\n method : 'GET',\n success : function(res, o)\n {\n Roo.docs.ViewSource.show({\n source : String.format(\"
{0}
\",res.responseText),\n fname : _this.data.src.split('/').pop()\n });\n \n },\n scope : this\n });\n \n \n return;\n }\n \n _this.body_ctr.el.dom.innerHTML = _this.data.source;\n _this.body_ctr.el.dom.scrollTop = 0;\n _this.dialog.setTitle(\"View Source: \" + _this.data.fname);\n _this.dialog.el.setStyle('zIndex', '10002');\n \n}" }, "xtype" : "Modal", "Boolean fitwindow" : true, diff --git a/docs/Roo.docs.ViewSource.js b/docs/Roo.docs.ViewSource.js index 6c131dbdbd..2785c6f521 100644 --- a/docs/Roo.docs.ViewSource.js +++ b/docs/Roo.docs.ViewSource.js @@ -47,9 +47,28 @@ Roo.apply(Roo.docs.ViewSource.prototype, { // _this.acceptBtn.setText(_this.data.buttonText); // } - _this.body_ctr.el.dom.innerHTML = _this.data.source; - _this.body_ctr.el.dom.scrollTop = 0; - _this.dialog.setTitle("View Source: " + _this.data.fname); + if (typeof( _this.data.source) == 'undefined') { + Roo.Ajax.request({ + url : _this.data.src, + method : 'GET', + success : function(res, o) + { + Roo.docs.ViewSource.show({ + source : String.format("
{0}
",res.responseText), + fname : _this.data.src.split('/').pop() + }); + + }, + scope : this + }); + + + return; + } + + _this.body_ctr.el.dom.innerHTML = _this.data.source; + _this.body_ctr.el.dom.scrollTop = 0; + _this.dialog.setTitle("View Source: " + _this.data.fname); _this.dialog.el.setStyle('zIndex', '10002'); } diff --git a/examples/bootstrap/dashboard4.bjs b/examples/bootstrap/dashboard4.bjs index becdfe705f..60b7285952 100644 --- a/examples/bootstrap/dashboard4.bjs +++ b/examples/bootstrap/dashboard4.bjs @@ -7,6 +7,7 @@ "modOrder" : "001", "strings" : { "098f6bcd4621d373cade4e832627b4f6" : "test", + "9c1ab57e621c2bb257798752dbbe6f14" : "view source", "e93b3fa481be3932aa08bd68c3deee70" : "example 1", "60ee66eb2cd31823032664c2e9a79fd5" : "body goes here", "fb66f41b81f5973740bbfed019aa5d7d" : "Upload Images or Documents", @@ -25,8 +26,12 @@ "$ xns" : "Roo.bootstrap", "items" : [ { + "listeners" : { + "click" : "function (btn, e)\n{\n // assumes installed as /roojs1.\n Roo.docs.ViewSource.show({\n src: '/roojs1/examples/bootstrap/dashboard4.js'\n });\n}" + }, "xtype" : "Button", - "$ xns" : "Roo.bootstrap" + "$ xns" : "Roo.bootstrap", + "String html" : "view source" }, { "xtype" : "Row", diff --git a/examples/bootstrap/dashboard4.js b/examples/bootstrap/dashboard4.js index 5ea667c64b..573920b96b 100644 --- a/examples/bootstrap/dashboard4.js +++ b/examples/bootstrap/dashboard4.js @@ -6,6 +6,7 @@ dashboard4 = new Roo.XComponent({ _strings : { '098f6bcd4621d373cade4e832627b4f6' :"test", + '9c1ab57e621c2bb257798752dbbe6f14' :"view source", 'e93b3fa481be3932aa08bd68c3deee70' :"example 1", '60ee66eb2cd31823032664c2e9a79fd5' :"body goes here", 'fb66f41b81f5973740bbfed019aa5d7d' :"Upload Images or Documents", @@ -38,6 +39,16 @@ dashboard4 = new Roo.XComponent({ items : [ { xtype : 'Button', + html : _this._strings['9c1ab57e621c2bb257798752dbbe6f14'] /* view source */, + listeners : { + click : function (btn, e) + { + // assumes installed as /roojs1. + Roo.docs.ViewSource.show({ + src: '/roojs1/examples/bootstrap/dashboard4.js' + }); + } + }, xns : Roo.bootstrap, '|xns' : 'Roo.bootstrap' }, diff --git a/examples/bootstrap4/dashboard4.html b/examples/bootstrap4/dashboard4.html index 8dc05d8e34..6ac43104fc 100644 --- a/examples/bootstrap4/dashboard4.html +++ b/examples/bootstrap4/dashboard4.html @@ -18,7 +18,8 @@ - + +