From 4b26740e9f98ab90581f513c62637c71c4bc6509 Mon Sep 17 00:00:00 2001 From: Jan-Christoph Borchardt Date: Mon, 8 Aug 2011 13:45:43 +0200 Subject: [PATCH 01/32] beautified backend, first iteration --- admin/css/apps.css | 19 ++++++++++++------- admin/templates/appsinst.php | 27 +++++++-------------------- admin/templates/users.php | 16 +++------------- core/css/styles.css | 5 +++-- 4 files changed, 25 insertions(+), 42 deletions(-) diff --git a/admin/css/apps.css b/admin/css/apps.css index c6b4f69ebc..e9049358e5 100644 --- a/admin/css/apps.css +++ b/admin/css/apps.css @@ -1,9 +1,14 @@ /* APPS TABLE */ -table td.date { width:5em; padding:.5em 1em; text-align:right; } -table td.version, table td.enabled, table td.disabled { padding:.5em 1em; text-align:center; } +table td.date { width:5em; padding:.5em 1em; text-align:left; } +table td.version, table td.enabled, table td.disabled { padding:.5em 1em; text-align:left; } .preview { padding:3px; text-align:left; } -table td.date { width:11em; color:#555555; } -table td.selection, table th.selection, table td.fileaction { width:2em; text-align:center; } -table td.name a { padding:6px; text-decoration:none; color:#555555; } -.type { text-decoration:none; color:#888888; font-size:.8em; } -.description { text-decoration:none; color:#666666; font-size:.9em; } +table td.date { width:11em; color:#555; } +table td.selection, table th.selection, table td.fileaction { width:2em; text-align:left; } +table td.name a { padding:6px; text-decoration:none; color:#555; } +.type { text-decoration:none; color:#888; font-size:.8em; } +.description { text-decoration:none; color:#666; font-size:.9em; } + +ul#apps { width:40em; list-style:none; } +ul#apps li { display:block; padding:.2em; clear:right; } +ul#apps em { color:#555; } +ul#apps input { float:right; } diff --git a/admin/templates/appsinst.php b/admin/templates/appsinst.php index d205d95cc3..e845cb451f 100644 --- a/admin/templates/appsinst.php +++ b/admin/templates/appsinst.php @@ -1,20 +1,7 @@ - - - - - - - - - - - - - - - - - - - -
t( 'Name' ); ?>t( 'Version' ); ?>t( 'Author' ); ?>t( 'Status' ); ?>
+ diff --git a/admin/templates/users.php b/admin/templates/users.php index 79a4c71204..c16270edbf 100644 --- a/admin/templates/users.php +++ b/admin/templates/users.php @@ -8,7 +8,7 @@ - +
@@ -26,8 +26,6 @@
- - "> @@ -44,23 +42,15 @@
- t( 'Groups' ); ?> + t( 'Groups' ); ?> - - - - - - - + - - "> diff --git a/core/css/styles.css b/core/css/styles.css index 114080f1f1..a0e67b4bde 100644 --- a/core/css/styles.css +++ b/core/css/styles.css @@ -32,8 +32,9 @@ form#user_settings p label { display:block; float:left; width:35%; padding:0.4em form p { padding:0.5em 4em 0.5em 0.5em; text-align:left; } form p.form_footer { margin:1em 0 0 0; text-align:right; } form label { cursor:pointer; } -fieldset { padding:1em; background-color:#f7f7f7; border:1px solid #ddd; max-width:600px; margin:2em; } -legend { padding:.5em; font-size:1.2em; } +fieldset { padding:1em; width:40em; margin:1em; +border:1px solid #ddd; font-weight:bold; cursor:pointer; background:#f2f2f2; color:#555; text-shadow:#fff 0 1px 0; -moz-box-shadow:0 1px 1px #fff, 0 1px 1px #fff inset; -webkit-box-shadow:0 1px 1px #fff, 0 1px 1px #fff inset; -moz-border-radius:.5em; -webkit-border-radius:.5em; border-radius:.5em;} +legend { padding:.2em; font-size:1.2em; } .template{display:none;} div.controls { width:100%; height:3em; margin:0; background-color:#f7f7f7; border-bottom:1px solid #eee; position:fixed; z-index:2; } From 3c01c36202008d22f67f5f45bce014a13f81a65f Mon Sep 17 00:00:00 2001 From: Jan-Christoph Borchardt Date: Mon, 8 Aug 2011 14:13:11 +0200 Subject: [PATCH 02/32] various style fixes --- admin/js/users.js | 4 ++-- admin/templates/users.php | 2 +- core/css/styles.css | 6 +++--- files/css/files.css | 2 +- help/css/help.css | 2 ++ help/templates/index.php | 4 ++-- settings/css/settings.css | 6 ++++-- 7 files changed, 15 insertions(+), 11 deletions(-) diff --git a/admin/js/users.js b/admin/js/users.js index 994ce6f6cb..5a99362726 100644 --- a/admin/js/users.js +++ b/admin/js/users.js @@ -57,7 +57,7 @@ $(document).ready(function(){ // Add user to table var newrow = ''; newrow = newrow+''; - newrow = newrow+''; + newrow = newrow+''; $("#usertable").append( newrow ); // Clear forms @@ -71,7 +71,7 @@ $(document).ready(function(){ function groupCreated( groupname ){ var newrow = ''; - newrow = newrow + ''; + newrow = newrow + ''; $("#grouptable").append( newrow ); // Delete form content diff --git a/admin/templates/users.php b/admin/templates/users.php index c16270edbf..fbb0fe79f3 100644 --- a/admin/templates/users.php +++ b/admin/templates/users.php @@ -56,7 +56,7 @@ - - - @@ -22,9 +19,6 @@ - - -
t( 'Name' ); ?>
'+username+'
'+groups+'
remove
' + groupname + 'remove
- +   diff --git a/core/css/styles.css b/core/css/styles.css index a0e67b4bde..0f05850e26 100644 --- a/core/css/styles.css +++ b/core/css/styles.css @@ -24,15 +24,15 @@ input[type="checkbox"] { width:auto; } #remember_login { margin:.8em .2em 0 1em; } form.searchbox input[type="search"] { position:fixed; font-size:1.2em; top:.3em; right:7em; padding:.2em .5em .2em 1.5em; background:#f8f8f8 url('../img/actions/search.png') .5em center no-repeat; border:0; -moz-border-radius:1em; -webkit-border- radius:1em; border-radius:1em; } -input[type="submit"].enabled { background:#aea; -moz-box-shadow:0 1px 1px #f8f8f8, 0 1px 1px #cfc inset; -webkit-box-shadow:0 1px 1px #f8f8f8, 0 1px 1px #cfc inset; box-shadow:0 1px 1px #f8f8f8, 0 1px 1px #cfc inset; } -input[type="submit"].highlight{ background:#ffc100; border:1px solid #dda600; text-shadow:#ffeedd 0 1px 0; -moz-box-shadow:0 1px 1px #f8f8f8, 0 1px 1px #ffeedd inset; -webkit-box-shadow:0 1px 1px #f8f8f8, 0 1px 1px #ffeedd inset; box-shadow:0 1px 1px #f8f8f8, 0 1px 1px #ffeedd inset; } +input[type="submit"].enabled { background:#66f866; border:1px solid #5e5; -moz-box-shadow:0 1px 1px #f8f8f8, 0 1px 1px #cfc inset; -webkit-box-shadow:0 1px 1px #f8f8f8, 0 1px 1px #cfc inset; box-shadow:0 1px 1px #f8f8f8, 0 1px 1px #cfc inset; } +input[type="submit"].highlight{ background:#ffc100; border:1px solid #db0; text-shadow:#ffeedd 0 1px 0; -moz-box-shadow:0 1px 1px #f8f8f8, 0 1px 1px #ffeedd inset; -webkit-box-shadow:0 1px 1px #f8f8f8, 0 1px 1px #ffeedd inset; box-shadow:0 1px 1px #f8f8f8, 0 1px 1px #ffeedd inset; } form#user_settings { max-width:600px; } form#user_settings p label { display:block; float:left; width:35%; padding:0.4em 0.5em 0 0; text-align:right; } form p { padding:0.5em 4em 0.5em 0.5em; text-align:left; } form p.form_footer { margin:1em 0 0 0; text-align:right; } form label { cursor:pointer; } -fieldset { padding:1em; width:40em; margin:1em; +#body-settings fieldset { padding:1em; width:40em; margin:1em; border:1px solid #ddd; font-weight:bold; cursor:pointer; background:#f2f2f2; color:#555; text-shadow:#fff 0 1px 0; -moz-box-shadow:0 1px 1px #fff, 0 1px 1px #fff inset; -webkit-box-shadow:0 1px 1px #fff, 0 1px 1px #fff inset; -moz-border-radius:.5em; -webkit-border-radius:.5em; border-radius:.5em;} legend { padding:.2em; font-size:1.2em; } .template{display:none;} diff --git a/files/css/files.css b/files/css/files.css index 004e42338f..bfd96bc2ac 100644 --- a/files/css/files.css +++ b/files/css/files.css @@ -9,7 +9,7 @@ .file_upload_wrapper { background:url("../img/file.png"); font-weight:bold; position:relative; top:-1.2em; left:-2em; display:-moz-inline-box; /* fallback for older firefox versions*/ display:inline-block; width:8em; } .file_upload_start { opacity:0; filter:alpha(opacity=0); } -#file_newfolder_name { background-image:url("../img/folder.png"); font-weight:bold; width:12em; } +#file_newfolder_name { background-image:url("../img/folder.png"); font-weight:bold; width:8em; } .file_upload_start, .file_upload_filename { position:absolute; top:0; left:0; font-size:1em; } #file_newfolder_submit, #file_upload_submit { width:3em; } .file_upload_target { display:none; } diff --git a/help/css/help.css b/help/css/help.css index e8c42f808d..2722c676a6 100644 --- a/help/css/help.css +++ b/help/css/help.css @@ -6,3 +6,5 @@ table td.selection, table th.selection, table td.fileaction { width:2em; text-al table td.name a { padding:6px; text-decoration:none; color:#555555; } .type { text-decoration:none; color:#888888; font-size:.8em; } .description { text-decoration:none; color:#666666; font-size:.9em; } + +table#help tr td { white-space:normal; } diff --git a/help/templates/index.php b/help/templates/index.php index f859a8ae70..ef5510e78b 100644 --- a/help/templates/index.php +++ b/help/templates/index.php @@ -1,12 +1,12 @@ Can't connect to Q&A database - +
- diff --git a/settings/css/settings.css b/settings/css/settings.css index 23561ec367..66299b1faa 100644 --- a/settings/css/settings.css +++ b/settings/css/settings.css @@ -1,2 +1,4 @@ -#passworderror{display:none;} -#passwordchanged{display:none;} \ No newline at end of file +#passworderror { display:none; } +#passwordchanged { display:none; } + +input#identity { width:20em; } From 2f95b829340369accb8b3f38034ecd38cfdf9c52 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 8 Aug 2011 16:33:01 +0200 Subject: [PATCH 03/32] fix disableing/enabling apps --- admin/ajax/disableapp.php | 1 - admin/js/apps.js | 7 +++---- admin/templates/appsinst.php | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/admin/ajax/disableapp.php b/admin/ajax/disableapp.php index dce62fa11d..0cf66a553f 100644 --- a/admin/ajax/disableapp.php +++ b/admin/ajax/disableapp.php @@ -1,5 +1,4 @@ -
  • by +
  • by
  • From 8c34ea496ae8961c4aea29da67b2b1776034a2c4 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 8 Aug 2011 17:53:03 +0200 Subject: [PATCH 04/32] initial work on the media player interface rework it looks bad atm bu should work enough to be stylable --- apps/media/appinfo/app.php | 30 ------ apps/media/css/music.css | 5 +- apps/media/js/collection.js | 152 +++++++++++++++++----------- apps/media/js/music.js | 20 +--- apps/media/js/playlist.js | 10 -- apps/media/templates/collection.php | 25 +++-- apps/media/templates/music.php | 2 +- apps/media/templates/player.php | 1 - apps/media/templates/playlist.php | 6 -- 9 files changed, 110 insertions(+), 141 deletions(-) diff --git a/apps/media/appinfo/app.php b/apps/media/appinfo/app.php index 4cdb36d450..bc80536a96 100644 --- a/apps/media/appinfo/app.php +++ b/apps/media/appinfo/app.php @@ -27,34 +27,4 @@ OC_Util::addScript('media','loader'); OC_App::register( array( 'order' => 3, 'id' => 'media', 'name' => 'Media' )); OC_App::addNavigationEntry( array( 'id' => 'media_index', 'order' => 2, 'href' => OC_Helper::linkTo( 'media', 'index.php' ), 'icon' => OC_Helper::imagePath( 'media', 'media.png' ), 'name' => 'Music' )); - -// add subnavigations -$entry = array( - 'id' => "media_playlist", - 'order'=>1, - 'href' => '#playlist', - 'name' => 'Playlist' -); -OC_App::addNavigationSubEntry( "media_index", $entry); -$entry = array( - 'id' => "media_collection", - 'order'=>1, - 'href' => '#collection', - 'name' => 'Collection' -); -OC_App::addNavigationSubEntry( "media_index", $entry); -// $entry = array( -// 'id' => "media_recent", -// 'order'=>1, -// 'href' => '#recent', -// 'name' => 'Most Recent' -// ); -// OC_App::addNavigationSubEntry( "media_index", $entry); -// $entry = array( -// 'id' => "media_mostplayer", -// 'order'=>1, -// 'href' => '#mostplayed', -// 'name' => 'Most Played' -// ); -// OC_App::addNavigationSubEntry( "media_index", $entry); ?> diff --git a/apps/media/css/music.css b/apps/media/css/music.css index 3637234ab1..b8c695f74d 100644 --- a/apps/media/css/music.css +++ b/apps/media/css/music.css @@ -3,7 +3,7 @@ li button.right.prettybutton{font-size:1em;} #collection{padding-top:1em;position:relative;width:70ex;float:left;} #collection li.album,#collection li.song{margin-left:3ex;} -#playlist{width:100%;border-spacing:0;} +#playlist{border-spacing:0;} #playlist th{background-color:#ccc; text-align:left; font-size:1.2em; padding:0.2em} #playlist tr.selected{background-color:#eee;} #playlist tr.current{background-color:#ccc;} @@ -12,7 +12,8 @@ li button.right.prettybutton{font-size:1em;} #collection li,#playlist li{list-style-type:none;} .template{display:none} -#collection{display:none}/*hide the collection initially*/ #collection li{padding-right:10px;} img.remove{float:right;} #searchresults input.play, #searchresults input.add{float:right; height:16px; width:16px;} +#collection tr.collapsed td.album, #collection tr.collapsed td.title{color:#ddd} +a.expander{float:right;display:block} \ No newline at end of file diff --git a/apps/media/js/collection.js b/apps/media/js/collection.js index 520ce7d112..df7b79e332 100644 --- a/apps/media/js/collection.js +++ b/apps/media/js/collection.js @@ -49,68 +49,106 @@ Collection={ Collection.load(Collection.display) }else{ if(Collection.parent){ - Collection.parent.children('li.artist').remove(); - var template=Collection.parent.children('li.template'); - for(var i=0;i1){ + var expander=$('>'); + expander.data('expanded',true); + expander.click(function(event){ + var tr=$(this).parent().parent(); + if(expander.data('expanded')){ + Collection.hideArtist(tr.data('artist')); + }else{ + Collection.showArtist(tr.data('artist')); + } + }); + tr.children('td.artist').append(expander); + } + } + if(album.album_name!=lastAlbum){ + tr.find('td.album a').click(function(event){ + event.preventDefault(); + PlayList.add(album); + PlayList.render(); + }); + tr.find('td.album a').text(album.album_name); + if(album.songs.length>1){ + var expander=$('>'); + expander.data('expanded',true); + expander.click(function(event){ + var tr=$(this).parent().parent(); + if(expander.data('expanded')){ + Collection.hideAlbum(tr.data('album')); + }else{ + Collection.showAlbum(tr.data('album')); + } + }); + tr.children('td.album').append(expander); + } + } + tr.attr('data-artist',artist.artist_name); + tr.attr('data-album',album.album_name); + lastArtist=artist.artist_name; + lastAlbum=album.album_name; + + Collection.parent.find('tbody').append(tr); + }); + Collection.hideAlbum(artist.artist_name,album.album_name); + }); + Collection.hideArtist(artist.artist_name); + }); } } }, + showArtist:function(artist){ + Collection.parent.find('tr[data-artist="'+artist+'"]').show(); + Collection.parent.find('tr[data-artist="'+artist+'"]').first().removeClass('collapsed'); + Collection.parent.find('tr[data-artist="'+artist+'"] a.expander').data('expanded',true); + Collection.parent.find('tr[data-artist="'+artist+'"] a.expander').addClass('expanded'); + Collection.parent.find('tr[data-artist="'+artist+'"] a.expander').text('v'); + }, + hideArtist:function(artist){ + if(Collection.parent.find('tr[data-artist="'+artist+'"]').length>1){ + Collection.parent.find('tr[data-artist="'+artist+'"]').hide(); + Collection.parent.find('tr[data-artist="'+artist+'"]').first().show(); + Collection.parent.find('tr[data-artist="'+artist+'"]').first().addClass('collapsed'); + Collection.parent.find('tr[data-artist="'+artist+'"] a.expander').data('expanded',false); + Collection.parent.find('tr[data-artist="'+artist+'"] a.expander').removeClass('expanded'); + Collection.parent.find('tr[data-artist="'+artist+'"] a.expander').text('>'); + } + }, + showAlbum:function(artist,album){ + Collection.parent.find('tr[data-artist="'+artist+'"][data-album="'+album+'"]').show(); + }, + hideAlbum:function(artist,album){ + Collection.parent.find('tr[data-artist="'+artist+'"][data-album="'+album+'"]').hide(); + Collection.parent.find('tr[data-artist="'+artist+'"][data-album="'+album+'"]').last().show(); + }, parent:null, hide:function(){ if(Collection.parent){ Collection.parent.hide(); } }, - showAlbums:function(artistLi){ - $('ul.albums').parent().removeClass('active'); - $('ul.albums').remove(); - var artist=artistLi.data('artist'); - if(artist){ - var template=Collection.parent.children('li.template'); - var ul=$('
      '); - for(var i=0;i'); - for(var i=0;ispan').live('click',function(){ - $(this).parent().toggleClass('active'); - Collection.showAlbums($(this).parent()); - }); - $('#collection li.album>span').live('click',function(){ - $(this).parent().toggleClass('active'); - Collection.showSongs($(this).parent()); - }); Collection.parent.hide(); $('#scan input.start').click(function(){ $('#scan input.start').hide(); diff --git a/apps/media/js/music.js b/apps/media/js/music.js index 4e11b2951b..7034824cad 100644 --- a/apps/media/js/music.js +++ b/apps/media/js/music.js @@ -1,23 +1,4 @@ $(document).ready(function(){ - //load the collection - $('#navigation a[href="#collection"]').click(function(){ - $('#navigation li.subentry a.active').removeClass('active'); - $(this).addClass('active'); - PlayList.hide(); - Collection.display(); - }); - $('#navigation a[href="#playlist"]').click(function(){ - $('#navigation li.subentry a.active').removeClass('active'); - $(this).addClass('active'); - PlayList.render(); - Collection.hide(); - }); - var tab=window.location.href.slice(window.location.href.indexOf('#') + 1); - PlayList.init('mp3',function(){ - if(tab=='collection'){ - $('#navigation a[href="#collection"]').trigger('click'); - } - }); OC.search.customResults.Music=function(row,item){ var parts=item.link.substr(item.link.indexOf('#')+1).split('&'); var data={}; @@ -43,6 +24,7 @@ $(document).ready(function(){ }); row.find('div.name').append(button); } + Collection.display(); }); diff --git a/apps/media/js/playlist.js b/apps/media/js/playlist.js index a15c34f93f..636ae29c55 100644 --- a/apps/media/js/playlist.js +++ b/apps/media/js/playlist.js @@ -10,19 +10,9 @@ PlayList.render=function(){ tr.removeClass('template'); tr.data('name',item.name); tr.data('artist',item.artist); - tr.data('album',item.album); - tr.data('time',item.length); - tr.data('plays',item.playcount); tr.children('td.name').children('span').text(item.name); tr.children('td.artist').text(item.artist); tr.children('td.album').text(item.album); - var secconds=(item.length%60); - if(secconds<10){ - secconds='0'+secconds; - } - var length=Math.floor(item.length/60)+':'+secconds; - tr.children('td.time').text(length); - tr.children('td.plays').text(item.playcount); tr.data('index',i); tr.click(function(){ PlayList.play($(this).data('index')); diff --git a/apps/media/templates/collection.php b/apps/media/templates/collection.php index f47cba2486..8fd437f769 100644 --- a/apps/media/templates/collection.php +++ b/apps/media/templates/collection.php @@ -4,14 +4,17 @@ -
        -
      • - loadingLoading Collection... -
      • -
      • - - - -
      • -
      - +
      "") { echo(''); } ?>
      '.$kb['description'].''); ?> +

      '.$kb['description'].''); ?> '') echo('
      Answer:
      '.$kb['answer'].'');?>
      + + + + + + + + + + + + +
      ArtistAlbumTitle
      diff --git a/apps/media/templates/music.php b/apps/media/templates/music.php index 7a61d59c9b..dd393535bb 100644 --- a/apps/media/templates/music.php +++ b/apps/media/templates/music.php @@ -1,3 +1,3 @@ - + diff --git a/apps/media/templates/player.php b/apps/media/templates/player.php index 31b06e097b..9d6ead458f 100644 --- a/apps/media/templates/player.php +++ b/apps/media/templates/player.php @@ -2,7 +2,6 @@
      Name ArtistAlbumTimePlays
      \ No newline at end of file From 90726b10c417cd53361a2c914b2fb9c7eb10aac4 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 8 Aug 2011 18:05:39 +0200 Subject: [PATCH 05/32] fix a problem with ranming files containing spaces --- files/js/filelist.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/js/filelist.js b/files/js/filelist.js index 8fd3bceafb..ce9595d349 100644 --- a/files/js/filelist.js +++ b/files/js/filelist.js @@ -113,7 +113,7 @@ FileList={ var tr=$('tr[data-file="'+name+'"]'); tr.data('renaming',true); var td=tr.children('td.filename'); - var input=$(''); + var input=$(''); var form=$('
      ') form.append(input); td.children('a.name').text(''); From 4de7009014f3b64b5a17a73d57167c7f82b56b33 Mon Sep 17 00:00:00 2001 From: Jan-Christoph Borchardt Date: Mon, 8 Aug 2011 17:52:29 +0200 Subject: [PATCH 06/32] removed gratuitous main div --- core/templates/layout.admin.php | 52 ++++++++++++++++----------------- core/templates/layout.user.php | 36 +++++++++++------------ 2 files changed, 42 insertions(+), 46 deletions(-) diff --git a/core/templates/layout.admin.php b/core/templates/layout.admin.php index d70c54f7b1..853fcff608 100644 --- a/core/templates/layout.admin.php +++ b/core/templates/layout.admin.php @@ -36,36 +36,34 @@ -
      - -
      - -
      +
      +
      diff --git a/core/templates/layout.user.php b/core/templates/layout.user.php index a8dff9ff3d..57c48563bd 100644 --- a/core/templates/layout.user.php +++ b/core/templates/layout.user.php @@ -37,25 +37,23 @@
      -
      - -
      - -
      + +
      +
      From c3503013427b587ecbd645362dd4d460db860f8f Mon Sep 17 00:00:00 2001 From: Jan-Christoph Borchardt Date: Mon, 8 Aug 2011 17:57:45 +0200 Subject: [PATCH 07/32] optimized CSS, fixed login header --- core/css/styles.css | 38 ++++---- core/templates/installation.php | 157 ++++++++++++++++---------------- core/templates/layout.guest.php | 5 +- core/templates/login.php | 40 ++++---- 4 files changed, 120 insertions(+), 120 deletions(-) diff --git a/core/css/styles.css b/core/css/styles.css index 0f05850e26..97352abb6c 100644 --- a/core/css/styles.css +++ b/core/css/styles.css @@ -1,16 +1,31 @@ -* { margin:0; padding:0; border:0; cursor:default; } +* { margin:0; padding:0; border:0; outline:0; cursor:default; } body { background:#fefefe; font:normal 80%/1.6em "Lucida Grande", Arial, Verdana, sans-serif; color:#000; } -#header { position:fixed; top:0; z-index:100; width:100%; height:2.5em; padding:.5em; background:#1d2d44; -moz-box-shadow:0 0 10px #000, inset 0 -2px 10px #222; -webkit-box-shadow:0 0 10px #000, inset 0 -2px 10px #222; box-shadow:0 0 10px #000, inset 0 -2px 10px #222; } + + +/* HEADERS */ +#body-user #header, #body-settings #header { position:fixed; top:0; z-index:100; width:100%; height:2.5em; padding:.5em; background:#1d2d44; -moz-box-shadow:0 0 10px #000, inset 0 -2px 10px #222; -webkit-box-shadow:0 0 10px #000, inset 0 -2px 10px #222; box-shadow:0 0 10px #000, inset 0 -2px 10px #222; } #body-settings #header { background:#313131; } +#body-login #header { margin:-2em auto 0; text-align:center; height:10em; + -moz-box-shadow:0 0 1em #000; -webkit-box-shadow:0 0 1em #000; box-shadow:0 0 1em #000; +background: #1d2d44; /* Old browsers */ +background: -moz-linear-gradient(top, #35537a 0%, #1d2d42 100%); /* FF3.6+ */ +background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#35537a), color-stop(100%,#1d2d42)); /* Chrome,Safari4+ */ +background: -webkit-linear-gradient(top, #35537a 0%,#1d2d42 100%); /* Chrome10+,Safari5.1+ */ +background: -o-linear-gradient(top, #35537a 0%,#1d2d42 100%); /* Opera11.10+ */ +background: -ms-linear-gradient(top, #35537a 0%,#1d2d42 100%); /* IE10+ */ +background: linear-gradient(top, #35537a 0%,#1d2d42 100%); /* W3C */ +filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#35537a', endColorstr='#1d2d42',GradientType=0 ); /* IE6-9 */ } + #owncloud { float:left; } h1 { margin:1em 3em 1em 0; border-bottom:1px solid #666; text-transform:uppercase; font-weight:normal; font-style:italic; color:#666; } p.center { text-align:center; } -a { color:#000; text-decoration:none; outline:0; } +a { color:#000; text-decoration:none; } table { white-space:nowrap; } -input, select { background:#fff; color:#333; outline:0; } a, a img, a strong, a span, input, button, select, li { cursor:pointer; } -input[type="text"], input[type="password"] { cursor:text; } + +/* INPUTS */ +input[type="text"], input[type="password"] { cursor:text; } input, select { font-size:1em; width:10em; margin:.3em; padding:.5em; background:#fff; color:#333; border:1px solid #ddd; -moz-box-shadow:0 1px 1px #fff, 0 2px 0 #bbb inset; -webkit-box-shadow:0 1px 1px #fff, 0 1px 0 #bbb inset; box-shadow:0 1px 1px #fff, 0 1px 0 #bbb inset; -moz-border-radius:.5em; -webkit-border-radius:.5em; border-radius:.5em; } input[type="text"], input[type="password"] { background:#f8f8f8; color:#555; cursor:text; } input[type="text"]:hover, input[type="text"]:focus, input[type="password"]:hover, input[type="password"]:focus { background:#fff; color:#333; } @@ -27,6 +42,8 @@ radius:1em; border-radius:1em; } input[type="submit"].enabled { background:#66f866; border:1px solid #5e5; -moz-box-shadow:0 1px 1px #f8f8f8, 0 1px 1px #cfc inset; -webkit-box-shadow:0 1px 1px #f8f8f8, 0 1px 1px #cfc inset; box-shadow:0 1px 1px #f8f8f8, 0 1px 1px #cfc inset; } input[type="submit"].highlight{ background:#ffc100; border:1px solid #db0; text-shadow:#ffeedd 0 1px 0; -moz-box-shadow:0 1px 1px #f8f8f8, 0 1px 1px #ffeedd inset; -webkit-box-shadow:0 1px 1px #f8f8f8, 0 1px 1px #ffeedd inset; box-shadow:0 1px 1px #f8f8f8, 0 1px 1px #ffeedd inset; } + + form#user_settings { max-width:600px; } form#user_settings p label { display:block; float:left; width:35%; padding:0.4em 0.5em 0 0; text-align:right; } form p { padding:0.5em 4em 0.5em 0.5em; text-align:left; } @@ -44,17 +61,6 @@ div.controls { width:100%; height:3em; margin:0; background-color:#f7f7f7; borde #body-login p.info { width:16em; margin:2em auto; padding:1em; background-color:#eee; -moz-box-shadow:0 1px 0 #bbb inset; -webkit-box-shadow:0 1px 0 #bbb inset; box-shadow:0 1px 0 #bbb inset; -moz-border-radius:1em; -webkit-border-radius:1em; border-radius:1em; } #body-login p.info a { font-weight:bold; } -#body-login header { margin:-2em auto 0; text-align:center; height:10em; - -moz-box-shadow:0 0 1em #000; -webkit-box-shadow:0 0 1em #000; box-shadow:0 0 1em #000; -background: #1d2d44; /* Old browsers */ -background: -moz-linear-gradient(top, #35537a 0%, #1d2d42 100%); /* FF3.6+ */ -background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#35537a), color-stop(100%,#1d2d42)); /* Chrome,Safari4+ */ -background: -webkit-linear-gradient(top, #35537a 0%,#1d2d42 100%); /* Chrome10+,Safari5.1+ */ -background: -o-linear-gradient(top, #35537a 0%,#1d2d42 100%); /* Opera11.10+ */ -background: -ms-linear-gradient(top, #35537a 0%,#1d2d42 100%); /* IE10+ */ -background: linear-gradient(top, #35537a 0%,#1d2d42 100%); /* W3C */ -filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#35537a', endColorstr='#1d2d42',GradientType=0 ); /* IE6-9 */ } - #login { min-height:30em; margin:2em auto 0; border-bottom:1px solid #f8f8f8; background:#eee; } #login form { width:18em; margin:2em auto 5em; padding:0; } #login form fieldset { background-color:transparent; border:0; margin:0; padding:0; } diff --git a/core/templates/installation.php b/core/templates/installation.php index de14c56241..c5cf26bf12 100644 --- a/core/templates/installation.php +++ b/core/templates/installation.php @@ -1,85 +1,82 @@ -
      -
      ownCloud
      -
      + + + + 0): ?> +
        + +
      • + + +

        + + + +
      • + +
      + + +
      + t( 'Create an admin account' ); ?> +

      +

      +
      + +t( 'Advanced' ); ?> ▾ + +
      + t( 'Set data folder' ); ?> +

      +
      - - 0): ?> -
        - -
      • - - -

        - - - -
      • - -
      +
      + t( 'Configure the database' ); ?> + + + +

      t( 'SQLite will be used.' ); ?>

      + + +

      />

      + -
      - t( 'Create an admin account' ); ?> -

      -

      -
      - - t( 'Advanced' ); ?> ▾ - -
      - t( 'Set data folder' ); ?> -

      -
      - -
      - t( 'Configure the database' ); ?> - - - -

      t( 'SQLite will be used.' ); ?>

      - - -

      />

      - - + + + +

      t( 'MySQL will be used.' ); ?>

      + + + /> + +
      + + + + + + +
      + - - - -

      t( 'MySQL will be used.' ); ?>

      - - - /> - -
      - - - - - - -
      - + + + +

      t( 'PostgreSQL will be used.' ); ?>

      + + +

      />

      + +
      + + + + + + +
      + +
      - - - -

      t( 'PostgreSQL will be used.' ); ?>

      - - -

      />

      - -
      - - - - - - -
      - -
      - - -
      -
      + + diff --git a/core/templates/layout.guest.php b/core/templates/layout.guest.php index 0b6189ef1c..cd4078395b 100644 --- a/core/templates/layout.guest.php +++ b/core/templates/layout.guest.php @@ -29,7 +29,10 @@ - +
      + + +

      t( 'ownCloud is a personal cloud which runs on your own server.

      ' ); ?> diff --git a/core/templates/login.php b/core/templates/login.php index 19f25f033d..85db3bc9a5 100644 --- a/core/templates/login.php +++ b/core/templates/login.php @@ -1,23 +1,17 @@ -
      -
      - ownCloud -
      -
      -
      - - t( 'Login failed!' ); ?> - - - - - - - - - - - -
      -
      -
      - +
      +
      + + t( 'Login failed!' ); ?> + + + + + + + + + + + +
      +
      From ded97de8915975d169025fd8d3a8ebab8cbfa513 Mon Sep 17 00:00:00 2001 From: Jan-Christoph Borchardt Date: Mon, 8 Aug 2011 19:50:36 +0200 Subject: [PATCH 08/32] removed excess code --- core/templates/404.php | 15 ++++++--------- core/templates/error.php | 20 ++++++++------------ 2 files changed, 14 insertions(+), 21 deletions(-) diff --git a/core/templates/404.php b/core/templates/404.php index 67ce8c8026..13a8101034 100644 --- a/core/templates/404.php +++ b/core/templates/404.php @@ -7,12 +7,9 @@ if(!isset($_)){//also provide standalone error page exit; } ?> -
      -
      ownCloud
      -
        -
      • - t( 'Error 404, Cloud not found' ); ?>
        -

        -
      • -
      -
      +
        +
      • + t( 'Cloud not found' ); ?>
        +

        +
      • +
      diff --git a/core/templates/error.php b/core/templates/error.php index aa8a8d473b..4f05e008f9 100644 --- a/core/templates/error.php +++ b/core/templates/error.php @@ -1,12 +1,8 @@ -
      -
      ownCloud
      -
        - -
      • -
        -

        -
      • - -
      -
      - +
        + +
      • +
        +

        +
      • + +
      From e153fb79bbfb74a832d1d6c4bdd4997f37923df5 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 8 Aug 2011 20:23:57 +0200 Subject: [PATCH 09/32] fix mysql config not showing for installation --- core/js/setup.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/core/js/setup.js b/core/js/setup.js index 3025a511c6..6ef20673f1 100644 --- a/core/js/setup.js +++ b/core/js/setup.js @@ -1,9 +1,4 @@ $(document).ready(function() { - // Hide the MySQL config div if needed : - if(!$('#mysql').is(':checked')) { - $('#use_mysql').hide(); - } - // Hide the PostgreSQL config div if needed: if(!$('#pgsql').is(':checked')) { $('#use_postgresql').hide(); @@ -35,4 +30,9 @@ $(document).ready(function() { $('#databaseField').slideToggle(250); } }); + + // Hide the MySQL config div if needed : + if($('#dbtype').val()=='sqlite') { + $('#databaseField').hide(); + } }); From 3b34cba4ae9846a7e1faf7353738a654d616abc6 Mon Sep 17 00:00:00 2001 From: Jan-Christoph Borchardt Date: Mon, 8 Aug 2011 21:40:39 +0200 Subject: [PATCH 10/32] first mediaplayer styling --- apps/media/css/player.css | 8 ++-- apps/media/js/settings.js | 65 ------------------------- apps/media/templates/collection.php | 20 -------- apps/media/templates/music.php | 74 +++++++++++++++++++++++++++-- apps/media/templates/player.php | 21 -------- apps/media/templates/playlist.php | 24 ---------- apps/media/templates/settings.php | 23 --------- core/css/styles.css | 4 +- core/templates/installation.php | 4 +- files/templates/index.php | 2 +- 10 files changed, 79 insertions(+), 166 deletions(-) delete mode 100644 apps/media/js/settings.js delete mode 100644 apps/media/templates/collection.php delete mode 100644 apps/media/templates/player.php delete mode 100644 apps/media/templates/playlist.php delete mode 100644 apps/media/templates/settings.php diff --git a/apps/media/css/player.css b/apps/media/css/player.css index 94dd4d6360..8f96a3c17a 100644 --- a/apps/media/css/player.css +++ b/apps/media/css/player.css @@ -1,8 +1,6 @@ -#jp-interface{position:fixed;z-index:100;width:25em;left:201px;top:-20px;height:60px;border-bottom:none;} -#jp-interface div.player{height:0px} -#jp-interface ul.jp-controls{list-style-type:none;padding:0;} -#jp-interface ul.jp-controls li{display:inline;} -#jp-interface ul.jp-controls a{position:absolute;overflow:hidden;text-indent:-9999px;} +#controls ul.jp-controls{list-style-type:none;padding:0;} +#controls ul.jp-controls li{display:inline;} +#controls ul.jp-controls a{position:absolute;overflow:hidden;text-indent:-9999px;} a.jp-play,a.jp-pause{width:40px;height:40px;z-index:1;top:20px;left:48px;} a.jp-play{background:url("../img/jplayer.blue.monday.png") 0 0 no-repeat;} a.jp-play:hover{background:url("../img/jplayer.blue.monday.png") -41px 0 no-repeat;} diff --git a/apps/media/js/settings.js b/apps/media/js/settings.js deleted file mode 100644 index 3dabd86a49..0000000000 --- a/apps/media/js/settings.js +++ /dev/null @@ -1,65 +0,0 @@ -$(document).ready(function() { - $("button.scan").click(function(event){ - event.preventDefault(); - var parent=$(this).parent().parent(); - var path=parent.children('input').val(); - scan(path); - }); - $("button.rescan").live('click', function(event) { - event.preventDefault(); - var parent=$(this).parent().parent(); - var path=parent.contents().filter(function(){ return(this.nodeType == 3); }).text(); - path=path.trim(); - scan(path); - }); - $("button.delete").live('click', function(event) { - event.preventDefault(); - var parent=$(this).parent().parent(); - var path=parent.contents().filter(function(){ return(this.nodeType == 3); }).text(); - path=path.trim(); - var data="action=delete&path="+path; - $.ajax({ - type: 'POST', - url: 'ajax/api.php', - cache: false, - data: data, - success: function(){ - parent.remove(); - } - }); - }); - $( "#scanpath" ).autocomplete({ - source: "../../files/ajax/autocomplete.php?dironly=true", - minLength: 1 - }); - $('#autoupdate').change(function(){ - $.ajax({ - url: 'ajax/autoupdate.php', - data: "autoupdate="+$(this).attr('checked') - }); - }) -}); - -function scan(path){ - var data="action=scan&path="+path; - $.ajax({ - type: 'POST', - url: 'ajax/api.php', - cache: false, - data: data, - success: function(songCount){ - var found=false; - $('#folderlist').children('li').each(function(){ - var otherPath=$(this).contents().filter(function(){ return(this.nodeType == 3); }).text(); - otherPath=otherPath.trim(); - if(otherPath==path){ - found=true; - $(this).children("span").html(songCount+" songs "); - } - }) - if(!found){ - $('#folderlist').children().last().before("
    • "+path+""+songCount+" songs
    • "); - } - } - }); -} diff --git a/apps/media/templates/collection.php b/apps/media/templates/collection.php deleted file mode 100644 index 8fd437f769..0000000000 --- a/apps/media/templates/collection.php +++ /dev/null @@ -1,20 +0,0 @@ -
      - -
      - - -
      - - - - - - - - - - - - - -
      ArtistAlbumTitle
      diff --git a/apps/media/templates/music.php b/apps/media/templates/music.php index dd393535bb..5fe11bdae3 100644 --- a/apps/media/templates/music.php +++ b/apps/media/templates/music.php @@ -1,3 +1,71 @@ - - - +
      + + + + + +
      +
      + +
      + + + + + + + + + + + + + + + + + + +
      NameArtist
      + The playlist is empty +
      + + +
      +
      + +
      +
      + +
      + + +
      + + + + + + + + + + + + + +
      ArtistAlbumTitle
      +
      diff --git a/apps/media/templates/player.php b/apps/media/templates/player.php deleted file mode 100644 index 9d6ead458f..0000000000 --- a/apps/media/templates/player.php +++ /dev/null @@ -1,21 +0,0 @@ -
      - - - - - -
      -
      diff --git a/apps/media/templates/playlist.php b/apps/media/templates/playlist.php deleted file mode 100644 index f99e8a0608..0000000000 --- a/apps/media/templates/playlist.php +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - - -
      NameArtist
      - The playlist is empty -
      - - -
      \ No newline at end of file diff --git a/apps/media/templates/settings.php b/apps/media/templates/settings.php deleted file mode 100644 index 45c6076150..0000000000 --- a/apps/media/templates/settings.php +++ /dev/null @@ -1,23 +0,0 @@ -
      -
      - Music Directories -
        - -
      • - - - songs - - - -
      • - -
      • - - -
      • -
      - - id='autoupdate' title='Automaticaly scan new files in above directories'> -
      -
      \ No newline at end of file diff --git a/core/css/styles.css b/core/css/styles.css index 97352abb6c..40f1602626 100644 --- a/core/css/styles.css +++ b/core/css/styles.css @@ -1,5 +1,5 @@ * { margin:0; padding:0; border:0; outline:0; cursor:default; } -body { background:#fefefe; font:normal 80%/1.6em "Lucida Grande", Arial, Verdana, sans-serif; color:#000; } +body { background:#fefefe; font:normal 80%/1.6em "Lucida Grande", Arial, Verdana, sans-serif; color:#000; margin-bottom:2em; } /* HEADERS */ @@ -54,7 +54,7 @@ border:1px solid #ddd; font-weight:bold; cursor:pointer; background:#f2f2f2; col legend { padding:.2em; font-size:1.2em; } .template{display:none;} -div.controls { width:100%; height:3em; margin:0; background-color:#f7f7f7; border-bottom:1px solid #eee; position:fixed; z-index:2; } +#controls { width:100%; height:3em; margin:0; background-color:#f7f7f7; border-bottom:1px solid #eee; position:fixed; z-index:2; } /* LOG IN & INSTALLATION ------------------------------------------------------------ */ #body-login { background-color:#ddd; } diff --git a/core/templates/installation.php b/core/templates/installation.php index c5cf26bf12..08a8cf1609 100644 --- a/core/templates/installation.php +++ b/core/templates/installation.php @@ -20,14 +20,14 @@ t( 'Create an admin account' ); ?>

      -
      + t( 'Advanced' ); ?> ▾
      t( 'Set data folder' ); ?>

      -
      +
      t( 'Configure the database' ); ?> diff --git a/files/templates/index.php b/files/templates/index.php index 46d47ee4e8..bb58f5e754 100644 --- a/files/templates/index.php +++ b/files/templates/index.php @@ -1,4 +1,4 @@ -
      +
      From 8bd82b96f3d9d2c6c8ec02922e2437c6cea02ff4 Mon Sep 17 00:00:00 2001 From: Bartek Przybylski Date: Mon, 8 Aug 2011 21:41:20 +0200 Subject: [PATCH 11/32] checking for apache server in setup --- lib/setup.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/setup.php b/lib/setup.php index f87581d758..04a65d0126 100644 --- a/lib/setup.php +++ b/lib/setup.php @@ -224,7 +224,9 @@ class OC_Setup { OC_Installer::installShippedApps(true); //create htaccess files for apache hosts - self::createHtaccess(); //TODO detect if apache is used + if (strstr($_SERVER['SERVER_SOFTWARE'], 'Apache')) { + self::createHtaccess(); + } //and we are done OC_Config::setValue('installed', true); From e6f6d3dabccb5f9fd42d7f0f609107a9023fc4d3 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 8 Aug 2011 21:42:25 +0200 Subject: [PATCH 12/32] dont use a different navigation page for settings stuff --- admin/appinfo/app.php | 7 - apps/files_publiclink/appinfo/app.php | 2 +- apps/user_ldap/appinfo/app.php | 2 +- core/templates/layout.admin.php | 69 ---------- core/templates/layout.user.php | 13 +- files/appinfo/app.php | 5 - help/appinfo/app.php | 9 -- lib/app.php | 181 +++++--------------------- lib/template.php | 16 +-- settings/appinfo/app.php | 1 - 10 files changed, 43 insertions(+), 262 deletions(-) delete mode 100644 core/templates/layout.admin.php diff --git a/admin/appinfo/app.php b/admin/appinfo/app.php index 08a36060fe..80850638f7 100644 --- a/admin/appinfo/app.php +++ b/admin/appinfo/app.php @@ -2,11 +2,4 @@ OC_App::register( array( "order" => 1, "id" => "admin", "name" => "Administration" )); -// OC_App::addAdminPage( array( "id" => "core_system", "order" => 1, "href" => OC_Helper::linkTo( "admin", "system.php" ), "name" =>"System", "icon" => OC_Helper::imagePath( "admin", "administration.png" ))); -OC_App::addAdminPage( array( "id" => "core_users", "order" => 2, "href" => OC_Helper::linkTo( "admin", "users.php" ), "name" => "Users", "icon" => OC_Helper::imagePath( "admin", "users.png" ))); -OC_App::addAdminPage( array( "id" => "core_apps", "order" => 3, "href" => OC_Helper::linkTo( "admin", "apps.php?installed" ), "name" => "Apps", "icon" => OC_Helper::imagePath( "admin", "apps.png" ))); - -// Add subentries for App installer -//OC_App::addNavigationSubEntry( "core_apps", array( "id" => "core_apps_get", "order" => 4, "href" => OC_Helper::linkTo( "admin", "apps.php" ), "name" => "Get new apps", "icon" => OC_Helper::imagePath( "admin", "navicon.png" ))); - ?> diff --git a/apps/files_publiclink/appinfo/app.php b/apps/files_publiclink/appinfo/app.php index 17646b3e5b..e2d8d27c00 100644 --- a/apps/files_publiclink/appinfo/app.php +++ b/apps/files_publiclink/appinfo/app.php @@ -1,6 +1,6 @@ "files_publiclink_administration", "order" => 1, "href" => OC_Helper::linkTo( "files_publiclink", "admin.php" ), "name" => "Public Links")); +OC_App::addNavigationEntry(array( "id" => "files_publiclink_administration", "order" => 2, "href" => OC_Helper::linkTo( "files_publiclink", "admin.php" ), "name" => "Public Links")); ?> diff --git a/apps/user_ldap/appinfo/app.php b/apps/user_ldap/appinfo/app.php index 7f20372ea8..a6fca41501 100644 --- a/apps/user_ldap/appinfo/app.php +++ b/apps/user_ldap/appinfo/app.php @@ -36,4 +36,4 @@ $entry = array( 'href' => OC_Helper::linkTo( "user_ldap", "settings.php" ), 'name' => 'LDAP' ); -OC_App::addNavigationSubEntry( "core_users", $entry); +// OC_App::addNavigationSubEntry( "core_users", $entry); diff --git a/core/templates/layout.admin.php b/core/templates/layout.admin.php deleted file mode 100644 index 853fcff608..0000000000 --- a/core/templates/layout.admin.php +++ /dev/null @@ -1,69 +0,0 @@ - - - - ownCloud - - - - - - - - - - - $value){ - echo "$name='$value' "; - }; - echo '>'; - echo $header['text']; - echo ''; - ?> - - - - - - - - -
      - -
      - - diff --git a/core/templates/layout.user.php b/core/templates/layout.user.php index 57c48563bd..db142241d6 100644 --- a/core/templates/layout.user.php +++ b/core/templates/layout.user.php @@ -32,13 +32,12 @@ ownCloud
        -
      diff --git a/files/appinfo/app.php b/files/appinfo/app.php index 0f95b19f59..a4cec3d6ec 100644 --- a/files/appinfo/app.php +++ b/files/appinfo/app.php @@ -3,10 +3,5 @@ OC_App::register( array( "order" => 2, "id" => "files", "name" => "Files" )); OC_App::addNavigationEntry( array( "id" => "files_index", "order" => 1, "href" => OC_Helper::linkTo( "files", "index.php" ), "icon" => OC_Helper::imagePath( "files", "home.png" ), "name" => "Files" )); -OC_App::addAdminPage( array( "id" => "files_administration", "order" => 3, "href" => OC_Helper::linkTo( "files", "admin.php" ), "name" => "Files", "icon" => OC_Helper::imagePath( "files", "folder.png" ))); - - -// To add navigation sub entries use -// OC_App::addNavigationSubEntry( "files_index", array( ... )); ?> diff --git a/help/appinfo/app.php b/help/appinfo/app.php index 2e82c0cd18..372e28c97b 100644 --- a/help/appinfo/app.php +++ b/help/appinfo/app.php @@ -2,13 +2,4 @@ OC_App::register( array( "order" => 1, "id" => "help", "name" => "Help" )); -// Workaround for having help as the last entry always -$entry = array( "id" => "help", "order" => 1000, "href" => OC_Helper::linkTo( "help", "index.php" ), "name" => "Help", "icon" => OC_Helper::imagePath( "help", "help.png" )); -if( isset( $_SESSION["user_id"] ) && OC_Group::inGroup( $_SESSION["user_id"], "admin" )){ - OC_App::addAdminPage( $entry ); -} -else{ - OC_App::addSettingsPage( $entry ); -} - ?> diff --git a/lib/app.php b/lib/app.php index 9e81ed8184..51e86c847d 100644 --- a/lib/app.php +++ b/lib/app.php @@ -30,10 +30,7 @@ class OC_App{ static private $init = false; static private $apps = array(); static private $activeapp = ''; - static private $adminpages = array(); - static private $settingspages = array(); static private $navigation = array(); - static private $subnavigation = array(); /** * @brief loads all apps @@ -166,38 +163,6 @@ class OC_App{ return true; } - /** - * @brief adds a sub entry to the navigation - * @param $parent id of the parent - * @param $data array containing the data - * @returns true/false - * - * This function adds a new sub entry to the navigation visible to users. - * these entries are visible only if the parent navigation entry is marked - * as being active (see activateNavigationEntry()). $data is an associative - * array. - * The following keys are required: - * - id: unique id for this entry ('addressbook_index') - * - href: link to the page - * - name: Human readable name ('Addressbook') - * - * The following keys are optional: - * - icon: path to the icon of the app - * - order: integer, that influences the position of your application in - * the navigation. Lower values come first. - */ - public static function addNavigationSubEntry( $parent, $data ){ - $data['active']=false; - if(!isset($data['icon'])){ - $data['icon']=''; - } - if( !array_key_exists( $parent, self::$subnavigation )){ - self::$subnavigation[$parent] = array(); - } - self::$subnavigation[$parent][] = $data; - return true; - } - /** * @brief marks a navigation entry as active * @param $id id of the entry @@ -223,70 +188,6 @@ class OC_App{ return self::$activeapp; } - /** - * @brief registers an admin page - * @param $data array containing the data - * @returns true/false - * - * This function registers a admin page that will be shown in the admin - * menu. $data is an associative array. - * The following keys are required: - * - id: unique id for this entry ('files_admin') - * - href: link to the admin page - * - name: Human readable name ('Files Administration') - * - * The following keys are optional: - * - order: integer, that influences the position of your application in - * the list. Lower values come first. - */ - public static function addAdminPage( $data = array()){ - // TODO: write function - OC_App::$adminpages[] = $data; - return true; - } - - /** - * @brief registers a settings page - * @param $data array containing the data - * @returns true/false - * - * This function registers a settings page. $data is an associative array. - * The following keys are required: - * - app: app the settings belong to ('files') - * - id: unique id for this entry ('files_public') - * - href: link to the admin page - * - name: Human readable name ('Public files') - * - * The following keys are optional: - * - order: integer, that influences the position of your application in - * the list. Lower values come first. - * - * For the main settings page of an app, the keys 'app' and 'id' have to be - * the same. - */ - public static function addSettingsPage( $data = array()){ - // TODO: write function - OC_App::$settingspages[] = $data; - return true; - } - - /** - * @brief Returns the navigation - * @returns associative array - * - * This function returns an array containing all entries added. The - * entries are sorted by the key 'order' ascending. Additional to the keys - * given for each app the following keys exist: - * - active: boolean, signals if the user is on this navigation entry - * - children: array that is empty if the key 'active' is false or - * contains the subentries if the key 'active' is true - */ - public static function getNavigation(){ - $navigation = self::proceedNavigation( self::$navigation ); - $navigation = self::addSubNavigation( $navigation ); - return $navigation; - } - /** * @brief Returns the Settings Navigation * @returns associative array @@ -295,57 +196,20 @@ class OC_App{ * entries are sorted by the key 'order' ascending. */ public static function getSettingsNavigation(){ - $navigation = self::proceedNavigation( self::$settingspages ); - $navigation = self::addSubNavigation( $navigation ); - - return $navigation; - } - - /** - * @brief Returns the admin navigation - * @returns associative array - * - * This function returns an array containing all admin pages added. The - * entries are sorted by the key 'order' ascending. - */ - public static function getAdminNavigation(){ - $navigation = self::proceedNavigation( self::$adminpages ); - $navigation = self::addSubNavigation( $navigation ); - - return $navigation; - } - - /// Private foo - private static function addSubNavigation( $list ){ - if(isset(self::$subnavigation[self::$activeapp])){ - $subNav=self::$subnavigation[self::$activeapp]; - foreach( $list as &$naventry ){ - if( $naventry['id'] == self::$activeapp ){ - $naventry['active'] = true; - $naventry['subnavigation'] = $subNav; - } - } - }else{ - foreach(self::$subnavigation as $parent=>$entries){ - $activeParent=false; - foreach($entries as &$subNav){ - $subNav['active']=$subNav['id'] == self::$activeapp; - if($subNav['active']){ - $activeParent=true; - } - } - if($activeParent){ - foreach( $list as &$naventry ){ - if( $naventry['id'] == $parent ){ - $naventry['active'] = true; - $naventry['subnavigation'] = $entries; - } - } - } - } + $admin=array( + array( "id" => "core_users", "order" => 2, "href" => OC_Helper::linkTo( "admin", "users.php" ), "name" => "Users", "icon" => OC_Helper::imagePath( "admin", "users.png" )), + array( "id" => "core_apps", "order" => 3, "href" => OC_Helper::linkTo( "admin", "apps.php?installed" ), "name" => "Apps", "icon" => OC_Helper::imagePath( "admin", "apps.png" )), + array( "id" => "files_administration", "order" => 3, "href" => OC_Helper::linkTo( "files", "admin.php" ), "name" => "Files", "icon" => OC_Helper::imagePath( "files", "folder.png" )), + ); + $settings=array( + array( "id" => "help", "order" => 1000, "href" => OC_Helper::linkTo( "help", "index.php" ), "name" => "Help", "icon" => OC_Helper::imagePath( "help", "help.png" )), + array( "id" => "settings", "order" => 1, "href" => OC_Helper::linkTo( "settings", "index.php" ), "name" => "Personal", "icon" => OC_Helper::imagePath( "settings", "personal.png" )) + ); + if( OC_Group::inGroup( $_SESSION["user_id"], "admin" )){ + $settings=array_merge($admin,$settings); } - - return $list; + $navigation = self::proceedNavigation($settings); + return $navigation; } /// This is private as well. It simply works, so don't ask for more details @@ -354,9 +218,6 @@ class OC_App{ $naventry['subnavigation'] = array(); if( $naventry['id'] == self::$activeapp ){ $naventry['active'] = true; - if( array_key_exists( $naventry['id'], self::$subnavigation )){ - $naventry['subnavigation'] = self::$subnavigation[$naventry['id']]; - } } else{ $naventry['active'] = false; @@ -392,6 +253,22 @@ class OC_App{ return $data; } + /** + * @brief Returns the navigation + * @returns associative array + * + * This function returns an array containing all entries added. The + * entries are sorted by the key 'order' ascending. Additional to the keys + * given for each app the following keys exist: + * - active: boolean, signals if the user is on this navigation entry + * - children: array that is empty if the key 'active' is false or + * contains the subentries if the key 'active' is true + */ + public static function getNavigation(){ + $navigation = self::proceedNavigation( self::$navigation ); + return $navigation; + } + /** * get the id of loaded app * @return string diff --git a/lib/template.php b/lib/template.php index 124343bd85..12047a38a1 100644 --- a/lib/template.php +++ b/lib/template.php @@ -242,22 +242,8 @@ class OC_Template{ // Add navigation entry $page->assign( "navigation", OC_App::getNavigation()); - } - elseif( $this->renderas == "admin" ) - { - $page = new OC_Template( "core", "layout.admin" ); - $search=new OC_Template( 'core', 'part.searchbox'); - $search->assign('searchurl',OC_Helper::linkTo( 'search', 'index.php' )); - $page->assign('searchbox', $search->fetchPage()); - - // Add menu data - if( OC_Group::inGroup( $_SESSION["user_id"], "admin" )){ - $page->assign( "adminnavigation", OC_App::getAdminNavigation()); - } $page->assign( "settingsnavigation", OC_App::getSettingsNavigation()); - } - else - { + }else{ $page = new OC_Template( "core", "layout.guest" ); } diff --git a/settings/appinfo/app.php b/settings/appinfo/app.php index db4594dcc2..4ffb944aba 100644 --- a/settings/appinfo/app.php +++ b/settings/appinfo/app.php @@ -1,6 +1,5 @@ "settings", "name" => "Settings" )); -OC_App::addSettingsPage( array( "id" => "settings", "order" => -1000, "href" => OC_Helper::linkTo( "settings", "index.php" ), "name" => "Personal", "icon" => OC_Helper::imagePath( "settings", "personal.png" ))); ?> From 5ecdd26902b7edd122a99de9286c8cdde8493185 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 8 Aug 2011 21:51:10 +0200 Subject: [PATCH 13/32] show settings page in the correct context --- admin/apps.php | 8 ++++---- admin/system.php | 2 +- admin/users.php | 2 +- files/admin.php | 2 +- help/index.php | 2 +- settings/index.php | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/admin/apps.php b/admin/apps.php index 4f39feab0c..de11dccc3d 100644 --- a/admin/apps.php +++ b/admin/apps.php @@ -53,7 +53,7 @@ if($installed){ $records[]=$record; } - $tmpl = new OC_Template( "admin", "appsinst", "admin" ); + $tmpl = new OC_Template( "admin", "appsinst", "user" ); $tmpl->assign( "apps", $records ); $tmpl->printPage(); unset($tmpl); @@ -63,7 +63,7 @@ if($installed){ if($categories==NULL){ OC_App::setActiveNavigationEntry( "core_apps" ); - $tmpl = new OC_Template( "admin", "app_noconn", "admin" ); + $tmpl = new OC_Template( "admin", "app_noconn", "user" ); $tmpl->printPage(); unset($tmpl); exit(); @@ -82,7 +82,7 @@ if($installed){ } // return template - $tmpl = new OC_Template( "admin", "apps", "admin" ); + $tmpl = new OC_Template( "admin", "apps", "user" ); $tmpl->assign( "categories", $categories ); $tmpl->assign( "apps", $apps ); @@ -94,7 +94,7 @@ if($installed){ $app=OC_OCSClient::getApplication($id); - $tmpl = new OC_Template( "admin", "app", "admin" ); + $tmpl = new OC_Template( "admin", "app", "user" ); $tmpl->assign( "categories", $categories ); $tmpl->assign( "app", $app ); $tmpl->printPage(); diff --git a/admin/system.php b/admin/system.php index 11a76132b4..da77027f7a 100644 --- a/admin/system.php +++ b/admin/system.php @@ -29,7 +29,7 @@ if( !OC_User::isLoggedIn() || !OC_Group::inGroup( OC_User::getUser(), 'admin' )) OC_App::setActiveNavigationEntry( "administration" ); -$tmpl = new OC_Template( "admin", "system", "admin" ); +$tmpl = new OC_Template( "admin", "system", "user" ); $tmpl->printPage(); ?> diff --git a/admin/users.php b/admin/users.php index b87f1bb5bc..30b9fa46d3 100644 --- a/admin/users.php +++ b/admin/users.php @@ -48,7 +48,7 @@ foreach( OC_Group::getGroups() as $i ){ $groups[] = array( "name" => $i ); } -$tmpl = new OC_Template( "admin", "users", "admin" ); +$tmpl = new OC_Template( "admin", "users", "user" ); $tmpl->assign( "users", $users ); $tmpl->assign( "groups", $groups ); $tmpl->printPage(); diff --git a/files/admin.php b/files/admin.php index 0b8639f38c..7161de6e19 100644 --- a/files/admin.php +++ b/files/admin.php @@ -42,7 +42,7 @@ if(isset($_POST['maxUploadSize'])){ OC_App::setActiveNavigationEntry( "files_administration" ); // return template -$tmpl = new OC_Template( "files", "admin", "admin" ); +$tmpl = new OC_Template( "files", "admin", "user" ); $tmpl->assign( 'htaccessWorking', $htaccessWorking ); $tmpl->assign( 'uploadMaxFilesize', $maxUploadFilesize); $tmpl->printPage(); diff --git a/help/index.php b/help/index.php index f1adea0be0..642b213173 100644 --- a/help/index.php +++ b/help/index.php @@ -18,7 +18,7 @@ OC_App::setActiveNavigationEntry( "help" ); $kbe=OC_OCSClient::getKnownledgebaseEntries(); -$tmpl = new OC_Template( "help", "index", "admin" ); +$tmpl = new OC_Template( "help", "index", "user" ); $tmpl->assign( "kbe", $kbe ); $tmpl->assign( "pagecount", $pagecount ); $tmpl->assign( "page", $page ); diff --git a/settings/index.php b/settings/index.php index 8b970a13c5..12f48f2383 100644 --- a/settings/index.php +++ b/settings/index.php @@ -24,7 +24,7 @@ unset($languages[array_search($lang,$languages)]); array_unshift($languages,$lang); // Return template -$tmpl = new OC_Template( "settings", "index", "admin"); +$tmpl = new OC_Template( "settings", "index", "user"); $tmpl->assign('usage',OC_Helper::humanFileSize($used)); $tmpl->assign('total_space',OC_Helper::humanFileSize($total)); $tmpl->assign('usage_relative',$relative); From 6aaa49d38620d2092f546cbb27f23da6f5e5e138 Mon Sep 17 00:00:00 2001 From: Jan-Christoph Borchardt Date: Mon, 8 Aug 2011 22:31:17 +0200 Subject: [PATCH 14/32] more media player fixes --- apps/media/css/music.css | 2 +- apps/media/css/player.css | 16 +++++++--------- apps/media/index.php | 10 +--------- apps/media/templates/music.php | 34 +++++++++++++++++----------------- core/css/styles.css | 14 +++++++------- 5 files changed, 33 insertions(+), 43 deletions(-) diff --git a/apps/media/css/music.css b/apps/media/css/music.css index b8c695f74d..dd9b8ea70d 100644 --- a/apps/media/css/music.css +++ b/apps/media/css/music.css @@ -16,4 +16,4 @@ li button.right.prettybutton{font-size:1em;} img.remove{float:right;} #searchresults input.play, #searchresults input.add{float:right; height:16px; width:16px;} #collection tr.collapsed td.album, #collection tr.collapsed td.title{color:#ddd} -a.expander{float:right;display:block} \ No newline at end of file +a.expander{float:right;display:block} diff --git a/apps/media/css/player.css b/apps/media/css/player.css index 8f96a3c17a..6cf424a8ea 100644 --- a/apps/media/css/player.css +++ b/apps/media/css/player.css @@ -1,27 +1,25 @@ #controls ul.jp-controls{list-style-type:none;padding:0;} #controls ul.jp-controls li{display:inline;} #controls ul.jp-controls a{position:absolute;overflow:hidden;text-indent:-9999px;} -a.jp-play,a.jp-pause{width:40px;height:40px;z-index:1;top:20px;left:48px;} +a.jp-play,a.jp-pause{width:40px;height:40px;z-index:1;top:0;left:48px;} a.jp-play{background:url("../img/jplayer.blue.monday.png") 0 0 no-repeat;} a.jp-play:hover{background:url("../img/jplayer.blue.monday.png") -41px 0 no-repeat;} a.jp-pause{background:url("../img/jplayer.blue.monday.png") 0 -42px no-repeat;display:none;} a.jp-pause:hover{background:url("../img/jplayer.blue.monday.png") -41px -42px no-repeat;} -a.jp-stop{top:26px;left:126px;background:url("../img/jplayer.blue.monday.png") 0 -83px no-repeat;width:28px;height:28px;z-index:1;} -a.jp-stop:hover{background:url("../img/jplayer.blue.monday.png") -29px -83px no-repeat;} -a.jp-previous{left:20px;top:26px;background:url("../img/jplayer.blue.monday.png") 0 -112px no-repeat;width:28px;height:28px;} +a.jp-previous{left:20px;top:.5em;background:url("../img/jplayer.blue.monday.png") 0 -112px no-repeat;width:28px;height:28px;} a.jp-previous:hover{background:url("../img/jplayer.blue.monday.png") -29px -112px no-repeat;} -a.jp-next{left:88px;top:26px;background:url("../img/jplayer.blue.monday.png") 0 -141px no-repeat;width:28px;height:28px;} +a.jp-next{left:88px;top:.5em;background:url("../img/jplayer.blue.monday.png") 0 -141px no-repeat;width:28px;height:28px;} a.jp-next:hover{background:url("../img/jplayer.blue.monday.png") -29px -141px no-repeat;} -div.jp-progress{position:absolute;overflow:hidden;background-color:#293b51;top:32px;left:164px;width:122px;height:15px;} +div.jp-progress{position:absolute;overflow:hidden;background-color:#293b51;top:1em;left:164px;width:122px;height:15px;} div.jp-seek-bar{background:url("../img/jplayer.blue.monday.png") 0 -202px repeat-x;width:0;height:100%;cursor:pointer;} div.jp-play-bar{background:url("../img/jplayer.blue.monday.png") 0 -218px repeat-x;width:0;height:100%;} div.jp-seeking-bg{background:url("../img/pbar-ani.gif");} -a.jp-mute,a.jp-unmute{height:15px;width:18px;top:32px;left:296px;} +a.jp-mute,a.jp-unmute{height:15px;width:18px;top:1em;left:296px;} a.jp-mute{background:url("../img/jplayer.blue.monday.png") 0 -186px no-repeat;} a.jp-mute:hover{background:url("../img/jplayer.blue.monday.png") -19px -170px no-repeat;} a.jp-unmute{background:url("../img/jplayer.blue.monday.png") 0 -170px no-repeat;display:none;} a.jp-unmute:hover{background:url("../img/jplayer.blue.monday.png") -19px -186px no-repeat;} -div.jp-volume-bar{position:absolute;overflow:hidden;background:url("../img/jplayer.blue.monday.png") 0 -250px repeat-x;width:46px;height:5px;cursor:pointer;top:37px;left:324px;} +div.jp-volume-bar{position:absolute;overflow:hidden;background:url("../img/jplayer.blue.monday.png") 0 -250px repeat-x;width:46px;height:5px;cursor:pointer;top:1.3em;left:324px;} div.jp-volume-bar-value{background:url("../img/jplayer.blue.monday.png") 0 -256px repeat-x;width:0;height:5px;} -div.jp-current-time,div.jp-duration{position:absolute;font-size:.64em;font-style:oblique;top:45px;left:164px;width:122px;} +div.jp-current-time,div.jp-duration{position:absolute;font-size:.64em;font-style:oblique;top:1em;left:164px;width:122px;} div.jp-duration{text-align:right;} diff --git a/apps/media/index.php b/apps/media/index.php index a7128aaad4..fe724b45dd 100644 --- a/apps/media/index.php +++ b/apps/media/index.php @@ -42,17 +42,9 @@ OC_Util::addScript('media','jquery.jplayer.min'); OC_Util::addStyle('media','player'); OC_Util::addStyle('media','music'); -OC_App::setActiveNavigationEntry( 'media_playlist' ); +OC_App::setActiveNavigationEntry( 'media_index' ); $tmpl = new OC_Template( 'media', 'music', 'user' ); - -$player = new OC_Template( 'media', 'player'); -$playlist = new OC_Template( 'media', 'playlist'); -$collection= new OC_Template( 'media', 'collection'); - -$tmpl->assign('player',$player->fetchPage()); -$tmpl->assign('playlist',$playlist->fetchPage()); -$tmpl->assign('collection',$collection->fetchPage()); $tmpl->printPage(); ?> diff --git a/apps/media/templates/music.php b/apps/media/templates/music.php index 5fe11bdae3..5d0b0b6f0c 100644 --- a/apps/media/templates/music.php +++ b/apps/media/templates/music.php @@ -17,15 +17,15 @@
      -
      +
      - +
      - - + + @@ -36,35 +36,35 @@ - - + - +
      NameArtistNameArtist
      - +
      +
      -
      - +
      +
      - - + +
      - +
      - - - - + + + +
      Artist Album Title
      diff --git a/core/css/styles.css b/core/css/styles.css index 40f1602626..e1999a61a5 100644 --- a/core/css/styles.css +++ b/core/css/styles.css @@ -3,8 +3,7 @@ body { background:#fefefe; font:normal 80%/1.6em "Lucida Grande", Arial, Verdana /* HEADERS */ -#body-user #header, #body-settings #header { position:fixed; top:0; z-index:100; width:100%; height:2.5em; padding:.5em; background:#1d2d44; -moz-box-shadow:0 0 10px #000, inset 0 -2px 10px #222; -webkit-box-shadow:0 0 10px #000, inset 0 -2px 10px #222; box-shadow:0 0 10px #000, inset 0 -2px 10px #222; } -#body-settings #header { background:#313131; } +#body-user #header { position:fixed; top:0; z-index:100; width:100%; height:2.5em; padding:.5em; background:#1d2d44; -moz-box-shadow:0 0 10px #000, inset 0 -2px 10px #222; -webkit-box-shadow:0 0 10px #000, inset 0 -2px 10px #222; box-shadow:0 0 10px #000, inset 0 -2px 10px #222; } #body-login #header { margin:-2em auto 0; text-align:center; height:10em; -moz-box-shadow:0 0 1em #000; -webkit-box-shadow:0 0 1em #000; box-shadow:0 0 1em #000; background: #1d2d44; /* Old browsers */ @@ -54,7 +53,12 @@ border:1px solid #ddd; font-weight:bold; cursor:pointer; background:#f2f2f2; col legend { padding:.2em; font-size:1.2em; } .template{display:none;} -#controls { width:100%; height:3em; margin:0; background-color:#f7f7f7; border-bottom:1px solid #eee; position:fixed; z-index:2; } +/* CONTENT ------------------------------------------------------------------ */ +#controls { width:100%; top:3.5em; height:3em; margin:0; background-color:#f7f7f7; border-bottom:1px solid #eee; position:fixed; z-index:2; } +#content { margin:3.5em 0 0 12.5em; } +#body-settings #content { padding:1em; } +#leftcontent { position:absolute; top:6.5em; width:50em; } +#rightcontent { position:absolute; top:6.5em; left:32em; } /* LOG IN & INSTALLATION ------------------------------------------------------------ */ #body-login { background-color:#ddd; } @@ -87,10 +91,6 @@ legend { padding:.2em; font-size:1.2em; } #navigation .subentry.active { background-color:#bbb; border-top:1px solid #888; border-bottom:1px solid #bbb; } #navigation .subentry a { padding-left:3.1em; font-size:1em; } -/* CONTENT ------------------------------------------------------------------ */ -#content { margin:3.5em 0 0 12.5em; } -#body-settings #content { padding:1em; } - /* USER SETTINGS ------------------------------------------------------------ */ #quota_indicator { margin:0 4em 1em 0; padding:0; border:1px solid #ddd; border-radius:10px; -webkit-border-radius:10px; -moz-border-radius:10px; } #quota_indicator div { background-color:#76A9EA; border-radius:10px; -webkit-border-radius:10px; -moz-border-radius:10px; } From d1d47eb5eb28d9a62f3a16cc3b1be4e0136bed8b Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 8 Aug 2011 22:37:27 +0200 Subject: [PATCH 15/32] do proper styling for settings pages --- core/css/styles.css | 2 +- core/templates/layout.user.php | 2 +- lib/template.php | 5 +++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/core/css/styles.css b/core/css/styles.css index e1999a61a5..b17224b269 100644 --- a/core/css/styles.css +++ b/core/css/styles.css @@ -3,7 +3,7 @@ body { background:#fefefe; font:normal 80%/1.6em "Lucida Grande", Arial, Verdana /* HEADERS */ -#body-user #header { position:fixed; top:0; z-index:100; width:100%; height:2.5em; padding:.5em; background:#1d2d44; -moz-box-shadow:0 0 10px #000, inset 0 -2px 10px #222; -webkit-box-shadow:0 0 10px #000, inset 0 -2px 10px #222; box-shadow:0 0 10px #000, inset 0 -2px 10px #222; } +#body-user #header, #body-settings #header { position:fixed; top:0; z-index:100; width:100%; height:2.5em; padding:.5em; background:#1d2d44; -moz-box-shadow:0 0 10px #000, inset 0 -2px 10px #222; -webkit-box-shadow:0 0 10px #000, inset 0 -2px 10px #222; box-shadow:0 0 10px #000, inset 0 -2px 10px #222; } #body-login #header { margin:-2em auto 0; text-align:center; height:10em; -moz-box-shadow:0 0 1em #000; -webkit-box-shadow:0 0 1em #000; box-shadow:0 0 1em #000; background: #1d2d44; /* Old browsers */ diff --git a/core/templates/layout.user.php b/core/templates/layout.user.php index db142241d6..4cbf6261cb 100644 --- a/core/templates/layout.user.php +++ b/core/templates/layout.user.php @@ -27,7 +27,7 @@ - + @@ -51,6 +51,7 @@
        +
      • class="active">
      • From 5ed1030dbf2fed22f0c5b4aaa9248ee3998e5cd6 Mon Sep 17 00:00:00 2001 From: Jan-Christoph Borchardt Date: Mon, 8 Aug 2011 23:39:16 +0200 Subject: [PATCH 19/32] fixed icons --- core/templates/layout.user.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/templates/layout.user.php b/core/templates/layout.user.php index ae847e9827..29dbfaa816 100644 --- a/core/templates/layout.user.php +++ b/core/templates/layout.user.php @@ -32,7 +32,7 @@ ownCloud
          -
        • +
      @@ -51,7 +51,7 @@
        - +
      • class="active">
      • From 82d2c45e14e5089defef8712dafa0fe97e16f8e0 Mon Sep 17 00:00:00 2001 From: Jan-Christoph Borchardt Date: Mon, 8 Aug 2011 23:41:41 +0200 Subject: [PATCH 20/32] cursor pointer cursor thingy --- core/css/styles.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/css/styles.css b/core/css/styles.css index 7960617d24..6f153f4209 100644 --- a/core/css/styles.css +++ b/core/css/styles.css @@ -95,7 +95,7 @@ legend { padding:.2em; font-size:1.2em; } #navigation .subentry.active { background-color:#bbb; border-top:1px solid #888; border-bottom:1px solid #bbb; } #navigation .subentry a { padding-left:3.1em; font-size:1em; } #navigation #settings { position:absolute; bottom:3.5em; width:100%; } -#navigation #expand { margin:0 0 .2em 1.2em; } +#navigation #expand { margin:0 0 .2em 1.2em; cursor:pointer; } /* USER SETTINGS ------------------------------------------------------------ */ #quota_indicator { margin:0 4em 1em 0; padding:0; border:1px solid #ddd; border-radius:10px; -webkit-border-radius:10px; -moz-border-radius:10px; } From 7b38e5d7c73cb29a5b57bb36b9f22ce2672cb325 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 8 Aug 2011 23:32:54 +0200 Subject: [PATCH 21/32] apps can now add their own forms to the Personal page --- apps/user_openid/appinfo/app.php | 2 ++ apps/user_openid/js/settings.js | 12 +++++++ apps/user_openid/settings.php | 10 ++++++ apps/user_openid/templates/settings.php | 6 ++++ lib/app.php | 47 +++++++++++++++++++++++++ settings/index.php | 8 ++--- settings/js/main.js | 11 ------ settings/templates/index.php | 14 +++----- 8 files changed, 85 insertions(+), 25 deletions(-) create mode 100644 apps/user_openid/js/settings.js create mode 100644 apps/user_openid/settings.php create mode 100644 apps/user_openid/templates/settings.php diff --git a/apps/user_openid/appinfo/app.php b/apps/user_openid/appinfo/app.php index 93b178ac70..3cdf2664e8 100644 --- a/apps/user_openid/appinfo/app.php +++ b/apps/user_openid/appinfo/app.php @@ -19,6 +19,8 @@ if(strpos($_SERVER["REQUEST_URI"],'?') and !strpos($_SERVER["REQUEST_URI"],'=')) OC_Util::addHeader('link',array('rel'=>'openid.server', 'href'=>$urlBase.OC_Helper::linkTo( "user_openid", "user.php" ).'/'.$userName)); OC_Util::addHeader('link',array('rel'=>'openid.delegate', 'href'=>$urlBase.OC_Helper::linkTo( "user_openid", "user.php" ).'/'.$userName)); +OC_APP::registerPersonal('user_openid','settings'); + require_once 'apps/user_openid/user_openid.php'; //active the openid backend diff --git a/apps/user_openid/js/settings.js b/apps/user_openid/js/settings.js new file mode 100644 index 0000000000..b85ce2d352 --- /dev/null +++ b/apps/user_openid/js/settings.js @@ -0,0 +1,12 @@ +$(document).ready(function(){ + $('#openidform input').blur(function(event){ + event.preventDefault(); + var post = $( "#openidform" ).serialize(); + $.post( 'ajax/openid.php', post, function(data){ + if( data.status == "success" ){ + }else{ + alert('error while setting OpenID'); + } + }); + }); +}); diff --git a/apps/user_openid/settings.php b/apps/user_openid/settings.php new file mode 100644 index 0000000000..d85eaebb5e --- /dev/null +++ b/apps/user_openid/settings.php @@ -0,0 +1,10 @@ +assign('identity',$identity); + +OC_Util::addScript('user_openid','settings'); + +return $tmpl->fetchPage(); +?> \ No newline at end of file diff --git a/apps/user_openid/templates/settings.php b/apps/user_openid/templates/settings.php new file mode 100644 index 0000000000..fff1eff09e --- /dev/null +++ b/apps/user_openid/templates/settings.php @@ -0,0 +1,6 @@ +
        +
        + t( 'OpenID' );?> + +
        +
        \ No newline at end of file diff --git a/lib/app.php b/lib/app.php index 51e86c847d..f1363c8af5 100644 --- a/lib/app.php +++ b/lib/app.php @@ -31,6 +31,9 @@ class OC_App{ static private $apps = array(); static private $activeapp = ''; static private $navigation = array(); + static private $settingsForms = array(); + static private $adminForms = array(); + static private $personalForms = array(); /** * @brief loads all apps @@ -284,4 +287,48 @@ class OC_App{ return $topFolder; } } + + + /** + * get the forms for either settings, admin or personal + */ + public static function getForms($type){ + $forms=array(); + switch($type){ + case 'settings': + $source=self::$settingsForms; + break; + case 'admin': + $source=self::$adminForms; + break; + case 'personal': + $source=self::$personalForms; + break; + } + foreach($source as $form){ + $forms[]=include $form; + } + return $forms; + } + + /** + * register a settings form to be shown + */ + public static function registerSettings($app,$page){ + self::$settingsForms[]='apps/'.$app.'/'.$page.'.php'; + } + + /** + * register an admin form to be shown + */ + public static function registerAdmin($app,$page){ + self::$adminForms[]='apps/'.$app.'/'.$page.'.php'; + } + + /** + * register a personal form to be shown + */ + public static function registerPersonal($app,$page){ + self::$personalForms[]='apps/'.$app.'/'.$page.'.php'; + } } diff --git a/settings/index.php b/settings/index.php index 12f48f2383..60cfd19c3f 100644 --- a/settings/index.php +++ b/settings/index.php @@ -29,10 +29,10 @@ $tmpl->assign('usage',OC_Helper::humanFileSize($used)); $tmpl->assign('total_space',OC_Helper::humanFileSize($total)); $tmpl->assign('usage_relative',$relative); $tmpl->assign('languages',$languages); -$tmpl->assign('hasopenid',OC_App::isEnabled( 'user_openid' )); -if(OC_App::isEnabled( 'user_openid' )){ - $identity=OC_Preferences::getValue(OC_User::getUser(),'user_openid','identity',''); - $tmpl->assign('identity',$identity); + +$forms=OC_App::getForms('personal'); +foreach($forms as $form){ + $tmpl->append('forms',$form); } $tmpl->printPage(); diff --git a/settings/js/main.js b/settings/js/main.js index e6ca30d0ce..f6b7eeb758 100644 --- a/settings/js/main.js +++ b/settings/js/main.js @@ -19,17 +19,6 @@ $(document).ready(function(){ return false; }); - $('#openidform').submit(function(event){ - event.preventDefault(); - var post = $( "#openidform" ).serialize(); - $.post( 'ajax/openid.php', post, function(data){ - if( data.status == "success" ){ - }else{ - alert('error while setting OpenID'); - } - }); - }); - $("#languageinput").change( function(){ // Serialize the data var post = $( "#languageinput" ).serialize(); diff --git a/settings/templates/index.php b/settings/templates/index.php index 6e68cfa148..0b5a14626f 100644 --- a/settings/templates/index.php +++ b/settings/templates/index.php @@ -18,16 +18,6 @@
      - -
      -
      - t( 'OpenID' );?> - -

      -
      -
      - -
      t( 'Language' );?> @@ -39,3 +29,7 @@
      + + From 8d03f03081b24d5491c52db4ad47768222a013c6 Mon Sep 17 00:00:00 2001 From: Jan-Christoph Borchardt Date: Mon, 8 Aug 2011 23:49:28 +0200 Subject: [PATCH 22/32] no mickey mouse hand on fieldsets please --- core/css/styles.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/css/styles.css b/core/css/styles.css index 6f153f4209..8af44482d6 100644 --- a/core/css/styles.css +++ b/core/css/styles.css @@ -53,7 +53,7 @@ form p { padding:0.5em 4em 0.5em 0.5em; text-align:left; } form p.form_footer { margin:1em 0 0 0; text-align:right; } form label { cursor:pointer; } #body-settings fieldset { padding:1em; width:40em; margin:1em; -border:1px solid #ddd; font-weight:bold; cursor:pointer; background:#f2f2f2; color:#555; text-shadow:#fff 0 1px 0; -moz-box-shadow:0 1px 1px #fff, 0 1px 1px #fff inset; -webkit-box-shadow:0 1px 1px #fff, 0 1px 1px #fff inset; -moz-border-radius:.5em; -webkit-border-radius:.5em; border-radius:.5em;} +border:1px solid #ddd; font-weight:bold; background:#f2f2f2; color:#555; text-shadow:#fff 0 1px 0; -moz-box-shadow:0 1px 1px #fff, 0 1px 1px #fff inset; -webkit-box-shadow:0 1px 1px #fff, 0 1px 1px #fff inset; -moz-border-radius:.5em; -webkit-border-radius:.5em; border-radius:.5em;} legend { padding:.2em; font-size:1.2em; } .template{display:none;} From 30d47732bd653cc38c6299aa01351daf049027db Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Tue, 9 Aug 2011 00:12:06 +0200 Subject: [PATCH 23/32] dont show an error if openid is dissabled --- settings/index.php | 1 + 1 file changed, 1 insertion(+) diff --git a/settings/index.php b/settings/index.php index 60cfd19c3f..9669b5b3db 100644 --- a/settings/index.php +++ b/settings/index.php @@ -31,6 +31,7 @@ $tmpl->assign('usage_relative',$relative); $tmpl->assign('languages',$languages); $forms=OC_App::getForms('personal'); +$tmpl->assign('forms',array()); foreach($forms as $form){ $tmpl->append('forms',$form); } From 8e3914bceb543bb8a8acba64e3e3adfdb06ca5d0 Mon Sep 17 00:00:00 2001 From: Jan-Christoph Borchardt Date: Tue, 9 Aug 2011 10:13:19 +0200 Subject: [PATCH 24/32] moved installation form error reporting directly to the HTML --- core/css/styles.css | 6 +++--- core/templates/installation.php | 32 ++++++++++++++++---------------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/core/css/styles.css b/core/css/styles.css index 8af44482d6..4cb630d4a9 100644 --- a/core/css/styles.css +++ b/core/css/styles.css @@ -71,13 +71,13 @@ legend { padding:.2em; font-size:1.2em; } #login { min-height:30em; margin:2em auto 0; border-bottom:1px solid #f8f8f8; background:#eee; } #login form { width:18em; margin:2em auto 5em; padding:0; } -#login form fieldset { background-color:transparent; border:0; margin:0; padding:0; } +#login form fieldset { background-color:transparent; border:0; margin-bottom:2em; padding:0; } +#login form fieldset legend { font-weight:bold; } #login form p { position:relative; padding:0; } #login form label { position:absolute; margin:.8em .8em; font-size:1.5em; color:#666; } #login form input[type="checkbox"]+label { position:relative; margin:0; font-size:1em; text-shadow:#fff 0 1px 0; } -#login form #use_mysql { font-size:.9em; margin:0 0 0 1em; } -#login form ul.errors { background:#fed7d7 url(images/no.png) no-repeat 1em 1em; border:1px solid #f00; font-size:1.2em; list-style-indent:inside; margin:0 0 4em 0; padding:1em 1em 1em 5em; } +#login form ul.errors { background:#fed7d7; border:1px solid #f00; list-style-indent:inside; margin:0 0 4em 0; padding:1em 1em 1em 5em; } /* META NAVIGATION (Settings, Log out) ---------------------------------------------------------------- */ #metanav { float:right; position:relative; top:.5em; right:1em; list-style:none; margin:0; padding:0; } diff --git a/core/templates/installation.php b/core/templates/installation.php index 08a8cf1609..f7352e1fd5 100644 --- a/core/templates/installation.php +++ b/core/templates/installation.php @@ -18,21 +18,14 @@
      t( 'Create an admin account' ); ?> -

      -

      +

      +

      - -t( 'Advanced' ); ?> ▾ - -
      - t( 'Set data folder' ); ?> -

      -
      t( 'Configure the database' ); ?> - +

      t( 'SQLite will be used.' ); ?>

      @@ -50,10 +43,10 @@ />
      - + - - + +
      @@ -68,15 +61,22 @@

      />

      - + - - + +
      + + t( 'Advanced' ); ?> ▾ + +
      + t( 'Set data folder' ); ?> +

      +
      From 44f3dfe771840ca426e52e4a32b1b7f31428aea1 Mon Sep 17 00:00:00 2001 From: Jan-Christoph Borchardt Date: Tue, 9 Aug 2011 10:30:37 +0200 Subject: [PATCH 25/32] added semantic meaning with header, nav and footer --- core/templates/layout.guest.php | 6 ++++-- core/templates/layout.user.php | 9 +++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/core/templates/layout.guest.php b/core/templates/layout.guest.php index cd4078395b..21388509f3 100644 --- a/core/templates/layout.guest.php +++ b/core/templates/layout.guest.php @@ -30,9 +30,11 @@
      - +
      -

      t( 'ownCloud is a personal cloud which runs on your own server.

      ' ); ?> +

      t( 'ownCloud is a personal cloud which runs on your own server.

      ' ); ?>

      diff --git a/core/templates/layout.user.php b/core/templates/layout.user.php index 29dbfaa816..2dce647873 100644 --- a/core/templates/layout.user.php +++ b/core/templates/layout.user.php @@ -28,15 +28,15 @@ - - +
      From 97462b018d7aae7bd6044bcb42d42c1b51171d5a Mon Sep 17 00:00:00 2001 From: Serge Martin Date: Tue, 9 Aug 2011 11:32:22 +0200 Subject: [PATCH 26/32] Merge MySQL and PostgreSQL input fields --- core/js/setup.js | 20 +++------------ core/templates/installation.php | 34 +++++++++++-------------- lib/setup.php | 45 ++++++++++++--------------------- 3 files changed, 35 insertions(+), 64 deletions(-) diff --git a/core/js/setup.js b/core/js/setup.js index 6ef20673f1..3fb895cc41 100644 --- a/core/js/setup.js +++ b/core/js/setup.js @@ -1,27 +1,20 @@ $(document).ready(function() { - // Hide the PostgreSQL config div if needed: - if(!$('#pgsql').is(':checked')) { - $('#use_postgresql').hide(); - } - $('#datadirField').hide(250); if($('#hasSQLite').val()=='true'){ $('#databaseField').hide(250); + $('#use_other_db').slideUp(250); } $('#sqlite').click(function() { - $('#use_mysql').slideUp(250); - $('#use_postgresql').slideUp(250); + $('#use_other_db').slideUp(250); }); $('#mysql').click(function() { - $('#use_mysql').slideDown(250); - $('#use_postgresql').slideUp(250); + $('#use_other_db').slideDown(250); }); $('#pgsql').click(function() { - $('#use_postgresql').slideDown(250); - $('#use_mysql').slideUp(250); + $('#use_other_db').slideDown(250); }); $('#showAdvanced').click(function() { @@ -30,9 +23,4 @@ $(document).ready(function() { $('#databaseField').slideToggle(250); } }); - - // Hide the MySQL config div if needed : - if($('#dbtype').val()=='sqlite') { - $('#databaseField').hide(); - } }); diff --git a/core/templates/installation.php b/core/templates/installation.php index f7352e1fd5..e9f7daf7b8 100644 --- a/core/templates/installation.php +++ b/core/templates/installation.php @@ -23,10 +23,11 @@
      + t( 'Configure the database' ); ?> - +

      t( 'SQLite will be used.' ); ?>

      @@ -42,7 +43,19 @@ /> -
      + + + + +

      t( 'PostgreSQL will be used.' ); ?>

      + + +

      />

      + + + + +
      @@ -52,23 +65,6 @@
      - - - -

      t( 'PostgreSQL will be used.' ); ?>

      - - -

      />

      - -
      - - - - - - -
      -
      t( 'Advanced' ); ?> ▾ diff --git a/lib/setup.php b/lib/setup.php index 04a65d0126..192fd13460 100644 --- a/lib/setup.php +++ b/lib/setup.php @@ -46,39 +46,26 @@ class OC_Setup { $error[] = 'STEP 2 : data directory path is not set.'; } - if($dbtype=='mysql') { //mysql needs more config options + if($dbtype=='mysql' or $dbtype=='pgsql') { //mysql and postgresql needs more config options + if($dbtype=='mysql') + $dbprettyname = 'MySQL'; + else + $dbprettyname = 'PostgreSQL'; + if(empty($options['dbuser'])) { - $error[] = 'STEP 3 : MySQL database user is not set.'; + $error[] = "STEP 3 : $dbprettyname database user is not set."; } if(empty($options['dbpass'])) { - $error[] = 'STEP 3 : MySQL database password is not set.'; + $error[] = "STEP 3 : $dbprettyname database password is not set."; } if(empty($options['dbname'])) { - $error[] = 'STEP 3 : MySQL database name is not set.'; + $error[] = "STEP 3 : $dbprettyname database name is not set."; } if(empty($options['dbhost'])) { - $error[] = 'STEP 3 : MySQL database host is not set.'; + $error[] = "STEP 3 : $dbprettyname database host is not set."; } if(!isset($options['dbtableprefix'])) { - $error[] = 'STEP 3 : MySQL database table prefix is not set.'; - } - } - - if($dbtype=='pgsql') { //postgresql needs more config options - if(empty($options['pg_dbuser'])) { - $error[] = 'STEP 3 : PostgreSQL database user is not set.'; - } - if(empty($options['pg_dbpass'])) { - $error[] = 'STEP 3 : PostgreSQL database password is not set.'; - } - if(empty($options['pg_dbname'])) { - $error[] = 'STEP 3 : PostgreSQL database name is not set.'; - } - if(empty($options['pg_dbhost'])) { - $error[] = 'STEP 3 : PostgreSQL database host is not set.'; - } - if(!isset($options['pg_dbtableprefix'])) { - $error[] = 'STEP 3 : PostgreSQL database table prefix is not set.'; + $error[] = "STEP 3 : $dbprettyname database table prefix is not set."; } } @@ -150,11 +137,11 @@ class OC_Setup { } } elseif($dbtype == 'pgsql') { - $dbuser = $options['pg_dbuser']; - $dbpass = $options['pg_dbpass']; - $dbname = $options['pg_dbname']; - $dbhost = $options['pg_dbhost']; - $dbtableprefix = $options['pg_dbtableprefix']; + $dbuser = $options['dbuser']; + $dbpass = $options['dbpass']; + $dbname = $options['dbname']; + $dbhost = $options['dbhost']; + $dbtableprefix = $options['dbtableprefix']; OC_CONFIG::setValue('dbname', $dbname); OC_CONFIG::setValue('dbhost', $dbhost); OC_CONFIG::setValue('dbtableprefix', $dbtableprefix); From 76fc062f27a178be97b2f4bf285f7f07c6361f60 Mon Sep 17 00:00:00 2001 From: Jakob Sack Date: Tue, 9 Aug 2011 13:53:58 +0200 Subject: [PATCH 27/32] Some more work on the address book --- apps/contacts/ajax/addcard.php | 54 +++++++ apps/contacts/ajax/addphoto.php | 59 +++++++ apps/contacts/ajax/addproperty.php | 73 +++++++++ apps/contacts/ajax/deletebook.php | 44 ++++++ apps/contacts/ajax/deletecard.php | 50 ++++++ apps/contacts/ajax/deleteproperty.php | 62 ++++++++ .../{details.php => ajax/getdetails.php} | 9 +- apps/contacts/ajax/setphoto.php | 77 +++++++++ apps/contacts/ajax/setproperty.php | 93 +++++++++++ apps/contacts/ajax/showaddcard.php | 39 +++++ apps/contacts/ajax/showaddproperty.php | 51 ++++++ apps/contacts/ajax/showsetproperty.php | 62 ++++++++ apps/contacts/carddav.php | 20 +++ apps/contacts/css/styles.css | 2 +- apps/contacts/index.php | 3 +- apps/contacts/js/interface.js | 148 +++++++++++++++++- apps/contacts/lib/addressbook.php | 71 +++++++-- apps/contacts/lib/connector_sabre.php | 26 ++- apps/contacts/templates/_details.php | 4 - apps/contacts/templates/index.php | 15 +- apps/contacts/templates/part.addcardform.php | 13 ++ .../templates/part.addpropertyform.php | 43 +++++ .../{_contacts.php => part.contacts.php} | 2 +- apps/contacts/templates/part.details.php | 22 +++ apps/contacts/templates/part.property.php | 50 ++++++ .../templates/part.setpropertyform.php | 21 +++ apps/contacts/temporaryupdate.php | 20 +++ 27 files changed, 1085 insertions(+), 48 deletions(-) create mode 100644 apps/contacts/ajax/addcard.php create mode 100644 apps/contacts/ajax/addphoto.php create mode 100644 apps/contacts/ajax/addproperty.php create mode 100644 apps/contacts/ajax/deletebook.php create mode 100644 apps/contacts/ajax/deletecard.php create mode 100644 apps/contacts/ajax/deleteproperty.php rename apps/contacts/{details.php => ajax/getdetails.php} (87%) create mode 100644 apps/contacts/ajax/setphoto.php create mode 100644 apps/contacts/ajax/setproperty.php create mode 100644 apps/contacts/ajax/showaddcard.php create mode 100644 apps/contacts/ajax/showaddproperty.php create mode 100644 apps/contacts/ajax/showsetproperty.php delete mode 100644 apps/contacts/templates/_details.php create mode 100644 apps/contacts/templates/part.addcardform.php create mode 100644 apps/contacts/templates/part.addpropertyform.php rename apps/contacts/templates/{_contacts.php => part.contacts.php} (95%) create mode 100644 apps/contacts/templates/part.details.php create mode 100644 apps/contacts/templates/part.property.php create mode 100644 apps/contacts/templates/part.setpropertyform.php diff --git a/apps/contacts/ajax/addcard.php b/apps/contacts/ajax/addcard.php new file mode 100644 index 0000000000..24766931d7 --- /dev/null +++ b/apps/contacts/ajax/addcard.php @@ -0,0 +1,54 @@ +. + * + */ + +// Init owncloud +require_once('../../../lib/base.php'); + +$aid = $_POST['id']; +$l10n = new OC_L10N('contacts'); + +// Check if we are a user +if( !OC_User::isLoggedIn()){ + echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('You need to log in!')))); + exit(); +} + +$addressbook = OC_Contacts_Addressbook::findAddressbook( $aid ); +if( $addressbook === false || $addressbook['userid'] != OC_USER::getUser()){ + echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('This is not your addressbook!')))); + exit(); +} + +$fn = $_POST['fn']; + +$vcard = new Sabre_VObject_Component('VCARD'); +$vcard->add(new Sabre_VObject_Property('FN',$fn)); +$vcard->add(new Sabre_VObject_Property('UID',OC_Contacts_Addressbook::createUID())); +$id = OC_Contacts_Addressbook::addCard($aid,$vcard->serialize()); + +$details = OC_Contacts_Addressbook::structureContact($vcard); +$tmpl = new OC_Template('contacts','part.details'); +$tmpl->assign('details',$details); +$tmpl->assign('id',$id); +$page = $tmpl->fetchPage(); + +echo json_encode( array( 'status' => 'success', 'data' => array( 'id' => $id, 'page' => $page ))); diff --git a/apps/contacts/ajax/addphoto.php b/apps/contacts/ajax/addphoto.php new file mode 100644 index 0000000000..03d5e6b3ce --- /dev/null +++ b/apps/contacts/ajax/addphoto.php @@ -0,0 +1,59 @@ +. + * + */ + +// Init owncloud +require_once('../../../lib/base.php'); + +$id = $_POST['id']; +$l10n = new OC_L10N('contacts'); + +// Check if we are a user +if( !OC_User::isLoggedIn()){ + echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('You need to log in!')))); + exit(); +} + +$card = OC_Contacts_Addressbook::findCard( $id ); +if( $card === false ){ + echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('Can not find Contact!')))); + exit(); +} + +$addressbook = OC_Contacts_Addressbook::findAddressbook( $card['addressbookid'] ); +if( $addressbook === false || $addressbook['userid'] != OC_USER::getUser()){ + echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('This is not your contact!')))); + exit(); +} + +$vcard = Sabre_VObject_Reader::read($card['carddata']); +$mimetype = $_FILES['photo']['type'] ? $_FILES['photo']['type'] : 'image/jpeg'; +$photobase = base64_encode(file_get_contents($_FILES['photo']['tmp_name'])); +$photo = new Sabre_VObject_Property( 'PHOTO', $photobase ); +$photo->parameters[] = new Sabre_VObject_Parameter('TYPE',$mimetype); +$photo->parameters[] = new Sabre_VObject_Parameter('ENCODING','b'); +$vcard->add($photo); + +$line = count($vcard->children) - 1; +$checksum = md5($vcard->children[$line]->serialize()); + +OC_Contacts_Addressbook::editCard($id,$vcard->serialize()); +echo json_encode( array( 'status' => 'success', 'data' => array( 'id' => $id, 'line' => $line, 'checksum' => $checksum ))); diff --git a/apps/contacts/ajax/addproperty.php b/apps/contacts/ajax/addproperty.php new file mode 100644 index 0000000000..35b4d122bd --- /dev/null +++ b/apps/contacts/ajax/addproperty.php @@ -0,0 +1,73 @@ +. + * + */ + +// Init owncloud +require_once('../../../lib/base.php'); + +$id = $_POST['id']; +$l10n = new OC_L10N('contacts'); + +// Check if we are a user +if( !OC_User::isLoggedIn()){ + echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('You need to log in!')))); + exit(); +} + +$card = OC_Contacts_Addressbook::findCard( $id ); +if( $card === false ){ + echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('Can not find Contact!')))); + exit(); +} + +$addressbook = OC_Contacts_Addressbook::findAddressbook( $card['addressbookid'] ); +if( $addressbook === false || $addressbook['userid'] != OC_USER::getUser()){ + echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('This is not your contact!')))); + exit(); +} + +$vcard = Sabre_VObject_Reader::read($card['carddata']); + +$name = $_POST['name']; +$value = $_POST['value']; +$parameters = $_POST['parameters']; + +if(is_array($value)){ + $value = OC_Contacts_Addressbook::escapeSemicolons($value); +} +$property = new Sabre_VObject_Property( $name, $value ); +$parameternames = array_keys($parameters); +foreach($parameternames as $i){ + $property->parameters[] = new Sabre_VObject_Parameter($i,$parameters[$i]); +} + +$vcard->add($property); + +$line = count($vcard->children) - 1; +$checksum = md5($property->serialize()); + +OC_Contacts_Addressbook::editCard($id,$vcard->serialize()); + +$tmpl = new OC_Template('contacts','part.property'); +$tmpl->assign('property',OC_Contacts_Addressbook::structureProperty($property,$line)); +$page = $tmpl->fetchPage(); + +echo json_encode( array( 'status' => 'success', 'data' => array( 'page' => $page ))); diff --git a/apps/contacts/ajax/deletebook.php b/apps/contacts/ajax/deletebook.php new file mode 100644 index 0000000000..ba36c494cd --- /dev/null +++ b/apps/contacts/ajax/deletebook.php @@ -0,0 +1,44 @@ +. + * + */ + +// Init owncloud +require_once('../../../lib/base.php'); + +$id = $_GET['id']; + +$l10n = new OC_L10N('contacts'); + +// Check if we are a user +if( !OC_User::isLoggedIn()){ + echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('You need to log in!')))); + exit(); +} + + +$addressbook = OC_Contacts_Addressbook::findAddressbook( $id ); +if( $addressbook === false || $addressbook['userid'] != OC_USER::getUser()){ + echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('This is not your contact!')))); + exit(); +} + +OC_Contacts_Addressbook::deleteAddressbook($id); +echo json_encode( array( 'status' => 'success', 'data' => array( 'id' => $id ))); diff --git a/apps/contacts/ajax/deletecard.php b/apps/contacts/ajax/deletecard.php new file mode 100644 index 0000000000..839936d3fa --- /dev/null +++ b/apps/contacts/ajax/deletecard.php @@ -0,0 +1,50 @@ +. + * + */ + +// Init owncloud +require_once('../../../lib/base.php'); + +$id = $_GET['id']; + +$l10n = new OC_L10N('contacts'); + +// Check if we are a user +if( !OC_User::isLoggedIn()){ + echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('You need to log in!')))); + exit(); +} + + +$card = OC_Contacts_Addressbook::findCard( $id ); +if( $card === false ){ + echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('Can not find Contact!')))); + exit(); +} + +$addressbook = OC_Contacts_Addressbook::findAddressbook( $card['addressbookid'] ); +if( $addressbook === false || $addressbook['userid'] != OC_USER::getUser()){ + echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('This is not your contact!')))); + exit(); +} + +OC_Contacts_Addressbook::deleteCard($id); +echo json_encode( array( 'status' => 'success', 'data' => array( 'id' => $id ))); diff --git a/apps/contacts/ajax/deleteproperty.php b/apps/contacts/ajax/deleteproperty.php new file mode 100644 index 0000000000..9f8b5dbbaf --- /dev/null +++ b/apps/contacts/ajax/deleteproperty.php @@ -0,0 +1,62 @@ +. + * + */ + +// Init owncloud +require_once('../../../lib/base.php'); + +$id = $_GET['id']; +$line = $_GET['line']; +$checksum = $_GET['checksum']; + + +$l10n = new OC_L10N('contacts'); + +// Check if we are a user +if( !OC_User::isLoggedIn()){ + echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('You need to log in!')))); + exit(); +} + + +$card = OC_Contacts_Addressbook::findCard( $id ); +if( $card === false ){ + echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('Can not find Contact!')))); + exit(); +} + +$addressbook = OC_Contacts_Addressbook::findAddressbook( $card['addressbookid'] ); +if( $addressbook === false || $addressbook['userid'] != OC_USER::getUser()){ + echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('This is not your contact!')))); + exit(); +} + +$vcard = Sabre_VObject_Reader::read($card['carddata']); + +if(md5($vcard->children[$line]->serialize()) != $checksum ){ + echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('Information about vCard is incorrect. Please reload page!')))); + exit(); +} + +unset($vcard->children[$line]); + +OC_Contacts_Addressbook::editCard($id,$vcard->serialize()); +echo json_encode( array( 'status' => 'success', 'data' => array( 'id' => $id ))); diff --git a/apps/contacts/details.php b/apps/contacts/ajax/getdetails.php similarity index 87% rename from apps/contacts/details.php rename to apps/contacts/ajax/getdetails.php index 7ab1b64de2..4ee3625afc 100644 --- a/apps/contacts/details.php +++ b/apps/contacts/ajax/getdetails.php @@ -21,7 +21,7 @@ */ // Init owncloud -require_once('../../lib/base.php'); +require_once('../../../lib/base.php'); $id = $_GET['id']; @@ -29,7 +29,7 @@ $l10n = new OC_L10N('contacts'); // Check if we are a user if( !OC_User::isLoggedIn()){ - echo $l10n->t('You need to log in!'); + echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('You need to log in!')))); exit(); } @@ -48,10 +48,9 @@ if( $addressbook === false || $addressbook['userid'] != OC_USER::getUser()){ $vcard = Sabre_VObject_Reader::read($card['carddata']); $details = OC_Contacts_Addressbook::structureContact($vcard); - -$tmpl = new OC_Template('contacts','_details'); +$tmpl = new OC_Template('contacts','part.details'); $tmpl->assign('details',$details); $tmpl->assign('id',$id); $page = $tmpl->fetchPage(); -echo json_encode( array( 'status' => 'success', 'data' => array( 'page' => $page ))); +echo json_encode( array( 'status' => 'success', 'data' => array( 'id' => $id, 'page' => $page ))); diff --git a/apps/contacts/ajax/setphoto.php b/apps/contacts/ajax/setphoto.php new file mode 100644 index 0000000000..c29b532602 --- /dev/null +++ b/apps/contacts/ajax/setphoto.php @@ -0,0 +1,77 @@ +. + * + */ + +// Init owncloud +require_once('../../../lib/base.php'); + +$id = $_POST['id']; +$line = $_POST['line']; +$checksum = $_POST['checksum']; +$l10n = new OC_L10N('contacts'); + +// Check if we are a user +if( !OC_User::isLoggedIn()){ + echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('You need to log in!')))); + exit(); +} + +$card = OC_Contacts_Addressbook::findCard( $id ); +if( $card === false ){ + echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('Can not find Contact!')))); + exit(); +} + +$addressbook = OC_Contacts_Addressbook::findAddressbook( $card['addressbookid'] ); +if( $addressbook === false || $addressbook['userid'] != OC_USER::getUser()){ + echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('This is not your contact!')))); + exit(); +} + +$vcard = Sabre_VObject_Reader::read($card['carddata']); +$mimetype = $_FILES['photo']['type'] ? $_FILES['photo']['type'] : 'image/jpeg'; +$photobase = base64_encode(file_get_contents($_FILES['photo']['tmp_name'])); + +if(md5($vcard->children[$line]->serialize()) != $checksum){ + echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('Information about vCard is incorrect. Please reload page!')))); + exit(); +} + +// replace photo +$vcard->children[$line]->setValue($photobase); +$encoding = $type = false; +foreach($vcard->children[$line]->parameters as &$parameter){ + if($parameter->name == 'TYPE'){ + $parameter->value = $mimetype; + $type = true; + } + elseif($parameter->name == 'ENCODING'){ + $parameter->value = 'b'; + $encoding = true; + } +} unset($parameter); +if(!$encoding) $vcard->children[$line]->parameters[] = new Sabre_VObject_Parameter('ENCODING','b'); +if(!$type) $vcard->children[$line]->parameters[] = new Sabre_VObject_Parameter('TYPE',$mimetype); + +$checksum = md5($vcard->children[$line]->serialize()); + +OC_Contacts_Addressbook::editCard($id,$vcard->serialize()); +echo json_encode( array( 'status' => 'success', 'data' => array( 'id' => $id, 'line' => $line, 'checksum' => $checksum ))); diff --git a/apps/contacts/ajax/setproperty.php b/apps/contacts/ajax/setproperty.php new file mode 100644 index 0000000000..6f33c68631 --- /dev/null +++ b/apps/contacts/ajax/setproperty.php @@ -0,0 +1,93 @@ +. + * + */ + +// Init owncloud +require_once('../../../lib/base.php'); + +$id = $_POST['id']; +$line = $_POST['line']; +$checksum = $_POST['checksum']; +$l10n = new OC_L10N('contacts'); + +// Check if we are a user +if( !OC_User::isLoggedIn()){ + echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('You need to log in!')))); + exit(); +} + +$card = OC_Contacts_Addressbook::findCard( $id ); +if( $card === false ){ + echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('Can not find Contact!')))); + exit(); +} + +$addressbook = OC_Contacts_Addressbook::findAddressbook( $card['addressbookid'] ); +if( $addressbook === false || $addressbook['userid'] != OC_USER::getUser()){ + echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('This is not your contact!')))); + exit(); +} + +$vcard = Sabre_VObject_Reader::read($card['carddata']); + +if(md5($vcard->children[$line]->serialize()) != $checksum){ + echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('Information about vCard is incorrect. Please reload page!')))); + exit(); +} + +// Set the value +$value = $_POST['value']; +if(is_array($value)){ + $value = OC_Contacts_Addressbook::escapeSemicolons($value); +} +$vcard->children[$line]->setValue($value); + +// Add parameters +$postparameters = isset($_POST['parameters'])?$_POST['parameters']:array(); +for($i=0;$ichildren[$line]->parameters);$i++){ + $name = $vcard->children[$line]->parameters[$i]->name; + if(array_key_exists($name,$postparameters)){ + if($postparameters[$name] == '' || is_null($postparameters[$name])){ + unset($vcard->children[$line]->parameters[$i]); + } + else{ + $vcard->children[$line]->parameters[$i]->value = $postparameters[$name]; + } + unset($postparameters[$name]); + } +} +$missingparameters = array_keys($postparameters); +foreach($missingparameters as $i){ + if(!$postparameters[$i] == '' && !is_null($postparameters[$i])){ + $vcard->children[$line]->parameters[] = new Sabre_VObject_Parameter($i,$postparameters[$i]); + } +} + +// Do checksum and be happy +$checksum = md5($vcard->children[$line]->serialize()); + +OC_Contacts_Addressbook::editCard($id,$vcard->serialize()); + +$tmpl = new OC_Template('contacts','part.property'); +$tmpl->assign('property',OC_Contacts_Addressbook::structureProperty($vcard->children[$line],$line)); +$page = $tmpl->fetchPage(); + +echo json_encode( array( 'status' => 'success', 'data' => array( 'page' => $page, 'line' => $line, 'oldchecksum' => $_POST['checksum'] ))); diff --git a/apps/contacts/ajax/showaddcard.php b/apps/contacts/ajax/showaddcard.php new file mode 100644 index 0000000000..41ebb41d3e --- /dev/null +++ b/apps/contacts/ajax/showaddcard.php @@ -0,0 +1,39 @@ +. + * + */ + +// Init owncloud +require_once('../../../lib/base.php'); + +$l10n = new OC_L10N('contacts'); + +// Check if we are a user +if( !OC_User::isLoggedIn()){ + echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('You need to log in!')))); + exit(); +} + +$addressbooks = OC_Contacts_Addressbook::allAddressbooks(OC_USER::getUser()); +$tmpl = new OC_Template('contacts','part.addcardform'); +$tmpl->assign('addressbooks',$addressbooks); +$page = $tmpl->fetchPage(); + +echo json_encode( array( 'status' => 'success', 'data' => array( 'page' => $page ))); diff --git a/apps/contacts/ajax/showaddproperty.php b/apps/contacts/ajax/showaddproperty.php new file mode 100644 index 0000000000..becc39b120 --- /dev/null +++ b/apps/contacts/ajax/showaddproperty.php @@ -0,0 +1,51 @@ +. + * + */ + +// Init owncloud +require_once('../../../lib/base.php'); + +$id = $_GET['id']; +$l10n = new OC_L10N('contacts'); + +// Check if we are a user +if( !OC_User::isLoggedIn()){ + echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('You need to log in!')))); + exit(); +} + +$card = OC_Contacts_Addressbook::findCard( $id ); +if( $card === false ){ + echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('Can not find Contact!')))); + exit(); +} + +$addressbook = OC_Contacts_Addressbook::findAddressbook( $card['addressbookid'] ); +if( $addressbook === false || $addressbook['userid'] != OC_USER::getUser()){ + echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('This is not your contact!')))); + exit(); +} + +$tmpl = new OC_Template('contacts','part.addpropertyform'); +$tmpl->assign('id',$id); +$page = $tmpl->fetchPage(); + +echo json_encode( array( 'status' => 'success', 'data' => array( 'page' => $page ))); diff --git a/apps/contacts/ajax/showsetproperty.php b/apps/contacts/ajax/showsetproperty.php new file mode 100644 index 0000000000..75c3ff88f5 --- /dev/null +++ b/apps/contacts/ajax/showsetproperty.php @@ -0,0 +1,62 @@ +. + * + */ + +// Init owncloud +require_once('../../../lib/base.php'); + +$id = $_GET['id']; +$line = $_GET['line']; +$checksum = $_GET['checksum']; +$l10n = new OC_L10N('contacts'); + +// Check if we are a user +if( !OC_User::isLoggedIn()){ + echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('You need to log in!')))); + exit(); +} + +$card = OC_Contacts_Addressbook::findCard( $id ); +if( $card === false ){ + echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('Can not find Contact!')))); + exit(); +} + +$addressbook = OC_Contacts_Addressbook::findAddressbook( $card['addressbookid'] ); +if( $addressbook === false || $addressbook['userid'] != OC_USER::getUser()){ + echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('This is not your contact!')))); + exit(); +} + +$vcard = Sabre_VObject_Reader::read($card['carddata']); +if(md5($vcard->children[$line]->serialize()) != $checksum){ + echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('Information about vCard is incorrect. Please reload page!')))); + exit(); +} + + +$tmpl = new OC_Template('contacts','part.setpropertyform'); +$tmpl->assign('id',$id); +$tmpl->assign('checksum',$checksum); +$tmpl->assign('property',OC_Contacts_Addressbook::structureProperty($vcard->children[$line],$line)); +$page = $tmpl->fetchPage(); + +echo json_encode( array( 'status' => 'success', 'data' => array( 'page' => $page ))); diff --git a/apps/contacts/carddav.php b/apps/contacts/carddav.php index ae2c5b9736..581bf4a717 100644 --- a/apps/contacts/carddav.php +++ b/apps/contacts/carddav.php @@ -1,4 +1,24 @@ . + * + */ // Do not load FS ... $RUNTIME_NOSETUPFS = true; diff --git a/apps/contacts/css/styles.css b/apps/contacts/css/styles.css index 8d1c8b69c3..c7680f4a71 100644 --- a/apps/contacts/css/styles.css +++ b/apps/contacts/css/styles.css @@ -1 +1 @@ - +.contacts_propertyname {float:left;} diff --git a/apps/contacts/index.php b/apps/contacts/index.php index 1e01b1c9fb..4330c31043 100644 --- a/apps/contacts/index.php +++ b/apps/contacts/index.php @@ -63,7 +63,8 @@ usort($contacts,'contacts_namesort'); $details = array(); if( !is_null($id) || count($contacts)){ - $contact = OC_Contacts_Addressbook::findCard(is_null($id)?$contacts[0]['id']:$id); + if(is_null($id)) $id = $contacts[0]['id']; + $contact = OC_Contacts_Addressbook::findCard($id); $vcard = Sabre_VObject_Reader::read($contact['carddata']); $details = OC_Contacts_Addressbook::structureContact($vcard); } diff --git a/apps/contacts/js/interface.js b/apps/contacts/js/interface.js index 6af160b392..0aae7d15d4 100644 --- a/apps/contacts/js/interface.js +++ b/apps/contacts/js/interface.js @@ -1,9 +1,15 @@ $(document).ready(function(){ - $('.contacts_contacts').find('li').live('click',function(){ + /* $('.contacts_addressbooksexpander').click(function(){ + $('.contacts_addressbooksdetails').toggle(); + return false; + });*/ + + $('#contacts_contacts li').live('click',function(){ var id = $(this).attr('x-id'); - $.getJSON('details.php',{'id':id},function(jsondata){ + $.getJSON('ajax/getdetails.php',{'id':id},function(jsondata){ if(jsondata.status == 'success'){ - $('.contacts_details').html(jsondata.data.page); + $('#contacts_details').attr('x-id',jsondata.data.id); + $('#contacts_details').html(jsondata.data.page); } else{ alert(jsondata.data.message); @@ -12,8 +18,140 @@ $(document).ready(function(){ return false; }); - $('.contacts_addressbooksexpander').click(function(){ - $('.contacts_addressbooksdetails').toggle(); + $('#contacts_deletecard').live('click',function(){ + var id = $('#contacts_details').attr('x-id'); + $.getJSON('ajax/deletecard.php',{'id':id},function(jsondata){ + if(jsondata.status == 'success'){ + $('#contacts_contacts [x-id="'+jsondata.data.id+'"]').remove(); + $('#contacts_details').attr('x-id',''); + $('#contacts_details').html(''); + } + else{ + alert(jsondata.data.message); + } + }); return false; }); + + $('#contacts_addproperty').live('click',function(){ + var id = $('#contacts_details').attr('x-id'); + $.getJSON('ajax/showaddproperty.php',{'id':id},function(jsondata){ + if(jsondata.status == 'success'){ + $('#contacts_details').append(jsondata.data.page); + } + else{ + alert(jsondata.data.message); + } + }); + return false; + }); + + $('#contacts_addpropertyform [name="name"]').live('change',function(){ + $('#contacts_addpropertyform #contacts_addresspart').remove(); + $('#contacts_addpropertyform #contacts_phonepart').remove(); + $('#contacts_addpropertyform #contacts_fieldpart').remove(); + $('#contacts_addpropertyform #contacts_generic').remove(); + if($(this).val() == 'ADR'){ + $('#contacts_addresspart').clone().insertBefore($('#contacts_addpropertyform input[type="submit"]')); + } + else if($(this).val() == 'TEL'){ + $('#contacts_phonepart').clone().insertBefore($('#contacts_addpropertyform input[type="submit"]')); + } + else if($(this).val() == 'NOTE'){ + $('#contacts_fieldpart').clone().insertBefore($('#contacts_addpropertyform input[type="submit"]')); + } + else{ + $('#contacts_generic').clone().insertBefore($('#contacts_addpropertyform input[type="submit"]')); + } + }); + + $('#contacts_addpropertyform input[type="submit"]').live('click',function(){ + $.post('ajax/addproperty.php',$('#contacts_addpropertyform').serialize(),function(jsondata){ + if(jsondata.status == 'success'){ + $('#contacts_details').append(jsondata.data.page); + $('#contacts_addpropertyform').remove(); + } + else{ + alert(jsondata.data.message); + } + }, 'json'); + return false; + }); + + $('#contacts_newcontact').click(function(){ + $.getJSON('ajax/showaddcard.php',{},function(jsondata){ + if(jsondata.status == 'success'){ + $('#contacts_details').attr('x-id',''); + $('#contacts_details').html(jsondata.data.page); + } + else{ + alert(jsondata.data.message); + } + }); + return false; + }); + + $('#contacts_addcardform input[type="submit"]').live('click',function(){ + $.post('ajax/addcard.php',$('#contacts_addcardform').serialize(),function(jsondata){ + if(jsondata.status == 'success'){ + $('#contacts_details').attr('x-id',jsondata.data.id); + $('#contacts_details').html(jsondata.data.page); + } + else{ + alert(jsondata.data.message); + } + }, 'json'); + return false; + }); + + $('.contacts_property [x-use="edit"]').live('click',function(){ + var id = $('#contacts_details').attr('x-id'); + var checksum = $(this).parent().parent().attr('x-checksum'); + var line = $(this).parent().parent().attr('x-line'); + $.getJSON('ajax/showsetproperty.php',{'id': id, 'checksum': checksum, 'line': line },function(jsondata){ + if(jsondata.status == 'success'){ + $('.contacts_property[x-line="'+line+'"][x-checksum="'+checksum+'"] .contacts_propertyvalue').html(jsondata.data.page); + } + else{ + alert(jsondata.data.message); + } + }); + return false; + }); + + $('#contacts_setpropertyform input[type="submit"]').live('click',function(){ + $.post('ajax/setproperty.php',$('#contacts_setpropertyform').serialize(),function(jsondata){ + if(jsondata.status == 'success'){ + $('.contacts_property[x-line="'+jsondata.data.line+'"][x-checksum="'+jsondata.data.oldchecksum+'"]').replaceWith(jsondata.data.page); + } + else{ + alert(jsondata.data.message); + } + },'json'); + return false; + }); + + $('.contacts_property [x-use="delete"]').live('click',function(){ + var id = $('#contacts_details').attr('x-id'); + var checksum = $(this).parent().parent().attr('x-checksum'); + var line = $(this).parent().parent().attr('x-line'); + $.getJSON('ajax/deleteproperty.php',{'id': id, 'checksum': checksum, 'line': line },function(jsondata){ + if(jsondata.status == 'success'){ + $('.contacts_property[x-line="'+line+'"][x-checksum="'+checksum+'"]').remove(); + } + else{ + alert(jsondata.data.message); + } + }); + return false; + }); + + + $('.contacts_property').live('mouseenter',function(){ + $(this).find('span').show(); + }); + + $('.contacts_property').live('mouseleave',function(){ + $(this).find('span').hide(); + }); }); diff --git a/apps/contacts/lib/addressbook.php b/apps/contacts/lib/addressbook.php index c0f26c7df5..b744465390 100644 --- a/apps/contacts/lib/addressbook.php +++ b/apps/contacts/lib/addressbook.php @@ -167,14 +167,14 @@ class OC_Contacts_Addressbook{ $uri = $property->value.'.vcf'; } } - $uri = self::createUID().'.vcf'; + if(is_null($uri)) $uri = self::createUID().'.vcf'; $stmt = OC_DB::prepare( 'INSERT INTO *PREFIX*contacts_cards (addressbookid,fullname,carddata,uri,lastmodified) VALUES(?,?,?,?,?)' ); $result = $stmt->execute(array($id,$fn,$data,$uri,time())); - self::touch($id); + self::touchAddressbook($id); - return OC_DB::insertid; + return OC_DB::insertid(); } public static function addCardFromDAVData($id,$uri,$data){ @@ -189,13 +189,13 @@ class OC_Contacts_Addressbook{ $stmt = OC_DB::prepare( 'INSERT INTO *PREFIX*contacts_cards (addressbookid,fullname,carddata,uri,lastmodified) VALUES(?,?,?,?,?)' ); $result = $stmt->execute(array($id,$fn,$data,$uri,time())); - self::touch($id); + self::touchAddressbook($id); - return OC_DB::insertid; + return OC_DB::insertid(); } public static function editCard($id, $data){ - $oldcard = self::findCard($id,$aid,$uri); + $oldcard = self::findCard($id); $fn = null; $card = Sabre_VObject_Reader::read($data); foreach($card->children as $property){ @@ -207,7 +207,7 @@ class OC_Contacts_Addressbook{ $stmt = OC_DB::prepare( 'UPDATE *PREFIX*contacts_cards SET fullname = ?,carddata = ?, lastmodified = ? WHERE id = ?' ); $result = $stmt->execute(array($fn,$data,time(),$id)); - self::touch($oldcard['addressbookid']); + self::touchAddressbook($oldcard['addressbookid']); return true; } @@ -226,20 +226,20 @@ class OC_Contacts_Addressbook{ $stmt = OC_DB::prepare( 'UPDATE *PREFIX*contacts_cards SET fullname = ?,carddata = ?, lastmodified = ? WHERE id = ?' ); $result = $stmt->execute(array($fn,$data,time(),$oldcard['id'])); - self::touch($oldcard['addressbookid']); + self::touchAddressbook($oldcard['addressbookid']); return true; } public static function deleteCard($id){ - $stmt = OC_DB::prepare( 'DELETE FROM *PREFIX*contacts_addressbooks WHERE id = ?' ); + $stmt = OC_DB::prepare( 'DELETE FROM *PREFIX*contacts_cards WHERE id = ?' ); $stmt->execute(array($id)); return true; } public static function deleteCardFromDAVData($aid,$uri){ - $stmt = OC_DB::prepare( 'DELETE FROM *PREFIX*contacts_addressbooks WHERE addressbookid = ? AND uri=?' ); + $stmt = OC_DB::prepare( 'DELETE FROM *PREFIX*contacts_cards WHERE addressbookid = ? AND uri=?' ); $stmt->execute(array($aid,$uri)); return true; @@ -265,23 +265,60 @@ class OC_Contacts_Addressbook{ return $userid; } + public static function escapeSemicolons($value){ + foreach($value as &$i ){ + $i = implode("\\\\;", explode(';', $i)); + } unset($i); + return implode(';',$value); + } + + public static function unescapeSemicolons($value){ + $array = explode(';',$value); + for($i=0;$ichildren as $property){ - $temp = array( - 'name' => $property->name, - 'value' => ($property->name == 'PHOTO' || $property->name == 'LOGO' ? null : $property->value ), - 'parameters' => array()); - foreach($property->parameters as $parameter){ - $temp['parameters'][] = array( 'name' => $parameter->name, 'value' => $parameter->value); - } + $temp = self::structureProperty($property,$line); if(array_key_exists($property->name,$details)){ $details[$property->name][] = $temp; } else{ $details[$property->name] = array($temp); } + $line++; } return $details; } + + public static function structureProperty($property,$line=null){ + $value = $property->value; + if($property->name == 'ADR'){ + $value = self::unescapeSemicolons($value); + } + $temp = array( + 'name' => $property->name, + 'value' => $value, + 'line' => $line, + 'parameters' => array(), + 'checksum' => md5($property->serialize())); + foreach($property->parameters as $parameter){ + $temp['parameters'][$parameter->name] = $parameter->value; + } + return $temp; + } } diff --git a/apps/contacts/lib/connector_sabre.php b/apps/contacts/lib/connector_sabre.php index 98e2598b3a..96a90dfc5d 100644 --- a/apps/contacts/lib/connector_sabre.php +++ b/apps/contacts/lib/connector_sabre.php @@ -1,13 +1,23 @@ . + * */ /** diff --git a/apps/contacts/templates/_details.php b/apps/contacts/templates/_details.php deleted file mode 100644 index e27b17ef2e..0000000000 --- a/apps/contacts/templates/_details.php +++ /dev/null @@ -1,4 +0,0 @@ -Name - - - \ No newline at end of file diff --git a/apps/contacts/templates/index.php b/apps/contacts/templates/index.php index ca189cb4c8..e6dd45739b 100644 --- a/apps/contacts/templates/index.php +++ b/apps/contacts/templates/index.php @@ -3,7 +3,8 @@ OC_Util::addScript('contacts','interface'); OC_Util::addStyle('contacts','styles'); ?> -
      +
      Addressbooks
      @@ -13,12 +14,14 @@ OC_Util::addStyle('contacts','styles');
      To use this addressbook, use .../apps/contacts/carddav.php/addressbooks/USERNAME/addressbookname.php
      - -
      +
      */ +?> +
        - inc("_contacts"); ?> + inc("part.contacts"); ?>
      + t('Add Contact'); ?>
      -
      - inc("_details"); ?> +
      + inc("part.details"); ?>
      diff --git a/apps/contacts/templates/part.addcardform.php b/apps/contacts/templates/part.addcardform.php new file mode 100644 index 0000000000..94a59fe097 --- /dev/null +++ b/apps/contacts/templates/part.addcardform.php @@ -0,0 +1,13 @@ +
      + + + + + +
      + +
      diff --git a/apps/contacts/templates/part.addpropertyform.php b/apps/contacts/templates/part.addpropertyform.php new file mode 100644 index 0000000000..ff9090b76d --- /dev/null +++ b/apps/contacts/templates/part.addpropertyform.php @@ -0,0 +1,43 @@ +
      + + +
      + +
      + +
      + diff --git a/apps/contacts/templates/_contacts.php b/apps/contacts/templates/part.contacts.php similarity index 95% rename from apps/contacts/templates/_contacts.php rename to apps/contacts/templates/part.contacts.php index bf633b79b0..fa6d4790cf 100644 --- a/apps/contacts/templates/_contacts.php +++ b/apps/contacts/templates/part.contacts.php @@ -1,3 +1,3 @@ -
    • +
    • diff --git a/apps/contacts/templates/part.details.php b/apps/contacts/templates/part.details.php new file mode 100644 index 0000000000..4aca8dbc79 --- /dev/null +++ b/apps/contacts/templates/part.details.php @@ -0,0 +1,22 @@ + + + +inc('part.property', array('property' => $_['details']['FN'][0])); ?> + + inc('part.property', array('property' => $_['details']['BDAY'][0])); ?> + + + inc('part.property', array('property' => $_['details']['ORG'][0])); ?> + + + + +
      + + inc('part.property',array('property' => $property )); ?> + + + + + + diff --git a/apps/contacts/templates/part.property.php b/apps/contacts/templates/part.property.php new file mode 100644 index 0000000000..1a4266b3a2 --- /dev/null +++ b/apps/contacts/templates/part.property.php @@ -0,0 +1,50 @@ +
      + +
      t('Name'); ?>
      +
      + + +
      + +
      t('Birthday'); ?>
      +
      + l('date',new DateTime($_['property']['value'])); ?> + + +
      + +
      t('Organisation'); ?>
      +
      + + + +
      + +
      t('Email'); ?>
      +
      + + + +
      + +
      t('Telefon'); ?>
      +
      + + + +
      + +
      t('Address'); ?>
      +
      + t('PO Box'); ?>
      + t('Extended Address'); ?>
      + t('Street Name'); ?>
      + t('City'); ?>
      + t('Region'); ?>
      + t('Postal Code'); ?>
      + t('Country'); ?> + + +
      + +
      diff --git a/apps/contacts/templates/part.setpropertyform.php b/apps/contacts/templates/part.setpropertyform.php new file mode 100644 index 0000000000..cd774ee659 --- /dev/null +++ b/apps/contacts/templates/part.setpropertyform.php @@ -0,0 +1,21 @@ +
      + + + + + t('PO Box'); ?> + t('Extended Address'); ?> + t('Street Name'); ?> + t('City'); ?> + t('Region'); ?> + t('Postal Code'); ?> + t('Country'); ?> + + + + + + + + +
      diff --git a/apps/contacts/temporaryupdate.php b/apps/contacts/temporaryupdate.php index bb5ff7604f..4b6453364e 100644 --- a/apps/contacts/temporaryupdate.php +++ b/apps/contacts/temporaryupdate.php @@ -1,4 +1,24 @@ . + * + */ // Init owncloud require_once('../../lib/base.php'); $connector = new OC_Connector_Sabre_Principal; From 5047b6e38537ac1104a5c49ca226ae604600bcc4 Mon Sep 17 00:00:00 2001 From: Jakob Sack Date: Tue, 9 Aug 2011 14:15:11 +0200 Subject: [PATCH 28/32] Fix naming bug --- apps/contacts/lib/addressbook.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/contacts/lib/addressbook.php b/apps/contacts/lib/addressbook.php index b744465390..cb7b0b4671 100644 --- a/apps/contacts/lib/addressbook.php +++ b/apps/contacts/lib/addressbook.php @@ -78,7 +78,7 @@ class OC_Contacts_Addressbook{ $uris[] = $i['uri']; } - $uri = self::createURI('name', $uris ); + $uri = self::createURI($name, $uris ); $stmt = OC_DB::prepare( 'INSERT INTO *PREFIX*contacts_addressbooks (userid,displayname,uri,description,ctag) VALUES(?,?,?,?,?)' ); $result = $stmt->execute(array($userid,$name,$uri,$description,1)); From 075db9f7eafb7030398f73ba609e16a5ae79f5b8 Mon Sep 17 00:00:00 2001 From: Jakob Sack Date: Tue, 9 Aug 2011 14:49:28 +0200 Subject: [PATCH 29/32] Add default addressbook --- apps/contacts/index.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/apps/contacts/index.php b/apps/contacts/index.php index 4330c31043..0d4ff83ef8 100644 --- a/apps/contacts/index.php +++ b/apps/contacts/index.php @@ -37,6 +37,12 @@ if( !OC_User::isLoggedIn()){ $addressbooks = OC_Contacts_Addressbook::allAddressbooks(OC_User::getUser()); if( count($addressbooks) == 0){ OC_Contacts_Addressbook::addAddressbook(OC_User::getUser(),'default','Default Address Book'); + $addressbooks = OC_Contacts_Addressbook::allAddressbooks(OC_User::getUser()); +} +$prefbooks = OC_Preferences::getValue(OC_User::getUser(),'contacts','openaddressbooks',null); +if(is_null($prefbooks)){ + $prefbooks = $addressbooks[0]['id']; + OC_Preferences::setValue(OC_User::getUser(),'contacts','openaddressbooks',$prefbooks); } // Load the files we need @@ -48,7 +54,7 @@ $id = isset( $_GET['id'] ) ? $_GET['id'] : null; // sort addressbooks (use contactsort) usort($addressbooks,'contacts_namesort'); // Addressbooks to load -$openaddressbooks = explode(';',OC_Preferences::getValue(OC_User::getUser(),'contacts','openaddressbooks',null)); +$openaddressbooks = explode(';',$prefbooks); $contacts = array(); foreach( $openaddressbooks as $addressbook ){ From 6d1c266e1e21e5fab56220df7529401c6c1729be Mon Sep 17 00:00:00 2001 From: Jakob Sack Date: Tue, 9 Aug 2011 15:00:10 +0200 Subject: [PATCH 30/32] You don't always have parameters in vcards! --- apps/contacts/ajax/addproperty.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/contacts/ajax/addproperty.php b/apps/contacts/ajax/addproperty.php index 35b4d122bd..d92566d6a1 100644 --- a/apps/contacts/ajax/addproperty.php +++ b/apps/contacts/ajax/addproperty.php @@ -48,7 +48,7 @@ $vcard = Sabre_VObject_Reader::read($card['carddata']); $name = $_POST['name']; $value = $_POST['value']; -$parameters = $_POST['parameters']; +$parameters = isset($_POST['parameteres'])?$_POST['parameters']:array(); if(is_array($value)){ $value = OC_Contacts_Addressbook::escapeSemicolons($value); From 88e2b3a8576a978605d2469b00b0bef1e3f11089 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Tue, 9 Aug 2011 15:25:18 +0200 Subject: [PATCH 31/32] initial work on new user management --- 3rdparty/css/chosen-sprite.png | Bin 0 -> 742 bytes 3rdparty/css/chosen.css | 340 ++++++++++ 3rdparty/js/chosen/LICENSE.md | 24 + 3rdparty/js/chosen/README.md | 46 ++ 3rdparty/js/chosen/VERSION | 1 + 3rdparty/js/chosen/chosen.jquery.js | 786 ++++++++++++++++++++++++ 3rdparty/js/chosen/chosen.jquery.min.js | 10 + 3rdparty/js/chosen/chosen.proto.js | 774 +++++++++++++++++++++++ 3rdparty/js/chosen/chosen.proto.min.js | 10 + admin/css/users.css | 5 + admin/js/users.js | 422 +++---------- admin/templates/users.php | 140 ++--- admin/users.php | 7 +- core/js/js.js | 3 +- 14 files changed, 2130 insertions(+), 438 deletions(-) create mode 100644 3rdparty/css/chosen-sprite.png create mode 100644 3rdparty/css/chosen.css create mode 100644 3rdparty/js/chosen/LICENSE.md create mode 100644 3rdparty/js/chosen/README.md create mode 100644 3rdparty/js/chosen/VERSION create mode 100644 3rdparty/js/chosen/chosen.jquery.js create mode 100644 3rdparty/js/chosen/chosen.jquery.min.js create mode 100644 3rdparty/js/chosen/chosen.proto.js create mode 100644 3rdparty/js/chosen/chosen.proto.min.js create mode 100644 admin/css/users.css diff --git a/3rdparty/css/chosen-sprite.png b/3rdparty/css/chosen-sprite.png new file mode 100644 index 0000000000000000000000000000000000000000..f20db4439ea5c1038126bf326c8fd048b03a8226 GIT binary patch literal 742 zcmeAS@N?(olHy`uVBq!ia0vp^HbAV#!3-qV=X2}@QlA5SLR>pKI{yFvKXc~Hw6wJT z{{AOVo_zoQeZqtZ&!0cvw{PF?-@ki%d;k6WS6EoMdiClhOP1WeeS7cTz4PYH`}FD4 zt5>h?-n~0()~rX59=&++V%xTD`T6-@zI<7}eEIzO^LOst`S@T)vFse zZ0PFhnmc#y*RNl9?AVc)msea|{PX9}Ns}gR+O%o+?%jtD9eVii;l+y=r%jvo;K760 zvu76+6kNZ4ed^SyPoF-WIC0|Z*ROy4_>r5N`~Lm=&!0c{_4O@WxbWAnUpYBBmoHy_ z_Uzfgg9n!`T{?O4j}$9Asc%4D@ty45_&F_R{g9Lk0qD52mW_e8hCD#Hn3?L-tbj`>OxT zJ7v;md~}?7W?s>W`VVqX@=db;D+pYCKd;4N)z`osoP6iyoB9teW8`B#?2;Ii#BfGM zL+6u_bqvF)z6Qwy7F^e#>{}{m61e02bdHnN$L$~3eq~pF@_OO1hcV%@q4${;^UfV+ znXY)w;%ghbu4vj9l}FCEd^hZyc+KPP6}AS4MsdBpQGw+X69gF?tV83O8O(MiJx^-A zboXW1bFqq*pAC;_YOi~??#RV$D!*(*_VfK;FjaJ|%YuJ~uPm<26>Fce&`YSSyXC`g zaTdR+Ec5IClowvmjG1!3;Krqz>yXh1n|0npm -g install uglify-js +3. Verify that your $NODE_PATH is properly configured using echo $NODE_PATH + +Once you're configured, building the JavasScript from the command line is easy: + + cake build # build Chosen from source + cake watch # watch coffee/ for changes and build Chosen + +If you're interested, you can find the recipes in Cakefile. + + +### Chosen Credits + +- Built by [Harvest](http://www.getharvest.com/) +- Concept and development by [Patrick Filler](http://www.patrickfiller.com/) +- Design and CSS by [Matthew Lettini](http://matthewlettini.com/) + +### Notable Forks + +- [Chosen for MooTools](https://github.com/julesjanssen/chosen), by Jules Janssen +- [Chosen Drupal 7 Module](https://github.com/Polzme/chosen), by Pol Dell'Aiera \ No newline at end of file diff --git a/3rdparty/js/chosen/VERSION b/3rdparty/js/chosen/VERSION new file mode 100644 index 0000000000..f374f6662e --- /dev/null +++ b/3rdparty/js/chosen/VERSION @@ -0,0 +1 @@ +0.9.1 diff --git a/3rdparty/js/chosen/chosen.jquery.js b/3rdparty/js/chosen/chosen.jquery.js new file mode 100644 index 0000000000..5ea409d90e --- /dev/null +++ b/3rdparty/js/chosen/chosen.jquery.js @@ -0,0 +1,786 @@ +// Chosen, a Select Box Enhancer for jQuery and Protoype +// by Patrick Filler for Harvest, http://getharvest.com +// +// Version 0.9 +// Full source at https://github.com/harvesthq/chosen +// Copyright (c) 2011 Harvest http://getharvest.com + +// MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md +// This file is generated by `cake build`, do not edit it by hand. +(function() { + /* + Chosen source: generate output using 'cake build' + Copyright (c) 2011 by Harvest + */ var $, Chosen, get_side_border_padding, root; + var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; + root = this; + $ = jQuery; + $.fn.extend({ + chosen: function(data, options) { + return $(this).each(function(input_field) { + if (!($(this)).hasClass("chzn-done")) { + return new Chosen(this, data, options); + } + }); + } + }); + Chosen = (function() { + function Chosen(elmn) { + this.set_default_values(); + this.form_field = elmn; + this.form_field_jq = $(this.form_field); + this.is_multiple = this.form_field.multiple; + this.is_rtl = this.form_field_jq.hasClass("chzn-rtl"); + this.default_text_default = this.form_field.multiple ? "Select Some Options" : "Select an Option"; + this.set_up_html(); + this.register_observers(); + this.form_field_jq.addClass("chzn-done"); + } + Chosen.prototype.set_default_values = function() { + this.click_test_action = __bind(function(evt) { + return this.test_active_click(evt); + }, this); + this.active_field = false; + this.mouse_on_container = false; + this.results_showing = false; + this.result_highlighted = null; + this.result_single_selected = null; + return this.choices = 0; + }; + Chosen.prototype.set_up_html = function() { + var container_div, dd_top, dd_width, sf_width; + this.container_id = this.form_field.id.length ? this.form_field.id.replace(/(:|\.)/g, '_') : this.generate_field_id(); + this.container_id += "_chzn"; + this.f_width = this.form_field_jq.width(); + this.default_text = this.form_field_jq.data('placeholder') ? this.form_field_jq.data('placeholder') : this.default_text_default; + container_div = $("
      ", { + id: this.container_id, + "class": "chzn-container " + (this.is_rtl ? ' chzn-rtl' : void 0), + style: 'width: ' + this.f_width + 'px;' + }); + if (this.is_multiple) { + container_div.html('
        '); + } else { + container_div.html('' + this.default_text + '
          '); + } + this.form_field_jq.hide().after(container_div); + this.container = $('#' + this.container_id); + this.container.addClass("chzn-container-" + (this.is_multiple ? "multi" : "single")); + this.dropdown = this.container.find('div.chzn-drop').first(); + dd_top = this.container.height(); + dd_width = this.f_width - get_side_border_padding(this.dropdown); + this.dropdown.css({ + "width": dd_width + "px", + "top": dd_top + "px" + }); + this.search_field = this.container.find('input').first(); + this.search_results = this.container.find('ul.chzn-results').first(); + this.search_field_scale(); + this.search_no_results = this.container.find('li.no-results').first(); + if (this.is_multiple) { + this.search_choices = this.container.find('ul.chzn-choices').first(); + this.search_container = this.container.find('li.search-field').first(); + } else { + this.search_container = this.container.find('div.chzn-search').first(); + this.selected_item = this.container.find('.chzn-single').first(); + sf_width = dd_width - get_side_border_padding(this.search_container) - get_side_border_padding(this.search_field); + this.search_field.css({ + "width": sf_width + "px" + }); + } + this.results_build(); + return this.set_tab_index(); + }; + Chosen.prototype.register_observers = function() { + this.container.click(__bind(function(evt) { + return this.container_click(evt); + }, this)); + this.container.mouseenter(__bind(function(evt) { + return this.mouse_enter(evt); + }, this)); + this.container.mouseleave(__bind(function(evt) { + return this.mouse_leave(evt); + }, this)); + this.search_results.click(__bind(function(evt) { + return this.search_results_click(evt); + }, this)); + this.search_results.mouseover(__bind(function(evt) { + return this.search_results_mouseover(evt); + }, this)); + this.search_results.mouseout(__bind(function(evt) { + return this.search_results_mouseout(evt); + }, this)); + this.form_field_jq.bind("liszt:updated", __bind(function(evt) { + return this.results_update_field(evt); + }, this)); + this.search_field.blur(__bind(function(evt) { + return this.input_blur(evt); + }, this)); + this.search_field.keyup(__bind(function(evt) { + return this.keyup_checker(evt); + }, this)); + this.search_field.keydown(__bind(function(evt) { + return this.keydown_checker(evt); + }, this)); + if (this.is_multiple) { + this.search_choices.click(__bind(function(evt) { + return this.choices_click(evt); + }, this)); + return this.search_field.focus(__bind(function(evt) { + return this.input_focus(evt); + }, this)); + } else { + return this.selected_item.focus(__bind(function(evt) { + return this.activate_field(evt); + }, this)); + } + }; + Chosen.prototype.container_click = function(evt) { + if (evt && evt.type === "click") { + evt.stopPropagation(); + } + if (!this.pending_destroy_click) { + if (!this.active_field) { + if (this.is_multiple) { + this.search_field.val(""); + } + $(document).click(this.click_test_action); + this.results_show(); + } else if (!this.is_multiple && evt && ($(evt.target) === this.selected_item || $(evt.target).parents("a.chzn-single").length)) { + evt.preventDefault(); + this.results_toggle(); + } + return this.activate_field(); + } else { + return this.pending_destroy_click = false; + } + }; + Chosen.prototype.mouse_enter = function() { + return this.mouse_on_container = true; + }; + Chosen.prototype.mouse_leave = function() { + return this.mouse_on_container = false; + }; + Chosen.prototype.input_focus = function(evt) { + if (!this.active_field) { + return setTimeout((__bind(function() { + return this.container_click(); + }, this)), 50); + } + }; + Chosen.prototype.input_blur = function(evt) { + if (!this.mouse_on_container) { + this.active_field = false; + return setTimeout((__bind(function() { + return this.blur_test(); + }, this)), 100); + } + }; + Chosen.prototype.blur_test = function(evt) { + if (!this.active_field && this.container.hasClass("chzn-container-active")) { + return this.close_field(); + } + }; + Chosen.prototype.close_field = function() { + $(document).unbind("click", this.click_test_action); + if (!this.is_multiple) { + this.selected_item.attr("tabindex", this.search_field.attr("tabindex")); + this.search_field.attr("tabindex", -1); + } + this.active_field = false; + this.results_hide(); + this.container.removeClass("chzn-container-active"); + this.winnow_results_clear(); + this.clear_backstroke(); + this.show_search_field_default(); + return this.search_field_scale(); + }; + Chosen.prototype.activate_field = function() { + if (!this.is_multiple && !this.active_field) { + this.search_field.attr("tabindex", this.selected_item.attr("tabindex")); + this.selected_item.attr("tabindex", -1); + } + this.container.addClass("chzn-container-active"); + this.active_field = true; + this.search_field.val(this.search_field.val()); + return this.search_field.focus(); + }; + Chosen.prototype.test_active_click = function(evt) { + if ($(evt.target).parents('#' + this.container_id).length) { + return this.active_field = true; + } else { + return this.close_field(); + } + }; + Chosen.prototype.results_build = function() { + var content, data, startTime, _i, _len, _ref; + startTime = new Date(); + this.parsing = true; + this.results_data = root.SelectParser.select_to_array(this.form_field); + if (this.is_multiple && this.choices > 0) { + this.search_choices.find("li.search-choice").remove(); + this.choices = 0; + } else if (!this.is_multiple) { + this.selected_item.find("span").text(this.default_text); + } + content = ''; + _ref = this.results_data; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + data = _ref[_i]; + if (data.group) { + content += this.result_add_group(data); + } else if (!data.empty) { + content += this.result_add_option(data); + if (data.selected && this.is_multiple) { + this.choice_build(data); + } else if (data.selected && !this.is_multiple) { + this.selected_item.find("span").text(data.text); + } + } + } + this.show_search_field_default(); + this.search_field_scale(); + this.search_results.html(content); + return this.parsing = false; + }; + Chosen.prototype.result_add_group = function(group) { + if (!group.disabled) { + group.dom_id = this.container_id + "_g_" + group.array_index; + return '
        • ' + $("
          ").text(group.label).html() + '
        • '; + } else { + return ""; + } + }; + Chosen.prototype.result_add_option = function(option) { + var classes; + if (!option.disabled) { + option.dom_id = this.container_id + "_o_" + option.array_index; + classes = option.selected && this.is_multiple ? [] : ["active-result"]; + if (option.selected) { + classes.push("result-selected"); + } + if (option.group_array_index != null) { + classes.push("group-option"); + } + return '
        • ' + option.html + '
        • '; + } else { + return ""; + } + }; + Chosen.prototype.results_update_field = function() { + this.result_clear_highlight(); + this.result_single_selected = null; + return this.results_build(); + }; + Chosen.prototype.result_do_highlight = function(el) { + var high_bottom, high_top, maxHeight, visible_bottom, visible_top; + if (el.length) { + this.result_clear_highlight(); + this.result_highlight = el; + this.result_highlight.addClass("highlighted"); + maxHeight = parseInt(this.search_results.css("maxHeight"), 10); + visible_top = this.search_results.scrollTop(); + visible_bottom = maxHeight + visible_top; + high_top = this.result_highlight.position().top + this.search_results.scrollTop(); + high_bottom = high_top + this.result_highlight.outerHeight(); + if (high_bottom >= visible_bottom) { + return this.search_results.scrollTop((high_bottom - maxHeight) > 0 ? high_bottom - maxHeight : 0); + } else if (high_top < visible_top) { + return this.search_results.scrollTop(high_top); + } + } + }; + Chosen.prototype.result_clear_highlight = function() { + if (this.result_highlight) { + this.result_highlight.removeClass("highlighted"); + } + return this.result_highlight = null; + }; + Chosen.prototype.results_toggle = function() { + if (this.results_showing) { + return this.results_hide(); + } else { + return this.results_show(); + } + }; + Chosen.prototype.results_show = function() { + var dd_top; + if (!this.is_multiple) { + this.selected_item.addClass("chzn-single-with-drop"); + if (this.result_single_selected) { + this.result_do_highlight(this.result_single_selected); + } + } + dd_top = this.is_multiple ? this.container.height() : this.container.height() - 1; + this.dropdown.css({ + "top": dd_top + "px", + "left": 0 + }); + this.results_showing = true; + this.search_field.focus(); + this.search_field.val(this.search_field.val()); + return this.winnow_results(); + }; + Chosen.prototype.results_hide = function() { + if (!this.is_multiple) { + this.selected_item.removeClass("chzn-single-with-drop"); + } + this.result_clear_highlight(); + this.dropdown.css({ + "left": "-9000px" + }); + return this.results_showing = false; + }; + Chosen.prototype.set_tab_index = function(el) { + var ti; + if (this.form_field_jq.attr("tabindex")) { + ti = this.form_field_jq.attr("tabindex"); + this.form_field_jq.attr("tabindex", -1); + if (this.is_multiple) { + return this.search_field.attr("tabindex", ti); + } else { + this.selected_item.attr("tabindex", ti); + return this.search_field.attr("tabindex", -1); + } + } + }; + Chosen.prototype.show_search_field_default = function() { + if (this.is_multiple && this.choices < 1 && !this.active_field) { + this.search_field.val(this.default_text); + return this.search_field.addClass("default"); + } else { + this.search_field.val(""); + return this.search_field.removeClass("default"); + } + }; + Chosen.prototype.search_results_click = function(evt) { + var target; + target = $(evt.target).hasClass("active-result") ? $(evt.target) : $(evt.target).parents(".active-result").first(); + if (target.length) { + this.result_highlight = target; + return this.result_select(); + } + }; + Chosen.prototype.search_results_mouseover = function(evt) { + var target; + target = $(evt.target).hasClass("active-result") ? $(evt.target) : $(evt.target).parents(".active-result").first(); + if (target) { + return this.result_do_highlight(target); + } + }; + Chosen.prototype.search_results_mouseout = function(evt) { + if ($(evt.target).hasClass("active-result" || $(evt.target).parents('.active-result').first())) { + return this.result_clear_highlight(); + } + }; + Chosen.prototype.choices_click = function(evt) { + evt.preventDefault(); + if (this.active_field && !($(evt.target).hasClass("search-choice" || $(evt.target).parents('.search-choice').first)) && !this.results_showing) { + return this.results_show(); + } + }; + Chosen.prototype.choice_build = function(item) { + var choice_id, link; + choice_id = this.container_id + "_c_" + item.array_index; + this.choices += 1; + this.search_container.before('
        • ' + item.html + '
        • '); + link = $('#' + choice_id).find("a").first(); + return link.click(__bind(function(evt) { + return this.choice_destroy_link_click(evt); + }, this)); + }; + Chosen.prototype.choice_destroy_link_click = function(evt) { + evt.preventDefault(); + this.pending_destroy_click = true; + return this.choice_destroy($(evt.target)); + }; + Chosen.prototype.choice_destroy = function(link) { + this.choices -= 1; + this.show_search_field_default(); + if (this.is_multiple && this.choices > 0 && this.search_field.val().length < 1) { + this.results_hide(); + } + this.result_deselect(link.attr("rel")); + return link.parents('li').first().remove(); + }; + Chosen.prototype.result_select = function() { + var high, high_id, item, position; + if (this.result_highlight) { + high = this.result_highlight; + high_id = high.attr("id"); + this.result_clear_highlight(); + high.addClass("result-selected"); + if (this.is_multiple) { + this.result_deactivate(high); + } else { + this.result_single_selected = high; + } + position = high_id.substr(high_id.lastIndexOf("_") + 1); + item = this.results_data[position]; + item.selected = true; + this.form_field.options[item.options_index].selected = true; + if (this.is_multiple) { + this.choice_build(item); + } else { + this.selected_item.find("span").first().text(item.text); + } + this.results_hide(); + this.search_field.val(""); + this.form_field_jq.trigger("change"); + return this.search_field_scale(); + } + }; + Chosen.prototype.result_activate = function(el) { + return el.addClass("active-result").show(); + }; + Chosen.prototype.result_deactivate = function(el) { + return el.removeClass("active-result").hide(); + }; + Chosen.prototype.result_deselect = function(pos) { + var result, result_data; + result_data = this.results_data[pos]; + result_data.selected = false; + this.form_field.options[result_data.options_index].selected = false; + result = $("#" + this.container_id + "_o_" + pos); + result.removeClass("result-selected").addClass("active-result").show(); + this.result_clear_highlight(); + this.winnow_results(); + this.form_field_jq.trigger("change"); + return this.search_field_scale(); + }; + Chosen.prototype.results_search = function(evt) { + if (this.results_showing) { + return this.winnow_results(); + } else { + return this.results_show(); + } + }; + Chosen.prototype.winnow_results = function() { + var found, option, part, parts, regex, result_id, results, searchText, startTime, startpos, text, zregex, _i, _j, _len, _len2, _ref; + startTime = new Date(); + this.no_results_clear(); + results = 0; + searchText = this.search_field.val() === this.default_text ? "" : $('
          ').text($.trim(this.search_field.val())).html(); + regex = new RegExp('^' + searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i'); + zregex = new RegExp(searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i'); + _ref = this.results_data; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + option = _ref[_i]; + if (!option.disabled && !option.empty) { + if (option.group) { + $('#' + option.dom_id).hide(); + } else if (!(this.is_multiple && option.selected)) { + found = false; + result_id = option.dom_id; + if (regex.test(option.html)) { + found = true; + results += 1; + } else if (option.html.indexOf(" ") >= 0 || option.html.indexOf("[") === 0) { + parts = option.html.replace(/\[|\]/g, "").split(" "); + if (parts.length) { + for (_j = 0, _len2 = parts.length; _j < _len2; _j++) { + part = parts[_j]; + if (regex.test(part)) { + found = true; + results += 1; + } + } + } + } + if (found) { + if (searchText.length) { + startpos = option.html.search(zregex); + text = option.html.substr(0, startpos + searchText.length) + '' + option.html.substr(startpos + searchText.length); + text = text.substr(0, startpos) + '' + text.substr(startpos); + } else { + text = option.html; + } + if ($("#" + result_id).html !== text) { + $("#" + result_id).html(text); + } + this.result_activate($("#" + result_id)); + if (option.group_array_index != null) { + $("#" + this.results_data[option.group_array_index].dom_id).show(); + } + } else { + if (this.result_highlight && result_id === this.result_highlight.attr('id')) { + this.result_clear_highlight(); + } + this.result_deactivate($("#" + result_id)); + } + } + } + } + if (results < 1 && searchText.length) { + return this.no_results(searchText); + } else { + return this.winnow_results_set_highlight(); + } + }; + Chosen.prototype.winnow_results_clear = function() { + var li, lis, _i, _len, _results; + this.search_field.val(""); + lis = this.search_results.find("li"); + _results = []; + for (_i = 0, _len = lis.length; _i < _len; _i++) { + li = lis[_i]; + li = $(li); + _results.push(li.hasClass("group-result") ? li.show() : !this.is_multiple || !li.hasClass("result-selected") ? this.result_activate(li) : void 0); + } + return _results; + }; + Chosen.prototype.winnow_results_set_highlight = function() { + var do_high; + if (!this.result_highlight) { + do_high = this.search_results.find(".active-result").first(); + if (do_high) { + return this.result_do_highlight(do_high); + } + } + }; + Chosen.prototype.no_results = function(terms) { + var no_results_html; + no_results_html = $('
        • No results match ""
        • '); + no_results_html.find("span").first().html(terms); + return this.search_results.append(no_results_html); + }; + Chosen.prototype.no_results_clear = function() { + return this.search_results.find(".no-results").remove(); + }; + Chosen.prototype.keydown_arrow = function() { + var first_active, next_sib; + if (!this.result_highlight) { + first_active = this.search_results.find("li.active-result").first(); + if (first_active) { + this.result_do_highlight($(first_active)); + } + } else if (this.results_showing) { + next_sib = this.result_highlight.nextAll("li.active-result").first(); + if (next_sib) { + this.result_do_highlight(next_sib); + } + } + if (!this.results_showing) { + return this.results_show(); + } + }; + Chosen.prototype.keyup_arrow = function() { + var prev_sibs; + if (!this.results_showing && !this.is_multiple) { + return this.results_show(); + } else if (this.result_highlight) { + prev_sibs = this.result_highlight.prevAll("li.active-result"); + if (prev_sibs.length) { + return this.result_do_highlight(prev_sibs.first()); + } else { + if (this.choices > 0) { + this.results_hide(); + } + return this.result_clear_highlight(); + } + } + }; + Chosen.prototype.keydown_backstroke = function() { + if (this.pending_backstroke) { + this.choice_destroy(this.pending_backstroke.find("a").first()); + return this.clear_backstroke(); + } else { + this.pending_backstroke = this.search_container.siblings("li.search-choice").last(); + return this.pending_backstroke.addClass("search-choice-focus"); + } + }; + Chosen.prototype.clear_backstroke = function() { + if (this.pending_backstroke) { + this.pending_backstroke.removeClass("search-choice-focus"); + } + return this.pending_backstroke = null; + }; + Chosen.prototype.keyup_checker = function(evt) { + var stroke, _ref; + stroke = (_ref = evt.which) != null ? _ref : evt.keyCode; + this.search_field_scale(); + switch (stroke) { + case 8: + if (this.is_multiple && this.backstroke_length < 1 && this.choices > 0) { + return this.keydown_backstroke(); + } else if (!this.pending_backstroke) { + this.result_clear_highlight(); + return this.results_search(); + } + break; + case 13: + evt.preventDefault(); + if (this.results_showing) { + return this.result_select(); + } + break; + case 27: + if (this.results_showing) { + return this.results_hide(); + } + break; + case 9: + case 38: + case 40: + case 16: + break; + default: + return this.results_search(); + } + }; + Chosen.prototype.keydown_checker = function(evt) { + var stroke, _ref; + stroke = (_ref = evt.which) != null ? _ref : evt.keyCode; + this.search_field_scale(); + if (stroke !== 8 && this.pending_backstroke) { + this.clear_backstroke(); + } + switch (stroke) { + case 8: + this.backstroke_length = this.search_field.val().length; + break; + case 9: + this.mouse_on_container = false; + break; + case 13: + evt.preventDefault(); + break; + case 38: + evt.preventDefault(); + this.keyup_arrow(); + break; + case 40: + this.keydown_arrow(); + break; + } + }; + Chosen.prototype.search_field_scale = function() { + var dd_top, div, h, style, style_block, styles, w, _i, _len; + if (this.is_multiple) { + h = 0; + w = 0; + style_block = "position:absolute; left: -1000px; top: -1000px; display:none;"; + styles = ['font-size', 'font-style', 'font-weight', 'font-family', 'line-height', 'text-transform', 'letter-spacing']; + for (_i = 0, _len = styles.length; _i < _len; _i++) { + style = styles[_i]; + style_block += style + ":" + this.search_field.css(style) + ";"; + } + div = $('
          ', { + 'style': style_block + }); + div.text(this.search_field.val()); + $('body').append(div); + w = div.width() + 25; + div.remove(); + if (w > this.f_width - 10) { + w = this.f_width - 10; + } + this.search_field.css({ + 'width': w + 'px' + }); + dd_top = this.container.height(); + return this.dropdown.css({ + "top": dd_top + "px" + }); + } + }; + Chosen.prototype.generate_field_id = function() { + var new_id; + new_id = this.generate_random_id(); + this.form_field.id = new_id; + return new_id; + }; + Chosen.prototype.generate_random_id = function() { + var string; + string = "sel" + this.generate_random_char() + this.generate_random_char() + this.generate_random_char(); + while ($("#" + string).length > 0) { + string += this.generate_random_char(); + } + return string; + }; + Chosen.prototype.generate_random_char = function() { + var chars, newchar, rand; + chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZ"; + rand = Math.floor(Math.random() * chars.length); + return newchar = chars.substring(rand, rand + 1); + }; + return Chosen; + })(); + get_side_border_padding = function(elmt) { + var side_border_padding; + return side_border_padding = elmt.outerWidth() - elmt.width(); + }; + root.get_side_border_padding = get_side_border_padding; +}).call(this); +(function() { + var SelectParser; + SelectParser = (function() { + function SelectParser() { + this.options_index = 0; + this.parsed = []; + } + SelectParser.prototype.add_node = function(child) { + if (child.nodeName === "OPTGROUP") { + return this.add_group(child); + } else { + return this.add_option(child); + } + }; + SelectParser.prototype.add_group = function(group) { + var group_position, option, _i, _len, _ref, _results; + group_position = this.parsed.length; + this.parsed.push({ + array_index: group_position, + group: true, + label: group.label, + children: 0, + disabled: group.disabled + }); + _ref = group.childNodes; + _results = []; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + option = _ref[_i]; + _results.push(this.add_option(option, group_position, group.disabled)); + } + return _results; + }; + SelectParser.prototype.add_option = function(option, group_position, group_disabled) { + if (option.nodeName === "OPTION") { + if (option.text !== "") { + if (group_position != null) { + this.parsed[group_position].children += 1; + } + this.parsed.push({ + array_index: this.parsed.length, + options_index: this.options_index, + value: option.value, + text: option.text, + html: option.innerHTML, + selected: option.selected, + disabled: group_disabled === true ? group_disabled : option.disabled, + group_array_index: group_position + }); + } else { + this.parsed.push({ + array_index: this.parsed.length, + options_index: this.options_index, + empty: true + }); + } + return this.options_index += 1; + } + }; + return SelectParser; + })(); + SelectParser.select_to_array = function(select) { + var child, parser, _i, _len, _ref; + parser = new SelectParser(); + _ref = select.childNodes; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + child = _ref[_i]; + parser.add_node(child); + } + return parser.parsed; + }; + this.SelectParser = SelectParser; +}).call(this); diff --git a/3rdparty/js/chosen/chosen.jquery.min.js b/3rdparty/js/chosen/chosen.jquery.min.js new file mode 100644 index 0000000000..1d6a6983d8 --- /dev/null +++ b/3rdparty/js/chosen/chosen.jquery.min.js @@ -0,0 +1,10 @@ +// Chosen, a Select Box Enhancer for jQuery and Protoype +// by Patrick Filler for Harvest, http://getharvest.com +// +// Version 0.9 +// Full source at https://github.com/harvesthq/chosen +// Copyright (c) 2011 Harvest http://getharvest.com + +// MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md +// This file is generated by `cake build`, do not edit it by hand. +(function(){var a,b,c,d,e=function(a,b){return function(){return a.apply(b,arguments)}};d=this,a=jQuery,a.fn.extend({chosen:function(c,d){return a(this).each(function(e){if(!a(this).hasClass("chzn-done"))return new b(this,c,d)})}}),b=function(){function b(b){this.set_default_values(),this.form_field=b,this.form_field_jq=a(this.form_field),this.is_multiple=this.form_field.multiple,this.is_rtl=this.form_field_jq.hasClass("chzn-rtl"),this.default_text_default=this.form_field.multiple?"Select Some Options":"Select an Option",this.set_up_html(),this.register_observers(),this.form_field_jq.addClass("chzn-done")}b.prototype.set_default_values=function(){this.click_test_action=e(function(a){return this.test_active_click(a)},this),this.active_field=!1,this.mouse_on_container=!1,this.results_showing=!1,this.result_highlighted=null,this.result_single_selected=null;return this.choices=0},b.prototype.set_up_html=function(){var b,d,e,f;this.container_id=this.form_field.id.length?this.form_field.id.replace(/(:|\.)/g,"_"):this.generate_field_id(),this.container_id+="_chzn",this.f_width=this.form_field_jq.width(),this.default_text=this.form_field_jq.data("placeholder")?this.form_field_jq.data("placeholder"):this.default_text_default,b=a("
          ",{id:this.container_id,"class":"chzn-container "+(this.is_rtl?" chzn-rtl":void 0),style:"width: "+this.f_width+"px;"}),this.is_multiple?b.html('
            '):b.html(''+this.default_text+'
              '),this.form_field_jq.hide().after(b),this.container=a("#"+this.container_id),this.container.addClass("chzn-container-"+(this.is_multiple?"multi":"single")),this.dropdown=this.container.find("div.chzn-drop").first(),d=this.container.height(),e=this.f_width-c(this.dropdown),this.dropdown.css({width:e+"px",top:d+"px"}),this.search_field=this.container.find("input").first(),this.search_results=this.container.find("ul.chzn-results").first(),this.search_field_scale(),this.search_no_results=this.container.find("li.no-results").first(),this.is_multiple?(this.search_choices=this.container.find("ul.chzn-choices").first(),this.search_container=this.container.find("li.search-field").first()):(this.search_container=this.container.find("div.chzn-search").first(),this.selected_item=this.container.find(".chzn-single").first(),f=e-c(this.search_container)-c(this.search_field),this.search_field.css({width:f+"px"})),this.results_build();return this.set_tab_index()},b.prototype.register_observers=function(){this.container.click(e(function(a){return this.container_click(a)},this)),this.container.mouseenter(e(function(a){return this.mouse_enter(a)},this)),this.container.mouseleave(e(function(a){return this.mouse_leave(a)},this)),this.search_results.click(e(function(a){return this.search_results_click(a)},this)),this.search_results.mouseover(e(function(a){return this.search_results_mouseover(a)},this)),this.search_results.mouseout(e(function(a){return this.search_results_mouseout(a)},this)),this.form_field_jq.bind("liszt:updated",e(function(a){return this.results_update_field(a)},this)),this.search_field.blur(e(function(a){return this.input_blur(a)},this)),this.search_field.keyup(e(function(a){return this.keyup_checker(a)},this)),this.search_field.keydown(e(function(a){return this.keydown_checker(a)},this));if(this.is_multiple){this.search_choices.click(e(function(a){return this.choices_click(a)},this));return this.search_field.focus(e(function(a){return this.input_focus(a)},this))}return this.selected_item.focus(e(function(a){return this.activate_field(a)},this))},b.prototype.container_click=function(b){b&&b.type==="click"&&b.stopPropagation();if(!this.pending_destroy_click){this.active_field?!this.is_multiple&&b&&(a(b.target)===this.selected_item||a(b.target).parents("a.chzn-single").length)&&(b.preventDefault(),this.results_toggle()):(this.is_multiple&&this.search_field.val(""),a(document).click(this.click_test_action),this.results_show());return this.activate_field()}return this.pending_destroy_click=!1},b.prototype.mouse_enter=function(){return this.mouse_on_container=!0},b.prototype.mouse_leave=function(){return this.mouse_on_container=!1},b.prototype.input_focus=function(a){if(!this.active_field)return setTimeout(e(function(){return this.container_click()},this),50)},b.prototype.input_blur=function(a){if(!this.mouse_on_container){this.active_field=!1;return setTimeout(e(function(){return this.blur_test()},this),100)}},b.prototype.blur_test=function(a){if(!this.active_field&&this.container.hasClass("chzn-container-active"))return this.close_field()},b.prototype.close_field=function(){a(document).unbind("click",this.click_test_action),this.is_multiple||(this.selected_item.attr("tabindex",this.search_field.attr("tabindex")),this.search_field.attr("tabindex",-1)),this.active_field=!1,this.results_hide(),this.container.removeClass("chzn-container-active"),this.winnow_results_clear(),this.clear_backstroke(),this.show_search_field_default();return this.search_field_scale()},b.prototype.activate_field=function(){!this.is_multiple&&!this.active_field&&(this.search_field.attr("tabindex",this.selected_item.attr("tabindex")),this.selected_item.attr("tabindex",-1)),this.container.addClass("chzn-container-active"),this.active_field=!0,this.search_field.val(this.search_field.val());return this.search_field.focus()},b.prototype.test_active_click=function(b){return a(b.target).parents("#"+this.container_id).length?this.active_field=!0:this.close_field()},b.prototype.results_build=function(){var a,b,c,e,f,g;c=new Date,this.parsing=!0,this.results_data=d.SelectParser.select_to_array(this.form_field),this.is_multiple&&this.choices>0?(this.search_choices.find("li.search-choice").remove(),this.choices=0):this.is_multiple||this.selected_item.find("span").text(this.default_text),a="",g=this.results_data;for(e=0,f=g.length;e'+a("
              ").text(b.label).html()+""}return""},b.prototype.result_add_option=function(a){var b;if(!a.disabled){a.dom_id=this.container_id+"_o_"+a.array_index,b=a.selected&&this.is_multiple?[]:["active-result"],a.selected&&b.push("result-selected"),a.group_array_index!=null&&b.push("group-option");return'
            • '+a.html+"
            • "}return""},b.prototype.results_update_field=function(){this.result_clear_highlight(),this.result_single_selected=null;return this.results_build()},b.prototype.result_do_highlight=function(a){var b,c,d,e,f;if(a.length){this.result_clear_highlight(),this.result_highlight=a,this.result_highlight.addClass("highlighted"),d=parseInt(this.search_results.css("maxHeight"),10),f=this.search_results.scrollTop(),e=d+f,c=this.result_highlight.position().top+this.search_results.scrollTop(),b=c+this.result_highlight.outerHeight();if(b>=e)return this.search_results.scrollTop(b-d>0?b-d:0);if(c'+b.html+''),d=a("#"+c).find("a").first();return d.click(e(function(a){return this.choice_destroy_link_click(a)},this))},b.prototype.choice_destroy_link_click=function(b){b.preventDefault(),this.pending_destroy_click=!0;return this.choice_destroy(a(b.target))},b.prototype.choice_destroy=function(a){this.choices-=1,this.show_search_field_default(),this.is_multiple&&this.choices>0&&this.search_field.val().length<1&&this.results_hide(),this.result_deselect(a.attr("rel"));return a.parents("li").first().remove()},b.prototype.result_select=function(){var a,b,c,d;if(this.result_highlight){a=this.result_highlight,b=a.attr("id"),this.result_clear_highlight(),a.addClass("result-selected"),this.is_multiple?this.result_deactivate(a):this.result_single_selected=a,d=b.substr(b.lastIndexOf("_")+1),c=this.results_data[d],c.selected=!0,this.form_field.options[c.options_index].selected=!0,this.is_multiple?this.choice_build(c):this.selected_item.find("span").first().text(c.text),this.results_hide(),this.search_field.val(""),this.form_field_jq.trigger("change");return this.search_field_scale()}},b.prototype.result_activate=function(a){return a.addClass("active-result").show()},b.prototype.result_deactivate=function(a){return a.removeClass("active-result").hide()},b.prototype.result_deselect=function(b){var c,d;d=this.results_data[b],d.selected=!1,this.form_field.options[d.options_index].selected=!1,c=a("#"+this.container_id+"_o_"+b),c.removeClass("result-selected").addClass("active-result").show(),this.result_clear_highlight(),this.winnow_results(),this.form_field_jq.trigger("change");return this.search_field_scale()},b.prototype.results_search=function(a){return this.results_showing?this.winnow_results():this.results_show()},b.prototype.winnow_results=function(){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r;j=new Date,this.no_results_clear(),h=0,i=this.search_field.val()===this.default_text?"":a("
              ").text(a.trim(this.search_field.val())).html(),f=new RegExp("^"+i.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"i"),m=new RegExp(i.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"i"),r=this.results_data;for(n=0,p=r.length;n=0||c.html.indexOf("[")===0){e=c.html.replace(/\[|\]/g,"").split(" ");if(e.length)for(o=0,q=e.length;o"+c.html.substr(k+i.length),l=l.substr(0,k)+""+l.substr(k)):l=c.html,a("#"+g).html!==l&&a("#"+g).html(l),this.result_activate(a("#"+g)),c.group_array_index!=null&&a("#"+this.results_data[c.group_array_index].dom_id).show()):(this.result_highlight&&g===this.result_highlight.attr("id")&&this.result_clear_highlight(),this.result_deactivate(a("#"+g)))}}return h<1&&i.length?this.no_results(i):this.winnow_results_set_highlight()},b.prototype.winnow_results_clear=function(){var b,c,d,e,f;this.search_field.val(""),c=this.search_results.find("li"),f=[];for(d=0,e=c.length;dNo results match ""'),c.find("span").first().html(b);return this.search_results.append(c)},b.prototype.no_results_clear=function(){return this.search_results.find(".no-results").remove()},b.prototype.keydown_arrow=function(){var b,c;this.result_highlight?this.results_showing&&(c=this.result_highlight.nextAll("li.active-result").first(),c&&this.result_do_highlight(c)):(b=this.search_results.find("li.active-result").first(),b&&this.result_do_highlight(a(b)));if(!this.results_showing)return this.results_show()},b.prototype.keyup_arrow=function(){var a;if(!this.results_showing&&!this.is_multiple)return this.results_show();if(this.result_highlight){a=this.result_highlight.prevAll("li.active-result");if(a.length)return this.result_do_highlight(a.first());this.choices>0&&this.results_hide();return this.result_clear_highlight()}},b.prototype.keydown_backstroke=function(){if(this.pending_backstroke){this.choice_destroy(this.pending_backstroke.find("a").first());return this.clear_backstroke()}this.pending_backstroke=this.search_container.siblings("li.search-choice").last();return this.pending_backstroke.addClass("search-choice-focus")},b.prototype.clear_backstroke=function(){this.pending_backstroke&&this.pending_backstroke.removeClass("search-choice-focus");return this.pending_backstroke=null},b.prototype.keyup_checker=function(a){var b,c;b=(c=a.which)!=null?c:a.keyCode,this.search_field_scale();switch(b){case 8:if(this.is_multiple&&this.backstroke_length<1&&this.choices>0)return this.keydown_backstroke();if(!this.pending_backstroke){this.result_clear_highlight();return this.results_search()}break;case 13:a.preventDefault();if(this.results_showing)return this.result_select();break;case 27:if(this.results_showing)return this.results_hide();break;case 9:case 38:case 40:case 16:break;default:return this.results_search()}},b.prototype.keydown_checker=function(a){var b,c;b=(c=a.which)!=null?c:a.keyCode,this.search_field_scale(),b!==8&&this.pending_backstroke&&this.clear_backstroke();switch(b){case 8:this.backstroke_length=this.search_field.val().length;break;case 9:this.mouse_on_container=!1;break;case 13:a.preventDefault();break;case 38:a.preventDefault(),this.keyup_arrow();break;case 40:this.keydown_arrow()}},b.prototype.search_field_scale=function(){var b,c,d,e,f,g,h,i,j;if(this.is_multiple){d=0,h=0,f="position:absolute; left: -1000px; top: -1000px; display:none;",g=["font-size","font-style","font-weight","font-family","line-height","text-transform","letter-spacing"];for(i=0,j=g.length;i",{style:f}),c.text(this.search_field.val()),a("body").append(c),h=c.width()+25,c.remove(),h>this.f_width-10&&(h=this.f_width-10),this.search_field.css({width:h+"px"}),b=this.container.height();return this.dropdown.css({top:b+"px"})}},b.prototype.generate_field_id=function(){var a;a=this.generate_random_id(),this.form_field.id=a;return a},b.prototype.generate_random_id=function(){var b;b="sel"+this.generate_random_char()+this.generate_random_char()+this.generate_random_char();while(a("#"+b).length>0)b+=this.generate_random_char();return b},b.prototype.generate_random_char=function(){var a,b,c;a="0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZ",c=Math.floor(Math.random()*a.length);return b=a.substring(c,c+1)};return b}(),c=function(a){var b;return b=a.outerWidth()-a.width()},d.get_side_border_padding=c}).call(this),function(){var a;a=function(){function a(){this.options_index=0,this.parsed=[]}a.prototype.add_node=function(a){return a.nodeName==="OPTGROUP"?this.add_group(a):this.add_option(a)},a.prototype.add_group=function(a){var b,c,d,e,f,g;b=this.parsed.length,this.parsed.push({array_index:b,group:!0,label:a.label,children:0,disabled:a.disabled}),f=a.childNodes,g=[];for(d=0,e=f.length;d#{default}
                '); + this.multi_temp = new Template('
                  '); + this.choice_temp = new Template('
                • #{choice}
                • '); + return this.no_results_temp = new Template('
                • No results match "#{terms}"
                • '); + }; + Chosen.prototype.set_up_html = function() { + var base_template, container_props, dd_top, dd_width, sf_width; + this.container_id = this.form_field.identify().replace(/(:|\.)/g, '_') + "_chzn"; + this.f_width = this.form_field.getStyle("width") ? parseInt(this.form_field.getStyle("width"), 10) : this.form_field.getWidth(); + container_props = { + 'id': this.container_id, + 'class': "chzn-container " + (this.is_rtl ? ' chzn-rtl' : void 0), + 'style': 'width: ' + this.f_width + 'px' + }; + this.default_text = this.form_field.readAttribute('data-placeholder') ? this.form_field.readAttribute('data-placeholder') : this.default_text_default; + base_template = this.is_multiple ? new Element('div', container_props).update(this.multi_temp.evaluate({ + "default": this.default_text + })) : new Element('div', container_props).update(this.single_temp.evaluate({ + "default": this.default_text + })); + this.form_field.hide().insert({ + after: base_template + }); + this.container = $(this.container_id); + this.container.addClassName("chzn-container-" + (this.is_multiple ? "multi" : "single")); + this.dropdown = this.container.down('div.chzn-drop'); + dd_top = this.container.getHeight(); + dd_width = this.f_width - get_side_border_padding(this.dropdown); + this.dropdown.setStyle({ + "width": dd_width + "px", + "top": dd_top + "px" + }); + this.search_field = this.container.down('input'); + this.search_results = this.container.down('ul.chzn-results'); + this.search_field_scale(); + this.search_no_results = this.container.down('li.no-results'); + if (this.is_multiple) { + this.search_choices = this.container.down('ul.chzn-choices'); + this.search_container = this.container.down('li.search-field'); + } else { + this.search_container = this.container.down('div.chzn-search'); + this.selected_item = this.container.down('.chzn-single'); + sf_width = dd_width - get_side_border_padding(this.search_container) - get_side_border_padding(this.search_field); + this.search_field.setStyle({ + "width": sf_width + "px" + }); + } + this.results_build(); + return this.set_tab_index(); + }; + Chosen.prototype.register_observers = function() { + this.container.observe("click", __bind(function(evt) { + return this.container_click(evt); + }, this)); + this.container.observe("mouseenter", __bind(function(evt) { + return this.mouse_enter(evt); + }, this)); + this.container.observe("mouseleave", __bind(function(evt) { + return this.mouse_leave(evt); + }, this)); + this.search_results.observe("click", __bind(function(evt) { + return this.search_results_click(evt); + }, this)); + this.search_results.observe("mouseover", __bind(function(evt) { + return this.search_results_mouseover(evt); + }, this)); + this.search_results.observe("mouseout", __bind(function(evt) { + return this.search_results_mouseout(evt); + }, this)); + this.form_field.observe("liszt:updated", __bind(function(evt) { + return this.results_update_field(evt); + }, this)); + this.search_field.observe("blur", __bind(function(evt) { + return this.input_blur(evt); + }, this)); + this.search_field.observe("keyup", __bind(function(evt) { + return this.keyup_checker(evt); + }, this)); + this.search_field.observe("keydown", __bind(function(evt) { + return this.keydown_checker(evt); + }, this)); + if (this.is_multiple) { + this.search_choices.observe("click", __bind(function(evt) { + return this.choices_click(evt); + }, this)); + return this.search_field.observe("focus", __bind(function(evt) { + return this.input_focus(evt); + }, this)); + } else { + return this.selected_item.observe("focus", __bind(function(evt) { + return this.activate_field(evt); + }, this)); + } + }; + Chosen.prototype.container_click = function(evt) { + if (evt && evt.type === "click") { + evt.stop(); + } + if (!this.pending_destroy_click) { + if (!this.active_field) { + if (this.is_multiple) { + this.search_field.clear(); + } + document.observe("click", this.click_test_action); + this.results_show(); + } else if (!this.is_multiple && evt && (evt.target === this.selected_item || evt.target.up("a.chzn-single"))) { + this.results_toggle(); + } + return this.activate_field(); + } else { + return this.pending_destroy_click = false; + } + }; + Chosen.prototype.mouse_enter = function() { + return this.mouse_on_container = true; + }; + Chosen.prototype.mouse_leave = function() { + return this.mouse_on_container = false; + }; + Chosen.prototype.input_focus = function(evt) { + if (!this.active_field) { + return setTimeout(this.container_click.bind(this), 50); + } + }; + Chosen.prototype.input_blur = function(evt) { + if (!this.mouse_on_container) { + this.active_field = false; + return setTimeout(this.blur_test.bind(this), 100); + } + }; + Chosen.prototype.blur_test = function(evt) { + if (!this.active_field && this.container.hasClassName("chzn-container-active")) { + return this.close_field(); + } + }; + Chosen.prototype.close_field = function() { + document.stopObserving("click", this.click_test_action); + if (!this.is_multiple) { + this.selected_item.tabIndex = this.search_field.tabIndex; + this.search_field.tabIndex = -1; + } + this.active_field = false; + this.results_hide(); + this.container.removeClassName("chzn-container-active"); + this.winnow_results_clear(); + this.clear_backstroke(); + this.show_search_field_default(); + return this.search_field_scale(); + }; + Chosen.prototype.activate_field = function() { + if (!this.is_multiple && !this.active_field) { + this.search_field.tabIndex = this.selected_item.tabIndex; + this.selected_item.tabIndex = -1; + } + this.container.addClassName("chzn-container-active"); + this.active_field = true; + this.search_field.value = this.search_field.value; + return this.search_field.focus(); + }; + Chosen.prototype.test_active_click = function(evt) { + if (evt.target.up('#' + this.container_id)) { + return this.active_field = true; + } else { + return this.close_field(); + } + }; + Chosen.prototype.results_build = function() { + var content, data, startTime, _i, _len, _ref; + startTime = new Date(); + this.parsing = true; + this.results_data = root.SelectParser.select_to_array(this.form_field); + if (this.is_multiple && this.choices > 0) { + this.search_choices.select("li.search-choice").invoke("remove"); + this.choices = 0; + } else if (!this.is_multiple) { + this.selected_item.down("span").update(this.default_text); + } + content = ''; + _ref = this.results_data; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + data = _ref[_i]; + if (data.group) { + content += this.result_add_group(data); + } else if (!data.empty) { + content += this.result_add_option(data); + if (data.selected && this.is_multiple) { + this.choice_build(data); + } else if (data.selected && !this.is_multiple) { + this.selected_item.down("span").update(data.html); + } + } + } + this.show_search_field_default(); + this.search_field_scale(); + this.search_results.update(content); + return this.parsing = false; + }; + Chosen.prototype.result_add_group = function(group) { + if (!group.disabled) { + group.dom_id = this.container_id + "_g_" + group.array_index; + return '
                • ' + group.label.escapeHTML() + '
                • '; + } else { + return ""; + } + }; + Chosen.prototype.result_add_option = function(option) { + var classes; + if (!option.disabled) { + option.dom_id = this.container_id + "_o_" + option.array_index; + classes = option.selected && this.is_multiple ? [] : ["active-result"]; + if (option.selected) { + classes.push("result-selected"); + } + if (option.group_array_index != null) { + classes.push("group-option"); + } + return '
                • ' + option.html + '
                • '; + } else { + return ""; + } + }; + Chosen.prototype.results_update_field = function() { + this.result_clear_highlight(); + this.result_single_selected = null; + return this.results_build(); + }; + Chosen.prototype.result_do_highlight = function(el) { + var high_bottom, high_top, maxHeight, visible_bottom, visible_top; + this.result_clear_highlight(); + this.result_highlight = el; + this.result_highlight.addClassName("highlighted"); + maxHeight = parseInt(this.search_results.getStyle('maxHeight'), 10); + visible_top = this.search_results.scrollTop; + visible_bottom = maxHeight + visible_top; + high_top = this.result_highlight.positionedOffset().top; + high_bottom = high_top + this.result_highlight.getHeight(); + if (high_bottom >= visible_bottom) { + return this.search_results.scrollTop = (high_bottom - maxHeight) > 0 ? high_bottom - maxHeight : 0; + } else if (high_top < visible_top) { + return this.search_results.scrollTop = high_top; + } + }; + Chosen.prototype.result_clear_highlight = function() { + if (this.result_highlight) { + this.result_highlight.removeClassName('highlighted'); + } + return this.result_highlight = null; + }; + Chosen.prototype.results_toggle = function() { + if (this.results_showing) { + return this.results_hide(); + } else { + return this.results_show(); + } + }; + Chosen.prototype.results_show = function() { + var dd_top; + if (!this.is_multiple) { + this.selected_item.addClassName('chzn-single-with-drop'); + if (this.result_single_selected) { + this.result_do_highlight(this.result_single_selected); + } + } + dd_top = this.is_multiple ? this.container.getHeight() : this.container.getHeight() - 1; + this.dropdown.setStyle({ + "top": dd_top + "px", + "left": 0 + }); + this.results_showing = true; + this.search_field.focus(); + this.search_field.value = this.search_field.value; + return this.winnow_results(); + }; + Chosen.prototype.results_hide = function() { + if (!this.is_multiple) { + this.selected_item.removeClassName('chzn-single-with-drop'); + } + this.result_clear_highlight(); + this.dropdown.setStyle({ + "left": "-9000px" + }); + return this.results_showing = false; + }; + Chosen.prototype.set_tab_index = function(el) { + var ti; + if (this.form_field.tabIndex) { + ti = this.form_field.tabIndex; + this.form_field.tabIndex = -1; + if (this.is_multiple) { + return this.search_field.tabIndex = ti; + } else { + this.selected_item.tabIndex = ti; + return this.search_field.tabIndex = -1; + } + } + }; + Chosen.prototype.show_search_field_default = function() { + if (this.is_multiple && this.choices < 1 && !this.active_field) { + this.search_field.value = this.default_text; + return this.search_field.addClassName("default"); + } else { + this.search_field.value = ""; + return this.search_field.removeClassName("default"); + } + }; + Chosen.prototype.search_results_click = function(evt) { + var target; + target = evt.target.hasClassName("active-result") ? evt.target : evt.target.up(".active-result"); + if (target) { + this.result_highlight = target; + return this.result_select(); + } + }; + Chosen.prototype.search_results_mouseover = function(evt) { + var target; + target = evt.target.hasClassName("active-result") ? evt.target : evt.target.up(".active-result"); + if (target) { + return this.result_do_highlight(target); + } + }; + Chosen.prototype.search_results_mouseout = function(evt) { + if (evt.target.hasClassName('active-result') || evt.target.up('.active-result')) { + return this.result_clear_highlight(); + } + }; + Chosen.prototype.choices_click = function(evt) { + evt.preventDefault(); + if (this.active_field && !(evt.target.hasClassName('search-choice') || evt.target.up('.search-choice')) && !this.results_showing) { + return this.results_show(); + } + }; + Chosen.prototype.choice_build = function(item) { + var choice_id, link; + choice_id = this.container_id + "_c_" + item.array_index; + this.choices += 1; + this.search_container.insert({ + before: this.choice_temp.evaluate({ + id: choice_id, + choice: item.html, + position: item.array_index + }) + }); + link = $(choice_id).down('a'); + return link.observe("click", __bind(function(evt) { + return this.choice_destroy_link_click(evt); + }, this)); + }; + Chosen.prototype.choice_destroy_link_click = function(evt) { + evt.preventDefault(); + this.pending_destroy_click = true; + return this.choice_destroy(evt.target); + }; + Chosen.prototype.choice_destroy = function(link) { + this.choices -= 1; + this.show_search_field_default(); + if (this.is_multiple && this.choices > 0 && this.search_field.value.length < 1) { + this.results_hide(); + } + this.result_deselect(link.readAttribute("rel")); + return link.up('li').remove(); + }; + Chosen.prototype.result_select = function() { + var high, item, position; + if (this.result_highlight) { + high = this.result_highlight; + this.result_clear_highlight(); + high.addClassName("result-selected"); + if (this.is_multiple) { + this.result_deactivate(high); + } else { + this.result_single_selected = high; + } + position = high.id.substr(high.id.lastIndexOf("_") + 1); + item = this.results_data[position]; + item.selected = true; + this.form_field.options[item.options_index].selected = true; + if (this.is_multiple) { + this.choice_build(item); + } else { + this.selected_item.down("span").update(item.html); + } + this.results_hide(); + this.search_field.value = ""; + if (typeof Event.simulate === 'function') { + this.form_field.simulate("change"); + } + return this.search_field_scale(); + } + }; + Chosen.prototype.result_activate = function(el) { + return el.addClassName("active-result").show(); + }; + Chosen.prototype.result_deactivate = function(el) { + return el.removeClassName("active-result").hide(); + }; + Chosen.prototype.result_deselect = function(pos) { + var result, result_data; + result_data = this.results_data[pos]; + result_data.selected = false; + this.form_field.options[result_data.options_index].selected = false; + result = $(this.container_id + "_o_" + pos); + result.removeClassName("result-selected").addClassName("active-result").show(); + this.result_clear_highlight(); + this.winnow_results(); + if (typeof Event.simulate === 'function') { + this.form_field.simulate("change"); + } + return this.search_field_scale(); + }; + Chosen.prototype.results_search = function(evt) { + if (this.results_showing) { + return this.winnow_results(); + } else { + return this.results_show(); + } + }; + Chosen.prototype.winnow_results = function() { + var found, option, part, parts, regex, result_id, results, searchText, startTime, startpos, text, zregex, _i, _j, _len, _len2, _ref; + startTime = new Date(); + this.no_results_clear(); + results = 0; + searchText = this.search_field.value === this.default_text ? "" : this.search_field.value.strip().escapeHTML(); + regex = new RegExp('^' + searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i'); + zregex = new RegExp(searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i'); + _ref = this.results_data; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + option = _ref[_i]; + if (!option.disabled && !option.empty) { + if (option.group) { + $(option.dom_id).hide(); + } else if (!(this.is_multiple && option.selected)) { + found = false; + result_id = option.dom_id; + if (regex.test(option.html)) { + found = true; + results += 1; + } else if (option.html.indexOf(" ") >= 0 || option.html.indexOf("[") === 0) { + parts = option.html.replace(/\[|\]/g, "").split(" "); + if (parts.length) { + for (_j = 0, _len2 = parts.length; _j < _len2; _j++) { + part = parts[_j]; + if (regex.test(part)) { + found = true; + results += 1; + } + } + } + } + if (found) { + if (searchText.length) { + startpos = option.html.search(zregex); + text = option.html.substr(0, startpos + searchText.length) + '
                  ' + option.html.substr(startpos + searchText.length); + text = text.substr(0, startpos) + '' + text.substr(startpos); + } else { + text = option.html; + } + if ($(result_id).innerHTML !== text) { + $(result_id).update(text); + } + this.result_activate($(result_id)); + if (option.group_array_index != null) { + $(this.results_data[option.group_array_index].dom_id).show(); + } + } else { + if ($(result_id) === this.result_highlight) { + this.result_clear_highlight(); + } + this.result_deactivate($(result_id)); + } + } + } + } + if (results < 1 && searchText.length) { + return this.no_results(searchText); + } else { + return this.winnow_results_set_highlight(); + } + }; + Chosen.prototype.winnow_results_clear = function() { + var li, lis, _i, _len, _results; + this.search_field.clear(); + lis = this.search_results.select("li"); + _results = []; + for (_i = 0, _len = lis.length; _i < _len; _i++) { + li = lis[_i]; + _results.push(li.hasClassName("group-result") ? li.show() : !this.is_multiple || !li.hasClassName("result-selected") ? this.result_activate(li) : void 0); + } + return _results; + }; + Chosen.prototype.winnow_results_set_highlight = function() { + var do_high; + if (!this.result_highlight) { + do_high = this.search_results.down(".active-result"); + if (do_high) { + return this.result_do_highlight(do_high); + } + } + }; + Chosen.prototype.no_results = function(terms) { + return this.search_results.insert(this.no_results_temp.evaluate({ + terms: terms + })); + }; + Chosen.prototype.no_results_clear = function() { + var nr, _results; + nr = null; + _results = []; + while (nr = this.search_results.down(".no-results")) { + _results.push(nr.remove()); + } + return _results; + }; + Chosen.prototype.keydown_arrow = function() { + var actives, nexts, sibs; + actives = this.search_results.select("li.active-result"); + if (actives.length) { + if (!this.result_highlight) { + this.result_do_highlight(actives.first()); + } else if (this.results_showing) { + sibs = this.result_highlight.nextSiblings(); + nexts = sibs.intersect(actives); + if (nexts.length) { + this.result_do_highlight(nexts.first()); + } + } + if (!this.results_showing) { + return this.results_show(); + } + } + }; + Chosen.prototype.keyup_arrow = function() { + var actives, prevs, sibs; + if (!this.results_showing && !this.is_multiple) { + return this.results_show(); + } else if (this.result_highlight) { + sibs = this.result_highlight.previousSiblings(); + actives = this.search_results.select("li.active-result"); + prevs = sibs.intersect(actives); + if (prevs.length) { + return this.result_do_highlight(prevs.first()); + } else { + if (this.choices > 0) { + this.results_hide(); + } + return this.result_clear_highlight(); + } + } + }; + Chosen.prototype.keydown_backstroke = function() { + if (this.pending_backstroke) { + this.choice_destroy(this.pending_backstroke.down("a")); + return this.clear_backstroke(); + } else { + this.pending_backstroke = this.search_container.siblings("li.search-choice").last(); + return this.pending_backstroke.addClassName("search-choice-focus"); + } + }; + Chosen.prototype.clear_backstroke = function() { + if (this.pending_backstroke) { + this.pending_backstroke.removeClassName("search-choice-focus"); + } + return this.pending_backstroke = null; + }; + Chosen.prototype.keyup_checker = function(evt) { + var stroke, _ref; + stroke = (_ref = evt.which) != null ? _ref : evt.keyCode; + this.search_field_scale(); + switch (stroke) { + case 8: + if (this.is_multiple && this.backstroke_length < 1 && this.choices > 0) { + return this.keydown_backstroke(); + } else if (!this.pending_backstroke) { + this.result_clear_highlight(); + return this.results_search(); + } + break; + case 13: + evt.preventDefault(); + if (this.results_showing) { + return this.result_select(); + } + break; + case 27: + if (this.results_showing) { + return this.results_hide(); + } + break; + case 9: + case 38: + case 40: + case 16: + break; + default: + return this.results_search(); + } + }; + Chosen.prototype.keydown_checker = function(evt) { + var stroke, _ref; + stroke = (_ref = evt.which) != null ? _ref : evt.keyCode; + this.search_field_scale(); + if (stroke !== 8 && this.pending_backstroke) { + this.clear_backstroke(); + } + switch (stroke) { + case 8: + return this.backstroke_length = this.search_field.value.length; + case 9: + return this.mouse_on_container = false; + case 13: + return evt.preventDefault(); + case 38: + evt.preventDefault(); + return this.keyup_arrow(); + case 40: + return this.keydown_arrow(); + } + }; + Chosen.prototype.search_field_scale = function() { + var dd_top, div, h, style, style_block, styles, w, _i, _len; + if (this.is_multiple) { + h = 0; + w = 0; + style_block = "position:absolute; left: -1000px; top: -1000px; display:none;"; + styles = ['font-size', 'font-style', 'font-weight', 'font-family', 'line-height', 'text-transform', 'letter-spacing']; + for (_i = 0, _len = styles.length; _i < _len; _i++) { + style = styles[_i]; + style_block += style + ":" + this.search_field.getStyle(style) + ";"; + } + div = new Element('div', { + 'style': style_block + }).update(this.search_field.value.escapeHTML()); + document.body.appendChild(div); + w = Element.measure(div, 'width') + 25; + div.remove(); + if (w > this.f_width - 10) { + w = this.f_width - 10; + } + this.search_field.setStyle({ + 'width': w + 'px' + }); + dd_top = this.container.getHeight(); + return this.dropdown.setStyle({ + "top": dd_top + "px" + }); + } + }; + return Chosen; + })(); + root.Chosen = Chosen; + document.observe('dom:loaded', function(evt) { + var select, selects, _i, _len, _results; + selects = $$(".chzn-select"); + _results = []; + for (_i = 0, _len = selects.length; _i < _len; _i++) { + select = selects[_i]; + _results.push(new Chosen(select)); + } + return _results; + }); + get_side_border_padding = function(elmt) { + var layout, side_border_padding; + layout = new Element.Layout(elmt); + return side_border_padding = layout.get("border-left") + layout.get("border-right") + layout.get("padding-left") + layout.get("padding-right"); + }; + root.get_side_border_padding = get_side_border_padding; +}).call(this); +(function() { + var SelectParser; + SelectParser = (function() { + function SelectParser() { + this.options_index = 0; + this.parsed = []; + } + SelectParser.prototype.add_node = function(child) { + if (child.nodeName === "OPTGROUP") { + return this.add_group(child); + } else { + return this.add_option(child); + } + }; + SelectParser.prototype.add_group = function(group) { + var group_position, option, _i, _len, _ref, _results; + group_position = this.parsed.length; + this.parsed.push({ + array_index: group_position, + group: true, + label: group.label, + children: 0, + disabled: group.disabled + }); + _ref = group.childNodes; + _results = []; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + option = _ref[_i]; + _results.push(this.add_option(option, group_position, group.disabled)); + } + return _results; + }; + SelectParser.prototype.add_option = function(option, group_position, group_disabled) { + if (option.nodeName === "OPTION") { + if (option.text !== "") { + if (group_position != null) { + this.parsed[group_position].children += 1; + } + this.parsed.push({ + array_index: this.parsed.length, + options_index: this.options_index, + value: option.value, + text: option.text, + html: option.innerHTML, + selected: option.selected, + disabled: group_disabled === true ? group_disabled : option.disabled, + group_array_index: group_position + }); + } else { + this.parsed.push({ + array_index: this.parsed.length, + options_index: this.options_index, + empty: true + }); + } + return this.options_index += 1; + } + }; + return SelectParser; + })(); + SelectParser.select_to_array = function(select) { + var child, parser, _i, _len, _ref; + parser = new SelectParser(); + _ref = select.childNodes; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + child = _ref[_i]; + parser.add_node(child); + } + return parser.parsed; + }; + this.SelectParser = SelectParser; +}).call(this); diff --git a/3rdparty/js/chosen/chosen.proto.min.js b/3rdparty/js/chosen/chosen.proto.min.js new file mode 100644 index 0000000000..c197c4d863 --- /dev/null +++ b/3rdparty/js/chosen/chosen.proto.min.js @@ -0,0 +1,10 @@ +// Chosen, a Select Box Enhancer for jQuery and Protoype +// by Patrick Filler for Harvest, http://getharvest.com +// +// Version 0.9 +// Full source at https://github.com/harvesthq/chosen +// Copyright (c) 2011 Harvest http://getharvest.com + +// MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md +// This file is generated by `cake build`, do not edit it by hand. +(function(){var a,b,c,d=function(a,b){return function(){return a.apply(b,arguments)}};c=this,a=function(){function a(a){this.set_default_values(),this.form_field=a,this.is_multiple=this.form_field.multiple,this.is_rtl=this.form_field.hasClassName("chzn-rtl"),this.default_text_default=this.form_field.multiple?"Select Some Options":"Select an Option",this.set_up_html(),this.register_observers()}a.prototype.set_default_values=function(){this.click_test_action=d(function(a){return this.test_active_click(a)},this),this.active_field=!1,this.mouse_on_container=!1,this.results_showing=!1,this.result_highlighted=null,this.result_single_selected=null,this.choices=0,this.single_temp=new Template('#{default}
                    '),this.multi_temp=new Template('
                      '),this.choice_temp=new Template('
                    • #{choice}
                    • ');return this.no_results_temp=new Template('
                    • No results match "#{terms}"
                    • ')},a.prototype.set_up_html=function(){var a,c,d,e,f;this.container_id=this.form_field.identify().replace(/(:|\.)/g,"_")+"_chzn",this.f_width=this.form_field.getStyle("width")?parseInt(this.form_field.getStyle("width"),10):this.form_field.getWidth(),c={id:this.container_id,"class":"chzn-container "+(this.is_rtl?" chzn-rtl":void 0),style:"width: "+this.f_width+"px"},this.default_text=this.form_field.readAttribute("data-placeholder")?this.form_field.readAttribute("data-placeholder"):this.default_text_default,a=this.is_multiple?(new Element("div",c)).update(this.multi_temp.evaluate({"default":this.default_text})):(new Element("div",c)).update(this.single_temp.evaluate({"default":this.default_text})),this.form_field.hide().insert({after:a}),this.container=$(this.container_id),this.container.addClassName("chzn-container-"+(this.is_multiple?"multi":"single")),this.dropdown=this.container.down("div.chzn-drop"),d=this.container.getHeight(),e=this.f_width-b(this.dropdown),this.dropdown.setStyle({width:e+"px",top:d+"px"}),this.search_field=this.container.down("input"),this.search_results=this.container.down("ul.chzn-results"),this.search_field_scale(),this.search_no_results=this.container.down("li.no-results"),this.is_multiple?(this.search_choices=this.container.down("ul.chzn-choices"),this.search_container=this.container.down("li.search-field")):(this.search_container=this.container.down("div.chzn-search"),this.selected_item=this.container.down(".chzn-single"),f=e-b(this.search_container)-b(this.search_field),this.search_field.setStyle({width:f+"px"})),this.results_build();return this.set_tab_index()},a.prototype.register_observers=function(){this.container.observe("click",d(function(a){return this.container_click(a)},this)),this.container.observe("mouseenter",d(function(a){return this.mouse_enter(a)},this)),this.container.observe("mouseleave",d(function(a){return this.mouse_leave(a)},this)),this.search_results.observe("click",d(function(a){return this.search_results_click(a)},this)),this.search_results.observe("mouseover",d(function(a){return this.search_results_mouseover(a)},this)),this.search_results.observe("mouseout",d(function(a){return this.search_results_mouseout(a)},this)),this.form_field.observe("liszt:updated",d(function(a){return this.results_update_field(a)},this)),this.search_field.observe("blur",d(function(a){return this.input_blur(a)},this)),this.search_field.observe("keyup",d(function(a){return this.keyup_checker(a)},this)),this.search_field.observe("keydown",d(function(a){return this.keydown_checker(a)},this));if(this.is_multiple){this.search_choices.observe("click",d(function(a){return this.choices_click(a)},this));return this.search_field.observe("focus",d(function(a){return this.input_focus(a)},this))}return this.selected_item.observe("focus",d(function(a){return this.activate_field(a)},this))},a.prototype.container_click=function(a){a&&a.type==="click"&&a.stop();if(!this.pending_destroy_click){this.active_field?!this.is_multiple&&a&&(a.target===this.selected_item||a.target.up("a.chzn-single"))&&this.results_toggle():(this.is_multiple&&this.search_field.clear(),document.observe("click",this.click_test_action),this.results_show());return this.activate_field()}return this.pending_destroy_click=!1},a.prototype.mouse_enter=function(){return this.mouse_on_container=!0},a.prototype.mouse_leave=function(){return this.mouse_on_container=!1},a.prototype.input_focus=function(a){if(!this.active_field)return setTimeout(this.container_click.bind(this),50)},a.prototype.input_blur=function(a){if(!this.mouse_on_container){this.active_field=!1;return setTimeout(this.blur_test.bind(this),100)}},a.prototype.blur_test=function(a){if(!this.active_field&&this.container.hasClassName("chzn-container-active"))return this.close_field()},a.prototype.close_field=function(){document.stopObserving("click",this.click_test_action),this.is_multiple||(this.selected_item.tabIndex=this.search_field.tabIndex,this.search_field.tabIndex=-1),this.active_field=!1,this.results_hide(),this.container.removeClassName("chzn-container-active"),this.winnow_results_clear(),this.clear_backstroke(),this.show_search_field_default();return this.search_field_scale()},a.prototype.activate_field=function(){!this.is_multiple&&!this.active_field&&(this.search_field.tabIndex=this.selected_item.tabIndex,this.selected_item.tabIndex=-1),this.container.addClassName("chzn-container-active"),this.active_field=!0,this.search_field.value=this.search_field.value;return this.search_field.focus()},a.prototype.test_active_click=function(a){return a.target.up("#"+this.container_id)?this.active_field=!0:this.close_field()},a.prototype.results_build=function(){var a,b,d,e,f,g;d=new Date,this.parsing=!0,this.results_data=c.SelectParser.select_to_array(this.form_field),this.is_multiple&&this.choices>0?(this.search_choices.select("li.search-choice").invoke("remove"),this.choices=0):this.is_multiple||this.selected_item.down("span").update(this.default_text),a="",g=this.results_data;for(e=0,f=g.length;e'+a.label.escapeHTML()+""}return""},a.prototype.result_add_option=function(a){var b;if(!a.disabled){a.dom_id=this.container_id+"_o_"+a.array_index,b=a.selected&&this.is_multiple?[]:["active-result"],a.selected&&b.push("result-selected"),a.group_array_index!=null&&b.push("group-option");return'
                    • '+a.html+"
                    • "}return""},a.prototype.results_update_field=function(){this.result_clear_highlight(),this.result_single_selected=null;return this.results_build()},a.prototype.result_do_highlight=function(a){var b,c,d,e,f;this.result_clear_highlight(),this.result_highlight=a,this.result_highlight.addClassName("highlighted"),d=parseInt(this.search_results.getStyle("maxHeight"),10),f=this.search_results.scrollTop,e=d+f,c=this.result_highlight.positionedOffset().top,b=c+this.result_highlight.getHeight();if(b>=e)return this.search_results.scrollTop=b-d>0?b-d:0;if(c0&&this.search_field.value.length<1&&this.results_hide(),this.result_deselect(a.readAttribute("rel"));return a.up("li").remove()},a.prototype.result_select=function(){var a,b,c;if(this.result_highlight){a=this.result_highlight,this.result_clear_highlight(),a.addClassName("result-selected"),this.is_multiple?this.result_deactivate(a):this.result_single_selected=a,c=a.id.substr(a.id.lastIndexOf("_")+1),b=this.results_data[c],b.selected=!0,this.form_field.options[b.options_index].selected=!0,this.is_multiple?this.choice_build(b):this.selected_item.down("span").update(b.html),this.results_hide(),this.search_field.value="",typeof Event.simulate=="function"&&this.form_field.simulate("change");return this.search_field_scale()}},a.prototype.result_activate=function(a){return a.addClassName("active-result").show()},a.prototype.result_deactivate=function(a){return a.removeClassName("active-result").hide()},a.prototype.result_deselect=function(a){var b,c;c=this.results_data[a],c.selected=!1,this.form_field.options[c.options_index].selected=!1,b=$(this.container_id+"_o_"+a),b.removeClassName("result-selected").addClassName("active-result").show(),this.result_clear_highlight(),this.winnow_results(),typeof Event.simulate=="function"&&this.form_field.simulate("change");return this.search_field_scale()},a.prototype.results_search=function(a){return this.results_showing?this.winnow_results():this.results_show()},a.prototype.winnow_results=function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q;i=new Date,this.no_results_clear(),g=0,h=this.search_field.value===this.default_text?"":this.search_field.value.strip().escapeHTML(),e=new RegExp("^"+h.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"i"),l=new RegExp(h.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"i"),q=this.results_data;for(m=0,o=q.length;m=0||b.html.indexOf("[")===0){d=b.html.replace(/\[|\]/g,"").split(" ");if(d.length)for(n=0,p=d.length;n"+b.html.substr(j+h.length),k=k.substr(0,j)+""+k.substr(j)):k=b.html,$(f).innerHTML!==k&&$(f).update(k),this.result_activate($(f)),b.group_array_index!=null&&$(this.results_data[b.group_array_index].dom_id).show()):($(f)===this.result_highlight&&this.result_clear_highlight(),this.result_deactivate($(f)))}}return g<1&&h.length?this.no_results(h):this.winnow_results_set_highlight()},a.prototype.winnow_results_clear=function(){var a,b,c,d,e;this.search_field.clear(),b=this.search_results.select("li"),e=[];for(c=0,d=b.length;c0&&this.results_hide();return this.result_clear_highlight()}},a.prototype.keydown_backstroke=function(){if(this.pending_backstroke){this.choice_destroy(this.pending_backstroke.down("a"));return this.clear_backstroke()}this.pending_backstroke=this.search_container.siblings("li.search-choice").last();return this.pending_backstroke.addClassName("search-choice-focus")},a.prototype.clear_backstroke=function(){this.pending_backstroke&&this.pending_backstroke.removeClassName("search-choice-focus");return this.pending_backstroke=null},a.prototype.keyup_checker=function(a){var b,c;b=(c=a.which)!=null?c:a.keyCode,this.search_field_scale();switch(b){case 8:if(this.is_multiple&&this.backstroke_length<1&&this.choices>0)return this.keydown_backstroke();if(!this.pending_backstroke){this.result_clear_highlight();return this.results_search()}break;case 13:a.preventDefault();if(this.results_showing)return this.result_select();break;case 27:if(this.results_showing)return this.results_hide();break;case 9:case 38:case 40:case 16:break;default:return this.results_search()}},a.prototype.keydown_checker=function(a){var b,c;b=(c=a.which)!=null?c:a.keyCode,this.search_field_scale(),b!==8&&this.pending_backstroke&&this.clear_backstroke();switch(b){case 8:return this.backstroke_length=this.search_field.value.length;case 9:return this.mouse_on_container=!1;case 13:return a.preventDefault();case 38:a.preventDefault();return this.keyup_arrow();case 40:return this.keydown_arrow()}},a.prototype.search_field_scale=function(){var a,b,c,d,e,f,g,h,i;if(this.is_multiple){c=0,g=0,e="position:absolute; left: -1000px; top: -1000px; display:none;",f=["font-size","font-style","font-weight","font-family","line-height","text-transform","letter-spacing"];for(h=0,i=f.length;hthis.f_width-10&&(g=this.f_width-10),this.search_field.setStyle({width:g+"px"}),a=this.container.getHeight();return this.dropdown.setStyle({top:a+"px"})}};return a}(),c.Chosen=a,document.observe("dom:loaded",function(b){var c,d,e,f,g;d=$$(".chzn-select"),g=[];for(e=0,f=d.length;eimg,td.select>input{display:none;cursor:pointer} +td.select,td.remove{width:1em} +tr:hover>td.remove>img{display:inline} +li.selected{background-color:#ddd} diff --git a/admin/js/users.js b/admin/js/users.js index 5a99362726..7e643fb60a 100644 --- a/admin/js/users.js +++ b/admin/js/users.js @@ -1,340 +1,100 @@ $(document).ready(function(){ - // Vars we need - var uid = ""; - var gid = ""; - var togglepassword = ""; - var togglegroup = ""; - - //######################################################################### - // Stuff I don't understand - //######################################################################### - - function doToggleGroup( group ){ - $("#changegroupgid").val(group); - - // Serialize the data - var post = $( "#changegroupsform" ).serialize(); - // Ajax foo - $.post( 'ajax/togglegroups.php', post, function(data){ - if( data.status == "success" ){ - var groups = []; - $("input[x-use='togglegroup']").each( function(index){ - if( $(this).attr("checked")){ - groups.push($(this).val()); - } - }); - if( groups.length == 0 ){ - $("#changegroups").prev().html( ' ' ); - } - else{ - $("#changegroups").prev().html( groups.join(", ")); - } + $('select[multiple]').chosen(); + + $('td.remove>img').live('click',function(event){ + var uid=$(this).parent().parent().data('uid'); + $.post( + OC.filePath('admin','ajax','removeuser.php'), + {username:uid}, + function(result){ + } - else{ - printError( data.data.message ); - } - }); - return false; - } - - function printError( message ){ - $("#errormessage").text( message ); - $("#errordialog").dialog( "open" ); - return false; - } - - //######################################################################### - // Functions for editing the dom after user manipulation - //######################################################################### - - // Manipulating the page after crteating a user - function userCreated( username, groups ){ - // We need at least a space for showing the div - if( groups == "" ){ - groups = ' '; - } - - // Add user to table - var newrow = '
                      '+username+'
                      '; - newrow = newrow+'
                      '+groups+''; - newrow = newrow+''; - $("#usertable").append( newrow ); - - // Clear forms - $("input[x-use='createuserfield']").val( "" ); - $("input[x-use='createusercheckbox']").attr( "checked", false ); - } - - function userRemoved( username ){ - $( "tr[x-uid='"+username+"']" ).remove(); - } - - function groupCreated( groupname ){ - var newrow = '' + groupname + ''; - newrow = newrow + ''; - $("#grouptable").append( newrow ); - - // Delete form content - $("input[x-use='creategroupfield']").val( "" ); - - // Add group option to Create User and Edit User - var createuser = ' '+groupname+'
                      '; - $("#createusergroups").append( createuser ); - var changeuser = ' '+groupname+'
                      '; - $("#changegroupsform").append( changeuser ); - } - - function groupRemoved( groupname ){ - // Delete the options - $( "tr[x-gid='"+groupname+"']" ).remove(); - $( "span[x-gid='"+groupname+"']" ).remove(); - $( "input[x-gid='"+groupname+"']" ).remove(); - - // remove it from user list - $( "div[x-use='usergroupsdiv']" ).each(function(index){ - var content = $(this).text(); - var list = content.split( ", " ); - var newlist = []; - for( var i = 0; i < list.length; i++ ){ - var temp = list[i]; - if( temp != groupname ){ - newlist.push( temp ); - } - } - var newstring = newlist.join( ", " ); - $(this).html( newstring ) - }); - - } - - //######################################################################### - // Editing the users properties by clicking the cell - //######################################################################### - - // Password (clicking on user name) - $("span[x-use='usernamediv']").live( "click", function(){ - if( togglepassword == "" || $(this).parent().parent().attr("x-uid") != togglepassword ){ - togglepassword = $(this).parent().parent().attr("x-uid"); - // Set the username! - $("#changepassworduid").val(togglepassword); - $("#changepasswordpwd").val(""); - $(this).parent().append( $('#changepassword') ); - $('#changepassword').show(); - } - else{ - $('#changepassword').hide(); - togglepassword = ""; - } + ); + $(this).parent().parent().remove(); }); - - $("#changepasswordbutton").click( function(){ - // Serialize the data - var post = $( "#changepasswordform" ).serialize(); - // Ajax foo - $.post( 'ajax/changepassword.php', post, function(data){ - if( data.status == "success" ){ - togglepassword = ""; - $('#changepassword').hide(); - } - else{ - printError( data.data.message ); - } - }); - return false; - }); - - // Groups - $("div[x-use='usergroupsdiv']").live( "click", function(){ - if( togglegroup == "" || $(this).parent().parent().attr("x-uid") != togglegroup){ - togglegroup = $(this).parent().parent().attr("x-uid"); - var groups = $(this).text(); - groups = groups.split(", "); - $("input[x-use='togglegroup']").each( function(index){ - var check = false; - // Group checked? - for( var i = 0; i < groups.length; i++ ){ - if( $(this).val() == groups[i] ){ - check = true; - } - } - - // Check/uncheck - if( check ){ - $(this).attr("checked","checked"); - } - else{ - $(this).removeAttr("checked"); - } - }); - $("#changegroupuid").val(togglegroup); - $(this).empty(); - $(this).parent().append( $('#changegroups') ); - $('#changegroups').show(); - } - else{ - var groups = []; - $("input[x-use='togglegroup']").each( function(index){ - if( $(this).attr("checked")){ - groups.push($(this).val()); - } - }); - if( groups.length == 0 ){ - $("#changegroups").prev().html( ' ' ); - } - else{ - $("#changegroups").prev().html( groups.join(", ")); - } - $('#changegroups').hide(); - togglegroup = ""; - } - }); - - $("span[x-use='togglegroup']").live( "click", function(){ - if( $(this).prev().attr("checked")){ - $(this).prev().removeAttr("checked") - } - else{ - $(this).prev().attr("checked","checked") - } - doToggleGroup( $(this).attr("x-gid")); - }); - - $("input[x-use='togglegroup']").live( "click", function(){ - doToggleGroup( $(this).attr("x-gid")); - }); - //######################################################################### - // Clicking on buttons - //######################################################################### - - - // Create a new user - $( "#createuserbutton" ) - .click(function(){ - if(!$( "#createuserbutton" ).data('active')){ - $( "#createuserbutton" ).data('active',true); + + $('#newuser').submit(function(event){ + event.preventDefault(); + var username=$('#newusername').val(); + var password=$('#newuserpassword').val(); + var groups=$('#newusergroups').val(); + $.post( + OC.filePath('admin','ajax','createuser.php'), + { + username:username, + password:password, + groups:groups, + }, + function(result){ - // Create the post data - var post = $( "#createuserdata" ).serialize(); - - // Ajax call - $.post( 'ajax/createuser.php', post, function(data){ - $( "#createuserbutton" ).data('active',false); + } + ); + var tr=$('#rightcontent tr').first().clone(); + tr.attr('data-uid',username); + tr.find('td.name').text(username); + tr.find('td.groups').text(groups.join(', ')); + $('#rightcontent tr').first().after(tr); + if(groups.indexOf($('#leftcontent li.selected').text().trim())!=-1){ + tr.find('td.select input').attr('checked','checked'); + } + }); + + $('#newgroup').submit(function(event){ + event.preventDefault(); + var name=$('#newgroupname').val(); + $.post( + OC.filePath('admin','ajax','creategroup.php'), + {groupname:name}, + function(result){ + + } + ); + $('#newusergroups').append(''); + $('select[multiple]').trigger("liszt:updated"); + var li=$('#leftcontent li').first().next().clone(); + li.text(name); + $('#leftcontent li').first().after(li); + }); + + $('#leftcontent li').live('click',function(event){ + $('#leftcontent li').removeClass('selected'); + $(this).addClass('selected'); + $('#rightcontent tr td.select input').show(); + $('#rightcontent tr td.select input').removeAttr('checked'); + var group=$(this).text().trim(); + var rows=$('#rightcontent tr').filter(function(i,tr){ + return ($(tr).children('td.groups').text().split(', ').indexOf(group)>-1); + }); + rows.find('td.select input').attr('checked','checked'); + }); + $('#rightcontent tr td.select input').live('change',function(event){ + var group=$('#leftcontent li.selected').text().trim(); + var user=$(this).parent().parent().children('td.name').text().trim(); + if(group=='admin' && user==OC.currentUser){ + event.preventDefault(); + $(this).attr('checked','checked'); + return false; + } + if(group){ + $.post( + OC.filePath('admin','ajax','togglegroups.php'), + { + username:user, + group:group + }, + function(result){ - // If it says "success" then we are happy - if( data.status == "success" ){ - userCreated( data.data.username, data.data.groups ); - } - else{ - printError( data.data.message ); - } - }); - } - return false; - }); - - $( ".removeuserbutton" ).live( 'click', function() { - uid = $( this ).parent().parent().attr( 'x-uid' ); - $("#deleteuserusername").html(uid); - $("#deleteusernamefield").val(uid); - $("#removeuserform").dialog( "open" ); - return false; - }); - - $( "#creategroupbutton" ) - .click(function(){ - // Serialize the data - var post = $( "#creategroupdata" ).serialize(); - // Ajax foo - $.post( 'ajax/creategroup.php', post, function(data){ - if( data.status == "success" ){ - groupCreated( data.data.groupname ); } - else{ - printError( data.data.message ); - } - }); - return false; - }); - - $( ".removegroupbutton" ).live( 'click', function(){ - gid = $( this ).parent().parent().attr( 'x-gid' ); - $("#removegroupgroupname").html(gid); - $("#removegroupnamefield").val(gid); - $("#removegroupform").dialog( "open" ); - return false; - }); - - //######################################################################### - // Dialogs - //######################################################################### - - // Removing users - $( "#errordialog" ).dialog({ - autoOpen: false, - modal: true, - buttons: { - OK: function() { - $( this ).dialog( "close" ); + ); + var groups=$(this).parent().parent().children('td.groups').text().trim().split(', '); + if(groups[0]=='') groups.pop(); + var index=groups.indexOf(group); + if(index==-1){ + groups.push(group); + }else{ + groups.splice(index,1); } + $(this).parent().parent().children('td.groups').text(groups.join(', ')); } }); - - // Removing users - $( "#removeuserform" ).dialog({ - autoOpen: false, - height: 300, - width: 350, - modal: true, - buttons: { - "Remove user": function() { - var post = $( "#removeuserdata" ).serialize(); - $.post( 'ajax/removeuser.php', post, function(data){ - if( data.status == "success" ){ - userRemoved( uid ); - } - else{ - printError( data.data.message ); - } - }); - $( this ).dialog( "close" ); - }, - Cancel: function() { - $( this ).dialog( "close" ); - } - }, - close: function() { - true; - } - }); - - - // Dialog for adding users - $( "#removegroupform" ).dialog({ - autoOpen: false, - height: 300, - width: 350, - modal: true, - buttons: { - "Remove group": function(){ - var post = $( "#removegroupdata" ).serialize(); - $.post( 'ajax/removegroup.php', post, function(data){ - if( data.status == "success" ){ - groupRemoved( gid ); - } - else{ - printError( data.data.message ); - } - }); - $( this ).dialog( "close" ); - }, - Cancel: function() { - $( this ).dialog( "close" ); - } - }, - close: function(){ - true; - } - }); - -} ); - +}); diff --git a/admin/templates/users.php b/admin/templates/users.php index fbb0fe79f3..8e34c908fc 100644 --- a/admin/templates/users.php +++ b/admin/templates/users.php @@ -1,107 +1,39 @@ -
                      - t( 'Users' ); ?> - - - - - - - - - - - - - - - - - - "> - - - - - - -
                      t( 'Name' ); ?>t( 'Groups' ); ?>
                      - - - - - " type="checkbox" name="groups[]" value="" /> - "> - - - -
                      - - - -
                      -
                      - -
                      - t( 'Groups' ); ?> - - - - - - - - +
                      +
                      + + + +
                      + + +
                      "> - - - - - -
                      - - - -   - -
                      -
                      - - -
                      +
                        + +
                      • "> + +
                      • + +
                      +
                      + + + "> + + + + + - - - - - -
                      -
                      - t( 'Do you really want to delete user' ); ?> $user? - - -
                      - -
                      -
                      - t( 'Do you really want to delete group' ); ?> $group? - - -
                      - -
                      - +
                      + + Remove'/> + +
                      diff --git a/admin/users.php b/admin/users.php index 30b9fa46d3..4a83510cb7 100644 --- a/admin/users.php +++ b/admin/users.php @@ -28,8 +28,11 @@ if( !OC_User::isLoggedIn() || !OC_Group::inGroup( OC_User::getUser(), 'admin' )) } // We have some javascript foo! -OC_Util::addScript( "admin", "users" ); -OC_App::setActiveNavigationEntry( "core_users" ); +OC_Util::addScript( 'admin', 'users' ); +OC_Util::addStyle( 'admin', 'users' ); +OC_Util::addScript( '3rdparty', 'chosen/chosen.jquery.min' ); +OC_Util::addStyle( '3rdparty', 'chosen' ); +OC_App::setActiveNavigationEntry( 'core_users' ); $users = array(); $groups = array(); diff --git a/core/js/js.js b/core/js/js.js index 6ad999878c..952c1b86ea 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -27,7 +27,8 @@ t.cache={}; OC={ webroot:oc_webroot, - coreApps:['files','admin','log','search','settings','core'], + currentUser:oc_current_user, + coreApps:['files','admin','log','search','settings','core','3rdparty'], /** * get an absolute url to a file in an appen * @param app the id of the app the file belongs to From 1419d7f2b02a2182eb746443b62572f1b4b3f655 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Tue, 9 Aug 2011 16:31:16 +0200 Subject: [PATCH 32/32] remove prototype versions of chosen --- 3rdparty/js/chosen/chosen.proto.js | 774 ------------------------- 3rdparty/js/chosen/chosen.proto.min.js | 10 - 2 files changed, 784 deletions(-) delete mode 100644 3rdparty/js/chosen/chosen.proto.js delete mode 100644 3rdparty/js/chosen/chosen.proto.min.js diff --git a/3rdparty/js/chosen/chosen.proto.js b/3rdparty/js/chosen/chosen.proto.js deleted file mode 100644 index 5e269fe003..0000000000 --- a/3rdparty/js/chosen/chosen.proto.js +++ /dev/null @@ -1,774 +0,0 @@ -// Chosen, a Select Box Enhancer for jQuery and Protoype -// by Patrick Filler for Harvest, http://getharvest.com -// -// Version 0.9 -// Full source at https://github.com/harvesthq/chosen -// Copyright (c) 2011 Harvest http://getharvest.com - -// MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md -// This file is generated by `cake build`, do not edit it by hand. -(function() { - /* - Chosen source: generate output using 'cake build' - Copyright (c) 2011 by Harvest - */ var Chosen, get_side_border_padding, root; - var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; - root = this; - Chosen = (function() { - function Chosen(elmn) { - this.set_default_values(); - this.form_field = elmn; - this.is_multiple = this.form_field.multiple; - this.is_rtl = this.form_field.hasClassName("chzn-rtl"); - this.default_text_default = this.form_field.multiple ? "Select Some Options" : "Select an Option"; - this.set_up_html(); - this.register_observers(); - } - Chosen.prototype.set_default_values = function() { - this.click_test_action = __bind(function(evt) { - return this.test_active_click(evt); - }, this); - this.active_field = false; - this.mouse_on_container = false; - this.results_showing = false; - this.result_highlighted = null; - this.result_single_selected = null; - this.choices = 0; - this.single_temp = new Template('#{default}
                        '); - this.multi_temp = new Template('
                          '); - this.choice_temp = new Template('
                        • #{choice}
                        • '); - return this.no_results_temp = new Template('
                        • No results match "#{terms}"
                        • '); - }; - Chosen.prototype.set_up_html = function() { - var base_template, container_props, dd_top, dd_width, sf_width; - this.container_id = this.form_field.identify().replace(/(:|\.)/g, '_') + "_chzn"; - this.f_width = this.form_field.getStyle("width") ? parseInt(this.form_field.getStyle("width"), 10) : this.form_field.getWidth(); - container_props = { - 'id': this.container_id, - 'class': "chzn-container " + (this.is_rtl ? ' chzn-rtl' : void 0), - 'style': 'width: ' + this.f_width + 'px' - }; - this.default_text = this.form_field.readAttribute('data-placeholder') ? this.form_field.readAttribute('data-placeholder') : this.default_text_default; - base_template = this.is_multiple ? new Element('div', container_props).update(this.multi_temp.evaluate({ - "default": this.default_text - })) : new Element('div', container_props).update(this.single_temp.evaluate({ - "default": this.default_text - })); - this.form_field.hide().insert({ - after: base_template - }); - this.container = $(this.container_id); - this.container.addClassName("chzn-container-" + (this.is_multiple ? "multi" : "single")); - this.dropdown = this.container.down('div.chzn-drop'); - dd_top = this.container.getHeight(); - dd_width = this.f_width - get_side_border_padding(this.dropdown); - this.dropdown.setStyle({ - "width": dd_width + "px", - "top": dd_top + "px" - }); - this.search_field = this.container.down('input'); - this.search_results = this.container.down('ul.chzn-results'); - this.search_field_scale(); - this.search_no_results = this.container.down('li.no-results'); - if (this.is_multiple) { - this.search_choices = this.container.down('ul.chzn-choices'); - this.search_container = this.container.down('li.search-field'); - } else { - this.search_container = this.container.down('div.chzn-search'); - this.selected_item = this.container.down('.chzn-single'); - sf_width = dd_width - get_side_border_padding(this.search_container) - get_side_border_padding(this.search_field); - this.search_field.setStyle({ - "width": sf_width + "px" - }); - } - this.results_build(); - return this.set_tab_index(); - }; - Chosen.prototype.register_observers = function() { - this.container.observe("click", __bind(function(evt) { - return this.container_click(evt); - }, this)); - this.container.observe("mouseenter", __bind(function(evt) { - return this.mouse_enter(evt); - }, this)); - this.container.observe("mouseleave", __bind(function(evt) { - return this.mouse_leave(evt); - }, this)); - this.search_results.observe("click", __bind(function(evt) { - return this.search_results_click(evt); - }, this)); - this.search_results.observe("mouseover", __bind(function(evt) { - return this.search_results_mouseover(evt); - }, this)); - this.search_results.observe("mouseout", __bind(function(evt) { - return this.search_results_mouseout(evt); - }, this)); - this.form_field.observe("liszt:updated", __bind(function(evt) { - return this.results_update_field(evt); - }, this)); - this.search_field.observe("blur", __bind(function(evt) { - return this.input_blur(evt); - }, this)); - this.search_field.observe("keyup", __bind(function(evt) { - return this.keyup_checker(evt); - }, this)); - this.search_field.observe("keydown", __bind(function(evt) { - return this.keydown_checker(evt); - }, this)); - if (this.is_multiple) { - this.search_choices.observe("click", __bind(function(evt) { - return this.choices_click(evt); - }, this)); - return this.search_field.observe("focus", __bind(function(evt) { - return this.input_focus(evt); - }, this)); - } else { - return this.selected_item.observe("focus", __bind(function(evt) { - return this.activate_field(evt); - }, this)); - } - }; - Chosen.prototype.container_click = function(evt) { - if (evt && evt.type === "click") { - evt.stop(); - } - if (!this.pending_destroy_click) { - if (!this.active_field) { - if (this.is_multiple) { - this.search_field.clear(); - } - document.observe("click", this.click_test_action); - this.results_show(); - } else if (!this.is_multiple && evt && (evt.target === this.selected_item || evt.target.up("a.chzn-single"))) { - this.results_toggle(); - } - return this.activate_field(); - } else { - return this.pending_destroy_click = false; - } - }; - Chosen.prototype.mouse_enter = function() { - return this.mouse_on_container = true; - }; - Chosen.prototype.mouse_leave = function() { - return this.mouse_on_container = false; - }; - Chosen.prototype.input_focus = function(evt) { - if (!this.active_field) { - return setTimeout(this.container_click.bind(this), 50); - } - }; - Chosen.prototype.input_blur = function(evt) { - if (!this.mouse_on_container) { - this.active_field = false; - return setTimeout(this.blur_test.bind(this), 100); - } - }; - Chosen.prototype.blur_test = function(evt) { - if (!this.active_field && this.container.hasClassName("chzn-container-active")) { - return this.close_field(); - } - }; - Chosen.prototype.close_field = function() { - document.stopObserving("click", this.click_test_action); - if (!this.is_multiple) { - this.selected_item.tabIndex = this.search_field.tabIndex; - this.search_field.tabIndex = -1; - } - this.active_field = false; - this.results_hide(); - this.container.removeClassName("chzn-container-active"); - this.winnow_results_clear(); - this.clear_backstroke(); - this.show_search_field_default(); - return this.search_field_scale(); - }; - Chosen.prototype.activate_field = function() { - if (!this.is_multiple && !this.active_field) { - this.search_field.tabIndex = this.selected_item.tabIndex; - this.selected_item.tabIndex = -1; - } - this.container.addClassName("chzn-container-active"); - this.active_field = true; - this.search_field.value = this.search_field.value; - return this.search_field.focus(); - }; - Chosen.prototype.test_active_click = function(evt) { - if (evt.target.up('#' + this.container_id)) { - return this.active_field = true; - } else { - return this.close_field(); - } - }; - Chosen.prototype.results_build = function() { - var content, data, startTime, _i, _len, _ref; - startTime = new Date(); - this.parsing = true; - this.results_data = root.SelectParser.select_to_array(this.form_field); - if (this.is_multiple && this.choices > 0) { - this.search_choices.select("li.search-choice").invoke("remove"); - this.choices = 0; - } else if (!this.is_multiple) { - this.selected_item.down("span").update(this.default_text); - } - content = ''; - _ref = this.results_data; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - data = _ref[_i]; - if (data.group) { - content += this.result_add_group(data); - } else if (!data.empty) { - content += this.result_add_option(data); - if (data.selected && this.is_multiple) { - this.choice_build(data); - } else if (data.selected && !this.is_multiple) { - this.selected_item.down("span").update(data.html); - } - } - } - this.show_search_field_default(); - this.search_field_scale(); - this.search_results.update(content); - return this.parsing = false; - }; - Chosen.prototype.result_add_group = function(group) { - if (!group.disabled) { - group.dom_id = this.container_id + "_g_" + group.array_index; - return '
                        • ' + group.label.escapeHTML() + '
                        • '; - } else { - return ""; - } - }; - Chosen.prototype.result_add_option = function(option) { - var classes; - if (!option.disabled) { - option.dom_id = this.container_id + "_o_" + option.array_index; - classes = option.selected && this.is_multiple ? [] : ["active-result"]; - if (option.selected) { - classes.push("result-selected"); - } - if (option.group_array_index != null) { - classes.push("group-option"); - } - return '
                        • ' + option.html + '
                        • '; - } else { - return ""; - } - }; - Chosen.prototype.results_update_field = function() { - this.result_clear_highlight(); - this.result_single_selected = null; - return this.results_build(); - }; - Chosen.prototype.result_do_highlight = function(el) { - var high_bottom, high_top, maxHeight, visible_bottom, visible_top; - this.result_clear_highlight(); - this.result_highlight = el; - this.result_highlight.addClassName("highlighted"); - maxHeight = parseInt(this.search_results.getStyle('maxHeight'), 10); - visible_top = this.search_results.scrollTop; - visible_bottom = maxHeight + visible_top; - high_top = this.result_highlight.positionedOffset().top; - high_bottom = high_top + this.result_highlight.getHeight(); - if (high_bottom >= visible_bottom) { - return this.search_results.scrollTop = (high_bottom - maxHeight) > 0 ? high_bottom - maxHeight : 0; - } else if (high_top < visible_top) { - return this.search_results.scrollTop = high_top; - } - }; - Chosen.prototype.result_clear_highlight = function() { - if (this.result_highlight) { - this.result_highlight.removeClassName('highlighted'); - } - return this.result_highlight = null; - }; - Chosen.prototype.results_toggle = function() { - if (this.results_showing) { - return this.results_hide(); - } else { - return this.results_show(); - } - }; - Chosen.prototype.results_show = function() { - var dd_top; - if (!this.is_multiple) { - this.selected_item.addClassName('chzn-single-with-drop'); - if (this.result_single_selected) { - this.result_do_highlight(this.result_single_selected); - } - } - dd_top = this.is_multiple ? this.container.getHeight() : this.container.getHeight() - 1; - this.dropdown.setStyle({ - "top": dd_top + "px", - "left": 0 - }); - this.results_showing = true; - this.search_field.focus(); - this.search_field.value = this.search_field.value; - return this.winnow_results(); - }; - Chosen.prototype.results_hide = function() { - if (!this.is_multiple) { - this.selected_item.removeClassName('chzn-single-with-drop'); - } - this.result_clear_highlight(); - this.dropdown.setStyle({ - "left": "-9000px" - }); - return this.results_showing = false; - }; - Chosen.prototype.set_tab_index = function(el) { - var ti; - if (this.form_field.tabIndex) { - ti = this.form_field.tabIndex; - this.form_field.tabIndex = -1; - if (this.is_multiple) { - return this.search_field.tabIndex = ti; - } else { - this.selected_item.tabIndex = ti; - return this.search_field.tabIndex = -1; - } - } - }; - Chosen.prototype.show_search_field_default = function() { - if (this.is_multiple && this.choices < 1 && !this.active_field) { - this.search_field.value = this.default_text; - return this.search_field.addClassName("default"); - } else { - this.search_field.value = ""; - return this.search_field.removeClassName("default"); - } - }; - Chosen.prototype.search_results_click = function(evt) { - var target; - target = evt.target.hasClassName("active-result") ? evt.target : evt.target.up(".active-result"); - if (target) { - this.result_highlight = target; - return this.result_select(); - } - }; - Chosen.prototype.search_results_mouseover = function(evt) { - var target; - target = evt.target.hasClassName("active-result") ? evt.target : evt.target.up(".active-result"); - if (target) { - return this.result_do_highlight(target); - } - }; - Chosen.prototype.search_results_mouseout = function(evt) { - if (evt.target.hasClassName('active-result') || evt.target.up('.active-result')) { - return this.result_clear_highlight(); - } - }; - Chosen.prototype.choices_click = function(evt) { - evt.preventDefault(); - if (this.active_field && !(evt.target.hasClassName('search-choice') || evt.target.up('.search-choice')) && !this.results_showing) { - return this.results_show(); - } - }; - Chosen.prototype.choice_build = function(item) { - var choice_id, link; - choice_id = this.container_id + "_c_" + item.array_index; - this.choices += 1; - this.search_container.insert({ - before: this.choice_temp.evaluate({ - id: choice_id, - choice: item.html, - position: item.array_index - }) - }); - link = $(choice_id).down('a'); - return link.observe("click", __bind(function(evt) { - return this.choice_destroy_link_click(evt); - }, this)); - }; - Chosen.prototype.choice_destroy_link_click = function(evt) { - evt.preventDefault(); - this.pending_destroy_click = true; - return this.choice_destroy(evt.target); - }; - Chosen.prototype.choice_destroy = function(link) { - this.choices -= 1; - this.show_search_field_default(); - if (this.is_multiple && this.choices > 0 && this.search_field.value.length < 1) { - this.results_hide(); - } - this.result_deselect(link.readAttribute("rel")); - return link.up('li').remove(); - }; - Chosen.prototype.result_select = function() { - var high, item, position; - if (this.result_highlight) { - high = this.result_highlight; - this.result_clear_highlight(); - high.addClassName("result-selected"); - if (this.is_multiple) { - this.result_deactivate(high); - } else { - this.result_single_selected = high; - } - position = high.id.substr(high.id.lastIndexOf("_") + 1); - item = this.results_data[position]; - item.selected = true; - this.form_field.options[item.options_index].selected = true; - if (this.is_multiple) { - this.choice_build(item); - } else { - this.selected_item.down("span").update(item.html); - } - this.results_hide(); - this.search_field.value = ""; - if (typeof Event.simulate === 'function') { - this.form_field.simulate("change"); - } - return this.search_field_scale(); - } - }; - Chosen.prototype.result_activate = function(el) { - return el.addClassName("active-result").show(); - }; - Chosen.prototype.result_deactivate = function(el) { - return el.removeClassName("active-result").hide(); - }; - Chosen.prototype.result_deselect = function(pos) { - var result, result_data; - result_data = this.results_data[pos]; - result_data.selected = false; - this.form_field.options[result_data.options_index].selected = false; - result = $(this.container_id + "_o_" + pos); - result.removeClassName("result-selected").addClassName("active-result").show(); - this.result_clear_highlight(); - this.winnow_results(); - if (typeof Event.simulate === 'function') { - this.form_field.simulate("change"); - } - return this.search_field_scale(); - }; - Chosen.prototype.results_search = function(evt) { - if (this.results_showing) { - return this.winnow_results(); - } else { - return this.results_show(); - } - }; - Chosen.prototype.winnow_results = function() { - var found, option, part, parts, regex, result_id, results, searchText, startTime, startpos, text, zregex, _i, _j, _len, _len2, _ref; - startTime = new Date(); - this.no_results_clear(); - results = 0; - searchText = this.search_field.value === this.default_text ? "" : this.search_field.value.strip().escapeHTML(); - regex = new RegExp('^' + searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i'); - zregex = new RegExp(searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i'); - _ref = this.results_data; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - option = _ref[_i]; - if (!option.disabled && !option.empty) { - if (option.group) { - $(option.dom_id).hide(); - } else if (!(this.is_multiple && option.selected)) { - found = false; - result_id = option.dom_id; - if (regex.test(option.html)) { - found = true; - results += 1; - } else if (option.html.indexOf(" ") >= 0 || option.html.indexOf("[") === 0) { - parts = option.html.replace(/\[|\]/g, "").split(" "); - if (parts.length) { - for (_j = 0, _len2 = parts.length; _j < _len2; _j++) { - part = parts[_j]; - if (regex.test(part)) { - found = true; - results += 1; - } - } - } - } - if (found) { - if (searchText.length) { - startpos = option.html.search(zregex); - text = option.html.substr(0, startpos + searchText.length) + '
                          ' + option.html.substr(startpos + searchText.length); - text = text.substr(0, startpos) + '' + text.substr(startpos); - } else { - text = option.html; - } - if ($(result_id).innerHTML !== text) { - $(result_id).update(text); - } - this.result_activate($(result_id)); - if (option.group_array_index != null) { - $(this.results_data[option.group_array_index].dom_id).show(); - } - } else { - if ($(result_id) === this.result_highlight) { - this.result_clear_highlight(); - } - this.result_deactivate($(result_id)); - } - } - } - } - if (results < 1 && searchText.length) { - return this.no_results(searchText); - } else { - return this.winnow_results_set_highlight(); - } - }; - Chosen.prototype.winnow_results_clear = function() { - var li, lis, _i, _len, _results; - this.search_field.clear(); - lis = this.search_results.select("li"); - _results = []; - for (_i = 0, _len = lis.length; _i < _len; _i++) { - li = lis[_i]; - _results.push(li.hasClassName("group-result") ? li.show() : !this.is_multiple || !li.hasClassName("result-selected") ? this.result_activate(li) : void 0); - } - return _results; - }; - Chosen.prototype.winnow_results_set_highlight = function() { - var do_high; - if (!this.result_highlight) { - do_high = this.search_results.down(".active-result"); - if (do_high) { - return this.result_do_highlight(do_high); - } - } - }; - Chosen.prototype.no_results = function(terms) { - return this.search_results.insert(this.no_results_temp.evaluate({ - terms: terms - })); - }; - Chosen.prototype.no_results_clear = function() { - var nr, _results; - nr = null; - _results = []; - while (nr = this.search_results.down(".no-results")) { - _results.push(nr.remove()); - } - return _results; - }; - Chosen.prototype.keydown_arrow = function() { - var actives, nexts, sibs; - actives = this.search_results.select("li.active-result"); - if (actives.length) { - if (!this.result_highlight) { - this.result_do_highlight(actives.first()); - } else if (this.results_showing) { - sibs = this.result_highlight.nextSiblings(); - nexts = sibs.intersect(actives); - if (nexts.length) { - this.result_do_highlight(nexts.first()); - } - } - if (!this.results_showing) { - return this.results_show(); - } - } - }; - Chosen.prototype.keyup_arrow = function() { - var actives, prevs, sibs; - if (!this.results_showing && !this.is_multiple) { - return this.results_show(); - } else if (this.result_highlight) { - sibs = this.result_highlight.previousSiblings(); - actives = this.search_results.select("li.active-result"); - prevs = sibs.intersect(actives); - if (prevs.length) { - return this.result_do_highlight(prevs.first()); - } else { - if (this.choices > 0) { - this.results_hide(); - } - return this.result_clear_highlight(); - } - } - }; - Chosen.prototype.keydown_backstroke = function() { - if (this.pending_backstroke) { - this.choice_destroy(this.pending_backstroke.down("a")); - return this.clear_backstroke(); - } else { - this.pending_backstroke = this.search_container.siblings("li.search-choice").last(); - return this.pending_backstroke.addClassName("search-choice-focus"); - } - }; - Chosen.prototype.clear_backstroke = function() { - if (this.pending_backstroke) { - this.pending_backstroke.removeClassName("search-choice-focus"); - } - return this.pending_backstroke = null; - }; - Chosen.prototype.keyup_checker = function(evt) { - var stroke, _ref; - stroke = (_ref = evt.which) != null ? _ref : evt.keyCode; - this.search_field_scale(); - switch (stroke) { - case 8: - if (this.is_multiple && this.backstroke_length < 1 && this.choices > 0) { - return this.keydown_backstroke(); - } else if (!this.pending_backstroke) { - this.result_clear_highlight(); - return this.results_search(); - } - break; - case 13: - evt.preventDefault(); - if (this.results_showing) { - return this.result_select(); - } - break; - case 27: - if (this.results_showing) { - return this.results_hide(); - } - break; - case 9: - case 38: - case 40: - case 16: - break; - default: - return this.results_search(); - } - }; - Chosen.prototype.keydown_checker = function(evt) { - var stroke, _ref; - stroke = (_ref = evt.which) != null ? _ref : evt.keyCode; - this.search_field_scale(); - if (stroke !== 8 && this.pending_backstroke) { - this.clear_backstroke(); - } - switch (stroke) { - case 8: - return this.backstroke_length = this.search_field.value.length; - case 9: - return this.mouse_on_container = false; - case 13: - return evt.preventDefault(); - case 38: - evt.preventDefault(); - return this.keyup_arrow(); - case 40: - return this.keydown_arrow(); - } - }; - Chosen.prototype.search_field_scale = function() { - var dd_top, div, h, style, style_block, styles, w, _i, _len; - if (this.is_multiple) { - h = 0; - w = 0; - style_block = "position:absolute; left: -1000px; top: -1000px; display:none;"; - styles = ['font-size', 'font-style', 'font-weight', 'font-family', 'line-height', 'text-transform', 'letter-spacing']; - for (_i = 0, _len = styles.length; _i < _len; _i++) { - style = styles[_i]; - style_block += style + ":" + this.search_field.getStyle(style) + ";"; - } - div = new Element('div', { - 'style': style_block - }).update(this.search_field.value.escapeHTML()); - document.body.appendChild(div); - w = Element.measure(div, 'width') + 25; - div.remove(); - if (w > this.f_width - 10) { - w = this.f_width - 10; - } - this.search_field.setStyle({ - 'width': w + 'px' - }); - dd_top = this.container.getHeight(); - return this.dropdown.setStyle({ - "top": dd_top + "px" - }); - } - }; - return Chosen; - })(); - root.Chosen = Chosen; - document.observe('dom:loaded', function(evt) { - var select, selects, _i, _len, _results; - selects = $$(".chzn-select"); - _results = []; - for (_i = 0, _len = selects.length; _i < _len; _i++) { - select = selects[_i]; - _results.push(new Chosen(select)); - } - return _results; - }); - get_side_border_padding = function(elmt) { - var layout, side_border_padding; - layout = new Element.Layout(elmt); - return side_border_padding = layout.get("border-left") + layout.get("border-right") + layout.get("padding-left") + layout.get("padding-right"); - }; - root.get_side_border_padding = get_side_border_padding; -}).call(this); -(function() { - var SelectParser; - SelectParser = (function() { - function SelectParser() { - this.options_index = 0; - this.parsed = []; - } - SelectParser.prototype.add_node = function(child) { - if (child.nodeName === "OPTGROUP") { - return this.add_group(child); - } else { - return this.add_option(child); - } - }; - SelectParser.prototype.add_group = function(group) { - var group_position, option, _i, _len, _ref, _results; - group_position = this.parsed.length; - this.parsed.push({ - array_index: group_position, - group: true, - label: group.label, - children: 0, - disabled: group.disabled - }); - _ref = group.childNodes; - _results = []; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - option = _ref[_i]; - _results.push(this.add_option(option, group_position, group.disabled)); - } - return _results; - }; - SelectParser.prototype.add_option = function(option, group_position, group_disabled) { - if (option.nodeName === "OPTION") { - if (option.text !== "") { - if (group_position != null) { - this.parsed[group_position].children += 1; - } - this.parsed.push({ - array_index: this.parsed.length, - options_index: this.options_index, - value: option.value, - text: option.text, - html: option.innerHTML, - selected: option.selected, - disabled: group_disabled === true ? group_disabled : option.disabled, - group_array_index: group_position - }); - } else { - this.parsed.push({ - array_index: this.parsed.length, - options_index: this.options_index, - empty: true - }); - } - return this.options_index += 1; - } - }; - return SelectParser; - })(); - SelectParser.select_to_array = function(select) { - var child, parser, _i, _len, _ref; - parser = new SelectParser(); - _ref = select.childNodes; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - child = _ref[_i]; - parser.add_node(child); - } - return parser.parsed; - }; - this.SelectParser = SelectParser; -}).call(this); diff --git a/3rdparty/js/chosen/chosen.proto.min.js b/3rdparty/js/chosen/chosen.proto.min.js deleted file mode 100644 index c197c4d863..0000000000 --- a/3rdparty/js/chosen/chosen.proto.min.js +++ /dev/null @@ -1,10 +0,0 @@ -// Chosen, a Select Box Enhancer for jQuery and Protoype -// by Patrick Filler for Harvest, http://getharvest.com -// -// Version 0.9 -// Full source at https://github.com/harvesthq/chosen -// Copyright (c) 2011 Harvest http://getharvest.com - -// MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md -// This file is generated by `cake build`, do not edit it by hand. -(function(){var a,b,c,d=function(a,b){return function(){return a.apply(b,arguments)}};c=this,a=function(){function a(a){this.set_default_values(),this.form_field=a,this.is_multiple=this.form_field.multiple,this.is_rtl=this.form_field.hasClassName("chzn-rtl"),this.default_text_default=this.form_field.multiple?"Select Some Options":"Select an Option",this.set_up_html(),this.register_observers()}a.prototype.set_default_values=function(){this.click_test_action=d(function(a){return this.test_active_click(a)},this),this.active_field=!1,this.mouse_on_container=!1,this.results_showing=!1,this.result_highlighted=null,this.result_single_selected=null,this.choices=0,this.single_temp=new Template('#{default}
                            '),this.multi_temp=new Template('
                              '),this.choice_temp=new Template('
                            • #{choice}
                            • ');return this.no_results_temp=new Template('
                            • No results match "#{terms}"
                            • ')},a.prototype.set_up_html=function(){var a,c,d,e,f;this.container_id=this.form_field.identify().replace(/(:|\.)/g,"_")+"_chzn",this.f_width=this.form_field.getStyle("width")?parseInt(this.form_field.getStyle("width"),10):this.form_field.getWidth(),c={id:this.container_id,"class":"chzn-container "+(this.is_rtl?" chzn-rtl":void 0),style:"width: "+this.f_width+"px"},this.default_text=this.form_field.readAttribute("data-placeholder")?this.form_field.readAttribute("data-placeholder"):this.default_text_default,a=this.is_multiple?(new Element("div",c)).update(this.multi_temp.evaluate({"default":this.default_text})):(new Element("div",c)).update(this.single_temp.evaluate({"default":this.default_text})),this.form_field.hide().insert({after:a}),this.container=$(this.container_id),this.container.addClassName("chzn-container-"+(this.is_multiple?"multi":"single")),this.dropdown=this.container.down("div.chzn-drop"),d=this.container.getHeight(),e=this.f_width-b(this.dropdown),this.dropdown.setStyle({width:e+"px",top:d+"px"}),this.search_field=this.container.down("input"),this.search_results=this.container.down("ul.chzn-results"),this.search_field_scale(),this.search_no_results=this.container.down("li.no-results"),this.is_multiple?(this.search_choices=this.container.down("ul.chzn-choices"),this.search_container=this.container.down("li.search-field")):(this.search_container=this.container.down("div.chzn-search"),this.selected_item=this.container.down(".chzn-single"),f=e-b(this.search_container)-b(this.search_field),this.search_field.setStyle({width:f+"px"})),this.results_build();return this.set_tab_index()},a.prototype.register_observers=function(){this.container.observe("click",d(function(a){return this.container_click(a)},this)),this.container.observe("mouseenter",d(function(a){return this.mouse_enter(a)},this)),this.container.observe("mouseleave",d(function(a){return this.mouse_leave(a)},this)),this.search_results.observe("click",d(function(a){return this.search_results_click(a)},this)),this.search_results.observe("mouseover",d(function(a){return this.search_results_mouseover(a)},this)),this.search_results.observe("mouseout",d(function(a){return this.search_results_mouseout(a)},this)),this.form_field.observe("liszt:updated",d(function(a){return this.results_update_field(a)},this)),this.search_field.observe("blur",d(function(a){return this.input_blur(a)},this)),this.search_field.observe("keyup",d(function(a){return this.keyup_checker(a)},this)),this.search_field.observe("keydown",d(function(a){return this.keydown_checker(a)},this));if(this.is_multiple){this.search_choices.observe("click",d(function(a){return this.choices_click(a)},this));return this.search_field.observe("focus",d(function(a){return this.input_focus(a)},this))}return this.selected_item.observe("focus",d(function(a){return this.activate_field(a)},this))},a.prototype.container_click=function(a){a&&a.type==="click"&&a.stop();if(!this.pending_destroy_click){this.active_field?!this.is_multiple&&a&&(a.target===this.selected_item||a.target.up("a.chzn-single"))&&this.results_toggle():(this.is_multiple&&this.search_field.clear(),document.observe("click",this.click_test_action),this.results_show());return this.activate_field()}return this.pending_destroy_click=!1},a.prototype.mouse_enter=function(){return this.mouse_on_container=!0},a.prototype.mouse_leave=function(){return this.mouse_on_container=!1},a.prototype.input_focus=function(a){if(!this.active_field)return setTimeout(this.container_click.bind(this),50)},a.prototype.input_blur=function(a){if(!this.mouse_on_container){this.active_field=!1;return setTimeout(this.blur_test.bind(this),100)}},a.prototype.blur_test=function(a){if(!this.active_field&&this.container.hasClassName("chzn-container-active"))return this.close_field()},a.prototype.close_field=function(){document.stopObserving("click",this.click_test_action),this.is_multiple||(this.selected_item.tabIndex=this.search_field.tabIndex,this.search_field.tabIndex=-1),this.active_field=!1,this.results_hide(),this.container.removeClassName("chzn-container-active"),this.winnow_results_clear(),this.clear_backstroke(),this.show_search_field_default();return this.search_field_scale()},a.prototype.activate_field=function(){!this.is_multiple&&!this.active_field&&(this.search_field.tabIndex=this.selected_item.tabIndex,this.selected_item.tabIndex=-1),this.container.addClassName("chzn-container-active"),this.active_field=!0,this.search_field.value=this.search_field.value;return this.search_field.focus()},a.prototype.test_active_click=function(a){return a.target.up("#"+this.container_id)?this.active_field=!0:this.close_field()},a.prototype.results_build=function(){var a,b,d,e,f,g;d=new Date,this.parsing=!0,this.results_data=c.SelectParser.select_to_array(this.form_field),this.is_multiple&&this.choices>0?(this.search_choices.select("li.search-choice").invoke("remove"),this.choices=0):this.is_multiple||this.selected_item.down("span").update(this.default_text),a="",g=this.results_data;for(e=0,f=g.length;e'+a.label.escapeHTML()+""}return""},a.prototype.result_add_option=function(a){var b;if(!a.disabled){a.dom_id=this.container_id+"_o_"+a.array_index,b=a.selected&&this.is_multiple?[]:["active-result"],a.selected&&b.push("result-selected"),a.group_array_index!=null&&b.push("group-option");return'
                            • '+a.html+"
                            • "}return""},a.prototype.results_update_field=function(){this.result_clear_highlight(),this.result_single_selected=null;return this.results_build()},a.prototype.result_do_highlight=function(a){var b,c,d,e,f;this.result_clear_highlight(),this.result_highlight=a,this.result_highlight.addClassName("highlighted"),d=parseInt(this.search_results.getStyle("maxHeight"),10),f=this.search_results.scrollTop,e=d+f,c=this.result_highlight.positionedOffset().top,b=c+this.result_highlight.getHeight();if(b>=e)return this.search_results.scrollTop=b-d>0?b-d:0;if(c0&&this.search_field.value.length<1&&this.results_hide(),this.result_deselect(a.readAttribute("rel"));return a.up("li").remove()},a.prototype.result_select=function(){var a,b,c;if(this.result_highlight){a=this.result_highlight,this.result_clear_highlight(),a.addClassName("result-selected"),this.is_multiple?this.result_deactivate(a):this.result_single_selected=a,c=a.id.substr(a.id.lastIndexOf("_")+1),b=this.results_data[c],b.selected=!0,this.form_field.options[b.options_index].selected=!0,this.is_multiple?this.choice_build(b):this.selected_item.down("span").update(b.html),this.results_hide(),this.search_field.value="",typeof Event.simulate=="function"&&this.form_field.simulate("change");return this.search_field_scale()}},a.prototype.result_activate=function(a){return a.addClassName("active-result").show()},a.prototype.result_deactivate=function(a){return a.removeClassName("active-result").hide()},a.prototype.result_deselect=function(a){var b,c;c=this.results_data[a],c.selected=!1,this.form_field.options[c.options_index].selected=!1,b=$(this.container_id+"_o_"+a),b.removeClassName("result-selected").addClassName("active-result").show(),this.result_clear_highlight(),this.winnow_results(),typeof Event.simulate=="function"&&this.form_field.simulate("change");return this.search_field_scale()},a.prototype.results_search=function(a){return this.results_showing?this.winnow_results():this.results_show()},a.prototype.winnow_results=function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q;i=new Date,this.no_results_clear(),g=0,h=this.search_field.value===this.default_text?"":this.search_field.value.strip().escapeHTML(),e=new RegExp("^"+h.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"i"),l=new RegExp(h.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"i"),q=this.results_data;for(m=0,o=q.length;m=0||b.html.indexOf("[")===0){d=b.html.replace(/\[|\]/g,"").split(" ");if(d.length)for(n=0,p=d.length;n"+b.html.substr(j+h.length),k=k.substr(0,j)+""+k.substr(j)):k=b.html,$(f).innerHTML!==k&&$(f).update(k),this.result_activate($(f)),b.group_array_index!=null&&$(this.results_data[b.group_array_index].dom_id).show()):($(f)===this.result_highlight&&this.result_clear_highlight(),this.result_deactivate($(f)))}}return g<1&&h.length?this.no_results(h):this.winnow_results_set_highlight()},a.prototype.winnow_results_clear=function(){var a,b,c,d,e;this.search_field.clear(),b=this.search_results.select("li"),e=[];for(c=0,d=b.length;c0&&this.results_hide();return this.result_clear_highlight()}},a.prototype.keydown_backstroke=function(){if(this.pending_backstroke){this.choice_destroy(this.pending_backstroke.down("a"));return this.clear_backstroke()}this.pending_backstroke=this.search_container.siblings("li.search-choice").last();return this.pending_backstroke.addClassName("search-choice-focus")},a.prototype.clear_backstroke=function(){this.pending_backstroke&&this.pending_backstroke.removeClassName("search-choice-focus");return this.pending_backstroke=null},a.prototype.keyup_checker=function(a){var b,c;b=(c=a.which)!=null?c:a.keyCode,this.search_field_scale();switch(b){case 8:if(this.is_multiple&&this.backstroke_length<1&&this.choices>0)return this.keydown_backstroke();if(!this.pending_backstroke){this.result_clear_highlight();return this.results_search()}break;case 13:a.preventDefault();if(this.results_showing)return this.result_select();break;case 27:if(this.results_showing)return this.results_hide();break;case 9:case 38:case 40:case 16:break;default:return this.results_search()}},a.prototype.keydown_checker=function(a){var b,c;b=(c=a.which)!=null?c:a.keyCode,this.search_field_scale(),b!==8&&this.pending_backstroke&&this.clear_backstroke();switch(b){case 8:return this.backstroke_length=this.search_field.value.length;case 9:return this.mouse_on_container=!1;case 13:return a.preventDefault();case 38:a.preventDefault();return this.keyup_arrow();case 40:return this.keydown_arrow()}},a.prototype.search_field_scale=function(){var a,b,c,d,e,f,g,h,i;if(this.is_multiple){c=0,g=0,e="position:absolute; left: -1000px; top: -1000px; display:none;",f=["font-size","font-style","font-weight","font-family","line-height","text-transform","letter-spacing"];for(h=0,i=f.length;hthis.f_width-10&&(g=this.f_width-10),this.search_field.setStyle({width:g+"px"}),a=this.container.getHeight();return this.dropdown.setStyle({top:a+"px"})}};return a}(),c.Chosen=a,document.observe("dom:loaded",function(b){var c,d,e,f,g;d=$$(".chzn-select"),g=[];for(e=0,f=d.length;e