From 69b970b72d30b7a7c79a3999275952fdc4eca165 Mon Sep 17 00:00:00 2001 From: swapnilmj Date: Fri, 27 Jul 2012 21:55:37 +0530 Subject: [PATCH] loads table list on click of addTable btn ; Fade effects. --- coffee/design.coffee | 47 +++++++++++++++++++------------------------- coffee/design.js | 29 +++++++++++++++++---------- index.php | 8 ++++---- js/tbl-selection.js | 30 +++++++++++++++++----------- 4 files changed, 61 insertions(+), 53 deletions(-) diff --git a/coffee/design.coffee b/coffee/design.coffee index 94f91f2..90c9e63 100644 --- a/coffee/design.coffee +++ b/coffee/design.coffee @@ -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) @@ -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') @@ -55,7 +51,6 @@ $ -> else #input #hide input - #SQLDataRestorer.init(0, newSQL) newSQL = $('#sql-text-ip').val() SQLDataRestorer.init(0, newSQL) #change btn label to Edit SQL @@ -63,26 +58,14 @@ $ -> $('#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" @@ -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) - \ No newline at end of file + } \ No newline at end of file diff --git a/coffee/design.js b/coffee/design.js index c07d5a0..b6704e9 100644 --- a/coffee/design.js +++ b/coffee/design.js @@ -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", @@ -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); + } + } + }; }); diff --git a/index.php b/index.php index 87a71a3..c9ee59b 100644 --- a/index.php +++ b/index.php @@ -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()); @@ -76,6 +75,8 @@ $('.bool.expr').draggable({ helper:'clone' }); + App.setAppVisibility(); + bindAddTableEvts(); }) @@ -93,7 +94,7 @@ Schema :