Skip to content

Instantly share code, notes, and snippets.

@jackysee
Created October 23, 2008 03:04
Show Gist options
  • Save jackysee/18906 to your computer and use it in GitHub Desktop.
Save jackysee/18906 to your computer and use it in GitHub Desktop.
Ubiquity Command to set document.body to a input width, auto align to center
CmdUtils.CreateCommand({
name: "page-width",
author: { name: "Jacky See"},
license: "GPL",
description: "Limit the page width by a given parameter, align it to center",
help: "e.g. page-width 400",
takes: {"input": noun_arb_text},
preview: function( pblock, input ) {
var template = "Setting page to width ${w} (default is 500)";
var width = 500; //default width
try{
width = parseInt(input.text);
}catch(ex){}
pblock.innerHTML = CmdUtils.renderTemplate(template, {"w": width});
},
execute: function(input) {
var body = Application.activeWindow.activeTab.document.body;
var width = 500; //default width
try{
width = parseInt(input.text);
}catch(ex){}
if(body){
body.style.width = width + "px";
body.style.margin = "0 auto";
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment