Skip to content
This repository has been archived by the owner on Sep 2, 2021. It is now read-only.

Commit

Permalink
Improve scripts. #168
Browse files Browse the repository at this point in the history
  • Loading branch information
tfrommen committed Jan 20, 2016
1 parent 3681d1a commit 7a800f0
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 35 deletions.
5 changes: 3 additions & 2 deletions resources/js/admin/common/Common.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@
initializeStateTogglers: function() {
$( '.mlp-state-toggler' ).each( function( index, element ) {
var $toggler = $( element );
$( '[name="' + $toggler.attr( 'name' ) + '"]' )
.on( 'change', { $toggler: $toggler }, this.toggleElementIfChecked );
$( '[name="' + $toggler.attr( 'name' ) + '"]' ).on( 'change', {
$toggler: $toggler
}, this.toggleElementIfChecked );
}.bind( this ) );
},

Expand Down
14 changes: 7 additions & 7 deletions resources/js/admin/nav-menus/NavMenus.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,12 @@
* @param {Event} event - The click event of the submit button.
*/
sendRequest: function( event ) {
var data;
var data = {
action: moduleSettings.action,
menu: this.$menu.val(),
mlp_sites: this.getSites()
};
data[ moduleSettings.nonceName ] = moduleSettings.nonce;

event.preventDefault();

Expand All @@ -64,12 +69,6 @@
*/
this.$spinner.addClass( 'is-active' ).show();

data = {
action: moduleSettings.action,
menu: this.$menu.val(),
mlp_sites: this.getSites()
};
data[ moduleSettings.nonceName ] = moduleSettings.nonce;
this.model.fetch( {
data: data,
processData: true
Expand All @@ -82,6 +81,7 @@
*/
getSites: function() {
var languages = [];

this.$languages.filter( ':checked' ).each( function() {
languages.push( $( this ).val() );
} );
Expand Down
1 change: 1 addition & 0 deletions resources/js/admin/network/AddNewSite.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
* Initializes the AddNewSite module.
*/
initialize: function() {
// Note: First render, then set up the properties, because the targeted elements are not yet in the DOM.
this.render();

this.$language = $( '#mlp-site-language' );
Expand Down
2 changes: 1 addition & 1 deletion resources/js/admin/post-translator/RelationshipControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
*/
updateUnsavedRelationships: function( event ) {
var $input = $( event.target ),
$metaBox = $input.closest( '.mlp_advanced_translator_metabox' ),
$metaBox = $input.closest( '.mlp-translation-meta-box' ),
index = this.findMetaBox( $metaBox ),
stay = 'stay' === $input.val();

Expand Down
2 changes: 1 addition & 1 deletion resources/scss/partials/admin/_advanced_translator.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.mlp_advanced_translator_metabox{
.mlp-translation-meta-box {
@include clearfix();
}

Expand Down
2 changes: 1 addition & 1 deletion src/assets/css/admin.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.mlp_advanced_translator_metabox:after, .mlp-taxonomy-fieldset-container:after, #mlp-quicklink-positions:after, .mlp-rsc-settings:after {
.mlp-translation-meta-box:after, .mlp-taxonomy-fieldset-container:after, #mlp-quicklink-positions:after, .mlp-rsc-settings:after {
content: '';
display: table;
clear: both;
Expand Down
2 changes: 1 addition & 1 deletion src/assets/css/admin.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 21 additions & 19 deletions src/assets/js/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@

$( window.MultilingualPress.initialize );
})( jQuery );


/* global MultilingualPress */
(function( $ ) {
'use strict';
Expand Down Expand Up @@ -137,8 +137,9 @@
initializeStateTogglers: function() {
$( '.mlp-state-toggler' ).each( function( index, element ) {
var $toggler = $( element );
$( '[name="' + $toggler.attr( 'name' ) + '"]' )
.on( 'change', { $toggler: $toggler }, this.toggleElementIfChecked );
$( '[name="' + $toggler.attr( 'name' ) + '"]' ).on( 'change', {
$toggler: $toggler
}, this.toggleElementIfChecked );
}.bind( this ) );
},

Expand Down Expand Up @@ -169,7 +170,7 @@
// Register the Common module for all admin pages.
MultilingualPress.Modules.Common = new Common();
})( jQuery );


/* global ajaxurl, MultilingualPress */
(function( $ ) {
'use strict';
Expand Down Expand Up @@ -222,7 +223,12 @@
* @param {Event} event - The click event of the submit button.
*/
sendRequest: function( event ) {
var data;
var data = {
action: moduleSettings.action,
menu: this.$menu.val(),
mlp_sites: this.getSites()
};
data[ moduleSettings.nonceName ] = moduleSettings.nonce;

event.preventDefault();

Expand All @@ -236,12 +242,6 @@
*/
this.$spinner.addClass( 'is-active' ).show();

data = {
action: moduleSettings.action,
menu: this.$menu.val(),
mlp_sites: this.getSites()
};
data[ moduleSettings.nonceName ] = moduleSettings.nonce;
this.model.fetch( {
data: data,
processData: true
Expand All @@ -254,6 +254,7 @@
*/
getSites: function() {
var languages = [];

this.$languages.filter( ':checked' ).each( function() {
languages.push( $( this ).val() );
} );
Expand Down Expand Up @@ -286,7 +287,7 @@
// Register the NavMenus module for the Menus admin page.
MultilingualPress.registerModule( 'nav-menus.php', 'NavMenus', NavMenus );
})( jQuery );


/* global MultilingualPress */
(function( $ ) {
'use strict';
Expand All @@ -309,6 +310,7 @@
* Initializes the AddNewSite module.
*/
initialize: function() {
// Note: First render, then set up the properties, because the targeted elements are not yet in the DOM.
this.render();

this.$language = $( '#mlp-site-language' );
Expand Down Expand Up @@ -363,7 +365,7 @@
// Register the AddNewSite module for the Add New Site network admin page.
MultilingualPress.registerModule( 'network/site-new.php', 'AddNewSite', AddNewSite );
})( jQuery );


/* global MultilingualPress */
(function( $ ) {
'use strict';
Expand Down Expand Up @@ -482,7 +484,7 @@
// Register the CopyPost module for the Edit Post and Add New Post admin pages.
MultilingualPress.registerModule( [ 'post.php', 'post-new.php' ], 'CopyPost', CopyPost );
})( jQuery );


/* global ajaxurl, MultilingualPress */
(function( $ ) {
'use strict';
Expand Down Expand Up @@ -587,7 +589,7 @@
// Register the RCPostSearch module for the Add New Post and the Edit Post admin pages.
MultilingualPress.registerModule( [ 'post.php', 'post-new.php' ], 'RCPostSearch', RCPostSearch );
})( jQuery );


/* global MultilingualPress */
(function( $ ) {
'use strict';
Expand Down Expand Up @@ -623,7 +625,7 @@
*/
updateUnsavedRelationships: function( event ) {
var $input = $( event.target ),
$metaBox = $input.closest( '.mlp_advanced_translator_metabox' ),
$metaBox = $input.closest( '.mlp-translation-meta-box' ),
index = this.findMetaBox( $metaBox ),
stay = 'stay' === $input.val();

Expand Down Expand Up @@ -666,7 +668,7 @@
// Register the RelationshipControl module for the Add New Post and the Edit Post admin pages.
MultilingualPress.registerModule( [ 'post.php', 'post-new.php' ], 'RelationshipControl', RelationshipControl );
})( jQuery );


/* global ajaxurl, mlpRelationshipControlSettings */
;( function( $, mlpL10n ) {
"use strict";
Expand Down Expand Up @@ -744,7 +746,7 @@
} );

} )( jQuery, mlpRelationshipControlSettings );


/* global MultilingualPress */
(function( $ ) {
'use strict';
Expand Down Expand Up @@ -820,7 +822,7 @@
// Register the TermTranslator module for the Edit Tags admin page.
MultilingualPress.registerModule( 'edit-tags.php', 'TermTranslator', TermTranslator );
})( jQuery );


/* global MultilingualPress */
(function() {
'use strict';
Expand Down

0 comments on commit 7a800f0

Please sign in to comment.