Skip to content

Commit

Permalink
Merge branch 'media-rules'
Browse files Browse the repository at this point in the history
Conflicts:
	test.js
  • Loading branch information
harthur committed Dec 1, 2014
2 parents c679e1d + cfaa0c5 commit a9caacd
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
25 changes: 25 additions & 0 deletions lib/stylesheets.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@ StyleSheet.prototype = extend(ClientMethods, {
}.bind(this), cb);
},

getMediaRules: function(cb) {
this.request('getMediaRules', function(resp) {
return resp.mediaRules.map(function(form) {
return new MediaRule(this.client, form);
}.bind(this));
}.bind(this), cb);
},

update: function(text, cb) {
this.request('update', { text: text, transition: true }, cb);
},
Expand All @@ -77,6 +85,23 @@ StyleSheet.prototype = extend(ClientMethods, {
}
});

function MediaRule(client, rule) {
this.initialize(client, rule.actor);
this.rule = rule;

this.on("matchesChange", function(event) {
this.emit("matches-change", event.matches);
}.bind(this));
}
MediaRule.prototype = extend(ClientMethods, {
get mediaText() {
return this.rule.mediaText;
},

get matches() {
return this.rule.matches;
}
})

function OriginalSource(client, source) {
console.log("source", source);
Expand Down
3 changes: 2 additions & 1 deletion test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ var assert = require('assert'),
FirefoxClient = require("./index");


var url = "file:///Users/harth/repos/sass-wwcode/index.html";
var url = "http://harthur.github.io/bugzilla-todos";

getFirstTab(function(tab) {
tab.DOM.querySelector("#title", function(err, node) {
Expand Down Expand Up @@ -43,6 +43,7 @@ loadUrl(url, function(tab) {
metadata: '' }
*/


/**
* Helper functions
*/
Expand Down

0 comments on commit a9caacd

Please sign in to comment.