w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Sass mixin to apply to class
You cannot have a mixin that will do both, no. The mixin you would need to generate your second set of code looks like this: @mixin colourCount { &.one { background: rgba(0, 160, 0, 0.5) } &.two { background: rgba(255, 255, 0, 0.6) } } Realistically, you would want to be using @extend for this purpose anyway. %colours { &.one { background: rgba(0, 160, 0, 0.5) } &.two { background: rgba(255, 255, 0, 0.6) } } .foo { @extend %colours; } .bar { .one { @extend %colours.one; } .two { @extend %colours.two; } } Generates: .one.foo, .bar .one { background: rgba(0, 160, 0, 0.5); } .two.foo, .bar .two { background: rgba(255, 255, 0, 0.6); }

Categories : CSS

SASS mixin for grid layout
You might want to have a look at singularitygs! With this sass extension you can write div { @include grid-span(1,1,4,$output-style: 'float'); } The parameters for grid-span are (with, startpos, context, options). All numbers will be converted to ratio-based widths. The above example can be read as: width 1 at position 1 in a grid-context of 4 => width: 25%; margin-left: 0; (ouput-style: 'float' is needed, because you are targeting multiple divs) Or you can define your base grid first, and leave out the context: $grids: 4; div { @include grid-span(1,1,$output-style: 'float'); } You can even go further and use breakpoints to have different grids for different window sizes: $grids: 4; // base grid (mobile first) $grids: add-grid(12 at 980px); // 12-grid for everything

Categories : CSS

What is wrong with my box-shadow SASS @Mixin?
You need to add commas between each component value: .login_window { width: 200px; height: 100px; background: red; @include box-shadow(inset 0, 1px, 1px, rgba(0, 0, 0, 0.5)); } http://codepen.io/anon/pen/GrIuh

Categories : CSS

Generic @mixin for sass with multiple and varied values
From the official documentation: Sass supports “variable arguments,” which are arguments at the end of a mixin declaration that take all leftover arguments and package them up as a list. These arguments look just like normal arguments, but are followed by .... For example: @mixin box-shadow($shadows...) { -moz-box-shadow: $shadows; -webkit-box-shadow: $shadows; box-shadow: $shadows; } .shadows { @include box-shadow(0px 4px 5px #666, 2px 6px 10px #999); }

Categories : CSS

Is it possible to mixin before the constructor is called?
This is wrong: The problem is that apparently initialize is called before the mixins are included, causing this to fail: Contrary to what you wrote, initialize is not called. @subloggers is not initialized for the SomeClass instance. Are you thinking that @subloggers assigned in Logging.included(base) is the same variable as the @subloggers you are accessing from the SomeClass constructor? That should not be the case. An instance variable cannot be created before creation of the instance itself.

Categories : Ruby

Reusable function/mixin for sass function
Basic usage Use the @each loop. @mixin generate($numbers...){ @each $number in $numbers { .item-#{$number} {@content;} } } @include generate(1, 2, 6); Demo: http://sassbin.com/gist/5999585/ Advanced usage You can use the @for loop to have both item and its index. Also, you can use a list of lists to pass multiple values for each element: =generate($items...) @for $i from 1 through length($items) $item: nth($items, $i) $offset: nth($item, 1) $color: nth($item, 2) .block-#{$i} margin-left: $offset background-color: $color +generate(10 red, 20 green, 60 blue) I've switched to the indented .sass syntax to get rid of curly braces and semicolons nuisance. Demo: http://sassbin.com/gist/6007849/ Precaution I hope that your example is synthetic. I

Categories : Function

Use selector name as variable in LESS mixin
Yes, LESS just introduced an extend feature in 1.4.0. Check out the answer to this question here: Does LESS have an "extend" feature?

Categories : CSS

Using Less mixin variable as a property value
The feature is being added (according to the LESS devs), but still hasn't shipped. I'd recommend following the commits on GitHub. Interesting reading in this issue > https://github.com/less/less.js/issues/36

Categories : CSS

Calling a mixin's method on an object that doesn't include that mixin
It sounds like for whatever reason you don't want to modify the class definition to include Enumerable but you can also of course just extend specific instances. So you have indicated that obj implements each so you can just do this: obj.extend(Enumerable).to_a Ah, from your original question I thought the goal was to just not modify the class, so extending the instance was the most logical solution. However, it sounds like you don't want to modify the class or any instance. I would do the following then: obj.to_enum.to_a

Categories : Ruby

Is it ok for a Django mixin to inherit another mixin?
It's perfectly valid for a mixin to inherit from another mixin - in fact, this is how most of Django's more advanced mixins are made. However, the idea of mixins is that they are reusable parts that, together with other classes, build a complete, usable class. Right now, your JSONResponseMixin might as well be a separate class that you don't inherit from, or the methods might just be module-wide methods. It definitely works, there's nothing wrong with it, but that's not the idea of a mixin. If you look at Django's BaseDetailView, you see the following get() method: def get(self, request, *args, **kwargs): self.object = self.get_object() context = self.get_context_data(object=self.object) return self.render_to_response(context) get_object() and get_context_data() are defi

Categories : Ajax

SASS set variable depending on CSS class
I think a mixin is the answer. (As I wrote, variables won’t work.) @mixin content($color-default, $color-main) { background: $color-default; color: $color-main; } body.class-1 { @include content(#444, #555); } body.class-2 { @include content(#666, #777); } That SCSS compiles to this CSS: body.class-1 { background: #444444; color: #555555; } body.class-2 { background: #666666; color: #777777; } If you wanted to group the color values together in your SCSS file, you could use variables in conjunction with the mixin: $color-1: #444; $color-2: #555; $color-3: #666; $color-4: #777; body.class-1 { @include content($color-1, $color-2); } body.class-2 { @include content($color-3, $color-4); }

Categories : CSS

Bootstrap Custom Variable Rails SASS
While we are talking about variables, there's nothing related to CSS. Variables, in this case, are used by SASS/Compass a CSS preprocessor tool, used by Rails to make the use of CSS more easy (eg. by using variables). So when you insert your variables in a file, and let it be processed alone, it wont produce any CSS code unless you make any use of then in a valid CSS attribute. If you want to test it, add to your bootstrap_custom.css something like: body { background-color: $black; } And you will see your $black variable being used.

Categories : Ruby On Rails

What's the industry standard way to pass SASS variable to javascript?
Not sure about "industry standard", but it's a very handy technique and not too difficult. The content of pseudo elements is not available via text() though, you have to use getComputedStyle. Example using body:after: Sass (using the compass breakpoint extension): body:after { display: none; @include breakpoint($bp-wide) { content: "wide"; } @include breakpoint($bp-medium) { content: "medium"; } @include breakpoint($bp-small) { content: "small"; } } JavaScript: if (window.getComputedStyle) { var mq = window.getComputedStyle(document.body,':after').getPropertyValue('content'); } if (mq.indexOf('small') !== -1) { // do something } Credit: I first saw this technique here: https://coderwall.com/p/_ldtkg

Categories : Javascript

Legal characters for SASS and SCSS variable names
If you check out the source for the SASS lexer, you'll see: # A hash of regular expressions that are used for tokenizing. REGULAR_EXPRESSIONS = { :whitespace => /s+/, :comment => COMMENT, :single_line_comment => SINGLE_LINE_COMMENT, :variable => /($)(#{IDENT})/, :ident => /(#{IDENT})(()?/, :number => /(-)?(?:(d*.d+)|(d+))([a-zA-Z%]+)?/, :color => HEXCOLOR, :bool => /(true|false)/, :null => /null/, :ident_op => %r{(#{Regexp.union(*IDENT_OP_NAMES.map{|s| Regexp.new(Regexp.escape(s) + "(?!#{NMCHAR}|)")})})}, :op => %r{(#{Regexp.union(*OP_NAMES)})}, } Which references the IDENT character set defined in a separate file: s = if Sass::Util.ruby1_8? '200-377' elsif Sass::Util.macruby? 'u0080-uD7FFuE000-uFFFDU00010000-U00

Categories : CSS

In a Lua file called foo.lua, what would the difference be between a variable called self.bar, foo.bar, and bar?
Metatables Metatables are used to overload common operations in the language. These operations can include such things as addition, multiplation, equality comparisons and (as the name would imply) table like operations such as accessing a value via a key table[key]. Metatables are often used to implement Object Oriented programming in Lua. The primary mechanism by which this is driven is the use of __index. This example will illustrate this in the most basic form: >>> parent = {parentID = 'Secret'} >>> child = {} >>> setmetatable(child,{__index=parent}) >>> =child.parentID Secret The key parentID doesn't actually exist within child, so nowhere in child is there something like the following: child = { parentID = 'Secret' } Instead, we

Categories : Lua

Install prerelease gem of sass 3.3 failed (sass requires listen (~> 0.7))
No surprise that the pre-release has issues with it. That said, I managed to get it working using gem install sass --version=3.3.0.alpha.184. If you want compass, try using v0.12.2. Then you'd need to run SASS with compass, not SASS. Example: sass --compass --sourcemap styles.scss:styles.css Info from here: https://github.com/chriseppstein/compass/issues/1108

Categories : Ruby

using sass color functions without sass engine
Update Now that I understand your problem better, why not just rewrite the functionality. require 'sass' class Rectangle include Sass::Script def color @color ||= Sass::Script::Color.new([0x82, 0x39, 0x06]) end def lighten(ammount) hsl = color.hsl.dup hsl[2] += ammount @color = Sass::Script::Color.new(hue: hsl[0], saturation: hsl[1], lightness: [2]) end end rec = Rectangle.new rec.lighten(20) Old Answer You aren't crazy, you've just included the wrong piece. This code runs as you expect it. Notice that I removed the ::Functions from the include. require 'sass' class Rectangle include Sass::Script def color color = Sass::Script::Color.new([0x82, 0x39, 0x06]) puts color.class end end rec = Rectangle.new rec.color

Categories : Ruby

How can I use a variable name called "object"?
You can name your field @object: public class FacebookObjectDataData { public FacebookObjectDataDataObject @object { get; set; } public FacebookObjectDataData() { } } So it will not be marked as error. You can do it with other restricted names. For more read here http://msdn.microsoft.com/en-us/library/aa664670.aspx

Categories : C#

Can I pass a VBA variable into a called Powershell script?
You just need to define parameters at the top of your script: param([string]$path) $content = [IO.File]::ReadAllText($path) # etc. In VBA, you need to pass the parameter: Shell("powershell.exe -ExecutionPolicy Unrestricted -File <pathname>Convert_To_Tab_Delimited.ps1 -path """ & pathVariable & """", 1)

Categories : Powershell

Destroy session variable when JS function being called
You are mixing php code with javascript code they dont work together like that you will need to do an ajax call and this is made easy since you are using jQuery. Javascript jQuery(document).ready(function() { jQuery("#LogoutButtonID").click(destroy()); }); function destroy() { jQuery.ajax({ "url":"http://www.example.com/someScriptToLogout.php", "success":function() { alert("i logged out"); } }); } and in someScriptToLogout.php <?php session_start(); $_SESSION['lastVisit'] = "logout";

Categories : PHP

why the c++ constructor was not called when it appear as the static member variable?
from the standard of C++ it should be called when the library was load, right? No. Dynamic initialisation of an object with static storage duration is guaranteed to happen before execution of any function defined in the same translation unit. If there are no such functions, or your program never calls them, then there's no guarantee that it will ever be initialised. I put another static int value using the same way, it could be initialized. but the class constructor is not called , very strange. An int variable is initialised statically, before the program starts, as long as its initialiser is constant. is there any compile option will influence the variable ? Not that I know of, but I'm not familiar with your platform. You could give yourself more control over the object'

Categories : C++

Move assignment is not called for member variable
Your expectations are correct and gcc 4.7.2 does generate the default move assignment, the vector& operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move()) is invoked, just as you expected. So, as DyP points out, it is a not yet implemented feature in Visual Studio 2012.

Categories : C++

How to pass a variable to a method that is called when UIButton is triggered?
You can use UIView's tag property into the button, and then take the value out of the button once it's pressed. something like: - (void)yourAction:(UIButton *)sender{ NSInteger value=[sender tag]; }

Categories : IOS

how to send a variable to a template called by a generic view
In this case there is no need to pass the username to the template if you use djangos auth system. You can access request.user in your template. Have a look here How to access the user profile in a Django template?. Anyway, if you want to pass in additional variables to a generic view, look here How to pass parameters to django generic views.

Categories : Django

Function is called too many times and retains old variable values
Why oh why are you passing data using a global current_deck variable? Each time you enter the updateCurrentDeckTable branch of your add method: if($(ev.target).data("card-id")) { this.card_array.push($(ev.target).data("card-id")); current_deck.push($(ev.target).data("card-id")); updateCurrentDeckTable(); } You're adding another entry to the global current_deck and then updateCurrentDeckTable iterates over that array: $.each(current_deck, function(i, cardId) { ... I don't see anything that clears out current_deck so it will just keep growing. That would explain the odd behavior you're describing. The solution would be to stop using a global for current_deck, just pass it around as an argument and clean it up as needed.

Categories : Javascript

CodeIgniter - What kind of variable can work during controller is called?
You need to call your controller like this: http://localhost:8080/ci/home/group/12 where 12 is your groupid and home is the name of your controller. Use a session for storing your $groupId in the group function: $this->CI->session->set_userdata('groupId', $groupId); To load your $groupId in test use this line of code: $groupId = $this->CI->session->userdata('groupId'); Another solution is (as requested) although it is not best practice, to make a static class called group: <?php class Group { public static $groupId = 12; }?> Then your homecontroller will look like this: include_once 'group.php'; class Home extends CI_Controller { public function __construct() { } public function index() { $this->load->model('product_model'); $

Categories : PHP

this is bound incorrectly if jquery function is called from a stored variable
Yes it does not know the element it is applying fadeOut animation to and this context will be mostly the window and not the jquery object in this case. You can pass the context using function.call Try this: var fadeOutFn = $('#my-div').fadeOut; fadeOutFn.call($('#my-div')); Or just do this: use function.bind to bind the context to the function reference, and invoke it. var fadeOutFn = $().fadeOut.bind($('#my-div')); fadeOutFn(); Read function.bind For non supported browsers you can add this in your js file for support as mentioned in the document: if (!Function.prototype.bind) { Function.prototype.bind = function (oThis) { if (typeof this !== "function") { // closest thing possible to the ECMAScript 5 internal IsCallable function throw new TypeError("Function.pr

Categories : Javascript

Using JS variable to index (pre-loaded) PHP array: "Uncaught Reference Error" even when function isn't called
In that function you have <? echo $Stimulus[1]; ?> before you've defined the $Stimulus array. Move your array definition to the top of your file. These lines must run before you try to access the array in PHP: <?php $Stimulus = array("a","b","c","d"); ?>

Categories : Javascript

Overwrite less mixin
Less works exactly like CSS does in this respect. For example, if you wrote this CSS: p { border: 1px solid black; } It would give all paragraphs a black border. If later in the document you added: p { } You wouldn't expect it to overwrite your previous definition, right? So, in this case it's the expected behaviour, you need to specifically overwrite the CSS values you want to overwrite.

Categories : CSS

Less mixin with optional parameters
To supply a parameter that far down the string of arguments, you have to also supply the expected variable it is to define. So this: .fontStyle('NimbusSansNovCon-Reg', 12px, @letter-spacing: 0.1em); Produces this (note how color, font-weight, and font-style used the defaults): font-family: 'NimbusSansNovCon-Reg'; font-size: 12px; color: #ffffff; font-weight: normal; font-style: normal; letter-spacing: 0.1em;

Categories : CSS

Building a variadic mixin in LESS
Less gets confused with your second and third .color mixin, as they can both take just one argument, and if @rest is passed to the mixin as an argument and is not numeric (i.e. a list or empty) it causes more problems. Also @rest... and ... are tricky with multiple mixins with the same name - it is better to pass the arguments to another set of mixins (as a list to a single argument) and then switch between them using guards or the number of arguments they can take. I would structure the mixins a bit differently (and add a helper mixin .loop that does the looping according to what is passed to .color). The two mixins would then work like this: .color: passes all arguments in @arguments to a single argument in mixin .loop .loop: if the argument is neither a list nor a numeric value ->

Categories : CSS

Passing Variables from one mixin to another in LESS CSS
Your issue is with the variable's scope. Your two variables are defined within the containing block of .divOne and .divTwo, which makes them locally scoped to those code blocks. To resolve that, you need to either make them more globally scoped (i.e. defined outside the containing block that is to use them, but not within another containing block), or scope them locally into the .containgDiv block. Many Options (there are probably more) Note, of the following options, #3 is the only one that directly matches your question title of "Passing variables from one mixin to another." However, the other ways of getting the variables are given to show the flexibility of what can be done, as well as making one aware of the decisions to be made about what is important for that accessibility. 1) Fu

Categories : CSS

less mixin returning Nanpx
The following worked for me when I pasted it into codepen (http://codepen.io/anon/pen/wkFdc). @base-font-size: 12px; @base-scale-factor: 2; @base-line-height: 12px; .rhythm(@font-scale, @margin-top : false, @margin-bottom : false) when (@font-scale > 0) { @new-font-size: round(@base-font-size * pow(@base-scale-factor, @font-scale)); font-size: @new-font-size; line-height: ceil((@new-font-size / (@base-line-height * @base-font-size))) * (@base-line-height * @base-font-size); } .rhythm(@font-scale, @margin-top : false, @margin-bottom : false) when (@font-scale = 0) { @new-font-size: round(@base-font-size * pow(@base-scale-factor, @font-scale)); font-size: @new-font-size; line-height: ceil((@new-font-size / (@base-line-height * @base-font-size))) * (@base-line-he

Categories : CSS

Dojo 1.9 mixin approach
I think you're right on with how to use mixins: they are meant to be small, portable, and specific adjustments to the behavior of other objects. There is no built-in mechanism for mixin idempotency: you would need to manage that on your own. I have never run into this situation in the field, as I tend to declare classes on the fly and the mixin happens right before use. For example, if I were using a mixin for theming, I would do that in my top-level "interface" (responsible for gluing all the widgets together) rather than in each class that can be themed. Mixins can and do hold state. See for example dijit/form/_FormWidgetMixin.js How should mixin's expose functionality? Well, I would say this depends upon the overall design and that there is no right way. My mixins generally just

Categories : Javascript

How to get the Susy +pad mixin to work?
A few things: Unless you use the border-box box-sizing model, padding is added to a span width. If you want an outer span of 9, with a prefix of 1, you need to span 8 and add the prefix. Relative padding is based on the parent element width, not the current element, so span-columns and pad or prefix should always be passed the same context argument. Currently, this is wrong: .image-group-title +span-columns(10, 14) padding: 1em 0 +pad(1,0,10) +trailer(.5) it should be: .image-group-title +span-columns(10, 14) padding: 1em 0 +prefix(1, 14) +trailer(.5) It's not clear in your example what code is applied to the p in question, so very hard to know if I'm actually answering the question, but I hope that helps.

Categories : CSS

LESS: mixin with non-class ruleset
The limitation might just be ease of parsing, since . or # don't show up as the first character of a normal style rule the parser automatically knows that those should be mixed in. You could get around it by defining .c1 as a mixin and using it for both buttons: .c1() { // c1 rules } button.c1 { .c1; } button.c2 { .c1; // additional rules } However, coming up in LESS 1.4.0 are :extend selectors, which will allow you to do what you want. The syntax would be: button.c2:extend(button.c1) { // additional rules }

Categories : CSS

How exactly does Tapestry mixin work?
Tapestry Mixin is a limited version of component that should be attached to another component and can not have its own template. It has access to container parameters and can introduce its own. It is not better than inheritance. It is a different way to change components behaviour. So, what you can do with mixins that can not be done with inheritance: you can change behaviour of core tapestry components you can use more than one mixin for one component Some other words about mixinns: they usually introduce some common logic that can be applied to all components, e.g. submit form on some client event or attach popup with help for some field they can fix some problem with core components, e.g. we have mixin that fixes upload component when it is used in ajax form

Categories : Java

Placeholder Mixin SCSS/CSS
You're looking for the @content directive: @mixin placeholder { ::-webkit-input-placeholder {@content} :-moz-placeholder {@content} ::-moz-placeholder {@content} :-ms-input-placeholder {@content} } @include placeholder { font-style:italic; color: white; font-weight:100; } SASS Reference has more information, which can be found here: http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#mixin-content As of Sass 3.4, this mixin can be written like so to work both nested and unnested: @mixin optional-at-root($sel) { @at-root #{if(not &, $sel, selector-append(&, $sel))} { @content; } } @mixin placeholder { @include optional-at-root('::-webkit-input-placeholder') { @content; } @include optional-at-root(':-moz-

Categories : CSS

Groovy mixin on Spring-MVC controller
When you map requests with annotations, what happens is that once the container is started, it scans the classpath, looks for annotated classes and methods, and builds the map internally, instead of you manually writing the deployment descriptor. The scanner reads methods and annotations from the compiled .class files. Maybe Groovy mixins are implemented in such a way that they are resolved at runtime, so the scanner software can't find them in the compiled bytecode. To solve this problem, you have to find a way to statically mixin code at compile time, so that the annotated method is actually written to the class file.

Categories : Spring

Can I use the mixin pattern with setters and getters
Object.create does take an object of property descriptors as its second argument, like defineProperties does. The correct syntax would be Point.prototype = Object.create(null, { x: { get: function() { return this._x; }, set: function(v) { this._x = v; }, // configurable: true, // enumerable: true }, x: { get: function() { return this._y; }, set: function(v) { this._y = v; }, // configurable: true, // enumerable: true } }); However, I don't see a reason why Points should not inherit from Object, so just make it Point.prototype = { get x() { return this._x; }, set x(v) { this._x = v; }, get y() { return this._y; }, set y(v) { this._y = v; } };

Categories : Javascript



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.