Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | 1x 2x 2x 2x 2x 2x 1x 1x 1x 1x 1x 1x 1x 2x 1x | /*! * VisualEditor ContentEditable CheckListItemNode class. * * @copyright See AUTHORS.txt */ /** * ContentEditable list item node. * * @class * @extends ve.ce.BranchNode * @constructor * @param {ve.dm.CheckListItemNode} model Model to observe * @param {Object} [config] Configuration options */ ve.ce.CheckListItemNode = function VeCeCheckListItemNode() { // Parent constructor ve.ce.CheckListItemNode.super.apply( this, arguments ); this.$element.addClass( 've-ce-checkListItemNode' ); // Events this.model.connect( this, { attributeChange: 'onAttributeChange' } ); this.$element.on( 'click', this.onClick.bind( this ) ); this.updateChecked(); }; /* Inheritance */ OO.inheritClass( ve.ce.CheckListItemNode, ve.ce.BranchNode ); /* Static Properties */ ve.ce.CheckListItemNode.static.name = 'checkListItem'; ve.ce.CheckListItemNode.static.tagName = 'li'; ve.ce.CheckListItemNode.static.splitOnEnter = true; /* Methods */ /** * Handle click events on the checkbox * * @param {jQuery.Event} e Click event */ ve.ce.CheckListItemNode.prototype.onClick = function ( e ) { if ( e.target === this.$element[ 0 ] ) { // TODO: This should probably live in ui.Actions. var fragment = this.getRoot().getSurface().getModel().getLinearFragment( this.getOuterRange(), true ); fragment.changeAttributes( { checked: !this.getModel().getAttribute( 'checked' ) } ); } }; /** * @param {string} key Attribute key * @param {string} from Old value * @param {string} to New value */ ve.ce.CheckListItemNode.prototype.onAttributeChange = function ( key ) { if ( key === 'checked' ) { this.updateChecked(); } }; ve.ce.CheckListItemNode.prototype.updateChecked = function () { this.$element.toggleClass( 've-ce-checkListItemNode-checked', !!this.getModel().getAttribute( 'checked' ) ); }; /* Registration */ ve.ce.nodeFactory.register( ve.ce.CheckListItemNode ); |