Skip to content

Commit

Permalink
add js function to show notice and error
Browse files Browse the repository at this point in the history
  • Loading branch information
manxingxing committed Aug 3, 2014
1 parent 82bd01b commit c9e3612
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 23 deletions.
18 changes: 17 additions & 1 deletion app/assets/javascripts/common.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ function selectDatasets(select) {

function clone_element_before(element) {
var input = element.previousSibling.previousSibling;
alert(input);
var name = input.name;
var id= input.id;
name = name.replace(/\[([0-9])\]*/, function(variable, p1) {
Expand Down Expand Up @@ -142,6 +141,23 @@ function selectElementText(element) {
}
}

function showAlert(str, type){
type = type || 'notice';
var html = "<div class='alert alert-" + type + "'>" + str + "<a href='#' class='remove_parent'></a></div>";
var jqEle = $(html);
$("#content").prepend(jqEle);
return jqEle;
}

function hideAlert(){
if (arguments.length > 0){
var ele = arguments[0];
$(ele).remove();
} else {
$(".alert", "#content").remove();
}
}


$(function(){
$("table.tablesorter").tablesorter();
Expand Down
2 changes: 1 addition & 1 deletion app/assets/stylesheets/datasets.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ ul.switchers {

#approval-area {
#too-many-alert {
padding: 5px;
padding: 5px 10px;
border: solid 1px #cdcdcd;
margin-bottom: 10px;
}
Expand Down
28 changes: 13 additions & 15 deletions app/assets/stylesheets/style.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -545,21 +545,19 @@ input#search_term {
}

/* --- Flashes ----------------------------------------------- */

#notice {
border: 2px solid #18921e;
clear: both;
padding: 10px;
margin-bottom: 10px;
font-weight: bold;
}

#error {
border: 2px solid #f00;
clear: both;
padding: 10px;
margin-bottom: 10px;
font-weight: bold;
.alert {
clear: both;
padding: 10px;
margin-bottom: 10px;
font-weight: bold;
border:2px solid #aaa;
&.alert-notice{
border: 2px solid #18921e;
}
&.alert-error{
border: 2px solid #f00;
.remove_parent{color:red;}
}
}

div#errorExplanation {
Expand Down
10 changes: 4 additions & 6 deletions app/views/layouts/application.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,10 @@
#login
= render :partial => 'user_sessions/login'
#content
#error{class: flash[:error].present? ? nil : 'hidden'}
= flash[:error]
= link_to "", "#", class: "hide_parent"
#notice{class: flash[:notice].present? ? nil : 'hidden'}
= flash[:notice]
= link_to "", "#", class: "hide_parent"
- flash.keys.each do |type|
.alert{class: "alert-#{type}"}
= flash[type]
= link_to "", "#", class: "remove_parent"

- sidebar_exists = content_for?(:actions) || content_for?(:info)
#main{:class => sidebar_exists ? "span-8 append-1" : "span-12"}
Expand Down

0 comments on commit c9e3612

Please sign in to comment.