Skip to content

Commit

Permalink
loads table list on click of addTable btn ; Fade effects.
Browse files Browse the repository at this point in the history
  • Loading branch information
swapnilmj committed Jul 27, 2012
1 parent 83413de commit 69b970b
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 53 deletions.
47 changes: 20 additions & 27 deletions coffee/design.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ $ ->
$(this).addClass('selected')

if $('#right-pane').hasClass('results-mode')
#fillResultData($('.output pre').html())
#sqlOut="SELECT * FROM mDC"
#sqlOut = $('.output pre').html()
sqlOut = QueryMaint.getSQL()
fillResultData(sqlOut)

Expand All @@ -29,7 +26,6 @@ $ ->
$('#results-pane').html(html)
)

#$('#design-results-btns .results-mode').on('clic)'clic

#set design-mode as default
$('#design-results-btns .design-mode').trigger('click')
Expand All @@ -55,34 +51,21 @@ $ ->

else #input
#hide input
#SQLDataRestorer.init(0, newSQL)
newSQL = $('#sql-text-ip').val()
SQLDataRestorer.init(0, newSQL)
#change btn label to Edit SQL
$(this).html('Edit SQL')

$('#sql-out').toggleClass 'output-mode input-mode'

###
$('#pane-where textarea')
.on 'blur', (event)->
SQLPaneView.render()
###
$('select[name=schema]')
.on 'blur', (evt)->
schema = $(evt.target).val()
#$.cookie 'schema', schema
#$.ajax({
# url:"ajax/table_list.php"
# data:{ schema: schema }
# cache:false
#}).done( (html) ->
# $('#table-list').html(html)
# bindAddTableEvts()
#)
LoadTableList schema
if $('select[name=schema]').val() == ""
App.reset()

window.LoadTableList = (schema)->
window.LoadTableList = (schema)->
if $.cookie('schema') == schema then return #no loading required
$.cookie 'schema', schema
$.ajax({
url:"ajax/table_list.php"
Expand All @@ -93,15 +76,25 @@ $ ->
bindAddTableEvts()
)


$('#pane-where textarea')
.on 'keyup', _.debounce(
(event) -> SQLPaneView.render(),
500)

$('#pane-where textarea')
.on 'blur', (event)->
SQLPaneView.render()

LoadTableList $('select[name=schema]').val()
window.App = {
reset : ->
$('select[name=schema]').val("")
if localStorage then localStorage.clear()
setAppVisibility()
SQLPaneView.render()

setAppVisibility : ->
#sets visibility of all but basic (top) ctrls
show = $('select[name=schema]').val() != ""
if show
$('.pane').fadeIn(500)
else
$('.pane').fadeOut(0)

}
29 changes: 19 additions & 10 deletions coffee/design.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,13 @@ $(function() {
}
return $('#sql-out').toggleClass('output-mode input-mode');
});
/*
$('#pane-where textarea')
.on 'blur', (event)->
SQLPaneView.render()
*/
$('select[name=schema]').on('blur', function(evt) {
var schema;
schema = $(evt.target).val();
return LoadTableList(schema);
if ($('select[name=schema]').val() === "") return App.reset();
});
window.LoadTableList = function(schema) {
if ($.cookie('schema') === schema) return;
$.cookie('schema', schema);
return $.ajax({
url: "ajax/table_list.php",
Expand All @@ -71,8 +67,21 @@ $(function() {
$('#pane-where textarea').on('keyup', _.debounce(function(event) {
return SQLPaneView.render();
}, 500));
$('#pane-where textarea').on('blur', function(event) {
return SQLPaneView.render();
});
return LoadTableList($('select[name=schema]').val());
return window.App = {
reset: function() {
$('select[name=schema]').val("");
if (localStorage) localStorage.clear();
setAppVisibility();
return SQLPaneView.render();
},
setAppVisibility: function() {
var show;
show = $('select[name=schema]').val() !== "";
if (show) {
return $('.pane').fadeIn(500);
} else {
return $('.pane').fadeOut(0);
}
}
};
});
8 changes: 4 additions & 4 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@

window.swapnil = {};
$(function(){
//showTableList(false);
if(localStorage) localStorage.clear();
if(localStorage) localStorage.clear();

$('.btn-refresh').click(function () {
$('.output > pre').html(QueryBuilder.GenerateSQL());
Expand All @@ -76,6 +75,8 @@
$('.bool.expr').draggable({
helper:'clone'
});
App.setAppVisibility();
bindAddTableEvts();
})
</script>
</head>
Expand All @@ -93,7 +94,7 @@
<span style="float: left;">
Schema :
<select name="schema" >
<option value="" > --Select-- </option>
<option value="" > -- Select schema -- </option>

<?php

Expand Down Expand Up @@ -148,7 +149,6 @@
</div>
<div id="table-list">


</div>
<div id="table-btns">
<span class="butn ok">
Expand Down
30 changes: 18 additions & 12 deletions js/tbl-selection.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@ $( function(){
}

window.bindAddTableEvts = function(){
$('#table-btns .ok').on('click', function(event){
$('#table-list .selected').each( function(i){
//continue only if it is not added
if(! $(this).hasClass('added')){
var tblName = $.trim($(this).html());
AddTable(tblName);
$(this).addClass('added');
}
} )
showTableList(false);
})
$('#table-btns .ok').on('click', function(event){
App.setAppVisibility();
$('#table-list .selected').each( function(i){
//continue only if it is not added
if(! $(this).hasClass('added')){
var tblName = $.trim($(this).html());
AddTable(tblName);
$(this).addClass('added');
}
})
showTableList(false);
})

$('#table-btns .cancel').on('click', function(event){
showTableList(false);
Expand All @@ -36,6 +36,12 @@ $( function(){
})

$('#btn-add-table').on('click', function(event){
schema = $('select[name=schema]').val()
if(schema == ""){
alert("Select a schema and then add tables")
return
}
LoadTableList(schema);
showTableList(true);

});
Expand Down

0 comments on commit 69b970b

Please sign in to comment.