Skip to content

Commit 7b05af9

Browse files
committed
Minor reorganisation of methoed (new: Message.tableColumns)
1 parent bd8c330 commit 7b05af9

7 files changed

+200
-189
lines changed

bower.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jquery-bootstrap-niord",
3-
"version": "3.3.5",
3+
"version": "3.3.6",
44
"homepage": "https://github.com/FCOO/jquery-bootstrap-niord",
55
"authors": [
66
"Niels Holt"

demo/bower_components.js

+102-103
Large diffs are not rendered by default.

demo/index.html

+4
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,12 @@
102102
window.Niord.options.onClickCoordinate = function(coord, text, messageId){
103103
latLngFormat.setFormat(window.latLngFormat.LATLNGFORMAT_DMM);
104104
$.bsNoty({text:text+ '<br>'+ latLngFormat(coord[1], coord[0]).format()});
105+
}
106+
105107

108+
window.Niord.options.getDefaultMap = function(){
106109
}
110+
107111
/*
108112
moment.sfAddTimezone({id:'Pacific/Honolulu'});
109113
moment.sfSetFormat({ timezone: 'Pacific/Honolulu' });

dist/jquery-bootstrap-niord.js

+46-42
Original file line numberDiff line numberDiff line change
@@ -834,7 +834,6 @@
834834
{
835835
type: 'accordion',
836836
list: messageContent,
837-
838837
onChange: dontSaveOpenPart ? null :
839838
$.proxy(function(partIdList, $acc, status){
840839

@@ -1038,7 +1037,7 @@
10381037
var result = {
10391038
header : this.bsHeaderOptions('NORMAL'),
10401039
fixedContent: this.bsFixedContent('NORMAL'),
1041-
content : this.bsAccordionOptions({fullDate: true}),
1040+
content : this.bsAccordionOptions({fullDate: true}, {multiOpen: true}),
10421041

10431042
footer : ns.options.modalFooter,
10441043

@@ -1108,7 +1107,7 @@
11081107

11091108
//First modal => add list-button
11101109
if (!_messages.bsModalMessage)
1111-
options.buttons = [ _messages._showAllButtonOptions('min-width-5em') ];
1110+
options.buttons = [ _messages._showAllButtonOptions() ];
11121111

11131112
_messages.bsModalMessage =
11141113
_messages.bsModalMessage ?
@@ -1117,13 +1116,13 @@
11171116

11181117
_messages.bsModalMessage.show();
11191118

1120-
//Find last button = "Show list"
1119+
//Find last button = "Show all"
11211120
if (!_messages.showMessagesButton){
11221121
var buttons = _messages.bsModalMessage.bsModal.$buttons;
11231122
_messages.showMessagesButton = buttons[buttons.length-1];
11241123
}
11251124

1126-
//Hide the "Show list"-button if messages-list is already visible
1125+
//Hide the "Show all"-button if messages-list is already visible
11271126
_messages.showMessagesButton.toggle(
11281127
!(_messages.bsModal && _messages.bsModal.hasClass('show'))
11291128
);
@@ -1219,13 +1218,49 @@
12191218
};
12201219
*/
12211220

1221+
/******************************************************
1222+
Messages.tableColumns
1223+
******************************************************/
1224+
ns.Messages.prototype.tableColumns = function(small){
1225+
return small ?
1226+
[{
1227+
id: 'id', noWrap: false, header: 'No shown', createContent: $.proxy(this._createTableCellContent, this),
1228+
sortable: true, sortBy: $.proxy(this._sortMessage, this)
1229+
}] :
1230+
[
1231+
{ id: 'shortId', noWrap: true, header: 'Id', align: 'center' },
1232+
{ id: 'date', noWrap: true, header: {da:'Dato', en:'Date'}, align: 'center', vfFormat: ns.options.vfFormatId.date, sortable: true, sortBy:'moment_date', sortDefault: true/*'desc'*/},
1233+
{ id: 'area', noWrap: false, header: {text:'niord:AREA'}, align: 'left',
1234+
//Options for sorting by area
1235+
sortable: true,
1236+
sortHeader: true,
1237+
_sortIndex:1000,
1238+
updateAfterSorting: true,
1239+
1240+
//Sort by full area-title
1241+
getSortContent: function(content){ return content.full; },
1242+
1243+
//Display only sub-area when list is sorted by area
1244+
createContent: function(content, $td, sortBy){
1245+
$td._bsAddHtml(sortBy ? content.sub : content.full);
1246+
},
1247+
1248+
//Use default area-title as header for sorted groups
1249+
getHeaderContent: function(content){ return content.normal; },
1250+
createHeaderContent: function(content, $span){ $span._bsAddHtml(content); },
1251+
},
1252+
{ id: 'title', noWrap: false, header: {da:'Titel', en:'Title'}, align: 'left', _sortable: true, _sortHeader: true, _sortIndex:1000}
1253+
];
1254+
};
1255+
1256+
12221257
/******************************************************
12231258
Messages.asModal
12241259
Will display a list of all messages as
12251260
1: One column with all info, or
12261261
2: Four columns with id, date, area, and title
12271262
******************************************************/
1228-
ns.Messages.prototype.asModal = function(modalOptions){
1263+
ns.Messages.prototype.asModal = function(){
12291264
var _this = this;
12301265

12311266
//Close any message-modal
@@ -1242,39 +1277,7 @@
12421277
allowZeroSelected: false,
12431278
allowReselect : true,
12441279
onChange : $.proxy(this.messageAsModal, this ),
1245-
1246-
1247-
1248-
columns: displayInSmallTable ?
1249-
[{
1250-
id: 'id', noWrap: false, header: 'No shown', createContent: $.proxy(this._createTableCellContent, this),
1251-
sortable: true, sortBy: $.proxy(this._sortMessage, this)
1252-
}] :
1253-
[
1254-
{ id: 'shortId', noWrap: true, header: 'Id', align: 'center' },
1255-
{ id: 'date', noWrap: true, header: {da:'Dato', en:'Date'}, align: 'center', vfFormat: ns.options.vfFormatId.date, sortable: true, sortBy:'moment_date', sortDefault: true/*'desc'*/},
1256-
{ id: 'area', noWrap: false, header: {text:'niord:AREA'}, align: 'left',
1257-
//Options for sorting by area
1258-
sortable: true,
1259-
sortHeader: true,
1260-
_sortIndex:1000,
1261-
updateAfterSorting: true,
1262-
1263-
//Sort by full area-title
1264-
getSortContent: function(content){ return content.full; },
1265-
1266-
//Display only sub-area when list is sorted by area
1267-
createContent: function(content, $td, sortBy){
1268-
$td._bsAddHtml(sortBy ? content.sub : content.full);
1269-
},
1270-
1271-
//Use default area-title as header for sorted groups
1272-
getHeaderContent: function(content){ return content.normal; },
1273-
createHeaderContent: function(content, $span){ $span._bsAddHtml(content); },
1274-
},
1275-
1276-
{ id: 'title', noWrap: false, header: {da:'Titel', en:'Title'}, align: 'left', _sortable: true, _sortHeader: true, _sortIndex:1000},
1277-
],
1280+
columns : this.tableColumns(displayInSmallTable)
12781281
};
12791282

12801283
//Create table and add data
@@ -1328,7 +1331,7 @@
13281331
}
13291332

13301333
//Filter and display the modal with the table
1331-
this.filter(modalOptions ? modalOptions.filterOptions : null);
1334+
// HER> this.filter(modalOptions ? modalOptions.filterOptions : null);
13321335

13331336
this.bsModal.show();
13341337

@@ -1339,11 +1342,11 @@
13391342
/******************************************************
13401343
Messages._showAllButtonOptions
13411344
******************************************************/
1342-
ns.Messages.prototype._showAllButtonOptions = function(className){
1345+
ns.Messages.prototype._showAllButtonOptions = function(){
13431346
return {
13441347
icon : 'fa-th-list',
13451348
text : {da:'Vis alle', en:'Show all'},
1346-
class : className,
1349+
class : 'min-width-5em',
13471350
onClick: this.asModal.bind( this )
13481351
};
13491352
};
@@ -1402,6 +1405,7 @@
14021405
});
14031406
};
14041407

1408+
14051409
/******************************************************
14061410
Messages.filterAsModalForm
14071411
Edit a filter-record = {domainId, area, chart, category}

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jquery-bootstrap-niord",
3-
"version": "3.3.5",
3+
"version": "3.3.6",
44
"homepage": "https://github.com/FCOO/jquery-bootstrap-niord",
55
"author": "Niels Holt nho@fcoo.dk",
66
"description": "package.json is only use for building the package. see bower.json for more info",

src/jquery-bootstrap-niord-message.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -834,7 +834,6 @@
834834
{
835835
type: 'accordion',
836836
list: messageContent,
837-
838837
onChange: dontSaveOpenPart ? null :
839838
$.proxy(function(partIdList, $acc, status){
840839

@@ -1038,7 +1037,7 @@
10381037
var result = {
10391038
header : this.bsHeaderOptions('NORMAL'),
10401039
fixedContent: this.bsFixedContent('NORMAL'),
1041-
content : this.bsAccordionOptions({fullDate: true}),
1040+
content : this.bsAccordionOptions({fullDate: true}, {multiOpen: true}),
10421041

10431042
footer : ns.options.modalFooter,
10441043

@@ -1108,7 +1107,7 @@
11081107

11091108
//First modal => add list-button
11101109
if (!_messages.bsModalMessage)
1111-
options.buttons = [ _messages._showAllButtonOptions('min-width-5em') ];
1110+
options.buttons = [ _messages._showAllButtonOptions() ];
11121111

11131112
_messages.bsModalMessage =
11141113
_messages.bsModalMessage ?
@@ -1117,13 +1116,13 @@
11171116

11181117
_messages.bsModalMessage.show();
11191118

1120-
//Find last button = "Show list"
1119+
//Find last button = "Show all"
11211120
if (!_messages.showMessagesButton){
11221121
var buttons = _messages.bsModalMessage.bsModal.$buttons;
11231122
_messages.showMessagesButton = buttons[buttons.length-1];
11241123
}
11251124

1126-
//Hide the "Show list"-button if messages-list is already visible
1125+
//Hide the "Show all"-button if messages-list is already visible
11271126
_messages.showMessagesButton.toggle(
11281127
!(_messages.bsModal && _messages.bsModal.hasClass('show'))
11291128
);

src/jquery-bootstrap-niord-messages.js

+42-37
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,49 @@
8484
};
8585
*/
8686

87+
/******************************************************
88+
Messages.tableColumns
89+
******************************************************/
90+
ns.Messages.prototype.tableColumns = function(small){
91+
return small ?
92+
[{
93+
id: 'id', noWrap: false, header: 'No shown', createContent: $.proxy(this._createTableCellContent, this),
94+
sortable: true, sortBy: $.proxy(this._sortMessage, this)
95+
}] :
96+
[
97+
{ id: 'shortId', noWrap: true, header: 'Id', align: 'center' },
98+
{ id: 'date', noWrap: true, header: {da:'Dato', en:'Date'}, align: 'center', vfFormat: ns.options.vfFormatId.date, sortable: true, sortBy:'moment_date', sortDefault: true/*'desc'*/},
99+
{ id: 'area', noWrap: false, header: {text:'niord:AREA'}, align: 'left',
100+
//Options for sorting by area
101+
sortable: true,
102+
sortHeader: true,
103+
_sortIndex:1000,
104+
updateAfterSorting: true,
105+
106+
//Sort by full area-title
107+
getSortContent: function(content){ return content.full; },
108+
109+
//Display only sub-area when list is sorted by area
110+
createContent: function(content, $td, sortBy){
111+
$td._bsAddHtml(sortBy ? content.sub : content.full);
112+
},
113+
114+
//Use default area-title as header for sorted groups
115+
getHeaderContent: function(content){ return content.normal; },
116+
createHeaderContent: function(content, $span){ $span._bsAddHtml(content); },
117+
},
118+
{ id: 'title', noWrap: false, header: {da:'Titel', en:'Title'}, align: 'left', _sortable: true, _sortHeader: true, _sortIndex:1000}
119+
];
120+
};
121+
122+
87123
/******************************************************
88124
Messages.asModal
89125
Will display a list of all messages as
90126
1: One column with all info, or
91127
2: Four columns with id, date, area, and title
92128
******************************************************/
93-
ns.Messages.prototype.asModal = function(modalOptions){
129+
ns.Messages.prototype.asModal = function(){
94130
var _this = this;
95131

96132
//Close any message-modal
@@ -107,39 +143,7 @@
107143
allowZeroSelected: false,
108144
allowReselect : true,
109145
onChange : $.proxy(this.messageAsModal, this ),
110-
111-
112-
113-
columns: displayInSmallTable ?
114-
[{
115-
id: 'id', noWrap: false, header: 'No shown', createContent: $.proxy(this._createTableCellContent, this),
116-
sortable: true, sortBy: $.proxy(this._sortMessage, this)
117-
}] :
118-
[
119-
{ id: 'shortId', noWrap: true, header: 'Id', align: 'center' },
120-
{ id: 'date', noWrap: true, header: {da:'Dato', en:'Date'}, align: 'center', vfFormat: ns.options.vfFormatId.date, sortable: true, sortBy:'moment_date', sortDefault: true/*'desc'*/},
121-
{ id: 'area', noWrap: false, header: {text:'niord:AREA'}, align: 'left',
122-
//Options for sorting by area
123-
sortable: true,
124-
sortHeader: true,
125-
_sortIndex:1000,
126-
updateAfterSorting: true,
127-
128-
//Sort by full area-title
129-
getSortContent: function(content){ return content.full; },
130-
131-
//Display only sub-area when list is sorted by area
132-
createContent: function(content, $td, sortBy){
133-
$td._bsAddHtml(sortBy ? content.sub : content.full);
134-
},
135-
136-
//Use default area-title as header for sorted groups
137-
getHeaderContent: function(content){ return content.normal; },
138-
createHeaderContent: function(content, $span){ $span._bsAddHtml(content); },
139-
},
140-
141-
{ id: 'title', noWrap: false, header: {da:'Titel', en:'Title'}, align: 'left', _sortable: true, _sortHeader: true, _sortIndex:1000},
142-
],
146+
columns : this.tableColumns(displayInSmallTable)
143147
};
144148

145149
//Create table and add data
@@ -193,7 +197,7 @@
193197
}
194198

195199
//Filter and display the modal with the table
196-
this.filter(modalOptions ? modalOptions.filterOptions : null);
200+
// HER> this.filter(modalOptions ? modalOptions.filterOptions : null);
197201

198202
this.bsModal.show();
199203

@@ -204,11 +208,11 @@
204208
/******************************************************
205209
Messages._showAllButtonOptions
206210
******************************************************/
207-
ns.Messages.prototype._showAllButtonOptions = function(className){
211+
ns.Messages.prototype._showAllButtonOptions = function(){
208212
return {
209213
icon : 'fa-th-list',
210214
text : {da:'Vis alle', en:'Show all'},
211-
class : className,
215+
class : 'min-width-5em',
212216
onClick: this.asModal.bind( this )
213217
};
214218
};
@@ -267,6 +271,7 @@
267271
});
268272
};
269273

274+
270275
/******************************************************
271276
Messages.filterAsModalForm
272277
Edit a filter-record = {domainId, area, chart, category}

0 commit comments

Comments
 (0)