Browse Source

more work on configurable time format

sisyphus
Dustin Falgout 8 years ago
parent
commit
7affd4dd01
  1. 6
      src/gresource/js/Greeter.js
  2. 16
      src/gresource/js/LightDMObjects.js
  3. 2
      src/gresource/js/ThemeHeartbeat.js
  4. 62
      src/gresource/js/ThemeUtils.js
  5. 5
      themes/antergos/js/greeter.js

6
src/gresource/js/Greeter.js

@ -30,7 +30,7 @@
* Base class for the greeter's JavaScript Theme API. Greeter themes will interact * Base class for the greeter's JavaScript Theme API. Greeter themes will interact
* directly with an object derived from this class to facilitate the user log-in process. * directly with an object derived from this class to facilitate the user log-in process.
* The greeter will automatically create an instance when it starts. * The greeter will automatically create an instance when it starts.
* The instance can be accessed using the global variable: `lightdm`. * The instance can be accessed using the global variable: `lightdm` ({@link window.lightdm}).
* *
* @memberOf LightDM * @memberOf LightDM
*/ */
@ -266,9 +266,7 @@ class Greeter {
* Triggers the system to restart. * Triggers the system to restart.
* @returns {Boolean} {@link true} if restart initiated, otherwise {@link false} * @returns {Boolean} {@link true} if restart initiated, otherwise {@link false}
*/ */
restart() { restart() {}
return this._do_mocked_system_action('restart');
}
/** /**
* Set the language for the currently authenticated user. * Set the language for the currently authenticated user.

16
src/gresource/js/LightDMObjects.js

@ -31,10 +31,10 @@
/** /**
* Interface for object that holds info about a session. Session objects are not * Interface for object that holds info about a session. Session objects are not
* created by the theme's code, but rather by the {@link LightDMGreeter} class. * created by the theme's code, but rather by the {@link LightDM.Greeter} class.
* @memberOf LightDM * @memberOf LightDM
*/ */
class LightDMSession { class Session {
constructor( { comment, key, name } ) { constructor( { comment, key, name } ) {
/** /**
* The comment for the session. * The comment for the session.
@ -62,10 +62,10 @@ class LightDMSession {
/** /**
* Interface for object that holds info about a language on the system. Language objects are not * Interface for object that holds info about a language on the system. Language objects are not
* created by the theme's code, but rather by the {@link LightDMGreeter} class. * created by the theme's code, but rather by the {@link LightDM.Greeter} class.
* @memberOf LightDM * @memberOf LightDM
*/ */
class LightDMLanguage { class Language {
constructor( { code, name, territory } ) { constructor( { code, name, territory } ) {
/** /**
* The code for the language. * The code for the language.
@ -93,10 +93,10 @@ class LightDMLanguage {
/** /**
* Interface for object that holds info about a keyboard layout on the system. Language * Interface for object that holds info about a keyboard layout on the system. Language
* objects are not created by the theme's code, but rather by the {@link LightDMGreeter} class. * objects are not created by the theme's code, but rather by the {@link LightDM.Greeter} class.
* @memberOf LightDM * @memberOf LightDM
*/ */
class LightDMLayout { class Layout {
constructor( { description, name, short_description } ) { constructor( { description, name, short_description } ) {
/** /**
* The description for the layout. * The description for the layout.
@ -124,10 +124,10 @@ class LightDMLayout {
/** /**
* Interface for object that holds info about a user account on the system. User * Interface for object that holds info about a user account on the system. User
* objects are not created by the theme's code, but rather by the {@link LightDMGreeter} class. * objects are not created by the theme's code, but rather by the {@link LightDM.Greeter} class.
* @memberOf LightDM * @memberOf LightDM
*/ */
class LightDMUser { class User {
constructor( user_info ) { constructor( user_info ) {
/** /**
* The display name for the user. * The display name for the user.

2
src/gresource/js/ThemeHeartbeat.js

@ -1,5 +1,5 @@
/* /*
* heartbeat.js * ThemeHeartbeat.js
* *
* Copyright © 2016 Antergos Developers <dev@antergos.com> * Copyright © 2016 Antergos Developers <dev@antergos.com>
* *

62
src/gresource/js/ThemeUtils.js

@ -25,6 +25,14 @@
* along with lightdm-webkit2-greeter; If not, see <http://www.gnu.org/licenses/>. * along with lightdm-webkit2-greeter; If not, see <http://www.gnu.org/licenses/>.
*/ */
if ( 'undefined' === typeof window.navigator.languages ) {
window.navigator.languages = [ window.navigator.language ];
}
moment.locale( window.navigator.languages );
let localized_invalid_date = moment('today', '!@#');
/** /**
* @namespace LightDM * @namespace LightDM
*/ */
@ -32,7 +40,7 @@
/** /**
* Provides various utility methods for use by theme authors. The greeter will automatically * Provides various utility methods for use by theme authors. The greeter will automatically
* create an instance of this class when it starts. The instance can be accessed * create an instance of this class when it starts. The instance can be accessed
* with the global variable: `theme_utils`. * with the global variable: `theme_utils` ({@link window.theme_utils}).
* *
* @memberOf LightDM * @memberOf LightDM
*/ */
@ -44,7 +52,7 @@ class ThemeUtils {
* *
* @return {function(new:*): Object} `context` with `this` bound to it for all of its methods. * @return {function(new:*): Object} `context` with `this` bound to it for all of its methods.
*/ */
static bind_this( context ) { bind_this( context ) {
let excluded_methods = ['constructor']; let excluded_methods = ['constructor'];
function not_excluded( _method, _context ) { function not_excluded( _method, _context ) {
@ -67,6 +75,55 @@ class ThemeUtils {
} }
} }
} }
/**
* Returns the contents of directory found at `path` provided that the (normalized) `path`
* meets at least one of the following conditions:
* * Is located within the greeter themes' root directory.
* * Has been explicitly allowed in the greeter's config file.
* * Is located within the greeter's shared data directory (`/var/lib/lightdm-data`)
*
* @param {String} path The abs path to desired directory.
*
* @returns {String[]} List of abs paths for the files and directories found in `path`.
*/
dirlist( path ) {}
/**
* Escape HTML entities in a string.
*
* @param {String} text The text to be escaped.
*
* @returns {String}
*/
esc_html( text ) {}
/**
* Get the current time in a localized format based on the `time_format` config file key.
* * When `time_format` has a valid value, time will be formatted
* according to that value.
* * When `time_format` does not have a valid value, the time format will be `LT`
* which is `1:00 PM` or `13:00` depending on the system's locale.
*/
get_current_localized_time() {
let config_format = greeter_config.greeter.time_format;
let format = ( '' !== config_format ) ? config_format : 'LT';
let local_time = moment().format( format );
if ( local_time === localized_invalid_date ) {
local_time = moment().format( 'LT' );
}
return local_time;
}
/**
* @deprecated Use {@link theme_utils.esc_html()} instead.
*/
txt2html( text ) {}
} }
@ -76,6 +133,7 @@ class ThemeUtils {
*/ */
window.theme_utils = __ThemeUtils; window.theme_utils = __ThemeUtils;
window.theme_utils.bind_this = ThemeUtils.bind_this; window.theme_utils.bind_this = ThemeUtils.bind_this;
window.theme_utils.get_current_localized_time = ThemeUtils.get_current_localized_time;
/* -------->>> DEPRECATED! <<<-------- */ /* -------->>> DEPRECATED! <<<-------- */
window.greeterutil = window.theme_utils; window.greeterutil = window.theme_utils;

5
themes/antergos/js/greeter.js

@ -64,11 +64,6 @@ class AntergosThemeUtils {
this.$log_container = $('#logArea'); this.$log_container = $('#logArea');
this.recursion = 0; this.recursion = 0;
this.cache_backend = ''; this.cache_backend = '';
this.heartbeat = '';
if ( 'undefined' === typeof window.navigator.languages ) {
window.navigator.languages = [ window.navigator.language ];
}
this.setup_cache_backend(); this.setup_cache_backend();
this.init_config_values(); this.init_config_values();

Loading…
Cancel
Save