Index: trunk/extensions/SemanticWatchlist/specials/jquery.watchlistcondition.js |
— | — | @@ -153,7 +153,7 @@ |
154 | 154 | |
155 | 155 | self.doDelete( function( success ) { |
156 | 156 | if ( success ) { |
157 | | - self.slideUp( 'fast' ); |
| 157 | + self.slideUp( 'fast', function() { self.remove(); } ); |
158 | 158 | } |
159 | 159 | else { |
160 | 160 | alert( 'Could not delete the watchlist group.' ); |
Index: trunk/extensions/SemanticWatchlist/specials/SpecialWatchlistConditions.php |
— | — | @@ -70,8 +70,45 @@ |
71 | 71 | $groupsHtml[] = $this->getGroupHtml( $group ); |
72 | 72 | } |
73 | 73 | |
74 | | - $wgOut->addHTML( implode( '', $groupsHtml ) ); |
| 74 | + $wgOut->addHTML( |
| 75 | + '<div id="swl-groups">' . |
| 76 | + implode( '', $groupsHtml ) . |
| 77 | + '</div>' |
| 78 | + ); |
75 | 79 | |
| 80 | + $wgOut->addHTML( Html::rawElement( |
| 81 | + 'fieldset', |
| 82 | + array( |
| 83 | + |
| 84 | + ), |
| 85 | + Html::element( |
| 86 | + 'legend', |
| 87 | + array(), |
| 88 | + wfMsg( 'swl-group-add-new-group' ) |
| 89 | + ) . |
| 90 | + Html::element( |
| 91 | + 'span', |
| 92 | + array(), |
| 93 | + wfMsg( 'swl-group-name' ) |
| 94 | + ) . ' ' . |
| 95 | + Html::element( |
| 96 | + 'input', |
| 97 | + array( |
| 98 | + 'type' => 'text', |
| 99 | + 'value' => '', |
| 100 | + 'id' => 'swl-add-group-name' |
| 101 | + ) |
| 102 | + ) . ' ' . |
| 103 | + Html::element( |
| 104 | + 'input', |
| 105 | + array( |
| 106 | + 'type' => 'button', |
| 107 | + 'value' => wfMsg( 'swl-group-add-group' ), |
| 108 | + 'id' => 'swl-add-group-button' |
| 109 | + ) |
| 110 | + ) |
| 111 | + ) ); |
| 112 | + |
76 | 113 | $wgOut->addHTML( Html::element( |
77 | 114 | 'input', |
78 | 115 | array( |
Index: trunk/extensions/SemanticWatchlist/specials/ext.swl.watchlistconditions.js |
— | — | @@ -17,9 +17,7 @@ |
18 | 18 | return element.attr( attribute ).split( separator ); |
19 | 19 | } |
20 | 20 | |
21 | | - $( '.swl_group' ).each(function( index, domElement ) { |
22 | | - var element = $( domElement ); |
23 | | - |
| 21 | + function initGroupElement( element ) { |
24 | 22 | element.watchlistcondition( |
25 | 23 | { |
26 | 24 | name: element.attr( 'groupname' ), |
— | — | @@ -30,11 +28,75 @@ |
31 | 29 | concepts: getSplitAttrValue( element, 'concepts', '|' ) |
32 | 30 | }, |
33 | 31 | {} |
34 | | - ); |
| 32 | + ); |
| 33 | + } |
| 34 | + |
| 35 | + $( '.swl_group' ).each(function( index, domElement ) { |
| 36 | + initGroupElement( $( domElement ) ); |
35 | 37 | }); |
36 | 38 | |
37 | 39 | $( '#swl-save-all' ).click( function() { |
38 | 40 | $( '.swl-save' ).click(); |
39 | 41 | } ); |
40 | 42 | |
| 43 | + function addGroupToDB( groupName, callback ) { |
| 44 | + $.getJSON( |
| 45 | + wgScriptPath + '/api.php', |
| 46 | + { |
| 47 | + 'action': 'addswlgroup', |
| 48 | + 'format': 'json', |
| 49 | + 'name': groupName, |
| 50 | + 'properties': '' |
| 51 | + }, |
| 52 | + function( data ) { |
| 53 | + callback( data.success, data.group ); |
| 54 | + } |
| 55 | + ); |
| 56 | + } |
| 57 | + |
| 58 | + function addGroupToGUI( groupName, groupId ) { |
| 59 | + var newGroup = $( '<fieldset />' ).attr( { |
| 60 | + 'id': 'swl_group_' + groupId, |
| 61 | + 'groupid': groupId, |
| 62 | + 'class': 'swl_group', |
| 63 | + 'groupname': groupName, |
| 64 | + 'categories': '', |
| 65 | + 'namespaces': '', |
| 66 | + 'properties': '', |
| 67 | + 'concepts': '' |
| 68 | + } ) |
| 69 | + .html( $( '<legend />' ).text( groupName ) ); |
| 70 | + |
| 71 | + $( '#swl-groups' ).append( newGroup ); |
| 72 | + |
| 73 | + initGroupElement( newGroup ); |
| 74 | + } |
| 75 | + |
| 76 | + $( '#swl-add-group-button' ).click( function() { |
| 77 | + var input = $( '#swl-add-group-name' ); |
| 78 | + var button = this; |
| 79 | + |
| 80 | + button.disabled = true; |
| 81 | + input.disabled = true; |
| 82 | + |
| 83 | + addGroupToDB( input.val(), function( success, group ) { |
| 84 | + if ( success ) { |
| 85 | + addGroupToGUI( group.name, group.id ); |
| 86 | + input.val( '' ); |
| 87 | + } |
| 88 | + else { |
| 89 | + alert( 'Could not add the group.' ); |
| 90 | + } |
| 91 | + |
| 92 | + button.disabled = false; |
| 93 | + input.disabled = false; |
| 94 | + } ); |
| 95 | + } ); |
| 96 | + |
| 97 | + $( '#swl-add-group-name' ).keypress( function( event ) { |
| 98 | + if ( event.which == '13' ) { |
| 99 | + $( '#swl-add-group-button' ).click(); |
| 100 | + } |
| 101 | + } ); |
| 102 | + |
41 | 103 | } ); })(jQuery); |
\ No newline at end of file |
Index: trunk/extensions/SemanticWatchlist/includes/SWL_Group.php |
— | — | @@ -75,7 +75,7 @@ |
76 | 76 | protected function insertIntoDB() { |
77 | 77 | $dbr = wfGetDB( DB_MASTER ); |
78 | 78 | |
79 | | - $dbr->insert( |
| 79 | + $result = $dbr->insert( |
80 | 80 | 'swl_groups', |
81 | 81 | array( |
82 | 82 | 'group_name' => $this->name, |
— | — | @@ -85,6 +85,10 @@ |
86 | 86 | 'group_concepts' => $this->concepts, |
87 | 87 | ) |
88 | 88 | ); |
| 89 | + |
| 90 | + $this->id = $dbr->insertId(); |
| 91 | + |
| 92 | + return $result; |
89 | 93 | } |
90 | 94 | |
91 | 95 | /** |
Index: trunk/extensions/SemanticWatchlist/api/ApiAddWatchlistGroup.php |
— | — | @@ -36,7 +36,23 @@ |
37 | 37 | $params['concepts'] |
38 | 38 | ); |
39 | 39 | |
40 | | - $group->writeToDB(); |
| 40 | + $this->getResult()->addValue( |
| 41 | + null, |
| 42 | + 'success', |
| 43 | + $group->writeToDB() |
| 44 | + ); |
| 45 | + |
| 46 | + $this->getResult()->addValue( |
| 47 | + 'group', |
| 48 | + 'id', |
| 49 | + $group->getId() |
| 50 | + ); |
| 51 | + |
| 52 | + $this->getResult()->addValue( |
| 53 | + 'group', |
| 54 | + 'name', |
| 55 | + $group->getName() |
| 56 | + ); |
41 | 57 | } |
42 | 58 | |
43 | 59 | public function getAllowedParams() { |
Index: trunk/extensions/SemanticWatchlist/SemanticWatchlist.i18n.php |
— | — | @@ -39,6 +39,8 @@ |
40 | 40 | 'swl-group-concept' => 'concept', |
41 | 41 | 'swl-group-confirmdelete' => 'Are you sure you want to delete the "$1" watchlist group?', |
42 | 42 | 'swl-group-save-all' => 'Save all', |
| 43 | + 'swl-group-add-new-group' => 'Add a new group', |
| 44 | + 'swl-group-add-group' => 'Add group', |
43 | 45 | |
44 | 46 | // Special:SemanticWatchlist |
45 | 47 | 'swl-watchlist-position' => "Showing '''$1''' of the last changes starting with '''#$2'''.", |