<p>You could check if the whole request is Live Preview using <a href="http://buildwithcraft.com/docs/templating/craft.request#isLivePreview" rel="nofollow"><code>craft.request.isLivePreview</code></a>.</p>

CC BY-SA 3.0
2014-12-02T20:18:58.637Z
What about the inline editing modal? That was the primary question, the live preview was an additional example of what I was asking since it was conceptually the same thing.
Justin Kimbrell
CC BY-SA 3.0
2014-12-03T05:30:47.707Z
Oh I see. I misunderstood the question. :-/ still a bit unfamiliar with the plugin side of Craft
Brian Whitton
CC BY-SA 3.0
2014-12-02T20:08:26.520Z
2014-12-02T20:08:26.520Z
Brian Whitton
<p>You would do that with JS, at least this is how it is done to the core fields (see <a href="https://github.com/pixelandtonic/Craft-Release/blob/8ea72d1e5503e3ed11aac86fb972eb1fac92e54b/app/resources/js/MatrixInput.js" rel="nofollow">MatrixInput.js</a> line 152 ff.).</p>

<p>Just check for the container width of your field and then swap your classes / do your responsive design magic.</p>

CC BY-SA 3.0
2014-12-02T21:44:10.057Z
2014-12-02T21:44:10.057Z
carlcs
<p>Is there was a way for a field type to detect if it is being instantiated for the inline editor or even the live preview? I am working on some responsive UI's to make Google Maps for Craft work optimally on all screen sizes, but current smaller screens are posing a problem. Obviously media queries are being used, but was also wondering if I could easily detect where the field type was being instantiated and then I could possible add additional classes to my field type wrapper.</p>

CC BY-SA 3.0
2014-12-03T00:38:36.240Z
Maybe this would be a good use for the Element Query Polyfill, so that the elements could adapt themselves to the size of their container rather than the viewport? https://github.com/marcj/css-element-queries
Patrick Harrington
CC BY-SA 3.0
2014-12-03T07:36:35.347Z
I was already thinking the same thing, but the for sake of knowing I was just wondering if this was technically possible to detect in some way without using a size to determine it. And just to clarify, "viewport" was using in the same way you were using "container". Container is probably better wording for it.
Justin Kimbrell
CC BY-SA 3.0
2014-12-03T07:55:58.327Z
I think size detection is the better way to do it, Justin. Keep in mind that the Live Preview pane is resizable!
carlcs
<plugin-development><custom-fieldtype>
Can a field type detect if it's being edited inline in Craft 2.3?
# Can a field type detect if it's being edited inline in Craft 2.3?

(Asked by: username_0 on 2014-12-02)

Is there was a way for a field type to detect if it is being instantiated for the inline editor or even the live preview? I am working on some responsive UI's to make Google Maps for Craft work optimally on all screen sizes, but current smaller screens are posing a problem. Obviously media queries are being used, but was also wondering if I could easily detect where the field type was being instantiated and then I could possible add additional classes to my field type wrapper.

**Tags:** plugin-development, custom-fieldtype

> **Comments:**
> **username_1**: Maybe this would be a good use for the Element Query Polyfill, so that the elements could adapt themselves to the size of their container rather than the viewport? https://github.com/marcj/css-element-queries  
> **username_0**: I was already thinking the same thing, but the for sake of knowing I was just wondering if this was technically possible to detect in some way without using a size to determine it. And just to clarify, "viewport" was using in the same way you were using "container". Container is probably better wording for it.  
> **username_2**: I think size detection is the better way to do it, Justin. Keep in mind that the Live Preview pane is resizable!  

---

## 2 answers

### Answer by username_3 on 2014-12-02. Score: 3

You could check if the whole request is Live Preview using [`craft.request.isLivePreview`](http://buildwithcraft.com/docs/templating/craft.request#isLivePreview).

> **Comments:**
> **username_0**: What about the inline editing modal? That was the primary question, the live preview was an additional example of what I was asking since it was conceptually the same thing.  
> **username_3**: Oh I see. I misunderstood the question. :-/ still a bit unfamiliar with the plugin side of Craft  

---

### Answer by username_2 on 2014-12-02. Score: 2

You would do that with JS, at least this is how it is done to the core fields (see [MatrixInput.js](https://github.com/pixelandtonic/Craft-Release/blob/8ea72d1e5503e3ed11aac86fb972eb1fac92e54b/app/resources/js/MatrixInput.js) line 152 ff.).

Just check for the container width of your field and then swap your classes / do your responsive design magic.


---

