changes in table - name table

1.0
Javier Álvarez Medina 14 years ago
parent 35a593002f
commit 364f2f9506

@ -9,7 +9,7 @@
<div class="mamufas">
<div class="inner_subheader">
<div class="left">
<h2><%= @table.name %></h2>
<h2><a href="#change_title"><%= @table.name %></a></h2>
<p class="status"><a class="<%= table_privacy_text(@table).downcase %>" href="#change_privacy"><%= table_privacy_text(@table) %></a></p>
<% unless @table.tags.blank? %>
<span class="tags">

@ -9,6 +9,7 @@ javascripts:
- table:
- plugins/jquery.livequery.min.js
- plugins/cDBtable.js
- admin/table_elements.js
- admin/table.js
stylesheets:

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 380 B

@ -9,149 +9,7 @@
total: 5000
}
);
//SUBHEADER EVENTS AND FLOATING WINDOWS
//Save operation loader
$('section.subheader').append(
'<div class="performing_op">' +
'<p class="loading">Loading...</p>'+
'</div>');
// change table status
$('div.inner_subheader div.left').append(
'<span class="privacy_window">'+
'<ul>'+
'<li class="public '+((status=="public")?'selected':'')+'"><a href="#"><strong>Public</strong> (visible to others)</a></li>'+
'<li class="private '+((status=="private")?'selected':'')+'"><a href="#"><strong>Private</strong> (visible to you)</a></li>'+
'</ul>'+
'</span>');
$('span.privacy_window ul li a').livequery('click',function(ev){
ev.stopPropagation();
ev.preventDefault();
var parent_li = $(this).parent();
if (parent_li.hasClass('selected')) {
$('span.privacy_window').hide();
} else {
var old_value = $('span.privacy_window ul li.selected a strong').text().toLowerCase();
$('span.privacy_window ul li').removeClass('selected');
parent_li.addClass('selected');
var new_value = $('span.privacy_window ul li.selected a strong').text().toLowerCase();
$('span.privacy_window').hide();
$('p.status a').removeClass('public private').addClass(new_value).text(new_value);
changesRequest('/toggle_privacy','privacy',new_value.toUpperCase(),old_value);
}
});
$('p.status a').livequery('click',function(ev){
ev.stopPropagation();
ev.preventDefault();
var privacy_window = $(this).parent().parent().children('span.privacy_window');
if (privacy_window.is(':visible')) {
privacy_window.hide();
} else {
var status_position = $('p.status a').position();
privacy_window.css('left',status_position.left-72+'px').show();
}
});
// End table status binding
$('div.inner_subheader div.right').append(
'<span class="advanced_options">'+
'<a href="#close_advanced_options" class="advanced">advanced<span></span></a>'+
'<ul>'+
'<li><a href="#export_data">Export data...</a></li>'+
'<li><a href="#save_table">Save table as...</a></li>'+
'</ul>'+
'</span>');
$('p.settings a.settings, span.advanced_options a.advanced').livequery('click',function(ev){
ev.stopPropagation();
ev.preventDefault();
if (!$('span.advanced_options').is(':visible')) {
$(this).parent().parent().children('span.advanced_options').show();
$('body').click(function(event) {
if (!$(event.target).closest('span.advanced_options').length) {
$('span.advanced_options').hide();
$('body').unbind('click');
};
});
} else {
$(this).parent().hide();
$('body').unbind('click');
}
});
});
function changesRequest(url_change,param,value,old_value) {
//show loader
$('div.performing_op').show();
var params = {};
params[param] = value;
$.ajax({
dataType: 'json',
type: "PUT",
url: '/api/json/tables/'+table_id+url_change,
data: params,
success: function(data) {
successActionPerform(param);
},
error: function(e) {
errorActionPerforming(param,old_value);
}
});
}
function successActionPerform(param) {
switch (param) {
case 'privacy': $('div.performing_op p').removeClass('loading').addClass('success').text('The status has been changed');
var width_text = $('div.performing_op p').width();
$('div.performing_op').css('margin-left','-'+(width_text/2)+'px');
break;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
default:
}
$('div.performing_op').delay(1000).fadeOut(function(){resetLoader()});
}
function errorActionPerforming(param, old_value) {
switch (param) {
case 'privacy': $('div.performing_op p').removeClass('loading').addClass('error').text('The status has not been changed. Try again later.');
var width_text = $('div.performing_op p').width();
$('div.performing_op').css('margin-left','-'+(width_text/2)+'px');
$('span.privacy_window ul li').removeClass('selected');
$('span.privacy_window ul li.'+old_value).addClass('selected');
$('p.status a').removeClass('public private').addClass(old_value).text(old_value);
break;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
default:
}
$('div.performing_op').delay(1000).fadeOut(function(){resetLoader()});
}
function resetLoader() {
$('div.performing_op p').removeClass('success').addClass('loading').text('Loading...');
var width_text = $('div.performing_op p').width();
$('div.performing_op').css('margin-left','-'+(width_text/2)+'px');
}

@ -0,0 +1,210 @@
$(document).ready(function(){
//SUBHEADER EVENTS AND FLOATING WINDOWS
//Save operation loader
$('section.subheader').append(
'<div class="performing_op">' +
'<p class="loading">Loading...</p>'+
'</div>');
//Change title name window
$('div.inner_subheader div.left').append(
'<span class="title_window">'+
'<p>Pick a name for this table</p>'+
'<form id="change_name"><input type="text" name="title"/>'+
'<input type="submit" value="Save" name="submit"/></form>'+
'</span>');
//Bind events
// -Open window
$('section.subheader h2 a').livequery('click',function(ev){
ev.stopPropagation();
ev.preventDefault();
if ($('span.title_window').is(':visible')) {
$('span.title_window').hide();
} else {
var position = ($(this).parent().width()/2) - 118;
if ($('section.subheader h2 a').text()=='Untitle table') {
$('span.title_window input[type="text"]').attr('value','');
} else {
$('span.title_window input[type="text"]').attr('value',$('section.subheader h2 a').text());
}
$('span.title_window').css('left',position+'px').show();
$('span.title_window input[type="text"]').focus();
}
});
$('#change_name').live('submit',function(){
console.log('jamon');
saveTableTitle();
});
// Change table status
$('div.inner_subheader div.left').append(
'<span class="privacy_window">'+
'<ul>'+
'<li class="public '+((status=="public")?'selected':'')+'"><a href="#"><strong>Public</strong> (visible to others)</a></li>'+
'<li class="private '+((status=="private")?'selected':'')+'"><a href="#"><strong>Private</strong> (visible to you)</a></li>'+
'</ul>'+
'</span>');
$('span.privacy_window ul li a').livequery('click',function(ev){
ev.stopPropagation();
ev.preventDefault();
var parent_li = $(this).parent();
if (parent_li.hasClass('selected')) {
$('span.privacy_window').hide();
} else {
var old_value = $('span.privacy_window ul li.selected a strong').text().toLowerCase();
$('span.privacy_window ul li').removeClass('selected');
parent_li.addClass('selected');
var new_value = $('span.privacy_window ul li.selected a strong').text().toLowerCase();
$('span.privacy_window').hide();
$('p.status a').removeClass('public private').addClass(new_value).text(new_value);
changesRequest('/toggle_privacy','privacy',new_value.toUpperCase(),old_value);
}
});
$('p.status a').livequery('click',function(ev){
ev.stopPropagation();
ev.preventDefault();
var privacy_window = $(this).parent().parent().children('span.privacy_window');
if (privacy_window.is(':visible')) {
privacy_window.hide();
} else {
var status_position = $('p.status a').position();
privacy_window.css('left',status_position.left-72+'px').show();
}
});
// End table status binding
$('div.inner_subheader div.right').append(
'<span class="advanced_options">'+
'<a href="#close_advanced_options" class="advanced">advanced<span></span></a>'+
'<ul>'+
'<li><a href="#export_data">Export data...</a></li>'+
'<li><a href="#save_table">Save table as...</a></li>'+
'</ul>'+
'</span>');
$('p.settings a.settings, span.advanced_options a.advanced').livequery('click',function(ev){
ev.stopPropagation();
ev.preventDefault();
if (!$('span.advanced_options').is(':visible')) {
$(this).parent().parent().children('span.advanced_options').show();
$('body').click(function(event) {
if (!$(event.target).closest('span.advanced_options').length) {
$('span.advanced_options').hide();
$('body').unbind('click');
};
});
} else {
$(this).parent().hide();
$('body').unbind('click');
}
});
});
function changesRequest(url_change,param,value,old_value) {
//show loader
$('div.performing_op').show();
var params = {};
params[param] = value;
$.ajax({
dataType: 'json',
type: "PUT",
url: '/api/json/tables/'+table_id+url_change,
data: params,
success: function(data) {
successActionPerform(param);
},
error: function(e) {
errorActionPerforming(param,old_value);
}
});
}
function successActionPerform(param) {
switch (param) {
case 'privacy': $('div.performing_op p').removeClass('loading').addClass('success').text('The status has been changed');
var width_text = $('div.performing_op p').width();
$('div.performing_op').css('margin-left','-'+(width_text/2)+'px');
break;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
case 'name': $('div.performing_op p').removeClass('loading').addClass('success').text('The table name has been changed');
var width_text = $('div.performing_op p').width();
$('div.performing_op').css('margin-left','-'+(width_text/2)+'px');
break;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
default:
}
$('div.performing_op').delay(2000).fadeOut(function(){resetLoader()});
}
function errorActionPerforming(param, old_value) {
switch (param) {
case 'privacy': $('div.performing_op p').removeClass('loading').addClass('error').text('The status has not been changed. Try again later.');
var width_text = $('div.performing_op p').width();
$('div.performing_op').css('margin-left','-'+(width_text/2)+'px');
$('span.privacy_window ul li').removeClass('selected');
$('span.privacy_window ul li.'+old_value).addClass('selected');
$('p.status a').removeClass('public private').addClass(old_value).text(old_value);
break;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
case 'name': $('div.performing_op p').removeClass('loading').addClass('error').text('The table name has not been changed. Try again later.');
var width_text = $('div.performing_op p').width();
$('div.performing_op').css('margin-left','-'+(width_text/2)+'px');
$('section.subheader h2 a').text(old_value);
break;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
default:
}
$('div.performing_op').delay(2000).fadeOut(function(){resetLoader()});
}
// -Save table name
function saveTableTitle() {
var new_value = $('span.title_window input[type="text"]').attr('value');
var old_value = $('section.subheader h2 a').text();
if (new_value==old_value) {
$('span.title_window').hide();
} else if (new_value=='') {
$('span.title_window input').css('border-color','#D05153');
setTimeout(function(){$('span.title_window input').css('border-color','#999999')},1000);
} else {
$('section.subheader h2 a').text(new_value);
$('span.title_window').hide();
changesRequest('/update','name',new_value,old_value);
}
}
function resetLoader() {
$('div.performing_op p').removeClass('success').addClass('loading').text('Loading...');
var width_text = $('div.performing_op p').width();
$('div.performing_op').css('margin-left','-'+(width_text/2)+'px');
}

@ -15,6 +15,8 @@ section.subheader {position:absolute; top:58px; left:0; width:100%; min-width:88
section.subheader div.mamufas {float:left; width:100%; background:url('/images/admin/common/sub_header_bkg.png') repeat-x 0 0;}
section.subheader div.left {position:relative; float:left; width:600px; height:88px; padding:15px 0 0 0; margin:0 0 0 40px;}
section.subheader h2 {float:left; width:auto; font:bold 21px Arial; color:white;}
section.subheader h2 a {color:white; text-decoration:none;}
section.subheader h2 a:hover {font-style:italic;}
section.subheader p.status {float:left; width:auto;}
section.subheader p.status a {float:left; padding:2px 7px; margin:4px 0 0 10px; border-radius:8px; -webkit-border-radius:8px; -moz-border-radius:8px; font:bold 11px Arial; color:white; text-decoration:none; text-transform:uppercase;}
section.subheader p.status a.public {background:#6FBE6F;}
@ -74,6 +76,16 @@ section.subheader div.performing_op p {font:normal 13px Arial; color:#333333; pa
section.subheader div.performing_op p.loading {padding:8px 12px 8px 32px; background:url('/images/admin/icons/watch.png') no-repeat 12px 9px #FFEAA4;}
section.subheader div.performing_op p.success {padding:8px 12px; background:#99CC66; border-bottom-color:#A5BB93; color:#111111;}
section.subheader div.performing_op p.error {padding:8px 12px; background:#FF5F5F; border-bottom-color:#D05153; color:white;}
/*Change table title*/
section.subheader span.title_window {position:absolute; display:none; top:22px; right:50px; width:200px; height:67px; padding:33px 18px 0 18px; background:url('/images/admin/table/save_title_bkg.png') no-repeat 0 0;}
section.subheader span.title_window p {font:bold 13px Arial; color:#000000;}
section.subheader span.title_window input[type="text"] {float:left; width:134px; height:14px; margin:5px 0 0 0; padding:6px 7px; background:white; color:#999999; border:none; font:normal 14px Arial; border:1px solid #999999; border-right:0;
-webkit-border-top-left-radius: 3px; -webkit-border-bottom-left-radius: 3px; -moz-border-radius-topleft: 3px; -moz-border-radius-bottomleft: 3px; border-top-left-radius: 3px; border-bottom-left-radius: 3px;}
section.subheader span.title_window input:focus {outline:none; color:#333333;}
section.subheader span.title_window input[type="submit"] {float:right; width:50px; height:28px; margin:5px 1px 0 0; padding:6px 0; font:bold 12px Arial; color:#333333; text-align:center; border:1px solid #999999; text-decoration:none;
-webkit-border-top-right-radius: 3px; -webkit-border-bottom-right-radius: 3px; -moz-border-radius-topright: 3px; -moz-border-radius-bottomright: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px;
background-image:-moz-linear-gradient(100% 100% 90deg, #FFFFFF, #CACBCE); background-image:-webkit-gradient(linear, 0% 0%, 0% 100%, from(#FFFFFF), to(#CACBCE));}
section.subheader span.title_window input[type="submit"]:hover {background-image:-moz-linear-gradient(100% 100% 90deg, #CACBCE, #FFFFFF); background-image:-webkit-gradient(linear, 0% 0%, 0% 100%, from(#CACBCE), to(#FFFFFF)); cursor:pointer;}

Loading…
Cancel
Save