diff options
-rwxr-xr-x | css/ninja.css | 2 | ||||
-rwxr-xr-x | js/controllers/styles-controller.js | 79 | ||||
-rw-r--r-- | js/panels/css-panel/rule-list.reel/rule-list.js | 2 | ||||
-rwxr-xr-x | scss/imports/scss/_PanelUI.scss | 4 |
4 files changed, 54 insertions, 33 deletions
diff --git a/css/ninja.css b/css/ninja.css index 212cf831..b71ab79c 100755 --- a/css/ninja.css +++ b/css/ninja.css | |||
@@ -600,7 +600,7 @@ button.panel-button { -webkit-appearance: none; font-size: 9px; color: white; ba | |||
600 | 600 | ||
601 | .panels .panel { min-height: 25px; -webkit-box-flex: 0; display: -webkit-box; -webkit-box-orient: vertical; background: #282828; height: 200px; padding: 0px 2px; -webkit-box-sizing: border-box; } | 601 | .panels .panel { min-height: 25px; -webkit-box-flex: 0; display: -webkit-box; -webkit-box-orient: vertical; background: #282828; height: 200px; padding: 0px 2px; -webkit-box-sizing: border-box; } |
602 | 602 | ||
603 | .panels .panel .panelBody { -webkit-box-flex: 1; -webkit-box-sizing: border-box; -webkit-box-orient: vertical; -webkit-box-align: stretch; position: relative; overflow: auto; height: 200px; } | 603 | .panels .panel .panelBody { -webkit-box-flex: 1; -webkit-box-sizing: border-box; -webkit-box-orient: vertical; -webkit-box-align: stretch; position: relative; } |
604 | 604 | ||
605 | .panel .panelBodyContent { -webkit-box-sizing: border-box; -webkit-box-align: stretch; position: absolute; height: 100%; width: 100%; } | 605 | .panel .panelBodyContent { -webkit-box-sizing: border-box; -webkit-box-align: stretch; position: absolute; height: 100%; width: 100%; } |
606 | 606 | ||
diff --git a/js/controllers/styles-controller.js b/js/controllers/styles-controller.js index 1c1e75ed..0f847653 100755 --- a/js/controllers/styles-controller.js +++ b/js/controllers/styles-controller.js | |||
@@ -604,51 +604,74 @@ var stylesController = exports.StylesController = Montage.create(Component, { | |||
604 | 604 | ||
605 | getRuleIndex : { | 605 | getRuleIndex : { |
606 | value : function(rule) { | 606 | value : function(rule) { |
607 | var rules = nj.toArray(rule.parentStyleSheet.rules), | 607 | var rules = nj.toArray(rule.parentStyleSheet.rules); |
608 | i; | ||
609 | 608 | ||
610 | return rules.indexOf(rule); | 609 | return rules.indexOf(rule); |
611 | } | 610 | } |
612 | }, | 611 | }, |
613 | 612 | ||
613 | _getRuleWithCSSText : { | ||
614 | value: function(cssText, doc) { | ||
615 | var _doc = doc || this.currentDocument.model.views.design._document, | ||
616 | ruleIndex, rule; | ||
617 | |||
618 | for(var i = 0; i < _doc.styleSheets.length; i++) { | ||
619 | ruleIndex = nj.toArray(_doc.styleSheets[i].rules).map(function(rule) { | ||
620 | return rule.cssText; | ||
621 | }).indexOf(cssText); | ||
622 | |||
623 | if(ruleIndex !== -1) { | ||
624 | rule = _doc.styleSheets[i].rules[ruleIndex]; | ||
625 | break; | ||
626 | } | ||
627 | } | ||
628 | |||
629 | if(!rule) { | ||
630 | ///// This should never be hit if providing cssText from existing rule (like those | ||
631 | ///// returned from getMatchedCSSRules() | ||
632 | console.warn('StylesController::_getRuleWithCSSText - No rule found with given cssText.'); | ||
633 | } | ||
634 | |||
635 | return rule; | ||
636 | } | ||
637 | }, | ||
638 | |||
614 | ///// Get All Matching Rules | 639 | ///// Get All Matching Rules |
615 | ///// Returns an array of css rules for an element | 640 | ///// Returns an array of css rules for an element |
616 | ///// Optionally sorted by specificity, and can omit pseudo elements | 641 | ///// Optionally sorted by specificity, and can omit pseudo elements |
617 | 642 | ||
618 | getMatchingRules : { | 643 | getMatchingRules : { //TODO: Remove omitPseudos from here and usages |
619 | value: function(element, omitPseudos, useStageStyleSheet) { | 644 | value: function(element, omitPseudos, useStageStyleSheet) { |
620 | var pseudos = [null], | 645 | var rules, |
621 | rules = [], | 646 | mappedRules, |
622 | win = element.ownerDocument.defaultView, | 647 | doc = element.ownerDocument, |
623 | self = this; | 648 | win = doc.defaultView; |
624 | |||
625 | if(!omitPseudos) { | ||
626 | pseudos.concat(['link', 'visited', 'active', 'hover', 'focus', 'first-letter', | ||
627 | 'first-line', 'first-child', 'before', 'after', 'lang', 'target']); | ||
628 | } | ||
629 | 649 | ||
630 | try { | 650 | try { |
631 | pseudos.forEach(function(pseudo) { | 651 | mappedRules = nj.toArray(win.getMatchedCSSRules(element)).map(function(rule) { |
632 | rules = rules.concat(nj.toArray(win.getMatchedCSSRules(element, pseudo)).filter(function(rule) { | 652 | return this._getRuleWithCSSText(rule.cssText, doc); |
633 | //// useStageStyleSheet flag indicates whether to only return rules from the stylesheet, | 653 | }, this); |
634 | //// or only use rules for other stylesheets | ||
635 | 654 | ||
636 | var sheetId = (rule.parentStyleSheet) ? rule.parentStyleSheet.ownerNode.id : null, | 655 | rules = mappedRules.filter(function(rule) { |
637 | isStageStyleSheet = sheetId === this.CONST.STAGE_SHEET_ID; | 656 | //// useStageStyleSheet flag indicates whether to only return rules from the stylesheet, |
657 | //// or only use rules for other stylesheets | ||
638 | 658 | ||
639 | ///// filter out (return false) depending on flag | 659 | var sheetId = (rule.parentStyleSheet) ? rule.parentStyleSheet.ownerNode.id : null, |
640 | if(useStageStyleSheet && !isStageStyleSheet) { return false; } | 660 | isStageStyleSheet = sheetId === this.CONST.STAGE_SHEET_ID; |
641 | if(!useStageStyleSheet && isStageStyleSheet) { return false; } | ||
642 | 661 | ||
643 | ///// Non-filter code - just assigning specificity to the rule | 662 | ///// filter out (return false) depending on flag |
644 | if(!rule[this.CONST.SPECIFICITY_KEY]) { | 663 | if(useStageStyleSheet && !isStageStyleSheet) { return false; } |
645 | rule[this.CONST.SPECIFICITY_KEY] = this.getSpecificity(rule.selectorText); | 664 | if(!useStageStyleSheet && isStageStyleSheet) { return false; } |
646 | } | ||
647 | 665 | ||
648 | return true; | 666 | ///// Non-filter code - just assigning specificity to the rule |
667 | if(!rule[this.CONST.SPECIFICITY_KEY]) { | ||
668 | rule[this.CONST.SPECIFICITY_KEY] = this.getSpecificity(rule.selectorText); | ||
669 | } | ||
670 | |||
671 | return true; | ||
649 | 672 | ||
650 | }, this)); | ||
651 | }, this); | 673 | }, this); |
674 | |||
652 | } catch(ERROR) { | 675 | } catch(ERROR) { |
653 | console.warn('StylesController::getMatchingRules - Un-attached element queried.'); | 676 | console.warn('StylesController::getMatchingRules - Un-attached element queried.'); |
654 | } | 677 | } |
diff --git a/js/panels/css-panel/rule-list.reel/rule-list.js b/js/panels/css-panel/rule-list.reel/rule-list.js index 27d74b2f..b4cd9e97 100644 --- a/js/panels/css-panel/rule-list.reel/rule-list.js +++ b/js/panels/css-panel/rule-list.reel/rule-list.js | |||
@@ -81,7 +81,7 @@ exports.RuleList = Montage.create(Component, { | |||
81 | // found rule in our component list, or it's the inline rule | 81 | // found rule in our component list, or it's the inline rule |
82 | ruleComponent.update(); | 82 | ruleComponent.update(); |
83 | foundIndices.push(index); | 83 | foundIndices.push(index); |
84 | } else if(!rule.applied) { /// remove rule (unless unapplied) | 84 | } else if(!ruleComponent.applied) { /// remove rule (unless unapplied) |
85 | this.rulesToRemove.push(ruleComponent); | 85 | this.rulesToRemove.push(ruleComponent); |
86 | } | 86 | } |
87 | }, this); | 87 | }, this); |
diff --git a/scss/imports/scss/_PanelUI.scss b/scss/imports/scss/_PanelUI.scss index 543901ad..a03991f9 100755 --- a/scss/imports/scss/_PanelUI.scss +++ b/scss/imports/scss/_PanelUI.scss | |||
@@ -1118,10 +1118,8 @@ button.panel-button { | |||
1118 | -webkit-box-orient: vertical; | 1118 | -webkit-box-orient: vertical; |
1119 | -webkit-box-align: stretch; | 1119 | -webkit-box-align: stretch; |
1120 | position:relative; | 1120 | position:relative; |
1121 | overflow: auto; | ||
1122 | height:200px; | ||
1123 | |||
1124 | } | 1121 | } |
1122 | |||
1125 | .panel .panelBodyContent { | 1123 | .panel .panelBodyContent { |
1126 | -webkit-box-sizing: border-box; | 1124 | -webkit-box-sizing: border-box; |
1127 | -webkit-box-align:stretch; | 1125 | -webkit-box-align:stretch; |