Index: ssts-web/src/main/webapp/ext/UploadDialog/Ext.ux.UploadDialog.js
===================================================================
diff -u -r12331 -r40987
--- ssts-web/src/main/webapp/ext/UploadDialog/Ext.ux.UploadDialog.js (.../Ext.ux.UploadDialog.js) (revision 12331)
+++ ssts-web/src/main/webapp/ext/UploadDialog/Ext.ux.UploadDialog.js (.../Ext.ux.UploadDialog.js) (revision 40987)
@@ -3,56 +3,53 @@
*/
Ext.namespace('Ext.ux.Utils');
+
/**
* This class implements event queue behaviour.
*
* @class Ext.ux.Utils.EventQueue
* @param function handler Event handler.
* @param object scope Handler scope.
*/
-Ext.ux.Utils.EventQueue = function(handler, scope)
-{
+Ext.ux.Utils.EventQueue = function (handler, scope) {
if (!handler) {
throw 'Handler is required.';
}
this.handler = handler;
this.scope = scope || window;
this.queue = [];
this.is_processing = false;
-
+
/**
* Posts event into the queue.
- *
+ *
* @access public
* @param mixed event Event identificator.
* @param mixed data Event data.
*/
- this.postEvent = function(event, data)
- {
+ this.postEvent = function (event, data) {
data = data || null;
- this.queue.push({event: event, data: data});
+ this.queue.push({ event: event, data: data });
if (!this.is_processing) {
this.process();
}
}
-
- this.flushEventQueue = function()
- {
+
+ this.flushEventQueue = function () {
this.queue = [];
},
-
- /**
- * @access private
- */
- this.process = function()
- {
- while (this.queue.length > 0) {
- this.is_processing = true;
- var event_data = this.queue.shift();
- this.handler.call(this.scope, event_data.event, event_data.data);
+
+ /**
+ * @access private
+ */
+ this.process = function () {
+ while (this.queue.length > 0) {
+ this.is_processing = true;
+ var event_data = this.queue.shift();
+ this.handler.call(this.scope, event_data.event, event_data.data);
+ }
+ this.is_processing = false;
}
- this.is_processing = false;
- }
}
/**
@@ -87,8 +84,7 @@
* @param object trans_table Transition / output table.
* @param trans_table_scope Transition / output table's methods scope.
*/
-Ext.ux.Utils.FSA = function(initial_state, trans_table, trans_table_scope)
-{
+Ext.ux.Utils.FSA = function (initial_state, trans_table, trans_table_scope) {
this.current_state = initial_state;
this.trans_table = trans_table || {};
this.trans_table_scope = trans_table_scope || window;
@@ -97,26 +93,24 @@
Ext.extend(Ext.ux.Utils.FSA, Ext.ux.Utils.EventQueue, {
- current_state : null,
- trans_table : null,
- trans_table_scope : null,
-
+ current_state: null,
+ trans_table: null,
+ trans_table_scope: null,
+
/**
* Returns current state
*
* @access public
* @return mixed Current state.
*/
- state : function()
- {
+ state: function () {
return this.current_state;
},
-
+
/**
* @access public
*/
- processEvent : function(event, data)
- {
+ processEvent: function (event, data) {
var transitions = this.currentStateEventTransitions(event);
if (!transitions) {
throw "State '" + this.current_state + "' has no transition for event '" + event + "'.";
@@ -128,108 +122,105 @@
var action = transition.action || transition.a || Ext.emptyFn;
var new_state = transition.state || transition.s || this.current_state;
var scope = transition.scope || this.trans_table_scope;
-
+
if (this.computePredicate(predicate, scope, data, event)) {
this.callAction(action, scope, data, event);
- this.current_state = new_state;
+ this.current_state = new_state;
return;
}
}
-
+
throw "State '" + this.current_state + "' has no transition for event '" + event + "' in current context";
},
-
+
/**
* @access private
*/
- currentStateEventTransitions : function(event)
- {
- return this.trans_table[this.current_state] ?
+ currentStateEventTransitions: function (event) {
+ return this.trans_table[this.current_state] ?
this.trans_table[this.current_state][event] || false
:
false;
},
-
+
/**
* @access private
*/
- computePredicate : function(predicate, scope, data, event)
- {
- var result = false;
-
+ computePredicate: function (predicate, scope, data, event) {
+ var result = false;
+
switch (Ext.type(predicate)) {
- case 'function':
- result = predicate.call(scope, data, event, this);
- break;
- case 'array':
- result = true;
- for (var i = 0, len = predicate.length; result && (i < len); i++) {
- if (Ext.type(predicate[i]) == 'function') {
- result = predicate[i].call(scope, data, event, this);
- }
- else {
- throw [
- 'Predicate: ',
- predicate[i],
- ' is not callable in "',
- this.current_state,
- '" state for event "',
- event
- ].join('');
- }
- }
- break;
- case 'boolean':
- result = predicate;
- break;
- default:
- throw [
- 'Predicate: ',
- predicate,
- ' is not callable in "',
- this.current_state,
- '" state for event "',
- event
- ].join('');
+ case 'function':
+ result = predicate.call(scope, data, event, this);
+ break;
+ case 'array':
+ result = true;
+ for (var i = 0, len = predicate.length; result && (i < len); i++) {
+ if (Ext.type(predicate[i]) == 'function') {
+ result = predicate[i].call(scope, data, event, this);
+ }
+ else {
+ throw [
+ 'Predicate: ',
+ predicate[i],
+ ' is not callable in "',
+ this.current_state,
+ '" state for event "',
+ event
+ ].join('');
+ }
+ }
+ break;
+ case 'boolean':
+ result = predicate;
+ break;
+ default:
+ throw [
+ 'Predicate: ',
+ predicate,
+ ' is not callable in "',
+ this.current_state,
+ '" state for event "',
+ event
+ ].join('');
}
return result;
},
-
+
/**
* @access private
*/
- callAction : function(action, scope, data, event)
- {
+ callAction: function (action, scope, data, event) {
switch (Ext.type(action)) {
- case 'array':
- for (var i = 0, len = action.length; i < len; i++) {
- if (Ext.type(action[i]) == 'function') {
- action[i].call(scope, data, event, this);
- }
- else {
- throw [
- 'Action: ',
- action[i],
- ' is not callable in "',
- this.current_state,
- '" state for event "',
- event
- ].join('');
- }
- }
- break;
- case 'function':
- action.call(scope, data, event, this);
- break;
- default:
- throw [
- 'Action: ',
- action,
- ' is not callable in "',
- this.current_state,
- '" state for event "',
- event
- ].join('');
+ case 'array':
+ for (var i = 0, len = action.length; i < len; i++) {
+ if (Ext.type(action[i]) == 'function') {
+ action[i].call(scope, data, event, this);
+ }
+ else {
+ throw [
+ 'Action: ',
+ action[i],
+ ' is not callable in "',
+ this.current_state,
+ '" state for event "',
+ event
+ ].join('');
+ }
+ }
+ break;
+ case 'function':
+ action.call(scope, data, event, this);
+ break;
+ default:
+ throw [
+ 'Action: ',
+ action,
+ ' is not callable in "',
+ this.current_state,
+ '" state for event "',
+ event
+ ].join('');
}
}
});
@@ -245,209 +236,198 @@
* File upload browse button.
*
* @class Ext.ux.UploadDialog.BrowseButton
- */
-Ext.ux.UploadDialog.BrowseButton = Ext.extend(Ext.Button,
-{
- input_name : 'file',
-
- input_file : null,
-
- original_handler : null,
-
- original_scope : null,
-
- /**
- * @access private
- */
- initComponent : function()
+ */
+Ext.ux.UploadDialog.BrowseButton = Ext.extend(Ext.Button,
{
- Ext.ux.UploadDialog.BrowseButton.superclass.initComponent.call(this);
- this.original_handler = this.handler || null;
- this.original_scope = this.scope || window;
- this.handler = null;
- this.scope = null;
- },
-
- /**
- * @access private
- */
- onRender : function(ct, position)
- {
- Ext.ux.UploadDialog.BrowseButton.superclass.onRender.call(this, ct, position);
- this.createInputFile();
- },
-
- /**
- * @access private
- */
- createInputFile : function()
- {
- var button_container = this.el.child('.x-btn-center');
- button_container.position('relative');
- this.input_file = Ext.DomHelper.append(
- button_container,
- {
- tag: 'input',
- type: 'file',
- size: 1,
- name: this.input_name || Ext.id(this.el),
- style: 'position: absolute; display: block; border: none; cursor: pointer'
- },
- true
- );
-
- this.input_file.setOpacity(0.0);
- this.adjustInputFileBox();
-
- if (this.handleMouseEvents) {
- this.input_file.on('mouseover', this.onMouseOver, this);
+ input_name: 'file',
+
+ input_file: null,
+
+ original_handler: null,
+
+ original_scope: null,
+
+ /**
+ * @access private
+ */
+ initComponent: function () {
+ Ext.ux.UploadDialog.BrowseButton.superclass.initComponent.call(this);
+ this.original_handler = this.handler || null;
+ this.original_scope = this.scope || window;
+ this.handler = null;
+ this.scope = null;
+ },
+
+ /**
+ * @access private
+ */
+ onRender: function (ct, position) {
+ Ext.ux.UploadDialog.BrowseButton.superclass.onRender.call(this, ct, position);
+ this.createInputFile();
+ },
+
+ /**
+ * @access private
+ */
+ createInputFile: function () {
+ var button_container = this.el.child('.x-btn-center');
+ button_container.position('relative');
+ this.input_file = Ext.DomHelper.append(
+ button_container,
+ {
+ tag: 'input',
+ type: 'file',
+ size: 1,
+ name: this.input_name || Ext.id(this.el),
+ style: 'position: absolute; display: block; border: none; cursor: pointer'
+ },
+ true
+ );
+
+ this.input_file.setOpacity(0.0);
+ this.adjustInputFileBox();
+
+ if (this.handleMouseEvents) {
+ this.input_file.on('mouseover', this.onMouseOver, this);
this.input_file.on('mousedown', this.onMouseDown, this);
- }
-
- if(this.tooltip){
- if(typeof this.tooltip == 'object'){
- Ext.QuickTips.register(Ext.apply({target: this.input_file}, this.tooltip));
- }
- else {
- this.input_file.dom[this.tooltipType] = this.tooltip;
+ }
+
+ if (this.tooltip) {
+ if (typeof this.tooltip == 'object') {
+ Ext.QuickTips.register(Ext.apply({ target: this.input_file }, this.tooltip));
}
+ else {
+ this.input_file.dom[this.tooltipType] = this.tooltip;
+ }
}
-
- this.input_file.on('change', this.onInputFileChange, this);
- this.input_file.on('click', function(e) { e.stopPropagation(); });
- },
- /**
- * @access private
- */
- autoWidth : function()
- {
- Ext.ux.UploadDialog.BrowseButton.superclass.autoWidth.call(this);
- this.adjustInputFileBox();
- },
+ this.input_file.on('change', this.onInputFileChange, this);
+ this.input_file.on('click', function (e) { e.stopPropagation(); });
+ },
- /**
- * @access private
- */
- adjustInputFileBox : function()
- {
- var btn_cont, btn_box, inp_box, adj;
+ /**
+ * @access private
+ */
+ autoWidth: function () {
+ Ext.ux.UploadDialog.BrowseButton.superclass.autoWidth.call(this);
+ this.adjustInputFileBox();
+ },
- if (this.el && this.input_file) {
- btn_cont = this.el.child('.x-btn-center');
- btn_box = btn_cont.getBox();
- this.input_file.setStyle('font-size', (btn_box.width * 0.5) + 'px');
- inp_box = this.input_file.getBox();
- adj = {x: 3, y: 3}
- if (Ext.isIE) {
- adj = {x: -3, y: 3}
- }
- this.input_file.setLeft(btn_box.width - inp_box.width + adj.x + 'px');
- this.input_file.setTop(btn_box.height - inp_box.height + adj.y + 'px');
- }
- },
-
- /**
- * @access public
- */
- detachInputFile : function(no_create)
- {
- var result = this.input_file;
-
- no_create = no_create || false;
-
- if (typeof this.tooltip == 'object') {
- Ext.QuickTips.unregister(this.input_file);
+ /**
+ * @access private
+ */
+ adjustInputFileBox: function () {
+ var btn_cont, btn_box, inp_box, adj;
+
+ if (this.el && this.input_file) {
+ btn_cont = this.el.child('.x-btn-center');
+ btn_box = btn_cont.getBox();
+ this.input_file.setStyle('font-size', (btn_box.width * 0.5) + 'px');
+ inp_box = this.input_file.getBox();
+ adj = { x: 3, y: 3 }
+ if (Ext.isIE) {
+ adj = { x: -3, y: 3 }
+ }
+ this.input_file.setLeft(btn_box.width - inp_box.width + adj.x + 'px');
+ this.input_file.setTop(btn_box.height - inp_box.height + adj.y + 'px');
+ }
+ },
+
+ /**
+ * @access public
+ */
+ detachInputFile: function (no_create) {
+ var result = this.input_file;
+
+ no_create = no_create || false;
+
+ if (typeof this.tooltip == 'object') {
+ Ext.QuickTips.unregister(this.input_file);
+ }
+ else {
+ this.input_file.dom[this.tooltipType] = null;
+ }
+ this.input_file.removeAllListeners();
+ this.input_file = null;
+
+ if (!no_create) {
+ this.createInputFile();
+ }
+ return result;
+ },
+
+ /**
+ * @access public
+ */
+ getInputFile: function () {
+ return this.input_file;
+ },
+
+ /**
+ * @access public
+ */
+ disable: function () {
+ Ext.ux.UploadDialog.BrowseButton.superclass.disable.call(this);
+ this.input_file.dom.disabled = true;
+ },
+
+ /**
+ * @access public
+ */
+ enable: function () {
+ Ext.ux.UploadDialog.BrowseButton.superclass.enable.call(this);
+ this.input_file.dom.disabled = false;
+ },
+
+ /**
+ * @access public
+ */
+ destroy: function () {
+ var input_file = this.detachInputFile(true);
+ input_file.remove();
+ input_file = null;
+ Ext.ux.UploadDialog.BrowseButton.superclass.destroy.call(this);
+ },
+
+ /**
+ * @access private
+ */
+ onInputFileChange: function () {
+ if (this.original_handler) {
+ this.original_handler.call(this.original_scope, this);
+ }
}
- else {
- this.input_file.dom[this.tooltipType] = null;
- }
- this.input_file.removeAllListeners();
- this.input_file = null;
-
- if (!no_create) {
- this.createInputFile();
- }
- return result;
- },
-
- /**
- * @access public
- */
- getInputFile : function()
- {
- return this.input_file;
- },
-
- /**
- * @access public
- */
- disable : function()
- {
- Ext.ux.UploadDialog.BrowseButton.superclass.disable.call(this);
- this.input_file.dom.disabled = true;
- },
-
- /**
- * @access public
- */
- enable : function()
- {
- Ext.ux.UploadDialog.BrowseButton.superclass.enable.call(this);
- this.input_file.dom.disabled = false;
- },
-
- /**
- * @access public
- */
- destroy : function()
- {
- var input_file = this.detachInputFile(true);
- input_file.remove();
- input_file = null;
- Ext.ux.UploadDialog.BrowseButton.superclass.destroy.call(this);
- },
-
- /**
- * @access private
- */
- onInputFileChange : function()
- {
- if (this.original_handler) {
- this.original_handler.call(this.original_scope, this);
- }
- }
-});
+ });
/**
* Toolbar file upload browse button.
*
* @class Ext.ux.UploadDialog.TBBrowseButton
*/
-Ext.ux.UploadDialog.TBBrowseButton = Ext.extend(Ext.ux.UploadDialog.BrowseButton,
-{
- hideParent : true,
-
- onDestroy : function()
+Ext.ux.UploadDialog.TBBrowseButton = Ext.extend(Ext.ux.UploadDialog.BrowseButton,
{
- Ext.ux.UploadDialog.TBBrowseButton.superclass.onDestroy.call(this);
- if(this.container) {
- this.container.remove();
+ hideParent: true,
+
+ onDestroy: function () {
+ Ext.ux.UploadDialog.TBBrowseButton.superclass.onDestroy.call(this);
+ if (this.container) {
+ this.container.remove();
}
- }
-});
+ }
+ });
/**
* Record type for dialogs grid.
*
* @class Ext.ux.UploadDialog.FileRecord
*/
Ext.ux.UploadDialog.FileRecord = Ext.data.Record.create([
- {name: 'filename'},
- {name: 'state', type: 'int'},
- {name: 'note'},
- {name: 'input_element'},
- {name: 'params'}
+ { name: 'filename' },
+ { name: 'state', type: 'int' },
+ { name: 'note' },
+ { name: 'blobs' },
+ { name: 'input_element' },
+ { name: 'params' }
]);
Ext.ux.UploadDialog.FileRecord.STATE_QUEUE = 0;
@@ -460,8 +440,7 @@
*
* @class Ext.ux.UploadDialog.Dialog
*/
-Ext.ux.UploadDialog.Dialog = function(config)
-{
+Ext.ux.UploadDialog.Dialog = function (config) {
var default_config = {
border: false,
width: 450,
@@ -484,80 +463,80 @@
base_params: {},
permitted_extensions: [],
reset_on_hide: true,
+ params: {},
allow_close_on_upload: false,
upload_autostart: false,
post_var_name: 'file'
}
config = Ext.applyIf(config || {}, default_config);
config.layout = 'absolute';
-
+
Ext.ux.UploadDialog.Dialog.superclass.constructor.call(this, config);
}
Ext.extend(Ext.ux.UploadDialog.Dialog, Ext.Window, {
- fsa : null,
-
- state_tpl : null,
-
- form : null,
-
- grid_panel : null,
-
- progress_bar : null,
-
- is_uploading : false,
-
- initial_queued_count : 0,
-
- upload_frame : null,
-
+ fsa: null,
+
+ state_tpl: null,
+
+ form: null,
+
+ grid_panel: null,
+
+ progress_bar: null,
+
+ is_uploading: false,
+
+ initial_queued_count: 0,
+
+ upload_frame: null,
+
/**
* @access private
*/
//--------------------------------------------------------------------------------------------- //
- initComponent : function()
- {
+ initComponent: function () {
Ext.ux.UploadDialog.Dialog.superclass.initComponent.call(this);
-
+
// Setting automata protocol
var tt = {
// --------------
- 'created' : {
- // --------------
- 'window-render' : [
+ 'created': {
+ // --------------
+ 'window-render': [
{
action: [this.createForm, this.createProgressBar, this.createGrid],
state: 'rendering'
}
],
- 'destroy' : [
+ 'destroy': [
{
action: this.flushEventQueue,
state: 'destroyed'
}
]
},
// --------------
- 'rendering' : {
- // --------------
- 'grid-render' : [
+ 'rendering': {
+ // --------------
+ 'grid-render': [
{
action: [this.fillToolbar, this.updateToolbar],
state: 'ready'
}
],
- 'destroy' : [
+ 'destroy': [
{
action: this.flushEventQueue,
state: 'destroyed'
}
]
},
// --------------
- 'ready' : {
- // --------------
- 'file-selected' : [
+ 'ready': {
+ // --------------
+ 'file-selected': [
{
predicate: [this.fireFileTestEvent, this.isPermittedFile],
action: this.addFileToUploadQueue,
@@ -568,26 +547,26 @@
action: this.resetAddButton
}
],
- 'grid-selection-change' : [
+ 'grid-selection-change': [
{
action: this.updateToolbar
}
],
- 'remove-files' : [
+ 'remove-files': [
{
action: [this.removeFiles, this.fireFileRemoveEvent]
}
],
- 'reset-queue' : [
+ 'reset-queue': [
{
action: [this.resetQueue, this.fireResetQueueEvent]
}
],
- 'start-upload' : [
+ 'start-upload': [
{
predicate: this.hasUnuploadedFiles,
action: [
- this.setUploadingFlag, this.saveInitialQueuedCount, this.updateToolbar,
+ this.setUploadingFlag, this.saveInitialQueuedCount, this.updateToolbar,
this.updateProgressBar, this.prepareNextUploadTask, this.fireUploadStartEvent
],
state: 'uploading'
@@ -596,12 +575,12 @@
// Has nothing to upload, do nothing.
}
],
- 'stop-upload' : [
+ 'stop-upload': [
{
// We are not uploading, do nothing. Can be posted by user only at this state.
}
],
- 'hide' : [
+ 'hide': [
{
predicate: [this.isNotEmptyQueue, this.getResetOnHide],
action: [this.resetQueue, this.fireResetQueueEvent]
@@ -610,21 +589,21 @@
// Do nothing
}
],
- 'destroy' : [
+ 'destroy': [
{
action: this.flushEventQueue,
state: 'destroyed'
}
]
},
// --------------
- 'adding-file' : {
- // --------------
- 'file-added' : [
+ 'adding-file': {
+ // --------------
+ 'file-added': [
{
predicate: this.isUploading,
action: [this.incInitialQueuedCount, this.updateProgressBar, this.fireFileAddEvent],
- state: 'uploading'
+ state: 'uploading'
},
{
predicate: this.getUploadAutostart,
@@ -638,9 +617,9 @@
]
},
// --------------
- 'uploading' : {
- // --------------
- 'file-selected' : [
+ 'uploading': {
+ // --------------
+ 'file-selected': [
{
predicate: [this.fireFileTestEvent, this.isPermittedFile],
action: this.addFileToUploadQueue,
@@ -651,111 +630,111 @@
action: this.resetAddButton
}
],
- 'grid-selection-change' : [
+ 'grid-selection-change': [
{
// Do nothing.
}
],
- 'start-upload' : [
+ 'start-upload': [
{
// Can be posted only by user in this state.
}
],
- 'stop-upload' : [
+ 'stop-upload': [
{
predicate: this.hasUnuploadedFiles,
action: [
- this.resetUploadingFlag, this.abortUpload, this.updateToolbar,
+ this.resetUploadingFlag, this.abortUpload, this.updateToolbar,
this.updateProgressBar, this.fireUploadStopEvent
],
state: 'ready'
},
{
action: [
- this.resetUploadingFlag, this.abortUpload, this.updateToolbar,
+ this.resetUploadingFlag, this.abortUpload, this.updateToolbar,
this.updateProgressBar, this.fireUploadStopEvent, this.fireUploadCompleteEvent
],
state: 'ready'
}
],
- 'file-upload-start' : [
- {
- predicate: this.fireBeforeFileUploadStartEvent,
- action: [this.uploadFile, this.findUploadFrame, this.fireFileUploadStartEvent]
- },
+ 'file-upload-start': [
{
- action: this.postFileUploadCancelEvent
+ predicate: this.fireBeforeFileUploadStartEvent,
+ action: [this.uploadFile, this.findUploadFrame, this.fireFileUploadStartEvent]
+ },
+ {
+ action: this.postFileUploadCancelEvent
}
],
- 'file-upload-success' : [
+ 'file-upload-success': [
{
predicate: this.hasUnuploadedFiles,
action: [
- this.resetUploadFrame, this.updateRecordState, this.updateProgressBar,
+ this.resetUploadFrame, this.updateRecordState, this.updateProgressBar,
this.prepareNextUploadTask, this.fireUploadSuccessEvent
]
},
{
action: [
- this.resetUploadFrame, this.resetUploadingFlag, this.updateRecordState,
- this.updateToolbar, this.updateProgressBar, this.fireUploadSuccessEvent,
+ this.resetUploadFrame, this.resetUploadingFlag, this.updateRecordState,
+ this.updateToolbar, this.updateProgressBar, this.fireUploadSuccessEvent,
this.fireUploadCompleteEvent
],
state: 'ready'
}
],
- 'file-upload-error' : [
+ 'file-upload-error': [
{
predicate: this.hasUnuploadedFiles,
action: [
- this.resetUploadFrame, this.updateRecordState, this.updateProgressBar,
+ this.resetUploadFrame, this.updateRecordState, this.updateProgressBar,
this.prepareNextUploadTask, this.fireUploadErrorEvent
]
},
{
action: [
- this.resetUploadFrame, this.resetUploadingFlag, this.updateRecordState,
- this.updateToolbar, this.updateProgressBar, this.fireUploadErrorEvent,
+ this.resetUploadFrame, this.resetUploadingFlag, this.updateRecordState,
+ this.updateToolbar, this.updateProgressBar, this.fireUploadErrorEvent,
this.fireUploadCompleteEvent
],
state: 'ready'
}
],
- 'file-upload-failed' : [
+ 'file-upload-failed': [
{
predicate: this.hasUnuploadedFiles,
action: [
- this.resetUploadFrame, this.updateRecordState, this.updateProgressBar,
+ this.resetUploadFrame, this.updateRecordState, this.updateProgressBar,
this.prepareNextUploadTask, this.fireUploadFailedEvent
]
},
{
action: [
- this.resetUploadFrame, this.resetUploadingFlag, this.updateRecordState,
- this.updateToolbar, this.updateProgressBar, this.fireUploadFailedEvent,
+ this.resetUploadFrame, this.resetUploadingFlag, this.updateRecordState,
+ this.updateToolbar, this.updateProgressBar, this.fireUploadFailedEvent,
this.fireUploadCompleteEvent
],
state: 'ready'
}
],
- 'file-upload-canceled' : [
- {
- predicate: this.hasUnuploadedFiles,
- action: [
- this.setRecordCanceledState, this.updateProgressBar, this.prepareNextUploadTask,
- this.fireUploadCanceledEvent
- ]
- },
- {
- action: [
- this.resetUploadingFlag, this.setRecordCanceledState,
- this.updateToolbar, this.updateProgressBar,
- this.fireUploadCanceledEvent, this.fireUploadCompleteEvent
- ],
- state: 'ready'
- }
+ 'file-upload-canceled': [
+ {
+ predicate: this.hasUnuploadedFiles,
+ action: [
+ this.setRecordCanceledState, this.updateProgressBar, this.prepareNextUploadTask,
+ this.fireUploadCanceledEvent
+ ]
+ },
+ {
+ action: [
+ this.resetUploadingFlag, this.setRecordCanceledState,
+ this.updateToolbar, this.updateProgressBar,
+ this.fireUploadCanceledEvent, this.fireUploadCompleteEvent
+ ],
+ state: 'ready'
+ }
],
- 'hide' : [
+ 'hide': [
{
predicate: this.getResetOnHide,
action: [this.stopUpload, this.repostHide]
@@ -764,7 +743,7 @@
// Do nothing.
}
],
- 'destroy' : [
+ 'destroy': [
{
predicate: this.hasUnuploadedFiles,
action: [
@@ -777,59 +756,57 @@
action: [
this.resetUploadingFlag, this.abortUpload,
this.fireUploadStopEvent, this.fireUploadCompleteEvent, this.flushEventQueue
- ],
+ ],
state: 'destroyed'
}
]
},
// --------------
- 'destroyed' : {
- // --------------
+ 'destroyed': {
+ // --------------
}
}
this.fsa = new top.Ext.ux.Utils.FSA('created', tt, this);
-
+
// Registering dialog events.
this.addEvents({
'filetest': true,
- 'fileadd' : true,
- 'fileremove' : true,
- 'resetqueue' : true,
- 'uploadsuccess' : true,
- 'uploaderror' : true,
- 'uploadfailed' : true,
- 'uploadcanceled' : true,
- 'uploadstart' : true,
- 'uploadstop' : true,
- 'uploadcomplete' : true,
- 'beforefileuploadstart' : true,
- 'fileuploadstart' : true
+ 'fileadd': true,
+ 'fileremove': true,
+ 'resetqueue': true,
+ 'uploadsuccess': true,
+ 'uploaderror': true,
+ 'uploadfailed': true,
+ 'uploadcanceled': true,
+ 'uploadstart': true,
+ 'uploadstop': true,
+ 'uploadcomplete': true,
+ 'beforefileuploadstart': true,
+ 'fileuploadstart': true
});
-
+
// Attaching to window events.
this.on('render', this.onWindowRender, this);
this.on('beforehide', this.onWindowBeforeHide, this);
this.on('hide', this.onWindowHide, this);
this.on('destroy', this.onWindowDestroy, this);
-
+
// Compiling state template.
this.state_tpl = new top.Ext.Template(
"
"
).compile();
},
-
- createForm : function()
- {
+
+ createForm: function () {
this.form = Ext.DomHelper.append(this.body, {
tag: 'form',
method: 'post',
action: this.url,
style: 'position: absolute; left: -100px; top: -100px; width: 100px; height: 100px'
});
},
-
- createProgressBar : function()
- {
+
+ createProgressBar: function () {
this.progress_bar = this.add(
new top.Ext.ProgressBar({
x: 0,
@@ -840,16 +817,15 @@
})
);
},
-
- createGrid : function()
- {
+
+ createGrid: function () {
var store = new top.Ext.data.Store({
proxy: new top.Ext.data.MemoryProxy([]),
reader: new top.Ext.data.JsonReader({}, Ext.ux.UploadDialog.FileRecord),
- sortInfo: {field: 'state', direction: 'DESC'},
+ sortInfo: { field: 'state', direction: 'DESC' },
pruneModifiedRecords: true
});
-
+
var cm = new top.Ext.grid.ColumnModel([
{
header: this.i18n.state_col_title,
@@ -868,41 +844,40 @@
},
{
header: this.i18n.note_col_title,
- width: this.i18n.note_col_width,
+ width: this.i18n.note_col_width,
dataIndex: 'note',
sortable: true,
renderer: this.renderNoteCell.createDelegate(this)
}
]);
-
- this.grid_panel = new top.Ext.grid.GridPanel({
+
+ this.grid_panel = new top.Ext.grid.GridPanel({
ds: store,
cm: cm,
-
+
x: 0,
y: 22,
anchor: '0 0',
border: true,
-
- viewConfig: {
+
+ viewConfig: {
autoFill: true,
- forceFit: true
- },
-
- bbar : new top.Ext.Toolbar()
+ forceFit: true
+ },
+
+ bbar: new top.Ext.Toolbar()
});
this.grid_panel.on('render', this.onGridRender, this);
-
+
this.add(this.grid_panel);
-
+
this.grid_panel.getSelectionModel().on('selectionchange', this.onGridSelectionChange, this);
},
-
- fillToolbar : function()
- {
+
+ fillToolbar: function () {
var tb = this.grid_panel.getBottomToolbar();
tb.x_buttons = {}
-
+
tb.x_buttons.add = tb.addItem(new top.Ext.ux.UploadDialog.TBBrowseButton({
input_name: this.post_var_name,
text: this.i18n.add_btn_text,
@@ -911,35 +886,43 @@
handler: this.onAddButtonFileSelected,
scope: this
}));
-
+
+ tb.x_buttons.camera = tb.addButton({
+ text: this.i18n.camera_btn_text,
+ tooltip: this.i18n.camera_btn_tip,
+ iconCls: 'ext-ux-uploaddialog-addbtn',
+ handler: this.onCameraButtonClick,
+ scope: this
+ });
+
tb.x_buttons.remove = tb.addButton({
text: this.i18n.remove_btn_text,
tooltip: this.i18n.remove_btn_tip,
iconCls: 'ext-ux-uploaddialog-removebtn',
handler: this.onRemoveButtonClick,
scope: this
});
-
+
tb.x_buttons.reset = tb.addButton({
text: this.i18n.reset_btn_text,
tooltip: this.i18n.reset_btn_tip,
iconCls: 'ext-ux-uploaddialog-resetbtn',
handler: this.onResetButtonClick,
scope: this
});
-
+
tb.add('-');
-
+
tb.x_buttons.upload = tb.addButton({
text: this.i18n.upload_btn_start_text,
tooltip: this.i18n.upload_btn_start_tip,
iconCls: 'ext-ux-uploaddialog-uploadstartbtn',
handler: this.onUploadButtonClick,
scope: this
});
-
+
tb.add('-');
-
+
tb.x_buttons.indicator = tb.addItem(
new top.Ext.Toolbar.Item(
Ext.DomHelper.append(tb.getEl(), {
@@ -949,74 +932,68 @@
})
)
);
-
+
tb.add('->');
-
+
tb.x_buttons.close = tb.addButton({
text: this.i18n.close_btn_text,
tooltip: this.i18n.close_btn_tip,
handler: this.onCloseButtonClick,
scope: this
});
},
-
- renderStateCell : function(data, cell, record, row_index, column_index, store)
- {
- return this.state_tpl.apply({state: data});
+
+ renderStateCell: function (data, cell, record, row_index, column_index, store) {
+ return this.state_tpl.apply({ state: data });
},
-
- renderFilenameCell : function(data, cell, record, row_index, column_index, store)
- {
+
+ renderFilenameCell: function (data, cell, record, row_index, column_index, store) {
if (Ext.QuickTips.isEnabled()) {
- cell.attr = 'ext:qtip="' + Ext.util.Format.htmlEncode(data) + '"';
+ cell.attr = 'ext:qtip="' + Ext.util.Format.htmlEncode(data) + '"';
}
else {
- cell.attr = 'title="' + data + '"';
+ cell.attr = 'title="' + data + '"';
}
return data;
},
-
- renderNoteCell : function(data, cell, record, row_index, column_index, store)
- {
+
+ renderNoteCell: function (data, cell, record, row_index, column_index, store) {
if (Ext.QuickTips.isEnabled()) {
- cell.attr = 'ext:qtip="' + Ext.util.Format.htmlEncode(data) + '"';
+ cell.attr = 'ext:qtip="' + Ext.util.Format.htmlEncode(data) + '"';
}
else {
- cell.attr = 'title="' + data + '"';
+ cell.attr = 'title="' + data + '"';
}
return data;
},
-
- getFileExtension : function(filename)
- {
+
+ getFileExtension: function (filename) {
var result = null;
var parts = filename.split('.');
if (parts.length > 1) {
result = parts.pop();
}
return result;
},
-
- isPermittedFileType : function(filename)
- {
+
+ isPermittedFileType: function (filename) {
var result = true;
if (this.permitted_extensions.length > 0) {
result = this.permitted_extensions.indexOf(this.getFileExtension(filename)) != -1;
}
return result;
},
- isPermittedFile : function(browse_btn)
- {
+ isPermittedFile: function (browse_btn) {
var result = false;
var filename = browse_btn.getInputFile().dom.value;
-
+
if (this.isPermittedFileType(filename)) {
result = true;
}
else {
Ext.Msg.alert(
- this.i18n.error_msgbox_title,
+ this.i18n.error_msgbox_title,
String.format(
this.i18n.err_file_type_not_permitted,
filename,
@@ -1025,49 +1002,45 @@
);
result = false;
}
-
+
return result;
},
-
- fireFileTestEvent : function(browse_btn)
- {
+
+ fireFileTestEvent: function (browse_btn) {
return this.fireEvent('filetest', this, browse_btn.getInputFile().dom.value) !== false;
},
-
- addFileToUploadQueue : function(browse_btn)
- {
+
+ addFileToUploadQueue: function (browse_btn) {
var input_file = browse_btn.detachInputFile();
-
+
input_file.appendTo(this.form);
input_file.setStyle('width', '100px');
input_file.dom.disabled = true;
-
+
var store = this.grid_panel.getStore();
store.add(
new top.Ext.ux.UploadDialog.FileRecord({
- state: Ext.ux.UploadDialog.FileRecord.STATE_QUEUE,
- filename: input_file.dom.value,
- note: this.i18n.note_queued_to_upload,
- input_element: input_file
- })
- );
+ state: Ext.ux.UploadDialog.FileRecord.STATE_QUEUE,
+ filename: input_file.dom.value,
+ note: this.i18n.note_queued_to_upload,
+ input_element: input_file
+ })
+ );
this.fsa.postEvent('file-added', input_file.dom.value);
},
-
- fireFileAddEvent : function(filename)
- {
+
+ fireFileAddEvent: function (filename) {
this.fireEvent('fileadd', this, filename);
},
-
- updateProgressBar : function()
- {
+
+ updateProgressBar: function () {
if (this.is_uploading) {
var queued = this.getQueuedCount(true);
var value = 1 - queued / this.initial_queued_count;
this.progress_bar.updateProgress(
value,
String.format(
- this.i18n.progress_uploading_text,
+ this.i18n.progress_uploading_text,
this.initial_queued_count - queued,
this.initial_queued_count
)
@@ -1077,9 +1050,8 @@
this.progress_bar.updateProgress(0, this.i18n.progress_waiting_text);
}
},
-
- updateToolbar : function()
- {
+
+ updateToolbar: function () {
var tb = this.grid_panel.getBottomToolbar();
if (this.is_uploading) {
tb.x_buttons.remove.disable();
@@ -1111,21 +1083,21 @@
tb.x_buttons.upload.getEl()
.child(tb.x_buttons.upload.buttonSelector)
.dom[tb.x_buttons.upload.tooltipType] = this.i18n.upload_btn_start_tip;
-
+
if (this.getQueuedCount() > 0) {
tb.x_buttons.upload.enable();
}
else {
- tb.x_buttons.upload.disable();
+ tb.x_buttons.upload.disable();
}
-
+
if (this.grid_panel.getSelectionModel().hasSelection()) {
tb.x_buttons.remove.enable();
}
else {
tb.x_buttons.remove.disable();
}
-
+
if (this.grid_panel.getStore().getCount() > 0) {
tb.x_buttons.reset.enable();
}
@@ -1134,132 +1106,158 @@
}
}
},
-
- saveInitialQueuedCount : function()
- {
+
+ saveInitialQueuedCount: function () {
this.initial_queued_count = this.getQueuedCount();
},
-
- incInitialQueuedCount : function()
- {
+
+ incInitialQueuedCount: function () {
this.initial_queued_count++;
},
-
- setUploadingFlag : function()
- {
+
+ setUploadingFlag: function () {
this.is_uploading = true;
- },
-
- resetUploadingFlag : function()
- {
+ },
+
+ resetUploadingFlag: function () {
this.is_uploading = false;
},
- prepareNextUploadTask : function()
- {
+ prepareNextUploadTask: function () {
// Searching for first unuploaded file.
var store = this.grid_panel.getStore();
var record = null;
-
- store.each(function(r) {
+
+ store.each(function (r) {
if (!record && r.get('state') == Ext.ux.UploadDialog.FileRecord.STATE_QUEUE) {
record = r;
}
else {
- r.get('input_element').dom.disabled = true;
+ if (r.get('input_element')) {
+ r.get('input_element').dom.disabled = true;
+ }
}
});
-
- record.get('input_element').dom.disabled = false;
+
+ if (record.get('input_element')) {
+ record.get('input_element').dom.disabled = false;
+ }
record.set('state', Ext.ux.UploadDialog.FileRecord.STATE_PROCESSING);
record.set('note', this.i18n.note_processing);
record.commit();
-
+
this.fsa.postEvent('file-upload-start', record);
},
-
- fireUploadStartEvent : function()
- {
+
+ fireUploadStartEvent: function () {
this.fireEvent('uploadstart', this);
},
-
- removeFiles : function(file_records)
- {
+
+ removeFiles: function (file_records) {
var store = this.grid_panel.getStore();
for (var i = 0, len = file_records.length; i < len; i++) {
var r = file_records[i];
- r.get('input_element').remove();
+ if (r.get('input_element')) {
+ r.get('input_element').remove();
+ }
store.remove(r);
}
},
-
- fireFileRemoveEvent : function(file_records)
- {
+
+ fireFileRemoveEvent: function (file_records) {
for (var i = 0, len = file_records.length; i < len; i++) {
this.fireEvent('fileremove', this, file_records[i].get('filename'), file_records[i]);
}
},
-
- resetQueue : function()
- {
+
+ resetQueue: function () {
var store = this.grid_panel.getStore();
store.each(
- function(r) {
- r.get('input_element').remove();
+ function (r) {
+ if (r.get('input_element')) {
+ r.get('input_element').remove();
+ }
}
);
store.removeAll();
},
-
- fireResetQueueEvent : function()
- {
+
+ fireResetQueueEvent: function () {
this.fireEvent('resetqueue', this);
},
-
- uploadFile : function(record)
- {
- Ext.Ajax.request({
- url : this.url,
- params : Ext.applyIf(record.get('params') || {}, this.base_params || this.baseParams || this.params),
- method : 'POST',
- form : this.form,
- isUpload : true,
- success : this.onAjaxSuccess,
- failure : this.onAjaxFailure,
- scope : this,
- record: record
- });
+
+ uploadFile: function (record) {
+ var imageTypeEncode = encodeURI(this.params.imageType, "UTF-8");
+ var that = this;
+ if (record.data.blobs) {
+ $.ajax({
+ type: 'post',
+ beforeSend: function (xhr) {
+ xhr.setRequestHeader("size", record.data.blobs.size);
+ xhr.setRequestHeader("fileTypes", "image");
+ xhr.setRequestHeader("imageType", imageTypeEncode);
+ xhr.setRequestHeader("objectId", that.params.id);
+ },
+ url: WWWROOT + '/disinfectSystem/baseData/uploadImageAndVideoAction!uploadImageAndVideo.do',
+ processData: false,//不需要将传输的数据序列化
+ contentType: false,
+ data: record.data.blobs,
+ success: function (response) {
+ var json_response = {
+ 'success': false,
+ 'error': that.i18n.note_upload_error
+ }
+ json_response = Ext.util.JSON.decode(response);
+ var data = {
+ record: record,
+ response: json_response
+ }
+ if ('success' in json_response && json_response.success) {
+ that.fsa.postEvent('file-upload-success', data);
+ }
+ else {
+ that.fsa.postEvent('file-upload-error', data);
+ }
+ }
+ })
+ } else {
+ Ext.Ajax.request({
+ url: this.url,
+ params: Ext.applyIf(record.get('params') || {}, this.base_params || this.baseParams || this.params),
+ method: 'POST',
+ form: this.form,
+ isUpload: true,
+ success: this.onAjaxSuccess,
+ failure: this.onAjaxFailure,
+ scope: this,
+ record: record
+ });
+ }
},
-
- fireBeforeFileUploadStartEvent : function(record)
- {
- return this.fireEvent('beforefileuploadstart', this, record.get('filename'), record) !== false;
+
+ fireBeforeFileUploadStartEvent: function (record) {
+ return this.fireEvent('beforefileuploadstart', this, record.get('filename'), record) !== false;
},
-
- postFileUploadCancelEvent : function(record)
- {
- this.fsa.postEvent('file-upload-canceled', record);
+
+ postFileUploadCancelEvent: function (record) {
+ this.fsa.postEvent('file-upload-canceled', record);
},
-
- setRecordCanceledState : function(record)
- {
- record.set('state', Ext.ux.UploadDialog.FileRecord.STATE_FAILED);
- record.set('note', this.i18n.note_canceled);
- record.commit();
+
+ setRecordCanceledState: function (record) {
+ record.set('state', Ext.ux.UploadDialog.FileRecord.STATE_FAILED);
+ record.set('note', this.i18n.note_canceled);
+ record.commit();
},
-
- fireUploadCanceledEvent : function(record)
- {
- this.fireEvent('uploadcanceled', this, record.get('filename'), record);
+
+ fireUploadCanceledEvent: function (record) {
+ this.fireEvent('uploadcanceled', this, record.get('filename'), record);
},
-
- fireFileUploadStartEvent : function(record)
- {
+
+ fireFileUploadStartEvent: function (record) {
this.fireEvent('fileuploadstart', this, record.get('filename'), record);
},
-
- updateRecordState : function(data)
- {
+
+ updateRecordState: function (data) {
if ('success' in data.response && data.response.success) {
data.record.set('state', Ext.ux.UploadDialog.FileRecord.STATE_FINISHED);
data.record.set(
@@ -1272,284 +1270,286 @@
'note', data.response.message || data.response.error || this.i18n.note_upload_error
);
}
-
+
data.record.commit();
},
-
- fireUploadSuccessEvent : function(data)
- {
+
+ fireUploadSuccessEvent: function (data) {
this.fireEvent('uploadsuccess', this, data.record.get('filename'), data.response, data.record);
},
-
- fireUploadErrorEvent : function(data)
- {
+
+ fireUploadErrorEvent: function (data) {
this.fireEvent('uploaderror', this, data.record.get('filename'), data.response, data.record);
},
-
- fireUploadFailedEvent : function(data)
- {
+
+ fireUploadFailedEvent: function (data) {
this.fireEvent('uploadfailed', this, data.record.get('filename'), data.record);
},
-
- fireUploadCompleteEvent : function()
- {
+
+ fireUploadCompleteEvent: function () {
this.fireEvent('uploadcomplete', this);
},
-
- findUploadFrame : function()
- {
+
+ findUploadFrame: function () {
this.upload_frame = Ext.getBody().child('iframe.x-hidden:last');
},
-
- resetUploadFrame : function()
- {
+
+ resetUploadFrame: function () {
this.upload_frame = null;
},
-
- removeUploadFrame : function()
- {
+
+ removeUploadFrame: function () {
if (this.upload_frame) {
this.upload_frame.removeAllListeners();
this.upload_frame.dom.src = 'about:blank';
this.upload_frame.remove();
}
this.upload_frame = null;
},
-
- abortUpload : function()
- {
+
+ abortUpload: function () {
this.removeUploadFrame();
-
+
var store = this.grid_panel.getStore();
var record = null;
- store.each(function(r) {
+ store.each(function (r) {
if (r.get('state') == Ext.ux.UploadDialog.FileRecord.STATE_PROCESSING) {
record = r;
return false;
}
});
-
+
record.set('state', Ext.ux.UploadDialog.FileRecord.STATE_FAILED);
record.set('note', this.i18n.note_aborted);
record.commit();
},
-
- fireUploadStopEvent : function()
- {
+
+ fireUploadStopEvent: function () {
this.fireEvent('uploadstop', this);
},
-
- repostHide : function()
- {
+
+ repostHide: function () {
this.fsa.postEvent('hide');
},
-
- flushEventQueue : function()
- {
+
+ flushEventQueue: function () {
this.fsa.flushEventQueue();
},
- resetAddButton : function(browse_btn)
- {
+ resetAddButton: function (browse_btn) {
browse_btn.detachInputFile();
},
-
+
/**
* @access private
*/
// -------------------------------------------------------------------------------------------- //
- onWindowRender : function()
- {
+ onWindowRender: function () {
this.fsa.postEvent('window-render');
},
-
- onWindowBeforeHide : function()
- {
+
+ onWindowBeforeHide: function () {
return this.isUploading() ? this.getAllowCloseOnUpload() : true;
},
-
- onWindowHide : function()
- {
+
+ onWindowHide: function () {
this.fsa.postEvent('hide');
},
-
- onWindowDestroy : function()
- {
+
+ onWindowDestroy: function () {
this.fsa.postEvent('destroy');
},
-
- onGridRender : function()
- {
+
+ onGridRender: function () {
this.fsa.postEvent('grid-render');
},
-
- onGridSelectionChange : function()
- {
+
+ onGridSelectionChange: function () {
this.fsa.postEvent('grid-selection-change');
},
-
- onAddButtonFileSelected : function(btn)
- {
+
+ onAddButtonFileSelected: function (btn) {
this.fsa.postEvent('file-selected', btn);
},
-
- onUploadButtonClick : function()
- {
+
+ onUploadButtonClick: function () {
if (this.is_uploading) {
this.fsa.postEvent('stop-upload');
}
else {
this.fsa.postEvent('start-upload');
}
},
-
- onRemoveButtonClick : function()
- {
+
+ onRemoveButtonClick: function () {
var selections = this.grid_panel.getSelectionModel().getSelections();
this.fsa.postEvent('remove-files', selections);
},
-
- onResetButtonClick : function()
- {
+
+ getNewDate: function () {
+ var date = new Date();
+ var fullYear = date.getFullYear();
+ var month = date.getMonth() + 1;
+ month = ((month) < 10) ? "0" + month : "" + month;
+ var day = date.getDate();
+ day = ((day) < 10) ? "0" + day : "" + day;
+ var hour = date.getHours();
+ hour = ((hour) < 10) ? "0" + hour : "" + hour;
+ var minutes = date.getMinutes();
+ minutes = ((minutes) < 10) ? "0" + minutes : "" + minutes;
+ var seconds = date.getSeconds();
+ seconds = ((seconds) < 10) ? "0" + seconds : "" + seconds;
+ return fullYear + '' + month + '' + day + '' + hour + '' + minutes + '' + seconds
+ },
+
+ onCameraButtonClick: function () {
+ if (this.params && this.params.imageType) {
+ var pageUrl = WWWROOT + '/disinfectsystem/test/takeVideoAndImg.jsp?showVideo=false&imageType=' + this.params.imageType;
+ var popwin = openFullSizeWindowWithName(pageUrl, true, '拍摄视频图片');
+ var that = this;
+ var loop = setInterval(function () {
+ if (popwin.closed) {
+ clearInterval(loop);
+ popwin.focus();
+ var returnValue = popwin.returnValue;
+ if (returnValue) {
+ var store = that.grid_panel.getStore();
+ store.add(
+ new top.Ext.ux.UploadDialog.FileRecord({
+ state: Ext.ux.UploadDialog.FileRecord.STATE_QUEUE,
+ filename: '图片' + that.getNewDate(),
+ note: that.i18n.note_queued_to_upload,
+ input_element: '',
+ blobs: returnValue
+ })
+ );
+ that.updateToolbar();
+ }
+ }
+ }, 1000);
+ }
+ },
+
+ onResetButtonClick: function () {
this.fsa.postEvent('reset-queue');
},
-
- onCloseButtonClick : function()
- {
+
+ onCloseButtonClick: function () {
this[this.closeAction].call(this);
},
-
- onAjaxSuccess : function(response, options)
- {
+
+ onAjaxSuccess: function (response, options) {
var json_response = {
- 'success' : false,
- 'error' : this.i18n.note_upload_error
+ 'success': false,
+ 'error': this.i18n.note_upload_error
}
- try {
- var rt = response.responseText;
- var filter = rt.match(/^<[^>]+>((?:.|\n)*)<\/[^>]+>$/);
- if (filter) {
- rt = filter[1];
- }
- json_response = Ext.util.JSON.decode(rt);
- }
- catch (e) {}
-
+ try {
+ var rt = response.responseText;
+ var filter = rt.match(/^<[^>]+>((?:.|\n)*)<\/[^>]+>$/);
+ if (filter) {
+ rt = filter[1];
+ }
+ json_response = Ext.util.JSON.decode(rt);
+ }
+ catch (e) { }
+
var data = {
record: options.record,
response: json_response
}
-
+
if ('success' in json_response && json_response.success) {
this.fsa.postEvent('file-upload-success', data);
}
else {
this.fsa.postEvent('file-upload-error', data);
}
},
-
- onAjaxFailure : function(response, options)
- {
+
+ onAjaxFailure: function (response, options) {
var data = {
- record : options.record,
- response : {
- 'success' : false,
- 'error' : this.i18n.note_upload_failed
+ record: options.record,
+ response: {
+ 'success': false,
+ 'error': this.i18n.note_upload_failed
}
}
this.fsa.postEvent('file-upload-failed', data);
},
-
+
/**
* @access public
*/
// -------------------------------------------------------------------------------------------- //
- startUpload : function()
- {
+ startUpload: function () {
this.fsa.postEvent('start-upload');
},
-
- stopUpload : function()
- {
+
+ stopUpload: function () {
this.fsa.postEvent('stop-upload');
},
-
- getUrl : function()
- {
+
+ getUrl: function () {
return this.url;
},
-
- setUrl : function(url)
- {
+
+ setUrl: function (url) {
this.url = url;
},
-
- getBaseParams : function()
- {
+
+ getBaseParams: function () {
return this.base_params;
},
-
- setBaseParams : function(params)
- {
+
+ setBaseParams: function (params) {
this.base_params = params;
},
-
- getUploadAutostart : function()
- {
+
+ getUploadAutostart: function () {
return this.upload_autostart;
},
-
- setUploadAutostart : function(value)
- {
+
+ setUploadAutostart: function (value) {
this.upload_autostart = value;
},
-
- getAllowCloseOnUpload : function()
- {
+
+ getAllowCloseOnUpload: function () {
return this.allow_close_on_upload;
},
-
- setAllowCloseOnUpload : function(value)
- {
+
+ setAllowCloseOnUpload: function (value) {
this.allow_close_on_upload = value;
},
-
- getResetOnHide : function()
- {
+
+ getResetOnHide: function () {
return this.reset_on_hide;
},
-
- setResetOnHide : function(value)
- {
+
+ setResetOnHide: function (value) {
this.reset_on_hide = value;
},
-
- getPermittedExtensions : function()
- {
+
+ getPermittedExtensions: function () {
return this.permitted_extensions;
},
-
- setPermittedExtensions : function(value)
- {
+
+ setPermittedExtensions: function (value) {
this.permitted_extensions = value;
},
-
- isUploading : function()
- {
+
+ isUploading: function () {
return this.is_uploading;
},
-
- isNotEmptyQueue : function()
- {
+
+ isNotEmptyQueue: function () {
return this.grid_panel.getStore().getCount() > 0;
},
-
- getQueuedCount : function(count_processing)
- {
+
+ getQueuedCount: function (count_processing) {
var count = 0;
var store = this.grid_panel.getStore();
- store.each(function(r) {
+ store.each(function (r) {
if (r.get('state') == Ext.ux.UploadDialog.FileRecord.STATE_QUEUE) {
count++;
}
@@ -1559,14 +1559,12 @@
});
return count;
},
-
- hasUnuploadedFiles : function()
- {
+
+ hasUnuploadedFiles: function () {
return this.getQueuedCount() > 0;
},
- getQueueStore : function()
- {
+ getQueueStore: function () {
return this.grid_panel.getStore();
}
});
@@ -1579,7 +1577,7 @@
state_col_title: 'State',
state_col_width: 70,
filename_col_title: 'Filename',
- filename_col_width: 230,
+ filename_col_width: 230,
note_col_title: 'Note',
note_col_width: 150,
add_btn_text: 'Add',
Index: ssts-web/src/main/webapp/disinfectsystem/sterilizationmanager/sterilizationrecord/sterilizationRecordForm.js
===================================================================
diff -u -r40805 -r40987
--- ssts-web/src/main/webapp/disinfectsystem/sterilizationmanager/sterilizationrecord/sterilizationRecordForm.js (.../sterilizationRecordForm.js) (revision 40805)
+++ ssts-web/src/main/webapp/disinfectsystem/sterilizationmanager/sterilizationrecord/sterilizationRecordForm.js (.../sterilizationRecordForm.js) (revision 40987)
@@ -6383,6 +6383,10 @@
constraintoviewport: true,
permitted_extensions: ['JPG', 'jpg', 'jpeg', 'JPEG', 'GIF', 'gif', 'png', 'PNG'],
modal: true,
+ params:{
+ imageType:imageType,
+ id:id
+ },
reset_on_hide: false,
allow_close_on_upload: false, //关闭上传窗口是否仍然上传文件
upload_autostart: false
Index: ssts-web/src/main/webapp/ext/UploadDialog/locale/ru.utf-8.js
===================================================================
diff -u -r12331 -r40987
--- ssts-web/src/main/webapp/ext/UploadDialog/locale/ru.utf-8.js (.../ru.utf-8.js) (revision 12331)
+++ ssts-web/src/main/webapp/ext/UploadDialog/locale/ru.utf-8.js (.../ru.utf-8.js) (revision 40987)
@@ -8,6 +8,8 @@
filename_col_width: 230,
note_col_title: '备注',
note_col_width: 150,
+ camera_btn_text: '拍摄',
+ camera_btn_tip: '拍摄图片到上传列表',
add_btn_text: '添加',
add_btn_tip: '添加文件到上传列表',
remove_btn_text: '删除',
Index: ssts-web/src/main/webapp/disinfectsystem/test/takeVideoAndImg.js
===================================================================
diff -u -r38847 -r40987
--- ssts-web/src/main/webapp/disinfectsystem/test/takeVideoAndImg.js (.../takeVideoAndImg.js) (revision 38847)
+++ ssts-web/src/main/webapp/disinfectsystem/test/takeVideoAndImg.js (.../takeVideoAndImg.js) (revision 40987)
@@ -418,9 +418,16 @@
contextBig.drawImage(videoShow, canvasLeft, canvasTop, maxWidth, maxHeight, 0, 0, maxWidth, maxHeight);
/* 预览大图 */
var base64DataBig = canvasBig.toDataURL('image/jpeg', 1.0);
- canvasBig.toBlob(function (blobObj) {
- window.opener.blobs.push(blobObj);
- });
+ if(window.opener && window.opener.blobs){
+ canvasBig.toBlob(function (blobObj) {
+ window.opener.blobs.push(blobObj);
+ });
+ }else {
+ canvasBig.toBlob(function (blobObj) {
+ self.returnValue = blobObj;
+ });
+ return
+ }
var list = "