github.com/insionng/yougam@v0.0.0-20170714101924-2bc18d833463/public/libs/tinymce/plugins/jbimages/js/dialog-v4.js (about)

     1  /**
     2   * Justboil.me - a TinyMCE image upload plugin
     3   * jbimages/js/dialog-v4.js
     4   *
     5   * Released under Creative Commons Attribution 3.0 Unported License
     6   *
     7   * License: http://creativecommons.org/licenses/by/3.0/
     8   * Plugin info: http://justboil.me/
     9   * Author: Viktor Kuzhelnyi
    10   *
    11   * Version: 2.3 released 23/06/2013
    12   */
    13   
    14  var jbImagesDialog = {
    15  	
    16  	resized : false,
    17  	iframeOpened : false,
    18  	timeoutStore : false,
    19  	
    20  	inProgress : function() {
    21  		document.getElementById("upload_infobar").style.display = 'none';
    22  		document.getElementById("upload_additional_info").innerHTML = '';
    23  		document.getElementById("upload_form_container").style.display = 'none';
    24  		document.getElementById("upload_in_progress").style.display = 'block';
    25  		this.timeoutStore = window.setTimeout(function(){
    26  			document.getElementById("upload_additional_info").innerHTML = '本次上传耗时比常规情况要长.' + '<br />' + '可能发生错误导致上传中断.' + '<br /><a href="###" onClick="jbImagesDialog.showIframe()">' + '查看响应信息' + '</a>';
    27  			// tinyMCEPopup.editor.windowManager.resizeBy(0, 30, tinyMCEPopup.id);
    28  		}, 50000);
    29  	},
    30  	
    31  	showIframe : function() {
    32  		if (this.iframeOpened == false)
    33  		{
    34  			document.getElementById("upload_target").className = 'upload_target_visible';
    35  			// tinyMCEPopup.editor.windowManager.resizeBy(0, 190, tinyMCEPopup.id);
    36  			this.iframeOpened = true;
    37  		}
    38  	},
    39  	
    40  	uploadFinish : function(result) {
    41  		if (result.resultCode == 'failed')
    42  		{
    43  			window.clearTimeout(this.timeoutStore);
    44  			document.getElementById("upload_in_progress").style.display = 'none';
    45  			document.getElementById("upload_infobar").style.display = 'block';
    46  			document.getElementById("upload_infobar").innerHTML = result.result;
    47  			document.getElementById("upload_form_container").style.display = 'block';
    48  			
    49  			if (this.resized == false)
    50  			{
    51  				// tinyMCEPopup.editor.windowManager.resizeBy(0, 30, tinyMCEPopup.id);
    52  				this.resized = true;
    53  			}
    54  		}
    55  		else
    56  		{
    57  			document.getElementById("upload_in_progress").style.display = 'none';
    58  			document.getElementById("upload_infobar").style.display = 'block';
    59  			document.getElementById("upload_infobar").innerHTML = '上传完成';
    60  			
    61  			var w = this.getWin();
    62  			tinymce = w.tinymce;
    63  		
    64  			tinymce.EditorManager.activeEditor.insertContent('<img src="' + result.filename +'"/>');
    65  			
    66  			this.close();
    67  		}
    68  	},
    69  	
    70  	getWin : function() {
    71  		return (!window.frameElement && window.dialogArguments) || opener || parent || top;
    72  	},
    73  	
    74  	close : function() {
    75  		var t = this;
    76  
    77  		// To avoid domain relaxing issue in Opera
    78  		function close() {
    79  			tinymce.EditorManager.activeEditor.windowManager.close(window);
    80  			tinymce = tinyMCE = t.editor = t.params = t.dom = t.dom.doc = null; // Cleanup
    81  		};
    82  
    83  		if (tinymce.isOpera)
    84  			this.getWin().setTimeout(close, 0);
    85  		else
    86  			close();
    87  	}
    88  
    89  };