$("#dialogCancel").click(function() { if(ignoreOrCancelCallback) { var dialogPathDetails: FilePath = createFinalPath(); ignoreOrCancelCallback(dialogPathDetails); } w2popup.close(); });
$("#dialogSave").click(function() { if(saveCallback) { var dialogPathDetails: FilePath = createFinalPath(); saveCallback(dialogPathDetails); } w2popup.close(); });
$("#dialogSave").click(function() { var searchText = $("#searchText").html(); var replaceText = $("#replaceText").html(); var filePatterns = $("#fileFilterPatterns").html(); var searchCriteria = { caseSensitive: isCheckboxSelected("inputCaseSensitive"), regularExpression: isCheckboxSelected("inputRegularExpression"), wholeWord: isCheckboxSelected("inputWholeWord"), enableReplace: true, replace: replaceText }; Command.replaceTokenInFiles(searchText, searchCriteria, filePatterns); w2popup.close(); });
function createEvaluateDialog(inputText, dialogTitle) { var windowHeight = $(window).height(); // returns height of browser viewport var windowWidth = $(window).width(); // returns width of browser viewport var dialogBody = createGridDialogLayout(inputText ? Common.escapeHtml(inputText) : ''); var focusInput = function() { var element = document.getElementById('dialogPath'); element.contentEditable = "true"; element.focus(); }; var executeEvaluation = function() { var text = $("#dialogPath").html(); var expression = Common.clearHtml(text); Command.browseScriptEvaluation([], expression, true); // clear the variables }; w2popup.open({ title : dialogTitle, body : dialogBody.content, buttons : '<button id="dialogSave" class="btn dialogButton">Evaluate</button>', width : Math.max(700, windowWidth / 2), height : Math.max(400, windowHeight / 2), overflow : 'hidden', color : '#999', speed : '0.3', opacity : '0.8', modal : false, showClose : true, showMax : true, onOpen : function(event) { setTimeout(function() { dialogBody.init(); // bind the functions $('#dialog').w2grid({ recordTitles: false, // show tooltips name : 'evaluation', columns : [ { field : 'name', caption : 'Name', size : '40%', sortable : false }, { field : 'value', caption : 'Value', size : '30%', sortable : false }, { field : 'type', caption : 'Type', size : '30%' } ], onClick : function(event) { var grid = this; event.onComplete = function() { var sel = grid.getSelection(); if (sel.length == 1) { var record = grid.get(sel[0]); var text = $("#dialogPath").html(); var expression = Common.clearHtml(text); VariableManager.toggleExpandEvaluation(record.path, expression); } grid.selectNone(); grid.refresh(); } } }); focusInput(); setTimeout(function() { VariableManager.showVariables(); }, 200); }, 200); }, onClose : function(event) { w2ui['evaluation'].destroy(); // destroy grid so you can recreate it //$("#dialog").remove(); // delete the element VariableManager.clearEvaluation(); Command.browseScriptEvaluation([], "", true); // clear the variables }, onMax : function(event) { event.onComplete = function() { w2ui['evaluation'].refresh(); // resize focusInput(); } $(window).trigger('resize'); }, onMin : function(event) { event.onComplete = function() { w2ui['evaluation'].refresh(); // resize focusInput(); } $(window).trigger('resize'); }, onKeydown : function(event) { console.log('keydown'); } }); $("#dialogSave").click(function() { executeEvaluation(); }); }
$("#dialogCancel").click(function() { w2popup.close(); });
function createTreeDialog(resourceDetails: FilePath, foldersOnly: boolean, saveCallback: any, ignoreOrCancelCallback: any, nameIsBlank: boolean, dialogTitle: string, treePath: string) { var windowHeight: number = $(window).height(); // returns height of browser viewport var windowWidth: number = $(window).width(); // returns width of browser viewport var dialogExpandPath: string = "/"; if (resourceDetails != null) { dialogExpandPath = resourceDetails.getProjectDirectory(); // /src/blah } var dialogBody = createFileSelectionDialogLayout(dialogExpandPath, ''); var focusInput = function() { var element = document.getElementById('dialogPath'); element.contentEditable = "true"; element.focus(); }; var createFinalPath = function() { var originalDialogFileName = $('#dialogPath').html(); var originalDialogFolder = $('#dialogFolder').html(); var dialogPathName: string = FileTree.cleanResourcePath(originalDialogFileName); var dialogFolder: string = FileTree.cleanResourcePath(originalDialogFolder); var dialogProjectPath: string = dialogFolder + "/" + dialogPathName; // /src/blah/script.snap var dialogPathDetails: FilePath = FileTree.createResourcePath(dialogProjectPath); return dialogPathDetails; } w2popup.open({ title : dialogTitle, body : dialogBody.content, buttons : '<button id="dialogSave" class="btn dialogButton">Save</button><button id="dialogCancel" class="btn dialogButton">Cancel</button>', width : Math.max(500, windowWidth / 2), height : Math.max(400, windowHeight / 2), overflow : 'hidden', color : '#999', speed : '0.3', opacity : '0.8', modal : true, showClose : true, showMax : true, onOpen : function(event) { setTimeout(function() { dialogBody.init(); focusInput(); }, 200); }, onClose : function(event) { console.log('close'); }, onMax : function(event) { console.log('max'); $(window).trigger('resize'); event.onComplete = function() { focusInput(); }; }, onMin : function(event) { console.log('min'); $(window).trigger('resize'); event.onComplete = function() { focusInput(); }; }, onKeydown : function(event) { console.log('keydown'); } }); $("#dialogSave").click(function() { if(saveCallback) { var dialogPathDetails: FilePath = createFinalPath(); saveCallback(dialogPathDetails); } w2popup.close(); }); $("#dialogCancel").click(function() { if(ignoreOrCancelCallback) { var dialogPathDetails: FilePath = createFinalPath(); ignoreOrCancelCallback(dialogPathDetails); } w2popup.close(); }); if (resourceDetails != null) { $('#dialogFolder').html(FileTree.cleanResourcePath(resourceDetails.getProjectDirectory())); // /src/blah if(!nameIsBlank) { $('#dialogPath').html(FileTree.cleanResourcePath(resourceDetails.getFileName())); // script.snap } } FileTree.createTree(treePath, "dialog", "dialogTree", dialogExpandPath, foldersOnly, null, function(event, data) { var selectedFileDetails: FilePath = FileTree.createResourcePath(data.node.tooltip); if (data.node.isFolder()) { $('#dialogFolder').html(FileTree.cleanResourcePath(selectedFileDetails.getProjectDirectory())); //$('#dialogPath').html(""); // DO NOT CLEAR THE PATH INPUT } else { $('#dialogFolder').html(FileTree.cleanResourcePath(selectedFileDetails.getProjectDirectory())); // /src/blah $('#dialogPath').html(FileTree.cleanResourcePath(selectedFileDetails.getFileName())); // file.snap } }); }
export function createTextSearchAndReplaceDialog(listFunction, fileFilterPatterns, dialogTitle) { // listFunction(token): [a, b, c] var windowHeight = $(window).height(); // returns height of browser viewport var windowWidth = $(window).width(); // returns width of browser viewport var focusInput = function() { var element = document.getElementById('searchText'); element.contentEditable = "true"; element.focus(); }; var executeSearch = function() { var expressionText = $("#searchText").html(); // add a delay before you execute executeIfTextUnchanged(expressionText, "searchText", 300, function() { var searchCriteria = { caseSensitive: isCheckboxSelected("inputCaseSensitive"), regularExpression: isCheckboxSelected("inputRegularExpression"), wholeWord: isCheckboxSelected("inputWholeWord") }; var expressionPattern = null; if(fileFilterPatterns) { expressionPattern = $("#fileFilterPatterns").html(); expressionPattern = Common.clearHtml(expressionPattern); } if(expressionText) { expressionText = Common.clearHtml(expressionText); } listFunction(expressionText, expressionPattern, searchCriteria, function(list, requestedText) { var currentText = $("#searchText").html(); if(!requestedText || currentText == requestedText) { var content = createDialogListTable(list); if(content.content){ $("#dialog").html(content.content); }else { $("#dialog").html(''); } // this is kind of crap, but we need to be sure the html is rendered before binding if(content.init) { setTimeout(content.init, 100); // register the init function to run } } }); }); }; var dialogBody = createTextSearchAndReplaceDialogLayout(fileFilterPatterns, '', executeSearch); w2popup.open({ title : dialogTitle, body : dialogBody.content, buttons : '<button id="dialogSave" class="btn dialogButton">Replace</button><button id="dialogCancel" class="btn dialogButton">Cancel</button>', width : Math.max(800, windowWidth / 2), height : Math.max(400, windowHeight / 2), overflow : 'hidden', color : '#999', speed : '0.3', opacity : '0.8', modal : true, showClose : true, showMax : true, onOpen : function(event) { setTimeout(function() { dialogBody.init(); $('#searchText').on('change keyup paste', executeSearch); // $('#inputCaseSensitive').change(executeSearch); // $('#inputRegularExpression').change(executeSearch); // $('#inputWholeWord').change(executeSearch); focusInput(); }, 200); }, onMax : function(event) { console.log('max'); $(window).trigger('resize'); event.onComplete = function() { focusInput(); }; }, onMin : function(event) { console.log('min'); $(window).trigger('resize'); event.onComplete = function() { focusInput(); }; } }); $("#dialogSave").click(function() { var searchText = $("#searchText").html(); var replaceText = $("#replaceText").html(); var filePatterns = $("#fileFilterPatterns").html(); var searchCriteria = { caseSensitive: isCheckboxSelected("inputCaseSensitive"), regularExpression: isCheckboxSelected("inputRegularExpression"), wholeWord: isCheckboxSelected("inputWholeWord"), enableReplace: true, replace: replaceText }; Command.replaceTokenInFiles(searchText, searchCriteria, filePatterns); w2popup.close(); }); $("#dialogCancel").click(function() { w2popup.close(); }); }
$("#dialogSave").click(function() { w2popup.close(); });
export function createListDialog(listFunction, patternList, dialogTitle) { // listFunction(token): [a, b, c] var windowHeight = $(window).height(); // returns height of browser viewport var windowWidth = $(window).width(); // returns width of browser viewport var dialogBody = createListDialogLayout(); var focusInput = function() { var element = document.getElementById('dialogPath'); element.contentEditable = "true"; element.focus(); }; w2popup.open({ title : dialogTitle, body : dialogBody.content, buttons : '<button id="dialogCancel" class="btn dialogButton">Cancel</button>', width : Math.max(800, windowWidth / 2), height : Math.max(400, windowHeight / 2), overflow : 'hidden', color : '#999', speed : '0.3', opacity : '0.8', modal : true, showClose : true, showMax : true, onOpen : function(event) { setTimeout(function() { dialogBody.init(); $('#dialogPath').on('change keyup paste', function() { var expressionText = $("#dialogPath").html(); // add a delay before you execute executeIfTextUnchanged(expressionText, "dialogPath", 300, function() { var expressionPattern = null; if(patternList) { expressionPattern = $("#dialogFolder").html(); expressionPattern = Common.clearHtml(expressionPattern); } if(expressionText) { expressionText = Common.clearHtml(expressionText); } listFunction(expressionText, expressionPattern, function(list, requestedExpression) { var currentExpression = $("#dialogPath").html(); if(!requestedExpression || requestedExpression == currentExpression) { var content = createDialogListTable(list); if(content.content){ $("#dialog").html(content.content); }else { $("#dialog").html(''); } // this is kind of crap, but we need to be sure the html is rendered before binding if(content.init) { setTimeout(content.init, 100); // register the init function to run } } }); }); }); focusInput(); }, 200); }, onMax : function(event) { console.log('max'); $(window).trigger('resize'); event.onComplete = function() { focusInput(); }; }, onMin : function(event) { console.log('min'); $(window).trigger('resize'); event.onComplete = function() { focusInput(); }; } }); $("#dialogSave").click(function() { w2popup.close(); }); $("#dialogCancel").click(function() { w2popup.close(); }); }
$("#dialogSave").click(function() { completeFunction(); w2popup.close(); });