https://www.mediawiki.org/wiki/Special:Code/MediaWiki/114571
Revision: 114571
Author: raindrift
Date: 2012-03-28 18:58:17 +0000 (Wed, 28 Mar 2012)
Log Message:
-----------
this is the list view. i left it out of r114568
Added Paths:
-----------
trunk/extensions/PageTriage/modules/ext.pageTriage.views/ext.pageTriage.listView.js
Added:
trunk/extensions/PageTriage/modules/ext.pageTriage.views/ext.pageTriage.listView.js
===================================================================
---
trunk/extensions/PageTriage/modules/ext.pageTriage.views/ext.pageTriage.listView.js
(rev 0)
+++
trunk/extensions/PageTriage/modules/ext.pageTriage.views/ext.pageTriage.listView.js
2012-03-28 18:58:17 UTC (rev 114571)
@@ -0,0 +1,59 @@
+$( function() {
+ // view for the article list
+
+ // instantiate the collection of articles
+ var articles = new mw.pageTriage.ArticleList;
+
+ // set the default sort order.
+ articles.comparator = function( article ) {
+ return -article.get( "creation_date" );
+ };
+
+ // overall list view
+ // currently, this is the main application view.
+ mw.pageTriage.ListView = Backbone.View.extend( {
+
+ initialize: function() {
+
+ // these events are triggered when items are added to
the articles collection
+ this.position = 0;
+ articles.bind( 'add', this.addOne, this );
+ articles.bind( 'reset', this.addAll, this );
+
+ // this event is triggered when the collection finishes
loading.
+ articles.bind( 'all', this.render, this );
+
+ // on init, make sure to load the contents of the
collection.
+ articles.fetch();
+ },
+
+ render: function() {
+ this.position = 0;
+ // TODO: refresh the view (show/hide the parts that
aren't attached to the ListItem view)
+ },
+
+ // add a single article to the list
+ addOne: function( article ) {
+ // define position, for making alternating background
colors.
+ // this is added at the last minute, so it gets updated
when the sort changes.
+ if(! this.position ) {
+ this.position = 0;
+ }
+ article.set( 'position', this.position++ );
+
+ // pass in the specific article instance
+ var view = new mw.pageTriage.ListItem( { model: article
} );
+ this.$( "#listView" ).append( view.render().el );
+ },
+
+ // add all the items in the articles collection
+ addAll: function() {
+ $("#listView").empty(); // remove the spinner before
displaying.
+ articles.each( this.addOne );
+ }
+
+ } );
+
+ // create an instance of the list view, which makes everything go.
+ var list = new mw.pageTriage.ListView();
+} );
Property changes on:
trunk/extensions/PageTriage/modules/ext.pageTriage.views/ext.pageTriage.listView.js
___________________________________________________________________
Added: svn:eol-style
+ native
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs