added boxes.js
This commit is contained in:
parent
038aabbb7e
commit
3c8b724f2b
|
@ -29,6 +29,7 @@ import ox
|
|||
from actions import actions
|
||||
from user.models import get_user_json
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
from boxes.views import _getPageData
|
||||
|
||||
@csrf_exempt
|
||||
def api(request):
|
||||
|
@ -106,6 +107,7 @@ def init(request):
|
|||
'name': 'India Theatre Forum'
|
||||
}
|
||||
}
|
||||
response['data']['page'] = _getPageData(request)
|
||||
return render_to_json_response(response)
|
||||
actions.register(init)
|
||||
|
||||
|
|
|
@ -223,4 +223,9 @@ class Panel(models.Model):
|
|||
'title': self.title,
|
||||
'boxes': map(lambda x: x.get_dict(), self.boxes.all())
|
||||
}
|
||||
|
||||
|
||||
'''
|
||||
class Page(models.Model):
|
||||
class Meta:
|
||||
abstract = True
|
||||
'''
|
||||
|
|
|
@ -4,7 +4,7 @@ import ox
|
|||
from ox.django.decorators import login_required_json
|
||||
from ox.django.shortcuts import render_to_json_response, get_object_or_404_json, json_response
|
||||
from models import Panel
|
||||
|
||||
import json
|
||||
|
||||
|
||||
def getPage(request):
|
||||
|
@ -18,6 +18,15 @@ def getPage(request):
|
|||
default_model
|
||||
etc
|
||||
'''
|
||||
# data = json.loads(request.POST['data'])
|
||||
panels = _getPageData(request)
|
||||
response = json_response({})
|
||||
response['data'] = panels
|
||||
response['status'] = {'code': 200}
|
||||
return render_to_json_response(response)
|
||||
actions.register(getPage)
|
||||
|
||||
def _getPageData(request):
|
||||
data = json.loads(request.POST['data'])
|
||||
displayedPanels = Panel.objects.filter(enabled=True).filter(displayed=True)
|
||||
hiddenPanels = Panel.objects.filter(enabled=True).filter(displayed=False)
|
||||
|
@ -28,8 +37,4 @@ def getPage(request):
|
|||
panels['hidden'] = []
|
||||
for h in hiddenPanels:
|
||||
panels['hidden'].append(h.get_dict())
|
||||
response = json_response({})
|
||||
response['data'] = panels
|
||||
response['status'] = {'code': 200}
|
||||
return render_to_json_response(response)
|
||||
actions.register(getPage)
|
||||
return panels
|
||||
|
|
|
@ -30,7 +30,7 @@ app.launch(function(data) {
|
|||
app.$ui[v] = app.construct[v]();
|
||||
});
|
||||
*/
|
||||
var wrapper = app.construct.wrapper();
|
||||
var wrapper = app.construct.wrapper(data.page);
|
||||
app.$body.css({'opacity': 0});
|
||||
//FIXME: user handling should be cleaner?
|
||||
if (data.user.level != 'guest') {
|
||||
|
|
0
itf/static/js/itf/box_types.js
Normal file
0
itf/static/js/itf/box_types.js
Normal file
83
itf/static/js/itf/boxes.js
Normal file
83
itf/static/js/itf/boxes.js
Normal file
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
|
||||
*/
|
||||
|
||||
Ox.ItfPage = function(page, parentPanel) {
|
||||
var panelItems = [];
|
||||
for (var i=0; i < page.panels.displayed.length; i++) {
|
||||
var t = page.panels.displayed[i];
|
||||
var displayed = true;
|
||||
var panel = new Ox.ItfPanel(t, displayed);
|
||||
panelItems.push(panel);
|
||||
}
|
||||
var hiddenPanel = new Ox.ItfHiddenPanelContainer();
|
||||
for (var j=0; j < page.panels.hidden.length; j++) {
|
||||
var t = page.panels.hidden[j];
|
||||
var displayed = false;
|
||||
var panel = new Ox.ItfPanel(t, displayed);
|
||||
hiddenPanel.addPanel(panel);
|
||||
}
|
||||
var that = app.ui['ItfPage'] = new Ox.SplitPanel({
|
||||
orientation: 'vertical',
|
||||
id: 'ItfPage',
|
||||
elements: panelItems
|
||||
});
|
||||
return that;
|
||||
}
|
||||
|
||||
Ox.ItfPanel = function(panelData, displayed) {
|
||||
var items = [];
|
||||
var id = panelData.title;
|
||||
for (var i=0; i < panelData.boxes.length; i++) {
|
||||
var t = panelData.boxes[i];
|
||||
var box = new Ox.ItfBox(t);
|
||||
items.push(box);
|
||||
}
|
||||
var that = new Ox.SplitPanel({
|
||||
orientation: 'horizontal',
|
||||
id: id,
|
||||
elements: items
|
||||
});
|
||||
that.displayed = displayed;
|
||||
};
|
||||
|
||||
Ox.HiddenPanelContainer = function() {
|
||||
|
||||
};
|
||||
|
||||
Ox.ItfBox = function(boxData) {
|
||||
var options = {
|
||||
'title': boxData.title,
|
||||
}
|
||||
var that = new Ox.Element(options, self);
|
||||
var $titlebar = new Ox.Bar({
|
||||
orientation: 'horizontal',
|
||||
size: '24
|
||||
}).appendTo(that);
|
||||
var $title = new Ox.Element()
|
||||
.addClass('OxTitle')
|
||||
.html(title)
|
||||
.appendTo($titlebar);
|
||||
var $buttons = new Ox.Element().appendTo($title).css({'position': 'absolute', 'top': '1px', 'right': '1px'});
|
||||
var boxButtons = Ox.merge(ItfBoxTypes[boxData.type].buttons, boxData.extra_buttons);
|
||||
for (var i=0; i<boxButtons.length; i++) {
|
||||
var t = boxButtons[i];
|
||||
var button = new Ox.ItfButton(t).appendTo($buttons);
|
||||
}
|
||||
|
||||
var $content = ItfBoxTypes[boxData.type].render(boxData);
|
||||
$content.appendTo(that);
|
||||
return that;
|
||||
}
|
||||
|
||||
/*
|
||||
ItfBoxes.StaticBox = function(boxData) {
|
||||
var self = {};
|
||||
var that = new Ox.Element(
|
||||
|
||||
}
|
||||
|
||||
ItfBoxes.ModelsBox = function(boxData) {
|
||||
|
||||
}
|
||||
*/
|
|
@ -31,7 +31,7 @@ Structure:
|
|||
*/
|
||||
|
||||
|
||||
'wrapper': function() {
|
||||
'wrapper': function(pageData) {
|
||||
var id = 'wrapper';
|
||||
// Constructs overall wrapper for the page, and should be appended to $(body)
|
||||
return app.$ui[id] = new Ox.SplitPanel({
|
||||
|
@ -43,7 +43,7 @@ Structure:
|
|||
size: 40
|
||||
},
|
||||
{
|
||||
element: app.construct.mainPanel(),
|
||||
element: app.construct.mainPanel(pageData),
|
||||
},
|
||||
{
|
||||
element: app.construct.footerPanel(),
|
||||
|
@ -108,18 +108,20 @@ END headerPanel
|
|||
BEGIN mainPanel
|
||||
*/
|
||||
|
||||
'mainPanel': function() {
|
||||
'mainPanel': function(pageData) {
|
||||
var id = 'mainPanel';
|
||||
// var p = app.$ui[id] = new ItfPage(pageData);
|
||||
|
||||
var p = app.$ui[id] = new Ox.SplitPanel({
|
||||
id: id,
|
||||
orientation: 'horizontal',
|
||||
elements: [
|
||||
{
|
||||
/* {
|
||||
element: app.construct.leftPanel(),
|
||||
size: 256,
|
||||
resizable: true,
|
||||
resize: [0, 128, 256, 384]
|
||||
},
|
||||
}, */
|
||||
{
|
||||
element: app.construct.middlePanel()
|
||||
// resizable: true
|
||||
|
@ -132,6 +134,7 @@ BEGIN mainPanel
|
|||
}
|
||||
]
|
||||
});
|
||||
|
||||
return p;
|
||||
},
|
||||
|
||||
|
@ -204,8 +207,10 @@ BEGIN mainPanel
|
|||
/*
|
||||
BEGIN middlePanel
|
||||
*/
|
||||
'middlePanel': function() {
|
||||
'middlePanel': function(pageData) {
|
||||
var id = 'middlePanel';
|
||||
var p = new Ox.ItfPage(pageData);
|
||||
/*
|
||||
var p = app.$ui[id] = new Ox.SplitPanel({
|
||||
orientation: 'vertical',
|
||||
id: id,
|
||||
|
@ -230,6 +235,7 @@ BEGIN mainPanel
|
|||
}
|
||||
]
|
||||
});
|
||||
*/
|
||||
return p;
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user