Skip to content

Commit

Permalink
Some changes&Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
myaaghubi committed Apr 18, 2016
1 parent 7dddede commit 1bc9a14
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 21 deletions.
3 changes: 2 additions & 1 deletion README.md
@@ -1,7 +1,8 @@
# QuickFormTool # ver 2.6.3
# QuickFormTool # ver 2.7

An extension for Adobe Brackets to insert form elements into editor quickly.<br>
This extension now available for download.<br>
![Alt text](/screenshot/shot1.png?raw=true "ScreenShot")

## Installation ##

Expand Down
61 changes: 43 additions & 18 deletions main.js
Expand Up @@ -7,6 +7,10 @@ define(function (require, exports, module)
Strings = brackets.getModule("strings"),
DocumentManager = brackets.getModule("document/DocumentManager"),
MainViewManager = brackets.getModule("view/MainViewManager"),
FileSystem = brackets.getModule("filesystem/FileSystem"),
DocumentModule = brackets.getModule("document/Document"),
InMemoryFile = brackets.getModule("document/InMemoryFile"),
Editor = brackets.getModule("editor/Editor"),
QuickFormToolTemplate = require("text!ui/QuickFormToolTemplate.html");

var untitledhtml5index = 1;
Expand Down Expand Up @@ -63,51 +67,51 @@ define(function (require, exports, module)
switch (_class)
{
case "form":
handleText("<form action=\"\" method=\"get\"></form>");
handleText("<form action=\"\" method=\"post\"></form>");
break;

case "textfield":
handleText("<input type=\"text\" name=\"textfield\" size=\"25\" value=\"TextField\">");
handleText("<input type=\"text\" name=\"textfield\" placeholder=\"TextField\">");
break;

case "textarea":
handleText("<textarea name=\"\" cols=\"25\" rows=\"5\">TextArea</textarea>");
handleText("<textarea name=\"textarea\" placeholder=\"TextArea\"></textarea>");
break;

case "button":
handleText("<input type=\"button\" name=\"button\" value=\"Button\">");
handleText("<input type=\"button\" name=\"button\">");
break;

case "checkbox":
handleText("<input type=\"checkbox\" name=\"checkbox\" value=\"CheckBox\">");
handleText("<input type=\"checkbox\" name=\"checkbox\">");
break;

case "radiobutton":
handleText("<input type=\"radio\" name=\"radiogroup\" value=\"RadioButton\">");
handleText("<input type=\"radio\" name=\"radio1\">");
break;

case "listmenu":
handleText("<select name=\"selectoptions\">\n\t<option value=\"option1\">Option 1</option>\n\t<option value=\"option2\">Option 2</option>\n</select>");
break;

case "imagebutton":
handleText("<input type=\"image\" name=\"\" src=\"\" width=\"\" height=\"\">");
handleText("<input type=\"image\" name=\"imageinput\" src=\"\" width=\"\" height=\"\">");
break;

case "imagefield":
handleText("<img src=\"\" alt=\"\" width=\"\" height=\"\">");
break;

case "filefield":
handleText("<input type=\"file\" name=\"filefield\">");
handleText("<input type=\"file\" name=\"fileinput\">");
break;

case "hiddenfield":
handleText("<input type=\"hidden\" name=\"hiddenfield\" value=\"hiddenfieldvalue\">");
handleText("<input type=\"hidden\" name=\"hiddeninput\" value=\"hiddeninputvalue\">");
break;

case "link":
handleText("<a href=\"\"></a>");
handleText("<a href=\"\" target=\"_self\"></a>");
break;

case "html5audio":
Expand All @@ -123,9 +127,7 @@ define(function (require, exports, module)
break;

case "html5file":
var doc = DocumentManager.createUntitledDocument(untitledhtml5index++, ".html");
handleFileNew(doc);
handleText(html5page);
makeHTML5File();
break;

case "cssfile":
Expand All @@ -144,20 +146,30 @@ define(function (require, exports, module)
}
};

function makeHTML5File()
{
var doc = createUntitledDocument("Untitled-", untitledhtml5index++, ".html");
handleFileNew(doc);
handleText("<!DOCTYPE html>\n<html>\n<head>\n\t<meta charset=\"UTF-8\">\n\t<title>Untitled Document</title>\n\t\n</head>\n<body>\n\t\n</body>\n</html>");
EditorManager.getActiveEditor().setCursorPos({ line: 8, pos: 0 });
}

function makeCSSFile()
{
var doc = DocumentManager.createUntitledDocument(untitledcssindex, ".css");
handleTextToTag("<link rel=\"stylesheet\" href=\"Untitled-" + untitledcssindex++ + ".css\">", "head");
var doc = createUntitledDocument("css", untitledcssindex, ".css");
handleTextToTag("<link rel=\"stylesheet\" href=\"css" + untitledcssindex++ + ".css\">", "head");
handleFileNew(doc);
handleText("html\n{\n\t\n\}\n");
}

function makeJSFile()
{
var doc = DocumentManager.createUntitledDocument(untitledjsindex, ".js");
handleText("<script type=\"javascript\" src=\"Untitled-" + untitledjsindex++ + ".js\" />");
var doc = createUntitledDocument("javascript", untitledjsindex, ".js");
handleText("<script type=\"javascript\" src=\"javascript" + untitledjsindex++ + ".js\" />");
handleFileNew(doc);
handleText("");
}

function handleText(commandString)
{
try
Expand All @@ -183,6 +195,7 @@ define(function (require, exports, module)
}
catch(err){}
}

function handleTextToTag(text, tag)
{
try
Expand All @@ -203,6 +216,19 @@ define(function (require, exports, module)
}
catch(err){alert("Error: "+err);}
}

//make new document. used of document/DocumentManager -> createUntitledDocument()
function createUntitledDocument(filename, counter, fileExt) {
var fullfilename = filename + counter + fileExt,
fullPath = DocumentManager._untitledDocumentPath + "/" + fullfilename,
now = new Date(),
file = new InMemoryFile(fullPath, FileSystem);

FileSystem.addEntryForPathIfRequired(file, fullPath);

return new DocumentManager.Document(file, now, "");
}

//make new file.
function handleFileNew(docname)
{
Expand All @@ -216,7 +242,6 @@ define(function (require, exports, module)
}
catch(err){alert("Error: "+err);}
}
var html5page = "<!doctype html>\n<html>\n<head>\n\t<meta charset=\"UTF-8\">\n\t<title>Untitled Document</title>\n\t\n</head>\n<body>\n\t\n\t\n\t\n</body>\n</html>";

ExtensionUtils.loadStyleSheet(module, "ui/style.css");
exports.quickFormToolProvider = quickFormToolProvider;
Expand Down
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -3,8 +3,8 @@
"title": "QuickFormTool",
"description": "Insert form elements quickly",
"homepage": "https://github.com/mohammadyaghobi/Brackets-QuickFormTool",
"version": "2.6.3",
"author": "Mohammad Yaghobi <m.yaghobi.abc@gmail.com> (http://www.pgrammer.com)",
"version": "2.7",
"author": "Mohammad Yaghobi <m.yaghobi.abc@gmail.com>",
"license": "MIT",
"repository": {
"type": "git",
Expand Down
Binary file added screenshot/shot1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 1bc9a14

Please sign in to comment.