From 90e51dbe3ac372283dfb9f38464f6687e26b704d Mon Sep 17 00:00:00 2001 From: sanj Date: Wed, 12 Jan 2011 15:58:18 +0530 Subject: [PATCH] resizing, and some bugs --- itf/api/views.py | 19 +++++++++++++ itf/bestpractices/models.py | 1 + itf/static/js/itf/itf.js | 57 ++++++++++++++++++++++++------------- itf/static/js/jquery.js | 2 +- 4 files changed, 58 insertions(+), 21 deletions(-) diff --git a/itf/api/views.py b/itf/api/views.py index 66e4f7e..3f40ffe 100644 --- a/itf/api/views.py +++ b/itf/api/views.py @@ -101,15 +101,34 @@ def api_find(request): model = getModel(data) response = json_response({}) l = model.get_list(data) + if data.has_key('ids'): + ids = data['ids'] + else: + ids = [] if data.has_key('range'): response['data']['items'] = l else: response['data']['items'] = len(l) + response['data']['positions'] = _get_positions(ids, l) response['status'] = {'code': 200} return render_to_json_response(response) +def _get_positions(ids, l): + ret = {} + i = 0 + for id in ids: + for obj in l: + if obj['id'] == id: + ret[id] = i + break + i += 1 + return ret + + def api_preview(request): data = json.loads(request.POST['data']) + if not data.has_key('id'): + return render_to_json_response({'status': {'code': 404}}) id = int(data['id']) model = getModel(data) response = json_response({}) diff --git a/itf/bestpractices/models.py b/itf/bestpractices/models.py index f4edcc1..3bbcecf 100644 --- a/itf/bestpractices/models.py +++ b/itf/bestpractices/models.py @@ -24,6 +24,7 @@ class BestPractice(ItfModel): def info_dict(self): return { + 'id': self.id, 'title': self.title, 'story': self.story, 'guideline': self.guideline, diff --git a/itf/static/js/itf/itf.js b/itf/static/js/itf/itf.js index f020985..dc55f05 100644 --- a/itf/static/js/itf/itf.js +++ b/itf/static/js/itf/itf.js @@ -310,8 +310,8 @@ BEGIN mainPanel { element: app.construct.leftPanel(), size: 256, -// resizable: true, -// resize: [0, 128, 256, 384] + resizable: true, + resize: [0, 128, 256, 384] }, { element: app.construct.middlePanel() @@ -320,8 +320,8 @@ BEGIN mainPanel { element: app.construct.rightPanel(), size: 256, -// resizable: true, -// resize: [0, 128, 256, 384] + resizable: true, + resize: [0, 128, 256, 384] } ] }); @@ -404,8 +404,8 @@ BEGIN mainPanel { element: app.construct.middleTopPanel(), size: 128, -// resizable: true, -// resize: [0, 64, 128, 196, 256], + resizable: true, + resize: [0, 64, 128, 196, 256], // collapsible: true }, { @@ -415,8 +415,8 @@ BEGIN mainPanel { element: app.construct.middleBottomPanel(), size: 128, -// resizable: true, -// resize: [0, 64, 128, 196, 256], + resizable: true, + resize: [0, 64, 128, 196, 256], // collapsible: true } ] @@ -435,14 +435,18 @@ BEGIN mainPanel elements: [ { element: app.construct.newsfeedBox(), - size: 256 + size: 256, + resizable: true, + resize: [0,128,196,256,384,512] }, { element: app.construct.aboutBox() }, { element: app.construct.itfBox(), - size: 256 + size: 256, + resizable: true, + resize: [0,128,196,256,384,512] } ] }); @@ -496,14 +500,18 @@ BEGIN mainPanel elements: [ { element: app.construct.erangBox(), - size: 256 + size: 256, + resizable: true, + resize: [0,128,196,256,384,512] }, { element: app.construct.scriptArchiveBox() }, { element: app.construct.bestPracticesBox(), - size: 256 + size: 256, + resizable: true, + resize: [0,128,196,256,384,512] } ] }); @@ -574,14 +582,18 @@ BEGIN mainPanel elements: [ { element: app.construct.biblioBox(), - size: 256 + size: 256, + resizable: true, + resize: [0,128,196,256,384,512] }, { element: app.construct.offersNeedsBox() }, { element: app.construct.surveysBox(), - size: 256 + size: 256, + resizable: true, + resize: [0,128,196,256,384,512] } ] }); @@ -763,13 +775,14 @@ Ox.ItfBox = function(options, self) { title: 'find', type: 'image', tooltip: 'Search' - }) - + }) .bindEvent("click", function() { -// alert("foo"); -// $search.slideDown(); - $search.is(":visible") ? $search.slideUp() : $search.slideDown(); - $search.focus(); + if ($search.is(":visible")) { + $search.slideUp(); + } else { + $search.slideDown(); + $search.focus(); + } }) .appendTo($buttons); @@ -865,6 +878,10 @@ Ox.ItfList = function(options, self) { var self = self || {}; var that = new Ox.TextList(options, self); that.bindEvent("select", function(e, data) { + if (data.ids.length === 0) { + app.$ui.previewBox.$content.html(''); + return; + } app.$ui[options.boxId].$loading.start(); // debugger; app.api.preview({ diff --git a/itf/static/js/jquery.js b/itf/static/js/jquery.js index 0185856..0a17377 120000 --- a/itf/static/js/jquery.js +++ b/itf/static/js/jquery.js @@ -1 +1 @@ -jquery-1.4.3.min.js \ No newline at end of file +jquery-1.4.4.js \ No newline at end of file