-
Notifications
You must be signed in to change notification settings - Fork 14.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
more css fixes #182
more css fixes #182
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -149,7 +149,8 @@ var Dashboard = function (dashboardData) { | |
editor.setTheme("ace/theme/crimson_editor"); | ||
editor.setOptions({ | ||
minLines: 16, | ||
maxLines: Infinity | ||
maxLines: Infinity, | ||
useWorker: false | ||
}); | ||
editor.getSession().setMode("ace/mode/css"); | ||
|
||
|
@@ -159,8 +160,10 @@ var Dashboard = function (dashboardData) { | |
$("#css_template").on("change", function () { | ||
var css = $(this).find('option:selected').data('css'); | ||
editor.setValue(css); | ||
|
||
$('#dash_css').val(css); | ||
$("#user_style").html(css); | ||
injectCss("dashboard-template", css); | ||
|
||
}); | ||
$('#filters').click(function () { | ||
alert(dashboard.readFilters()); | ||
|
@@ -170,19 +173,51 @@ var Dashboard = function (dashboardData) { | |
gridster.remove_widget(li); | ||
}); | ||
|
||
$(".slice_info").click(function () { | ||
var widget = $(this).parents('.widget'); | ||
var slice_description = widget.find('.slice_description'); | ||
slice_description.slideToggle(500, function () { | ||
widget.find('.refresh').click(); | ||
}); | ||
$("li.widget").click(function (e) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FYI this is typically better practice for event listeners, you place the listener on the parent element and the event "bubbles" up from the dom element you click on, up to the parent with the listener. then you don't have to add a million listeners. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Gotcha. |
||
var $this = $(this); | ||
var $target = $(e.target); | ||
|
||
if ($target.hasClass("slice_info")) { | ||
$this.find(".slice_description").slideToggle(0, function () { | ||
$this.find('.refresh').click(); | ||
}); | ||
} else if ($target.hasClass("controls-toggle")) { | ||
$this.find(".chart-controls").toggle(); | ||
} | ||
}); | ||
|
||
editor.on("change", function () { | ||
var css = editor.getValue(); | ||
$('#dash_css').val(css); | ||
$("#user_style").html(css); | ||
injectCss("dashboard-template", css); | ||
}); | ||
|
||
var css = $('.dashboard').data('css'); | ||
injectCss("dashboard-template", css); | ||
|
||
// Injects the passed css string into a style sheet with the specified className | ||
// If a stylesheet doesn't exist with the passed className, one will be injected into <head> | ||
function injectCss(className, css) { | ||
|
||
var head = document.head || document.getElementsByTagName('head')[0]; | ||
var style = document.querySelector('.' + className); | ||
|
||
if (!style) { | ||
if (className.split(' ').length > 1) { | ||
throw new Error("This method only supports selections with a single class name."); | ||
} | ||
style = document.createElement('style'); | ||
style.className = className; | ||
style.type = 'text/css'; | ||
head.appendChild(style); | ||
} | ||
|
||
if (style.styleSheet) { | ||
style.styleSheet.cssText = css; | ||
} else { | ||
style.innerHTML = css; | ||
} | ||
} | ||
} | ||
}); | ||
dashboard.init(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
require('../node_modules/select2/select2.css'); | ||
require('../node_modules/select2-bootstrap-css/select2-bootstrap.min.css'); | ||
require('../node_modules/jquery-ui/themes/base/jquery-ui.css') | ||
require('../node_modules/jquery-ui/themes/base/jquery-ui.css'); | ||
require('select2'); | ||
require('../vendor/select2.sortable.js'); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
.select2-highlighted>.filter_box { | ||
.select2-highlighted > .filter_box { | ||
background-color: transparent; | ||
border: 1px dashed black; | ||
} | ||
|
||
.dashboard .filter_box .slice_container > div { | ||
padding-top: 0; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,12 @@ | ||
{% extends "panoramix/basic.html" %} | ||
|
||
{% block head_css %} | ||
{{ super() }} | ||
<style id="user_style" type="text/css"> | ||
{{ dashboard.css or '' }} | ||
</style> | ||
{% block head_js %} | ||
{{ super() }} | ||
<script src="/static/assets/javascripts/dist/dashboard.entry.js"></script> | ||
{% endblock %} | ||
|
||
{% block body %} | ||
<div class="dashboard container-fluid" data-dashboard="{{ dashboard.json_data }}"> | ||
<div class="dashboard container-fluid" data-dashboard="{{ dashboard.json_data }}" data-css="{{ dashboard.css }}"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added the css here as data and created the |
||
|
||
<!-- Modal --> | ||
<div class="modal fade" id="css_modal" tabindex="-1" role="dialog"> | ||
|
@@ -17,10 +15,11 @@ | |
<div class="modal-header"> | ||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> | ||
<h4 class="modal-title" id="myModalLabel">Dashboard CSS</h4> | ||
<h6><strong>Styling applies to this dashboard only</strong></h6> | ||
</div> | ||
<div class="modal-body"> | ||
<select id="css_template" class="select2" style="margin-bottom: 5px;"> | ||
<option value="" data-css="">-= CSS templates =-</option> | ||
<option value="" data-css="">CSS template</option> | ||
{% for t in templates %} | ||
<option value="{{ t.id }}" data-css="{{t.css}}"> | ||
{{ t.template_name }} | ||
|
@@ -81,14 +80,21 @@ <h2> | |
data-sizey="{{ pos.size_y or 4 }}"> | ||
|
||
<div class="row chart-header"> | ||
|
||
<div class="col-md-12 text-center header"> | ||
{{ slice.slice_name }} | ||
{% if slice.description %} | ||
<i class="fa fa-info-circle slice_info" slice_id="{{ slice.id }}"></i> | ||
<a title="Toggle chart description"> | ||
<i class="fa fa-info-circle slice_info" slice_id="{{ slice.id }}"></i> | ||
</a> | ||
{% endif %} | ||
<a title="Toggle chart controls"> | ||
<i class="fa fa-ellipsis-h controls-toggle"></i> | ||
</a> | ||
</div> | ||
<div class="row text-center"> | ||
<div class="chart-controls col-md-12"> | ||
|
||
<div class="row text-center chart-controls"> | ||
<div class="col-md-12"> | ||
<a title="Move chart"> | ||
<i class="fa fa-arrows drag"></i> | ||
</a> | ||
|
@@ -106,6 +112,7 @@ <h2> | |
</a> | ||
</div> | ||
</div> | ||
|
||
</div> | ||
|
||
<div class="row"> | ||
|
@@ -130,7 +137,3 @@ <h2> | |
</div> | ||
</div> | ||
{% endblock %} | ||
|
||
{% block tail_js %} | ||
<script src="/static/assets/javascripts/dist/dashboard.entry.js"></script> | ||
{% endblock %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is the flag for not watching errors.