2013-01-25 02:23:05 +01:00
|
|
|
/**
|
|
|
|
* @provides javelin-behavior-conpherence-menu
|
|
|
|
* @requires javelin-behavior
|
|
|
|
* javelin-dom
|
2013-03-08 19:40:06 +01:00
|
|
|
* javelin-request
|
2013-01-25 02:23:05 +01:00
|
|
|
* javelin-stratcom
|
|
|
|
* javelin-uri
|
2013-03-08 19:40:06 +01:00
|
|
|
* javelin-util
|
|
|
|
* javelin-workflow
|
2013-01-25 02:23:05 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
JX.behavior('conpherence-menu', function(config) {
|
|
|
|
|
2013-02-15 23:01:27 +01:00
|
|
|
function onwidgetresponse(context, response) {
|
|
|
|
var widgets = JX.$H(response.widgets);
|
|
|
|
var widgetsRoot = JX.$(config.widgets_pane);
|
|
|
|
JX.DOM.setContent(widgetsRoot, widgets);
|
|
|
|
}
|
|
|
|
|
2013-01-25 02:23:05 +01:00
|
|
|
function onresponse(context, response) {
|
|
|
|
var header = JX.$H(response.header);
|
|
|
|
var messages = JX.$H(response.messages);
|
|
|
|
var form = JX.$H(response.form);
|
|
|
|
var headerRoot = JX.$(config.header);
|
|
|
|
var messagesRoot = JX.$(config.messages);
|
|
|
|
var formRoot = JX.$(config.form_pane);
|
|
|
|
var widgetsRoot = JX.$(config.widgets_pane);
|
2013-02-05 20:58:19 +01:00
|
|
|
var menuRoot = JX.$(config.menu_pane);
|
2013-01-25 02:23:05 +01:00
|
|
|
JX.DOM.setContent(headerRoot, header);
|
|
|
|
JX.DOM.setContent(messagesRoot, messages);
|
|
|
|
messagesRoot.scrollTop = messagesRoot.scrollHeight;
|
|
|
|
JX.DOM.setContent(formRoot, form);
|
|
|
|
|
2013-02-05 20:58:19 +01:00
|
|
|
var conpherences = JX.DOM.scry(
|
|
|
|
menuRoot,
|
|
|
|
'a',
|
|
|
|
'conpherence-menu-click'
|
|
|
|
);
|
|
|
|
|
|
|
|
for (var i = 0; i < conpherences.length; i++) {
|
|
|
|
var current = conpherences[i];
|
2013-01-25 02:23:05 +01:00
|
|
|
if (current.id == context.id) {
|
|
|
|
JX.DOM.alterClass(current, 'conpherence-selected', true);
|
|
|
|
JX.DOM.alterClass(current, 'hide-unread-count', true);
|
|
|
|
} else {
|
|
|
|
JX.DOM.alterClass(current, 'conpherence-selected', false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO - update the browser URI T2086
|
|
|
|
|
|
|
|
JX.Stratcom.invoke(
|
|
|
|
'conpherence-selected-loaded',
|
|
|
|
null,
|
|
|
|
{}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
JX.Stratcom.listen(
|
|
|
|
'click',
|
|
|
|
'conpherence-menu-click',
|
|
|
|
function(e) {
|
|
|
|
e.kill();
|
|
|
|
var selected = e.getNode(['conpherence-menu-click']);
|
|
|
|
if (config.fancy_ajax) {
|
|
|
|
JX.Stratcom.invoke(
|
|
|
|
'conpherence-selected',
|
|
|
|
null,
|
|
|
|
{ selected : selected }
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
var data = JX.Stratcom.getData(selected);
|
|
|
|
var uri = new JX.URI(config.base_uri + data.id + '/');
|
|
|
|
uri.go();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
JX.Stratcom.listen(
|
|
|
|
'conpherence-initial-selected',
|
|
|
|
null,
|
|
|
|
function(e) {
|
|
|
|
var selected = e.getData().selected;
|
|
|
|
e.kill();
|
|
|
|
JX.Stratcom.invoke(
|
|
|
|
'conpherence-selected',
|
|
|
|
null,
|
|
|
|
{ selected : selected }
|
|
|
|
);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
JX.Stratcom.listen(
|
|
|
|
'conpherence-selected',
|
|
|
|
null,
|
|
|
|
function(e) {
|
|
|
|
|
|
|
|
var selected = e.getData().selected;
|
|
|
|
var data = JX.Stratcom.getData(selected);
|
|
|
|
var uri = config.base_uri + 'view/' + data.id + '/';
|
2013-02-15 23:01:27 +01:00
|
|
|
var widget_uri = config.base_uri + 'widget/' + data.id + '/';
|
2013-01-25 02:23:05 +01:00
|
|
|
new JX.Workflow(uri, {})
|
|
|
|
.setHandler(JX.bind(null, onresponse, selected))
|
|
|
|
.start();
|
2013-02-15 23:01:27 +01:00
|
|
|
new JX.Workflow(widget_uri, {})
|
|
|
|
.setHandler(JX.bind(null, onwidgetresponse, selected))
|
|
|
|
.start();
|
2013-01-25 02:23:05 +01:00
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2013-03-08 19:40:06 +01:00
|
|
|
JX.Stratcom.listen('click', 'conpherence-edit-metadata', function (e) {
|
|
|
|
e.kill();
|
2013-03-16 07:41:36 +01:00
|
|
|
var root = JX.$(config.form_pane);
|
2013-03-08 19:40:06 +01:00
|
|
|
var form = JX.DOM.find(root, 'form');
|
|
|
|
var data = e.getNodeData('conpherence-edit-metadata');
|
|
|
|
new JX.Workflow.newFromForm(form, data)
|
|
|
|
.setHandler(function (r) {
|
|
|
|
// update the header
|
|
|
|
JX.DOM.setContent(
|
|
|
|
JX.$(config.header),
|
|
|
|
JX.$H(r.header)
|
|
|
|
);
|
|
|
|
|
|
|
|
// update the menu entry as well
|
|
|
|
JX.DOM.replace(
|
|
|
|
JX.$(r.conpherence_phid + '-nav-item'),
|
|
|
|
JX.$H(r.nav_item)
|
|
|
|
);
|
|
|
|
JX.DOM.replace(
|
|
|
|
JX.$(r.conpherence_phid + '-menu-item'),
|
|
|
|
JX.$H(r.menu_item)
|
|
|
|
);
|
|
|
|
})
|
|
|
|
.start();
|
|
|
|
});
|
|
|
|
|
2013-02-15 23:01:27 +01:00
|
|
|
JX.Stratcom.listen('click', 'show-older-messages', function(e) {
|
|
|
|
e.kill();
|
|
|
|
console.log(document.URL);
|
2013-03-08 19:40:06 +01:00
|
|
|
new JX.Request('/conpherence/view/1/', function(r) {
|
|
|
|
console.log('100');
|
|
|
|
})
|
|
|
|
.setData({offset: 100}) // get the next page
|
|
|
|
.send();
|
|
|
|
});
|
2013-02-15 23:01:27 +01:00
|
|
|
|
2013-03-16 07:41:36 +01:00
|
|
|
// select the current message
|
|
|
|
var selectedConpherence = false;
|
|
|
|
if (config.selected_conpherence_id) {
|
|
|
|
var selected = JX.$(config.selected_conpherence_id + '-nav-item');
|
|
|
|
JX.Stratcom.invoke(
|
|
|
|
'conpherence-initial-selected',
|
|
|
|
null,
|
|
|
|
{ selected : selected }
|
|
|
|
);
|
|
|
|
selectedConpherence = true;
|
|
|
|
}
|
|
|
|
|
2013-01-25 02:23:05 +01:00
|
|
|
});
|