Make iPad support usable again, add viewport meta, see #18863
git-svn-id: http://svn.automattic.com/wordpress/trunk@18926 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
1050e0023a
commit
f85e0b3f00
|
@ -584,4 +584,12 @@ foreach ( $_wp_admin_css_colors as $color => $color_info ): ?>
|
|||
</fieldset>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
function _ipad_meta() {
|
||||
if ( strpos($_SERVER['HTTP_USER_AGENT'], 'iPad') !== false ) { ?>
|
||||
<meta name="viewport" id="ipad-viewportmeta" content="width=750, initial-scale=1, maximum-scale=1">
|
||||
<?php
|
||||
}
|
||||
}
|
||||
add_action('admin_head', '_ipad_meta');
|
||||
|
||||
|
|
|
@ -187,7 +187,7 @@ $('.contextual-help-tabs').delegate('a', 'click focus', function(e) {
|
|||
|
||||
$(document).ready( function() {
|
||||
var lastClicked = false, checks, first, last, checked, menu = $('#adminmenu'),
|
||||
pageInput = $('input.current-page'), currentPage = pageInput.val(), folded;
|
||||
pageInput = $('input.current-page'), currentPage = pageInput.val(), folded, vp = document.getElementById('ipad-viewportmeta');
|
||||
|
||||
// admin menu
|
||||
$('#collapse-menu', menu).click(function(){
|
||||
|
@ -356,6 +356,20 @@ $(document).ready( function() {
|
|||
}
|
||||
|
||||
}).triggerHandler('resize');
|
||||
|
||||
// iPad orientation scale fix
|
||||
if ( vp ) {
|
||||
document.body.addEventListener('gesturestart', function(){
|
||||
if ( vp.content.indexOf('maximum-scale=1') != -1 )
|
||||
vp.content = 'width=750px, maximum-scale=5, initial-scale=1';
|
||||
}, false);
|
||||
document.body.addEventListener('gestureend', function(){
|
||||
setTimeout(function(){
|
||||
if ( vp.content.indexOf('maximum-scale=1') == -1 )
|
||||
vp.content = 'width=750px, maximum-scale=1, initial-scale=1';
|
||||
}, 2000);
|
||||
}, false);
|
||||
}
|
||||
});
|
||||
|
||||
// internal use
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,11 +1,11 @@
|
|||
var postboxes;
|
||||
var postboxes, is_iPad = navigator.userAgent.match(/iPad/);
|
||||
|
||||
(function($) {
|
||||
postboxes = {
|
||||
add_postbox_toggles : function(page, args) {
|
||||
this.init(page, args);
|
||||
|
||||
$('.postbox h3, .postbox .handlediv').click( function() {
|
||||
$('.postbox h3, .postbox .handlediv').bind('click.postboxes', function() {
|
||||
var p = $(this).parent('.postbox'), id = p.attr('id');
|
||||
|
||||
if ( 'dashboard_browser_nag' == id )
|
||||
|
@ -26,13 +26,13 @@ var postboxes;
|
|||
e.stopPropagation();
|
||||
});
|
||||
|
||||
$('.postbox a.dismiss').click( function(e) {
|
||||
$('.postbox a.dismiss').bind('click.postboxes', function(e) {
|
||||
var hide_id = $(this).parents('.postbox').attr('id') + '-hide';
|
||||
$( '#' + hide_id ).prop('checked', false).triggerHandler('click');
|
||||
return false;
|
||||
});
|
||||
|
||||
$('.hide-postbox-tog').click( function() {
|
||||
$('.hide-postbox-tog').bind('click.postboxes', function() {
|
||||
var box = $(this).val();
|
||||
|
||||
if ( $(this).prop('checked') ) {
|
||||
|
@ -48,71 +48,13 @@ var postboxes;
|
|||
postboxes._mark_area();
|
||||
});
|
||||
|
||||
$('.columns-prefs input[type="radio"]').click(function(){
|
||||
var num = $(this).val(), i, el, done, ps = $('#poststuff'), move;
|
||||
$('.columns-prefs input[type="radio"]').bind('click.postboxes', function(){
|
||||
var n = parseInt($(this).val(), 10), pb = postboxes;
|
||||
|
||||
num = parseInt(num, 10);
|
||||
|
||||
if ( ps.length ) { // edit pages
|
||||
|
||||
if ( num == 2 ) {
|
||||
$('.wrap').removeClass('columns-1').addClass('columns-2');
|
||||
ps.addClass('has-right-sidebar');
|
||||
|
||||
if ( !$('#side-info-column #side-sortables').length )
|
||||
$('#side-info-column').append( $('#side-sortables') );
|
||||
|
||||
} else if ( num == 1 ) {
|
||||
$('.wrap').removeClass('columns-2').addClass('columns-1');
|
||||
ps.removeClass('has-right-sidebar');
|
||||
|
||||
if ( !$('#post-body-content #side-sortables').length )
|
||||
$('#normal-sortables').before( $('#side-sortables') );
|
||||
}
|
||||
|
||||
} else { // dashboard
|
||||
for ( i = 4; ( i > num && i > 1 ); i-- ) {
|
||||
el = $('#' + postboxes._colname(i) + '-sortables');
|
||||
$('#' + postboxes._colname(i-1) + '-sortables').append(el.children('.postbox'));
|
||||
el.parent().hide();
|
||||
}
|
||||
|
||||
for ( i = num; i > 0; i-- ) {
|
||||
el = $('#' + postboxes._colname(i) + '-sortables');
|
||||
done = false;
|
||||
|
||||
if ( el.parent().is(':hidden') ) {
|
||||
switch ( i ) {
|
||||
case 4:
|
||||
move = $('.postbox:visible', $('#column3-sortables'));
|
||||
if ( move.length > 1 ) {
|
||||
el.append( move.last() );
|
||||
done = true;
|
||||
}
|
||||
case 3:
|
||||
move = $('.postbox:visible', $('#side-sortables'));
|
||||
if ( !done && move.length > 1 ) {
|
||||
el.append( move.last() );
|
||||
done = true;
|
||||
}
|
||||
case 2:
|
||||
move = $('.postbox:visible', $('#normal-sortables'));
|
||||
if ( !done && move.length > 1 ) {
|
||||
el.append( move.last() );
|
||||
done = true;
|
||||
}
|
||||
default:
|
||||
if ( !done )
|
||||
el.addClass('empty-container')
|
||||
}
|
||||
|
||||
el.parent().show();
|
||||
}
|
||||
}
|
||||
|
||||
$('.postbox-container:visible').css('width', 100/num + '%');
|
||||
if ( n ) {
|
||||
pb._pb_edit(n);
|
||||
pb.save_order(page);
|
||||
}
|
||||
postboxes.save_order(page);
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -137,7 +79,6 @@ var postboxes;
|
|||
}
|
||||
|
||||
postboxes.save_order(page);
|
||||
ui.item.parent().removeClass('temp-border');
|
||||
},
|
||||
receive: function(e,ui) {
|
||||
if ( 'dashboard_browser_nag' == ui.item[0].id )
|
||||
|
@ -146,6 +87,12 @@ var postboxes;
|
|||
postboxes._mark_area();
|
||||
}
|
||||
});
|
||||
|
||||
if ( navigator.userAgent.match(/iPad/) ) {
|
||||
$(document.body).bind('orientationchange', function(){ postboxes._pb_change(); });
|
||||
this._pb_change();
|
||||
}
|
||||
|
||||
this._mark_area();
|
||||
},
|
||||
|
||||
|
@ -195,7 +142,7 @@ var postboxes;
|
|||
return '';
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
_mark_area : function() {
|
||||
$('#side-info-column .meta-box-sortables:visible, #dashboard-widgets .meta-box-sortables:visible').each(function(n, el){
|
||||
var t = $(this);
|
||||
|
@ -207,6 +154,85 @@ var postboxes;
|
|||
});
|
||||
},
|
||||
|
||||
_pb_edit : function(n) {
|
||||
var ps = $('#poststuff'), i, el, done, pb = postboxes, visible = $('.postbox-container:visible').length;
|
||||
|
||||
if ( n == visible )
|
||||
return;
|
||||
|
||||
if ( ps.length ) {
|
||||
if ( n == 2 ) {
|
||||
$('.wrap').removeClass('columns-1').addClass('columns-2');
|
||||
ps.addClass('has-right-sidebar');
|
||||
|
||||
if ( !$('#side-info-column #side-sortables').length )
|
||||
$('#side-info-column').append( $('#side-sortables') );
|
||||
|
||||
} else if ( n == 1 ) {
|
||||
$('.wrap').removeClass('columns-2').addClass('columns-1');
|
||||
ps.removeClass('has-right-sidebar');
|
||||
|
||||
if ( !$('#post-body-content #side-sortables').length )
|
||||
$('#normal-sortables').before( $('#side-sortables') );
|
||||
}
|
||||
} else {
|
||||
for ( i = 4; ( i > n && i > 1 ); i-- ) {
|
||||
el = $('#' + postboxes._colname(i) + '-sortables');
|
||||
$('#' + postboxes._colname(i-1) + '-sortables').append(el.children('.postbox'));
|
||||
el.parent().hide();
|
||||
}
|
||||
|
||||
for ( i = n; i > 0; i-- ) {
|
||||
el = $('#' + postboxes._colname(i) + '-sortables');
|
||||
done = false;
|
||||
|
||||
if ( el.parent().is(':hidden') ) {
|
||||
switch ( i ) {
|
||||
case 4:
|
||||
done = pb._move_one( el, $('.postbox:visible', $('#column3-sortables')) );
|
||||
case 3:
|
||||
if ( !done )
|
||||
done = pb._move_one( el, $('.postbox:visible', $('#side-sortables')) );
|
||||
case 2:
|
||||
if ( !done )
|
||||
done = pb._move_one( el, $('.postbox:visible', $('#normal-sortables')) );
|
||||
default:
|
||||
if ( !done )
|
||||
el.addClass('empty-container')
|
||||
}
|
||||
|
||||
el.parent().show();
|
||||
}
|
||||
}
|
||||
|
||||
$('.postbox-container:visible').css('width', 100/n + '%');
|
||||
}
|
||||
},
|
||||
|
||||
_pb_change : function() {
|
||||
switch ( window.orientation ) {
|
||||
case 90:
|
||||
case -90:
|
||||
this._pb_edit(2);
|
||||
break;
|
||||
case 0:
|
||||
case 180:
|
||||
if ( $('#poststuff').length )
|
||||
this._pb_edit(1);
|
||||
else
|
||||
this._pb_edit(2);
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
_move_one : function(el, move) {
|
||||
if ( move.length > 1 ) {
|
||||
el.append( move.last() );
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
/* Callbacks */
|
||||
pbshow : false,
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
var postboxes;(function(a){postboxes={add_postbox_toggles:function(c,b){this.init(c,b);a(".postbox h3, .postbox .handlediv").click(function(){var d=a(this).parent(".postbox"),e=d.attr("id");if("dashboard_browser_nag"==e){return}d.toggleClass("closed");postboxes.save_state(c);if(e){if(!d.hasClass("closed")&&a.isFunction(postboxes.pbshow)){postboxes.pbshow(e)}else{if(d.hasClass("closed")&&a.isFunction(postboxes.pbhide)){postboxes.pbhide(e)}}}});a(".postbox h3 a").click(function(d){d.stopPropagation()});a(".postbox a.dismiss").click(function(f){var d=a(this).parents(".postbox").attr("id")+"-hide";a("#"+d).prop("checked",false).triggerHandler("click");return false});a(".hide-postbox-tog").click(function(){var d=a(this).val();if(a(this).prop("checked")){a("#"+d).show();if(a.isFunction(postboxes.pbshow)){postboxes.pbshow(d)}}else{a("#"+d).hide();if(a.isFunction(postboxes.pbhide)){postboxes.pbhide(d)}}postboxes.save_state(c);postboxes._mark_area()});a('.columns-prefs input[type="radio"]').click(function(){var f=a(this).val(),g,h,e,j=a("#poststuff"),d;f=parseInt(f,10);if(j.length){if(f==2){a(".wrap").removeClass("columns-1").addClass("columns-2");j.addClass("has-right-sidebar");if(!a("#side-info-column #side-sortables").length){a("#side-info-column").append(a("#side-sortables"))}}else{if(f==1){a(".wrap").removeClass("columns-2").addClass("columns-1");j.removeClass("has-right-sidebar");if(!a("#post-body-content #side-sortables").length){a("#normal-sortables").before(a("#side-sortables"))}}}}else{for(g=4;(g>f&&g>1);g--){h=a("#"+postboxes._colname(g)+"-sortables");a("#"+postboxes._colname(g-1)+"-sortables").append(h.children(".postbox"));h.parent().hide()}for(g=f;g>0;g--){h=a("#"+postboxes._colname(g)+"-sortables");e=false;if(h.parent().is(":hidden")){switch(g){case 4:d=a(".postbox:visible",a("#column3-sortables"));if(d.length>1){h.append(d.last());e=true}case 3:d=a(".postbox:visible",a("#side-sortables"));if(!e&&d.length>1){h.append(d.last());e=true}case 2:d=a(".postbox:visible",a("#normal-sortables"));if(!e&&d.length>1){h.append(d.last());e=true}default:if(!e){h.addClass("empty-container")}}h.parent().show()}}a(".postbox-container:visible").css("width",100/f+"%")}postboxes.save_order(c)})},init:function(c,b){a.extend(this,b||{});a("#wpbody-content").css("overflow","hidden");a(".meta-box-sortables").sortable({placeholder:"sortable-placeholder",connectWith:".meta-box-sortables",items:".postbox",handle:".hndle",cursor:"move",distance:2,tolerance:"pointer",forcePlaceholderSize:true,helper:"clone",opacity:0.65,stop:function(f,d){if(a(this).find("#dashboard_browser_nag").is(":visible")&&"dashboard_browser_nag"!=this.firstChild.id){a(this).sortable("cancel");return}postboxes.save_order(c);d.item.parent().removeClass("temp-border")},receive:function(f,d){if("dashboard_browser_nag"==d.item[0].id){a(d.sender).sortable("cancel")}postboxes._mark_area()}});this._mark_area()},save_state:function(d){var b=a(".postbox").filter(".closed").map(function(){return this.id}).get().join(","),c=a(".postbox").filter(":hidden").map(function(){return this.id}).get().join(",");a.post(ajaxurl,{action:"closed-postboxes",closed:b,hidden:c,closedpostboxesnonce:jQuery("#closedpostboxesnonce").val(),page:d})},save_order:function(c){var b,d=a(".columns-prefs input:checked").val()||0;b={action:"meta-box-order",_ajax_nonce:a("#meta-box-order-nonce").val(),page_columns:d,page:c};a(".meta-box-sortables").each(function(){b["order["+this.id.split("-")[0]+"]"]=a(this).sortable("toArray").join(",")});a.post(ajaxurl,b)},_colname:function(b){switch(b){case 1:return"normal";break;case 2:return"side";break;case 3:return"column3";break;case 4:return"column4";break;default:return""}},_mark_area:function(){a("#side-info-column .meta-box-sortables:visible, #dashboard-widgets .meta-box-sortables:visible").each(function(d,c){var b=a(this);if(!b.children(".postbox:visible").length){b.addClass("empty-container")}else{b.removeClass("empty-container")}})},pbshow:false,pbhide:false}}(jQuery));
|
||||
var postboxes,is_iPad=navigator.userAgent.match(/iPad/);(function(a){postboxes={add_postbox_toggles:function(c,b){this.init(c,b);a(".postbox h3, .postbox .handlediv").bind("click.postboxes",function(){var d=a(this).parent(".postbox"),e=d.attr("id");if("dashboard_browser_nag"==e){return}d.toggleClass("closed");postboxes.save_state(c);if(e){if(!d.hasClass("closed")&&a.isFunction(postboxes.pbshow)){postboxes.pbshow(e)}else{if(d.hasClass("closed")&&a.isFunction(postboxes.pbhide)){postboxes.pbhide(e)}}}});a(".postbox h3 a").click(function(d){d.stopPropagation()});a(".postbox a.dismiss").bind("click.postboxes",function(f){var d=a(this).parents(".postbox").attr("id")+"-hide";a("#"+d).prop("checked",false).triggerHandler("click");return false});a(".hide-postbox-tog").bind("click.postboxes",function(){var d=a(this).val();if(a(this).prop("checked")){a("#"+d).show();if(a.isFunction(postboxes.pbshow)){postboxes.pbshow(d)}}else{a("#"+d).hide();if(a.isFunction(postboxes.pbhide)){postboxes.pbhide(d)}}postboxes.save_state(c);postboxes._mark_area()});a('.columns-prefs input[type="radio"]').bind("click.postboxes",function(){var e=parseInt(a(this).val(),10),d=postboxes;if(e){d._pb_edit(e);d.save_order(c)}})},init:function(c,b){a.extend(this,b||{});a("#wpbody-content").css("overflow","hidden");a(".meta-box-sortables").sortable({placeholder:"sortable-placeholder",connectWith:".meta-box-sortables",items:".postbox",handle:".hndle",cursor:"move",distance:2,tolerance:"pointer",forcePlaceholderSize:true,helper:"clone",opacity:0.65,stop:function(f,d){if(a(this).find("#dashboard_browser_nag").is(":visible")&&"dashboard_browser_nag"!=this.firstChild.id){a(this).sortable("cancel");return}postboxes.save_order(c)},receive:function(f,d){if("dashboard_browser_nag"==d.item[0].id){a(d.sender).sortable("cancel")}postboxes._mark_area()}});if(navigator.userAgent.match(/iPad/)){a(document.body).bind("orientationchange",function(){postboxes._pb_change()});this._pb_change()}this._mark_area()},save_state:function(d){var b=a(".postbox").filter(".closed").map(function(){return this.id}).get().join(","),c=a(".postbox").filter(":hidden").map(function(){return this.id}).get().join(",");a.post(ajaxurl,{action:"closed-postboxes",closed:b,hidden:c,closedpostboxesnonce:jQuery("#closedpostboxesnonce").val(),page:d})},save_order:function(c){var b,d=a(".columns-prefs input:checked").val()||0;b={action:"meta-box-order",_ajax_nonce:a("#meta-box-order-nonce").val(),page_columns:d,page:c};a(".meta-box-sortables").each(function(){b["order["+this.id.split("-")[0]+"]"]=a(this).sortable("toArray").join(",")});a.post(ajaxurl,b)},_colname:function(b){switch(b){case 1:return"normal";break;case 2:return"side";break;case 3:return"column3";break;case 4:return"column4";break;default:return""}},_mark_area:function(){a("#side-info-column .meta-box-sortables:visible, #dashboard-widgets .meta-box-sortables:visible").each(function(d,c){var b=a(this);if(!b.children(".postbox:visible").length){b.addClass("empty-container")}else{b.removeClass("empty-container")}})},_pb_edit:function(h){var g=a("#poststuff"),d,e,b,c=postboxes,f=a(".postbox-container:visible").length;if(h==f){return}if(g.length){if(h==2){a(".wrap").removeClass("columns-1").addClass("columns-2");g.addClass("has-right-sidebar");if(!a("#side-info-column #side-sortables").length){a("#side-info-column").append(a("#side-sortables"))}}else{if(h==1){a(".wrap").removeClass("columns-2").addClass("columns-1");g.removeClass("has-right-sidebar");if(!a("#post-body-content #side-sortables").length){a("#normal-sortables").before(a("#side-sortables"))}}}}else{for(d=4;(d>h&&d>1);d--){e=a("#"+postboxes._colname(d)+"-sortables");a("#"+postboxes._colname(d-1)+"-sortables").append(e.children(".postbox"));e.parent().hide()}for(d=h;d>0;d--){e=a("#"+postboxes._colname(d)+"-sortables");b=false;if(e.parent().is(":hidden")){switch(d){case 4:b=c._move_one(e,a(".postbox:visible",a("#column3-sortables")));case 3:if(!b){b=c._move_one(e,a(".postbox:visible",a("#side-sortables")))}case 2:if(!b){b=c._move_one(e,a(".postbox:visible",a("#normal-sortables")))}default:if(!b){e.addClass("empty-container")}}e.parent().show()}}a(".postbox-container:visible").css("width",100/h+"%")}},_pb_change:function(){switch(window.orientation){case 90:case -90:this._pb_edit(2);break;case 0:case 180:if(a("#poststuff").length){this._pb_edit(1)}else{this._pb_edit(2)}break}},_move_one:function(c,b){if(b.length>1){c.append(b.last());return true}return false},pbshow:false,pbhide:false}}(jQuery));
|
|
@ -61,7 +61,7 @@ function wp_default_scripts( &$scripts ) {
|
|||
|
||||
$scripts->add( 'utils', "/wp-admin/js/utils$suffix.js", false, '20101110' );
|
||||
|
||||
$scripts->add( 'common', "/wp-admin/js/common$suffix.js", array('jquery', 'hoverIntent', 'utils'), '20111005', 1 );
|
||||
$scripts->add( 'common', "/wp-admin/js/common$suffix.js", array('jquery', 'hoverIntent', 'utils'), '20111009', 1 );
|
||||
$scripts->add_script_data( 'common', 'commonL10n', array(
|
||||
'warnDelete' => __("You are about to permanently delete the selected items.\n 'Cancel' to stop, 'OK' to delete.")
|
||||
) );
|
||||
|
@ -305,7 +305,7 @@ function wp_default_scripts( &$scripts ) {
|
|||
|
||||
$scripts->add( 'xfn', "/wp-admin/js/xfn$suffix.js", array('jquery'), '20110524', 1 );
|
||||
|
||||
$scripts->add( 'postbox', "/wp-admin/js/postbox$suffix.js", array('jquery-ui-sortable'), '20111009', 1 );
|
||||
$scripts->add( 'postbox', "/wp-admin/js/postbox$suffix.js", array('jquery-ui-sortable'), '20111009a', 1 );
|
||||
|
||||
$scripts->add( 'post', "/wp-admin/js/post$suffix.js", array('suggest', 'wp-lists', 'postbox'), '20110524', 1 );
|
||||
$scripts->add_script_data( 'post', 'postL10n', array(
|
||||
|
|
Loading…
Reference in New Issue