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   "ea4788705e6873b424c65e91c2846b19" : "Cancel",
12   "91412465ea9169dfd901dd5e7c96dd99" : "Upload",
13   "ea72bacd2fdfa818907bb9559e6905a1" : "Upload Image or File"
14  },
15  "items" : [
16   {
17    "listeners" : {
18     "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}"
19    },
20    "modal" : true,
21    "shadow" : true,
22    "collapsible" : false,
23    "title" : "Upload an Image or File",
24    "xtype" : "LayoutDialog",
25    "uploadComplete" : false,
26    "width" : 500,
27    "$ xns" : "Roo",
28    "closable" : false,
29    "resizable" : false,
30    "haveProgress" : false,
31    "height" : 140,
32    "$ 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",
33    "items" : [
34     {
35      "xtype" : "LayoutRegion",
36      "$ xns" : "Roo",
37      "* prop" : "center"
38     },
39     {
40      "fitToFrame" : true,
41      "region" : "center",
42      "xtype" : "ContentPanel",
43      "$ xns" : "Roo",
44      "items" : [
45       {
46        "listeners" : {
47         "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}",
48         "|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",
49         "|rendered" : "function (form)\n{\n    _this.form= form;\n}\n"
50        },
51        "$ url" : "baseURL + '/Roo/Images.php'",
52        "fileUpload" : true,
53        "method" : "POST",
54        "style" : "margin:10px;",
55        "xtype" : "Form",
56        "labelWidth" : 140,
57        "timeout" : 300,
58        "$ xns" : "Roo.form",
59        "items" : [
60         {
61          "xtype" : "Hidden",
62          "$ xns" : "Roo.form",
63          "name" : "UPLOAD_IDENTIFIER"
64         },
65         {
66          "xtype" : "Hidden",
67          "value" : "32M",
68          "$ xns" : "Roo.form",
69          "name" : "post_max_size"
70         },
71         {
72          "xtype" : "Hidden",
73          "value" : "32M",
74          "$ xns" : "Roo.form",
75          "name" : "upload_max_filesize"
76         },
77         {
78          "inputType" : "file",
79          "fieldLabel" : "Upload Image or File",
80          "xtype" : "TextField",
81          "width" : 200,
82          "$ xns" : "Roo.form",
83          "name" : "imageUpload"
84         },
85         {
86          "xtype" : "Hidden",
87          "$ xns" : "Roo.form",
88          "name" : "ontable"
89         },
90         {
91          "xtype" : "Hidden",
92          "$ xns" : "Roo.form",
93          "name" : "onid"
94         },
95         {
96          "xtype" : "Hidden",
97          "$ xns" : "Roo.form",
98          "name" : "id"
99         },
100         {
101          "xtype" : "Hidden",
102          "$ xns" : "Roo.form"
103         },
104         {
105          "xtype" : "Hidden",
106          "$ xns" : "Roo.form",
107          "name" : "imgtype"
108         }
109        ]
110       }
111      ]
112     },
113     {
114      "listeners" : {
115       "click" : "function (_self, e)\n{\n    _this.dialog.hide();\n}"
116      },
117      "text" : "Cancel",
118      "xtype" : "Button",
119      "$ xns" : "Roo",
120      "* prop" : "buttons[]"
121     },
122     {
123      "listeners" : {
124       "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}"
125      },
126      "text" : "Upload",
127      "xtype" : "Button",
128      "$ xns" : "Roo",
129      "* prop" : "buttons[]"
130     }
131    ]
132   }
133  ]
134 }