tinyMCEPopup.requireLangPack(); var ImgManagerDialog = { cropedImageData: null, //INIT init : function() { var f = document.forms[0]; $('#imageInserModal').modal({show:false}); //Image insert popup init this.openDirectory(null, null); // populate directories and files this.populateDirectoriesSelect("directoriesSelect","Choose directory to upload to:"); //Populate folder select infomation this.populateDirectoriesSelect("directoriesSelectParent","Choose parent directory:"); //Populate folder select infomation //Uploadify INIT $("#file_upload").uploadify({ 'uploader' : tinyMCEPopup.getWindowArg('plugin_url')+'/libs/uploadify.swf', 'script' : tinyMCEPopup.getWindowArg('plugin_url')+'/libs/ajax.php', 'cancelImg' : 'img/cancel.png', 'folder' : '', 'auto' : false, 'multi' : true, 'scriptData': {"uploadify":1,"hash":hash} }); }, close : function() { tinyMCEPopup.popup_css = false; tinyMCEPopup.close(); }, insert : function() { // Insert the contents from the input into the document var dialog = $("#imageInserModal"); var alt = dialog.find("#imgAlt").val(); var width = dialog.find("#imgWidth").val(); var height = dialog.find("#imgHeight").val(); var align = dialog.find("#imgAlign").val(); var src = dialog.find("#imgWebUrl").val(); var html = '",{"src":src}); if(alt){img.attr("alt",alt);html = html+' alt="'+alt+'"';} if(width){img.attr("width",width);html = html+' width="'+width+'"';} if(height){img.attr("height",height);html = html+' height="'+height+'"';} if(align){img.attr("align",align);html = html+' align="'+align+'"';} html = html + ' />'; var ed = tinyMCEPopup.editor, el; tinyMCEPopup.restoreSelection(); if (tinymce.isIE){ ed.selection.setContent(html); }else{ el = ed.selection.getNode(); $(el).append(img); } ed.undoManager.add(); tinyMCEPopup.popup_css = false; tinyMCEPopup.close(); }, showTab: function(tabId){ jQuery(".contentContainers").hide(); jQuery("#"+tabId).show(); return false; }, openDirectory: function (dirName, parent){ if(parent && parent != "/" && parent != "../"){ if(dirName) dirName = parent+"/"+dirName; else dirName = parent; } if(dirName == parent || parent == "../"){ parent = Helppers.getParentDir(dirName); } $.ajax({ url: tinyMCEPopup.getWindowArg('plugin_url')+'/libs/ajax.php?getFilesAndDirectories=1&dir='+dirName, type: 'GET', dataType: 'text json', success:function(data){ Helppers.populateFoldersAndImages(data,dirName,parent); }, error:function(){ alert("Error eccured. Please refresh site and try again"); } }); return false; }, populateDirsAfterUpdate: function(){ this.populateDirectoriesSelect("directoriesSelect","Choose directory to upload to:"); this.populateDirectoriesSelect("directoriesSelectParent","Choose parent directory:"); }, populateDirectoriesSelect: function(container_id, label){ $.ajax({ url: tinyMCEPopup.getWindowArg('plugin_url')+'/libs/ajax.php?getDirectoryList=1', type: 'GET', dataType: 'text json', success:function(data){ $("#"+container_id).html(""); var labelSelect = $("