-
{{ gname }}
+
{{ gname }}
-
-
{{ data.name }}
+
+ {{ data.name }}
@@ -133,6 +133,21 @@
name: 'CONTAINER_VIEW',
data(){
return { gstore: gstore.get }
+ },
+ beforeMount(){
+
+ // set onblur to hide filter
+ window.onblur.link('teacher.filter', (e) => {
+
+ // ignore [data-unblur-filter] elements
+ if( e.target.getAttribute('data-unblur-filter') !== null )
+ return;
+
+ // else: hide
+ gstore.get.show_fgroup(-1);
+
+ });
+
}
}
diff --git a/webpack/data/common.js b/webpack/data/common.js
index 4ba3139..70e9b69 100644
--- a/webpack/data/common.js
+++ b/webpack/data/common.js
@@ -1,6 +1,7 @@
-import {GlobalStore} from '../lib/gstore'
-import {APIClient} from '../lib/api-client'
-import {PopUp} from '../lib/pop-up'
+import {GlobalStore} from '../lib/gstore'
+import {APIClient} from '../lib/api-client'
+import {PopUp} from '../lib/pop-up'
+import {OnBlurManager} from '../lib/onblur'
require('../lib/css-class-override')
window.gstore = new GlobalStore();
@@ -20,6 +21,10 @@ window.api = new APIClient(gstore.get.is_local ? 'http://ptut.com:8080/api/v/1.0
/* (4) PopUp instance */
window.popup = new PopUp();
+/* (5) Create class in window */
+window.onblur = new OnBlurManager(document.body);
+
+
/* (2) Main components
diff --git a/webpack/lib/onblur.js b/webpack/lib/onblur.js
new file mode 100644
index 0000000..71a3e52
--- /dev/null
+++ b/webpack/lib/onblur.js
@@ -0,0 +1,81 @@
+/* OnBlur Manager Class */
+export class OnBlurManager{
+
+ /* (1) Initialize an OnBlurManager
+ *
+ * @root
The root element to work in
+ *
+ ---------------------------------------------------------*/
+ constructor(root){
+
+ /* (1) Error: invalid @root argument */
+ if( !(root instanceof Element) )
+ throw new Error(`[OnBlurManager::new] expected argument to be of type (Element), received (${typeof root})`);
+
+ /* (2) Store as attribute */
+ this.root = root;
+
+ /* (3) Initialize @callback list */
+ this.callback = {};
+
+ /* (4) Bind to event */
+ this.root.addEventListener('click', function(e){
+
+ // launch each callback
+ for( var c of Object.keys(this.callback) )
+ this.callback[c](e);
+
+ }.bind(this) );
+
+
+ }
+
+
+
+
+ /* (2) Add a @callback
+ *
+ * @index String to name the callback for removing
+ * @callback Function to link to callback
+ *
+ * @return linked Whether the callback has been linked
+ *
+ ---------------------------------------------------------*/
+ link(index, callback){
+
+ /* (1) Fail: invalid @index or @callback arguments */
+ if( typeof index !== 'string' || !(callback instanceof Function) ){
+ console.error(`[OnBlurManager::link] expected (String, Function), received (${typeof index}, ${typeof callback})`);
+ return false;
+ }
+
+ /* (2) Add to list of callbacks */
+ return ( this.callback[index] = callback ) instanceof Function;
+
+ }
+
+
+
+
+ /* (3) Unlink a @callback
+ *
+ * @index Name of the callback to remove
+ *
+ * @return unlinked Whether the callback has been unlinked
+ *
+ ---------------------------------------------------------*/
+ unlink(index, callback){
+
+ /* (1) Fail: invalid @index argument */
+ if( typeof index !== 'string' ){
+ console.error(`[OnBlurManager::unlink] expected (String), received (${typeof index})`);
+ return false;
+ }
+
+ /* (2) Remove from list of callbacks */
+ return ( delete this.callback[index] );
+
+ }
+
+
+}
\ No newline at end of file
diff --git a/webpack/vue/header.vue b/webpack/vue/header.vue
index f258283..5db7a07 100644
--- a/webpack/vue/header.vue
+++ b/webpack/vue/header.vue
@@ -3,21 +3,21 @@