{"action":"created","issue":{"url":"https://api.github.com/repos/micjamking/succinct/issues/14","labels_url":"https://api.github.com/repos/micjamking/succinct/issues/14/labels{/name}","comments_url":"https://api.github.com/repos/micjamking/succinct/issues/14/comments","events_url":"https://api.github.com/repos/micjamking/succinct/issues/14/events","html_url":"https://github.com/micjamking/succinct/issues/14","id":68282128,"number":14,"title":"Using .succint with a js matchMedia","user":{"login":"Design2Well","id":11938044,"avatar_url":"https://avatars.githubusercontent.com/u/11938044?v=3","gravatar_id":"","url":"https://api.github.com/users/Design2Well","html_url":"https://github.com/Design2Well","followers_url":"https://api.github.com/users/Design2Well/followers","following_url":"https://api.github.com/users/Design2Well/following{/other_user}","gists_url":"https://api.github.com/users/Design2Well/gists{/gist_id}","starred_url":"https://api.github.com/users/Design2Well/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Design2Well/subscriptions","organizations_url":"https://api.github.com/users/Design2Well/orgs","repos_url":"https://api.github.com/users/Design2Well/repos","events_url":"https://api.github.com/users/Design2Well/events{/privacy}","received_events_url":"https://api.github.com/users/Design2Well/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/micjamking/succinct/labels/question","name":"question","color":"cc317c"}],"state":"open","locked":false,"assignee":{"login":"micjamking","id":651702,"avatar_url":"https://avatars.githubusercontent.com/u/651702?v=3","gravatar_id":"","url":"https://api.github.com/users/micjamking","html_url":"https://github.com/micjamking","followers_url":"https://api.github.com/users/micjamking/followers","following_url":"https://api.github.com/users/micjamking/following{/other_user}","gists_url":"https://api.github.com/users/micjamking/gists{/gist_id}","starred_url":"https://api.github.com/users/micjamking/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/micjamking/subscriptions","organizations_url":"https://api.github.com/users/micjamking/orgs","repos_url":"https://api.github.com/users/micjamking/repos","events_url":"https://api.github.com/users/micjamking/events{/privacy}","received_events_url":"https://api.github.com/users/micjamking/received_events","type":"User","site_admin":false},"milestone":null,"comments":1,"created_at":"2015-04-14T06:47:59Z","updated_at":"2015-04-14T20:39:56Z","closed_at":null,"body":"Nice plugin!\r\n\r\nPlaying around with .succinct today - calling it from a javascript media query. As the query sets a smaller .succinct size the textDefault truncates nicely. If the query tries to set a larger .succinct size it appears as if the textDefault is no longer based on the original but rather on the current. As a result, the only way to view a larger truncated length is to refresh the browser. \r\n\r\nSeems like you figured this out with the live demo input button. It would be great to have a reset we can call into the .succint plugin that works similarly. \r\n\r\nHaven't quite figured that out yet though."},"comment":{"url":"https://api.github.com/repos/micjamking/succinct/issues/comments/93052489","html_url":"https://github.com/micjamking/succinct/issues/14#issuecomment-93052489","issue_url":"https://api.github.com/repos/micjamking/succinct/issues/14","id":93052489,"user":{"login":"micjamking","id":651702,"avatar_url":"https://avatars.githubusercontent.com/u/651702?v=3","gravatar_id":"","url":"https://api.github.com/users/micjamking","html_url":"https://github.com/micjamking","followers_url":"https://api.github.com/users/micjamking/followers","following_url":"https://api.github.com/users/micjamking/following{/other_user}","gists_url":"https://api.github.com/users/micjamking/gists{/gist_id}","starred_url":"https://api.github.com/users/micjamking/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/micjamking/subscriptions","organizations_url":"https://api.github.com/users/micjamking/orgs","repos_url":"https://api.github.com/users/micjamking/repos","events_url":"https://api.github.com/users/micjamking/events{/privacy}","received_events_url":"https://api.github.com/users/micjamking/received_events","type":"User","site_admin":false},"created_at":"2015-04-14T20:39:56Z","updated_at":"2015-04-14T20:39:56Z","body":"Hey @Design2Well, first off, thank you for using Succinct! \r\n\r\nI'm not sure if I understand you 100% correctly, but I'll try my best to help. If you can share some of the code describing your particular scenario that could help us figure out a proper solution. \r\n\r\nWhile I think you bring up a valid use case, my desire for succinct, at it's core, to be simple and driven by a singular purpose. I like to think of succinct more of as a helper module being included in your app, rather than a general purpose library.\r\n\r\nThe demo I created is in the development branch of this repo if you want to see how I put it together. It's fairly simple; I cache the text of the paragraph in a variable, call succinct on the original element object, and reset using the variable under certain conditions. For example, using matchMedia as a condition:\r\n\r\n```js\r\n// Cache the text of the target element\r\nvar ogText = $('.my-paragraph').html();\r\n// Create variable of media query\r\nvar mq = window.matchMedia(\"(min-width:768px)\");\r\n\r\n// if above 768px...\r\nif (mq.matches) {\r\n  // ...display original (cached) text\r\n  $('.my-paragraph').html(ogText);\r\n}\r\n// ...else if it's below 768px\r\nelse {\r\n  // ...truncate text using succinct\r\n  $('.my-paragraph').succinct();\r\n}\r\n```\r\n\r\nIf you have multiple conditions (ie, `if...else if...else if...` or `switch`) or nested conditions, you can reset the text to its original state (ie, `$('.my-paragraph').html(ogText)`) before each time you truncate, ensuring that the text is always being truncated based on its original value.\r\n\r\nHope this makes sense and let me know how everything goes :v: "}}