diff --git a/bower.json b/bower.json
new file mode 100644
index 0000000..819ee40
--- /dev/null
+++ b/bower.json
@@ -0,0 +1,24 @@
+{
+ "name": "searchy.js",
+ "description": "JQuery and Lunr.js blog search plugin",
+ "main": "dist/searchy.min.js",
+ "authors": [
+ "PJ Tatlow"
+ ],
+ "license": "MIT",
+ "keywords": [
+ "blog",
+ "search",
+ "Searchy",
+ "McSearchBox"
+ ],
+ "homepage": "https://github.com/pjtatlow/searchy.js",
+ "moduleType": [],
+ "ignore": [
+ "**/.*",
+ "node_modules",
+ "bower_components",
+ "test",
+ "tests"
+ ]
+}
diff --git a/dist/searchy.min.css b/dist/searchy.min.css
new file mode 100644
index 0000000..2f5e921
--- /dev/null
+++ b/dist/searchy.min.css
@@ -0,0 +1 @@
+.searchy-background{position:fixed;height:100vh;min-width:100%;z-index:8888;top:0;left:0;overflow:hidden;display:none}.searchy-background .searchy-cover{position:absolute;height:55px;width:80%;width:100%;max-width:700px;top:0;left:0;background-color:transparent;top:35%;left:50%;transform:translate(-50%,-50%)}.searchy-background .searchy-cover .searchy-box{background-color:rgba(246,246,246,0.99);position:absolute;border-radius:7px;z-index:-1;-webkit-box-shadow:0 14px 32px 0 rgba(0,0,0,0.75);-moz-box-shadow:0 14px 32px 0 rgba(0,0,0,0.75);box-shadow:0 14px 32px 0 rgba(0,0,0,0.75);clear:both;width:100%;max-width:700px}.searchy-background .searchy-cover .searchy-box .input-group .searchy-addon{position:relative;background:transparent;height:55px !important;border:0;font-size:24px}.searchy-background .searchy-cover .searchy-box .input-group .searchy-input{margin:0;height:55px;border:0;background:transparent;font-size:24px}.searchy-background .searchy-cover .searchy-box .input-group .searchy-input:active{box-shadow:none}.searchy-background .searchy-cover .searchy-box .input-group .searchy-input:focus{box-shadow:none}.searchy-background .searchy-cover .searchy-box .input-group .searchy-input:hover{box-shadow:none}.searchy-background .searchy-cover .searchy-box .searchy-input-cover{position:absolute;height:55px;width:100%;left:0;top:0;z-index:8900}.searchy-background .searchy-cover .searchy-box .searchy-bottom{position:relative;border-top:1px solid #e0ddd8;padding:0;max-height:400px}.searchy-background .searchy-cover .searchy-box .searchy-bottom .searchy-results{border-right:1px solid #e4e4e4;overflow-x:hidden;overflow-y:scroll;padding:0;width:40%;display:inline-block;float:left}.searchy-background .searchy-cover .searchy-box .searchy-bottom .searchy-results .searchy-results-title{padding-left:12px;background-color:gainsboro;margin:0;padding-top:10px;padding-bottom:10px}.searchy-background .searchy-cover .searchy-box .searchy-bottom .searchy-results .searchy-result{padding-top:3px;padding-bottom:3px;padding-left:12px;vertical-align:middle}.searchy-background .searchy-cover .searchy-box .searchy-bottom .searchy-results .searchy-result h5{position:relative;max-width:90%;white-space:nowrap;text-overflow:clip;overflow:hidden;display:inline-block;line-height:normal !important;cursor:default}.searchy-background .searchy-cover .searchy-box .searchy-bottom .searchy-results .searchy-result a{float:right;color:#606060;margin-right:5px;display:inline-block;margin-top:10px}.searchy-background .searchy-cover .searchy-box .searchy-bottom .searchy-results .searchy-result:focus{outline:0}.searchy-background .searchy-cover .searchy-box .searchy-bottom .searchy-results .searchy-result.selected{outline:0}.searchy-background .searchy-cover .searchy-box .searchy-bottom .searchy-results .searchy-result.selected a{color:inherit}.searchy-background .searchy-cover .searchy-box .searchy-bottom .searchy-results .searchy-result.striped{background-color:#e4e4e4}.searchy-background .searchy-cover .searchy-box .searchy-bottom .searchy-results .searchy-result.striped.selected{outline:0}.searchy-background .searchy-cover .searchy-box .searchy-bottom .searchy-results .searchy-result.striped.selected a{color:inherit}.searchy-background .searchy-cover .searchy-box .searchy-bottom .searchy-results-preview{position:relative;display:inline-block;float:left;width:60%;padding:0;overflow-y:scroll;max-height:inherit}.searchy-background .searchy-cover .searchy-box .searchy-bottom .searchy-results-preview h5{margin:0;padding-top:10px;padding-bottom:10px}.searchy-background .searchy-cover .searchy-box .searchy-bottom .searchy-results-preview .searchy-preview-container{padding:10px}.searchy-background .searchy-cover .searchy-box .searchy-bottom .searchy-results-preview .searchy-results-preview-meta{border-top:1px solid #e4e4e4;padding-top:10px;padding-left:12px}.searchy-button{position:fixed;bottom:10px;right:10px;border-radius:50%;border:0;margin:auto;font-size:18px;height:45px;width:45px;-webkit-box-shadow:2px 3px 3px 0 rgba(41,41,41,0.3);-moz-box-shadow:2px 3px 3px 0 rgba(41,41,41,0.3);box-shadow:2px 3px 3px 0 rgba(41,41,41,0.3)}.searchy-button:hover{background-color:#ff4060}.searchy-button i{line-height:normal}
\ No newline at end of file
diff --git a/dist/searchy.min.js b/dist/searchy.min.js
new file mode 100644
index 0000000..96153e9
--- /dev/null
+++ b/dist/searchy.min.js
@@ -0,0 +1 @@
+!function(e){e.fn.searchyBox=function(s){var t=e.extend({appendTo:"body",dates:!1,draggable:!1,posts:[],index:{},floatingBtn:!1,placeHolder:"Search Blog",style:{background:"#579A00",text:"#eee"},shortcut:{key:32,modifier:"shiftKey"}},s);if(!(t.posts.length>0||t.index!=={}))throw"Missing required input!";var a=["shiftKey","ctrlKey","altKey"];if(a.indexOf(t.shortcut.modifier)===-1)throw"Illegal modifier: "+t.shortcut.modifier;if(void 0===t.shortcut.key||null===t.shortcut.key)throw"Illegal shortcut key:"+t.shortcut.key;e(t.appendTo).append('
'),t.floatingBtn&&(e(t.appendTo).append(' '),e(".searchy-button").click(function(){e(".searchy-background").fadeToggle(100,function(){"none"!==e(".searchy-background").css("display")?e(".searchy-input").focus():e(".searchy-input").blur()})})),e(t.appendTo).append("");var r=function(s){e(".searchy-result").each(function(){e(this).removeClass("selected"),e(this).attr("data-searchy-id")==s&&e(this).addClass("selected")});var a=t.posts[s];e(".searchy-results-preview").empty(),e(".searchy-results-preview").append('Preview
'),e(".searchy-preview-container").append(a.html),t.dates&&e(".searchy-results-preview").append('"),e(".searchy-input").focus()};return t.draggable&&e(".searchy-box").draggable({containment:".searchy-background",handle:".searchy-input-cover"}),e(document).keydown(function(s){if(s.which==t.shortcut.key)s[t.shortcut.modifier]&&(s.preventDefault(),e(".searchy-background").fadeToggle(100,function(){"none"!==e(".searchy-background").css("display")?e(".searchy-input").focus():e(".searchy-input").blur()}));else if("none"!==e(".searchy-background").css("display"))if(40==s.which||9==s.which&&s.shiftKey===!1){s.preventDefault();var a=-1,c=-1;e(".searchy-result").each(function(){e(this).attr("data-searchy-index")>c&&(c=e(this).attr("data-searchy-index")),e(this).hasClass("selected")&&(e(this).removeClass("selected"),a=e(this).attr("data-searchy-index"))}),a++,a>c&&(a=0),r(e("[data-searchy-index="+a+"]").attr("data-searchy-id"))}else if(38==s.which||9==s.which&&s.shiftKey===!0){s.preventDefault();var a=-1,c=-1;e(".searchy-result").each(function(){e(this).attr("data-searchy-index")>c&&(c=e(this).attr("data-searchy-index")),e(this).hasClass("selected")&&(e(this).removeClass("selected"),a=e(this).attr("data-searchy-index"))}),a--,a<0&&(a=c),r(e("[data-searchy-index="+a+"]").attr("data-searchy-id"))}else if(13==s.which){var i=e(".searchy-result.selected").children("a").attr("href");void 0!==i&&(e(".searchy-bottom").empty(),e(".searchy-background").hide(),window.location=i)}}),e(".searchy-background").on("click",function(s){s.target==e(this)[0]&&e(this).fadeToggle(100,function(){e("#searchy-input").blur()})}),e(".searchy-input-cover").on("click",function(s){e(".searchy-input").focus()}),e(".searchy-input").on("input",function(s){e(".searchy-bottom").empty();var a=t.index.search(e(this).val());if(a.length>0){e(".searchy-bottom").empty(),e(".searchy-bottom").append('
');for(var c=0,c=0;c'+n.title+" "),0==c&&r(i.ref)}}}),e(".searchy-input").keydown(function(e){40!=e.which&&38!=e.which||e.preventDefault()}),e(document).on("click",".searchy-result",function(s){var t=e(s.target).attr("data-searchy-id");void 0===t&&(t=e(s.target).parent().attr("data-searchy-id")),r(t)}),this}}(jQuery);
\ No newline at end of file
diff --git a/dist/searchyMcSearchBox.min.css b/dist/searchyMcSearchBox.min.css
deleted file mode 100644
index c0d69a7..0000000
--- a/dist/searchyMcSearchBox.min.css
+++ /dev/null
@@ -1 +0,0 @@
-.searchy-background{position:fixed;height:100vh;min-width:100%;z-index:8888;top:0;left:0;overflow:hidden;display:none}.searchy-background .searchy-cover{position:absolute;height:55px;width:80%;width:100%;max-width:700px;top:0;left:0;background-color:transparent;top:35%;left:50%;transform:translate(-50%,-50%)}.searchy-background .searchy-cover .searchy-box{background-color:rgba(246,246,246,0.99);position:absolute;border-radius:7px;z-index:-1;-webkit-box-shadow:0 14px 32px 0 rgba(0,0,0,0.75);-moz-box-shadow:0 14px 32px 0 rgba(0,0,0,0.75);box-shadow:0 14px 32px 0 rgba(0,0,0,0.75);clear:both;width:100%;max-width:700px}.searchy-background .searchy-cover .searchy-box .input-group .searchy-addon{position:relative;background:transparent;height:55px!important;border:none;font-size:24px}.searchy-background .searchy-cover .searchy-box .input-group .searchy-input{margin:0;height:55px;border:none;background:transparent;font-size:24px}.searchy-background .searchy-cover .searchy-box .input-group .searchy-input:active{box-shadow:none}.searchy-background .searchy-cover .searchy-box .input-group .searchy-input:focus{box-shadow:none}.searchy-background .searchy-cover .searchy-box .input-group .searchy-input:hover{box-shadow:none}.searchy-background .searchy-cover .searchy-box .searchy-input-cover{position:absolute;height:55px;width:100%;left:0;top:0;z-index:8900}.searchy-background .searchy-cover .searchy-box .searchy-bottom{position:relative;border-top:1px solid RGB(224,221,216);padding:0;max-height:400px}.searchy-background .searchy-cover .searchy-box .searchy-bottom .searchy-results{border-right:1px solid RGB(228,228,228);overflow-x:hidden;overflow-y:scroll;padding:0;width:40%;display:inline-block;float:left}.searchy-background .searchy-cover .searchy-box .searchy-bottom .searchy-results .searchy-results-title{padding-left:12px;background-color:gainsboro;margin:0;padding-top:10px;padding-bottom:10px}.searchy-background .searchy-cover .searchy-box .searchy-bottom .searchy-results .searchy-result{padding-top:3px;padding-bottom:3px;padding-left:12px;vertical-align:middle}.searchy-background .searchy-cover .searchy-box .searchy-bottom .searchy-results .searchy-result h5{position:relative;max-width:90%;white-space:nowrap;text-overflow:clip;overflow:hidden;display:inline-block;line-height:normal!important;cursor:default}.searchy-background .searchy-cover .searchy-box .searchy-bottom .searchy-results .searchy-result a{float:right;color:#606060;margin-right:5px;display:inline-block;margin-top:10px}.searchy-background .searchy-cover .searchy-box .searchy-bottom .searchy-results .searchy-result:focus{outline:none}.searchy-background .searchy-cover .searchy-box .searchy-bottom .searchy-results .searchy-result.selected{outline:none;background-color:#579A00;color:#eee}.searchy-background .searchy-cover .searchy-box .searchy-bottom .searchy-results .searchy-result.selected a{color:#eee}.searchy-background .searchy-cover .searchy-box .searchy-bottom .searchy-results .searchy-result.striped{background-color:#e4e4e4}.searchy-background .searchy-cover .searchy-box .searchy-bottom .searchy-results .searchy-result.striped.selected{outline:none;background-color:#579A00;color:#eee}.searchy-background .searchy-cover .searchy-box .searchy-bottom .searchy-results .searchy-result.striped.selected a{color:#eee}.searchy-background .searchy-cover .searchy-box .searchy-bottom .searchy-results-preview{position:relative;display:inline-block;float:left;width:60%;padding:0;overflow-y:scroll;max-height:inherit}.searchy-background .searchy-cover .searchy-box .searchy-bottom .searchy-results-preview h5{margin:0;padding-top:10px;padding-bottom:10px}.searchy-background .searchy-cover .searchy-box .searchy-bottom .searchy-results-preview .searchy-preview-container{padding:10px}.searchy-background .searchy-cover .searchy-box .searchy-bottom .searchy-results-preview .searchy-results-preview-meta{border-top:1px solid RGB(228,228,228);padding-top:10px;padding-left:12px}.searchy-button{position:fixed;bottom:10px;right:10px;border-radius:50%;border:none;margin:auto;background-color:#579A00;color:#eee;font-size:18px;height:45px;width:45px;-webkit-box-shadow:2px 3px 3px 0 rgba(41,41,41,0.3);-moz-box-shadow:2px 3px 3px 0 rgba(41,41,41,0.3);box-shadow:2px 3px 3px 0 rgba(41,41,41,0.3)}.searchy-button:hover{background-color:#ff4060}.searchy-button i{line-height:normal}
\ No newline at end of file
diff --git a/dist/searchyMcSearchBox.min.js b/dist/searchyMcSearchBox.min.js
deleted file mode 100644
index c91e7cd..0000000
--- a/dist/searchyMcSearchBox.min.js
+++ /dev/null
@@ -1,27 +0,0 @@
-(function($){$.fn.searchyBox=function(options){var settings=$.extend({appendTo:"body",dates:false,draggable:false,posts:[],idx:{},floatingBtn:false},options);$(settings.appendTo).append('')
-if(settings.floatingBtn){$(settings.appendTo).append(' ')
-$(".searchy-button").click(function(){$(".searchy-background").fadeToggle(100,function(){if($(".searchy-background").css('display')!=="none"){$(".searchy-input").focus();}
-else{$(".searchy-input").blur();}});})}
-var selectPost=function(id){$(".searchy-result").each(function(){$(this).removeClass("selected");if($(this).attr("data-searchy-id")==id){$(this).addClass("selected");}})
-var post=settings.posts[id];$(".searchy-results-preview").empty();$(".searchy-results-preview").append('Preview
');$(".searchy-preview-container").append(post.html);if(settings.dates){$(".searchy-results-preview").append('");}
-$('.searchy-input').focus();}
-if(settings.draggable){$(".searchy-box").draggable({containment:".searchy-background",handle:".searchy-input-cover"});}
-$(document).keydown(function(e){if(e.which==32){if(e.shiftKey){e.preventDefault();$(".searchy-background").fadeToggle(100,function(){if($(".searchy-background").css('display')!=="none"){$(".searchy-input").focus();}
-else{$(".searchy-input").blur();}})}}
-else if($(".searchy-background").css('display')!=="none"){if(e.which==40||(e.which==9&&e.shiftKey===false)){e.preventDefault();var index=-1;var max=-1;$(".searchy-result").each(function(){if($(this).attr("data-searchy-index")>max){max=$(this).attr("data-searchy-index");}
-if($(this).hasClass("selected")){$(this).removeClass("selected");index=$(this).attr("data-searchy-index");}})
-index++;if(index>max){index=0;}
-selectPost($("[data-searchy-index="+index+"]").attr("data-searchy-id"));}
-else if(e.which==38||(e.which==9&&e.shiftKey===true)){e.preventDefault();var index=-1;var max=-1;$(".searchy-result").each(function(){if($(this).attr("data-searchy-index")>max){max=$(this).attr("data-searchy-index");}
-if($(this).hasClass("selected")){$(this).removeClass("selected");index=$(this).attr("data-searchy-index");}})
-index--;if(index<0){index=max;}
-selectPost($("[data-searchy-index="+index+"]").attr("data-searchy-id"));}
-else if(e.which==13){console.log($(".searchy-result.selected").children('a').attr("href"));var href=$(".searchy-result.selected").children('a').attr("href");$(".searchy-bottom").empty();$('.searchy-background').hide()
-window.location=href;}}});$(".searchy-background").on("click",function(e){if(e.target==$(this)[0]){$(this).fadeToggle(100,function(){$("#searchy-input").blur();});}});$(".searchy-input-cover").on("click",function(e){$(".searchy-input").focus();});$(".searchy-input").on("input",function(e){$(".searchy-bottom").empty();var results=settings.idx.search($(this).val());if(results.length>0){$(".searchy-bottom").empty();$(".searchy-bottom").append('
')
-var i=0;for(var result of results){var post=settings.posts[result.ref]
-var striped="";if((i%2)==1){striped="striped";}
-$(".searchy-results").append('")
-if(i==0){selectPost(result.ref);}
-i++;}}});$(".searchy-input").keydown(function(e){if(e.which==40||e.which==38){e.preventDefault();}});$(document).on('click',".searchy-result",function(e){var id=$(e.target).attr("data-searchy-id")
-if(id===undefined){id=$(e.target).parent().attr("data-searchy-id")}
-selectPost(id);});return this;};}(jQuery));
diff --git a/gulpfile.js b/gulpfile.js
new file mode 100644
index 0000000..c854b34
--- /dev/null
+++ b/gulpfile.js
@@ -0,0 +1,26 @@
+'use strict';
+
+var gulp = require('gulp'),
+ rename = require('gulp-rename'),
+ uglify_js = require('gulp-uglify'),
+ uglify_css = require('gulp-uglifycss'),
+ sass = require('gulp-sass');
+
+gulp.task('build',function() {
+ gulp
+ .src('src/searchy.js')
+ .pipe(uglify_js())
+ .pipe(rename('searchy.min.js'))
+ .pipe(gulp.dest('dist/'));
+
+ gulp
+ .src('src/searchy.scss')
+ .pipe(sass())
+ .pipe(uglify_css())
+ .pipe(rename('searchy.min.css'))
+ .pipe(gulp.dest('dist/'));
+});
+
+
+gulp.task('default',['build'])
+
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..db5f61d
--- /dev/null
+++ b/package.json
@@ -0,0 +1,34 @@
+{
+ "name": "searchy.js",
+ "version": "1.0.0",
+ "homepage": "https://github.com/pjtatlow/searchy.js",
+ "authors": [
+ "PJ Tatlow"
+ ],
+ "description": "JQuery and Lunr.js blog search plugin",
+ "main": "dist/searchy.min.js",
+ "keywords": [
+ "blog",
+ "search",
+ "Searchy McSearchBox"
+ ],
+ "devDependencies": {
+ "gulp": "^3.8.10",
+ "gulp-rename": "^1.2.0",
+ "gulp-uglify": "^1.1.0",
+ "gulp-sass": "^2.3.0",
+ "gulp-uglifycss": "^1.0.0"
+ },
+ "scripts": {
+ "test": "echo \"Error: no test specified\" && exit 1"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/pjtatlow/searchy.js.git"
+ },
+ "author": "PJ Tatlow",
+ "license": "MIT",
+ "bugs": {
+ "url": "https://github.com/pjtatlow/searchy.js/issues"
+ }
+}
diff --git a/src/searchy.js b/src/searchy.js
new file mode 100644
index 0000000..b269c44
--- /dev/null
+++ b/src/searchy.js
@@ -0,0 +1,202 @@
+
+(function( $ ) {
+
+ $.fn.searchyBox = function(options) {
+
+ var settings = $.extend({
+ appendTo: "body",
+ dates: false,
+ draggable: false,
+ posts : [],
+ index : {},
+ floatingBtn: false,
+ placeHolder: "Search Blog",
+ style: {
+ background: "#579A00",
+ text: "#eee"
+ },
+ shortcut: {
+ key: 32,
+ modifier: "shiftKey"
+ }
+ }, options );
+
+ if (settings.posts.length > 0 || settings.index !== {}) {
+
+ var legalModifers = ["shiftKey","ctrlKey","altKey"];
+ if (legalModifers.indexOf(settings.shortcut.modifier) === -1) {
+ throw "Illegal modifier: " + settings.shortcut.modifier
+ }
+ else if (settings.shortcut.key === undefined || settings.shortcut.key === null) {
+ throw "Illegal shortcut key:" + settings.shortcut.key
+ }
+ $(settings.appendTo).append('')
+
+ if (settings.floatingBtn) {
+ $(settings.appendTo).append(' ')
+ $(".searchy-button").click(function() {
+ $(".searchy-background").fadeToggle(100, function() {
+ if ($(".searchy-background").css('display') !== "none") {
+ $(".searchy-input").focus();
+ }
+ else {
+ $(".searchy-input").blur();
+ }
+ });
+ })
+ }
+
+ $(settings.appendTo).append("")
+
+ var selectPost = function(id) {
+ $(".searchy-result").each(function() {
+ $(this).removeClass("selected");
+ if ($(this).attr("data-searchy-id") == id) {
+ $(this).addClass("selected");
+ }
+ })
+ var post = settings.posts[id];
+ $(".searchy-results-preview").empty();
+ $(".searchy-results-preview").append('Preview
');
+ $(".searchy-preview-container").append(post.html);
+ if (settings.dates) {
+ $(".searchy-results-preview").append('");
+ }
+ $('.searchy-input').focus();
+ }
+
+ if (settings.draggable) {
+ $(".searchy-box").draggable({
+ containment: ".searchy-background",
+ handle: ".searchy-input-cover"
+ }); // make searchy-bar draggable
+ }
+
+ $(document).keydown(function(e) {
+ if (e.which == settings.shortcut.key) { // shortcut key
+ if (e[settings.shortcut.modifier]) { // checks to make sure modifier is active
+ e.preventDefault();
+ $(".searchy-background").fadeToggle(100, function() {
+ if ($(".searchy-background").css('display') !== "none") {
+ $(".searchy-input").focus();
+ }
+ else {
+ $(".searchy-input").blur();
+ }
+ })
+ }
+ }
+ else if ($(".searchy-background").css('display') !== "none") {
+ if (e.which == 40 || (e.which == 9 && e.shiftKey === false)) { // down arrow
+ e.preventDefault();
+ var index = -1;
+ var max = -1;
+ $(".searchy-result").each(function() {
+ if ($(this).attr("data-searchy-index") > max) {
+ max = $(this).attr("data-searchy-index");
+ }
+ if ($(this).hasClass("selected")) {
+ $(this).removeClass("selected");
+ index = $(this).attr("data-searchy-index");
+ }
+ })
+ index++;
+ if (index > max) {
+ index = 0;
+ }
+ selectPost($("[data-searchy-index="+ index + "]").attr("data-searchy-id"));
+
+ }
+ else if (e.which == 38 || (e.which == 9 && e.shiftKey === true)) { // up arrow
+
+ e.preventDefault();
+ var index = -1;
+ var max = -1;
+ $(".searchy-result").each(function() {
+ if ($(this).attr("data-searchy-index") > max) {
+ max = $(this).attr("data-searchy-index");
+ }
+ if ($(this).hasClass("selected")) {
+ $(this).removeClass("selected");
+ index = $(this).attr("data-searchy-index");
+ }
+ })
+ index--;
+ if (index < 0) {
+ index = max;
+ }
+
+ selectPost($("[data-searchy-index="+ index + "]").attr("data-searchy-id"));
+ }
+ else if (e.which == 13) {
+ var href = $(".searchy-result.selected").children('a').attr("href");
+ if (href !== undefined) {
+ $(".searchy-bottom").empty();
+ $('.searchy-background').hide()
+ window.location = href;
+ }
+ }
+ }
+
+ }); // watch for SHIFT + SPACE and arrow up and down
+
+ $(".searchy-background").on("click",function(e) {
+ if (e.target == $(this)[0]) {
+ $(this).fadeToggle(100, function() {
+ $("#searchy-input").blur();
+ });
+ }
+ }); // close when you click outside of
+
+ $(".searchy-input-cover").on("click",function(e) {
+ $(".searchy-input").focus();
+ }); // focus on input box when you click anywhere on the searchy bar
+
+ $(".searchy-input").on("input",function(e) {
+ $(".searchy-bottom").empty();
+ var results = settings.index.search($(this).val());
+ if (results.length > 0) {
+ $(".searchy-bottom").empty();
+ $(".searchy-bottom").append('
')
+ var i = 0;
+ for (var i=0;i' + post.title + " ")
+ if (i == 0) {
+ selectPost(result.ref);
+ }
+ }
+ }
+ });
+
+ $(".searchy-input").keydown(function(e) {
+ if (e.which == 40 || e.which == 38) {
+ e.preventDefault();
+ }
+ });
+
+
+
+ $(document).on('click',".searchy-result",function(e) {
+ var id = $(e.target).attr("data-searchy-id")
+ if (id === undefined) {
+ id = $(e.target).parent().attr("data-searchy-id")
+ }
+ selectPost(id);
+ });
+ }
+ else {
+ throw "Missing required input!";
+ }
+ return this;
+ };
+
+
+}( jQuery ));
diff --git a/src/searchyMcSearchBox.scss b/src/searchy.scss
similarity index 93%
rename from src/searchyMcSearchBox.scss
rename to src/searchy.scss
index a25169a..218b306 100644
--- a/src/searchyMcSearchBox.scss
+++ b/src/searchy.scss
@@ -1,4 +1,3 @@
-$brand-primary: #579A00 !default;
.searchy-background {
position: fixed;
height: 100vh;
@@ -131,20 +130,16 @@ $brand-primary: #579A00 !default;
}
&.selected {
outline: none;
- background-color: $brand-primary;
- color: #eee;
a {
- color: #eee;
+ color: inherit;
}
}
&.striped {
background-color: rgb(228,228,228);
&.selected {
outline: none;
- background-color: $brand-primary;
- color: #eee;
a {
- color: #eee;
+ color: inherit;
}
}
}
@@ -197,8 +192,6 @@ $brand-primary: #579A00 !default;
border-radius: 50%;
border: none;
margin: auto;
- background-color: $brand-primary;
- color: #eee;
font-size: 18px;
height: 45px;
width: 45px;
diff --git a/src/searchyMcSearchBox.js b/src/searchyMcSearchBox.js
deleted file mode 100644
index 7f2a675..0000000
--- a/src/searchyMcSearchBox.js
+++ /dev/null
@@ -1,177 +0,0 @@
-
-(function( $ ) {
-
- $.fn.searchyBox = function(options) {
-
- var settings = $.extend({
- appendTo: "body",
- dates: false,
- draggable: false,
- posts : [],
- idx : {},
- floatingBtn: false
- }, options );
-
- $(settings.appendTo).append('')
-
- if (settings.floatingBtn) {
- $(settings.appendTo).append(' ')
- $(".searchy-button").click(function() {
- $(".searchy-background").fadeToggle(100, function() {
- if ($(".searchy-background").css('display') !== "none") {
- $(".searchy-input").focus();
- }
- else {
- $(".searchy-input").blur();
- }
- });
- })
- }
-
-
- var selectPost = function(id) {
- $(".searchy-result").each(function() {
- $(this).removeClass("selected");
- if ($(this).attr("data-searchy-id") == id) {
- $(this).addClass("selected");
- }
- })
-
- var post = settings.posts[id];
-
- $(".searchy-results-preview").empty();
- $(".searchy-results-preview").append('Preview
');
- $(".searchy-preview-container").append(post.html);
- if (settings.dates) {
- $(".searchy-results-preview").append('");
- }
- $('.searchy-input').focus();
- }
-
- if (settings.draggable) {
- $(".searchy-box").draggable({
- containment: ".searchy-background",
- handle: ".searchy-input-cover"
- }); // make searchy-bar draggable
- }
- $(document).keydown(function(e) {
- if (e.which == 32) { // spacebar
- if (e.shiftKey) {
- e.preventDefault();
- $(".searchy-background").fadeToggle(100, function() {
- if ($(".searchy-background").css('display') !== "none") {
- $(".searchy-input").focus();
- }
- else {
- $(".searchy-input").blur();
- }
- })
- }
- }
- else if ($(".searchy-background").css('display') !== "none") {
- if (e.which == 40 || (e.which == 9 && e.shiftKey === false)) { // down arrow
- e.preventDefault();
- var index = -1;
- var max = -1;
- $(".searchy-result").each(function() {
- if ($(this).attr("data-searchy-index") > max) {
- max = $(this).attr("data-searchy-index");
- }
- if ($(this).hasClass("selected")) {
- $(this).removeClass("selected");
- index = $(this).attr("data-searchy-index");
- }
- })
- index++;
- if (index > max) {
- index = 0;
- }
- selectPost($("[data-searchy-index="+ index + "]").attr("data-searchy-id"));
-
- }
- else if (e.which == 38 || (e.which == 9 && e.shiftKey === true)) { // up arrow
-
- e.preventDefault();
- var index = -1;
- var max = -1;
- $(".searchy-result").each(function() {
- if ($(this).attr("data-searchy-index") > max) {
- max = $(this).attr("data-searchy-index");
- }
- if ($(this).hasClass("selected")) {
- $(this).removeClass("selected");
- index = $(this).attr("data-searchy-index");
- }
- })
- index--;
- if (index < 0) {
- index = max;
- }
-
- selectPost($("[data-searchy-index="+ index + "]").attr("data-searchy-id"));
- }
- else if (e.which == 13) {
- console.log($(".searchy-result.selected").children('a').attr("href"));
- var href = $(".searchy-result.selected").children('a').attr("href");
- $(".searchy-bottom").empty();
- $('.searchy-background').hide()
- window.location = href;
- }
- }
-
- }); // watch for SHIFT + SPACE and arrow up and down
-
- $(".searchy-background").on("click",function(e) {
- if (e.target == $(this)[0]) {
- $(this).fadeToggle(100, function() {
- $("#searchy-input").blur();
- });
- }
- }); // close when you click outside of
-
- $(".searchy-input-cover").on("click",function(e) {
- $(".searchy-input").focus();
- }); // focus on input box when you click anywhere on the searchy bar
-
- $(".searchy-input").on("input",function(e) {
- $(".searchy-bottom").empty();
- var results = settings.idx.search($(this).val());
- if (results.length > 0) {
- $(".searchy-bottom").empty();
- $(".searchy-bottom").append('
')
- var i = 0;
- for (var result of results) {
- var post = settings.posts[result.ref]
- var striped = "";
- if ((i % 2) == 1) {
- striped = "striped";
- }
- $(".searchy-results").append('")
- if (i == 0) {
- selectPost(result.ref);
- }
- i++;
- }
- }
- });
-
- $(".searchy-input").keydown(function(e) {
- if (e.which == 40 || e.which == 38) {
- e.preventDefault();
- }
- });
-
-
-
- $(document).on('click',".searchy-result",function(e) {
- var id = $(e.target).attr("data-searchy-id")
- if (id === undefined) {
- id = $(e.target).parent().attr("data-searchy-id")
- }
- selectPost(id);
- });
- return this;
-
- };
-
-}( jQuery ));