New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Responsive design #726
Responsive design #726
Changes from 47 commits
294dffb
c496e76
f96cdd2
a01f72d
aa04ab9
ffa069b
935990d
8b1fa31
0f98bb1
c09a509
1d42a49
d0430a9
c8629b7
92f6338
a884896
01c6422
0c53265
023dc46
1c94fd5
c7f28b2
e56091e
d8205c5
1699481
8f87d25
a4160bb
843b85b
f3f4d28
e3ce4d6
bd7bf86
7a55013
a02ff73
048eb2b
71b2cf3
0eb87d5
94dec58
e612f92
7aa656f
b09bfe0
26dbbb7
65baacc
ec95c23
ea628d5
3afa053
689c289
c9f415c
3fccf29
042f62f
2a30a29
5939e35
e3247fe
9385bfd
a268b0e
a634e6e
0aa3cb3
cb46623
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
/* | ||
Copyright 2016 OCAD University | ||
|
||
Licensed under the Educational Community License (ECL), Version 2.0 or the New | ||
BSD license. You may not use this file except in compliance with one these | ||
Licenses. | ||
|
||
You may obtain a copy of the ECL 2.0 License and BSD License at | ||
https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt | ||
*/ | ||
|
||
var fluid_2_0_0 = fluid_2_0_0 || {}; | ||
|
||
(function ($, fluid) { | ||
"use strict"; | ||
|
||
/******************** | ||
* Textfield Buttons * | ||
********************/ | ||
|
||
fluid.defaults("fluid.textfieldButtons", { | ||
gradeNames: ["fluid.viewComponent"], | ||
distributeOptions: { | ||
target: "{that > fluid.stepper.button}.options", | ||
record: { | ||
model: "{fluid.textfieldButtons}.model", | ||
range: "{textfieldButtons}.options.range", | ||
buttonOptions: "{fluid.textfieldButtons}.options.buttonOptions" | ||
} | ||
}, | ||
components: { | ||
textfield: { | ||
type: "fluid.textfieldSlider.textfield", | ||
container: "{textfieldButtons}.dom.textfield", | ||
options: { | ||
model: "{textfieldButtons}.model", | ||
range: "{textfieldButtons}.options.range" | ||
} | ||
}, | ||
increaseButton: { | ||
type: "fluid.stepper.button", | ||
container: "{textfieldButtons}.dom.increaseButton", | ||
options: { | ||
incrementCoefficient: 1 | ||
} | ||
}, | ||
decreaseButton: { | ||
type: "fluid.stepper.button", | ||
container: "{textfieldButtons}.dom.decreaseButton", | ||
options: { | ||
incrementCoefficient: -1 | ||
} | ||
} | ||
}, | ||
selectors: { | ||
textfield: ".flc-textfieldButtons-field", | ||
increaseButton: ".fl-increase-button", | ||
decreaseButton: ".fl-decrease-button" | ||
}, | ||
model: { | ||
value: null | ||
}, | ||
modelRelay: { | ||
target: "value", | ||
singleTransform: { | ||
type: "fluid.transforms.limitRange", | ||
input: "{that}.model.value", | ||
min: "{that}.options.range.min", | ||
max: "{that}.options.range.max" | ||
} | ||
}, | ||
range: { | ||
min: 0, | ||
max: 100 | ||
} | ||
}); | ||
|
||
fluid.defaults("fluid.stepper.button", { | ||
gradeNames: ["fluid.viewComponent"], | ||
range: {}, // should be used to specify the min, max range e.g. {min: 0, max: 100} | ||
invokers: { | ||
setModel: { | ||
changePath: "value", | ||
value: { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. line 127-131 can be simplified to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, the use of |
||
expander: { | ||
funcName: "{that}.calculateValue" | ||
} | ||
} | ||
}, | ||
calculateValue: { | ||
funcName: "fluid.stepper.button.buttonCalculateValue", | ||
args: ["{that}.options.incrementCoefficient", "{that}.options.buttonOptions.stepMultiplier", "{that}.model.value", "{that}.options.range.min", "{that}.options.range.max"] | ||
} | ||
}, | ||
listeners: { | ||
"onCreate.bindClickEvt": { | ||
"this": "{that}.container", | ||
"method": "click", | ||
"args": "{that}.setModel" | ||
} | ||
}, | ||
incrementCoefficient: 1, | ||
buttonOptions: { | ||
stepMultiplier: 10 | ||
} | ||
}); | ||
|
||
fluid.stepper.button.buttonCalculateValue = function (value, stepMultiplier, modelValue, min, max) { | ||
modelValue = Math.round(modelValue * stepMultiplier); | ||
min = Math.round(min * stepMultiplier); | ||
max = Math.round(max * stepMultiplier); | ||
if ((modelValue + value) < min) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't line 155-160 already guarded by There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not entirely sure how the limit Range works. Does it return the max value if the supplied value is greater than the max and what is its syntax? I use stepMultipliers to avoid rounding errors. We discussed that with jobara here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Some test cases to help you understand how limitRange works: https://github.com/fluid-project/infusion/blob/master/tests/framework-tests/core/js/ModelTransformationTests.js#L4028-L4077 The effectiveness should be tested in your test coverage for this component. From my understanding, this function simply needs one line: BTW, using the name There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure where to put the transform. If I put it in the setModel invoker in the place of value the model ends up being a function. I am using this transformation There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The transformation has already been placed in the parent component There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see I have just made some unnecessary checks. |
||
return min/stepMultiplier; | ||
} | ||
else if ((modelValue + value) > max) { | ||
return max/stepMultiplier; | ||
} | ||
else { | ||
return (modelValue + value)/stepMultiplier; | ||
} | ||
}; | ||
|
||
})(jQuery, fluid_2_0_0); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"textfieldButtons": { | ||
"name": "Textfield Buttons", | ||
"description": "A synchronized buttons and textfield", | ||
"cssFiles": [], | ||
"files": [ | ||
"./js/TextfieldButtons.js" | ||
], | ||
"dependencies": [ | ||
"jQuery", | ||
"jQueryUICore", | ||
"normalize", | ||
"framework", | ||
"jQueryUIWidgets", | ||
"jQueryTouchPunchPlugin" | ||
] | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to be consistent with other lines by using
{fluid.textfieldButtons}
.