added boxes.js
This commit is contained in:
parent
038aabbb7e
commit
3c8b724f2b
|
@ -29,6 +29,7 @@ import ox
|
||||||
from actions import actions
|
from actions import actions
|
||||||
from user.models import get_user_json
|
from user.models import get_user_json
|
||||||
from django.views.decorators.csrf import csrf_exempt
|
from django.views.decorators.csrf import csrf_exempt
|
||||||
|
from boxes.views import _getPageData
|
||||||
|
|
||||||
@csrf_exempt
|
@csrf_exempt
|
||||||
def api(request):
|
def api(request):
|
||||||
|
@ -106,6 +107,7 @@ def init(request):
|
||||||
'name': 'India Theatre Forum'
|
'name': 'India Theatre Forum'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
response['data']['page'] = _getPageData(request)
|
||||||
return render_to_json_response(response)
|
return render_to_json_response(response)
|
||||||
actions.register(init)
|
actions.register(init)
|
||||||
|
|
||||||
|
|
|
@ -224,3 +224,8 @@ class Panel(models.Model):
|
||||||
'boxes': map(lambda x: x.get_dict(), self.boxes.all())
|
'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.decorators import login_required_json
|
||||||
from ox.django.shortcuts import render_to_json_response, get_object_or_404_json, json_response
|
from ox.django.shortcuts import render_to_json_response, get_object_or_404_json, json_response
|
||||||
from models import Panel
|
from models import Panel
|
||||||
|
import json
|
||||||
|
|
||||||
|
|
||||||
def getPage(request):
|
def getPage(request):
|
||||||
|
@ -18,6 +18,15 @@ def getPage(request):
|
||||||
default_model
|
default_model
|
||||||
etc
|
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'])
|
data = json.loads(request.POST['data'])
|
||||||
displayedPanels = Panel.objects.filter(enabled=True).filter(displayed=True)
|
displayedPanels = Panel.objects.filter(enabled=True).filter(displayed=True)
|
||||||
hiddenPanels = Panel.objects.filter(enabled=True).filter(displayed=False)
|
hiddenPanels = Panel.objects.filter(enabled=True).filter(displayed=False)
|
||||||
|
@ -28,8 +37,4 @@ def getPage(request):
|
||||||
panels['hidden'] = []
|
panels['hidden'] = []
|
||||||
for h in hiddenPanels:
|
for h in hiddenPanels:
|
||||||
panels['hidden'].append(h.get_dict())
|
panels['hidden'].append(h.get_dict())
|
||||||
response = json_response({})
|
return panels
|
||||||
response['data'] = panels
|
|
||||||
response['status'] = {'code': 200}
|
|
||||||
return render_to_json_response(response)
|
|
||||||
actions.register(getPage)
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ app.launch(function(data) {
|
||||||
app.$ui[v] = app.construct[v]();
|
app.$ui[v] = app.construct[v]();
|
||||||
});
|
});
|
||||||
*/
|
*/
|
||||||
var wrapper = app.construct.wrapper();
|
var wrapper = app.construct.wrapper(data.page);
|
||||||
app.$body.css({'opacity': 0});
|
app.$body.css({'opacity': 0});
|
||||||
//FIXME: user handling should be cleaner?
|
//FIXME: user handling should be cleaner?
|
||||||
if (data.user.level != 'guest') {
|
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';
|
var id = 'wrapper';
|
||||||
// Constructs overall wrapper for the page, and should be appended to $(body)
|
// Constructs overall wrapper for the page, and should be appended to $(body)
|
||||||
return app.$ui[id] = new Ox.SplitPanel({
|
return app.$ui[id] = new Ox.SplitPanel({
|
||||||
|
@ -43,7 +43,7 @@ Structure:
|
||||||
size: 40
|
size: 40
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
element: app.construct.mainPanel(),
|
element: app.construct.mainPanel(pageData),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
element: app.construct.footerPanel(),
|
element: app.construct.footerPanel(),
|
||||||
|
@ -108,18 +108,20 @@ END headerPanel
|
||||||
BEGIN mainPanel
|
BEGIN mainPanel
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'mainPanel': function() {
|
'mainPanel': function(pageData) {
|
||||||
var id = 'mainPanel';
|
var id = 'mainPanel';
|
||||||
|
// var p = app.$ui[id] = new ItfPage(pageData);
|
||||||
|
|
||||||
var p = app.$ui[id] = new Ox.SplitPanel({
|
var p = app.$ui[id] = new Ox.SplitPanel({
|
||||||
id: id,
|
id: id,
|
||||||
orientation: 'horizontal',
|
orientation: 'horizontal',
|
||||||
elements: [
|
elements: [
|
||||||
{
|
/* {
|
||||||
element: app.construct.leftPanel(),
|
element: app.construct.leftPanel(),
|
||||||
size: 256,
|
size: 256,
|
||||||
resizable: true,
|
resizable: true,
|
||||||
resize: [0, 128, 256, 384]
|
resize: [0, 128, 256, 384]
|
||||||
},
|
}, */
|
||||||
{
|
{
|
||||||
element: app.construct.middlePanel()
|
element: app.construct.middlePanel()
|
||||||
// resizable: true
|
// resizable: true
|
||||||
|
@ -132,6 +134,7 @@ BEGIN mainPanel
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
return p;
|
return p;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -204,8 +207,10 @@ BEGIN mainPanel
|
||||||
/*
|
/*
|
||||||
BEGIN middlePanel
|
BEGIN middlePanel
|
||||||
*/
|
*/
|
||||||
'middlePanel': function() {
|
'middlePanel': function(pageData) {
|
||||||
var id = 'middlePanel';
|
var id = 'middlePanel';
|
||||||
|
var p = new Ox.ItfPage(pageData);
|
||||||
|
/*
|
||||||
var p = app.$ui[id] = new Ox.SplitPanel({
|
var p = app.$ui[id] = new Ox.SplitPanel({
|
||||||
orientation: 'vertical',
|
orientation: 'vertical',
|
||||||
id: id,
|
id: id,
|
||||||
|
@ -230,6 +235,7 @@ BEGIN mainPanel
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
return p;
|
return p;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user