/* # Movable Type (r) Open Source (C) 2001-2010 Six Apart, Ltd. # This program is distributed under the terms of the # GNU General Public License, version 2. # # $Id: mt.js 3988 2009-07-08 00:05:54Z mjacobs $ */ var pager; var CMSScriptURI; var ScriptURI; var ScriptBaseURI; var StaticURI; var HelpBaseURI; var Lexicon = {}; var itemset_options = {}; if ((!(navigator.appVersion.indexOf('MSIE') != -1) && (parseInt(navigator.appVersion)==4))) { document.write(""); } var origWidth, origHeight; if ((navigator.appName == 'Netscape') && (parseInt(navigator.appVersion) == 4)) { origWidth = innerWidth; origHeight = innerHeight; window.onresize = restore; } function restore () { if (innerWidth != origWidth || innerHeight != origHeight) location.reload(); } function doRebuild (blogID, otherParams) { window.open(CMSScriptURI + '?__mode=rebuild_confirm&blog_id=' + blogID + '&' + otherParams, 'rebuild_blog_' + blogID, 'width=400,height=400,resizable=yes'); } function openManual (section, page) { var url; if (page) url = HelpBaseURI + 'help/' + section + '/' + page + '/'; else if (section) url = HelpBaseURI + 'help/' + section + '/'; else url = HelpBaseURI + 'help/'; window.open(url, 'mt_help', 'scrollbars=yes,status=yes,resizable=yes,toolbar=yes,location=yes,menubar=yes'); return false; } function countMarked (f, nameRestrict) { var count = 0; var e = f.id; if (!e) return 0; if (e.type && e.type == 'hidden') return 1; if (e.value && e.checked) count++; else if (nameRestrict) { for (i=0; i opt['max'])) { alert(trans('You can only act upon a maximum of [_1] [_2].', opt['max'], plural)); return false; } else if (opt['input']) { if (input = prompt(opt['input'])) { f.elements['itemset_action_input'].value = input; } else { return false; } } else if (opt['continue_prompt']) { if (!confirm(opt['continue_prompt'])) { return false; } } if (opt['dialog']) { f.target = "dialog_iframe"; show("dialog-container"); DOM.addEventListener( document.body, "keypress", dialogKeyPress, true ); } } for (var arg in args) { if (f.elements[arg]) f.elements[arg].value = args[arg]; } } f.elements["__mode"].value = mode; f.submit(); } function submitFormConfirm(f, mode, message) { log.warn('submitFormConfirm() deprecated'); if (confirm(message)) { if (f.elements["__mode"] && mode) f.elements["__mode"].value = mode; f.submit(); } } function submitForm(f, mode) { log.warn('submitForm() deprecated'); if (f.elements["__mode"] && mode) f.elements["__mode"].value = mode; f.submit(); } function doPluginAction(f, plural, phrase) { if (!f) { var forms = document.getElementsByTagName( "form" ); for ( var i = 0; i < forms.length; i++ ) { var pas = truth( forms[ i ][ 'plugin_action_selector' ] ); if (pas) { f = forms[ i ]; break; } } } if (!f) return; var sel = f['plugin_action_selector']; if (sel.length && sel[0].options) sel = sel[0]; var action = sel.options[sel.selectedIndex].value; if (action == '0' || action == '') { alert(trans('You must select an action.')); return; } if (itemset_options[action]) { if (itemset_options[action]['js']) { return eval(itemset_options[action]['js'] + '(f,action);'); } } return doForMarkedInThisWindow(f, '', plural, 'id', 'itemset_action', {'action_name': action}, phrase); } function updatePluginAction(s) { var frm = s.form; frm.elements['plugin_action_selector'].value = s[s.selectedIndex].value; // synchronize top and bottom plugin action selection var el = frm[s.name]; for (var i = 0; i < el.length; i++) if (el[i].selectedIndex != s.selectedIndex) el[i].selectedIndex = s.selectedIndex; } function doItemsAreJunk (f, type, plural, nameRestrict) { doForMarkedInThisWindow(f, type, plural, nameRestrict, 'handle_junk', {}, trans('to mark as spam')); } function doItemsAreNotJunk (f, type, plural, nameRestrict) { doForMarkedInThisWindow(f, type, plural, nameRestrict, 'not_junk', {}, trans('to remove spam status')); } function dialogKeyPress(e) { if (e.keyCode == 27) { // escape key... DOM.removeEventListener( document.body, "keypress", dialogKeyPress, true ); closeDialog(); } } function openDialog(f, mode, params) { var url = ScriptURI; url += '?__mode=' + mode; if (params) url += '&' + params; url += '&__type=dialog'; if (window.app) window.app.closeFlyouts(); show("dialog-container"); // handle escape key for closing modal dialog DOM.addEventListener( document.body, "keypress", dialogKeyPress, true ); openDialogUrl(url); if ( document.all && DOM.getElement( "dialog-container" ) ) { DOM.addClassName( "dialog-container", "hidden" ); new Timer(function() { DOM.removeClassName( "dialog-container", "hidden" ); }, 500, 1 ); } return false; } function openDialogUrl(url) { var iframe = getByID("dialog-iframe"); var frame_d = iframe.contentDocument; if (!frame_d) { // Sometimes the contentWindow is unavailable because we've just // unhidden the container div that holds the iframe. If this happens // we have to wait for the contentWindow object to be created // before we can access the document within. This may take an extra // try using a setTimeout on this window. if (iframe.contentWindow) frame_d = iframe.contentWindow.document || iframe.document; } if (frame_d) { frame_d.open(); frame_d.write("