/** * This model is used by admin/about.blade.php, to perform a version check against Github. * @constructor */ function AboutViewModel(urls) { this.el = '#about-app'; this.data = { can_upgrade: false, is_loading: true, version_body: '', version_date: '', version_name: '', version_url: '' }; this.computed = { }; this.methods = { init: function () { var self = this; $.ajax( urls.latest_release_url, { complete: function() { self.is_loading = false; }, dataType: 'json', error: function (xhr, textStatus, errorThrown) { }, method: 'GET', success: function (data) { self.version_body = data.body; self.version_date = data.publish_date; self.version_name = data.name; self.version_url = data.url; // Set this last so any watchers on this property execute after all version data has been set self.can_upgrade = data.can_upgrade; } } ); } }; } /** * This model is used by admin/create_album.blade.php. * @constructor */ function CreateAlbumViewModel() { this.el = '#create-album-app'; this.data = { is_inherit_permissions: true, is_private: false, parent_id: '' }; this.computed = { isParentAlbum: function() { return this.parent_id == ''; }, isPrivateDisabled: function() { return !this.isParentAlbum && this.is_inherit_permissions; } } } /** * This model is used by admin/edit_album.blade.php. * @constructor */ function EditAlbumViewModel() { this.el = '#edit-album-app'; this.data = { parent_id: '' }; this.computed = { isParentAlbum: function() { return this.parent_id == ''; } } } /** * This model is used by admin/settings.blade.php. * @constructor */ function SettingsViewModel(urls, lang) { this.el = '#settings-app'; this.data = { is_rebuilding_permissions_cache: false }; this.methods = { rebuildPermissionsCache: function (e) { var self = this; $.ajax( urls.rebuild_permissions_cache, { complete: function() { self.is_rebuilding_permissions_cache = false; }, dataType: 'json', error: function (xhr, textStatus, errorThrown) { alert(lang.permissions_cache_rebuild_failed); }, method: 'POST', success: function (data) { alert(lang.permissions_cache_rebuild_succeeded); } } ); e.preventDefault(); return false; } }; }