@ -2,6 +2,10 @@
var _createClass = ( function ( ) { function defineProperties ( target , props ) { for ( var i = 0 ; i < props . length ; i ++ ) { var descriptor = props [ i ] ; descriptor . enumerable = descriptor . enumerable || false ; descriptor . configurable = true ; if ( "value" in descriptor ) descriptor . writable = true ; Object . defineProperty ( target , descriptor . key , descriptor ) ; } } return function ( Constructor , protoProps , staticProps ) { if ( protoProps ) defineProperties ( Constructor . prototype , protoProps ) ; if ( staticProps ) defineProperties ( Constructor , staticProps ) ; return Constructor ; } ; } ) ( ) ;
function _possibleConstructorReturn ( self , call ) { if ( ! self ) { throw new ReferenceError ( "this hasn't been initialised - super() hasn't been called" ) ; } return call && ( typeof call === "object" || typeof call === "function" ) ? call : self ; }
function _inherits ( subClass , superClass ) { if ( typeof superClass !== "function" && superClass !== null ) { throw new TypeError ( "Super expression must either be null or a function, not " + typeof superClass ) ; } subClass . prototype = Object . create ( superClass && superClass . prototype , { constructor : { value : subClass , enumerable : false , writable : true , configurable : true } } ) ; if ( superClass ) Object . setPrototypeOf ? Object . setPrototypeOf ( subClass , superClass ) : subClass . _ _proto _ _ = superClass ; }
function _classCallCheck ( instance , Constructor ) { if ( ! ( instance instanceof Constructor ) ) { throw new TypeError ( "Cannot call a class as a function" ) ; } }
/ *
@ -33,9 +37,15 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
* /
/ * *
* This is used to access our main clas s from within jQuery callbacks .
* This is used to access our classe s from within jQuery callbacks .
* /
var _self = null ;
var _bg _self = null ;
/ * *
* This is used so we don ' t ask the greeter for config values more than once .
* /
var _have _config _values = false ;
/ * *
* Capitalize a string .
@ -47,29 +57,14 @@ String.prototype.capitalize = function () {
} ;
/ * *
* This is the theme 's main class object. It contains almost all the theme' s logic .
* This class handles the theme ' s background switcher .
* /
var AntergosTheme = ( function ( ) {
function AntergosTheme ( ) {
_classCallCheck ( this , AntergosTheme ) ;
var GreeterThemeComponent = ( function ( ) {
function GreeterThemeComponent ( ) {
_classCallCheck ( this , GreeterThemeComponent ) ;
if ( null !== _self ) {
return _self ;
} else {
_self = this ;
}
this . debug = this . cache _get ( 'debug' , 'enabled' ) ;
this . user _list _visible = false ;
this . auth _pending = false ;
this . selected _user = null ;
this . $user _list = $ ( '#user-list2' ) ;
this . $session _list = $ ( '#sessions' ) ;
this . $clock _container = $ ( '#collapseOne' ) ;
this . $clock = $ ( "#current_time" ) ;
this . $actions _container = $ ( "#actionsArea" ) ;
this . $msg _area _container = $ ( '#statusArea' ) ;
this . $msg _area = $ ( '#showMsg' ) ;
this . lang = window . navigator . language . split ( '-' ) [ 0 ] . toLowerCase ( ) ;
this . translations = window . ant _translations ;
@ -77,30 +72,16 @@ var AntergosTheme = (function () {
window . navigator . languages = [ window . navigator . language ] ;
}
this . initialize ( ) ;
this . init _config _values ( ) ;
}
_createClass ( AntergosTheme , [ {
key : 'initialize' ,
value : function initialize ( ) {
this . prepare _translations ( ) ;
this . do _static _translations ( ) ;
this . initialize _clock ( ) ;
this . prepare _login _panel _header ( ) ;
this . prepare _user _list ( ) ;
this . prepare _session _list ( ) ;
this . prepare _system _action _buttons ( ) ;
this . register _callbacks ( ) ;
}
/ * *
* Add text to the debug log element ( accessible from the login screen ) .
*
* @ param { string } text - To be added to the log .
* /
/ * *
* Add text to the debug log element ( accessible from the login screen ) .
*
* @ param { string } text - To be added to the log .
* /
} , {
_createClass ( GreeterThemeComponent , [ {
key : 'log' ,
value : function log ( text ) {
if ( 'true' === this . debug ) {
@ -119,8 +100,7 @@ var AntergosTheme = (function () {
} , {
key : 'cache_get' ,
value : function cache _get ( ) {
var key = 'ant' ,
index = 0 ;
var key = 'ant' ;
for ( var _len = arguments . length , key _parts = Array ( _len ) , _key = 0 ; _key < _len ; _key ++ ) {
key _parts [ _key ] = arguments [ _key ] ;
@ -135,7 +115,6 @@ var AntergosTheme = (function () {
var part = _step . value ;
key += ':' + part ;
index += 1 ;
}
} catch ( err ) {
_didIteratorError = true ;
@ -166,8 +145,7 @@ var AntergosTheme = (function () {
} , {
key : 'cache_set' ,
value : function cache _set ( value ) {
var key = 'ant' ,
index = 0 ;
var key = 'ant' ;
for ( var _len2 = arguments . length , key _parts = Array ( _len2 > 1 ? _len2 - 1 : 0 ) , _key2 = 1 ; _key2 < _len2 ; _key2 ++ ) {
key _parts [ _key2 - 1 ] = arguments [ _key2 ] ;
@ -182,7 +160,6 @@ var AntergosTheme = (function () {
var part = _step2 . value ;
key += ':' + part ;
index += 1 ;
}
} catch ( err ) {
_didIteratorError2 = true ;
@ -202,6 +179,169 @@ var AntergosTheme = (function () {
return localStorage . setItem ( key , value ) ;
}
/ * *
* Get some values from ` lightdm-webkit2-greeter.conf ` and save them for later .
* /
} , {
key : 'init_config_values' ,
value : function init _config _values ( ) {
var logo = '' ,
background _images = '' ,
background _images _dir = '' ;
if ( 'undefined' !== typeof config ) {
if ( this instanceof AntergosTheme ) {
logo = config . get _str ( 'branding' , 'logo_image' ) || '' ;
} else if ( this instanceof AntergosBackgroundManager ) {
background _images = config . get _str ( 'branding' , 'background_images_array' ) || '' ;
background _images = background _images . length ? background _images . split ( ',' ) : [ ] ;
background _images _dir = config . get _str ( 'branding' , 'background_images' ) || '' ;
}
}
this . logo = logo ;
this . background _images = background _images ;
this . background _images _dir = background _images _dir ;
}
} ] ) ;
return GreeterThemeComponent ;
} ) ( ) ;
/ * *
* This class handles the theme ' s background switcher .
* /
var AntergosBackgroundManager = ( function ( _GreeterThemeComponen ) {
_inherits ( AntergosBackgroundManager , _GreeterThemeComponen ) ;
function AntergosBackgroundManager ( ) {
var _ret ;
_classCallCheck ( this , AntergosBackgroundManager ) ;
var _this = _possibleConstructorReturn ( this , Object . getPrototypeOf ( AntergosBackgroundManager ) . call ( this ) ) ;
if ( null === _bg _self ) {
_bg _self = _this ;
}
_this . current _background = _this . cache _get ( 'background_config' , 'current_background' ) ;
if ( ! _this . background _images _dir . length || ! _this . background _images . length ) {
_this . log ( 'AntergosBackgroundManager: [ERROR] No background images detected.' ) ;
}
_this . initialize ( ) ;
return _ret = _bg _self , _possibleConstructorReturn ( _this , _ret ) ;
}
_createClass ( AntergosBackgroundManager , [ {
key : 'initialize' ,
value : function initialize ( ) {
if ( ! this . current _background ) {
// For backwards compatibility
if ( null !== localStorage . getItem ( 'bgsaved' ) && '0' === localStorage . getItem ( 'bgrandom' ) ) {
this . current _background = localStorage . getItem ( 'bgsaved' ) ;
this . cache _set ( this . current _background , 'background_manager' , 'current_background' ) ;
localStorage . removeItem ( 'bgrandom' ) ;
localStorage . removeItem ( 'bgsaved' ) ;
} else if ( '0' === localStorage . getItem ( 'bgrandom' ) ) {
this . current _background = this . get _random _image ( ) ;
this . cache _set ( 'true' , 'background_manager' , 'random_background' ) ;
localStorage . removeItem ( 'bgrandom' ) ;
}
}
if ( ! this . current _background ) {
// For current and future versions
var current _background = this . cache _get ( 'background_manager' , 'current_background' ) ,
random _background = this . cache _get ( 'background_manager' , 'random_background' ) ;
if ( 'true' === random _background ) { }
}
$ ( '.header' ) . fadeTo ( 300 , 0.5 , function ( ) {
$ ( '.header' ) . css ( "background" , this . current _background ) ;
} ) . fadeTo ( 300 , 1 ) ;
}
} , {
key : 'get_random_image' ,
value : function get _random _image ( ) {
var background = undefined ,
random _bg = undefined ;
if ( this . background _images . length ) {
random _bg = Math . floor ( Math . random ( ) * this . background _images . length ) ;
background = this . background _images [ random _bg ] ;
}
}
} , {
key : 'get_old_backgrounds' ,
value : function get _old _backgrounds ( ) {
var old _backgrounds = [ ] ;
$ ( '.bgs .clearfix' ) . each ( function ( i ) {
if ( i > 0 ) {
old _backgrounds . push ( $ ( this ) . attr ( 'data-img' ) ) ;
}
} ) ;
}
} ] ) ;
return AntergosBackgroundManager ;
} ) ( GreeterThemeComponent ) ;
/ * *
* This is the theme 's main class object. It contains almost all the theme' s logic .
* /
var AntergosTheme = ( function ( _GreeterThemeComponen2 ) {
_inherits ( AntergosTheme , _GreeterThemeComponen2 ) ;
function AntergosTheme ( ) {
var _ret2 ;
_classCallCheck ( this , AntergosTheme ) ;
var _this2 = _possibleConstructorReturn ( this , Object . getPrototypeOf ( AntergosTheme ) . call ( this ) ) ;
if ( null === _self ) {
_self = _this2 ;
}
_this2 . user _list _visible = false ;
_this2 . auth _pending = false ;
_this2 . selected _user = null ;
_this2 . $user _list = $ ( '#user-list2' ) ;
_this2 . $session _list = $ ( '#sessions' ) ;
_this2 . $clock _container = $ ( '#collapseOne' ) ;
_this2 . $clock = $ ( "#current_time" ) ;
_this2 . $actions _container = $ ( "#actionsArea" ) ;
_this2 . $msg _area _container = $ ( '#statusArea' ) ;
_this2 . $msg _area = $ ( '#showMsg' ) ;
_this2 . background _manager = new AntergosBackgroundManager ( ) ;
_this2 . initialize ( ) ;
return _ret2 = _self , _possibleConstructorReturn ( _this2 , _ret2 ) ;
}
_createClass ( AntergosTheme , [ {
key : 'initialize' ,
value : function initialize ( ) {
this . prepare _translations ( ) ;
this . do _static _translations ( ) ;
this . initialize _clock ( ) ;
this . prepare _login _panel _header ( ) ;
this . prepare _user _list ( ) ;
this . prepare _session _list ( ) ;
this . prepare _system _action _buttons ( ) ;
this . register _callbacks ( ) ;
}
/ * *
* Register callbacks for the LDM Greeter as well as any others that haven ' t been registered
* elsewhere .
@ -210,14 +350,19 @@ var AntergosTheme = (function () {
} , {
key : 'register_callbacks' ,
value : function register _callbacks ( ) {
var events = 'shown.bs.collapse, hidden.bs.collapse' ;
this . $user _list . parents ( '.collapse' ) . on ( events , this . user _list _collapse _handler ) ;
$ ( document ) . keydown ( this . key _press _handler ) ;
$ ( '.cancel_auth' ) . click ( this . cancel _authentication ) ;
$ ( '.submit_passwd' ) . click ( this . submit _password ) ;
window . show _prompt = this . show _prompt ;
window . show _message = this . show _message ;
window . start _authentication = this . start _authentication ;
window . cancel _authentication = this . cancel _authentication ;
window . authentication _complete = this . authentication _complete ;
window . autologin _timer _expired = this . cancel _authentication ;
}
/ * *
@ -258,7 +403,7 @@ var AntergosTheme = (function () {
template = '\n\t\t\t\t<a href="#" id="' + user . name + '" class="list-group-item ' + user . name + '" data-session="' + last _session + '">\n\t\t\t\t\t<img src="' + image _src + '" class="img-circle" alt="' + user . display _name + '" />\n\t\t\t\t\t<span>' + user . display _name + '</span>\n\t\t\t\t\t<span class="badge"><i class="fa fa-check"></i></span>\n\t\t\t\t</a>' ;
// Register event handler here so we don't have to iterate over the users again later.
$ ( template ) . appendTo ( this . $user _list ) . click ( this . start _authentication ) . children ( 'img' ) . on ( 'error' , this . image _not _found ) ;
$ ( template ) . appendTo ( this . $user _list ) . click ( this . start _authentication ) ;
} // END for ( var user of lightdm.users )
} catch ( err ) {
_didIteratorError3 = true ;
@ -376,52 +521,16 @@ var AntergosTheme = (function () {
} , {
key : 'initialize_clock' ,
value : function initialize _clock ( ) {
var _this = this ;
var _this3 = this ;
var saved _format = this . cache _get ( 'clock' , 'time_format' ) ,
format = null !== saved _format ? saved _format : 'LT' ,
detected _language = this . lang ;
// Workaround for moment.js bug: https://github.com/moment/moment/issues/2856
var _iteratorNormalCompletion6 = true ;
var _didIteratorError6 = false ;
var _iteratorError6 = undefined ;
try {
for ( var _iterator6 = window . navigator . languages [ Symbol . iterator ] ( ) , _step6 ; ! ( _iteratorNormalCompletion6 = ( _step6 = _iterator6 . next ( ) ) . done ) ; _iteratorNormalCompletion6 = true ) {
var lang = _step6 . value ;
try {
detected _language = lang . split ( '-' ) [ 0 ] . toLowerCase ( ) ;
break ;
} catch ( err ) {
this . log ( String ( err ) ) ;
}
}
} catch ( err ) {
_didIteratorError6 = true ;
_iteratorError6 = err ;
} finally {
try {
if ( ! _iteratorNormalCompletion6 && _iterator6 . return ) {
_iterator6 . return ( ) ;
}
} finally {
if ( _didIteratorError6 ) {
throw _iteratorError6 ;
}
}
}
if ( null === detected _language ) {
detected _language = 'en' ;
}
format = null !== saved _format ? saved _format : 'LT' ;
moment . locale ( detected _language ) ;
moment . locale ( window . navigator . languages ) ;
this . $clock . html ( moment ( ) . format ( format ) ) ;
setInterval ( function ( ) {
_this . $clock . html ( moment ( ) . format ( format ) ) ;
_this3 . $clock . html ( moment ( ) . format ( format ) ) ;
} , 60000 ) ;
}
@ -435,7 +544,6 @@ var AntergosTheme = (function () {
value : function show _user _list ( ) {
if ( $ ( this . $clock _container ) . hasClass ( 'in' ) ) {
$ ( '#trigger' ) . trigger ( 'click' ) ;
this . user _list _visible = true ;
}
if ( $ ( this . $user _list ) . length <= 1 ) {
$ ( this . $user _list ) . find ( 'a' ) . trigger ( 'click' , this ) ;
@ -444,7 +552,8 @@ var AntergosTheme = (function () {
} , {
key : 'prepare_login_panel_header' ,
value : function prepare _login _panel _header ( ) {
var greeting = this . translations . greeting ? this . translations . greeting : 'Welcome!' ;
var greeting = this . translations . greeting ? this . translations . greeting : 'Welcome!' ,
logo = '' !== this . logo ? this . logo : 'img/antergos.png' ;
$ ( '.welcome' ) . text ( greeting ) ;
$ ( '#hostname' ) . append ( lightdm . hostname ) ;
@ -453,13 +562,13 @@ var AntergosTheme = (function () {
key : 'prepare_translations' ,
value : function prepare _translations ( ) {
if ( ! this . translations . hasOwnProperty ( this . lang ) ) {
var _iteratorNormalCompletion7 = true ;
var _didIteratorError7 = false ;
var _iteratorError7 = undefined ;
var _iteratorNormalCompletion6 = true ;
var _didIteratorError6 = false ;
var _iteratorError6 = undefined ;
try {
for ( var _iterator7 = window . navigator . languages [ Symbol . iterator ] ( ) , _step7 ; ! ( _iteratorNormalCompletion7 = ( _step7 = _iterator7 . next ( ) ) . done ) ; _iteratorNormalCompletion7 = true ) {
var lang = _step7 . value ;
for ( var _iterator6 = window . navigator . languages [ Symbol . iterator ] ( ) , _step6 ; ! ( _iteratorNormalCompletion6 = ( _step6 = _iterator6 . next ( ) ) . done ) ; _iteratorNormalCompletion6 = true ) {
var lang = _step6 . value ;
if ( this . translations . hasOwnProperty ( lang ) ) {
this . lang = lang ;
@ -467,16 +576,16 @@ var AntergosTheme = (function () {
}
}
} catch ( err ) {
_didIteratorError7 = true ;
_iteratorError7 = err ;
_didIteratorError6 = true ;
_iteratorError6 = err ;
} finally {
try {
if ( ! _iteratorNormalCompletion7 && _iterator7 . return ) {
_iterator7 . return ( ) ;
if ( ! _iteratorNormalCompletion6 && _iterator6 . return ) {
_iterator6 . return ( ) ;
}
} finally {
if ( _didIteratorError7 ) {
throw _iteratorError7 ;
if ( _didIteratorError6 ) {
throw _iteratorError6 ;
}
}
}
@ -546,7 +655,7 @@ var AntergosTheme = (function () {
_self . auth _pending = true ;
lightdm . start _authentication ( user _id ) ;
lightdm . authenticate ( user _id ) ;
}
/ * *
@ -560,27 +669,27 @@ var AntergosTheme = (function () {
value : function cancel _authentication ( event ) {
var selectors = [ '#statusArea' , '#timerArea' , '#passwordArea' , '#session-list' ] ;
var _iteratorNormalCompletion8 = true ;
var _didIteratorError8 = false ;
var _iteratorError8 = undefined ;
var _iteratorNormalCompletion7 = true ;
var _didIteratorError7 = false ;
var _iteratorError7 = undefined ;
try {
for ( var _iterator8 = selectors [ Symbol . iterator ] ( ) , _step8 ; ! ( _iteratorNormalCompletion8 = ( _step8 = _iterator8 . next ( ) ) . done ) ; _iteratorNormalCompletion8 = true ) {
var selector = _step8 . value ;
for ( var _iterator7 = selectors [ Symbol . iterator ] ( ) , _step7 ; ! ( _iteratorNormalCompletion7 = ( _step7 = _iterator7 . next ( ) ) . done ) ; _iteratorNormalCompletion7 = true ) {
var selector = _step7 . value ;
$ ( selector ) . hide ( ) ;
}
} catch ( err ) {
_didIteratorError8 = true ;
_iteratorError8 = err ;
_didIteratorError7 = true ;
_iteratorError7 = err ;
} finally {
try {
if ( ! _iteratorNormalCompletion8 && _iterator8 . return ) {
_iterator8 . return ( ) ;
if ( ! _iteratorNormalCompletion7 && _iterator7 . return ) {
_iterator7 . return ( ) ;
}
} finally {
if ( _didIteratorError8 ) {
throw _iteratorError8 ;
if ( _didIteratorError7 ) {
throw _iteratorError7 ;
}
}
}
@ -629,7 +738,7 @@ var AntergosTheme = (function () {
} , {
key : 'submit_password' ,
value : function submit _password ( event ) {
lightdm . provide _secret ( $ ( '#passwordField' ) . val ( ) ) ;
lightdm . respond ( $ ( '#passwordField' ) . val ( ) ) ;
$ ( '#passwordArea' ) . hide ( ) ;
$ ( '#timerArea' ) . show ( ) ;
}
@ -666,60 +775,55 @@ var AntergosTheme = (function () {
} , {
key : 'system_action_handler' ,
value : function system _action _handler ( ) {
var _this2 = this ;
var _this4 = this ;
var action = $ ( this ) . attr ( 'id' ) ,
$modal = $ ( '.modal' ) ;
$modal . find ( '.btn-primary' ) . text ( _self . translations [ action ] ) . click ( action , function ( event ) {
$ ( _this2 ) . off ( 'click' ) ;
$ ( _this4 ) . off ( 'click' ) ;
lightdm [ event . data ] ( ) ;
} ) ;
$modal . find ( '.btn-default' ) . click ( function ( ) {
$ ( _this2 ) . next ( ) . off ( 'click' ) ;
$ ( _this4 ) . next ( ) . off ( 'click' ) ;
} ) ;
$modal . modal ( 'toggle' ) ;
}
/ * *
* User image on ( 'error' ) handler .
* /
} , {
key : 'image_not_found' ,
value : function image _not _found ( source ) {
source . onerror = "" ;
source . src = 'img/antergos-logo-user.png' ;
return true ;
key : 'user_list_collapse_handler' ,
value : function user _list _collapse _handler ( ) {
_self . user _list _visible = _self . $user _list . hasClass ( 'in' ) ? true : false ;
}
/ * *
* LightDM Callback - Show password prompt to user .
*
* @ param text
* @ param type
* /
} , {
key : 'show_prompt' ,
value : function show _prompt ( text ) {
$ ( '#passwordField' ) . val ( "" ) ;
$ ( '#passwordArea' ) . show ( ) ;
$ ( '#passwordField' ) . focus ( ) ;
value : function show _prompt ( text , type ) {
if ( 'password' === type ) {
$ ( '#passwordField' ) . val ( "" ) ;
$ ( '#passwordArea' ) . show ( ) ;
$ ( '#passwordField' ) . focus ( ) ;
}
}
/ * *
* LightDM Callback - Show message to user .
*
* @ param msg
* @ param text
* /
} , {
key : 'show_message' ,
value : function show _message ( msg ) {
if ( msg . length > 0 ) {
$ ( this . $msg _area ) . html ( msg ) ;
value : function show _message ( text , type ) {
if ( text . length > 0 ) {
$ ( this . $msg _area ) . html ( text ) ;
$ ( '#passwordArea' ) . hide ( ) ;
$ ( this . $msg _area _container ) . show ( ) ;
}
@ -727,7 +831,7 @@ var AntergosTheme = (function () {
} ] ) ;
return AntergosTheme ;
} ) ( ) ;
} ) ( GreeterThemeComponent ) ;
/ * *
* Initialize the theme once the window has loaded .