Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Javascript refactoring, add search field to index
- Loading branch information
Showing
16 changed files
with
212 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"root": true, | ||
"extends": "airbnb", | ||
"globals": { | ||
"wp": true | ||
}, | ||
"env": { | ||
"amd": true, | ||
"browser": true, | ||
"jquery": true, | ||
"node": true | ||
}, | ||
"parser": "babel-eslint" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
preset: laravel | ||
|
||
risky: true | ||
|
||
enabled: | ||
- unalign_double_arrow | ||
- combine_consecutive_unsets | ||
- concat_with_spaces | ||
- dir_constant | ||
- ereg_to_preg | ||
- linebreak_after_opening_tag | ||
- modernize_types_casting | ||
- no_blank_lines_before_namespace | ||
- no_empty_comment | ||
- no_php4_constructor | ||
- no_short_echo_tag | ||
- no_useless_else | ||
- ordered_class_elements | ||
- ordered_imports | ||
- php_unit_construct | ||
- php_unit_dedicate_assert | ||
- php_unit_strict | ||
- phpdoc_order | ||
- phpdoc_property | ||
- phpdoc_separation | ||
- random_api_migration | ||
- semicolon_after_instruction | ||
- strict_comparison | ||
- strict_param | ||
|
||
disabled: | ||
- concat_without_spaces | ||
- single_blank_line_before_namespace | ||
- not_operator_with_successor_space |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 25 additions & 32 deletions
57
public/build/js/app-a09bb827c1.js → public/build/js/app-b10bd0110d.js
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"css/app.css": "css/app-7af4a9b9dd.css", | ||
"js/app.js": "js/app-a09bb827c1.js" | ||
"js/app.js": "js/app-b10bd0110d.js" | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,34 @@ | ||
|
||
/** | ||
* First we will load all of this project's JavaScript dependencies which | ||
* include Vue and Vue Resource. This gives a great starting point for | ||
* building robust, powerful web applications using Vue and Laravel. | ||
*/ | ||
|
||
import './bootstrap.es6'; | ||
|
||
/** | ||
* Setup the routes of the application to allow for class-based | ||
* controllers. CommonController is always fired regardless of page classes, | ||
* class names should be the camel cased name, ie. post-25 -> Post25. | ||
*/ | ||
|
||
import Router from './util/Router.es6'; | ||
import CommonController from './controllers/CommonController.es6'; | ||
import PostController from './controllers/PostController.es6'; | ||
|
||
document.addEventListener('DOMContentLoaded', () => new Router([ | ||
new CommonController, | ||
new PostController | ||
]).loadEvents()); | ||
|
||
/** | ||
* Next, we will create a fresh Vue application instance and attach it to | ||
* the body of the page. From here, you may begin adding components to | ||
* the application, or feel free to tweak this setup for your needs. | ||
*/ | ||
|
||
Vue.component('example', require('./components/Example.vue')); | ||
Vue.component('rabbit', require('./components/Rabbit.vue')); | ||
// Vue.component('example', require('./components/Example.vue')); | ||
|
||
const app = new Vue({ | ||
el: '#app' | ||
}); | ||
// const app = new Vue({ | ||
// el: '#app' | ||
// }); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/** | ||
* This controller is fired on every pageload. | ||
*/ | ||
export default class CommonController { | ||
init() { | ||
|
||
} | ||
|
||
finalize() { | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/** | ||
* This controller is fired on post pageload. | ||
*/ | ||
export default class PostController { | ||
init() { | ||
|
||
} | ||
|
||
finalize() { | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import _ from 'lodash'; | ||
|
||
export default class Router { | ||
constructor(routes) { | ||
this.routes = Object.assign(...routes.map(d => ({ [d.constructor.name]: d }))); | ||
} | ||
|
||
fire(route, fn = 'init', args = []) { | ||
const fire = route !== '' && this.routes[route] | ||
&& typeof this.routes[route][fn] === 'function'; | ||
|
||
if (fire) { | ||
this.routes[route][fn](...args); | ||
} | ||
} | ||
|
||
loadEvents() { | ||
// Fire common init JS | ||
this.fire('CommonController'); | ||
|
||
// Fire page-specific init JS, and then finalize JS | ||
document.body.className | ||
.split(/\s+/g) | ||
.map(_.camelCase) | ||
.map(_.upperFirst) | ||
.map((v) => v.concat('Controller')) | ||
.forEach((className) => { | ||
console.log(className); | ||
this.fire(className); | ||
this.fire(className, 'finalize'); | ||
}); | ||
|
||
// Fire common finalize JS | ||
this.fire('CommonController', 'finalize'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<form role="search" method="get" class="search-form" action="{{ url('/') }}"> | ||
<div class="input-group col-md-4 pull-right"> | ||
<input type="search" class="search-field form-control" placeholder="Search …" value="{{ Request::get('s') }}" name="s"> | ||
<span class="input-group-btn"> | ||
<button class="btn btn-default" type="button">Search</button> | ||
</span> | ||
</div> | ||
</form> | ||
|
||
<div class="clearfix" style="margin-bottom: 10px;"></div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters