Index: trunk/extensions/PageTriage/SpecialPageTriage.php |
— | — | @@ -57,10 +57,7 @@ |
58 | 58 | $out->setPageTitle( wfMessage( 'pagetriage' ) ); |
59 | 59 | |
60 | 60 | // load the JS |
61 | | - $out->addModules( 'ext.pageTriage.init' ); |
62 | | - $out->addModules( 'ext.pageTriage.external' ); |
63 | | - $out->addModules( 'ext.pageTriage.models' ); |
64 | | - $out->addModules( 'ext.pageTriage.views' ); |
| 61 | + $out->addModules( array( 'ext.pageTriage.external', 'ext.pageTriage.models', 'ext.pageTriage.views' ) ); |
65 | 62 | |
66 | 63 | // This will hold the HTML for the triage interface |
67 | 64 | $triageInterface = ''; |
Index: trunk/extensions/PageTriage/modules/ext.pageTriage.views/ext.pageTriage.articleListItem.js |
— | — | @@ -1,103 +1,105 @@ |
2 | | -// view for the article list |
| 2 | +$( function() { |
| 3 | + // view for the article list |
3 | 4 | |
4 | 5 | |
5 | | -// TODO: find a way to insert these templates raw with RL instead of appending them to |
6 | | -// the DOM with javascript later (which is lame) |
| 6 | + // TODO: find a way to insert these templates raw with RL instead of appending them to |
| 7 | + // the DOM with javascript later (which is lame) |
7 | 8 | |
8 | | -// This template is repeated many times for each element in list view |
9 | | -// TODO there's some words in here which need to become wfMsg() calls |
10 | | -$( "#backboneTemplates" ).append('<script type="text/template" id="listItemTemplate"> \ |
11 | | - <div class="mwe-pt-article-row"> \ |
12 | | - <div class="mwe-pt-status-icon"> \ |
13 | | - <% if ( afd_status == "1" || blp_prod_status == "1" || csd_status == "1" || prod_status == "1" ) { %> \ |
14 | | - [DEL] <!-- deleted --> \ |
15 | | - <% } else if ( patrol_status == "1" ) { %> \ |
16 | | - [PTR] <!-- patrolled --> \ |
17 | | - <% } else { %> \ |
18 | | - [NEW] <!-- not patrolled --> \ |
19 | | - <% } %> \ |
| 9 | + // This template is repeated many times for each element in list view |
| 10 | + // TODO there's some words in here which need to become wfMsg() calls |
| 11 | + $( "#backboneTemplates" ).append('<script type="text/template" id="listItemTemplate"> \ |
| 12 | + <div class="mwe-pt-article-row"> \ |
| 13 | + <div class="mwe-pt-status-icon"> \ |
| 14 | + <% if ( afd_status == "1" || blp_prod_status == "1" || csd_status == "1" || prod_status == "1" ) { %> \ |
| 15 | + [DEL] <!-- deleted --> \ |
| 16 | + <% } else if ( patrol_status == "1" ) { %> \ |
| 17 | + [PTR] <!-- patrolled --> \ |
| 18 | + <% } else { %> \ |
| 19 | + [NEW] <!-- not patrolled --> \ |
| 20 | + <% } %> \ |
| 21 | + </div> \ |
| 22 | + <div class="mwe-pt-info-pane"> \ |
| 23 | + <div> \ |
| 24 | + <span class="mwe-pt-page-title"><%= title %></span> \ |
| 25 | + <span class="mwe-pt-histlink">(hist)</span> \ |
| 26 | + <span class="mwe-pt-metadata"> \ |
| 27 | + · \ |
| 28 | + bytes \ |
| 29 | + · \ |
| 30 | + edits \ |
| 31 | + · \ |
| 32 | + images \ |
| 33 | + · \ |
| 34 | + categories \ |
| 35 | + </span> \ |
| 36 | + </div> \ |
| 37 | + <div class="mwe-pt-snippet"> \ |
| 38 | + <%= snippet %> \ |
| 39 | + </div> \ |
| 40 | + </div> \ |
20 | 41 | </div> \ |
21 | | - <div class="mwe-pt-info-pane"> \ |
22 | | - <div> \ |
23 | | - <span class="mwe-pt-page-title"><%= title %></span> \ |
24 | | - <span class="mwe-pt-histlink">(hist)</span> \ |
25 | | - <span class="mwe-pt-metadata"> \ |
26 | | - · \ |
27 | | - bytes \ |
28 | | - · \ |
29 | | - edits \ |
30 | | - · \ |
31 | | - images \ |
32 | | - · \ |
33 | | - categories \ |
34 | | - </span> \ |
35 | | - </div> \ |
36 | | - <div class="mwe-pt-snippet"> \ |
37 | | - <%= snippet %> \ |
38 | | - </div> \ |
39 | | - </div> \ |
40 | | - </div> \ |
41 | | - <br/> \ |
42 | | - </script>' |
43 | | -); |
| 42 | + <br/> \ |
| 43 | + </script>' |
| 44 | + ); |
44 | 45 | |
45 | | -// instantiate the collection of articles |
46 | | -var articles = new ArticleList; |
| 46 | + // instantiate the collection of articles |
| 47 | + var articles = new mw.pageTriage.ArticleList; |
47 | 48 | |
48 | | -// single list item |
49 | | -// TODO: move this into its own file? |
50 | | -ListItem = Backbone.View.extend( { |
51 | | - tagName: "div", |
52 | | - template: _.template( $( "#listItemTemplate" ).html() ), |
| 49 | + // single list item |
| 50 | + // TODO: move this into its own file? |
| 51 | + var ListItem = Backbone.View.extend( { |
| 52 | + tagName: "div", |
| 53 | + template: _.template( $( "#listItemTemplate" ).html() ), |
53 | 54 | |
54 | | - // listen for changes to the model and re-render. |
55 | | - initialize: function() { |
56 | | - this.model.bind('change', this.render, this); |
57 | | - this.model.bind('destroy', this.remove, this); |
58 | | - }, |
| 55 | + // listen for changes to the model and re-render. |
| 56 | + initialize: function() { |
| 57 | + this.model.bind('change', this.render, this); |
| 58 | + this.model.bind('destroy', this.remove, this); |
| 59 | + }, |
59 | 60 | |
60 | | - render: function() { |
61 | | - // insert the template into the document. fill with the current model. |
62 | | - this.$el.html( this.template( this.model.toJSON() ) ); |
63 | | - return this; |
64 | | - } |
| 61 | + render: function() { |
| 62 | + // insert the template into the document. fill with the current model. |
| 63 | + this.$el.html( this.template( this.model.toJSON() ) ); |
| 64 | + return this; |
| 65 | + } |
65 | 66 | |
66 | | -} ); |
| 67 | + } ); |
67 | 68 | |
68 | | -// overall list view |
69 | | -// currently, this is the main application view. |
70 | | -ListView = Backbone.View.extend( { |
| 69 | + // overall list view |
| 70 | + // currently, this is the main application view. |
| 71 | + var ListView = Backbone.View.extend( { |
71 | 72 | |
72 | | - initialize: function() { |
| 73 | + initialize: function() { |
73 | 74 | |
74 | | - // these events are triggered when items are added to the articles collection |
75 | | - articles.bind( 'add', this.addOne, this ); |
76 | | - articles.bind( 'reset', this.addAll, this ); |
| 75 | + // these events are triggered when items are added to the articles collection |
| 76 | + articles.bind( 'add', this.addOne, this ); |
| 77 | + articles.bind( 'reset', this.addAll, this ); |
77 | 78 | |
78 | | - // this event is triggered when the collection finishes loading. |
79 | | - articles.bind( 'all', this.render, this ); |
| 79 | + // this event is triggered when the collection finishes loading. |
| 80 | + articles.bind( 'all', this.render, this ); |
80 | 81 | |
81 | | - // on init, make sure to load the contents of the collection. |
82 | | - articles.fetch(); |
83 | | - }, |
| 82 | + // on init, make sure to load the contents of the collection. |
| 83 | + articles.fetch(); |
| 84 | + }, |
84 | 85 | |
85 | | - render: function() { |
86 | | - // TODO: refresh the view (show/hide the parts that aren't attached to the ListItem view) |
87 | | - }, |
| 86 | + render: function() { |
| 87 | + // TODO: refresh the view (show/hide the parts that aren't attached to the ListItem view) |
| 88 | + }, |
88 | 89 | |
89 | | - // add a single article to the list |
90 | | - addOne: function( article ) { |
91 | | - // pass in the specific article instance |
92 | | - var view = new ListItem( { model: article } ); |
93 | | - this.$( "#listView" ).append( view.render().el ); |
94 | | - }, |
| 90 | + // add a single article to the list |
| 91 | + addOne: function( article ) { |
| 92 | + // pass in the specific article instance |
| 93 | + var view = new ListItem( { model: article } ); |
| 94 | + this.$( "#listView" ).append( view.render().el ); |
| 95 | + }, |
95 | 96 | |
96 | | - // add all the items in the articles collection |
97 | | - addAll: function() { |
98 | | - $("#listView").empty(); // remove the spinner before displaying. |
99 | | - articles.each( this.addOne ); |
100 | | - } |
| 97 | + // add all the items in the articles collection |
| 98 | + addAll: function() { |
| 99 | + $("#listView").empty(); // remove the spinner before displaying. |
| 100 | + articles.each( this.addOne ); |
| 101 | + } |
101 | 102 | |
| 103 | + } ); |
| 104 | + |
| 105 | + var list = new ListView(); |
102 | 106 | } ); |
103 | | - |
104 | | -var list = new ListView(); |
Index: trunk/extensions/PageTriage/modules/ext.pageTriage.models/ext.pageTriage.article.js |
— | — | @@ -1,13 +1,18 @@ |
2 | | - var Article = Backbone.Model.extend( { |
3 | | - defaults: { |
4 | | - title: 'Empty Article', |
5 | | - pageid: '' |
6 | | - }, |
| 2 | +$( function() { |
| 3 | + mw.pageTriage = { |
| 4 | + Article: Backbone.Model.extend( { |
| 5 | + defaults: { |
| 6 | + title: 'Empty Article', |
| 7 | + pageid: '' |
| 8 | + }, |
7 | 9 | |
8 | | - } ); |
9 | | - |
10 | | - var ArticleList = Backbone.Collection.extend( { |
11 | | - model: Article, |
| 10 | + } ), |
| 11 | + }; |
| 12 | + |
| 13 | + // can't include this in the declaration above because it references the |
| 14 | + // object created therein. |
| 15 | + mw.pageTriage.ArticleList = Backbone.Collection.extend( { |
| 16 | + model: mw.pageTriage.Article, |
12 | 17 | url: '/w/api.php?action=pagetriagelist&format=json', |
13 | 18 | |
14 | 19 | parse: function( response ) { |
— | — | @@ -16,4 +21,4 @@ |
17 | 22 | } |
18 | 23 | |
19 | 24 | } ); |
20 | | - |
| 25 | +} ); |
Index: trunk/extensions/PageTriage/PageTriage.php |
— | — | @@ -133,13 +133,18 @@ |
134 | 134 | 'ext.pageTriage.external' |
135 | 135 | ), |
136 | 136 | 'scripts' => array( |
137 | | - 'ext.pageTriage.models/ext.pageTriage.article.js' |
| 137 | + 'ext.pageTriage.models/ext.pageTriage.article.js', |
| 138 | + 'ext.pageTriage.views/ext.pageTriage.articleListItem.js' |
| 139 | + ), |
| 140 | + 'styles' => array( |
| 141 | + 'ext.pageTriage.views/ext.pageTriage.articleListItem.css' |
138 | 142 | ) |
139 | 143 | ); |
140 | 144 | |
| 145 | +/* |
141 | 146 | $wgResourceModules['ext.pageTriage.views'] = $ptResourceTemplate + array( |
142 | 147 | 'dependencies' => array( |
143 | | - 'ext.pageTriage.models', |
| 148 | + 'ext.pageTriage.models' |
144 | 149 | ), |
145 | 150 | 'scripts' => array( |
146 | 151 | 'ext.pageTriage.views/ext.pageTriage.articleListItem.js' |
— | — | @@ -148,6 +153,7 @@ |
149 | 154 | 'ext.pageTriage.views/ext.pageTriage.articleListItem.css' |
150 | 155 | ) |
151 | 156 | ); |
| 157 | +*/ |
152 | 158 | |
153 | 159 | $wgResourceModules['ext.pageTriage.article'] = $ptResourceTemplate + array( |
154 | 160 | 'styles' => 'ext.pageTriage.article/ext.pageTriage.article.css', |