ohzi-core 6.6.1 → 6.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ohzi-core",
3
- "version": "6.6.1",
3
+ "version": "6.7.0",
4
4
  "description": "OHZI Core Library",
5
5
  "source": "src/index.js",
6
6
  "module": "build/index.module.js",
@@ -11,6 +11,8 @@ class ViewManager
11
11
  this.transition_handler = new ViewStateTransitionHandler(this.transition_table);
12
12
 
13
13
  this.view_change_subscribers = [];
14
+
15
+ this.browser_title_suffix = '';
14
16
  }
15
17
 
16
18
  update()
@@ -28,6 +30,7 @@ class ViewManager
28
30
  if (change_url)
29
31
  {
30
32
  this.__change_browser_url(v.url);
33
+ this.__change_browser_title(v.url);
31
34
  }
32
35
 
33
36
  this.notify_view_change(view_name);
@@ -81,6 +84,11 @@ class ViewManager
81
84
  this.transition_handler.set_state(view);
82
85
  }
83
86
 
87
+ set_browser_title_suffix(title_suffix)
88
+ {
89
+ this.browser_title_suffix = title_suffix;
90
+ }
91
+
84
92
  get_current_view()
85
93
  {
86
94
  return this.transition_handler.current_state;
@@ -135,6 +143,13 @@ class ViewManager
135
143
  window.history.pushState('', '', url);
136
144
  }
137
145
 
146
+ __change_browser_title(name)
147
+ {
148
+ const title = this.__capitalize(name);
149
+
150
+ document.title = title ? `${title} | ${this.browser_title_suffix}` : this.browser_title_suffix;
151
+ }
152
+
138
153
  __set_views_opacities()
139
154
  {
140
155
  for (let i = 0; i < this.views.length; i++)
@@ -142,6 +157,24 @@ class ViewManager
142
157
  this.views[i].set_opacity(this.transition_handler.current_state_data);
143
158
  }
144
159
  }
160
+
161
+ __capitalize(string)
162
+ {
163
+ let aux_string = string.toUpperCase().replace('/', '');
164
+ aux_string = this.__snake_to_whitespace(aux_string);
165
+
166
+ return aux_string;
167
+ }
168
+
169
+ __snake_to_whitespace(string)
170
+ {
171
+ return string.replace(
172
+ /([-_][A-Z])/g,
173
+ (group) => group
174
+ .replace('-', ' ')
175
+ .replace('_', ' ')
176
+ );
177
+ }
145
178
  }
146
179
 
147
180
  export default new ViewManager();