devtools-modules
Advanced tools
Comparing version 0.0.9 to 0.0.10
@@ -24,2 +24,4 @@ const React = require("devtools/client/shared/vendor/react"); | ||
startPanel: PropTypes.any, | ||
// Left/top panel collapse state. | ||
startPanelCollapsed: PropTypes.bool, | ||
// Min panel size. | ||
@@ -31,2 +33,4 @@ minSize: PropTypes.any, | ||
endPanel: PropTypes.any, | ||
// Right/bottom panel collapse state. | ||
endPanelCollapsed: PropTypes.bool, | ||
// True if the right/bottom panel should be controlled. | ||
@@ -48,3 +52,5 @@ endPanelControl: PropTypes.bool, | ||
vert: true, | ||
endPanelControl: false | ||
endPanelControl: false, | ||
endPanelCollapsed: false, | ||
startPanelCollapsed: false | ||
}; | ||
@@ -66,2 +72,8 @@ }, | ||
componentWillReceiveProps(nextProps) { | ||
if (this.props.vert !== nextProps.vert) { | ||
this.setState({ vert: nextProps.vert }); | ||
} | ||
}, | ||
// Dragging Events | ||
@@ -148,26 +160,18 @@ | ||
// Rendering | ||
render() { | ||
preparePanelStyles() { | ||
const vert = this.state.vert; | ||
const { startPanel, endPanel, endPanelControl, minSize, | ||
maxSize, splitterSize } = this.props; | ||
const { | ||
minSize, maxSize, startPanelCollapsed, endPanelControl, | ||
endPanelCollapsed } = this.props; | ||
let leftPanelStyle, rightPanelStyle; | ||
let style = Object.assign({}, this.props.style); | ||
// Calculate class names list. | ||
let classNames = ["split-box"]; | ||
classNames.push(vert ? "vert" : "horz"); | ||
if (this.props.className) { | ||
classNames = classNames.concat(this.props.className.split(" ")); | ||
} | ||
let leftPanelStyle; | ||
let rightPanelStyle; | ||
// Set proper size for panels depending on the current state. | ||
if (vert) { | ||
let startWidth = endPanelControl ? null : this.state.width, | ||
endWidth = endPanelControl ? this.state.width : null; | ||
leftPanelStyle = { | ||
maxWidth: endPanelControl ? null : maxSize, | ||
minWidth: endPanelControl ? null : minSize, | ||
width: endPanelControl ? null : this.state.width | ||
width: startPanelCollapsed ? 0 : startWidth | ||
}; | ||
@@ -177,3 +181,3 @@ rightPanelStyle = { | ||
minWidth: endPanelControl ? minSize : null, | ||
width: endPanelControl ? this.state.width : null | ||
width: endPanelCollapsed ? 0 : endWidth | ||
}; | ||
@@ -193,5 +197,23 @@ } else { | ||
return { leftPanelStyle, rightPanelStyle }; | ||
}, | ||
render() { | ||
const vert = this.state.vert; | ||
const { startPanel, endPanel, endPanelControl, splitterSize } = this.props; | ||
let style = Object.assign({}, this.props.style); | ||
// Calculate class names list. | ||
let classNames = ["split-box"]; | ||
classNames.push(vert ? "vert" : "horz"); | ||
if (this.props.className) { | ||
classNames = classNames.concat(this.props.className.split(" ")); | ||
} | ||
const { leftPanelStyle, rightPanelStyle } = this.preparePanelStyles(); | ||
// Calculate splitter size | ||
let splitterStyle = { | ||
flex: "0 0 " + splitterSize + "px" | ||
flex: `0 0 ${splitterSize}px` | ||
}; | ||
@@ -198,0 +220,0 @@ |
@@ -7,3 +7,2 @@ /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ | ||
/* globals localStorage, window, document, NodeFilter */ | ||
@@ -249,3 +248,3 @@ | ||
localStorage.setItem(PREFIX + this.fullName, JSON.stringify(store)); | ||
localStorage.setItem(PREFIX + this._fullName, JSON.stringify(store)); | ||
this._parent._notify(this._name); | ||
@@ -296,3 +295,3 @@ }, | ||
if (!branch) { | ||
throw new Error("could not find pref branch " + prefName); | ||
throw new Error(`could not find pref branch ${ prefName}`); | ||
} | ||
@@ -330,3 +329,3 @@ } | ||
if (this._parent) { | ||
this._parent._notify(this._name + "." + relativeName); | ||
this._parent._notify(`${this._name }.${ relativeName}`); | ||
} | ||
@@ -347,4 +346,5 @@ }, | ||
if (!parent._children[branch]) { | ||
parent._children[branch] = new PrefBranch(parent, branch, | ||
parent.root + "." + branch); | ||
let isParentRoot = !parent._parent; | ||
let branchName = (isParentRoot ? "" : `${parent.root }.`) + branch; | ||
parent._children[branch] = new PrefBranch(parent, branch, branchName); | ||
} | ||
@@ -363,12 +363,15 @@ parent = parent._children[branch]; | ||
* @param {Any} userValue the user value to use if the pref does not exist | ||
* @param {Boolean} hasUserValue if a new pref is created, whether | ||
* the default value is also a user value | ||
* @param {Any} defaultValue the default value to use if the pref | ||
* does not exist | ||
* @param {Boolean} hasUserValue if a new pref is created, whether | ||
* the default value is also a user value | ||
* @param {Boolean} init if true, then this call is initialization | ||
* from local storage and should override the default prefs | ||
*/ | ||
_findOrCreatePref: function(keyName, userValue, hasUserValue, defaultValue) { | ||
_findOrCreatePref: function(keyName, userValue, hasUserValue, defaultValue, | ||
init = false) { | ||
let branch = this._createBranch(keyName.split(".")); | ||
if (hasUserValue && typeof (userValue) !== typeof (defaultValue)) { | ||
throw new Error("inconsistent values when creating " + keyName); | ||
throw new Error(`inconsistent values when creating ${ keyName}`); | ||
} | ||
@@ -388,9 +391,9 @@ | ||
default: | ||
throw new Error("unhandled argument type: " + typeof (defaultValue)); | ||
throw new Error(`unhandled argument type: ${ typeof (defaultValue)}`); | ||
} | ||
if (branch._type === PREF_INVALID) { | ||
if (init || branch._type === PREF_INVALID) { | ||
branch._storageUpdated(type, userValue, hasUserValue, defaultValue); | ||
} else if (branch._type !== type) { | ||
throw new Error("attempt to change type of pref " + keyName); | ||
throw new Error(`attempt to change type of pref ${ keyName}`); | ||
} | ||
@@ -431,3 +434,3 @@ | ||
_initializeRoot: function() { | ||
if (localStorage.length === 0 && Services._defaultPrefsEnabled) { | ||
if (Services._defaultPrefsEnabled) { | ||
/* eslint-disable no-eval */ | ||
@@ -449,3 +452,3 @@ // let devtools = require("raw!prefs!devtools/client/preferences/devtools"); | ||
this._findOrCreatePref(keyName.slice(PREFIX.length), userValue, | ||
hasUserValue, defaultValue); | ||
hasUserValue, defaultValue, true); | ||
} | ||
@@ -487,5 +490,2 @@ } | ||
get OS() { | ||
if (typeof window == "undefined") { | ||
return "Unknown"; | ||
} | ||
const os = window.navigator.userAgent; | ||
@@ -595,2 +595,18 @@ if (os) { | ||
}, | ||
/** | ||
* An implementation of Services.wm that provides a shim for | ||
* getMostRecentWindow. | ||
*/ | ||
wm: { | ||
getMostRecentWindow: function() { | ||
// Having the returned object implement openUILinkIn is | ||
// sufficient for our purposes. | ||
return { | ||
openUILinkIn: function(url) { | ||
window.open(url, "_blank"); | ||
}, | ||
}; | ||
}, | ||
}, | ||
}; | ||
@@ -611,3 +627,3 @@ | ||
module.exports = Services; | ||
Services.pref = pref; | ||
module.exports = Services; |
{ | ||
"name": "devtools-modules", | ||
"version": "0.0.9", | ||
"version": "0.0.10", | ||
"description": "DevTools Modules from M-C", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
112012
3395