https://www.mediawiki.org/wiki/Special:Code/MediaWiki/114494

Revision: 114494
Author:   raindrift
Date:     2012-03-26 21:14:23 +0000 (Mon, 26 Mar 2012)
Log Message:
-----------
fixed list view so it runs with debug=false too

Modified Paths:
--------------
    trunk/extensions/PageTriage/PageTriage.php
    trunk/extensions/PageTriage/SpecialPageTriage.php
    
trunk/extensions/PageTriage/modules/ext.pageTriage.models/ext.pageTriage.article.js
    
trunk/extensions/PageTriage/modules/ext.pageTriage.views/ext.pageTriage.articleListItem.js

Modified: trunk/extensions/PageTriage/PageTriage.php
===================================================================
--- trunk/extensions/PageTriage/PageTriage.php  2012-03-26 19:16:16 UTC (rev 
114493)
+++ trunk/extensions/PageTriage/PageTriage.php  2012-03-26 21:14:23 UTC (rev 
114494)
@@ -133,13 +133,18 @@
                'ext.pageTriage.external'
        ),
        'scripts' => array(
-               'ext.pageTriage.models/ext.pageTriage.article.js'
+               'ext.pageTriage.models/ext.pageTriage.article.js',
+               'ext.pageTriage.views/ext.pageTriage.articleListItem.js'        
        
+       ),
+       'styles' => array(
+               'ext.pageTriage.views/ext.pageTriage.articleListItem.css'
        )
 );
 
+/*
 $wgResourceModules['ext.pageTriage.views'] = $ptResourceTemplate + array(
        'dependencies' => array(
-               'ext.pageTriage.models',
+               'ext.pageTriage.models'
        ),
        'scripts' => array(
                'ext.pageTriage.views/ext.pageTriage.articleListItem.js'
@@ -148,6 +153,7 @@
                'ext.pageTriage.views/ext.pageTriage.articleListItem.css'
        )
 );
+*/
 
 $wgResourceModules['ext.pageTriage.article'] = $ptResourceTemplate + array(
        'styles' => 'ext.pageTriage.article/ext.pageTriage.article.css',

Modified: trunk/extensions/PageTriage/SpecialPageTriage.php
===================================================================
--- trunk/extensions/PageTriage/SpecialPageTriage.php   2012-03-26 19:16:16 UTC 
(rev 114493)
+++ trunk/extensions/PageTriage/SpecialPageTriage.php   2012-03-26 21:14:23 UTC 
(rev 114494)
@@ -57,10 +57,7 @@
                $out->setPageTitle( wfMessage( 'pagetriage' ) );
 
                // load the JS
-               $out->addModules( 'ext.pageTriage.init' );
-               $out->addModules( 'ext.pageTriage.external' );
-               $out->addModules( 'ext.pageTriage.models' );
-               $out->addModules( 'ext.pageTriage.views' );
+               $out->addModules( array( 'ext.pageTriage.external', 
'ext.pageTriage.models', 'ext.pageTriage.views' ) );
                                
                // This will hold the HTML for the triage interface
                $triageInterface = '';

Modified: 
trunk/extensions/PageTriage/modules/ext.pageTriage.models/ext.pageTriage.article.js
===================================================================
--- 
trunk/extensions/PageTriage/modules/ext.pageTriage.models/ext.pageTriage.article.js
 2012-03-26 19:16:16 UTC (rev 114493)
+++ 
trunk/extensions/PageTriage/modules/ext.pageTriage.models/ext.pageTriage.article.js
 2012-03-26 21:14:23 UTC (rev 114494)
@@ -1,13 +1,18 @@
-       var Article = Backbone.Model.extend( {
-               defaults: {
-                       title: 'Empty Article',
-                       pageid: ''
-               },
+$( function() {
+       mw.pageTriage = {
+               Article: Backbone.Model.extend( {
+                       defaults: {
+                               title: 'Empty Article',
+                               pageid: ''
+                       },
 
-       } );
-
-       var ArticleList = Backbone.Collection.extend( {
-               model: Article,
+               } ),
+       };
+       
+       // can't include this in the declaration above because it references the
+       // object created therein.
+       mw.pageTriage.ArticleList = Backbone.Collection.extend( {
+               model: mw.pageTriage.Article,
                url: '/w/api.php?action=pagetriagelist&format=json',
 
                parse: function( response ) {
@@ -16,4 +21,4 @@
                }
 
        } );
-
+} );

Modified: 
trunk/extensions/PageTriage/modules/ext.pageTriage.views/ext.pageTriage.articleListItem.js
===================================================================
--- 
trunk/extensions/PageTriage/modules/ext.pageTriage.views/ext.pageTriage.articleListItem.js
  2012-03-26 19:16:16 UTC (rev 114493)
+++ 
trunk/extensions/PageTriage/modules/ext.pageTriage.views/ext.pageTriage.articleListItem.js
  2012-03-26 21:14:23 UTC (rev 114494)
@@ -1,103 +1,105 @@
-// view for the article list
+$( function() {
+       // view for the article list
 
 
-// TODO: find a way to insert these templates raw with RL instead of appending 
them to
-// the DOM with javascript later (which is lame)
+       // TODO: find a way to insert these templates raw with RL instead of 
appending them to
+       // the DOM with javascript later (which is lame)
 
-// This template is repeated many times for each element in list view
-// TODO there's some words in here which need to become wfMsg() calls
-$( "#backboneTemplates" ).append('<script type="text/template" 
id="listItemTemplate"> \
-               <div class="mwe-pt-article-row"> \
-                       <div class="mwe-pt-status-icon"> \
-                       <% if ( afd_status == "1" || blp_prod_status == "1" || 
csd_status == "1" || prod_status == "1" ) { %> \
-                               [DEL] <!-- deleted --> \
-                       <% } else if ( patrol_status == "1" ) { %> \
-                               [PTR] <!-- patrolled --> \
-                       <% } else { %> \
-                               [NEW] <!-- not patrolled --> \
-                       <% } %> \
+       // This template is repeated many times for each element in list view
+       // TODO there's some words in here which need to become wfMsg() calls
+       $( "#backboneTemplates" ).append('<script type="text/template" 
id="listItemTemplate"> \
+                       <div class="mwe-pt-article-row"> \
+                               <div class="mwe-pt-status-icon"> \
+                               <% if ( afd_status == "1" || blp_prod_status == 
"1" || csd_status == "1" || prod_status == "1" ) { %> \
+                                       [DEL] <!-- deleted --> \
+                               <% } else if ( patrol_status == "1" ) { %> \
+                                       [PTR] <!-- patrolled --> \
+                               <% } else { %> \
+                                       [NEW] <!-- not patrolled --> \
+                               <% } %> \
+                               </div> \
+                               <div class="mwe-pt-info-pane"> \
+                               <div> \
+                               <span class="mwe-pt-page-title"><%= title 
%></span> \
+                               <span class="mwe-pt-histlink">(hist)</span> \
+                               <span class="mwe-pt-metadata"> \
+                               &#xb7; \
+                               bytes \
+                               &#xb7; \
+                               edits \
+                               &#xb7; \
+                               images \
+                               &#xb7; \
+                               categories \
+                               </span> \
+                               </div> \
+                               <div class="mwe-pt-snippet"> \
+                               <%= snippet %> \
+                               </div> \
+                               </div> \
                        </div> \
-                       <div class="mwe-pt-info-pane"> \
-                       <div> \
-                       <span class="mwe-pt-page-title"><%= title %></span> \
-                       <span class="mwe-pt-histlink">(hist)</span> \
-                       <span class="mwe-pt-metadata"> \
-                       &#xb7; \
-                       bytes \
-                       &#xb7; \
-                       edits \
-                       &#xb7; \
-                       images \
-                       &#xb7; \
-                       categories \
-                       </span> \
-                       </div> \
-                       <div class="mwe-pt-snippet"> \
-                       <%= snippet %> \
-                       </div> \
-                       </div> \
-               </div> \
-               <br/> \
-       </script>'
-);
+                       <br/> \
+               </script>'
+       );
 
-// instantiate the collection of articles
-var articles = new ArticleList;
+       // instantiate the collection of articles
+       var articles = new mw.pageTriage.ArticleList;
 
-// single list item
-// TODO: move this into its own file?
-ListItem = Backbone.View.extend( {
-       tagName: "div",
-       template: _.template( $( "#listItemTemplate" ).html() ),
+       // single list item
+       // TODO: move this into its own file?
+       var ListItem = Backbone.View.extend( {
+               tagName: "div",
+               template: _.template( $( "#listItemTemplate" ).html() ),
 
-       // listen for changes to the model and re-render.
-       initialize: function() {
-               this.model.bind('change', this.render, this);
-               this.model.bind('destroy', this.remove, this);
-       },
+               // listen for changes to the model and re-render.
+               initialize: function() {
+                       this.model.bind('change', this.render, this);
+                       this.model.bind('destroy', this.remove, this);
+               },
 
-       render: function() {
-               // insert the template into the document.  fill with the 
current model.
-               this.$el.html( this.template( this.model.toJSON() ) );
-               return this;
-       }               
+               render: function() {
+                       // insert the template into the document.  fill with 
the current model.
+                       this.$el.html( this.template( this.model.toJSON() ) );
+                       return this;
+               }               
 
-} );
+       } );
 
-// overall list view
-// currently, this is the main application view.
-ListView = Backbone.View.extend( {
+       // overall list view
+       // currently, this is the main application view.
+       var ListView = Backbone.View.extend( {
 
-       initialize: function() {
+               initialize: function() {
 
-               // these events are triggered when items are added to the 
articles collection
-               articles.bind( 'add', this.addOne, this );
-               articles.bind( 'reset', this.addAll, this );
+                       // these events are triggered when items are added to 
the articles collection
+                       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 );
+                       // 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();
-       },
+                       // on init, make sure to load the contents of the 
collection.
+                       articles.fetch();
+               },
 
-       render: function() {
-               // TODO: refresh the view (show/hide the parts that aren't 
attached to the ListItem view)
-       },
+               render: function() {
+                       // 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 ) {
-               // pass in the specific article instance
-               var view = new ListItem( { model: article } );
-               this.$( "#listView" ).append( view.render().el );
-       },
+               // add a single article to the list
+               addOne: function( article ) {
+                       // pass in the specific article instance
+                       var view = new 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 );
-    }
+               // add all the items in the articles collection
+               addAll: function() {
+                       $("#listView").empty(); // remove the spinner before 
displaying.
+                       articles.each( this.addOne );
+           }
 
+       } );
+
+       var list = new ListView();
 } );
-
-var list = new ListView();


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to