summaryrefslogtreecommitdiffstats
path: root/wp-admin/js
diff options
context:
space:
mode:
authordonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2008-06-13 17:21:00 +0000
committerdonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2008-06-13 17:21:00 +0000
commit12de05107e4c8b006bde6ee8916f34eb476d08da (patch)
tree123ee54ecd1f3f777373b7df54a4604012d43640 /wp-admin/js
parente51c7a9ca4bfdb45fa3ec7334bd33871e78c68b1 (diff)
downloadwordpress-mu-12de05107e4c8b006bde6ee8916f34eb476d08da.tar.gz
wordpress-mu-12de05107e4c8b006bde6ee8916f34eb476d08da.tar.xz
wordpress-mu-12de05107e4c8b006bde6ee8916f34eb476d08da.zip
WP Merge with revision 8075
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@1328 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-admin/js')
-rw-r--r--wp-admin/js/forms.js51
-rw-r--r--wp-admin/js/gallery.js20
-rw-r--r--wp-admin/js/media-upload.js6
-rw-r--r--wp-admin/js/post.js2
-rw-r--r--wp-admin/js/theme-preview.js44
-rw-r--r--wp-admin/js/word-count.js39
-rw-r--r--wp-admin/js/wp-gears.js83
7 files changed, 215 insertions, 30 deletions
diff --git a/wp-admin/js/forms.js b/wp-admin/js/forms.js
index 6cb2cb7..39ec66b 100644
--- a/wp-admin/js/forms.js
+++ b/wp-admin/js/forms.js
@@ -1,31 +1,26 @@
-function checkAll(form) {
- for (i = 0, n = form.elements.length; i < n; i++) {
- if(form.elements[i].type == "checkbox" && !(form.elements[i].getAttribute('onclick',2))) {
- if(form.elements[i].checked == true)
- form.elements[i].checked = false;
- else
- form.elements[i].checked = true;
- }
- }
+function checkAll(jQ) { // use attr( checked, fn )
+ jQuery(jQ).find( 'tbody :checkbox' ).attr( 'checked', function() {
+ return jQuery(this).attr( 'checked' ) ? '' : 'checked';
+ } );
}
-function getNumChecked(form) {
- var num = 0;
- for (i = 0, n = form.elements.length; i < n; i++) {
- if (form.elements[i].type == "checkbox") {
- if (form.elements[i].checked == true)
- num++;
+jQuery( function($) {
+ var lastClicked = false;
+ $( 'tbody :checkbox' ).click( function(e) {
+ if ( 'undefined' == e.shiftKey ) { return true; }
+ if ( e.shiftKey ) {
+ if ( !lastClicked ) { return true; }
+ var checks = $( lastClicked ).parents( 'form:first' ).find( ':checkbox' );
+ var first = checks.index( lastClicked );
+ var last = checks.index( this );
+ if ( 0 < first && 0 < last && first != last ) {
+ checks.slice( first, last ).attr( 'checked', $( this ).is( ':checked' ) ? 'checked' : '' );
+ }
}
- }
- return num;
-}
-
-function checkAllUsers(role) {
- var checkboxs = document.getElementsByTagName('input');
- for(var i = 0, inp; inp = checkboxs[i]; i++)
- if(inp.type.toLowerCase() == 'checkbox' && inp.className == role)
- if(inp.checked == false)
- inp.checked = true;
- else
- inp.checked = false;
-}
+ lastClicked = this;
+ return true;
+ } );
+ $( 'thead :checkbox' ).click( function() {
+ checkAll( $(this).parents( 'form:first' ) );
+ } );
+} );
diff --git a/wp-admin/js/gallery.js b/wp-admin/js/gallery.js
new file mode 100644
index 0000000..aae0221
--- /dev/null
+++ b/wp-admin/js/gallery.js
@@ -0,0 +1,20 @@
+jQuery(function($) {
+ var gallerySortable;
+ var gallerySortableInit = function() {
+ gallerySortable = $('#media-items').sortable( {
+ items: '.media-item',
+ placeholder: 'sorthelper',
+ update: galleryReorder
+ } );
+ }
+
+ // When an update has occurred, adjust the order for each item
+ var galleryReorder = function(e, sort) {
+ jQuery.each(sort['instance'].toArray(), function(i, id) {
+ jQuery('#' + id + ' .menu_order input')[0].value = i;
+ });
+ }
+
+ // initialize sortable
+ gallerySortableInit();
+});
diff --git a/wp-admin/js/media-upload.js b/wp-admin/js/media-upload.js
index 506faf8..8c88270 100644
--- a/wp-admin/js/media-upload.js
+++ b/wp-admin/js/media-upload.js
@@ -21,7 +21,10 @@ jQuery(function($) {
if ( tbWindow.size() ) {
tbWindow.width( W - 50 ).height( H - 45 );
$('#TB_iframeContent').width( W - 50 ).height( H - 75 );
- tbWindow.css({marginLeft: '-' + parseInt((( W - 50 ) / 2),10) + 'px'});
+ tbWindow.css({'margin-left': '-' + parseInt((( W - 50 ) / 2),10) + 'px'});
+ if ( ! ( $.browser.msie && $.browser.version.substr(0,1) < 7 ) )
+ tbWindow.css({'top':'20px','margin-top':'0'});
+ $('#TB_title').css({'background-color':'#222','color':'#cfcfcf'});
};
return $('a.thickbox').each( function() {
@@ -34,6 +37,5 @@ jQuery(function($) {
};
$(window).resize( function() { tb_position() } );
- $(document).ready( function() { tb_position() } );
});
diff --git a/wp-admin/js/post.js b/wp-admin/js/post.js
index 9b3313c..a81fc81 100644
--- a/wp-admin/js/post.js
+++ b/wp-admin/js/post.js
@@ -18,6 +18,8 @@ function new_tag_remove_tag() {
}
function tag_update_quickclicks() {
+ if ( jQuery( '#tags-input' ).length == 0 )
+ return;
var current_tags = jQuery( '#tags-input' ).val().split(',');
jQuery( '#tagchecklist' ).empty();
shown = false;
diff --git a/wp-admin/js/theme-preview.js b/wp-admin/js/theme-preview.js
new file mode 100644
index 0000000..43b01cd
--- /dev/null
+++ b/wp-admin/js/theme-preview.js
@@ -0,0 +1,44 @@
+
+jQuery(function($) {
+ if ( 'undefined' == typeof $.fn.pngFix )
+ $.fn.pngFix = function() { return this; }
+
+ var thickDims = function() {
+ var tbWindow = $('#TB_window');
+ var H = $(window).height();
+ var W = $(window).width();
+
+ if ( tbWindow.size() ) {
+ tbWindow.width( W - 90 ).height( H - 60 );
+ $('#TB_iframeContent').width( W - 90 ).height( H - 90 );
+ tbWindow.css({'margin-left': '-' + parseInt((( W - 90 ) / 2),10) + 'px'});
+ if ( ! ( $.browser.msie && $.browser.version.substr(0,1) < 7 ) )
+ tbWindow.css({'top':'30px','margin-top':'0'});
+ };
+
+ return $('a.thickbox').each( function() {
+ var href = $(this).parents('.available-theme').find('.previewlink').attr('href');
+ if ( ! href ) return;
+ href = href.replace(/&width=[0-9]+/g, '');
+ href = href.replace(/&height=[0-9]+/g, '');
+ $(this).attr( 'href', href + '&width=' + ( W - 110 ) + '&height=' + ( H - 100 ) );
+ });
+ };
+
+ thickDims()
+ .click( function() {
+ var alink = $(this).parents('.available-theme').find('.activatelink');
+ var url = alink.attr('href');
+ var text = alink.html();
+
+ $('#TB_title').css({'background-color':'#222','color':'#cfcfcf'});
+ $('#TB_closeAjaxWindow').css({'float':'left'});
+ $('#TB_ajaxWindowTitle').css({'float':'right'})
+ .append('&nbsp;<a href="' + url + '" target="_top" class="tb-theme-preview-link">' + text + '</a>');
+
+ $('#TB_iframeContent').width('100%');
+ return false;
+ } );
+
+ $(window).resize( function() { thickDims() } );
+});
diff --git a/wp-admin/js/word-count.js b/wp-admin/js/word-count.js
new file mode 100644
index 0000000..9e3c1df
--- /dev/null
+++ b/wp-admin/js/word-count.js
@@ -0,0 +1,39 @@
+// Word count
+(function(JQ) {
+ wpWordCount = {
+
+ init : function() {
+ var t = this, last = 0, co = JQ('#content');
+
+ JQ('#wp-word-count').html( wordCountL10n.count.replace( /%d/, '<span id="word-count">0</span>' ) );
+ t.block = 0;
+ t.wc(co.val());
+ co.keyup( function(e) {
+ if ( e.keyCode == last ) return true;
+ if ( 13 == e.keyCode || 8 == last || 46 == last ) t.wc(co.val());
+ last = e.keyCode;
+ return true;
+ });
+ },
+
+ wc : function(tx) {
+ var t = this, w = JQ('#word-count'), tc = 0;
+
+ if ( t.block ) return;
+ t.block = 1;
+
+ setTimeout( function() {
+ if ( tx ) {
+ tx = tx.replace( /<.[^<>]*?>/g, ' ' ).replace( /&nbsp;/gi, ' ' );
+ tx = tx.replace( /[0-9.(),;:!?%#$¿'"_+=\\/-]*/g, '' );
+ tx.replace( /\S\s+/g, function(){tc++;} );
+ }
+ w.html(tc.toString());
+
+ setTimeout( function() { t.block = 0; }, 2000 );
+ }, 1 );
+ }
+ }
+}(jQuery));
+
+jQuery(document).ready( function(){ wpWordCount.init(); } );
diff --git a/wp-admin/js/wp-gears.js b/wp-admin/js/wp-gears.js
new file mode 100644
index 0000000..22b5c00
--- /dev/null
+++ b/wp-admin/js/wp-gears.js
@@ -0,0 +1,83 @@
+
+wpGears = {
+
+ createStore : function() {
+ if ( 'undefined' == typeof google || ! google.gears ) return;
+
+ if ( 'undefined' == typeof localServer )
+ localServer = google.gears.factory.create("beta.localserver");
+
+ store = localServer.createManagedStore(this.storeName());
+ store.manifestUrl = "gears-manifest.php";
+ store.checkForUpdate();
+ this.message();
+ },
+
+ getPermission : function() {
+ if ( 'undefined' != typeof google && google.gears ) {
+ if ( ! google.gears.factory.hasPermission )
+ google.gears.factory.getPermission( 'WordPress', 'images/logo.gif' );
+
+ try {
+ this.createStore();
+ } catch(e) {} // silence if canceled
+ }
+ },
+
+ storeName : function() {
+ var name = window.location.protocol + window.location.host;
+
+ name = name.replace(/[\/\\:*"?<>|;,]+/g, '_'); // gears beta doesn't allow certain chars in the store name
+ name = 'wp_' + name.substring(0, 60); // max length of name is 64 chars
+
+ return name;
+ },
+
+ message : function(show) {
+ var t = this, msg1 = t.I('gears-msg1'), msg2 = t.I('gears-msg2'), msg3 = t.I('gears-msg3'), num = t.I('gears-upd-number'), wait = t.I('gears-wait');
+
+ if ( ! msg1 ) return;
+
+ if ( 'undefined' != typeof google && google.gears ) {
+ if ( google.gears.factory.hasPermission ) {
+ msg1.style.display = msg2.style.display = 'none';
+ msg3.style.display = 'block';
+
+ if ( 'undefined' == typeof store )
+ t.createStore();
+
+ store.oncomplete = function(){wait.innerHTML = (' ' + wpGearsL10n.updateCompleted);};
+ store.onerror = function(){wait.innerHTML = (' ' + wpGearsL10n.error + ' ' + store.lastErrorMessage);};
+ store.onprogress = function(e){if(num) num.innerHTML = (' ' + e.filesComplete + ' / ' + e.filesTotal);};
+ } else {
+ msg1.style.display = msg3.style.display = 'none';
+ msg2.style.display = 'block';
+ }
+ }
+
+ if ( show ) t.I('gears-info-box').style.display = 'block';
+ },
+
+ I : function(id) {
+ return document.getElementById(id);
+ }
+}
+
+function gearsInit() {
+ if ( 'undefined' != typeof google && google.gears ) return;
+
+ var gf = false;
+ if ( 'undefined' != typeof GearsFactory ) { // Firefox
+ gf = new GearsFactory();
+ } else { // IE
+ try {
+ gf = new ActiveXObject('Gears.Factory');
+ } catch (e) {}
+ }
+
+ if ( ! gf ) return;
+ if ( 'undefined' == typeof google ) google = {};
+ if ( ! google.gears ) google.gears = { factory : gf };
+}
+
+gearsInit();