crouton
1.0.0
Rails && xhr에 대한 컨텍스트 민감한 알림.
gem install 'crouton'
JavaScript 및 CSS에 crouton 필요합니다.
//= require crouton @import ' crouton ' ; 그런 다음 컨트롤러에서 render_crouton 메소드를 사용하면 전달한 옵션이 메시지로 변환됩니다.
class PostsController < ActionController :: Base
def update
if @post . save
render_crouton notice : 'Saved'
else
render_crouton errors : @post . errors
end
end
end 마지막으로, Crouton의 HTML에서 좋은 지점을 찾아 선택한 컨테이너에 .crouton-placeholder CSS 클래스를 추가하십시오.
< div class =" content crouton-placeholder " >
...정보 , 경고 및 위험의 세 가지 스타일이 상자에서 지원됩니다. 각 메시지의 지속 시간은 각각 1500, 2000 및 3000입니다.
다음 SASS 변수를 정의 하여이 세 가지 스타일의 색상을 사용자 정의 할 수 있습니다.
$crouton-info$crouton-warning$crouton-danger사용자 정의 메시지를 만들 수도 있습니다.
render_crouton Crouton :: Message . new ( :hint , 'You can double tap for more info.' , duration : 5000 ) , placeholder : '.custom-crouton-placeholder' Copyright (c) 2014 Máximo Mussini
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Crouton의 이름과 아이디어는 Cyril Mottier의 블로그 기사에서 시작됩니다.