Skip to content

Commit 921c69d

Browse files
committed
First commit
0 parents  commit 921c69d

4 files changed

Lines changed: 189 additions & 0 deletions

File tree

LICENSE

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
The MIT License (MIT)
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of
4+
this software and associated documentation files (the "Software"), to deal in
5+
the Software without restriction, including without limitation the rights to
6+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
7+
the Software, and to permit persons to whom the Software is furnished to do so,
8+
subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
15+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
16+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Brackets Bootstrap Skeleton #
2+
3+
A [Brackets](http://brackets.io/) extension to add Bootstrap 3 HTML5 Snippets to your page using simple shortcut keys.
4+
5+
## Installation ##
6+
1. Open the Brackets Extension Manager and search for "bootstrap".
7+
2. Download straight from GitHub using [https://github.com/mirorauhala/brackets-bootstrap-skeleton/archive/master.zip](https://github.com/mirorauhala/brackets-bootstrap-skeleton/archive/master.zip)
8+
9+
## Directions ##
10+
* Ctrl-Shift-N > Ccreate a Navigation toolbar
11+
* Ctrl-Shift-P > Create a Panel
12+
* Ctrl-Shift-M > Create a Modal
13+
* Ctrl-Shift-I > Create an input group
14+
* More Components coming soon
15+
16+
This will make the relevant snippets at cursor location.
17+
18+
## License ##
19+
[MIT License](LICENSE)

main.js

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
/*jslint vars: true, plusplus: true, devel: true, nomen: true, regexp: true, indent: 4, maxerr: 50 */
2+
/*global define, $, brackets, window */
3+
4+
/** Simple extension that adds a "File > Hello World" menu item */
5+
define(function (require, exports, module) {
6+
"use strict";
7+
var keyBoardShortCutPanel = "Ctrl-Shift-P";
8+
var keyBoardShortCutModal = "Ctrl-Shift-M";
9+
var keyBoardShortCutNav = "Ctrl-Shift-N";
10+
var keyBoardShortCutInputGroup = "Ctrl-Shift-I";
11+
var keyBoardShortCutHelp = "Ctrl-`";
12+
var CommandManager = brackets.getModule("command/CommandManager");
13+
var kbManager = brackets.getModule("command/KeyBindingManager");
14+
var edManager = brackets.getModule("editor/EditorManager");
15+
16+
//append a panel to current editor
17+
function appendPanel(){
18+
/*jQuery('<div/>', {
19+
id: "foo",
20+
text: "Get into Facebook"
21+
}).appendTo("body");*/
22+
var panelSeklly = '<div class="panel panel-default">\n' +
23+
' <div class="panel-heading">\n' +
24+
' <h3 class="panel-title">Panel title</h3>\n' +
25+
' </div>\n' +
26+
' <div class="panel-body">\n' +
27+
' Panel content\n' +
28+
' </div>\n' +
29+
' <div class="panel-footer">Panel footer</div>\n' +
30+
'</div>';
31+
//window.alert("Hello");
32+
var editor = edManager.getCurrentFullEditor();
33+
if(editor){
34+
var insertionPos = editor.getCursorPos();
35+
editor.document.replaceRange(panelSeklly, insertionPos);
36+
}
37+
}
38+
//append a modal to the current editor
39+
function appendModal(){
40+
var panelSeklly = '<div class="modal fade">\n' +
41+
' <div class="modal-dialog">\n' +
42+
' <div class="modal-content">\n' +
43+
' <div class="modal-header">\n' +
44+
' <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>\n' +
45+
' <h4 class="modal-title">Modal title</h4>\n' +
46+
' </div>\n' +
47+
' <div class="modal-body">\n' +
48+
' <p>One fine body&hellip;</p>\n' +
49+
' </div>\n' +
50+
' <div class="modal-footer">\n' +
51+
' <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>\n' +
52+
' <button type="button" class="btn btn-primary">Save changes</button>\n' +
53+
' </div>\n' +
54+
' </div>\n' +
55+
' </div>\n' +
56+
'</div>';
57+
// window.alert("Hello");
58+
var editor = edManager.getCurrentFullEditor();
59+
if(editor){
60+
var insertionPos = editor.getCursorPos();
61+
editor.document.replaceRange(panelSeklly, insertionPos);
62+
}
63+
}
64+
65+
function appendNav(){
66+
var panelSeklly = '<nav class="navbar navbar-default">\n'+
67+
' <div class="container-fluid">\n'+
68+
' <div class="navbar-header">\n'+
69+
' <a class="navbar-brand" href="#">WebSiteName</a>\n'+
70+
' </div>\n'+
71+
' <div>\n'+
72+
' <ul class="nav navbar-nav">\n'+
73+
' <li class="active"><a href="#">Home</a></li>\n'+
74+
' <li><a href="#">Page 1</a></li>\n'+
75+
' <li><a href="#">Page 2</a></li>\n' +
76+
' <li><a href="#">Page 3</a></li>\n' +
77+
' </ul>\n'+
78+
' </div>\n'+
79+
' </div>\n'+
80+
'</nav>';
81+
var editor = edManager.getCurrentFullEditor();
82+
if(editor){
83+
var insertionPos = editor.getCursorPos();
84+
editor.document.replaceRange(panelSeklly, insertionPos);
85+
}
86+
}
87+
88+
function appendInputGroup(){
89+
var panelSeklly = '<div class="input-group">\n' +
90+
' <span class="input-group-addon">$</span>\n' +
91+
' <input type="text" class="form-control" aria-label="Amount (to the nearest dollar)">\n' +
92+
' <span class="input-group-addon">.00</span>\n' +
93+
'</div>';
94+
var editor = edManager.getCurrentFullEditor();
95+
if(editor){
96+
var insertionPos = editor.getCursorPos();
97+
editor.document.replaceRange(panelSeklly, insertionPos);
98+
}
99+
}
100+
101+
function showHelp(){
102+
window.alert("Ctrl-Alt-P : Panel\nCtrl-Alt-M: Modal\nCtrl-Alt-I: Input Groups\nCtrl-Alt-N: Navbar");
103+
}
104+
105+
var COMMAND_ID_P = "bootstrapsnippets.getPanel";
106+
var COMMAND_ID_M = "bootstrapsnippets.getModal";
107+
var COMMAND_ID_N = "bootstrapsnippets.getNav";
108+
var COMMAND_ID_I = "bootstrapsnippets.getInputGroup";
109+
var COMMAND_ID_H = "bootstrapsnippets.help";
110+
111+
CommandManager.register("Panel", COMMAND_ID_P, appendPanel);
112+
113+
kbManager.addBinding(COMMAND_ID_P, keyBoardShortCutPanel);
114+
115+
CommandManager.register("Help", COMMAND_ID_H, showHelp);
116+
117+
kbManager.addBinding(COMMAND_ID_H, keyBoardShortCutHelp);
118+
119+
CommandManager.register("Modal", COMMAND_ID_M, appendModal);
120+
121+
kbManager.addBinding(COMMAND_ID_M, keyBoardShortCutModal);
122+
123+
CommandManager.register("Nav", COMMAND_ID_N, appendNav);
124+
125+
kbManager.addBinding(COMMAND_ID_N, keyBoardShortCutNav);
126+
CommandManager.register("InputGroup", COMMAND_ID_I, appendInputGroup);
127+
128+
kbManager.addBinding(COMMAND_ID_I, keyBoardShortCutInputGroup);
129+
});

package.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "codeomnitrix.bootstrap-snippets",
3+
"title": "Bootstrap 3 Snippets",
4+
"description": "Add Bootstrap 3 HTML5 Snippets to your page by hitting Ctrl-Shift keys with designated snippets eg. P for panel etc.",
5+
"homepage": "https://github.com/codeomnitrix/bootstrap-snippets",
6+
"version": "0.1.0",
7+
"author": "Vinit Tiwari (https://github.com/codeomnitrix)",
8+
"license": "MIT",
9+
"engines": {
10+
"brackets": ">=0.37.0"
11+
},
12+
"keywords": [
13+
"Bootstrap",
14+
"Bootstrap 3",
15+
"Bootstrap Snippets",
16+
"Snippets"
17+
"HTML",
18+
"device",
19+
"screen",
20+
"html",
21+
"HTML Document"
22+
]
23+
}

0 commit comments

Comments
 (0)