-
Notifications
You must be signed in to change notification settings - Fork 110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Raw merge of qtranslate-slug 1.1.18 as qtranslate-xt module #1060
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b1bf3aa
Raw merge of qtranslate-slug 1.1.8 as qtranslate-xt module
spleen1981 19e9cfb
Format code PHP JS CSS as main project
herrvigg e58a599
Merge https://github.com/qtranslate/qtranslate-xt into slugs-module
herrvigg 0b29534
Reformat PHP in slugs
herrvigg 2cf9637
Use module status defs
herrvigg 5c980b1
Move slugs checkbox to integration panel
herrvigg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
.qts_type_image .qts_lang_item { | ||
float: left; | ||
margin-right: 7px; | ||
} | ||
|
||
.qts_type_image .qts_lang_item.last-child { | ||
margin-right: 0; | ||
} | ||
|
||
.qts_lang_item { | ||
margin-top: 7px; | ||
margin-bottom: 7px; | ||
} | ||
|
||
.qts_both { | ||
white-space: nowrap; | ||
line-height: 1em; | ||
} | ||
|
||
.qts_both img { | ||
margin-right: 4px | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/*messages*/ | ||
.error { | ||
color: #cc0000; | ||
} | ||
|
||
.settings_page_qtranslate-slug-settings .form-table th { | ||
width: 15%; | ||
min-width: 15% !important; | ||
} | ||
|
||
.settings_page_qtranslate-slug-settings .form-table td > span { | ||
display: inline-block; | ||
min-width: 100px; | ||
} | ||
|
||
.settings_page_qtranslate-slug-settings .form-table label { | ||
display: block; | ||
margin-bottom: 8px; | ||
} | ||
|
||
.settings_page_qtranslate-slug-settings .qts-slug { | ||
width: 35%; | ||
} | ||
|
||
#qts-loading { | ||
display: none; | ||
position: relative; | ||
margin-left: 5px; | ||
vertical-align: middle; | ||
} | ||
|
||
div.updated.success { | ||
border-color: #298e00; | ||
background-color: #D4EDC9; | ||
} | ||
|
||
.error a.button-primary { | ||
color: white !important; | ||
text-decoration: none !important; | ||
} | ||
|
||
.ko { | ||
color: #c00; | ||
} | ||
|
||
/* v1.1.18 */ | ||
#edittag #qts_term_slugs { | ||
display: none; | ||
} | ||
|
||
.term-slug-wrap .qts_term_block input { | ||
width: 86.5%; | ||
} | ||
|
||
.qts_term_block label { | ||
display: inline-block; | ||
min-width: 120px; | ||
} | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,165 @@ | ||
jQuery(document).ready(function ($) { | ||
var qts_menuitemlang = []; | ||
// Change titles (and values) when user add new item to the menu: | ||
var oldAddMenuItemToBottom = wpNavMenu.addMenuItemToBottom; | ||
wpNavMenu.addMenuItemToBottom = function (menuMarkup, req) { | ||
oldAddMenuItemToBottom(menuMarkup, req); | ||
saveLang(); | ||
changeTitles(); | ||
}; | ||
var oldAddMenuItemToTop = wpNavMenu.addMenuItemToTop; | ||
wpNavMenu.addMenuItemToTop = function (menuMarkup, req) { | ||
oldAddMenuItemToTop(menuMarkup, req); | ||
saveLang(); | ||
changeTitles(); | ||
}; | ||
|
||
// Change titles (and values) when document is ready: | ||
var lang = $('#qt-languages :radio:checked').val(); | ||
saveLang(); | ||
changeTitles(); | ||
|
||
/** | ||
* Change titles when there is a click on pagination | ||
* on show all pages tab. | ||
* | ||
* It happens when there are a large number of pages. | ||
*/ | ||
$(document).ajaxComplete(function () { | ||
lang = $('#qt-languages :radio:checked').val(); | ||
changeTitles(); | ||
}); | ||
|
||
// Change titles (and values) when language is changed: | ||
$('#qt-languages :radio').change(function () { | ||
lang = $('#qt-languages :radio:checked').val(); | ||
|
||
changeTitles(); | ||
}); | ||
|
||
// Change titles (and values) when new menu is added: | ||
$('.submit-add-to-menu').click(function () { | ||
lang = $('#qt-languages :radio:checked').val(); | ||
changeTitles(); | ||
}); | ||
|
||
// Update original value when user changed a value: | ||
$(document.body).on('change', 'input.edit-menu-item-title', null, function () { | ||
regexp = new RegExp('<!--:' + lang + '-->(.*?)<!--:-->', 'i'); | ||
|
||
|
||
var qts_old_value = qts_menuitemlang[$(this).closest("li").attr("id")][$(this).attr("id")], | ||
qts_new_value = $(this).val(); | ||
|
||
if (regexp.test(qts_old_value)) { | ||
qts_menuitemlang[$(this).closest("li").attr("id")][$(this).attr("id")] = qts_old_value.replace(regexp, '<!--:' + lang + '-->' + qts_new_value + '<!--:-->'); | ||
} | ||
|
||
}); | ||
|
||
|
||
// Update original title="" value when user changed a value: | ||
$(document.body).on('change', 'input.edit-menu-item-attr-title', null, function () { | ||
regexp = new RegExp('<!--:' + lang + '-->(.*?)<!--:-->', 'i'); | ||
var qts_old_value = qts_menuitemlang[$(this).closest("li").attr("id")][$(this).attr("id")], | ||
qts_new_value = $(this).val(); | ||
qts_new_string = '<!--:' + lang + '-->' + qts_new_value + '<!--:-->'; | ||
if (typeof qts_old_value === "undefined" || qts_old_value == "") { | ||
qts_menuitemlang[$(this).closest("li").attr("id")][$(this).attr("id")] = qts_new_string; | ||
$(this).val(qts_new_string); | ||
} else if (regexp.test(qts_old_value)) { | ||
qts_menuitemlang[$(this).closest("li").attr("id")][$(this).attr("id")] = qts_old_value.replace(regexp, qts_new_string); | ||
} else { | ||
$(this).val(qts_old_value + qts_new_string); | ||
qts_menuitemlang[$(this).closest("li").attr("id")][$(this).attr("id")] = qts_old_value + qts_new_string; | ||
} | ||
|
||
}); | ||
|
||
|
||
// Change titles (and values): | ||
function saveLang() { | ||
$('.item-title').each(function () { | ||
qts_menuitemlang[$(this).closest("li").attr("id")] = []; | ||
qts_menuitemlang[$(this).closest("li").attr("id")]['Title'] = $(this).find("span").html(); | ||
|
||
if (typeof qts_menuitemlang[$(this).closest("li").attr("id")]['Original'] === "undefined") { | ||
qts_menuitemlang[$(this).closest("li").attr("id")]['Original'] = qts_menuitemlang[$(this).closest("li").attr("id")]['Title']; | ||
} | ||
}); | ||
$('.menu-item').each(function () { | ||
|
||
this_label = $(this).find('input.edit-menu-item-title'); | ||
this_title = $(this).find('input.edit-menu-item-attr-title'); | ||
|
||
qts_menuitemlang[$(this).attr("id")][this_label.attr("id")] = this_label.val(); | ||
qts_menuitemlang[$(this).attr("id")][this_title.attr("id")] = this_title.val(); | ||
|
||
}); | ||
|
||
} | ||
|
||
// Change titles (and values): | ||
function changeTitles() { | ||
// Change menu item titles and links (on the right side): | ||
// TODO: review, and dump | ||
regexp = new RegExp('<!--:' + lang + '-->(.*?)<!--:-->', 'i'); | ||
$('.item-title').each(function () { | ||
if (matches = qts_menuitemlang[$(this).closest("li").attr("id")]['Original'].match(regexp)) { | ||
$(this).closest('li').find('.link-to-original a').text(matches[1]); | ||
} | ||
|
||
}); | ||
// Change menu item title inputs (on the right side): Navigation Label, Title Attribute... | ||
regexp2 = new RegExp('<!--:' + lang + '-->(.*?)<!--:-->', 'i'); | ||
$('.menu-item').each(function () { | ||
this_label = $(this).find('input.edit-menu-item-title'); | ||
this_title = $(this).find('input.edit-menu-item-attr-title'); | ||
if (lang === "all") { | ||
this_label.val(qts_menuitemlang[$(this).attr("id")][this_label.attr("id")]); | ||
this_title.val(qts_menuitemlang[$(this).attr("id")][this_title.attr("id")]); | ||
} else { | ||
|
||
if (matches = qts_menuitemlang[$(this).attr("id")][this_label.attr("id")].match(regexp2)) { | ||
this_label.val(matches[1]); | ||
} | ||
|
||
if (matches2 = qts_menuitemlang[$(this).attr("id")][this_title.attr("id")].match(regexp2)) { | ||
this_title.val(matches2[1]); | ||
} | ||
} | ||
}); | ||
|
||
// Change menu item checkbox labels (on the left side): | ||
// TODO: fix this, not a show stopper | ||
/*$('label.menu-item-title').each( function() { | ||
var textNode = $(this).contents().get(1); | ||
});*/ | ||
} | ||
|
||
// Restore the original input values: | ||
function restoreValues() { | ||
|
||
$('.menu-item').each(function () { | ||
|
||
this_label = $(this).find('input.edit-menu-item-title'); | ||
this_title = $(this).find('input.edit-menu-item-attr-title'); | ||
|
||
this_label.val(qts_menuitemlang[$(this).attr("id")][this_label.attr("id")]); | ||
this_title.val(qts_menuitemlang[$(this).attr("id")][this_title.attr("id")]); | ||
$(this).find('.link-to-original a').text(qts_menuitemlang[$(this).closest("li").attr("id")]['Original']); | ||
}); | ||
} | ||
|
||
// Just before saving restore the original input values: | ||
$('.menu-save').click(function () { | ||
restoreValues(); | ||
}); | ||
|
||
// Just before leaving the page (or refresh) restore the original input values: | ||
window.onbeforeunload = function () { | ||
restoreValues(); | ||
return; | ||
}; | ||
|
||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should rather enable that if the user checks "enable experimental slugs", so the other way around.
But I see why it is easier like this for now. The module has still the legacy code of the plugin, so the init sequence should be refactored.