1/* ========================================================== 2 * sco.message.js 3 * http://github.com/terebentina/sco.js 4 * ========================================================== 5 * Copyright 2013 Dan Caragea. 6 * 7 * Licensed under the Apache License, Version 2.0 (the "License"); 8 * you may not use this file except in compliance with the License. 9 * You may obtain a copy of the License at 10 * 11 * http://apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, software 14 * distributed under the License is distributed on an "AS IS" BASIS, 15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 * See the License for the specific language governing permissions and 17 * limitations under the License. 18 * ========================================================== */ 19 20/*jshint laxcomma:true, sub:true, browser:true, jquery:true, eqeqeq: false */ 21 22(function($, undefined) { 23 "use strict"; 24 25 var pluginName = 'scojs_message'; 26 27 $[pluginName] = function(message, type) { 28 clearTimeout($[pluginName].timeout); 29 var $selector = $('#' + $[pluginName].options.id); 30 if (!$selector.length) { 31 $selector = $('<div/>', {id: $[pluginName].options.id}).appendTo($[pluginName].options.appendTo); 32 } 33 if ($[pluginName].options.animate) { 34 $selector.addClass('page_mess_animate'); 35 } else { 36 $selector.removeClass('page_mess_animate'); 37 } 38 $selector.html(message); 39 if (type === undefined || type == $[pluginName].TYPE_ERROR) { 40 $selector.removeClass($[pluginName].options.okClass).addClass($[pluginName].options.errClass); 41 } else if (type == $[pluginName].TYPE_OK) { 42 $selector.removeClass($[pluginName].options.errClass).addClass($[pluginName].options.okClass); 43 } 44 $selector.slideDown('fast', function() { 45 $[pluginName].timeout = setTimeout(function() { $selector.slideUp('fast'); }, $[pluginName].options.delay); 46 }); 47 }; 48 49 50 $.extend($[pluginName], { 51 options: { 52 id: 'page_message' 53 ,okClass: 'page_mess_ok' 54 ,errClass: 'page_mess_error' 55 ,animate: true 56 ,delay: 2000 57 ,appendTo: 'body' // where should the modal be appended to (default to document.body). Added for unit tests, not really needed in real life. 58 }, 59 60 TYPE_ERROR: 1, 61 TYPE_OK: 2 62 }); 63})(jQuery); 64 65/*successæç¤º*/ 66showInfoMessage = function(message) { 67 $.scojs_message(message, $.scojs_message.TYPE_OK); 68} 69/*erroræç¤º*/ 70showErrorMessage = function(message) { 71 $.scojs_message(message, $.scojs_message.TYPE_ERROR); 72}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.