Pman.Dialog.Image.bjs
[Pman.Core] / Pman.Dialog.Image.bjs
1 {
2  "name" : "Pman.Dialog.Image",
3  "parent" : "",
4  "title" : "",
5  "path" : "/home/alan/gitlive/Pman.Core/Pman.Dialog.Image.bjs",
6  "permname" : "",
7  "modOrder" : "001",
8  "strings" : {
9   "eb5d45750c7ab13aa8e6bacc80315a30" : "32M",
10   "2859a4ae58ae4e25abdfc530f814e42f" : "Upload an Image or File",
11   "c4ca4238a0b923820dcc509a6f75849b" : "1",
12   "ea4788705e6873b424c65e91c2846b19" : "Cancel",
13   "91412465ea9169dfd901dd5e7c96dd99" : "Upload",
14   "ea72bacd2fdfa818907bb9559e6905a1" : "Upload Image or File"
15  },
16  "items" : [
17   {
18    "listeners" : {
19     "show" : "function (_self)\n{\n\n    // this does not really work - escape on the borders works..\n    // resize to fit.. if we have styled stuff...\n    \n    \n    \n    \n    var d = this;\n    \n    var pad =     d.el.getSize().height - (d.header.getSize().height +\n        d.footer.getSize().height +        \n        d.layout.getRegion('center').getPanel(0).el.getSize().height\n        );\n    \n    var height = (\n        pad + \n        d.header.getSize().height +\n        d.footer.getSize().height +        \n        d.layout.getRegion('center').getPanel(0).el.child('div').getSize().height\n    );\n    this.resizeTo(d.el.getSize().width, height);\n    \n    if (this.keylistener) {\n        return;\n    }\n    this.keylistener = this.addKeyListener(27, this.hide, this);\n    \n}"
20    },
21    "modal" : true,
22    "shadow" : true,
23    "collapsible" : false,
24    "title" : "Upload an Image or File",
25    "xtype" : "LayoutDialog",
26    "uploadComplete" : false,
27    "width" : 500,
28    "$ xns" : "Roo",
29    "closable" : false,
30    "resizable" : false,
31    "haveProgress" : false,
32    "height" : 200,
33    "$ uploadProgress" : "function()\n{\n    var dlg = this;\n   if (!dlg.haveProgress) {\n        Roo.MessageBox.progress(\"Uploading\", \"Uploading\");\n    }\n    \n    if (dlg.haveProgress == 2) {\n        // it's been closed elsewhere..\n        return;\n    }\n    if (dlg.uploadComplete) {\n        Roo.MessageBox.hide();\n        return;\n    }\n    \n    dlg.haveProgress = 1;\n\n    var uid = _this.form.findField('UPLOAD_IDENTIFIER').getValue();\n    new Pman.Request({\n        url : baseURL + '/Core/UploadProgress.php',\n        params: {\n            id : uid\n        },\n        method: 'GET',\n        success : function(res){\n            //console.log(data);\n            var data = res.data;\n            if (dlg.haveProgress == 2) {\n                // it's been closed elsewhere..\n                return;\n            }\n            \n            if (dlg.uploadComplete) {\n                Roo.MessageBox.hide();\n                return;\n            }\n                \n            if (data){\n                Roo.MessageBox.updateProgress(data.bytes_uploaded/data.bytes_total,\n                    Math.floor((data.bytes_total - data.bytes_uploaded)/1000) + 'k remaining'\n                );\n            } else {\n                Roo.MessageBox.updateProgress(1,\n                    \"Upload Complete - processing\"\n                );\n                return;\n            }\n            dlg.uploadProgress.defer(2000,dlg);\n        },\n        failure: function(data) {\n          //  console.log('fail');\n         //   console.log(data);\n        }\n    })\n    \n}\n",
34    "items" : [
35     {
36      "xtype" : "LayoutRegion",
37      "$ xns" : "Roo",
38      "* prop" : "center"
39     },
40     {
41      "fitToFrame" : true,
42      "region" : "center",
43      "xtype" : "ContentPanel",
44      "$ xns" : "Roo",
45      "items" : [
46       {
47        "listeners" : {
48         "actionfailed" : "function (_self, act)\n{\n   \n   \n    _this.dialog.uploadComplete = true;\n   // _this.dialog.el.unmask();\n    // error msg???\n     _this.dialog.haveProgress = 2; \n    if (act.type == 'submit') {\n        Roo.log(\"Upload error\");\n        Roo.log(act);\n        \n        try {\n            Roo.MessageBox.alert(\"Error\", act.result.errorMsg.split(/\\n/).join('<BR/>'));\n        } catch(e) {\n          //  Roo.log(e);\n            Roo.MessageBox.alert(\"Error\", \"Saving failed = fix errors and try again\");        \n        }\n        return;\n    }\n    \n    // what about load failing..\n    Roo.MessageBox.alert(\"Error\", \"Error loading details\"); \n}",
49         "|actioncomplete" : "function(_self,act)\n{\n    _this.dialog.uploadComplete = true;\n    _this.dialog.haveProgress = 2; \n    Roo.MessageBox.hide(); // force hiding\n    //_this.dialog.el.unmask();\n     \n    if (act.type == 'setdata') { \n        this.url = _this.data._url ? _this.data._url : baseURL + '/Roo/Images.php';\n        this.el.dom.action = this.url;\n        if (typeof(_this.data.timeout) != 'undefined') {\n            this.timeout = _this.data.timeout;\n        }\n        \n        this.findField('UPLOAD_IDENTIFIER').setValue(\n            (new Date() * 1) + '' + Math.random());\n            \n        return;\n    }\n     \n   \n    if (act.type == 'load') {\n      // should this happen?  \n        _this.data = act.result.data;\n       // _this.loaded();\n        return;\n    }\n    \n    \n    if (act.type == 'submit') { // only submitted here if we are \n        _this.dialog.hide();\n        Roo.log(\"Upload success\");\n        Roo.log(act);\n        //console.log(act);\n        if (_this.callback) {\n            _this.callback.call(this, act.result.data, act.result.extra);\n        }\n        return; \n    }\n    \n\n    \n}\n",
50         "|rendered" : "function (form)\n{\n    _this.form= form;\n}\n"
51        },
52        "$ url" : "baseURL + '/Roo/Images.php'",
53        "fileUpload" : true,
54        "method" : "POST",
55        "style" : "margin:10px;",
56        "xtype" : "Form",
57        "labelWidth" : 140,
58        "timeout" : 300,
59        "$ xns" : "Roo.form",
60        "items" : [
61         {
62          "xtype" : "Hidden",
63          "$ xns" : "Roo.form",
64          "name" : "UPLOAD_IDENTIFIER"
65         },
66         {
67          "xtype" : "Hidden",
68          "value" : "32M",
69          "$ xns" : "Roo.form",
70          "name" : "post_max_size"
71         },
72         {
73          "xtype" : "Hidden",
74          "value" : "32M",
75          "$ xns" : "Roo.form",
76          "name" : "upload_max_filesize"
77         },
78         {
79          "inputType" : "file",
80          "fieldLabel" : "Upload Image or File",
81          "xtype" : "TextField",
82          "width" : 200,
83          "$ xns" : "Roo.form",
84          "name" : "imageUpload"
85         },
86         {
87          "xtype" : "Hidden",
88          "$ xns" : "Roo.form",
89          "name" : "ontable"
90         },
91         {
92          "xtype" : "Hidden",
93          "$ xns" : "Roo.form",
94          "name" : "onid"
95         },
96         {
97          "xtype" : "Hidden",
98          "$ xns" : "Roo.form",
99          "name" : "id"
100         },
101         {
102          "String name" : "fred",
103          "xtype" : "TextField",
104          "Mixed value" : 1,
105          "$ xns" : "Roo.form"
106         },
107         {
108          "xtype" : "Hidden",
109          "$ xns" : "Roo.form",
110          "name" : "imgtype"
111         }
112        ]
113       }
114      ]
115     },
116     {
117      "listeners" : {
118       "click" : "function (_self, e)\n{\n    _this.dialog.hide();\n}"
119      },
120      "text" : "Cancel",
121      "xtype" : "Button",
122      "$ xns" : "Roo",
123      "* prop" : "buttons[]"
124     },
125     {
126      "listeners" : {
127       "click" : "function (_self, e)\n{\n    // do some checks?\n     \n    //_this.dialog.el.mask(\"Sending\");\n    _this.dialog.uploadComplete = false;\n    _this.form.doAction('submit', {\n        params: {\n            ts : Math.random()\n        } \n    });\n    _this.dialog.haveProgress = 0; // set to show..\n    _this.dialog.uploadProgress.defer(1000, _this.dialog);\n\n}"
128      },
129      "text" : "Upload",
130      "xtype" : "Button",
131      "$ xns" : "Roo",
132      "* prop" : "buttons[]"
133     }
134    ]
135   }
136  ]
137 }