source: Dev/branches/rest-dojo-ui/client/util/less/tree/url.js @ 256

Last change on this file since 256 was 256, checked in by hendrikvanantwerpen, 13 years ago

Reworked project structure based on REST interaction and Dojo library. As
soon as this is stable, the old jQueryUI branch can be removed (it's
kept for reference).

  • Property svn:executable set to *
File size: 876 bytes
Line 
1(function (tree) {
2
3tree.URL = function (val, paths) {
4    if (val.data) {
5        this.attrs = val;
6    } else {
7        // Add the base path if the URL is relative and we are in the browser
8        if (!/^(?:https?:\/|file:\/|data:\/)?\//.test(val.value) && paths.length > 0 && typeof(window) !== 'undefined') {
9            val.value = paths[0] + (val.value.charAt(0) === '/' ? val.value.slice(1) : val.value);
10        }
11        this.value = val;
12        this.paths = paths;
13    }
14};
15tree.URL.prototype = {
16    toCSS: function () {
17        return "url(" + (this.attrs ? 'data:' + this.attrs.mime + this.attrs.charset + this.attrs.base64 + this.attrs.data
18                                    : this.value.toCSS()) + ")";
19    },
20    eval: function (ctx) {
21        return this.attrs ? this : new(tree.URL)(this.value.eval(ctx), this.paths);
22    }
23};
24
25})(require('less/tree'));
Note: See TracBrowser for help on using the repository browser.