summaryrefslogtreecommitdiffstats
path: root/core/js/listview.js
diff options
context:
space:
mode:
authorRobin Appelman <icewind1991@gmail.com>2011-08-12 22:18:38 +0200
committerRobin Appelman <icewind1991@gmail.com>2011-08-13 00:23:15 +0200
commit686be824b520e4f04e634846b415e82ed9fb1c4d (patch)
treeb1463dcc1aa39c5960ddded6cc2d9dd1055ca3e3 /core/js/listview.js
parent42c5a24dc3f67bde57c8d4180e71abb1b1aefe70 (diff)
downloadnextcloud-server-686be824b520e4f04e634846b415e82ed9fb1c4d.tar.gz
nextcloud-server-686be824b520e4f04e634846b415e82ed9fb1c4d.zip
hide settings menu when clicking outside it
Diffstat (limited to 'core/js/listview.js')
-rw-r--r--core/js/listview.js71
1 files changed, 71 insertions, 0 deletions
diff --git a/core/js/listview.js b/core/js/listview.js
new file mode 100644
index 00000000000..e3e5ebdab8f
--- /dev/null
+++ b/core/js/listview.js
@@ -0,0 +1,71 @@
+function ListView(element){
+ this.element=element;
+}
+
+ListView.generateTable=function(collumns){
+ var html='<table>';
+ html+='<thead>';
+ $.each(collumns,function(index,collumn){
+ html+='<th>'+collumn+'</th>';
+ });
+ html+='<thead>';
+ html+='</head>';
+ html+='<tbody>';
+ html+'<tr class="template">'
+ $.each(collumns,function(index,collumn){
+ html+='<th class="'+collumn.toLower()+'"</th>';
+ });
+ html+'</tr>'
+ html+='</tbody>';
+ html='</table>';
+ return $(html);
+}
+
+ListView.prototype={
+ rows:{},
+ hoverElements:{},
+ addRow:function(id,data,extraData){
+ var tr=this.element.find('tr.template').clone();
+ tr.removeClass('template');
+ $.each(data,function(name,value){
+ tr.children('td.'+name).text(value);
+ tr.attr('data-'+name,value);
+ });
+ $.each(extraData,function(name,value){
+ tr.attr('data-'+name,value);
+ });
+ this.rows[id]=data;
+ tr.data('id',id);
+ this.element.children('tbody').append(tr);
+ },
+ removeRow:function(id){
+ this.rows[id].remove();
+ delete this.rows[id];
+ },
+ hoverHandeler:function(tr){
+ $.each(this.hoverElement,function(index,collumn){
+ $.each(collumn,function(index,element){
+ var html='<a href="#" title="'+element.title+'" class="hoverElement"/>';
+ var element=$(html);
+ element.append($('<img src="'+element.icon+'"/>'));
+ element.click(element.callback);
+ tr.children('td.'+collumn).append(element)
+ });
+ });
+ if(this.deleteCallback){
+
+ }
+ },
+ hoverHandelerOut:function(tr){
+ tr.find('*.hoverElement').remove();
+ },
+ addHoverElement:function(collumn,icon,title,callback){
+ if(!this.hoverElements[collumn]){
+ this.hoverElements[collumn]=[];
+ }
+ this.hoverElements[row].push({icon:icon,callback:callback,title:title});
+ },
+ empty:function(){
+ this.element.children('tr:not(.template)').remove();
+ }
+} \ No newline at end of file