diff options
| author | Patrick Seeger <pseeger@ccwn.org> | 2012-04-15 18:37:40 +0200 |
|---|---|---|
| committer | Patrick Seeger <pseeger@ccwn.org> | 2012-04-15 18:37:40 +0200 |
| commit | feb2fe055435e7ecdc657cacee2aaf7dc339dbc9 (patch) | |
| tree | 77fa07572ae7a5a2b6e808c97b9adc7f035059b3 /assets/e96affe6/listview | |
| parent | ba20ededac6fd68d281603e8c9273f5134d21a4c (diff) | |
Irgendwas in der art von posts
Diffstat (limited to 'assets/e96affe6/listview')
| -rw-r--r-- | assets/e96affe6/listview/down.gif | bin | 0 -> 55 bytes | |||
| -rw-r--r-- | assets/e96affe6/listview/jquery.yiilistview.js | 114 | ||||
| -rw-r--r-- | assets/e96affe6/listview/loading.gif | bin | 0 -> 1849 bytes | |||
| -rw-r--r-- | assets/e96affe6/listview/styles.css | 56 | ||||
| -rw-r--r-- | assets/e96affe6/listview/up.gif | bin | 0 -> 54 bytes |
5 files changed, 170 insertions, 0 deletions
diff --git a/assets/e96affe6/listview/down.gif b/assets/e96affe6/listview/down.gif Binary files differnew file mode 100644 index 0000000..a4933b8 --- /dev/null +++ b/assets/e96affe6/listview/down.gif diff --git a/assets/e96affe6/listview/jquery.yiilistview.js b/assets/e96affe6/listview/jquery.yiilistview.js new file mode 100644 index 0000000..682402f --- /dev/null +++ b/assets/e96affe6/listview/jquery.yiilistview.js @@ -0,0 +1,114 @@ +/** + * jQuery Yii ListView plugin file. + * + * @author Qiang Xue <qiang.xue@gmail.com> + * @link http://www.yiiframework.com/ + * @copyright Copyright © 2008-2010 Yii Software LLC + * @license http://www.yiiframework.com/license/ + * @version $Id: jquery.yiilistview.js 3296 2011-06-22 17:15:17Z qiang.xue $ + */ + +;(function($) { + /** + * yiiListView set function. + * @param options map settings for the list view. Availablel options are as follows: + * - ajaxUpdate: array, IDs of the containers whose content may be updated by ajax response + * - ajaxVar: string, the name of the GET variable indicating the ID of the element triggering the AJAX request + * - pagerClass: string, the CSS class for the pager container + * - sorterClass: string, the CSS class for the sorter container + * - updateSelector: string, the selector for choosing which elements can trigger ajax requests + * - beforeAjaxUpdate: function, the function to be called before ajax request is sent + * - afterAjaxUpdate: function, the function to be called after ajax response is received + */ + $.fn.yiiListView = function(options) { + return this.each(function(){ + var settings = $.extend({}, $.fn.yiiListView.defaults, options || {}); + var $this = $(this); + var id = $this.attr('id'); + if(settings.updateSelector == undefined) { + settings.updateSelector = '#'+id+' .'+settings.pagerClass.replace(/\s+/g,'.')+' a, #'+id+' .'+settings.sorterClass.replace(/\s+/g,'.')+' a'; + } + $.fn.yiiListView.settings[id] = settings; + + if(settings.ajaxUpdate.length > 0) { + $(settings.updateSelector).die('click').live('click',function(){ + $.fn.yiiListView.update(id, {url: $(this).attr('href')}); + return false; + }); + } + }); + }; + + $.fn.yiiListView.defaults = { + ajaxUpdate: [], + ajaxVar: 'ajax', + pagerClass: 'pager', + loadingClass: 'loading', + sorterClass: 'sorter' + // updateSelector: '#id .pager a, '#id .sort a', + // beforeAjaxUpdate: function(id) {}, + // afterAjaxUpdate: function(id, data) {}, + // url: 'ajax request URL' + }; + + $.fn.yiiListView.settings = {}; + + /** + * Returns the key value for the specified row + * @param id string the ID of the list view container + * @param index integer the zero-based index of the data item + * @return string the key value + */ + $.fn.yiiListView.getKey = function(id, index) { + return $('#'+id+' > div.keys > span:eq('+index+')').text(); + }; + + /** + * Returns the URL that generates the list view content. + * @param id string the ID of the list view container + * @return string the URL that generates the list view content. + */ + $.fn.yiiListView.getUrl = function(id) { + var settings = $.fn.yiiListView.settings[id]; + return settings.url || $('#'+id+' > div.keys').attr('title'); + }; + + /** + * Performs an AJAX-based update of the list view contents. + * @param id string the ID of the list view container + * @param options map the AJAX request options (see jQuery.ajax API manual). By default, + * the URL to be requested is the one that generates the current content of the list view. + */ + $.fn.yiiListView.update = function(id, options) { + var settings = $.fn.yiiListView.settings[id]; + $('#'+id).addClass(settings.loadingClass); + options = $.extend({ + type: 'GET', + url: $.fn.yiiListView.getUrl(id), + success: function(data,status) { + $.each(settings.ajaxUpdate, function(i,v) { + var id='#'+v; + $(id).replaceWith($(id,'<div>'+data+'</div>')); + }); + if(settings.afterAjaxUpdate != undefined) + settings.afterAjaxUpdate(id, data); + $('#'+id).removeClass(settings.loadingClass); + }, + error: function(XMLHttpRequest, textStatus, errorThrown) { + $('#'+id).removeClass(settings.loadingClass); + alert(XMLHttpRequest.responseText); + } + }, options || {}); + + if(options.data!=undefined && options.type=='GET') { + options.url = $.param.querystring(options.url, options.data); + options.data = {}; + } + options.url = $.param.querystring(options.url, settings.ajaxVar+'='+id); + + if(settings.beforeAjaxUpdate != undefined) + settings.beforeAjaxUpdate(id); + $.ajax(options); + }; + +})(jQuery);
\ No newline at end of file diff --git a/assets/e96affe6/listview/loading.gif b/assets/e96affe6/listview/loading.gif Binary files differnew file mode 100644 index 0000000..5b33f7e --- /dev/null +++ b/assets/e96affe6/listview/loading.gif diff --git a/assets/e96affe6/listview/styles.css b/assets/e96affe6/listview/styles.css new file mode 100644 index 0000000..974507c --- /dev/null +++ b/assets/e96affe6/listview/styles.css @@ -0,0 +1,56 @@ +.list-view-loading +{ + background:url(loading.gif) no-repeat; +} + +.list-view .summary +{ + margin: 0 0 5px 0; + text-align: right; +} + +.list-view .sorter +{ + margin: 0 0 5px 0; + text-align: right; +} + +.list-view .pager +{ + margin: 5px 0 0 0; + text-align: right; +} + +.list-view .sorter +{ + font-size: 0.9em; +} + +.list-view .sorter ul +{ + display: inline; + list-style-image:none; + list-style-position:outside; + list-style-type:none; + margin:0; + padding:0; +} + +.list-view .sorter li +{ + display: inline; + margin: 0 0 0 5px; + padding: 0; +} + +.list-view .sorter a.asc +{ + background:url(up.gif) right center no-repeat; + padding-right: 10px; +} + +.list-view .sorter a.desc +{ + background:url(down.gif) right center no-repeat; + padding-right: 10px; +} diff --git a/assets/e96affe6/listview/up.gif b/assets/e96affe6/listview/up.gif Binary files differnew file mode 100644 index 0000000..890b038 --- /dev/null +++ b/assets/e96affe6/listview/up.gif |
