Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

angular-theme

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

angular-theme - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

6

demo/demo.js

@@ -5,2 +5,6 @@ (function() {

.module('demoApp', ['angular.theme'])
.config(['$themeProvider', function ($themeProvider) {
// overrides the default theme
$themeProvider.setInitialTheme('blue');
}])
.controller('DemoController', DemoController);

@@ -12,3 +16,3 @@

$scope.theme = $theme.activeTheme;
$scope.themes = $theme.themes.map(function(t){return t.name;});
$scope.themes = $theme.themes;
$scope.$watch('theme', $theme.setTheme);

@@ -15,0 +19,0 @@ }

51

dist/angular-theme.js
/**
* angular-theme v0.1.0
* Thu Oct 01 2015 22:52:00 GMT-0400 (EDT)
* angular-theme v1.0.0
* Sat Apr 23 2016 15:42:37 GMT-0400 (EDT)
* Justin Tormey <jrtormey@gmail.com>

@@ -11,10 +11,20 @@ */

angular.module('angular.theme', []);
angular.module('angular.theme').factory('$theme', $theme);
angular.module('angular.theme').provider('$theme', ThemeProvider);
$theme.$inject = [];
function ThemeProvider() {
var initialTheme;
function $theme() {
this.setInitialTheme = function (themeName) {
initialTheme = themeName;
};
this.$get = function themeFactory() {
return new Theme(initialTheme);
};
}
function Theme(initialTheme) {
var service = {
themes: [],
activeTheme: undefined,
activeTheme: initialTheme,
addTheme: addTheme,

@@ -25,14 +35,8 @@ setTheme: setTheme

function addTheme(themeName, setter) {
service.themes.unshift({ name: themeName, setDisabled: setter });
function addTheme(theme) {
if (! ~service.themes.indexOf(theme)) service.themes.unshift(theme);
}
function setTheme(themeName) {
service.themes.forEach(function (theme) {
var match = theme.name === themeName;
if (match) {
service.activeTheme = theme.name;
}
theme.setDisabled(!match);
});
function setTheme(theme) {
if (!! ~service.themes.indexOf(theme)) service.activeTheme = theme;
}

@@ -55,16 +59,19 @@ }

function link(scope, elem, attrs) {
if (elem[0].tagName !== 'LINK') return;
var isDefault = attrs['default'] !== undefined;
setDisabled(!isDefault);
$theme.addTheme(scope.themeName, setDisabled);
$theme.addTheme(scope.themeName);
if (isDefault) {
if (isDefault && $theme.activeTheme == null) {
$theme.setTheme(scope.themeName);
}
function setDisabled(state) {
elem[0].disabled = state;
}
scope.$watch(function () {
return $theme.activeTheme === scope.themeName;
}, function (isEnabled) {
elem[0].disabled = !isEnabled;
});
}
}
}());

@@ -1,1 +0,1 @@

!function(){"use strict";function e(){function e(e,t){n.themes.unshift({name:e,setDisabled:t})}function t(e){n.themes.forEach(function(t){var a=t.name===e;a&&(n.activeTheme=t.name),t.setDisabled(!a)})}var n={themes:[],activeTheme:void 0,addTheme:e,setTheme:t};return n}function t(e){function t(t,n,a){function m(e){n[0].disabled=e}var i=void 0!==a["default"];m(!i),e.addTheme(t.themeName,m),i&&e.setTheme(t.themeName)}var n={restrict:"A",scope:{themeName:"@ngTheme"},link:t};return n}angular.module("angular.theme",[]),angular.module("angular.theme").factory("$theme",e),e.$inject=[],angular.module("angular.theme").directive("ngTheme",t),t.$inject=["$theme"]}();
!function(){"use strict";function e(){var e;this.setInitialTheme=function(t){e=t},this.$get=function(){return new t(e)}}function t(e){function t(e){~a.themes.indexOf(e)||a.themes.unshift(e)}function n(e){~a.themes.indexOf(e)&&(a.activeTheme=e)}var a={themes:[],activeTheme:e,addTheme:t,setTheme:n};return a}function n(e){function t(t,n,a){if("LINK"===n[0].tagName){var i=void 0!==a["default"];e.addTheme(t.themeName),i&&null==e.activeTheme&&e.setTheme(t.themeName),t.$watch(function(){return e.activeTheme===t.themeName},function(e){n[0].disabled=!e})}}var n={restrict:"A",scope:{themeName:"@ngTheme"},link:t};return n}angular.module("angular.theme",[]),angular.module("angular.theme").provider("$theme",e),angular.module("angular.theme").directive("ngTheme",n),n.$inject=["$theme"]}();

@@ -14,3 +14,3 @@ 'use strict';

gulp.task('default', ['dist']);
gulp.task('default', ['dist', 'watch']);

@@ -67,1 +67,5 @@ gulp.task('dist', function() {

});
gulp.task('watch', function () {
gulp.watch(files.src.all, { cwd: files.src.dir }, ['dist']);
});
{
"name": "angular-theme",
"version": "1.0.0",
"version": "1.1.0",
"description": "Dynamic style and layout switching using Angular",

@@ -5,0 +5,0 @@ "main": "theme.module.js",

@@ -18,15 +18,18 @@ angular

function link(scope, elem, attrs) {
if (elem[0].tagName !== 'LINK') return;
var isDefault = (attrs.default !== undefined);
setDisabled(!isDefault);
$theme.addTheme(scope.themeName, setDisabled);
$theme.addTheme(scope.themeName);
if (isDefault) {
if (isDefault && $theme.activeTheme == null) {
$theme.setTheme(scope.themeName);
}
function setDisabled(state) {
elem[0].disabled = state;
}
scope.$watch(function () {
return $theme.activeTheme === scope.themeName;
}, function (isEnabled) {
elem[0].disabled = !isEnabled;
});
}
}
angular
.module('angular.theme')
.factory('$theme', $theme);
.provider('$theme', ThemeProvider);
$theme.$inject = [];
function ThemeProvider() {
var initialTheme;
function $theme() {
this.setInitialTheme = function (themeName) {
initialTheme = themeName;
};
this.$get = function themeFactory() {
return new Theme(initialTheme);
};
}
function Theme(initialTheme) {
var service = {
themes: [],
activeTheme: undefined,
activeTheme: initialTheme,
addTheme: addTheme,

@@ -16,15 +26,9 @@ setTheme: setTheme

function addTheme(themeName, setter) {
service.themes.unshift({ name: themeName, setDisabled: setter });
function addTheme(theme) {
if (!~service.themes.indexOf(theme)) service.themes.unshift(theme);
}
function setTheme(themeName) {
service.themes.forEach(function(theme) {
var match = (theme.name === themeName);
if (match) {
service.activeTheme = theme.name;
}
theme.setDisabled(!match);
});
function setTheme(theme) {
if (!!~service.themes.indexOf(theme)) service.activeTheme = theme;
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc