rails_modular_admin 0.2.4 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/rails_modular_admin.js +1 -2
- data/app/assets/stylesheets/rails_modular_admin/application.scss +1 -1
- data/app/assets/stylesheets/rails_modular_admin.scss +1 -0
- data/config/initializers/assets.rb +34 -2
- data/lib/rails_modular_admin/version.rb +1 -1
- metadata +30 -30
- data/app/assets/javascripts/rails_modular_admin/_common/_helpers/code-helper.js +0 -36
- data/app/assets/javascripts/rails_modular_admin/_common/_helpers/for-helper.js +0 -8
- data/app/assets/javascripts/rails_modular_admin/_common/_helpers/is-helper.js +0 -98
- data/app/assets/javascripts/rails_modular_admin/_common/_helpers/times-helper.js +0 -11
- data/app/assets/javascripts/rails_modular_admin/_common/animations/animations.js +0 -14
- data/app/assets/javascripts/rails_modular_admin/_common/items-list/items-list.js +0 -19
- data/app/assets/javascripts/rails_modular_admin/_common/nprogress/nprogress.js +0 -9
- data/app/assets/javascripts/rails_modular_admin/_common/sameheight-items/sameheight-items.js +0 -44
- data/app/assets/javascripts/rails_modular_admin/app/_common/editor/editor-helper.js +0 -10
- data/app/assets/javascripts/rails_modular_admin/app/_common/editor/editor.js +0 -34
- data/app/assets/javascripts/rails_modular_admin/app/_common/header/nav/nav.js +0 -14
- data/app/assets/javascripts/rails_modular_admin/app/_common/modals/modal-media/modal-media.js +0 -23
- data/app/assets/javascripts/rails_modular_admin/app/_common/sidebar/customize/customize.js +0 -155
- data/app/assets/javascripts/rails_modular_admin/app/_common/sidebar/sidebar.js +0 -38
- data/app/assets/javascripts/rails_modular_admin/app/charts/charts-flot/charts-flot.js +0 -329
- data/app/assets/javascripts/rails_modular_admin/app/charts/charts-morris/charts-morris.js +0 -125
- data/app/assets/javascripts/rails_modular_admin/app/dashboard/history/history.js +0 -145
- data/app/assets/javascripts/rails_modular_admin/app/dashboard/items/items.js +0 -41
- data/app/assets/javascripts/rails_modular_admin/app/dashboard/sales-breakdown/sales-breakdown.js +0 -37
- data/app/assets/javascripts/rails_modular_admin/app/dashboard/sales-by-countries/sales-by-countries.js +0 -50
- data/app/assets/javascripts/rails_modular_admin/app/dashboard/tasks/tasks.js +0 -13
- data/app/assets/javascripts/rails_modular_admin/app/forms/input-groups/input-groups.js +0 -14
- data/app/assets/javascripts/rails_modular_admin/app/items/editor/item-editor.js +0 -34
- data/app/assets/javascripts/rails_modular_admin/app/items/list/items-list.js +0 -44
- data/app/assets/javascripts/rails_modular_admin/app/pages/error.js +0 -18
- data/app/assets/javascripts/rails_modular_admin/auth/login/login.js +0 -35
- data/app/assets/javascripts/rails_modular_admin/auth/reset/reset.js +0 -31
- data/app/assets/javascripts/rails_modular_admin/auth/signup/signup.js +0 -88
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7156db769db77382e9fdeaf5e24f0b7860d65e25
|
4
|
+
data.tar.gz: 4cec4315c630374338578461b7bb2b4535d0de55
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f0b8b112515ebd4a935957a571276d500bd25deba78272a98e6d1ed3afe355adec902cdc8bb04afcc9212254ab1b87952810de12ee560bdd8f49d7d93583959d
|
7
|
+
data.tar.gz: b7009597ab8d521d193ed06521705e57c268b6e05f5cfd7011766b6eecf59a96cd5c19a93d76cecdb6ad5b138d2f7756c048212de98d7dab39917f24a5385734
|
@@ -1,2 +1,34 @@
|
|
1
|
-
Rails.application.config.assets.paths << RailsModularAdmin::Engine.root.join('node_modules
|
2
|
-
|
1
|
+
Rails.application.config.assets.paths << RailsModularAdmin::Engine.root.join('node_modules')
|
2
|
+
|
3
|
+
%w(bootstrap popper_js).each do |pkg|
|
4
|
+
Rails.application.config.assets.paths << "#{Gem.loaded_specs[pkg].full_gem_path}/assets/stylesheets"
|
5
|
+
Rails.application.config.assets.paths << "#{Gem.loaded_specs[pkg].full_gem_path}/assets/javascripts"
|
6
|
+
end
|
7
|
+
|
8
|
+
# ['/jquery/dist/',
|
9
|
+
# '/jquery-flot/',
|
10
|
+
# '/jquery-flot/',
|
11
|
+
# '/jquery-flot/',
|
12
|
+
# '/jquery-flot/',
|
13
|
+
# '/jquery.flot.tooltip/',
|
14
|
+
# '/jquery-validation/dist/',
|
15
|
+
# '/jquery-sparkline/',
|
16
|
+
# '/jqvmap/dist/',
|
17
|
+
# '/jqvmap/dist/maps/',
|
18
|
+
# '/metismenu/dist/',
|
19
|
+
# '/nprogress/',
|
20
|
+
# '/quill/dist/',
|
21
|
+
# '/responsive-toolkit/dist/',
|
22
|
+
# '/sortablejs/',
|
23
|
+
# '/tether/dist/js/',
|
24
|
+
# '/tinycolor2/',
|
25
|
+
# '/dropzone/dist/',
|
26
|
+
# '/jquery-touchswipe/',
|
27
|
+
# '/jquery.browser/dist/',
|
28
|
+
# '/popper.js/dist/umd/',
|
29
|
+
# '/bootstrap/dist/js/',
|
30
|
+
# '/bootstrap/scss/',
|
31
|
+
# '/raphael/',
|
32
|
+
# '/morris.js/'].each do |pkg|
|
33
|
+
# Rails.application.config.assets.paths << RailsModularAdmin::Engine.root.join('node_modules' + pkg)
|
34
|
+
# end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_modular_admin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Will Payne
|
@@ -80,6 +80,34 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: jquery-rails
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: bootstrap
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '4'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '4'
|
83
111
|
- !ruby/object:Gem::Dependency
|
84
112
|
name: sqlite3
|
85
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -122,7 +150,7 @@ dependencies:
|
|
122
150
|
- - ">="
|
123
151
|
- !ruby/object:Gem::Version
|
124
152
|
version: '0'
|
125
|
-
description:
|
153
|
+
description: this plugin is designed to quickly generate views for Rails applications
|
126
154
|
in need of dashboard functionality. This includes admin panels and SaaS applications.
|
127
155
|
I found that over the course of my projects, I needed Dashboard pages very often,
|
128
156
|
so by creating this gem, I'm at least saving my self a bunch of time...
|
@@ -137,35 +165,7 @@ files:
|
|
137
165
|
- Rakefile
|
138
166
|
- app/assets/config/rails_modular_admin_manifest.js
|
139
167
|
- app/assets/javascripts/rails_modular_admin.js
|
140
|
-
- app/assets/javascripts/rails_modular_admin/_common/_helpers/code-helper.js
|
141
|
-
- app/assets/javascripts/rails_modular_admin/_common/_helpers/for-helper.js
|
142
|
-
- app/assets/javascripts/rails_modular_admin/_common/_helpers/is-helper.js
|
143
|
-
- app/assets/javascripts/rails_modular_admin/_common/_helpers/times-helper.js
|
144
|
-
- app/assets/javascripts/rails_modular_admin/_common/animations/animations.js
|
145
|
-
- app/assets/javascripts/rails_modular_admin/_common/items-list/items-list.js
|
146
|
-
- app/assets/javascripts/rails_modular_admin/_common/nprogress/nprogress.js
|
147
|
-
- app/assets/javascripts/rails_modular_admin/_common/sameheight-items/sameheight-items.js
|
148
168
|
- app/assets/javascripts/rails_modular_admin/app.js
|
149
|
-
- app/assets/javascripts/rails_modular_admin/app/_common/editor/editor-helper.js
|
150
|
-
- app/assets/javascripts/rails_modular_admin/app/_common/editor/editor.js
|
151
|
-
- app/assets/javascripts/rails_modular_admin/app/_common/header/nav/nav.js
|
152
|
-
- app/assets/javascripts/rails_modular_admin/app/_common/modals/modal-media/modal-media.js
|
153
|
-
- app/assets/javascripts/rails_modular_admin/app/_common/sidebar/customize/customize.js
|
154
|
-
- app/assets/javascripts/rails_modular_admin/app/_common/sidebar/sidebar.js
|
155
|
-
- app/assets/javascripts/rails_modular_admin/app/charts/charts-flot/charts-flot.js
|
156
|
-
- app/assets/javascripts/rails_modular_admin/app/charts/charts-morris/charts-morris.js
|
157
|
-
- app/assets/javascripts/rails_modular_admin/app/dashboard/history/history.js
|
158
|
-
- app/assets/javascripts/rails_modular_admin/app/dashboard/items/items.js
|
159
|
-
- app/assets/javascripts/rails_modular_admin/app/dashboard/sales-breakdown/sales-breakdown.js
|
160
|
-
- app/assets/javascripts/rails_modular_admin/app/dashboard/sales-by-countries/sales-by-countries.js
|
161
|
-
- app/assets/javascripts/rails_modular_admin/app/dashboard/tasks/tasks.js
|
162
|
-
- app/assets/javascripts/rails_modular_admin/app/forms/input-groups/input-groups.js
|
163
|
-
- app/assets/javascripts/rails_modular_admin/app/items/editor/item-editor.js
|
164
|
-
- app/assets/javascripts/rails_modular_admin/app/items/list/items-list.js
|
165
|
-
- app/assets/javascripts/rails_modular_admin/app/pages/error.js
|
166
|
-
- app/assets/javascripts/rails_modular_admin/auth/login/login.js
|
167
|
-
- app/assets/javascripts/rails_modular_admin/auth/reset/reset.js
|
168
|
-
- app/assets/javascripts/rails_modular_admin/auth/signup/signup.js
|
169
169
|
- app/assets/javascripts/rails_modular_admin/vendor.js
|
170
170
|
- app/assets/stylesheets/rails_modular_admin.scss
|
171
171
|
- app/assets/stylesheets/rails_modular_admin/_common/_styles/_mixins.scss
|
@@ -1,36 +0,0 @@
|
|
1
|
-
module.exports.register = function (handlebars) {
|
2
|
-
handlebars.registerHelper('code', function(options) {
|
3
|
-
|
4
|
-
var className = options.hash.lang || "";
|
5
|
-
|
6
|
-
// Input html
|
7
|
-
var input = options.fn(this);
|
8
|
-
|
9
|
-
// Escale html to string
|
10
|
-
input = handlebars.Utils.escapeExpression(input);
|
11
|
-
|
12
|
-
// Break by lines
|
13
|
-
var lines = input.split("\n");
|
14
|
-
|
15
|
-
// Get number of tabs before first line
|
16
|
-
var numTabs = getNumFrontTabs(lines[0]);
|
17
|
-
|
18
|
-
// Remove tabs before
|
19
|
-
lines = lines.map(function(line) {
|
20
|
-
return line.substring(numTabs);
|
21
|
-
});
|
22
|
-
|
23
|
-
// Rejoin the lines
|
24
|
-
return "<pre><code class='" + className + "'>" + lines.join("\n") + "</code></pre>";
|
25
|
-
});
|
26
|
-
};
|
27
|
-
|
28
|
-
|
29
|
-
function getNumFrontTabs(line) {
|
30
|
-
var count = 0;
|
31
|
-
var index = 0;
|
32
|
-
while (line.charAt(index++) === "\t") {
|
33
|
-
count++;
|
34
|
-
}
|
35
|
-
return count;
|
36
|
-
}
|
@@ -1,98 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
Custom handlebars helpers which allows to make
|
3
|
-
|
4
|
-
{{#is a '===' b}}}
|
5
|
-
|
6
|
-
{{/is}}
|
7
|
-
*/
|
8
|
-
|
9
|
-
module.exports.register = function (handlebars) {
|
10
|
-
|
11
|
-
var isArray = function(value) {
|
12
|
-
return Object.prototype.toString.call(value) === '[object Array]';
|
13
|
-
}
|
14
|
-
|
15
|
-
var ExpressionRegistry = function() {
|
16
|
-
this.expressions = [];
|
17
|
-
};
|
18
|
-
|
19
|
-
ExpressionRegistry.prototype.add = function (operator, method) {
|
20
|
-
this.expressions[operator] = method;
|
21
|
-
};
|
22
|
-
|
23
|
-
ExpressionRegistry.prototype.call = function (operator, left, right) {
|
24
|
-
if ( ! this.expressions.hasOwnProperty(operator)) {
|
25
|
-
throw new Error('Unknown operator "'+operator+'"');
|
26
|
-
}
|
27
|
-
|
28
|
-
return this.expressions[operator](left, right);
|
29
|
-
};
|
30
|
-
|
31
|
-
var eR = new ExpressionRegistry;
|
32
|
-
eR.add('not', function(left, right) {
|
33
|
-
return left != right;
|
34
|
-
});
|
35
|
-
eR.add('>', function(left, right) {
|
36
|
-
return left > right;
|
37
|
-
});
|
38
|
-
eR.add('<', function(left, right) {
|
39
|
-
return left < right;
|
40
|
-
});
|
41
|
-
eR.add('>=', function(left, right) {
|
42
|
-
return left >= right;
|
43
|
-
});
|
44
|
-
eR.add('<=', function(left, right) {
|
45
|
-
return left <= right;
|
46
|
-
});
|
47
|
-
|
48
|
-
eR.add('==', function(left, right) {
|
49
|
-
return left == right;
|
50
|
-
});
|
51
|
-
|
52
|
-
eR.add('===', function(left, right) {
|
53
|
-
return left === right;
|
54
|
-
});
|
55
|
-
eR.add('!==', function(left, right) {
|
56
|
-
return left !== right;
|
57
|
-
});
|
58
|
-
eR.add('in', function(left, right) {
|
59
|
-
if ( ! isArray(right)) {
|
60
|
-
right = right.split(',');
|
61
|
-
}
|
62
|
-
return right.indexOf(left) !== -1;
|
63
|
-
});
|
64
|
-
|
65
|
-
var isHelper = function() {
|
66
|
-
var args = arguments
|
67
|
-
, left = args[0]
|
68
|
-
, operator = args[1]
|
69
|
-
, right = args[2]
|
70
|
-
, options = args[3]
|
71
|
-
;
|
72
|
-
|
73
|
-
|
74
|
-
// console.log(args);
|
75
|
-
|
76
|
-
if (args.length == 2) {
|
77
|
-
options = args[1];
|
78
|
-
if (left) return options.fn(this);
|
79
|
-
return options.inverse(this);
|
80
|
-
}
|
81
|
-
|
82
|
-
if (args.length == 3) {
|
83
|
-
right = args[1];
|
84
|
-
options = args[2];
|
85
|
-
if (left == right) return options.fn(this);
|
86
|
-
return options.inverse(this);
|
87
|
-
}
|
88
|
-
|
89
|
-
if (eR.call(operator, left, right)) {
|
90
|
-
return options.fn(this);
|
91
|
-
}
|
92
|
-
return options.inverse(this);
|
93
|
-
};
|
94
|
-
|
95
|
-
handlebars.registerHelper('is', isHelper);
|
96
|
-
|
97
|
-
return eR;
|
98
|
-
};
|
@@ -1,14 +0,0 @@
|
|
1
|
-
/***********************************************
|
2
|
-
* Animation Settings
|
3
|
-
***********************************************/
|
4
|
-
function animate(options) {
|
5
|
-
var animationName = "animated " + options.name;
|
6
|
-
var animationEnd = "webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend";
|
7
|
-
$(options.selector)
|
8
|
-
.addClass(animationName)
|
9
|
-
.one(animationEnd,
|
10
|
-
function(){
|
11
|
-
$(this).removeClass(animationName);
|
12
|
-
}
|
13
|
-
);
|
14
|
-
}
|
@@ -1,19 +0,0 @@
|
|
1
|
-
$(function() {
|
2
|
-
var $itemActions = $(".item-actions-dropdown");
|
3
|
-
|
4
|
-
$(document).on('click',function(e) {
|
5
|
-
if (!$(e.target).closest('.item-actions-dropdown').length) {
|
6
|
-
$itemActions.removeClass('active');
|
7
|
-
}
|
8
|
-
});
|
9
|
-
|
10
|
-
$('.item-actions-toggle-btn').on('click',function(e){
|
11
|
-
e.preventDefault();
|
12
|
-
|
13
|
-
var $thisActionList = $(this).closest('.item-actions-dropdown');
|
14
|
-
|
15
|
-
$itemActions.not($thisActionList).removeClass('active');
|
16
|
-
|
17
|
-
$thisActionList.toggleClass('active');
|
18
|
-
});
|
19
|
-
});
|
data/app/assets/javascripts/rails_modular_admin/_common/sameheight-items/sameheight-items.js
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
$(function() {
|
2
|
-
setSameHeights();
|
3
|
-
|
4
|
-
var resizeTimer;
|
5
|
-
|
6
|
-
$(window).resize(function() {
|
7
|
-
clearTimeout(resizeTimer);
|
8
|
-
resizeTimer = setTimeout(setSameHeights, 150);
|
9
|
-
});
|
10
|
-
});
|
11
|
-
|
12
|
-
|
13
|
-
function setSameHeights($container) {
|
14
|
-
|
15
|
-
$container = $container || $('.sameheight-container');
|
16
|
-
|
17
|
-
var viewport = ResponsiveBootstrapToolkit.current();
|
18
|
-
|
19
|
-
$container.each(function() {
|
20
|
-
|
21
|
-
var $items = $(this).find(".sameheight-item");
|
22
|
-
|
23
|
-
// Get max height of items in container
|
24
|
-
var maxHeight = 0;
|
25
|
-
|
26
|
-
$items.each(function() {
|
27
|
-
$(this).css({height: 'auto'});
|
28
|
-
maxHeight = Math.max(maxHeight, $(this).innerHeight());
|
29
|
-
});
|
30
|
-
|
31
|
-
|
32
|
-
// Set heights of items
|
33
|
-
$items.each(function() {
|
34
|
-
// Ignored viewports for item
|
35
|
-
var excludedStr = $(this).data('exclude') || '';
|
36
|
-
var excluded = excludedStr.split(',');
|
37
|
-
|
38
|
-
// Set height of element if it's not excluded on
|
39
|
-
if (excluded.indexOf(viewport) === -1) {
|
40
|
-
$(this).innerHeight(maxHeight);
|
41
|
-
}
|
42
|
-
});
|
43
|
-
});
|
44
|
-
}
|
@@ -1,10 +0,0 @@
|
|
1
|
-
module.exports.register = function (handlebars) {
|
2
|
-
handlebars.registerHelper('editor', function(options) {
|
3
|
-
// Partial
|
4
|
-
var template = handlebars.partials["app/_common/editor/editor"];
|
5
|
-
|
6
|
-
return template({
|
7
|
-
content: options.fn(this) || ""
|
8
|
-
});
|
9
|
-
});
|
10
|
-
};
|
@@ -1,34 +0,0 @@
|
|
1
|
-
$(function() {
|
2
|
-
|
3
|
-
$(".wyswyg").each(function() {
|
4
|
-
|
5
|
-
var $editor = $(this).find(".editor");
|
6
|
-
var $toolbar = $(this).find(".toolbar");
|
7
|
-
|
8
|
-
var editor = new Quill($editor.get(0), {
|
9
|
-
theme: 'snow',
|
10
|
-
// modules: {
|
11
|
-
// toolbar: toolbarOptions
|
12
|
-
// }
|
13
|
-
modules: {
|
14
|
-
toolbar: $toolbar.get(0)
|
15
|
-
}
|
16
|
-
});
|
17
|
-
|
18
|
-
// var $toolbar = $(this).find(".toolbar");
|
19
|
-
// var $editor = $(this).find(".editor");
|
20
|
-
|
21
|
-
|
22
|
-
// var editor = new Quill($editor.get(0), {
|
23
|
-
// theme: 'snow'
|
24
|
-
// });
|
25
|
-
|
26
|
-
// editor.addModule('toolbar', {
|
27
|
-
// container: $toolbar.get(0) // Selector for toolbar container
|
28
|
-
// });
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
});
|
33
|
-
|
34
|
-
});
|
@@ -1,14 +0,0 @@
|
|
1
|
-
// Animating dropdowns is temporary disabled
|
2
|
-
// Please feel free to send a pull request :)
|
3
|
-
|
4
|
-
// $(function() {
|
5
|
-
// $('.nav-profile > li > a').on('click', function() {
|
6
|
-
// var $el = $(this).next();
|
7
|
-
|
8
|
-
|
9
|
-
// animate({
|
10
|
-
// name: 'flipInX',
|
11
|
-
// selector: $el
|
12
|
-
// });
|
13
|
-
// });
|
14
|
-
// })
|
data/app/assets/javascripts/rails_modular_admin/app/_common/modals/modal-media/modal-media.js
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
var modalMedia = {
|
2
|
-
$el: $("#modal-media"),
|
3
|
-
result: {},
|
4
|
-
options: {},
|
5
|
-
open: function(options) {
|
6
|
-
options = options || {};
|
7
|
-
this.options = options;
|
8
|
-
|
9
|
-
|
10
|
-
this.$el.modal('show');
|
11
|
-
},
|
12
|
-
close: function() {
|
13
|
-
if ($.isFunction(this.options.beforeClose)) {
|
14
|
-
this.options.beforeClose(this.result);
|
15
|
-
}
|
16
|
-
|
17
|
-
this.$el.modal('hide');
|
18
|
-
|
19
|
-
if ($.isFunction(this.options.afterClose)) {
|
20
|
-
this.options.beforeClose(this.result);
|
21
|
-
}
|
22
|
-
}
|
23
|
-
};
|
@@ -1,155 +0,0 @@
|
|
1
|
-
$(function () {
|
2
|
-
|
3
|
-
// Local storage settings
|
4
|
-
var themeSettings = getThemeSettings();
|
5
|
-
|
6
|
-
// Elements
|
7
|
-
|
8
|
-
var $app = $('#app');
|
9
|
-
var $styleLink = $('#theme-style');
|
10
|
-
var $customizeMenu = $('#customize-menu');
|
11
|
-
|
12
|
-
// Color switcher
|
13
|
-
var $customizeMenuColorBtns = $customizeMenu.find('.color-item');
|
14
|
-
|
15
|
-
// Position switchers
|
16
|
-
var $customizeMenuRadioBtns = $customizeMenu.find('.radio');
|
17
|
-
|
18
|
-
|
19
|
-
// /////////////////////////////////////////////////
|
20
|
-
|
21
|
-
// Initial state
|
22
|
-
|
23
|
-
// On setting event, set corresponding options
|
24
|
-
|
25
|
-
// Update customize view based on options
|
26
|
-
|
27
|
-
// Update theme based on options
|
28
|
-
|
29
|
-
/************************************************
|
30
|
-
* Initial State
|
31
|
-
*************************************************/
|
32
|
-
|
33
|
-
setThemeSettings();
|
34
|
-
|
35
|
-
/************************************************
|
36
|
-
* Events
|
37
|
-
*************************************************/
|
38
|
-
|
39
|
-
// set theme type
|
40
|
-
$customizeMenuColorBtns.on('click', function() {
|
41
|
-
themeSettings.themeName = $(this).data('theme');
|
42
|
-
|
43
|
-
setThemeSettings();
|
44
|
-
});
|
45
|
-
|
46
|
-
|
47
|
-
$customizeMenuRadioBtns.on('click', function() {
|
48
|
-
|
49
|
-
var optionName = $(this).prop('name');
|
50
|
-
var value = $(this).val();
|
51
|
-
|
52
|
-
themeSettings[optionName] = value;
|
53
|
-
|
54
|
-
setThemeSettings();
|
55
|
-
});
|
56
|
-
|
57
|
-
function setThemeSettings() {
|
58
|
-
setThemeState()
|
59
|
-
.delay(config.delayTime)
|
60
|
-
.queue(function (next) {
|
61
|
-
|
62
|
-
setThemeColor();
|
63
|
-
setThemeControlsState();
|
64
|
-
saveThemeSettings();
|
65
|
-
|
66
|
-
$(document).trigger("themechange");
|
67
|
-
|
68
|
-
next();
|
69
|
-
});
|
70
|
-
}
|
71
|
-
|
72
|
-
/************************************************
|
73
|
-
* Update theme based on options
|
74
|
-
*************************************************/
|
75
|
-
|
76
|
-
function setThemeState() {
|
77
|
-
// set theme type
|
78
|
-
if (themeSettings.themeName) {
|
79
|
-
$styleLink.attr('href', 'css/app-' + themeSettings.themeName + '.css');
|
80
|
-
}
|
81
|
-
else {
|
82
|
-
$styleLink.attr('href', 'css/app.css');
|
83
|
-
}
|
84
|
-
|
85
|
-
// App classes
|
86
|
-
$app.removeClass('header-fixed footer-fixed sidebar-fixed');
|
87
|
-
|
88
|
-
// set header
|
89
|
-
$app.addClass(themeSettings.headerPosition);
|
90
|
-
|
91
|
-
// set footer
|
92
|
-
$app.addClass(themeSettings.footerPosition);
|
93
|
-
|
94
|
-
// set footer
|
95
|
-
$app.addClass(themeSettings.sidebarPosition);
|
96
|
-
|
97
|
-
return $app;
|
98
|
-
}
|
99
|
-
|
100
|
-
/************************************************
|
101
|
-
* Update theme controls based on options
|
102
|
-
*************************************************/
|
103
|
-
|
104
|
-
function setThemeControlsState() {
|
105
|
-
// set color switcher
|
106
|
-
$customizeMenuColorBtns.each(function() {
|
107
|
-
if($(this).data('theme') === themeSettings.themeName) {
|
108
|
-
$(this).addClass('active');
|
109
|
-
}
|
110
|
-
else {
|
111
|
-
$(this).removeClass('active');
|
112
|
-
}
|
113
|
-
});
|
114
|
-
|
115
|
-
// set radio buttons
|
116
|
-
$customizeMenuRadioBtns.each(function() {
|
117
|
-
var name = $(this).prop('name');
|
118
|
-
var value = $(this).val();
|
119
|
-
|
120
|
-
if (themeSettings[name] === value) {
|
121
|
-
$(this).prop("checked", true );
|
122
|
-
}
|
123
|
-
else {
|
124
|
-
$(this).prop("checked", false );
|
125
|
-
}
|
126
|
-
});
|
127
|
-
}
|
128
|
-
|
129
|
-
/************************************************
|
130
|
-
* Update theme color
|
131
|
-
*************************************************/
|
132
|
-
function setThemeColor(){
|
133
|
-
config.chart.colorPrimary = tinycolor($ref.find(".chart .color-primary").css("color"));
|
134
|
-
config.chart.colorSecondary = tinycolor($ref.find(".chart .color-secondary").css("color"));
|
135
|
-
}
|
136
|
-
|
137
|
-
/************************************************
|
138
|
-
* Storage Functions
|
139
|
-
*************************************************/
|
140
|
-
|
141
|
-
function getThemeSettings() {
|
142
|
-
var settings = (localStorage.getItem('themeSettings')) ? JSON.parse(localStorage.getItem('themeSettings')) : {};
|
143
|
-
|
144
|
-
settings.headerPosition = settings.headerPosition || '';
|
145
|
-
settings.sidebarPosition = settings.sidebarPosition || '';
|
146
|
-
settings.footerPosition = settings.footerPosition || '';
|
147
|
-
|
148
|
-
return settings;
|
149
|
-
}
|
150
|
-
|
151
|
-
function saveThemeSettings() {
|
152
|
-
localStorage.setItem('themeSettings', JSON.stringify(themeSettings));
|
153
|
-
}
|
154
|
-
|
155
|
-
});
|