r114568 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r114567‎ | r114568 | r114569 >
Date:18:45, 28 March 2012
Author:raindrift
Status:deferred
Tags:
Comment:
moved ListItem and ListView into separate files
Modified paths:
  • /trunk/extensions/PageTriage/PageTriage.php (modified) (history)
  • /trunk/extensions/PageTriage/modules/ext.pageTriage.views/ext.pageTriage.articleListItem.css (deleted) (history)
  • /trunk/extensions/PageTriage/modules/ext.pageTriage.views/ext.pageTriage.articleListItem.js (deleted) (history)
  • /trunk/extensions/PageTriage/modules/ext.pageTriage.views/ext.pageTriage.listItem.css (added) (history)
  • /trunk/extensions/PageTriage/modules/ext.pageTriage.views/ext.pageTriage.listItem.js (added) (history)

Diff [purge]

Index: trunk/extensions/PageTriage/modules/ext.pageTriage.views/ext.pageTriage.articleListItem.js
@@ -1,78 +0,0 @@
2 -$( function() {
3 - // view for the article list
4 -
5 - // instantiate the collection of articles
6 - var articles = new mw.pageTriage.ArticleList;
7 -
8 - // set the default sort order.
9 - articles.comparator = function( article ) {
10 - return -article.get( "creation_date" );
11 - };
12 -
13 - // single list item
14 - var ListItem = Backbone.View.extend( {
15 - tagName: "div",
16 - template: _.template( $( "#listItemTemplate" ).html() ),
17 -
18 - // listen for changes to the model and re-render.
19 - initialize: function() {
20 - this.model.bind('change', this.render, this);
21 - this.model.bind('destroy', this.remove, this);
22 - },
23 -
24 - render: function() {
25 - // insert the template into the document. fill with the current model.
26 - this.$el.html( this.template( this.model.toJSON() ) );
27 - return this;
28 - }
29 -
30 - } );
31 -
32 - // overall list view
33 - // currently, this is the main application view.
34 - var ListView = Backbone.View.extend( {
35 -
36 - initialize: function() {
37 -
38 - // these events are triggered when items are added to the articles collection
39 - this.position = 0;
40 - articles.bind( 'add', this.addOne, this );
41 - articles.bind( 'reset', this.addAll, this );
42 -
43 - // this event is triggered when the collection finishes loading.
44 - articles.bind( 'all', this.render, this );
45 -
46 - // on init, make sure to load the contents of the collection.
47 - articles.fetch();
48 - },
49 -
50 - render: function() {
51 - this.position = 0;
52 - // TODO: refresh the view (show/hide the parts that aren't attached to the ListItem view)
53 - },
54 -
55 - // add a single article to the list
56 - addOne: function( article ) {
57 - // define position, for making alternating background colors.
58 - // this is added at the last minute, so it gets updated when the sort changes.
59 - if(! this.position ) {
60 - this.position = 0;
61 - }
62 - article.set( 'position', this.position++ );
63 -
64 - // pass in the specific article instance
65 - var view = new ListItem( { model: article } );
66 - this.$( "#listView" ).append( view.render().el );
67 - },
68 -
69 - // add all the items in the articles collection
70 - addAll: function() {
71 - $("#listView").empty(); // remove the spinner before displaying.
72 - articles.each( this.addOne );
73 - }
74 -
75 - } );
76 -
77 - // create an instance of the list view, which makes everything go.
78 - var list = new ListView();
79 -} );
Index: trunk/extensions/PageTriage/modules/ext.pageTriage.views/ext.pageTriage.articleListItem.css
@@ -1,75 +0,0 @@
2 -
3 -.mwe-pt-info-pane-even {
4 - background-color: #efefef;
5 -}
6 -
7 -.mwe-pt-info-pane-odd {
8 - background-color: white;
9 -}
10 -
11 -.mwe-pt-info-pane {
12 - margin-left: 50px;
13 - padding-bottom: 1em;
14 - border: 2px;
15 -}
16 -
17 -.mwe-pt-status-icon {
18 - float: left;
19 - width: 50px;
20 - height: 50px;
21 -}
22 -
23 -.mwe-pt-status-icon-new {
24 - background-color: #f2b3b3;
25 -}
26 -
27 -.mwe-pt-status-icon-triaged {
28 - background-color: #c3ead7;
29 -}
30 -
31 -.mwe-pt-status-icon-deleted {
32 - background-color: #b3b3b3;
33 -}
34 -
35 -/* info about the article */
36 -.mwe-pt-article {
37 - font-size: 1.2em;
38 - margin-left: 5px;
39 -}
40 -
41 -.mwe-pt-page-title {
42 - font-weight: bold;
43 -}
44 -
45 -.mwe-pt-histlink {
46 - font-size: 1em;
47 -}
48 -
49 -.mwe-pt-metadata {
50 -}
51 -
52 -.mwe-pt-metadata-warning {
53 - color: red;
54 - font-weight: bold;
55 -}
56 -
57 -.mwe-pt-creation-date {
58 - float: right;
59 - font-weight: bold;
60 - font-size: 1em;
61 -}
62 -
63 -/* info about the article's author */
64 -.mwe-pt-author {
65 - margin-left: 25px;
66 -}
67 -
68 -.mwe-pt-talk-contribs {
69 - font-size: 0.8em;
70 -}
71 -
72 -/* the article snippet */
73 -.mwe-pt-snippet {
74 - color: #808080;
75 - margin-left: 25px;
76 -}
Index: trunk/extensions/PageTriage/modules/ext.pageTriage.views/ext.pageTriage.listItem.css
@@ -0,0 +1,75 @@
 2+
 3+.mwe-pt-info-pane-even {
 4+ background-color: #efefef;
 5+}
 6+
 7+.mwe-pt-info-pane-odd {
 8+ background-color: white;
 9+}
 10+
 11+.mwe-pt-info-pane {
 12+ margin-left: 50px;
 13+ padding-bottom: 1em;
 14+ border: 2px;
 15+}
 16+
 17+.mwe-pt-status-icon {
 18+ float: left;
 19+ width: 50px;
 20+ height: 50px;
 21+}
 22+
 23+.mwe-pt-status-icon-new {
 24+ background-color: #f2b3b3;
 25+}
 26+
 27+.mwe-pt-status-icon-triaged {
 28+ background-color: #c3ead7;
 29+}
 30+
 31+.mwe-pt-status-icon-deleted {
 32+ background-color: #b3b3b3;
 33+}
 34+
 35+/* info about the article */
 36+.mwe-pt-article {
 37+ font-size: 1.2em;
 38+ margin-left: 5px;
 39+}
 40+
 41+.mwe-pt-page-title {
 42+ font-weight: bold;
 43+}
 44+
 45+.mwe-pt-histlink {
 46+ font-size: 1em;
 47+}
 48+
 49+.mwe-pt-metadata {
 50+}
 51+
 52+.mwe-pt-metadata-warning {
 53+ color: red;
 54+ font-weight: bold;
 55+}
 56+
 57+.mwe-pt-creation-date {
 58+ float: right;
 59+ font-weight: bold;
 60+ font-size: 1em;
 61+}
 62+
 63+/* info about the article's author */
 64+.mwe-pt-author {
 65+ margin-left: 25px;
 66+}
 67+
 68+.mwe-pt-talk-contribs {
 69+ font-size: 0.8em;
 70+}
 71+
 72+/* the article snippet */
 73+.mwe-pt-snippet {
 74+ color: #808080;
 75+ margin-left: 25px;
 76+}
Property changes on: trunk/extensions/PageTriage/modules/ext.pageTriage.views/ext.pageTriage.listItem.css
___________________________________________________________________
Added: svn:eol-style
177 + native
Index: trunk/extensions/PageTriage/modules/ext.pageTriage.views/ext.pageTriage.listItem.js
@@ -0,0 +1,21 @@
 2+$( function() {
 3+ // single list list view item
 4+
 5+ mw.pageTriage.ListItem = Backbone.View.extend( {
 6+ tagName: "div",
 7+ template: _.template( $( "#listItemTemplate" ).html() ),
 8+
 9+ // listen for changes to the model and re-render.
 10+ initialize: function() {
 11+ this.model.bind('change', this.render, this);
 12+ this.model.bind('destroy', this.remove, this);
 13+ },
 14+
 15+ render: function() {
 16+ // insert the template into the document. fill with the current model.
 17+ this.$el.html( this.template( this.model.toJSON() ) );
 18+ return this;
 19+ }
 20+
 21+ } );
 22+} );
Property changes on: trunk/extensions/PageTriage/modules/ext.pageTriage.views/ext.pageTriage.listItem.js
___________________________________________________________________
Added: svn:eol-style
123 + native
Index: trunk/extensions/PageTriage/PageTriage.php
@@ -187,10 +187,11 @@
188188 'ext.pageTriage.models'
189189 ),
190190 'scripts' => array(
191 - 'ext.pageTriage.views/ext.pageTriage.articleListItem.js'
 191+ 'ext.pageTriage.views/ext.pageTriage.listItem.js',
 192+ 'ext.pageTriage.views/ext.pageTriage.listView.js'
192193 ),
193194 'styles' => array(
194 - 'ext.pageTriage.views/ext.pageTriage.articleListItem.css'
 195+ 'ext.pageTriage.views/ext.pageTriage.listItem.css'
195196 ),
196197 'messages' => array(
197198 'pagetriage-hist',

Follow-up revisions

RevisionCommit summaryAuthorDate
r114571this is the list view. i left it out of r114568raindrift18:58, 28 March 2012

Status & tagging log