Created
October 23, 2008 03:04
-
-
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
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
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