Jdlrobson has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/219489

Change subject: Hygiene: Allow rendering of sections
......................................................................

Hygiene: Allow rendering of sections

In the long term perfect future we would be able to use this on
server side when combined with Parsoid.

Change-Id: I76f58051aaed04053da5c637fb491068be936984
---
M includes/Resources.php
M resources/mobile.startup/Section.hogan
M resources/mobile.startup/Section.js
A resources/mobile.startup/heading.hogan
M tests/qunit/mobile.startup/test_PageApi.js
5 files changed, 23 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend 
refs/changes/89/219489/1

diff --git a/includes/Resources.php b/includes/Resources.php
index 1466e6a..e0fb723 100644
--- a/includes/Resources.php
+++ b/includes/Resources.php
@@ -494,6 +494,8 @@
                        'button.hogan' => 
'resources/mobile.startup/button.hogan',
                ),
                'messages' => array(
+                       // Sections.js
+                       'edit',
                        // icons.js
                        'mobile-frontend-loading-message',
                        'mobile-frontend-console-recruit',
diff --git a/resources/mobile.startup/Section.hogan 
b/resources/mobile.startup/Section.hogan
index 0ad5fdb..b3d3eaa 100644
--- a/resources/mobile.startup/Section.hogan
+++ b/resources/mobile.startup/Section.hogan
@@ -1,2 +1,2 @@
-{{#line}}<h{{level}} id="{{anchor}}">{{{line}}}</h{{level}}>{{/line}}
-{{{text}}}
+{{#line}}<h{{level}} 
id="{{anchor}}"><span>{{{line}}}</span>{{#editIcon}}{{>icon}}{{/editIcon}}</h{{level}}>{{/line}}
+<div>{{{text}}}</div>
diff --git a/resources/mobile.startup/Section.js 
b/resources/mobile.startup/Section.js
index 95c1515..90458a5 100644
--- a/resources/mobile.startup/Section.js
+++ b/resources/mobile.startup/Section.js
@@ -2,6 +2,7 @@
 
        var View = M.require( 'View' ),
                Section,
+               Icon = M.require( 'Icon' ),
                icons = M.require( 'icons' );
 
        /**
@@ -11,13 +12,18 @@
         */
        Section = View.extend( {
                template: mw.template.get( 'mobile.startup', 'Section.hogan' ),
+               templatePartials: {
+                       icon: Icon.prototype.template
+               },
                /**
                 * @cfg {Object} defaults Default options hash.
                 * @cfg {String} defaults.text Section text.
+                * @cfg {Object} defaults.editIcon options for an edit button.
                 * @cfg {String} defaults.spinner HTML of the spinner icon.
                 */
                defaults: {
                        line: undefined,
+                       editIcon:  undefined,
                        text: '',
                        spinner: icons.spinner().toHtmlString()
                },
@@ -29,6 +35,13 @@
                        this.text = options.text;
                        this.hasReferences = options.hasReferences || false;
                        this.id = options.id || null;
+                       options.editIcon = new Icon( {
+                               href: '#/editor/' + options.id,
+                               name: 'edit-enabled',
+                               title: mw.msg( 'edit' ),
+                               label: mw.msg( 'edit' ),
+                               additionalClassNames: 'edit-page'
+                       } ).options;
                        this.anchor = options.anchor;
                        this.children = [];
                        $.each( options.children || [], function () {
diff --git a/resources/mobile.startup/heading.hogan 
b/resources/mobile.startup/heading.hogan
new file mode 100644
index 0000000..0933979
--- /dev/null
+++ b/resources/mobile.startup/heading.hogan
@@ -0,0 +1 @@
+{{#line}}<h{{level}} 
id="{{anchor}}"><span>{{{line}}}</span>{{#editIcon}}{{>icon}}{{/editIcon}}</h{{level}}>{{/line}}
\ No newline at end of file
diff --git a/tests/qunit/mobile.startup/test_PageApi.js 
b/tests/qunit/mobile.startup/test_PageApi.js
index 195c5a4..554a10e 100644
--- a/tests/qunit/mobile.startup/test_PageApi.js
+++ b/tests/qunit/mobile.startup/test_PageApi.js
@@ -83,7 +83,7 @@
                                                line: '1',
                                                anchor: '1',
                                                id: 1,
-                                               text: '<p>Text of 1\n</p><h2 
id="1.1"><i>1.1</i></h2>\n<p>Text of 1.1\n</p>\n',
+                                               text: '<p>Text of 1\n</p><h2 
id="1.1"><span><i>1.1</i></span></h2>\n<div><p>Text of 1.1\n</p></div>\n',
                                                children: [
                                                        {
                                                                level: '2',
@@ -100,7 +100,7 @@
                                                line: '2',
                                                anchor: '2',
                                                id: 3,
-                                               text: '<p>Text of 2\n</p><h2 
id="2.1">2.1</h2>\n<p>Text of 2.1\n</p>\n',
+                                               text: '<p>Text of 2\n</p><h2 
id="2.1"><span>2.1</span></h2>\n<div><p>Text of 2.1\n</p></div>\n',
                                                children: [
                                                        {
                                                                level: '2',
@@ -196,7 +196,7 @@
                                                line: 'Aaa section',
                                                anchor: 'Aaa_section',
                                                id: 1,
-                                               text: 'aaa content<h3 
id="Subaaa_section">Subaaa section</h3>\nsubaaa content\n',
+                                               text: 'aaa content<h3 
id="Subaaa_section"><span>Subaaa section</span></h3>\n<div>subaaa 
content</div>\n',
                                                children: [
                                                        {
                                                                level: '3',
@@ -394,7 +394,7 @@
                                line: 'A1',
                                level: '2',
                                anchor: '1.0',
-                               text: '<h3 id="">A2.1</h3>\n\n',
+                               text: '<h3 
id=""><span>A2.1</span></h3>\n<div></div>\n',
                                children: [ {
                                        line: 'A2.1',
                                        level: '3',
@@ -414,7 +414,7 @@
                                line: 'A2',
                                level: '1',
                                anchor: '',
-                               text: '<h2 id="">A2.1</h2>\n\n',
+                               text: '<h2 
id=""><span>A2.1</span></h2>\n<div></div>\n',
                                children: [ {
                                        line: 'A2.1',
                                        level: '2',

-- 
To view, visit https://gerrit.wikimedia.org/r/219489
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I76f58051aaed04053da5c637fb491068be936984
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <jrob...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to