]> git.proxmox.com Git - extjs.git/blame - extjs/classic/theme-base/sass/overrides.rb
add extjs 6.0.1 sources
[extjs.git] / extjs / classic / theme-base / sass / overrides.rb
CommitLineData
6527f429
DM
1# These overrides add support for variable-exists(), mixin-exists() and function-exists()\r
2# to SASS 3.1.7. These functions are added to SASS in 3.3, so when Sencha Cmd is upgraded\r
3# to use SASS 3.3 these overrides should be removed.\r
4# Some monkey patching was required to get these methods working, specifically, we had to\r
5# add the "environment" instance variable to EvaluationContext. These patches should be\r
6# removed when Cmd is upgraded to use SASS 3.3. Additionally, if Cmd is upgraded to use\r
7# SASS 3.2, these patches may need to be updated, because the _perform() method underwent\r
8# changes from 3.1 - 3.2\r
9\r
10# These functions are not currently included in the build. To use them, add this file\r
11# to the ruby path. e.g.\r
12# package.sass.rubypath=${package.dir}/sass/utils.rb,${package.dir}/sass/overrides.rb\r
13\r
14module Sass::Script\r
15 class Funcall\r
16 def _perform(environment)\r
17 args = @args.map {|a| a.perform(environment)}\r
18 if fn = environment.function(@name)\r
19 keywords = Sass::Util.map_hash(@keywords) {|k, v| [k, v.perform(environment)]}\r
20 return perform_sass_fn(fn, args, keywords)\r
21 end \r
22\r
23 ruby_name = @name.tr('-', '_')\r
24 args = construct_ruby_args(ruby_name, args, environment)\r
25\r
26 unless Functions.callable?(ruby_name)\r
27 opts(to_literal(args))\r
28 else\r
29 ###############################################################################\r
30 # BEGIN PATCH\r
31 ###############################################################################\r
32 context = Functions::EvaluationContext.new(environment.options)\r
33 context.instance_variable_set('@environment', environment)\r
34 opts(context.send(ruby_name, *args))\r
35 ###############################################################################\r
36 # END PATCH\r
37 ###############################################################################\r
38 end\r
39 rescue ArgumentError => e\r
40 raise e unless e.backtrace.any? {|t| t =~ /:in `(block in )?(#{name}|perform)'$/}\r
41 raise Sass::SyntaxError.new("#{e.message} for `#{name}'")\r
42 end\r
43 end\r
44\r
45 module Functions\r
46 ###################################################################################\r
47 # BEGIN PATCH\r
48 ###################################################################################\r
49 class EvaluationContext\r
50 attr_reader :environment\r
51 end \r
52 ###################################################################################\r
53 # END PATCH\r
54 ###################################################################################\r
55\r
56 def variable_exists(variable_name)\r
57 if(environment.var(variable_name.value))\r
58 Sass::Script::Bool.new(true)\r
59 else\r
60 Sass::Script::Bool.new(false)\r
61 end\r
62 end\r
63\r
64 def mixin_exists(mixin_name)\r
65 if(environment.mixin(mixin_name.value))\r
66 Sass::Script::Bool.new(true)\r
67 else\r
68 Sass::Script::Bool.new(false)\r
69 end\r
70 end\r
71\r
72 def function_exists(function_name)\r
73 if(environment.function(function_name.value))\r
74 Sass::Script::Bool.new(true)\r
75 else\r
76 Sass::Script::Bool.new(false)\r
77 end\r
78 end\r
79 end\r
80end\r
81\r