diff --git a/bootstrap-components/js/bootstrap-components.js b/bootstrap-components/js/bootstrap-components.js index 9a14406..47a83b9 100644 --- a/bootstrap-components/js/bootstrap-components.js +++ b/bootstrap-components/js/bootstrap-components.js @@ -1,64 +1,66 @@ -$.extend({_bc: new Object()}); +!function ($) { + $.extend({_bc: new Object()}); // init vars for bootstrap-component use -$._bc.vals = new Object(); + $._bc.vals = new Object(); // get the setting & callback -$._bc.vars = function(options, callback){ - var vars = new Object(); - if(typeof(options) == 'object') { - vars.options = options; - } else if(typeof(options) == 'function') { - vars.callback = options; - } else if(typeof(options) == 'string') { - vars.key = options; - } - if(typeof(callback) == 'function') { - vars.callback = callback; + $._bc.vars = function (options, callback) { + var vars = new Object(); + if (typeof(options) == 'object') { + vars.options = options; + } else if (typeof(options) == 'function') { + vars.callback = options; + } else if (typeof(options) == 'string') { + vars.key = options; + } + if (typeof(callback) == 'function') { + vars.callback = callback; + } + return vars; } - return vars; -} // get the option by key and return default if not set -$._bc.get = function(options, key, defaultValue) { - if(options != null) { - if(options[key] != null) { - return options[key]; + $._bc.get = function (options, key, defaultValue) { + if (options != null) { + if (options[key] != null) { + return options[key]; + } else { + return defaultValue; + } } else { return defaultValue; } - } else { - return defaultValue; } -} // get a simple list to add / remove element -$._bc.list = function() { - var list = new Array(); - list.add = function(obj) { - list.push(obj); - } - list.remove = function(obj) { - var loc = null; - for (var i = 0; i < list.length; i++) { - var _o = list[i]; - if(obj == _o) { - loc = i; - break; + $._bc.list = function () { + var list = new Array(); + list.add = function (obj) { + list.push(obj); + } + list.remove = function (obj) { + var loc = null; + for (var i = 0; i < list.length; i++) { + var _o = list[i]; + if (obj == _o) { + loc = i; + break; + } } + if (loc != null) list.splice(loc, 1); } - if(loc != null) list.splice(loc, 1); - } - return list; -} + return list; + }; // get the broswer version -var userAgent = navigator.userAgent.toLowerCase(); -$._bc.browser = { -version: (userAgent.match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [])[1], -safari: /webkit/.test( userAgent ), -opera: /opera/.test( userAgent ), -msie: /msie/.test( userAgent ) && !/opera/.test( userAgent ), -mozilla: /mozilla/.test( userAgent ) && !/(compatible|webkit)/.test( userAgent ) -}; + var userAgent = navigator.userAgent.toLowerCase(); + $._bc.browser = { + version: (userAgent.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/) || [])[1], + safari: /webkit/.test(userAgent), + opera: /opera/.test(userAgent), + msie: /msie/.test(userAgent) && !/opera/.test(userAgent), + mozilla: /mozilla/.test(userAgent) && !/(compatible|webkit)/.test(userAgent) + }; +}(jQuery); /* options: boolean default false. true to open auto tooltips else to close it. */ @@ -225,12 +227,12 @@ mozilla: /mozilla/.test( userAgent ) && !/(compatible|webkit)/.test( userAgent ) goon: boolean default false. True will change value immediately when click. - TODO */ -// init env -$._bc.vals.datepicker = new Object(); -$._bc.vals.datepicker.index = 1; - -// init function !function ($) { + // init env + $._bc.vals.datepicker = new Object(); + $._bc.vals.datepicker.index = 1; + + // init function $.extend({ datepicker: { toDate: function(str, format) { @@ -822,143 +824,144 @@ callback: [function] it will trigger event when user close this dialog by cl return boolean of confirm, and false of alert and close button. */ +!function ($) { // init env -$._bc.vals.dialog = new Object(); -$._bc.vals.dialog.z_index = 1051; + $._bc.vals.dialog = new Object(); + $._bc.vals.dialog.z_index = 1051; // init function -$.extend({ - dialog:function(options, callback){ - // get options - var vars = $._bc.vars(options, callback); - var _options = vars.options; - var _callback = vars.callback; - - var _title = $._bc.get(_options, "title", ""); - var _content = $._bc.get(_options, "content", ""); - var _close = $._bc.get(_options, "close", true); - var _confirm = $._bc.get(_options, "confirm", false); - var _buttons = $._bc.get(_options, "buttons", null); - var _fade = $._bc.get(_options, "fade", true); - var _size = $._bc.get(_options, "size", ""); - - var _ret = null; - - // generate modal - var $modal = $('