Related
Is there a way to delete a file in Roxy Fileman, I keep on getting a error when I try to delete a pdf in Roxy Fileman, the delete folder is working fine just the file not want to delete.
I have been struggling to find a solution for two weeks, still this problem persist, Any help, suggestions would be much appreciated.
Hi yall,
Basically everything is working fine just not the deleteFile() the only thing that's giving me error, when Im I try to delete, its a javascript error Main.js the deleteFile() function needs to be corrected
I have updated the script
Please see code below, Thanks alot
Main.js
$.ajaxSetup ({cache: false});
function selectFile(item){
$('#pnlFileList li').removeClass('selected');
$(item).prop('class', 'selected');
var html = RoxyUtils.GetFilename($(item).attr('data-path'));
html += ' ('+t('Size')+': '+RoxyUtils.FormatFileSize($(item).attr('data-size'));
if($(item).attr('data-w') > 0)
html += ', '+t('Dimensions')+':'+$(item).attr('data-w')+'x'+$(item).attr('data-h');
html += ')';
$('#pnlStatus').html(html);
}
var uploadFileList = new Array();
function showUploadList(files){
var filesPane = $('#uploadFilesList');
filesPane.html('');
clearFileField();
for(i = 0; i < files.length; i++){
filesPane.append('<div class="fileUpload"><div class="fileName">'+files[i].name+' ('+RoxyUtils.FormatFileSize(files[i].size)+')<span class="progressPercent"></span><div class="uploadProgress"><div class="stripes"></div></div></div><a class="removeUpload" onclick="removeUpload(' + i + ')"></a></div>');
}
if(files.length > 0)
$('#btnUpload').button('enable');
else
$('#btnUpload').button('disable');
}
function listUploadFiles(files){
if(!window.FileList) {
$('#btnUpload').button('enable');
}
else if(files.length > 0) {
uploadFileList = new Array();
addUploadFiles(files);
}
}
function addUploadFiles(files){
for(i = 0; i < files.length; i++)
uploadFileList.push(files[i]);
showUploadList(uploadFileList);
}
function removeUpload(i){
var el = findUploadElement(i);
el.remove();
try{
uploadFileList.splice(i, 1);
showUploadList(uploadFileList);
}
catch(ex){
//alert(ex);
}
}
function findUploadElement(i){
return $('#uploadFilesList .fileUpload:eq(' + (i)+ ')');
}
function updateUploadProgress(e, i){
var el = findUploadElement(i);
var percent = 99;
if (e.lengthComputable) {
percent = Math.floor((e.loaded / e.total) * 100);
}
if(percent > 99)
percent = 99;
el.find('.uploadProgress').css('width', percent + '%');
el.find('.progressPercent').html(' - ' + percent + '%');
}
function uploadComplete(e, i){
uploadFinished(e, i, 'ok');
}
function uploadError(e, i){
setUploadError(i);
uploadFinished(e, i, 'error');
}
function setUploadError(i){
var el = findUploadElement(i);
el.find('.uploadProgress').css('width', '100%').addClass('uploadError').removeClass('uploadComplete');
el.find('.progressPercent').html(' - <span class="error">' + t('E_UploadingFile')+'</span>');
}
function setUploadSuccess(i){
var el = findUploadElement(i);
el.find('.uploadProgress').css('width', '100%').removeClass('uploadError').addClass('uploadComplete');
el.find('.progressPercent').html(' - 100%');
}
function uploadCanceled(e, i){
uploadFinished(e, i, 'error');
}
function uploadFinished(e, i, res){
var el = findUploadElement(i);
var httpRes = null;
try{
httpRes = JSON.parse(e.target.responseText);
}
catch(ex){}
if((httpRes && httpRes.res == 'error') || res != 'ok'){
res = 'error';
setUploadError(i);
}
else{
res = 'ok';
setUploadSuccess(i)
}
el.attr('data-ulpoad', res);
checkUploadResult();
}
function checkUploadResult(){
var all = $('#uploadFilesList .fileUpload').length;
var completed = $('#uploadFilesList .fileUpload[data-ulpoad]').length;
var success = $('#uploadFilesList .fileUpload[data-ulpoad="ok"]').length;
if(completed == all){
//$('#uploadResult').html(success + ' files uploaded; '+(all - success)+' failed');
uploadFileList = new Array();
var d = Directory.Parse($('#hdDir').val());
d.ListFiles(true);
$('#btnUpload').button('disable');
}
}
function fileUpload(f, i){
var http = new XMLHttpRequest();
var fData = new FormData();
var el = findUploadElement(i);
el.find('.removeUpload').remove();
fData.append("action", 'upload');
fData.append("method", 'ajax');
fData.append("d", $('#hdDir').attr('value'));
fData.append("files[]", f);
http.upload.addEventListener("progress", function(e){updateUploadProgress(e, i);}, false);
http.addEventListener("load", function(e){uploadComplete(e, i);}, false);
http.addEventListener("error", function(e){uploadError(e, i);}, false);
http.addEventListener("abort", function(e){uploadCanceled(e, i);}, false);
http.open("POST", RoxyFilemanConf.UPLOAD, true);
http.setRequestHeader("Accept", "*/*");
http.send(fData);
}
function dropFiles(e, append){
if(e && e.dataTransfer && e.dataTransfer.files){
addFile();
if(append)
addUploadFiles(e.dataTransfer.files);
else
listUploadFiles(e.dataTransfer.files);
}
else
addFile();
}
function clearFileField(selector){
if(!selector)
selector = '#fileUploads';
try{
$(selector).val('');
$(selector).val(null);
}
catch(ex){}
}
function addFileClick(){
$('#uploadResult').html('');
showUploadList(new Array());
addFile();
}
function addFile(){
clickFirstOnEnter('dlgAddFile');
$('#uploadResult').html('');
clearFileField();
var dialogButtons = {};
dialogButtons[t('Upload')] = {id:'btnUpload', text: t('Upload'), disabled:true, click:function(){
if(!$('#fileUploads').val() && (!uploadFileList || uploadFileList.length == 0))
alert(t('E_SelectFiles'));
else{
if(!RoxyFilemanConf.UPLOAD){
alert(t('E_ActionDisabled'));
//$('#dlgAddFile').dialog('close');
}
else{
if(window.FormData && window.XMLHttpRequest && window.FileList && uploadFileList && uploadFileList.length > 0){
for(i = 0; i < uploadFileList.length; i++){
fileUpload(uploadFileList[i], i);
}
}
else{
document.forms['addfile'].action = RoxyFilemanConf.UPLOAD;
document.forms['addfile'].submit();
}
}
}
}};
dialogButtons[t('Cancel')] = function(){$('#dlgAddFile').dialog('close');};
$('#dlgAddFile').dialog({title:t('T_AddFile'),modal:true,buttons:dialogButtons,width:400});
}
function fileUploaded(res){
if(res.res == 'ok' && res.msg){
$('#dlgAddFile').dialog('close');
var d = Directory.Parse($('#hdDir').val());
d.ListFiles(true);
alert(res.msg);
}
else if(res.res == 'ok'){
$('#dlgAddFile').dialog('close');
var d = Directory.Parse($('#hdDir').val());
d.ListFiles(true);
}
else
alert(res.msg);
}
function renameDir(){
var f = getSelectedDir();
if(!f)
return;
if($('[data-path="'+f.fullPath+'"]').parents('li').length < 1){
alert(t('E_CannotRenameRoot'));
return;
}
clickFirstOnEnter('pnlDirName');
$('#txtDirName').val(f.name);
var dialogButtons = {};
dialogButtons[t('RenameDir')] = function(){
var newName = $.trim($('#txtDirName').val());
if(!newName)
alert(t('E_MissingDirName'));
if(f.Rename(newName))
$('#pnlDirName').dialog('close');
};
dialogButtons[t('Cancel')] = function(){$('#pnlDirName').dialog('close');};
$('#pnlDirName').dialog({title:t('T_RenameDir'),modal:true,buttons:dialogButtons});
RoxyUtils.SelectText('txtDirName', 0, new String(f.name).length);
}
function renameFile(){
var f = getSelectedFile();
if(!f)
return;
clickFirstOnEnter('pnlRenameFile');
$('#txtFileName').val(f.name);
var dialogButtons = {};
dialogButtons[t('RenameFile')] = function(){
var newName = $.trim($('#txtFileName').val());
if(!newName)
alert('Missing file name');
else if(f.Rename(newName)){
$('li[data-path="'+f.fullPath+'"] .name').text(newName);
$('li[data-path="'+f.fullPath+'"]').attr('data-path', RoxyUtils.MakePath(f.path, newName));
$('#pnlRenameFile').dialog('close');
}
};
dialogButtons[t('Cancel')] = function(){$('#pnlRenameFile').dialog('close');};
$('#pnlRenameFile').dialog({title:t('T_RenameFile'),modal:true,buttons:dialogButtons});
if(f.name.lastIndexOf('.') > 0)
RoxyUtils.SelectText('txtFileName', 0, f.name.lastIndexOf('.'));
}
function getSelectedFile(){
var ret = null;
if($('#pnlFileList .selected').length > 0)
ret = new File($('#pnlFileList .selected').attr('data-path'));
return ret;
}
function getSelectedDir(){
var ret = null;
if($('#pnlDirList .selected'))
ret = Directory.Parse($('#pnlDirList .selected').closest('li').attr('data-path'));
return ret;
}
function deleteDir(path){
var d = null;
if(path)
d = Directory.Parse(path);
else
d = getSelectedDir();
if(d && confirm(t('Q_DeleteFolder'))){
d.Delete();
}
}
function deleteFile(){
var f = getSelectedFile();
if(f && confirm(t('Q_DeleteFile'))){
f.Delete();
}
}
function previewFile(){
var f = getSelectedFile();
if(f){
window.open(f.fullPath);
}
}
function downloadFile(){
var f = getSelectedFile();
if(f && RoxyFilemanConf.DOWNLOAD){
var url = RoxyUtils.AddParam(RoxyFilemanConf.DOWNLOAD, 'f', f.fullPath);
window.frames['frmUploadFile'].location.href = url;
}
else if(!RoxyFilemanConf.DOWNLOAD)
alert(t('E_ActionDisabled'));
}
function downloadDir(){
var d = getSelectedDir();
if(d && RoxyFilemanConf.DOWNLOADDIR){
var url = RoxyUtils.AddParam(RoxyFilemanConf.DOWNLOADDIR, 'd', d.fullPath);
window.frames['frmUploadFile'].location.href = url;
}
else if(!RoxyFilemanConf.DOWNLOAD)
alert(t('E_ActionDisabled'));
}
function closeMenus(el){
if(!el || el == 'dir')
$('#menuDir').fadeOut();
if(!el || el == 'file')
$('#menuFile').fadeOut();
}
function selectFirst(){
var item = $('#pnlDirList li:first').children('div').first();
if(item.length > 0)
selectDir(item);
else
window.setTimeout('selectFirst()', 300);
}
function tooltipContent(){
if($('#menuFile').is(':visible'))
return '';
var html = '';
var f = File.Parse($(this).attr('data-path'));
if($('#hdViewType').val() == 'thumb' && f.IsImage()){
html = f.fullPath+'<br><span class="filesize">'+t('Size')+': '+RoxyUtils.FormatFileSize(f.size) + ' '+t('Dimensions')+': '+f.width+'x'+f.height+'</span>';
}
else if(f.IsImage()){
if(RoxyFilemanConf.GENERATETHUMB){
imgUrl = RoxyUtils.AddParam(RoxyFilemanConf.GENERATETHUMB, 'f', f.fullPath);
imgUrl = RoxyUtils.AddParam(imgUrl, 'width', RoxyFilemanConf.PREVIEW_THUMB_WIDTH);
imgUrl = RoxyUtils.AddParam(imgUrl, 'height', RoxyFilemanConf.PREVIEW_THUMB_HEIGHT);
}
else
imgUrl = f.fullPath;
html = '<img src="'+imgUrl+'" class="imgPreview"><br>'+f.name+' <br><span class="filesize">'+t('Size')+': '+RoxyUtils.FormatFileSize(f.size) + ' '+t('Dimensions')+': '+f.width+'x'+f.height+'</span>';
}
else
html = f.fullPath+' <span class="filesize">'+t('Size')+': '+RoxyUtils.FormatFileSize(f.size) + '</span>';
return html;
}
function filterFiles(){
var str = $('#txtSearch').val();
$('#pnlSearchNoFiles').hide();
if($('#pnlFileList li').length == 0)
return;
if(!str){
$('#pnlFileList li').show();
return;
}
var i = 0;
$('#pnlFileList li').each(function(){
var name = $(this).children('.name').text();
if(name.toLowerCase().indexOf(str.toLowerCase()) > -1){
i++;
$(this).show();
}
else{
$(this).removeClass('selected');
$(this).hide();
}
});
if(i == 0)
$('#pnlSearchNoFiles').show();
}
function sortFiles(){
var d = getSelectedDir();
if(!d)
return;
d.ListFiles();
filterFiles();
switchView($('#hdViewType').val());
}
function switchView(t){
if(t == $('#hdViewType').val())
return;
if(!t)
t = $('#hdViewType').val();
$('.btnView').removeClass('selected');
if(t == 'thumb'){
$('#pnlFileList .icon').attr('src', 'images/blank.gif');
$('#pnlFileList').addClass('thumbView');
if($('#dynStyle').length == 0){
$('head').append('<style id="dynStyle" />');
var rules = 'ul#pnlFileList.thumbView li{width:'+RoxyFilemanConf.THUMBS_VIEW_WIDTH+'px;}';
rules += 'ul#pnlFileList.thumbView li{height:'+(parseInt(RoxyFilemanConf.THUMBS_VIEW_HEIGHT) + 20)+'px;}';
rules += 'ul#pnlFileList.thumbView .icon{width:'+RoxyFilemanConf.THUMBS_VIEW_WIDTH+'px;}';
rules += 'ul#pnlFileList.thumbView .icon{height:'+RoxyFilemanConf.THUMBS_VIEW_HEIGHT+'px;}';
$('#dynStyle').html(rules);
}
$('#pnlFileList li').each(function(){
//$('ul#pnlFileList.thumbView li').css('width', RoxyFilemanConf.THUMBS_VIEW_WIDTH + 'px');
//$('ul#pnlFileList.thumbView li').css('height', (parseInt(RoxyFilemanConf.THUMBS_VIEW_HEIGHT) + 20) + 'px');
//$('ul#pnlFileList.thumbView .icon').css('width', RoxyFilemanConf.THUMBS_VIEW_WIDTH + 'px');
//$('ul#pnlFileList.thumbView .icon').css('height', RoxyFilemanConf.THUMBS_VIEW_HEIGHT + 'px');
var imgUrl = $(this).attr('data-icon-big');
if(RoxyFilemanConf.GENERATETHUMB && RoxyUtils.IsImage($(this).attr('data-path'))){
imgUrl = RoxyUtils.AddParam(RoxyFilemanConf.GENERATETHUMB, 'f', imgUrl);
imgUrl = RoxyUtils.AddParam(imgUrl, 'width', RoxyFilemanConf.THUMBS_VIEW_WIDTH);
imgUrl = RoxyUtils.AddParam(imgUrl, 'height', RoxyFilemanConf.THUMBS_VIEW_HEIGHT);
}
$(this).children('.icon').css('background-image', 'url('+imgUrl+')');
$(this).tooltip('option', 'show', {delay:50});
});
$('#btnThumbView').addClass('selected');
}
else{
$('#pnlFileList').removeClass('thumbView');
$('#pnlFileList li').each(function(){
$(this).children('.icon').css('background-image','').attr('src', $(this).attr('data-icon'));
$(this).tooltip('option', 'show', {delay:500});
});
$('#btnListView').addClass('selected');
}
$('#hdViewType').val(t);
RoxyUtils.SetCookie('roxyview', t, 10);
}
var clipBoard = null;
function Clipboard(a, obj){
this.action = a;
this.obj = obj;
}
function cutDir(){
var d = getSelectedDir();
if(d){
setClipboard('cut', d);
d.GetElement().addClass('pale');
}
}
function copyDir(){
var d = getSelectedDir();
if(d){
setClipboard('copy', d);
}
}
function cutFile(){
var f = getSelectedFile();
if(f){
setClipboard('cut', f);
f.GetElement().addClass('pale');
}
}
function copyFile(){
var f = getSelectedFile();
if(f){
setClipboard('copy', f);
}
}
function pasteToFiles(e, el){
if($(el).hasClass('pale')){
e.stopPropagation();
return false;
}
var d = getSelectedDir();
if(!d)
d = Directory.Parse($('#pnlDirList li:first').children('div').first());
if(d && clipBoard && clipBoard.obj){
if(clipBoard.action == 'copy')
clipBoard.obj.Copy(d.fullPath);
else{
clipBoard.obj.Move(d.fullPath);
clearClipboard();
}
}
return true;
}
function pasteToDirs(e, el){
if($(el).hasClass('pale')){
e.stopPropagation();
return false;
}
var d = getSelectedDir();
if(!d)
d = Directory.Parse($('#pnlDirList li:first').children('div').first());
if(clipBoard && d){
if(clipBoard.action == 'copy')
clipBoard.obj.Copy(d.fullPath);
else{
clipBoard.obj.Move(d.fullPath);
clearClipboard();
d.ListFiles(true);
}
}
else
alert('error');
return true;
}
function clearClipboard(){
$('#pnlDirList li').removeClass('pale');
$('#pnlFileList li').removeClass('pale');
clipBoard = null;
$('.paste').addClass('pale');
}
function setClipboard(a, obj){
clearClipboard();
if(obj){
clipBoard = new Clipboard(a, obj);
$('.paste').removeClass('pale');
}
}
function ResizeLists(){
var tmp = $(window).innerHeight() - $('#fileActions .actions').outerHeight() - $('.bottomLine').outerHeight();
$('.scrollPane').css('height', tmp);
}
function removeDisabledActions(){
if(RoxyFilemanConf.CREATEDIR == ''){
$('#mnuCreateDir').next().remove();
$('#mnuCreateDir').remove();
$('#btnAddDir').remove();
}
if(RoxyFilemanConf.DELETEDIR == ''){
$('#mnuDeleteDir').prev().remove();
$('#mnuDeleteDir').remove();
$('#btnDeleteDir').remove();
}
if(RoxyFilemanConf.MOVEDIR == ''){
$('#mnuDirCut').next().remove();
$('#mnuDirCut').remove();
}
if(RoxyFilemanConf.COPYDIR == ''){
$('#mnuDirCopy').next().remove();
$('#mnuDirCopy').remove();
}
if(RoxyFilemanConf.COPYDIR == '' && RoxyFilemanConf.MOVEDIR == ''){
$('#mnuDirPaste').next().remove();
$('#mnuDirPaste').remove();
}
if(RoxyFilemanConf.RENAMEDIR == ''){
$('#mnuRenameDir').next().remove();
$('#mnuRenameDir').remove();
$('#btnRenameDir').remove();
}
if(RoxyFilemanConf.UPLOAD == ''){
$('#btnAddFile').remove();
}
if(RoxyFilemanConf.DOWNLOAD == ''){
$('#mnuDownload').next().remove();
$('#mnuDownload').remove();
}
if(RoxyFilemanConf.DOWNLOADDIR == ''){
$('#mnuDownloadDir').next().remove();
$('#mnuDownloadDir').remove();
}
if(RoxyFilemanConf.DELETEFILE == ''){
$('#mnuDeleteFile').prev().remove();
$('#mnuDeleteFile').remove();
$('#btnDeleteFile').remove();
}
if(RoxyFilemanConf.MOVEFILE == ''){
$('#mnuFileCut').next().remove();
$('#mnuFileCut').remove();
}
if(RoxyFilemanConf.COPYFILE == ''){
$('#mnuFileCopy').next().remove();
$('#mnuFileCopy').remove();
}
if(RoxyFilemanConf.COPYFILE == '' && RoxyFilemanConf.MOVEFILE == ''){
$('#mnuFilePaste').next().remove();
$('#mnuFilePaste').remove();
}
if(RoxyFilemanConf.RENAMEFILE == ''){
$('#mnuRenameFile').next().remove();
$('#mnuRenameFile').remove();
$('#btnRenameFile').remove();
}
}
function getPreselectedFile(){
var filePath = RoxyUtils.GetUrlParam('selected');
if(!filePath){
switch(getFilemanIntegration()){
case 'ckeditor':
try{
var dialog = window.opener.CKEDITOR.dialog.getCurrent();
filePath = dialog.getValueOf('info', (dialog.getName() == 'link'?'url':'txtUrl'));
}
catch(ex){}
break;
case 'tinymce3':
try{
var win = tinyMCEPopup.getWindowArg("window");
filePath = win.document.getElementById(tinyMCEPopup.getWindowArg("input")).value;
if(filePath.indexOf('..') == 0)
filePath = filePath.substr(2);
}
catch(ex){}
break;
case 'tinymce4':
try{
var win = (window.opener?window.opener:window.parent);
filePath = win.document.getElementById(RoxyUtils.GetUrlParam('input')).value;
if(filePath.indexOf('..') == 0)
filePath = filePath.substr(2);
}
catch(ex){}
break;
default:
filePath = GetSelectedValue();
break;
}
}
if(RoxyFilemanConf.RETURN_URL_PREFIX){
var prefix = RoxyFilemanConf.RETURN_URL_PREFIX;
if(filePath.indexOf(prefix) == 0){
if(prefix.substr(-1) == '/')
prefix = prefix.substr(0, prefix.length - 1);
filePath = filePath.substr(prefix.length);
}
}
return filePath;
}
function initSelection(filePath){
var hasSelection = false, fileSelected = true;
if(!filePath)
filePath = getPreselectedFile();
if(!filePath && RoxyUtils.ToBool(RoxyFilemanConf.OPEN_LAST_DIR)){
filePath = getLastDir();
fileSelected = false;
}
if(filePath){
var p = (fileSelected? RoxyUtils.GetPath(filePath): filePath);
var d = tmp = Directory.Parse(p);
do{
if(tmp){
tmp.Expand(true);
hasSelection = true;
}
tmp = Directory.Parse(tmp.path);
}while(tmp);
if(d){
d.Select(filePath);
hasSelection = true;
}
}
if(!hasSelection)
selectFirst();
}
$(function(){
RoxyUtils.LoadConfig();
var d = new Directory();
d.LoadAll();
$('#wraper').show();
window.setTimeout('initSelection()', 100);
RoxyUtils.Translate();
$('body').click(function(){
closeMenus();
});
var viewType = RoxyUtils.GetCookie('roxyview');
if(!viewType)
viewType = RoxyFilemanConf.DEFAULTVIEW;
if(viewType)
switchView(viewType);
ResizeLists();
$(".actions input").tooltip({track: true});
$( window ).resize(ResizeLists);
document.oncontextmenu = function() {return false;};
removeDisabledActions();
$('#copyYear').html(new Date().getFullYear());
if(RoxyFilemanConf.UPLOAD && RoxyFilemanConf.UPLOAD != ''){
var dropZone = document.getElementById('fileActions');
dropZone.ondragover = function () { return false; };
dropZone.ondragend = function () { return false; };
dropZone.ondrop = function (e) {
e.preventDefault();
e.stopPropagation();
dropFiles(e);
};
dropZone = document.getElementById('dlgAddFile');
dropZone.ondragover = function () { return false; };
dropZone.ondragend = function () { return false; };
dropZone.ondrop = function (e) {
e.preventDefault();
e.stopPropagation();
dropFiles(e, true);
};
}
if(getFilemanIntegration() == 'tinymce3'){
try {
$('body').append('<script src="js/tiny_mce_popup.js"><\/script>');
}
catch(ex){}
}
});
function getFilemanIntegration(){
var integration = RoxyUtils.GetUrlParam('integration');
if(!integration)
integration = RoxyFilemanConf.INTEGRATION;
return integration.toLowerCase();
}
function setFile(){
var f = getSelectedFile();
if(!f){
alert(t('E_NoFileSelected'));
return;
}
var insertPath = f.fullPath;
if(RoxyFilemanConf.RETURN_URL_PREFIX){
var prefix = RoxyFilemanConf.RETURN_URL_PREFIX;
if(prefix.substr(-1) == '/')
prefix = prefix.substr(0, prefix.length - 1);
insertPath = prefix + (insertPath.substr(0, 1) != '/'? '/': '') + insertPath;
}
switch(getFilemanIntegration()){
case 'ckeditor':
window.opener.CKEDITOR.tools.callFunction(RoxyUtils.GetUrlParam('CKEditorFuncNum'), insertPath);
self.close();
break;
case 'tinymce3':
var win = tinyMCEPopup.getWindowArg("window");
win.document.getElementById(tinyMCEPopup.getWindowArg("input")).value = insertPath;
if (typeof(win.ImageDialog) != "undefined") {
if (win.ImageDialog.getImageData)
win.ImageDialog.getImageData();
if (win.ImageDialog.showPreviewImage)
win.ImageDialog.showPreviewImage(insertPath);
}
tinyMCEPopup.close();
break;
case 'tinymce4':
var win = (window.opener?window.opener:window.parent);
win.document.getElementById(RoxyUtils.GetUrlParam('input')).value = insertPath;
if (typeof(win.ImageDialog) != "undefined") {
if (win.ImageDialog.getImageData)
win.ImageDialog.getImageData();
if (win.ImageDialog.showPreviewImage)
win.ImageDialog.showPreviewImage(insertPath);
}
win.tinyMCE.activeEditor.windowManager.close();
break;
default:
FileSelected(f);
break;
}
}
Below is the error I'm getting in Nopcommerce roxyFileman
jquery-migrate.js:69 JQMIGRATE: Migrate is installed, version 3.3.2
plugin.min.js:9 Text color plugin is now built in to the core editor, please remove it from your editor configuration
(anonymous) # plugin.min.js:9
DevTools failed to load source map: Could not load content for http://localhost:51848/lib_npm/bootstrap/js/bootstrap.bundle.min.js.map: HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE
DevTools failed to load source map: Could not load content for http://localhost:51848/lib_npm/admin-lte/js/adminlte.min.js.map: HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE
DevTools failed to load source map: Could not load content for http://localhost:51848/lib_npm/moment/min/moment-with-locales.min.js.map: HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE
DevTools failed to load source map: Could not load content for http://localhost:51848/lib_npm/fine-uploader/jquery.fine-uploader/jquery.fine-uploader.min.js.map: HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE
DevTools failed to load source map: Could not load content for http://localhost:51848/lib_npm/admin-lte/css/adminlte.min.css.map: HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE
DevTools failed to load source map: Could not load content for http://localhost:51848/lib_npm/fine-uploader/fine-uploader/fine-uploader.min.css.map: HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE
I don't know who need this, I found the solution I was using NopCommerce 4.40.3 version, upgrade Nopcommerce to its latest version then the delete pdf etc. and all functions will work in roxy Fileman.
I tried to make parts of code read-only in Ace editor.
I have tried by using code given in JsFiddle
$(function() {
var editor = ace.edit("editor1")
, session = editor.getSession()
, Range = require("ace/range").Range
, range = new Range(1, 4, 1, 10)
, markerId = session.addMarker(range, "readonly-highlight");
session.setMode("ace/mode/javascript");
editor.keyBinding.addKeyboardHandler({
handleKeyboard : function(data, hash, keyString, keyCode, event) {
if (hash === -1 || (keyCode <= 40 && keyCode >= 37)) return false;
if (intersects(range)) {
return {command:"null", passEvent:false};
}
}
});
before(editor, 'onPaste', preventReadonly);
before(editor, 'onCut', preventReadonly);
range.start = session.doc.createAnchor(range.start);
range.end = session.doc.createAnchor(range.end);
range.end.$insertRight = true;
function before(obj, method, wrapper) {
var orig = obj[method];
obj[method] = function() {
var args = Array.prototype.slice.call(arguments);
return wrapper.call(this, function(){
return orig.apply(obj, args);
}, args);
}
return obj[method];
}
function intersects(range) {
return editor.getSelectionRange().intersects(range);
}
function preventReadonly(next, args) {
if (intersects(range)) return;
next();
}
});
I got a problem when I keep pressing backspace it went into the read-only part and there was no editable part left.
How can I make multiple chunks of code read-only and avoid last character from read-only getting deleted.
Also, how to achieve the whole thing dynamically where I have markers in text specifying editable portions ?
Check the below code that allows multiple chunk of lines read-only with Enter at end of range to prevent non reversible delete and drag/drop handled.
function set_readonly(editor,readonly_ranges) {
var session = editor.getSession()
, Range = require("ace/range").Range;
ranges = [];
function before(obj, method, wrapper) {
var orig = obj[method];
obj[method] = function() {
var args = Array.prototype.slice.call(arguments);
return wrapper.call(this, function(){
return orig.apply(obj, args);
}, args);
}
return obj[method];
}
function intersects(range) {
return editor.getSelectionRange().intersects(range);
}
function intersectsRange(newRange) {
for (i=0;i<ranges.length;i++)
if(newRange.intersects(ranges[i]))
return true;
return false;
}
function preventReadonly(next, args) {
for(i=0;i<ranges.length;i++){if (intersects(ranges[i])) return;}
next();
}
function onEnd(position){
var row = position["row"],column=position["column"];
for (i=0;i<ranges.length;i++)
if(ranges[i].end["row"] == row && ranges[i].end["column"]==column)
return true;
return false;
}
function outSideRange(position){
var row = position["row"],column=position["column"];
for (i=0;i<ranges.length;i++){
if(ranges[i].start["row"]< row && ranges[i].end["row"]>row)
return false;
if(ranges[i].start["row"]==row && ranges[i].start["column"]<column){
if(ranges[i].end["row"] != row || ranges[i].end["column"]>column)
return false;
}
else if(ranges[i].end["row"] == row&&ranges[i].end["column"]>column){
return false;
}
}
return true;
}
for(i=0;i<readonly_ranges.length;i++){
ranges.push(new Range(...readonly_ranges[i]));
}
ranges.forEach(function(range){session.addMarker(range, "readonly-highlight");});
session.setMode("ace/mode/javascript");
editor.keyBinding.addKeyboardHandler({
handleKeyboard : function(data, hash, keyString, keyCode, event) {
if (Math.abs(keyCode) == 13 && onEnd(editor.getCursorPosition())){
return false;
}
if (hash === -1 || (keyCode <= 40 && keyCode >= 37)) return false;
for(i=0;i<ranges.length;i++){
if (intersects(ranges[i])) {
return {command:"null", passEvent:false};
}
}
}
});
before(editor, 'onPaste', preventReadonly);
before(editor, 'onCut', preventReadonly);
for(i=0;i<ranges.length;i++){
ranges[i].start = session.doc.createAnchor(ranges[i].start);
ranges[i].end = session.doc.createAnchor(ranges[i].end);
ranges[i].end.$insertRight = true;
}
var old$tryReplace = editor.$tryReplace;
editor.$tryReplace = function(range, replacement) {
return intersectsRange(range)?null:old$tryReplace.apply(this, arguments);
}
var session = editor.getSession();
var oldInsert = session.insert;
session.insert = function(position, text) {
return oldInsert.apply(this, [position, outSideRange(position)?text:""]);
}
var oldRemove = session.remove;
session.remove = function(range) {
return intersectsRange(range)?false:oldRemove.apply(this, arguments);
}
var oldMoveText = session.moveText;
session.moveText = function(fromRange, toPosition, copy) {
if (intersectsRange(fromRange) || !outSideRange(toPosition)) return fromRange;
return oldMoveText.apply(this, arguments);
}
}
function refresheditor(id,content,readonly) {
var temp_id=id+'_temp';
document.getElementById(id).innerHTML="<div id='"+temp_id+"'></div>";
document.getElementById(temp_id).innerHTML=content;
var editor = ace.edit(temp_id);
set_readonly(editor,readonly);
}
function get_readonly_by_editable_tag(id,content){
var text= content.split("\n");
var starts=[0],ends=[];
text.forEach(function(line,index){
if((line.indexOf("<editable>") !== -1))ends.push(index);
if((line.indexOf("</editable>") !== -1))starts.push(index+1);
});
ends.push(text.length);
var readonly_ranges=[];
for(i=0;i<starts.length;i++){
readonly_ranges.push([starts[i],0,ends[i],0])
}
refresheditor(id,content,readonly_ranges);
}
var content=document.getElementById("code").innerHTML;
function readonly_lines(id,content,line_numbers){
var readonly_ranges=[];
all_lines= line_numbers.sort();
for(i=0;i<line_numbers.length;i++){
readonly_ranges.push([line_numbers[i]-1,0,line_numbers[i],0]);
}
refresheditor(id,content,readonly_ranges);
}
get_readonly_by_editable_tag("myeditor",content)
//readonly_lines("myeditor",content,[5,7,9]);
.ace_editor {
width:100%;
height:300px;
}
.readonly-highlight{
background-color: red;
opacity: 0.2;
position: absolute;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://ace.c9.io/build/src/ace.js"></script>
<link rel="stylesheet" type="text/css" href="http://jsfiddle.net/css/normalize.css">
<link rel="stylesheet" type="text/css" href="http://jsfiddle.net/css/result-light.css">
<button onclick="get_readonly_by_editable_tag('myeditor',content)">Readonly by tags</button>
<button onclick="readonly_lines('myeditor',content,[3,7])">Readonly lines 3 and 7 </button>
<div id="myeditor" ></div>
<div id="code" style="display:none;">//<editable>
//</editable>
function refresheditor() {
//<editable>
document.getElementById("myeditor").innerHTML="<div id='editor'></div>";
document.getElementById("editor").innerHTML=document.getElementById("code").innerHTML;
//</editable>
var editor = ace.edit("editor")
, session = editor.getSession()
, Range = require("ace/range").Range;
ranges = [];
var text= document.getElementById("code").innerHTML.split("\n");
var starts=[0],ends=[];
text.forEach(function(line,index){
if((line.indexOf("<editable>") !== -1))ends.push(index);
if((line.indexOf("</editable>") !== -1))starts.push(index+1);
});
ends.push(text.length);
for(i=0;i<starts.length;i++){
ranges.push(new Range(starts[i], 0,ends[i] ,0));
}
ranges.forEach(function(range){session.addMarker(range, "readonly-highlight");});
session.setMode("ace/mode/javascript");
//<editable>
editor.keyBinding.addKeyboardHandler({
handleKeyboard : function(data, hash, keyString, keyCode, event) {
var pos=editor.getCursorPosition();
if (Math.abs(keyCode) == 13){
for (i=0;i<ranges.length;i++){
if((ranges[i].end["row"]==pos["row"])&&(ranges[i].end["column"]==pos["column"])){ return false;}
}
}
if (hash === -1 || (keyCode <= 40 && keyCode >= 37)) return false;
for(i=0;i<ranges.length;i++){
if (intersects(ranges[i])) {
return {command:"null", passEvent:false};
}
}
}
});
//</editable>
before(editor, 'onPaste', preventReadonly);
before(editor, 'onCut', preventReadonly);
for(i=0;i<ranges.length;i++){
ranges[i].start = session.doc.createAnchor(ranges[i].start);
ranges[i].end = session.doc.createAnchor(ranges[i].end);
ranges[i].end.$insertRight = true;
}
function before(obj, method, wrapper) {
var orig = obj[method];
obj[method] = function() {
var args = Array.prototype.slice.call(arguments);
return wrapper.call(this, function(){
return orig.apply(obj, args);
}, args);
}
return obj[method];
}
function intersects(range) {
return editor.getSelectionRange().intersects(range);
}
function preventReadonly(next, args) {
for(i=0;i<ranges.length;i++){if (intersects(ranges[i])) return;}
next();
}
}
refresheditor();
</div>
This code snippet will prevent the user from editing the first or last line of the editor:
editor.commands.on("exec", function(e) {
var rowCol = editor.selection.getCursor();
if ((rowCol.row == 0) || ((rowCol.row + 1) == editor.session.getLength())) {
e.preventDefault();
e.stopPropagation();
}
});
https://jsfiddle.net/tripflex/y0huvc1b/
Source:
https://groups.google.com/forum/#!topic/ace-discuss/yffGsSG7GSA
sorry: this code does not handle drag/drop
I added this last proposal last week: Ace Editor: Lock or Readonly Code Segment
I'm using a jquery plugin called quicksearch within Sharepoint 2010 and it works perfectly. Unfortunately were being forced to migrate onto sharepoint 2013 and it's stopped working. An error is shown saying that the function is undefined. I believe I've narrowed this down to the quicksearch function itself.
Here is the preliminary code:
_spBodyOnLoadFunctionNames.push("Load");
$('[name=search]').on('keyup', function(){
Load();
});
function Load() {
var searchArea = "#cbqwpctl00_ctl22_g_ca6bb172_1ab4_430d_ae38_a32cfa03b56b ul li";
var qs = $('input#id_search_list').val();
qs.quicksearch(searchArea);
$('.filter input').on('change', function(){
checkAndHide()
//$(searchArea).unhighlight();
});
function checkAndHide(){
var inputs = $('.filter input');
var i =0;
for (var i = 0; i < inputs.length; i++){
if (!inputs[i].checked){
$('.' + inputs[i].name).addClass('filter-hide');
} else {
$('.' + inputs[i].name).removeClass('filter-hide');
};
};
};
}
Here is an example of the quicksearch library I'm using:
(function($, window, document, undefined) {
$.fn.quicksearch = function (target, opt) {
var timeout, cache, rowcache, jq_results, val = '', e = this, options = $.extend({
delay: 300,
selector: null,
stripeRows: null,
loader: null,
noResults: 'div#noresults',
bind: 'keyup keydown',
onBefore: function () {
var ar = $('input#id_search_list').val()
if (ar.length > 2) {
var i=0;
var ar2 = $('input#id_search_list').val().split(" ");
for (i = 0; i < ar2.length; i++) {
$(searchArea + ':visible');
}
return true;
}
return false;
checkAndHide()
},
onAfter: function () {
return;
},
show: function () {
this.style.display = "block";
},
hide: function () {
this.style.display = "none";
},
prepareQuery: function (val) {
return val.toLowerCase().split(' ');
},
testQuery: function (query, txt, _row) {
for (var i = 0; i < query.length; i += 1) {
if (txt.indexOf(query[i]) === -1) {
return false;
}
}
return true;
}
}, opt);
this.go = function () {
var i = 0,
noresults = true,
query = options.prepareQuery(val),
val_empty = (val.replace(' ', '').length === 0);
for (var i = 0, len = rowcache.length; i < len; i++) {
if (val_empty) {
options.hide.apply(rowcache[i]);
noresults = false;
} else if (options.testQuery(query, cache[i], rowcache[i])){
options.show.apply(rowcache[i]);
noresults = false;
} else {
options.hide.apply(rowcache[i]);
}
}
if (noresults) {
this.results(false);
} else {
this.results(true);
this.stripe();
}
this.loader(false);
options.onAfter();
return this;
};
this.stripe = function () {
if (typeof options.stripeRows === "object" && options.stripeRows !== null)
{
var joined = options.stripeRows.join(' ');
var stripeRows_length = options.stripeRows.length;
jq_results.not(':hidden').each(function (i) {
$(this).removeClass(joined).addClass(options.stripeRows[i % stripeRows_length]);
});
}
return this;
};
this.strip_html = function (input) {
var output = input.replace(new RegExp('<[^<]+\>', 'g'), "");
output = $.trim(output.toLowerCase());
return output;
};
this.results = function (bool) {
if (typeof options.noResults === "string" && options.noResults !== "") {
if (bool) {
$(options.noResults).hide();
} else {
$(options.noResults).show();
}
}
return this;
};
this.loader = function (bool) {
if (typeof options.loader === "string" && options.loader !== "") {
(bool) ? $(options.loader).show() : $(options.loader).hide();
}
return this;
};
this.cache = function () {
jq_results = $(target);
if (typeof options.noResults === "string" && options.noResults !== "") {
jq_results = jq_results.not(options.noResults);
}
var t = (typeof options.selector === "string") ? jq_results.find(options.selector) : $(target).not(options.noResults);
cache = t.map(function () {
return e.strip_html(this.innerHTML);
});
rowcache = jq_results.map(function () {
return this;
});
return this.go();
};
this.trigger = function () {
this.loader(true);
if (options.onBefore()) {
window.clearTimeout(timeout);
timeout = window.setTimeout(function () {
e.go();
}, options.delay);
}
return this;
};
this.cache();
this.results(true);
this.stripe();
this.loader(false);
return this.each(function () {
$(this).bind(options.bind, function () {
val = $(this).val();
e.trigger();
});
});
};
}(jQuery, this, document));
`
This is where the error comes up:
var qs = $('input#id_search_list').val();
qs.quicksearch(searchArea);
Any help would be appreciated
Turns out was a small issue in the code and major css as sharepoint plays differently in 2013
I am trying to render a pdf in chrome using PDFJS
This is the function I am calling:
open: function pdfViewOpen(url, scale, password) {
var parameters = {password: password};
if (typeof url === 'string') { // URL
this.setTitleUsingUrl(url);
parameters.url = url;
} else if (url && 'byteLength' in url) { // ArrayBuffer
parameters.data = url;
}
if (!PDFView.loadingBar) {
PDFView.loadingBar = new ProgressBar('#loadingBar', {});
}
this.pdfDocument = null;
var self = this;
self.loading = true;
getDocument(parameters).then(
function getDocumentCallback(pdfDocument) {
self.load(pdfDocument, scale);
self.loading = false;
},
function getDocumentError(message, exception) {
if (exception && exception.name === 'PasswordException') {
if (exception.code === 'needpassword') {
var promptString = mozL10n.get('request_password', null,
'PDF is protected by a password:');
password = prompt(promptString);
if (password && password.length > 0) {
return PDFView.open(url, scale, password);
}
}
}
var loadingErrorMessage = mozL10n.get('loading_error', null,
'An error occurred while loading the PDF.');
if (exception && exception.name === 'InvalidPDFException') {
// change error message also for other builds
var loadingErrorMessage = mozL10n.get('invalid_file_error', null,
'Invalid or corrupted PDF file.');
//#if B2G
// window.alert(loadingErrorMessage);
// return window.close();
//#endif
}
var loadingIndicator = document.getElementById('loading');
loadingIndicator.textContent = mozL10n.get('loading_error_indicator',
null, 'Error');
var moreInfo = {
message: message
};
self.error(loadingErrorMessage, moreInfo);
self.loading = false;
},
function getDocumentProgress(progressData) {
self.progress(progressData.loaded / progressData.total);
}
);
}
This is the call:
PDFView.open('/MyPDFs/Pdf2.pdf', 'auto', null);
All I get is this:
If you notice, even the page number is retrieved but the content is not painted in the pages. Can´t find why.. Is the any other function I should call next to PDFView.open?
Found the solution...!
This is the code that does the work.
$(document).ready(function () {
PDFView.initialize();
var params = PDFView.parseQueryString(document.location.search.substring(1));
//#if !(FIREFOX || MOZCENTRAL)
var file = params.file || DEFAULT_URL;
//#else
//var file = window.location.toString()
//#endif
//#if !(FIREFOX || MOZCENTRAL)
if (!window.File || !window.FileReader || !window.FileList || !window.Blob) {
document.getElementById('openFile').setAttribute('hidden', 'true');
} else {
document.getElementById('fileInput').value = null;
}
//#else
//document.getElementById('openFile').setAttribute('hidden', 'true');
//#endif
// Special debugging flags in the hash section of the URL.
var hash = document.location.hash.substring(1);
var hashParams = PDFView.parseQueryString(hash);
if ('disableWorker' in hashParams)
PDFJS.disableWorker = (hashParams['disableWorker'] === 'true');
//#if !(FIREFOX || MOZCENTRAL)
var locale = navigator.language;
if ('locale' in hashParams)
locale = hashParams['locale'];
mozL10n.setLanguage(locale);
//#endif
if ('textLayer' in hashParams) {
switch (hashParams['textLayer']) {
case 'off':
PDFJS.disableTextLayer = true;
break;
case 'visible':
case 'shadow':
case 'hover':
var viewer = document.getElementById('viewer');
viewer.classList.add('textLayer-' + hashParams['textLayer']);
break;
}
}
//#if !(FIREFOX || MOZCENTRAL)
if ('pdfBug' in hashParams) {
//#else
//if ('pdfBug' in hashParams && FirefoxCom.requestSync('pdfBugEnabled')) {
//#endif
PDFJS.pdfBug = true;
var pdfBug = hashParams['pdfBug'];
var enabled = pdfBug.split(',');
PDFBug.enable(enabled);
PDFBug.init();
}
if (!PDFView.supportsPrinting) {
document.getElementById('print').classList.add('hidden');
}
if (!PDFView.supportsFullscreen) {
document.getElementById('fullscreen').classList.add('hidden');
}
if (PDFView.supportsIntegratedFind) {
document.querySelector('#viewFind').classList.add('hidden');
}
// Listen for warnings to trigger the fallback UI. Errors should be caught
// and call PDFView.error() so we don't need to listen for those.
PDFJS.LogManager.addLogger({
warn: function () {
PDFView.fallback();
}
});
var mainContainer = document.getElementById('mainContainer');
var outerContainer = document.getElementById('outerContainer');
mainContainer.addEventListener('transitionend', function (e) {
if (e.target == mainContainer) {
var event = document.createEvent('UIEvents');
event.initUIEvent('resize', false, false, window, 0);
window.dispatchEvent(event);
outerContainer.classList.remove('sidebarMoving');
}
}, true);
document.getElementById('sidebarToggle').addEventListener('click',
function () {
this.classList.toggle('toggled');
outerContainer.classList.add('sidebarMoving');
outerContainer.classList.toggle('sidebarOpen');
PDFView.sidebarOpen = outerContainer.classList.contains('sidebarOpen');
PDFView.renderHighestPriority();
});
document.getElementById('viewThumbnail').addEventListener('click',
function () {
PDFView.switchSidebarView('thumbs');
});
document.getElementById('viewOutline').addEventListener('click',
function () {
PDFView.switchSidebarView('outline');
});
document.getElementById('previous').addEventListener('click',
function () {
PDFView.page--;
});
document.getElementById('next').addEventListener('click',
function () {
PDFView.page++;
});
document.querySelector('.zoomIn').addEventListener('click',
function () {
PDFView.zoomIn();
});
document.querySelector('.zoomOut').addEventListener('click',
function () {
PDFView.zoomOut();
});
document.getElementById('fullscreen').addEventListener('click',
function () {
PDFView.fullscreen();
});
document.getElementById('openFile').addEventListener('click',
function () {
document.getElementById('fileInput').click();
});
document.getElementById('print').addEventListener('click',
function () {
window.print();
});
document.getElementById('download').addEventListener('click',
function () {
PDFView.download();
});
document.getElementById('pageNumber').addEventListener('change',
function () {
PDFView.page = this.value;
});
document.getElementById('scaleSelect').addEventListener('change',
function () {
PDFView.parseScale(this.value);
});
document.getElementById('first_page').addEventListener('click',
function () {
PDFView.page = 1;
});
document.getElementById('last_page').addEventListener('click',
function () {
PDFView.page = PDFView.pdfDocument.numPages;
});
document.getElementById('page_rotate_ccw').addEventListener('click',
function () {
PDFView.rotatePages(-90);
});
document.getElementById('page_rotate_cw').addEventListener('click',
function () {
PDFView.rotatePages(90);
});
//#if (FIREFOX || MOZCENTRAL)
//if (FirefoxCom.requestSync('getLoadingType') == 'passive') {
// PDFView.setTitleUsingUrl(file);
// PDFView.initPassiveLoading();
// return;
//}
//#endif
//#if !B2G
PDFView.open(file, 0);
//#endif
});
The system must be initialized first before PDFView.open call!
Thanks
I'm getting WebResource error in my asp.Net page:
var __pendingCallbacks = new Array();
Microsoft JScript runtime error: 'Array' is undefined
I have no idea what might cause this to happen. Isn't Array part of Javascript itself? Any help would be appreciated.
EDIT
The problem is that this isn't code that I wrote, it's built into the page structure in asp.Net.
EDIT
The problem only occurs in IE9 and only when run in IE9 mode (not compatibility)
Code:
(This is dynamically generated code, sorry for the length. Problem is about halfway down)
function WebForm_PostBackOptions(eventTarget, eventArgument, validation, validationGroup, actionUrl, trackFocus, clientSubmit) {
this.eventTarget = eventTarget;
this.eventArgument = eventArgument;
this.validation = validation;
this.validationGroup = validationGroup;
this.actionUrl = actionUrl;
this.trackFocus = trackFocus;
this.clientSubmit = clientSubmit;
}
function WebForm_DoPostBackWithOptions(options) {
var validationResult = true;
if (options.validation) {
if (typeof(Page_ClientValidate) == 'function') {
validationResult = Page_ClientValidate(options.validationGroup);
}
}
if (validationResult) {
if ((typeof(options.actionUrl) != "undefined") && (options.actionUrl != null) && (options.actionUrl.length > 0)) {
theForm.action = options.actionUrl;
}
if (options.trackFocus) {
var lastFocus = theForm.elements["__LASTFOCUS"];
if ((typeof(lastFocus) != "undefined") && (lastFocus != null)) {
if (typeof(document.activeElement) == "undefined") {
lastFocus.value = options.eventTarget;
}
else {
var active = document.activeElement;
if ((typeof(active) != "undefined") && (active != null)) {
if ((typeof(active.id) != "undefined") && (active.id != null) && (active.id.length > 0)) {
lastFocus.value = active.id;
}
else if (typeof(active.name) != "undefined") {
lastFocus.value = active.name;
}
}
}
}
}
}
if (options.clientSubmit) {
__doPostBack(options.eventTarget, options.eventArgument);
}
}
var __pendingCallbacks = new Array();
var __synchronousCallBackIndex = -1;
function WebForm_DoCallback(eventTarget, eventArgument, eventCallback, context, errorCallback, useAsync) {
var postData = __theFormPostData +
"__CALLBACKID=" + WebForm_EncodeCallback(eventTarget) +
"&__CALLBACKPARAM=" + WebForm_EncodeCallback(eventArgument);
if (theForm["__EVENTVALIDATION"]) {
postData += "&__EVENTVALIDATION=" + WebForm_EncodeCallback(theForm["__EVENTVALIDATION"].value);
}
var xmlRequest,e;
try {
xmlRequest = new XMLHttpRequest();
}
catch(e) {
try {
xmlRequest = new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e) {
}
}
var setRequestHeaderMethodExists = true;
try {
setRequestHeaderMethodExists = (xmlRequest && xmlRequest.setRequestHeader);
}
catch(e) {}
var callback = new Object();
callback.eventCallback = eventCallback;
callback.context = context;
callback.errorCallback = errorCallback;
callback.async = useAsync;
var callbackIndex = WebForm_FillFirstAvailableSlot(__pendingCallbacks, callback);
if (!useAsync) {
if (__synchronousCallBackIndex != -1) {
__pendingCallbacks[__synchronousCallBackIndex] = null;
}
__synchronousCallBackIndex = callbackIndex;
}
if (setRequestHeaderMethodExists) {
xmlRequest.onreadystatechange = WebForm_CallbackComplete;
callback.xmlRequest = xmlRequest;
xmlRequest.open("POST", theForm.action, true);
xmlRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8");
xmlRequest.send(postData);
return;
}
callback.xmlRequest = new Object();
var callbackFrameID = "__CALLBACKFRAME" + callbackIndex;
var xmlRequestFrame = document.frames[callbackFrameID];
if (!xmlRequestFrame) {
xmlRequestFrame = document.createElement("IFRAME");
xmlRequestFrame.width = "1";
xmlRequestFrame.height = "1";
xmlRequestFrame.frameBorder = "0";
xmlRequestFrame.id = callbackFrameID;
xmlRequestFrame.name = callbackFrameID;
xmlRequestFrame.style.position = "absolute";
xmlRequestFrame.style.top = "-100px"
xmlRequestFrame.style.left = "-100px";
try {
if (callBackFrameUrl) {
xmlRequestFrame.src = callBackFrameUrl;
}
}
catch(e) {}
document.body.appendChild(xmlRequestFrame);
}
var interval = window.setInterval(function() {
xmlRequestFrame = document.frames[callbackFrameID];
if (xmlRequestFrame && xmlRequestFrame.document) {
window.clearInterval(interval);
xmlRequestFrame.document.write("");
xmlRequestFrame.document.close();
xmlRequestFrame.document.write('<html><body><form method="post"><input type="hidden" name="__CALLBACKLOADSCRIPT" value="t"></form></body></html>');
xmlRequestFrame.document.close();
xmlRequestFrame.document.forms[0].action = theForm.action;
var count = __theFormPostCollection.length;
var element;
for (var i = 0; i < count; i++) {
element = __theFormPostCollection[i];
if (element) {
var fieldElement = xmlRequestFrame.document.createElement("INPUT");
fieldElement.type = "hidden";
fieldElement.name = element.name;
fieldElement.value = element.value;
xmlRequestFrame.document.forms[0].appendChild(fieldElement);
}
}
var callbackIdFieldElement = xmlRequestFrame.document.createElement("INPUT");
callbackIdFieldElement.type = "hidden";
callbackIdFieldElement.name = "__CALLBACKID";
callbackIdFieldElement.value = eventTarget;
xmlRequestFrame.document.forms[0].appendChild(callbackIdFieldElement);
var callbackParamFieldElement = xmlRequestFrame.document.createElement("INPUT");
callbackParamFieldElement.type = "hidden";
callbackParamFieldElement.name = "__CALLBACKPARAM";
callbackParamFieldElement.value = eventArgument;
xmlRequestFrame.document.forms[0].appendChild(callbackParamFieldElement);
if (theForm["__EVENTVALIDATION"]) {
var callbackValidationFieldElement = xmlRequestFrame.document.createElement("INPUT");
callbackValidationFieldElement.type = "hidden";
callbackValidationFieldElement.name = "__EVENTVALIDATION";
callbackValidationFieldElement.value = theForm["__EVENTVALIDATION"].value;
xmlRequestFrame.document.forms[0].appendChild(callbackValidationFieldElement);
}
var callbackIndexFieldElement = xmlRequestFrame.document.createElement("INPUT");
callbackIndexFieldElement.type = "hidden";
callbackIndexFieldElement.name = "__CALLBACKINDEX";
callbackIndexFieldElement.value = callbackIndex;
xmlRequestFrame.document.forms[0].appendChild(callbackIndexFieldElement);
xmlRequestFrame.document.forms[0].submit();
}
}, 10);
}
This happens because we have this setup
<collapsible panel>
<iframe>
<script>
</script>
</iframe>
</collapsible panel>
When the page loads, the panel being shown forces the script inside the iframe to be dragged through the DOM before the javascript libraries are loaded. This seems to be a change in that was made for IE9. I have yet to fine a way around this issue but at least I know the cause. A temporary workaround is to force the compatibility of the page to IE8 using a meta tag in case anybody else runs into this issue.
The problem was fixed when I removed the SRC attribute from the iframe and I added onOpen event to jQuery's dialog:
open: function(){
document.getElementById("iframename").src = "page.aspx";
}